Compare commits

...
Sign in to create a new pull request.

311 commits

Author SHA1 Message Date
Coia Prant
d388c347d4 configure: Use MSYSTEM_CARCH for default arch on msys2
On msys2, `uname -m` returns the architecture of the base msys2
layer. On Windows on arm64, the base msys2 layer itself is still
x86_64 only, even if running with e.g. the clangarm64 where the
windows native applications are built as aarch64.

If MSYSTEM_CARCH is set, use this instead of `uname -m` for
the default architecture. This gives the correct behaviour
for the clangarm64 environments. It also gives the correct
default for the 32 bit x86 environments such as `mingw32`.

(On `mingw32`, the fact that `uname -m` returned `x86_64`
hasn't been an issue, as both that and `i686` gets normalized
into `x86` internally in ffmpeg's configure.)

Signed-off-by: Coia Prant <coiaprant@gmail.com>
Signed-off-by: Martin Storsjö <martin@martin.st>
(cherry picked from commit df967d095a)
2025-05-28 10:57:46 +03:00
Paul B Mahol
bd1c255af8 avfilter/avfiltergraph: fix regression in picking channel layout
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 1b3f4842c1)
2025-05-22 19:42:09 -03:00
Brad Smith
b67a6631a2 lsws/ppc/yuv2rgb_altivec: Fix build in non-VSX environments with Clang v2
v2: test for function if AltiVec is enabled instead of with AltiVec and without VSX

(cherry picked from commit 49c8f33262)
Signed-off-by: Brad Smith <brad@comstyle.com>
2025-03-16 00:17:26 -04:00
Brad Smith
2a341fc5b2 lsws/ppc/yuv2rgb_altivec: Fix build in non-VSX environments with Clang
Add a check for the existence of the vec_xl() function. Clang provides
the function even with VSX not enabled.

(cherry picked from commit 30a8641465)
Signed-off-by: Brad Smith <brad@comstyle.com>
2025-03-16 00:17:20 -04:00
Pavel Koshevoy
5911b7e9f5 avformat/mov: (v4) fix get_eia608_packet
The problem is reproducible with "Test for Quicktime 608 CC file.mov"
from https://samples.ffmpeg.org/MPEG2/subcc/

ffmpeg -i "Test for Quicktime 608 CC file.mov" -map 0 -c copy -y remuxed.mov

See https://trac.ffmpeg.org/ticket/11470
2025-02-26 16:05:21 -07:00
Rémi Denis-Courmont
b98349b205 riscv: test for assembler support
This should fix the build on LLVM 16 and earlier, at the cost of turning
all non-RVV optimisations off.

Signed-off-by: Brad Smith <brad@comstyle.com>
2024-12-08 02:25:43 -05:00
Gyan Doshi
769c36b013 avcodec/libx265: unbreak build for X265_BUILD >= 213
Earlier, x265 made an API change to support alpha and
other multiple layer pictures. We added guards to accommodate
that in 1f801dfdb5

They have now reverted that API change in
78e5b703b1

Updated our wrapper guards to unbreak build again.
2024-10-06 13:30:34 +02:00
Anton Khirnov
35f906521e lavc/hevcdec: set per-CTB filter parameters for WPP
Fixes #10887

(cherry picked from commit 536bb98888)
Signed-off-by: Anton Khirnov <anton@khirnov.net>
(cherry picked from commit f705bc5b73)
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2024-09-13 12:23:04 +02:00
Anton Khirnov
c22db2bcf2 lavc/hevc: check framerate num/den to be strictly positive
Rather than just != 0. These values are read as uint32 and can become
negative when cast to int.

(cherry picked from commit eec1a7a6bb)
Signed-off-by: Anton Khirnov <anton@khirnov.net>
(cherry picked from commit 9cadadb9a1)
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2024-09-12 11:14:55 +02:00
Gyan Doshi
6387156008 lavc/libx265: unbreak build for X265_BUILD >= 210
x265 added support for alpha starting with build 210.
While doing so, x265_encoder_encode() changed its fifth arg to
an array of pointers to x265_picture. This broke building lavc/libx265.c

This patch simply unbreaks the build and maintains existing single-layer
non-alpha encoding support.

Fixes #11130
2024-09-04 13:55:28 +02:00
Ramiro Polla
d9d47bc981 configure: improve check for POSIX ioctl
Instead of relying on system #ifdefs which may or may not be correct,
detect the POSIX ioctl signature at configure time.

(cherry picked from commit 00b64fca55)
Signed-off-by: Brad Smith <brad@comstyle.com>
2024-09-01 20:14:30 -04:00
Ramiro Polla
8c6186efbe configure: restore autodetection of v4l2 and fbdev
The detection logic for v4l2 and fbdev was accidentally modified to
depend on v4l2-m2m in 43b3412.

(cherry picked from commit 7405f1ad53)
Signed-off-by: Brad Smith <brad@comstyle.com>
2024-09-01 20:14:16 -04:00
Brad Smith
d859805efe configure: use just the pkg-config for sndio
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit f6d8464590)
Signed-off-by: Brad Smith <brad@comstyle.com>
2024-09-01 05:05:56 -04:00
Timo Rothenpieler
bf0e6c6cb5 avformat/hlsenc: correctly reset subtitle stream counter per-varstream
Without resetting it, if there was a previous set of varstreams with
subtitles, it would subtract from all the streams, leading to chaos and
segfaults when trying to access for example stream -1.
2024-08-16 20:26:12 +02:00
Ross Burton
3096967c93 libavcodec/arm/mlpdsp_armv5te: fix label format to work with binutils 2.43
binutils 2.43 has stricter validation for labels[1] and results in errors
when building ffmpeg for armv5:

