Compare commits

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

325 commits

Author SHA1 Message Date
Brad Smith
ce2b636fe3 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:42:08 -04:00
Brad Smith
c7e3a1b6af 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:41:59 -04:00
Pavel Koshevoy
76913f0b9f 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:06:56 -07:00
Gyan Doshi
f3eb622fc4 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:31:58 +02:00
Gyan Doshi
ebe0f1d2bb 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:51:44 +02:00
Ramiro Polla
76e4a113ae 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:10:44 -04:00
Ramiro Polla
a95bb07897 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:10:20 -04:00
Brad Smith
bfa74c890b 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 19:46:44 -04:00
Timo Rothenpieler
4810ff7d72 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:27:32 +02:00
llyyr
0b7f5b7566
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:45:32 +02:00
Brad Smith
80a676e8ae 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:37:11 -04:00
Andreas Rheinhardt
43de07cd20 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:35:44 +02:00
Brad Smith
d6bec7f83e 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:22:18 -04:00
Brad Smith
537a17a16f avutil/ppc/cpu: Use proper header for OpenBSD PPC CPU detection
Use the proper header for PPC CPU detection code. sys/param.h includes
sys/types, but sys/types.h is the more appropriate header to be used
here.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit beaf172d75)
Signed-off-by: Brad Smith <brad@comstyle.com>
2024-05-18 19:20:44 -04:00
Brad Smith
307df02e1d 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:19:20 -04:00
Eugene Zemtsov
60df6aad93 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:17:44 -03:00
Timo Rothenpieler
201d0e6fc1 avcodec/nvdec: reset bitstream_len/nb_slices when resetting bitstream pointer 2024-03-30 00:22:23 +01:00
James Almer
09f9f1d7ee 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:56:03 -03:00
Frank Plowman
7c2efd6cdc 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>
2024-03-15 00:27:10 +01:00
Frank Plowman
72281adec0 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>
2024-03-15 00:26:54 +01:00
Christopher Degawa
2142d6e410 avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
compressed_ten_bit_format has been deprecated upstream and has no effect
and can be removed. Plus, technically it was never used in the first place
since it would require the app (ffmpeg) to set it and do additional
processing of the input frames.

Also simplify alloc_buffer by removing calculations relating to the
non-existant processing.

Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
2024-03-15 00:23:32 +01:00
Rémi Denis-Courmont
b0e2146b06 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>
2024-03-13 03:26:12 +01:00
Jan Ekström
6073fff84d 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:39:15 +02:00
James Almer
4f9c230f42 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:48:27 -03:00
Hendrik Leppkes
536cd25b99
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:43:40 +02:00
Hendrik Leppkes
8ea65672ca
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:43:40 +02:00
Hendrik Leppkes
a2c62be31d
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:43:40 +02:00
Hendrik Leppkes
5086261af4
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:43:39 +02:00
Anton Khirnov
e30302c636 fftools/ffmpeg: avoid possible invalid reads with short -tag values
Fixes #10319 and #10309.

Based on 89c9a3ac35.

(cherry picked from commit 1e413487bf)
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2023-04-17 12:22:18 +02:00
Kyle Manning
f6facaf8c9 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:10:22 +02:00
Michael Niedermayer
0e15444ace
update for 5.0.3
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-04-02 16:21:05 +02:00
Michael Niedermayer
4e8da0dc22
avcodec/tests/snowenc: Fix 2nd test
(cherry picked from commit 163013c724)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-03-27 13:37:26 +02:00
Michael Niedermayer
1fca7ff2be
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-03-27 13:37:25 +02:00
Michael Niedermayer
a9655efa6f
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-03-27 13:37:25 +02:00
Michael Niedermayer
8ec5085898
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-03-27 13:37:25 +02:00
Jiasheng Jiang
481e81be12
avformat/nutdec: Add check for avformat_new_stream
Check for failure of avformat_new_stream() and propagate
the error code.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 9cf652cef4)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-03-27 13:37:24 +02:00
Jiasheng Jiang
2cdddcd6ec
avcodec/vp3: Add missing check for av_malloc
Since the av_malloc() may fail and return NULL pointer,
it is needed that the 's->edge_emu_buffer' should be checked
whether the new allocation is success.

Fixes: d14723861b ("VP3: fix decoding of videos with stride > 2048")
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
(cherry picked from commit 656cb0450a)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-03-27 13:37:24 +02:00
Michael Niedermayer
9097001f80
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-03-27 13:37:24 +02:00
Michael Niedermayer
54326fd8d8
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-03-27 13:37:23 +02:00
Michael Niedermayer
35977631a2
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-03-27 13:37:23 +02:00
Michael Niedermayer
49872ca447
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-03-27 13:37:23 +02:00
Paul B Mahol
1eb002596e
avcodec/rpzaenc: stop accessing out of bounds frame
(cherry picked from commit 92f9b28ed8)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-03-27 13:37:22 +02:00
Paul B Mahol
293dc39bca
avcodec/smcenc: stop accessing out of bounds frame
(cherry picked from commit 13c1310975)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-03-27 13:37:22 +02:00
Michael Niedermayer
f380b1d22a
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-03-27 13:37:22 +02:00
Michael Niedermayer
bee5541a44
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-03-27 13:37:21 +02:00
Michael Niedermayer
1c9136ddd7
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-03-27 13:37:21 +02:00
Michael Niedermayer
fb895f9d4d
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-03-27 13:37:21 +02:00
Michael Niedermayer
1e22a8a9d0
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-03-27 13:37:20 +02:00
Michael Niedermayer
8ed2948348
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-03-27 13:37:20 +02:00
Michael Niedermayer
9fc6586a00
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-03-27 13:37:20 +02:00
Michael Niedermayer
904836c89f
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-03-27 13:37:19 +02:00
Michael Niedermayer
ebdeef043a
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-03-27 13:37:19 +02:00
Michael Niedermayer
520af24c77
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-03-27 13:37:19 +02:00
Michael Niedermayer
33785a4fd9
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-03-27 13:37:18 +02:00
Michael Niedermayer
123181bca4
avcodec/pictordec: Remove mid exit branch
This causes the RLE decoder to exit before applying the last RLE run
All images i tested with are unchanged, this makes the special case
for handling the last run unused for non truncated images.

Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 88f0e05c72)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-03-27 13:37:18 +02:00
Michael Niedermayer
6c9e472672
avcodec/eac3dec: avoid float noise in fixed mode addition to overflow
Fixes: 2.28595e+09 is outside the range of representable values of type 'int'
Fixes: 54644/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AC3_FIXED_fuzzer-4816961584627712

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 2f48d227c1)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-03-27 13:37:18 +02:00
Michael Niedermayer
b810bd948f
avcodec/utils: use 32pixel alignment for bink
bink supports 16x16 blocks in chroma planes thus we need to allocate enough.
Fixes: out of array access
Fixes: 55026/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_BINK_fuzzer-6013915371012096
Reviewed-by: Peter Ross <pross@xvid.org>

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 b95b2c8492)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-03-27 13:37:17 +02:00
Michael Niedermayer
15eaacfa5c
avcodec/scpr3: Check bx
Fixes: Out of array access
Fixes: 55102/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SCPR_fuzzer-4877396618903552

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 cc7e984a05)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-03-27 13:37:17 +02:00
Michael Niedermayer
9e9360e4c8
avcodec/012v: Order operations for odd size handling
Fixes: out of array access
Fixes: 48567/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ZERO12V_fuzzer-6714182078955520.fuzz
Fixes: 48567/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ZERO12V_fuzzer-6698145212137472.fuzz

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 4d42d82563)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-03-27 13:37:17 +02:00
Michael Niedermayer
1a6f5b0ff4
avcodec/eatgq: : Check index increments in tgq_decode_block()
Fixes: out of array access
Fixes: 48567/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EATGQ_fuzzer-6743211456724992

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 e7755b433e)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-03-27 13:37:16 +02:00
Michael Niedermayer
892bafba0e
avcodec/h274: fix include
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 379e43e6ec)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-03-27 13:37:16 +02:00
Michael Niedermayer
d33eae03aa
avcodec/scpr: Test bx before use
Fixes: out of array access on 32bit
Fixes: 54850/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SCPR_fuzzer-5302669294305280

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 1b59de3770)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-03-27 13:37:16 +02:00
Michael Niedermayer
a2d13b294c
avformat/mxfdec: Use 64bit in remainder
Fixes: signed integer overflow: 48000 * 223587 cannot be represented in type 'int'
Fixes: 54513/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5817594836025344

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 64a04fc165)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-03-27 13:37:15 +02:00
Michael Niedermayer
63fc122f5c
avcodec/sunrast: Fix maplength check
Fixes: out of bounds read

Found-by: Ibrahim Mohamed <ielsayed@meta.com>
Reviewed-by; Ibrahim Mohamed <ielsayed@meta.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit f8a2a65078)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-03-27 13:37:15 +02:00
Michael Niedermayer
21e30231d8
avcodec/wavpack: Avoid undefined shift in get_tail()
Fixes: left shift of 1208485947 by 1 places cannot be represented in type 'int'
Fixes: 54058/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WAVPACK_fuzzer-5827521084260352

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 8374a747af)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-03-27 13:37:15 +02:00
Michael Niedermayer
957d9a40b2
avcodec/wavpack: Check for end of input in wv_unpack_dsd_high()
Fixes: Timeout
Fixes: 50793/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WAVPACK_fuzzer-4980185027444736

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 6ad7403bce)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-03-27 13:37:14 +02:00
Michael Niedermayer
f75911ee66
avformat/id3v2: Check taglen in read_uslt()
Fixes: Timeout (read mostly the same data repeatly)
Fixes: 52457/clusterfuzz-testcase-minimized-ffmpeg_dem_ALP_fuzzer-6610706313379840
Fixes: 53098/clusterfuzz-testcase-minimized-ffmpeg_dem_SOL_fuzzer-6481382981632000

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 a798af91d7)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-03-27 13:37:14 +02:00
Michael Niedermayer
da325c45d9
avcodec/tiff: Ignore tile_count
Fixes: out of array access
Fixes: 52427/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-4849108968144896

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 65ce417828)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-03-27 13:37:14 +02:00
Michael Niedermayer
4f91373918
avcodec/ffv1dec: restructure slice coordinate reading a bit
Fixes: signed integer overflow: -1094995528 * 8224 cannot be represented in type 'int'
Fixes: 53508/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFV1_fuzzer-474551033462784

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 74b6ac7ebb)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-03-27 13:37:13 +02:00
Michael Niedermayer
f547b05e78
avcodec/mlpdec: Check max matrix instead of max channel in noise check
This is a regression since: adaa06581c
Before this, max_channel and  max_matrix_channel where compared for equality

Fixes: out of array access
Fixes: 53340/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TRUEHD_fuzzer-514959011885875

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 aa79560de5)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-03-27 13:37:13 +02:00
Michael Niedermayer
1f07ecd632
swscale/input: Use more unsigned intermediates
Same principle as previous commit, with sufficiently huge rgb2yuv table
values this produces wrong results and undefined behavior.
The unsigned produces the same incorrect results. That is probably
ok as these cases with huge values seem not to occur in any real
use case.

Fixes: signed integer overflow
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit ba209e3d51)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-03-27 13:37:13 +02:00
Michael Niedermayer
9ea6ebd12a
avcodec/alsdec: The minimal block is at least 7 bits
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 5280947fb6)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-03-27 13:37:12 +02:00
Michael Niedermayer
889a295384
avformat/replaygain: avoid undefined / negative abs
Fixes: signed integer overflow: -2147483648 * 100000 cannot be represented in type 'int'
Fixes: 52060/clusterfuzz-testcase-minimized-ffmpeg_dem_MP3_fuzzer-5131616708329472

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 2532b20b17)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-03-27 13:37:12 +02:00
Michael Niedermayer
2334da0faa
swscale/output: Bias 16bps output calculations to improve non overflowing range
Fixes: integer overflow
Fixes: ./ffmpeg   -f rawvideo -video_size 66x64 -pixel_format yuva420p10le   -i ~/videos/overflow_input_w66h64.yuva420p10le   -filter_complex "scale=flags=bicubic+full_chroma_int+full_chroma_inp+bitexact+accurate_rnd:in_color_matrix=bt2020:out_color_matrix=bt2020:in_range=full:out_range=full,format=rgba64[out]"   -pixel_format rgba64 -map '[out]'   -y overflow_w66h64.png

Found-by: Drew Dunne <asdunne@google.com>
Tested-by: Drew Dunne <asdunne@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 0f0afc7fb5)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-03-27 13:37:12 +02:00
Michael Niedermayer
486bba4698
avcodec/speedhq: Check buf_size to be big enough for DC
Fixes: Timeout
Fixes: 51919/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SPEEDHQ_fuzzer-6023716480090112

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 9184d3d7b6)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-03-27 13:37:11 +02:00
Michael Niedermayer
100c16ace3
avcodec/ffv1dec: Fail earlier if prior context is corrupted
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 4df91e2215)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-03-27 13:36:53 +02:00
James Almer
4249a81c31 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:09:54 -03:00
Lynne
376a1ebfcb hwcontext_vulkan: remove optional encode/decode extensions from the list
They're not currently used, so they don't need to be there.
Vulkan stabilized the decode extensions less than a week ago, and their
name prefixes were changed from EXT to KHR. It's a bit too soon to be
depending on it, so rather than bumping, just remove these for now.

(cherry picked from commit eb0455d646)
2023-02-06 17:45:54 +02:00
Timo Rothenpieler
df2e08e452 avcodec/nvenc: fix vbv buffer size in cq mode
The CQ calculation gets thrown off and behaves very nonsensical
if it isn't set to 0.
2022-12-08 12:39:18 +01:00
James Almer
c77210491a avcodec/mjpegenc: take into account component count when writing the SOF header size
Fixes ticket #10069

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 1009396953)
2022-11-28 08:44:40 -03:00
Michael Niedermayer
2f428de9eb
Changelog: update
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-11-04 21:19:58 +01:00
Martin Storsjö
7bc6dab675 swscale: aarch64: Fix yuv2rgb with negative strides
Treat the 32 bit stride registers as signed.

Alternatively, we could make the stride arguments ptrdiff_t instead
of int, and changing all of the assembly to operate on these
registers with their full 64 bit width, but that's a much larger
and more intrusive change (and risks missing some operation, which
would clamp the intermediates to 32 bit still).

Fixes: https://trac.ffmpeg.org/ticket/9985

Signed-off-by: Martin Storsjö <martin@martin.st>
(cherry picked from commit cb803a0072)
Signed-off-by: Martin Storsjö <martin@martin.st>
2022-11-04 14:28:37 +02:00
James Almer
e2a529bdca avcodec/atrac3plusdec: fix compilation failure after last commit
Signed-off-by: James Almer <jamrial@gmail.com>
2022-11-04 09:12:19 -03:00
James Almer
9a15221731 avcodec/atrac3plus: reorder channels to match the output layout
The order in which the channels are coded in the bitstream do not always follow
the native, bitmask-based order of channels both signaled by the WAV container
and forced by this same decoder. This is the case with layouts containing an
LFE channel, as it's always coded last.

Fixes ticket #9964.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 3819719099)
2022-11-04 09:06:50 -03:00
James Almer
c351fdc0c6 avcodec/aacdec: fix parsing streams with channel configuration 11
Set the correct amount of tags in tags_per_config[].
Also, there are no channels that correspond to a side element in this
configuration, so reflect this in the list of known/supported channel layouts.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 8c7d3b43cc)
2022-11-04 09:04:41 -03:00
Michael Niedermayer
1a8defb281
Changelog: update
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-11-04 11:07:53 +01:00
Michael Niedermayer
59fe00912a
avcodec/speexdec: Check channels > 2
More than 2 channels seems unsupported, the code seems to just output empty extra channels

Fixes: Timeout
Fixes: 51569/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SPEEX_fuzzer-5511509165342720

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 77164b2344)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-11-03 23:29:55 +01:00
Michael Niedermayer
e4c5c90493
avformat/vividas: Check packet size
Fixes: signed integer overflow: 119760682 - -2084600173 cannot be represented in type 'int'
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_VIVIDAS_fuzzer-6745781167587328

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 5f44489cc5)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-11-03 23:29:55 +01:00
Michael Niedermayer
2376a4d5a7
avcodec/dstdec: Check for overflow in build_filter()
Fixes: signed integer overflow: 1917019860 + 265558963 cannot be represented in type 'int'
Fixes: 48798/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DST_fuzzer-4833165046317056

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 8008940da5)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-11-03 23:29:54 +01:00
Michael Niedermayer
831a251ac6
avformat/spdifdec: Use 64bit to compute bit rate
Fixes: signed integer overflow: 32 * 553590816 cannot be represented in type 'int'
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_WAV_fuzzer-6564974517944320

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 4075f0cec1)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-11-03 23:29:54 +01:00
Michael Niedermayer
109a9f366b
avformat/rpl: Use 64bit for duration computation
Fixes: signed integer overflow: 24709512 * 88 cannot be represented in type 'int'
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-6737973728641024

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 529f64b2eb)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-11-03 23:29:54 +01:00
Michael Niedermayer
45ec9713c7
avformat/xwma: Use av_rescale() for duration computation
Fixes: signed integer overflow: 34242363648 * 538976288 cannot be represented in type 'long'
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-6577923913547776

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 2c789f753c)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-11-03 23:29:53 +01:00
Michael Niedermayer
c895e6d0b3
avformat/sdsdec: Use av_rescale() to avoid intermediate overflow in duration calculation
Fixes: signed integer overflow: 72128794995445727 * 240 cannot be represented in type 'long'
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_SDS_fuzzer-6628185583779840

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 aa8eb1bed0)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-11-03 23:29:53 +01:00
Michael Niedermayer
ba1b943c05
avformat/sbgdec: Check ts_int in genrate_intervals
There is probably a better place to check for this, but better
here than nowhere

Fixes: signed integer overflow: -9223372036824775808 - 86400000000 cannot be represented in type 'long'
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_SBG_fuzzer-6601162580688896

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 5f529e9147)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-11-03 23:29:53 +01:00
Michael Niedermayer
eff1e619a9
avformat/sbgdec: clamp end_ts
Fixes: signed integer overflow: 9223372036851135042 + 15666854 cannot be represented in type 'long'
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_SBG_fuzzer-6573717339111424

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 981f5e46af)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-11-03 23:29:52 +01:00
Michael Niedermayer
626094b9d3
avformat/rmdec: check tag_size
Fixes: signed integer overflow: -2147483648 - 8 cannot be represented in type 'int'
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_RM_fuzzer-6598073725353984

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 2cb7ee8a36)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-11-03 23:29:52 +01:00
Michael Niedermayer
cdf35ba1d1
avformat/nutdec: Check fields
Fixes: signed integer overflow: -2147483648 - 1 cannot be represented in type 'int'
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_NUT_fuzzer-6566001610719232

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 2c146406ea)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-11-03 23:29:52 +01:00
Michael Niedermayer
8ba8071507
avformat/flvdec: Use 64bit for sum_flv_tag_size
Fixes: signed integer overflow: 2138820085 + 16130322 cannot be represented in type 'int'
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_LIVE_FLV_fuzzer-6704728165187584

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 7124f10c1d)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-11-03 23:29:51 +01:00
Michael Niedermayer
b8d29eab19
avformat/jacosubdec: Fix overflow in get_shift()
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_JACOSUB_fuzzer-6722544461283328
Fixes: signed integer overflow: 48214448 * 60 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 b1a68127bb)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-11-03 23:29:51 +01:00
Michael Niedermayer
622893afe3
avformat/dxa: avoid bpc overflows
Fixes: signed integer overflow: 2147483647 + 32 cannot be represented in type 'int'
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_DXA_fuzzer-6639823726706688

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 93db0f0740)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-11-03 23:29:51 +01:00
Michael Niedermayer
ad15735158
avformat/dhav: Use 64bit seek_back
Fixes: negation of -2147483648 cannot be represented in type 'int'; cast to an unsigned type to negate this value to itself
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_DHAV_fuzzer-6604736532447232

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 10453f5192)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-11-03 23:29:50 +01:00
Michael Niedermayer
91376b3cc4
avformat/cafdec: Check that nb_frasmes fits within 64bit
Fixes: signed integer overflow: 1099511693312 * 538976288 cannot be represented in type 'long'
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_CAF_fuzzer-6565048815845376

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 d4bb4e3759)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-11-03 23:29:50 +01:00
Michael Niedermayer
eef9a44445
avformat/asfdec_o: Limit packet offset
avoids overflows with it

Fixes: signed integer overflow: 9223372036846866010 + 4294967047 cannot be represented in type 'long'
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_ASF_O_fuzzer-6538296768987136
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_ASF_O_fuzzer-657169555665715

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 736e9e69d5)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-11-03 23:29:50 +01:00
Michael Niedermayer
a00c812a9b
avformat/ape: Check frames size
Fixes: signed integer overflow: 9223372036854775806 + 3 cannot be represented in type 'long'
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_APE_fuzzer-6389264140599296

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 d0349c9929)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-11-03 23:29:49 +01:00
Michael Niedermayer
35d5d2a4b2
avformat/icodec: Check nb_pal
Fixes: signed integer overflow: 538976288 * 4 cannot be represented in type 'int'
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_ICO_fuzzer-6690068904935424

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit db73ae0dc1)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-11-03 23:29:49 +01:00
Michael Niedermayer
2a6e750c87
avformat/aiffdec: Use 64bit for block_duration use
Fixes: signed integer overflow: 3 * -2147483648 cannot be represented in type 'int'
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_AIFF_fuzzer-6668935979728896

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 9303ba272e)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-11-03 23:29:49 +01:00
Michael Niedermayer
ed455b98d0
avformat/aiffdec: Check block_duration
Fixes: signed integer overflow: 3 * -2147483648 cannot be represented in type 'int'
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_AIFF_fuzzer-6668935979728896

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 1c2b6265c8)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-11-03 23:29:48 +01:00
Michael Niedermayer
1bc5684211
avformat/mxfdec: only probe max run in
Suggested-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 1182bbb2c3)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-11-03 23:29:48 +01:00
Michael Niedermayer
51ccf7f5c6
avformat/mxfdec: Check run_in is within 65536
Fixes: signed integer overflow: 9223372036854775807 - -2146905566 cannot be represented in type 'long'
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_MXF_fuzzer-6570996594769920

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 7786097825)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-11-03 23:29:48 +01:00
Michael Niedermayer
cef1c6311d
avcodec/mjpegdec: Check for unsupported bayer case
Fixes: out of array access
Fixes: 51462/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-662559341582745

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 dd81cc22b3)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-11-03 23:29:47 +01:00
Michael Niedermayer
d597343321
avcodec/apedec: Fix integer overflow in filter_3800()
Fixes: signed integer overflow: -2147448926 + -198321 cannot be represented in type 'int'
Fixes: 48798/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-5739619273015296
Fixes: 48798/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-6744428485672960

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 f05247f6a4)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-11-03 23:29:47 +01:00
Michael Niedermayer
d282d019c2
avcodec/tta: Check 24bit scaling for overflow
Fixes: signed integer overflow: -8427924 * 256 cannot be represented in type 'int'
Fixes: 48798/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TTA_fuzzer-5409428670644224

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 3993345f91)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-11-03 23:29:47 +01:00
Michael Niedermayer
4dcc092a5a
avcodec/mobiclip: Check quantizer for overflow
Fixes: signed integer overflow: 127 + 2147483536 cannot be represented in type 'int'
Fixes: 48798/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MOBICLIP_fuzzer-6014034970804224

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 677e27a9af)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-11-03 23:29:47 +01:00
Michael Niedermayer
ef8a0dc800
avcodec/exr: Check preview psize
Fixes: signed integer overflow: 17121181824 * 538976288 cannot be represented in type 'long long'
Fixes: 48798/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EXR_fuzzer-5915330316206080

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 ac26712e35)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-11-03 23:29:46 +01:00
Michael Niedermayer
db51f193e4
avcodec/tiff: Fix loop detection
Fixes regression with tickets/4364/L1004220.DNG

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 43a4854510)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-11-03 23:29:46 +01:00
Michael Niedermayer
71dd8b8da0
libavformat/hls: Free keys
Fixes: memleak
Fixes: 50703/clusterfuzz-testcase-minimized-ffmpeg_dem_HLS_fuzzer-6399058578636800

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit d32a9f3137)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-11-03 23:29:46 +01:00
Michael Niedermayer
728b3bc74e
avcodec/fmvc: Move frame allocation to a later stage
This way more things are checked before allocation

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 9783749c66)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-11-03 23:29:45 +01:00
Michael Niedermayer
6535e158f9
avfilter/vf_showinfo: remove backspaces
They mess with storing editing and comparing the results

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 31581ae7ee)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-11-03 23:29:45 +01:00
Michael Niedermayer
14ec214d5c
avcodec/speedhq: Check width
Fixes: out of array access
Fixes: 50014/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SPEEDHQ_fuzzer-4748914632294400

Alternatively the buffer size can be increased

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 f0395f9ef6)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-11-03 23:29:45 +01:00
Michael Niedermayer
1f3236ac1e
avcodec/bink: disallow odd positioned scaled blocks
Fixes: out of array access
Fixes: 47911/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_BINK_fuzzer-6194020855971840

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 b14104a637)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-11-03 23:29:27 +01:00
Chema Gonzalez
a00072a9d5 libswscale: force a minimum size of the slide for bayer sources
Bayer sources are read in groups of 2 lines (e.g. for a
BGGR flavor, the first row contains only B and G samples,
while the second row contains only G and R samples). They
need to be read as a whole.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
(cherry picked from commit bf64a75c5a)
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2022-10-14 12:25:40 +02:00
Anton Khirnov
ddf3bedfb8 lavc/videotoolbox: do not pass AVCodecContext to decoder output callback
The opaque parameter for the callback is set in videotoolbox_start(),
called when the hwaccel is initialized. When frame threading is used,
avctx will be the context corresponding to the frame thread currently
doing the decoding. Using this same codec context in all subsequent
invocations of the decoder callback (even those triggered by a different
frame thread) is unsafe, and broken after
cc867f2c09, since each frame thread now
cleans up its hwaccel state after decoding each frame.

Fix this by passing hwaccel_priv_data as the opaque parameter, which
exists in a single instance forwarded between all frame threads.

The only other use of AVCodecContext in the decoder output callback is
as a logging context. For this purpose, store a logging context in
hwaccel_priv_data.

(cherry picked from commit d7f4ad88a0)
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2022-09-25 10:01:34 +02:00
Anton Khirnov
fe741cd0af lavc/pthread_frame: always transfer stashed hwaccel state
Fixes assertion failures after avcodec_flush_buffers(), where
stashed hwaccel state is present, but prev_thread is NULL.

Found-by: Wang Bin <wbsecg1@gmail.com>
(cherry picked from commit c504fb8692)
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2022-09-25 10:01:34 +02:00
James Almer
57e15b2e07 avformat/cafenc: derive Opus frame size from the relevant stream parameters
Use the stream duration as last resort, as an off-by-one result of the
"st->duration / (caf->packets - 1)" calculation can break playback on some
devices.
Also, don't write the sample_rate value propagated by encoders like libopus.
The sample rate of the audio fed to it is irrelevant after being encoded.

Fixes ticket #9930.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit aa79d13f51)
2022-09-24 12:23:50 -03:00
James Cowgill
c1b8ffbed8 avcodec/arm/sbcenc: avoid callee preserved vfp registers
When compiling FFmpeg with GCC-9, some very random segfaults were
observed in code which had previously called down into the SBC encoder
NEON assembly routines. This was caused by these functions clobbering
some of the vfp callee saved registers (d8 - d15 aka q4 - q7). GCC was
using these registers to save local variables, but after these
functions returned, they would contain garbage.

Fix by reallocating the registers in the two affected functions in
the following way:
 ff_sbc_analyze_4_neon: q2-q5 => q8-q11, then q1-q4 => q8-q11
 ff_sbc_analyze_8_neon: q2-q9 => q8-q15

The reason for using these replacements is to keep closely related
sets of registers consecutively numbered which hopefully makes the
code more easy to follow. Since this commit only reallocates
registers, it should have no performance impact.

Signed-off-by: James Cowgill <jcowgill@debian.org>
Signed-off-by: Martin Storsjö <martin@martin.st>
(cherry picked from commit 50a4dff69f)
Signed-off-by: Martin Storsjö <martin@martin.st>
2022-09-20 11:21:45 +03:00
James Almer
068faf4f74 avfilter/vf_scale: overwrite the width and height expressions with the original values
Instead of the potentially adjusted ones. Otherwise, if config_props() is
called again and if using force_original_aspect_ratio, the already adjusted
values could be altered again.

Example command line
scale=size=1920x1000:force_original_aspect_ratio=decrease:force_divisible_by=2

user value 1920x1000 -> 1920x798 on init_dict() -> 1918x798 on frame
change when eval_mode == EVAL_MODE_INIT, which after e645a1ddb9 could be at the
very first frame.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit d9e3cb7e73)
2022-09-07 20:37:54 -03:00
Anton Khirnov
3bc28e9d1a lavc/pthread_frame: avoid leaving stale hwaccel state in worker threads
This state is not refcounted, so make sure it always has a well-defined
owner.

Remove the block added in 091341f2ab, as
this commit also solves that issue in a more general way.

(cherry picked from commit cc867f2c09)
Signed-off-by: Anton Khirnov <anton@khirnov.net>
(cherry picked from commit 35aa7e70e7)
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2022-09-06 09:42:34 +02:00
Michael Niedermayer
491bf78721
Update for 5.0.2
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
9b4f9233c3
avformat/asfdec_o: limit recursion depth in asf_read_unknown()
The threshold of 5 is arbitrary, both smaller and larger should work fine

Fixes: Stack overflow
Fixes: 50603/clusterfuzz-testcase-minimized-ffmpeg_dem_ASF_O_fuzzer-6049302564175872

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 1f1a368169)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
3c293ad92c
doc/git-howto.texi: Document commit signing
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit ced0dc807e)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
a221a3bfaf
libavcodec/8bps: Check that line lengths fit within the buffer
Fixes: Timeout
Fixes: undefined pointer arithmetic
Fixes: 50330/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EIGHTBPS_fuzzer-5436287485607936

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 2316d5ec1a)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
9e92d14dbf
avcodec/midivid: Perform lzss_uncompress() before ff_reget_buffer()
This would avoid regeting the frame on lzss errors

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 628fb97efb)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
b24407a9ba
libavformat/iff: Check for overflow in body_end calculation
Fixes: signed integer overflow: -6322983228386819992 - 5557477266266529857 cannot be represented in type 'long'
Fixes: 50112/clusterfuzz-testcase-minimized-ffmpeg_dem_IFF_fuzzer-6329186221948928

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 bcb4690304)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
74f855fed2
avformat/avidec: Prevent entity expansion attacks
Fixes: Timeout
Fixes no testcase, this is the same idea as similar attacks against XML parsers

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit f3e823c2aa)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
408c0c43d7
avcodec/h263dec: Sanity check against minimal I/P frame size
Fixes: Timeout
Fixes: 49718/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPEG4_fuzzer-4874987894341632

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 ca4ff9c21c)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
d246af82c2
avcodec/hevcdec: Check s->ref in the md5 path similar to hwaccel
This is somewhat redundant with the is_decoded check. Maybe
there is a nicer solution

Fixes: Null pointer dereference
Fixes: 49584/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-5297367351427072

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 3b51e19922)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
a90844d443
avcodec/mpegaudiodec_template: use unsigned shift in handle_crc()
Fixes: left shift of 192 by 24 places cannot be represented in type 'int'
Fixes: 49577/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MP1FLOAT_fuzzer-5205996678545408

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 7086491fa0)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
50698086ee
avformat/subviewerdec: Make read_ts() more flexible
Fixes: signed integer overflow: -1948269928 * 10 cannot be represented in type 'int'
Fixes: 49451/clusterfuzz-testcase-minimized-ffmpeg_dem_SUBVIEWER_fuzzer-6344614822412288

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
(cherry picked from commit 58a8e739ef)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
7ce588047b
avcodec/mjpegdec: bayer and rct are incompatible
Fixes: out of array read
Fixes: 49434/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-5208501080686592

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 a44f5a5212)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
e9e4d21911
MAINTAINERS: Add ED25519 key for signing my commits in the future
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 05225180be)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
c2cb656667
avcodec/hevc_filter: copy_CTB() only within width&height
Fixes: out of array access
Fixes: 49271/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-5424984922652672

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 009ef35d38)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
447c1942ce
avcodec/tiff: Check tile_length and tile_width
Fixes: Division by 0
Fixes: 49235/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-5495613847896064

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 76112c2b41)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
b821f224fb
avcodec/mss4: Check image size with av_image_check_size2()
Fixes: Timeout
Fixes: 48418/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MTS2_fuzzer-4834851466903552

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 4e145f1dcd)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
904cb851ce
avformat/flvdec: Check for EOF in index reading
Fixes: Timeout
Fixes: 47992/clusterfuzz-testcase-minimized-ffmpeg_dem_LIVE_FLV_fuzzer-6020443879899136

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 ceff5d7b74)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
c39b1d310a
avformat/nutdec: Check get_packetheader() in mainheader
Fixes; Timeout
Fixes: 48794/clusterfuzz-testcase-minimized-ffmpeg_dem_NUT_fuzzer-6524604713140224

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 b5de084aa6)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
04dabb241b
avformat/asfdec_f: Use 64bit for packet start time
Fixes: signed integer overflow: 2147483647 + 32 cannot be represented in type 'int'
Fixes: 49014/clusterfuzz-testcase-minimized-ffmpeg_dem_ASF_fuzzer-6314973315334144

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 8ed78486fc)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
aeaa86aacd
avcodec/exr: Check x/ysize
Fixes: OOM
Fixes: 48911/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EXR_fuzzer-6352002510094336

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 614a4d1476)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
a158789f0d
tools/target_dec_fuzzer: Adjust threshold for MMVIDEO
Fixes: Timeout
Fixes: 49003/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MMVIDEO_fuzzer-5550368423018496

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 3592b05c84)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
f22b7e65c5
avcodec/lagarith: Check dst/src in zero run code
Fixes: out of array access
Fixes: 48799/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_LAGARITH_fuzzer-4764457825337344

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 9450f75974)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
fe026fd0cb
avcodec/h264dec: Skip late SEI
Fixes: Race condition
Fixes: clusterfuzz-testcase-minimized-mediasource_MP2T_AVC_pipeline_integration_fuzzer-6282675434094592