src/libavcodec/arm/mlpdsp_armv5te.S:232: Error: junk at end of line, first unrecognized character is `0'

Remove the leading zero in the "01" label to resolve this error.

[1] https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=226749d5a6ff0d5c607d6428d6c81e1e7e7a994b

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Martin Storsjö <martin@martin.st>
(cherry picked from commit 654bd47716)
2024-08-16 13:47:11 +03:00
Josh Allmann
3610a803e7 avcodec/nvenc: fix segfault in intra-only mode
In intra-only mode, frameIntervalP is 0, which means the frame
data array is smaller than the number of surfaces.

Together with using the wrong size on deallocation of the
frame_data_array, this lead to a crash.

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
(cherry picked from commit c9151ea507)
2024-07-01 20:07:27 +02:00
llyyr
c185e11321
lavc/vp9: reset segmentation fields when segmentation isn't enabled
Fields under the segmentation switch are never reset on a new frame, and
retain the value from the previous frame. This bugs out a bunch of
hwaccel drivers when segmentation is disabled but update_map isn't
reset because they don't ignore values behind switches. This commit also
resets the temporal field, though it may not be required.

We also do this for vp8 [1] so this commit is just mirroring the vp8
logic.

This fixes an issue with certain samples [2] that causes blocky
artifacts with vaapi, d3d11va and cuda (and possibly others).
Mesa worked around [3] this by ignoring these fields if
segmentation.enabled is 0, but d3d11va still displays blocky artifacts.

[1] 2e877090f9:/libavcodec/vp8.c#l797
[2] https://github.com/mpv-player/mpv/issues/13533
[3] https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27816

Signed-off-by: llyyr <llyyr.public@gmail.com>
2024-05-27 12:38:56 +02:00
Brad Smith
0819bdc621 configure: enable ffnvcodec, nvenc, nvdec for FreeBSD
Signed-off-by: Brad Smith <brad@comstyle.com>
(cherry picked from commit 43b1a95678)
Signed-off-by: Brad Smith <brad@comstyle.com>
2024-05-26 19:40:25 -04:00
Andreas Rheinhardt
90a59f9e48 avcodec/x86/vp3dsp_init: Set correct function pointer, fix crash
Regression since fd17218558;
triggered by vp4/KTkvw8dg1J8.avi in the FATE suite, but not
when running fate as this code is not used when the bitexact
flag is set.

Bisecting done by ami_stuff, patch from user Mika Fischer
in ticket #10027 (which this commit fixes).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit c3ca90a92e)
2024-05-22 17:10:17 +02:00
Marton Balint
9dbeb1d5d0 avutil/thread: fix pthread_setname_np parameters for NetBSD and Apple
Signed-off-by: Marton Balint <cus@passwd.hu>
(cherry picked from commit 71ea90638e)
Signed-off-by: Brad Smith <brad@comstyle.com>
2024-05-19 02:26:54 -04:00
Brad Smith
ce29811117 avutil/thread: add support for setting thread name on *bsd and solaris
FreeBSD/DragonFly/Solaris use pthread_setname_np(). OpenBSD uses pthread_set_name_np().

Signed-off-by: Brad Smith <brad@comstyle.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
(cherry picked from commit fd16d8c68c)
Signed-off-by: Brad Smith <brad@comstyle.com>
2024-05-19 02:23:32 -04:00
Brad Smith
4873178ee3 avutil/ppc/cpu: Also use the machdep.altivec sysctl on NetBSD
Use the machdep.altivec sysctl on NetBSD for AltiVec detection
as is done with OpenBSD.

(cherry picked from commit 115c96b9bd)
Signed-off-by: Brad Smith <brad@comstyle.com>
2024-05-18 19:29:47 -04:00
Brad Smith
13ebc73259 lavd/v4l2: Use proper field type for second parameter of ioctl() with BSD's
The proper type was used until 73251678c8.

This covers all of the OS's that currently have V4L2 support, permutations
of Linux glibc/musl, Android bionic, FreeBSD, NetBSD, OpenBSD, Solaris.

Copied from FreeBSD ports patch.

Signed-off-by: Brad Smith <brad@comstyle.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
(cherry picked from commit 9e674b3160)
Signed-off-by: Brad Smith <brad@comstyle.com>
2024-05-18 19:29:15 -04:00
Michael Niedermayer
af1bc3a91f
Update for 6.0.2
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-15 01:10:09 +02:00
Andreas Rheinhardt
27bcc1e967
fate/subtitles: Ignore line endings for sub-scc test
Since 7bf1b9b357,
the test produces ordinary \n, yet this is not what the reference
file used for the most time, leading to test failures.

Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit 99d33cc661)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-14 03:24:43 +02:00
Michael Niedermayer
fe5946684a
avformat/mxfdec: Check index_edit_rate
Fixes: Assertion b >=0 failed at libavutil/mathematics.c:62
Fixes: 67811/clusterfuzz-testcase-minimized-ffmpeg_dem_MXF_fuzzer-5108429687422976

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit ed49391961)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-04 21:10:40 +02:00
Michael Niedermayer
5987250c42
swscale/utils: Fix xInc overflow
Fixes: signed integer overflow: 2 * 1073741824 cannot be represented in type 'int'
Fixes: 67802/clusterfuzz-testcase-minimized-ffmpeg_SWS_fuzzer-6249515855183872

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 1a9eda65d0)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-04 21:09:44 +02:00
Michael Niedermayer
06c213c8c4
avformat/isom: Uninit layout in ff_mp4_read_dec_config_descr()
Fixes: memleak
Fixes: 67442/clusterfuzz-testcase-minimized-ffmpeg_dem_CAF_fuzzer-5068813261406208

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit d157725cf7)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-04 20:55:27 +02:00
Michael Niedermayer
df95c2630d
avcodec/exr: Dont use 64bits to hold 6bits
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit e3984de6ff)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:10:00 +02:00
Michael Niedermayer
853e15fb85
avcodec/exr: Check for remaining bits in huf_unpack_enc_table()
Fixes: Timeout
Fixes: 67645/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EXR_fuzzer-6308760977997824

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 589fa8a027)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:09:05 +02:00
Michael Niedermayer
d0c5329c1b
avformat/mpegts: Reset local nb_prg on add_program() failure
add_program() will deallocate the whole array on failure so
we must clear nb_prgs

Fixes: null pointer dereference
Fixes: crash-35a3b39ddcc5babeeb005b7399a3a1217c8781bc

Found-by: Catena cyber
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit cb9752d897)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:25 +02:00
Michael Niedermayer
2c06fbfd0d
avformat/aiffdec: Check for previously set channels
Fixes: out of array access (av_channel_layout_copy())
Fixes: 67087/clusterfuzz-testcase-minimized-ffmpeg_dem_AIFF_fuzzer-4920720268263424

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 23b29f72ee)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:25 +02:00
Michael Niedermayer
f5f350919e
avformat/mxfdec: Make edit_unit_byte_count unsigned
Suggested-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit f30fe5e8d0)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:24 +02:00
Michael Niedermayer
9ffa59eba5
avformat/movenc: Check that cts fits in 32bit
Fixes: Assertion av_rescale_rnd(start_dts, mov->movie_timescale, track->timescale, AV_ROUND_DOWN) <= 0 failed at libavformat/movenc.c:3694
Fixes: poc2

Found-by: Wang Dawei and Zhou Geng, from Zhongguancun Laboratory
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit d88c284c18)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:24 +02:00
Michael Niedermayer
04cff32872
avformat/mxfdec: Check first case of offset_temp computation for overflow
This is kind of ugly
Fixes: signed integer overflow: 255 * 1157565362826411919 cannot be represented in type 'long'
Fixes: 67313/clusterfuzz-testcase-minimized-ffmpeg_dem_MXF_fuzzer-6250434245230592

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit d6ed6f6e8d)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:24 +02:00
Michael Niedermayer
d9882369d8
avfilter/vf_signature: Dont crash on no frames
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 3d5f03bbc8)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:23 +02:00
Michael Niedermayer
d9b0effe77
avformat/westwood_vqa: Fix 2g packets
Fixes: signed integer overflow: 2147483424 * 2 cannot be represented in type 'int'
Fixes: 62276/clusterfuzz-testcase-minimized-ffmpeg_dem_WSVQA_fuzzer-4576211411795968

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 86f73277bf)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:23 +02:00
Michael Niedermayer
308c337182
avformat/matroskadec: Check timescale
Fixes: 3.82046e+18 is outside the range of representable values of type 'unsigned int'
Fixes: 62276/clusterfuzz-testcase-minimized-ffmpeg_dem_WEBM_DASH_MANIFEST_fuzzer-6381436594421760

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit e849eb2343)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:23 +02:00
Michael Niedermayer
05d253b420
avformat/wavdec: satuarte next_tag_ofs, data_end
Fixes: signed integer overflow: 5053074104798691550 + 5053074104259715104 cannot be represented in type 'long'
Fixes: 62276/clusterfuzz-testcase-minimized-ffmpeg_dem_WAV_fuzzer-6515315309936640

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 61dca9e150)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:22 +02:00
Michael Niedermayer
2c1117e6e2
avformat/sbgdec: Check for negative duration
Fixes: signed integer overflow: 9223372036854775807 - -8000000 cannot be represented in type 'long'
Fixes: 62276/clusterfuzz-testcase-minimized-ffmpeg_dem_SBG_fuzzer-5133181743136768

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 0bed22d597)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:22 +02:00
Michael Niedermayer
ae59aff594
avformat/rpl: Use 64bit for total_audio_size and check it
Fixes: 62276/clusterfuzz-testcase-minimized-ffmpeg_dem_RPL_fuzzer-4677434693517312
Fixes: signed integer overflow: 5555555555555555556 * 8 cannot be represented in type 'long long'

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 878625812f)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:22 +02:00
Michael Niedermayer
bf67615a1f
avformat/timecode: use 64bit for intermediate for rounding in fps_from_frame_rate()
Fixes: 62276/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-4802790784303104
Fixes: signed integer overflow: 1768972133 + 968491058 cannot be represented in type 'int'

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 3d8d778a68)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:21 +02:00
Michael Niedermayer
40775100a0
avformat/mov: use 64bit for intermediate for rounding
Fixes: signed integer overflow: 1768972133 + 968491058 cannot be represented in type 'int'
Fixes: 62276/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-4802790784303104

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit f01a89c5a3)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:21 +02:00
Michael Niedermayer
d1eca0d05a
avformat/jacosubdec: Use 64bit for abs
Fixes: negation of -2147483648 cannot be represented in type 'int'; cast to an unsigned type to negate this value to itself
Fixes: 62276/clusterfuzz-testcase-minimized-ffmpeg_dem_JACOSUB_fuzzer-5401294942371840

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 746203af31)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:21 +02:00
Michael Niedermayer
f70db01b83
avformat/concatdec: Check user_duration sum
Fixes: 62276/clusterfuzz-testcase-minimized-ffmpeg_dem_CONCAT_fuzzer-6434245599690752
Fixes: signed integer overflow: 9223372026773000000 + 22337000000 cannot be represented in type 'long'

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 007486058c)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:20 +02:00
Michael Niedermayer
b9a3065c66
avcodec/wavarc: Avoid signed integer overflow in sample
Fixes: signed integer overflow: -2147483648 + -25122315 cannot be represented in type 'int'
Fixes: 62285/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WAVARC_fuzzer-6199806972198912

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 6009dd07bd)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:20 +02:00
Michael Niedermayer
a004db8f4e
avcodec/truemotion1: Height not being a multiple of 4 is unsupported
mb_change_bits is given space based on height >> 2, while more data is read

Fixes: out of array access
Fixes: 62285/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TRUEMOTION1_fuzzer-5201925062590464.fuzz

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit ebdcf98499)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:20 +02:00
Michael Niedermayer
055265fed1
avcodec/hcadec: do not set hfr_group_count to invalid values
Fixes: 62285/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HCA_fuzzer-6247136417087488
Fixes: out of array write

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit addb85ea39)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:19 +02:00
Michael Niedermayer
c746bc5269
avformat/concatdec: clip outpoint - inpoint overflow in get_best_effort_duration()
An alternative would be to limit all time/duration fields to below 64bit

Fixes: signed integer overflow: -93000000 - 9223372036839000000 cannot be represented in type 'long long'
Fixes: 64546/clusterfuzz-testcase-minimized-ffmpeg_dem_CONCAT_fuzzer-5110813828186112

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit dd733b2be4)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:19 +02:00
Michael Niedermayer
0100d1ae97
avformat/jacosubdec: clarify code
add comments, rename variables and indent things differently

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit e83e8d443b)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:19 +02:00
Michael Niedermayer
bf36c2211d
avformat/cafdec: Check that data chunk end fits within 64bit
Fixes: signed integer overflow: 64 + 9223372036854775803 cannot be represented in type 'long long'
Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_CAF_fuzzer-6536881135550464
Fixes: 62276/clusterfuzz-testcase-minimized-ffmpeg_dem_CAF_fuzzer-6536881135550464

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit b792e4d4c7)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:18 +02:00
Michael Niedermayer
73efebad01
avformat/iff: Saturate avio_tell() + 12
Fixes: signed integer overflow: 9223372036854775796 + 12 cannot be represented in type 'long long'
Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_IFF_fuzzer-4898373660704768

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit b8e754525c)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:18 +02:00
Michael Niedermayer
22b7b67931
avformat/dxa: Adjust order of operations around block align
Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_DXA_fuzzer-5730576523198464
Fixes: signed integer overflow: 2147483566 + 82 cannot be represented in type 'int'

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 50d8e4f273)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:18 +02:00
Michael Niedermayer
e534814967
avformat/cafdec: dont seek beyond 64bit
Fixes: signed integer overflow: 64 + 9223372036854775807 cannot be represented in type 'long long'
Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_CAF_fuzzer-6418242730328064
Fixes: 62276/clusterfuzz-testcase-minimized-ffmpeg_dem_CAF_fuzzer-6418242730328064

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit d973fcbcc2)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:17 +02:00
Michael Niedermayer
a5103808f4
avformat/id3v2: read_uslt() check for the amount read
Fixes: timeout
Fixes: 66783/clusterfuzz-testcase-minimized-ffmpeg_dem_GENH_fuzzer-5356884892647424

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c0f4abe2aa)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:17 +02:00
Michael Niedermayer
0c9b524163
avformat/wady: Check >0 samplerate and channels 1 || 2.
The WADY decoder only supports mono and stereo

This fixes a probetest failure

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 6f9e90ab0b)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:17 +02:00
Michael Niedermayer
0bd8112921
avcodec/proresenc_kostya: Remove bug similarity text
According to kostya, it is not based on Wassermans encoder

CC: Kostya Shishkov <kostya.shishkov@gmail.com>
CC: Anatoliy Wasserman <anatoliy.wasserman@yandex.ru>

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit e0e30e07a1)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:16 +02:00
Michael Niedermayer
e0339c57e6
avcodec/vorbisdec: Check remaining data in vorbis_residue_decode_internal()
Fixes: timeout
Fixes: 66326/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VORBIS_fuzzer-6295291863040000

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit dc89cf804a)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:16 +02:00
Michael Niedermayer
1ae20f1779
avformat/concatdec: Check in and outpoints to be to produce a positive representable duration
Fixes: signed integer overflow: -93000000 - 9223372036839000000 cannot be represented in type 'long'
Fixes: 64546/clusterfuzz-testcase-minimized-ffmpeg_dem_CONCAT_fuzzer-5110813828186112

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit b2d7cbc378)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:16 +02:00
Michael Niedermayer
eea625e217
avcodec/8bps: Consider width in the minimal size check
Fixes: Timeout
Fixes: 64479/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EIGHTBPS_fuzzer-5434435386081280

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 5db09574df)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:15 +02:00
Michael Niedermayer
a7d8b3c7e4
libswscale/utils: Fix bayer to yuvj
Fixes: out of array access.

Earlier code assumes that a unscaled bayer to yuvj420 converter exists
but the later code then skips yuvj420

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit e9cc9e492f)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:15 +02:00
Michael Niedermayer
d9dc74fa1a
swscale/swscale: Check srcSliceH for bayer
Fixes: Assertion srcSliceH > 1 failed at libswscale/swscale_unscaled.c:1359
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 64098d0cd8)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:15 +02:00
Michael Niedermayer
a18520cce8
swscale/utils: Allocate more dithererror
Fixes: out of array read
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 18f26f8a2f)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:14 +02:00
Michael Niedermayer
8e72472dcc
avcodec/indeo3: Round dimensions up in allocate_frame_buffers()
Fixes: Ticket6581

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 3be80ce299)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:14 +02:00
Michael Niedermayer
5a1b84bbd9
avutil/rational: Document what is to be expected from av_d2q() of doubles representing rational numbers
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit f465badb06)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:14 +02:00
Michael Niedermayer
a7a73839ee
avfilter/signature_lookup: Do not dereference NULL pointers after malloc failure
Fixes: CID 1403229 Dereference after null check

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 98ae1ad7cf)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:13 +02:00
Michael Niedermayer
43a9665f4a
avfilter/signature_lookup: dont leave uncleared pointers in sll_free()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 6c50482951)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:13 +02:00
Michael Niedermayer
4565b4a507
avcodec/mpegvideo_enc: Use ptrdiff_t for stride
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit e063c1d079)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:13 +02:00
Romain Beauxis
e9479065e1
libavformat/hlsenc.c: Populate OTI using AAC profile in write_codec_attr.
This patch populates the third entry for HLS codec attribute using the
AAC profile.

The HLS specifications[1] require this value to be the Object Type ID as
referred to in table 1.3 of ISO/IEC 14496-3:2009[2].

The numerical constants in the code refer to these OTIs minus one, as
documented in commit 372597e[3], confirmed by comparing the values in the
code with the values in the table mentioned above.

Links:
1: https://datatracker.ietf.org/doc/html/rfc6381#section-3.3
2: https://csclub.uwaterloo.ca/~ehashman/ISO14496-3-2009.pdf
3: 372597e538

Changes in this version:
- Default value set to "mp4a.40.2" when profile is unknown for backward
  compatibility.

Signed-off-by: Steven Liu <liuqi05@kuaishou.com>
(cherry picked from commit 797f0b27c1)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:12 +02:00
Michael Niedermayer
dce4cf6871
avcodec/mpegvideo_enc: Dont copy beyond the image
Fixes: out of array access
Fixes: tickets/10754/poc17ffmpeg

Discovered by Zeng Yunxiang.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit a066b8a809)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:12 +02:00
Michael Niedermayer
a83c489c02
avfilter/vf_minterpolate: Check pts before division
Fixes: FPE
Fixes: tickets/10758/poc20ffmpeg

Discovered by Zeng Yunxiang

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 68146f06f8)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:12 +02:00
Michael Niedermayer
cd306f0019
avformat/flacdec: Avoid double AVERRORS
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 029294ff54)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:11 +02:00
Michael Niedermayer
7a42e9d892
avfilter/vf_vidstabdetect: Avoid double AVERRORS
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit bb04235d72)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:11 +02:00
Michael Niedermayer
96cc1dd4d3
avfilter/vf_swaprect: round coordinates down
Fixes: out of array access:
Fixes: tickets/10745/poc12ffmpeg

Found-by: Li Zeyuan and Zeng Yunxiang.
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 7deaca71b3)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:11 +02:00
Michael Niedermayer
a487a57d72
avfilter/vf_swaprect: Use height for vertical variables
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 9f4c5bd7d2)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:10 +02:00
Michael Niedermayer
552a58fb68
avfilter/vf_swaprect: assert that rectangles are within memory
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 9d1ba698d2)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:10 +02:00
Michael Niedermayer
4df8f9fa2b
avfilter/af_alimiter: Check nextpos before use
Fixes: out of array read
Fixes: tickets/10744/poc11ffmpeg

Found-by: Li Zeyuan and Zeng Yunxiang.
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit a88b06f9ee)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:10 +02:00
Michael Niedermayer
302af6f9a7
avfilter/f_reverse: Apply PTS compensation only when pts is available
Fixes: out of array access
Fixes: tickets/10753/poc16ffmpeg

Regression since: 45dc668aea
Found-by: Zeng Yunxiang
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 61e73851a3)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:09 +02:00
Michael Niedermayer
ccf8c9bff7
avfilter/af_stereowiden: Check length
Fixes: out of array access
Fixes: tickets/10746/poc13ffmpeg

Found-by: Zeng Yunxiang
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 50f0f8c53c)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:09 +02:00
Thomas Guilbert
9258cc72cb
avformat/mov: Fix MSAN issue with stsd_id
Fixes: use of uninitialized value
Fixes: bbb-320x240-2video-2audio.mp4

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit ff451df947)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:09 +02:00
Michael Niedermayer
8cc8f54121
avfilter/vf_weave: Fix odd height handling
Fixes: out of array access
Fixes: tickets/10743/poc10ffmpeg

Found-by: Zeng Yunxiang and Li Zeyuan
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 0ecc1f0e48)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:08 +02:00
Michael Niedermayer
c0fc7466f1
avfilter/edge_template: Fix small inputs with gaussian_blur()
Fixes: out of array access
Fixes: Ticket10699
Fixes: poc5ffmpeg

Found-by: Zeng Yunxiang
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c443658d26)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:08 +02:00
Michael Niedermayer
978f270ef9
avfilter/vf_gradfun: Do not overread last line
The code works in steps of 2 lines and lacks support for odd height
Implementing odd height support is better but for now this fixes the
out of array access

Fixes: out of array access
Fixes: tickets/10702/poc6ffmpe

Found-by: Zeng Yunxiang
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit e4d2666bdc)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:08 +02:00
Michael Niedermayer
244bf4fa35
avfilter/avf_showspectrum: fix off by 1 error
Fixes: out of array access
Fixes: tickets/10749/poc15ffmpeg

Regression since: 81df787b53

Found-by: Zeng Yunxiang
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit ab0fdaedd1)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:07 +02:00
Michael Niedermayer
3e0bc91f68
avformat/mov: do not set sign bit for chunk_offsets
Fixes: signed integer overflow: 2314885530818453536 - -7412889664301817824 cannot be represented in type 'long'
Fixes: 64296/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-6304027146846208

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit cfc0a68d4d)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:07 +02:00
Michael Niedermayer
bda83cba9d
avcodec/jpeglsdec: Check Jpeg-LS LSE
Fixes: signed integer overflow: 2147478526 + 33924 cannot be represented in type 'int'
Fixes: shift exponent 32 is too large for 32-bit type 'unsigned int'
Fixes: 64243/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEGLS_fuzzer-5195717848989696

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c72a20f01a)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:07 +02:00
Brad Smith
13bbc0cd5b
configure: Enable section_data_rel_ro for FreeBSD and NetBSD aarch64 / arm
Fixes the build. It's a requirement when utilizing PIE.

Signed-off-by: Brad Smith <brad@comstyle.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 6066c430e3)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:06 +02:00
Michael Niedermayer
b751dfc151
avcodec/av1dec: Fix resolving zero divisor
Fixes: Out of array read
Fixes: global-buffer-overflow-AV1

Found-by: "Leonelli, Matteo" <matteo.leonelli@cispa.de>
Tested-by: "Wang, Fei W" <fei.w.wang@intel.com>
Reviewed-by: "Wang, Fei W" <fei.w.wang@intel.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 22daf2148f)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:06 +02:00
Michael Niedermayer
21b22341ef
avformat/mov: Ignore duplicate ftyp
Fixes: switch_1080p_720p.mp4
Found-by: Dale Curtis <dalecurtis@chromium.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 4cdf2c7f76)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:06 +02:00
Dale Curtis
90571795e2
avformat/mov: Fix integer overflow in mov_read_packet().
Fixes https://crbug.com/1499669:
runtime error: signed integer overflow: 9223372036853334272 + 1375731456
cannot be represented in type 'int64_t' (aka 'long')

Signed-off-by: Dale Curtis <dalecurtis@chromium.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 2182173a69)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:05 +02:00
Eugene Zemtsov
f9821fd907 avformat/mov: Check if a key is longer than the atom containing it
Stop reading keys and return AVERROR_INVALIDDATA if key_size
is larger than the amount of space left in the atom.

Bug: https://crbug.com/41496983
Signed-off-by: Eugene Zemtsov <eugene@chromium.org>
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 8a23a145d8)
2024-04-02 09:15:25 -03:00
Marton Balint
aae59be400 avfilter/buffersrc: fix overriding unknown channel layouts with negotiated one
Fixes ffplay playback of unknown layouts, when SDL directly supports the audio
format, such as:

ffplay -f lavfi anullsrc=cl=2C,aformat=s16

Without the patch, "Channel layout change is not supported" errors are
generated because buffersrc (unknown 2 channel) and buffersink (stereo)
negotiated a stereo layout, but the stereo layout was never stored in the
BufferSourceContext.

This fixes a regression of 7251f90972, but this
is more of a regression of the avfilter channel layout conversion
(1f96db959c).

Signed-off-by: Marton Balint <cus@passwd.hu>
(cherry picked from commit 2df2b4067e)
2024-03-30 21:57:43 +01:00
Marton Balint
fc8775ae96 avfilter/af_channelmap: disallow channel index 64
MAX_CH is 64, therefore the maximum index is 63.

Signed-off-by: Marton Balint <cus@passwd.hu>
(cherry picked from commit 2f754a96bd)
2024-03-30 21:57:09 +01:00
Marton Balint
1ad767bf27 avfilter/af_channelmap: fix mapping if in_channel was a string but out_channel was not specified
In this case in_channel_idx was never set and the default 0 was used.
Suprisingly no one noticed that the respective fate test output was wrong.

Signed-off-by: Marton Balint <cus@passwd.hu>
(cherry picked from commit 1bea3e9ee2)
2024-03-30 21:56:31 +01:00
Marton Balint
ea2dcb9b39 avfilter/af_channelmap: fix error message if FL source channel was missing
FL channel ID is 0, so for an unset value we must check for ID < 0.

Regression since 1f96db959c.

Signed-off-by: Marton Balint <cus@passwd.hu>
(cherry picked from commit 9a5627ea9a)
2024-03-30 21:56:19 +01:00
Timo Rothenpieler
a39e922fb7 avcodec/nvdec: reset bitstream_len/nb_slices when resetting bitstream pointer 2024-03-30 00:18:39 +01:00
James Almer
59918c65ad avformat/mov: don't abort on duplicate Mastering Display Metadata boxes
The VP9 spec defines a SmDm box for this information, and the ISOBMFF spec defines a
mdvc one. If both are present, just ignore one of them.
This is in line with clli and CoLL boxes.

Fixes ticket #10711.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 189c32f536)
2024-03-27 13:54:13 -03:00
Marton Balint
87f8335bdf fftools/ffplay: use correct buffersink channel layout parameters
Regression since 0995e1f1b3.

Signed-off-by: Marton Balint <cus@passwd.hu>
(cherry picked from commit 7251f90972)
2024-03-19 21:18:07 +01:00
Marton Balint
c18115b413 swresample/resample: fix rounding errors with filter_size=1 and phase_shift=0
Depending on input chunk size noticable corrpution was hearable, here is an
example command line:

ffplay -f lavfi -i "sine=440:r=8000:samples_per_frame=32,aresample=24000:filter_size=1:phase_shift=0"

Fix this by rounding the fixed point fractions up instead of down.

Signed-off-by: Marton Balint <cus@passwd.hu>
(cherry picked from commit 7b1b9bb31f)
2024-03-19 21:18:07 +01:00
Marton Balint
b6925ebc08 avformat/mxfdec: remove resolve_strong_ref usage with AnyType
UUIDs do not have to be unique if their type sets them apart, so avoid using
AnyType, since we are only interested in specific types.

Signed-off-by: Marton Balint <cus@passwd.hu>
(cherry picked from commit aa299faa9a)
2024-03-19 21:18:07 +01:00
Marton Balint
eac9841a9f avformat/libsrt: use SRT_EPOLL_IN for waiting for an incoming connection
This is the proper poll mode for waiting for an incoming connection according
to the SRT API docs.

Fixes ticket #9142.

Signed-off-by: Marton Balint <cus@passwd.hu>
(cherry picked from commit 87677c2195)
2024-03-19 21:18:07 +01:00
Marton Balint
47fa87996d avformat/mxfdec: do not use AnyType when resolving Descriptors and MultipleDescriptors
By using AnyType for resolving a strong reference we searched among all types,
not just the ones which can be the target of the reference, which in some cases
caused to find the wrong type, if the metadata set UUIDs were not unique.

UUIDs do not have to be unique if their type sets them apart, SMPTE 377M says:

> StrongRef: 'One to One’ relationship between sets and implemented in MXF
> with UUIDs. Strong References are typed which means that the definition
> identifies the kind of set which is the target of the reference.

Fixes ticket #10865.

Signed-off-by: Marton Balint <cus@passwd.hu>
(cherry picked from commit 68f2b32ef2)
2024-03-19 21:18:07 +01:00
Marton Balint
48e30b8fab avformat/mxfdec: move resolving Descriptors to the multi descriptor resolve function
Also remove unused descriptor member from MXFPackage.

Signed-off-by: Marton Balint <cus@passwd.hu>
(cherry picked from commit 41672f5586)
2024-03-19 21:18:07 +01:00
Timo Rothenpieler
cd49ee45ba avutil/hwcontext_d3d11va: prefer DXGI 1.1 factory when available
A lot of modern stuff straight up fails on the old 1.0 factory, which is
masked by the fact that it's only used when an explicit adapter is
specified.
2024-03-18 13:31:12 +01:00
Jan Ekström
511b844423 avcodec/av1dec: fix matrix coefficients exposed by codec context
`colorspace` in avcodec terms means `matrix coefficients`.

Reviewed-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 37936b09ce)
2024-02-20 21:13:05 +02:00
Marton Balint
b991129f83 avformat/mov_chan: never override number of channels based on chan atom
The channel designation metadata should not override the number of channels.
Let's warn the user if it is inconsistent, and keep the channel layout
unspecified.

Before the conversion to the channel layout API the code only set the mask, but
never overridden the channel count, so this restores the old behaviour.

Signed-off-by: Marton Balint <cus@passwd.hu>
(cherry picked from commit dc9d64f794)
2024-02-11 23:15:55 +01:00
Marton Balint
ae7cd2fc02 avformat/mov_chan: do not assume channels are in native order
Existing code could have caused wrong channel order signalling or reduced
channel count if a channel designation appeared multiple times. This is
actually an old bug, but the conversion to the new channel layout API made it
visible, because now the code overrides the proper channel count with the one
calculated from the mask.

Signed-off-by: Marton Balint <cus@passwd.hu>
(cherry picked from commit 3d3cad7483)
2024-02-11 23:15:50 +01:00
James Almer
178575bdc1 avcodec/nvdec: don't free NVDECContext->bitstream
Ensure all hwaccels that allocate a buffer use NVDECContext->bitstream_internal
instead. Otherwise, if FFHWAccel->end_frame() isn't called before
FFHWAccel->uninit(), an attempt to free a stale pointer to memory not owned by
the hwaccel could take place.

Reviewed-by: Timo Rothenpieler <timo@rothenpieler.org>
Signed-off-by: James Almer <jamrial@gmail.com>
2024-02-07 11:35:58 -03:00
Anton Khirnov
133069b434 lavc/dvdsubenc: only check canvas size when it is actually set
Fixes #10650

(cherry picked from commit 5230257ea1)
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2023-12-02 11:46:10 +01:00
Michael Niedermayer
c41ff724ed
Changelog: update
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-11-10 01:00:22 +01:00
Michael Niedermayer
1f61aad00d
avcodec/4xm: Check for cfrm exhaustion
Fixes: index -1 out of bounds for type 'CFrameBuffer [100]'
Fixes: 63877/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FOURXM_fuzzer-5854263397711872

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit bb0a684d93)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-11-10 00:25:37 +01:00
Michael Niedermayer
dcaadb2a10
avformat/mov: Disallow FTYP after streams
Fixes: Assertion !c->fc->nb_streams failed at libavformat/mov.c:7799
Fixes: 63875/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-5479178702815232

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 19fcf43131)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-11-10 00:24:18 +01:00
Frank Plowman
34ef4e9d46
doc/html: fix styling issue with Texinfo 7.0
Texinfo 7.0 produces quite different HTML to Texinfo 6.8. Without
this change, enumerated option flags (i.e. Possible values of x
are...) render as white text on a white background with Texinfo 7.0
and are unreadable. This change removes a style for the selector
`.table .table` which causes the background to turn white for these
elements. As far as I can tell, it is not actually used anywhere in
files generated by Texinfo 6.8.

Signed-off-by: Frank Plowman <post@frankplowman.com>
(cherry picked from commit f16900bda2)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-11-09 00:22:33 +01:00
Frank Plowman
302aa941eb
doc/html: support texinfo 7.0
Resolves trac ticket #10636 (http://trac.ffmpeg.org/ticket/10636).

Texinfo 7.0, released in November 2022, changed the names of various
functions. Compiling docs with Texinfo 7.0 resulted in warnings and
improperly formatted documentation. More old names appear to have
been removed in Texinfo 7.1, released October 2023, which causes docs
compilation to fail.

This commit addresses the issue by adding logic to switch between the old
and new function names depending on the Texinfo version. Texinfo 6.8
produces identical documentation before and after the patch.

CC
https://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg1938238.html
https://bugs.gentoo.org/916104

Signed-off-by: Frank Plowman <post@frankplowman.com>
(cherry picked from commit f01fdedb69)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-11-09 00:16:17 +01:00
Michael Niedermayer
2baff271a2
Changelog: update 2023-11-03 23:34:59 +01:00
Michael Niedermayer
028ae6f26c
avformat/lafdec: Check for 0 parameters
Fixes: Timeout
Fixes: 63661/clusterfuzz-testcase-minimized-ffmpeg_dem_LAF_fuzzer-6615365234589696

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Sean McGovern <gseanmcg@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 4fb9d94688)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-11-03 23:33:46 +01:00
Michael Niedermayer
d77be99a83
avfilter/buffersink: fix order of operation with = and <0
Reviewed-by: Sean McGovern <gseanmcg@gmail.com>
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c0a18e884c)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-11-03 23:33:46 +01:00
Michael Niedermayer
14b1998c1a
avfilter/framesync: fix order of operation with = and <0
Reviewed-by: Sean McGovern <gseanmcg@gmail.com>
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 9450a4a7fe)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-11-03 23:33:45 +01:00
Michael Niedermayer
7e7c3d5db2
tools/target_dec_fuzzer: Adjust threshold for CSCD
Fixes: Timeout
Fixes: 63362/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CSCD_fuzzer-4694620065628160

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c2f2bf82c1)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-11-03 23:33:45 +01:00
Michael Niedermayer
66caaeec13
avcodec/dovi_rpu: Use 64 bit in get_us/se_coeff()
Fixes: shift exponent 32 is too large for 32-bit type 'int'
Fixes: 63151/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-5067531154751488

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 2817efbba3)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-11-03 23:33:45 +01:00
Michael Niedermayer
e825157874
avformat/mov: Check that is_still_picture_avif has no trak based streams
Fixes: Assertion failure in mov_read_iloc( in mov_read_iloc())
Fixes: 62866/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-5282997370486784

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 98c2711b58)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-11-03 23:33:44 +01:00
Andreas Rheinhardt
f2a4a49afb
avformat/matroskadec: Fix declaration-after-statement warnings
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit 37b5f4a1f6)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-11-03 23:33:44 +01:00
Michael Niedermayer
7058f9a3d6
Update for FFmpeg 6.0.1
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-11-03 23:33:44 +01:00
Andreas Rheinhardt
330b8305c1 fftools/ffmpeg_mux_init: Restrict disabling automatic copying of metadata
Fixes ticket #10638 (and should also fix ticket #10482)
by restoring the behaviour from before
3c7dd5ed37.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit 02064ba3a3)
2023-11-02 23:54:16 -03:00
Michael Niedermayer
07e3223dd0
avformat/rtsp: Use rtsp_st->stream_index
Fixes: out of array access
Fixes: rtpdec_h264.c149/poc

Found-by: Hardik Shah of Vehere
Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit e4d5ac8d7d)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 20:15:29 +02:00
Michael Niedermayer
2269a892fb
avutil/tx_template: fix integer ovberflwo in fft3()
Fixes: signed integer overflow: -1028966111 + -1314089526 cannot be represented in type 'int'
Fixes: 63174/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AAC_FIXED_fuzzer-5853273711837184

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 907743239d)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 20:15:29 +02:00
Michael Niedermayer
e770922e30
avcodec/jpeg2000dec: Check image offset
Fixes: left shift of negative value -538967841
Fixes: 62447/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-6427134337613824

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Tomas Härdin <git@haerdin.se>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 88453250db)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 20:15:29 +02:00
Michael Niedermayer
d2577e1622
avformat/mxfdec: Check klv offset
Fixes: Assertion klv_offset >= mxf->run_in failed at libavformat/mxfdec.c:736
Fixes: 62936/clusterfuzz-testcase-minimized-ffmpeg_dem_MXF_fuzzer-5778404366221312.fuzz

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Tomas Härdin <git@haerdin.se>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 70f5fa6325)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 20:15:29 +02:00
Sean McGovern
7b2b48078c
libavutil/ppc/cpu.c: check that AT_HWCAP2 is defined
It was not introduced until glibc 2.18.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit d799ad2404)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 20:15:29 +02:00
Michael Niedermayer
b902f5113e
avcodec/h2645_parse: Avoid EAGAIN
EAGAIN causes an assertion failure when it is returned from the decoder

Fixes: Assertion consumed != (-(11)) failed at libavcodec/decode.c:462
Fixes: assertion_IOT_instruction_decode_c_462/poc

Found-by: Hardik Shah of Vehere (Dawn Treaders team)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 5ddab49d48)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 20:15:29 +02:00
Michael Niedermayer
1079565e8e
avcodec/xvididct: Make c* unsigned to avoid undefined overflows
Fixes: signed integer overflow: 1496950099 + 728014168 cannot be represented in type 'int'
Fixes: 62667/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MJPEGB_fuzzer-6511785170305024

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit f7e5537dc1)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 20:15:29 +02:00
Michael Niedermayer
6d25672afa
avcodec/bonk: Fix undefined overflow in predictor_calc_error()
Fixes: signed integer overflow: -2146469728 - 1488954 cannot be represented in type 'int'
Fixes: 62490/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_BONK_fuzzer-5612782399389696

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit cd66606a8f)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 20:15:29 +02:00
Michael Niedermayer
85b9a8f296
avformat/tmv: Check video chunk size
This check matches the audio chunk check

Fixes: Timeout
Fixes: 62681/clusterfuzz-testcase-minimized-ffmpeg_dem_TMV_fuzzer-5299107876700160

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit b79fc70596)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 20:15:29 +02:00
Michael Niedermayer
55769812f7
avcodec/h264_parser: saturate dts a bit
Fixes: signed integer overflow: 0 - -9223372036854775808 cannot be represented in type 'long'
Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-6112289464123392

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 7fedbc7606)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 20:15:29 +02:00
Michael Niedermayer
8af32643c0
avformat/asfdec_f: Saturate presentation time in marker
Fixes: signed integer overflow: -9223372036315799520 - 3873890816 cannot be represented in type 'long'
Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5009302746431488

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit cedb4736f5)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 20:15:29 +02:00
Michael Niedermayer
2d87c74e60
avformat/xwma: sanity check bits_per_coded_sample
Fixes: signed integer overflow: 65312 * 524296 cannot be represented in type 'int'
Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_XWMA_fuzzer-6595971445555200

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit fe6ce28d11)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 20:15:29 +02:00
Michael Niedermayer
ba90a8dff2
avformat/matroskadec: Check prebuffered_ns for overflow
Fixes: signed integer overflow: 9223372036630775808 + 1000000000 cannot be represented in type 'long'
Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_WEBM_DASH_MANIFEST_fuzzer-5406131992526848

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 2d6df3719d)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 20:15:29 +02:00
Michael Niedermayer
df8936ef12
avformat/wavdec: Check left avio_tell for overflow
Fixes: signed integer overflow: 155 + 9223372036854775655 cannot be represented in type 'long'
Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_W64_fuzzer-5364032278495232

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 929ddef3f4)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 20:15:29 +02:00
Michael Niedermayer
6ddb165b4b
avformat/tta: Better totalframes check
Fixes: signed integer overflow: 4 * 740491135 cannot be represented in type 'int'
Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_TTA_fuzzer-6298893367508992

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 5f0d00464a)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 20:15:29 +02:00
Michael Niedermayer
f4270205a4
avformat/rpl: Check for number_of_chunks overflow
Fixes: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int32_t' (aka 'int')
Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_RPL_fuzzer-6086131095830528

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit b3c973acbe)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 20:15:29 +02:00
Michael Niedermayer
034a3e6f9c
avformat/mov: compute absolute dts difference without overflow in mov_find_next_sample()
Fixes: signed integer overflow: -9223372036854775808 - 9222726413022000000 cannot be represented in type 'long'
Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-5959420033761280

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 3508b496e1)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 20:15:29 +02:00
Michael Niedermayer
d67bb81161
avformat/jacosubdec: Check timeres
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 51f0ab8b12)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 20:15:29 +02:00
Michael Niedermayer
de458e5d3f
avformat/jacosubdec: avoid signed integer overflows in get_shift()
Fixes: signed integer overflow: 22014562800 * 934633746 cannot be represented in type 'long'
Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_JACOSUB_fuzzer-5189603246866432

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 32447b149f)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 20:15:29 +02:00
Michael Niedermayer
be3ca673f4
avformat/jacosubdec: Factorize code in get_shift() a bit
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 6490b9aed6)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 20:15:29 +02:00
Michael Niedermayer
5d6524445c
avformat/sbgdec: Check for negative duration or un-representable end pts
Fixes: signed integer overflow: 9230955872951340 - -9223372036854775808 cannot be represented in type 'long'
Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_SBG_fuzzer-6330481893572608

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 9b00b5734d)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 20:15:29 +02:00
Michael Niedermayer
f630725cb0
avcodec/escape124: Do not return random numbers
Fixes: out of array access
Fixes: 62164/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ESCAPE124_fuzzer-6035022714634240
Fixes: 62164/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ESCAPE124_fuzzer-6422176201572352

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit fe6d46490f)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 20:15:29 +02:00
Michael Niedermayer
303afea1a8
avcodec/apedec: Fix an integer overflow in predictor_update_filter()
Fixes: signed integer overflow: -2147483506 + -801380 cannot be represented in type 'int'
Fixes: 62164/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-6578985923117056

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 515c0247a3)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 20:15:29 +02:00
Michael Niedermayer
8a0e48001f
tools/target_dec_fuzzer: Adjust wmapro threshold
Fixes: Timeout
Fixes: 62266/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMAPRO_fuzzer-5125460729921536

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit bb9f8a1cb7)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 20:15:29 +02:00
Michael Niedermayer
3b822405cd
avcodec/wavarc: Allocate AV_INPUT_BUFFER_PADDING_SIZE
Fixes: overread
Fixes: 62164/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WAVARC_fuzzer-5963163952349184
Fixes: 62164/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WAVARC_fuzzer-6048030137909248

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit dbcf285abd)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 20:15:29 +02:00
Michael Niedermayer
0ae86db6ba
avcodec/wavarc: Fix integer overflwo in do_stereo()
Fixes: signed integer overflow: 148676193 - -2006512262 cannot be represented in type 'int'
Fixes: 62164/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WAVARC_fuzzer-5963163952349184

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit f3c986200d)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 20:15:29 +02:00
Michael Niedermayer
47333e3e30
avutil/tx_template: Fix some signed integer overflows in DECL_FFT5()
Fixes: signed integer overflow: -1364715454 + -1468954671 cannot be represented in type 'int'
Fixes: 62093/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AAC_FIXED_fuzzer-5538774254485504

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c42a89309a)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 20:15:29 +02:00
Michael Niedermayer
f16d72dfeb
avcodec/aacdec_template: Better avoidance of signed integer overflow in imdct_and_windowing_eld()
Fixes: 62171/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AAC_FIXED_fuzzer-5644657180409856
Fixes: signed integer overflow: 2 * 1079352273 cannot be represented in type 'int'

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 7f4fed5216)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 20:15:29 +02:00
Michael Niedermayer
5fd5e84474
tools/target_dec_fuzzer: Adjust threshold for MVHA
Fixes: Timeout
Fixes: 62120/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MVHA_fuzzer-5647877768347648

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 6359b2ce03)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 20:15:29 +02:00
Michael Niedermayer
8aae506dd2
avformat/avs: Check if return code is representable
Fixes: leak
Fixes: 62164/clusterfuzz-testcase-minimized-ffmpeg_dem_AVS_fuzzer-6738814988320768

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 52d666edec)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 20:15:29 +02:00
Michael Niedermayer
f23f0ba87c
avcodec/flacdec: Fix integer overflow in "33bit" DECODER_SUBFRAME_FIXED_WIDE()
Fixes: signed integer overflow: 4 * 2307917133220067266 cannot be represented in type 'long'
Fixes: 62164/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FLAC_fuzzer-6307690022043648

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 112a077d06)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:05:07 +02:00
Michael Niedermayer
8c5b391c63
avcodec/flacdec: Fix overflow in "33bit" decorrelate
Fixes: signed integer overflow: 538976288 - -9223372036854775808 cannot be represented in type 'long'
Fixes: 62164/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FLAC_fuzzer-6275845531238400

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 35e6960a6b)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:05:07 +02:00
Michael Niedermayer
342121cd35
avcodec/lcldec: Make PNG filter addressing match the code afterwards
Also update check accordingly

Fixes: tickets/10237/mszh_306_306_yuv422_nocompress.avi
Fixes: tickets/10237/mszh_306_306_yuv411_nocompress.avi

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit d11b8bd0c6)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:05:06 +02:00
Michael Niedermayer
c8319b4e00
avformat/westwood_vqa: Check chunk size
the type is also changed to int as it is interpreted as int in av_get_packet()

Fixes: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int'
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_WSVQA_fuzzer-6593408795279360
Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_WSVQA_fuzzer-4613908817903616

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 5c0df3da0b)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:05:06 +02:00
Michael Niedermayer
33c009130c
avformat/sbgdec: Check for period overflow
Fixes: signed integer overflow: 4481246996173000000 - -4778576820000000000 cannot be represented in type 'long'
Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_SBG_fuzzer-5063670588899328

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit a9137110ed)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:05:06 +02:00
Michael Niedermayer
afb5d20e23
avformat/concatdec: Check in/outpoint for overflow
Fixes: signed integer overflow: 91542414454000000 - -9154241494546000000 cannot be represented in type 'long'
Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_CONCAT_fuzzer-4739147999084544

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit dedc78b4b5)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:05:05 +02:00
Michael Niedermayer
53bcb6eaf5
avformat/mov: Check avif_info
Fixes: leak
Fixes: 45982/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-6674082962997248
Fixes: 62164/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-6674082962997248

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 9a3bbf89bd)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:05:05 +02:00
Michael Niedermayer
3a177811f4
avformat/mxfdec: Remove this_partition
Suggested-by: Tomas Härdin <git@haerdin.se>
Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_MXF_fuzzer-5130394286817280

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 442d9412d2)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:05:05 +02:00
Michael Niedermayer
ea918615a1
avcodec/xvididct: Fix integer overflow in idct_row()
Fixes: signed integer overflow: 1871429831 + 343006811 cannot be represented in type 'int'
Fixes: 61784/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AIC_fuzzer-5372151001120768

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit b12444fe72)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:05:04 +02:00
Michael Niedermayer
4917892af7
avcodec/celp_math: avoid overflow in shift
by making gain unsigned we have 1 bit more available
alternatively we can clip twice as in the g729 reference

Fixes: left shift of 23404 by 17 places cannot be represented in type 'int'
Fixes: 61728/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ACELP_KELVIN_fuzzer-6280412547383296

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 6580a7b2b2)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:05:04 +02:00
Michael Niedermayer
882052e293
tools/target_dec_fuzzer: Adjust threshold for rtv1
Fixes: 60499/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RTV1_fuzzer-5020295866744832
Fixes: Timeout

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 9ee87245c5)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:05:04 +02:00
Michael Niedermayer
eb32d51302
avformat/hls: reduce default max reload to 3
The 1000 did result in the appearance of a never ending reload loop

The RFC mandates that "If the client reloads a Playlist file and finds that it has not
changed, then it MUST wait for a period of one-half the target
duration before retrying." and if it has changed
"the client MUST wait for at least the target duration before attempting to reload the
Playlist file again"

Trying to reload 3 times seems a better default than 1000 given these
durations

Issue found by: Сергей Колесников
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 5f810435c2)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:05:03 +02:00
Michael Niedermayer
d30d9c817a
avformat/format: Stop reading data at EOF during probing
Issue found by: Сергей Колесников
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 80f6e0378b)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:05:03 +02:00
Michael Niedermayer
38bc713c6d
avcodec/bonk: Fix integer overflow in predictor_calc_error()
Fixes: signed integer overflow: -2147483300 - 12285 cannot be represented in type 'int'
Fixes: 59462/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_BONK_fuzzer-5714298807386112

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 2b25a5168e)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:05:03 +02:00
Michael Niedermayer
ebc4d0a310
avcodec/jpeg2000dec: jpeg2000 has its own lowres option
jpeg2000 overrides the global lowres variable with a lowres field called reduction_factor
ffmpeg -lowres X causes the reduction_factor to be set
ffplay -lowres X causes both lowres and the reduction_factor to be set
ossfuss sets only lowres

only the ffmpeg variant works. This patch tries to make the other 2 work.

Alternative we could just error out if things are inconsistent.
More complex restructuring should be limited to the master branch
to keep this reasonably easy to backport

Fixes: out of array access
Fixes: 59672/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c012d1f2bb)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:05:02 +02:00
Michael Niedermayer
47bd650d68
avcodec/huffyuvdec: avoid undefined behavior with get_vlc2() failure
Fixes: left shift of negative value -1
Fixes: 59889/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HUFFYUV_fuzzer-5472742275940352

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 90647a9249)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:05:02 +02:00
Michael Niedermayer
58c8e61703
avcodec/cscd: Fix "CamStudio Lossless Codec 1.0" gzip files
Fixes: tickets/10241/cscd_1_0_306_306_gzip.avi

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit ab7d38f970)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:05:02 +02:00
Michael Niedermayer
e1a05fdb58
avcodec/cscd: Check for CamStudio Lossless Codec 1.0 behavior in end check of LZO files
Alternatively the check could be simply made more tolerant
Fixes: Ticket10227

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit d2a0464fc2)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:05:01 +02:00
Michael Niedermayer
24be4134fd
avcodec/mpeg4videodec: consider lowres in dest_pcm[]
Fixes: out of array access
Fixes: 59999/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPEG4_fuzzer-5767982157266944

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit d48476183f)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:05:01 +02:00
Michael Niedermayer
45d113af3a
avcodec/hevcdec: Fix undefined memcpy()
There is likely a better way to fix this, this is mainly to show the problem

Fixes: MC within same frame resulting in overlapping memcpy()
Fixes: 60189/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-4992746590175232
Fixes: 61753/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-5022150806077440
Fixes: 58062/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-4717458841010176

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 94bd1796ff)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:05:01 +02:00
Michael Niedermayer
2631c7c7ce
avcodec/mpeg4videodec: more unsigned in amv computation
Fixes: signed integer overflow: -2147483648 + -1048576 cannot be represented in type 'int'
Fixes: 59365/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPEG4_fuzzer-642654923954585

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 0adaa90d89)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:05:00 +02:00
Michael Niedermayer
3fa5039012
avcodec/tta: fix signed overflow in decorrelate
Fixes: signed integer overflow: 2079654542 - -139267653 cannot be represented in type 'int'
Fixes: 60811/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TTA_fuzzer-5915858409750528

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 283bf5c35b)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:05:00 +02:00
Michael Niedermayer
b7a55ae0a8
avcodec/apedec: remove unused variable
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 7995e175b8)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:05:00 +02:00
Michael Niedermayer
e4dbe25f3b
avcodec/apedec: Fix 48khz 24bit below insane level
Fixes: Ticket9816
Fixes: vlc.ape and APE_48K_24bit_2CH_02_01.ape

Regression since: ed0001482a.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 80ad0e2198)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:59 +02:00
Michael Niedermayer
e0cd8ac126
avcodec/apedec: Fix CRC for 24bps and bigendian
Fixes CRC for vlc.ape and APE_48K_24bit_2CH_02_01.ape

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 696e161919)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:59 +02:00
Michael Niedermayer
60e46128f7
avcodec/wavarc: Check that nb_samples is not negative
It is currently probably not possible for it to be negative as
the needed 2Mb input buf size is not achievable. But it is more
robust to check for it too.
If it would become negative than code like
s->samples[0][n] = s->samples[0][s->nb_samples + n];
would crash

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 5f5a1ccd04)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:59 +02:00
Michael Niedermayer
d57b29ff2b
avcodec/wavarc: Check shift
Fixes: shift exponent 1285 is too large for 32-bit type 'int'
Fixes: 60870/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WAVARC_fuzzer-5332050340347904

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 1a81a40de2)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:58 +02:00
Michael Niedermayer
ab1981b445
avcodec/xvididct: Fix integer overflow in idct_row()
Fixes: signed integer overflow: -1403461578 + -843974775 cannot be represented in type 'int'
Fixes: 60868/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPEG1VIDEO_fuzzer-4599793035378688

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 0ce322a51e)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:58 +02:00
Michael Niedermayer
1e26c4923a
avformat/avr: Check sample rate
Fixes: 54979/clusterfuzz-testcase-minimized-ffmpeg_dem_AVR_fuzzer-6681035461230592
Fixes: Timeout

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 32556fa62b)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:58 +02:00
Michael Niedermayer
b07211eb9e
avformat/imf_cpl: Replace NULL content_title_utf8 by ""
Suggested-by: Pierre-Anthony Lemieux <pal@sandflow.com>
Reviewed-by: Pierre-Anthony Lemieux <pal@sandflow.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit ac3e6b74bd)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:57 +02:00
Michael Niedermayer
ba5e12b2ed
avformat/imf_cpl: xmlNodeListGetString() can return NULL
Fixes: NULL pointer dereference
Fixes: 60166/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5998301577871360

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Pierre-Anthony Lemieux <pal@sandflow.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 509ce40f18)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:57 +02:00
Michael Niedermayer
13438a6900
avcodec/aacdec_template: Fix undefined signed interger operations
Fixed: signed integer overflow: -2 * -1085502286 cannot be represented in type 'int'
Fixed: 57986/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AAC_FIXED_fuzzer-5123651145170944

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 87f76d3bee)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:57 +02:00
Michael Niedermayer
cea882ef99
avcodec/wavarc: Fix k limit
The implementation does not support k=32

Fixes: shift exponent 32 is too large for 32-bit type 'unsigned int'
Fixes: 57976/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WAVARC_fuzzer-5911925807775744

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 40cec0b465)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:56 +02:00
Michael Niedermayer
8bce6ca582
avcodec/rka: Fix integer overflow in decode_filter()
Fixes: signed integer overflow: 2147443649 + 65535 cannot be represented in type 'int'
Fixes: 60054/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RKA_fuzzer-5095674572832768

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit f9b29451e4)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:56 +02:00
Michael Niedermayer
15e1093f9a
avformat/rka: bps < 8 is invalid
Fixes: division by zero
Fixes: 57828/clusterfuzz-testcase-minimized-ffmpeg_dem_RKA_fuzzer-6571818338353152

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 167b4f56f1)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:56 +02:00
Michael Niedermayer
1bee64983e
avcodec/pcm: allow Changing parameters
SDR needs this for switching between mono and stereo stations

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 94d44dbe21)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:55 +02:00
Michael Niedermayer
161b2b6ed6
avutil/tx_template: extend to 2M
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 8f48a62151)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:55 +02:00
Michael Niedermayer
68604c9dee
avcodec/jpeg2000dec: Check for reduction factor and image offset
This combination is not working (it writes out of array)

Reviewed-by: Tomas Härdin <git@haerdin.se>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 9b6d191a66)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:55 +02:00
Michael Niedermayer
992fc9d75a
avutil/softfloat: Basic documentation for av_sincos_sf()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 4aa1a42a91)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:54 +02:00
Michael Niedermayer
5531eacf9e
avutil/softfloat: fix av_sincos_sf()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit d84677abd8)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:54 +02:00
Michael Niedermayer
410d733a8b
tools/target_dec_fuzzer: Adjust threshold for speex
Fixes: Timeout
Fixes: 59731/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SPEEX_fuzzer-4809436670328832

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit fe167bae96)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:54 +02:00
Michael Niedermayer
09e888a5b4
avcodec/utils: fix 2 integer overflows in get_audio_frame_duration()
Fixes: signed integer overflow: 256 * 668003712 cannot be represented in type 'int'
Fixes: 59819/clusterfuzz-testcase-minimized-ffmpeg_dem_MATROSKA_fuzzer-4674636538052608

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit a4bf559683)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:53 +02:00
Michael Niedermayer
aef59048e6
avcodec/hevcdec: Avoid null pointer dereferences in MC
Fixes: runtime error: pointer index expression with base 0x000000000000 overflowed to 0xfffffffffffffff8
Fixes: 58440/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-5956015530311680

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit a0f4d4e650)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:53 +02:00
Michael Niedermayer
4c906c5867
avcodec/takdsp: Fix integer overflows
Fixes: avcodec/takdsp.c:44:23: runtime error: signed integer overflow: -2097158 - 2147012608 cannot be represented in type 'int'
Fixes: 58417/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TAK_fuzzer-5268919664640000

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit ff8a496d41)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:53 +02:00
Michael Niedermayer
52dd7a9f7a
avcodec/mpegvideo_dec: consider interlaced lowres 4:2:0 chroma in edge emulation check better
Fixes: out of array read
Fixes: 59673/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPEG1VIDEO_fuzzer-5194311374077952

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit d7d3f1af2a)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:52 +02:00
Michael Niedermayer
85cb7abb4c
avcodec/rka: use unsigned for buf0 additions
Fixes: signed integer overflow: -38912000 + -2109276160 cannot be represented in type 'int'
Fixes: 59670/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RKA_fuzzer-4987563245699072

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit e736238b35)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:52 +02:00
Michael Niedermayer
819e9068af
avcodec/rka: Avoid undefined left shift
Fixes: left shift of 34136248 by 6 places cannot be represented in type 'int'
Fixes: 58429/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RKA_fuzzer-5692211592560640

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 1ee303f1e1)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:52 +02:00
Michael Niedermayer
a66733a8c9
avcodec: Ignoring errors is only possible before the input end
Fixes: out of array read
Fixes: Ticket 10308

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit fead656a7b)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:51 +02:00
Michael Niedermayer
79af71223d
avformat/jpegxl_probe: Forward error codes
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 09621fd7d9)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:51 +02:00
Michael Niedermayer
63270289a0
avformat/jpegxl_probe: check length instead of blindly reading
Enable the checked bitreader to avoid overread.
Also add a few checks in loops and between blocks so we exit instead of continued
execution.
Alternatively we could add manual checks so that no overread can happen. This would be
slightly faster but a bit more work and a bit more fragile

Fixes: Out of array accesses
Fixes: 59640/clusterfuzz-testcase-minimized-ffmpeg_dem_JPEGXL_ANIM_fuzzer-6584117345779712

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 1ec4553e35)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:51 +02:00
Michael Niedermayer
c598778d37
avformat/jpegxl_probe: Remove intermediate macro obfuscation around get_bits*()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 25c937c0e0)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:50 +02:00
Michael Niedermayer
33ee9ab941
avcodec/noise_bsf: Check for wrapped frames
Wrapped frames contain pointers so they need specific code to
noise them, the generic code would lead to segfaults

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 0889ebc577)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:50 +02:00
Michael Niedermayer
339463bd90
avformat/oggparsetheora: clip duration within 64bit
Fixes: signed integer overflow: 9079256848778919936 - -288230376151711746 cannot be represented in type 'long'
Fixes: 58248/clusterfuzz-testcase-minimized-ffmpeg_dem_OGG_fuzzer-6326851353313280

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit b1c3d81e71)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:50 +02:00
Michael Niedermayer
426117bb7e
avcodec/rka: avoid undefined multiply in cmode==0
Fixes: signed integer overflow: -182838 * 32768 cannot be represented in type 'int'
Fixes: 58179/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RKA_fuzzer-5333265899978752

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit b168aeb734)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:49 +02:00
Michael Niedermayer
011511791a
avcodec/rka: use 64bit for srate_pad computation
Fixes: left shift of 538976288 by 13 places cannot be represented in type 'int'
Fixes: 56148/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RKA_fuzzer-6257370708967424

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit cbe5e480aa)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:49 +02:00
Michael Niedermayer
79edf58ba8
avcodec/bonk: Avoid undefined integer overflow in predictor_calc_error()
Fixes: signed integer overflow: -159584 * 5105950 cannot be represented in type 'int'
Fixes: 55165/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_BONK_fuzzer-5796023719297024

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 43e5e2e423)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:49 +02:00
Michael Niedermayer
86682ab20f
avformat/wavdec: Check that smv block fits in available space
Fixes: OOM
Fixes: 56271/clusterfuzz-testcase-minimized-ffmpeg_dem_WAV_fuzzer-5290810045497344

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit a76efafdb9)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:48 +02:00
Michael Niedermayer
24b6f44f96
avcodec/adpcm: Fix integer overflow in intermediate in ADPCM_XMD
Fixes: runtime error: signed integer overflow: 2140143616 + 254665816 cannot be represented in type 'int'
Fixes: 45982/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ADPCM_XMD_fuzzer-6690181676924928

As a sideeffect this simplifies the equation, the high bits are different after this but only
the low 16bits are stored and used in later steps.

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 722ff74055)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:48 +02:00
Michael Niedermayer
838cab9a07
avcodec/dpcm: fix undefined interger overflow in wady
Fixes: signed integer overflow: -2147375930 + -133875 cannot be represented in type 'int'
Fixes: 45982/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WADY_DPCM_fuzzer-6703727013920768

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 8f0e200a12)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:48 +02:00
Michael Niedermayer
40e81d5a8b
avcodec/tiff: add a zero DNG_LINEARIZATION_TABLE check
Fixes: index 4294967295 out of bounds for type 'uint16_t [65536]'
Fixes: 45982/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-5950405086674944
Fixes: 45982/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-6666195176914944

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 6e98cf0280)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:47 +02:00
Michael Niedermayer
4e3f8fd46a
avcodec/tak: Check remaining bits in ff_tak_decode_frame_header()
Fixes: out of array access
Fixes: 45982/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TAK_fuzzer-6682195323650048

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 19b66b89da)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:47 +02:00
Michael Niedermayer
0ec70368b0
avcodec/sonic: Fix two undefined integer overflows
Fixes: signed integer overflow: 2147483372 - -148624 cannot be represented in type 'int'
Fixes: 45982/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SONIC_fuzzer-5477177805373440
Fixes: 45982/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SONIC_fuzzer-6681622236233728

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 2632e90493)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:47 +02:00
Michael Niedermayer
fbc224b126
avcodec/utils: the IFF_ILBM implementation assumes that there are a multiple of 16 allocated
Fixes: out of array access
Fixes: 45982/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_IFF_ILBM_fuzzer-5124452659888128
Fixes: 45982/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_IFF_ILBM_fuzzer-6362836707442688

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 34056a94ea)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:46 +02:00
Michael Niedermayer
fc7f2fdacf
avcodec/flacdec: Fix signed integre overflow
Fixes: signed integer overflow: 3011809745540902265 + 6323452730883571725 cannot be represented in type 'long'
Fixes: 45982/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FLAC_fuzzer-6687553022722048

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit fd7352660b)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:46 +02:00
Michael Niedermayer
89950105b9
avcodec/exr: Cleanup befor return
Fixes: leaks
Fixes: 45982/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EXR_fuzzer-6703454090559488

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 885ff3b879)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:46 +02:00
Michael Niedermayer
9000efe97f
avcodec/pngdec: Do not pass AVFrame into global header decode
The global header should not contain a frame, and decoding it
would result in leaks

Fixes: memleak
Fixes: 45982/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APNG_fuzzer-6603443149340672

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit d31d4f3228)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:45 +02:00
Michael Niedermayer
344f333c6c
avcodec/pngdec: remove AVFrame argument from decode_iccp_chunk()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 7117b380a7)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:45 +02:00
Michael Niedermayer
8c8a08e1bf
avcodec/wavarc: Check order before using it to write the list
Fixes: out of array access
Fixes: 45982/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WAVARC_fuzzer-6247711015043072
Fixes: 45982/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WAVARC_fuzzer-6487578428964864
Fixes: 45982/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WAVARC_fuzzer-6651587794960384
Fixes: 45982/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WAVARC_fuzzer-6686265824378880

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit e2e34c7731)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:45 +02:00
Michael Niedermayer
63aa0cfd0e
avcodec/bonk: decode multiple passes in intlist_read() at once
This makes the worst case much faster

Fixes: Timeout
Fixes: 51363/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_BONK_fuzzer-5660734784143360
Fixes: 57957/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_BONK_fuzzer-5874095467397120

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 957106a24d)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:44 +02:00
Michael Niedermayer
1d7dd08199
avcodec/vorbisdec: Check codebook float values to be finite
Fixes: Timeout
Fixes: 55116/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VORBIS_fuzzer-4572159970508800

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit cadd7e7a75)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:44 +02:00
Michael Niedermayer
6500c15977
avcodec/g2meet: Replace fake allocation avoidance for framebuf
framebuf is only allocated when the new width/height are larger than the old
but nothing sets the old so its always allocated.
Use av_fast_mallocz() instead.

Fixes: Timeout
Fixes: 55094/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_G2M_fuzzer-5116909932904448

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 38adbc6eeb)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:44 +02:00
Michael Niedermayer
81ab846988
avutil/tx_priv: Use unsigned in BF() to avoid signed overflows
Fixes: signed integer overflow: 100183269 - -2132769113 cannot be represented in type 'int'
Fixes: 55063/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AAC_FIXED_fuzzer-5039294027005952

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit eddf7e2a3e)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:43 +02:00
Michael Niedermayer
19db9ffb3b
avcodec/lcldec: More space for rgb24
Fixes: Ticket 10239
Fixes: zlib_306_306_rgb24.av

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit e2c3aa8e2b)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:43 +02:00
Michael Niedermayer
735f6be311
avcodec/lcldec: Support 4:1:1 and 4:2:2 with odd width
Fixes: Ticket10240
Fixes: zlib_306_306_yuv422.avi
Fixes: zlib_306_306_yuv411.avi

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 0cf1ac905d)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:43 +02:00
Michael Niedermayer
a06bf3dae8
libavcodec/lcldec: width and height should not be unsigned
Computations like col < width - 3 will not work with unsigned width=1

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 3eb4e28c26)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:42 +02:00
Pierre-Anthony Lemieux
953e26755b
avformat/imf: fix invalid resource handling
(cherry picked from commit 23d968d55a)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:42 +02:00
Michael Niedermayer
0291b86a94
avcodec/escape124: Check that blocks are allocated before use
Fixes: NULL pointer dereference
Fixes: 57819/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ESCAPE124_fuzzer-5077280228769792

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 5366ae12b9)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:42 +02:00
Michael Niedermayer
d84e889785
avcodec/rka: Fix signed integer overflow in decode_filter()
Fixes: signed integer overflow: -631553 * 32768 cannot be represented in type 'int'
Fixes: 57814/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RKA_fuzzer-4614661233573888

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 0ecda4fbce)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:41 +02:00
Michael Niedermayer
a85d0bc84b
avcodec/huffyuvdec: Fix undefined behavior with shift
Fixes: left shift of negative value -1
Fixes: 57554/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFVHUFF_fuzzer-4853603839115264

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 27e7857bd1)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:41 +02:00
Michael Niedermayer
67919ba682
avcodec/j2kenc: Replace RGB24 special case by generic test
This fixes RGB48 with libavcodec as decoder

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit ad4d647591)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:41 +02:00
Michael Niedermayer
1ed34709ff
avcodec/j2kenc: Replace BGR48 / GRAY16 test by test for number of bits
BGR48 is not supported and this was probably meant to be RGB48 so this fixes
RGB48 a bit

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 7fb70d27a2)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:40 +02:00
Michael Niedermayer
4cec33869e
avcodec/j2kenc: simplify pixel format setup
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 644d15716d)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:40 +02:00
Michael Niedermayer
9a086ad5b1
avcodec/j2kenc: Fix funky bpno errors on decoding
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 816676085e)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:40 +02:00
Michael Niedermayer
407e6cde75
avcodec/j2kenc: remove misleading pred value
This field is only checked for being 0 or not and not zero means 5/3

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 0adb375377)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:39 +02:00
Michael Niedermayer
fa35ce082a
avcodec/j2kenc: fix 5/3 DWT identifer
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit f6955b6df4)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:39 +02:00
Michael Niedermayer
efab690c16
avcodec/vp3: Check width to avoid assertion failure
Fixes: Assertion failure on x86-32
       av_assert2(block_w * sizeof(pixel) <= FFABS(buf_linesize)); in ff_emulated_edge_mc()
Fixes: 39641/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_THEORA_fuzzer-5925660741206016

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit dab1cd2dc0)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:39 +02:00
Michael Niedermayer
14da53d4c6
avcodec/g729postfilter: Limit shift in long term filter
Fixes: shift exponent 34 is too large for 32-bit type 'int'
Fixes: 57389/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ACELP_KELVIN_fuzzer-6229522659016704

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 6d1d8609ac)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:38 +02:00
Michael Niedermayer
b89cda3269
avcodec/wavarc: Fix several integer overflows
Fixes: signed integer overflow: -532410125 + -1759642300 cannot be represented in type 'int'
Fixes: 57045/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WAVARC_fuzzer-637023665297817

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 1942dbb8ca)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:38 +02:00
Michael Niedermayer
deeb0b6e94
avcodec/tests/snowenc: Fix 2nd test
(cherry picked from commit 163013c724)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:38 +02:00
Michael Niedermayer
89c0a651ad
avcodec/tests/snowenc: return a failure if DWT/IDWT mismatches
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 771c266c0b)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:37 +02:00
Michael Niedermayer
ea6ec6b507
avcodec/snowenc: Fix visual weight calculation
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 5b5fcadea0)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:37 +02:00
Michael Niedermayer
c2a484cf5b
avcodec/tests/snowenc: unbreak DWT tests
the IDWT data type mismatched current code

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 8b3351bbea)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:37 +02:00
Michael Niedermayer
1957bd1110
avcodec/mpeg12dec: Check input size
Fixes: Timeout
Fixes: 53599/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_IPU_fuzzer-4950102511058944

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 7c130d6911)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:36 +02:00
Michael Niedermayer
438ea0eaf3
avcodec/escape124: Fix some return codes
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 98df605f7a)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:36 +02:00
Michael Niedermayer
f081f94601
avcodec/escape124: fix signdness of end of input check
Fixes: Timeout
Fixes: 56561/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ESCAPE124_fuzzer-5560363635834880

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 87ad0a5dd7)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:36 +02:00
Michael Niedermayer
318c295925
Use https for repository links
Reviewed-by: Stefano Sabatini <stefasab@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 011f30fc82)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-28 19:04:35 +02:00
Timo Rothenpieler
c5039e158d avcodec/nvdec_hevc: fail to initialize on unsupported profiles 2023-10-12 21:03:03 +02:00
Anton Khirnov
067ed535f4 fftools/ffmpeg_enc: apply -top to individual encoded frames
Fixes #9339.

(Adapted from commit 43a0004b5c)
2023-09-25 16:11:33 +02:00
Marton Balint
3d5edb89e7 avcodec/on2avc: use correct fft sizes
Also rename the contexts and the functions so their names will reflect their
intended size.

With the earlier patch this fixes the audio corruption regression caused by
6ba0aa1770.

Fixes ticket #10029.

Signed-off-by: Marton Balint <cus@passwd.hu>
(cherry picked from commit 2eb7df1cbd)
2023-08-08 19:41:20 +02:00
Marton Balint
d2efb80027 avcodec/on2avc: use the matching AVTX context for the 512 sized iMDCT
Improves the audio corruption regression caused by
6ba0aa1770 reported in ticket #10029.

There is still however a noticable audio glitch, so the FFT conversion to AVTX
probably also needs some modifications.

Signed-off-by: Marton Balint <cus@passwd.hu>
(cherry picked from commit f296c76590)
2023-08-08 19:41:02 +02:00
Sebastian Ramacher
d4a7a6e7fa examples: fix build of mux and resample_audio
The commits eac4324bfb and
cd8211527e renamed the examples, but the
targets were not updated. Hence, the builds are missing -lm.

Signed-off-by: Sebastian Ramacher <sramacher@debian.org>
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 7de3fcb059)
2023-07-28 09:22:22 -03:00
Timo Rothenpieler
1ebb0e43f9 avcodec/nvenc: stop using deprecated rc modes with SDK 12.1 2023-07-23 12:58:13 +02:00
Timo Rothenpieler
9212b53ed5 configure: use non-deprecated nvenc GUID for conftest 2023-07-23 12:58:13 +02:00
Rémi Denis-Courmont
cc703cf607 avcodec/x86/mathops: clip constants used with shift instructions within inline assembly
Fixes assembling with binutil as >= 2.41

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit effadce6c7)
2023-07-20 16:53:17 -03:00
Timo Rothenpieler
cedbf27a35 avfilter/vsrc_ddagrab: calculate pointer position on rotated screens 2023-07-15 19:02:37 +02:00
Timo Rothenpieler
c433ad89a0 avfilter/vsrc_ddagrab: account for mouse-only frames during probing 2023-07-15 19:02:35 +02:00
James Almer
3f345ebf21 avcodec/aac_ac3_parser: add preprocessor checks for codec specific code
Should fix ticket #10421.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 35af1695a9)
2023-06-24 14:43:46 -03:00
Timo Rothenpieler
868af7d7a4 avcodec/nvenc: handle frame durations and AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE 2023-06-16 22:45:24 +02:00
Timo Rothenpieler
d341895a08 Revert "lavc/nvenc: handle frame durations and AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE"
The implementation is flawed in that the frame opaque data is not in
fact correctly reordered along with the packets, but is being output in
packet input order, just like the dts are.

This reverts commit 3553809703.
2023-06-16 22:43:32 +02:00
Timo Rothenpieler
cb3453eb25 Revert "avcodec/nvenc: fix b-frame DTS behavior with fractional framerates"
This reverts commit 9a245bdf5d.

This commit basically broke all samples with fractional framerates,
rather than fixing them.
I at this point do not understand the original issue anymore, and I'm
not sure how this slipped my initial testing.
All my test samples must have happened to have a simple timebase.

The actual dts values pretty much always are just a simple chain of
1,2,3,4,5,... Or maybe slightly bigger steps. Each increase by one means
an advance in time by one unit of the timebase.
So a fractional framerate/timebase is already not an issue.

So with this patch applied, the calculation might end up substracting
huge values (1001 is a common one) from the dts, which would be an
offset of that many frames, not of that many fractions of a second.
This broke at least muxing into mp4, if the sample happened to have a
fractional framerate.

I do not thing the original issue this patch tried to fix existed in the
first place, so it can be reverted without further consequences.
2023-06-16 22:35:24 +02:00
Hendrik Leppkes
549430e14d
avcodec/vdpau_mpeg4: fix order of quant matrix coefficients
The matrix coefficients are stored permutated for the IDCT,
rather then in plain raster order, and need to be un-permutated
for the hardware.
2023-05-15 18:41:30 +02:00
Hendrik Leppkes
bfa8a4a44b
avcodec/vdpau_mpeg12: fix order of quant matrix coefficients
The matrix coefficients are stored permutated for the IDCT,
rather then in plain raster order, and need to be un-permutated
for the hardware.
2023-05-15 18:41:30 +02:00
Hendrik Leppkes
d7c0991cfc
avcodec/nvdec_mpeg4: fix order of quant matrix coefficients
The matrix coefficients are stored permutated for the IDCT,
rather then in plain raster order, and need to be un-permutated
for the hardware.
2023-05-15 18:41:30 +02:00
Hendrik Leppkes
8ea302832f
avcodec/nvdec_mpeg2: fix order of quant matrix coefficients
The matrix coefficients are stored permutated for the IDCT,
rather then in plain raster order, and need to be un-permutated
for the hardware.
2023-05-15 18:41:30 +02:00
James Almer
27205c0b47 fftools/ffmpeg_filter: fix leak of AVIOContext in read_binary()
It was only being freed on failure.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 1b7c13e1a4)
2023-04-28 13:54:57 -03:00
Anton Khirnov
8f61cbf1b9 fftools/ffmpeg: avoid possible invalid reads with short -tag values
Fixes #10319 and #10309.

(cherry picked from commit 89c9a3ac35)
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2023-04-17 12:08:46 +02:00
James Almer
2c11164707 avcodec/mp_cmp: reject invalid comparison function values
Fixes tickets #10306 and #10318.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 7c6e26a184)
2023-04-16 11:38:26 -03:00
James Almer
5606d27006 avcodec/aacpsy: clip global_quality within the psy_vbr_map array boundaries
Fixes ticket #10317.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 5cda6b94f4)
2023-04-16 11:38:26 -03:00
James Almer
4808ed94e3 avutil/wchar_filename: propagate MultiByteToWideChar() and WideCharToMultiByte() failures
Don't return success if the string could not be converted.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 92885f2681)
2023-04-16 11:38:26 -03:00
James Almer
bf704a0b30 avformat/concatf: check if any nodes were allocated
Fixes ticket #10304

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 19c2dc677f)
2023-04-16 11:38:26 -03:00
Kyle Manning
a6dc92968a avcodec/nvenc: fix b-frame DTS behavior with fractional framerates
When using fractional framerates (or any fraction with a numerator != 1),
DTS values for packets would be calculated incorrectly.

Signed-off-by: Kyle Manning <tt2468@irltoolkit.com>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2023-04-03 12:03:56 +02:00
James Almer
3980415627 avcodec/vorbisdec: export skip_samples instead of dropping frames
pts may not be set on input packets, which could result in the entire stream
being discarded.
This reverts commit 8fc2dedfe6, reintroducing the
behavior it replaced but now allowing the caller to manually drop the preroll
samples by looking at the skip_samples side data at the start while ignoring it
on seek, by setting the skip_manual avctx flag.

Fixes ticket #10251.

Suggested-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit cbcc817353)
2023-03-22 12:51:17 -03:00
Anton Khirnov
a0d6566498 fftools/ffmpeg_mux_init: avoid invalid reads in forced keyframe parsing
Fixes #10243

(cherry picked from commit 1e406692e5)
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2023-03-20 10:57:40 +01:00
Haihao Xiang
a3c93c03ad lavfi/vf_vpp_qsv: set the right timestamp for AVERROR_EOF
Rescale the timestamp for AVERROR_EOF. This can fix tickets 10261 and
10262.

Tested-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com>
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
(cherry picked from commit 57afccc0ef)
2023-03-20 10:09:21 +08:00
James Almer
18dde8d4cf avfilter/vf_untile: swap the chroma shift values used for plane offsets
Fixes ticket #10265

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit dc61d5cf19)
2023-03-16 17:06:09 -03:00
Anton Khirnov
adb4688bfb lavc/decode: stop mangling last_pkt_props->opaque
It is currently abused to store packet size, which breaks
AV_CODEC_FLAG_COPY_OPAQUE.

Use stream_index instead, which is unused in libavcodec and has the
same type as size.

Found-by: Martin Storsjö
(cherry picked from commit a3bf63c26e)
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2023-03-11 11:41:45 +01:00
Timo Rothenpieler
916bdc0f19 avcodec/nvenc: avoid failing b_ref_mode check when unset 2023-03-10 13:17:52 +01:00
Kacper Michajłow
58f18df430 lavu/vulkan: fix handle type for 32-bit targets
Fixes compilation with clang which errors out on Wint-conversion.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Martin Storsjö <martin@martin.st>
(cherry picked from commit cc76e8340d)
Signed-off-by: Martin Storsjö <martin@martin.st>
2023-03-10 12:36:16 +02:00
Martin Storsjö
1cf17633cd vulkan: Fix win/i386 calling convention
This fixes the following error when compiling with a modern
version of Clang for Windows/i386:

src/libavutil/hwcontext_vulkan.c:738:32: error: incompatible function pointer types initializing 'PFN_vkDebugUtilsMessengerCallbackEXT' (aka 'unsigned int (*)(enum VkDebugUtilsMessageSeverityFlagBitsEXT, unsigned int, const struct VkDebugUtilsMessengerCallbackDataEXT *, void *) __attribute__((stdcall))') with an expression of type 'VkBool32 (VkDebugUtilsMessageSeverityFlagBitsEXT, VkDebugUtilsMessageTypeFlagsEXT, const VkDebugUtilsMessengerCallbackDataEXT *, void *)' (aka 'unsigned int (enum VkDebugUtilsMessageSeverityFlagBitsEXT, unsigned int, const struct VkDebugUtilsMessengerCallbackDataEXT *, void *)') [-Wincompatible-function-pointer-types]
            .pfnUserCallback = vk_dbg_callback,
                               ^~~~~~~~~~~~~~~

Signed-off-by: Martin Storsjö <martin@martin.st>
(cherry picked from commit f9620d74cd)
Signed-off-by: Martin Storsjö <martin@martin.st>
2023-03-10 12:36:15 +02:00
James Almer
0e11aafb08 avfilter/graphparser: fix filter instance name when an id is provided
Restores the behavior of naming the instance filter@id, which was accidentally changed
to simpy id in commit f17051eaae.

Fixes ticket #10226.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 2fd86d9afa)
2023-03-06 08:43:57 -03:00
Zhao Zhili
46970dd155 avcodec/aacps_tablegen: fix build error after avutil bump
Fix tickets #10225

DECLARE_ALIGNED has been moved to mem_internal.h.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
Reviewed-by: Anton Khirnov <anton@khirnov.net>
(cherry picked from commit 814178f926)
2023-03-02 14:43:24 -03:00
Zhao Zhili
0981053c29 avcodec/nvenc: fix potential NULL pointer dereference
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2023-02-28 19:20:02 +01:00
Michael Niedermayer
ea3d24bbe3
RELEASE_NOTES: Based on the version from 5.1
Name suggested by Niklas Haas

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-26 00:13:45 +01:00
Michael Niedermayer
ff5cce2eaf
avcodec/motionpixels: Mask pixels to valid values
Fixes: out of array access
Fixes: 48567/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MOTIONPIXELS_fuzzer-6724203352555520

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit ac6eec1fc2)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-25 22:50:36 +01:00
Michael Niedermayer
1eb1acb62b
avcodec/xpmdec: Check size before allocation to avoid truncation
Fixes:OOM
Fixes:out of array access (no testcase)
Fixes: 48567/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_XPM_fuzzer-6573323838685184

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 95f0f84dae)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-25 22:50:10 +01:00
Michael Niedermayer
718d6c71ef
avcodec/bink: Avoid undefined out of array end pointers in binkb_decode_plane()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit ea9deafd3b)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-25 22:49:27 +01:00
Michael Niedermayer
8ab01c8b0d
avcodec/bink: Fix off by 1 error in ref end
Fixes: out of array access
Fixes: 48567/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_BINK_fuzzer-6657932926517248

Alterantivly to this it is possibly to allocate a bigger array

Note: oss-fuzz assigned this issue to a unrelated theora bug so the bug number matches that

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 49487045dd)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-25 22:48:29 +01:00
Michael Niedermayer
d1e446d570
avcodec/utils: Ensure linesize for SVQ3
Fixes: Assertion block_w * sizeof(uint8_t) <= ((buf_linesize) >= 0 ? (buf_linesize) : (-(buf_linesize))
Fixes: 54861/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SVQ3_fuzzer-5352418248622080

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 4eef658ca5)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-25 21:52:50 +01:00
Michael Niedermayer
8e478e0cb1
avcodec/utils: allocate a line more for VC1 and WMV3
Fixes: out of array read on 32bit
Fixes: 54857/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC1_fuzzer-5840588224462848

The chroma MC code reads over the currently allocated frame.
Alternative fixes would be allocating a few bytes more at the end instead of a whole
line extra or to adjust the threshold where the edge emu code is activated

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 01636a63d4)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-25 21:40:02 +01:00
Michael Niedermayer
81d9c57c43
avcodec/videodsp_template: Adjust pointers to avoid undefined pointer things
Fixes: subtraction of unsigned offset from 0xf6602770 overflowed to 0xf6638c80
Fixes: 48567/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_THEORA_fuzzer-495074400600064

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit f0150cd41c)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-25 21:39:17 +01:00
Michael Niedermayer
3ae6feff7e
avcodec/pngdec: dont skip/read chunk twice
Fixes: out of array access
Fixes: 48567/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PNG_fuzzer-6668158952144896.fuzz

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit df1a38d520)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-25 21:27:12 +01:00
Michael Niedermayer
197dcd28ef
avcodec/pngdec: Check deloco index more exactly
Fixes: out of array access:
Fixes: 48567/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PNG_fuzzer-6716193709096960

Alternatively it should be possible to limit this to 3 plane RGB 8 /16bit to ensure the size is what it should be

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit d5bae70406)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-25 21:20:35 +01:00
Michael Niedermayer
bc531eedbd
avformat/wavarc: Check if extradata has been fully read
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 2df271c78c)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-25 21:20:11 +01:00
Michael Niedermayer
e4eed31133
avcodec/wavarc: Check k
Fixes: Assertion failure
Fixes: 55849/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WAVARC_fuzzer-6590105973555200

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 4dee46426e)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-25 21:19:58 +01:00
Michael Niedermayer
c56f84e656
avcodec/ffv1dec: Check that num h/v slices is supported
Fixes: out of array access
Fixes: 55597/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFV1_fuzzer-4898293416329216

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 8ead0ae68e)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-25 21:08:41 +01:00
Michael Niedermayer
bbcf3f4234
avcodec/rka: avoid undefined doubling sum overflow
Fixes: signed integer overflow: -2124073172 * 2 cannot be represented in type 'int'
Fixes: 56099/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RKA_fuzzer-4530933127839744

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit a02e45a1f3)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-25 21:08:13 +01:00
Michael Niedermayer
8a6c037acd
avcodec/rka: avoid negative value shift
Fixes: left shift of negative value -81
Fixes: 56061/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RKA_fuzzer-4649758062149632

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit a5d4e7e3f9)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-25 21:08:03 +01:00
Michael Niedermayer
b59152b474
avcodec/rka: check for size 1 filter
Such filters will not advance and be stuck in the current implementation

Fixes: Infinite loop
Fixes: 56052/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RKA_fuzzer-5236218750435328

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 8874cfa2e1)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-25 21:06:40 +01:00
Michael Niedermayer
0c1e67ab14
avcodec/rka: Fix some integer anomalies
Fixes: left shift of negative value -3201
Fixes: integer overflow: -76470276 * -25608 cannot be represented in type 'int'
Fixes: 56052/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RKA_fuzzer-5236218750435328

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit d495747a9f)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-25 21:06:21 +01:00
Michael Niedermayer
ec5edc0946
avformat/rka: Fix 1/0 with bps=1
Fixes: division by zero
Fixes: 55940/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-6333107679920128

The decoder does not support bps=1 and i have no such sample so it is not
known if this duration is correct. Alternatively we could error out on all
bps we currently do not support on the decoder side or not set duration.

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit b3df7ca748)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-25 21:05:55 +01:00
Michael Niedermayer
6f1b24c4fe
avformat/mov: Check samplesize and offset to avoid integer overflow
Fixes: signed integer overflow: 9223372036854775584 + 536870912 cannot be represented in type 'long'
Fixes: 55844/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-510613920664780

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 53c1f5c2e2)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-25 20:54:16 +01:00
John Coiner
691d019899 avformat/mpegtsenc: re-emit extradata ahead of IDR pictures even if AUD is already present
Current mpegtsenc code only inserts SPS/PPS from extradata before IDR frames if
AUD is also inserted.

Unfortunately some encoders may preface a key frame with an AUD, but no
SPS/PPS. In that case current code does not repeat the "extradata" and the
resulting HLS stream may become noncompliant and unjoinable.

Fix this by always inserting SPS/PPS and moving AUD to the beginning of the
packet if it is already present.

Fixes ticket #10148.

Signed-off-by: Marton Balint <cus@passwd.hu>
(cherry picked from commit e0cb89c354)
2023-02-19 22:50:32 +01:00
Marton Balint
65873ac3ee doc: remove docs for options removed at the bump
Signed-off-by: Marton Balint <cus@passwd.hu>
(cherry picked from commit 3807fbd90a)
2023-02-19 22:50:21 +01:00
James Almer
34a1403831 avfilter/af_pan: use the new swr used channel layout option
Fixes ticket #10180

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 4561232b1a)
2023-02-19 18:30:15 -03:00
James Almer
a34b348328 swresample/swresample: add a used channel layout option using the new API
Replaces the "used channel count" option, which is now deprecated.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 223c70cf1d)
2023-02-19 18:30:15 -03:00
James Almer
6112745d8e doc/resampler.texi: add missing swr channel layout options
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 1d14959f12)
2023-02-19 18:30:15 -03:00
Michael Niedermayer
71534916df
Update things for 6.0
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-19 19:16:39 +01:00
214 changed files with 2005 additions and 933 deletions

View file

@ -1,6 +1,6 @@
See the Git history of the project (git://source.ffmpeg.org/ffmpeg) to
See the Git history of the project (https://git.ffmpeg.org/ffmpeg) to
get the names of people who have contributed to FFmpeg.
To check the log, you can type the command "git log" in the FFmpeg
source directory, or browse the online repository at
http://source.ffmpeg.org.
https://git.ffmpeg.org/ffmpeg

269
Changelog
View file

@ -1,6 +1,275 @@
Entries are sorted chronologically from oldest to youngest within each release,
releases are sorted from youngest to oldest.
version 6.0.2:
fate/subtitles: Ignore line endings for sub-scc test
avformat/mxfdec: Check index_edit_rate
swscale/utils: Fix xInc overflow
avformat/isom: Uninit layout in ff_mp4_read_dec_config_descr()
avcodec/exr: Dont use 64bits to hold 6bits
avcodec/exr: Check for remaining bits in huf_unpack_enc_table()
avformat/mpegts: Reset local nb_prg on add_program() failure
avformat/aiffdec: Check for previously set channels
avformat/mxfdec: Make edit_unit_byte_count unsigned
avformat/movenc: Check that cts fits in 32bit
avformat/mxfdec: Check first case of offset_temp computation for overflow
avfilter/vf_signature: Dont crash on no frames
avformat/westwood_vqa: Fix 2g packets
avformat/matroskadec: Check timescale
avformat/wavdec: satuarte next_tag_ofs, data_end
avformat/sbgdec: Check for negative duration
avformat/rpl: Use 64bit for total_audio_size and check it
avformat/timecode: use 64bit for intermediate for rounding in fps_from_frame_rate()
avformat/mov: use 64bit for intermediate for rounding
avformat/jacosubdec: Use 64bit for abs
avformat/concatdec: Check user_duration sum
avcodec/wavarc: Avoid signed integer overflow in sample
avcodec/truemotion1: Height not being a multiple of 4 is unsupported
avcodec/hcadec: do not set hfr_group_count to invalid values
avformat/concatdec: clip outpoint - inpoint overflow in get_best_effort_duration()
avformat/jacosubdec: clarify code
avformat/cafdec: Check that data chunk end fits within 64bit
avformat/iff: Saturate avio_tell() + 12
avformat/dxa: Adjust order of operations around block align
avformat/cafdec: dont seek beyond 64bit
avformat/id3v2: read_uslt() check for the amount read
avformat/wady: Check >0 samplerate and channels 1 || 2.
avcodec/proresenc_kostya: Remove bug similarity text
avcodec/vorbisdec: Check remaining data in vorbis_residue_decode_internal()
avformat/concatdec: Check in and outpoints to be to produce a positive representable duration
avcodec/8bps: Consider width in the minimal size check
libswscale/utils: Fix bayer to yuvj
swscale/swscale: Check srcSliceH for bayer
swscale/utils: Allocate more dithererror
avcodec/indeo3: Round dimensions up in allocate_frame_buffers()
avutil/rational: Document what is to be expected from av_d2q() of doubles representing rational numbers
avfilter/signature_lookup: Do not dereference NULL pointers after malloc failure
avfilter/signature_lookup: dont leave uncleared pointers in sll_free()
avcodec/mpegvideo_enc: Use ptrdiff_t for stride
libavformat/hlsenc.c: Populate OTI using AAC profile in write_codec_attr.
avcodec/mpegvideo_enc: Dont copy beyond the image
avfilter/vf_minterpolate: Check pts before division
avformat/flacdec: Avoid double AVERRORS
avfilter/vf_vidstabdetect: Avoid double AVERRORS
avfilter/vf_swaprect: round coordinates down
avfilter/vf_swaprect: Use height for vertical variables
avfilter/vf_swaprect: assert that rectangles are within memory
avfilter/af_alimiter: Check nextpos before use
avfilter/f_reverse: Apply PTS compensation only when pts is available
avfilter/af_stereowiden: Check length
avformat/mov: Fix MSAN issue with stsd_id
avfilter/vf_weave: Fix odd height handling
avfilter/edge_template: Fix small inputs with gaussian_blur()
avfilter/vf_gradfun: Do not overread last line
avfilter/avf_showspectrum: fix off by 1 error
avformat/mov: do not set sign bit for chunk_offsets
avcodec/jpeglsdec: Check Jpeg-LS LSE
configure: Enable section_data_rel_ro for FreeBSD and NetBSD aarch64 / arm
avcodec/av1dec: Fix resolving zero divisor
avformat/mov: Ignore duplicate ftyp
avformat/mov: Fix integer overflow in mov_read_packet().
avformat/mov: Check if a key is longer than the atom containing it
avfilter/buffersrc: fix overriding unknown channel layouts with negotiated one
avfilter/af_channelmap: disallow channel index 64
avfilter/af_channelmap: fix mapping if in_channel was a string but out_channel was not specified
avfilter/af_channelmap: fix error message if FL source channel was missing
avcodec/nvdec: reset bitstream_len/nb_slices when resetting bitstream pointer
avformat/mov: don't abort on duplicate Mastering Display Metadata boxes
fftools/ffplay: use correct buffersink channel layout parameters
swresample/resample: fix rounding errors with filter_size=1 and phase_shift=0
avformat/mxfdec: remove resolve_strong_ref usage with AnyType
avformat/libsrt: use SRT_EPOLL_IN for waiting for an incoming connection
avformat/mxfdec: do not use AnyType when resolving Descriptors and MultipleDescriptors
avformat/mxfdec: move resolving Descriptors to the multi descriptor resolve function
avutil/hwcontext_d3d11va: prefer DXGI 1.1 factory when available
avcodec/av1dec: fix matrix coefficients exposed by codec context
avformat/mov_chan: never override number of channels based on chan atom
avformat/mov_chan: do not assume channels are in native order
avcodec/nvdec: don't free NVDECContext->bitstream
lavc/dvdsubenc: only check canvas size when it is actually set
version 6.0.1:
avcodec/4xm: Check for cfrm exhaustion
avformat/mov: Disallow FTYP after streams
doc/html: fix styling issue with Texinfo 7.0
doc/html: support texinfo 7.0
Changelog: update
avformat/lafdec: Check for 0 parameters
avformat/lafdec: Check for 0 parameters
avfilter/buffersink: fix order of operation with = and <0
avfilter/framesync: fix order of operation with = and <0
tools/target_dec_fuzzer: Adjust threshold for CSCD
avcodec/dovi_rpu: Use 64 bit in get_us/se_coeff()
avformat/mov: Check that is_still_picture_avif has no trak based streams
avformat/matroskadec: Fix declaration-after-statement warnings
Update for FFmpeg 6.0.1
fftools/ffmpeg_mux_init: Restrict disabling automatic copying of metadata
avformat/rtsp: Use rtsp_st->stream_index
avformat/rtsp: Use rtsp_st->stream_index
avutil/tx_template: fix integer ovberflwo in fft3()
avcodec/jpeg2000dec: Check image offset
avformat/mxfdec: Check klv offset
libavutil/ppc/cpu.c: check that AT_HWCAP2 is defined
avcodec/h2645_parse: Avoid EAGAIN
avcodec/xvididct: Make c* unsigned to avoid undefined overflows
avcodec/bonk: Fix undefined overflow in predictor_calc_error()
avformat/tmv: Check video chunk size
avcodec/h264_parser: saturate dts a bit
avformat/asfdec_f: Saturate presentation time in marker
avformat/xwma: sanity check bits_per_coded_sample
avformat/matroskadec: Check prebuffered_ns for overflow
avformat/wavdec: Check left avio_tell for overflow
avformat/tta: Better totalframes check
avformat/rpl: Check for number_of_chunks overflow
avformat/mov: compute absolute dts difference without overflow in mov_find_next_sample()
avformat/jacosubdec: Check timeres
avformat/jacosubdec: avoid signed integer overflows in get_shift()
avformat/jacosubdec: Factorize code in get_shift() a bit
avformat/sbgdec: Check for negative duration or un-representable end pts
avcodec/escape124: Do not return random numbers
avcodec/apedec: Fix an integer overflow in predictor_update_filter()
tools/target_dec_fuzzer: Adjust wmapro threshold
avcodec/wavarc: Allocate AV_INPUT_BUFFER_PADDING_SIZE
avcodec/wavarc: Fix integer overflwo in do_stereo()
avutil/tx_template: Fix some signed integer overflows in DECL_FFT5()
avcodec/aacdec_template: Better avoidance of signed integer overflow in imdct_and_windowing_eld()
tools/target_dec_fuzzer: Adjust threshold for MVHA
avformat/avs: Check if return code is representable
avcodec/flacdec: Fix integer overflow in "33bit" DECODER_SUBFRAME_FIXED_WIDE()
avcodec/flacdec: Fix overflow in "33bit" decorrelate
avcodec/lcldec: Make PNG filter addressing match the code afterwards
avformat/westwood_vqa: Check chunk size
avformat/sbgdec: Check for period overflow
avformat/concatdec: Check in/outpoint for overflow
avformat/mov: Check avif_info
avformat/mxfdec: Remove this_partition
avcodec/xvididct: Fix integer overflow in idct_row()
avcodec/celp_math: avoid overflow in shift
tools/target_dec_fuzzer: Adjust threshold for rtv1
avformat/hls: reduce default max reload to 3
avformat/format: Stop reading data at EOF during probing
avcodec/bonk: Fix integer overflow in predictor_calc_error()
avcodec/jpeg2000dec: jpeg2000 has its own lowres option
avcodec/huffyuvdec: avoid undefined behavior with get_vlc2() failure
avcodec/cscd: Fix "CamStudio Lossless Codec 1.0" gzip files
avcodec/cscd: Check for CamStudio Lossless Codec 1.0 behavior in end check of LZO files
avcodec/mpeg4videodec: consider lowres in dest_pcm[]
avcodec/hevcdec: Fix undefined memcpy()
avcodec/mpeg4videodec: more unsigned in amv computation
avcodec/tta: fix signed overflow in decorrelate
avcodec/apedec: remove unused variable
avcodec/apedec: Fix 48khz 24bit below insane level
avcodec/apedec: Fix CRC for 24bps and bigendian
avcodec/wavarc: Check that nb_samples is not negative
avcodec/wavarc: Check shift
avcodec/xvididct: Fix integer overflow in idct_row()
avformat/avr: Check sample rate
avformat/imf_cpl: Replace NULL content_title_utf8 by ""
avformat/imf_cpl: xmlNodeListGetString() can return NULL
avcodec/aacdec_template: Fix undefined signed interger operations
avcodec/wavarc: Fix k limit
avcodec/rka: Fix integer overflow in decode_filter()
avformat/rka: bps < 8 is invalid
avcodec/pcm: allow Changing parameters
avutil/tx_template: extend to 2M
avcodec/jpeg2000dec: Check for reduction factor and image offset
avutil/softfloat: Basic documentation for av_sincos_sf()
avutil/softfloat: fix av_sincos_sf()
tools/target_dec_fuzzer: Adjust threshold for speex
avcodec/utils: fix 2 integer overflows in get_audio_frame_duration()
avcodec/hevcdec: Avoid null pointer dereferences in MC
avcodec/takdsp: Fix integer overflows
avcodec/mpegvideo_dec: consider interlaced lowres 4:2:0 chroma in edge emulation check better
avcodec/rka: use unsigned for buf0 additions
avcodec/rka: Avoid undefined left shift
avcodec: Ignoring errors is only possible before the input end
avformat/jpegxl_probe: Forward error codes
avformat/jpegxl_probe: check length instead of blindly reading
avformat/jpegxl_probe: Remove intermediate macro obfuscation around get_bits*()
avcodec/noise_bsf: Check for wrapped frames
avformat/oggparsetheora: clip duration within 64bit
avcodec/rka: avoid undefined multiply in cmode==0
avcodec/rka: use 64bit for srate_pad computation
avcodec/bonk: Avoid undefined integer overflow in predictor_calc_error()
avformat/wavdec: Check that smv block fits in available space
avcodec/adpcm: Fix integer overflow in intermediate in ADPCM_XMD
avcodec/dpcm: fix undefined interger overflow in wady
avcodec/tiff: add a zero DNG_LINEARIZATION_TABLE check
avcodec/tak: Check remaining bits in ff_tak_decode_frame_header()
avcodec/sonic: Fix two undefined integer overflows
avcodec/utils: the IFF_ILBM implementation assumes that there are a multiple of 16 allocated
avcodec/flacdec: Fix signed integre overflow
avcodec/exr: Cleanup befor return
avcodec/pngdec: Do not pass AVFrame into global header decode
avcodec/pngdec: remove AVFrame argument from decode_iccp_chunk()
avcodec/wavarc: Check order before using it to write the list
avcodec/bonk: decode multiple passes in intlist_read() at once
avcodec/vorbisdec: Check codebook float values to be finite
avcodec/g2meet: Replace fake allocation avoidance for framebuf
avutil/tx_priv: Use unsigned in BF() to avoid signed overflows
avcodec/lcldec: More space for rgb24
avcodec/lcldec: Support 4:1:1 and 4:2:2 with odd width
libavcodec/lcldec: width and height should not be unsigned
avformat/imf: fix invalid resource handling
avcodec/escape124: Check that blocks are allocated before use
avcodec/rka: Fix signed integer overflow in decode_filter()
avcodec/huffyuvdec: Fix undefined behavior with shift
avcodec/j2kenc: Replace RGB24 special case by generic test
avcodec/j2kenc: Replace BGR48 / GRAY16 test by test for number of bits
avcodec/j2kenc: simplify pixel format setup
avcodec/j2kenc: Fix funky bpno errors on decoding
avcodec/j2kenc: remove misleading pred value
avcodec/j2kenc: fix 5/3 DWT identifer
avcodec/vp3: Check width to avoid assertion failure
avcodec/g729postfilter: Limit shift in long term filter
avcodec/wavarc: Fix several integer overflows
avcodec/tests/snowenc: Fix 2nd test
avcodec/tests/snowenc: return a failure if DWT/IDWT mismatches
avcodec/snowenc: Fix visual weight calculation
avcodec/tests/snowenc: unbreak DWT tests
avcodec/mpeg12dec: Check input size
avcodec/escape124: Fix some return codes
avcodec/escape124: fix signdness of end of input check
Use https for repository links
avcodec/nvdec_hevc: fail to initialize on unsupported profiles
fftools/ffmpeg_enc: apply -top to individual encoded frames
avcodec/on2avc: use correct fft sizes
avcodec/on2avc: use the matching AVTX context for the 512 sized iMDCT
examples: fix build of mux and resample_audio
avcodec/nvenc: stop using deprecated rc modes with SDK 12.1
configure: use non-deprecated nvenc GUID for conftest
avcodec/x86/mathops: clip constants used with shift instructions within inline assembly
avfilter/vsrc_ddagrab: calculate pointer position on rotated screens
avfilter/vsrc_ddagrab: account for mouse-only frames during probing
avcodec/aac_ac3_parser: add preprocessor checks for codec specific code
avcodec/nvenc: handle frame durations and AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
Revert "lavc/nvenc: handle frame durations and AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE"
Revert "avcodec/nvenc: fix b-frame DTS behavior with fractional framerates"
avcodec/vdpau_mpeg4: fix order of quant matrix coefficients
avcodec/vdpau_mpeg12: fix order of quant matrix coefficients
avcodec/nvdec_mpeg4: fix order of quant matrix coefficients
avcodec/nvdec_mpeg2: fix order of quant matrix coefficients
fftools/ffmpeg_filter: fix leak of AVIOContext in read_binary()
fftools/ffmpeg: avoid possible invalid reads with short -tag values
avcodec/mp_cmp: reject invalid comparison function values
avcodec/aacpsy: clip global_quality within the psy_vbr_map array boundaries
avutil/wchar_filename: propagate MultiByteToWideChar() and WideCharToMultiByte() failures
avformat/concatf: check if any nodes were allocated
avcodec/nvenc: fix b-frame DTS behavior with fractional framerates
avcodec/vorbisdec: export skip_samples instead of dropping frames
fftools/ffmpeg_mux_init: avoid invalid reads in forced keyframe parsing
lavfi/vf_vpp_qsv: set the right timestamp for AVERROR_EOF
avfilter/vf_untile: swap the chroma shift values used for plane offsets
lavc/decode: stop mangling last_pkt_props->opaque
avcodec/nvenc: avoid failing b_ref_mode check when unset
lavu/vulkan: fix handle type for 32-bit targets
vulkan: Fix win/i386 calling convention
avfilter/graphparser: fix filter instance name when an id is provided
avcodec/aacps_tablegen: fix build error after avutil bump
avcodec/nvenc: fix potential NULL pointer dereference
version 6.0:
- Radiance HDR image support
- ddagrab (Desktop Duplication) video capture filter

View file

@ -91,10 +91,10 @@ ffbuild/.config: $(CONFIGURABLE_COMPONENTS)
SUBDIR_VARS := CLEANFILES FFLIBS HOSTPROGS TESTPROGS TOOLS \
HEADERS ARCH_HEADERS BUILT_HEADERS SKIPHEADERS \
ARMV5TE-OBJS ARMV6-OBJS ARMV8-OBJS VFP-OBJS NEON-OBJS \
ALTIVEC-OBJS VSX-OBJS RVV-OBJS MMX-OBJS X86ASM-OBJS \
ALTIVEC-OBJS VSX-OBJS MMX-OBJS X86ASM-OBJS \
MIPSFPU-OBJS MIPSDSPR2-OBJS MIPSDSP-OBJS MSA-OBJS \
MMI-OBJS LSX-OBJS LASX-OBJS OBJS SLIBOBJS SHLIBOBJS \
STLIBOBJS HOSTOBJS TESTOBJS
MMI-OBJS LSX-OBJS LASX-OBJS RV-OBJS RVV-OBJS \
OBJS SLIBOBJS SHLIBOBJS STLIBOBJS HOSTOBJS TESTOBJS
define RESET
$(1) :=

View file

@ -1 +1 @@
5.1.git
6.0.2

15
RELEASE_NOTES Normal file
View file

@ -0,0 +1,15 @@
┌────────────────────────────────────────────┐
│ RELEASE NOTES for FFmpeg 6.0 "Von Neumann" │
└────────────────────────────────────────────┘
The FFmpeg Project proudly presents FFmpeg 6.0 "Von Neumann", about 6
months after the release of FFmpeg 5.1.
A complete Changelog is available at the root of the project, and the
complete Git history on https://git.ffmpeg.org/gitweb/ffmpeg.git
We hope you will like this release as much as we enjoyed working on it, and
as usual, if you have any questions about it, or any FFmpeg related topic,
feel free to join us on the #ffmpeg IRC channel (on irc.libera.chat) or ask
on the mailing-lists.

41
configure vendored
View file

@ -2110,10 +2110,12 @@ ARCH_EXT_LIST_PPC="
ldbrx
power8
ppc4xx
vec_xl
vsx
"
ARCH_EXT_LIST_RISCV="
rv
rvv
"
@ -2191,6 +2193,7 @@ HEADERS_LIST="
opencv2_core_core_c_h
OpenGL_gl3_h
poll_h
pthread_np_h
sys_param_h
sys_resource_h
sys_select_h
@ -2293,6 +2296,8 @@ SYSTEM_FUNCS="
posix_memalign
prctl
pthread_cancel
pthread_set_name_np
pthread_setname_np
sched_getaffinity
SecItemImport
SetConsoleTextAttribute
@ -2407,6 +2412,7 @@ HAVE_LIST="
opencl_vaapi_intel_media
perl
pod2man
posix_ioctl
texi2html
xmllint
zlib_gzip
@ -2627,9 +2633,11 @@ altivec_deps="ppc"
dcbzl_deps="ppc"
ldbrx_deps="ppc"
ppc4xx_deps="ppc"
vec_xl_deps="altivec"
vsx_deps="altivec"
power8_deps="vsx"
rv_deps="riscv"
rvv_deps="riscv"
loongson2_deps="mips"
@ -3892,6 +3900,8 @@ if test "$target_os_default" = aix; then
arch_default=$(uname -p)
strip_default="strip -X32_64"
nm_default="nm -g -X32_64"
elif test "$MSYSTEM_CARCH" != ""; then
arch_default="$MSYSTEM_CARCH"
else
arch_default=$(uname -m)
fi
@ -5519,6 +5529,7 @@ case $target_os in
;;
netbsd)
disable symver
enable section_data_rel_ro
oss_indev_extralibs="-lossaudio"
oss_outdev_extralibs="-lossaudio"
enabled gcc || check_ldflags -Wl,-zmuldefs
@ -5537,6 +5548,7 @@ case $target_os in
disable symver
;;
freebsd)
enable section_data_rel_ro
;;
bsd/os)
add_extralibs -lpoll -lgnugetopt
@ -6113,8 +6125,14 @@ elif enabled ppc; then
check_cpp_condition power8 "altivec.h" "defined(_ARCH_PWR8)"
fi
if enabled altivec; then
check_cc vec_xl altivec.h "const unsigned char *y1i = { 0 };
vector unsigned char y0 = vec_xl(0, y1i);"
fi
elif enabled riscv; then
enabled rv && check_inline_asm rv '".option arch, +zbb\nrev8 t0, t1"'
enabled rvv && check_inline_asm rvv '".option arch, +v\nvsetivli zero, 0, e8, m1, ta, ma"'
elif enabled x86; then
@ -6350,6 +6368,7 @@ check_headers malloc.h
check_headers mftransform.h
check_headers net/udplite.h
check_headers poll.h
check_headers pthread_np.h
check_headers sys/param.h
check_headers sys/resource.h
check_headers sys/select.h
@ -6513,6 +6532,12 @@ if ! disabled pthreads && ! enabled w32threads && ! enabled os2threads; then
if enabled pthreads; then
check_builtin sem_timedwait semaphore.h "sem_t *s; sem_init(s,0,0); sem_timedwait(s,0); sem_destroy(s)" $pthreads_extralibs
check_func pthread_cancel $pthreads_extralibs
hdrs=pthread.h
if enabled pthread_np_h; then
hdrs="$hdrs pthread_np.h"
fi
check_lib pthread_set_name_np "$hdrs" pthread_set_name_np -lpthread
check_lib pthread_setname_np "$hdrs" pthread_setname_np -lpthread
fi
fi
@ -6859,11 +6884,13 @@ pod2man --help > /dev/null 2>&1 && enable pod2man || disable pod2man
rsync --help 2> /dev/null | grep -q 'contimeout' && enable rsync_contimeout || disable rsync_contimeout
xmllint --version > /dev/null 2>&1 && enable xmllint || disable xmllint
check_headers linux/fb.h
check_headers linux/videodev2.h
test_code cc linux/videodev2.h "struct v4l2_frmsizeenum vfse; vfse.discrete.width = 0;" && enable_sanitized struct_v4l2_frmivalenum_discrete
test_code cc sys/ioctl.h "int ioctl(int, int, ...)" && enable posix_ioctl
# check V4L2 codecs available in the API
if enabled v4l2_m2m; then
check_headers linux/fb.h
check_headers linux/videodev2.h
test_code cc linux/videodev2.h "struct v4l2_frmsizeenum vfse; vfse.discrete.width = 0;" && enable_sanitized struct_v4l2_frmivalenum_discrete
check_cc v4l2_m2m linux/videodev2.h "int i = V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_VIDEO_M2M | V4L2_BUF_FLAG_LAST;"
check_cc vc1_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_VC1_ANNEX_G;"
check_cc mpeg1_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_MPEG1;"
@ -6908,8 +6935,7 @@ enabled alsa && { check_pkg_config alsa alsa "alsa/asoundlib.h" snd_pcm_htimesta
enabled libjack &&
require_pkg_config libjack jack jack/jack.h jack_port_get_latency_range
enabled sndio && { check_pkg_config sndio sndio "sndio.h" sio_open ||
check_lib sndio sndio.h sio_open -lsndio; }
enabled sndio && check_pkg_config sndio sndio sndio.h sio_open
if enabled libcdio; then
check_pkg_config libcdio libcdio_paranoia "cdio/cdda.h cdio/paranoia.h" cdio_cddap_open ||
@ -7018,7 +7044,7 @@ fi
if enabled x86; then
case $target_os in
mingw32*|mingw64*|win32|win64|linux|cygwin*)
freebsd|mingw32*|mingw64*|win32|win64|linux|cygwin*)
;;
*)
disable ffnvcodec cuvid nvdec nvenc
@ -7042,7 +7068,7 @@ enabled nvenc &&
test_cc -I$source_path <<EOF || disable nvenc
#include <ffnvcodec/nvEncodeAPI.h>
NV_ENCODE_API_FUNCTION_LIST flist;
void f(void) { struct { const GUID guid; } s[] = { { NV_ENC_PRESET_HQ_GUID } }; }
void f(void) { struct { const GUID guid; } s[] = { { NV_ENC_CODEC_H264_GUID } }; }
int main(void) { return 0; }
EOF
@ -7601,6 +7627,7 @@ if enabled ppc; then
echo "POWER8 enabled ${power8-no}"
echo "PPC 4xx optimizations ${ppc4xx-no}"
echo "dcbzl available ${dcbzl-no}"
echo "vec_xl available ${vec_xl-no}"
fi
if enabled loongarch; then
echo "LSX enabled ${lsx-no}"

View file

@ -38,7 +38,7 @@ PROJECT_NAME = FFmpeg
# could be handy for archiving the generated documentation or if some version
# control system is used.
PROJECT_NUMBER =
PROJECT_NUMBER = 6.0.2
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a

View file

@ -3,9 +3,9 @@
The FFmpeg developers.
For details about the authorship, see the Git history of the project
(git://source.ffmpeg.org/ffmpeg), e.g. by typing the command
(https://git.ffmpeg.org/ffmpeg), e.g. by typing the command
@command{git log} in the FFmpeg source directory, or browsing the
online repository at @url{http://source.ffmpeg.org}.
online repository at @url{https://git.ffmpeg.org/ffmpeg}.
Maintainers for the specific components are listed in the file
@file{MAINTAINERS} in the source code tree.

File diff suppressed because one or more lines are too long

View file

@ -1949,22 +1949,6 @@ Set the number of slices, used in parallelized encoding. Default value
is 0. This is only used when @option{slice_mode} is set to
@samp{fixed}.
@item slice_mode
Set slice mode. Can assume one of the following possible values:
@table @samp
@item fixed
a fixed number of slices
@item rowmb
one slice per row of macroblocks
@item auto
automatic number of slices according to number of threads
@item dyn
dynamic slicing
@end table
Default value is @samp{auto}.
@item loopfilter
Enable loop filter, if set to 1 (automatically enabled). To disable
set a value of 0.

View file

@ -43,8 +43,8 @@ OBJS=$(addsuffix .o,$(EXAMPLES))
# the following examples make explicit use of the math library
avcodec: LDLIBS += -lm
encode_audio: LDLIBS += -lm
muxing: LDLIBS += -lm
resampling_audio: LDLIBS += -lm
mux: LDLIBS += -lm
resample_audio: LDLIBS += -lm
.phony: all clean-test clean

View file

@ -26943,11 +26943,6 @@ Specify the frame rate expected for the video stream.
@item pixel_aspect, sar
The sample (pixel) aspect ratio of the input video.
@item sws_param
This option is deprecated and ignored. Prepend @code{sws_flags=@var{flags};}
to the filtergraph description to specify swscale flags for automatically
inserted scalers. See @ref{Filtergraph syntax}.
@item hw_frames_ctx
When using a hardware pixel format, this should be a reference to an
AVHWFramesContext describing input frames.

View file

@ -53,7 +53,7 @@ Most distribution and operating system provide a package for it.
@section Cloning the source tree
@example
git clone git://source.ffmpeg.org/ffmpeg <target>
git clone https://git.ffmpeg.org/ffmpeg.git <target>
@end example
This will put the FFmpeg sources into the directory @var{<target>}.

View file

@ -795,12 +795,6 @@ deletes them. Increase this to allow continue clients to download segments which
were recently referenced in the playlist. Default value is 1, meaning segments older than
@code{hls_list_size+1} will be deleted.
@item hls_ts_options @var{options_list}
Set output format options using a :-separated list of key=value
parameters. Values containing @code{:} special characters must be
escaped.
@code{hls_ts_options} is deprecated, use hls_segment_options instead of it..
@item hls_start_number_source
Start the playlist sequence number (@code{#EXT-X-MEDIA-SEQUENCE}) according to the specified source.
Unless @code{hls_flags single_file} is set, it also specifies source of starting sequence numbers of

View file

@ -11,18 +11,8 @@ programmatic use.
@table @option
@item ich, in_channel_count
Set the number of input channels. Default value is 0. Setting this
value is not mandatory if the corresponding channel layout
@option{in_channel_layout} is set.
@item och, out_channel_count
Set the number of output channels. Default value is 0. Setting this
value is not mandatory if the corresponding channel layout
@option{out_channel_layout} is set.
@item uch, used_channel_count
Set the number of used input channels. Default value is 0. This option is
@item uchl, used_chlayout
Set used input channel layout. Default is unset. This option is
only used for special remapping.
@item isr, in_sample_rate
@ -41,8 +31,8 @@ Specify the output sample format. It is set by default to @code{none}.
Set the internal sample format. Default value is @code{none}.
This will automatically be chosen when it is not explicitly set.
@item icl, in_channel_layout
@item ocl, out_channel_layout
@item ichl, in_chlayout
@item ochl, out_chlayout
Set the input/output channel layout.
See @ref{channel layout syntax,,the Channel Layout section in the ffmpeg-utils(1) manual,ffmpeg-utils}

View file

@ -20,8 +20,45 @@
# License along with FFmpeg; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
# Texinfo 7.0 changed the syntax of various functions.
# Provide a shim for older versions.
sub ff_set_from_init_file($$) {
my $key = shift;
my $value = shift;
if (exists &{'texinfo_set_from_init_file'}) {
texinfo_set_from_init_file($key, $value);
} else {
set_from_init_file($key, $value);
}
}
sub ff_get_conf($) {
my $key = shift;
if (exists &{'texinfo_get_conf'}) {
texinfo_get_conf($key);
} else {
get_conf($key);
}
}
sub get_formatting_function($$) {
my $obj = shift;
my $func = shift;
my $sub = $obj->can('formatting_function');
if ($sub) {
return $obj->formatting_function($func);
} else {
return $obj->{$func};
}
}
# determine texinfo version
my $program_version_num = version->declare(ff_get_conf('PACKAGE_VERSION'))->numify;
my $program_version_6_8 = $program_version_num >= 6.008000;
# no navigation elements
set_from_init_file('HEADERS', 0);
ff_set_from_init_file('HEADERS', 0);
sub ffmpeg_heading_command($$$$$)
{
@ -55,7 +92,7 @@ sub ffmpeg_heading_command($$$$$)
$element = $command->{'parent'};
}
if ($element) {
$result .= &{$self->{'format_element_header'}}($self, $cmdname,
$result .= &{get_formatting_function($self, 'format_element_header')}($self, $cmdname,
$command, $element);
}
@ -112,7 +149,11 @@ sub ffmpeg_heading_command($$$$$)
$cmdname
= $Texinfo::Common::level_to_structuring_command{$cmdname}->[$heading_level];
}
$result .= &{$self->{'format_heading_text'}}(
# format_heading_text expects an array of headings for texinfo >= 7.0
if ($program_version_num >= 7.000000) {
$heading = [$heading];
}
$result .= &{get_formatting_function($self,'format_heading_text')}(
$self, $cmdname, $heading,
$heading_level +
$self->get_conf('CHAPTER_HEADER_LEVEL') - 1, $command);
@ -126,23 +167,19 @@ foreach my $command (keys(%Texinfo::Common::sectioning_commands), 'node') {
texinfo_register_command_formatting($command, \&ffmpeg_heading_command);
}
# determine if texinfo is at least version 6.8
my $program_version_num = version->declare(get_conf('PACKAGE_VERSION'))->numify;
my $program_version_6_8 = $program_version_num >= 6.008000;
# print the TOC where @contents is used
if ($program_version_6_8) {
set_from_init_file('CONTENTS_OUTPUT_LOCATION', 'inline');
ff_set_from_init_file('CONTENTS_OUTPUT_LOCATION', 'inline');
} else {
set_from_init_file('INLINE_CONTENTS', 1);
ff_set_from_init_file('INLINE_CONTENTS', 1);
}
# make chapters <h2>
set_from_init_file('CHAPTER_HEADER_LEVEL', 2);
ff_set_from_init_file('CHAPTER_HEADER_LEVEL', 2);
# Do not add <hr>
set_from_init_file('DEFAULT_RULE', '');
set_from_init_file('BIG_RULE', '');
ff_set_from_init_file('DEFAULT_RULE', '');
ff_set_from_init_file('BIG_RULE', '');
# Customized file beginning
sub ffmpeg_begin_file($$$)
@ -159,7 +196,18 @@ sub ffmpeg_begin_file($$$)
my ($title, $description, $encoding, $date, $css_lines,
$doctype, $bodytext, $copying_comment, $after_body_open,
$extra_head, $program_and_version, $program_homepage,
$program, $generator) = $self->_file_header_informations($command);
$program, $generator);
if ($program_version_num >= 7.000000) {
($title, $description, $encoding, $date, $css_lines,
$doctype, $bodytext, $copying_comment, $after_body_open,
$extra_head, $program_and_version, $program_homepage,
$program, $generator) = $self->_file_header_information($command);
} else {
($title, $description, $encoding, $date, $css_lines,
$doctype, $bodytext, $copying_comment, $after_body_open,
$extra_head, $program_and_version, $program_homepage,
$program, $generator) = $self->_file_header_informations($command);
}
my $links = $self->_get_links ($filename, $element);
@ -223,7 +271,7 @@ if ($program_version_6_8) {
sub ffmpeg_end_file($)
{
my $self = shift;
my $program_string = &{$self->{'format_program_string'}}($self);
my $program_string = &{get_formatting_function($self,'format_program_string')}($self);
my $program_text = <<EOT;
<p style="font-size: small;">
$program_string
@ -244,7 +292,7 @@ if ($program_version_6_8) {
# Dummy title command
# Ignore title. Title is handled through ffmpeg_begin_file().
set_from_init_file('USE_TITLEPAGE_FOR_TITLE', 1);
ff_set_from_init_file('USE_TITLEPAGE_FOR_TITLE', 1);
sub ffmpeg_title($$$$)
{
return '';
@ -262,8 +310,14 @@ sub ffmpeg_float($$$$$)
my $args = shift;
my $content = shift;
my ($caption, $prepended) = Texinfo::Common::float_name_caption($self,
$command);
my ($caption, $prepended);
if ($program_version_num >= 7.000000) {
($caption, $prepended) = Texinfo::Convert::Converter::float_name_caption($self,
$command);
} else {
($caption, $prepended) = Texinfo::Common::float_name_caption($self,
$command);
}
my $caption_text = '';
my $prepended_text;
my $prepended_save = '';
@ -335,8 +389,13 @@ sub ffmpeg_float($$$$$)
$caption->{'args'}->[0], 'float caption');
}
if ($prepended_text.$caption_text ne '') {
$prepended_text = $self->_attribute_class('div','float-caption'). '>'
. $prepended_text;
if ($program_version_num >= 7.000000) {
$prepended_text = $self->html_attribute_class('div',['float-caption']). '>'
. $prepended_text;
} else {
$prepended_text = $self->_attribute_class('div','float-caption'). '>'
. $prepended_text;
}
$caption_text .= '</div>';
}
my $html_class = '';
@ -349,8 +408,13 @@ sub ffmpeg_float($$$$$)
$prepended_text = '';
$caption_text = '';
}
return $self->_attribute_class('div', $html_class). '>' . "\n" .
$prepended_text . $caption_text . $content . '</div>';
if ($program_version_num >= 7.000000) {
return $self->html_attribute_class('div', [$html_class]). '>' . "\n" .
$prepended_text . $caption_text . $content . '</div>';
} else {
return $self->_attribute_class('div', $html_class). '>' . "\n" .
$prepended_text . $caption_text . $content . '</div>';
}
}
texinfo_register_command_formatting('float',

View file

@ -15,6 +15,7 @@ OBJS-$(HAVE_LASX) += $(LASX-OBJS) $(LASX-OBJS-yes)
OBJS-$(HAVE_ALTIVEC) += $(ALTIVEC-OBJS) $(ALTIVEC-OBJS-yes)
OBJS-$(HAVE_VSX) += $(VSX-OBJS) $(VSX-OBJS-yes)
OBJS-$(HAVE_RV) += $(RV-OBJS) $(RV-OBJS-yes)
OBJS-$(HAVE_RVV) += $(RVV-OBJS) $(RVV-OBJS-yes)
OBJS-$(HAVE_MMX) += $(MMX-OBJS) $(MMX-OBJS-yes)

View file

@ -1337,6 +1337,9 @@ static void do_video_out(OutputFile *of,
in_picture->quality = enc->global_quality;
in_picture->pict_type = forced_kf_apply(ost, &ost->kf, enc->time_base, in_picture, i);
if (ost->top_field_first >= 0)
in_picture->top_field_first = !!ost->top_field_first;
ret = submit_encode_frame(of, ost, in_picture);
if (ret == AVERROR_EOF)
break;

View file

@ -628,8 +628,12 @@ static void add_input_streams(const OptionsContext *o, Demuxer *d)
MATCH_PER_STREAM_OPT(codec_tags, str, codec_tag, ic, st);
if (codec_tag) {
uint32_t tag = strtol(codec_tag, &next, 0);
if (*next)
tag = AV_RL32(codec_tag);
if (*next) {
uint8_t buf[4] = { 0 };
memcpy(buf, codec_tag, FFMIN(sizeof(buf), strlen(codec_tag)));
tag = AV_RL32(buf);
}
st->codecpar->codec_tag = tag;
}

View file

@ -352,11 +352,13 @@ static int read_binary(const char *path, uint8_t **data, int *len)
*len = fsize;
return 0;
ret = 0;
fail:
avio_close(io);
av_freep(data);
*len = 0;
if (ret < 0) {
av_freep(data);
*len = 0;
}
return ret;
}

View file

@ -606,8 +606,11 @@ static OutputStream *new_output_stream(Muxer *mux, const OptionsContext *o,
MATCH_PER_STREAM_OPT(codec_tags, str, codec_tag, oc, st);
if (codec_tag) {
uint32_t tag = strtol(codec_tag, &next, 0);
if (*next)
tag = AV_RL32(codec_tag);
if (*next) {
uint8_t buf[4] = { 0 };
memcpy(buf, codec_tag, FFMIN(sizeof(buf), strlen(codec_tag)));
tag = AV_RL32(buf);
}
ost->st->codecpar->codec_tag = tag;
if (ost->enc_ctx)
ost->enc_ctx->codec_tag = tag;
@ -1819,11 +1822,11 @@ static int copy_metadata(Muxer *mux, AVFormatContext *ic,
parse_meta_type(mux, inspec, &type_in, &idx_in, &istream_spec);
parse_meta_type(mux, outspec, &type_out, &idx_out, &ostream_spec);
if (type_in == 'g' || type_out == 'g')
if (type_in == 'g' || type_out == 'g' || (!*outspec && !ic))
*metadata_global_manual = 1;
if (type_in == 's' || type_out == 's')
if (type_in == 's' || type_out == 's' || (!*outspec && !ic))
*metadata_streams_manual = 1;
if (type_in == 'c' || type_out == 'c')
if (type_in == 'c' || type_out == 'c' || (!*outspec && !ic))
*metadata_chapters_manual = 1;
/* ic is NULL when just disabling automatic mappings */
@ -2063,7 +2066,7 @@ static void parse_forced_key_frames(KeyframeForceCtx *kf, const Muxer *mux,
if (next)
*next++ = 0;
if (!memcmp(p, "chapters", 8)) {
if (strstr(p, "chapters") == p) {
AVChapter * const *ch = mux->fc->chapters;
unsigned int nb_ch = mux->fc->nb_chapters;
int j;

View file

@ -1998,6 +1998,8 @@ static int configure_audio_filters(VideoState *is, const char *afilters, int for
goto end;
if (force_output_format) {
av_bprint_clear(&bp);
av_channel_layout_describe_bprint(&is->audio_tgt.ch_layout, &bp);
sample_rates [0] = is->audio_tgt.freq;
if ((ret = av_opt_set_int(filt_asink, "all_channel_counts", 0, AV_OPT_SEARCH_CHILDREN)) < 0)
goto end;

View file

@ -887,6 +887,8 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *picture,
}
if (i >= CFRAME_BUFFER_COUNT) {
if (free_index < 0)
return AVERROR_INVALIDDATA;
i = free_index;
f->cfrm[i].id = id;
}

View file

@ -68,7 +68,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
unsigned char *planemap = c->planemap;
int ret;
if (buf_size < planes * height * 2)
if (buf_size < planes * height * (2 + 2*((avctx->width+128)/129)))
return AVERROR_INVALIDDATA;
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)

View file

@ -95,6 +95,7 @@ get_next:
duration in seconds is still correct (as is the number of bits in
the frame). */
if (avctx->codec_id != AV_CODEC_ID_AAC) {
#if CONFIG_AC3_PARSER
AC3HeaderInfo hdr, *phrd = &hdr;
int offset = ff_ac3_find_syncword(buf, buf_size);
@ -146,7 +147,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
if (hdr.bitstream_mode == 0x7 && hdr.channels > 1)
avctx->audio_service_type = AV_AUDIO_SERVICE_TYPE_KARAOKE;
bit_rate = hdr.bit_rate;
#endif
} else {
#if CONFIG_AAC_PARSER
AACADTSHeaderInfo hdr, *phrd = &hdr;
int ret = avpriv_adts_header_parse(&phrd, buf, buf_size);
@ -154,6 +157,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
return i;
bit_rate = hdr.bit_rate;
#endif
}
/* Calculate the average bit rate */

View file

@ -2856,8 +2856,8 @@ static void imdct_and_windowing_eld(AACContext *ac, SingleChannelElement *sce)
ac->mdct512_fn(ac->mdct512, buf, in, sizeof(INTFLOAT));
for (i = 0; i < n; i+=2) {
buf[i + 0] = -(USE_FIXED + 1)*buf[i + 0];
buf[i + 1] = (USE_FIXED + 1)*buf[i + 1];
buf[i + 0] = -(UINTFLOAT)(USE_FIXED + 1)*buf[i + 0];
buf[i + 1] = (UINTFLOAT)(USE_FIXED + 1)*buf[i + 1];
}
// Like with the regular IMDCT at this point we still have the middle half
// of a transform but with even symmetry on the left and odd symmetry on

View file

@ -34,7 +34,7 @@
#include "libavutil/common.h"
#include "libavutil/libm.h"
#include "libavutil/mathematics.h"
#include "libavutil/mem.h"
#include "libavutil/mem_internal.h"
#define NR_ALLPASS_BANDS20 30
#define NR_ALLPASS_BANDS34 50
#define PS_AP_LINKS 3

View file

@ -267,7 +267,7 @@ static av_cold void lame_window_init(AacPsyContext *ctx, AVCodecContext *avctx)
AacPsyChannel *pch = &ctx->ch[i];
if (avctx->flags & AV_CODEC_FLAG_QSCALE)
pch->attack_threshold = psy_vbr_map[avctx->global_quality / FF_QP2LAMBDA].st_lrm;
pch->attack_threshold = psy_vbr_map[av_clip(avctx->global_quality / FF_QP2LAMBDA, 0, 10)].st_lrm;
else
pch->attack_threshold = lame_calc_attack_threshold(avctx->bit_rate / avctx->ch_layout.nb_channels / 1000);

View file

@ -1579,11 +1579,11 @@ static int adpcm_decode_frame(AVCodecContext *avctx, AVFrame *frame,
nibble[0] = sign_extend(byte & 15, 4);
nibble[1] = sign_extend(byte >> 4, 4);
out[2+n*2] = (nibble[0]*(scale<<14) + (history[0]*29336) - (history[1]*13136)) >> 14;
out[2+n*2] = nibble[0]*scale + ((history[0]*3667 - history[1]*1642) >> 11);
history[1] = history[0];
history[0] = out[2+n*2];
out[2+n*2+1] = (nibble[1]*(scale<<14) + (history[0]*29336) - (history[1]*13136)) >> 14;
out[2+n*2+1] = nibble[1]*scale + ((history[0]*3667 - history[1]*1642) >> 11);
history[1] = history[0];
history[0] = out[2+n*2+1];
}

View file

@ -145,8 +145,6 @@ typedef struct APEPredictor64 {
uint64_t coeffsA[2][4]; ///< adaption coefficients
uint64_t coeffsB[2][5]; ///< adaption coefficients
int64_t historybuffer[HISTORY_SIZE + PREDICTOR_SIZE];
unsigned int sample_pos;
} APEPredictor64;
/** Decoder context */
@ -860,8 +858,6 @@ static void init_predictor_decoder(APEContext *ctx)
p64->lastA[0] = p64->lastA[1] = 0;
p->sample_pos = 0;
p64->sample_pos = 0;
}
/** Get inverse sign of integer (-1 for positive, 1 for negative and 0 for zero) */
@ -1170,7 +1166,8 @@ static void predictor_decode_mono_3930(APEContext *ctx, int count)
static av_always_inline int predictor_update_filter(APEPredictor64 *p,
const int decoded, const int filter,
const int delayA, const int delayB,
const int adaptA, const int adaptB)
const int adaptA, const int adaptB,
int compression_level)
{
int64_t predictionA, predictionB;
int32_t sign;
@ -1198,7 +1195,13 @@ static av_always_inline int predictor_update_filter(APEPredictor64 *p,
p->buf[delayB - 3] * p->coeffsB[filter][3] +
p->buf[delayB - 4] * p->coeffsB[filter][4];
p->lastA[filter] = decoded + ((int64_t)((uint64_t)predictionA + (predictionB >> 1)) >> 10);
if (compression_level < COMPRESSION_LEVEL_INSANE) {
predictionA = (int32_t)predictionA;
predictionB = (int32_t)predictionB;
p->lastA[filter] = (int32_t)(decoded + (unsigned)((int32_t)(predictionA + (predictionB >> 1)) >> 10));
} else {
p->lastA[filter] = decoded + ((int64_t)((uint64_t)predictionA + (predictionB >> 1)) >> 10);
}
p->filterA[filter] = p->lastA[filter] + ((int64_t)(p->filterA[filter] * 31ULL) >> 5);
sign = APESIGN(decoded);
@ -1226,10 +1229,12 @@ static void predictor_decode_stereo_3950(APEContext *ctx, int count)
while (count--) {
/* Predictor Y */
*decoded0 = predictor_update_filter(p, *decoded0, 0, YDELAYA, YDELAYB,
YADAPTCOEFFSA, YADAPTCOEFFSB);
YADAPTCOEFFSA, YADAPTCOEFFSB,
ctx->compression_level);
decoded0++;
*decoded1 = predictor_update_filter(p, *decoded1, 1, XDELAYA, XDELAYB,
XADAPTCOEFFSA, XADAPTCOEFFSB);
XADAPTCOEFFSA, XADAPTCOEFFSB,
ctx->compression_level);
decoded1++;
/* Combined */
@ -1611,13 +1616,24 @@ static int ape_decode_frame(AVCodecContext *avctx, AVFrame *frame,
s->samples -= blockstodecode;
if (avctx->err_recognition & AV_EF_CRCCHECK &&
s->fileversion >= 3900 && s->bps < 24) {
s->fileversion >= 3900) {
uint32_t crc = s->CRC_state;
const AVCRC *crc_tab = av_crc_get_table(AV_CRC_32_IEEE_LE);
int stride = s->bps == 24 ? 4 : (s->bps>>3);
int offset = s->bps == 24;
int bytes = s->bps >> 3;
for (i = 0; i < blockstodecode; i++) {
for (ch = 0; ch < s->channels; ch++) {
uint8_t *smp = frame->data[ch] + (i*(s->bps >> 3));
crc = av_crc(crc_tab, crc, smp, s->bps >> 3);
#if HAVE_BIGENDIAN
uint8_t *smp_native = frame->data[ch] + i*stride;
uint8_t smp[4];
for(int j = 0; j<stride; j++)
smp[j] = smp_native[stride-j-1];
#else
uint8_t *smp = frame->data[ch] + i*stride;
#endif
crc = av_crc(crc_tab, crc, smp+offset, bytes);
}
}

View file

@ -229,7 +229,7 @@ A .endif
.endif
// Begin loop
01:
1:
.if TOTAL_TAPS == 0
// Things simplify a lot in this case
// In fact this could be pipelined further if it's worth it...
@ -241,7 +241,7 @@ A .endif
str ST0, [PST, #-4]!
str ST0, [PST, #4 * (MAX_BLOCKSIZE + MAX_FIR_ORDER)]
str ST0, [PSAMP], #4 * MAX_CHANNELS
bne 01b
bne 1b
.else
.if \fir_taps & 1
.set LOAD_REG, 1
@ -333,7 +333,7 @@ T orr AC0, AC0, AC1
str ST3, [PST, #-4]!
str ST2, [PST, #4 * (MAX_BLOCKSIZE + MAX_FIR_ORDER)]
str ST3, [PSAMP], #4 * MAX_CHANNELS
bne 01b
bne 1b
.endif
b 99f

View file

@ -170,7 +170,7 @@ static uint8_t get_shear_params_valid(AV1DecContext *s, int idx)
int16_t alpha, beta, gamma, delta, divf, divs;
int64_t v, w;
int32_t *param = &s->cur_frame.gm_params[idx][0];
if (param[2] < 0)
if (param[2] <= 0)
return 0;
alpha = av_clip_int16(param[2] - (1 << AV1_WARPEDMODEL_PREC_BITS));
@ -675,7 +675,7 @@ static int set_context_with_sequence(AVCodecContext *avctx,
avctx->color_range =
seq->color_config.color_range ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG;
avctx->color_primaries = seq->color_config.color_primaries;
avctx->colorspace = seq->color_config.color_primaries;
avctx->colorspace = seq->color_config.matrix_coefficients;
avctx->color_trc = seq->color_config.transfer_characteristics;
switch (seq->color_config.chroma_sample_position) {

View file

@ -870,7 +870,7 @@ static int binkb_decode_plane(BinkContext *c, AVFrame *frame, GetBitContext *gb,
binkb_init_bundles(c);
ref_start = frame->data[plane_idx];
ref_end = frame->data[plane_idx] + (bh * frame->linesize[plane_idx] + bw) * 8;
ref_end = frame->data[plane_idx] + ((bh - 1) * frame->linesize[plane_idx] + bw - 1) * 8;
for (i = 0; i < 64; i++)
coordmap[i] = (i & 7) + (i >> 3) * stride;
@ -926,7 +926,7 @@ static int binkb_decode_plane(BinkContext *c, AVFrame *frame, GetBitContext *gb,
xoff = binkb_get_value(c, BINKB_SRC_X_OFF);
yoff = binkb_get_value(c, BINKB_SRC_Y_OFF) + ybias;
ref = dst + xoff + yoff * stride;
if (ref < ref_start || ref + 8*stride > ref_end) {
if (ref < ref_start || ref > ref_end) {
av_log(c->avctx, AV_LOG_WARNING, "Reference block is out of bounds\n");
} else if (ref + 8*stride < dst || ref >= dst + 8*stride) {
c->put_pixels_tab(dst, ref, stride, 8);
@ -942,7 +942,7 @@ static int binkb_decode_plane(BinkContext *c, AVFrame *frame, GetBitContext *gb,
xoff = binkb_get_value(c, BINKB_SRC_X_OFF);
yoff = binkb_get_value(c, BINKB_SRC_Y_OFF) + ybias;
ref = dst + xoff + yoff * stride;
if (ref < ref_start || ref + 8 * stride > ref_end) {
if (ref < ref_start || ref > ref_end) {
av_log(c->avctx, AV_LOG_WARNING, "Reference block is out of bounds\n");
} else if (ref + 8*stride < dst || ref >= dst + 8*stride) {
c->put_pixels_tab(dst, ref, stride, 8);
@ -974,7 +974,7 @@ static int binkb_decode_plane(BinkContext *c, AVFrame *frame, GetBitContext *gb,
xoff = binkb_get_value(c, BINKB_SRC_X_OFF);
yoff = binkb_get_value(c, BINKB_SRC_Y_OFF) + ybias;
ref = dst + xoff + yoff * stride;
if (ref < ref_start || ref + 8 * stride > ref_end) {
if (ref < ref_start || ref > ref_end) {
av_log(c->avctx, AV_LOG_WARNING, "Reference block is out of bounds\n");
} else if (ref + 8*stride < dst || ref >= dst + 8*stride) {
c->put_pixels_tab(dst, ref, stride, 8);

View file

@ -155,6 +155,7 @@ static int intlist_read(BonkContext *s, int *buf, int entries, int base_2_part)
int n_zeros = 0, step = 256, dominant = 0;
int pos = 0, level = 0;
BitCount *bits = s->bits;
int passes = 1;
memset(buf, 0, entries * sizeof(*buf));
if (base_2_part) {
@ -216,24 +217,28 @@ static int intlist_read(BonkContext *s, int *buf, int entries, int base_2_part)
x = 0;
n_zeros = 0;
for (i = 0; n_zeros < entries; i++) {
if (x >= max_x)
return AVERROR_INVALIDDATA;
if (pos >= entries) {
pos = 0;
level += 1 << low_bits;
level += passes << low_bits;
passes = 1;
if (bits[x].bit && bits[x].count > entries - n_zeros)
passes = bits[x].count / (entries - n_zeros);
}
if (level > 1 << 16)
return AVERROR_INVALIDDATA;
if (x >= max_x)
return AVERROR_INVALIDDATA;
if (buf[pos] >= level) {
if (bits[x].bit)
buf[pos] += 1 << low_bits;
buf[pos] += passes << low_bits;
else
n_zeros++;
bits[x].count--;
av_assert1(bits[x].count >= passes);
bits[x].count -= passes;
x += bits[x].count == 0;
}
@ -265,14 +270,14 @@ static inline int shift(int a, int b)
static int predictor_calc_error(int *k, int *state, int order, int error)
{
int i, x = error - shift_down(k[order-1] * state[order-1], LATTICE_SHIFT);
int i, x = error - (unsigned)shift_down(k[order-1] * (unsigned)state[order-1], LATTICE_SHIFT);
int *k_ptr = &(k[order-2]),
*state_ptr = &(state[order-2]);
for (i = order-2; i >= 0; i--, k_ptr--, state_ptr--) {
unsigned k_value = *k_ptr, state_value = *state_ptr;
x -= shift_down(k_value * state_value, LATTICE_SHIFT);
x -= (unsigned) shift_down(k_value * (unsigned)state_value, LATTICE_SHIFT);
state_ptr[1] = state_value + shift_down(k_value * x, LATTICE_SHIFT);
}

View file

@ -78,7 +78,7 @@ int64_t ff_dot_product(const int16_t *a, const int16_t *b, int length);
*
* @return value << offset, if offset>=0; value >> -offset - otherwise
*/
static inline int bidir_sal(int value, int offset)
static inline unsigned bidir_sal(unsigned value, int offset)
{
if(offset < 0) return value >> -offset;
else return value << offset;

View file

@ -70,6 +70,9 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe,
int buf_size = avpkt->size;
CamStudioContext *c = avctx->priv_data;
int ret;
int bpp = avctx->bits_per_coded_sample / 8;
int bugdelta = FFALIGN(avctx->width * bpp, 4) * avctx->height
- (avctx->width & ~3) * bpp * avctx->height;
if (buf_size < 2) {
av_log(avctx, AV_LOG_ERROR, "coded frame too small\n");
@ -83,7 +86,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe,
switch ((buf[0] >> 1) & 7) {
case 0: { // lzo compression
int outlen = c->decomp_size, inlen = buf_size - 2;
if (av_lzo1x_decode(c->decomp_buf, &outlen, &buf[2], &inlen) || outlen) {
if (av_lzo1x_decode(c->decomp_buf, &outlen, &buf[2], &inlen) || (outlen && outlen != bugdelta)) {
av_log(avctx, AV_LOG_ERROR, "error during lzo decompression\n");
return AVERROR_INVALIDDATA;
}
@ -92,7 +95,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe,
case 1: { // zlib compression
#if CONFIG_ZLIB
unsigned long dlen = c->decomp_size;
if (uncompress(c->decomp_buf, &dlen, &buf[2], buf_size - 2) != Z_OK || dlen != c->decomp_size) {
if (uncompress(c->decomp_buf, &dlen, &buf[2], buf_size - 2) != Z_OK || (dlen != c->decomp_size && dlen != c->decomp_size - bugdelta)) {
av_log(avctx, AV_LOG_ERROR, "error during zlib decompression\n");
return AVERROR_INVALIDDATA;
}

View file

@ -140,7 +140,7 @@ static int extract_packet_props(AVCodecInternal *avci, const AVPacket *pkt)
if (pkt) {
ret = av_packet_copy_props(avci->last_pkt_props, pkt);
if (!ret)
avci->last_pkt_props->opaque = (void *)(intptr_t)pkt->size; // Needed for ff_decode_frame_props().
avci->last_pkt_props->stream_index = pkt->size; // Needed for ff_decode_frame_props().
}
return ret;
}
@ -461,7 +461,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
pkt->dts = AV_NOPTS_VALUE;
if (!(codec->caps_internal & FF_CODEC_CAP_SETS_FRAME_PROPS)) {
// See extract_packet_props() comment.
avci->last_pkt_props->opaque = (void *)((intptr_t)avci->last_pkt_props->opaque - consumed);
avci->last_pkt_props->stream_index = avci->last_pkt_props->stream_index - consumed;
avci->last_pkt_props->pts = AV_NOPTS_VALUE;
avci->last_pkt_props->dts = AV_NOPTS_VALUE;
}
@ -1355,7 +1355,7 @@ int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame)
int ret = ff_decode_frame_props_from_pkt(avctx, frame, pkt);
if (ret < 0)
return ret;
frame->pkt_size = (int)(intptr_t)pkt->opaque;
frame->pkt_size = pkt->stream_index;
}
#if FF_API_REORDERED_OPAQUE
FF_DISABLE_DEPRECATION_WARNINGS

View file

@ -157,7 +157,7 @@ static inline uint64_t get_ue_coef(GetBitContext *gb, const AVDOVIRpuDataHeader
case RPU_COEFF_FLOAT:
fpart.u32 = get_bits_long(gb, 32);
return fpart.f32 * (1 << hdr->coef_log2_denom);
return fpart.f32 * (1LL << hdr->coef_log2_denom);
}
return 0; /* unreachable */
@ -176,7 +176,7 @@ static inline int64_t get_se_coef(GetBitContext *gb, const AVDOVIRpuDataHeader *
case RPU_COEFF_FLOAT:
fpart.u32 = get_bits_long(gb, 32);
return fpart.f32 * (1 << hdr->coef_log2_denom);
return fpart.f32 * (1LL << hdr->coef_log2_denom);
}
return 0; /* unreachable */

View file

@ -444,7 +444,7 @@ static int dpcm_decode_frame(AVCodecContext *avctx, AVFrame *frame,
if (n & 0x80)
s->sample[idx] = sign_extend((n & 0x7f) << 9, 16);
else
s->sample[idx] += s->scale * wady_table[n & 0x7f];
s->sample[idx] += s->scale * (unsigned)wady_table[n & 0x7f];
*output_samples++ = av_clip_int16(s->sample[idx]);
idx ^= stereo;
}

View file

@ -376,7 +376,8 @@ static int encode_dvd_subtitles(AVCodecContext *avctx,
x2 = vrect.x + vrect.w - 1;
y2 = vrect.y + vrect.h - 1;
if (x2 > avctx->width || y2 > avctx->height) {
if ((avctx->width > 0 && x2 > avctx->width) ||
(avctx->height > 0 && y2 > avctx->height)) {
av_log(avctx, AV_LOG_ERROR, "canvas_size(%d:%d) is too small(%d:%d) for render\n",
avctx->width, avctx->height, x2, y2);
ret = AVERROR(EINVAL);

View file

@ -104,7 +104,9 @@ static av_cold int dvvideo_encode_init(AVCodecContext *avctx)
ff_fdctdsp_init(&fdsp, avctx);
ff_me_cmp_init(&mecc, avctx);
ff_pixblockdsp_init(&pdsp, avctx);
ff_set_cmp(&mecc, mecc.ildct_cmp, avctx->ildct_cmp);
ret = ff_set_cmp(&mecc, mecc.ildct_cmp, avctx->ildct_cmp);
if (ret < 0)
return AVERROR(EINVAL);
s->get_pixels = pdsp.get_pixels;
s->ildct_cmp = mecc.ildct_cmp[5];

View file

@ -89,11 +89,6 @@ static CodeBook unpack_codebook(GetBitContext* gb, unsigned depth,
unsigned i, j;
CodeBook cb = { 0 };
if (size >= INT_MAX / 34 || get_bits_left(gb) < size * 34)
return cb;
if (size >= INT_MAX / sizeof(MacroBlock))
return cb;
cb.blocks = av_malloc(size ? size * sizeof(MacroBlock) : 1);
if (!cb.blocks)
return cb;
@ -163,7 +158,7 @@ static MacroBlock decode_macroblock(Escape124Context* s, GetBitContext* gb,
// This condition can occur with invalid bitstreams and
// *codebook_index == 2
if (block_index >= s->codebooks[*codebook_index].size)
if (block_index >= s->codebooks[*codebook_index].size || !s->codebooks[*codebook_index].blocks)
return (MacroBlock) { { 0 } };
return s->codebooks[*codebook_index].blocks[block_index];
@ -225,7 +220,7 @@ static int escape124_decode_frame(AVCodecContext *avctx, AVFrame *frame,
// represent a lower bound of the space needed for skipped superblocks. Non
// skipped SBs need more space.
if (get_bits_left(&gb) < 64 + s->num_superblocks * 23LL / 4320)
return -1;
return AVERROR_INVALIDDATA;
frame_flags = get_bits_long(&gb, 32);
frame_size = get_bits_long(&gb, 32);
@ -242,7 +237,7 @@ static int escape124_decode_frame(AVCodecContext *avctx, AVFrame *frame,
if ((ret = av_frame_ref(frame, s->frame)) < 0)
return ret;
return frame_size;
return 0;
}
for (i = 0; i < 3; i++) {
@ -276,9 +271,14 @@ static int escape124_decode_frame(AVCodecContext *avctx, AVFrame *frame,
}
av_freep(&s->codebooks[i].blocks);
if (cb_size >= INT_MAX / 34 || get_bits_left(&gb) < (int)cb_size * 34)
return AVERROR_INVALIDDATA;
if (cb_size >= INT_MAX / sizeof(MacroBlock))
return AVERROR_INVALIDDATA;
s->codebooks[i] = unpack_codebook(&gb, cb_depth, cb_size);
if (!s->codebooks[i].blocks)
return -1;
return AVERROR(ENOMEM);
}
}
@ -371,7 +371,7 @@ static int escape124_decode_frame(AVCodecContext *avctx, AVFrame *frame,
*got_frame = 1;
return frame_size;
return 0;
}

View file

@ -334,7 +334,10 @@ static int huf_unpack_enc_table(GetByteContext *gb,
return ret;
for (; im <= iM; im++) {
uint64_t l = freq[im] = get_bits(&gbit, 6);
int l;
if (get_bits_left(&gbit) < 6)
return AVERROR_INVALIDDATA;
l = freq[im] = get_bits(&gbit, 6);
if (l == LONG_ZEROCODE_RUN) {
int zerun = get_bits(&gbit, 8) + SHORTEST_LONG_RUN;
@ -1930,8 +1933,10 @@ static int decode_header(EXRContext *s, AVFrame *frame)
bytestream2_get_buffer(gb, key, FFMIN(sizeof(key) - 1, var_size));
if (strncmp("scanlineimage", key, var_size) &&
strncmp("tiledimage", key, var_size))
return AVERROR_PATCHWELCOME;
strncmp("tiledimage", key, var_size)) {
ret = AVERROR_PATCHWELCOME;
goto fail;
}
continue;
} else if ((var_size = check_header_variable(s, "preview",
@ -1939,12 +1944,16 @@ static int decode_header(EXRContext *s, AVFrame *frame)
uint32_t pw = bytestream2_get_le32(gb);
uint32_t ph = bytestream2_get_le32(gb);
uint64_t psize = pw * ph;
if (psize > INT64_MAX / 4)
return AVERROR_INVALIDDATA;
if (psize > INT64_MAX / 4) {
ret = AVERROR_INVALIDDATA;
goto fail;
}
psize *= 4;
if ((int64_t)psize >= bytestream2_get_bytes_left(gb))
return AVERROR_INVALIDDATA;
if ((int64_t)psize >= bytestream2_get_bytes_left(gb)) {
ret = AVERROR_INVALIDDATA;
goto fail;
}
bytestream2_skip(gb, psize);

View file

@ -475,6 +475,11 @@ static int read_extra_header(FFV1Context *f)
return AVERROR_INVALIDDATA;
}
if (f->num_h_slices > MAX_SLICES / f->num_v_slices) {
av_log(f->avctx, AV_LOG_ERROR, "slice count unsupported\n");
return AVERROR_PATCHWELCOME;
}
f->quant_table_count = get_symbol(c, state, 0);
if (f->quant_table_count > (unsigned)MAX_QUANT_TABLES || !f->quant_table_count) {
av_log(f->avctx, AV_LOG_ERROR, "quant table count %d is invalid\n", f->quant_table_count);

View file

@ -366,19 +366,19 @@ static int decode_subframe_fixed(FLACContext *s, int32_t *decoded,
break; \
case 1: \
for (int i = pred_order; i < blocksize; i++) \
decoded[i] = (int64_t)residual[i] + (int64_t)decoded[i-1];\
decoded[i] = (uint64_t)residual[i] + (uint64_t)decoded[i-1];\
break; \
case 2: \
for (int i = pred_order; i < blocksize; i++) \
decoded[i] = (int64_t)residual[i] + 2*(int64_t)decoded[i-1] - (int64_t)decoded[i-2]; \
decoded[i] = (uint64_t)residual[i] + 2*(uint64_t)decoded[i-1] - (uint64_t)decoded[i-2]; \
break; \
case 3: \
for (int i = pred_order; i < blocksize; i++) \
decoded[i] = (int64_t)residual[i] + 3*(int64_t)decoded[i-1] - 3*(int64_t)decoded[i-2] + (int64_t)decoded[i-3]; \
decoded[i] = (uint64_t)residual[i] + 3*(uint64_t)decoded[i-1] - 3*(uint64_t)decoded[i-2] + (uint64_t)decoded[i-3]; \
break; \
case 4: \
for (int i = pred_order; i < blocksize; i++) \
decoded[i] = (int64_t)residual[i] + 4*(int64_t)decoded[i-1] - 6*(int64_t)decoded[i-2] + 4*(int64_t)decoded[i-3] - (int64_t)decoded[i-4]; \
decoded[i] = (uint64_t)residual[i] + 4*(uint64_t)decoded[i-1] - 6*(uint64_t)decoded[i-2] + 4*(uint64_t)decoded[i-3] - (uint64_t)decoded[i-4]; \
break; \
default: \
av_log(s->avctx, AV_LOG_ERROR, "illegal pred order %d\n", pred_order); \
@ -513,7 +513,7 @@ static int decode_subframe_lpc_33bps(FLACContext *s, int64_t *decoded,
for (i = pred_order; i < s->blocksize; i++, decoded++) {
int64_t sum = 0;
for (j = 0; j < pred_order; j++)
sum += (int64_t)coeffs[j] * decoded[j];
sum += (int64_t)coeffs[j] * (uint64_t)decoded[j];
decoded[j] = residual[i] + (sum >> qlevel);
}
@ -706,10 +706,10 @@ static void decorrelate_33bps(int ch_mode, int32_t **decoded, int64_t *decoded_3
int i;
if (ch_mode == FLAC_CHMODE_LEFT_SIDE ) {
for (i = 0; i < len; i++)
decoded[1][i] = decoded[0][i] - decoded_33bps[i];
decoded[1][i] = decoded[0][i] - (uint64_t)decoded_33bps[i];
} else if (ch_mode == FLAC_CHMODE_RIGHT_SIDE ) {
for (i = 0; i < len; i++)
decoded[0][i] = decoded[1][i] + decoded_33bps[i];
decoded[0][i] = decoded[1][i] + (uint64_t)decoded_33bps[i];
} else if (ch_mode == FLAC_CHMODE_MID_SIDE ) {
for (i = 0; i < len; i++) {
uint64_t a = decoded[0][i];

View file

@ -145,7 +145,8 @@ typedef struct G2MContext {
int got_header;
uint8_t *framebuf;
int framebuf_stride, old_width, old_height;
int framebuf_stride;
unsigned int framebuf_allocated;
uint8_t *synth_tile, *jpeg_tile, *epic_buf, *epic_buf_base;
int tile_stride, epic_buf_stride, old_tile_w, old_tile_h;
@ -1160,14 +1161,13 @@ static int g2m_init_buffers(G2MContext *c)
{
int aligned_height;
if (!c->framebuf || c->old_width < c->width || c->old_height < c->height) {
c->framebuf_stride = FFALIGN(c->width + 15, 16) * 3;
aligned_height = c->height + 15;
av_free(c->framebuf);
c->framebuf = av_calloc(c->framebuf_stride, aligned_height);
if (!c->framebuf)
return AVERROR(ENOMEM);
}
c->framebuf_stride = FFALIGN(c->width + 15, 16) * 3;
aligned_height = c->height + 15;
av_fast_mallocz(&c->framebuf, &c->framebuf_allocated, c->framebuf_stride * aligned_height);
if (!c->framebuf)
return AVERROR(ENOMEM);
if (!c->synth_tile || !c->jpeg_tile ||
(c->compression == 2 && !c->epic_buf_base) ||
c->old_tile_w < c->tile_width ||
@ -1617,6 +1617,7 @@ static av_cold int g2m_decode_end(AVCodecContext *avctx)
av_freep(&c->jpeg_tile);
av_freep(&c->cursor);
av_freep(&c->framebuf);
c->framebuf_allocated = 0;
return 0;
}

View file

@ -353,7 +353,7 @@ static int16_t long_term_filter(AudioDSPContext *adsp, int pitch_delay_int,
if (tmp > 0)
L_temp0 >>= tmp;
else
L_temp1 >>= -tmp;
L_temp1 >>= FFMIN(-tmp, 31);
/* Check if longer filter increases the values of R'(k). */
if (L_temp1 > L_temp0) {
@ -581,7 +581,7 @@ void ff_g729_postfilter(AudioDSPContext *adsp, int16_t* ht_prev_data, int* voici
int16_t ff_g729_adaptive_gain_control(int gain_before, int gain_after, int16_t *speech,
int subframe_size, int16_t gain_prev)
{
int gain; // (3.12)
unsigned gain; // (3.12)
int n;
int exp_before, exp_after;
@ -603,7 +603,7 @@ int16_t ff_g729_adaptive_gain_control(int gain_before, int gain_after, int16_t *
gain = ((gain_before - gain_after) << 14) / gain_after + 0x4000;
gain = bidir_sal(gain, exp_after - exp_before);
}
gain = av_clip_int16(gain);
gain = FFMIN(gain, 32767);
gain = (gain * G729_AGC_FAC1 + 0x4000) >> 15; // gain * (1-0.9875)
} else
gain = 0;

View file

@ -281,7 +281,7 @@ static int decode_slice(MpegEncContext *s)
ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y,
s->mb_x, s->mb_y, ER_MB_ERROR & part_mask);
if (s->avctx->err_recognition & AV_EF_IGNORE_ERR)
if ((s->avctx->err_recognition & AV_EF_IGNORE_ERR) && get_bits_left(&s->gb) > 0)
continue;
return AVERROR_INVALIDDATA;
}

View file

@ -123,7 +123,7 @@ static inline int get_nalsize(int nal_length_size, const uint8_t *buf,
if (*buf_index >= buf_size - nal_length_size) {
// the end of the buffer is reached, refill it
return AVERROR(EAGAIN);
return AVERROR_INVALIDDATA;
}
for (i = 0; i < nal_length_size; i++)

View file

@ -646,10 +646,10 @@ static int h264_parse(AVCodecParserContext *s,
int64_t num = time_base.num * (int64_t)avctx->pkt_timebase.den;
if (s->dts != AV_NOPTS_VALUE) {
// got DTS from the stream, update reference timestamp
p->reference_dts = s->dts - av_rescale(s->dts_ref_dts_delta, num, den);
p->reference_dts = av_sat_sub64(s->dts, av_rescale(s->dts_ref_dts_delta, num, den));
} else if (p->reference_dts != AV_NOPTS_VALUE) {
// compute DTS based on reference timestamp
s->dts = p->reference_dts + av_rescale(s->dts_ref_dts_delta, num, den);
s->dts = av_sat_add64(p->reference_dts, av_rescale(s->dts_ref_dts_delta, num, den));
}
if (p->reference_dts != AV_NOPTS_VALUE && s->pts == AV_NOPTS_VALUE)

View file

@ -109,6 +109,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
float scale = 1.f / 8.f;
unsigned b, chunk;
int version, ret;
unsigned hfr_group_count;
avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
c->crc_table = av_crc_get_table(AV_CRC_16_ANSI);
@ -229,11 +230,12 @@ static av_cold int decode_init(AVCodecContext *avctx)
if (c->total_band_count < c->base_band_count)
return AVERROR_INVALIDDATA;
c->hfr_group_count = ceil2(c->total_band_count - (c->base_band_count + c->stereo_band_count),
hfr_group_count = ceil2(c->total_band_count - (c->base_band_count + c->stereo_band_count),
c->bands_per_hfr_group);
if (c->base_band_count + c->stereo_band_count + (unsigned long)c->hfr_group_count > 128ULL)
if (c->base_band_count + c->stereo_band_count + (uint64_t)hfr_group_count > 128ULL)
return AVERROR_INVALIDDATA;
c->hfr_group_count = hfr_group_count;
for (int i = 0; i < avctx->ch_layout.nb_channels; i++) {
c->ch[i].chan_type = r[i];

View file

@ -105,7 +105,7 @@ static int hevc_parse_slice_header(AVCodecParserContext *s, H2645NAL *nal,
den = ps->sps->vui.vui_time_scale;
}
if (num != 0 && den != 0)
if (num > 0 && den > 0)
av_reduce(&avctx->framerate.den, &avctx->framerate.num,
num, den, 1 << 30);

View file

@ -374,7 +374,7 @@ static void export_stream_params(HEVCContext *s, const HEVCSPS *sps)
den = sps->vui.vui_time_scale;
}
if (num != 0 && den != 0)
if (num > 0 && den > 0)
av_reduce(&avctx->framerate.den, &avctx->framerate.num,
num, den, 1 << 30);
}
@ -1523,7 +1523,8 @@ static void luma_mc_uni(HEVCLocalContext *lc, uint8_t *dst, ptrdiff_t dststride,
if (x_off < QPEL_EXTRA_BEFORE || y_off < QPEL_EXTRA_AFTER ||
x_off >= pic_width - block_w - QPEL_EXTRA_AFTER ||
y_off >= pic_height - block_h - QPEL_EXTRA_AFTER) {
y_off >= pic_height - block_h - QPEL_EXTRA_AFTER ||
ref == s->frame) {
const ptrdiff_t edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->ps.sps->pixel_shift;
int offset = QPEL_EXTRA_BEFORE * srcstride + (QPEL_EXTRA_BEFORE << s->ps.sps->pixel_shift);
int buf_offset = QPEL_EXTRA_BEFORE * edge_emu_stride + (QPEL_EXTRA_BEFORE << s->ps.sps->pixel_shift);
@ -1673,6 +1674,7 @@ static void chroma_mc_uni(HEVCLocalContext *lc, uint8_t *dst0,
intptr_t my = av_mod_uintp2(mv->y, 2 + vshift);
intptr_t _mx = mx << (1 - hshift);
intptr_t _my = my << (1 - vshift);
int emu = src0 == s->frame->data[1] || src0 == s->frame->data[2];
x_off += mv->x >> (2 + hshift);
y_off += mv->y >> (2 + vshift);
@ -1680,7 +1682,8 @@ static void chroma_mc_uni(HEVCLocalContext *lc, uint8_t *dst0,
if (x_off < EPEL_EXTRA_BEFORE || y_off < EPEL_EXTRA_AFTER ||
x_off >= pic_width - block_w - EPEL_EXTRA_AFTER ||
y_off >= pic_height - block_h - EPEL_EXTRA_AFTER) {
y_off >= pic_height - block_h - EPEL_EXTRA_AFTER ||
emu) {
const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->ps.sps->pixel_shift;
int offset0 = EPEL_EXTRA_BEFORE * (srcstride + (1 << s->ps.sps->pixel_shift));
int buf_offset0 = EPEL_EXTRA_BEFORE *
@ -1920,13 +1923,13 @@ static void hls_prediction_unit(HEVCLocalContext *lc, int x0, int y0,
if (current_mv.pred_flag & PF_L0) {
ref0 = refPicList[0].ref[current_mv.ref_idx[0]];
if (!ref0)
if (!ref0 || !ref0->frame->data[0])
return;
hevc_await_progress(s, ref0, &current_mv.mv[0], y0, nPbH);
}
if (current_mv.pred_flag & PF_L1) {
ref1 = refPicList[1].ref[current_mv.ref_idx[1]];
if (!ref1)
if (!ref1 || !ref1->frame->data[0])
return;
hevc_await_progress(s, ref1, &current_mv.mv[1], y0, nPbH);
}
@ -2590,6 +2593,11 @@ static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *hevc_lclist,
if (ret < 0)
goto error;
hls_sao_param(lc, x_ctb >> s->ps.sps->log2_ctb_size, y_ctb >> s->ps.sps->log2_ctb_size);
s->deblock[ctb_addr_rs].beta_offset = s->sh.beta_offset;
s->deblock[ctb_addr_rs].tc_offset = s->sh.tc_offset;
s->filter_slice_edges[ctb_addr_rs] = s->sh.slice_loop_filter_across_slices_enabled_flag;
more_data = hls_coding_quadtree(lc, x_ctb, y_ctb, s->ps.sps->log2_ctb_size, 0);
if (more_data < 0) {

View file

@ -695,9 +695,9 @@ static void decode_422_bitstream(HYuvDecContext *s, int count)
/* TODO instead of restarting the read when the code isn't in the first level
* of the joint table, jump into the 2nd level of the individual table. */
#define READ_2PIX_PLANE16(dst0, dst1, plane){\
dst0 = get_vlc2(&s->gb, s->vlc[plane].table, VLC_BITS, 3)<<2;\
dst0 = get_vlc2(&s->gb, s->vlc[plane].table, VLC_BITS, 3)*4;\
dst0 += get_bits(&s->gb, 2);\
dst1 = get_vlc2(&s->gb, s->vlc[plane].table, VLC_BITS, 3)<<2;\
dst1 = get_vlc2(&s->gb, s->vlc[plane].table, VLC_BITS, 3)*4;\
dst1 += get_bits(&s->gb, 2);\
}
static void decode_plane_bitstream(HYuvDecContext *s, int width, int plane)
@ -755,7 +755,7 @@ static void decode_plane_bitstream(HYuvDecContext *s, int width, int plane)
}
}
if( width&1 && get_bits_left(&s->gb)>0 ) {
int dst = get_vlc2(&s->gb, s->vlc[plane].table, VLC_BITS, 3)<<2;
int dst = (unsigned)get_vlc2(&s->gb, s->vlc[plane].table, VLC_BITS, 3)<<2;
s->temp16[0][width-1] = dst + get_bits(&s->gb, 2);
}
}

View file

@ -171,6 +171,9 @@ static av_cold int allocate_frame_buffers(Indeo3DecodeContext *ctx,
int luma_size, chroma_size;
ptrdiff_t luma_pitch, chroma_pitch;
luma_width = FFALIGN(luma_width , 2);
luma_height = FFALIGN(luma_height, 2);
if (luma_width < 16 || luma_width > 640 ||
luma_height < 16 || luma_height > 480 ||
luma_width & 1 || luma_height & 1) {

View file

@ -721,11 +721,10 @@ static void encode_cblk(Jpeg2000EncoderContext *s, Jpeg2000T1Context *t1, Jpeg20
if (max == 0){
cblk->nonzerobits = 0;
bpno = 0;
} else{
cblk->nonzerobits = av_log2(max) + 1 - NMSEDEC_FRACBITS;
bpno = cblk->nonzerobits - 1;
}
bpno = cblk->nonzerobits - 1;
cblk->data[0] = 0;
ff_mqc_initenc(&t1->mqc, cblk->data + 1);
@ -1531,6 +1530,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
int tileno, ret;
Jpeg2000EncoderContext *s = avctx->priv_data;
uint8_t *chunkstart, *jp2cstart, *jp2hstart;
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
if ((ret = ff_alloc_packet(avctx, pkt, avctx->width*avctx->height*9 + AV_INPUT_BUFFER_MIN_SIZE)) < 0)
return ret;
@ -1543,7 +1543,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
s->lambda = s->picture->quality * LAMBDA_SCALE;
if (avctx->pix_fmt == AV_PIX_FMT_BGR48 || avctx->pix_fmt == AV_PIX_FMT_GRAY16)
if (s->cbps[0] > 8)
copy_frame_16(s);
else
copy_frame_8(s);
@ -1587,7 +1587,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
bytestream_put_byte(&s->buf, 1);
bytestream_put_byte(&s->buf, 0);
bytestream_put_byte(&s->buf, 0);
if (avctx->pix_fmt == AV_PIX_FMT_RGB24 || avctx->pix_fmt == AV_PIX_FMT_PAL8) {
if ((desc->flags & AV_PIX_FMT_FLAG_RGB) || avctx->pix_fmt == AV_PIX_FMT_PAL8) {
bytestream_put_be32(&s->buf, 16);
} else if (s->ncomponents == 1) {
bytestream_put_be32(&s->buf, 17);
@ -1717,6 +1717,7 @@ static av_cold int j2kenc_init(AVCodecContext *avctx)
Jpeg2000EncoderContext *s = avctx->priv_data;
Jpeg2000CodingStyle *codsty = &s->codsty;
Jpeg2000QuantStyle *qntsty = &s->qntsty;
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
s->avctx = avctx;
av_log(s->avctx, AV_LOG_DEBUG, "init\n");
@ -1729,7 +1730,7 @@ static av_cold int j2kenc_init(AVCodecContext *avctx)
if (avctx->pix_fmt == AV_PIX_FMT_PAL8 && (s->pred != FF_DWT97_INT || s->format != CODEC_JP2)) {
av_log(s->avctx, AV_LOG_WARNING, "Forcing lossless jp2 for pal8\n");
s->pred = FF_DWT97_INT;
s->pred = 1;
s->format = CODEC_JP2;
}
@ -1759,20 +1760,13 @@ static av_cold int j2kenc_init(AVCodecContext *avctx)
s->width = avctx->width;
s->height = avctx->height;
s->ncomponents = desc->nb_components;
for (i = 0; i < 3; i++) {
if (avctx->pix_fmt == AV_PIX_FMT_GRAY16 || avctx->pix_fmt == AV_PIX_FMT_RGB48)
s->cbps[i] = 16;
else
s->cbps[i] = 8;
s->cbps[i] = desc->comp[i].depth;
}
if (avctx->pix_fmt == AV_PIX_FMT_RGB24 || avctx->pix_fmt == AV_PIX_FMT_RGB48){
s->ncomponents = 3;
} else if (avctx->pix_fmt == AV_PIX_FMT_GRAY8 || avctx->pix_fmt == AV_PIX_FMT_PAL8 || avctx->pix_fmt == AV_PIX_FMT_GRAY16){
s->ncomponents = 1;
} else{ // planar YUV
if ((desc->flags & AV_PIX_FMT_FLAG_PLANAR) && s->ncomponents > 1) {
s->planar = 1;
s->ncomponents = 3;
ret = av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt,
s->chroma_shift, s->chroma_shift + 1);
if (ret)
@ -1810,7 +1804,7 @@ static const AVOption options[] = {
{ "tile_height", "Tile Height", OFFSET(tile_height), AV_OPT_TYPE_INT, { .i64 = 256 }, 1, 1<<30, VE, },
{ "pred", "DWT Type", OFFSET(pred), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE, "pred" },
{ "dwt97int", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, VE, "pred" },
{ "dwt53", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, VE, "pred" },
{ "dwt53", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, INT_MIN, INT_MAX, VE, "pred" },
{ "sop", "SOP marker", OFFSET(sop), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE, },
{ "eph", "EPH marker", OFFSET(eph), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE, },
{ "prog", "Progression Order", OFFSET(prog), AV_OPT_TYPE_INT, { .i64 = 0 }, JPEG2000_PGOD_LRCP, JPEG2000_PGOD_CPRL, VE, "prog" },

View file

@ -323,6 +323,16 @@ static int get_siz(Jpeg2000DecoderContext *s)
return AVERROR_INVALIDDATA;
}
if (s->image_offset_x >= s->width || s->image_offset_y >= s->height) {
av_log(s->avctx, AV_LOG_ERROR, "image offsets outside image");
return AVERROR_INVALIDDATA;
}
if (s->reduction_factor && (s->image_offset_x || s->image_offset_y) ){
av_log(s->avctx, AV_LOG_ERROR, "reduction factor with image offsets is not fully implemented");
return AVERROR_PATCHWELCOME;
}
s->ncomponents = ncomponents;
if (s->tile_width <= 0 || s->tile_height <= 0) {
@ -388,7 +398,7 @@ static int get_siz(Jpeg2000DecoderContext *s)
dimy = FFMAX(dimy, ff_jpeg2000_ceildiv(o_dimy, s->cdy[i]));
}
ret = ff_set_dimensions(s->avctx, dimx, dimy);
ret = ff_set_dimensions(s->avctx, dimx << s->avctx->lowres, dimy << s->avctx->lowres);
if (ret < 0)
return ret;
@ -2471,6 +2481,14 @@ static av_cold int jpeg2000_decode_init(AVCodecContext *avctx)
{
Jpeg2000DecoderContext *s = avctx->priv_data;
if (avctx->lowres)
av_log(avctx, AV_LOG_WARNING, "lowres is overriden by reduction_factor but set anyway\n");
if (!s->reduction_factor && avctx->lowres < JPEG2000_MAX_RESLEVELS) {
s->reduction_factor = avctx->lowres;
}
if (avctx->lowres != s->reduction_factor && avctx->lowres)
return AVERROR(EINVAL);
ff_jpeg2000dsp_init(&s->dsp);
ff_jpeg2000_init_tier1_luts();

View file

@ -382,6 +382,19 @@ int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near,
state->T3 = s->t3;
state->reset = s->reset;
ff_jpegls_reset_coding_parameters(state, 0);
/* Testing parameters here, we cannot test in LSE or SOF because
* these interdepend and are allowed in either order
*/
if (state->maxval >= (1<<state->bpp) ||
state->T1 > state->T2 ||
state->T2 > state->T3 ||
state->T3 > state->maxval ||
state->reset > FFMAX(255, state->maxval)) {
ret = AVERROR_INVALIDDATA;
goto end;
}
ff_jpegls_init_state(state);
if (s->bits <= 8)

View file

@ -152,6 +152,8 @@ static int zlib_decomp(AVCodecContext *avctx, const uint8_t *src, int src_len, i
if (expected != (unsigned int)zstream->total_out) {
av_log(avctx, AV_LOG_ERROR, "Decoded size differs (%d != %lu)\n",
expected, zstream->total_out);
if (expected > (unsigned int)zstream->total_out)
return (unsigned int)zstream->total_out;
return AVERROR_UNKNOWN;
}
return zstream->total_out;
@ -169,8 +171,8 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
int row, col;
unsigned char *encoded = avpkt->data, *outptr;
uint8_t *y_out, *u_out, *v_out;
unsigned int width = avctx->width; // Real image width
unsigned int height = avctx->height; // Real image height
int width = avctx->width; // Real image width
int height = avctx->height; // Real image height
unsigned int mszh_dlen;
unsigned char yq, y1q, uq, vq;
int uqvq, ret;
@ -227,16 +229,19 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
break;
case COMP_MSZH_NOCOMP: {
int bppx2;
int aligned_width = width;
switch (c->imgtype) {
case IMGTYPE_YUV111:
case IMGTYPE_RGB24:
bppx2 = 6;
break;
case IMGTYPE_YUV422:
aligned_width &= ~3;
case IMGTYPE_YUV211:
bppx2 = 4;
break;
case IMGTYPE_YUV411:
aligned_width &= ~3;
case IMGTYPE_YUV420:
bppx2 = 3;
break;
@ -244,7 +249,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
bppx2 = 0; // will error out below
break;
}
if (len < ((width * height * bppx2) >> 1))
if (len < ((aligned_width * height * bppx2) >> 1))
return AVERROR_INVALIDDATA;
break;
}
@ -276,12 +281,13 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
ret = zlib_decomp(avctx, buf + 8 + mthread_inlen, len - 8 - mthread_inlen,
mthread_outlen, mthread_outlen);
if (ret < 0) return ret;
len = c->decomp_size;
} else {
int ret = zlib_decomp(avctx, buf, len, 0, c->decomp_size);
if (ret < 0) return ret;
len = ret;
}
encoded = c->decomp_buf;
len = c->decomp_size;
break;
#endif
default:
@ -309,8 +315,8 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
}
break;
case IMGTYPE_YUV422:
pixel_ptr = 0;
for (row = 0; row < height; row++) {
pixel_ptr = row * width * 2;
yq = uq = vq =0;
for (col = 0; col < width/4; col++) {
encoded[pixel_ptr] = yq -= encoded[pixel_ptr];
@ -326,8 +332,8 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
}
break;
case IMGTYPE_YUV411:
pixel_ptr = 0;
for (row = 0; row < height; row++) {
pixel_ptr = row * width / 2 * 3;
yq = uq = vq =0;
for (col = 0; col < width/4; col++) {
encoded[pixel_ptr] = yq -= encoded[pixel_ptr];
@ -403,6 +409,11 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
v_out[ col >> 1 ] = *encoded++ + 128;
v_out[(col >> 1) + 1] = *encoded++ + 128;
}
if (col && col < width) {
u_out[ col >> 1 ] = u_out[(col>>1) - 1];
v_out[ col >> 1 ] = v_out[(col>>1) - 1];
}
y_out -= frame->linesize[0];
u_out -= frame->linesize[1];
v_out -= frame->linesize[2];
@ -424,6 +435,10 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
u_out[col >> 2] = *encoded++ + 128;
v_out[col >> 2] = *encoded++ + 128;
}
if (col && col < width) {
u_out[col >> 2] = u_out[(col>>2) - 1];
v_out[col >> 2] = v_out[(col>>2) - 1];
}
y_out -= frame->linesize[0];
u_out -= frame->linesize[1];
v_out -= frame->linesize[2];
@ -481,6 +496,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
FFALIGN(avctx->height, 4);
unsigned int max_decomp_size;
int subsample_h, subsample_v;
int partial_h_supported = 0;
if (avctx->extradata_size < 8) {
av_log(avctx, AV_LOG_ERROR, "Extradata size too small.\n");
@ -502,26 +518,24 @@ static av_cold int decode_init(AVCodecContext *avctx)
av_log(avctx, AV_LOG_DEBUG, "Image type is YUV 1:1:1.\n");
break;
case IMGTYPE_YUV422:
c->decomp_size = basesize * 2;
c->decomp_size = (avctx->width & ~3) * avctx->height * 2;
max_decomp_size = max_basesize * 2;
avctx->pix_fmt = AV_PIX_FMT_YUV422P;
av_log(avctx, AV_LOG_DEBUG, "Image type is YUV 4:2:2.\n");
if (avctx->width % 4) {
avpriv_request_sample(avctx, "Unsupported dimensions");
return AVERROR_INVALIDDATA;
}
partial_h_supported = 1;
break;
case IMGTYPE_RGB24:
c->decomp_size = basesize * 3;
c->decomp_size = FFALIGN(avctx->width*3, 4) * avctx->height;
max_decomp_size = max_basesize * 3;
avctx->pix_fmt = AV_PIX_FMT_BGR24;
av_log(avctx, AV_LOG_DEBUG, "Image type is RGB 24.\n");
break;
case IMGTYPE_YUV411:
c->decomp_size = basesize / 2 * 3;
c->decomp_size = (avctx->width & ~3) * avctx->height / 2 * 3;
max_decomp_size = max_basesize / 2 * 3;
avctx->pix_fmt = AV_PIX_FMT_YUV411P;
av_log(avctx, AV_LOG_DEBUG, "Image type is YUV 4:1:1.\n");
partial_h_supported = 1;
break;
case IMGTYPE_YUV211:
c->decomp_size = basesize * 2;
@ -541,7 +555,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
}
av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt, &subsample_h, &subsample_v);
if (avctx->width % (1<<subsample_h) || avctx->height % (1<<subsample_v)) {
if ((avctx->width % (1<<subsample_h) && !partial_h_supported) || avctx->height % (1<<subsample_v)) {
avpriv_request_sample(avctx, "Unsupported dimensions");
return AVERROR_INVALIDDATA;
}

View file

@ -575,7 +575,13 @@ static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
{
libx265Context *ctx = avctx->priv_data;
x265_picture x265pic;
x265_picture x265pic_out = { 0 };
#if (X265_BUILD >= 210) && (X265_BUILD < 213)
x265_picture x265pic_layers_out[MAX_SCALABLE_LAYERS];
x265_picture* x265pic_lyrptr_out[MAX_SCALABLE_LAYERS];
#else
x265_picture x265pic_solo_out = { 0 };
#endif
x265_picture* x265pic_out;
x265_nal *nal;
x265_sei *sei;
uint8_t *dst;
@ -698,8 +704,16 @@ FF_ENABLE_DEPRECATION_WARNINGS
}
}
#if (X265_BUILD >= 210) && (X265_BUILD < 213)
for (i = 0; i < MAX_SCALABLE_LAYERS; i++)
x265pic_lyrptr_out[i] = &x265pic_layers_out[i];
ret = ctx->api->encoder_encode(ctx->encoder, &nal, &nnal,
pic ? &x265pic : NULL, &x265pic_out);
pic ? &x265pic : NULL, x265pic_lyrptr_out);
#else
ret = ctx->api->encoder_encode(ctx->encoder, &nal, &nnal,
pic ? &x265pic : NULL, &x265pic_solo_out);
#endif
for (i = 0; i < sei->numPayloads; i++)
av_free(sei->payloads[i].payload);
@ -729,10 +743,16 @@ FF_ENABLE_DEPRECATION_WARNINGS
pkt->flags |= AV_PKT_FLAG_KEY;
}
pkt->pts = x265pic_out.pts;
pkt->dts = x265pic_out.dts;
#if (X265_BUILD >= 210) && (X265_BUILD < 213)
x265pic_out = x265pic_lyrptr_out[0];
#else
x265pic_out = &x265pic_solo_out;
#endif
switch (x265pic_out.sliceType) {
pkt->pts = x265pic_out->pts;
pkt->dts = x265pic_out->dts;
switch (x265pic_out->sliceType) {
case X265_TYPE_IDR:
case X265_TYPE_I:
pict_type = AV_PICTURE_TYPE_I;
@ -750,16 +770,16 @@ FF_ENABLE_DEPRECATION_WARNINGS
}
#if X265_BUILD >= 130
if (x265pic_out.sliceType == X265_TYPE_B)
if (x265pic_out->sliceType == X265_TYPE_B)
#else
if (x265pic_out.frameData.sliceType == 'b')
if (x265pic_out->frameData.sliceType == 'b')
#endif
pkt->flags |= AV_PKT_FLAG_DISPOSABLE;
ff_side_data_set_encoder_stats(pkt, x265pic_out.frameData.qp * FF_QP2LAMBDA, NULL, 0, pict_type);
ff_side_data_set_encoder_stats(pkt, x265pic_out->frameData.qp * FF_QP2LAMBDA, NULL, 0, pict_type);
if (x265pic_out.userData) {
int idx = (int)(intptr_t)x265pic_out.userData - 1;
if (x265pic_out->userData) {
int idx = (int)(intptr_t)x265pic_out->userData - 1;
ReorderedData *rd = &ctx->rd[idx];
#if FF_API_REORDERED_OPAQUE

View file

@ -473,8 +473,9 @@ static int zero_cmp(MpegEncContext *s, const uint8_t *a, const uint8_t *b,
return 0;
}
void ff_set_cmp(MECmpContext *c, me_cmp_func *cmp, int type)
int ff_set_cmp(MECmpContext *c, me_cmp_func *cmp, int type)
{
int ret = 0;
int i;
memset(cmp, 0, sizeof(void *) * 6);
@ -533,9 +534,13 @@ void ff_set_cmp(MECmpContext *c, me_cmp_func *cmp, int type)
#endif
default:
av_log(NULL, AV_LOG_ERROR,
"internal error in cmp function selection\n");
"invalid cmp function selection\n");
ret = -1;
break;
}
}
return ret;
}
#define BUTTERFLY2(o1, o2, i1, i2) \

View file

@ -89,7 +89,7 @@ void ff_me_cmp_init_ppc(MECmpContext *c, AVCodecContext *avctx);
void ff_me_cmp_init_x86(MECmpContext *c, AVCodecContext *avctx);
void ff_me_cmp_init_mips(MECmpContext *c, AVCodecContext *avctx);
void ff_set_cmp(MECmpContext *c, me_cmp_func *cmp, int type);
int ff_set_cmp(MECmpContext *c, me_cmp_func *cmp, int type);
void ff_dsputil_init_dwt(MECmpContext *c);

View file

@ -309,6 +309,7 @@ int ff_init_me(MpegEncContext *s){
MotionEstContext * const c= &s->me;
int cache_size= FFMIN(ME_MAP_SIZE>>ME_MAP_SHIFT, 1<<ME_MAP_SHIFT);
int dia_size= FFMAX(FFABS(s->avctx->dia_size)&255, FFABS(s->avctx->pre_dia_size)&255);
int ret;
if(FFMIN(s->avctx->dia_size, s->avctx->pre_dia_size) < -FFMIN(ME_MAP_SIZE, MAX_SAB_SIZE)){
av_log(s->avctx, AV_LOG_ERROR, "ME_MAP size is too small for SAB diamond\n");
@ -324,10 +325,12 @@ int ff_init_me(MpegEncContext *s){
av_log(s->avctx, AV_LOG_INFO, "ME_MAP size may be a little small for the selected diamond size\n");
}
ff_set_cmp(&s->mecc, s->mecc.me_pre_cmp, c->avctx->me_pre_cmp);
ff_set_cmp(&s->mecc, s->mecc.me_cmp, c->avctx->me_cmp);
ff_set_cmp(&s->mecc, s->mecc.me_sub_cmp, c->avctx->me_sub_cmp);
ff_set_cmp(&s->mecc, s->mecc.mb_cmp, c->avctx->mb_cmp);
ret = ff_set_cmp(&s->mecc, s->mecc.me_pre_cmp, c->avctx->me_pre_cmp);
ret |= ff_set_cmp(&s->mecc, s->mecc.me_cmp, c->avctx->me_cmp);
ret |= ff_set_cmp(&s->mecc, s->mecc.me_sub_cmp, c->avctx->me_sub_cmp);
ret |= ff_set_cmp(&s->mecc, s->mecc.mb_cmp, c->avctx->mb_cmp);
if (ret < 0)
return ret;
c->flags = get_flags(c, 0, c->avctx->me_cmp &FF_CMP_CHROMA);
c->sub_flags= get_flags(c, 0, c->avctx->me_sub_cmp&FF_CMP_CHROMA);

View file

@ -185,7 +185,7 @@ static YuvPixel mp_get_yuv_from_rgb(MotionPixelsContext *mp, int x, int y)
int color;
color = *(uint16_t *)&mp->frame->data[0][y * mp->frame->linesize[0] + x * 2];
return mp_rgb_yuv_table[color];
return mp_rgb_yuv_table[color & 0x7FFF];
}
static void mp_set_rgb_from_yuv(MotionPixelsContext *mp, int x, int y, const YuvPixel *p)

View file

@ -2956,6 +2956,10 @@ static int ipu_decode_frame(AVCodecContext *avctx, AVFrame *frame,
GetBitContext *gb = &m->gb;
int ret;
// Check for minimal intra MB size (considering mb header, luma & chroma dc VLC, ac EOB VLC)
if (avpkt->size*8LL < (avctx->width+15)/16 * ((avctx->height+15)/16) * (2 + 3*4 + 2*2 + 2*6))
return AVERROR_INVALIDDATA;
ret = ff_get_buffer(avctx, frame, 0);
if (ret < 0)
return ret;

View file

@ -295,7 +295,7 @@ void ff_mpeg4_decode_studio(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb
int hsub = i ? s->chroma_x_shift : 0;
int lowres = s->avctx->lowres;
int step = 1 << lowres;
dest_pcm[i] += (linesize[i] / 2) * ((16 >> vsub) - 1);
dest_pcm[i] += (linesize[i] / 2) * ((16 >> vsub + lowres) - 1);
for (int h = (16 >> (vsub + lowres)) - 1; h >= 0; h--){
for (int w = (16 >> (hsub + lowres)) - 1, idx = 0; w >= 0; w--, idx += step)
dest_pcm[i][w] = src[idx];
@ -861,7 +861,7 @@ static inline int get_amv(Mpeg4DecContext *ctx, int n)
for (y = 0; y < 16; y++) {
int v;
v = mb_v + dy * y;
v = mb_v + (unsigned)dy * y;
// FIXME optimize
for (x = 0; x < 16; x++) {
sum += v >> shift;
@ -1437,7 +1437,7 @@ static inline int mpeg4_decode_block(Mpeg4DecContext *ctx, int16_t *block,
if (SHOW_UBITS(re, &s->gb, 1) == 0) {
av_log(s->avctx, AV_LOG_ERROR,
"1. marker bit missing in 3. esc\n");
if (!(s->avctx->err_recognition & AV_EF_IGNORE_ERR))
if (!(s->avctx->err_recognition & AV_EF_IGNORE_ERR) || get_bits_left(&s->gb) <= 0)
return AVERROR_INVALIDDATA;
}
SKIP_CACHE(re, &s->gb, 1);
@ -1448,7 +1448,7 @@ static inline int mpeg4_decode_block(Mpeg4DecContext *ctx, int16_t *block,
if (SHOW_UBITS(re, &s->gb, 1) == 0) {
av_log(s->avctx, AV_LOG_ERROR,
"2. marker bit missing in 3. esc\n");
if (!(s->avctx->err_recognition & AV_EF_IGNORE_ERR))
if (!(s->avctx->err_recognition & AV_EF_IGNORE_ERR) || get_bits_left(&s->gb) <= 0)
return AVERROR_INVALIDDATA;
}

View file

@ -637,6 +637,7 @@ static av_always_inline void mpeg_motion_lowres(MpegEncContext *s,
const int s_mask = (2 << lowres) - 1;
const int h_edge_pos = s->h_edge_pos >> lowres;
const int v_edge_pos = s->v_edge_pos >> lowres;
int hc = s->chroma_y_shift ? (h+1-bottom_field)>>1 : h;
linesize = s->current_picture.f->linesize[0] << field_based;
uvlinesize = s->current_picture.f->linesize[1] << field_based;
@ -699,7 +700,7 @@ static av_always_inline void mpeg_motion_lowres(MpegEncContext *s,
ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
if ((unsigned) src_x > FFMAX( h_edge_pos - (!!sx) - 2 * block_s, 0) || uvsrc_y<0 ||
(unsigned) src_y > FFMAX((v_edge_pos >> field_based) - (!!sy) - h, 0)) {
(unsigned) src_y > FFMAX((v_edge_pos >> field_based) - (!!sy) - FFMAX(h, hc<<s->chroma_y_shift), 0)) {
s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, ptr_y,
linesize >> field_based, linesize >> field_based,
17, 17 + field_based,
@ -744,7 +745,6 @@ static av_always_inline void mpeg_motion_lowres(MpegEncContext *s,
pix_op[lowres - 1](dest_y, ptr_y, linesize, h, sx, sy);
if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
int hc = s->chroma_y_shift ? (h+1-bottom_field)>>1 : h;
uvsx = (uvsx << 2) >> lowres;
uvsy = (uvsy << 2) >> lowres;
if (hc) {

View file

@ -902,8 +902,10 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
s->quant_precision = 5;
ff_set_cmp(&s->mecc, s->mecc.ildct_cmp, avctx->ildct_cmp);
ff_set_cmp(&s->mecc, s->mecc.frame_skip_cmp, s->frame_skip_cmp);
ret = ff_set_cmp(&s->mecc, s->mecc.ildct_cmp, avctx->ildct_cmp);
ret |= ff_set_cmp(&s->mecc, s->mecc.frame_skip_cmp, s->frame_skip_cmp);
if (ret < 0)
return AVERROR(EINVAL);
if (CONFIG_H263_ENCODER && s->out_format == FMT_H263) {
ff_h263_encode_init(s);
@ -1175,8 +1177,8 @@ static int load_input_picture(MpegEncContext *s, const AVFrame *pic_arg)
&v_chroma_shift);
for (i = 0; i < 3; i++) {
int src_stride = pic_arg->linesize[i];
int dst_stride = i ? s->uvlinesize : s->linesize;
ptrdiff_t src_stride = pic_arg->linesize[i];
ptrdiff_t dst_stride = i ? s->uvlinesize : s->linesize;
int h_shift = i ? h_chroma_shift : 0;
int v_shift = i ? v_chroma_shift : 0;
int w = s->width >> h_shift;
@ -1194,7 +1196,7 @@ static int load_input_picture(MpegEncContext *s, const AVFrame *pic_arg)
dst += INPLACE_OFFSET;
if (src_stride == dst_stride)
memcpy(dst, src, src_stride * h);
memcpy(dst, src, src_stride * h - src_stride + w);
else {
int h2 = h;
uint8_t *dst2 = dst;

View file

@ -86,6 +86,12 @@ static int noise_init(AVBSFContext *ctx)
return AVERROR(ENOMEM);
}
if (ctx->par_in->codec_id == AV_CODEC_ID_WRAPPED_AVFRAME &&
strcmp(s->amount_str, "0")) {
av_log(ctx, AV_LOG_ERROR, "Wrapped AVFrame noising is unsupported\n");
return AVERROR_PATCHWELCOME;
}
ret = av_expr_parse(&s->amount_pexpr, s->amount_str,
var_names, NULL, NULL, NULL, NULL, 0, ctx);
if (ret < 0) {

View file

@ -266,8 +266,8 @@ int ff_nvdec_decode_uninit(AVCodecContext *avctx)
{
NVDECContext *ctx = avctx->internal->hwaccel_priv_data;
av_freep(&ctx->bitstream);
av_freep(&ctx->bitstream_internal);
ctx->bitstream = NULL;
ctx->bitstream_len = 0;
ctx->bitstream_allocated = 0;
@ -677,6 +677,8 @@ int ff_nvdec_simple_end_frame(AVCodecContext *avctx)
NVDECContext *ctx = avctx->internal->hwaccel_priv_data;
int ret = ff_nvdec_end_frame(avctx);
ctx->bitstream = NULL;
ctx->bitstream_len = 0;
ctx->nb_slices = 0;
return ret;
}

View file

@ -137,11 +137,11 @@ static int nvdec_h264_decode_slice(AVCodecContext *avctx, const uint8_t *buffer,
const H264SliceContext *sl = &h->slice_ctx[0];
void *tmp;
tmp = av_fast_realloc(ctx->bitstream, &ctx->bitstream_allocated,
tmp = av_fast_realloc(ctx->bitstream_internal, &ctx->bitstream_allocated,
ctx->bitstream_len + size + 3);
if (!tmp)
return AVERROR(ENOMEM);
ctx->bitstream = tmp;
ctx->bitstream = ctx->bitstream_internal = tmp;
tmp = av_fast_realloc(ctx->slice_offsets, &ctx->slice_offsets_allocated,
(ctx->nb_slices + 1) * sizeof(*ctx->slice_offsets));

View file

@ -273,11 +273,11 @@ static int nvdec_hevc_decode_slice(AVCodecContext *avctx, const uint8_t *buffer,
NVDECContext *ctx = avctx->internal->hwaccel_priv_data;
void *tmp;
tmp = av_fast_realloc(ctx->bitstream, &ctx->bitstream_allocated,
tmp = av_fast_realloc(ctx->bitstream_internal, &ctx->bitstream_allocated,
ctx->bitstream_len + size + 3);
if (!tmp)
return AVERROR(ENOMEM);
ctx->bitstream = tmp;
ctx->bitstream = ctx->bitstream_internal = tmp;
tmp = av_fast_realloc(ctx->slice_offsets, &ctx->slice_offsets_allocated,
(ctx->nb_slices + 1) * sizeof(*ctx->slice_offsets));
@ -305,6 +305,15 @@ static int nvdec_hevc_frame_params(AVCodecContext *avctx,
static int nvdec_hevc_decode_init(AVCodecContext *avctx) {
NVDECContext *ctx = avctx->internal->hwaccel_priv_data;
ctx->supports_444 = 1;
if (avctx->profile != FF_PROFILE_HEVC_MAIN &&
avctx->profile != FF_PROFILE_HEVC_MAIN_10 &&
avctx->profile != FF_PROFILE_HEVC_MAIN_STILL_PICTURE &&
avctx->profile != FF_PROFILE_HEVC_REXT) {
av_log(avctx, AV_LOG_ERROR, "Unsupported HEVC profile: %d\n", avctx->profile);
return AVERROR(ENOTSUP);
}
return ff_nvdec_decode_init(avctx);
}

View file

@ -83,8 +83,9 @@ static int nvdec_mpeg12_start_frame(AVCodecContext *avctx, const uint8_t *buffer
};
for (i = 0; i < 64; ++i) {
ppc->QuantMatrixIntra[i] = s->intra_matrix[i];
ppc->QuantMatrixInter[i] = s->inter_matrix[i];
int n = s->idsp.idct_permutation[i];
ppc->QuantMatrixIntra[i] = s->intra_matrix[n];
ppc->QuantMatrixInter[i] = s->inter_matrix[n];
}
return 0;

View file

@ -88,8 +88,9 @@ static int nvdec_mpeg4_start_frame(AVCodecContext *avctx, const uint8_t *buffer,
};
for (i = 0; i < 64; ++i) {
ppc->QuantMatrixIntra[i] = s->intra_matrix[i];
ppc->QuantMatrixInter[i] = s->inter_matrix[i];
int n = s->idsp.idct_permutation[i];
ppc->QuantMatrixIntra[i] = s->intra_matrix[n];
ppc->QuantMatrixInter[i] = s->inter_matrix[n];
}
// We need to pass the full frame buffer and not just the slice

View file

@ -28,7 +28,6 @@
#include "av1.h"
#endif
#include "libavutil/buffer.h"
#include "libavutil/hwcontext_cuda.h"
#include "libavutil/hwcontext.h"
#include "libavutil/cuda_check.h"
@ -44,9 +43,14 @@
#define CHECK_CU(x) FF_CUDA_CHECK_DL(avctx, dl_fn->cuda_dl, x)
#define NVENC_CAP 0x30
#ifndef NVENC_NO_DEPRECATED_RC
#define IS_CBR(rc) (rc == NV_ENC_PARAMS_RC_CBR || \
rc == NV_ENC_PARAMS_RC_CBR_LOWDELAY_HQ || \
rc == NV_ENC_PARAMS_RC_CBR_HQ)
#else
#define IS_CBR(rc) (rc == NV_ENC_PARAMS_RC_CBR)
#endif
const enum AVPixelFormat ff_nvenc_pix_fmts[] = {
AV_PIX_FMT_YUV420P,
@ -163,25 +167,6 @@ static int nvenc_print_error(AVCodecContext *avctx, NVENCSTATUS err,
return ret;
}
typedef struct FrameData {
int64_t pts;
int64_t duration;
#if FF_API_REORDERED_OPAQUE
int64_t reordered_opaque;
#endif
void *frame_opaque;
AVBufferRef *frame_opaque_ref;
} FrameData;
static void reorder_queue_flush(AVFifo *queue)
{
FrameData fd;
while (av_fifo_read(queue, &fd, 1) >= 0)
av_buffer_unref(&fd.frame_opaque_ref);
}
typedef struct GUIDTuple {
const GUID guid;
int flags;
@ -457,7 +442,7 @@ static int nvenc_check_cap(AVCodecContext *avctx, NV_ENC_CAPS cap)
static int nvenc_check_capabilities(AVCodecContext *avctx)
{
NvencContext *ctx = avctx->priv_data;
int ret;
int tmp, ret;
ret = nvenc_check_codec_support(avctx);
if (ret < 0) {
@ -538,16 +523,18 @@ static int nvenc_check_capabilities(AVCodecContext *avctx)
}
#ifdef NVENC_HAVE_BFRAME_REF_MODE
tmp = (ctx->b_ref_mode >= 0) ? ctx->b_ref_mode : NV_ENC_BFRAME_REF_MODE_DISABLED;
ret = nvenc_check_cap(avctx, NV_ENC_CAPS_SUPPORT_BFRAME_REF_MODE);
if (ctx->b_ref_mode == NV_ENC_BFRAME_REF_MODE_EACH && ret != 1 && ret != 3) {
if (tmp == NV_ENC_BFRAME_REF_MODE_EACH && ret != 1 && ret != 3) {
av_log(avctx, AV_LOG_WARNING, "Each B frame as reference is not supported\n");
return AVERROR(ENOSYS);
} else if (ctx->b_ref_mode != NV_ENC_BFRAME_REF_MODE_DISABLED && ret == 0) {
} else if (tmp != NV_ENC_BFRAME_REF_MODE_DISABLED && ret == 0) {
av_log(avctx, AV_LOG_WARNING, "B frames as references are not supported\n");
return AVERROR(ENOSYS);
}
#else
if (ctx->b_ref_mode != 0) {
tmp = (ctx->b_ref_mode >= 0) ? ctx->b_ref_mode : 0;
if (tmp > 0) {
av_log(avctx, AV_LOG_WARNING, "B frames as references need SDK 8.1 at build time\n");
return AVERROR(ENOSYS);
}
@ -922,6 +909,7 @@ static void nvenc_override_rate_control(AVCodecContext *avctx)
case NV_ENC_PARAMS_RC_CONSTQP:
set_constqp(avctx);
return;
#ifndef NVENC_NO_DEPRECATED_RC
case NV_ENC_PARAMS_RC_VBR_MINQP:
if (avctx->qmin < 0) {
av_log(avctx, AV_LOG_WARNING,
@ -932,12 +920,15 @@ static void nvenc_override_rate_control(AVCodecContext *avctx)
}
/* fall through */
case NV_ENC_PARAMS_RC_VBR_HQ:
#endif
case NV_ENC_PARAMS_RC_VBR:
set_vbr(avctx);
break;
case NV_ENC_PARAMS_RC_CBR:
#ifndef NVENC_NO_DEPRECATED_RC
case NV_ENC_PARAMS_RC_CBR_HQ:
case NV_ENC_PARAMS_RC_CBR_LOWDELAY_HQ:
#endif
break;
}
@ -980,6 +971,10 @@ static av_cold int nvenc_recalc_surfaces(AVCodecContext *avctx)
ctx->nb_surfaces = FFMAX(1, FFMIN(MAX_REGISTERED_FRAMES, ctx->nb_surfaces));
ctx->async_depth = FFMIN(ctx->async_depth, ctx->nb_surfaces - 1);
// Output in the worst case will only start when the surface buffer is completely full.
// Hence we need to keep at least the max amount of surfaces plus the max reorder delay around.
ctx->frame_data_array_nb = FFMAX(ctx->nb_surfaces, ctx->nb_surfaces + ctx->encode_config.frameIntervalP - 1);
return 0;
}
@ -1207,12 +1202,14 @@ static av_cold int nvenc_setup_h264_config(AVCodecContext *avctx)
h264->outputPictureTimingSEI = 1;
#ifndef NVENC_NO_DEPRECATED_RC
if (cc->rcParams.rateControlMode == NV_ENC_PARAMS_RC_CBR_LOWDELAY_HQ ||
cc->rcParams.rateControlMode == NV_ENC_PARAMS_RC_CBR_HQ ||
cc->rcParams.rateControlMode == NV_ENC_PARAMS_RC_VBR_HQ) {
h264->adaptiveTransformMode = NV_ENC_H264_ADAPTIVE_TRANSFORM_ENABLE;
h264->fmoMode = NV_ENC_H264_FMO_DISABLE;
}
#endif
if (ctx->flags & NVENC_LOSSLESS) {
h264->qpPrimeYZeroTransformBypassFlag = 1;
@ -1768,8 +1765,12 @@ static av_cold int nvenc_setup_surfaces(AVCodecContext *avctx)
if (!ctx->surfaces)
return AVERROR(ENOMEM);
ctx->reorder_queue = av_fifo_alloc2(ctx->nb_surfaces, sizeof(FrameData), 0);
if (!ctx->reorder_queue)
ctx->frame_data_array = av_calloc(ctx->frame_data_array_nb, sizeof(*ctx->frame_data_array));
if (!ctx->frame_data_array)
return AVERROR(ENOMEM);
ctx->timestamp_list = av_fifo_alloc2(ctx->nb_surfaces, sizeof(int64_t), 0);
if (!ctx->timestamp_list)
return AVERROR(ENOMEM);
ctx->unused_surface_queue = av_fifo_alloc2(ctx->nb_surfaces, sizeof(NvencSurface*), 0);
@ -1853,12 +1854,17 @@ av_cold int ff_nvenc_encode_close(AVCodecContext *avctx)
p_nvenc->nvEncEncodePicture(ctx->nvencoder, &params);
}
reorder_queue_flush(ctx->reorder_queue);
av_fifo_freep2(&ctx->reorder_queue);
av_fifo_freep2(&ctx->timestamp_list);
av_fifo_freep2(&ctx->output_surface_ready_queue);
av_fifo_freep2(&ctx->output_surface_queue);
av_fifo_freep2(&ctx->unused_surface_queue);
if (ctx->frame_data_array) {
for (i = 0; i < ctx->frame_data_array_nb; i++)
av_buffer_unref(&ctx->frame_data_array[i].frame_opaque_ref);
av_freep(&ctx->frame_data_array);
}
if (ctx->surfaces && (avctx->pix_fmt == AV_PIX_FMT_CUDA || avctx->pix_fmt == AV_PIX_FMT_D3D11)) {
for (i = 0; i < ctx->nb_registered_frames; i++) {
if (ctx->registered_frames[i].mapped)
@ -2198,53 +2204,18 @@ static void nvenc_codec_specific_pic_params(AVCodecContext *avctx,
}
}
static void reorder_queue_enqueue(AVFifo *queue, const AVCodecContext *avctx,
const AVFrame *frame, AVBufferRef **opaque_ref)
static inline void timestamp_queue_enqueue(AVFifo *queue, int64_t timestamp)
{
FrameData fd;
fd.pts = frame->pts;
fd.duration = frame->duration;
#if FF_API_REORDERED_OPAQUE
FF_DISABLE_DEPRECATION_WARNINGS
fd.reordered_opaque = frame->reordered_opaque;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
fd.frame_opaque = frame->opaque;
fd.frame_opaque_ref = *opaque_ref;
*opaque_ref = NULL;
av_fifo_write(queue, &fd, 1);
av_fifo_write(queue, &timestamp, 1);
}
static int64_t reorder_queue_dequeue(AVFifo *queue, AVCodecContext *avctx,
AVPacket *pkt)
static inline int64_t timestamp_queue_dequeue(AVFifo *queue)
{
FrameData fd;
int64_t timestamp = AV_NOPTS_VALUE;
// The following call might fail if the queue is empty.
if (av_fifo_read(queue, &fd, 1) < 0)
return AV_NOPTS_VALUE;
av_fifo_read(queue, &timestamp, 1);
if (pkt) {
#if FF_API_REORDERED_OPAQUE
FF_DISABLE_DEPRECATION_WARNINGS
avctx->reordered_opaque = fd.reordered_opaque;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
pkt->duration = fd.duration;
if (avctx->flags & AV_CODEC_FLAG_COPY_OPAQUE) {
pkt->opaque = fd.frame_opaque;
pkt->opaque_ref = fd.frame_opaque_ref;
fd.frame_opaque_ref = NULL;
}
}
av_buffer_unref(&fd.frame_opaque_ref);
return fd.pts;
return timestamp;
}
static int nvenc_set_timestamp(AVCodecContext *avctx,
@ -2252,14 +2223,12 @@ static int nvenc_set_timestamp(AVCodecContext *avctx,
AVPacket *pkt)
{
NvencContext *ctx = avctx->priv_data;
int64_t dts;
pkt->pts = params->outputTimeStamp;
dts = reorder_queue_dequeue(ctx->reorder_queue, avctx, pkt);
if (avctx->codec_descriptor->props & AV_CODEC_PROP_REORDER) {
pkt->dts = dts - FFMAX(ctx->encode_config.frameIntervalP - 1, 0) * FFMAX(avctx->ticks_per_frame, 1);
pkt->dts = timestamp_queue_dequeue(ctx->timestamp_list) -
FFMAX(ctx->encode_config.frameIntervalP - 1, 0) * FFMAX(avctx->ticks_per_frame, 1);
} else {
pkt->dts = pkt->pts;
}
@ -2267,6 +2236,65 @@ static int nvenc_set_timestamp(AVCodecContext *avctx,
return 0;
}
static int nvenc_store_frame_data(AVCodecContext *avctx, NV_ENC_PIC_PARAMS *pic_params, const AVFrame *frame)
{
NvencContext *ctx = avctx->priv_data;
int res = 0;
int idx = ctx->frame_data_array_pos;
NvencFrameData *frame_data = &ctx->frame_data_array[idx];
// in case the encoder got reconfigured, there might be leftovers
av_buffer_unref(&frame_data->frame_opaque_ref);
if (frame && frame->opaque_ref && avctx->flags & AV_CODEC_FLAG_COPY_OPAQUE) {
frame_data->frame_opaque_ref = av_buffer_ref(frame->opaque_ref);
if (!frame_data->frame_opaque_ref)
return AVERROR(ENOMEM);
}
frame_data->duration = frame->duration;
frame_data->frame_opaque = frame->opaque;
#if FF_API_REORDERED_OPAQUE
FF_DISABLE_DEPRECATION_WARNINGS
frame_data->reordered_opaque = frame->reordered_opaque;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
ctx->frame_data_array_pos = (ctx->frame_data_array_pos + 1) % ctx->frame_data_array_nb;
pic_params->inputDuration = idx;
return res;
}
static int nvenc_retrieve_frame_data(AVCodecContext *avctx, NV_ENC_LOCK_BITSTREAM *lock_params, AVPacket *pkt)
{
NvencContext *ctx = avctx->priv_data;
int res = 0;
int idx = lock_params->outputDuration;
NvencFrameData *frame_data = &ctx->frame_data_array[idx];
pkt->duration = frame_data->duration;
#if FF_API_REORDERED_OPAQUE
FF_DISABLE_DEPRECATION_WARNINGS
avctx->reordered_opaque = frame_data->reordered_opaque;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
if (avctx->flags & AV_CODEC_FLAG_COPY_OPAQUE) {
pkt->opaque = frame_data->frame_opaque;
pkt->opaque_ref = frame_data->frame_opaque_ref;
frame_data->frame_opaque_ref = NULL;
}
av_buffer_unref(&frame_data->frame_opaque_ref);
return res;
}
static int process_output_surface(AVCodecContext *avctx, AVPacket *pkt, NvencSurface *tmpoutsurf)
{
NvencContext *ctx = avctx->priv_data;
@ -2353,10 +2381,14 @@ static int process_output_surface(AVCodecContext *avctx, AVPacket *pkt, NvencSur
if (res < 0)
goto error2;
res = nvenc_retrieve_frame_data(avctx, &lock_params, pkt);
if (res < 0)
goto error2;
return 0;
error:
reorder_queue_dequeue(ctx->reorder_queue, avctx, NULL);
timestamp_queue_dequeue(ctx->timestamp_list);
error2:
return res;
@ -2586,8 +2618,6 @@ static int nvenc_send_frame(AVCodecContext *avctx, const AVFrame *frame)
int sei_count = 0;
int i;
AVBufferRef *opaque_ref = NULL;
NvencContext *ctx = avctx->priv_data;
NvencDynLoadFunctions *dl_fn = &ctx->nvenc_dload_funcs;
NV_ENCODE_API_FUNCTION_LIST *p_nvenc = &dl_fn->nvenc_funcs;
@ -2650,22 +2680,18 @@ static int nvenc_send_frame(AVCodecContext *avctx, const AVFrame *frame)
sei_count = res;
}
res = nvenc_store_frame_data(avctx, &pic_params, frame);
if (res < 0)
return res;
nvenc_codec_specific_pic_params(avctx, &pic_params, ctx->sei_data, sei_count);
} else {
pic_params.encodePicFlags = NV_ENC_PIC_FLAG_EOS;
}
// make a reference for enqueing in the reorder queue here,
// so that reorder_queue_enqueue() cannot fail
if (frame && frame->opaque_ref && avctx->flags & AV_CODEC_FLAG_COPY_OPAQUE) {
opaque_ref = av_buffer_ref(frame->opaque_ref);
if (!opaque_ref)
return AVERROR(ENOMEM);
}
res = nvenc_push_context(avctx);
if (res < 0)
goto opaque_ref_fail;
return res;
nv_status = p_nvenc->nvEncEncodePicture(ctx->nvencoder, &pic_params);
@ -2674,17 +2700,17 @@ static int nvenc_send_frame(AVCodecContext *avctx, const AVFrame *frame)
res = nvenc_pop_context(avctx);
if (res < 0)
goto opaque_ref_fail;
return res;
if (nv_status != NV_ENC_SUCCESS &&
nv_status != NV_ENC_ERR_NEED_MORE_INPUT) {
res = nvenc_print_error(avctx, nv_status, "EncodePicture failed!");
goto opaque_ref_fail;
}
nv_status != NV_ENC_ERR_NEED_MORE_INPUT)
return nvenc_print_error(avctx, nv_status, "EncodePicture failed!");
if (frame && frame->buf[0]) {
av_fifo_write(ctx->output_surface_queue, &in_surf, 1);
reorder_queue_enqueue(ctx->reorder_queue, avctx, frame, &opaque_ref);
if (avctx->codec_descriptor->props & AV_CODEC_PROP_REORDER)
timestamp_queue_enqueue(ctx->timestamp_list, frame->pts);
}
/* all the pending buffers are now ready for output */
@ -2694,10 +2720,6 @@ static int nvenc_send_frame(AVCodecContext *avctx, const AVFrame *frame)
}
return 0;
opaque_ref_fail:
av_buffer_unref(&opaque_ref);
return res;
}
int ff_nvenc_receive_packet(AVCodecContext *avctx, AVPacket *pkt)
@ -2756,5 +2778,5 @@ av_cold void ff_nvenc_encode_flush(AVCodecContext *avctx)
NvencContext *ctx = avctx->priv_data;
nvenc_send_frame(avctx, NULL);
reorder_queue_flush(ctx->reorder_queue);
av_fifo_reset2(ctx->timestamp_list);
}

View file

@ -31,6 +31,7 @@ typedef void ID3D11Device;
#include <ffnvcodec/nvEncodeAPI.h>
#include "compat/cuda/dynlink_loader.h"
#include "libavutil/buffer.h"
#include "libavutil/fifo.h"
#include "libavutil/opt.h"
#include "hwconfig.h"
@ -77,6 +78,11 @@ typedef void ID3D11Device;
#define NVENC_HAVE_SINGLE_SLICE_INTRA_REFRESH
#endif
// SDK 12.1 compile time feature checks
#if NVENCAPI_CHECK_VERSION(12, 1)
#define NVENC_NO_DEPRECATED_RC
#endif
typedef struct NvencSurface
{
NV_ENC_INPUT_PTR input_surface;
@ -90,6 +96,18 @@ typedef struct NvencSurface
NV_ENC_BUFFER_FORMAT format;
} NvencSurface;
typedef struct NvencFrameData
{
int64_t duration;
#if FF_API_REORDERED_OPAQUE
int64_t reordered_opaque;
#endif
void *frame_opaque;
AVBufferRef *frame_opaque_ref;
} NvencFrameData;
typedef struct NvencDynLoadFunctions
{
CudaFunctions *cuda_dl;
@ -168,10 +186,14 @@ typedef struct NvencContext
int nb_surfaces;
NvencSurface *surfaces;
NvencFrameData *frame_data_array;
int frame_data_array_nb;
int frame_data_array_pos;
AVFifo *unused_surface_queue;
AVFifo *output_surface_queue;
AVFifo *output_surface_ready_queue;
AVFifo *reorder_queue;
AVFifo *timestamp_list;
NV_ENC_SEI_PAYLOAD *sei_data;
int sei_data_size;

View file

@ -100,6 +100,7 @@ static const AVOption options[] = {
{ "constqp", "Constant QP mode", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_PARAMS_RC_CONSTQP }, 0, 0, VE, "rc" },
{ "vbr", "Variable bitrate mode", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_PARAMS_RC_VBR }, 0, 0, VE, "rc" },
{ "cbr", "Constant bitrate mode", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_PARAMS_RC_CBR }, 0, 0, VE, "rc" },
#ifndef NVENC_NO_DEPRECATED_RC
{ "vbr_minqp", "Variable bitrate mode with MinQP (deprecated)", 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_VBR_MINQP) }, 0, 0, VE, "rc" },
{ "ll_2pass_quality", "Multi-pass optimized for image quality (deprecated)",
0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_2_PASS_QUALITY) }, 0, 0, VE, "rc" },
@ -109,6 +110,17 @@ static const AVOption options[] = {
{ "cbr_ld_hq", "Constant bitrate low delay high quality mode", 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_CBR_LOWDELAY_HQ) }, 0, 0, VE, "rc" },
{ "cbr_hq", "Constant bitrate high quality mode", 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_CBR_HQ) }, 0, 0, VE, "rc" },
{ "vbr_hq", "Variable bitrate high quality mode", 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_VBR_HQ) }, 0, 0, VE, "rc" },
#else
{ "vbr_minqp", "Variable bitrate mode with MinQP (deprecated)", 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_VBR) }, 0, 0, VE, "rc" },
{ "ll_2pass_quality", "Multi-pass optimized for image quality (deprecated)",
0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_VBR) }, 0, 0, VE, "rc" },
{ "ll_2pass_size", "Multi-pass optimized for constant frame size (deprecated)",
0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_CBR) }, 0, 0, VE, "rc" },
{ "vbr_2pass", "Multi-pass variable bitrate mode (deprecated)", 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_VBR) }, 0, 0, VE, "rc" },
{ "cbr_ld_hq", "Constant bitrate low delay high quality mode", 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_CBR) }, 0, 0, VE, "rc" },
{ "cbr_hq", "Constant bitrate high quality mode", 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_CBR) }, 0, 0, VE, "rc" },
{ "vbr_hq", "Variable bitrate high quality mode", 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_VBR) }, 0, 0, VE, "rc" },
#endif
{ "rc-lookahead", "Number of frames to look ahead for rate-control",
OFFSET(rc_lookahead), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
{ "surfaces", "Number of concurrent surfaces", OFFSET(nb_surfaces), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, MAX_REGISTERED_FRAMES, VE },

View file

@ -89,6 +89,7 @@ static const AVOption options[] = {
{ "constqp", "Constant QP mode", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_PARAMS_RC_CONSTQP }, 0, 0, VE, "rc" },
{ "vbr", "Variable bitrate mode", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_PARAMS_RC_VBR }, 0, 0, VE, "rc" },
{ "cbr", "Constant bitrate mode", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_PARAMS_RC_CBR }, 0, 0, VE, "rc" },
#ifndef NVENC_NO_DEPRECATED_RC
{ "vbr_minqp", "Variable bitrate mode with MinQP (deprecated)", 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_VBR_MINQP) }, 0, 0, VE, "rc" },
{ "ll_2pass_quality", "Multi-pass optimized for image quality (deprecated)",
0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_2_PASS_QUALITY) }, 0, 0, VE, "rc" },
@ -98,6 +99,17 @@ static const AVOption options[] = {
{ "cbr_ld_hq", "Constant bitrate low delay high quality mode", 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_CBR_LOWDELAY_HQ) }, 0, 0, VE, "rc" },
{ "cbr_hq", "Constant bitrate high quality mode", 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_CBR_HQ) }, 0, 0, VE, "rc" },
{ "vbr_hq", "Variable bitrate high quality mode", 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_VBR_HQ) }, 0, 0, VE, "rc" },
#else
{ "vbr_minqp", "Variable bitrate mode with MinQP (deprecated)", 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_VBR) }, 0, 0, VE, "rc" },
{ "ll_2pass_quality", "Multi-pass optimized for image quality (deprecated)",
0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_VBR) }, 0, 0, VE, "rc" },
{ "ll_2pass_size", "Multi-pass optimized for constant frame size (deprecated)",
0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_CBR) }, 0, 0, VE, "rc" },
{ "vbr_2pass", "Multi-pass variable bitrate mode (deprecated)", 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_VBR) }, 0, 0, VE, "rc" },
{ "cbr_ld_hq", "Constant bitrate low delay high quality mode", 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_CBR) }, 0, 0, VE, "rc" },
{ "cbr_hq", "Constant bitrate high quality mode", 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_CBR) }, 0, 0, VE, "rc" },
{ "vbr_hq", "Variable bitrate high quality mode", 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_VBR) }, 0, 0, VE, "rc" },
#endif
{ "rc-lookahead", "Number of frames to look ahead for rate-control",
OFFSET(rc_lookahead), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
{ "surfaces", "Number of concurrent surfaces", OFFSET(nb_surfaces), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, MAX_REGISTERED_FRAMES, VE },

View file

@ -51,9 +51,9 @@ typedef struct On2AVCContext {
AVCodecContext *avctx;
AVFloatDSPContext *fdsp;
AVTXContext *mdct, *mdct_half, *mdct_small;
AVTXContext *fft128, *fft256, *fft512, *fft1024;
AVTXContext *fft64, *fft128, *fft256, *fft512;
av_tx_fn mdct_fn, mdct_half_fn, mdct_small_fn;
av_tx_fn fft128_fn, fft256_fn, fft512_fn, fft1024_fn;
av_tx_fn fft64_fn, fft128_fn, fft256_fn, fft512_fn;
void (*wtf)(struct On2AVCContext *ctx, float *out, float *in, int size);
int is_av500;
@ -475,16 +475,16 @@ static void wtf_end_512(On2AVCContext *c, float *out, float *src,
zero_head_and_tail(tmp1 + 256, 128, 13, 7);
zero_head_and_tail(tmp1 + 384, 128, 15, 5);
c->fft128_fn(c->fft128, src + 0, tmp1 + 0, sizeof(float));
c->fft128_fn(c->fft128, src + 128, tmp1 + 128, sizeof(float));
c->fft128_fn(c->fft128, src + 256, tmp1 + 256, sizeof(float));
c->fft128_fn(c->fft128, src + 384, tmp1 + 384, sizeof(float));
c->fft64_fn(c->fft64, src + 0, tmp1 + 0, sizeof(float));
c->fft64_fn(c->fft64, src + 128, tmp1 + 128, sizeof(float));
c->fft64_fn(c->fft64, src + 256, tmp1 + 256, sizeof(float));
c->fft64_fn(c->fft64, src + 384, tmp1 + 384, sizeof(float));
combine_fft(src, src + 128, src + 256, src + 384, tmp1,
ff_on2avc_ctab_1, ff_on2avc_ctab_2,
ff_on2avc_ctab_3, ff_on2avc_ctab_4, 512, 2);
c->fft512_fn(c->fft512, src, tmp1, sizeof(float));
c->fft256_fn(c->fft256, src, tmp1, sizeof(float));
pretwiddle(&tmp0[ 0], src, 512, 84, 4, 16, 4, ff_on2avc_tabs_20_84_1);
pretwiddle(&tmp0[128], src, 512, 84, 4, 16, 4, ff_on2avc_tabs_20_84_2);
@ -503,16 +503,16 @@ static void wtf_end_1024(On2AVCContext *c, float *out, float *src,
zero_head_and_tail(tmp1 + 512, 256, 13, 7);
zero_head_and_tail(tmp1 + 768, 256, 15, 5);
c->fft256_fn(c->fft256, src + 0, tmp1 + 0, sizeof(float));
c->fft256_fn(c->fft256, src + 256, tmp1 + 256, sizeof(float));
c->fft256_fn(c->fft256, src + 512, tmp1 + 512, sizeof(float));
c->fft256_fn(c->fft256, src + 768, tmp1 + 768, sizeof(float));
c->fft128_fn(c->fft128, src + 0, tmp1 + 0, sizeof(float));
c->fft128_fn(c->fft128, src + 256, tmp1 + 256, sizeof(float));
c->fft128_fn(c->fft128, src + 512, tmp1 + 512, sizeof(float));
c->fft128_fn(c->fft128, src + 768, tmp1 + 768, sizeof(float));
combine_fft(src, src + 256, src + 512, src + 768, tmp1,
ff_on2avc_ctab_1, ff_on2avc_ctab_2,
ff_on2avc_ctab_3, ff_on2avc_ctab_4, 1024, 1);
c->fft1024_fn(c->fft1024, src, tmp1, sizeof(float));
c->fft512_fn(c->fft512, src, tmp1, sizeof(float));
pretwiddle(&tmp0[ 0], src, 1024, 84, 4, 16, 4, ff_on2avc_tabs_20_84_1);
pretwiddle(&tmp0[256], src, 1024, 84, 4, 16, 4, ff_on2avc_tabs_20_84_2);
@ -700,7 +700,7 @@ static int on2avc_reconstruct_channel_ext(On2AVCContext *c, AVFrame *dst, int of
break;
case WINDOW_TYPE_EXT5:
c->wtf(c, buf, in, 512);
c->mdct_half_fn(c->mdct, buf + 512, in + 512, sizeof(float));
c->mdct_half_fn(c->mdct_half, buf + 512, in + 512, sizeof(float));
for (i = 0; i < 256; i++) {
FFSWAP(float, buf[i + 512], buf[1023 - i]);
}
@ -956,14 +956,14 @@ static av_cold int on2avc_decode_init(AVCodecContext *avctx)
if ((ret = av_tx_init(&c->mdct_small, &c->mdct_small_fn, AV_TX_FLOAT_MDCT, 1, 128, &scale, 0)) < 0)
return ret;
if ((ret = av_tx_init(&c->fft1024, &c->fft1024_fn, AV_TX_FLOAT_FFT, 1, 1024, NULL, 0)) < 0)
return ret;
if ((ret = av_tx_init(&c->fft512, &c->fft512_fn, AV_TX_FLOAT_FFT, 1, 512, NULL, 0)) < 0)
return ret;
if ((ret = av_tx_init(&c->fft256, &c->fft256_fn, AV_TX_FLOAT_FFT, 0, 256, NULL, 0)) < 0)
if ((ret = av_tx_init(&c->fft256, &c->fft256_fn, AV_TX_FLOAT_FFT, 1, 256, NULL, 0)) < 0)
return ret;
if ((ret = av_tx_init(&c->fft128, &c->fft128_fn, AV_TX_FLOAT_FFT, 0, 128, NULL, 0)) < 0)
return ret;
if ((ret = av_tx_init(&c->fft64, &c->fft64_fn, AV_TX_FLOAT_FFT, 0, 64, NULL, 0)) < 0)
return ret;
c->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
if (!c->fdsp)
@ -998,10 +998,10 @@ static av_cold int on2avc_decode_close(AVCodecContext *avctx)
av_tx_uninit(&c->mdct);
av_tx_uninit(&c->mdct_half);
av_tx_uninit(&c->mdct_small);
av_tx_uninit(&c->fft64);
av_tx_uninit(&c->fft128);
av_tx_uninit(&c->fft256);
av_tx_uninit(&c->fft512);
av_tx_uninit(&c->fft1024);
av_freep(&c->fdsp);

View file

@ -578,7 +578,7 @@ const FFCodec ff_ ## name_ ## _decoder = { \
.priv_data_size = sizeof(PCMDecode), \
.init = pcm_decode_init, \
FF_CODEC_DECODE_CB(pcm_decode_frame), \
.p.capabilities = AV_CODEC_CAP_DR1, \
.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_PARAM_CHANGE, \
.p.sample_fmts = (const enum AVSampleFormat[]){ sample_fmt_, \
AV_SAMPLE_FMT_NONE }, \
}

View file

@ -329,7 +329,7 @@ void ff_png_filter_row(PNGDSPContext *dsp, uint8_t *dst, int filter_type,
static void deloco_ ## NAME(TYPE *dst, int size, int alpha) \
{ \
int i; \
for (i = 0; i < size; i += 3 + alpha) { \
for (i = 0; i < size - 2; i += 3 + alpha) { \
int g = dst [i + 1]; \
dst[i + 0] += g; \
dst[i + 2] += g; \
@ -647,6 +647,8 @@ static int decode_idat_chunk(AVCodecContext *avctx, PNGDecContext *s,
int ret;
size_t byte_depth = s->bit_depth > 8 ? 2 : 1;
if (!p)
return AVERROR_INVALIDDATA;
if (!(s->hdr_state & PNG_IHDR)) {
av_log(avctx, AV_LOG_ERROR, "IDAT without IHDR\n");
return AVERROR_INVALIDDATA;
@ -883,7 +885,7 @@ static int decode_trns_chunk(AVCodecContext *avctx, PNGDecContext *s,
return 0;
}
static int decode_iccp_chunk(PNGDecContext *s, GetByteContext *gb, AVFrame *f)
static int decode_iccp_chunk(PNGDecContext *s, GetByteContext *gb)
{
int ret, cnt = 0;
AVBPrint bp;
@ -1238,6 +1240,7 @@ static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s,
}
av_log(avctx, AV_LOG_ERROR, ", skipping\n");
bytestream2_skip(&s->gb, length + 8); /* tag */
continue;
}
}
tag = bytestream2_get_le32(&s->gb);
@ -1337,7 +1340,7 @@ static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s,
s->have_srgb = 1;
break;
case MKTAG('i', 'C', 'C', 'P'): {
if ((ret = decode_iccp_chunk(s, &gb_chunk, p)) < 0)
if ((ret = decode_iccp_chunk(s, &gb_chunk)) < 0)
goto fail;
break;
}
@ -1382,6 +1385,9 @@ static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s,
}
exit_loop:
if (!p)
return AVERROR_INVALIDDATA;
if (avctx->codec_id == AV_CODEC_ID_PNG &&
avctx->skip_frame == AVDISCARD_ALL) {
return 0;
@ -1642,7 +1648,7 @@ static int decode_frame_apng(AVCodecContext *avctx, AVFrame *p,
if ((ret = inflateReset(&s->zstream.zstream)) != Z_OK)
return AVERROR_EXTERNAL;
bytestream2_init(&s->gb, avctx->extradata, avctx->extradata_size);
if ((ret = decode_frame_common(avctx, s, p, avpkt)) < 0)
if ((ret = decode_frame_common(avctx, s, NULL, avpkt)) < 0)
return ret;
}

View file

@ -3,9 +3,6 @@
*
* Copyright (c) 2012 Konstantin Shishkov
*
* This encoder appears to be based on Anatoliy Wassermans considering
* similarities in the bugs.
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or

View file

@ -2,11 +2,11 @@ OBJS-$(CONFIG_AAC_DECODER) += riscv/aacpsdsp_init.o
RVV-OBJS-$(CONFIG_AAC_DECODER) += riscv/aacpsdsp_rvv.o
OBJS-$(CONFIG_ALAC_DECODER) += riscv/alacdsp_init.o
RVV-OBJS-$(CONFIG_ALAC_DECODER) += riscv/alacdsp_rvv.o
OBJS-$(CONFIG_AUDIODSP) += riscv/audiodsp_init.o \
riscv/audiodsp_rvf.o
OBJS-$(CONFIG_AUDIODSP) += riscv/audiodsp_init.o
RV-OBJS-$(CONFIG_AUDIODSP) += riscv/audiodsp_rvf.o
RVV-OBJS-$(CONFIG_AUDIODSP) += riscv/audiodsp_rvv.o
OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_init.o \
riscv/bswapdsp_rvb.o
OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_init.o
RV-OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_rvb.o
RVV-OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_rvv.o
OBJS-$(CONFIG_FMTCONVERT) += riscv/fmtconvert_init.o
RVV-OBJS-$(CONFIG_FMTCONVERT) += riscv/fmtconvert_rvv.o
@ -14,8 +14,8 @@ OBJS-$(CONFIG_IDCTDSP) += riscv/idctdsp_init.o
RVV-OBJS-$(CONFIG_IDCTDSP) += riscv/idctdsp_rvv.o
OBJS-$(CONFIG_OPUS_DECODER) += riscv/opusdsp_init.o
RVV-OBJS-$(CONFIG_OPUS_DECODER) += riscv/opusdsp_rvv.o
OBJS-$(CONFIG_PIXBLOCKDSP) += riscv/pixblockdsp_init.o \
riscv/pixblockdsp_rvi.o
OBJS-$(CONFIG_PIXBLOCKDSP) += riscv/pixblockdsp_init.o
RV-OBJS-$(CONFIG_PIXBLOCKDSP) += riscv/pixblockdsp_rvi.o
RVV-OBJS-$(CONFIG_PIXBLOCKDSP) += riscv/pixblockdsp_rvv.o
OBJS-$(CONFIG_VORBIS_DECODER) += riscv/vorbisdsp_init.o
RVV-OBJS-$(CONFIG_VORBIS_DECODER) += riscv/vorbisdsp_rvv.o

View file

@ -33,6 +33,7 @@ void ff_vector_clipf_rvv(float *dst, const float *src, int len, float min, float
av_cold void ff_audiodsp_init_riscv(AudioDSPContext *c)
{
#if HAVE_RV
int flags = av_get_cpu_flags();
if (flags & AV_CPU_FLAG_RVF)
@ -45,4 +46,5 @@ av_cold void ff_audiodsp_init_riscv(AudioDSPContext *c)
if (flags & AV_CPU_FLAG_RVV_F32)
c->vector_clipf = ff_vector_clipf_rvv;
#endif
#endif
}

View file

@ -31,6 +31,7 @@ void ff_bswap16_buf_rvv(uint16_t *dst, const uint16_t *src, int len);
av_cold void ff_bswapdsp_init_riscv(BswapDSPContext *c)
{
#if HAVE_RV
int cpu_flags = av_get_cpu_flags();
#if (__riscv_xlen >= 64)
@ -43,4 +44,5 @@ av_cold void ff_bswapdsp_init_riscv(BswapDSPContext *c)
c->bswap16_buf = ff_bswap16_buf_rvv;
}
#endif
#endif
}

View file

@ -43,6 +43,7 @@ av_cold void ff_pixblockdsp_init_riscv(PixblockDSPContext *c,
AVCodecContext *avctx,
unsigned high_bit_depth)
{
#if HAVE_RV
int cpu_flags = av_get_cpu_flags();
if (cpu_flags & AV_CPU_FLAG_RVI) {
@ -62,4 +63,5 @@ av_cold void ff_pixblockdsp_init_riscv(PixblockDSPContext *c,
c->diff_pixels_unaligned = c->diff_pixels = ff_diff_pixels_rvv;
}
#endif
#endif
}

View file

@ -207,7 +207,7 @@ static int chctx_init(RKAContext *s, ChContext *c,
c->bprob[0] = s->bprob[0];
c->bprob[1] = s->bprob[1];
c->srate_pad = (sample_rate << 13) / 44100 & 0xFFFFFFFCU;
c->srate_pad = ((int64_t)sample_rate << 13) / 44100 & 0xFFFFFFFCU;
c->pos_idx = 1;
for (int i = 0; i < FF_ARRAY_ELEMS(s->bprob[0]); i++)
@ -691,7 +691,7 @@ static int decode_filter(RKAContext *s, ChContext *ctx, ACoder *ac, int off, uns
else
split = size >> 4;
if (size <= 0)
if (size <= 1)
return 0;
for (int x = 0; x < size;) {
@ -723,34 +723,34 @@ static int decode_filter(RKAContext *s, ChContext *ctx, ACoder *ac, int off, uns
last_val = val;
src = &ctx->buf1[off + -1];
for (int i = 0; i < filt.size && i < 15; i++)
sum += filt.coeffs[i] * src[-i];
sum = sum * 2;
sum += filt.coeffs[i] * (unsigned)src[-i];
sum = sum * 2U;
for (int i = 15; i < filt.size; i++)
sum += filt.coeffs[i] * src[-i];
sum += filt.coeffs[i] * (unsigned)src[-i];
sum = sum >> 6;
if (ctx->cmode == 0) {
if (bits == 0) {
ctx->buf1[off] = sum + val;
} else {
ctx->buf1[off] = (val + (sum >> bits) << bits) +
ctx->buf1[off] = (val + (sum >> bits)) * (1U << bits) +
(((1U << bits) - 1U) & ctx->buf1[off + -1]);
}
ctx->buf0[off] = ctx->buf1[off] + ctx->buf0[off + -1];
ctx->buf0[off] = ctx->buf1[off] + (unsigned)ctx->buf0[off + -1];
} else {
val <<= ctx->cmode;
sum += ctx->buf0[off + -1] + val;
val *= 1U << ctx->cmode;
sum += ctx->buf0[off + -1] + (unsigned)val;
switch (s->bps) {
case 16: sum = av_clip_int16(sum); break;
case 8: sum = av_clip_int8(sum); break;
}
ctx->buf1[off] = sum - ctx->buf0[off + -1];
ctx->buf0[off] = sum;
m += FFABS(ctx->buf1[off]);
m += (unsigned)FFABS(ctx->buf1[off]);
}
}
if (ctx->cmode2 != 0) {
int sum = 0;
for (int i = (m << 6) / split; i > 0; i = i >> 1)
for (int i = (signed)((unsigned)m << 6) / split; i > 0; i = i >> 1)
sum++;
sum = sum - (ctx->cmode2 + 7);
ctx->cmode = FFMAX(sum, tab[ctx->cmode2]);

View file

@ -129,8 +129,10 @@ static av_cold int encode_init(AVCodecContext *avctx)
if (ret)
return ret;
ff_set_cmp(&s->mecc, s->mecc.me_cmp, s->avctx->me_cmp);
ff_set_cmp(&s->mecc, s->mecc.me_sub_cmp, s->avctx->me_sub_cmp);
ret = ff_set_cmp(&s->mecc, s->mecc.me_cmp, s->avctx->me_cmp);
ret |= ff_set_cmp(&s->mecc, s->mecc.me_sub_cmp, s->avctx->me_sub_cmp);
if (ret < 0)
return AVERROR(EINVAL);
s->input_picture = av_frame_alloc();
if (!s->input_picture)
@ -1551,10 +1553,10 @@ static void calculate_visual_weight(SnowContext *s, Plane *p){
int level, orientation, x, y;
for(level=0; level<s->spatial_decomposition_count; level++){
int64_t error=0;
for(orientation=level ? 1 : 0; orientation<4; orientation++){
SubBand *b= &p->band[level][orientation];
IDWTELEM *ibuf= b->ibuf;
int64_t error=0;
memset(s->spatial_idwt_buffer, 0, sizeof(*s->spatial_idwt_buffer)*width*height);
ibuf[b->width/2 + b->height/2*b->stride]= 256*16;
@ -1565,9 +1567,13 @@ static void calculate_visual_weight(SnowContext *s, Plane *p){
error += d*d;
}
}
if (orientation == 2)
error /= 2;
b->qlog= (int)(QROOT * log2(352256.0/sqrt(error)) + 0.5);
if (orientation != 1)
error = 0;
}
p->band[level][1].qlog = p->band[level][2].qlog;
}
}

View file

@ -473,7 +473,7 @@ static void predictor_init_state(int *k, int *state, int order)
static int predictor_calc_error(int *k, int *state, int order, int error)
{
int i, x = error - shift_down(k[order-1] * (unsigned)state[order-1], LATTICE_SHIFT);
int i, x = error - (unsigned)shift_down(k[order-1] * (unsigned)state[order-1], LATTICE_SHIFT);
#if 1
int *k_ptr = &(k[order-2]),
@ -1013,7 +1013,7 @@ static int sonic_decode_frame(AVCodecContext *avctx, AVFrame *frame,
if (s->lossless)
quant = 1;
else
quant = get_symbol(&c, state, 0) * SAMPLE_FACTOR;
quant = get_symbol(&c, state, 0) * (unsigned)SAMPLE_FACTOR;
// av_log(NULL, AV_LOG_INFO, "quant: %d\n", quant);

View file

@ -169,6 +169,9 @@ int ff_tak_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb,
if (ti->flags & TAK_FRAME_FLAG_HAS_METADATA)
return AVERROR_INVALIDDATA;
if (get_bits_left(gb) < 24)
return AVERROR_INVALIDDATA;
skip_bits(gb, 24);
return 0;

View file

@ -28,8 +28,8 @@ static void decorrelate_ls(int32_t *p1, int32_t *p2, int length)
int i;
for (i = 0; i < length; i++) {
int32_t a = p1[i];
int32_t b = p2[i];
uint32_t a = p1[i];
uint32_t b = p2[i];
p2[i] = a + b;
}
}
@ -39,8 +39,8 @@ static void decorrelate_sr(int32_t *p1, int32_t *p2, int length)
int i;
for (i = 0; i < length; i++) {
int32_t a = p1[i];
int32_t b = p2[i];
uint32_t a = p1[i];
uint32_t b = p2[i];
p1[i] = b - a;
}
}
@ -50,7 +50,7 @@ static void decorrelate_sm(int32_t *p1, int32_t *p2, int length)
int i;
for (i = 0; i < length; i++) {
int32_t a = p1[i];
uint32_t a = p1[i];
int32_t b = p2[i];
a -= b >> 1;
p1[i] = a;
@ -63,7 +63,7 @@ static void decorrelate_sf(int32_t *p1, int32_t *p2, int length, int dshift, int
int i;
for (i = 0; i < length; i++) {
int32_t a = p1[i];
uint32_t a = p1[i];
int32_t b = p2[i];
b = (unsigned)((int)(dfactor * (unsigned)(b >> dshift) + 128) >> 8) << dshift;
p1[i] = b - a;

View file

@ -31,11 +31,13 @@ int main(void){
#define width 256
#define height 256
int buffer[2][width*height];
short obuffer[width*height];
SnowContext s;
int i;
AVLFG prng;
s.spatial_decomposition_count=6;
s.spatial_decomposition_type=1;
int ret = 0;
s.temp_dwt_buffer = av_calloc(width, sizeof(*s.temp_dwt_buffer));
s.temp_idwt_buffer = av_calloc(width, sizeof(*s.temp_idwt_buffer));
@ -49,24 +51,34 @@ int main(void){
printf("testing 5/3 DWT\n");
for(i=0; i<width*height; i++)
buffer[0][i] = buffer[1][i] = av_lfg_get(&prng) % 54321 - 12345;
buffer[0][i] = buffer[1][i] = av_lfg_get(&prng) % 19000 - 9000;
ff_spatial_dwt(buffer[0], s.temp_dwt_buffer, width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count);
ff_spatial_idwt((IDWTELEM*)buffer[0], s.temp_idwt_buffer, width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count);
for(i=0; i<width*height; i++)
obuffer[i] = buffer[0][i];
ff_spatial_idwt(obuffer, s.temp_idwt_buffer, width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count);
for(i=0; i<width*height; i++)
if(buffer[0][i]!= buffer[1][i]) printf("fsck: %6d %12d %7d\n",i, buffer[0][i], buffer[1][i]);
if(buffer[1][i]!= obuffer[i]) {
printf("fsck: %4dx%4dx %12d %7d\n",i%width, i/width, buffer[1][i], obuffer[i]);
ret = 1;
}
printf("testing 9/7 DWT\n");
s.spatial_decomposition_type=0;
for(i=0; i<width*height; i++)
buffer[0][i] = buffer[1][i] = av_lfg_get(&prng) % 54321 - 12345;
buffer[0][i] = buffer[1][i] = av_lfg_get(&prng) % 11000 - 5000;
ff_spatial_dwt(buffer[0], s.temp_dwt_buffer, width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count);
ff_spatial_idwt((IDWTELEM*)buffer[0], s.temp_idwt_buffer, width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count);
for(i=0; i<width*height; i++)
obuffer[i] = buffer[0][i];
ff_spatial_idwt(obuffer, s.temp_idwt_buffer, width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count);
for(i=0; i<width*height; i++)
if(FFABS(buffer[0][i] - buffer[1][i])>20) printf("fsck: %6d %12d %7d\n",i, buffer[0][i], buffer[1][i]);
if(FFABS(buffer[1][i] - obuffer[i])>20) {
printf("fsck: %4dx%4d %12d %7d\n",i%width, i/width, buffer[1][i], obuffer[i]);
ret = 1;
}
{
int level, orientation, x, y;
@ -81,18 +93,18 @@ int main(void){
int w= width >> (s.spatial_decomposition_count-level);
int h= height >> (s.spatial_decomposition_count-level);
int stride= width << (s.spatial_decomposition_count-level);
DWTELEM *buf= buffer[0];
IDWTELEM *buf= obuffer;
int64_t error=0;
if(orientation&1) buf+=w;
if(orientation>1) buf+=stride>>1;
memset(buffer[0], 0, sizeof(int)*width*height);
buf[w/2 + h/2*stride]= 256*256;
ff_spatial_idwt((IDWTELEM*)buffer[0], s.temp_idwt_buffer, width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count);
memset(obuffer, 0, sizeof(short)*width*height);
buf[w/2 + h/2*stride]= 8*256;
ff_spatial_idwt(obuffer, s.temp_idwt_buffer, width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count);
for(y=0; y<height; y++){
for(x=0; x<width; x++){
int64_t d= buffer[0][x + y*width];
int64_t d= obuffer[x + y*width];
error += d*d;
if(FFABS(width/2-x)<9 && FFABS(height/2-y)<9 && level==2) printf("%8"PRId64" ", d);
}
@ -132,5 +144,5 @@ int main(void){
}
}
return 0;
return ret;
}

View file

@ -1451,7 +1451,7 @@ static int tiff_decode_tag(TiffContext *s, AVFrame *frame)
break;
case TIFF_GRAY_RESPONSE_CURVE:
case DNG_LINEARIZATION_TABLE:
if (count > FF_ARRAY_ELEMS(s->dng_lut))
if (count < 1 || count > FF_ARRAY_ELEMS(s->dng_lut))
return AVERROR_INVALIDDATA;
for (int i = 0; i < count; i++)
s->dng_lut[i] = ff_tget(&s->gb, type, s->le);

View file

@ -408,6 +408,11 @@ static int truemotion1_decode_header(TrueMotion1Context *s)
return AVERROR_PATCHWELCOME;
}
if (s->h & 3) {
avpriv_request_sample(s->avctx, "Frame with height not being a multiple of 4");
return AVERROR_PATCHWELCOME;
}
if (s->w != s->avctx->width || s->h != s->avctx->height ||
new_pix_fmt != s->avctx->pix_fmt) {
av_frame_unref(s->frame);

View file

@ -342,7 +342,7 @@ static int tta_decode_frame(AVCodecContext *avctx, AVFrame *frame,
if (s->channels > 1) {
int32_t *r = p - 1;
for (*p += *r / 2; r > (int32_t*)p - s->channels; r--)
*r = *(r + 1) - *r;
*r = *(r + 1) - (unsigned)*r;
}
cur_chan = 0;
i++;

View file

@ -317,12 +317,13 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
}
if (s->codec_id == AV_CODEC_ID_IFF_ILBM) {
w_align = FFMAX(w_align, 8);
w_align = FFMAX(w_align, 16);
}
*width = FFALIGN(*width, w_align);
*height = FFALIGN(*height, h_align);
if (s->codec_id == AV_CODEC_ID_H264 || s->lowres ||
s->codec_id == AV_CODEC_ID_VC1 || s->codec_id == AV_CODEC_ID_WMV3 ||
s->codec_id == AV_CODEC_ID_VP5 || s->codec_id == AV_CODEC_ID_VP6 ||
s->codec_id == AV_CODEC_ID_VP6F || s->codec_id == AV_CODEC_ID_VP6A
) {
@ -336,6 +337,9 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
// the next rounded up width is 32
*width = FFMAX(*width, 32);
}
if (s->codec_id == AV_CODEC_ID_SVQ3) {
*width = FFMAX(*width, 32);
}
for (i = 0; i < 4; i++)
linesize_align[i] = STRIDE_ALIGN;
@ -637,9 +641,9 @@ static int get_audio_frame_duration(enum AVCodecID id, int sr, int ch, int ba,
if (sr > 0) {
/* calc from sample rate */
if (id == AV_CODEC_ID_TTA)
return 256 * sr / 245;
return 256ll * sr / 245;
else if (id == AV_CODEC_ID_DST)
return 588 * sr / 44100;
return 588ll * sr / 44100;
else if (id == AV_CODEC_ID_BINKAUDIO_DCT) {
if (sr / 22050 > 22)
return 0;

View file

@ -75,8 +75,9 @@ static int vdpau_mpeg_start_frame(AVCodecContext *avctx,
info->f_code[1][0] = s->mpeg_f_code[1][0];
info->f_code[1][1] = s->mpeg_f_code[1][1];
for (i = 0; i < 64; ++i) {
info->intra_quantizer_matrix[i] = s->intra_matrix[i];
info->non_intra_quantizer_matrix[i] = s->inter_matrix[i];
int n = s->idsp.idct_permutation[i];
info->intra_quantizer_matrix[i] = s->intra_matrix[n];
info->non_intra_quantizer_matrix[i] = s->inter_matrix[n];
}
return ff_vdpau_common_start_frame(pic_ctx, buffer, size);

View file

@ -74,8 +74,9 @@ static int vdpau_mpeg4_start_frame(AVCodecContext *avctx,
info->alternate_vertical_scan_flag = s->alternate_scan;
info->top_field_first = s->top_field_first;
for (i = 0; i < 64; ++i) {
info->intra_quantizer_matrix[i] = s->intra_matrix[i];
info->non_intra_quantizer_matrix[i] = s->inter_matrix[i];
int n = s->idsp.idct_permutation[i];
info->intra_quantizer_matrix[i] = s->intra_matrix[n];
info->non_intra_quantizer_matrix[i] = s->inter_matrix[n];
}
ff_vdpau_common_start_frame(pic_ctx, buffer, size);

View file

@ -64,7 +64,7 @@ void FUNC(ff_emulated_edge_mc)(uint8_t *buf, const uint8_t *src,
av_assert2(start_x < end_x && block_w);
w = end_x - start_x;
src += start_y * src_linesize + start_x * sizeof(pixel);
src += start_y * src_linesize + start_x * (ptrdiff_t)sizeof(pixel);
buf += start_x * sizeof(pixel);
// top
@ -87,7 +87,7 @@ void FUNC(ff_emulated_edge_mc)(uint8_t *buf, const uint8_t *src,
buf += buf_linesize;
}
buf -= block_h * buf_linesize + start_x * sizeof(pixel);
buf -= block_h * buf_linesize + start_x * (ptrdiff_t)sizeof(pixel);
while (block_h--) {
pixel *bufp = (pixel *) buf;

View file

@ -38,6 +38,7 @@
#include "codec_internal.h"
#include "decode.h"
#include "get_bits.h"
#include "internal.h"
#include "vorbis.h"
#include "vorbisdsp.h"
#include "vorbis_data.h"
@ -134,7 +135,6 @@ typedef struct vorbis_context_s {
av_tx_fn mdct_fn[2];
uint8_t first_frame;
int64_t initial_pts;
uint32_t version;
uint8_t audio_channels;
uint32_t audio_samplerate;
@ -368,6 +368,10 @@ static int vorbis_parse_setup_hdr_codebooks(vorbis_context *vc)
unsigned codebook_value_bits = get_bits(gb, 4) + 1;
unsigned codebook_sequence_p = get_bits1(gb);
if (!isfinite(codebook_minimum_value) || !isfinite(codebook_delta_value)) {
ret = AVERROR_INVALIDDATA;
goto error;
}
ff_dlog(NULL, " We expect %d numbers for building the codevectors. \n",
codebook_lookup_values);
ff_dlog(NULL, " delta %f minmum %f \n",
@ -1464,6 +1468,9 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc,
unsigned step = FASTDIV(vr->partition_size << 1, dim << 1);
vorbis_codebook codebook = vc->codebooks[vqbook];
if (get_bits_left(gb) <= 0)
return AVERROR_INVALIDDATA;
if (vr_type == 0) {
voffs = voffset+j*vlen;
@ -1839,13 +1846,7 @@ static int vorbis_decode_frame(AVCodecContext *avctx, AVFrame *frame,
if (!vc->first_frame) {
vc->first_frame = 1;
vc->initial_pts = frame->pts;
}
if (frame->pts == vc->initial_pts) {
*got_frame_ptr = 0;
av_frame_unref(frame);
return buf_size;
avctx->internal->skip_samples = len;
}
ff_dlog(NULL, "parsed %d bytes %d bits, returned %d samples (*ch*bits) \n",
@ -1877,6 +1878,7 @@ static av_cold void vorbis_decode_flush(AVCodecContext *avctx)
sizeof(*vc->saved));
}
vc->previous_window = -1;
vc->first_frame = 0;
}
const FFCodec ff_vorbis_decoder = {

Some files were not shown because too many files have changed in this diff Show more