Found-by: google ClusterFuzz
Tested-by: Dan Sanders <sandersd@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit f7dd408d64)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
1fbd6f8d05
avcodec/sbrdsp_fixed: Fix integer overflows in sbr_qmf_deint_neg_c()
Fixes: signed integer overflow: 2147483645 + 16 cannot be represented in type 'int'
Fixes: 46993/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AAC_FIXED_fuzzer-4759025234870272

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 1537f40516)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
e028020213
avfilter/vf_signature: Fix integer overflow in filter_frame()
Fixes: CID1403233

The second of the 2 changes may be unneeded but will help coverity

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit dd6040675e)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
273a3c5b82
avformat/rtsp: break on unknown protocols
This function needs more cleanup and it lacks error handling

Fixes: use of uninitialized memory
Fixes: CID700776

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 73c0fd27c5)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
c03f09f6f4
avcodec/hevcdsp_template: stay within tables in sao_band_filter()
Fixes: out of array read
Fixes: 47875/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-5719393113341952

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 9c5250a561)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
5bf38f660c
avcodec/tiff: Check pixel format types for dng
Fixes: out of array access
Fixes: 48271/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-6149705769287680

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 75f3d1b822)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
dac6f854a9
avcodec/qpeldsp: copy less for the mc0x cases
Fixes: out of array access
Fixes: 47936/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPEG4_fuzzer-5745039940124672

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 e690d4edf5)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
024b94bab3
avformat/aaxdec: Check for empty segments
Fixes: Timeout
Fixes: 48154/clusterfuzz-testcase-minimized-ffmpeg_dem_AAX_fuzzer-5149094353436672

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 db31b3ea86)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
89685f280a
avcodec/ffv1dec: Limit golomb rice coded slices to width 8M
This limit is possibly not reachable due to other restrictions on buffers but
the decoder run table is too small beyond this, so explicitly check for it.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit b4431399ec)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
b5fc01adbe
avformat/iff: simplify duration calculation
Fixes: signed integer overflow: 315680096256 * 134215943 cannot be represented in type 'long long'
Fixes: 48713/clusterfuzz-testcase-minimized-ffmpeg_dem_IFF_fuzzer-5886272312311808

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 0740641e93)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
048f3714c2
avcodec/wnv1: Check for width =1
The decoder only outputs pixels for width >1 images, fail early

Fixes: Timeout
Fixes: 48298/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WNV1_fuzzer-6198626319204352

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 d98d5a436a)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
ae8aabe398
avcodec/ffv1dec_template: fix indention
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit eee7364c90)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
47dc801ec0
avformat/sctp: close socket on errors
This is untested as i have no testcase

Fixes: CID1302709

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c9a2996544)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
abbf22ac63
avformat/cinedec: Check size and pos more
Fixes: signed integer overflow: 9223372036848019263 + 134232320 cannot be represented in type 'long'
Fixes: 48155/clusterfuzz-testcase-minimized-ffmpeg_dem_CINE_fuzzer-5751429207293952

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 884a108121)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
ab936ed53e
avcodec/aasc: Fix indention
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit af2ed09220)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
0ba8bf7011
avcodec/qdrw: adjust max colors to array size
Fixes: out of array access
Fixes: 48429/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_QDRAW_fuzzer-4608329791438848

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 cd847f86d3)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
b03a42587f
avcodec/alacdsp: Make intermediates unsigned
Fixes: signed integer overflow: -14914387 + -2147418648 cannot be represented in type 'int'
Fixes: 46464/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALAC_fuzzer-474307197311385

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 8709f4c10a)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
9764ec67b2
avformat/aiffdec: cleanup size handling for extreem cases
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c6f1e48b86)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
dccf8c591a
avformat/matroskadec: avoid integer overflows in SAR computation
This ignores >64bit
Alternatively we could support that if it occurs in reality

Fixes: negation of -9223372036854775808
Fixes: integer overflows
Fixes: 46072/clusterfuzz-testcase-minimized-ffmpeg_dem_MATROSKA_fuzzer-5029840966778880

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 e6cad01122)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
bc24cf32f3
avcodec/jpeglsdec: fix end check for xfrm
Fixes: out of array access
Fixes: 47871/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AMV_fuzzer-5646305956855808

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 6a82412bf3)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
ccf14bcbe4
avcodec/cdgraphics: limit scrolling to the line
Fixes: out of array access
Fixes: 47877/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CDGRAPHICS_fuzzer-5690504626438144

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 b7e30a13d4)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
40ed3f6e84
avformat/hls: Limit start_seq_no to one bit less
This avoids overflow checks on additions with 32bit numbers

Fixes: signed integer overflow: 9223372036854775806 + 2 cannot be represented in type 'long'
Fixes: 44012/clusterfuzz-testcase-minimized-ffmpeg_dem_HLS_fuzzer-4747770734444544
Fixes: 48065/clusterfuzz-testcase-minimized-ffmpeg_dem_HLS_fuzzer-5372410355908608

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 d8ee014254)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
a9ccfc1210
avformat/aiffdec: avoid integer overflow in get_meta()
Fixes: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int'
Fixes: 45891/clusterfuzz-testcase-minimized-ffmpeg_dem_AIFF_fuzzer-6159183893889024

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 6a02de2127)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
9db37b02ed
avformat/aaxdec: Check for overlaping segments
Fixes: Timeout
Fixes: 45875/clusterfuzz-testcase-minimized-ffmpeg_dem_AAX_fuzzer-6121689903136768

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 c16a0ed242)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
39f15f6663
avformat/ape: more bits in size for less overflows
Fixes: signed integer overflow: 2147483647 + 3 cannot be represented in type 'int'
Fixes: 46184/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-4678059519770624

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 e5f6707a7b)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
540ad9ddbd
avformat/aviobuf: Check buf_size in ffio_ensure_seekback()
buffer_size is an int

Fixes: signed integer overflow: 9223372036854775754 + 32767 cannot be represented in type 'long'
Fixes: 45691/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-5263458831040512

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c4b130e876)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
25d7f2eed5
avformat/bfi: Check offsets better
Fixes: signed integer overflow: -2145378272 - 538976288 cannot be represented in type 'int'
Fixes: 45690/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-5015496544616448

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 35dc93ab44)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
6a60c92be0
avformat/asfdec_f: Check packet_frag_timestamp
Fixes: signed integer overflow: -9223372036854775808 - 4607 cannot be represented in type 'long'
Fixes: 45685/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-5280102802391040

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 ffc8772150)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
bfb365e851
avcodec/texturedspenc: Fix indexing in color distribution determination
Fixes CID1396405

MSE and PSNR is slightly improved, and some noticable corruptions disappear as
well.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Marton Balint <cus@passwd.hu>
(cherry picked from commit ade36d61de)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
b9bda06ea5
avformat/act: Check ff_get_wav_header() for failure
Fixes: missing error check
Fixes: CID717495

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 5982da87e3)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
0cbe98cbbe
avcodec/libxavs2: Improve r redundancy in occured
Reviewed-by: "mypopy@gmail.com" <mypopy@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit f3b7ba21ba)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
b00df63465
avformat/libzmq: Improve r redundancy in occured
Reviewed-by: "mypopy@gmail.com" <mypopy@gmail.com>
(cherry picked from commit e06b1ba7d7)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
0327a29c93
avfilter/vf_libplacebo: Match AV_OPT_TYPE_FLOAT to dbl
Reviewed-by: "mypopy@gmail.com" <mypopy@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 0a3e121798)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
e509fa78c1
avfilter/vsrc_mandelbrot: Check for malloc failure
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit fbd22504c4)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
6a32a608dc
avfilter/vf_frei0r: Copy to frame allocated according to frei0r requirements
Fixes: issues with non trivial linesize

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit d353909e77)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
5e821d9143
avfilter/video: Add ff_default_get_video_buffer2() to set specific alignment
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit d740782701)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-01 00:41:28 +02:00
Michael Niedermayer
0af520417b
avformat/genh: Check sample rate
Fixes: signed integer overflow: -2515507630940093440 * 4 cannot be represented in type 'long'
Fixes: 46318/clusterfuzz-testcase-minimized-ffmpeg_dem_GENH_fuzzer-5009637474172928

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 a3d790f197)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-08-31 21:35:14 +02:00
Michael Niedermayer
14d8814edc
avformat/demux: Use unsigned to check duration vs duration_text
Fixes: signed integer overflow: 9223371898743775808 - -138111000000 cannot be represented in type 'long'
Fixes: 46245/clusterfuzz-testcase-minimized-ffmpeg_dem_OGG_fuzzer-5075129786302464

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 6007d5688c)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-08-31 21:35:14 +02:00
Timo Rothenpieler
54e0971edb avutil/hwcontext_d3d11va: fix texture_infos writes on non-fixed-size pools 2022-07-18 02:13:25 +02:00
Zhao Zhili
7389a49fd3 avcodec/cuviddec: fix null pointer dereference
It can happened on error path of cuvid_decode_init().

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2022-06-26 21:50:30 +02:00
Zhao Zhili
3607d7bbea avcodec/cuviddec: fix AV1 decoding error
cuvidParseVideoData only supports pure OBUs, it reports an unknown
error with AV1CodecConfigurationRecord. Check whether extradata
is AV1CodecConfigurationRecord and skip the first 4 bytes to fix
the issue.

The bug is revealed in ffmpeg cmd since 45e3b6a68 and ffd1316e.

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2022-06-26 21:50:28 +02:00
Christopher Degawa
240d82f26e configure: extend SDL check to accept all 2.x versions
sdl2 recently changed their versioning, moving the patch level to minor level
cd7c2f1de7
and have said that they will instead ship sdl3.pc for 3.0.0

Fixes ticket 9768

Signed-off-by: Christopher Degawa <ccom@randomderp.com>
Signed-off-by: Gyan Doshi <ffmpeg@gyani.pro>
2022-06-10 13:56:26 +02:00
Timo Rothenpieler
a5ebb3d25e lavf/tls_mbedtls: add support for mbedtls version 3
- certs.h is gone. Only contains test data, and was not used at all.
- config.h is renamed. Was seemingly not used, so can be removed.
- MBEDTLS_ERR_SSL_NO_USABLE_CIPHERSUITE is gone, instead
  MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE will be thrown.
- mbedtls_pk_parse_keyfile now needs to be passed a properly seeded
  RNG. Hence, move the call to after RNG seeding.

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2022-04-27 18:46:14 +02:00
James Almer
b655beb025 fate: update reference files after the recent dash manifest muxer changes
Missed in 487b49d8f2.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit aa0829d834)
2022-04-08 16:10:34 -03:00
James Almer
2db2bdabbd avformat/webmdashenc: fix on-demand profile string
Fixes ticket #9596

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 487b49d8f2)
2022-04-08 00:05:07 -03:00
James Almer
0d487be837 avcodec/libdav1d: don't depend on the event flags API to init sequence params the first time
A bug was found in dav1d <= 1.0.0 where the event flag New Sequence Header would
not be signaled for some samples using delayed random access points.
It has since been fixed, but nonetheless it's best to ensure the AVCodecContext
is filled with parameters when parsing the first frame, regardless of what events
were signaled.

Fixes ticket #9694.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 3e186148ca)
2022-04-07 15:33:19 -03:00
Michael Niedermayer
9687cae2b4 Update for 5.0.1
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-04-04 00:07:14 +02:00
Michael Niedermayer
70522b7262 avcodec/exr: Avoid signed overflow in displayWindow
The inputs are unused except for this computation so wraparound
does not give an attacker any extra values as they are already fully
controlled

Fixes: signed integer overflow: 0 - -2147483648 cannot be represented in type 'int'
Fixes: 45820/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EXR_fuzzer-5766159019933696

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 1291568c98)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-04-04 00:05:36 +02:00
Michael Niedermayer
1ed490b9dc avcodec/diracdec: avoid signed integer overflow in global mv
Fixes: signed integer overflow: -128275513086 * -76056576 cannot be represented in type 'long'
Fixes: 45818/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DIRAC_fuzzer-5129799149944832

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 7f1279684e)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-04-04 00:05:36 +02:00
Michael Niedermayer
9cd9f958eb avcodec/takdsp: Fix integer overflow in decorrelate_sf()
Fixes: signed integer overflow: -101 * 71041254 cannot be represented in type 'int'
Fixes: 45938/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TAK_fuzzer-4687974320701440

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 01d8c887f6)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-04-04 00:05:36 +02:00
Michael Niedermayer
89374decf6 avcodec/apedec: fix a integer overflow in long_filter_high_3800()
Fixes: signed integer overflow: -2146549696 - 3923884 cannot be represented in type 'int'
Fixes: 45907/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-5992380584558592

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 b085b400be)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-04-04 00:05:36 +02:00
Diederick Niehorster
3010773508 avdevice/dshow: fix regression
a1c4929f accidentally undid part of d9a9b4c8, so the bug in ticket #9420
resurfaced. Fixing again.

Signed-off-by: Diederick Niehorster <dcnieho@gmail.com>
Reviewed-by: Roger Pack <rogerdpack2@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit f125c504d8)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-04-04 00:05:36 +02:00
Oneric
482d51884c avfilter/vf_subtitles: pass storage size to libass
Due to a quirk of the ASS format some tags depend on the exact storage
resolution of the video, so tell libass via ass_set_storage_size.

Reviewed-by: Soft Works <softworkz@hotmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2022-04-04 00:05:36 +02:00
Andreas Rheinhardt
a50aa980eb avcodec/vp9_superframe_split_bsf: Don't read inexistent data
Fixes: Out of array read
Fixes: 45137/clusterfuzz-testcase-minimized-ffmpeg_BSF_VP9_SUPERFRAME_SPLIT_fuzzer-4984270639202304

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit d311d820a7)
2022-04-01 13:20:56 +02:00
Andreas Rheinhardt
550d70fde3 avcodec/vp9_superframe_split_bsf: Discard invalid zero-sized frames
They are invalid in VP9. If any of the frames inside a superframe
had a size of zero, the code would either read into the next frame
or into the superframe index; so check for the length to stop this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit d20ef30f53)
2022-04-01 13:20:56 +02:00
Andreas Rheinhardt
f93ca3a278 avcodec/vp9_superframe_bsf: Check for existence of data before reading it
Packets without data need to be handled specially in order to avoid
undefined reads. Pass these packets through unchanged in case there
are no cached packets* and error out in case there are cached packets:
Returning the packet would mess with the order of the packets;
if one returned the zero-sized packet before the superframe that will
be created from the packets in the cache, the zero-sized packet would
overtake the packets in the cache; if one returned the packet later,
the packets that complete the superframe will overtake the zero-sized
packet.

*: This case e.g. encompasses the scenario of updated extradata
side-data at the end.

Fixes: Out of array read
Fixes: 45722/clusterfuzz-testcase-minimized-ffmpeg_BSF_VP9_SUPERFRAME_fuzzer-5173378975137792

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit c12e8c97b1)
2022-04-01 13:20:56 +02:00
Andreas Rheinhardt
4e61bf403f avcodec/vp9_raw_reorder_bsf: Check for existence of data before reading it
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit ab25b6aee6)
2022-04-01 13:20:56 +02:00
Pierre-Anthony Lemieux
cffa10a0cb
avformat/imf: fix packet pts, dts and muxing
The IMF demuxer does not set the DTS and PTS of packets accurately in all
scenarios. Moreover, audio packets are not trimmed when they exceed the
duration of the underlying resource.

imf-cpl-with-repeat FATE ref file is regenerated.

Addresses https://trac.ffmpeg.org/ticket/9611

(cherry picked from commit b0193e26ca)
2022-03-31 21:28:42 +10:00
Pierre-Anthony Lemieux
08206484bc
avformat/imf: open resources only when first needed
IMF CPLs can reference thousands of files, which can result in system limits
for the number of open files to be exceeded. The following patch opens and
closes files as needed.

Addresses https://trac.ffmpeg.org/ticket/9623

(cherry picked from commit ef0d5245d6)
2022-03-31 21:28:29 +10:00
Zane van Iperen
afa04c1e9e
avformat/imf: cosmetics
s/++i/i++/g

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
(cherry picked from commit 40766ae1da)
2022-03-31 21:28:29 +10:00
Marton Balint
07d953187b
avformat/imf_cpl: do not use filesize when reading XML file
Similar to the earlier patch applied to imfdec.

Signed-off-by: Marton Balint <cus@passwd.hu>
(cherry picked from commit 8a9d3d3dec)
2022-03-31 21:28:29 +10:00
Andreas Rheinhardt
2ae18635da
avformat/imfdec: Use proper logcontext
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit b7a543707f)
2022-03-29 20:03:14 +10:00
Marton Balint
d0e9e8c5d0
avformat/imfdec: do not use filesize when reading XML file
Signed-off-by: Marton Balint <cus@passwd.hu>
(cherry picked from commit ae690d5cf5)
2022-03-29 20:03:08 +10:00
James Almer
8fd2dc3f2b doc/utils: add missing 22.2 layout entry
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 1e24fad867)
2022-03-28 20:36:04 -03:00
James Almer
fd4121a0aa avcodec/av1: only set the private context pix_fmt field if get_pixel_format() succeeds
Otherwise get_pixel_format() will not be called when parsing a subsequent Sequence
Header in non hwaccel enabled scenarios, allowing frame parsing when it shouldn't.

This prevents the scenario seqhdr -> frame_hdr/redundant_frame_hdr -> seqhdr ->
redundant_frame_hdr from having the latter redundant frame header parsed as if it
was a frame header by the decoder because the former was discarded.
Since CBS did not discard it, the latter redundant frame header is output with a
zeroed AV1RawFrameHeader struct, which can have undesired results, like division
by zero with fields normally guaranteed to be anything else.

Fixes: division by zero
Fixes: 43769/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AV1_fuzzer-5392562205097984
Fixes: 43950/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AV1_fuzzer-5769210217758720

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 5670eddf8c)
2022-03-28 20:36:04 -03:00
Michael Niedermayer
ba595e8d83 avformat/aqtitledec: Skip unrepresentable durations
Fixes: signed integer overflow: -5 - 9223372036854775807 cannot be represented in type 'long'
Fixes: 45665/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-475618463934054

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 c2d1597a8a)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-03-28 23:18:56 +02:00
Michael Niedermayer
518b7474b2 avformat/cafdec: Do not store empty keys in read_info_chunk()
Fixes: Timeout
Fixes: 45543/clusterfuzz-testcase-minimized-ffmpeg_dem_CAF_fuzzer-5684953164152832

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 7ec28e1d4c)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-03-28 23:18:56 +02:00
Michael Niedermayer
5c1ae6738a avformat/mxfdec: Do not clear array in mxf_read_strong_ref_array() before writing
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 7aebdb8bf1)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-03-28 23:18:56 +02:00
Michael Niedermayer
d63e7c3b39 avformat/mxfdec: Check for avio_read() failure in mxf_read_strong_ref_array()
Fixes: 42827/clusterfuzz-testcase-minimized-ffmpeg_dem_MXF_fuzzer-4900528511909888

Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 8d6f49cfc3)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-03-28 23:18:56 +02:00
Michael Niedermayer
8b13cfcc3c avformat/mxfdec: Check count in mxf_read_strong_ref_array()
Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 3015c556f3)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-03-28 23:18:56 +02:00
Michael Niedermayer
478bd4c73f avformat/hls: Check target_duration
Fixes: signed integer overflow: 77777777777777 * 1000000 cannot be represented in type 'long long'
Fixes: 45545/clusterfuzz-testcase-minimized-ffmpeg_dem_HLS_fuzzer-6438101247983616

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit a8fd3f7fab)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-03-28 23:18:56 +02:00
Michael Niedermayer
e35f910591 avcodec/pixlet: Avoid signed integer overflow in scaling in filterfn()
Fixes: signed integer overflow: 11494 * 1073741824000000 cannot be represented in type 'long'
Fixes: 26586/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PIXLET_fuzzer-5752633970917376

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 0c1f20c6c8)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-03-28 23:18:56 +02:00
Michael Niedermayer
ffe1ded457 avformat/matroskadec: Check pre_ns
Fixes: division by 0
Fixes: 44615/clusterfuzz-testcase-minimized-ffmpeg_dem_WEBM_DASH_MANIFEST_fuzzer-6681108677263360

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 710e51677a)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-03-28 23:18:56 +02:00
Michael Niedermayer
af2913d46f avcodec/sonic: Use unsigned for predictor_k to avoid undefined behavior
Fixes: signed integer overflow: -1094995529 * 24 cannot be represented in type 'int'
Fixes: 44436/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SONIC_fuzzer-4874459459223552

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 28008bf95e)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-03-28 23:18:56 +02:00
Michael Niedermayer
debfbad67a avcodec/libuavs3d: Check ff_set_dimensions() for failure
Untested, no testcase

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit e88b99afdf)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-03-28 23:18:56 +02:00
Michael Niedermayer
ee16bb81de avcodec/speexdec: Align some comments
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 6530c240c8)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-03-28 23:18:56 +02:00
Michael Niedermayer
637bda4cdd avcodec/speexdec: Use correct doxygen comments
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 487679cc50)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-03-28 23:18:56 +02:00
Michael Niedermayer
780de33f32 avcodec/mjpegbdec: Set buf_size
Fixes: Timeout
Fixes: 45170/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MJPEGB_fuzzer-5874820431085568

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-03-28 23:18:56 +02:00
Michael Niedermayer
49f8f8ba20 avformat/matroskadec: Use rounded down duration in get_cue_desc() check
Floating point is evil, it would be better if duration was not a double

Fixes: Infinite loop
Fixes: 45123/clusterfuzz-testcase-minimized-ffmpeg_dem_WEBM_DASH_MANIFEST_fuzzer-6725052291219456

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 bd3a03db9a)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-03-28 23:18:56 +02:00
Michael Niedermayer
849a20343d avcodec/argo: Check packet size
Fixes: Timeout
Fixes: 45052/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ARGO_fuzzer-6033489206575104

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 1bed27acef)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-03-28 23:18:56 +02:00
Michael Niedermayer
95322e0767 avcodec/g729_parser: Check channels
Fixes: signed integer overflow: 10 * 808464428 cannot be represented in type 'int'
Fixes: assertion failure
Fixes: ticket9651

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 757da974b2)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-03-28 23:18:56 +02:00
Michael Niedermayer
432cbff7bb avformat/avidec: Check height
Fixes: negation of -2147483648 cannot be represented in type 'int'; cast to an unsigned type to negate this value to itself
Fixes: Ticket8486

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit ec8ff659f5)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-03-28 23:18:56 +02:00
Michael Niedermayer
32778e5a5e avformat/rmdec: Better duplicate tags check
Fixes: memleaks
Fixes: 44810/clusterfuzz-testcase-minimized-ffmpeg_dem_IVR_fuzzer-5619494647627776

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 15a646e501)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-03-28 23:18:56 +02:00
Michael Niedermayer
f87f100558 avformat/mov: Disallow empty sidx
It appears this is not allowed "Each Segment Index box documents how a (sub)segment is divided into one or more subsegments
(which may themselves be further subdivided using Segment Index boxes)."
Fixes: Null pointer dereference
Fixes: Ticket9517

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 4419433d77)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-03-28 23:18:56 +02:00
Michael Niedermayer
5c4fdf111e avformat/argo_cvg:: Fix order of operations in error check in argo_cvg_write_trailer()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 70a1024290)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-03-28 23:18:56 +02:00
Michael Niedermayer
6bd882f98a avformat/argo_asf: Fix order of operations in error check in argo_asf_write_trailer()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c8c12fb5d6)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-03-28 23:18:56 +02:00
Michael Niedermayer
405c75998d avcodec/movtextdec: add () to CMP() macro to avoid unexpected behavior
Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c182c70658)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-03-28 23:18:55 +02:00
Michael Niedermayer
f514336829 avformat/matroskadec: Check duration
Fixes: -nan is outside the range of representable values of type 'long'
Fixes: 44614/clusterfuzz-testcase-minimized-ffmpeg_dem_WEBM_DASH_MANIFEST_fuzzer-6216204841254912

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 36680078ca)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-03-28 23:18:55 +02:00
Michael Niedermayer
096a936567 avformat/mov: Corner case encryption error cleanup in mov_read_senc()
Fixes: memleak
Fixes: 42341/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-4566632823914496

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 8ee0e4abcb)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-03-28 23:18:55 +02:00
Michael Niedermayer
025bf57f77 avcodec/jpeglsdec: Fix if( code style
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit f306b8e80a)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-03-28 23:18:55 +02:00
Michael Niedermayer
473ea811db avcodec/jpeglsdec: Check get_ur_golomb_jpegls() for error
Fixes: Timeout
Fixes: Invalid shift
Fixes: 44548/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEGLS_fuzzer-556487680891289
Fixes: 44569/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AMV_fuzzer-6302543246917632
Fixes: 44570/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_THP_fuzzer-4550196556595200
Fixes: 44592/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MJPEG_fuzzer-5651610385121280
Fixes: 44571/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-5094698987945984
Fixes: 44607/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-5341352013987840

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 151f83584e)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-03-28 23:18:55 +02:00
Michael Niedermayer
e086aeb792 avcodec/motion_est: fix indention of ff_get_best_fcode()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit ce43e1c581)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-03-28 23:18:55 +02:00
Michael Niedermayer
2e901b1304 avcodec/motion_est: Fix xy indexing on range violation in ff_get_best_fcode()
This codepath seems untested, no testcases change

Found-by: <mkver>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 634312a70f)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-03-28 23:18:55 +02:00
Michael Niedermayer
0ea439dab7 avformat/hls: Use unsigned for iv computation
Fixes: signed integer overflow: 9223372036854775748 + 60 cannot be represented in type 'long'
Fixes: 44417/clusterfuzz-testcase-minimized-ffmpeg_dem_HLS_fuzzer-5802443881971712

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit bf33a38499)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-03-28 23:18:55 +02:00
Michael Niedermayer
0dabd7f603 avcodec/jpeglsdec: Increase range for N in ls_get_code_runterm() by using unsigned
Fixes: left shift of 32768 by 16 places cannot be represented in type 'int'
Fixes: Timeout
Fixes: 44219/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SMVJPEG_fuzzer-4679455379947520
Fixes: 44088/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SMVJPEG_fuzzer-4885976600674304

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 6ee283d7d0)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-03-28 23:18:55 +02:00
Michael Niedermayer
0a5feebc57 avformat/matroskadec: Check desc_bytes
Fixes: Division by 0
Fixes: 44035/clusterfuzz-testcase-minimized-ffmpeg_dem_WEBM_DASH_MANIFEST_fuzzer-4826721386364928

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 5038933977)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-03-28 23:18:55 +02:00
Michael Niedermayer
ba92c416af avformat/utils: Fix invalid NULL pointer operation in ff_parse_key_value()
Fixes: pointer index expression with base 0x000000000000 overflowed to 0xffffffffffffffff
Fixes: 44012/clusterfuzz-testcase-minimized-ffmpeg_dem_HLS_fuzzer-5670607746891776

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 59328aabd2)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-03-28 23:18:55 +02:00
Michael Niedermayer
7a9ea4399d avformat/matroskadec: Fix infinite loop with bz decompression
The same check is added to zlib too, it seems not needed there though

Fixes: Infinite loop
Fixes: 43932/clusterfuzz-testcase-minimized-ffmpeg_dem_MATROSKA_fuzzer-6175167573786624

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 9c3d2cbb51)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-03-28 23:18:55 +02:00
Michael Niedermayer
fc85847223 avformat/utils: keep chapter monotonicity on chapter updates
Updating a chapter with the same id does not break monotonicity
Fixes: Timeout
Fixes: 43727/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-4960623367159808

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 948c262099)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-03-28 23:18:55 +02:00
Michael Niedermayer
ea98cb2465 avformat/mov: Check size before subtraction
Fixes: signed integer overflow: -9223372036854775808 - 8 cannot be represented in type 'long'
Fixes: 43542/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-5237670148702208

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 d8d9d506a3)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-03-28 23:18:55 +02:00
Michael Niedermayer
f1ae880298 avcodec/cfhd: Avoid signed integer overflow in coeff
Fixes: signed integer overflow: 15244032 * 256 cannot be represented in type 'int'
Fixes: 43504/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-4865014842916864

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 cd6ac013a0)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-03-28 23:18:55 +02:00
James Almer
911d7f167c avcodec/libdav1d: free the Dav1dData packet on dav1d_send_data() failure
We still own it on failure, and there's no point trying to feed it again.

This should address the issue reported in dav1d #383 and part of VLC #26259.

Signed-off-by: James Almer <jamrial@gmail.com>
Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
2022-02-01 13:04:16 -03:00
James Almer
a394d35a43 avcodec/h264_parser: don't alter decoder private data
Signed-off-by: James Almer <jamrial@gmail.com>
2022-01-25 10:16:15 -03:00
Anton Khirnov
2bc8c87b2e configure: link to libatomic when it's present
C11 atomics in some configurations (e.g. 64bit operations on ppc64 with
GCC) require linking to libatomic.

Fixes #9275

(cherry picked from commit 2f0a214a62)
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2022-01-21 09:40:55 +01:00
James Almer
a66b58d61c fate/ffmpeg: add missing samples dependency to fate-shortest
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit b1ef5882e3)
2022-01-16 00:34:11 -03:00
Michael Niedermayer
390d6853d0 RELEASE_NOTES: Based on the version from 4.3
Name suggested by jb and Reto

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-01-14 19:43:55 +01:00
Vittorio Giovara
e540605d42 vf_tonemap: Fix order of planes
This resulted in a dimmed tonemapping due to bad resulting luma
calculation.

Found by: Derek Buitenhuis

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
(cherry picked from commit 7d377558a6)
2022-01-14 16:34:01 +01:00
softworkz
4a9ec4d4e3 avfilter/vpp_qsv: fix regression on older api versions (e.g. 1.11)
Commit 8b83dad825 introduced a
regression in a way that scaling via vpp_qsv doesn't work any longer
for devices with an MSDK runtime version lower than 1.19. This is true
for older CPUs which are stuck at 1.11.
The commit added checks for the compile-sdk version but it didn't test
for the runtime version.

Signed-off-by: softworkz <softworkz@hotmail.com>
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
(cherry picked from commit 479f3c6598)
2022-01-14 08:50:03 +08:00
Michael Niedermayer
171802a1ba avformat/rawvideodec: check packet size
Fixes: division by zero
Fixes: integer overflow
Fixes: 43347/clusterfuzz-testcase-minimized-ffmpeg_dem_V210X_fuzzer-5846911637127168

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: lance.lmwang@gmail.com
Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c36a5dfc8f)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-01-13 23:24:22 +01:00
Michael Niedermayer
af06b9255f avcodec/apedec: Fix integer overflows in predictor_update_3930()
Fixes: signed integer overflow: 1074134419 - -1075212485 cannot be represented in type 'int'
Fixes: 43273/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-4706880883130368

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 0c9c9bbd01)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-01-13 23:23:18 +01:00
Limin Wang
99d6ab7154 avutil/parseutils: use quadhd for Quad HD
qHD is 960x540 (q stands for quarter) and QHD is 2560x1440 (Q is quad).
use quadhd for QHD for abbreviation.

Fix ticket#9591

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2022-01-12 17:54:19 +08:00
Anton Khirnov
92c57aece4 lavf/udp: do not return an uninitialized value from udp_open()
(cherry picked from commit 3c2b674468)
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2022-01-11 09:11:00 +01:00
Andreas Rheinhardt
58922dc565 fftools/cmdutils: Fix undefined 1 << 31
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit bbf00916e4)
2022-01-11 00:24:23 +01:00
James Almer
fa1328babf avcodec/libdav1d: explicitly set Dav1dSettings.apply_grain
Don't depend on its default value being 1, as that could change anytime.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 6c4074e423)
2022-01-10 12:21:52 -03:00
Timo Rothenpieler
cd74c838fc avcodec/nvenc: zero-initialize NV_ENC_REGISTER_RESOURCE struct 2022-01-10 15:53:15 +01:00
Zhao Zhili
ce1558e66b avformat/movenc: fix duration in mdhd box
mvhd and tkhd present the post-editlist duration, while mdhd should
have the pre-editlist duration. Regression since c2424b1f3.

Signed-off-by: Martin Storsjö <martin@martin.st>
(cherry picked from commit f37e66b393)
2022-01-10 12:42:51 +02:00
Niklas Haas
fb840a79b9 lavfi/vf_libplacebo: fix side data stripping logic
This was accidentally comparing s->colorspace against out->colorspace,
which is wrong - the intent was to compare in->colorspace against
out->colorspace.

We also forgot to strip mastering metadata. Finally, the order is sort
of wrong - we should strip this side data *before* process_frames,
because otherwise it may end up being seen and used by libplacebo.

Signed-off-by: Niklas Haas <git@haasn.dev>
2022-01-10 09:11:18 +01:00
Andreas Rheinhardt
0acca1791e avformat/amr: Return error upon error
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit abc7d1c697)
2022-01-09 21:26:58 +01:00
Marc-Antoine Arnaud
e53ab575da avformat/mxfdec: support MCA audio information
Channel reordering is removed from this patch because the new channel layout
API will support it properly.

Signed-off-by: Marton Balint <cus@passwd.hu>
(cherry picked from commit 47c4df2203)
2022-01-09 18:28:18 +01:00
Ming Qian
832aae6c86 avcodec/v4l2_context: send start decode command after dynamic resolution change event
Fixes decoding of sample https://streams.videolan.org/ffmpeg/incoming/720p60.mp4
on RPi4 after kernel driver commit:
staging: bcm2835-codec: Format changed should trigger drain

Reference:
linux/Documentation/userspace-api/media/v4l/dev-decoder.rst
    "A source change triggers an implicit decoder drain, similar to the
     explicit Drain sequence. The decoder is stopped after it completes.
     The decoding process must be resumed with either a pair of calls to
     VIDIOC_STREAMOFF and VIDIOC_STREAMON on the CAPTURE queue, or a call to
     VIDIOC_DECODER_CMD with the V4L2_DEC_CMD_START command."

Reviewed-by: Andriy Gelman <andriy.gelman@gmail.com>
Signed-off-by: Ming Qian <ming.qian@nxp.com>
2022-01-09 11:47:26 -05:00
Ming Qian
91b459ab23 avcodec/v4l2_context: don't reinit output queue on dynamic resolution change event
Reference:
linux/Documentation/userspace-api/media/v4l/dev-decoder.rst
    "During the resolution change sequence, the OUTPUT queue must remain
     streaming. Calling VIDIOC_STREAMOFF() on the OUTPUT queue would
     abort the sequence and initiate a seek.

     In principle, the OUTPUT queue operates separately from the CAPTURE
     queue and this remains true for the duration of the entire
     resolution change sequence as well."

Reviewed-by: Andriy Gelman <andriy.gelman@gmail.com>
Signed-off-by: Ming Qian <ming.qian@nxp.com>
2022-01-09 11:47:09 -05:00
Gyan Doshi
1c2d1d988a avformat/hlsenc: convey stream id to segment streams 2022-01-09 10:38:04 +05:30
Andreas Rheinhardt
4eb182b714 avformat/matroskaenc: Disable MKV-only code if MKV muxer is disabled
The Matroska muxer has quite a lot of dependencies and lots of them
are unnecessary for WebM. By disabling the Matroska-only code
at compile time one can get rid of them.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit 52c1e9e530)
2022-01-08 19:11:17 +01:00
Andreas Rheinhardt
201a486a11 fate/subtitles: Fix check for fate-binsub-mksenc test
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit e852b1b063)
2022-01-08 19:11:17 +01:00
Andreas Rheinhardt
48e85918b8 avformat/matroskaenc: Move AAC extradata check to other audio checks
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit d266bf1798)
2022-01-08 19:11:17 +01:00
Andreas Rheinhardt
60604702cd avdevice/iec61883: #if unused code away, fix -O0 compilation
iec61883_parse_queue_hdv() is only called when the mpegts-demuxer
is available and can be optimized away when not. Yet this
optimization is not a given and it fails with e.g. GCC 11 when
using -O0 in which case one will get a compilation error
because the call to the unavailable avpriv_mpegts_parse_packet()
is not optimized away. Therefore #if the offending code away
in this case.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit ad0b4afec5)
2022-01-08 19:11:17 +01:00
Andreas Rheinhardt
fbbbe73b0f configure: Let decklink indev suggest libzvbi
Fixes build errors if libzvbi is enabled while libzvbi_teletextdec
is disabled.

Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit 2d0b17e820)
2022-01-08 19:11:17 +01:00
Andreas Rheinhardt
e9b7e781d7 avformat/rtsp: #if unused functions away, fix -O0 compilation
parse_rtsp_message() is only called if the rtsp demuxer is enabled
and so it is normally compiled away if said demuxer is disabled.
Yet this does not happen when compiling with -O0 and this leads
to a linking failure because parse_rtsp_message() calls functions
that may not be available if the rtsp demuxer is disabled.
Fix this by properly #if'ing the unused functions away.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit aeb5d943c6)
2022-01-08 19:11:17 +01:00
Andreas Rheinhardt
6d2317a611 avformat/Makefile: Add entries for CRI, GEM and PGX image pipe demuxers
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit 99f3fb8ea1)
2022-01-08 19:01:10 +01:00
Andreas Rheinhardt
237268f6df avformat/Makefile: Add missing alp-muxer->rawenc.o dependency
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit 1beeeaf23d)
2022-01-08 19:01:10 +01:00
Andreas Rheinhardt
519e22b31e avformat/amr: Fix writing AMR header
Regression since f282c34c00.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit a22a71eb2c)
2022-01-08 19:00:26 +01:00
Andreas Rheinhardt
24f1997822 avformat/amr: Don't reset AVFormatContext.priv_data
The AMR muxer doesn't have a private context, so it's priv_data
will be NULL. If it weren't, simply setting it to NULL would lead
to a memleak.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit a5a99cc11c)
2022-01-08 19:00:26 +01:00
Andreas Rheinhardt
a20d6eb223 avformat/Makefile, amr: Add missing amr-demuxers->rawdec.o dependency
Forgotten in 1f447fd954.
Also only enable amr_probe() and amr_read_header() in case
the AMR demuxer is enabled; this avoids having to add
a rawdec.o dependency to the muxer.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit 78a840e7a3)
2022-01-08 19:00:26 +01:00
Andreas Rheinhardt
359836ce6c avformat/Makefile: Add missing libamqp->urldecode dependency
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit 5bdd8e67e6)
2022-01-08 19:00:26 +01:00
Fei Wang
9b099a97f0 lavc/av1dec: use frame split bsf
Split packed data in case of its contains multiple show frame in some
non-standard bitstream. This can benefit decoder which can decode
continuously instead of interrupt with unexpected error.

Signed-off-by: Fei Wang <fei.w.wang@intel.com>
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
(cherry picked from commit 7787cca180)
2022-01-08 11:09:17 -03:00
Martin Storsjö
6ff38630e1 aarch64: Disable ff_hevc_sao_band_filter_8x8_8_neon out of precaution
While this function on its own passes all of fate-hevc, there's
indications that the function might need to handle widths that
aren't a multiple of 8 (noted in commit
f63f9be37c, which later was
reverted).

Signed-off-by: Martin Storsjö <martin@martin.st>
(cherry picked from commit 24b93022fe)
2022-01-07 22:36:47 +02:00
Andreas Rheinhardt
60d6efe218 avformat/matroskaenc: Fix build with only WebM muxer enabled
In this case ff_isom_put_dvcc_dvvc() might not be available, leading
to linking failures. Given that WebM currently doesn't support DOVI,
this is fixed by #if'ing the offending code away if the Matroska
muxer is not enabled.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit 217c90aac7)
2022-01-07 13:27:41 +01:00
Andreas Rheinhardt
3975f9328a configure: Add missing AMV muxer->riffenc dependency
Reviewed-by: Zane van Iperen <zane@zanevaniperen.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit 41c62207f6)
2022-01-07 13:26:40 +01:00
Andreas Rheinhardt
743d26ca04 avformat/Makefile: Fix name of PhotoCD demuxer
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit 6e163619e3)
2022-01-07 13:26:26 +01:00
James Almer
c8df72fce5 avcodec/libdav1d: honor the requested strict_std_compliance level on supported builds
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 3e17e0e5ef)
2022-01-06 23:05:12 -03:00
Andreas Rheinhardt
761a65106b configure: Add missing libshine->mpegaudioheader dependency
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit e228d7b0db)
2022-01-06 08:31:12 +01:00
Andreas Rheinhardt
f59e8666f9 avcodec/Makefile: Add missing entry for ADPCM_IMA_AMV_ENCODER
Forgotten in 555f5c1fc5.

Reviewed-by: Zane van Iperen <zane@zanevaniperen.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit df4cb384fb)
2022-01-06 08:31:12 +01:00
Andreas Rheinhardt
b04b475917 avcodec/Makefile: Only compile nvenc.o if needed
This fixes compilation errors in case nvenc is enabled
(e.g. autodected) with both nvenc-based encoders disabled
because nvenc uses ff_alloc_a53_sei(), yet only the nvenc-based
encoders require atsc_a53.
(This error does not manifest itself in case of static linking
(nothing pulls in nvenc.o), but it exists with shared builds.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2022-01-05 19:37:50 +01:00
Wu Jianhua
eb091d211f avfilter/vf_blend: fix un-checked potential memory allocation failure
Signed-off-by: Wu Jianhua <jianhua.wu@intel.com>
2022-01-05 15:17:35 +01:00
Andreas Rheinhardt
85fca9f92b avcodec/Makefile: Add missing HEVC decoder->h274.o dependency
Forgotten in 3cc3f5de2a.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit aa8bb05d29)
2022-01-05 14:43:11 +01:00
Wu Jianhua
b4d254f2e6 avutil/hwcontext_vulkan: fixed incorrect memory offset
This commit fixed hwupload in Vulkan:

ffmpeg -init_hw_device vulkan -i test.jpg -vf hwupload,hwdownload,format=yuv420p -y out.jpg

Signed-off-by: Wu Jianhua <jianhua.wu@intel.com>
2022-01-05 14:14:54 +01:00
James Almer
b9dbb6c114 Changelog: replace <next> by 5.0
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 746df0a19a)
2022-01-05 08:39:53 -03:00
Zane van Iperen
d4baad9fe3
Changelog: add IMF demuxer
Suggested-By: Pierre-Anthony Lemieux <pal@palemieux.com>
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
(cherry picked from commit 21e25d2fe2)
2022-01-05 21:23:29 +10:00
Pierre-Anthony Lemieux
2c1dd39a98
avformat/imf: Fix indentation
Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com>
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
(cherry picked from commit 74afc3c650)
2022-01-05 21:23:28 +10:00
Pierre-Anthony Lemieux
8d18c08f0c
avformat/imf: fix CPL parsing error handling
Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com>
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
(cherry picked from commit 76ffe1c2f1)
2022-01-05 21:23:27 +10:00
Pierre-Anthony Lemieux
2186555bc9
avformat/imf: fix bad free() when directory name of the input url is empty
Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com>
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
(cherry picked from commit 59f1a46048)
2022-01-05 21:23:26 +10:00
Pierre-Anthony Lemieux
5fd7b8e9b2
avformat/imf: fix error CPL root element is absent
Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com>
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
(cherry picked from commit c1b55cb70c)
2022-01-05 21:23:24 +10:00
Andreas Rheinhardt
696079924a avcodec/Makefile: Add missing mpegaudiodata.o dependency to MPEGAUDIO
mpegaudiodec_template.c uses stuff from mpegaudiodata directly,
yet this dependency was only indirectly fulfilled via mpegaudio-headers
before 33e6d57f01. Since this commit,
the latter only needs (and therefore provides) mpegaudiotabs,
leading to compilation failures.
This commit adds this missing direct dependency directly.
(Sorry for not having checked indirect dependencies.)

Found-by: Zane van Iperen <zane@zanevaniperen.com>
Reviewed-by: Zane van Iperen <zane@zanevaniperen.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit 07fd34aca7)
2022-01-05 05:17:50 +01:00
Niklas Haas
660858a9e4 lavfi/libplacebo: support dovi metadata application
libplacebo supports automatic dolby vision application, but it requires
us to switch to a new API. Also add some logic to strip the dolby vision
metadata from the output frames in any case where we end up changing the
colorimetry.

The libplacebo dependency bump is justified because neither 184 nor 192
are part of any stable libplacebo release, so users have to build from
git anyways for this filter to exist.

Signed-off-by: Niklas Haas <git@haasn.dev>
2022-01-05 03:16:35 +01:00
rcombs
1477386ca2 lavfi/drawutils: re-enable P010 and P016 support
These formats now work as expected.
2022-01-04 20:01:10 -06:00
rcombs
052ee78d14 lavfi/drawutils: overhaul to improve pixel format support
- No longer mixes u8 and u16 component accesses (this was UB)
- De-duplicated 8->16 conversion
- De-duplicated component -> plane+offset conversion
- De-duplicated planar + packed RGB
- No longer calls ff_fill_rgba_map
- Removed redundant comp_mask data member
- RGB0 and related formats no longer write an alpha value to the 0 byte
- Non-planar YA formats now work correctly
- High-bit-depth semi-planar YUV now works correctly
2022-01-04 20:01:10 -06:00
rcombs
8688209176 lavfi/drawutils: ensure we don't support formats with non-pixel-sized offsets 2022-01-04 20:01:10 -06:00
rcombs
55ff7356bf lavfi/drawutils: ensure we can't overflow a component 2022-01-04 20:01:10 -06:00
rcombs
c327743ee0 lavfi/drawutils: ensure we don't allow mixed-byte-depth formats
These could be hazardous because of FFDrawColor's union
2022-01-04 20:01:10 -06:00
rcombs
74210138a4 lavfi/drawutils: reimplement ff_fill_rgba_map without hardcoding the list
Same outputs, but computed instead of statically known, so new formats will be
supported more easily. Asserts in place to ensure we update this if we add
anything incompatible with its logic.
2022-01-04 20:01:10 -06:00
rcombs
b059ded2a9 lavfi/drawutils: reject shift-packed formats
Disables x2bgr10/x2rgb10 (which did not behave correctly before).
2022-01-04 20:01:10 -06:00
rcombs
2641f7338d lavfi/drawutils: remove redundant BE format checks
We already explicitly don't support big-endian in general
2022-01-04 20:01:10 -06:00
rcombs
3cad1f756e lavfi/drawutils: move BE check out of loop 2022-01-04 20:01:10 -06:00
rcombs
9f7875c18e swscale/output: use isSwappedChroma 2022-01-04 20:01:10 -06:00
rcombs
656ffdbd28 swscale/output: use isSemiPlanarYUV for NV12/21/24/42 case 2022-01-04 20:01:10 -06:00
rcombs
df94cdde4b swscale: introduce isSwappedChroma 2022-01-04 20:01:10 -06:00
rcombs
1292a8d91b swscale/output: use isDataInHighBits for 10-bit case
This code will need fleshing-out (probably templating) if we ever add
e.g. a P012 format.
2022-01-04 20:01:10 -06:00
rcombs
795f803a47 swscale/output: use isSemiPlanarYUV for 16-bit case 2022-01-04 20:01:10 -06:00
rcombs
a5f1f0558f swscale: introduce isDataInHighBits 2022-01-04 20:01:10 -06:00
rcombs
ff9bb93145 swscale/output: template-ize yuv2nv12cX 10-bit and 16-bit cases
Fixes incorrect big-endian output introduced in 88d804b7ff

Avoids making the filter-time BE check more expensive
2022-01-04 20:01:10 -06:00
Limin Wang
f582e40595 avcodec/videotoolbox: Fix undefined symbol with minimal configuration
Please reproduced with the following minimal configure command:
./configure --enable-shared --disable-all --enable-avcodec --enable-decoder=h264 --enable-hwaccel=h264_videotoolbox

You'll get below error:

Undefined symbols for architecture x86_64:
  "_ff_videotoolbox_vpcc_extradata_create", referenced from:
      _videotoolbox_start in videotoolbox.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Reported-by: Cameron Gutman <aicommander@gmail.com>
Tested-by: Cameron Gutman <aicommander@gmail.com>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2022-01-05 09:34:22 +08:00
Niklas Haas
a02d3054ea lavfi/showinfo: fix printf precision for dovi metadata
Fix warning caused by this field changing from uint64_t to uint16_t.

Signed-off-by: Niklas Haas <git@haasn.dev>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit 10e4b2b1d2)
2022-01-04 14:43:53 +01:00
Andreas Rheinhardt
312060ecfc Merge branch 'master' into release/5.0
This is necessary to have the recent DOVI additions
in the 5.0 release.

Merged-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-04 14:26:04 +01:00
Pierre-Anthony Lemieux
311ea9c529
avformat/imf: Fix error handling in set_context_streams_from_tracks()
Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com>
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
(cherry picked from commit 4c03928f4d)
2022-01-04 19:40:32 +10:00
Andreas Rheinhardt
b01ac2d863 avformat/tests/imf: Don't use uninitialized value
Reviewed-by: Zane van Iperen <zane@zanevaniperen.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit 20b0b2be6c)
2022-01-04 10:37:53 +01:00
Michael Niedermayer
1f447cf9c4 Update versions for 5.0
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-01-03 22:21:12 +01:00
230 changed files with 2711 additions and 1257 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. get the names of people who have contributed to FFmpeg.
To check the log, you can type the command "git log" in the FFmpeg To check the log, you can type the command "git log" in the FFmpeg
source directory, or browse the online repository at source directory, or browse the online repository at
http://source.ffmpeg.org. https://git.ffmpeg.org/ffmpeg

232
Changelog
View file

@ -1,7 +1,236 @@
Entries are sorted chronologically from oldest to youngest within each release, Entries are sorted chronologically from oldest to youngest within each release,
releases are sorted from youngest to oldest. releases are sorted from youngest to oldest.
version <next>:
version 5.0.3:
- 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
- avformat/nutdec: Add check for avformat_new_stream
- avcodec/vp3: Add missing check for av_malloc
- 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/rpzaenc: stop accessing out of bounds frame
- avcodec/smcenc: stop accessing out of bounds frame
- avcodec/motionpixels: Mask pixels to valid values
- avcodec/xpmdec: Check size before allocation to avoid truncation
- avcodec/bink: Avoid undefined out of array end pointers in binkb_decode_plane()
- avcodec/bink: Fix off by 1 error in ref end
- avcodec/utils: Ensure linesize for SVQ3
- avcodec/utils: allocate a line more for VC1 and WMV3
- avcodec/videodsp_template: Adjust pointers to avoid undefined pointer things
- avcodec/pngdec: dont skip/read chunk twice
- avcodec/pngdec: Check deloco index more exactly
- avcodec/ffv1dec: Check that num h/v slices is supported
- avformat/mov: Check samplesize and offset to avoid integer overflow
- avcodec/pictordec: Remove mid exit branch
- avcodec/eac3dec: avoid float noise in fixed mode addition to overflow
- avcodec/utils: use 32pixel alignment for bink
- avcodec/scpr3: Check bx
- avcodec/012v: Order operations for odd size handling
- avcodec/eatgq: : Check index increments in tgq_decode_block()
- avcodec/h274: fix include
- avcodec/scpr: Test bx before use
- avformat/mxfdec: Use 64bit in remainder
- avcodec/sunrast: Fix maplength check
- avcodec/wavpack: Avoid undefined shift in get_tail()
- avcodec/wavpack: Check for end of input in wv_unpack_dsd_high()
- avformat/id3v2: Check taglen in read_uslt()
- avcodec/tiff: Ignore tile_count
- avcodec/ffv1dec: restructure slice coordinate reading a bit
- avcodec/mlpdec: Check max matrix instead of max channel in noise check
- swscale/input: Use more unsigned intermediates
- avcodec/alsdec: The minimal block is at least 7 bits
- avformat/replaygain: avoid undefined / negative abs
- swscale/output: Bias 16bps output calculations to improve non overflowing range
- avcodec/speedhq: Check buf_size to be big enough for DC
- avcodec/ffv1dec: Fail earlier if prior context is corrupted
- avfilter/vf_untile: swap the chroma shift values used for plane offsets
- hwcontext_vulkan: remove optional encode/decode extensions from the list
- avcodec/nvenc: fix vbv buffer size in cq mode
- avcodec/mjpegenc: take into account component count when writing the SOF header size
version 5.0.2:
- swscale: aarch64: Fix yuv2rgb with negative strides
- avcodec/atrac3plusdec: fix compilation failure after last commit
- avcodec/atrac3plus: reorder channels to match the output layout
- avcodec/aacdec: fix parsing streams with channel configuration 11
- Changelog: update
- avcodec/speexdec: Check channels > 2
- avformat/vividas: Check packet size
- avcodec/dstdec: Check for overflow in build_filter()
- avformat/spdifdec: Use 64bit to compute bit rate
- avformat/rpl: Use 64bit for duration computation
- avformat/xwma: Use av_rescale() for duration computation
- avformat/sdsdec: Use av_rescale() to avoid intermediate overflow in duration calculation
- avformat/sbgdec: Check ts_int in genrate_intervals
- avformat/sbgdec: clamp end_ts
- avformat/rmdec: check tag_size
- avformat/nutdec: Check fields
- avformat/flvdec: Use 64bit for sum_flv_tag_size
- avformat/jacosubdec: Fix overflow in get_shift()
- avformat/dxa: avoid bpc overflows
- avformat/dhav: Use 64bit seek_back
- avformat/cafdec: Check that nb_frasmes fits within 64bit
- avformat/asfdec_o: Limit packet offset
- avformat/ape: Check frames size
- avformat/icodec: Check nb_pal
- avformat/aiffdec: Use 64bit for block_duration use
- avformat/aiffdec: Check block_duration
- avformat/mxfdec: only probe max run in
- avformat/mxfdec: Check run_in is within 65536
- avcodec/mjpegdec: Check for unsupported bayer case
- avcodec/apedec: Fix integer overflow in filter_3800()
- avcodec/tta: Check 24bit scaling for overflow
- avcodec/mobiclip: Check quantizer for overflow
- avcodec/exr: Check preview psize
- avcodec/tiff: Fix loop detection
- libavformat/hls: Free keys
- avcodec/fmvc: Move frame allocation to a later stage
- avfilter/vf_showinfo: remove backspaces
- avcodec/speedhq: Check width
- avcodec/bink: disallow odd positioned scaled blocks
- libswscale: force a minimum size of the slide for bayer sources
- lavc/videotoolbox: do not pass AVCodecContext to decoder output callback
- lavc/pthread_frame: always transfer stashed hwaccel state
- avformat/cafenc: derive Opus frame size from the relevant stream parameters
- avcodec/arm/sbcenc: avoid callee preserved vfp registers
- avfilter/vf_scale: overwrite the width and height expressions with the original values
- lavc/pthread_frame: avoid leaving stale hwaccel state in worker threads
- Update for 5.0.2
- avformat/asfdec_o: limit recursion depth in asf_read_unknown()
- doc/git-howto.texi: Document commit signing
- libavcodec/8bps: Check that line lengths fit within the buffer
- avcodec/midivid: Perform lzss_uncompress() before ff_reget_buffer()
- libavformat/iff: Check for overflow in body_end calculation
- avformat/avidec: Prevent entity expansion attacks
- avcodec/h263dec: Sanity check against minimal I/P frame size
- avcodec/hevcdec: Check s->ref in the md5 path similar to hwaccel
- avcodec/mpegaudiodec_template: use unsigned shift in handle_crc()
- avformat/subviewerdec: Make read_ts() more flexible
- avcodec/mjpegdec: bayer and rct are incompatible
- MAINTAINERS: Add ED25519 key for signing my commits in the future
- avcodec/hevc_filter: copy_CTB() only within width&height
- avcodec/tiff: Check tile_length and tile_width
- avcodec/mss4: Check image size with av_image_check_size2()
- avformat/flvdec: Check for EOF in index reading
- avformat/nutdec: Check get_packetheader() in mainheader
- avformat/asfdec_f: Use 64bit for packet start time
- avcodec/exr: Check x/ysize
- tools/target_dec_fuzzer: Adjust threshold for MMVIDEO
- avcodec/lagarith: Check dst/src in zero run code
- avcodec/h264dec: Skip late SEI
- avcodec/sbrdsp_fixed: Fix integer overflows in sbr_qmf_deint_neg_c()
- avfilter/vf_signature: Fix integer overflow in filter_frame()
- avformat/rtsp: break on unknown protocols
- avcodec/hevcdsp_template: stay within tables in sao_band_filter()
- avcodec/tiff: Check pixel format types for dng
- avcodec/qpeldsp: copy less for the mc0x cases
- avformat/aaxdec: Check for empty segments
- avcodec/ffv1dec: Limit golomb rice coded slices to width 8M
- avformat/iff: simplify duration calculation
- avcodec/wnv1: Check for width =1
- avcodec/ffv1dec_template: fix indention
- avformat/sctp: close socket on errors
- avformat/cinedec: Check size and pos more
- avcodec/aasc: Fix indention
- avcodec/qdrw: adjust max colors to array size
- avcodec/alacdsp: Make intermediates unsigned
- avformat/aiffdec: cleanup size handling for extreem cases
- avformat/matroskadec: avoid integer overflows in SAR computation
- avcodec/jpeglsdec: fix end check for xfrm
- avcodec/cdgraphics: limit scrolling to the line
- avformat/hls: Limit start_seq_no to one bit less
- avformat/aiffdec: avoid integer overflow in get_meta()
- avformat/aaxdec: Check for overlaping segments
- avformat/ape: more bits in size for less overflows
- avformat/aviobuf: Check buf_size in ffio_ensure_seekback()
- avformat/bfi: Check offsets better
- avformat/asfdec_f: Check packet_frag_timestamp
- avcodec/texturedspenc: Fix indexing in color distribution determination
- avformat/act: Check ff_get_wav_header() for failure
- avcodec/libxavs2: Improve r redundancy in occured
- avformat/libzmq: Improve r redundancy in occured
- avfilter/vf_libplacebo: Match AV_OPT_TYPE_FLOAT to dbl
- avfilter/vsrc_mandelbrot: Check for malloc failure
- avfilter/vf_frei0r: Copy to frame allocated according to frei0r requirements
- avfilter/video: Add ff_default_get_video_buffer2() to set specific alignment
- avformat/genh: Check sample rate
- avformat/demux: Use unsigned to check duration vs duration_text
- avutil/hwcontext_d3d11va: fix texture_infos writes on non-fixed-size pools
- avcodec/cuviddec: fix null pointer dereference
- avcodec/cuviddec: fix AV1 decoding error
- configure: extend SDL check to accept all 2.x versions
- lavf/tls_mbedtls: add support for mbedtls version 3
- fate: update reference files after the recent dash manifest muxer changes
- avformat/webmdashenc: fix on-demand profile string
- avcodec/libdav1d: don't depend on the event flags API to init sequence params the first time
version 5.0.1:
- avcodec/exr: Avoid signed overflow in displayWindow
- avcodec/diracdec: avoid signed integer overflow in global mv
- avcodec/takdsp: Fix integer overflow in decorrelate_sf()
- avcodec/apedec: fix a integer overflow in long_filter_high_3800()
- avdevice/dshow: fix regression
- avfilter/vf_subtitles: pass storage size to libass
- avcodec/vp9_superframe_split_bsf: Don't read inexistent data
- avcodec/vp9_superframe_split_bsf: Discard invalid zero-sized frames
- avcodec/vp9_superframe_bsf: Check for existence of data before reading it
- avcodec/vp9_raw_reorder_bsf: Check for existence of data before reading it
- avformat/imf: fix packet pts, dts and muxing
- avformat/imf: open resources only when first needed
- avformat/imf: cosmetics
- avformat/imf_cpl: do not use filesize when reading XML file
- avformat/imfdec: Use proper logcontext
- avformat/imfdec: do not use filesize when reading XML file
- doc/utils: add missing 22.2 layout entry
- avcodec/av1: only set the private context pix_fmt field if get_pixel_format() succeeds
- avformat/aqtitledec: Skip unrepresentable durations
- avformat/cafdec: Do not store empty keys in read_info_chunk()
- avformat/mxfdec: Do not clear array in mxf_read_strong_ref_array() before writing
- avformat/mxfdec: Check for avio_read() failure in mxf_read_strong_ref_array()
- avformat/mxfdec: Check count in mxf_read_strong_ref_array()
- avformat/hls: Check target_duration
- avcodec/pixlet: Avoid signed integer overflow in scaling in filterfn()
- avformat/matroskadec: Check pre_ns
- avcodec/sonic: Use unsigned for predictor_k to avoid undefined behavior
- avcodec/libuavs3d: Check ff_set_dimensions() for failure
- avcodec/speexdec: Align some comments
- avcodec/speexdec: Use correct doxygen comments
- avcodec/mjpegbdec: Set buf_size
- avformat/matroskadec: Use rounded down duration in get_cue_desc() check
- avcodec/argo: Check packet size
- avcodec/g729_parser: Check channels
- avformat/avidec: Check height
- avformat/rmdec: Better duplicate tags check
- avformat/mov: Disallow empty sidx
- avformat/argo_cvg:: Fix order of operations in error check in argo_cvg_write_trailer()
- avformat/argo_asf: Fix order of operations in error check in argo_asf_write_trailer()
- avcodec/movtextdec: add () to CMP() macro to avoid unexpected behavior
- avformat/matroskadec: Check duration
- avformat/mov: Corner case encryption error cleanup in mov_read_senc()
- avcodec/jpeglsdec: Fix if( code style
- avcodec/jpeglsdec: Check get_ur_golomb_jpegls() for error
- avcodec/motion_est: fix indention of ff_get_best_fcode()
- avcodec/motion_est: Fix xy indexing on range violation in ff_get_best_fcode()
- avformat/hls: Use unsigned for iv computation
- avcodec/jpeglsdec: Increase range for N in ls_get_code_runterm() by using unsigned
- avformat/matroskadec: Check desc_bytes
- avformat/utils: Fix invalid NULL pointer operation in ff_parse_key_value()
- avformat/matroskadec: Fix infinite loop with bz decompression
- avformat/utils: keep chapter monotonicity on chapter updates
- avformat/mov: Check size before subtraction
- avcodec/cfhd: Avoid signed integer overflow in coeff
- avcodec/libdav1d: free the Dav1dData packet on dav1d_send_data() failure
- avcodec/h264_parser: don't alter decoder private data
- configure: link to libatomic when it's present
- fate/ffmpeg: add missing samples dependency to fate-shortest
version 5.0:
- ADPCM IMA Westwood encoder - ADPCM IMA Westwood encoder
- Westwood AUD muxer - Westwood AUD muxer
- ADPCM IMA Acorn Replay decoder - ADPCM IMA Acorn Replay decoder
@ -44,6 +273,7 @@ version <next>:
- yadif_videotoolbox filter - yadif_videotoolbox filter
- VideoToolbox ProRes encoder - VideoToolbox ProRes encoder
- anlmf audio filter - anlmf audio filter
- IMF demuxer (experimental)
version 4.4: version 4.4:

View file

@ -618,6 +618,7 @@ Jean Delvare 7CA6 9F44 60F1 BDC4 1FD2 C858 A552 6B9B B3CD 4E6A
Loren Merritt ABD9 08F4 C920 3F65 D8BE 35D7 1540 DAA7 060F 56DE Loren Merritt ABD9 08F4 C920 3F65 D8BE 35D7 1540 DAA7 060F 56DE
Lynne FE50 139C 6805 72CA FD52 1F8D A2FE A5F0 3F03 4464 Lynne FE50 139C 6805 72CA FD52 1F8D A2FE A5F0 3F03 4464
Michael Niedermayer 9FF2 128B 147E F673 0BAD F133 611E C787 040B 0FAB Michael Niedermayer 9FF2 128B 147E F673 0BAD F133 611E C787 040B 0FAB
DD1E C9E8 DE08 5C62 9B3E 1846 B18E 8928 B394 8D64
Nicolas George 24CE 01CE 9ACC 5CEB 74D8 8D9D B063 D997 36E5 4C93 Nicolas George 24CE 01CE 9ACC 5CEB 74D8 8D9D B063 D997 36E5 4C93
Nikolay Aleksandrov 8978 1D8C FB71 588E 4B27 EAA8 C4F0 B5FC E011 13B1 Nikolay Aleksandrov 8978 1D8C FB71 588E 4B27 EAA8 C4F0 B5FC E011 13B1
Panagiotis Issaris 6571 13A3 33D9 3726 F728 AA98 F643 B12E ECF3 E029 Panagiotis Issaris 6571 13A3 33D9 3726 F728 AA98 F643 B12E ECF3 E029

View file

@ -1 +1 @@
4.4.git 5.0.3

15
RELEASE_NOTES Normal file
View file

@ -0,0 +1,15 @@
┌────────────────────────────────────────┐
│ RELEASE NOTES for FFmpeg 5.0 "Lorentz" │
└────────────────────────────────────────┘
The FFmpeg Project proudly presents FFmpeg 5.0 "Lorentz", about 9
months after the release of FFmpeg 4.4.
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.

56
configure vendored
View file

@ -2117,6 +2117,7 @@ ARCH_EXT_LIST_PPC="
ldbrx ldbrx
power8 power8
ppc4xx ppc4xx
vec_xl
vsx vsx
" "
@ -2409,6 +2410,7 @@ HAVE_LIST="
opencl_vaapi_intel_media opencl_vaapi_intel_media
perl perl
pod2man pod2man
posix_ioctl
texi2html texi2html
xmllint xmllint
zlib_gzip zlib_gzip
@ -2624,6 +2626,7 @@ altivec_deps="ppc"
dcbzl_deps="ppc" dcbzl_deps="ppc"
ldbrx_deps="ppc" ldbrx_deps="ppc"
ppc4xx_deps="ppc" ppc4xx_deps="ppc"
vec_xl_deps="altivec"
vsx_deps="altivec" vsx_deps="altivec"
power8_deps="vsx" power8_deps="vsx"
@ -3353,7 +3356,7 @@ librav1e_encoder_deps="librav1e"
librav1e_encoder_select="extract_extradata_bsf" librav1e_encoder_select="extract_extradata_bsf"
librsvg_decoder_deps="librsvg" librsvg_decoder_deps="librsvg"
libshine_encoder_deps="libshine" libshine_encoder_deps="libshine"
libshine_encoder_select="audio_frame_queue" libshine_encoder_select="audio_frame_queue mpegaudioheader"
libspeex_decoder_deps="libspeex" libspeex_decoder_deps="libspeex"
libspeex_encoder_deps="libspeex" libspeex_encoder_deps="libspeex"
libspeex_encoder_select="audio_frame_queue" libspeex_encoder_select="audio_frame_queue"
@ -3391,6 +3394,7 @@ ac3_demuxer_select="ac3_parser"
act_demuxer_select="riffdec" act_demuxer_select="riffdec"
adts_muxer_select="mpeg4audio" adts_muxer_select="mpeg4audio"
aiff_muxer_select="iso_media" aiff_muxer_select="iso_media"
amv_muxer_select="riffenc"
asf_demuxer_select="riffdec" asf_demuxer_select="riffdec"
asf_o_demuxer_select="riffdec" asf_o_demuxer_select="riffdec"
asf_muxer_select="riffenc" asf_muxer_select="riffenc"
@ -3476,7 +3480,6 @@ w64_muxer_select="wav_muxer"
wav_demuxer_select="riffdec" wav_demuxer_select="riffdec"
wav_muxer_select="riffenc" wav_muxer_select="riffenc"
webm_chunk_muxer_select="webm_muxer" webm_chunk_muxer_select="webm_muxer"
webm_muxer_select="mpeg4audio riffenc"
webm_dash_manifest_demuxer_select="matroska_demuxer" webm_dash_manifest_demuxer_select="matroska_demuxer"
wtv_demuxer_select="mpegts_demuxer riffdec" wtv_demuxer_select="mpegts_demuxer riffdec"
wtv_muxer_select="mpegts_muxer riffenc" wtv_muxer_select="mpegts_muxer riffenc"
@ -3498,6 +3501,7 @@ caca_outdev_deps="libcaca"
decklink_deps_any="libdl LoadLibrary" decklink_deps_any="libdl LoadLibrary"
decklink_indev_deps="decklink threads" decklink_indev_deps="decklink threads"
decklink_indev_extralibs="-lstdc++" decklink_indev_extralibs="-lstdc++"
decklink_indev_suggest="libzvbi"
decklink_outdev_deps="decklink threads" decklink_outdev_deps="decklink threads"
decklink_outdev_suggest="libklvanc" decklink_outdev_suggest="libklvanc"
decklink_outdev_extralibs="-lstdc++" decklink_outdev_extralibs="-lstdc++"
@ -3790,20 +3794,20 @@ cws2fws_extralibs="zlib_extralibs"
# libraries, in any order # libraries, in any order
avcodec_deps="avutil" avcodec_deps="avutil"
avcodec_suggest="libm" avcodec_suggest="libm stdatomic"
avdevice_deps="avformat avcodec avutil" avdevice_deps="avformat avcodec avutil"
avdevice_suggest="libm" avdevice_suggest="libm stdatomic"
avfilter_deps="avutil" avfilter_deps="avutil"
avfilter_suggest="libm" avfilter_suggest="libm stdatomic"
avformat_deps="avcodec avutil" avformat_deps="avcodec avutil"
avformat_suggest="libm network zlib" avformat_suggest="libm network zlib stdatomic"
avutil_suggest="clock_gettime ffnvcodec libm libdrm libmfx opencl user32 vaapi vulkan videotoolbox corefoundation corevideo coremedia bcrypt" avutil_suggest="clock_gettime ffnvcodec libm libdrm libmfx opencl user32 vaapi vulkan videotoolbox corefoundation corevideo coremedia bcrypt stdatomic"
postproc_deps="avutil gpl" postproc_deps="avutil gpl"
postproc_suggest="libm" postproc_suggest="libm stdatomic"
swresample_deps="avutil" swresample_deps="avutil"
swresample_suggest="libm libsoxr" swresample_suggest="libm libsoxr stdatomic"
swscale_deps="avutil" swscale_deps="avutil"
swscale_suggest="libm" swscale_suggest="libm stdatomic"
avcodec_extralibs="pthreads_extralibs iconv_extralibs dxva2_extralibs" avcodec_extralibs="pthreads_extralibs iconv_extralibs dxva2_extralibs"
avfilter_extralibs="pthreads_extralibs" avfilter_extralibs="pthreads_extralibs"
@ -6083,6 +6087,11 @@ elif enabled ppc; then
check_cpp_condition power8 "altivec.h" "defined(_ARCH_PWR8)" check_cpp_condition power8 "altivec.h" "defined(_ARCH_PWR8)"
fi 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 x86; then elif enabled x86; then
check_builtin rdtsc intrin.h "__rdtsc()" check_builtin rdtsc intrin.h "__rdtsc()"
@ -6320,7 +6329,14 @@ check_headers asm/types.h
# it seems there are versions of clang in some distros that try to use the # it seems there are versions of clang in some distros that try to use the
# gcc headers, which explodes for stdatomic # gcc headers, which explodes for stdatomic
# so we also check that atomics actually work here # so we also check that atomics actually work here
check_builtin stdatomic stdatomic.h "atomic_int foo, bar = ATOMIC_VAR_INIT(-1); atomic_store(&foo, 0); foo += bar" #
# some configurations also require linking to libatomic, so try
# both with -latomic and without
for LATOMIC in "-latomic" ""; do
check_builtin stdatomic stdatomic.h \
"atomic_int foo, bar = ATOMIC_VAR_INIT(-1); atomic_store(&foo, 0); foo += bar" \
$LATOMIC && eval stdatomic_extralibs="\$LATOMIC" && break
done
check_lib advapi32 "windows.h" RegCloseKey -ladvapi32 check_lib advapi32 "windows.h" RegCloseKey -ladvapi32
check_lib bcrypt "windows.h bcrypt.h" BCryptGenRandom -lbcrypt && check_lib bcrypt "windows.h bcrypt.h" BCryptGenRandom -lbcrypt &&
@ -6586,7 +6602,7 @@ enabled libopus && {
require_pkg_config libopus opus opus_multistream.h opus_multistream_surround_encoder_create require_pkg_config libopus opus opus_multistream.h opus_multistream_surround_encoder_create
} }
} }
enabled libplacebo && require_pkg_config libplacebo "libplacebo >= 4.184.0" libplacebo/vulkan.h pl_vulkan_create enabled libplacebo && require_pkg_config libplacebo "libplacebo >= 4.192.0" libplacebo/vulkan.h pl_vulkan_create
enabled libpulse && require_pkg_config libpulse libpulse pulse/pulseaudio.h pa_context_new enabled libpulse && require_pkg_config libpulse libpulse pulse/pulseaudio.h pa_context_new
enabled librabbitmq && require_pkg_config librabbitmq "librabbitmq >= 0.7.1" amqp.h amqp_new_connection enabled librabbitmq && require_pkg_config librabbitmq "librabbitmq >= 0.7.1" amqp.h amqp_new_connection
enabled librav1e && require_pkg_config librav1e "rav1e >= 0.4.0" rav1e.h rav1e_context_new enabled librav1e && require_pkg_config librav1e "rav1e >= 0.4.0" rav1e.h rav1e_context_new
@ -6731,7 +6747,7 @@ fi
if enabled sdl2; then if enabled sdl2; then
SDL2_CONFIG="${cross_prefix}sdl2-config" SDL2_CONFIG="${cross_prefix}sdl2-config"
test_pkg_config sdl2 "sdl2 >= 2.0.1 sdl2 < 2.1.0" SDL_events.h SDL_PollEvent test_pkg_config sdl2 "sdl2 >= 2.0.1 sdl2 < 3.0.0" SDL_events.h SDL_PollEvent
if disabled sdl2 && "${SDL2_CONFIG}" --version > /dev/null 2>&1; then if disabled sdl2 && "${SDL2_CONFIG}" --version > /dev/null 2>&1; then
sdl2_cflags=$("${SDL2_CONFIG}" --cflags) sdl2_cflags=$("${SDL2_CONFIG}" --cflags)
sdl2_extralibs=$("${SDL2_CONFIG}" --libs) sdl2_extralibs=$("${SDL2_CONFIG}" --libs)
@ -6778,11 +6794,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 rsync --help 2> /dev/null | grep -q 'contimeout' && enable rsync_contimeout || disable rsync_contimeout
xmllint --version > /dev/null 2>&1 && enable xmllint || disable xmllint 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 # check V4L2 codecs available in the API
if enabled v4l2_m2m; then 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 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 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;" check_cc mpeg1_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_MPEG1;"
@ -6827,8 +6845,7 @@ enabled alsa && { check_pkg_config alsa alsa "alsa/asoundlib.h" snd_pcm_htimesta
enabled libjack && enabled libjack &&
require_pkg_config libjack jack jack/jack.h jack_port_get_latency_range require_pkg_config libjack jack jack/jack.h jack_port_get_latency_range
enabled sndio && { check_pkg_config sndio sndio "sndio.h" sio_open || enabled sndio && check_pkg_config sndio sndio sndio.h sio_open
check_lib sndio sndio.h sio_open -lsndio; }
if enabled libcdio; then if enabled libcdio; then
check_pkg_config libcdio libcdio_paranoia "cdio/cdda.h cdio/paranoia.h" cdio_cddap_open || check_pkg_config libcdio libcdio_paranoia "cdio/cdda.h cdio/paranoia.h" cdio_cddap_open ||
@ -6931,7 +6948,7 @@ fi
if enabled x86; then if enabled x86; then
case $target_os in case $target_os in
mingw32*|mingw64*|win32|win64|linux|cygwin*) freebsd|mingw32*|mingw64*|win32|win64|linux|cygwin*)
;; ;;
*) *)
disable ffnvcodec cuvid nvdec nvenc disable ffnvcodec cuvid nvdec nvenc
@ -7514,6 +7531,7 @@ if enabled ppc; then
echo "POWER8 enabled ${power8-no}" echo "POWER8 enabled ${power8-no}"
echo "PPC 4xx optimizations ${ppc4xx-no}" echo "PPC 4xx optimizations ${ppc4xx-no}"
echo "dcbzl available ${dcbzl-no}" echo "dcbzl available ${dcbzl-no}"
echo "vec_xl available ${vec_xl-no}"
fi fi
if enabled loongarch; then if enabled loongarch; then
echo "LSX enabled ${lsx-no}" 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 # could be handy for archiving the generated documentation or if some version
# control system is used. # control system is used.
PROJECT_NUMBER = PROJECT_NUMBER = 5.0.3
# Using the PROJECT_BRIEF tag one can provide an optional one line description # 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 # 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. The FFmpeg developers.
For details about the authorship, see the Git history of the project 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 @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 Maintainers for the specific components are listed in the file
@file{MAINTAINERS} in the source code tree. @file{MAINTAINERS} in the source code tree.

File diff suppressed because one or more lines are too long

View file

@ -53,7 +53,7 @@ Most distribution and operating system provide a package for it.
@section Cloning the source tree @section Cloning the source tree
@example @example
git clone git://source.ffmpeg.org/ffmpeg <target> git clone https://git.ffmpeg.org/ffmpeg.git <target>
@end example @end example
This will put the FFmpeg sources into the directory @var{<target>}. This will put the FFmpeg sources into the directory @var{<target>}.
@ -187,11 +187,18 @@ to make sure you don't have untracked files or deletions.
git add [-i|-p|-A] <filenames/dirnames> git add [-i|-p|-A] <filenames/dirnames>
@end example @end example
Make sure you have told Git your name and email address Make sure you have told Git your name, email address and GPG key
@example @example
git config --global user.name "My Name" git config --global user.name "My Name"
git config --global user.email my@@email.invalid git config --global user.email my@@email.invalid
git config --global user.signingkey ABCDEF0123245
@end example
Enable signing all commits or use -S
@example
git config --global commit.gpgsign true
@end example @end example
Use @option{--global} to set the global configuration for all your Git checkouts. Use @option{--global} to set the global configuration for all your Git checkouts.
@ -423,6 +430,19 @@ git checkout -b svn_23456 $SHA1
where @var{$SHA1} is the commit hash from the @command{git log} output. where @var{$SHA1} is the commit hash from the @command{git log} output.
@chapter gpg key generation
If you have no gpg key yet, we recommend that you create a ed25519 based key as it
is small, fast and secure. Especially it results in small signatures in git.
@example
gpg --default-new-key-algo "ed25519/cert,sign+cv25519/encr" --quick-generate-key "human@@server.com"
@end example
When generating a key, make sure the email specified matches the email used in git as some sites like
github consider mismatches a reason to declare such commits unverified. After generating a key you
can add it to the MAINTAINER file and upload it to a keyserver.
@chapter Pre-push checklist @chapter Pre-push checklist
Once you have a set of commits that you feel are ready for pushing, Once you have a set of commits that you feel are ready for pushing,

View file

@ -20,8 +20,45 @@
# License along with FFmpeg; if not, write to the Free Software # License along with FFmpeg; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # 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 # no navigation elements
set_from_init_file('HEADERS', 0); ff_set_from_init_file('HEADERS', 0);
sub ffmpeg_heading_command($$$$$) sub ffmpeg_heading_command($$$$$)
{ {
@ -55,7 +92,7 @@ sub ffmpeg_heading_command($$$$$)
$element = $command->{'parent'}; $element = $command->{'parent'};
} }
if ($element) { if ($element) {
$result .= &{$self->{'format_element_header'}}($self, $cmdname, $result .= &{get_formatting_function($self, 'format_element_header')}($self, $cmdname,
$command, $element); $command, $element);
} }
@ -112,7 +149,11 @@ sub ffmpeg_heading_command($$$$$)
$cmdname $cmdname
= $Texinfo::Common::level_to_structuring_command{$cmdname}->[$heading_level]; = $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, $self, $cmdname, $heading,
$heading_level + $heading_level +
$self->get_conf('CHAPTER_HEADER_LEVEL') - 1, $command); $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); 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 # print the TOC where @contents is used
if ($program_version_6_8) { if ($program_version_6_8) {
set_from_init_file('CONTENTS_OUTPUT_LOCATION', 'inline'); ff_set_from_init_file('CONTENTS_OUTPUT_LOCATION', 'inline');
} else { } else {
set_from_init_file('INLINE_CONTENTS', 1); ff_set_from_init_file('INLINE_CONTENTS', 1);
} }
# make chapters <h2> # make chapters <h2>
set_from_init_file('CHAPTER_HEADER_LEVEL', 2); ff_set_from_init_file('CHAPTER_HEADER_LEVEL', 2);
# Do not add <hr> # Do not add <hr>
set_from_init_file('DEFAULT_RULE', ''); ff_set_from_init_file('DEFAULT_RULE', '');
set_from_init_file('BIG_RULE', ''); ff_set_from_init_file('BIG_RULE', '');
# Customized file beginning # Customized file beginning
sub ffmpeg_begin_file($$$) sub ffmpeg_begin_file($$$)
@ -159,7 +196,18 @@ sub ffmpeg_begin_file($$$)
my ($title, $description, $encoding, $date, $css_lines, my ($title, $description, $encoding, $date, $css_lines,
$doctype, $bodytext, $copying_comment, $after_body_open, $doctype, $bodytext, $copying_comment, $after_body_open,
$extra_head, $program_and_version, $program_homepage, $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); my $links = $self->_get_links ($filename, $element);
@ -223,7 +271,7 @@ if ($program_version_6_8) {
sub ffmpeg_end_file($) sub ffmpeg_end_file($)
{ {
my $self = shift; 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; my $program_text = <<EOT;
<p style="font-size: small;"> <p style="font-size: small;">
$program_string $program_string
@ -244,7 +292,7 @@ if ($program_version_6_8) {
# Dummy title command # Dummy title command
# Ignore title. Title is handled through ffmpeg_begin_file(). # 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($$$$) sub ffmpeg_title($$$$)
{ {
return ''; return '';
@ -262,8 +310,14 @@ sub ffmpeg_float($$$$$)
my $args = shift; my $args = shift;
my $content = shift; my $content = shift;
my ($caption, $prepended) = Texinfo::Common::float_name_caption($self, my ($caption, $prepended);
$command); 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 $caption_text = '';
my $prepended_text; my $prepended_text;
my $prepended_save = ''; my $prepended_save = '';
@ -335,8 +389,13 @@ sub ffmpeg_float($$$$$)
$caption->{'args'}->[0], 'float caption'); $caption->{'args'}->[0], 'float caption');
} }
if ($prepended_text.$caption_text ne '') { if ($prepended_text.$caption_text ne '') {
$prepended_text = $self->_attribute_class('div','float-caption'). '>' if ($program_version_num >= 7.000000) {
. $prepended_text; $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>'; $caption_text .= '</div>';
} }
my $html_class = ''; my $html_class = '';
@ -349,8 +408,13 @@ sub ffmpeg_float($$$$$)
$prepended_text = ''; $prepended_text = '';
$caption_text = ''; $caption_text = '';
} }
return $self->_attribute_class('div', $html_class). '>' . "\n" . if ($program_version_num >= 7.000000) {
$prepended_text . $caption_text . $content . '</div>'; 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', texinfo_register_command_formatting('float',

View file

@ -719,6 +719,8 @@ FL+FR+FC+BL+BR+BC+SL+SR
FL+FR+FC+BL+BR+BC+SL+SR+WL+WR+TBL+TBR+TBC+TFC+TFL+TFR FL+FR+FC+BL+BR+BC+SL+SR+WL+WR+TBL+TBR+TBC+TFC+TFL+TFR
@item downmix @item downmix
DL+DR DL+DR
@item 22.2
FL+FR+FC+LFE+BL+BR+FLC+FRC+BC+SL+SR+TC+TFL+TFC+TFR+TBL+TBC+TBR+LFE2+TSL+TSR+BFC+BFL+BFR
@end table @end table
A custom channel layout can be specified as a sequence of terms, separated by A custom channel layout can be specified as a sequence of terms, separated by

View file

@ -1823,7 +1823,7 @@ int show_sample_fmts(void *optctx, const char *opt, const char *arg)
int show_dispositions(void *optctx, const char *opt, const char *arg) int show_dispositions(void *optctx, const char *opt, const char *arg)
{ {
for (int i = 0; i < 32; i++) { for (int i = 0; i < 32; i++) {
const char *str = av_disposition_to_string(1 << i); const char *str = av_disposition_to_string(1U << i);
if (str) if (str)
printf("%s\n", str); printf("%s\n", str);
} }

View file

@ -819,8 +819,11 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
MATCH_PER_STREAM_OPT(codec_tags, str, codec_tag, ic, st); MATCH_PER_STREAM_OPT(codec_tags, str, codec_tag, ic, st);
if (codec_tag) { if (codec_tag) {
uint32_t tag = strtol(codec_tag, &next, 0); uint32_t tag = strtol(codec_tag, &next, 0);
if (*next) if (*next) {
tag = AV_RL32(codec_tag); uint8_t buf[4] = { 0 };
memcpy(buf, codec_tag, FFMIN(sizeof(buf), strlen(codec_tag)));
tag = AV_RL32(buf);
}
st->codecpar->codec_tag = tag; st->codecpar->codec_tag = tag;
} }
@ -1572,8 +1575,11 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e
MATCH_PER_STREAM_OPT(codec_tags, str, codec_tag, oc, st); MATCH_PER_STREAM_OPT(codec_tags, str, codec_tag, oc, st);
if (codec_tag) { if (codec_tag) {
uint32_t tag = strtol(codec_tag, &next, 0); uint32_t tag = strtol(codec_tag, &next, 0);
if (*next) if (*next) {
tag = AV_RL32(codec_tag); uint8_t buf[4] = { 0 };
memcpy(buf, codec_tag, FFMIN(sizeof(buf), strlen(codec_tag)));
tag = AV_RL32(buf);
}
ost->st->codecpar->codec_tag = ost->st->codecpar->codec_tag =
ost->enc_ctx->codec_tag = tag; ost->enc_ctx->codec_tag = tag;
} }

View file

@ -131,8 +131,8 @@ static int zero12v_decode_frame(AVCodecContext *avctx, void *data,
u = x/2 + (uint16_t *)(pic->data[1] + line * pic->linesize[1]); u = x/2 + (uint16_t *)(pic->data[1] + line * pic->linesize[1]);
v = x/2 + (uint16_t *)(pic->data[2] + line * pic->linesize[2]); v = x/2 + (uint16_t *)(pic->data[2] + line * pic->linesize[2]);
memcpy(y, y_temp, sizeof(*y) * (width - x)); memcpy(y, y_temp, sizeof(*y) * (width - x));
memcpy(u, u_temp, sizeof(*u) * (width - x + 1) / 2); memcpy(u, u_temp, sizeof(*u) * ((width - x + 1) / 2));
memcpy(v, v_temp, sizeof(*v) * (width - x + 1) / 2); memcpy(v, v_temp, sizeof(*v) * ((width - x + 1) / 2));
} }
line_end += stride; line_end += stride;

View file

@ -71,6 +71,9 @@ static int decode_frame(AVCodecContext *avctx, void *data,
unsigned char *planemap = c->planemap; unsigned char *planemap = c->planemap;
int ret; int ret;
if (buf_size < planes * height *2)
return AVERROR_INVALIDDATA;
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
return ret; return ret;

View file

@ -118,7 +118,8 @@ OBJS-$(CONFIG_MDCT) += mdct_float.o mdct_fixed_32.o
OBJS-$(CONFIG_ME_CMP) += me_cmp.o OBJS-$(CONFIG_ME_CMP) += me_cmp.o
OBJS-$(CONFIG_MEDIACODEC) += mediacodecdec_common.o mediacodec_surface.o mediacodec_wrapper.o mediacodec_sw_buffer.o OBJS-$(CONFIG_MEDIACODEC) += mediacodecdec_common.o mediacodec_surface.o mediacodec_wrapper.o mediacodec_sw_buffer.o
OBJS-$(CONFIG_MPEG_ER) += mpeg_er.o OBJS-$(CONFIG_MPEG_ER) += mpeg_er.o
OBJS-$(CONFIG_MPEGAUDIO) += mpegaudio.o mpegaudiodec_common.o OBJS-$(CONFIG_MPEGAUDIO) += mpegaudio.o mpegaudiodec_common.o \
mpegaudiodata.o
OBJS-$(CONFIG_MPEGAUDIODSP) += mpegaudiodsp.o \ OBJS-$(CONFIG_MPEGAUDIODSP) += mpegaudiodsp.o \
mpegaudiodsp_data.o \ mpegaudiodsp_data.o \
mpegaudiodsp_fixed.o \ mpegaudiodsp_fixed.o \
@ -133,7 +134,6 @@ OBJS-$(CONFIG_MPEGVIDEOENC) += mpegvideo_enc.o mpeg12data.o \
motion_est.o ratecontrol.o \ motion_est.o ratecontrol.o \
mpegvideoencdsp.o mpegvideoencdsp.o
OBJS-$(CONFIG_MSS34DSP) += mss34dsp.o OBJS-$(CONFIG_MSS34DSP) += mss34dsp.o
OBJS-$(CONFIG_NVENC) += nvenc.o
OBJS-$(CONFIG_PIXBLOCKDSP) += pixblockdsp.o OBJS-$(CONFIG_PIXBLOCKDSP) += pixblockdsp.o
OBJS-$(CONFIG_QPELDSP) += qpeldsp.o OBJS-$(CONFIG_QPELDSP) += qpeldsp.o
OBJS-$(CONFIG_QSV) += qsv.o OBJS-$(CONFIG_QSV) += qsv.o
@ -381,7 +381,7 @@ OBJS-$(CONFIG_H264_CUVID_DECODER) += cuviddec.o
OBJS-$(CONFIG_H264_MEDIACODEC_DECODER) += mediacodecdec.o OBJS-$(CONFIG_H264_MEDIACODEC_DECODER) += mediacodecdec.o
OBJS-$(CONFIG_H264_MF_ENCODER) += mfenc.o mf_utils.o OBJS-$(CONFIG_H264_MF_ENCODER) += mfenc.o mf_utils.o
OBJS-$(CONFIG_H264_MMAL_DECODER) += mmaldec.o OBJS-$(CONFIG_H264_MMAL_DECODER) += mmaldec.o
OBJS-$(CONFIG_H264_NVENC_ENCODER) += nvenc_h264.o OBJS-$(CONFIG_H264_NVENC_ENCODER) += nvenc_h264.o nvenc.o
OBJS-$(CONFIG_H264_OMX_ENCODER) += omx.o OBJS-$(CONFIG_H264_OMX_ENCODER) += omx.o
OBJS-$(CONFIG_H264_QSV_DECODER) += qsvdec.o OBJS-$(CONFIG_H264_QSV_DECODER) += qsvdec.o
OBJS-$(CONFIG_H264_QSV_ENCODER) += qsvenc_h264.o OBJS-$(CONFIG_H264_QSV_ENCODER) += qsvenc_h264.o
@ -396,12 +396,13 @@ OBJS-$(CONFIG_HCA_DECODER) += hcadec.o
OBJS-$(CONFIG_HCOM_DECODER) += hcom.o OBJS-$(CONFIG_HCOM_DECODER) += hcom.o
OBJS-$(CONFIG_HEVC_DECODER) += hevcdec.o hevc_mvs.o \ OBJS-$(CONFIG_HEVC_DECODER) += hevcdec.o hevc_mvs.o \
hevc_cabac.o hevc_refs.o hevcpred.o \ hevc_cabac.o hevc_refs.o hevcpred.o \
hevcdsp.o hevc_filter.o hevc_data.o hevcdsp.o hevc_filter.o hevc_data.o \
h274.o
OBJS-$(CONFIG_HEVC_AMF_ENCODER) += amfenc_hevc.o OBJS-$(CONFIG_HEVC_AMF_ENCODER) += amfenc_hevc.o
OBJS-$(CONFIG_HEVC_CUVID_DECODER) += cuviddec.o OBJS-$(CONFIG_HEVC_CUVID_DECODER) += cuviddec.o
OBJS-$(CONFIG_HEVC_MEDIACODEC_DECODER) += mediacodecdec.o OBJS-$(CONFIG_HEVC_MEDIACODEC_DECODER) += mediacodecdec.o
OBJS-$(CONFIG_HEVC_MF_ENCODER) += mfenc.o mf_utils.o OBJS-$(CONFIG_HEVC_MF_ENCODER) += mfenc.o mf_utils.o
OBJS-$(CONFIG_HEVC_NVENC_ENCODER) += nvenc_hevc.o OBJS-$(CONFIG_HEVC_NVENC_ENCODER) += nvenc_hevc.o nvenc.o
OBJS-$(CONFIG_HEVC_QSV_DECODER) += qsvdec.o OBJS-$(CONFIG_HEVC_QSV_DECODER) += qsvdec.o
OBJS-$(CONFIG_HEVC_QSV_ENCODER) += qsvenc_hevc.o hevc_ps_enc.o \ OBJS-$(CONFIG_HEVC_QSV_ENCODER) += qsvenc_hevc.o hevc_ps_enc.o \
hevc_data.o hevc_data.o
@ -886,6 +887,7 @@ OBJS-$(CONFIG_ADPCM_G726LE_DECODER) += g726.o
OBJS-$(CONFIG_ADPCM_G726LE_ENCODER) += g726.o OBJS-$(CONFIG_ADPCM_G726LE_ENCODER) += g726.o
OBJS-$(CONFIG_ADPCM_IMA_ACORN_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_IMA_ACORN_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_IMA_AMV_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_IMA_AMV_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_IMA_AMV_ENCODER) += adpcmenc.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_IMA_ALP_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_IMA_ALP_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_IMA_ALP_ENCODER) += adpcmenc.o adpcm_data.o OBJS-$(CONFIG_ADPCM_IMA_ALP_ENCODER) += adpcmenc.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_IMA_APC_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_IMA_APC_DECODER) += adpcm.o adpcm_data.o

View file

@ -716,9 +716,7 @@ static ChannelElement *get_che(AACContext *ac, int type, int elem_id)
return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][2]; return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][2];
} }
case 11: case 11:
if (ac->tags_mapped == 2 && if (ac->tags_mapped == 3 && type == TYPE_SCE) {
ac->oc[1].m4ac.chan_config == 11 &&
type == TYPE_SCE) {
ac->tags_mapped++; ac->tags_mapped++;
return ac->tag_che_map[TYPE_SCE][elem_id] = ac->che[TYPE_SCE][1]; return ac->tag_che_map[TYPE_SCE][elem_id] = ac->che[TYPE_SCE][1];
} }

View file

@ -35,7 +35,7 @@
#include <stdint.h> #include <stdint.h>
static const int8_t tags_per_config[16] = { 0, 1, 1, 2, 3, 3, 4, 5, 0, 0, 0, 4, 5, 16, 5, 0 }; static const int8_t tags_per_config[16] = { 0, 1, 1, 2, 3, 3, 4, 5, 0, 0, 0, 5, 5, 16, 5, 0 };
static const uint8_t aac_channel_layout_map[16][16][3] = { static const uint8_t aac_channel_layout_map[16][16][3] = {
{ { TYPE_SCE, 0, AAC_CHANNEL_FRONT }, }, { { TYPE_SCE, 0, AAC_CHANNEL_FRONT }, },
@ -83,7 +83,7 @@ static const uint64_t aac_channel_layout[16] = {
0, 0,
0, 0,
0, 0,
AV_CH_LAYOUT_6POINT1, AV_CH_LAYOUT_6POINT1_BACK,
AV_CH_LAYOUT_7POINT1, AV_CH_LAYOUT_7POINT1,
AV_CH_LAYOUT_22POINT2, AV_CH_LAYOUT_22POINT2,
0, 0,

View file

@ -75,7 +75,11 @@ av_cold void ff_hevc_dsp_init_aarch64(HEVCDSPContext *c, const int bit_depth)
c->idct_dc[1] = ff_hevc_idct_8x8_dc_8_neon; c->idct_dc[1] = ff_hevc_idct_8x8_dc_8_neon;
c->idct_dc[2] = ff_hevc_idct_16x16_dc_8_neon; c->idct_dc[2] = ff_hevc_idct_16x16_dc_8_neon;
c->idct_dc[3] = ff_hevc_idct_32x32_dc_8_neon; c->idct_dc[3] = ff_hevc_idct_32x32_dc_8_neon;
c->sao_band_filter[0] = ff_hevc_sao_band_filter_8x8_8_neon; // This function is disabled, as it doesn't handle widths that aren't
// an even multiple of 8 correctly. fate-hevc doesn't exercise that
// for the current size, but if enabled for bigger sizes, the cases
// of non-multiple of 8 seem to arise.
// c->sao_band_filter[0] = ff_hevc_sao_band_filter_8x8_8_neon;
} }
if (bit_depth == 10) { if (bit_depth == 10) {
c->add_residual[0] = ff_hevc_add_residual_4x4_10_neon; c->add_residual[0] = ff_hevc_add_residual_4x4_10_neon;

View file

@ -104,26 +104,26 @@ static int aasc_decode_frame(AVCodecContext *avctx,
ff_msrle_decode(avctx, s->frame, 8, &s->gb); ff_msrle_decode(avctx, s->frame, 8, &s->gb);
break; break;
case MKTAG('A', 'A', 'S', 'C'): case MKTAG('A', 'A', 'S', 'C'):
switch (compr) { switch (compr) {
case 0: case 0:
stride = (avctx->width * psize + psize) & ~psize; stride = (avctx->width * psize + psize) & ~psize;
if (buf_size < stride * avctx->height) if (buf_size < stride * avctx->height)
return AVERROR_INVALIDDATA;
for (i = avctx->height - 1; i >= 0; i--) {
memcpy(s->frame->data[0] + i * s->frame->linesize[0], buf, avctx->width * psize);
buf += stride;
buf_size -= stride;
}
break;
case 1:
bytestream2_init(&s->gb, buf, buf_size);
ff_msrle_decode(avctx, s->frame, 8, &s->gb);
break;
default:
av_log(avctx, AV_LOG_ERROR, "Unknown compression type %d\n", compr);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
for (i = avctx->height - 1; i >= 0; i--) {
memcpy(s->frame->data[0] + i * s->frame->linesize[0], buf, avctx->width * psize);
buf += stride;
buf_size -= stride;
} }
break; break;
case 1:
bytestream2_init(&s->gb, buf, buf_size);
ff_msrle_decode(avctx, s->frame, 8, &s->gb);
break;
default:
av_log(avctx, AV_LOG_ERROR, "Unknown compression type %d\n", compr);
return AVERROR_INVALIDDATA;
}
break;
default: default:
av_log(avctx, AV_LOG_ERROR, "Unknown FourCC: %X\n", avctx->codec_tag); av_log(avctx, AV_LOG_ERROR, "Unknown FourCC: %X\n", avctx->codec_tag);
return -1; return -1;

View file

@ -75,6 +75,7 @@
#define AC3_DYNAMIC_RANGE1 0 #define AC3_DYNAMIC_RANGE1 0
typedef int INTFLOAT; typedef int INTFLOAT;
typedef unsigned int UINTFLOAT;
typedef int16_t SHORTFLOAT; typedef int16_t SHORTFLOAT;
#else /* USE_FIXED */ #else /* USE_FIXED */
@ -94,6 +95,7 @@ typedef int16_t SHORTFLOAT;
#define AC3_DYNAMIC_RANGE1 1.0f #define AC3_DYNAMIC_RANGE1 1.0f
typedef float INTFLOAT; typedef float INTFLOAT;
typedef float UINTFLOAT;
typedef float SHORTFLOAT; typedef float SHORTFLOAT;
#endif /* USE_FIXED */ #endif /* USE_FIXED */

View file

@ -29,12 +29,12 @@ static void decorrelate_stereo(int32_t *buffer[2], int nb_samples,
int i; int i;
for (i = 0; i < nb_samples; i++) { for (i = 0; i < nb_samples; i++) {
int32_t a, b; uint32_t a, b;
a = buffer[0][i]; a = buffer[0][i];
b = buffer[1][i]; b = buffer[1][i];
a -= (int)(b * (unsigned)decorr_left_weight) >> decorr_shift; a -= (int)(b * decorr_left_weight) >> decorr_shift;
b += a; b += a;
buffer[0][i] = b; buffer[0][i] = b;

View file

@ -1017,7 +1017,7 @@ static int read_block(ALSDecContext *ctx, ALSBlockData *bd)
*bd->shift_lsbs = 0; *bd->shift_lsbs = 0;
if (get_bits_left(gb) < 1) if (get_bits_left(gb) < 7)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
// read block type flag and read the samples accordingly // read block type flag and read the samples accordingly

View file

@ -930,7 +930,7 @@ static av_always_inline int filter_3800(APEPredictor *p,
p->coeffsB[filter][0] += (((d3 >> 29) & 4) - 2) * sign; p->coeffsB[filter][0] += (((d3 >> 29) & 4) - 2) * sign;
p->coeffsB[filter][1] -= (((d4 >> 30) & 2) - 1) * sign; p->coeffsB[filter][1] -= (((d4 >> 30) & 2) - 1) * sign;
p->filterB[filter] = p->lastA[filter] + (predictionB >> shift); p->filterB[filter] = p->lastA[filter] + (unsigned)(predictionB >> shift);
p->filterA[filter] = p->filterB[filter] + (unsigned)((int)(p->filterA[filter] * 31U) >> 5); p->filterA[filter] = p->filterB[filter] + (unsigned)((int)(p->filterA[filter] * 31U) >> 5);
return p->filterA[filter]; return p->filterA[filter];
@ -955,7 +955,7 @@ static void long_filter_high_3800(int32_t *buffer, int order, int shift, int len
dotprod += delay[j] * (unsigned)coeffs[j]; dotprod += delay[j] * (unsigned)coeffs[j];
coeffs[j] += ((delay[j] >> 31) | 1) * sign; coeffs[j] += ((delay[j] >> 31) | 1) * sign;
} }
buffer[i] -= dotprod >> shift; buffer[i] -= (unsigned)(dotprod >> shift);
for (j = 0; j < order - 1; j++) for (j = 0; j < order - 1; j++)
delay[j] = delay[j + 1]; delay[j] = delay[j + 1];
delay[order - 1] = buffer[i]; delay[order - 1] = buffer[i];
@ -1088,13 +1088,13 @@ static av_always_inline int predictor_update_3930(APEPredictor *p,
const int delayA) const int delayA)
{ {
int32_t predictionA, sign; int32_t predictionA, sign;
int32_t d0, d1, d2, d3; uint32_t d0, d1, d2, d3;
p->buf[delayA] = p->lastA[filter]; p->buf[delayA] = p->lastA[filter];
d0 = p->buf[delayA ]; d0 = p->buf[delayA ];
d1 = p->buf[delayA ] - p->buf[delayA - 1]; d1 = p->buf[delayA ] - (unsigned)p->buf[delayA - 1];
d2 = p->buf[delayA - 1] - p->buf[delayA - 2]; d2 = p->buf[delayA - 1] - (unsigned)p->buf[delayA - 2];
d3 = p->buf[delayA - 2] - p->buf[delayA - 3]; d3 = p->buf[delayA - 2] - (unsigned)p->buf[delayA - 3];
predictionA = d0 * p->coeffsA[filter][0] + predictionA = d0 * p->coeffsA[filter][0] +
d1 * p->coeffsA[filter][1] + d1 * p->coeffsA[filter][1] +
@ -1105,10 +1105,10 @@ static av_always_inline int predictor_update_3930(APEPredictor *p,
p->filterA[filter] = p->lastA[filter] + ((int)(p->filterA[filter] * 31U) >> 5); p->filterA[filter] = p->lastA[filter] + ((int)(p->filterA[filter] * 31U) >> 5);
sign = APESIGN(decoded); sign = APESIGN(decoded);
p->coeffsA[filter][0] += ((d0 < 0) * 2 - 1) * sign; p->coeffsA[filter][0] += (((int32_t)d0 < 0) * 2 - 1) * sign;
p->coeffsA[filter][1] += ((d1 < 0) * 2 - 1) * sign; p->coeffsA[filter][1] += (((int32_t)d1 < 0) * 2 - 1) * sign;
p->coeffsA[filter][2] += ((d2 < 0) * 2 - 1) * sign; p->coeffsA[filter][2] += (((int32_t)d2 < 0) * 2 - 1) * sign;
p->coeffsA[filter][3] += ((d3 < 0) * 2 - 1) * sign; p->coeffsA[filter][3] += (((int32_t)d3 < 0) * 2 - 1) * sign;
return p->filterA[filter]; return p->filterA[filter];
} }

View file

@ -607,6 +607,9 @@ static int decode_frame(AVCodecContext *avctx, void *data,
uint32_t chunk; uint32_t chunk;
int ret; int ret;
if (avpkt->size < 4)
return AVERROR_INVALIDDATA;
bytestream2_init(gb, avpkt->data, avpkt->size); bytestream2_init(gb, avpkt->data, avpkt->size);
if ((ret = ff_reget_buffer(avctx, frame, 0)) < 0) if ((ret = ff_reget_buffer(avctx, frame, 0)) < 0)

View file

@ -38,49 +38,49 @@ function ff_sbc_analyze_4_neon, export=1
/* TODO: merge even and odd cases (or even merge all four calls to this /* TODO: merge even and odd cases (or even merge all four calls to this
* function) in order to have only aligned reads from 'in' array * function) in order to have only aligned reads from 'in' array
* and reduce number of load instructions */ * and reduce number of load instructions */
vld1.16 {d4, d5}, [r0, :64]! vld1.16 {d16, d17}, [r0, :64]!
vld1.16 {d8, d9}, [r2, :128]! vld1.16 {d20, d21}, [r2, :128]!
vmull.s16 q0, d4, d8 vmull.s16 q0, d16, d20
vld1.16 {d6, d7}, [r0, :64]! vld1.16 {d18, d19}, [r0, :64]!
vmull.s16 q1, d5, d9 vmull.s16 q1, d17, d21
vld1.16 {d10, d11}, [r2, :128]! vld1.16 {d22, d23}, [r2, :128]!
vmlal.s16 q0, d6, d10 vmlal.s16 q0, d18, d22
vld1.16 {d4, d5}, [r0, :64]! vld1.16 {d16, d17}, [r0, :64]!
vmlal.s16 q1, d7, d11 vmlal.s16 q1, d19, d23
vld1.16 {d8, d9}, [r2, :128]! vld1.16 {d20, d21}, [r2, :128]!
vmlal.s16 q0, d4, d8 vmlal.s16 q0, d16, d20
vld1.16 {d6, d7}, [r0, :64]! vld1.16 {d18, d19}, [r0, :64]!
vmlal.s16 q1, d5, d9 vmlal.s16 q1, d17, d21
vld1.16 {d10, d11}, [r2, :128]! vld1.16 {d22, d23}, [r2, :128]!
vmlal.s16 q0, d6, d10 vmlal.s16 q0, d18, d22
vld1.16 {d4, d5}, [r0, :64]! vld1.16 {d16, d17}, [r0, :64]!
vmlal.s16 q1, d7, d11 vmlal.s16 q1, d19, d23
vld1.16 {d8, d9}, [r2, :128]! vld1.16 {d20, d21}, [r2, :128]!
vmlal.s16 q0, d4, d8 vmlal.s16 q0, d16, d20
vmlal.s16 q1, d5, d9 vmlal.s16 q1, d17, d21
vpadd.s32 d0, d0, d1 vpadd.s32 d0, d0, d1
vpadd.s32 d1, d2, d3 vpadd.s32 d1, d2, d3
vrshrn.s32 d0, q0, SBC_PROTO_FIXED_SCALE vrshrn.s32 d0, q0, SBC_PROTO_FIXED_SCALE
vld1.16 {d2, d3, d4, d5}, [r2, :128]! vld1.16 {d16, d17, d18, d19}, [r2, :128]!
vdup.i32 d1, d0[1] /* TODO: can be eliminated */ vdup.i32 d1, d0[1] /* TODO: can be eliminated */
vdup.i32 d0, d0[0] /* TODO: can be eliminated */ vdup.i32 d0, d0[0] /* TODO: can be eliminated */
vmull.s16 q3, d2, d0 vmull.s16 q10, d16, d0
vmull.s16 q4, d3, d0 vmull.s16 q11, d17, d0
vmlal.s16 q3, d4, d1 vmlal.s16 q10, d18, d1
vmlal.s16 q4, d5, d1 vmlal.s16 q11, d19, d1
vpadd.s32 d0, d6, d7 /* TODO: can be eliminated */ vpadd.s32 d0, d20, d21 /* TODO: can be eliminated */
vpadd.s32 d1, d8, d9 /* TODO: can be eliminated */ vpadd.s32 d1, d22, d23 /* TODO: can be eliminated */
vst1.32 {d0, d1}, [r1, :128] vst1.32 {d0, d1}, [r1, :128]
@ -91,57 +91,57 @@ function ff_sbc_analyze_8_neon, export=1
/* TODO: merge even and odd cases (or even merge all four calls to this /* TODO: merge even and odd cases (or even merge all four calls to this
* function) in order to have only aligned reads from 'in' array * function) in order to have only aligned reads from 'in' array
* and reduce number of load instructions */ * and reduce number of load instructions */
vld1.16 {d4, d5}, [r0, :64]! vld1.16 {d16, d17}, [r0, :64]!
vld1.16 {d8, d9}, [r2, :128]! vld1.16 {d20, d21}, [r2, :128]!
vmull.s16 q6, d4, d8 vmull.s16 q12, d16, d20
vld1.16 {d6, d7}, [r0, :64]! vld1.16 {d18, d19}, [r0, :64]!
vmull.s16 q7, d5, d9 vmull.s16 q13, d17, d21
vld1.16 {d10, d11}, [r2, :128]! vld1.16 {d22, d23}, [r2, :128]!
vmull.s16 q8, d6, d10 vmull.s16 q14, d18, d22
vld1.16 {d4, d5}, [r0, :64]! vld1.16 {d16, d17}, [r0, :64]!
vmull.s16 q9, d7, d11 vmull.s16 q15, d19, d23
vld1.16 {d8, d9}, [r2, :128]! vld1.16 {d20, d21}, [r2, :128]!
vmlal.s16 q6, d4, d8 vmlal.s16 q12, d16, d20
vld1.16 {d6, d7}, [r0, :64]! vld1.16 {d18, d19}, [r0, :64]!
vmlal.s16 q7, d5, d9 vmlal.s16 q13, d17, d21
vld1.16 {d10, d11}, [r2, :128]! vld1.16 {d22, d23}, [r2, :128]!
vmlal.s16 q8, d6, d10 vmlal.s16 q14, d18, d22
vld1.16 {d4, d5}, [r0, :64]! vld1.16 {d16, d17}, [r0, :64]!
vmlal.s16 q9, d7, d11 vmlal.s16 q15, d19, d23
vld1.16 {d8, d9}, [r2, :128]! vld1.16 {d20, d21}, [r2, :128]!
vmlal.s16 q6, d4, d8 vmlal.s16 q12, d16, d20
vld1.16 {d6, d7}, [r0, :64]! vld1.16 {d18, d19}, [r0, :64]!
vmlal.s16 q7, d5, d9 vmlal.s16 q13, d17, d21
vld1.16 {d10, d11}, [r2, :128]! vld1.16 {d22, d23}, [r2, :128]!
vmlal.s16 q8, d6, d10 vmlal.s16 q14, d18, d22
vld1.16 {d4, d5}, [r0, :64]! vld1.16 {d16, d17}, [r0, :64]!
vmlal.s16 q9, d7, d11 vmlal.s16 q15, d19, d23
vld1.16 {d8, d9}, [r2, :128]! vld1.16 {d20, d21}, [r2, :128]!
vmlal.s16 q6, d4, d8 vmlal.s16 q12, d16, d20
vld1.16 {d6, d7}, [r0, :64]! vld1.16 {d18, d19}, [r0, :64]!
vmlal.s16 q7, d5, d9 vmlal.s16 q13, d17, d21
vld1.16 {d10, d11}, [r2, :128]! vld1.16 {d22, d23}, [r2, :128]!
vmlal.s16 q8, d6, d10 vmlal.s16 q14, d18, d22
vld1.16 {d4, d5}, [r0, :64]! vld1.16 {d16, d17}, [r0, :64]!
vmlal.s16 q9, d7, d11 vmlal.s16 q15, d19, d23
vld1.16 {d8, d9}, [r2, :128]! vld1.16 {d20, d21}, [r2, :128]!
vmlal.s16 q6, d4, d8 vmlal.s16 q12, d16, d20
vld1.16 {d6, d7}, [r0, :64]! vld1.16 {d18, d19}, [r0, :64]!
vmlal.s16 q7, d5, d9 vmlal.s16 q13, d17, d21
vld1.16 {d10, d11}, [r2, :128]! vld1.16 {d22, d23}, [r2, :128]!
vmlal.s16 q8, d6, d10 vmlal.s16 q14, d18, d22
vmlal.s16 q9, d7, d11 vmlal.s16 q15, d19, d23
vpadd.s32 d0, d12, d13 vpadd.s32 d0, d24, d25
vpadd.s32 d1, d14, d15 vpadd.s32 d1, d26, d27
vpadd.s32 d2, d16, d17 vpadd.s32 d2, d28, d29
vpadd.s32 d3, d18, d19 vpadd.s32 d3, d30, d31
vrshr.s32 q0, q0, SBC_PROTO_FIXED_SCALE vrshr.s32 q0, q0, SBC_PROTO_FIXED_SCALE
vrshr.s32 q1, q1, SBC_PROTO_FIXED_SCALE vrshr.s32 q1, q1, SBC_PROTO_FIXED_SCALE
@ -153,38 +153,38 @@ function ff_sbc_analyze_8_neon, export=1
vdup.i32 d1, d0[1] /* TODO: can be eliminated */ vdup.i32 d1, d0[1] /* TODO: can be eliminated */
vdup.i32 d0, d0[0] /* TODO: can be eliminated */ vdup.i32 d0, d0[0] /* TODO: can be eliminated */
vld1.16 {d4, d5}, [r2, :128]! vld1.16 {d16, d17}, [r2, :128]!
vmull.s16 q6, d4, d0 vmull.s16 q12, d16, d0
vld1.16 {d6, d7}, [r2, :128]! vld1.16 {d18, d19}, [r2, :128]!
vmull.s16 q7, d5, d0 vmull.s16 q13, d17, d0
vmull.s16 q8, d6, d0 vmull.s16 q14, d18, d0
vmull.s16 q9, d7, d0 vmull.s16 q15, d19, d0
vld1.16 {d4, d5}, [r2, :128]! vld1.16 {d16, d17}, [r2, :128]!
vmlal.s16 q6, d4, d1 vmlal.s16 q12, d16, d1
vld1.16 {d6, d7}, [r2, :128]! vld1.16 {d18, d19}, [r2, :128]!
vmlal.s16 q7, d5, d1 vmlal.s16 q13, d17, d1
vmlal.s16 q8, d6, d1 vmlal.s16 q14, d18, d1
vmlal.s16 q9, d7, d1 vmlal.s16 q15, d19, d1
vld1.16 {d4, d5}, [r2, :128]! vld1.16 {d16, d17}, [r2, :128]!
vmlal.s16 q6, d4, d2 vmlal.s16 q12, d16, d2
vld1.16 {d6, d7}, [r2, :128]! vld1.16 {d18, d19}, [r2, :128]!
vmlal.s16 q7, d5, d2 vmlal.s16 q13, d17, d2
vmlal.s16 q8, d6, d2 vmlal.s16 q14, d18, d2
vmlal.s16 q9, d7, d2 vmlal.s16 q15, d19, d2
vld1.16 {d4, d5}, [r2, :128]! vld1.16 {d16, d17}, [r2, :128]!
vmlal.s16 q6, d4, d3 vmlal.s16 q12, d16, d3
vld1.16 {d6, d7}, [r2, :128]! vld1.16 {d18, d19}, [r2, :128]!
vmlal.s16 q7, d5, d3 vmlal.s16 q13, d17, d3
vmlal.s16 q8, d6, d3 vmlal.s16 q14, d18, d3
vmlal.s16 q9, d7, d3 vmlal.s16 q15, d19, d3
vpadd.s32 d0, d12, d13 /* TODO: can be eliminated */ vpadd.s32 d0, d24, d25 /* TODO: can be eliminated */
vpadd.s32 d1, d14, d15 /* TODO: can be eliminated */ vpadd.s32 d1, d26, d27 /* TODO: can be eliminated */
vpadd.s32 d2, d16, d17 /* TODO: can be eliminated */ vpadd.s32 d2, d28, d29 /* TODO: can be eliminated */
vpadd.s32 d3, d18, d19 /* TODO: can be eliminated */ vpadd.s32 d3, d30, d31 /* TODO: can be eliminated */
vst1.32 {d0, d1, d2, d3}, [r1, :128] vst1.32 {d0, d1, d2, d3}, [r1, :128]

View file

@ -47,6 +47,17 @@
#include "atrac.h" #include "atrac.h"
#include "atrac3plus.h" #include "atrac3plus.h"
static const uint8_t channel_map[8][8] = {
{ 0, },
{ 0, 1, },
{ 0, 1, 2, },
{ 0, 1, 2, 3, },
{ 0, },
{ 0, 1, 2, 4, 5, 3, },
{ 0, 1, 2, 4, 5, 6, 3, },
{ 0, 1, 2, 4, 5, 6, 7, 3, },
};
typedef struct ATRAC3PContext { typedef struct ATRAC3PContext {
GetBitContext gb; GetBitContext gb;
AVFloatDSPContext *fdsp; AVFloatDSPContext *fdsp;
@ -65,6 +76,7 @@ typedef struct ATRAC3PContext {
int num_channel_blocks; ///< number of channel blocks int num_channel_blocks; ///< number of channel blocks
uint8_t channel_blocks[5]; ///< channel configuration descriptor uint8_t channel_blocks[5]; ///< channel configuration descriptor
uint64_t my_channel_layout; ///< current channel layout uint64_t my_channel_layout; ///< current channel layout
const uint8_t *channel_map; ///< channel layout map
} ATRAC3PContext; } ATRAC3PContext;
static av_cold int atrac3p_decode_close(AVCodecContext *avctx) static av_cold int atrac3p_decode_close(AVCodecContext *avctx)
@ -143,6 +155,8 @@ static av_cold int set_channel_params(ATRAC3PContext *ctx,
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
ctx->channel_map = channel_map[avctx->channels - 1];
return 0; return 0;
} }
@ -381,7 +395,7 @@ static int atrac3p_decode_frame(AVCodecContext *avctx, void *data,
channels_to_process, avctx); channels_to_process, avctx);
for (i = 0; i < channels_to_process; i++) for (i = 0; i < channels_to_process; i++)
memcpy(samples_p[out_ch_index + i], ctx->outp_buf[i], memcpy(samples_p[ctx->channel_map[out_ch_index + i]], ctx->outp_buf[i],
ATRAC3P_FRAME_SAMPLES * sizeof(**samples_p)); ATRAC3P_FRAME_SAMPLES * sizeof(**samples_p));
ch_block++; ch_block++;

View file

@ -499,9 +499,8 @@ static int get_pixel_format(AVCodecContext *avctx)
if (pix_fmt == AV_PIX_FMT_NONE) if (pix_fmt == AV_PIX_FMT_NONE)
return -1; return -1;
s->pix_fmt = pix_fmt;
switch (s->pix_fmt) { switch (pix_fmt) {
case AV_PIX_FMT_YUV420P: case AV_PIX_FMT_YUV420P:
#if CONFIG_AV1_DXVA2_HWACCEL #if CONFIG_AV1_DXVA2_HWACCEL
*fmtp++ = AV_PIX_FMT_DXVA2_VLD; *fmtp++ = AV_PIX_FMT_DXVA2_VLD;
@ -544,7 +543,7 @@ static int get_pixel_format(AVCodecContext *avctx)
break; break;
} }
*fmtp++ = s->pix_fmt; *fmtp++ = pix_fmt;
*fmtp = AV_PIX_FMT_NONE; *fmtp = AV_PIX_FMT_NONE;
ret = ff_thread_get_format(avctx, pix_fmts); ret = ff_thread_get_format(avctx, pix_fmts);
@ -562,6 +561,7 @@ static int get_pixel_format(AVCodecContext *avctx)
return AVERROR(ENOSYS); return AVERROR(ENOSYS);
} }
s->pix_fmt = pix_fmt;
avctx->pix_fmt = ret; avctx->pix_fmt = ret;
return 0; return 0;
@ -661,7 +661,7 @@ static int set_context_with_sequence(AVCodecContext *avctx,
avctx->color_range = avctx->color_range =
seq->color_config.color_range ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG; seq->color_config.color_range ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG;
avctx->color_primaries = seq->color_config.color_primaries; 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; avctx->color_trc = seq->color_config.transfer_characteristics;
switch (seq->color_config.chroma_sample_position) { switch (seq->color_config.chroma_sample_position) {
@ -1240,6 +1240,7 @@ const AVCodec ff_av1_decoder = {
.flush = av1_decode_flush, .flush = av1_decode_flush,
.profiles = NULL_IF_CONFIG_SMALL(ff_av1_profiles), .profiles = NULL_IF_CONFIG_SMALL(ff_av1_profiles),
.priv_class = &av1_class, .priv_class = &av1_class,
.bsfs = "av1_frame_split",
.hw_configs = (const AVCodecHWConfigInternal *const []) { .hw_configs = (const AVCodecHWConfigInternal *const []) {
#if CONFIG_AV1_DXVA2_HWACCEL #if CONFIG_AV1_DXVA2_HWACCEL
HWACCEL_DXVA2(av1), HWACCEL_DXVA2(av1),

View file

@ -870,7 +870,7 @@ static int binkb_decode_plane(BinkContext *c, AVFrame *frame, GetBitContext *gb,
binkb_init_bundles(c); binkb_init_bundles(c);
ref_start = frame->data[plane_idx]; 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++) for (i = 0; i < 64; i++)
coordmap[i] = (i & 7) + (i >> 3) * stride; 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); xoff = binkb_get_value(c, BINKB_SRC_X_OFF);
yoff = binkb_get_value(c, BINKB_SRC_Y_OFF) + ybias; yoff = binkb_get_value(c, BINKB_SRC_Y_OFF) + ybias;
ref = dst + xoff + yoff * stride; 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"); av_log(c->avctx, AV_LOG_WARNING, "Reference block is out of bounds\n");
} else if (ref + 8*stride < dst || ref >= dst + 8*stride) { } else if (ref + 8*stride < dst || ref >= dst + 8*stride) {
c->put_pixels_tab(dst, ref, stride, 8); 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); xoff = binkb_get_value(c, BINKB_SRC_X_OFF);
yoff = binkb_get_value(c, BINKB_SRC_Y_OFF) + ybias; yoff = binkb_get_value(c, BINKB_SRC_Y_OFF) + ybias;
ref = dst + xoff + yoff * stride; 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"); av_log(c->avctx, AV_LOG_WARNING, "Reference block is out of bounds\n");
} else if (ref + 8*stride < dst || ref >= dst + 8*stride) { } else if (ref + 8*stride < dst || ref >= dst + 8*stride) {
c->put_pixels_tab(dst, ref, stride, 8); 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); xoff = binkb_get_value(c, BINKB_SRC_X_OFF);
yoff = binkb_get_value(c, BINKB_SRC_Y_OFF) + ybias; yoff = binkb_get_value(c, BINKB_SRC_Y_OFF) + ybias;
ref = dst + xoff + yoff * stride; 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"); av_log(c->avctx, AV_LOG_WARNING, "Reference block is out of bounds\n");
} else if (ref + 8*stride < dst || ref >= dst + 8*stride) { } else if (ref + 8*stride < dst || ref >= dst + 8*stride) {
c->put_pixels_tab(dst, ref, stride, 8); c->put_pixels_tab(dst, ref, stride, 8);
@ -1087,7 +1087,7 @@ static int bink_decode_plane(BinkContext *c, AVFrame *frame, GetBitContext *gb,
for (bx = 0; bx < bw; bx++, dst += 8, prev += 8) { for (bx = 0; bx < bw; bx++, dst += 8, prev += 8) {
blk = get_value(c, BINK_SRC_BLOCK_TYPES); blk = get_value(c, BINK_SRC_BLOCK_TYPES);
// 16x16 block type on odd line means part of the already decoded block, so skip it // 16x16 block type on odd line means part of the already decoded block, so skip it
if ((by & 1) && blk == SCALED_BLOCK) { if (((by & 1) || (bx & 1)) && blk == SCALED_BLOCK) {
bx++; bx++;
dst += 8; dst += 8;
prev += 8; prev += 8;

View file

@ -239,7 +239,7 @@ static void cdg_scroll(CDGraphicsContext *cc, uint8_t *data,
for (y = FFMAX(0, vinc); y < FFMIN(CDG_FULL_HEIGHT + vinc, CDG_FULL_HEIGHT); y++) for (y = FFMAX(0, vinc); y < FFMIN(CDG_FULL_HEIGHT + vinc, CDG_FULL_HEIGHT); y++)
memcpy(out + FFMAX(0, hinc) + stride * y, memcpy(out + FFMAX(0, hinc) + stride * y,
in + FFMAX(0, hinc) - hinc + (y - vinc) * stride, in + FFMAX(0, hinc) - hinc + (y - vinc) * stride,
FFMIN(stride + hinc, stride)); FFABS(stride) - FFABS(hinc));
if (vinc > 0) if (vinc > 0)
cdg_fill_wrapper(0, 0, out, cdg_fill_wrapper(0, 0, out,

View file

@ -838,7 +838,7 @@ static int cfhd_decode(AVCodecContext *avctx, void *data, int *got_frame,
const uint16_t q = s->quantisation; const uint16_t q = s->quantisation;
for (i = 0; i < run; i++) { for (i = 0; i < run; i++) {
*coeff_data |= coeff * 256; *coeff_data |= coeff * 256U;
*coeff_data++ *= q; *coeff_data++ *= q;
} }
} else { } else {
@ -869,7 +869,7 @@ static int cfhd_decode(AVCodecContext *avctx, void *data, int *got_frame,
const uint16_t q = s->quantisation; const uint16_t q = s->quantisation;
for (i = 0; i < run; i++) { for (i = 0; i < run; i++) {
*coeff_data |= coeff * 256; *coeff_data |= coeff * 256U;
*coeff_data++ *= q; *coeff_data++ *= q;
} }
} else { } else {

View file

@ -653,21 +653,23 @@ error:
static av_cold int cuvid_decode_end(AVCodecContext *avctx) static av_cold int cuvid_decode_end(AVCodecContext *avctx)
{ {
CuvidContext *ctx = avctx->priv_data; CuvidContext *ctx = avctx->priv_data;
AVHWDeviceContext *device_ctx = (AVHWDeviceContext *)ctx->hwdevice->data; AVHWDeviceContext *device_ctx = ctx->hwdevice ? (AVHWDeviceContext *)ctx->hwdevice->data : NULL;
AVCUDADeviceContext *device_hwctx = device_ctx->hwctx; AVCUDADeviceContext *device_hwctx = device_ctx ? device_ctx->hwctx : NULL;
CUcontext dummy, cuda_ctx = device_hwctx->cuda_ctx; CUcontext dummy, cuda_ctx = device_hwctx ? device_hwctx->cuda_ctx : NULL;
av_fifo_freep(&ctx->frame_queue); av_fifo_freep(&ctx->frame_queue);
ctx->cudl->cuCtxPushCurrent(cuda_ctx); if (cuda_ctx) {
ctx->cudl->cuCtxPushCurrent(cuda_ctx);
if (ctx->cuparser) if (ctx->cuparser)
ctx->cvdl->cuvidDestroyVideoParser(ctx->cuparser); ctx->cvdl->cuvidDestroyVideoParser(ctx->cuparser);
if (ctx->cudecoder) if (ctx->cudecoder)
ctx->cvdl->cuvidDestroyDecoder(ctx->cudecoder); ctx->cvdl->cuvidDestroyDecoder(ctx->cudecoder);
ctx->cudl->cuCtxPopCurrent(&dummy); ctx->cudl->cuCtxPopCurrent(&dummy);
}
ctx->cudl = NULL; ctx->cudl = NULL;
@ -951,6 +953,16 @@ static av_cold int cuvid_decode_init(AVCodecContext *avctx)
extradata_size = avctx->extradata_size; extradata_size = avctx->extradata_size;
} }
// Check first bit to determine whether it's AV1CodecConfigurationRecord.
// Skip first 4 bytes of AV1CodecConfigurationRecord to keep configOBUs
// only, otherwise cuvidParseVideoData report unknown error.
if (avctx->codec->id == AV_CODEC_ID_AV1 &&
extradata_size > 4 &&
extradata[0] & 0x80) {
extradata += 4;
extradata_size -= 4;
}
ctx->cuparse_ext = av_mallocz(sizeof(*ctx->cuparse_ext) ctx->cuparse_ext = av_mallocz(sizeof(*ctx->cuparse_ext)
+ FFMAX(extradata_size - (int)sizeof(ctx->cuparse_ext->raw_seqhdr_data), 0)); + FFMAX(extradata_size - (int)sizeof(ctx->cuparse_ext->raw_seqhdr_data), 0));
if (!ctx->cuparse_ext) { if (!ctx->cuparse_ext) {

View file

@ -1432,8 +1432,8 @@ static void global_mv(DiracContext *s, DiracBlock *block, int x, int y, int ref)
int *c = s->globalmc[ref].perspective; int *c = s->globalmc[ref].perspective;
int64_t m = (1<<ep) - (c[0]*(int64_t)x + c[1]*(int64_t)y); int64_t m = (1<<ep) - (c[0]*(int64_t)x + c[1]*(int64_t)y);
int64_t mx = m * (int64_t)((A[0][0] * (int64_t)x + A[0][1]*(int64_t)y) + (1LL<<ez) * b[0]); int64_t mx = m * (uint64_t)((A[0][0] * (int64_t)x + A[0][1]*(int64_t)y) + (1LL<<ez) * b[0]);
int64_t my = m * (int64_t)((A[1][0] * (int64_t)x + A[1][1]*(int64_t)y) + (1LL<<ez) * b[1]); int64_t my = m * (uint64_t)((A[1][0] * (int64_t)x + A[1][1]*(int64_t)y) + (1LL<<ez) * b[1]);
block->u.mv[ref][0] = (mx + (1<<(ez+ep))) >> (ez+ep); block->u.mv[ref][0] = (mx + (1<<(ez+ep))) >> (ez+ep);
block->u.mv[ref][1] = (my + (1<<(ez+ep))) >> (ez+ep); block->u.mv[ref][1] = (my + (1<<(ez+ep))) >> (ez+ep);

View file

@ -214,7 +214,7 @@ static uint8_t prob_dst_x_bit(int c)
return (ff_reverse[c & 127] >> 1) + 1; return (ff_reverse[c & 127] >> 1) + 1;
} }
static void build_filter(int16_t table[DST_MAX_ELEMENTS][16][256], const Table *fsets) static int build_filter(int16_t table[DST_MAX_ELEMENTS][16][256], const Table *fsets)
{ {
int i, j, k, l; int i, j, k, l;
@ -225,14 +225,17 @@ static void build_filter(int16_t table[DST_MAX_ELEMENTS][16][256], const Table *
int total = av_clip(length - j * 8, 0, 8); int total = av_clip(length - j * 8, 0, 8);
for (k = 0; k < 256; k++) { for (k = 0; k < 256; k++) {
int v = 0; int64_t v = 0;
for (l = 0; l < total; l++) for (l = 0; l < total; l++)
v += (((k >> l) & 1) * 2 - 1) * fsets->coeff[i][j * 8 + l]; v += (((k >> l) & 1) * 2 - 1) * fsets->coeff[i][j * 8 + l];
if ((int16_t)v != v)
return AVERROR_INVALIDDATA;
table[i][j][k] = v; table[i][j][k] = v;
} }
} }
} }
return 0;
} }
static int decode_frame(AVCodecContext *avctx, void *data, static int decode_frame(AVCodecContext *avctx, void *data,
@ -328,7 +331,9 @@ static int decode_frame(AVCodecContext *avctx, void *data,
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
ac_init(ac, gb); ac_init(ac, gb);
build_filter(s->filter, &s->fsets); ret = build_filter(s->filter, &s->fsets);
if (ret < 0)
return ret;
memset(s->status, 0xAA, sizeof(s->status)); memset(s->status, 0xAA, sizeof(s->status));
memset(dsd, 0, frame->nb_samples * 4 * channels); memset(dsd, 0, frame->nb_samples * 4 * channels);

View file

@ -139,9 +139,11 @@ static void ff_eac3_apply_spectral_extension(AC3DecodeContext *s)
// spx_noise_blend and spx_signal_blend are both FP.23 // spx_noise_blend and spx_signal_blend are both FP.23
nscale *= 1.0 / (1<<23); nscale *= 1.0 / (1<<23);
sscale *= 1.0 / (1<<23); sscale *= 1.0 / (1<<23);
if (nscale < -1.0)
nscale = -1.0;
#endif #endif
for (i = 0; i < s->spx_band_sizes[bnd]; i++) { for (i = 0; i < s->spx_band_sizes[bnd]; i++) {
float noise = nscale * (int32_t)av_lfg_get(&s->dith_state); UINTFLOAT noise = (INTFLOAT)(nscale * (int32_t)av_lfg_get(&s->dith_state));
s->transform_coeffs[ch][bin] *= sscale; s->transform_coeffs[ch][bin] *= sscale;
s->transform_coeffs[ch][bin++] += noise; s->transform_coeffs[ch][bin++] += noise;
} }

View file

@ -61,7 +61,7 @@ static av_cold int tgq_decode_init(AVCodecContext *avctx)
return 0; return 0;
} }
static void tgq_decode_block(TgqContext *s, int16_t block[64], GetBitContext *gb) static int tgq_decode_block(TgqContext *s, int16_t block[64], GetBitContext *gb)
{ {
uint8_t *perm = s->scantable.permutated; uint8_t *perm = s->scantable.permutated;
int i, j, value; int i, j, value;
@ -69,6 +69,8 @@ static void tgq_decode_block(TgqContext *s, int16_t block[64], GetBitContext *gb
for (i = 1; i < 64;) { for (i = 1; i < 64;) {
switch (show_bits(gb, 3)) { switch (show_bits(gb, 3)) {
case 4: case 4:
if (i >= 63)
return AVERROR_INVALIDDATA;
block[perm[i++]] = 0; block[perm[i++]] = 0;
case 0: case 0:
block[perm[i++]] = 0; block[perm[i++]] = 0;
@ -78,6 +80,8 @@ static void tgq_decode_block(TgqContext *s, int16_t block[64], GetBitContext *gb
case 1: case 1:
skip_bits(gb, 2); skip_bits(gb, 2);
value = get_bits(gb, 6); value = get_bits(gb, 6);
if (value > 64 - i)
return AVERROR_INVALIDDATA;
for (j = 0; j < value; j++) for (j = 0; j < value; j++)
block[perm[i++]] = 0; block[perm[i++]] = 0;
break; break;
@ -105,6 +109,7 @@ static void tgq_decode_block(TgqContext *s, int16_t block[64], GetBitContext *gb
} }
} }
block[0] += 128 << 4; block[0] += 128 << 4;
return 0;
} }
static void tgq_idct_put_mb(TgqContext *s, int16_t (*block)[64], AVFrame *frame, static void tgq_idct_put_mb(TgqContext *s, int16_t (*block)[64], AVFrame *frame,
@ -164,8 +169,11 @@ static int tgq_decode_mb(TgqContext *s, AVFrame *frame, int mb_y, int mb_x)
if (ret < 0) if (ret < 0)
return ret; return ret;
for (i = 0; i < 6; i++) for (i = 0; i < 6; i++) {
tgq_decode_block(s, s->block[i], &gb); int ret = tgq_decode_block(s, s->block[i], &gb);
if (ret < 0)
return ret;
}
tgq_idct_put_mb(s, s->block, frame, mb_x, mb_y); tgq_idct_put_mb(s, s->block, frame, mb_x, mb_y);
bytestream2_skip(&s->gb, mode); bytestream2_skip(&s->gb, mode);
} else { } else {

View file

@ -88,11 +88,6 @@ static CodeBook unpack_codebook(GetBitContext* gb, unsigned depth,
unsigned i, j; unsigned i, j;
CodeBook cb = { 0 }; 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); cb.blocks = av_malloc(size ? size * sizeof(MacroBlock) : 1);
if (!cb.blocks) if (!cb.blocks)
return cb; return cb;
@ -226,7 +221,7 @@ static int escape124_decode_frame(AVCodecContext *avctx,
// represent a lower bound of the space needed for skipped superblocks. Non // represent a lower bound of the space needed for skipped superblocks. Non
// skipped SBs need more space. // skipped SBs need more space.
if (get_bits_left(&gb) < 64 + s->num_superblocks * 23LL / 4320) if (get_bits_left(&gb) < 64 + s->num_superblocks * 23LL / 4320)
return -1; return AVERROR_INVALIDDATA;
frame_flags = get_bits_long(&gb, 32); frame_flags = get_bits_long(&gb, 32);
frame_size = get_bits_long(&gb, 32); frame_size = get_bits_long(&gb, 32);
@ -277,9 +272,14 @@ static int escape124_decode_frame(AVCodecContext *avctx,
} }
av_freep(&s->codebooks[i].blocks); 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); s->codebooks[i] = unpack_codebook(&gb, cb_depth, cb_size);
if (!s->codebooks[i].blocks) if (!s->codebooks[i].blocks)
return -1; return AVERROR(ENOMEM);
} }
} }

View file

@ -1240,7 +1240,8 @@ static int decode_block(AVCodecContext *avctx, void *tdata,
td->ysize = FFMIN(s->tile_attr.ySize, s->ydelta - tile_y * s->tile_attr.ySize); td->ysize = FFMIN(s->tile_attr.ySize, s->ydelta - tile_y * s->tile_attr.ySize);
td->xsize = FFMIN(s->tile_attr.xSize, s->xdelta - tile_x * s->tile_attr.xSize); td->xsize = FFMIN(s->tile_attr.xSize, s->xdelta - tile_x * s->tile_attr.xSize);
if (td->xsize * (uint64_t)s->current_channel_offset > INT_MAX) if (td->xsize * (uint64_t)s->current_channel_offset > INT_MAX ||
av_image_check_size2(td->xsize, td->ysize, s->avctx->max_pixels, AV_PIX_FMT_NONE, 0, s->avctx) < 0)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
td->channel_line_size = td->xsize * s->current_channel_offset;/* uncompress size of one line */ td->channel_line_size = td->xsize * s->current_channel_offset;/* uncompress size of one line */
@ -1264,7 +1265,8 @@ static int decode_block(AVCodecContext *avctx, void *tdata,
td->ysize = FFMIN(s->scan_lines_per_block, s->ymax - line + 1); /* s->ydelta - line ?? */ td->ysize = FFMIN(s->scan_lines_per_block, s->ymax - line + 1); /* s->ydelta - line ?? */
td->xsize = s->xdelta; td->xsize = s->xdelta;
if (td->xsize * (uint64_t)s->current_channel_offset > INT_MAX) if (td->xsize * (uint64_t)s->current_channel_offset > INT_MAX ||
av_image_check_size2(td->xsize, td->ysize, s->avctx->max_pixels, AV_PIX_FMT_NONE, 0, s->avctx) < 0)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
td->channel_line_size = td->xsize * s->current_channel_offset;/* uncompress size of one line */ td->channel_line_size = td->xsize * s->current_channel_offset;/* uncompress size of one line */
@ -1832,8 +1834,8 @@ static int decode_header(EXRContext *s, AVFrame *frame)
dx = bytestream2_get_le32(gb); dx = bytestream2_get_le32(gb);
dy = bytestream2_get_le32(gb); dy = bytestream2_get_le32(gb);
s->w = dx - sx + 1; s->w = (unsigned)dx - sx + 1;
s->h = dy - sy + 1; s->h = (unsigned)dy - sy + 1;
continue; continue;
} else if ((var_size = check_header_variable(s, "lineOrder", } else if ((var_size = check_header_variable(s, "lineOrder",
@ -1948,9 +1950,12 @@ static int decode_header(EXRContext *s, AVFrame *frame)
"preview", 16)) >= 0) { "preview", 16)) >= 0) {
uint32_t pw = bytestream2_get_le32(gb); uint32_t pw = bytestream2_get_le32(gb);
uint32_t ph = bytestream2_get_le32(gb); uint32_t ph = bytestream2_get_le32(gb);
int64_t psize = 4LL * pw * ph; uint64_t psize = pw * ph;
if (psize > INT64_MAX / 4)
return AVERROR_INVALIDDATA;
psize *= 4;
if (psize >= bytestream2_get_bytes_left(gb)) if ((int64_t)psize >= bytestream2_get_bytes_left(gb))
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
bytestream2_skip(gb, psize); bytestream2_skip(gb, psize);

View file

@ -166,24 +166,34 @@ static int decode_slice_header(const FFV1Context *f, FFV1Context *fs)
RangeCoder *c = &fs->c; RangeCoder *c = &fs->c;
uint8_t state[CONTEXT_SIZE]; uint8_t state[CONTEXT_SIZE];
unsigned ps, i, context_count; unsigned ps, i, context_count;
int sx, sy, sw, sh;
memset(state, 128, sizeof(state)); memset(state, 128, sizeof(state));
sx = get_symbol(c, state, 0);
sy = get_symbol(c, state, 0);
sw = get_symbol(c, state, 0) + 1U;
sh = get_symbol(c, state, 0) + 1U;
av_assert0(f->version > 2); av_assert0(f->version > 2);
fs->slice_x = get_symbol(c, state, 0) * f->width ;
fs->slice_y = get_symbol(c, state, 0) * f->height;
fs->slice_width = (get_symbol(c, state, 0) + 1) * f->width + fs->slice_x;
fs->slice_height = (get_symbol(c, state, 0) + 1) * f->height + fs->slice_y;
fs->slice_x /= f->num_h_slices; if (sx < 0 || sy < 0 || sw <= 0 || sh <= 0)
fs->slice_y /= f->num_v_slices; return AVERROR_INVALIDDATA;
fs->slice_width = fs->slice_width /f->num_h_slices - fs->slice_x; if (sx > f->num_h_slices - sw || sy > f->num_v_slices - sh)
fs->slice_height = fs->slice_height/f->num_v_slices - fs->slice_y; return AVERROR_INVALIDDATA;
if ((unsigned)fs->slice_width > f->width || (unsigned)fs->slice_height > f->height)
return -1; fs->slice_x = sx * (int64_t)f->width / f->num_h_slices;
if ( (unsigned)fs->slice_x + (uint64_t)fs->slice_width > f->width fs->slice_y = sy * (int64_t)f->height / f->num_v_slices;
|| (unsigned)fs->slice_y + (uint64_t)fs->slice_height > f->height) fs->slice_width = (sx + sw) * (int64_t)f->width / f->num_h_slices - fs->slice_x;
return -1; fs->slice_height = (sy + sh) * (int64_t)f->height / f->num_v_slices - fs->slice_y;
av_assert0((unsigned)fs->slice_width <= f->width &&
(unsigned)fs->slice_height <= f->height);
av_assert0 ( (unsigned)fs->slice_x + (uint64_t)fs->slice_width <= f->width
&& (unsigned)fs->slice_y + (uint64_t)fs->slice_height <= f->height);
if (fs->ac == AC_GOLOMB_RICE && fs->slice_width >= (1<<23))
return AVERROR_INVALIDDATA;
for (i = 0; i < f->plane_count; i++) { for (i = 0; i < f->plane_count; i++) {
PlaneContext * const p = &fs->plane[i]; PlaneContext * const p = &fs->plane[i];
@ -298,8 +308,11 @@ static int decode_slice(AVCodecContext *c, void *arg)
} }
if ((ret = ff_ffv1_init_slice_state(f, fs)) < 0) if ((ret = ff_ffv1_init_slice_state(f, fs)) < 0)
return ret; return ret;
if (f->cur->key_frame || fs->slice_reset_contexts) if (f->cur->key_frame || fs->slice_reset_contexts) {
ff_ffv1_clear_slice_state(f, fs); ff_ffv1_clear_slice_state(f, fs);
} else if (fs->slice_damaged) {
return AVERROR_INVALIDDATA;
}
width = fs->slice_width; width = fs->slice_width;
height = fs->slice_height; height = fs->slice_height;
@ -462,6 +475,11 @@ static int read_extra_header(FFV1Context *f)
return AVERROR_INVALIDDATA; 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); f->quant_table_count = get_symbol(c, state, 0);
if (f->quant_table_count > (unsigned)MAX_QUANT_TABLES || !f->quant_table_count) { 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); av_log(f->avctx, AV_LOG_ERROR, "quant table count %d is invalid\n", f->quant_table_count);
@ -764,21 +782,25 @@ static int read_header(FFV1Context *f)
fs->slice_damaged = 0; fs->slice_damaged = 0;
if (f->version == 2) { if (f->version == 2) {
fs->slice_x = get_symbol(c, state, 0) * f->width ; int sx = get_symbol(c, state, 0);
fs->slice_y = get_symbol(c, state, 0) * f->height; int sy = get_symbol(c, state, 0);
fs->slice_width = (get_symbol(c, state, 0) + 1) * f->width + fs->slice_x; int sw = get_symbol(c, state, 0) + 1U;
fs->slice_height = (get_symbol(c, state, 0) + 1) * f->height + fs->slice_y; int sh = get_symbol(c, state, 0) + 1U;
fs->slice_x /= f->num_h_slices; if (sx < 0 || sy < 0 || sw <= 0 || sh <= 0)
fs->slice_y /= f->num_v_slices;
fs->slice_width = fs->slice_width / f->num_h_slices - fs->slice_x;
fs->slice_height = fs->slice_height / f->num_v_slices - fs->slice_y;
if ((unsigned)fs->slice_width > f->width ||
(unsigned)fs->slice_height > f->height)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
if ( (unsigned)fs->slice_x + (uint64_t)fs->slice_width > f->width if (sx > f->num_h_slices - sw || sy > f->num_v_slices - sh)
|| (unsigned)fs->slice_y + (uint64_t)fs->slice_height > f->height)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
fs->slice_x = sx * (int64_t)f->width / f->num_h_slices;
fs->slice_y = sy * (int64_t)f->height / f->num_v_slices;
fs->slice_width = (sx + sw) * (int64_t)f->width / f->num_h_slices - fs->slice_x;
fs->slice_height = (sy + sh) * (int64_t)f->height / f->num_v_slices - fs->slice_y;
av_assert0((unsigned)fs->slice_width <= f->width &&
(unsigned)fs->slice_height <= f->height);
av_assert0 ( (unsigned)fs->slice_x + (uint64_t)fs->slice_width <= f->width
&& (unsigned)fs->slice_y + (uint64_t)fs->slice_height <= f->height);
} }
for (i = 0; i < f->plane_count; i++) { for (i = 0; i < f->plane_count; i++) {

View file

@ -93,11 +93,11 @@ static av_always_inline int RENAME(decode_line)(FFV1Context *s, int w,
run_count--; run_count--;
} }
} else { } else {
while (run_count > 1 && w-x > 1) { while (run_count > 1 && w-x > 1) {
sample[1][x] = RENAME(predict)(sample[1] + x, sample[0] + x); sample[1][x] = RENAME(predict)(sample[1] + x, sample[0] + x);
x++; x++;
run_count--; run_count--;
} }
} }
run_count--; run_count--;
if (run_count < 0) { if (run_count < 0) {

View file

@ -401,20 +401,17 @@ static int decode_frame(AVCodecContext *avctx, void *data,
PutByteContext *pb = &s->pb; PutByteContext *pb = &s->pb;
AVFrame *frame = data; AVFrame *frame = data;
int ret, y, x; int ret, y, x;
int key_frame;
if (avpkt->size < 8) if (avpkt->size < 8)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
return ret;
bytestream2_init(gb, avpkt->data, avpkt->size); bytestream2_init(gb, avpkt->data, avpkt->size);
bytestream2_skip(gb, 2); bytestream2_skip(gb, 2);
frame->key_frame = !!bytestream2_get_le16(gb); key_frame = !!bytestream2_get_le16(gb);
frame->pict_type = frame->key_frame ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
if (frame->key_frame) { if (key_frame) {
const uint8_t *src; const uint8_t *src;
unsigned type, size; unsigned type, size;
uint8_t *dst; uint8_t *dst;
@ -434,6 +431,12 @@ static int decode_frame(AVCodecContext *avctx, void *data,
return AVERROR_PATCHWELCOME; return AVERROR_PATCHWELCOME;
} }
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
return ret;
frame->key_frame = 1;
frame->pict_type = AV_PICTURE_TYPE_I;
src = s->buffer; src = s->buffer;
dst = frame->data[0] + (avctx->height - 1) * frame->linesize[0]; dst = frame->data[0] + (avctx->height - 1) * frame->linesize[0];
for (y = 0; y < avctx->height; y++) { for (y = 0; y < avctx->height; y++) {
@ -514,6 +517,12 @@ static int decode_frame(AVCodecContext *avctx, void *data,
dst = &rect[block_h * s->stride]; dst = &rect[block_h * s->stride];
} }
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
return ret;
frame->key_frame = 0;
frame->pict_type = AV_PICTURE_TYPE_P;
ssrc = s->buffer; ssrc = s->buffer;
ddst = frame->data[0] + (avctx->height - 1) * frame->linesize[0]; ddst = frame->data[0] + (avctx->height - 1) * frame->linesize[0];
for (y = 0; y < avctx->height; y++) { for (y = 0; y < avctx->height; y++) {

View file

@ -48,6 +48,9 @@ static int g729_parse(AVCodecParserContext *s1, AVCodecContext *avctx,
s->block_size = (avctx->bit_rate < 8000) ? G729D_6K4_BLOCK_SIZE : G729_8K_BLOCK_SIZE; s->block_size = (avctx->bit_rate < 8000) ? G729D_6K4_BLOCK_SIZE : G729_8K_BLOCK_SIZE;
if (avctx->codec_id == AV_CODEC_ID_ACELP_KELVIN) if (avctx->codec_id == AV_CODEC_ID_ACELP_KELVIN)
s->block_size++; s->block_size++;
// channels > 2 is invalid, we pass the packet on unchanged
if (avctx->channels > 2)
s->block_size = 0;
s->block_size *= avctx->channels; s->block_size *= avctx->channels;
s->duration = avctx->frame_size; s->duration = avctx->frame_size;
} }

View file

@ -551,6 +551,8 @@ retry:
avctx->has_b_frames = !s->low_delay; avctx->has_b_frames = !s->low_delay;
if (CONFIG_MPEG4_DECODER && avctx->codec_id == AV_CODEC_ID_MPEG4) { if (CONFIG_MPEG4_DECODER && avctx->codec_id == AV_CODEC_ID_MPEG4) {
if (s->pict_type != AV_PICTURE_TYPE_B && s->mb_num/2 > get_bits_left(&s->gb))
return AVERROR_INVALIDDATA;
if (ff_mpeg4_workaround_bugs(avctx) == 1) if (ff_mpeg4_workaround_bugs(avctx) == 1)
goto retry; goto retry;
if (s->studio_profile != (s->idsp.idct == NULL)) if (s->studio_profile != (s->idsp.idct == NULL))

View file

@ -247,7 +247,6 @@ static inline int parse_nal_units(AVCodecParserContext *s,
const uint8_t * const buf, int buf_size) const uint8_t * const buf, int buf_size)
{ {
H264ParseContext *p = s->priv_data; H264ParseContext *p = s->priv_data;
H264Context *h = avctx->priv_data;
H2645RBSP rbsp = { NULL }; H2645RBSP rbsp = { NULL };
H2645NAL nal = { NULL }; H2645NAL nal = { NULL };
int buf_index, next_avc; int buf_index, next_avc;
@ -553,11 +552,9 @@ static inline int parse_nal_units(AVCodecParserContext *s,
p->last_picture_structure = s->picture_structure; p->last_picture_structure = s->picture_structure;
p->last_frame_num = p->poc.frame_num; p->last_frame_num = p->poc.frame_num;
} }
if (h && sps->timing_info_present_flag) { if (sps->timing_info_present_flag) {
int64_t den = sps->time_scale; int64_t den = sps->time_scale;
if (p->sei.unregistered.x264_build >= 0) if (p->sei.unregistered.x264_build < 44U)
h->x264_build = p->sei.unregistered.x264_build;
if (h->x264_build < 44U)
den *= 2; den *= 2;
av_reduce(&avctx->framerate.den, &avctx->framerate.num, av_reduce(&avctx->framerate.den, &avctx->framerate.num,
sps->num_units_in_tick * avctx->ticks_per_frame, den, 1 << 30); sps->num_units_in_tick * avctx->ticks_per_frame, den, 1 << 30);

View file

@ -680,6 +680,10 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size)
avpriv_request_sample(avctx, "data partitioning"); avpriv_request_sample(avctx, "data partitioning");
break; break;
case H264_NAL_SEI: case H264_NAL_SEI:
if (h->setup_finished) {
avpriv_request_sample(avctx, "Late SEI");
break;
}
ret = ff_h264_sei_decode(&h->sei, &nal->gb, &h->ps, avctx); ret = ff_h264_sei_decode(&h->sei, &nal->gb, &h->ps, avctx);
h->has_recovery_point = h->has_recovery_point || h->sei.recovery_point.recovery_frame_cnt != -1; h->has_recovery_point = h->has_recovery_point || h->sei.recovery_point.recovery_frame_cnt != -1;
if (avctx->debug & FF_DEBUG_GREEN_MD) if (avctx->debug & FF_DEBUG_GREEN_MD)

View file

@ -28,7 +28,7 @@
#ifndef AVCODEC_H274_H #ifndef AVCODEC_H274_H
#define AVCODEC_H274_H #define AVCODEC_H274_H
#include <libavutil/film_grain_params.h> #include "libavutil/film_grain_params.h"
// Must be initialized to {0} prior to first usage // Must be initialized to {0} prior to first usage
typedef struct H274FilmGrainDatabase { typedef struct H274FilmGrainDatabase {

View file

@ -142,11 +142,22 @@ static void copy_CTB(uint8_t *dst, const uint8_t *src, int width, int height,
if (((intptr_t)dst | (intptr_t)src | stride_dst | stride_src) & 15) { if (((intptr_t)dst | (intptr_t)src | stride_dst | stride_src) & 15) {
for (i = 0; i < height; i++) { for (i = 0; i < height; i++) {
for (j = 0; j < width; j+=8) for (j = 0; j < width - 7; j+=8)
AV_COPY64U(dst+j, src+j); AV_COPY64U(dst+j, src+j);
dst += stride_dst; dst += stride_dst;
src += stride_src; src += stride_src;
} }
if (width&7) {
dst += ((width>>3)<<3) - stride_dst * height;
src += ((width>>3)<<3) - stride_src * height;
width &= 7;
for (i = 0; i < height; i++) {
for (j = 0; j < width; j++)
dst[j] = src[j];
dst += stride_dst;
src += stride_src;
}
}
} else { } else {
for (i = 0; i < height; i++) { for (i = 0; i < height; i++) {
for (j = 0; j < width; j+=16) for (j = 0; j < width; j+=16)

View file

@ -3499,7 +3499,7 @@ static int hevc_decode_frame(AVCodecContext *avctx, void *data, int *got_output,
} }
} else { } else {
/* verify the SEI checksum */ /* verify the SEI checksum */
if (avctx->err_recognition & AV_EF_CRCCHECK && s->is_decoded && if (avctx->err_recognition & AV_EF_CRCCHECK && s->ref && s->is_decoded &&
s->sei.picture_hash.is_md5) { s->sei.picture_hash.is_md5) {
ret = verify_md5(s, s->ref->frame); ret = verify_md5(s, s->ref->frame);
if (ret < 0 && avctx->err_recognition & AV_EF_EXPLODE) { if (ret < 0 && avctx->err_recognition & AV_EF_EXPLODE) {

View file

@ -313,7 +313,7 @@ static void FUNC(sao_band_filter)(uint8_t *_dst, uint8_t *_src,
offset_table[(k + sao_left_class) & 31] = sao_offset_val[k + 1]; offset_table[(k + sao_left_class) & 31] = sao_offset_val[k + 1];
for (y = 0; y < height; y++) { for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) for (x = 0; x < width; x++)
dst[x] = av_clip_pixel(src[x] + offset_table[src[x] >> shift]); dst[x] = av_clip_pixel(src[x] + offset_table[(src[x] >> shift) & 31]);
dst += stride_dst; dst += stride_dst;
src += stride_src; src += stride_src;
} }

View file

@ -67,7 +67,7 @@ int ff_jpegls_decode_lse(MJpegDecodeContext *s)
s->t3 = get_bits(&s->gb, 16); s->t3 = get_bits(&s->gb, 16);
s->reset = get_bits(&s->gb, 16); s->reset = get_bits(&s->gb, 16);
if(s->avctx->debug & FF_DEBUG_PICT_INFO) { if (s->avctx->debug & FF_DEBUG_PICT_INFO) {
av_log(s->avctx, AV_LOG_DEBUG, "Coding parameters maxval:%d T1:%d T2:%d T3:%d reset:%d\n", av_log(s->avctx, AV_LOG_DEBUG, "Coding parameters maxval:%d T1:%d T2:%d T3:%d reset:%d\n",
s->maxval, s->t1, s->t2, s->t3, s->reset); s->maxval, s->t1, s->t2, s->t3, s->reset);
} }
@ -96,7 +96,7 @@ int ff_jpegls_decode_lse(MJpegDecodeContext *s)
else else
maxtab = 65530/wt - 1; maxtab = 65530/wt - 1;
if(s->avctx->debug & FF_DEBUG_PICT_INFO) { if (s->avctx->debug & FF_DEBUG_PICT_INFO) {
av_log(s->avctx, AV_LOG_DEBUG, "LSE palette %d tid:%d wt:%d maxtab:%d\n", id, tid, wt, maxtab); av_log(s->avctx, AV_LOG_DEBUG, "LSE palette %d tid:%d wt:%d maxtab:%d\n", id, tid, wt, maxtab);
} }
if (maxtab >= 256) { if (maxtab >= 256) {
@ -191,7 +191,7 @@ static inline int ls_get_code_runterm(GetBitContext *gb, JLSState *state,
if (RItype) if (RItype)
temp += state->N[Q] >> 1; temp += state->N[Q] >> 1;
for (k = 0; (state->N[Q] << k) < temp; k++) for (k = 0; ((unsigned)state->N[Q] << k) < temp; k++)
; ;
#ifdef JLS_BROKEN #ifdef JLS_BROKEN
@ -200,6 +200,8 @@ static inline int ls_get_code_runterm(GetBitContext *gb, JLSState *state,
#endif #endif
ret = get_ur_golomb_jpegls(gb, k, state->limit - limit_add - 1, ret = get_ur_golomb_jpegls(gb, k, state->limit - limit_add - 1,
state->qbpp); state->qbpp);
if (ret < 0)
return -0x10000;
/* decode mapped error */ /* decode mapped error */
map = 0; map = 0;
@ -214,7 +216,7 @@ static inline int ls_get_code_runterm(GetBitContext *gb, JLSState *state,
ret = ret >> 1; ret = ret >> 1;
} }
if(FFABS(ret) > 0xFFFF) if (FFABS(ret) > 0xFFFF)
return -0x10000; return -0x10000;
/* update state */ /* update state */
state->A[Q] += FFABS(ret) - RItype; state->A[Q] += FFABS(ret) - RItype;
@ -483,19 +485,19 @@ int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near,
for (i = 0; i < s->height; i++) { for (i = 0; i < s->height; i++) {
switch(s->xfrm) { switch(s->xfrm) {
case 1: case 1:
for (x = off; x < w; x += 3) { for (x = off; x + 2 < w; x += 3) {
src[x ] += src[x+1] + 128; src[x ] += src[x+1] + 128;
src[x+2] += src[x+1] + 128; src[x+2] += src[x+1] + 128;
} }
break; break;
case 2: case 2:
for (x = off; x < w; x += 3) { for (x = off; x + 2 < w; x += 3) {
src[x ] += src[x+1] + 128; src[x ] += src[x+1] + 128;
src[x+2] += ((src[x ] + src[x+1])>>1) + 128; src[x+2] += ((src[x ] + src[x+1])>>1) + 128;
} }
break; break;
case 3: case 3:
for (x = off; x < w; x += 3) { for (x = off; x + 2 < w; x += 3) {
int g = src[x+0] - ((src[x+2]+src[x+1])>>2) + 64; int g = src[x+0] - ((src[x+2]+src[x+1])>>2) + 64;
src[x+0] = src[x+2] + g + 128; src[x+0] = src[x+2] + g + 128;
src[x+2] = src[x+1] + g + 128; src[x+2] = src[x+1] + g + 128;
@ -503,7 +505,7 @@ int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near,
} }
break; break;
case 4: case 4:
for (x = off; x < w; x += 3) { for (x = off; x + 2 < w; x += 3) {
int r = src[x+0] - (( 359 * (src[x+2]-128) + 490) >> 8); int r = src[x+0] - (( 359 * (src[x+2]-128) + 490) >> 8);
int g = src[x+0] - (( 88 * (src[x+1]-128) - 183 * (src[x+2]-128) + 30) >> 8); int g = src[x+0] - (( 88 * (src[x+1]-128) - 183 * (src[x+2]-128) + 30) >> 8);
int b = src[x+0] + ((454 * (src[x+1]-128) + 574) >> 8); int b = src[x+0] + ((454 * (src[x+1]-128) + 574) >> 8);

View file

@ -409,6 +409,9 @@ output_zeros:
if (zero_run) { if (zero_run) {
zero_run = 0; zero_run = 0;
i += esc_count; i += esc_count;
if (i > end - dst ||
i >= src_end - src)
return AVERROR_INVALIDDATA;
memcpy(dst, src, i); memcpy(dst, src, i);
dst += i; dst += i;
l->zeros_rem = lag_calc_zero_run(src[i]); l->zeros_rem = lag_calc_zero_run(src[i]);

View file

@ -230,12 +230,15 @@ static av_cold int libdav1d_init(AVCodecContext *c)
s.frame_size_limit = c->max_pixels; s.frame_size_limit = c->max_pixels;
if (dav1d->apply_grain >= 0) if (dav1d->apply_grain >= 0)
s.apply_grain = dav1d->apply_grain; s.apply_grain = dav1d->apply_grain;
else if (c->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN) else
s.apply_grain = 0; s.apply_grain = !(c->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN);
s.all_layers = dav1d->all_layers; s.all_layers = dav1d->all_layers;
if (dav1d->operating_point >= 0) if (dav1d->operating_point >= 0)
s.operating_point = dav1d->operating_point; s.operating_point = dav1d->operating_point;
#if FF_DAV1D_VERSION_AT_LEAST(6,2)
s.strict_std_compliance = c->strict_std_compliance > 0;
#endif
#if FF_DAV1D_VERSION_AT_LEAST(6,0) #if FF_DAV1D_VERSION_AT_LEAST(6,0)
if (dav1d->frame_threads || dav1d->tile_threads) if (dav1d->frame_threads || dav1d->tile_threads)
@ -344,8 +347,10 @@ static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame)
if (res < 0) { if (res < 0) {
if (res == AVERROR(EINVAL)) if (res == AVERROR(EINVAL))
res = AVERROR_INVALIDDATA; res = AVERROR_INVALIDDATA;
if (res != AVERROR(EAGAIN)) if (res != AVERROR(EAGAIN)) {
dav1d_data_unref(data);
return res; return res;
}
} }
res = dav1d_get_picture(dav1d->c, p); res = dav1d_get_picture(dav1d->c, p);
@ -376,7 +381,8 @@ static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame)
#if FF_DAV1D_VERSION_AT_LEAST(5,1) #if FF_DAV1D_VERSION_AT_LEAST(5,1)
dav1d_get_event_flags(dav1d->c, &event_flags); dav1d_get_event_flags(dav1d->c, &event_flags);
if (event_flags & DAV1D_EVENT_FLAG_NEW_SEQUENCE) if (c->pix_fmt == AV_PIX_FMT_NONE ||
(event_flags & DAV1D_EVENT_FLAG_NEW_SEQUENCE))
#endif #endif
libdav1d_init_params(c, p->seq_hdr); libdav1d_init_params(c, p->seq_hdr);
res = ff_decode_frame_props(c, frame); res = ff_decode_frame_props(c, frame);

View file

@ -120,16 +120,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc) static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
{ {
const int pack_mode_10bit = const size_t luma_size = config->source_width * config->source_height *
(config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0; (config->encoder_bit_depth > 8 ? 2 : 1);
const size_t luma_size_8bit =
config->source_width * config->source_height * (1 << pack_mode_10bit);
const size_t luma_size_10bit =
(config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
EbSvtIOFormat *in_data; EbSvtIOFormat *in_data;
svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2; svt_enc->raw_size = luma_size * 3 / 2;
// allocate buffer for in and out // allocate buffer for in and out
svt_enc->in_buf = av_mallocz(sizeof(*svt_enc->in_buf)); svt_enc->in_buf = av_mallocz(sizeof(*svt_enc->in_buf));

View file

@ -208,7 +208,9 @@ static int libuavs3d_decode_frame(AVCodecContext *avctx, void *data, int *got_fr
} }
avctx->has_b_frames = !seqh->low_delay; avctx->has_b_frames = !seqh->low_delay;
avctx->pix_fmt = seqh->bit_depth_internal == 8 ? AV_PIX_FMT_YUV420P : AV_PIX_FMT_YUV420P10LE; avctx->pix_fmt = seqh->bit_depth_internal == 8 ? AV_PIX_FMT_YUV420P : AV_PIX_FMT_YUV420P10LE;
ff_set_dimensions(avctx, seqh->horizontal_size, seqh->vertical_size); ret = ff_set_dimensions(avctx, seqh->horizontal_size, seqh->vertical_size);
if (ret < 0)
return ret;
h->got_seqhdr = 1; h->got_seqhdr = 1;
if (seqh->colour_description) { if (seqh->colour_description) {

View file

@ -502,7 +502,13 @@ static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
{ {
libx265Context *ctx = avctx->priv_data; libx265Context *ctx = avctx->priv_data;
x265_picture x265pic; 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_nal *nal;
uint8_t *dst; uint8_t *dst;
int pict_type; int pict_type;
@ -573,8 +579,16 @@ static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
} }
} }
#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, 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
av_freep(&x265pic.quantOffsets); av_freep(&x265pic.quantOffsets);
@ -602,10 +616,16 @@ static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
pkt->flags |= AV_PKT_FLAG_KEY; pkt->flags |= AV_PKT_FLAG_KEY;
} }
pkt->pts = x265pic_out.pts; #if (X265_BUILD >= 210) && (X265_BUILD < 213)
pkt->dts = x265pic_out.dts; 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_IDR:
case X265_TYPE_I: case X265_TYPE_I:
pict_type = AV_PICTURE_TYPE_I; pict_type = AV_PICTURE_TYPE_I;
@ -623,17 +643,17 @@ static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
} }
#if X265_BUILD >= 130 #if X265_BUILD >= 130
if (x265pic_out.sliceType == X265_TYPE_B) if (x265pic_out->sliceType == X265_TYPE_B)
#else #else
if (x265pic_out.frameData.sliceType == 'b') if (x265pic_out->frameData.sliceType == 'b')
#endif #endif
pkt->flags |= AV_PKT_FLAG_DISPOSABLE; 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) { if (x265pic_out->userData) {
memcpy(&avctx->reordered_opaque, x265pic_out.userData, sizeof(avctx->reordered_opaque)); memcpy(&avctx->reordered_opaque, x265pic_out->userData, sizeof(avctx->reordered_opaque));
av_freep(&x265pic_out.userData); av_freep(&x265pic_out->userData);
} else } else
avctx->reordered_opaque = 0; avctx->reordered_opaque = 0;

View file

@ -206,7 +206,7 @@ static int xavs2_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
ret = cae->api->encoder_encode(cae->encoder, &pic, &cae->packet); ret = cae->api->encoder_encode(cae->encoder, &pic, &cae->packet);
if (ret) { if (ret) {
av_log(avctx, AV_LOG_ERROR, "Encoding error occured.\n"); av_log(avctx, AV_LOG_ERROR, "Encoding error occurred.\n");
return AVERROR_EXTERNAL; return AVERROR_EXTERNAL;
} }

View file

@ -202,12 +202,7 @@ static int decode_frame(AVCodecContext *avctx, void *data,
bytestream2_skip(gb, 8); bytestream2_skip(gb, 8);
uncompressed = bytestream2_get_le32(gb); uncompressed = bytestream2_get_le32(gb);
if ((ret = ff_reget_buffer(avctx, s->frame, 0)) < 0) if (!uncompressed) {
return ret;
if (uncompressed) {
ret = decode_mvdv(s, avctx, frame);
} else {
av_fast_padded_malloc(&s->uncompressed, &s->uncompressed_size, 16LL * (avpkt->size - 12)); av_fast_padded_malloc(&s->uncompressed, &s->uncompressed_size, 16LL * (avpkt->size - 12));
if (!s->uncompressed) if (!s->uncompressed)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
@ -216,9 +211,13 @@ static int decode_frame(AVCodecContext *avctx, void *data,
if (ret < 0) if (ret < 0)
return ret; return ret;
bytestream2_init(gb, s->uncompressed, ret); bytestream2_init(gb, s->uncompressed, ret);
ret = decode_mvdv(s, avctx, frame);
} }
if ((ret = ff_reget_buffer(avctx, s->frame, 0)) < 0)
return ret;
ret = decode_mvdv(s, avctx, frame);
if (ret < 0) if (ret < 0)
return ret; return ret;
key = ret; key = ret;

View file

@ -57,6 +57,7 @@ static int mjpegb_decode_frame(AVCodecContext *avctx,
buf_end = buf + buf_size; buf_end = buf + buf_size;
s->got_picture = 0; s->got_picture = 0;
s->adobe_transform = -1; s->adobe_transform = -1;
s->buf_size = buf_size;
read_header: read_header:
/* reset on every SOI */ /* reset on every SOI */

View file

@ -1088,6 +1088,10 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, int nb_components, int p
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
if (s->v_max != 1 || s->h_max != 1 || !s->lossless) if (s->v_max != 1 || s->h_max != 1 || !s->lossless)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
if (s->bayer) {
if (s->rct || s->pegasus_rct)
return AVERROR_INVALIDDATA;
}
s->restart_count = s->restart_interval; s->restart_count = s->restart_interval;
@ -1204,6 +1208,8 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, int nb_components, int p
ptr[3*mb_x + 2] = buffer[mb_x][2] + ptr[3*mb_x + 1]; ptr[3*mb_x + 2] = buffer[mb_x][2] + ptr[3*mb_x + 1];
} }
} else if (s->bayer) { } else if (s->bayer) {
if (s->bits <= 8)
return AVERROR_PATCHWELCOME;
if (nb_components == 1) { if (nb_components == 1) {
/* Leave decoding to the TIFF/DNG decoder (see comment in ff_mjpeg_decode_sof) */ /* Leave decoding to the TIFF/DNG decoder (see comment in ff_mjpeg_decode_sof) */
for (mb_x = 0; mb_x < width; mb_x++) for (mb_x = 0; mb_x < width; mb_x++)
@ -1938,6 +1944,8 @@ static int mjpeg_decode_app(MJpegDecodeContext *s)
} }
len -= 9; len -= 9;
if (s->bayer)
goto out;
if (s->got_picture) if (s->got_picture)
if (rgb != s->rgb || pegasus_rct != s->pegasus_rct) { if (rgb != s->rgb || pegasus_rct != s->pegasus_rct) {
av_log(s->avctx, AV_LOG_WARNING, "Mismatching LJIF tag\n"); av_log(s->avctx, AV_LOG_WARNING, "Mismatching LJIF tag\n");

View file

@ -247,7 +247,7 @@ void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, PutBitContext *pb,
default: av_assert0(0); default: av_assert0(0);
} }
put_bits(pb, 16, 17); put_bits(pb, 16, 8 + 3 * components);
if (lossless && ( avctx->pix_fmt == AV_PIX_FMT_BGR0 if (lossless && ( avctx->pix_fmt == AV_PIX_FMT_BGR0
|| avctx->pix_fmt == AV_PIX_FMT_BGRA || avctx->pix_fmt == AV_PIX_FMT_BGRA
|| avctx->pix_fmt == AV_PIX_FMT_BGR24)) || avctx->pix_fmt == AV_PIX_FMT_BGR24))

View file

@ -529,7 +529,7 @@ static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp,
/* This should happen for TrueHD streams with >6 channels and MLP's noise /* This should happen for TrueHD streams with >6 channels and MLP's noise
* type. It is not yet known if this is allowed. */ * type. It is not yet known if this is allowed. */
if (max_channel > MAX_MATRIX_CHANNEL_MLP && !noise_type) { if (max_matrix_channel > MAX_MATRIX_CHANNEL_MLP && !noise_type) {
avpriv_request_sample(m->avctx, avpriv_request_sample(m->avctx,
"%d channels (more than the " "%d channels (more than the "
"maximum supported by the decoder)", "maximum supported by the decoder)",

View file

@ -329,7 +329,7 @@ static av_cold int mobiclip_init(AVCodecContext *avctx)
return 0; return 0;
} }
static int setup_qtables(AVCodecContext *avctx, int quantizer) static int setup_qtables(AVCodecContext *avctx, int64_t quantizer)
{ {
MobiClipContext *s = avctx->priv_data; MobiClipContext *s = avctx->priv_data;
int qx, qy; int qx, qy;
@ -1255,7 +1255,7 @@ static int mobiclip_decode(AVCodecContext *avctx, void *data,
frame->key_frame = 0; frame->key_frame = 0;
s->dct_tab_idx = 0; s->dct_tab_idx = 0;
ret = setup_qtables(avctx, s->quantizer + get_se_golomb(gb)); ret = setup_qtables(avctx, s->quantizer + (int64_t)get_se_golomb(gb));
if (ret < 0) if (ret < 0)
return ret; return ret;

View file

@ -1614,7 +1614,7 @@ int ff_get_best_fcode(MpegEncContext * s, int16_t (*mv_table)[2], int type)
for(y=0; y<s->mb_height; y++){ for(y=0; y<s->mb_height; y++){
int x; int x;
int xy= y*s->mb_stride; int xy= y*s->mb_stride;
for(x=0; x<s->mb_width; x++){ for(x=0; x<s->mb_width; x++, xy++){
if(s->mb_type[xy] & type){ if(s->mb_type[xy] & type){
int mx= mv_table[xy][0]; int mx= mv_table[xy][0];
int my= mv_table[xy][1]; int my= mv_table[xy][1];
@ -1622,16 +1622,15 @@ int ff_get_best_fcode(MpegEncContext * s, int16_t (*mv_table)[2], int type)
fcode_tab[my + MAX_MV]); fcode_tab[my + MAX_MV]);
int j; int j;
if(mx >= range || mx < -range || if (mx >= range || mx < -range ||
my >= range || my < -range) my >= range || my < -range)
continue; continue;
for(j=0; j<fcode && j<8; j++){ for(j=0; j<fcode && j<8; j++){
if(s->pict_type==AV_PICTURE_TYPE_B || s->current_picture.mc_mb_var[xy] < s->current_picture.mb_var[xy]) if(s->pict_type==AV_PICTURE_TYPE_B || s->current_picture.mc_mb_var[xy] < s->current_picture.mb_var[xy])
score[j]-= 170; score[j]-= 170;
} }
} }
xy++;
} }
} }

View file

@ -184,7 +184,7 @@ static YuvPixel mp_get_yuv_from_rgb(MotionPixelsContext *mp, int x, int y)
int color; int color;
color = *(uint16_t *)&mp->frame->data[0][y * mp->frame->linesize[0] + x * 2]; 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) static void mp_set_rgb_from_yuv(MotionPixelsContext *mp, int x, int y, const YuvPixel *p)

View file

@ -263,7 +263,7 @@ static int decode_hclr(const uint8_t *tsmb, MovTextContext *m, uint64_t size)
static int styles_equivalent(const StyleBox *a, const StyleBox *b) static int styles_equivalent(const StyleBox *a, const StyleBox *b)
{ {
#define CMP(field) a->field == b->field #define CMP(field) ((a)->field == (b)->field)
return CMP(bold) && CMP(italic) && CMP(underline) && CMP(color) && return CMP(bold) && CMP(italic) && CMP(underline) && CMP(color) &&
CMP(alpha) && CMP(fontsize) && CMP(font_id); CMP(alpha) && CMP(fontsize) && CMP(font_id);
#undef CMP #undef CMP

View file

@ -3019,6 +3019,10 @@ static int ipu_decode_frame(AVCodecContext *avctx, void *data,
AVFrame * const frame = data; AVFrame * const frame = data;
int ret; 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); ret = ff_get_buffer(avctx, frame, 0);
if (ret < 0) if (ret < 0)
return ret; return ret;

View file

@ -372,7 +372,7 @@ static int handle_crc(MPADecodeContext *s, int sec_len)
crc_val = av_crc(crc_tab, crc_val, &buf[6], sec_byte_len); crc_val = av_crc(crc_tab, crc_val, &buf[6], sec_byte_len);
AV_WB32(tmp_buf, AV_WB32(tmp_buf,
((buf[6 + sec_byte_len] & (0xFF00 >> sec_rem_bits)) << 24) + ((buf[6 + sec_byte_len] & (0xFF00U >> sec_rem_bits)) << 24) +
((s->crc << 16) >> sec_rem_bits)); ((s->crc << 16) >> sec_rem_bits));
crc_val = av_crc(crc_tab, crc_val, tmp_buf, 3); crc_val = av_crc(crc_tab, crc_val, tmp_buf, 3);

View file

@ -26,6 +26,7 @@
*/ */
#include "libavutil/thread.h" #include "libavutil/thread.h"
#include "libavutil/imgutils.h"
#include "avcodec.h" #include "avcodec.h"
#include "bytestream.h" #include "bytestream.h"
@ -476,6 +477,9 @@ static int mss4_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
width, height); width, height);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
if (av_image_check_size2(width, height, avctx->max_pixels, AV_PIX_FMT_NONE, 0, avctx) < 0)
return AVERROR_INVALIDDATA;
if (quality < 1 || quality > 100) { if (quality < 1 || quality > 100) {
av_log(avctx, AV_LOG_ERROR, "Invalid quality setting %d\n", quality); av_log(avctx, AV_LOG_ERROR, "Invalid quality setting %d\n", quality);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;

View file

@ -263,8 +263,8 @@ int ff_nvdec_decode_uninit(AVCodecContext *avctx)
{ {
NVDECContext *ctx = avctx->internal->hwaccel_priv_data; NVDECContext *ctx = avctx->internal->hwaccel_priv_data;
av_freep(&ctx->bitstream);
av_freep(&ctx->bitstream_internal); av_freep(&ctx->bitstream_internal);
ctx->bitstream = NULL;
ctx->bitstream_len = 0; ctx->bitstream_len = 0;
ctx->bitstream_allocated = 0; ctx->bitstream_allocated = 0;
@ -667,6 +667,8 @@ int ff_nvdec_simple_end_frame(AVCodecContext *avctx)
NVDECContext *ctx = avctx->internal->hwaccel_priv_data; NVDECContext *ctx = avctx->internal->hwaccel_priv_data;
int ret = ff_nvdec_end_frame(avctx); int ret = ff_nvdec_end_frame(avctx);
ctx->bitstream = NULL; ctx->bitstream = NULL;
ctx->bitstream_len = 0;
ctx->nb_slices = 0;
return ret; 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]; const H264SliceContext *sl = &h->slice_ctx[0];
void *tmp; 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); ctx->bitstream_len + size + 3);
if (!tmp) if (!tmp)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
ctx->bitstream = tmp; ctx->bitstream = ctx->bitstream_internal = tmp;
tmp = av_fast_realloc(ctx->slice_offsets, &ctx->slice_offsets_allocated, tmp = av_fast_realloc(ctx->slice_offsets, &ctx->slice_offsets_allocated,
(ctx->nb_slices + 1) * sizeof(*ctx->slice_offsets)); (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; NVDECContext *ctx = avctx->internal->hwaccel_priv_data;
void *tmp; 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); ctx->bitstream_len + size + 3);
if (!tmp) if (!tmp)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
ctx->bitstream = tmp; ctx->bitstream = ctx->bitstream_internal = tmp;
tmp = av_fast_realloc(ctx->slice_offsets, &ctx->slice_offsets_allocated, tmp = av_fast_realloc(ctx->slice_offsets, &ctx->slice_offsets_allocated,
(ctx->nb_slices + 1) * sizeof(*ctx->slice_offsets)); (ctx->nb_slices + 1) * sizeof(*ctx->slice_offsets));

View file

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

View file

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

View file

@ -1078,8 +1078,9 @@ static av_cold void nvenc_setup_rate_control(AVCodecContext *avctx)
av_log(avctx, AV_LOG_VERBOSE, "CQ(%d) mode enabled.\n", tmp_quality); av_log(avctx, AV_LOG_VERBOSE, "CQ(%d) mode enabled.\n", tmp_quality);
//CQ mode shall discard avg bitrate & honor max bitrate; // CQ mode shall discard avg bitrate/vbv buffer size and honor only max bitrate
ctx->encode_config.rcParams.averageBitRate = avctx->bit_rate = 0; ctx->encode_config.rcParams.averageBitRate = avctx->bit_rate = 0;
ctx->encode_config.rcParams.vbvBufferSize = avctx->rc_buffer_size = 0;
ctx->encode_config.rcParams.maxBitRate = avctx->rc_max_rate; ctx->encode_config.rcParams.maxBitRate = avctx->rc_max_rate;
} }
} }
@ -1856,7 +1857,7 @@ static int nvenc_register_frame(AVCodecContext *avctx, const AVFrame *frame)
NV_ENCODE_API_FUNCTION_LIST *p_nvenc = &dl_fn->nvenc_funcs; NV_ENCODE_API_FUNCTION_LIST *p_nvenc = &dl_fn->nvenc_funcs;
AVHWFramesContext *frames_ctx = (AVHWFramesContext*)frame->hw_frames_ctx->data; AVHWFramesContext *frames_ctx = (AVHWFramesContext*)frame->hw_frames_ctx->data;
NV_ENC_REGISTER_RESOURCE reg; NV_ENC_REGISTER_RESOURCE reg = { 0 };
int i, idx, ret; int i, idx, ret;
for (i = 0; i < ctx->nb_registered_frames; i++) { for (i = 0; i < ctx->nb_registered_frames; i++) {
@ -2021,7 +2022,7 @@ static int nvenc_set_timestamp(AVCodecContext *avctx,
pkt->pts = params->outputTimeStamp; pkt->pts = params->outputTimeStamp;
pkt->dts = timestamp_queue_dequeue(ctx->timestamp_list); pkt->dts = timestamp_queue_dequeue(ctx->timestamp_list);
pkt->dts -= FFMAX(ctx->encode_config.frameIntervalP - 1, 0) * FFMAX(avctx->ticks_per_frame, 1); pkt->dts -= FFMAX(ctx->encode_config.frameIntervalP - 1, 0) * FFMAX(avctx->ticks_per_frame, 1) * FFMAX(avctx->time_base.num, 1);
return 0; return 0;
} }

View file

@ -244,8 +244,6 @@ static int decode_frame(AVCodecContext *avctx,
run = bytestream2_get_le16(&s->g); run = bytestream2_get_le16(&s->g);
val = bytestream2_get_byte(&s->g); val = bytestream2_get_byte(&s->g);
} }
if (!bytestream2_get_bytes_left(&s->g))
break;
if (bits_per_plane == 8) { if (bits_per_plane == 8) {
picmemset_8bpp(s, frame, val, run, &x, &y); picmemset_8bpp(s, frame, val, run, &x, &y);

View file

@ -405,7 +405,7 @@ static void filterfn(int16_t *dest, int16_t *tmp, unsigned size, int64_t scale)
(int64_t) low [i - 1] * -INT64_C(325392907) + (int64_t) low [i - 1] * -INT64_C(325392907) +
(int64_t) high[i + 0] * INT64_C(1518500249) + (int64_t) high[i + 0] * INT64_C(1518500249) +
(int64_t) high[i - 1] * INT64_C(1518500249); (int64_t) high[i - 1] * INT64_C(1518500249);
dest[i * 2] = av_clip_int16(((value >> 32) * scale) >> 32); dest[i * 2] = av_clip_int16(((value >> 32) * (uint64_t)scale) >> 32);
} }
for (i = 0; i < hsize; i++) { for (i = 0; i < hsize; i++) {
@ -416,7 +416,7 @@ static void filterfn(int16_t *dest, int16_t *tmp, unsigned size, int64_t scale)
(int64_t) high[i + 1] * INT64_C(303700064) + (int64_t) high[i + 1] * INT64_C(303700064) +
(int64_t) high[i + 0] * -INT64_C(3644400640) + (int64_t) high[i + 0] * -INT64_C(3644400640) +
(int64_t) high[i - 1] * INT64_C(303700064); (int64_t) high[i - 1] * INT64_C(303700064);
dest[i * 2 + 1] = av_clip_int16(((value >> 32) * scale) >> 32); dest[i * 2 + 1] = av_clip_int16(((value >> 32) * (uint64_t)scale) >> 32);
} }
} }

View file

@ -322,7 +322,7 @@ void ff_png_filter_row(PNGDSPContext *dsp, uint8_t *dst, int filter_type,
static void deloco_ ## NAME(TYPE *dst, int size, int alpha) \ static void deloco_ ## NAME(TYPE *dst, int size, int alpha) \
{ \ { \
int i; \ int i; \
for (i = 0; i < size; i += 3 + alpha) { \ for (i = 0; i < size - 2; i += 3 + alpha) { \
int g = dst [i + 1]; \ int g = dst [i + 1]; \
dst[i + 0] += g; \ dst[i + 0] += g; \
dst[i + 2] += g; \ dst[i + 2] += g; \
@ -1229,6 +1229,7 @@ static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s,
} }
av_log(avctx, AV_LOG_ERROR, ", skipping\n"); av_log(avctx, AV_LOG_ERROR, ", skipping\n");
bytestream2_skip(&s->gb, length + 8); /* tag */ bytestream2_skip(&s->gb, length + 8); /* tag */
continue;
} }
} }
tag = bytestream2_get_le32(&s->gb); tag = bytestream2_get_le32(&s->gb);

View file

@ -145,6 +145,12 @@ typedef struct FrameThreadContext {
* Set for the first N packets, where N is the number of threads. * Set for the first N packets, where N is the number of threads.
* While it is set, ff_thread_en/decode_frame won't return any results. * While it is set, ff_thread_en/decode_frame won't return any results.
*/ */
/* hwaccel state is temporarily stored here in order to transfer its ownership
* to the next decoding thread without the need for extra synchronization */
const AVHWAccel *stash_hwaccel;
void *stash_hwaccel_context;
void *stash_hwaccel_priv;
} FrameThreadContext; } FrameThreadContext;
#if FF_API_THREAD_SAFE_CALLBACKS #if FF_API_THREAD_SAFE_CALLBACKS
@ -229,9 +235,17 @@ FF_ENABLE_DEPRECATION_WARNINGS
ff_thread_finish_setup(avctx); ff_thread_finish_setup(avctx);
if (p->hwaccel_serializing) { if (p->hwaccel_serializing) {
/* wipe hwaccel state to avoid stale pointers lying around;
* the state was transferred to FrameThreadContext in
* ff_thread_finish_setup(), so nothing is leaked */
avctx->hwaccel = NULL;
avctx->hwaccel_context = NULL;
avctx->internal->hwaccel_priv_data = NULL;
p->hwaccel_serializing = 0; p->hwaccel_serializing = 0;
pthread_mutex_unlock(&p->parent->hwaccel_mutex); pthread_mutex_unlock(&p->parent->hwaccel_mutex);
} }
av_assert0(!avctx->hwaccel);
if (p->async_serializing) { if (p->async_serializing) {
p->async_serializing = 0; p->async_serializing = 0;
@ -294,14 +308,10 @@ static int update_context_from_thread(AVCodecContext *dst, AVCodecContext *src,
dst->color_range = src->color_range; dst->color_range = src->color_range;
dst->chroma_sample_location = src->chroma_sample_location; dst->chroma_sample_location = src->chroma_sample_location;
dst->hwaccel = src->hwaccel;
dst->hwaccel_context = src->hwaccel_context;
dst->channels = src->channels; dst->channels = src->channels;
dst->sample_rate = src->sample_rate; dst->sample_rate = src->sample_rate;
dst->sample_fmt = src->sample_fmt; dst->sample_fmt = src->sample_fmt;
dst->channel_layout = src->channel_layout; dst->channel_layout = src->channel_layout;
dst->internal->hwaccel_priv_data = src->internal->hwaccel_priv_data;
if (!!dst->hw_frames_ctx != !!src->hw_frames_ctx || if (!!dst->hw_frames_ctx != !!src->hw_frames_ctx ||
(dst->hw_frames_ctx && dst->hw_frames_ctx->data != src->hw_frames_ctx->data)) { (dst->hw_frames_ctx && dst->hw_frames_ctx->data != src->hw_frames_ctx->data)) {
@ -444,6 +454,12 @@ static int submit_packet(PerThreadContext *p, AVCodecContext *user_avctx,
} }
} }
/* transfer the stashed hwaccel state, if any */
av_assert0(!p->avctx->hwaccel);
FFSWAP(const AVHWAccel*, p->avctx->hwaccel, fctx->stash_hwaccel);
FFSWAP(void*, p->avctx->hwaccel_context, fctx->stash_hwaccel_context);
FFSWAP(void*, p->avctx->internal->hwaccel_priv_data, fctx->stash_hwaccel_priv);
av_packet_unref(p->avpkt); av_packet_unref(p->avpkt);
ret = av_packet_ref(p->avpkt, avpkt); ret = av_packet_ref(p->avpkt, avpkt);
if (ret < 0) { if (ret < 0) {
@ -647,6 +663,14 @@ void ff_thread_finish_setup(AVCodecContext *avctx) {
async_lock(p->parent); async_lock(p->parent);
} }
/* save hwaccel state for passing to the next thread;
* this is done here so that this worker thread can wipe its own hwaccel
* state after decoding, without requiring synchronization */
av_assert0(!p->parent->stash_hwaccel);
p->parent->stash_hwaccel = avctx->hwaccel;
p->parent->stash_hwaccel_context = avctx->hwaccel_context;
p->parent->stash_hwaccel_priv = avctx->internal->hwaccel_priv_data;
pthread_mutex_lock(&p->progress_mutex); pthread_mutex_lock(&p->progress_mutex);
if(atomic_load(&p->state) == STATE_SETUP_FINISHED){ if(atomic_load(&p->state) == STATE_SETUP_FINISHED){
av_log(avctx, AV_LOG_WARNING, "Multiple ff_thread_finish_setup() calls\n"); av_log(avctx, AV_LOG_WARNING, "Multiple ff_thread_finish_setup() calls\n");
@ -700,13 +724,6 @@ void ff_frame_thread_free(AVCodecContext *avctx, int thread_count)
park_frame_worker_threads(fctx, thread_count); park_frame_worker_threads(fctx, thread_count);
if (fctx->prev_thread && avctx->internal->hwaccel_priv_data !=
fctx->prev_thread->avctx->internal->hwaccel_priv_data) {
if (update_context_from_thread(avctx, fctx->prev_thread->avctx, 1) < 0) {
av_log(avctx, AV_LOG_ERROR, "Failed to update user thread.\n");
}
}
if (fctx->prev_thread && fctx->prev_thread != fctx->threads) if (fctx->prev_thread && fctx->prev_thread != fctx->threads)
if (update_context_from_thread(fctx->threads->avctx, fctx->prev_thread->avctx, 0) < 0) { if (update_context_from_thread(fctx->threads->avctx, fctx->prev_thread->avctx, 0) < 0) {
av_log(avctx, AV_LOG_ERROR, "Final thread update failed\n"); av_log(avctx, AV_LOG_ERROR, "Final thread update failed\n");
@ -760,6 +777,13 @@ void ff_frame_thread_free(AVCodecContext *avctx, int thread_count)
av_freep(&fctx->threads); av_freep(&fctx->threads);
ff_pthread_free(fctx, thread_ctx_offsets); ff_pthread_free(fctx, thread_ctx_offsets);
/* if we have stashed hwaccel state, move it to the user-facing context,
* so it will be freed in avcodec_close() */
av_assert0(!avctx->hwaccel);
FFSWAP(const AVHWAccel*, avctx->hwaccel, fctx->stash_hwaccel);
FFSWAP(void*, avctx->hwaccel_context, fctx->stash_hwaccel_context);
FFSWAP(void*, avctx->internal->hwaccel_priv_data, fctx->stash_hwaccel_priv);
av_freep(&avctx->internal->thread_ctx); av_freep(&avctx->internal->thread_ctx);
} }

View file

@ -369,7 +369,7 @@ static int decode_frame(AVCodecContext *avctx,
bytestream2_skip(&gbc, 18); bytestream2_skip(&gbc, 18);
colors = bytestream2_get_be16(&gbc); colors = bytestream2_get_be16(&gbc);
if (colors < 0 || colors > 256) { if (colors < 0 || colors > 255) {
av_log(avctx, AV_LOG_ERROR, av_log(avctx, AV_LOG_ERROR,
"Error color count - %i(0x%X)\n", colors, colors); "Error color count - %i(0x%X)\n", colors, colors);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;

View file

@ -198,7 +198,7 @@ static void OPNAME ## qpel8_mc01_c(uint8_t *dst, const uint8_t *src, \
uint8_t full[16 * 9]; \ uint8_t full[16 * 9]; \
uint8_t half[64]; \ uint8_t half[64]; \
\ \
copy_block9(full, src, 16, stride, 9); \ copy_block8(full, src, 16, stride, 9); \
put ## RND ## mpeg4_qpel8_v_lowpass(half, full, 8, 16); \ put ## RND ## mpeg4_qpel8_v_lowpass(half, full, 8, 16); \
OPNAME ## pixels8_l2_8(dst, full, half, stride, 16, 8, 8); \ OPNAME ## pixels8_l2_8(dst, full, half, stride, 16, 8, 8); \
} \ } \
@ -208,7 +208,7 @@ static void OPNAME ## qpel8_mc02_c(uint8_t *dst, const uint8_t *src, \
{ \ { \
uint8_t full[16 * 9]; \ uint8_t full[16 * 9]; \
\ \
copy_block9(full, src, 16, stride, 9); \ copy_block8(full, src, 16, stride, 9); \
OPNAME ## mpeg4_qpel8_v_lowpass(dst, full, stride, 16); \ OPNAME ## mpeg4_qpel8_v_lowpass(dst, full, stride, 16); \
} \ } \
\ \
@ -218,7 +218,7 @@ static void OPNAME ## qpel8_mc03_c(uint8_t *dst, const uint8_t *src, \
uint8_t full[16 * 9]; \ uint8_t full[16 * 9]; \
uint8_t half[64]; \ uint8_t half[64]; \
\ \
copy_block9(full, src, 16, stride, 9); \ copy_block8(full, src, 16, stride, 9); \
put ## RND ## mpeg4_qpel8_v_lowpass(half, full, 8, 16); \ put ## RND ## mpeg4_qpel8_v_lowpass(half, full, 8, 16); \
OPNAME ## pixels8_l2_8(dst, full + 16, half, stride, 16, 8, 8); \ OPNAME ## pixels8_l2_8(dst, full + 16, half, stride, 16, 8, 8); \
} \ } \
@ -458,7 +458,7 @@ static void OPNAME ## qpel16_mc01_c(uint8_t *dst, const uint8_t *src, \
uint8_t full[24 * 17]; \ uint8_t full[24 * 17]; \
uint8_t half[256]; \ uint8_t half[256]; \
\ \
copy_block17(full, src, 24, stride, 17); \ copy_block16(full, src, 24, stride, 17); \
put ## RND ## mpeg4_qpel16_v_lowpass(half, full, 16, 24); \ put ## RND ## mpeg4_qpel16_v_lowpass(half, full, 16, 24); \
OPNAME ## pixels16_l2_8(dst, full, half, stride, 24, 16, 16); \ OPNAME ## pixels16_l2_8(dst, full, half, stride, 24, 16, 16); \
} \ } \
@ -468,7 +468,7 @@ static void OPNAME ## qpel16_mc02_c(uint8_t *dst, const uint8_t *src, \
{ \ { \
uint8_t full[24 * 17]; \ uint8_t full[24 * 17]; \
\ \
copy_block17(full, src, 24, stride, 17); \ copy_block16(full, src, 24, stride, 17); \
OPNAME ## mpeg4_qpel16_v_lowpass(dst, full, stride, 24); \ OPNAME ## mpeg4_qpel16_v_lowpass(dst, full, stride, 24); \
} \ } \
\ \
@ -478,7 +478,7 @@ static void OPNAME ## qpel16_mc03_c(uint8_t *dst, const uint8_t *src, \
uint8_t full[24 * 17]; \ uint8_t full[24 * 17]; \
uint8_t half[256]; \ uint8_t half[256]; \
\ \
copy_block17(full, src, 24, stride, 17); \ copy_block16(full, src, 24, stride, 17); \
put ## RND ## mpeg4_qpel16_v_lowpass(half, full, 16, 24); \ put ## RND ## mpeg4_qpel16_v_lowpass(half, full, 16, 24); \
OPNAME ## pixels16_l2_8(dst, full + 24, half, stride, 24, 16, 16); \ OPNAME ## pixels16_l2_8(dst, full + 24, half, stride, 24, 16, 16); \
} \ } \

View file

@ -205,7 +205,7 @@ static void get_max_component_diff(BlockInfo *bi, uint16_t *block_ptr,
// loop thru and compare pixels // loop thru and compare pixels
for (y = 0; y < bi->block_height; y++) { for (y = 0; y < bi->block_height; y++) {
for (x = 0; x < bi->block_width; x++){ for (x = 0; x < bi->block_width; x++) {
// TODO: optimize // TODO: optimize
min_r = FFMIN(R(block_ptr[x]), min_r); min_r = FFMIN(R(block_ptr[x]), min_r);
min_g = FFMIN(G(block_ptr[x]), min_g); min_g = FFMIN(G(block_ptr[x]), min_g);
@ -277,7 +277,7 @@ static int leastsquares(uint16_t *block_ptr, BlockInfo *bi,
return -1; return -1;
for (i = 0; i < bi->block_height; i++) { for (i = 0; i < bi->block_height; i++) {
for (j = 0; j < bi->block_width; j++){ for (j = 0; j < bi->block_width; j++) {
x = GET_CHAN(block_ptr[j], xchannel); x = GET_CHAN(block_ptr[j], xchannel);
y = GET_CHAN(block_ptr[j], ychannel); y = GET_CHAN(block_ptr[j], ychannel);
sumx += x; sumx += x;
@ -324,7 +324,7 @@ static int calc_lsq_max_fit_error(uint16_t *block_ptr, BlockInfo *bi,
int max_err = 0; int max_err = 0;
for (i = 0; i < bi->block_height; i++) { for (i = 0; i < bi->block_height; i++) {
for (j = 0; j < bi->block_width; j++){ for (j = 0; j < bi->block_width; j++) {
int x_inc, lin_y, lin_x; int x_inc, lin_y, lin_x;
x = GET_CHAN(block_ptr[j], xchannel); x = GET_CHAN(block_ptr[j], xchannel);
y = GET_CHAN(block_ptr[j], ychannel); y = GET_CHAN(block_ptr[j], ychannel);
@ -419,7 +419,9 @@ static void update_block_in_prev_frame(const uint16_t *src_pixels,
uint16_t *dest_pixels, uint16_t *dest_pixels,
const BlockInfo *bi, int block_counter) const BlockInfo *bi, int block_counter)
{ {
for (int y = 0; y < 4; y++) { const int y_size = FFMIN(4, bi->image_height - bi->row * 4);
for (int y = 0; y < y_size; y++) {
memcpy(dest_pixels, src_pixels, 8); memcpy(dest_pixels, src_pixels, 8);
dest_pixels += bi->rowstride; dest_pixels += bi->rowstride;
src_pixels += bi->rowstride; src_pixels += bi->rowstride;
@ -729,14 +731,15 @@ post_skip :
if (err > s->sixteen_color_thresh) { // DO SIXTEEN COLOR BLOCK if (err > s->sixteen_color_thresh) { // DO SIXTEEN COLOR BLOCK
uint16_t *row_ptr; uint16_t *row_ptr;
int rgb555; int y_size, rgb555;
block_offset = get_block_info(&bi, block_counter); block_offset = get_block_info(&bi, block_counter);
row_ptr = &src_pixels[block_offset]; row_ptr = &src_pixels[block_offset];
y_size = FFMIN(4, bi.image_height - bi.row * 4);
for (int y = 0; y < 4; y++) { for (int y = 0; y < y_size; y++) {
for (int x = 0; x < 4; x++){ for (int x = 0; x < 4; x++) {
rgb555 = row_ptr[x] & ~0x8000; rgb555 = row_ptr[x] & ~0x8000;
put_bits(&s->pb, 16, rgb555); put_bits(&s->pb, 16, rgb555);
@ -744,6 +747,11 @@ post_skip :
row_ptr += bi.rowstride; row_ptr += bi.rowstride;
} }
for (int y = y_size; y < 4; y++) {
for (int x = 0; x < 4; x++)
put_bits(&s->pb, 16, 0);
}
block_counter++; block_counter++;
} else { // FOUR COLOR BLOCK } else { // FOUR COLOR BLOCK
block_counter += encode_four_color_block(min_color, max_color, block_counter += encode_four_color_block(min_color, max_color,

View file

@ -114,8 +114,8 @@ static void sbr_qmf_deint_neg_c(int *v, const int *src)
{ {
int i; int i;
for (i = 0; i < 32; i++) { for (i = 0; i < 32; i++) {
v[ i] = ( src[63 - 2*i ] + 0x10) >> 5; v[ i] = (int)(0x10U + src[63 - 2*i ]) >> 5;
v[63 - i] = (-src[63 - 2*i - 1] + 0x10) >> 5; v[63 - i] = (int)(0x10U - src[63 - 2*i - 1]) >> 5;
} }
} }

View file

@ -459,6 +459,9 @@ static int decompress_p(AVCodecContext *avctx,
int run, bx = x * 16 + sx1, by = y * 16 + sy1; int run, bx = x * 16 + sx1, by = y * 16 + sy1;
uint32_t r, g, b, clr, ptype = 0; uint32_t r, g, b, clr, ptype = 0;
if (bx >= avctx->width)
return AVERROR_INVALIDDATA;
for (; by < y * 16 + sy2 && by < avctx->height;) { for (; by < y * 16 + sy2 && by < avctx->height;) {
ret = decode_value(s, s->op_model[ptype], 6, 1000, &ptype); ret = decode_value(s, s->op_model[ptype], 6, 1000, &ptype);
if (ret < 0) if (ret < 0)

View file

@ -1168,6 +1168,9 @@ static int decompress_p3(AVCodecContext *avctx,
int run, bx = x * 16 + sx1, by = y * 16 + sy1; int run, bx = x * 16 + sx1, by = y * 16 + sy1;
uint32_t clr, ptype = 0, r, g, b; uint32_t clr, ptype = 0, r, g, b;
if (bx >= avctx->width)
return AVERROR_INVALIDDATA;
for (; by < y * 16 + sy2 && by < avctx->height;) { for (; by < y * 16 + sy2 && by < avctx->height;) {
ret = decode_value3(s, 5, &s->op_model3[ptype].cntsum, ret = decode_value3(s, 5, &s->op_model3[ptype].cntsum,
s->op_model3[ptype].freqs[0], s->op_model3[ptype].freqs[0],

View file

@ -61,6 +61,7 @@ typedef struct SMCContext {
{ \ { \
row_ptr += stride * 4; \ row_ptr += stride * 4; \
pixel_ptr = row_ptr; \ pixel_ptr = row_ptr; \
cur_y += 4; \
} \ } \
} \ } \
} }
@ -117,6 +118,7 @@ static void smc_encode_stream(SMCContext *s, const AVFrame *frame,
const uint8_t *prev_pixels = (const uint8_t *)s->prev_frame->data[0]; const uint8_t *prev_pixels = (const uint8_t *)s->prev_frame->data[0];
uint8_t *distinct_values = s->distinct_values; uint8_t *distinct_values = s->distinct_values;
const uint8_t *pixel_ptr, *row_ptr; const uint8_t *pixel_ptr, *row_ptr;
const int height = frame->height;
const int width = frame->width; const int width = frame->width;
uint8_t block_values[16]; uint8_t block_values[16];
int block_counter = 0; int block_counter = 0;
@ -125,13 +127,14 @@ static void smc_encode_stream(SMCContext *s, const AVFrame *frame,
int color_octet_index = 0; int color_octet_index = 0;
int color_table_index; /* indexes to color pair, quad, or octet tables */ int color_table_index; /* indexes to color pair, quad, or octet tables */
int total_blocks; int total_blocks;
int cur_y = 0;
memset(s->color_pairs, 0, sizeof(s->color_pairs)); memset(s->color_pairs, 0, sizeof(s->color_pairs));
memset(s->color_quads, 0, sizeof(s->color_quads)); memset(s->color_quads, 0, sizeof(s->color_quads));
memset(s->color_octets, 0, sizeof(s->color_octets)); memset(s->color_octets, 0, sizeof(s->color_octets));
/* Number of 4x4 blocks in frame. */ /* Number of 4x4 blocks in frame. */
total_blocks = ((frame->width + 3) / 4) * ((frame->height + 3) / 4); total_blocks = ((width + 3) / 4) * ((height + 3) / 4);
pixel_ptr = row_ptr = src_pixels; pixel_ptr = row_ptr = src_pixels;
@ -145,11 +148,13 @@ static void smc_encode_stream(SMCContext *s, const AVFrame *frame,
int cache_index; int cache_index;
int distinct = 0; int distinct = 0;
int blocks = 0; int blocks = 0;
int frame_y = cur_y;
while (prev_pixels && s->key_frame == 0 && block_counter + inter_skip_blocks < total_blocks) { while (prev_pixels && s->key_frame == 0 && block_counter + inter_skip_blocks < total_blocks) {
const int y_size = FFMIN(4, height - cur_y);
int compare = 0; int compare = 0;
for (int y = 0; y < 4; y++) { for (int y = 0; y < y_size; y++) {
const ptrdiff_t offset = pixel_ptr - src_pixels; const ptrdiff_t offset = pixel_ptr - src_pixels;
const uint8_t *prev_pixel_ptr = prev_pixels + offset; const uint8_t *prev_pixel_ptr = prev_pixels + offset;
@ -170,8 +175,10 @@ static void smc_encode_stream(SMCContext *s, const AVFrame *frame,
pixel_ptr = xpixel_ptr; pixel_ptr = xpixel_ptr;
row_ptr = xrow_ptr; row_ptr = xrow_ptr;
cur_y = frame_y;
while (block_counter > 0 && block_counter + intra_skip_blocks < total_blocks) { while (block_counter > 0 && block_counter + intra_skip_blocks < total_blocks) {
const int y_size = FFMIN(4, height - cur_y);
const ptrdiff_t offset = pixel_ptr - src_pixels; const ptrdiff_t offset = pixel_ptr - src_pixels;
const int sy = offset / stride; const int sy = offset / stride;
const int sx = offset % stride; const int sx = offset % stride;
@ -180,7 +187,7 @@ static void smc_encode_stream(SMCContext *s, const AVFrame *frame,
const uint8_t *old_pixel_ptr = src_pixels + nx + ny * stride; const uint8_t *old_pixel_ptr = src_pixels + nx + ny * stride;
int compare = 0; int compare = 0;
for (int y = 0; y < 4; y++) { for (int y = 0; y < y_size; y++) {
compare |= memcmp(old_pixel_ptr + y * stride, pixel_ptr + y * stride, 4); compare |= memcmp(old_pixel_ptr + y * stride, pixel_ptr + y * stride, 4);
if (compare) if (compare)
break; break;
@ -197,9 +204,11 @@ static void smc_encode_stream(SMCContext *s, const AVFrame *frame,
pixel_ptr = xpixel_ptr; pixel_ptr = xpixel_ptr;
row_ptr = xrow_ptr; row_ptr = xrow_ptr;
cur_y = frame_y;
while (block_counter + coded_blocks < total_blocks && coded_blocks < 256) { while (block_counter + coded_blocks < total_blocks && coded_blocks < 256) {
for (int y = 0; y < 4; y++) const int y_size = FFMIN(4, height - cur_y);
for (int y = 0; y < y_size; y++)
memcpy(block_values + y * 4, pixel_ptr + y * stride, 4); memcpy(block_values + y * 4, pixel_ptr + y * stride, 4);
qsort(block_values, 16, sizeof(block_values[0]), smc_cmp_values); qsort(block_values, 16, sizeof(block_values[0]), smc_cmp_values);
@ -224,6 +233,7 @@ static void smc_encode_stream(SMCContext *s, const AVFrame *frame,
pixel_ptr = xpixel_ptr; pixel_ptr = xpixel_ptr;
row_ptr = xrow_ptr; row_ptr = xrow_ptr;
cur_y = frame_y;
blocks = coded_blocks; blocks = coded_blocks;
distinct = coded_distinct; distinct = coded_distinct;

View file

@ -1533,10 +1533,10 @@ static void calculate_visual_weight(SnowContext *s, Plane *p){
int level, orientation, x, y; int level, orientation, x, y;
for(level=0; level<s->spatial_decomposition_count; level++){ for(level=0; level<s->spatial_decomposition_count; level++){
int64_t error=0;
for(orientation=level ? 1 : 0; orientation<4; orientation++){ for(orientation=level ? 1 : 0; orientation<4; orientation++){
SubBand *b= &p->band[level][orientation]; SubBand *b= &p->band[level][orientation];
IDWTELEM *ibuf= b->ibuf; IDWTELEM *ibuf= b->ibuf;
int64_t error=0;
memset(s->spatial_idwt_buffer, 0, sizeof(*s->spatial_idwt_buffer)*width*height); memset(s->spatial_idwt_buffer, 0, sizeof(*s->spatial_idwt_buffer)*width*height);
ibuf[b->width/2 + b->height/2*b->stride]= 256*16; ibuf[b->width/2 + b->height/2*b->stride]= 256*16;
@ -1547,9 +1547,13 @@ static void calculate_visual_weight(SnowContext *s, Plane *p){
error += d*d; error += d*d;
} }
} }
if (orientation == 2)
error /= 2;
b->qlog= (int)(QROOT * log2(352256.0/sqrt(error)) + 0.5); 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

@ -1003,7 +1003,7 @@ static int sonic_decode_frame(AVCodecContext *avctx,
// dequantize // dequantize
for (i = 0; i < s->num_taps; i++) for (i = 0; i < s->num_taps; i++)
s->predictor_k[i] *= s->tap_quant[i]; s->predictor_k[i] *= (unsigned) s->tap_quant[i];
if (s->lossless) if (s->lossless)
quant = 1; quant = 1;

View file

@ -497,7 +497,9 @@ static int speedhq_decode_frame(AVCodecContext *avctx,
uint32_t second_field_offset; uint32_t second_field_offset;
int ret; int ret;
if (buf_size < 4 || avctx->width < 8) if (buf_size < 4 || avctx->width < 8 || avctx->width % 8 != 0)
return AVERROR_INVALIDDATA;
if (buf_size < avctx->width*avctx->height / 64 / 4)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
quality = buf[0]; quality = buf[0];

View file

@ -164,39 +164,39 @@ typedef struct SpeexSubmode {
} SpeexSubmode; } SpeexSubmode;
typedef struct SpeexMode { typedef struct SpeexMode {
int modeID; /** ID of the mode */ int modeID; /**< ID of the mode */
int (*decode)(AVCodecContext *avctx, void *dec, GetBitContext *gb, float *out); int (*decode)(AVCodecContext *avctx, void *dec, GetBitContext *gb, float *out);
int frame_size; /**< Size of frames used for decoding */ int frame_size; /**< Size of frames used for decoding */
int subframe_size; /**< Size of sub-frames used for decoding */ int subframe_size; /**< Size of sub-frames used for decoding */
int lpc_size; /**< Order of LPC filter */ int lpc_size; /**< Order of LPC filter */
float folding_gain; /**< Folding gain */ float folding_gain; /**< Folding gain */
const SpeexSubmode *submodes[NB_SUBMODES]; /**< Sub-mode data for the mode */ const SpeexSubmode *submodes[NB_SUBMODES]; /**< Sub-mode data for the mode */
int default_submode; /**< Default sub-mode to use when decoding */ int default_submode; /**< Default sub-mode to use when decoding */
} SpeexMode; } SpeexMode;
typedef struct DecoderState { typedef struct DecoderState {
const SpeexMode *mode; const SpeexMode *mode;
int modeID; /** ID of the decoder mode */ int modeID; /**< ID of the decoder mode */
int first; /** Is first frame */ int first; /**< Is first frame */
int full_frame_size; /**< Length of full-band frames */ int full_frame_size; /**< Length of full-band frames */
int is_wideband; /**< If wideband is present */ int is_wideband; /**< If wideband is present */
int count_lost; /**< Was the last frame lost? */ int count_lost; /**< Was the last frame lost? */
int frame_size; /**< Length of high-band frames */ int frame_size; /**< Length of high-band frames */
int subframe_size; /**< Length of high-band sub-frames */ int subframe_size; /**< Length of high-band sub-frames */
int nb_subframes; /**< Number of high-band sub-frames */ int nb_subframes; /**< Number of high-band sub-frames */
int lpc_size; /**< Order of high-band LPC analysis */ int lpc_size; /**< Order of high-band LPC analysis */
float last_ol_gain; /**< Open-loop gain for previous frame */ float last_ol_gain; /**< Open-loop gain for previous frame */
float *innov_save; /** If non-NULL, innovation is copied here */ float *innov_save; /**< If non-NULL, innovation is copied here */
/* This is used in packet loss concealment */ /* This is used in packet loss concealment */
int last_pitch; /**< Pitch of last correctly decoded frame */ int last_pitch; /**< Pitch of last correctly decoded frame */
float last_pitch_gain; /**< Pitch gain of last correctly decoded frame */ float last_pitch_gain; /**< Pitch gain of last correctly decoded frame */
uint32_t seed; /** Seed used for random number generation */ uint32_t seed; /**< Seed used for random number generation */
int encode_submode; int encode_submode;
const SpeexSubmode *const *submodes; /**< Sub-mode data */ const SpeexSubmode *const *submodes; /**< Sub-mode data */
int submodeID; /**< Activated sub-mode */ int submodeID; /**< Activated sub-mode */
int lpc_enh_enabled; /**< 1 when LPC enhancer is on, 0 otherwise */ int lpc_enh_enabled; /**< 1 when LPC enhancer is on, 0 otherwise */
/* Vocoder data */ /* Vocoder data */
float voc_m1; float voc_m1;
@ -205,10 +205,10 @@ typedef struct DecoderState {
int voc_offset; int voc_offset;
int dtx_enabled; int dtx_enabled;
int highpass_enabled; /**< Is the input filter enabled */ int highpass_enabled; /**< Is the input filter enabled */
float *exc; /**< Start of excitation frame */ float *exc; /**< Start of excitation frame */
float mem_hp[2]; /**< High-pass filter memory */ float mem_hp[2]; /**< High-pass filter memory */
float exc_buf[NB_DEC_BUFFER]; /**< Excitation buffer */ float exc_buf[NB_DEC_BUFFER]; /**< Excitation buffer */
float old_qlsp[NB_ORDER]; /**< Quantized LSPs for previous frame */ float old_qlsp[NB_ORDER]; /**< Quantized LSPs for previous frame */
float interp_qlpc[NB_ORDER]; /**< Interpolated quantized LPCs */ float interp_qlpc[NB_ORDER]; /**< Interpolated quantized LPCs */
@ -1451,7 +1451,7 @@ static av_cold int speex_decode_init(AVCodecContext *avctx)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
s->nb_channels = avctx->channels; s->nb_channels = avctx->channels;
if (s->nb_channels <= 0) if (s->nb_channels <= 0 || s->nb_channels > 2)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
switch (s->rate) { switch (s->rate) {

View file

@ -19,6 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#include "libavutil/avassert.h"
#include "libavutil/common.h" #include "libavutil/common.h"
#include "libavutil/intreadwrite.h" #include "libavutil/intreadwrite.h"
#include "libavutil/imgutils.h" #include "libavutil/imgutils.h"
@ -75,6 +76,12 @@ static int sunrast_decode_frame(AVCodecContext *avctx, void *data,
return AVERROR_PATCHWELCOME; return AVERROR_PATCHWELCOME;
} }
if (maplength > 768) {
av_log(avctx, AV_LOG_WARNING, "invalid colormap length\n");
return AVERROR_INVALIDDATA;
}
// This also checks depth to be valid
switch (depth) { switch (depth) {
case 1: case 1:
avctx->pix_fmt = maplength ? AV_PIX_FMT_PAL8 : AV_PIX_FMT_MONOWHITE; avctx->pix_fmt = maplength ? AV_PIX_FMT_PAL8 : AV_PIX_FMT_MONOWHITE;
@ -96,15 +103,23 @@ static int sunrast_decode_frame(AVCodecContext *avctx, void *data,
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
// This checks w and h to be valid in the sense that bytes of a padded bitmap are addressable with 32bit int
ret = ff_set_dimensions(avctx, w, h); ret = ff_set_dimensions(avctx, w, h);
if (ret < 0) if (ret < 0)
return ret; return ret;
// ensured by ff_set_dimensions()
av_assert0(w <= (INT32_MAX - 7) / depth);
/* scanlines are aligned on 16 bit boundaries */ /* scanlines are aligned on 16 bit boundaries */
len = (depth * w + 7) >> 3; len = (depth * w + 7) >> 3;
alen = len + (len & 1); alen = len + (len & 1);
if (buf_end - buf < maplength + (len * h) * 3 / 256) // ensured by ff_set_dimensions()
av_assert0(h <= INT32_MAX / (3 * len));
// maplength is limited to 768 and the right term is limited to INT32_MAX / 256 so the add needs no check
if (buf_end - buf < (uint64_t)maplength + (len * h) * 3 / 256)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
if ((ret = ff_get_buffer(avctx, p, 0)) < 0) if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
@ -118,7 +133,7 @@ static int sunrast_decode_frame(AVCodecContext *avctx, void *data,
} else if (maplength) { } else if (maplength) {
unsigned int len = maplength / 3; unsigned int len = maplength / 3;
if (maplength % 3 || maplength > 768) { if (maplength % 3) {
av_log(avctx, AV_LOG_WARNING, "invalid colormap length\n"); av_log(avctx, AV_LOG_WARNING, "invalid colormap length\n");
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }

View file

@ -65,7 +65,7 @@ static void decorrelate_sf(int32_t *p1, int32_t *p2, int length, int dshift, int
for (i = 0; i < length; i++) { for (i = 0; i < length; i++) {
int32_t a = p1[i]; int32_t a = p1[i];
int32_t b = p2[i]; int32_t b = p2[i];
b = (unsigned)(dfactor * (b >> dshift) + 128 >> 8) << dshift; b = (unsigned)((int)(dfactor * (unsigned)(b >> dshift) + 128) >> 8) << dshift;
p1[i] = b - a; p1[i] = b - a;
} }
} }

View file

@ -31,11 +31,13 @@ int main(void){
#define width 256 #define width 256
#define height 256 #define height 256
int buffer[2][width*height]; int buffer[2][width*height];
short obuffer[width*height];
SnowContext s; SnowContext s;
int i; int i;
AVLFG prng; AVLFG prng;
s.spatial_decomposition_count=6; s.spatial_decomposition_count=6;
s.spatial_decomposition_type=1; s.spatial_decomposition_type=1;
int ret = 0;
s.temp_dwt_buffer = av_calloc(width, sizeof(*s.temp_dwt_buffer)); s.temp_dwt_buffer = av_calloc(width, sizeof(*s.temp_dwt_buffer));
s.temp_idwt_buffer = av_calloc(width, sizeof(*s.temp_idwt_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"); printf("testing 5/3 DWT\n");
for(i=0; i<width*height; i++) 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_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++) 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"); printf("testing 9/7 DWT\n");
s.spatial_decomposition_type=0; s.spatial_decomposition_type=0;
for(i=0; i<width*height; i++) 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_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++) 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; int level, orientation, x, y;
@ -81,18 +93,18 @@ int main(void){
int w= width >> (s.spatial_decomposition_count-level); int w= width >> (s.spatial_decomposition_count-level);
int h= height >> (s.spatial_decomposition_count-level); int h= height >> (s.spatial_decomposition_count-level);
int stride= width << (s.spatial_decomposition_count-level); int stride= width << (s.spatial_decomposition_count-level);
DWTELEM *buf= buffer[0]; IDWTELEM *buf= obuffer;
int64_t error=0; int64_t error=0;
if(orientation&1) buf+=w; if(orientation&1) buf+=w;
if(orientation>1) buf+=stride>>1; if(orientation>1) buf+=stride>>1;
memset(buffer[0], 0, sizeof(int)*width*height); memset(obuffer, 0, sizeof(short)*width*height);
buf[w/2 + h/2*stride]= 256*256; buf[w/2 + h/2*stride]= 8*256;
ff_spatial_idwt((IDWTELEM*)buffer[0], s.temp_idwt_buffer, width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count); 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(y=0; y<height; y++){
for(x=0; x<width; x++){ for(x=0; x<width; x++){
int64_t d= buffer[0][x + y*width]; int64_t d= obuffer[x + y*width];
error += d*d; error += d*d;
if(FFABS(width/2-x)<9 && FFABS(height/2-y)<9 && level==2) printf("%8"PRId64" ", d); if(FFABS(width/2-x)<9 && FFABS(height/2-y)<9 && level==2) printf("%8"PRId64" ", d);
} }
@ -143,5 +155,5 @@ int main(void){
} }
} }
return 0; return ret;
} }

View file

@ -255,11 +255,11 @@ static void optimize_colors(const uint8_t *block, ptrdiff_t stride,
muv = minv = maxv = bp[0]; muv = minv = maxv = bp[0];
for (y = 0; y < 4; y++) { for (y = 0; y < 4; y++) {
for (x = 4; x < 4; x += 4) { for (x = 0; x < 4; x++) {
muv += bp[x * 4 + y * stride]; muv += bp[x * 4 + y * stride];
if (bp[x] < minv) if (bp[x * 4 + y * stride] < minv)
minv = bp[x * 4 + y * stride]; minv = bp[x * 4 + y * stride];
else if (bp[x] > maxv) else if (bp[x * 4 + y * stride] > maxv)
maxv = bp[x * 4 + y * stride]; maxv = bp[x * 4 + y * stride];
} }
} }

View file

@ -100,7 +100,6 @@ typedef struct TiffContext {
int is_tiled; int is_tiled;
int tile_byte_counts_offset, tile_offsets_offset; int tile_byte_counts_offset, tile_offsets_offset;
int tile_width, tile_length; int tile_width, tile_length;
int tile_count;
int is_jpeg; int is_jpeg;
@ -759,6 +758,7 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, uint8_t *dst, int strid
if (s->is_bayer) { if (s->is_bayer) {
av_assert0(width == (s->bpp * s->width + 7) >> 3); av_assert0(width == (s->bpp * s->width + 7) >> 3);
} }
av_assert0(!(s->is_bayer && is_yuv));
if (p->format == AV_PIX_FMT_GRAY12) { if (p->format == AV_PIX_FMT_GRAY12) {
av_fast_padded_malloc(&s->yuv_line, &s->yuv_line_size, width); av_fast_padded_malloc(&s->yuv_line, &s->yuv_line_size, width);
if (s->yuv_line == NULL) { if (s->yuv_line == NULL) {
@ -842,6 +842,8 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, uint8_t *dst, int strid
av_log(s->avctx, AV_LOG_ERROR, "More than one DNG JPEG strips unsupported\n"); av_log(s->avctx, AV_LOG_ERROR, "More than one DNG JPEG strips unsupported\n");
return AVERROR_PATCHWELCOME; return AVERROR_PATCHWELCOME;
} }
if (!s->is_bayer)
return AVERROR_PATCHWELCOME;
if ((ret = dng_decode_jpeg(s->avctx, p, s->stripsize, 0, 0, s->width, s->height)) < 0) if ((ret = dng_decode_jpeg(s->avctx, p, s->stripsize, 0, 0, s->width, s->height)) < 0)
return ret; return ret;
return 0; return 0;
@ -960,6 +962,9 @@ static int dng_decode_tiles(AVCodecContext *avctx, AVFrame *frame,
int pos_x = 0, pos_y = 0; int pos_x = 0, pos_y = 0;
int ret; int ret;
if (s->tile_width <= 0 || s->tile_length <= 0)
return AVERROR_INVALIDDATA;
has_width_leftover = (s->width % s->tile_width != 0); has_width_leftover = (s->width % s->tile_width != 0);
has_height_leftover = (s->height % s->tile_length != 0); has_height_leftover = (s->height % s->tile_length != 0);
@ -968,7 +973,7 @@ static int dng_decode_tiles(AVCodecContext *avctx, AVFrame *frame,
tile_count_y = (s->height + s->tile_length - 1) / s->tile_length; tile_count_y = (s->height + s->tile_length - 1) / s->tile_length;
/* Iterate over the number of tiles */ /* Iterate over the number of tiles */
for (tile_idx = 0; tile_idx < s->tile_count; tile_idx++) { for (tile_idx = 0; tile_idx < tile_count_x * tile_count_y; tile_idx++) {
tile_x = tile_idx % tile_count_x; tile_x = tile_idx % tile_count_x;
tile_y = tile_idx / tile_count_x; tile_y = tile_idx / tile_count_x;
@ -1388,7 +1393,6 @@ static int tiff_decode_tag(TiffContext *s, AVFrame *frame)
break; break;
case TIFF_TILE_OFFSETS: case TIFF_TILE_OFFSETS:
s->tile_offsets_offset = off; s->tile_offsets_offset = off;
s->tile_count = count;
s->is_tiled = 1; s->is_tiled = 1;
break; break;
case TIFF_TILE_BYTE_COUNTS: case TIFF_TILE_BYTE_COUNTS:
@ -1744,7 +1748,7 @@ static int decode_frame(AVCodecContext *avctx,
TiffContext *const s = avctx->priv_data; TiffContext *const s = avctx->priv_data;
AVFrame *const p = data; AVFrame *const p = data;
ThreadFrame frame = { .f = data }; ThreadFrame frame = { .f = data };
unsigned off, last_off; unsigned off, last_off = 0;
int le, ret, plane, planes; int le, ret, plane, planes;
int i, j, entries, stride; int i, j, entries, stride;
unsigned soff, ssize; unsigned soff, ssize;
@ -1809,7 +1813,6 @@ again:
/** whether we should process this multi-page IFD's next page */ /** whether we should process this multi-page IFD's next page */
retry_for_page = s->get_page && s->cur_page + 1 < s->get_page; // get_page is 1-indexed retry_for_page = s->get_page && s->cur_page + 1 < s->get_page; // get_page is 1-indexed
last_off = off;
if (retry_for_page) { if (retry_for_page) {
// set offset to the next IFD // set offset to the next IFD
off = ff_tget_long(&s->gb, le); off = ff_tget_long(&s->gb, le);
@ -1827,6 +1830,7 @@ again:
avpriv_request_sample(s->avctx, "non increasing IFD offset"); avpriv_request_sample(s->avctx, "non increasing IFD offset");
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
last_off = off;
if (off >= UINT_MAX - 14 || avpkt->size < off + 14) { if (off >= UINT_MAX - 14 || avpkt->size < off + 14) {
av_log(avctx, AV_LOG_ERROR, "IFD offset is greater than image size\n"); av_log(avctx, AV_LOG_ERROR, "IFD offset is greater than image size\n");
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
@ -1883,7 +1887,7 @@ again:
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
has_tile_bits = s->is_tiled || s->tile_byte_counts_offset || s->tile_offsets_offset || s->tile_width || s->tile_length || s->tile_count; has_tile_bits = s->is_tiled || s->tile_byte_counts_offset || s->tile_offsets_offset || s->tile_width || s->tile_length;
has_strip_bits = s->strippos || s->strips || s->stripoff || s->rps || s->sot || s->sstype || s->stripsize || s->stripsizesoff; has_strip_bits = s->strippos || s->strips || s->stripoff || s->rps || s->sot || s->sstype || s->stripsize || s->stripsizesoff;
if (has_tile_bits && has_strip_bits) { if (has_tile_bits && has_strip_bits) {

View file

@ -373,8 +373,15 @@ static int tta_decode_frame(AVCodecContext *avctx, void *data,
case 3: { case 3: {
// shift samples for 24-bit sample format // shift samples for 24-bit sample format
int32_t *samples = (int32_t *)frame->data[0]; int32_t *samples = (int32_t *)frame->data[0];
for (i = 0; i < framelen * s->channels; i++) int overflow = 0;
*samples++ *= 256;
for (i = 0; i < framelen * s->channels; i++) {
int scaled = *samples * 256U;
overflow += (scaled >> 8 != *samples);
*samples++ = scaled;
}
if (overflow)
av_log(avctx, AV_LOG_WARNING, "%d overflows occurred on 24bit upscale\n", overflow);
// reset decode buffer // reset decode buffer
s->decode_buffer = NULL; s->decode_buffer = NULL;
break; break;

View file

@ -238,6 +238,8 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
case AV_PIX_FMT_GBRAP16BE: case AV_PIX_FMT_GBRAP16BE:
w_align = 16; //FIXME assume 16 pixel per macroblock w_align = 16; //FIXME assume 16 pixel per macroblock
h_align = 16 * 2; // interlaced needs 2 macroblocks height h_align = 16 * 2; // interlaced needs 2 macroblocks height
if (s->codec_id == AV_CODEC_ID_BINKVIDEO)
w_align = 16*2;
break; break;
case AV_PIX_FMT_YUV411P: case AV_PIX_FMT_YUV411P:
case AV_PIX_FMT_YUVJ411P: case AV_PIX_FMT_YUVJ411P:
@ -316,6 +318,7 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
*width = FFALIGN(*width, w_align); *width = FFALIGN(*width, w_align);
*height = FFALIGN(*height, h_align); *height = FFALIGN(*height, h_align);
if (s->codec_id == AV_CODEC_ID_H264 || s->lowres || 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_VP5 || s->codec_id == AV_CODEC_ID_VP6 ||
s->codec_id == AV_CODEC_ID_VP6F || s->codec_id == AV_CODEC_ID_VP6A s->codec_id == AV_CODEC_ID_VP6F || s->codec_id == AV_CODEC_ID_VP6A
) { ) {
@ -329,6 +332,9 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
// the next rounded up width is 32 // the next rounded up width is 32
*width = FFMAX(*width, 32); *width = FFMAX(*width, 32);
} }
if (s->codec_id == AV_CODEC_ID_SVQ3) {
*width = FFMAX(*width, 32);
}
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
linesize_align[i] = STRIDE_ALIGN; linesize_align[i] = STRIDE_ALIGN;

View file

@ -153,6 +153,21 @@ static inline void v4l2_save_to_context(V4L2Context* ctx, struct v4l2_format_upd
} }
} }
static int v4l2_start_decode(V4L2Context *ctx)
{
struct v4l2_decoder_cmd cmd = {
.cmd = V4L2_DEC_CMD_START,
.flags = 0,
};
int ret;
ret = ioctl(ctx_to_m2mctx(ctx)->fd, VIDIOC_DECODER_CMD, &cmd);
if (ret)
return AVERROR(errno);
return 0;
}
/** /**
* handle resolution change event and end of stream event * handle resolution change event and end of stream event
* returns 1 if reinit was successful, negative if it failed * returns 1 if reinit was successful, negative if it failed
@ -162,9 +177,8 @@ static int v4l2_handle_event(V4L2Context *ctx)
{ {
V4L2m2mContext *s = ctx_to_m2mctx(ctx); V4L2m2mContext *s = ctx_to_m2mctx(ctx);
struct v4l2_format cap_fmt = s->capture.format; struct v4l2_format cap_fmt = s->capture.format;
struct v4l2_format out_fmt = s->output.format;
struct v4l2_event evt = { 0 }; struct v4l2_event evt = { 0 };
int full_reinit, reinit, ret; int reinit, ret;
ret = ioctl(s->fd, VIDIOC_DQEVENT, &evt); ret = ioctl(s->fd, VIDIOC_DQEVENT, &evt);
if (ret < 0) { if (ret < 0) {
@ -180,44 +194,25 @@ static int v4l2_handle_event(V4L2Context *ctx)
if (evt.type != V4L2_EVENT_SOURCE_CHANGE) if (evt.type != V4L2_EVENT_SOURCE_CHANGE)
return 0; return 0;
ret = ioctl(s->fd, VIDIOC_G_FMT, &out_fmt);
if (ret) {
av_log(logger(ctx), AV_LOG_ERROR, "%s VIDIOC_G_FMT\n", s->output.name);
return 0;
}
ret = ioctl(s->fd, VIDIOC_G_FMT, &cap_fmt); ret = ioctl(s->fd, VIDIOC_G_FMT, &cap_fmt);
if (ret) { if (ret) {
av_log(logger(ctx), AV_LOG_ERROR, "%s VIDIOC_G_FMT\n", s->capture.name); av_log(logger(ctx), AV_LOG_ERROR, "%s VIDIOC_G_FMT\n", s->capture.name);
return 0; return 0;
} }
full_reinit = v4l2_resolution_changed(&s->output, &out_fmt);
if (full_reinit) {
s->output.height = v4l2_get_height(&out_fmt);
s->output.width = v4l2_get_width(&out_fmt);
s->output.sample_aspect_ratio = v4l2_get_sar(&s->output);
}
reinit = v4l2_resolution_changed(&s->capture, &cap_fmt); reinit = v4l2_resolution_changed(&s->capture, &cap_fmt);
if (reinit) { if (reinit) {
s->capture.height = v4l2_get_height(&cap_fmt); s->capture.height = v4l2_get_height(&cap_fmt);
s->capture.width = v4l2_get_width(&cap_fmt); s->capture.width = v4l2_get_width(&cap_fmt);
s->capture.sample_aspect_ratio = v4l2_get_sar(&s->capture); s->capture.sample_aspect_ratio = v4l2_get_sar(&s->capture);
} else {
v4l2_start_decode(ctx);
return 0;
} }
if (full_reinit || reinit) if (reinit)
s->reinit = 1; s->reinit = 1;
if (full_reinit) {
ret = ff_v4l2_m2m_codec_full_reinit(s);
if (ret) {
av_log(logger(ctx), AV_LOG_ERROR, "v4l2_m2m_codec_full_reinit\n");
return AVERROR(EINVAL);
}
goto reinit_run;
}
if (reinit) { if (reinit) {
if (s->avctx) if (s->avctx)
ret = ff_set_dimensions(s->avctx, s->capture.width, s->capture.height); ret = ff_set_dimensions(s->avctx, s->capture.width, s->capture.height);

View file

@ -73,8 +73,9 @@ static int vdpau_mpeg_start_frame(AVCodecContext *avctx,
info->f_code[1][0] = s->mpeg_f_code[1][0]; info->f_code[1][0] = s->mpeg_f_code[1][0];
info->f_code[1][1] = s->mpeg_f_code[1][1]; info->f_code[1][1] = s->mpeg_f_code[1][1];
for (i = 0; i < 64; ++i) { for (i = 0; i < 64; ++i) {
info->intra_quantizer_matrix[i] = s->intra_matrix[i]; int n = s->idsp.idct_permutation[i];
info->non_intra_quantizer_matrix[i] = s->inter_matrix[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); 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->alternate_vertical_scan_flag = s->alternate_scan;
info->top_field_first = s->top_field_first; info->top_field_first = s->top_field_first;
for (i = 0; i < 64; ++i) { for (i = 0; i < 64; ++i) {
info->intra_quantizer_matrix[i] = s->intra_matrix[i]; int n = s->idsp.idct_permutation[i];
info->non_intra_quantizer_matrix[i] = s->inter_matrix[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); ff_vdpau_common_start_frame(pic_ctx, buffer, size);

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