Compare commits

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

562 commits

Author SHA1 Message Date
Marton Balint
56a67d122c avfilter/split: consume all frames before forwarding inlink status
Signed-off-by: Marton Balint <cus@passwd.hu>
(cherry picked from commit 28a7b9c863)
2025-07-06 23:00:01 +02:00
Paul B Mahol
f6efc1e8aa avfilter/split: fix EOF passing to inlink
(cherry picked from commit 374184a4dc)
2025-07-06 22:59:48 +02:00
Paul B Mahol
e09bd41752 avfilter/avfiltergraph: fix regression in picking channel layout
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 1b3f4842c1)
2025-05-22 19:42:33 -03:00
Marton Balint
b791523bb9 avformat/wavdec: increase requested probe score for codec probe
Codec probing was primarily added to the wav demuxer to support DTS-in-wav
files, but DTS probing functions return AVPROBE_SCORE_EXTENSION+1, so we can be
a bit more strict with the required score.

This fixes MP3 misdetections for some wav files.

Fixes ticket #11581.

Signed-off-by: Marton Balint <cus@passwd.hu>
(cherry picked from commit ce01c7fb58)
2025-05-17 22:00:33 +02:00
James Almer
cb46a09750 doc/resampler.texi: add missing swr channel layout options
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 1d14959f12)
2025-04-30 01:32:04 +02:00
Paul B Mahol
f868ded795 swresample/swresample_frame: fix regression in detecting changes
Do not overwrite return variable values, instead use different
one for checking results.

(cherry picked from commit 99bd2dbc91)
2025-04-30 01:32:04 +02:00
Brad Smith
c0067757ab 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:39:09 -04:00
Brad Smith
6ad0eab0b5 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:38:36 -04:00
Pavel Koshevoy
01af45c0f3 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:03 -07:00
Martin Storsjö
1bcb1be4a2 configure: Improve the check for the rsync --contimeout option
Traditionally, macOS has shipped an old version of rsync that lacked
support for this option, hence this check (added in
a8b3f0c5cf).

However, in macOS 15.x, Apple have switched to providing rsync as a
different tool, openrsync. The version of openrsync in at least
macOS 15.2 does include "[--contimeout]" (note the lack of "=" after
the option), in the output of "rsync --help", but when used, the tool
errors out with "rsync: --contimeout=60: unknown option". So apparently
the tool erroenously lists the option as supported, while it really
isn't.

The original rsync tool (with a new enough version) prints
"--contimeout=SECONDS" in the output of "rsync --help".

It is unclear which version of openrsync Apple are shipping; the latest
upstream openrsync from OpenBSD does support the option and includes
"[--contimeout=seconds]" in the output of "--help", and older versions
don't seem to include the option as listed at all.

Therefore, check for "--conntimeout=" with the "=", this should
properly detect both new enough rsync and openrsync.

This fixes running "fate-rsync" on macOS 15.x.

Signed-off-by: Martin Storsjö <martin@martin.st>
(cherry picked from commit 3cd4e8470a)
2025-02-11 10:35:55 +02:00
Martin Storsjö
7c954bf682 rtmpproto: Avoid rare crashes in the fail: codepath in rtmp_open
When running the cleanup in rtmp_close on failures in rtmp_open,
we can in rare cases end up using rt->playpath, assuming that it
is still set.

The crash could happen if we hit the fail codepath in rtmp_open
while publishing (rt->is_input == 0) with rt->state set to
a value > STATE_FCPUBLISH.

This would normally not happen while publishing; either we have
an error (and rt->state <= STATE_FCPUBLISH) or we reach
rt->state = STATE_PUBLISHING, and then we also return successfully
from rtmp_open.

The unexpected combination of states could happen if the server
responds with e.g. "NetStream.Play.Stop" while expecting
"NetStream.Publish.Start"; this sets rt->state to STATE_STOPPED,
which also fulfills the condition "> STATE_FCPUBLISH".

We don't need to free the rt->playpath/tcurl/flashver strings here;
they're handled via AVOption, and thus are freed automatically when
the protocol instance is freed (that's why they aren't freed
manually within the rtmp_close function either).

We also don't need to free the AVDictionary with options; it's
owned by the caller.

A smaller fix would be to just call rtmp_close before freeing
the strings and dictionary, but as we don't need to free them
at all, let's remove that redundant code.

Signed-off-by: Martin Storsjö <martin@martin.st>
(cherry picked from commit 8f4819ce01)
2025-02-11 10:35:04 +02:00
Bin Peng
6e63e49496 lavc/aarch64: Fix ff_pred16x16_plane_neon_10
Fix test failure on aarch64:
./tests/checkasm/checkasm --test=h264pred 367840

Signed-off-by: Peng Bin <pengbin@visionular.com>
Signed-off-by: Martin Storsjö <martin@martin.st>
(cherry picked from commit 72a3656e84)
2025-01-07 22:48:06 +02:00
Bin Peng
941b05ab56 lavc/aarch64: Fix ff_pred8x8_plane_neon_10
Fix test failure on aarch64:
./tests/checkasm/checkasm --test=h264pred 479612

The mismatch between neon and C functions can also be reproduced using the following bitstream and command line.

wget https://streams.videolan.org/ffmpeg/incoming/intra8x8pred_10bit.264
 ./ffmpeg -cpuflags 0  -threads 1 -i intra8x8pred_10bit.264  -f framemd5 -y md5_ref
 ./ffmpeg              -threads 1 -i intra8x8pred_10bit.264  -f framemd5 -y md5_neon

Signed-off-by: Bin Peng <pengbin@visionular.com>
Signed-off-by: Martin Storsjö <martin@martin.st>
(cherry picked from commit decc9e643c)
2025-01-07 22:48:06 +02:00
Janne Grunau
14afc43c27 vp9: recon: Use emulated edge to prevent buffer overflows
The arm/aarch64 horizontal filter reads one additional pixel beyond what
the filter uses. This can become an issue if the application does not
allocate larger buffers than what's required for the pixel data. If the
motion vector points to the bottom right edge of the picture this
becomes a read buffer overflow. This triggers segfaults in Firefox for
video resolutions which result in a page aligned picture size like
1280x640.
Prevent this by using emulated edge in this case.

Fixes: https://bugzilla.mozilla.org/show_bug.cgi?id=1881185
Signed-off-by: Janne Grunau <janne-ffmpeg@jannau.net>
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
(cherry picked from commit 060464105b)
2025-01-04 07:31:13 -05:00
Janne Grunau
3562311c30 arm: vp9mc: Load only 12 pixels in the 4 pixel wide horizontal filter
This reduces the amount the horizontal filters read beyond the filter
width to a consistent 1 pixel. The data is not used so this is usually
not noticeable. It becomes a problem when the application allocates
frame buffers only for the aligned picture size and the end of it is at
a page boundary. This happens for picture sizes which are a multiple of
the page size like 1280x640. The frame buffer allocation is based on
its most likely done via mmap + MAP_ANONYMOUS so start and end of the
buffer are page aligned and the previous and next page are not
necessarily mapped.
This mirrors the aarch64 change.

Signed-off-by: Janne Grunau <janne-ffmpeg@jannau.net>
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
(cherry picked from commit f366256215)
2025-01-04 07:31:13 -05:00
Janne Grunau
0dac8251f7 aarch64: vp9mc: Load only 12 pixels in the 4 pixel wide horizontal filter
This reduces the amount the horizontal filters read beyond the filter
width to a consistent 1 pixel. The data is not used so this is usually
not noticeable. It becomes a problem when the application allocates
frame buffers only for the aligned picture size and the end of it is at
a page boundary. This happens for picture sizes which are a multiple of
the page size like 1280x640. The frame buffer allocation is based on
its most likely done via mmap + MAP_ANONYMOUS so start and end of the
buffer are page aligned and the previous and next page are not
necessarily mapped.
Under these conditions like seen by Firefox a read beyond the end of the
buffer results in a segfault.
After the over-read is reduced to a single pixel it's reasonable to use
VP9's emulated edge motion compensation for this.

Fixes: https://bugzilla.mozilla.org/show_bug.cgi?id=1881185
Signed-off-by: Janne Grunau <janne-ffmpeg@jannau.net>
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
(cherry picked from commit 430c38f698)
2025-01-04 07:31:12 -05:00
Marton Balint
cde3c5fc0c avfilter/f_loop: fix aloop activate logic
The logic did not follow the documented behaviour and that caused skipping of
some audio in the loop and in the leftover buffer.

Example command line which should produce a smooth sine wave for the whole
duration of the output:

ffmpeg -f lavfi -i "sine=r=48000:f=480:d=4" -af "aloop=loop=4:start=48000:size=48000" out.wav

Fixes ticket #11283.

Signed-off-by: Marton Balint <cus@passwd.hu>
(cherry picked from commit fe18ed3f2a)
2024-11-17 22:54:08 +01:00
Marton Balint
ff0f25a154 avfilter/f_loop: fix length of aloop leftover buffer
If the audio loop stops inside an audio frame, the leftover buffer contains the
end of the frame, which is not looped. The length supposed to be the part which
was not written to the loop buffer, so we need to drain exactly that number of
bytes from the leftover buffer.

Signed-off-by: Marton Balint <cus@passwd.hu>
(cherry picked from commit b33a594160)
2024-11-17 22:39:23 +01:00
Marton Balint
dcdfd7fb62 avutil/wchar_filename: re-introduce explicit cast of void* to char*
Fixes compile error on windows with decklink:

In file included from ./libavformat/os_support.h:175,
                 from ./libavformat/internal.h:30,
                 from libavdevice/decklink_common.cpp:25:
./libavutil/wchar_filename.h: In function 'int wchartocp(unsigned int, const wchar_t*, char**)':
./libavutil/wchar_filename.h:59:32: error: invalid conversion from 'void*' to 'char*' [-fpermissive]
   59 |     *filename = av_malloc_array(num_chars, sizeof **filename);
      |                 ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                |
      |                                void*

Regression since e9e8bea2e7.

Fixes ticket #11103.

Signed-off-by: Marton Balint <cus@passwd.hu>
(cherry picked from commit 9b0128aa76)
2024-10-27 10:00:43 +01:00
Gyan Doshi
768807492d 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:01 +02:00
Gyan Doshi
4ce4ecc19c 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:46:40 +02:00
Marton Balint
17e84a454e avformat/libzmq: fix check for zmq protocol prefix
Fixes ticket #11134.

Signed-off-by: Marton Balint <cus@passwd.hu>
(cherry picked from commit a87a96105e)
2024-09-02 23:28:11 +02:00
Ramiro Polla
ed09f56097 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:12:39 -04:00
Ramiro Polla
df5a848c83 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:12:15 -04:00
Brad Smith
12e308b66d 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:45:10 -04:00
Timo Rothenpieler
0e8b267a97 avformat/hlsenc: correctly reset subtitle stream counter per-varstream
Without resetting it, if there was a previous set of varstreams with
subtitles, it would subtract from all the streams, leading to chaos and
segfaults when trying to access for example stream -1.
2024-08-16 20:26:56 +02:00
Ross Burton
e466f0dbad libavcodec/arm/mlpdsp_armv5te: fix label format to work with binutils 2.43
binutils 2.43 has stricter validation for labels[1] and results in errors
when building ffmpeg for armv5:

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

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

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

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Martin Storsjö <martin@martin.st>
(cherry picked from commit 654bd47716)
2024-08-16 13:48:04 +03:00
Michael Niedermayer
6338d19eb3
Changelog: update
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-08-05 00:41:42 +02:00
Michael Niedermayer
8c689f4d0c
avcodec/snow: Fix off by 1 error in run_buffer
Fixes: out of array access
Fixes: 70741/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SNOW_fuzzer-5703668010647552

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 06f5ed40f8)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-08-01 00:28:09 +02:00
Michael Niedermayer
999c1619f9
avcodec/utils: apply the same alignment to YUV410 as we do to YUV420 for snow
The snow encoder uses block based motion estimation which can read out of array if
insufficient alignment is used

It may be better to only apply this for the encoder, as it would safe a few bytes of memory
for the decoder. Until then, this fixes the issue in a simple way.

Fixes: out of array access
Fixes: 68963/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SNOW_fuzzer-4979988435632128
Fixes: 68969/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SNOW_fuzzer-6239933667803136.fuzz
Fixed: 70497/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SNOW_fuzzer-5751882631413760

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 58fbeb59e7)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-08-01 00:27:21 +02:00
James Almer
a937b3c58b
swsresample/swresample: error out on invalid layouts
If it's unsupported or invalid, then there's no point trying to rebuild it
using a value that may have been derived from the same layout to begin with.

Move the checks before the attempts at copying the layout while at it.

Fixes ticket #9908.

Signed-off-by: James Almer <jamrial@gmail.com>

Fixes: out of array acces
Fixes: poc5
Fixes: poc6

Reported-by: VulDB CNA Team
Found-by: CookedMelon
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-29 23:52:50 +02:00
Michael Niedermayer
8fdfc290ae
Update for 5.1.6
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-25 20:30:30 +02:00
Jens Frederich
bf5fd7a5cf
avdevice/dshow: Don't skip audio devices if no video device is present
The search of the current DirectShow device list has been customized so
that audio devices are always found even if no video device is connected.

Signed-off-by: Jens Frederich <jens.frederich@vector.com>
Reviewed-by: Roger Pack <rogerdpack2@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 60b1750134)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-24 14:47:51 +02:00
Michael Niedermayer
2b82e33f4b
avcodec/cfhdenc: Height of 16 is not supported
Fixes: out of array access
Fixes: 68941/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-5990952685600768

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 5dde255abd)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-24 14:28:32 +02:00
Michael Niedermayer
e3c5099ec9
avcodec/cfhdenc: Allocate more space
Fixes: Assertion failure
Fixes: 68979/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-5375874714107904

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 a308d79e4d)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-24 14:24:16 +02:00
Michael Niedermayer
9acf04761d
avcodec/vaapi_encode: Check hwctx
Fixes: null pointer dereference
Fixes: 70376/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_H264_VAAPI_fuzzer-4733551250046976

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 3cd077e282)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-24 14:21:44 +02:00
Michael Niedermayer
5bc8490216
avcodec/proresdec: Consider negative bits left
Fixes: 70036/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PRORES_fuzzer-6298797647396864
Fixes: shift exponent 40 is too large for 32-bit type 'uint32_t' (aka 'unsigned 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 419eee6356)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-24 14:19:33 +02:00
Michael Niedermayer
1165dc610e
avcodec/alsdec: Clear shift_value
(the exact issue is unreproducable but the use of uninitialized data is reproducable)

Should fix: signed integer overflow: -2147483648 - 127 cannot be represented in type 'int'
Should fix: 69881/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALS_fuzzer-4751301204836352

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 6194cb87cb)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-24 14:16:16 +02:00
Michael Niedermayer
9dbed2ef83
avcodec/hevc/hevcdec: Do not allow slices to depend on failed slices
An alternative would be to leave the context unchanged on failure of hls_slice_header()

Fixes: out of array access
Fixes: NULL pointer dereference
Fixes: 69584/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-5931086299856896
Fixes: 69724/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-5104066422702080
Fixes: 70422/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-5908731129298944

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 5d9544cfb0)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-24 01:02:59 +02:00
Michael Niedermayer
f09c9749ac
avutil/slicethread: Check pthread_*_init() for failure
Fixes: CID1604383 Unchecked return value
Fixes: CID1604439 Unchecked return value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 23851c9ee0)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-22 16:30:01 +02:00
Michael Niedermayer
62f5e89d77
avutil/frame: Check log2_crop_align
Fixes: CID1604586 Overflowed constant

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 15540b3d28)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-22 16:28:59 +02:00
Michael Niedermayer
e1e3ebfc38
avutil/buffer: Check ff_mutex_init() for failure
Fixes: CID1604487 Unchecked return value
Fixes: CID1604494 Unchecked return value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 82f5b20ff5)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-22 16:28:30 +02:00
Michael Niedermayer
6381da354b
avformat/xmv: Check this_packet_size
Fixes: CID1604489 Overflowed constant

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 696685df0c)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-22 16:27:37 +02:00
Michael Niedermayer
5217c7bf7f
avformat/ty: rec_size seems to only need 32bit
May help CID1604560 Overflowed integer argument

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit be30913538)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-22 16:27:06 +02:00
Michael Niedermayer
03f12a4c47
avformat/tty: Check avio_size()
Fixes: CID1220824 Overflowed constant

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 41745e550a)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-22 16:26:48 +02:00
Michael Niedermayer
a1ef7e86a3
avformat/siff: Basic pkt_size check
Fixes: half of CID1258461 Overflowed constant

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 124a97dd8b)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-22 16:26:15 +02:00
Michael Niedermayer
29d4c0f70d
avformat/sauce: Check avio_size() for failure
Fixes: CID1604592 Overflowed constant

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 759aae590c)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-22 16:25:37 +02:00
Michael Niedermayer
76a059b6b2
avformat/sapdec: Check ffurl_get_file_handle() for error
Fixes: CID1604506 Overflowed constant

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 3e305a0e70)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-22 16:24:47 +02:00
Michael Niedermayer
5902cab5dd
avformat/nsvdec: Check asize for PCM
Fixes: CID1604527 Overflowed constant

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit e83e246504)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-22 16:24:27 +02:00
Michael Niedermayer
617c635d04
avformat/mp3dec: Check header_filesize
Fixes: CID1608714 Division or modulo by float zero

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit cea4dbc903)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-22 16:24:00 +02:00
Michael Niedermayer
a3b4e8156c
avformat/mp3dec; Check for avio_size() failure
Fixes: CID1608710 Improper use of negative value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit bb936a1a72)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-22 16:23:23 +02:00
Michael Niedermayer
532f504642
avformat/mov: Use 64bit for str_size
We assign a 64bit variable to it before checking

Fixes: CID1604544 Overflowed integer argument

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 046d069552)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-22 16:22:58 +02:00
Michael Niedermayer
61306c1f51
avformat/mm: Check length
Fixes: CID1220824 Overflowed constant

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 139bf41246)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-22 16:22:15 +02:00
Michael Niedermayer
e8f477a5f1
avformat/hnm: Check *chunk_size
Fixes: CID1604419 Overflowed constant

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 291356f58b)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-22 16:21:49 +02:00
Michael Niedermayer
a44dbb58fa
avformat/hlsenc: Check ret
Fixes: CID1609624 Unused value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 7e577165c1)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-22 14:50:39 +02:00
Michael Niedermayer
a39cbdbd67
avformat/bintext: Check avio_size() return
Fixes: CID1604503 Overflowed constant
Fixes: CID1604566 Overflowed constant

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit bf61f811e7)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-22 14:50:20 +02:00
Michael Niedermayer
f32f82b421
avformat/asfdec_o: Check size of index object
We subtract 24 so it must be at least 24

Fixes: CID1604482 Overflowed constant

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 891bc070f0)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-22 14:49:47 +02:00
Michael Niedermayer
d63a35fcf1
avfilter/vf_scale: Check ff_scale_adjust_dimensions() for failure
Helps: CID1513722 Operands don't affect result

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 2a8fb3c2cc)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-22 14:24:19 +02:00
Michael Niedermayer
a579bc48ec
avfilter/scale_eval: Use 64bit, check values in ff_scale_adjust_dimensions()
Found by reviewing CID1513722 Operands don't affect result

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit ad9df8bcfe)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-22 10:49:30 +02:00
Michael Niedermayer
f3600aff21
avfilter/vf_lut3d: Check av_scanf()
Fixes: CID1604398 Unchecked return value
Fixes: CID1604542 Unchecked return value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit ace2e25720)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-22 10:47:13 +02:00
Michael Niedermayer
b07d36fe69
avfilter/vf_elbg: Use unsigned for shifting into the top bit
Fixes: part of CID1355110 Overflowed constant

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 2af95b9214)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-22 10:46:30 +02:00
Michael Niedermayer
0f843c76ee
avfilter/vf_deshake_opencl: Ensure that the first iteration initializes the best variables
Fixes: CID1452759 Uninitialized scalar variable

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 9385847af4)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-22 10:45:22 +02:00
Michael Niedermayer
bb40556df4
swscale/output: Fix integer overflows in yuv2rgba64_X_c_template
Fixes: signed integer overflow: -1082982400 + -1068681048 cannot be represented in type 'int'
Fixes: 69995/clusterfuzz-testcase-minimized-ffmpeg_SWS_fuzzer-6285740271534080

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 bcab9789ef)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-22 10:42:21 +02:00
Michael Niedermayer
3b253df309
avformat/mxfdec: Reorder elements of expression in bisect loop
Fixes: signed integer overflow: 9223372036854775807 - -1 cannot be represented in type 'long'
Fixes: 68578/clusterfuzz-testcase-minimized-ffmpeg_dem_MXF_fuzzer-6032171648221184

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 d8d288479d)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-22 01:18:32 +02:00
Michael Niedermayer
46161ba1a9
avutil/timecode: Use a 64bit framenum internally
Fixes: negation of -2147483648 cannot be represented in type 'int'; cast to an unsigned type to negate this value to itself
Fixes: 68550/clusterfuzz-testcase-minimized-ffmpeg_dem_MXF_fuzzer-6424065930756096

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 d5ca373d7e)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-22 01:18:15 +02:00
Michael Niedermayer
5372bfe01e
avcodec/pnmdec: Use 64bit for input size check
Fixes: out of array read
Fixes: poc3

Reported-by: VulDB CNA Team
Found-by: CookedMelon
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 3faadbe2a2)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-22 01:12:41 +02:00
Michael Niedermayer
47c6e5f1b3
avcodec/mpeg12enc: Use av_rescale() in vbv_buffer_size computation
Fixes: signed integer overflow: 20 * 2314885530818453759 cannot be represented in type 'long'
Fixes: 69098/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPEG2VIDEO_fuzzer-6107989688778752

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 0993ef675f)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-22 01:10:50 +02:00
Michael Niedermayer
e542e1b8f7
avcodec/utvideoenc: Use unsigned shift to build flags
Fixes: left shift of 255 by 24 places cannot be represented in type 'int'
Fixes: 69083/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_UTVIDEO_fuzzer-5608202363273216

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 69e90491f1)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-22 01:09:41 +02:00
Michael Niedermayer
19af012dac
avcodec/vc2enc: Fix overflows with storing large values
Fixes: left shift of 1431634944 by 2 places cannot be represented in type 'int'
Fixes: left shift of 1073741824 by 1 places cannot be represented in type 'int'
Fixes: 69061/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC2_fuzzer-6325700826038272

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 af99358353)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-22 01:07:43 +02:00
Michael Niedermayer
9e2f1e8a6e
avcodec/mpegvideo_enc: Do not duplicate pictures on shifting
Fixes: out of array access
Fixes: 69098/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPEG2VIDEO_fuzzer-6107989688778752
Fixes: 69599/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPEG4_fuzzer-4848626296225792.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 9c8881cb35)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-22 01:07:02 +02:00
Michael Niedermayer
26ec1d1afb
avdevice/dshow_capture: Fix error handling in ff_dshow_##prefix##_Create()
Untested, needs review

Fixes: CID1591856 Resource leak
Fixes: CID1591887 Resource leak
Fixes: CID1591874 Resource leak

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 348968e9f7)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-22 01:05:28 +02:00
Michael Niedermayer
dfb67d9dab
avcodec/tiff: Check value on positive signed targets
Fixes: CID1604593 Overflowed constant

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 66d6b8033b)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-22 01:05:04 +02:00
Michael Niedermayer
7481e2bb30
avfilter/vf_convolution_opencl: Assert that the filter name is one of the filters
Helps with: CID1439572 Uninitialized pointer read

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 19a5a8997c)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-22 01:04:24 +02:00
Michael Niedermayer
1264f27110
avfilter/vf_bm3d: Dont round MSE2SSE to an integer
Fixes: CID1439581 Result is not floating-point

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit ec18ec9fc1)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 22:24:11 +02:00
Michael Niedermayer
bff5c102b3
avdevice/dshow: Remove NULL check on pin
The pointer is used before the check

Fixes: CID1591884 Dereference before null check

Sponsored-by: Sovereign Tech Fund
Reviewed-by: Roger Pack <rogerdpack@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 989e11acb6)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 22:23:08 +02:00
Michael Niedermayer
672314f46f
avdevice/dshow: check ff_dshow_pin_ConnectionMediaType() for failure
Maybe Fixes: CID1598557 Explicit null dereferenced

Sponsored-by: Sovereign Tech Fund
Reviewed-by: Roger Pack <rogerdpack@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 2c2e727088)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 22:22:55 +02:00
Michael Niedermayer
2a0253d066
avdevice/dshow: Check device_filter_unique_name before use
Fixes: CID1591931 Explicit null dereferenced

Sponsored-by: Sovereign Tech Fund
Reviewed-by: Roger Pack <rogerdpack@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 175c191668)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 22:22:33 +02:00
Michael Niedermayer
374a5f8b0a
avdevice/dshow: Cleanup also on av_log case
Fixes: CID1598550 Resource leak

Sponsored-by: Sovereign Tech Fund
Reviewed-by: Roger Pack <rogerdpack@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 25f9211bdd)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 22:22:19 +02:00
Michael Niedermayer
4ae285a773
avdevice/dshow_filter: Use wcscpy_s()
Fixes: CID1591929 Copy into fixed size buffer

Sponsored-by: Sovereign Tech Fund
Reviewed-by: Roger Pack <rogerdpack@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit daf61dddc8)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 22:21:28 +02:00
Michael Niedermayer
062862fe39
avcodec/flac_parser: Assert that we do not overrun the link_penalty array
Helps: CID1454676 Out-of-bounds read

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 9af348bd1a)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 22:20:26 +02:00
Michael Niedermayer
e607479d3c
avcodec/pixlet: Simplify pfx computation
Found by reviewing code related to CID1604365 Overflowed constant

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 0474614e6c)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 22:19:14 +02:00
Michael Niedermayer
d16caed6b1
avcodec/motion_est: Fix score squaring overflow
Fixes: CID1604552 Overflowed constant

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit f18b442370)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 22:18:29 +02:00
Michael Niedermayer
c0cb0d5418
avcodec/loco: Check loco_get_rice() for failure
Fixes: CID1604495 Overflowed constant

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit d553276843)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 22:16:34 +02:00
Michael Niedermayer
525bb4cbc0
avcodec/loco: check get_ur_golomb_jpegls() for failure
Fixes: CID1604400 Overflowed constant

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit b989986641)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 22:16:06 +02:00
Michael Niedermayer
569b678653
avcodec/imm4: check cbphi for error
Fixes: CID1604356 Overflowed constant
Fixes: CID1604573 Overflowed constant

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 6e4c037833)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 22:14:11 +02:00
Michael Niedermayer
94b3f8f30b
avcodec/iff: Use signed count
This is more a style fix than a bugfix (CID1604392 Overflowed constant)

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit cfe66dfebb)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 22:12:44 +02:00
Michael Niedermayer
007191cdc4
avcodec/golomb: Assert that k is in the supported range for get_ur/sr_golomb()
Found by code review related to CID1604563 Overflowed return value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit b2aaeb81f6)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 22:11:19 +02:00
Michael Niedermayer
e75bc11027
avcodec/golomb: Document return for get_ur_golomb_jpegls() and get_sr_golomb_flac()
Found while reviewing code related to CID1604409 Overflowed return value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 7cf5b83f6f)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 21:45:54 +02:00
Michael Niedermayer
2f0931a418
avcodec/dxv: Fix type in get_opcodes()
Found by code review related to CID1604386 Overflowed constant

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit e5af1c6e91)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 21:45:37 +02:00
Michael Niedermayer
f12e4ea885
avcodec/cri: Check length
Fixes: CID1604394 Overflowed constant

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 69dcd123f1)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 21:45:15 +02:00
Michael Niedermayer
8cc5348df6
avcodec/xsubdec: Check parse_timecode()
Fixes: CID1604490 Overflowed constant

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 96fd9417e2)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 21:44:52 +02:00
Michael Niedermayer
5fd805dfb4
avutil/imgutils: av_image_check_size2() ensure width and height fit in 32bit
width and height > 32bit is not supported and its easier to check in a central place

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit ba63e32957)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 21:44:06 +02:00
Michael Niedermayer
c7e8baeb75
doc/examples/mux: remove nop
Found through code review related to CID1604493 Overflowed constant

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit e6c0c5731e)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 21:43:28 +02:00
Michael Niedermayer
0300b1dcde
avcodec/proresenc_kostya: use unsigned alpha for rotation
Fixes: left shift of negative value -208
Fixes: 69073/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PRORES_KS_fuzzer-4745020002336768

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 93e0265e27)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 21:42:56 +02:00
Michael Niedermayer
4be6ff8823
avformat/rtpenc_rfc4175: Use 64bit in computation if copy_offset
Found while reviewing: CID1494441 Untrusted value as argument

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit f13ae63259)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 21:42:38 +02:00
Michael Niedermayer
a8c4967416
avformat/rtmppkt: Simplify and deobfuscate amf_tag_skip() slightly
Found while reviewing: CID1530313 Untrusted loop bound

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit cedbef0394)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 21:41:41 +02:00
Michael Niedermayer
40c9fb918a
avformat/rmdec: use 64bit for audio_framesize checks
It is not entirely clear what would prevent such overflow so even if it is
not possible, it is better to use 64bit

Fixes: CID1491898 Unintentional integer overflow

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 665be4fa2f)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 21:40:52 +02:00
Michael Niedermayer
0e5c0a6178
avutil/wchar_filename: Correct sizeof
Fixes: CID1591930 Wrong sizeof argument

Sponsored-by: Sovereign Tech Fund
Reviewed-by: Steve Lhomme <robux4@ycbcr.xyz>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit e9e8bea2e7)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 21:40:40 +02:00
Michael Niedermayer
0362214b1c
avutil/hwcontext_d3d11va: correct sizeof IDirect3DSurface9
Fixes: CID1591944 Wrong sizeof argument

Sponsored-by: Sovereign Tech Fund
Reviewed-by: Steve Lhomme <robux4@ycbcr.xyz>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 628ba061c8)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 21:40:09 +02:00
Michael Niedermayer
ea48c665d1
avutil/hwcontext_d3d11va: Free AVD3D11FrameDescriptor on error
Fixes: CID1598558 Resource leak

Sponsored-by: Sovereign Tech Fund
Reviewed-by: Steve Lhomme <robux4@ycbcr.xyz>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit cf22f944d5)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 21:39:57 +02:00
Michael Niedermayer
f55dbd882f
avutil/hwcontext_d3d11va: correct sizeof AVD3D11FrameDescriptor
Fixes: CID1591909 Wrong sizeof argument

Sponsored-by: Sovereign Tech Fund
Reviewed-by: Steve Lhomme <robux4@ycbcr.xyz>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 698ed0d5a5)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 21:39:39 +02:00
Michael Niedermayer
16a0e979e7
doc/examples/vaapi_encode: Try to check fwrite() for failure
Fixes: CID1604548 Unused value

Sponsored-by: Sovereign Tech Fund
Reviewed-by: "Xiang, Haihao" <haihao.xiang-at-intel.com@ffmpeg.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 3e4bfff211)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 21:39:07 +02:00
Michael Niedermayer
2528ab4895
avformat/tls_schannel: Initialize ret
Fixes: CID1591881 Uninitialized scalar variable

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit f022afea77)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 21:36:42 +02:00
Michael Niedermayer
a19d3de12a
avformat/subfile: Assert that whence is a known case
This may help CID1452449 Uninitialized scalar variable

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 426d8c84c3)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 21:35:13 +02:00
Michael Niedermayer
ff072fe651
avformat/subfile: Merge if into switch()
Found while reviewing CID1452449 Uninitialized scalar variable

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 2a0a7d964b)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 21:34:42 +02:00
Michael Niedermayer
4d958c1e5a
avformat/rtsp: Check that lower transport is handled in one of the if()
Fixes: CID1473554 Uninitialized scalar variable

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c8200d3825)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 21:12:30 +02:00
Michael Niedermayer
6c21843037
avformat/rtsp: initialize reply1
It seems reply1 is initialized by ff_rtsp_send_cmd() in most cases but there
are code paths like "continue" which look like they could skip it but even if not
writing this so a complex loop after several layers of calls initialized a local
variable through a pointer is just bad design.
This patch simply initialized the variable.

Fixes: CID1473532 Uninitialized scalar variable

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 498ce4e8b8)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 21:11:45 +02:00
Michael Niedermayer
9b450494a2
avformat/rtsp: use < 0 for error check
Found while reviewing CID1473532 Uninitialized scalar variable

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 9bb38ba2b7)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 21:11:00 +02:00
Michael Niedermayer
ab086c7234
avformat/rtpenc_vc2hq: Check sizes
Fixes: CID1452585 Untrusted loop bound

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 7a9ddb7051)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 21:10:33 +02:00
Michael Niedermayer
221dc6bb5e
avfilter/af_aderivative: Free out on error
Fixes: CID1197065 Resource leak

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 382e9e79f3)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 21:09:23 +02:00
Michael Niedermayer
28d9f116f9
swscale/swscale: Use ptrdiff_t for linesize computations
This is unlikely to make a difference

Fixes: CID1591896 Unintentional integer overflow
Fixes: CID1591901 Unintentional integer overflow

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 66b60bae68)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 21:07:11 +02:00
Michael Niedermayer
5b2860a722
avfilter/af_pan: check nb_output_channels before use
Fixes: CID1500281 Out-of-bounds write
Fixes: CID1500331 Out-of-bounds write

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 5fe8bf4aa5)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 20:06:30 +02:00
Mark Thompson
1b07b2e7e5
cbs_av1: Reject thirty-two zero bits in uvlc code
The spec allows at least thirty-two zero bits followed by a one to mean
2^32-1, with no constraint on the number of zeroes.  The libaom
reference decoder does not match this, instead reading thirty-two zeroes
but not the following one to mean 2^32-1.  These two interpretations are
incompatible and other implementations may follow one or the other.
Therefore reject thirty-two zeroes because the intended behaviour is not
clear.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 7110a36ba0)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 20:05:20 +02:00
Michael Niedermayer
5929007ac5
avfilter/af_mcompand: compute half frequency in double
Fixes: CID1422217 Result is not floating-point

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 2d0d502ff1)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 20:03:19 +02:00
Michael Niedermayer
0003e3cd19
avfilter/af_channelsplit: Assert that av_channel_layout_channel_from_index() succeeds
Maybe Helps: CID1503077 Bad bit shift operation

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit cef720ab42)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 20:03:00 +02:00
Michael Niedermayer
e3dd030ef8
avfilter/af_aresample: Cleanup on av_channel_layout_copy() failure
Fixes: CID1503078 Resource leak

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 7a0ea15c7a)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 20:02:43 +02:00
Michael Niedermayer
8762af5366
tools/coverity: Phase 1 study of anti-halicogenic for coverity av_rescale()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 380a8213b1)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 20:02:25 +02:00
Michael Niedermayer
085422937f
avfilter/vf_avgblur: Check plane instead of AVFrame
Fixes: CID1551694 Use after free (false positive based on assuming that out == in and one is freed and one used)

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c296d4fdec)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 20:01:59 +02:00
Michael Niedermayer
6b977edd82
avfilter/drawutils: Fix depthb computation
Fixes: CID1496940 Logically dead code

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 34f821e448)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 20:00:12 +02:00
Michael Niedermayer
25d4dcd474
avformat/rdt: Check pkt_len
Fixes: CID1473553 Untrusted loop bound

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 0d0373de3b)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 19:59:18 +02:00
Michael Niedermayer
5136568148
avformat/mpeg: Check len in mpegps_probe()
Fixes: CID1473590 Untrusted loop bound

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit ca237a841e)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 19:58:34 +02:00
Michael Niedermayer
68d61b4eaf
avdevice/dshow: Check ICaptureGraphBuilder2_SetFiltergraph() for failure
Fixes: CID1591939 Logically dead code

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 4c285bb278)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 19:57:18 +02:00
Michael Niedermayer
2039e3cf80
avcodec/mfenc: check IMFSample_ConvertToContiguousBuffer() for failure
Fixes: CID1591911 Logically dead code

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 86cd7c68bc)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 19:57:01 +02:00
Michael Niedermayer
b0b3673588
avcodec/vc1_loopfilter: Factor duplicate code in vc1_b_h_intfi_loop_filter()
Fixes: CID1435168

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 63ecce9ba8)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 19:56:42 +02:00
Michael Niedermayer
c8156f90ff
avformat/img2dec: assert no pipe on ts_from_file
Help coverity with CID1500302 Uninitialized scalar variable

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 4824156fa0)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 19:55:40 +02:00
Michael Niedermayer
ae37eda47c
avcodec/cbs_jpeg: Try to move the read entity to one side in a test
The checked entity should be alone on one side of the check, this avoids
complex considerations of overflows.
This fixes a issue of bad style in our code and a coverity issue.

Fixes: CID1439654 Untrusted pointer read

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 385784a148)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 19:55:11 +02:00
Michael Niedermayer
773a25a2c6
avformat/mov: Check edit list for overflow
Fixes: 67492/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-5778297231310848
Fixes: signed integer overflow: 2314885530818453536 + 7782220156096217088 cannot be represented in type 'long'

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 2882d30e3a)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 18:56:08 +02:00
Michael Niedermayer
afe53194ac
fftools/ffmpeg: Check read() for failure
Fixes: CID1591932 Ignoring number of bytes read

Sponsored-by: Sovereign Tech Fund
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 34fd247c3b)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 18:55:33 +02:00
Michael Niedermayer
1e1a0182f7
swscale/output: Avoid undefined overflow in yuv2rgb_write_full()
Fixes: signed integer overflow: -140140 * 16525 cannot be represented in type 'int'
Fixes: 68859/clusterfuzz-testcase-minimized-ffmpeg_SWS_fuzzer-4516387130245120

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 c221c7422f)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 17:36:36 +02:00
Michael Niedermayer
076ecf6cb1
swscale/output: alpha can become negative after scaling, use multiply
Fixes: left shift of negative value -3245
Fixes: 69047/clusterfuzz-testcase-minimized-ffmpeg_SWS_fuzzer-6571511551950848

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 9e6c5b6e86)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 17:36:04 +02:00
Michael Niedermayer
9c96e0badc
avcodec/targaenc: Allocate space for the palette
Fixes: out of array access
Fixes: 68927/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TARGA_fuzzer-5105665067515904

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 4a7220bd5c)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 17:26:04 +02:00
Michael Niedermayer
071527557c
avcodec/r210enc: Use av_rescale for bitrate
Fixes: signed integer overflow: 281612954574848 * 65344 cannot be represented in type 'long'
Fixes: 68956/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_R210_fuzzer-6459074458746880

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 d34d4b6a7c)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 17:25:32 +02:00
Michael Niedermayer
8a15de7499
avcodec/jfdctint_template: Fewer integer anomalies
Fixes: signed integer overflow: 105788 * -20995 cannot be represented in type 'int'
Fixes: signed integer overflow: 923211729 + 2073948236 cannot be represented in type 'int'
Fixes: signed integer overflow: 1281179284 + 2073948236 cannot be represented in type 'int'
Fixes: 68975/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PRORES_fuzzer-6266769177116672
Fixes: 68997/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PRORES_KS_fuzzer-6284237161431040

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 228f255b5d)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 17:25:11 +02:00
Michael Niedermayer
c1c9a07eed
avcodec/snowenc: MV limits due to mv_penalty table size
Fixes: out of array read
Fixes: 69673/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SNOW_fuzzer-5476592894148608

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 3a9292aff3)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 17:24:39 +02:00
Michael Niedermayer
691aa476d7
avformat/mxfdec: Check container_ul->desc before use
Fixes: CID1592939 Dereference after null check

Sponsored-by: Sovereign Tech Fund
Reviewed-by: Tomas Härdin <git@haerdin.se>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 4cab028bd0)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 17:22:23 +02:00
Michael Niedermayer
0144448025
MAINTAINERS: Update the entries for the release maintainer for FFmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 97ecfb5a19)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 17:20:25 +02:00
Lynne
68f2794354
configure: update copyright year
(cherry picked from commit b95ee2ec5f)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-15 00:38:05 +02:00
Michael Niedermayer
0dfbf1dffc
Changelog: more backported commits 2024-06-13 22:24:42 +02:00
Michael Niedermayer
12edfe7004
doc/developer: Provide information about git send-email and gmail
The 2 links are the clearest i found.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 959cb2e2e3)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 22:22:27 +02:00
Michael Niedermayer
293b368b81
avfilter/vf_rotate: Check ff_draw_init2() return value
Fixes: NULL pointer dereference
Fixes: 3_343

Found-by: De3mond
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 9c9f095e30)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 22:17:27 +02:00
Michael Niedermayer
74aeed90eb
avformat/mov: Use int64_t in intermediate for corrected_dts
Fixes: CID1500312 Unintentional integer overflow

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 034054b370)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 21:40:38 +02:00
Michael Niedermayer
14aff02a10
avformat/mov: Use 64bit in intermediate for current_dts
Fixes: CID1500304 Unintentional integer overflow
Fixes: CID1500318 Unintentional integer overflow

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 0c977d37aa)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 21:33:55 +02:00
Michael Niedermayer
e0e1a3893d
avformat/matroskadec: Assert that num_levels is non negative
Maybe Closes: CID1452496 Uninitialized scalar variable

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 019fce18bb)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 21:33:33 +02:00
Michael Niedermayer
8dc091daee
avformat/libzmq: Check av_strstart()
Fixes: CID1453457 Unchecked return value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 0263b6a48c)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 21:33:00 +02:00
Michael Niedermayer
393005575b
avformat/img2dec: Little JFIF / Exif cleanup
This changes the behavior and makes it behave how it probably was intended.
Either way this is unlikely to result in any user visible change

Fixes: CID1494637 Missing break in switch

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 5712f36dd0)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 21:32:33 +02:00
Michael Niedermayer
5f4036b66b
avformat/img2dec: Move DQT after unrelated if()
Fixes: CID1494636 Missing break in switch

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 7d04c6016b)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 21:32:10 +02:00
Michael Niedermayer
4446e6b55f
avdevice/xcbgrab: Check sscanf() return
Alot more input checking can be performed, this is only checking the obvious missing case

Fixes: CID1598562 Unchecked return value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 78d6d13bab)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 20:21:38 +02:00
Michael Niedermayer
040db2b447
fftools/cmdutils: Add protective () to FLAGS
issue found while reviewing CID1452612 Free of array-typed value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit d9b9fc4be2)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 19:58:01 +02:00
Michael Niedermayer
f466265169
avformat/sdp: Check before appending ","
Found by reviewing code related to CID1500301 String not null terminated

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 5b82852519)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 19:46:08 +02:00
Michael Niedermayer
5d891ffbe5
avcodec/ilbcdec: Remove dead code
Yes the same dead code is in "iLBC Speech Coder ANSI-C Source Code"

Fixes: CID1509370 Logically dead code

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 8a64a003b5)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 19:45:26 +02:00
Michael Niedermayer
188fe46e92
avcodec/vp8: Check cond init
Fixes: CID1598563 Unchecked return value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 9b76e49061)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 19:44:50 +02:00
Michael Niedermayer
417723accc
avcodec/vp8: Check mutex init
Fixes: CID1598556 Unchecked return value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 4ac7405aaf)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 19:43:55 +02:00
Michael Niedermayer
206816e915
avcodec/pcm-dvdenc: 64bit pkt-size
It seems nothing prevents such overflow even though odd

Fixes: CID1441934 Unintentional integer overflow

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 160b81ce2a)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 19:43:09 +02:00
Michael Niedermayer
85242a8aaf
avcodec/notchlc: Check init_get_bits8() for failure
Fixes: CID1500300 Unchecked return value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 19db9636c5)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 19:42:45 +02:00
Michael Niedermayer
9e46b70436
avcodec/tests/dct: Use 64bit in intermediate for error computation
Fixes: CID1500284 Unintentional integer overflow

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 161d0aa2a8)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 19:40:50 +02:00
Michael Niedermayer
4d9530afdf
avcodec/scpr3: Check add_dec() for failure
Fixes: CID1441459 Improper use of negative value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit d741638042)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 19:40:36 +02:00
Michael Niedermayer
442d18371e
avcodec/rv34: assert that size is not 0 in rv34_gen_vlc_ext()
Helps: CID1548380 Uninitialized scalar variable

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit e5098589b0)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 19:40:03 +02:00
Michael Niedermayer
896af4bd3e
avcodec/wavpackenc: Use unsigned for potential 31bit shift
Fixes: CID1465481 Unintentional integer overflow

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 6f976db251)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 19:39:33 +02:00
Michael Niedermayer
2b7260fbb7
avcodec/tests/jpeg2000dwt: Use 64bit in comparission
Found while reviewing: CID1500309 Unintentional integer overflow

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 12391b732f)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 19:38:39 +02:00
Michael Niedermayer
f85527cd8b
avcodec/tests/jpeg2000dwt: Use 64bit in err2 computation
This issue cannot happen with the current function parameters

Fixes: CID1500309 Unintentional integer overflow

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 847a53f264)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 19:38:19 +02:00
Michael Niedermayer
c48387a3f5
avformat/fwse: Remove always false expression
Fixes: CID1460758 Operands don't affect result

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 348c3a7ffe)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 19:37:11 +02:00
Michael Niedermayer
a0f0e6d813
avcodec/sga: Make it clear that the return is intentionally not checked
Related: CID1473496 Unchecked return value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 00d029d5c0)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 19:36:40 +02:00
Michael Niedermayer
8b19671c78
avformat/asfdec_f: Use 64bit for preroll computation
Fixes: CID1500342 Unintentional integer overflow

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 70b4994762)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 18:52:15 +02:00
Michael Niedermayer
66e306b8e3
avformat/argo_asf: Use 64bit in offset intermediate
Fixes: CID1467435 Unintentional integer overflow

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit d9d1f65308)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 18:51:58 +02:00
Michael Niedermayer
1763189d0e
avformat/ape: Use 64bit for final frame size
Fixes: CID1505963 Unintentional integer overflow

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit a2b8d03347)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 18:51:22 +02:00
Michael Niedermayer
b7efe0f704
avdevice/pulse_audio_enc: Use av_rescale() to avoid integer overflow
Fixes: CID1503075 Unintentional integer overflow

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 6f52b64bcc)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 18:34:43 +02:00
Michael Niedermayer
bc5b55a4ca
avcodec/tiff: Assert init_get_bits8() success in unpack_gray()
Helps: CID1441939 Unchecked return value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit a287f17db2)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 18:33:00 +02:00
Michael Niedermayer
f3424f0470
avcodec/tiff: Assert init_get_bits8() success in horizontal_fill()
Helps: CID1441167 Unchecked return value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 8814cedb07)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 18:32:47 +02:00
Michael Niedermayer
3b94cf8b20
swscale/yuv2rgb: Use 64bit for brightness computation
This will not overflow for normal values
Fixes: CID1500280 Unintentional integer overflow

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit bfc22f364d)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 18:30:04 +02:00
Michael Niedermayer
b8dfe07c50
swscale/x86/swscale: use a clearer name for INPUT_PLANER_RGB_A_FUNC_CASE
related: CID1497114 Missing break in switch

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 3f9daf1c18)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 18:29:48 +02:00
Michael Niedermayer
b2864f699e
avutil/tests/opt: Check av_set_options_string() for failure
This is test code after all so it should test things

Fixes: CID1518990 Unchecked return value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit e3481730ed)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 18:29:22 +02:00
Michael Niedermayer
3ab1855847
avutil/tests/dict: Check av_dict_set() before get for failure
Failure is possible due to strdup()

Fixes: CID1516764 Dereference null return value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit e8a1e1899d)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 18:28:56 +02:00
Michael Niedermayer
2f9a4353bb
avdevice/dshow: fix badly indented line
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c4004605b2)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 18:26:40 +02:00
Michael Niedermayer
84953f5c23
avformat/demux: resurrect dead stores
Fixes: CID1473512 Unused value
Fixes: CID1529228 Unused value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 33da5f4e27)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 18:24:44 +02:00
Michael Niedermayer
21fe5ce693
avcodec/mscc & mwsc: Check loop counts before use
This could cause timeouts

Fixes: CID1439568 Untrusted loop bound

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit e35fe3d8b9)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 11:22:13 +02:00
Michael Niedermayer
cb4e45231c
avcodec/mpegvideo_enc: Fix potential overflow in RD
Fixes: CID1500285 Unintentional integer overflow

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit b6b2b01025)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 11:22:13 +02:00
Michael Niedermayer
ed40d4850b
avcodec/mpeg4videodec: assert impossible wrap points
Helps: CID1473517 Uninitialized scalar variable
Helps: CID1473497 Uninitialized scalar variable

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 8fc649b931)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 11:22:13 +02:00
Michael Niedermayer
701ca03b00
avcodec/mpeg12dec: Use 64bit in bit computation
I dont think this can actually overflow but 64bit seems reasonable to use

Fixes: CID1521983 Unintentional integer overflow

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 4c725df059)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 11:22:12 +02:00
Michael Niedermayer
61332f89a6
avcodec/vble: Check av_image_get_buffer_size() for failure
Fixes: CID1461482 Improper use of negative value

Sponsored-by: Sovereign Tech Fund
Reviewed-.by: "Xiang, Haihao" <haihao.xiang@intel.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit dd5379db5d)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 11:22:12 +02:00
Michael Niedermayer
5bc913c235
avcodec/vp3: Replace check by assert
Fixes: CID1452425 Logically dead code

Sponsored-by: Sovereign Tech Fund
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 1b991e77b9)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 11:22:12 +02:00
Michael Niedermayer
21fd9fb7db
avcodec/jpeg2000dec: remove ST=3 case
Fixes: CID1460979 Logically dead code

Sponsored-by: Sovereign Tech Fund
Reviewed-by: Tomas Härdin <git@haerdin.se>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 4ed4f9a6c0)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 11:22:11 +02:00
Michael Niedermayer
52af506fdb
avcodec/qsvdec: Check av_image_get_buffer_size() for failure
Fixes: CID1477406 Improper use of negative value

Sponsored-by: Sovereign Tech Fund
Reviewed-by: "Xiang, Haihao" <haihao.xiang@intel.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 8789c550fa)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 11:22:11 +02:00
Michael Niedermayer
cb03082cfa
avcodec/exr: Fix preview overflow
Fixes: CID1515456 Unintentional integer overflow

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 36126e4c14)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 11:22:11 +02:00
Michael Niedermayer
21249e8cbe
avcodec/fmvc: remove dead assignment
Fixes: CID1529220 Unused value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 96c1162545)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 11:22:10 +02:00
Michael Niedermayer
148a3ed506
avcodec/h264_slice: Remove dead sps check
Fixes: CID1439574 Dereference after null check

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit a68aa951b2)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 11:22:10 +02:00
Michael Niedermayer
0a27f1d331
avcodec/lpc: copy levenson coeffs only when they have been computed
Fixes: CID1473514 Uninitialized scalar variable

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c2d897f356)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 11:22:10 +02:00
Michael Niedermayer
353cc497cc
avutil/tests/base64: Check with too short output array
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c304784a86)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 11:22:09 +02:00
Michael Niedermayer
f7fcdeb6a0
libavutil/base64: Try not to write over the array end
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 2d216566f2)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 11:22:09 +02:00
Michael Niedermayer
ed6b5d6164
avcodec/cbs_av1: Avoid shift overflow
Fixes: CID1465488 Unintentional integer overflow

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit d7924a4f60)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 11:22:09 +02:00
Michael Niedermayer
b76f24c708
fftools/ffplay: Check return of swr_alloc_set_opts2()
This probably makes no difference but its more correct

Fixes: CID1503080 Unchecked return value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit f44f441555)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 11:22:08 +02:00
Michael Niedermayer
b0754513f4
tools/opt_common: Check for malloc failure
Fixes: CID1539100 Negative loop bound

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit ba7038043a)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 11:22:08 +02:00
Michael Niedermayer
c3471d55c5
doc/examples/demux_decode: Simplify loop
Fixes: CID1463550 Logically dead code

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 91d27f7e02)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 11:22:08 +02:00
Michael Niedermayer
c379893ebe
avformat/concatdec: Check file
Fixes: null pointer dereference
Fixes: -stream_loop 1 -ss 00:00:05 -i zgclab/ffmpeg_crash/poc2 -codec:v copy -codec:a aac -y output.mp4

Found-by: Wang Dawei and Zhou Geng, from Zhongguancun Laboratory
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit a5d1497f33)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 11:22:07 +02:00
Michael Niedermayer
7618da9b2d
avcodec/mpegvideo_enc: Fix 1 line and one column images
Fixes: Ticket10952
Fixes: poc21ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 96449cfeae)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 11:22:07 +02:00
Michael Niedermayer
3ca9febc6e
swscale/output: Fix integer overflow in yuv2rgba64_full_1_c_template()
Fixes: signed integer overflow: -1082982400 + -1079364728 cannot be represented in type 'int'
Fixes: 67910/clusterfuzz-testcase-minimized-ffmpeg_SWS_fuzzer-5329011971522560
The input is 9bit in 16bit, the fuzzer fills all 16bit thus generating "invalid" input
No overflow should happen with valid input.

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 1330a73cca)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 11:22:07 +02:00
Michael Niedermayer
91df1b66c7
swscale/output: Fix integer overflow in yuv2rgba64_1_c_template
Fixes: signed integer overflow: -831176 * 9539 cannot be represented in type 'int'
Fixes: 67869/clusterfuzz-testcase-minimized-ffmpeg_SWS_fuzzer-5117342091640832

The input is 9bit in 16bit, the fuzzer fills all 16bit thus generating "invalid" input
No overflow should happen with valid input.

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 a56559e688)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 11:22:06 +02:00
Michael Niedermayer
d71036b455
avcodec/avs3_parser: assert the return value of init_get_bits()
Fixes: CID1492867 Unchecked return value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit f9218e4d52)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 11:22:06 +02:00
Michael Niedermayer
4408336d9e
avcodec/avs2_parser: Assert init_get_bits8() success with const size 15
Fixes: CID1506708 Unchecked return value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit a7c4f119c9)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 11:22:06 +02:00
Michael Niedermayer
a17885a73d
avformat/mxfdec: Check body_offset
Fixes: signed integer overflow: 538976288 - -9223372036315799520 cannot be represented in type 'long'
Fixes: 68060/clusterfuzz-testcase-minimized-ffmpeg_dem_MXF_fuzzer-5523457266745344

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 20a6bfda0f)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 11:22:05 +02:00
Michael Niedermayer
a2e4f3e5f4
avformat/kvag: Check sample_rate
Fixes: Division by 0
Fixes: -copyts -start_at_zero -itsoffset 00:00:01 -itsscale 1 -ss 00:00:02  -i zgclab/ffmpeg_crash/poc1 output.mp4

Found-by: Wang Dawei and Zhou Geng, from Zhongguancun Laboratory
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c26a762ea1)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 11:22:05 +02:00
Michael Niedermayer
06cc1197e5
avcodec/ac3_parser: Check init_get_bits8() for failure
Fixes: CID1420393 Unchecked return value

Sponsored-by: Sovereign Tech Fund
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 63415168db)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 11:13:57 +02:00
Michael Niedermayer
dc9d2eb69d
avcodec/pngdec: Check last AVFrame before deref
Fixes: NULL pointer dereference
Fixes: 68184/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APNG_fuzzer-4926478069334016

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 091fdce87e)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 11:13:56 +02:00
Michael Niedermayer
2f0919b26a
avcodec/hevcdec: Check ref frame
Fixes: NULL pointer dereferences
Fixes: 68197/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-6382538823106560

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 5eb05f4450)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 11:13:56 +02:00
Michael Niedermayer
b9867cade3
doc/examples/vaapi_transcode: Simplify loop
Fixes: CID1428858(1/2) Logically dead code

Sponsored-by: Sovereign Tech Fund
Reviewed-by: "mypopy@gmail.com" <mypopy@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c9c11a0866)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 11:13:55 +02:00
Michael Niedermayer
d9ccbd71f4
avfilter/vf_thumbnail_cuda: Set ret before checking it
Fixes: CID1418336 Logically dead code

Sponsored-by: Sovereign Tech Fund
Reviewed-by: Timo Rothenpieler <timo@rothenpieler.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 02301017d2)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 11:13:55 +02:00
Michael Niedermayer
601e4fb1f0
avfilter/signature_lookup: Dont copy uninitialized stuff around
Fixes: CID1403238 Uninitialized pointer read
Fixes: CID1403239 Uninitialized pointer read

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit e7174e66ac)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 11:13:55 +02:00
Michael Niedermayer
32af5cb10a
avfilter/signature_lookup: Fix 2 differences to the refernce SW
Fixes: CID1403227 Division or modulo by float zero

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 25cb66369e)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-13 11:13:49 +02:00
llyyr
1f3baf7218
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:39:43 +02:00
Brad Smith
389861c021 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:38:51 -04:00
Andreas Rheinhardt
41c2da99f7 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:36:16 +02:00
Brad Smith
2d50a0e84a 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:26:52 -04:00
Brad Smith
ff8eee6470 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:25:19 -04:00
Michael Niedermayer
c8bd7f9209
Update for 5.1.5
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-15 02:01:03 +02:00
Andreas Rheinhardt
1b47af0b84
fate/subtitles: Ignore line endings for sub-scc test
Since 7bf1b9b357,
the test produces ordinary \n, yet this is not what the reference
file used for the most time, leading to test failures.

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

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

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

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

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

Fixes: null pointer dereference
Fixes: crash-35a3b39ddcc5babeeb005b7399a3a1217c8781bc

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c0f4abe2aa)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:43 +02:00
Michael Niedermayer
7d9656e858
avcodec/proresenc_kostya: Remove bug similarity text
According to kostya, it is not based on Wassermans encoder

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

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

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

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

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

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

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

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

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

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

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

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

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

Discovered by Zeng Yunxiang.

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

Discovered by Zeng Yunxiang

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 68146f06f8)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:39 +02:00
Michael Niedermayer
e8265e6ebd
avformat/flacdec: Avoid double AVERRORS
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 029294ff54)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:38 +02:00
Michael Niedermayer
87ef16a690
avfilter/vf_vidstabdetect: Avoid double AVERRORS
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit bb04235d72)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:38 +02:00
Michael Niedermayer
ae6912b982
avfilter/vf_swaprect: round coordinates down
Fixes: out of array access:
Fixes: tickets/10745/poc12ffmpeg

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

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

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

Found-by: Zeng Yunxiang
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 50f0f8c53c)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:36 +02:00
Michael Niedermayer
9f52c6184f
avfilter/vf_weave: Fix odd height handling
Fixes: out of array access
Fixes: tickets/10743/poc10ffmpeg

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

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

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

Regression since: 81df787b53

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

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

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

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

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

Signed-off-by: Dale Curtis <dalecurtis@chromium.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 2182173a69)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 02:04:33 +02:00
Eugene Zemtsov
36cf037fb8 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:16:03 -03:00
Marton Balint
defa085fc8 avfilter/buffersrc: fix overriding unknown channel layouts with negotiated one
Fixes ffplay playback of unknown layouts, when SDL directly supports the audio
format, such as:

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

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

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

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

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

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

Regression since 1f96db959c.

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

Fixes ticket #10711.

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

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

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

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

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

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

Fixes ticket #9142.

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

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

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

Fixes ticket #10865.

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

Signed-off-by: Marton Balint <cus@passwd.hu>
(cherry picked from commit 41672f5586)
2024-02-20 21:57:26 +01:00
Jan Ekström
9bf90b1260 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:24:15 +02:00
Marton Balint
352fe0d4bf avformat/mov_chan: never override number of channels based on chan atom
The channel designation metadata should not override the number of channels.
Let's warn the user if it is inconsistent, and keep the channel layout
unspecified.

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

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

Signed-off-by: Marton Balint <cus@passwd.hu>
(cherry picked from commit 3d3cad7483)
2024-02-11 23:20:35 +01:00
James Almer
c36c91900f 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:37:05 -03:00
Anton Khirnov
dd885ab2f5 fftools/ffmpeg_enc: apply -top to individual encoded frames
Fixes #9339.

(Adapted from commit 43a0004b5c)
2024-01-26 23:24:22 +01:00
James Almer
ae14d9c06b fftools/ffprobe: support 2D arrays in print_list_fmt()
Should fix undefined behavior.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit b119b3da1e)
2023-12-06 16:12:39 -03:00
Michael Niedermayer
4729204c17
Update for 5.1.4
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-11-10 00:32:27 +01:00
Michael Niedermayer
49beba036c
avcodec/4xm: Check for cfrm exhaustion
Fixes: index -1 out of bounds for type 'CFrameBuffer [100]'
Fixes: 63877/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FOURXM_fuzzer-5854263397711872

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

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

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

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

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

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

Signed-off-by: Frank Plowman <post@frankplowman.com>
(cherry picked from commit f01fdedb69)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-11-09 00:16:18 +01:00
Michael Niedermayer
e531abaf3c
avfilter/buffersink: fix order of operation with = and <0
Reviewed-by: Sean McGovern <gseanmcg@gmail.com>
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c0a18e884c)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-11-03 22:27:37 +01:00
Michael Niedermayer
0f93f8ce2c
tools/target_dec_fuzzer: Adjust threshold for CSCD
Fixes: Timeout
Fixes: 63362/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CSCD_fuzzer-4694620065628160

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

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

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 98c2711b58)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-11-03 22:24:54 +01:00
Andreas Rheinhardt
7739dabb89
avformat/matroskadec: Fix declaration-after-statement warnings
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit 37b5f4a1f6)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-30 00:39:15 +01:00
Michael Niedermayer
5e71da4ef9
avformat/rtsp: Use rtsp_st->stream_index
Fixes: out of array access
Fixes: rtpdec_h264.c149/poc

Found-by: Hardik Shah of Vehere
Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit e4d5ac8d7d)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-30 00:39:15 +01:00
Michael Niedermayer
4bd4b178bf
avcodec/jpeg2000dec: Check image offset
Fixes: left shift of negative value -538967841
Fixes: 62447/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-6427134337613824

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

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

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit d799ad2404)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-30 00:39:14 +01:00
Michael Niedermayer
181d6e17e0
avcodec/h2645_parse: Avoid EAGAIN
EAGAIN causes an assertion failure when it is returned from the decoder

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

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

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit f7e5537dc1)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-30 00:39:13 +01:00
Michael Niedermayer
d7f64a78e0
avformat/tmv: Check video chunk size
This check matches the audio chunk check

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit bb9f8a1cb7)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-30 00:39:08 +01:00
Michael Niedermayer
3817209b6d
avformat/avs: Check if return code is representable
Fixes: leak
Fixes: 62164/clusterfuzz-testcase-minimized-ffmpeg_dem_AVS_fuzzer-6738814988320768

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 52d666edec)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-30 00:39:08 +01:00
Michael Niedermayer
6e4690ede0
avcodec/lcldec: Make PNG filter addressing match the code afterwards
Also update check accordingly

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

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit d11b8bd0c6)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-30 00:39:08 +01:00
Michael Niedermayer
87f556a10c
avformat/westwood_vqa: Check chunk size
the type is also changed to int as it is interpreted as int in av_get_packet()

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

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

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

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit dedc78b4b5)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-30 00:39:07 +01:00
Michael Niedermayer
b358b080a1
avformat/mxfdec: Remove this_partition
Suggested-by: Tomas Härdin <git@haerdin.se>
Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_MXF_fuzzer-5130394286817280

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

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

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

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

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

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

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

Issue found by: Сергей Колесников
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 5f810435c2)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-30 00:39:05 +01:00
Michael Niedermayer
ee90868c67
avformat/format: Stop reading data at EOF during probing
Issue found by: Сергей Колесников
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 80f6e0378b)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-30 00:39:05 +01:00
Michael Niedermayer
3c56b5c3df
avcodec/jpeg2000dec: jpeg2000 has its own lowres option
jpeg2000 overrides the global lowres variable with a lowres field called reduction_factor
ffmpeg -lowres X causes the reduction_factor to be set
ffplay -lowres X causes both lowres and the reduction_factor to be set
ossfuss sets only lowres

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

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

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

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

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

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

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

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

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

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

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

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

Regression since: ed0001482a.

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

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 696e161919)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-30 00:39:01 +01:00
Michael Niedermayer
7c646d22cf
avcodec/xvididct: Fix integer overflow in idct_row()
Fixes: signed integer overflow: -1403461578 + -843974775 cannot be represented in type 'int'
Fixes: 60868/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPEG1VIDEO_fuzzer-4599793035378688

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

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

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Pierre-Anthony Lemieux <pal@sandflow.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 509ce40f18)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-30 00:39:00 +01:00
Michael Niedermayer
1759fd0d82
avcodec/pcm: allow Changing parameters
SDR needs this for switching between mono and stereo stations

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 94d44dbe21)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-30 00:39:00 +01:00
Michael Niedermayer
fc94130cd6
avcodec/jpeg2000dec: Check for reduction factor and image offset
This combination is not working (it writes out of array)

Reviewed-by: Tomas Härdin <git@haerdin.se>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 9b6d191a66)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-30 00:38:59 +01:00
Michael Niedermayer
18bf4e4ff7
avutil/softfloat: Basic documentation for av_sincos_sf()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 4aa1a42a91)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-30 00:38:59 +01:00
Michael Niedermayer
706c44541e
avutil/softfloat: fix av_sincos_sf()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit d84677abd8)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-30 00:38:59 +01:00
Michael Niedermayer
cde6758306
tools/target_dec_fuzzer: Adjust threshold for speex
Fixes: Timeout
Fixes: 59731/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SPEEX_fuzzer-4809436670328832

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

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

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

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit ff8a496d41)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-30 00:38:57 +01:00
Michael Niedermayer
74d3c9261a
avcodec: Ignoring errors is only possible before the input end
Fixes: out of array read
Fixes: Ticket 10308

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

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

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

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

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit b1c3d81e71)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-30 00:38:55 +01:00
Michael Niedermayer
50e2f8ef33
avformat/wavdec: Check that smv block fits in available space
Fixes: OOM
Fixes: 56271/clusterfuzz-testcase-minimized-ffmpeg_dem_WAV_fuzzer-5290810045497344

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

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

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

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

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 34056a94ea)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-30 00:38:54 +01:00
Michael Niedermayer
b9c79be726
avcodec/exr: Cleanup befor return
Fixes: leaks
Fixes: 45982/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EXR_fuzzer-6703454090559488

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

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

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit d31d4f3228)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-30 00:38:53 +01:00
Michael Niedermayer
ac015347a8
avcodec/pngdec: remove AVFrame argument from decode_iccp_chunk()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 7117b380a7)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-30 00:38:53 +01:00
Michael Niedermayer
efcb821157
avcodec/vorbisdec: Check codebook float values to be finite
Fixes: Timeout
Fixes: 55116/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VORBIS_fuzzer-4572159970508800

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

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

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

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

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit e2c3aa8e2b)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-30 00:38:51 +01:00
Michael Niedermayer
002471255d
avcodec/lcldec: Support 4:1:1 and 4:2:2 with odd width
Fixes: Ticket10240
Fixes: zlib_306_306_yuv422.avi
Fixes: zlib_306_306_yuv411.avi

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 0cf1ac905d)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-30 00:38:51 +01:00
Michael Niedermayer
8abcd8b124
libavcodec/lcldec: width and height should not be unsigned
Computations like col < width - 3 will not work with unsigned width=1

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 3eb4e28c26)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-30 00:38:51 +01:00
Pierre-Anthony Lemieux
c2d4ab2552
avformat/imf: fix invalid resource handling
(cherry picked from commit 23d968d55a)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-30 00:38:50 +01:00
Michael Niedermayer
d1553cad73
avcodec/escape124: Check that blocks are allocated before use
Fixes: NULL pointer dereference
Fixes: 57819/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ESCAPE124_fuzzer-5077280228769792

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 5366ae12b9)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-30 00:38:50 +01:00
Michael Niedermayer
7158ad82da
avcodec/huffyuvdec: Fix undefined behavior with shift
Fixes: left shift of negative value -1
Fixes: 57554/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFVHUFF_fuzzer-4853603839115264

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

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit ad4d647591)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-30 00:38:49 +01:00
Michael Niedermayer
4c07c4d29a
avcodec/j2kenc: Replace BGR48 / GRAY16 test by test for number of bits
BGR48 is not supported and this was probably meant to be RGB48 so this fixes
RGB48 a bit

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 7fb70d27a2)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-30 00:38:49 +01:00
Michael Niedermayer
cf6ae79a71
avcodec/j2kenc: simplify pixel format setup
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 644d15716d)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-30 00:38:49 +01:00
Michael Niedermayer
0ab5965b69
avcodec/j2kenc: Fix funky bpno errors on decoding
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 816676085e)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-30 00:38:48 +01:00
Michael Niedermayer
1990527edb
avcodec/j2kenc: remove misleading pred value
This field is only checked for being 0 or not and not zero means 5/3

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

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

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 6d1d8609ac)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-30 00:38:47 +01:00
Lynne
dad04e27b0
configure: update copyright year
(cherry picked from commit 62da0b4a74)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-30 00:38:47 +01:00
Michael Niedermayer
af1f71cfd3
Changelog: Add forgotten line
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-30 00:38:36 +01:00
Will Cassella
566aa38d98 libavformat/riffec: Zero-initialize channels in ff_get_wav_header
Clang's static analyzer complains that leaving the  variable
uninitialized could lead to a code path where the uninitialized value is
written to  at the end of this function.
This patch simply zero-initializes that variable to avoid that.

Signed-off-by: Will Cassella <cassew@google.com>
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit e601ec3c19)
2023-08-12 13:25:36 -03:00
Rémi Denis-Courmont
25cd95a9dc avcodec/x86/mathops: clip constants used with shift instructions within inline assembly
Fixes assembling with binutil as >= 2.41

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit effadce6c7)
2023-07-22 19:29:08 -03:00
Jan Ekström
e5b5dd6653 avcodec/libsvtav1: use larger of bit rate and max rate for buffer size
Generally if maxrate is set, the calculation should be maxrate over
bufsize. This additionally enables CRF + maxrate & bufsize usage.

In order to keep negative values from enabling zero to be treated
as larger and causing a division by zero, check that one of the
variables is larger than zero.
2023-06-06 23:54:50 +02:00
Christopher Degawa
8fe2fec453 avcodec/libsvtav1: only set max_buf_sz if both bitrate and rc_buf_sz is set
maximum_buffer_size_ms should only be set if both are specified or if
the user sets it through -svtav1-params buf-sz=val

Signed-off-by: Christopher Degawa <ccom@randomderp.com>
2023-06-06 23:50:18 +02:00
Christopher Degawa
3344d47a88 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>
2023-05-30 00:28:14 +02:00
Christopher Degawa
bea695d543 avcodec/libsvtav1: replace vbv_bufsize with maximum_buffer_size_ms
svt-av1 v1.2.0 has deprecated vbv_bufsize in favor of using
- maximum_buffer_size_ms (--buf-sz)
- starting_buffer_level_ms (--buf-initial-sz)
- optimal_buffer_level_ms (--buf-optimal-sz)

and vbv_bufsize has not been in use since svt-av1 v0.8.6

Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
2023-05-29 23:12:13 +02:00
Hendrik Leppkes
33ed503e59
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:42:37 +02:00
Hendrik Leppkes
4015609fcd
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:42:37 +02:00
Hendrik Leppkes
a4f995fa84
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:42:37 +02:00
Hendrik Leppkes
e6f7183eb6
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:42:37 +02:00
Anton Khirnov
1e413487bf fftools/ffmpeg: avoid possible invalid reads with short -tag values
Fixes #10319 and #10309.

Based on 89c9a3ac35.
2023-04-17 12:20:12 +02:00
James Almer
c36f69d7e3 avcodec/mp_cmp: reject invalid comparison function values
Fixes tickets #10306 and #10318.

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

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

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

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 19c2dc677f)
2023-04-16 11:39:13 -03:00
Kyle Manning
0028275216 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:05:15 +02:00
Michael Niedermayer
963937e408
Changelog: update
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-03-26 15:30:31 +02:00
Michael Niedermayer
037c7a2eac
avcodec/tests/snowenc: Fix 2nd test
(cherry picked from commit 163013c724)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-03-26 15:30:31 +02:00
Michael Niedermayer
06dfb4fef2
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-26 15:30:31 +02:00
Michael Niedermayer
28b03ac192
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-26 15:30:30 +02:00
Michael Niedermayer
29412c75eb
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-26 15:30:30 +02:00
James Almer
3553421888 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:07:03 -03:00
Michael Niedermayer
643318bba2
update for 5.1.3
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-03-16 14:53:52 +01:00
Michael Niedermayer
43ea18703c
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-16 14:48:41 +01:00
Michael Niedermayer
405bfbd873
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-16 14:48:41 +01:00
Michael Niedermayer
0dca540766
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-16 14:48:41 +01:00
Michael Niedermayer
75ece79ff4
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-16 14:48:40 +01:00
Paul B Mahol
7c234248f8
avcodec/rpzaenc: stop accessing out of bounds frame
(cherry picked from commit 92f9b28ed8)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-03-16 14:48:40 +01:00
Paul B Mahol
9886e4c3b0
avcodec/smcenc: stop accessing out of bounds frame
(cherry picked from commit 13c1310975)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-03-16 14:48:40 +01:00
Michael Niedermayer
0b6c4936dd
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-16 14:48:39 +01:00
Michael Niedermayer
fbe44d7a82
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-16 14:48:39 +01:00
Michael Niedermayer
e1b1ead9e3
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-16 14:48:39 +01:00
Michael Niedermayer
2d6c2b6dc2
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-16 14:48:38 +01:00
Michael Niedermayer
44c1e6ed2c
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-16 14:48:38 +01:00
Michael Niedermayer
86a50643ab
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-16 14:48:38 +01:00
Michael Niedermayer
ac3e0e7beb
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-16 14:48:37 +01:00
Michael Niedermayer
ce0bb67b1f
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-16 14:48:37 +01:00
Michael Niedermayer
365203e99e
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-16 14:48:37 +01:00
Michael Niedermayer
14446f1831
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-16 14:48:36 +01:00
Michael Niedermayer
fa22608c46
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-16 14:48:36 +01:00
Kacper Michajłow
52d055b34d lavu/vulkan: fix handle type for 32-bit targets
Fixes compilation with clang which errors out on Wint-conversion.

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

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

Signed-off-by: Martin Storsjö <martin@martin.st>
(cherry picked from commit f9620d74cd)
Signed-off-by: Martin Storsjö <martin@martin.st>
2023-03-09 13:56:12 +02:00
Michael Niedermayer
2953c6381a
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-02-22 19:49:17 +01:00
Michael Niedermayer
9057d34748
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-02-22 19:48:31 +01:00
Michael Niedermayer
af6919486b
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-02-22 01:03:30 +01:00
Michael Niedermayer
14da78a8c1
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-02-22 01:02:57 +01:00
Michael Niedermayer
2e9faba7c7
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-02-22 01:02:11 +01:00
Michael Niedermayer
a34fe535e4
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-02-22 00:42:22 +01:00
Michael Niedermayer
d78fe4d3fb
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-02-22 00:32:19 +01:00
Michael Niedermayer
7e211d001f
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-02-22 00:10:15 +01:00
Michael Niedermayer
87e6221d53
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-02-22 00:03:43 +01:00
Michael Niedermayer
8f4e355416
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-02-21 23:53:32 +01:00
Michael Niedermayer
194a9429b2
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-02-21 23:43:56 +01:00
Michael Niedermayer
7d2360f8d6
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-02-21 23:41:55 +01:00
Michael Niedermayer
3aee1b1ec3
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-02-21 23:37:11 +01:00
Michael Niedermayer
46a1e9e386
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-02-21 23:36:26 +01:00
Michael Niedermayer
16b8de719e
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-02-21 23:30:42 +01:00
Michael Niedermayer
7c5b975f6f
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-02-21 00:41:57 +01:00
Michael Niedermayer
c1780eeccf
avutil/tx: Use unsigned in ff_tx_fft_sr_combine() to avoid undefined behavior
Fixes: signed integer overflow: -1284837070 - 982101618 cannot be represented in type 'int'
Fixes: 53105/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AC3_FIXED_fuzzer-4848015827664896

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 7792825ad6)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-21 00:41:29 +01:00
Michael Niedermayer
f291b241a3
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-02-21 00:37:06 +01:00
Michael Niedermayer
e475ea86f2
avcodec/alsdec: Check bits left before block decoding in non multi channel coding loop
Fixes: Timeout
Fixes: 52161/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALS_fuzzer-6440216563154944

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
(cherry picked from commit 1dc8d82da9)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-21 00:33:01 +01:00
Michael Niedermayer
bb7e683a21
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-02-21 00:31:08 +01:00
Michael Niedermayer
71b40b2645
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-02-21 00:30:35 +01:00
Michael Niedermayer
8b09afb86e
swscale/output: Bias 16bps output calculations to improve non overflowing range for GBRP16/GBRPF32
Fixes: integer overflow
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit b74f89caae)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-21 00:29:01 +01:00
Michael Niedermayer
e17632834d
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-02-21 00:28:24 +01:00
Michael Niedermayer
aca17a8f89
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-02-21 00:27:53 +01:00
Michael Niedermayer
3314bababf
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-02-21 00:27:14 +01:00
Michael Niedermayer
4b0d23902f
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>
2023-02-11 11:51:37 +01:00
Michael Niedermayer
11d07808bc
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>
2023-02-11 11:51:11 +01:00
Lynne
7268323193 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:43:33 +02:00
Leo Izen
30d432f205 avcodec/libjxldec: fix gamma22 and gamma28 recognition
Gamma 2.2 and Gamma 2.8 are tagged in the file as 0.45455 and 0.35714,
respectively (i.e. 1/2.2 and 1/2.8). Trying to identify them as 2.2 and
2.8 instead of these values will cause the transfer function to not
properly be recognized. This patch fixes this.

(cherry picked from commit 9d5e66942c)
2023-01-22 17:05:42 +02:00
Thierry Foucu
070b38167c avcodec/mpeg12dec: use init_get_bits8 and check the return value
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit efbe84eb1b)
2023-01-04 16:19:56 -03:00
Timo Rothenpieler
807afa59cc 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:38:46 +01:00
James Almer
5746987bad 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:41:10 -03:00
Martin Storsjö
a6e26053c2 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:11 +02:00
James Almer
b4a4a31499 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:14:51 -03:00
James Almer
fe2d8f1872 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:14:51 -03:00
Chema Gonzalez
f5455889fd 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:24:21 +02:00
Guangyu Sun
e7dd643419 lavf/async: Fix ring_write return value
This fixes a regression from commit 36117968ad.

wrapped_url_read() used to be able to return positive number from
ffurl_read(). It relies on the result to check if EOF is reached in
async_buffer_task().

But FIFO callbacks must return 0 on success. This should be handled
in ring_write() instead.

Test case:
  ffmpeg -f lavfi -i testsrc -t 1 test.mp4
  ffmpeg -i async:test.mp4

Signed-off-by: Guangyu Sun <gsun@roblox.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
(cherry picked from commit fc6f7e2a3b)
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2022-10-14 12:24:21 +02:00
Steven Liu
79bd6a21a0 avcodec/audiotoolboxenc: return AVERROR_EXTERNAL immediately when encode error
Just return AVERROR_EXTERNAL immediately when encode error.
The other logic should keep the old behavior before commit 7c05b7951.

Suggested-By: Zhao Zhili <zhilizhao@tencent.com>
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2022-10-05 23:21:04 +08:00
Leo Izen
05d6157aab avcodec/libjxlenc: avoid hard failure with unspecified primaries
This patch prevents the libjxl encoder wrapper from failing to
encode images when the input video has untagged primaries. It will
instead assume BT.709/sRGB primaries and print a warning.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
(cherry picked from commit 940169b8aa)
2022-09-25 11:15:57 -03:00
Michael Niedermayer
eacfcbae69
Update for 5.1.2
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-24 22:59:48 +02:00
Michael Niedermayer
6bbe4d1f4f
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-09-24 22:58:24 +02:00
Michael Niedermayer
9658d1da59
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-09-24 22:58:24 +02:00
Michael Niedermayer
67648acb76
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-09-24 22:58:23 +02:00
Michael Niedermayer
c54161e199
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-09-24 22:58:23 +02:00
Michael Niedermayer
e443e2e210
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-09-24 22:58:23 +02:00
Michael Niedermayer
ad56da7634
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-09-24 22:58:22 +02:00
Michael Niedermayer
3e2b970b00
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-09-24 22:58:22 +02:00
Michael Niedermayer
77628600aa
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-09-24 22:58:22 +02:00
Michael Niedermayer
de79299bf0
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-09-24 22:58:21 +02:00
Michael Niedermayer
1c3c25491a
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-09-24 22:58:21 +02:00
Michael Niedermayer
740a71b583
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-09-24 22:58:21 +02:00
Michael Niedermayer
4038dfc1d1
avformat/genh: Check nb_channels for IMA ADPCM
The check could be made more strict

Fixes: signed integer overflow: 36 * 538976288 cannot be represented in type 'int'
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_GENH_fuzzer-6539389873815552

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 0345a88545)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-24 22:58:20 +02:00
Michael Niedermayer
c38fde3b9d
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-09-24 22:58:20 +02:00
Michael Niedermayer
48acb06c78
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-09-24 22:58:20 +02:00
Michael Niedermayer
ef0a505126
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-09-24 22:58:19 +02:00
Michael Niedermayer
01834eaec2
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-09-24 22:58:19 +02:00
Michael Niedermayer
08047db178
avformat/apm: Use 64bit for bit_rate computation
Fixes: signed integer overflow: -1155522528 * 4 cannot be represented in type 'int'
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_APM_fuzzer-6580670570299392

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 5b23cab5c7)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-24 22:58:19 +02:00
Michael Niedermayer
ca55032020
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-09-24 22:58:19 +02:00
Michael Niedermayer
c9bb4e3bcc
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-09-24 22:58:18 +02:00
Michael Niedermayer
14787c60ec
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-09-24 22:58:18 +02:00
Michael Niedermayer
4143d0a33a
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-09-24 22:58:18 +02:00
Michael Niedermayer
a3d59e33d9
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-09-24 22:58:17 +02:00
Michael Niedermayer
89c2911a3c
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-09-24 22:58:17 +02:00
Michael Niedermayer
04a2dd8054
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-09-24 22:58:17 +02:00
Michael Niedermayer
c15b355eb5
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-09-24 22:58:16 +02:00
Michael Niedermayer
5a944b3a98
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-09-24 22:58:16 +02:00
Michael Niedermayer
03c168869e
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-09-24 22:58:16 +02:00
Michael Niedermayer
4e07d4a1ee
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-09-24 22:58:15 +02:00
Michael Niedermayer
8f483d42e0
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-09-24 22:58:15 +02:00
Michael Niedermayer
47e510aa0c
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-09-24 22:58:15 +02:00
Michael Niedermayer
b877696f16
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-09-24 22:58:14 +02:00
Michael Niedermayer
82207ef266
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-09-24 22:58:14 +02:00
Michael Niedermayer
58c5976ca0
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-09-24 22:58:14 +02:00
Michael Niedermayer
344c1134a9
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-09-24 22:58:13 +02:00
James Almer
746a210630 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>
2022-09-24 12:20:24 -03:00
Andreas Rheinhardt
f202a1fdf7 avformat/dashdec: Fix crash on invalid input/ENOMEM, fix leak
In case a SupplementalProperty node exists in an adaptationset,
it is searched for a "schemeIdUri" property via xmlGetProp().
Whatever xmlGetProp() returns is then compared via av_strcasecmp()
to a string literal. xmlGetProp() can return NULL, namely in case
no "schemeIdUri" exists and (given that this string is allocated)
presumably also on allocation failure. No check for NULL is done,
so this may crash.

Furthermore, the string returned by xmlGetProp() needs to be freed
with xmlFree(), but this is not done either.

This commit fixes both of these issues; they existed since this code
has been added in 10d008f0fd.

This has been found while investigating ticket #9697. The continuous
leaks might very well be the reason behind the observed slowdown.

Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit 14b3830b33)
2022-09-23 16:25:21 +02:00
Anton Khirnov
9772ba1b6a 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-23 16:18:16 +02:00
Anton Khirnov
96c78e50a6 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-23 16:17:52 +02:00
James Cowgill
2d04a18264 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:20:52 +03:00
James Almer
425ffaec23 avformat/riffdec: don't unconditionally overwrite WAVEFORMATEXTENSIBLE layout
Do it only if the value conflicts with the previous channels value.

Fixes ticket #9912

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 60d8c2019f)
2022-09-11 09:56:37 -03:00
James Almer
fcbd9ec248 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-06 15:29:05 -03:00
Anton Khirnov
35aa7e70e7 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>
2022-09-06 09:19:09 +02:00
Andreas Rheinhardt
4424a6223b avutil/tests/.gitignore: Add channel_layout testtool
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit f89949afed)
2022-09-05 02:00:55 +02:00
Michael Niedermayer
1bad30dbe3
Update for 5.1.1
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-08-31 18:10:03 +02:00
Michael Niedermayer
5c0309d278
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-08-31 18:06:17 +02:00
Michael Niedermayer
6f53f0d09e
avformat/mov: Check count sums in build_open_gop_key_points()
Fixes: ffmpeg.md
Fixes: Out of array access
Fixes: CVE-2022-2566

Found-by: Andy Nguyen <theflow@google.com>
Found-by: 3pvd <3pvd@google.com>
Reviewed-by: Andy Nguyen <theflow@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c953baa084)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-08-28 23:07:07 +02:00
Michael Niedermayer
30bd4831e6
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-08-28 23:07:07 +02:00
Michael Niedermayer
5a2bb10733
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-08-28 23:07:07 +02:00
Michael Niedermayer
550fd2212d
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-08-28 23:07:06 +02:00
Michael Niedermayer
1cd07b178b
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-08-28 23:07:06 +02:00
Michael Niedermayer
59afc50ab4
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-08-28 23:07:06 +02:00
Michael Niedermayer
54971af920
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-08-28 23:07:05 +02:00
Michael Niedermayer
8cf035cd88
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-08-28 23:07:05 +02:00
Michael Niedermayer
c8ee3f9f6f
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-08-28 23:07:05 +02:00
Michael Niedermayer
fdc5e2329a
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-08-28 23:07:04 +02:00
Michael Niedermayer
9eb36ab0a1
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-08-28 23:07:04 +02:00
Michael Niedermayer
5d6b733277
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-08-28 23:07:04 +02:00
Andreas Rheinhardt
bc7df3bc64 avcodec/pngdec: Fix APNG_DISPOSE_OP_BACKGROUND
APNG works with a single reference frame and an output frame.
According to the spec, decoding APNG works by decoding
the current IDAT/fdAT chunks (which decodes to a rectangular
subregion of the whole image region), followed by either
overwriting the region of the output frame with the newly
decoded data or by blending the newly decoded data with
the data from the reference frame onto the current subregion
of the output frame. The remainder of the output frame
is just copied from the reference frame.
Then the reference frame might be left untouched
(APNG_DISPOSE_OP_PREVIOUS), it might be replaced by the output
frame (APNG_DISPOSE_OP_NONE) or the rectangular subregion
corresponding to the just decoded frame has to be reset
to black (APNG_DISPOSE_OP_BACKGROUND).

The latter case is not handled correctly by our decoder:
It only performs resetting the rectangle in the reference frame
when decoding the next frame; and since commit
b593abda6c it does not reset
the reference frame permanently, but only temporarily (i.e.
it only affects decoding the frame after the frame with
APNG_DISPOSE_OP_BACKGROUND). This is a problem if the
frame after the APNG_DISPOSE_OP_BACKGROUND frame uses
APNG_DISPOSE_OP_PREVIOUS, because then the frame after
the APNG_DISPOSE_OP_PREVIOUS frame has an incorrect reference
frame. (If it is not followed by an APNG_DISPOSE_OP_PREVIOUS
frame, the decoder only keeps a reference to the output frame,
which is ok.)

This commit fixes this by being much closer to the spec
than the earlier code: Resetting the background is no longer
postponed until the next frame; instead it is applied to
the reference frame.

Fixes ticket #9602.

(For multithreaded decoding it was actually already broken
since commit 5663301560.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-08-26 21:56:01 +02:00
James Almer
db2d52e1ff avcodec/libvpx: fix assembling vp9 packets with alpha channel
There's no warranty that vpx_codec_encode() will generate a list with the same
amount of packets for both the yuv planes encoder and the alpha plane encoder,
so queueing packets based on what the main encoder returns will fail when the
amount of packets in both lists differ.
Queue all data packets for every vpx_codec_encode() call from both encoders
before attempting to assemble output AVPackets out of them.

Fixes ticket #9884

Reviewed-by: Vignesh Venkatasubramanian <vigneshv@google.com>
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 9c7a8a8546)
2022-08-24 10:43:03 -03:00
James Almer
f28cb0c1a8 fftools/ffmpeg_opt: try to propagate the requested output channel layout
Don't silently replace it with the default layout for the amount of channels
from the requested layout.

Should fix ticket #9869

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit f5a663f2a9)
2022-08-24 10:41:59 -03:00
James Almer
07286d82f7 avcodec/libsvtav1: properly initialize the flush EbBufferHeaderType struct
Should fix ticket #9834

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit fb70e0611b)
2022-08-24 10:36:06 -03:00
Hendrik Leppkes
0143b0d964 configure: enable the av1_frame_split bsf for the av1 decoder
The BSF is required to make use of the AV1 decoder, thus configure
should also ensure it is built.
2022-08-23 14:34:56 +02:00
James Almer
6ee1996721 swresample/swresample: fill the correct buffer to print the output layout string
Signed-off-by: James Almer <jamrial@gmail.com>
2022-08-21 17:51:18 -03:00
Gyan Doshi
4e4cc6e56a ffprobe: restore reporting error code for failed inputs
c11fb46731 led to a regression whereby the return code for missing
input or input probe is overridden by writer close return code and
hence not conveyed in the exit code.
2022-08-17 16:46:56 +05:30
Derek Buitenhuis
8479e2fc8b ipfsgateway: Remove default gateway
A gateway can see everything, and we should not be shipping a hardcoded
default from a third party company; it's a security risk.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
(cherry picked from commit 412922cc6f)
2022-08-15 20:38:08 +01:00
Andreas Rheinhardt
1ad802c45c avcodec/libspeexdec: Fix use of uninitialized value
Regression since 97d9a32938.
Fixes Coverity issue #1503072.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit eb608fd0b0)
2022-08-10 18:48:25 +02:00
Stephen Hutchinson
ffaf606130 avformat/avisynth: use ch_layout.nb_channels for channel count
Fixes deprecation warning

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit dc9843d829)
2022-08-07 22:43:32 -03:00
Andreas Rheinhardt
aba74d7843 fate/lavf-image: Disable file checksums for exr tests
The generated files are endian-dependent, so no checksums
may be part of the ref files.

Fixes ticket #9854.

Tested-by: Sebastian Ramacher <sramacher@debian.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit fe211aebbf)
2022-08-02 02:57:41 +02:00
Andreas Rheinhardt
17426f84f6 tests/fate-run: Allow to skip file checksums for lavf_image
The output file (even the filesize) of the recently added
EXR tests depends on the endianness; therefore checksums
of these files must not be part of the ref file. Therefore
this commit adds an option (unused for now) to disable these
checksums on a per-test basis.

In order to avoid having to check twice, the checksum and
the filesize info are moved to immediately follow one another;
this results into updates to the ref files of all lavf-image tests.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit 4fb8741c46)
2022-08-02 02:57:41 +02:00
Andreas Rheinhardt
80d1b8938e fate/imf: Rename IMF fate-target
It conflicts with the name of the test using the testtool
in libavformat.mak.

Fixes ticket #9841.

Reviewed-by: Pierre-Anthony Lemieux <pal@sandflow.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit 3b923116e5)
2022-07-31 19:05:35 +02:00
James Almer
915ef932a3 avcodec/alac: don't fail if channels aren't set during init() when extradata is valid
The decoder is meant to use it as a fallback if the value in extradata is
invalid.

Regression since d199099be.

Signed-off-by: James Almer <jamrial@gmail.com>
2022-07-30 10:24:52 -03:00
Marvin Scholz
6d83c5f876 configure: properly require libx264 if enabled
When libx264 can not be found even though it is enabled, it should error
out properly instead of silently disabling it.

(cherry picked from commit 564d7946de)
2022-07-24 23:06:33 +03:00
Michael Niedermayer
e0723b7e4e 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-07-22 17:31:41 +02:00
Michael Niedermayer
6fbd4d2285 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-07-22 17:31:16 +02:00
Michael Niedermayer
fa511b03d3 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-07-22 17:16:52 +02:00
Michael Niedermayer
5767941df8 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-07-22 17:15:48 +02:00
Michael Niedermayer
e6584a3f19 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-07-22 17:15:14 +02:00
Michael Niedermayer
e8a51675ea avformat/mov: Check for EOF in mov_read_iloc()
Fixes: Timeout
Fixes: 49216/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-6563000529584128

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 744ad45c44)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-22 17:14:53 +02:00
Michael Niedermayer
1c06f776e6 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-07-22 17:12:24 +02:00
Michael Niedermayer
e95f80c8df 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-07-22 17:12:03 +02:00
Michael Niedermayer
6a78425604 avcodec/ffv1dec: Fix AC_GOLOMB_RICE min size check
Found-by: mkver

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit f7d510b33f)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-22 15:48:06 +02:00
Michael Niedermayer
288ef1939f avcodec/ffv1dec: consider run increase in minimal golomb frame size
Fixes: Timeout
Fixes: 49160/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFV1_fuzzer-5672826144686080

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 15785e044e)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-20 18:24:47 +02:00
Michael Niedermayer
cd894807fe 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-07-20 18:24:47 +02:00
Michael Niedermayer
22878e8177 RELEASE_NOTES: Based on the version from 5.0
Name suggested by Leo Izen and Andreas Rheinhardt

LTS text suggested by Martijn van Beurden <mvanb1@gmail.com>

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-20 18:24:16 +02:00
Timo Rothenpieler
d6a1e5980b avutil/hwcontext_d3d11va: fix texture_infos writes on non-fixed-size pools 2022-07-18 02:10:41 +02:00
Marton Balint
83feded492 avdevice/avdevice: fix return value of avdevice_list_devices()
According to API docs avdevice_list_devices(), avdevice_list_input_sources()
and avdevice_list_input_sinks() should return the number of autodetected
devices on success. This is redundant with AVDeviceInfoList->nb_devices so it
was not noticed earlier that none of the underlying device list functions work
like that.

Let's fix it in generic code to make it in line with the API docs.

Fixes ticket #9820.

Signed-off-by: Marton Balint <cus@passwd.hu>
(cherry picked from commit 64f04df379)
2022-07-17 22:12:31 +02:00
Michael Niedermayer
2720715dab 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-07-16 17:08:26 +02:00
Michael Niedermayer
e04cb59ecc Update for 5.1
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-16 17:08:26 +02:00
Gyan Doshi
b21d387d6f ffmpeg: add option -isync
This is a per-file input option that adjusts an input's timestamps
with reference to another input, so that emitted packet timestamps
account for the difference between the start times of the two inputs.

Typical use case is to sync two or more live inputs such as from capture
devices. Both the target and reference input source timestamps should be
based on the same clock source.

If either input lacks starting timestamps, then no sync adjustment is made.
2022-07-14 15:49:10 +05:30
409 changed files with 3400 additions and 1569 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

526
Changelog
View file

@ -1,6 +1,532 @@
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 5.1.6:
avcodec/snow: Fix off by 1 error in run_buffer
avcodec/utils: apply the same alignment to YUV410 as we do to YUV420 for snow
swsresample/swresample: error out on invalid layouts
Update for 5.1.6
avdevice/dshow: Don't skip audio devices if no video device is present
avcodec/cfhdenc: Height of 16 is not supported
avcodec/cfhdenc: Allocate more space
avcodec/vaapi_encode: Check hwctx
avcodec/proresdec: Consider negative bits left
avcodec/alsdec: Clear shift_value
avcodec/hevc/hevcdec: Do not allow slices to depend on failed slices
avutil/slicethread: Check pthread_*_init() for failure
avutil/frame: Check log2_crop_align
avutil/buffer: Check ff_mutex_init() for failure
avformat/xmv: Check this_packet_size
avformat/ty: rec_size seems to only need 32bit
avformat/tty: Check avio_size()
avformat/siff: Basic pkt_size check
avformat/sauce: Check avio_size() for failure
avformat/sapdec: Check ffurl_get_file_handle() for error
avformat/nsvdec: Check asize for PCM
avformat/mp3dec: Check header_filesize
avformat/mp3dec; Check for avio_size() failure
avformat/mov: Use 64bit for str_size
avformat/mm: Check length
avformat/hnm: Check *chunk_size
avformat/hlsenc: Check ret
avformat/bintext: Check avio_size() return
avformat/asfdec_o: Check size of index object
avfilter/vf_scale: Check ff_scale_adjust_dimensions() for failure
avfilter/scale_eval: Use 64bit, check values in ff_scale_adjust_dimensions()
avfilter/vf_lut3d: Check av_scanf()
avfilter/vf_elbg: Use unsigned for shifting into the top bit
avfilter/vf_deshake_opencl: Ensure that the first iteration initializes the best variables
swscale/output: Fix integer overflows in yuv2rgba64_X_c_template
avformat/mxfdec: Reorder elements of expression in bisect loop
avutil/timecode: Use a 64bit framenum internally
avcodec/pnmdec: Use 64bit for input size check
avcodec/mpeg12enc: Use av_rescale() in vbv_buffer_size computation
avcodec/utvideoenc: Use unsigned shift to build flags
avcodec/vc2enc: Fix overflows with storing large values
avcodec/mpegvideo_enc: Do not duplicate pictures on shifting
avdevice/dshow_capture: Fix error handling in ff_dshow_##prefix##_Create()
avcodec/tiff: Check value on positive signed targets
avfilter/vf_convolution_opencl: Assert that the filter name is one of the filters
avfilter/vf_bm3d: Dont round MSE2SSE to an integer
avdevice/dshow: Remove NULL check on pin
avdevice/dshow: check ff_dshow_pin_ConnectionMediaType() for failure
avdevice/dshow: Check device_filter_unique_name before use
avdevice/dshow: Cleanup also on av_log case
avdevice/dshow_filter: Use wcscpy_s()
avcodec/flac_parser: Assert that we do not overrun the link_penalty array
avcodec/pixlet: Simplify pfx computation
avcodec/motion_est: Fix score squaring overflow
avcodec/loco: Check loco_get_rice() for failure
avcodec/loco: check get_ur_golomb_jpegls() for failure
avcodec/imm4: check cbphi for error
avcodec/iff: Use signed count
avcodec/golomb: Assert that k is in the supported range for get_ur/sr_golomb()
avcodec/golomb: Document return for get_ur_golomb_jpegls() and get_sr_golomb_flac()
avcodec/dxv: Fix type in get_opcodes()
avcodec/cri: Check length
avcodec/xsubdec: Check parse_timecode()
avutil/imgutils: av_image_check_size2() ensure width and height fit in 32bit
doc/examples/mux: remove nop
avcodec/proresenc_kostya: use unsigned alpha for rotation
avformat/rtpenc_rfc4175: Use 64bit in computation if copy_offset
avformat/rtmppkt: Simplify and deobfuscate amf_tag_skip() slightly
avformat/rmdec: use 64bit for audio_framesize checks
avutil/wchar_filename: Correct sizeof
avutil/hwcontext_d3d11va: correct sizeof IDirect3DSurface9
avutil/hwcontext_d3d11va: Free AVD3D11FrameDescriptor on error
avutil/hwcontext_d3d11va: correct sizeof AVD3D11FrameDescriptor
doc/examples/vaapi_encode: Try to check fwrite() for failure
avformat/tls_schannel: Initialize ret
avformat/subfile: Assert that whence is a known case
avformat/subfile: Merge if into switch()
avformat/rtsp: Check that lower transport is handled in one of the if()
avformat/rtsp: initialize reply1
avformat/rtsp: use < 0 for error check
avformat/rtpenc_vc2hq: Check sizes
avfilter/af_aderivative: Free out on error
swscale/swscale: Use ptrdiff_t for linesize computations
avfilter/af_pan: check nb_output_channels before use
cbs_av1: Reject thirty-two zero bits in uvlc code
avfilter/af_mcompand: compute half frequency in double
avfilter/af_channelsplit: Assert that av_channel_layout_channel_from_index() succeeds
avfilter/af_aresample: Cleanup on av_channel_layout_copy() failure
tools/coverity: Phase 1 study of anti-halicogenic for coverity av_rescale()
avfilter/vf_avgblur: Check plane instead of AVFrame
avfilter/drawutils: Fix depthb computation
avformat/rdt: Check pkt_len
avformat/mpeg: Check len in mpegps_probe()
avdevice/dshow: Check ICaptureGraphBuilder2_SetFiltergraph() for failure
avcodec/mfenc: check IMFSample_ConvertToContiguousBuffer() for failure
avcodec/vc1_loopfilter: Factor duplicate code in vc1_b_h_intfi_loop_filter()
avformat/img2dec: assert no pipe on ts_from_file
avcodec/cbs_jpeg: Try to move the read entity to one side in a test
avformat/mov: Check edit list for overflow
fftools/ffmpeg: Check read() for failure
swscale/output: Avoid undefined overflow in yuv2rgb_write_full()
swscale/output: alpha can become negative after scaling, use multiply
avcodec/targaenc: Allocate space for the palette
avcodec/r210enc: Use av_rescale for bitrate
avcodec/jfdctint_template: Fewer integer anomalies
avcodec/snowenc: MV limits due to mv_penalty table size
avformat/mxfdec: Check container_ul->desc before use
MAINTAINERS: Update the entries for the release maintainer for FFmpeg
version 5.1.5:
doc/developer: Provide information about git send-email and gmail
avfilter/vf_rotate: Check ff_draw_init2() return value
avformat/mov: Use int64_t in intermediate for corrected_dts
avformat/mov: Use 64bit in intermediate for current_dts
avformat/matroskadec: Assert that num_levels is non negative
avformat/libzmq: Check av_strstart()
avformat/img2dec: Little JFIF / Exif cleanup
avformat/img2dec: Move DQT after unrelated if()
avdevice/xcbgrab: Check sscanf() return
fftools/cmdutils: Add protective () to FLAGS
avformat/sdp: Check before appending ","
avcodec/ilbcdec: Remove dead code
avcodec/vp8: Check cond init
avcodec/vp8: Check mutex init
avcodec/pcm-dvdenc: 64bit pkt-size
avcodec/notchlc: Check init_get_bits8() for failure
avcodec/tests/dct: Use 64bit in intermediate for error computation
avcodec/scpr3: Check add_dec() for failure
avcodec/rv34: assert that size is not 0 in rv34_gen_vlc_ext()
avcodec/wavpackenc: Use unsigned for potential 31bit shift
avcodec/tests/jpeg2000dwt: Use 64bit in comparission
avcodec/tests/jpeg2000dwt: Use 64bit in err2 computation
avformat/fwse: Remove always false expression
avcodec/sga: Make it clear that the return is intentionally not checked
avformat/asfdec_f: Use 64bit for preroll computation
avformat/argo_asf: Use 64bit in offset intermediate
avformat/ape: Use 64bit for final frame size
avdevice/pulse_audio_enc: Use av_rescale() to avoid integer overflow
avcodec/tiff: Assert init_get_bits8() success in unpack_gray()
avcodec/tiff: Assert init_get_bits8() success in horizontal_fill()
swscale/yuv2rgb: Use 64bit for brightness computation
swscale/x86/swscale: use a clearer name for INPUT_PLANER_RGB_A_FUNC_CASE
avutil/tests/opt: Check av_set_options_string() for failure
avutil/tests/dict: Check av_dict_set() before get for failure
avdevice/dshow: fix badly indented line
avformat/demux: resurrect dead stores
avcodec/mscc & mwsc: Check loop counts before use
avcodec/mpegvideo_enc: Fix potential overflow in RD
avcodec/mpeg4videodec: assert impossible wrap points
avcodec/mpeg12dec: Use 64bit in bit computation
avcodec/vble: Check av_image_get_buffer_size() for failure
avcodec/vp3: Replace check by assert
avcodec/jpeg2000dec: remove ST=3 case
avcodec/qsvdec: Check av_image_get_buffer_size() for failure
avcodec/exr: Fix preview overflow
avcodec/fmvc: remove dead assignment
avcodec/h264_slice: Remove dead sps check
avcodec/lpc: copy levenson coeffs only when they have been computed
avutil/tests/base64: Check with too short output array
libavutil/base64: Try not to write over the array end
avcodec/cbs_av1: Avoid shift overflow
fftools/ffplay: Check return of swr_alloc_set_opts2()
tools/opt_common: Check for malloc failure
doc/examples/demux_decode: Simplify loop
avformat/concatdec: Check file
avcodec/mpegvideo_enc: Fix 1 line and one column images
swscale/output: Fix integer overflow in yuv2rgba64_full_1_c_template()
swscale/output: Fix integer overflow in yuv2rgba64_1_c_template
avcodec/avs3_parser: assert the return value of init_get_bits()
avcodec/avs2_parser: Assert init_get_bits8() success with const size 15
avformat/mxfdec: Check body_offset
avformat/kvag: Check sample_rate
avcodec/ac3_parser: Check init_get_bits8() for failure
avcodec/pngdec: Check last AVFrame before deref
avcodec/hevcdec: Check ref frame
doc/examples/vaapi_transcode: Simplify loop
avfilter/vf_thumbnail_cuda: Set ret before checking it
avfilter/signature_lookup: Dont copy uninitialized stuff around
avfilter/signature_lookup: Fix 2 differences to the refernce SW
(origin/release/5.1, github/release/5.1) lavc/vp9: reset segmentation fields when segmentation isn't enabled
configure: enable ffnvcodec, nvenc, nvdec for FreeBSD
avcodec/x86/vp3dsp_init: Set correct function pointer, fix crash
avutil/ppc/cpu: Also use the machdep.altivec sysctl on NetBSD
lavd/v4l2: Use proper field type for second parameter of ioctl() with BSD's
Update for 5.1.5
fate/subtitles: Ignore line endings for sub-scc test
avformat/mxfdec: Check index_edit_rate
swscale/utils: Fix xInc overflow
avformat/isom: Uninit layout in ff_mp4_read_dec_config_descr()
avcodec/exr: Dont use 64bits to hold 6bits
avcodec/exr: Check for remaining bits in huf_unpack_enc_table()
avformat/mpegts: Reset local nb_prg on add_program() failure
avformat/aiffdec: Check for previously set channels
avformat/mxfdec: Make edit_unit_byte_count unsigned
avformat/movenc: Check that cts fits in 32bit
avformat/mxfdec: Check first case of offset_temp computation for overflow
avfilter/vf_signature: Dont crash on no frames
avformat/westwood_vqa: Fix 2g packets
avformat/matroskadec: Check timescale
avformat/wavdec: satuarte next_tag_ofs, data_end
avformat/sbgdec: Check for negative duration
avformat/rpl: Use 64bit for total_audio_size and check it
avformat/timecode: use 64bit for intermediate for rounding in fps_from_frame_rate()
avformat/mov: use 64bit for intermediate for rounding
avformat/jacosubdec: Use 64bit for abs
avformat/concatdec: Check user_duration sum
avcodec/truemotion1: Height not being a multiple of 4 is unsupported
avcodec/hcadec: do not set hfr_group_count to invalid values
avformat/concatdec: clip outpoint - inpoint overflow in get_best_effort_duration()
avformat/jacosubdec: clarify code
avformat/cafdec: Check that data chunk end fits within 64bit
avformat/iff: Saturate avio_tell() + 12
avformat/dxa: Adjust order of operations around block align
avformat/cafdec: dont seek beyond 64bit
avformat/id3v2: read_uslt() check for the amount read
avcodec/proresenc_kostya: Remove bug similarity text
avcodec/vorbisdec: Check remaining data in vorbis_residue_decode_internal()
avformat/concatdec: Check in and outpoints to be to produce a positive representable duration
libswscale/utils: Fix bayer to yuvj
swscale/swscale: Check srcSliceH for bayer
swscale/utils: Allocate more dithererror
avcodec/indeo3: Round dimensions up in allocate_frame_buffers()
avutil/rational: Document what is to be expected from av_d2q() of doubles representing rational numbers
avfilter/signature_lookup: Do not dereference NULL pointers after malloc failure
avfilter/signature_lookup: dont leave uncleared pointers in sll_free()
avcodec/mpegvideo_enc: Use ptrdiff_t for stride
libavformat/hlsenc.c: Populate OTI using AAC profile in write_codec_attr.
avcodec/mpegvideo_enc: Dont copy beyond the image
avfilter/vf_minterpolate: Check pts before division
avformat/flacdec: Avoid double AVERRORS
avfilter/vf_vidstabdetect: Avoid double AVERRORS
avfilter/vf_swaprect: round coordinates down
avfilter/vf_swaprect: Use height for vertical variables
avfilter/vf_swaprect: assert that rectangles are within memory
avfilter/af_alimiter: Check nextpos before use
avfilter/f_reverse: Apply PTS compensation only when pts is available
avfilter/af_stereowiden: Check length
avfilter/vf_weave: Fix odd height handling
avfilter/vf_gradfun: Do not overread last line
avfilter/avf_showspectrum: fix off by 1 error
avformat/mov: do not set sign bit for chunk_offsets
avcodec/jpeglsdec: Check Jpeg-LS LSE
configure: Enable section_data_rel_ro for FreeBSD and NetBSD aarch64 / arm
avcodec/av1dec: Fix resolving zero divisor
avformat/mov: Ignore duplicate ftyp
avformat/mov: Fix integer overflow in mov_read_packet().
avformat/mov: Check if a key is longer than the atom containing it
avfilter/buffersrc: fix overriding unknown channel layouts with negotiated one
avfilter/af_channelmap: disallow channel index 64
avfilter/af_channelmap: fix mapping if in_channel was a string but out_channel was not specified
avfilter/af_channelmap: fix error message if FL source channel was missing
avcodec/nvdec: reset bitstream_len/nb_slices when resetting bitstream pointer
avformat/mov: don't abort on duplicate Mastering Display Metadata boxes
fftools/ffplay: use correct buffersink channel layout parameters
swresample/resample: fix rounding errors with filter_size=1 and phase_shift=0
avformat/mxfdec: remove resolve_strong_ref usage with AnyType
avformat/libsrt: use SRT_EPOLL_IN for waiting for an incoming connection
avformat/mxfdec: do not use AnyType when resolving Descriptors and MultipleDescriptors
avformat/mxfdec: move resolving Descriptors to the multi descriptor resolve function
avcodec/av1dec: fix matrix coefficients exposed by codec context
avformat/mov_chan: never override number of channels based on chan atom
avformat/mov_chan: do not assume channels are in native order
avcodec/nvdec: don't free NVDECContext->bitstream
fftools/ffmpeg_enc: apply -top to individual encoded frames
fftools/ffprobe: support 2D arrays in print_list_fmt()
version 5.1.4:
avcodec/4xm: Check for cfrm exhaustion
avformat/mov: Disallow FTYP after streams
doc/html: fix styling issue with Texinfo 7.0
doc/html: support texinfo 7.0
avfilter/buffersink: fix order of operation with = and <0
tools/target_dec_fuzzer: Adjust threshold for CSCD
avcodec/dovi_rpu: Use 64 bit in get_us/se_coeff()
avformat/mov: Check that is_still_picture_avif has no trak based streams
avformat/matroskadec: Fix declaration-after-statement warnings
avformat/rtsp: Use rtsp_st->stream_index
avcodec/jpeg2000dec: Check image offset
avformat/mxfdec: Check klv offset
libavutil/ppc/cpu.c: check that AT_HWCAP2 is defined
avcodec/h2645_parse: Avoid EAGAIN
avcodec/xvididct: Make c* unsigned to avoid undefined overflows
avformat/tmv: Check video chunk size
avcodec/h264_parser: saturate dts a bit
avformat/asfdec_f: Saturate presentation time in marker
avformat/xwma: sanity check bits_per_coded_sample
avformat/matroskadec: Check prebuffered_ns for overflow
avformat/wavdec: Check left avio_tell for overflow
avformat/tta: Better totalframes check
avformat/rpl: Check for number_of_chunks overflow
avformat/mov: compute absolute dts difference without overflow in mov_find_next_sample()
avformat/jacosubdec: Check timeres
avformat/jacosubdec: avoid signed integer overflows in get_shift()
avformat/jacosubdec: Factorize code in get_shift() a bit
avformat/sbgdec: Check for negative duration or un-representable end pts
avcodec/escape124: Do not return random numbers
avcodec/apedec: Fix an integer overflow in predictor_update_filter()
tools/target_dec_fuzzer: Adjust wmapro threshold
avformat/avs: Check if return code is representable
avcodec/lcldec: Make PNG filter addressing match the code afterwards
avformat/westwood_vqa: Check chunk size
avformat/sbgdec: Check for period overflow
avformat/concatdec: Check in/outpoint for overflow
avformat/mxfdec: Remove this_partition
avcodec/xvididct: Fix integer overflow in idct_row()
avcodec/celp_math: avoid overflow in shift
tools/target_dec_fuzzer: Adjust threshold for rtv1
avformat/hls: reduce default max reload to 3
avformat/format: Stop reading data at EOF during probing
avcodec/jpeg2000dec: jpeg2000 has its own lowres option
avcodec/huffyuvdec: avoid undefined behavior with get_vlc2() failure
avcodec/cscd: Fix "CamStudio Lossless Codec 1.0" gzip files
avcodec/cscd: Check for CamStudio Lossless Codec 1.0 behavior in end check of LZO files
avcodec/mpeg4videodec: consider lowres in dest_pcm[]
avcodec/hevcdec: Fix undefined memcpy()
avcodec/mpeg4videodec: more unsigned in amv computation
avcodec/tta: fix signed overflow in decorrelate
avcodec/apedec: Fix 48khz 24bit below insane level
avcodec/apedec: Fix CRC for 24bps and bigendian
avcodec/xvididct: Fix integer overflow in idct_row()
avformat/avr: Check sample rate
avformat/imf_cpl: Replace NULL content_title_utf8 by ""
avformat/imf_cpl: xmlNodeListGetString() can return NULL
avcodec/pcm: allow Changing parameters
avcodec/jpeg2000dec: Check for reduction factor and image offset
avutil/softfloat: Basic documentation for av_sincos_sf()
avutil/softfloat: fix av_sincos_sf()
tools/target_dec_fuzzer: Adjust threshold for speex
avcodec/utils: fix 2 integer overflows in get_audio_frame_duration()
avcodec/hevcdec: Avoid null pointer dereferences in MC
avcodec/takdsp: Fix integer overflows
avcodec: Ignoring errors is only possible before the input end
avformat/jpegxl_probe: Forward error codes
avformat/jpegxl_probe: check length instead of blindly reading
avformat/jpegxl_probe: Remove intermediate macro obfuscation around get_bits*()
avcodec/noise_bsf: Check for wrapped frames
avformat/oggparsetheora: clip duration within 64bit
avformat/wavdec: Check that smv block fits in available space
avcodec/tiff: add a zero DNG_LINEARIZATION_TABLE check
avcodec/tak: Check remaining bits in ff_tak_decode_frame_header()
avcodec/sonic: Fix two undefined integer overflows
avcodec/utils: the IFF_ILBM implementation assumes that there are a multiple of 16 allocated
avcodec/exr: Cleanup befor return
avcodec/pngdec: Do not pass AVFrame into global header decode
avcodec/pngdec: remove AVFrame argument from decode_iccp_chunk()
avcodec/vorbisdec: Check codebook float values to be finite
avcodec/g2meet: Replace fake allocation avoidance for framebuf
avutil/tx_priv: Use unsigned in BF() to avoid signed overflows
avcodec/lcldec: More space for rgb24
avcodec/lcldec: Support 4:1:1 and 4:2:2 with odd width
libavcodec/lcldec: width and height should not be unsigned
avformat/imf: fix invalid resource handling
avcodec/escape124: Check that blocks are allocated before use
avcodec/huffyuvdec: Fix undefined behavior with shift
avcodec/j2kenc: Replace RGB24 special case by generic test
avcodec/j2kenc: Replace BGR48 / GRAY16 test by test for number of bits
avcodec/j2kenc: simplify pixel format setup
avcodec/j2kenc: Fix funky bpno errors on decoding
avcodec/j2kenc: remove misleading pred value
avcodec/j2kenc: fix 5/3 DWT identifer
avcodec/vp3: Check width to avoid assertion failure
avcodec/g729postfilter: Limit shift in long term filter
configure: update copyright year
Changelog: Add forgotten line
libavformat/riffec: Zero-initialize channels in ff_get_wav_header
avcodec/x86/mathops: clip constants used with shift instructions within inline assembly
avcodec/libsvtav1: use larger of bit rate and max rate for buffer size
avcodec/libsvtav1: only set max_buf_sz if both bitrate and rc_buf_sz is set
avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
avcodec/libsvtav1: replace vbv_bufsize with maximum_buffer_size_ms
avcodec/vdpau_mpeg4: fix order of quant matrix coefficients
avcodec/vdpau_mpeg12: fix order of quant matrix coefficients
avcodec/nvdec_mpeg4: fix order of quant matrix coefficients
avcodec/nvdec_mpeg2: fix order of quant matrix coefficients
fftools/ffmpeg: avoid possible invalid reads with short -tag values
avcodec/mp_cmp: reject invalid comparison function values
avcodec/aacpsy: clip global_quality within the psy_vbr_map array boundaries
avutil/wchar_filename: propagate MultiByteToWideChar() and WideCharToMultiByte() failures
avformat/concatf: check if any nodes were allocated
avcodec/nvenc: fix b-frame DTS behavior with fractional framerates
version 5.1.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
- avfilter/vf_untile: swap the chroma shift values used for plane offsets
- update for 5.1.3
- 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
- lavu/vulkan: fix handle type for 32-bit targets
- vulkan: Fix win/i386 calling convention
- 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
- avutil/tx: Use unsigned in ff_tx_fft_sr_combine() to avoid undefined behavior
- swscale/input: Use more unsigned intermediates
- avcodec/alsdec: Check bits left before block decoding in non multi channel coding loop
- 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 for GBRP16/GBRPF32
- 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
- avcodec/speexdec: Check channels > 2
- avformat/vividas: Check packet size
- hwcontext_vulkan: remove optional encode/decode extensions from the list
- avcodec/libjxldec: fix gamma22 and gamma28 recognition
- avcodec/mpeg12dec: use init_get_bits8 and check the return value
- avcodec/nvenc: fix vbv buffer size in cq mode
- avcodec/mjpegenc: take into account component count when writing the SOF header size
- swscale: aarch64: Fix yuv2rgb with negative strides
- avcodec/atrac3plus: reorder channels to match the output layout
- avcodec/aacdec: fix parsing streams with channel configuration 11
- libswscale: force a minimum size of the slide for bayer sources
- lavf/async: Fix ring_write return value
- avcodec/audiotoolboxenc: return AVERROR_EXTERNAL immediately when encode error
- avcodec/libjxlenc: avoid hard failure with unspecified primaries
version 5.1.2:
- 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/genh: Check nb_channels for IMA ADPCM
- 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/apm: Use 64bit for bit_rate computation
- 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
- avformat/cafenc: derive Opus frame size from the relevant stream parameters
- avformat/dashdec: Fix crash on invalid input/ENOMEM, fix leak
- lavc/videotoolbox: do not pass AVCodecContext to decoder output callback
- lavc/pthread_frame: always transfer stashed hwaccel state
- avcodec/arm/sbcenc: avoid callee preserved vfp registers
- avformat/riffdec: don't unconditionally overwrite WAVEFORMATEXTENSIBLE layout
- avfilter/vf_scale: overwrite the width and height expressions with the original values
- lavc/pthread_frame: avoid leaving stale hwaccel state in worker threads
- avutil/tests/.gitignore: Add channel_layout testtool
version 5.1.1:
- avformat/asfdec_o: limit recursion depth in asf_read_unknown()
- avformat/mov: Check count sums in build_open_gop_key_points()
- 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/pngdec: Fix APNG_DISPOSE_OP_BACKGROUND
- avcodec/libvpx: fix assembling vp9 packets with alpha channel
- fftools/ffmpeg_opt: try to propagate the requested output channel layout
- avcodec/libsvtav1: properly initialize the flush EbBufferHeaderType struct
- configure: enable the av1_frame_split bsf for the av1 decoder
- swresample/swresample: fill the correct buffer to print the output layout string
- ffprobe: restore reporting error code for failed inputs
- ipfsgateway: Remove default gateway
- avcodec/libspeexdec: Fix use of uninitialized value
- avformat/avisynth: use ch_layout.nb_channels for channel count
- fate/lavf-image: Disable file checksums for exr tests
- tests/fate-run: Allow to skip file checksums for lavf_image
- fate/imf: Rename IMF fate-target
- avcodec/alac: don't fail if channels aren't set during init() when extradata is valid
- configure: properly require libx264 if enabled
version 5.1: version 5.1:
- add ipfs/ipns protocol support - add ipfs/ipns protocol support
- dialogue enhance audio filter - dialogue enhance audio filter

View file

@ -591,10 +591,12 @@ wm4
Releases Releases
======== ========
7.0 Michael Niedermayer
6.1 Michael Niedermayer
5.1 Michael Niedermayer
4.4 Michael Niedermayer
3.4 Michael Niedermayer
2.8 Michael Niedermayer 2.8 Michael Niedermayer
2.7 Michael Niedermayer
2.6 Michael Niedermayer
2.5 Michael Niedermayer
If you want to maintain an older release, please contact us If you want to maintain an older release, please contact us
@ -625,6 +627,7 @@ Leo Izen (thebombzen) B6FD 3CFC 7ACF 83FC 9137 6945 5A71 C331 FD2F A19A
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
Niklas Haas (haasn) 1DDB 8076 B14D 5B48 32FC 99D9 EB52 DA9C 02BA 6FB4 Niklas Haas (haasn) 1DDB 8076 B14D 5B48 32FC 99D9 EB52 DA9C 02BA 6FB4
Nikolay Aleksandrov 8978 1D8C FB71 588E 4B27 EAA8 C4F0 B5FC E011 13B1 Nikolay Aleksandrov 8978 1D8C FB71 588E 4B27 EAA8 C4F0 B5FC E011 13B1

View file

@ -1 +1 @@
4.4.git 5.1.6

18
RELEASE_NOTES Normal file
View file

@ -0,0 +1,18 @@
┌────────────────────────────────────────────┐
│ RELEASE NOTES for FFmpeg 5.1 "Riemann" LTS │
└────────────────────────────────────────────┘
The FFmpeg Project proudly presents FFmpeg 5.1 "Riemann" LTS, about 6
months after the release of FFmpeg 5.0, our first Long Term Support
release. While several past FFmpeg releases have enjoyed long term
support, this is the first release where such an intention is made
clear at release.
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.

32
configure vendored
View file

@ -2121,6 +2121,7 @@ ARCH_EXT_LIST_PPC="
ldbrx ldbrx
power8 power8
ppc4xx ppc4xx
vec_xl
vsx vsx
" "
@ -2415,6 +2416,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
@ -2633,6 +2635,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"
@ -2781,7 +2784,7 @@ atrac3al_decoder_select="mdct"
atrac3p_decoder_select="mdct sinewin" atrac3p_decoder_select="mdct sinewin"
atrac3pal_decoder_select="mdct sinewin" atrac3pal_decoder_select="mdct sinewin"
atrac9_decoder_select="mdct" atrac9_decoder_select="mdct"
av1_decoder_select="cbs_av1" av1_decoder_select="av1_frame_split_bsf cbs_av1"
bink_decoder_select="blockdsp hpeldsp" bink_decoder_select="blockdsp hpeldsp"
binkaudio_dct_decoder_select="mdct rdft dct sinewin wma_freqs" binkaudio_dct_decoder_select="mdct rdft dct sinewin wma_freqs"
binkaudio_rdft_decoder_select="mdct rdft sinewin wma_freqs" binkaudio_rdft_decoder_select="mdct rdft sinewin wma_freqs"
@ -5495,6 +5498,7 @@ case $target_os in
;; ;;
netbsd) netbsd)
disable symver disable symver
enable section_data_rel_ro
oss_indev_extralibs="-lossaudio" oss_indev_extralibs="-lossaudio"
oss_outdev_extralibs="-lossaudio" oss_outdev_extralibs="-lossaudio"
enabled gcc || check_ldflags -Wl,-zmuldefs enabled gcc || check_ldflags -Wl,-zmuldefs
@ -5513,6 +5517,7 @@ case $target_os in
disable symver disable symver
;; ;;
freebsd) freebsd)
enable section_data_rel_ro
;; ;;
bsd/os) bsd/os)
add_extralibs -lpoll -lgnugetopt add_extralibs -lpoll -lgnugetopt
@ -6088,6 +6093,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()"
@ -6666,7 +6676,7 @@ enabled libvpx && {
enabled libwebp && { enabled libwebp && {
enabled libwebp_encoder && require_pkg_config libwebp "libwebp >= 0.2.0" webp/encode.h WebPGetEncoderVersion enabled libwebp_encoder && require_pkg_config libwebp "libwebp >= 0.2.0" webp/encode.h WebPGetEncoderVersion
enabled libwebp_anim_encoder && check_pkg_config libwebp_anim_encoder "libwebpmux >= 0.4.0" webp/mux.h WebPAnimEncoderOptionsInit; } enabled libwebp_anim_encoder && check_pkg_config libwebp_anim_encoder "libwebpmux >= 0.4.0" webp/mux.h WebPAnimEncoderOptionsInit; }
enabled libx264 && check_pkg_config libx264 x264 "stdint.h x264.h" x264_encoder_encode && enabled libx264 && require_pkg_config libx264 x264 "stdint.h x264.h" x264_encoder_encode &&
require_cpp_condition libx264 x264.h "X264_BUILD >= 118" && { require_cpp_condition libx264 x264.h "X264_BUILD >= 118" && {
[ "$toolchain" != "msvc" ] || [ "$toolchain" != "msvc" ] ||
require_cpp_condition libx264 x264.h "X264_BUILD >= 158"; } && require_cpp_condition libx264 x264.h "X264_BUILD >= 158"; } &&
@ -6797,14 +6807,16 @@ enabled makeinfo \
disabled makeinfo_html && texi2html --help 2> /dev/null | grep -q 'init-file' && enable texi2html || disable texi2html disabled makeinfo_html && texi2html --help 2> /dev/null | grep -q 'init-file' && enable texi2html || disable texi2html
perl -v > /dev/null 2>&1 && enable perl || disable perl perl -v > /dev/null 2>&1 && enable perl || disable perl
pod2man --help > /dev/null 2>&1 && enable pod2man || disable pod2man 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;"
@ -6849,8 +6861,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 ||
@ -6957,7 +6968,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
@ -7538,6 +7549,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}"
@ -7783,7 +7795,7 @@ cat > $TMPH <<EOF
#define FFMPEG_CONFIG_H #define FFMPEG_CONFIG_H
#define FFMPEG_CONFIGURATION "$(c_escape $FFMPEG_CONFIGURATION)" #define FFMPEG_CONFIGURATION "$(c_escape $FFMPEG_CONFIGURATION)"
#define FFMPEG_LICENSE "$(c_escape $license)" #define FFMPEG_LICENSE "$(c_escape $license)"
#define CONFIG_THIS_YEAR 2022 #define CONFIG_THIS_YEAR 2024
#define FFMPEG_DATADIR "$(eval c_escape $datadir)" #define FFMPEG_DATADIR "$(eval c_escape $datadir)"
#define AVCONV_DATADIR "$(eval c_escape $datadir)" #define AVCONV_DATADIR "$(eval c_escape $datadir)"
#define CC_IDENT "$(c_escape ${cc_ident:-Unknown compiler})" #define CC_IDENT "$(c_escape ${cc_ident:-Unknown compiler})"

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.1.6
# 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

@ -494,6 +494,11 @@ patch is inline or attached per mail.
You can check @url{https://patchwork.ffmpeg.org}, if your patch does not show up, its mime type You can check @url{https://patchwork.ffmpeg.org}, if your patch does not show up, its mime type
likely was wrong. likely was wrong.
@subheading How to setup git send-email?
Please see @url{https://git-send-email.io/}.
For gmail additionally see @url{https://shallowsky.com/blog/tech/email/gmail-app-passwds.html}.
@subheading Sending patches from email clients @subheading Sending patches from email clients
Using @code{git send-email} might not be desirable for everyone. The Using @code{git send-email} might not be desirable for everyone. The
following trick allows to send patches via email clients in a safe following trick allows to send patches via email clients in a safe

View file

@ -138,11 +138,9 @@ static int decode_packet(AVCodecContext *dec, const AVPacket *pkt)
ret = output_audio_frame(frame); ret = output_audio_frame(frame);
av_frame_unref(frame); av_frame_unref(frame);
if (ret < 0)
return ret;
} }
return 0; return ret;
} }
static int open_codec_context(int *stream_idx, static int open_codec_context(int *stream_idx,

View file

@ -351,8 +351,7 @@ static int write_audio_frame(AVFormatContext *oc, OutputStream *ost)
if (frame) { if (frame) {
/* convert samples from native format to destination codec format, using the resampler */ /* convert samples from native format to destination codec format, using the resampler */
/* compute destination number of samples */ /* compute destination number of samples */
dst_nb_samples = av_rescale_rnd(swr_get_delay(ost->swr_ctx, c->sample_rate) + frame->nb_samples, dst_nb_samples = swr_get_delay(ost->swr_ctx, c->sample_rate) + frame->nb_samples;
c->sample_rate, c->sample_rate, AV_ROUND_UP);
av_assert0(dst_nb_samples == frame->nb_samples); av_assert0(dst_nb_samples == frame->nb_samples);
/* when we pass a frame to the encoder, it may keep a reference to it /* when we pass a frame to the encoder, it may keep a reference to it

View file

@ -91,6 +91,10 @@ static int encode_write(AVCodecContext *avctx, AVFrame *frame, FILE *fout)
enc_pkt->stream_index = 0; enc_pkt->stream_index = 0;
ret = fwrite(enc_pkt->data, enc_pkt->size, 1, fout); ret = fwrite(enc_pkt->data, enc_pkt->size, 1, fout);
av_packet_unref(enc_pkt); av_packet_unref(enc_pkt);
if (ret != enc_pkt->size) {
ret = AVERROR(errno);
break;
}
} }
end: end:

View file

@ -218,10 +218,8 @@ static int dec_enc(AVPacket *pkt, const AVCodec *enc_codec)
fail: fail:
av_frame_free(&frame); av_frame_free(&frame);
if (ret < 0)
return ret;
} }
return 0; return ret;
} }
int main(int argc, char **argv) int main(int argc, char **argv)

View file

@ -518,6 +518,21 @@ see @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1)
Like the @code{-ss} option but relative to the "end of file". That is negative Like the @code{-ss} option but relative to the "end of file". That is negative
values are earlier in the file, 0 is at EOF. values are earlier in the file, 0 is at EOF.
@item -isync @var{input_index} (@emph{input})
Assign an input as a sync source.
This will take the difference between the start times of the target and reference inputs and
offset the timestamps of the target file by that difference. The source timestamps of the two
inputs should derive from the same clock source for expected results. If @code{copyts} is set
then @code{start_at_zero} must also be set. If either of the inputs has no starting timestamp
then no sync adjustment is made.
Acceptable values are those that refer to a valid ffmpeg input index. If the sync reference is
the target index itself or @var{-1}, then no adjustment is made to target timestamps. A sync
reference may not itself be synced to any other input.
Default value is @var{-1}.
@item -itsoffset @var{offset} (@emph{input}) @item -itsoffset @var{offset} (@emph{input})
Set the input time offset. Set the input time offset.

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

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

View file

@ -20,8 +20,45 @@
# License along with FFmpeg; if not, write to the Free Software # 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

@ -506,7 +506,7 @@ static const AVOption *opt_find(void *obj, const char *name, const char *unit,
return o; return o;
} }
#define FLAGS (o->type == AV_OPT_TYPE_FLAGS && (arg[0]=='-' || arg[0]=='+')) ? AV_DICT_APPEND : 0 #define FLAGS ((o->type == AV_OPT_TYPE_FLAGS && (arg[0]=='-' || arg[0]=='+')) ? AV_DICT_APPEND : 0)
int opt_default(void *optctx, const char *opt, const char *arg) int opt_default(void *optctx, const char *opt, const char *arg)
{ {
const AVOption *o; const AVOption *o;

View file

@ -491,8 +491,9 @@ static int read_key(void)
} }
//Read it //Read it
if(nchars != 0) { if(nchars != 0) {
read(0, &ch, 1); if (read(0, &ch, 1) == 1)
return ch; return ch;
return 0;
}else{ }else{
return -1; return -1;
} }
@ -1278,6 +1279,9 @@ static void do_video_out(OutputFile *of,
av_log(NULL, AV_LOG_DEBUG, "Forced keyframe at time %f\n", pts_time); av_log(NULL, AV_LOG_DEBUG, "Forced keyframe at time %f\n", pts_time);
} }
if (ost->top_field_first >= 0)
in_picture->top_field_first = !!ost->top_field_first;
ret = encode_frame(of, ost, in_picture); ret = encode_frame(of, ost, in_picture);
if (ret < 0) if (ret < 0)
exit_program(1); exit_program(1);

View file

@ -118,6 +118,7 @@ typedef struct OptionsContext {
float readrate; float readrate;
int accurate_seek; int accurate_seek;
int thread_queue_size; int thread_queue_size;
int input_sync_ref;
SpecifierOpt *ts_scale; SpecifierOpt *ts_scale;
int nb_ts_scale; int nb_ts_scale;
@ -410,6 +411,7 @@ typedef struct InputFile {
at the moment when looping happens */ at the moment when looping happens */
AVRational time_base; /* time base of the duration */ AVRational time_base; /* time base of the duration */
int64_t input_ts_offset; int64_t input_ts_offset;
int input_sync_ref;
int64_t ts_offset; int64_t ts_offset;
int64_t last_ts; int64_t last_ts;

View file

@ -235,6 +235,7 @@ static void init_options(OptionsContext *o)
o->chapters_input_file = INT_MAX; o->chapters_input_file = INT_MAX;
o->accurate_seek = 1; o->accurate_seek = 1;
o->thread_queue_size = -1; o->thread_queue_size = -1;
o->input_sync_ref = -1;
} }
static int show_hwaccels(void *optctx, const char *opt, const char *arg) static int show_hwaccels(void *optctx, const char *opt, const char *arg)
@ -287,6 +288,58 @@ static int parse_and_set_vsync(const char *arg, int *vsync_var, int file_idx, in
return 0; return 0;
} }
static int apply_sync_offsets(void)
{
for (int i = 0; i < nb_input_files; i++) {
InputFile *ref, *self = input_files[i];
int64_t adjustment;
int64_t self_start_time, ref_start_time, self_seek_start, ref_seek_start;
int start_times_set = 1;
if (self->input_sync_ref == -1 || self->input_sync_ref == i) continue;
if (self->input_sync_ref >= nb_input_files || self->input_sync_ref < -1) {
av_log(NULL, AV_LOG_FATAL, "-isync for input %d references non-existent input %d.\n", i, self->input_sync_ref);
exit_program(1);
}
if (copy_ts && !start_at_zero) {
av_log(NULL, AV_LOG_FATAL, "Use of -isync requires that start_at_zero be set if copyts is set.\n");
exit_program(1);
}
ref = input_files[self->input_sync_ref];
if (ref->input_sync_ref != -1 && ref->input_sync_ref != self->input_sync_ref) {
av_log(NULL, AV_LOG_ERROR, "-isync for input %d references a resynced input %d. Sync not set.\n", i, self->input_sync_ref);
continue;
}
if (self->ctx->start_time_realtime != AV_NOPTS_VALUE && ref->ctx->start_time_realtime != AV_NOPTS_VALUE) {
self_start_time = self->ctx->start_time_realtime;
ref_start_time = ref->ctx->start_time_realtime;
} else if (self->ctx->start_time != AV_NOPTS_VALUE && ref->ctx->start_time != AV_NOPTS_VALUE) {
self_start_time = self->ctx->start_time;
ref_start_time = ref->ctx->start_time;
} else {
start_times_set = 0;
}
if (start_times_set) {
self_seek_start = self->start_time == AV_NOPTS_VALUE ? 0 : self->start_time;
ref_seek_start = ref->start_time == AV_NOPTS_VALUE ? 0 : ref->start_time;
adjustment = (self_start_time - ref_start_time) + !copy_ts*(self_seek_start - ref_seek_start) + ref->input_ts_offset;
self->ts_offset += adjustment;
av_log(NULL, AV_LOG_INFO, "Adjusted ts offset for Input #%d by %"PRId64" us to sync with Input #%d.\n", i, adjustment, self->input_sync_ref);
} else {
av_log(NULL, AV_LOG_INFO, "Unable to identify start times for Inputs #%d and %d both. No sync adjustment made.\n", i, self->input_sync_ref);
}
}
return 0;
}
static int opt_filter_threads(void *optctx, const char *opt, const char *arg) static int opt_filter_threads(void *optctx, const char *opt, const char *arg)
{ {
av_free(filter_nbthreads); av_free(filter_nbthreads);
@ -845,8 +898,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;
} }
@ -1305,6 +1361,7 @@ static int open_input_file(OptionsContext *o, const char *filename)
f->ist_index = nb_input_streams - ic->nb_streams; f->ist_index = nb_input_streams - ic->nb_streams;
f->start_time = o->start_time; f->start_time = o->start_time;
f->recording_time = o->recording_time; f->recording_time = o->recording_time;
f->input_sync_ref = o->input_sync_ref;
f->input_ts_offset = o->input_ts_offset; f->input_ts_offset = o->input_ts_offset;
f->ts_offset = o->input_ts_offset - (copy_ts ? (start_at_zero && ic->start_time != AV_NOPTS_VALUE ? ic->start_time : 0) : timestamp); f->ts_offset = o->input_ts_offset - (copy_ts ? (start_at_zero && ic->start_time != AV_NOPTS_VALUE ? ic->start_time : 0) : timestamp);
f->nb_streams = ic->nb_streams; f->nb_streams = ic->nb_streams;
@ -1606,8 +1663,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;
} }
@ -2318,6 +2378,43 @@ static int init_complex_filters(void)
return 0; return 0;
} }
static void set_channel_layout(OutputFilter *f, OutputStream *ost)
{
int i, err;
if (ost->enc_ctx->ch_layout.order != AV_CHANNEL_ORDER_UNSPEC) {
/* Pass the layout through for all orders but UNSPEC */
err = av_channel_layout_copy(&f->ch_layout, &ost->enc_ctx->ch_layout);
if (err < 0)
exit_program(1);
return;
}
/* Requested layout is of order UNSPEC */
if (!ost->enc->ch_layouts) {
/* Use the default native layout for the requested amount of channels when the
encoder doesn't have a list of supported layouts */
av_channel_layout_default(&f->ch_layout, ost->enc_ctx->ch_layout.nb_channels);
return;
}
/* Encoder has a list of supported layouts. Pick the first layout in it with the
same amount of channels as the requested layout */
for (i = 0; ost->enc->ch_layouts[i].nb_channels; i++) {
if (ost->enc->ch_layouts[i].nb_channels == ost->enc_ctx->ch_layout.nb_channels)
break;
}
if (ost->enc->ch_layouts[i].nb_channels) {
/* Use it if one is found */
err = av_channel_layout_copy(&f->ch_layout, &ost->enc->ch_layouts[i]);
if (err < 0)
exit_program(1);
return;
}
/* If no layout for the amount of channels requested was found, use the default
native layout for it. */
av_channel_layout_default(&f->ch_layout, ost->enc_ctx->ch_layout.nb_channels);
}
static int open_output_file(OptionsContext *o, const char *filename) static int open_output_file(OptionsContext *o, const char *filename)
{ {
AVFormatContext *oc; AVFormatContext *oc;
@ -2720,7 +2817,7 @@ loop_end:
f->sample_rates = ost->enc->supported_samplerates; f->sample_rates = ost->enc->supported_samplerates;
} }
if (ost->enc_ctx->ch_layout.nb_channels) { if (ost->enc_ctx->ch_layout.nb_channels) {
av_channel_layout_default(&f->ch_layout, ost->enc_ctx->ch_layout.nb_channels); set_channel_layout(f, ost);
} else if (ost->enc->ch_layouts) { } else if (ost->enc->ch_layouts) {
f->ch_layouts = ost->enc->ch_layouts; f->ch_layouts = ost->enc->ch_layouts;
} }
@ -3489,6 +3586,8 @@ int ffmpeg_parse_options(int argc, char **argv)
goto fail; goto fail;
} }
apply_sync_offsets();
/* create the complex filtergraphs */ /* create the complex filtergraphs */
ret = init_complex_filters(); ret = init_complex_filters();
if (ret < 0) { if (ret < 0) {
@ -3603,6 +3702,9 @@ const OptionDef options[] = {
{ "accurate_seek", OPT_BOOL | OPT_OFFSET | OPT_EXPERT | { "accurate_seek", OPT_BOOL | OPT_OFFSET | OPT_EXPERT |
OPT_INPUT, { .off = OFFSET(accurate_seek) }, OPT_INPUT, { .off = OFFSET(accurate_seek) },
"enable/disable accurate seeking with -ss" }, "enable/disable accurate seeking with -ss" },
{ "isync", HAS_ARG | OPT_INT | OPT_OFFSET |
OPT_EXPERT | OPT_INPUT, { .off = OFFSET(input_sync_ref) },
"Indicate the input index for sync reference", "sync ref" },
{ "itsoffset", HAS_ARG | OPT_TIME | OPT_OFFSET | { "itsoffset", HAS_ARG | OPT_TIME | OPT_OFFSET |
OPT_EXPERT | OPT_INPUT, { .off = OFFSET(input_ts_offset) }, OPT_EXPERT | OPT_INPUT, { .off = OFFSET(input_ts_offset) },
"set the input ts offset", "time_off" }, "set the input ts offset", "time_off" },

View file

@ -1992,6 +1992,8 @@ static int configure_audio_filters(VideoState *is, const char *afilters, int for
goto end; goto end;
if (force_output_format) { if (force_output_format) {
av_bprint_clear(&bp);
av_channel_layout_describe_bprint(&is->audio_tgt.ch_layout, &bp);
sample_rates [0] = is->audio_tgt.freq; sample_rates [0] = is->audio_tgt.freq;
if ((ret = av_opt_set_int(filt_asink, "all_channel_counts", 0, AV_OPT_SEARCH_CHILDREN)) < 0) if ((ret = av_opt_set_int(filt_asink, "all_channel_counts", 0, AV_OPT_SEARCH_CHILDREN)) < 0)
goto end; goto end;
@ -2356,12 +2358,13 @@ static int audio_decode_frame(VideoState *is)
av_channel_layout_compare(&af->frame->ch_layout, &is->audio_src.ch_layout) || av_channel_layout_compare(&af->frame->ch_layout, &is->audio_src.ch_layout) ||
af->frame->sample_rate != is->audio_src.freq || af->frame->sample_rate != is->audio_src.freq ||
(wanted_nb_samples != af->frame->nb_samples && !is->swr_ctx)) { (wanted_nb_samples != af->frame->nb_samples && !is->swr_ctx)) {
int ret;
swr_free(&is->swr_ctx); swr_free(&is->swr_ctx);
swr_alloc_set_opts2(&is->swr_ctx, ret = swr_alloc_set_opts2(&is->swr_ctx,
&is->audio_tgt.ch_layout, is->audio_tgt.fmt, is->audio_tgt.freq, &is->audio_tgt.ch_layout, is->audio_tgt.fmt, is->audio_tgt.freq,
&af->frame->ch_layout, af->frame->format, af->frame->sample_rate, &af->frame->ch_layout, af->frame->format, af->frame->sample_rate,
0, NULL); 0, NULL);
if (!is->swr_ctx || swr_init(is->swr_ctx) < 0) { if (ret < 0 || swr_init(is->swr_ctx) < 0) {
av_log(NULL, AV_LOG_ERROR, av_log(NULL, AV_LOG_ERROR,
"Cannot create sample rate converter for conversion of %d Hz %s %d channels to %d Hz %s %d channels!\n", "Cannot create sample rate converter for conversion of %d Hz %s %d channels to %d Hz %s %d channels!\n",
af->frame->sample_rate, av_get_sample_fmt_name(af->frame->format), af->frame->ch_layout.nb_channels, af->frame->sample_rate, av_get_sample_fmt_name(af->frame->format), af->frame->ch_layout.nb_channels,

View file

@ -1896,12 +1896,14 @@ static void writer_register_all(void)
writer_print_string(w, k, pbuf.str, 0); \ writer_print_string(w, k, pbuf.str, 0); \
} while (0) } while (0)
#define print_list_fmt(k, f, n, ...) do { \ #define print_list_fmt(k, f, n, m, ...) do { \
av_bprint_clear(&pbuf); \ av_bprint_clear(&pbuf); \
for (int idx = 0; idx < n; idx++) { \ for (int idx = 0; idx < n; idx++) { \
if (idx > 0) \ for (int idx2 = 0; idx2 < m; idx2++) { \
av_bprint_chars(&pbuf, ' ', 1); \ if (idx > 0 || idx2 > 0) \
av_bprintf(&pbuf, f, __VA_ARGS__); \ av_bprint_chars(&pbuf, ' ', 1); \
av_bprintf(&pbuf, f, __VA_ARGS__); \
} \
} \ } \
writer_print_string(w, k, pbuf.str, 0); \ writer_print_string(w, k, pbuf.str, 0); \
} while (0) } while (0)
@ -2012,7 +2014,7 @@ static void print_dovi_metadata(WriterContext *w, const AVDOVIMetadata *dovi)
const AVDOVIReshapingCurve *curve = &mapping->curves[c]; const AVDOVIReshapingCurve *curve = &mapping->curves[c];
writer_print_section_header(w, SECTION_ID_FRAME_SIDE_DATA_COMPONENT); writer_print_section_header(w, SECTION_ID_FRAME_SIDE_DATA_COMPONENT);
print_list_fmt("pivots", "%"PRIu16, curve->num_pivots, curve->pivots[idx]); print_list_fmt("pivots", "%"PRIu16, curve->num_pivots, 1, curve->pivots[idx]);
writer_print_section_header(w, SECTION_ID_FRAME_SIDE_DATA_PIECE_LIST); writer_print_section_header(w, SECTION_ID_FRAME_SIDE_DATA_PIECE_LIST);
for (int i = 0; i < curve->num_pivots - 1; i++) { for (int i = 0; i < curve->num_pivots - 1; i++) {
@ -2024,7 +2026,7 @@ static void print_dovi_metadata(WriterContext *w, const AVDOVIMetadata *dovi)
print_str("mapping_idc_name", "polynomial"); print_str("mapping_idc_name", "polynomial");
print_int("poly_order", curve->poly_order[i]); print_int("poly_order", curve->poly_order[i]);
print_list_fmt("poly_coef", "%"PRIi64, print_list_fmt("poly_coef", "%"PRIi64,
curve->poly_order[i] + 1, curve->poly_order[i] + 1, 1,
curve->poly_coef[i][idx]); curve->poly_coef[i][idx]);
break; break;
case AV_DOVI_MAPPING_MMR: case AV_DOVI_MAPPING_MMR:
@ -2032,8 +2034,8 @@ static void print_dovi_metadata(WriterContext *w, const AVDOVIMetadata *dovi)
print_int("mmr_order", curve->mmr_order[i]); print_int("mmr_order", curve->mmr_order[i]);
print_int("mmr_constant", curve->mmr_constant[i]); print_int("mmr_constant", curve->mmr_constant[i]);
print_list_fmt("mmr_coef", "%"PRIi64, print_list_fmt("mmr_coef", "%"PRIi64,
curve->mmr_order[i] * 7, curve->mmr_order[i], 7,
curve->mmr_coef[i][0][idx]); curve->mmr_coef[i][idx][idx2]);
break; break;
default: default:
print_str("mapping_idc_name", "unknown"); print_str("mapping_idc_name", "unknown");
@ -2071,15 +2073,15 @@ static void print_dovi_metadata(WriterContext *w, const AVDOVIMetadata *dovi)
print_int("dm_metadata_id", color->dm_metadata_id); print_int("dm_metadata_id", color->dm_metadata_id);
print_int("scene_refresh_flag", color->scene_refresh_flag); print_int("scene_refresh_flag", color->scene_refresh_flag);
print_list_fmt("ycc_to_rgb_matrix", "%d/%d", print_list_fmt("ycc_to_rgb_matrix", "%d/%d",
FF_ARRAY_ELEMS(color->ycc_to_rgb_matrix), FF_ARRAY_ELEMS(color->ycc_to_rgb_matrix), 1,
color->ycc_to_rgb_matrix[idx].num, color->ycc_to_rgb_matrix[idx].num,
color->ycc_to_rgb_matrix[idx].den); color->ycc_to_rgb_matrix[idx].den);
print_list_fmt("ycc_to_rgb_offset", "%d/%d", print_list_fmt("ycc_to_rgb_offset", "%d/%d",
FF_ARRAY_ELEMS(color->ycc_to_rgb_offset), FF_ARRAY_ELEMS(color->ycc_to_rgb_offset), 1,
color->ycc_to_rgb_offset[idx].num, color->ycc_to_rgb_offset[idx].num,
color->ycc_to_rgb_offset[idx].den); color->ycc_to_rgb_offset[idx].den);
print_list_fmt("rgb_to_lms_matrix", "%d/%d", print_list_fmt("rgb_to_lms_matrix", "%d/%d",
FF_ARRAY_ELEMS(color->rgb_to_lms_matrix), FF_ARRAY_ELEMS(color->rgb_to_lms_matrix), 1,
color->rgb_to_lms_matrix[idx].num, color->rgb_to_lms_matrix[idx].num,
color->rgb_to_lms_matrix[idx].den); color->rgb_to_lms_matrix[idx].den);
print_int("signal_eotf", color->signal_eotf); print_int("signal_eotf", color->signal_eotf);
@ -4026,7 +4028,7 @@ int main(int argc, char **argv)
WriterContext *wctx; WriterContext *wctx;
char *buf; char *buf;
char *w_name = NULL, *w_args = NULL; char *w_name = NULL, *w_args = NULL;
int ret, i; int ret, input_ret, i;
init_dynload(); init_dynload();
@ -4150,10 +4152,14 @@ int main(int argc, char **argv)
show_error(wctx, ret); show_error(wctx, ret);
} }
input_ret = ret;
writer_print_section_footer(wctx); writer_print_section_footer(wctx);
ret = writer_close(&wctx); ret = writer_close(&wctx);
if (ret < 0) if (ret < 0)
av_log(NULL, AV_LOG_ERROR, "Writing output failed: %s\n", av_err2str(ret)); av_log(NULL, AV_LOG_ERROR, "Writing output failed: %s\n", av_err2str(ret));
ret = FFMIN(ret, input_ret);
} }
end: end:

View file

@ -722,10 +722,13 @@ int show_codecs(void *optctx, const char *opt, const char *arg)
return 0; return 0;
} }
static void print_codecs(int encoder) static int print_codecs(int encoder)
{ {
const AVCodecDescriptor **codecs; const AVCodecDescriptor **codecs;
unsigned i, nb_codecs = get_codecs_sorted(&codecs); int i, nb_codecs = get_codecs_sorted(&codecs);
if (nb_codecs < 0)
return nb_codecs;
printf("%s:\n" printf("%s:\n"
" V..... = Video\n" " V..... = Video\n"
@ -759,18 +762,17 @@ static void print_codecs(int encoder)
} }
} }
av_free(codecs); av_free(codecs);
return 0;
} }
int show_decoders(void *optctx, const char *opt, const char *arg) int show_decoders(void *optctx, const char *opt, const char *arg)
{ {
print_codecs(0); return print_codecs(0);
return 0;
} }
int show_encoders(void *optctx, const char *opt, const char *arg) int show_encoders(void *optctx, const char *opt, const char *arg)
{ {
print_codecs(1); return print_codecs(1);
return 0;
} }
int show_bsfs(void *optctx, const char *opt, const char *arg) int show_bsfs(void *optctx, const char *opt, const char *arg)

View file

@ -131,8 +131,8 @@ static int zero12v_decode_frame(AVCodecContext *avctx, AVFrame *pic,
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

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

View file

@ -71,6 +71,9 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
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

@ -730,9 +730,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 }, },
@ -84,7 +84,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,
@ -103,7 +103,7 @@ static const AVChannelLayout aac_ch_layout[16] = {
{ 0 }, { 0 },
{ 0 }, { 0 },
{ 0 }, { 0 },
AV_CHANNEL_LAYOUT_6POINT1, AV_CHANNEL_LAYOUT_6POINT1_BACK,
AV_CHANNEL_LAYOUT_7POINT1, AV_CHANNEL_LAYOUT_7POINT1,
AV_CHANNEL_LAYOUT_22POINT2, AV_CHANNEL_LAYOUT_22POINT2,
{ 0 }, { 0 },

View file

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

View file

@ -502,28 +502,27 @@ function ff_pred16x16_plane_neon_10, export=1
add v7.4h, v7.4h, v0.4h add v7.4h, v7.4h, v0.4h
shl v2.4h, v7.4h, #4 shl v2.4h, v7.4h, #4
ssubl v2.4s, v2.4h, v3.4h ssubl v2.4s, v2.4h, v3.4h
shl v3.4h, v4.4h, #4
ext v0.16b, v0.16b, v0.16b, #14 ext v0.16b, v0.16b, v0.16b, #14
ssubl v6.4s, v5.4h, v3.4h sxtl v6.4s, v5.4h // c
mov v0.h[0], wzr mov v0.h[0], wzr
mul v0.8h, v0.8h, v4.h[0] mul v0.8h, v0.8h, v4.h[0]
dup v16.4s, v2.s[0] dup v16.4s, v2.s[0]
dup v17.4s, v2.s[0] dup v17.4s, v2.s[0]
dup v2.8h, v4.h[0] dup v2.8h, v4.h[0] // b
dup v3.4s, v6.s[0] dup v3.4s, v6.s[0] // c
shl v2.8h, v2.8h, #3 sshll v2.4s, v2.4h, #3 // b * 8
saddw v16.4s, v16.4s, v0.4h saddw v16.4s, v16.4s, v0.4h
saddw2 v17.4s, v17.4s, v0.8h saddw2 v17.4s, v17.4s, v0.8h
saddw v3.4s, v3.4s, v2.4h sub v3.4s, v3.4s, v2.4s
mov w3, #16 mov w3, #16
mvni v4.8h, #0xFC, lsl #8 // 1023 for clipping mvni v4.8h, #0xFC, lsl #8 // 1023 for clipping
1: 1:
sqshrun v0.4h, v16.4s, #5 sqshrun v0.4h, v16.4s, #5
sqshrun2 v0.8h, v17.4s, #5 sqshrun2 v0.8h, v17.4s, #5
saddw v16.4s, v16.4s, v2.4h add v16.4s, v16.4s, v2.4s
saddw v17.4s, v17.4s, v2.4h add v17.4s, v17.4s, v2.4s
sqshrun v1.4h, v16.4s, #5 sqshrun v1.4h, v16.4s, #5
sqshrun2 v1.8h, v17.4s, #5 sqshrun2 v1.8h, v17.4s, #5
add v16.4s, v16.4s, v3.4s add v16.4s, v16.4s, v3.4s
@ -595,12 +594,11 @@ function ff_pred8x8_plane_neon_10, export=1
ssubl v2.4s, v2.4h, v3.4h ssubl v2.4s, v2.4h, v3.4h
ext v0.16b, v0.16b, v0.16b, #14 ext v0.16b, v0.16b, v0.16b, #14
mov v0.h[0], wzr mov v0.h[0], wzr
mul v0.8h, v0.8h, v5.h[0]
dup v1.4s, v2.s[0] dup v1.4s, v2.s[0]
dup v2.4s, v2.s[0] dup v2.4s, v2.s[0]
dup v3.8h, v5.h[1] dup v3.8h, v5.h[1]
saddw v1.4s, v1.4s, v0.4h smlal v1.4s, v0.4h, v5.h[0]
saddw2 v2.4s, v2.4s, v0.8h smlal2 v2.4s, v0.8h, v5.h[0]
mov w3, #8 mov w3, #8
mvni v4.8h, #0xFC, lsl #8 // 1023 for clipping mvni v4.8h, #0xFC, lsl #8 // 1023 for clipping
1: 1:

View file

@ -230,6 +230,9 @@ function \type\()_8tap_\size\()h_\idx1\idx2
// reduced dst stride // reduced dst stride
.if \size >= 16 .if \size >= 16
sub x1, x1, x5 sub x1, x1, x5
.elseif \size == 4
add x12, x2, #8
add x13, x7, #8
.endif .endif
// size >= 16 loads two qwords and increments x2, // size >= 16 loads two qwords and increments x2,
// for size 4/8 it's enough with one qword and no // for size 4/8 it's enough with one qword and no
@ -248,9 +251,14 @@ function \type\()_8tap_\size\()h_\idx1\idx2
.if \size >= 16 .if \size >= 16
ld1 {v4.8b, v5.8b, v6.8b}, [x2], #24 ld1 {v4.8b, v5.8b, v6.8b}, [x2], #24
ld1 {v16.8b, v17.8b, v18.8b}, [x7], #24 ld1 {v16.8b, v17.8b, v18.8b}, [x7], #24
.else .elseif \size == 8
ld1 {v4.8b, v5.8b}, [x2] ld1 {v4.8b, v5.8b}, [x2]
ld1 {v16.8b, v17.8b}, [x7] ld1 {v16.8b, v17.8b}, [x7]
.else // \size == 4
ld1 {v4.8b}, [x2]
ld1 {v16.8b}, [x7]
ld1 {v5.s}[0], [x12], x3
ld1 {v17.s}[0], [x13], x3
.endif .endif
uxtl v4.8h, v4.8b uxtl v4.8h, v4.8b
uxtl v5.8h, v5.8b uxtl v5.8h, v5.8b

View file

@ -55,6 +55,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 */
@ -75,6 +76,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

@ -185,7 +185,9 @@ int av_ac3_parse_header(const uint8_t *buf, size_t size,
AC3HeaderInfo hdr; AC3HeaderInfo hdr;
int err; int err;
init_get_bits8(&gb, buf, size); err = init_get_bits8(&gb, buf, size);
if (err < 0)
return AVERROR_INVALIDDATA;
err = ff_ac3_parse_header(&gb, &hdr); err = ff_ac3_parse_header(&gb, &hdr);
if (err < 0) if (err < 0)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;

View file

@ -574,13 +574,15 @@ static av_cold int alac_decode_init(AVCodecContext * avctx)
avctx->bits_per_raw_sample = alac->sample_size; avctx->bits_per_raw_sample = alac->sample_size;
avctx->sample_rate = alac->sample_rate; avctx->sample_rate = alac->sample_rate;
if (alac->channels < 1 || alac->channels > ALAC_MAX_CHANNELS) { if (alac->channels < 1) {
av_log(avctx, AV_LOG_WARNING, "Invalid channel count\n"); av_log(avctx, AV_LOG_WARNING, "Invalid channel count\n");
if (avctx->ch_layout.nb_channels < 1)
return AVERROR(EINVAL);
alac->channels = avctx->ch_layout.nb_channels; alac->channels = avctx->ch_layout.nb_channels;
} }
if (avctx->ch_layout.nb_channels > ALAC_MAX_CHANNELS || avctx->ch_layout.nb_channels <= 0 ) { if (alac->channels > ALAC_MAX_CHANNELS) {
avpriv_report_missing_feature(avctx, "Channel count %d", avpriv_report_missing_feature(avctx, "Channel count %d",
avctx->ch_layout.nb_channels); alac->channels);
return AVERROR_PATCHWELCOME; return AVERROR_PATCHWELCOME;
} }
av_channel_layout_uninit(&avctx->ch_layout); av_channel_layout_uninit(&avctx->ch_layout);

View file

@ -1027,7 +1027,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
@ -1659,7 +1659,8 @@ static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame)
if (!sconf->mc_coding || ctx->js_switch) { if (!sconf->mc_coding || ctx->js_switch) {
int independent_bs = !sconf->joint_stereo; int independent_bs = !sconf->joint_stereo;
if (get_bits_left(gb) < 7*channels*ctx->num_blocks)
return AVERROR_INVALIDDATA;
for (c = 0; c < channels; c++) { for (c = 0; c < channels; c++) {
js_blocks[0] = 0; js_blocks[0] = 0;
js_blocks[1] = 0; js_blocks[1] = 0;
@ -2108,8 +2109,8 @@ static av_cold int decode_init(AVCodecContext *avctx)
if (sconf->floating) { if (sconf->floating) {
ctx->acf = av_malloc_array(channels, sizeof(*ctx->acf)); ctx->acf = av_malloc_array(channels, sizeof(*ctx->acf));
ctx->shift_value = av_malloc_array(channels, sizeof(*ctx->shift_value)); ctx->shift_value = av_calloc(channels, sizeof(*ctx->shift_value));
ctx->last_shift_value = av_malloc_array(channels, sizeof(*ctx->last_shift_value)); ctx->last_shift_value = av_calloc(channels, sizeof(*ctx->last_shift_value));
ctx->last_acf_mantissa = av_malloc_array(channels, sizeof(*ctx->last_acf_mantissa)); ctx->last_acf_mantissa = av_malloc_array(channels, sizeof(*ctx->last_acf_mantissa));
ctx->raw_mantissa = av_calloc(channels, sizeof(*ctx->raw_mantissa)); ctx->raw_mantissa = av_calloc(channels, sizeof(*ctx->raw_mantissa));

View file

@ -934,7 +934,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];
@ -1170,7 +1170,8 @@ static void predictor_decode_mono_3930(APEContext *ctx, int count)
static av_always_inline int predictor_update_filter(APEPredictor64 *p, static av_always_inline int predictor_update_filter(APEPredictor64 *p,
const int decoded, const int filter, const int decoded, const int filter,
const int delayA, const int delayB, const int delayA, const int delayB,
const int adaptA, const int adaptB) const int adaptA, const int adaptB,
int compression_level)
{ {
int64_t predictionA, predictionB; int64_t predictionA, predictionB;
int32_t sign; int32_t sign;
@ -1198,7 +1199,13 @@ static av_always_inline int predictor_update_filter(APEPredictor64 *p,
p->buf[delayB - 3] * p->coeffsB[filter][3] + p->buf[delayB - 3] * p->coeffsB[filter][3] +
p->buf[delayB - 4] * p->coeffsB[filter][4]; p->buf[delayB - 4] * p->coeffsB[filter][4];
p->lastA[filter] = decoded + ((int64_t)((uint64_t)predictionA + (predictionB >> 1)) >> 10); if (compression_level < COMPRESSION_LEVEL_INSANE) {
predictionA = (int32_t)predictionA;
predictionB = (int32_t)predictionB;
p->lastA[filter] = (int32_t)(decoded + (unsigned)((int32_t)(predictionA + (predictionB >> 1)) >> 10));
} else {
p->lastA[filter] = decoded + ((int64_t)((uint64_t)predictionA + (predictionB >> 1)) >> 10);
}
p->filterA[filter] = p->lastA[filter] + ((int64_t)(p->filterA[filter] * 31ULL) >> 5); p->filterA[filter] = p->lastA[filter] + ((int64_t)(p->filterA[filter] * 31ULL) >> 5);
sign = APESIGN(decoded); sign = APESIGN(decoded);
@ -1226,10 +1233,12 @@ static void predictor_decode_stereo_3950(APEContext *ctx, int count)
while (count--) { while (count--) {
/* Predictor Y */ /* Predictor Y */
*decoded0 = predictor_update_filter(p, *decoded0, 0, YDELAYA, YDELAYB, *decoded0 = predictor_update_filter(p, *decoded0, 0, YDELAYA, YDELAYB,
YADAPTCOEFFSA, YADAPTCOEFFSB); YADAPTCOEFFSA, YADAPTCOEFFSB,
ctx->compression_level);
decoded0++; decoded0++;
*decoded1 = predictor_update_filter(p, *decoded1, 1, XDELAYA, XDELAYB, *decoded1 = predictor_update_filter(p, *decoded1, 1, XDELAYA, XDELAYB,
XADAPTCOEFFSA, XADAPTCOEFFSB); XADAPTCOEFFSA, XADAPTCOEFFSB,
ctx->compression_level);
decoded1++; decoded1++;
/* Combined */ /* Combined */
@ -1612,13 +1621,24 @@ static int ape_decode_frame(AVCodecContext *avctx, AVFrame *frame,
s->samples -= blockstodecode; s->samples -= blockstodecode;
if (avctx->err_recognition & AV_EF_CRCCHECK && if (avctx->err_recognition & AV_EF_CRCCHECK &&
s->fileversion >= 3900 && s->bps < 24) { s->fileversion >= 3900) {
uint32_t crc = s->CRC_state; uint32_t crc = s->CRC_state;
const AVCRC *crc_tab = av_crc_get_table(AV_CRC_32_IEEE_LE); const AVCRC *crc_tab = av_crc_get_table(AV_CRC_32_IEEE_LE);
int stride = s->bps == 24 ? 4 : (s->bps>>3);
int offset = s->bps == 24;
int bytes = s->bps >> 3;
for (i = 0; i < blockstodecode; i++) { for (i = 0; i < blockstodecode; i++) {
for (ch = 0; ch < s->channels; ch++) { for (ch = 0; ch < s->channels; ch++) {
uint8_t *smp = frame->data[ch] + (i*(s->bps >> 3)); #if HAVE_BIGENDIAN
crc = av_crc(crc_tab, crc, smp, s->bps >> 3); uint8_t *smp_native = frame->data[ch] + i*stride;
uint8_t smp[4];
for(int j = 0; j<stride; j++)
smp[j] = smp_native[stride-j-1];
#else
uint8_t *smp = frame->data[ch] + i*stride;
#endif
crc = av_crc(crc_tab, crc, smp+offset, bytes);
} }
} }

View file

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

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

@ -279,11 +279,13 @@ function \type\()_8tap_\size\()h_\idx1\idx2
sub r1, r1, r5 sub r1, r1, r5
.endif .endif
@ size >= 16 loads two qwords and increments r2, @ size >= 16 loads two qwords and increments r2,
@ for size 4/8 it's enough with one qword and no @ size 4 loads 1 d word, increments r2 and loads 1 32-bit lane
@ postincrement @ for size 8 it's enough with one qword and no postincrement
.if \size >= 16 .if \size >= 16
sub r3, r3, r5 sub r3, r3, r5
sub r3, r3, #8 sub r3, r3, #8
.elseif \size == 4
sub r3, r3, #8
.endif .endif
@ Load the filter vector @ Load the filter vector
vld1.16 {q0}, [r12,:128] vld1.16 {q0}, [r12,:128]
@ -295,9 +297,14 @@ function \type\()_8tap_\size\()h_\idx1\idx2
.if \size >= 16 .if \size >= 16
vld1.8 {d18, d19, d20}, [r2]! vld1.8 {d18, d19, d20}, [r2]!
vld1.8 {d24, d25, d26}, [r7]! vld1.8 {d24, d25, d26}, [r7]!
.else .elseif \size == 8
vld1.8 {q9}, [r2] vld1.8 {q9}, [r2]
vld1.8 {q12}, [r7] vld1.8 {q12}, [r7]
.else @ size == 4
vld1.8 {d18}, [r2]!
vld1.8 {d24}, [r7]!
vld1.32 {d19[0]}, [r2]
vld1.32 {d25[0]}, [r7]
.endif .endif
vmovl.u8 q8, d18 vmovl.u8 q8, d18
vmovl.u8 q9, d19 vmovl.u8 q9, d19

View file

@ -48,6 +48,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
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[channels - 1];
return 0; return 0;
} }
@ -378,7 +392,7 @@ static int atrac3p_decode_frame(AVCodecContext *avctx, AVFrame *frame,
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

@ -554,13 +554,12 @@ static int ffat_encode(AVCodecContext *avctx, AVPacket *avpkt,
avctx->frame_size, avctx->frame_size,
&avpkt->pts, &avpkt->pts,
&avpkt->duration); &avpkt->duration);
ret = 0;
} else if (ret && ret != 1) { } else if (ret && ret != 1) {
av_log(avctx, AV_LOG_ERROR, "Encode error: %i\n", ret); av_log(avctx, AV_LOG_ERROR, "Encode error: %i\n", ret);
ret = AVERROR_EXTERNAL; return AVERROR_EXTERNAL;
} }
return ret; return 0;
} }
static av_cold void ffat_encode_flush(AVCodecContext *avctx) static av_cold void ffat_encode_flush(AVCodecContext *avctx)

View file

@ -170,7 +170,7 @@ static uint8_t get_shear_params_valid(AV1DecContext *s, int idx)
int16_t alpha, beta, gamma, delta, divf, divs; int16_t alpha, beta, gamma, delta, divf, divs;
int64_t v, w; int64_t v, w;
int32_t *param = &s->cur_frame.gm_params[idx][0]; int32_t *param = &s->cur_frame.gm_params[idx][0];
if (param[2] < 0) if (param[2] <= 0)
return 0; return 0;
alpha = av_clip_int16(param[2] - (1 << AV1_WARPEDMODEL_PREC_BITS)); alpha = av_clip_int16(param[2] - (1 << AV1_WARPEDMODEL_PREC_BITS));
@ -675,7 +675,7 @@ static int set_context_with_sequence(AVCodecContext *avctx,
avctx->color_range = 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) {

View file

@ -72,13 +72,15 @@ static void parse_avs2_seq_header(AVCodecParserContext *s, const uint8_t *buf,
unsigned aspect_ratio; unsigned aspect_ratio;
unsigned frame_rate_code; unsigned frame_rate_code;
int low_delay; int low_delay;
av_unused int ret;
// update buf_size_min if parse more deeper // update buf_size_min if parse more deeper
const int buf_size_min = 15; const int buf_size_min = 15;
if (buf_size < buf_size_min) if (buf_size < buf_size_min)
return; return;
init_get_bits8(&gb, buf, buf_size_min); ret = init_get_bits8(&gb, buf, buf_size_min);
av_assert1(ret >= 0);
s->key_frame = 1; s->key_frame = 1;
s->pict_type = AV_PICTURE_TYPE_I; s->pict_type = AV_PICTURE_TYPE_I;

View file

@ -73,7 +73,8 @@ static void parse_avs3_nal_units(AVCodecParserContext *s, const uint8_t *buf,
GetBitContext gb; GetBitContext gb;
int profile, ratecode, low_delay; int profile, ratecode, low_delay;
init_get_bits8(&gb, buf + 4, buf_size - 4); av_unused int ret = init_get_bits(&gb, buf + 4, 100);
av_assert1(ret >= 0);
s->key_frame = 1; s->key_frame = 1;
s->pict_type = AV_PICTURE_TYPE_I; s->pict_type = AV_PICTURE_TYPE_I;

View file

@ -871,7 +871,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;
@ -927,7 +927,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);
@ -943,7 +943,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);
@ -975,7 +975,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);
@ -1088,7 +1088,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

@ -37,7 +37,7 @@ static int cbs_av1_read_uvlc(CodedBitstreamContext *ctx, GetBitContext *gbc,
position = get_bits_count(gbc); position = get_bits_count(gbc);
zeroes = 0; zeroes = 0;
while (1) { while (zeroes < 32) {
if (get_bits_left(gbc) < 1) { if (get_bits_left(gbc) < 1) {
av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid uvlc code at " av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid uvlc code at "
"%s: bitstream ended.\n", name); "%s: bitstream ended.\n", name);
@ -50,7 +50,18 @@ static int cbs_av1_read_uvlc(CodedBitstreamContext *ctx, GetBitContext *gbc,
} }
if (zeroes >= 32) { if (zeroes >= 32) {
value = MAX_UINT_BITS(32); // The spec allows at least thirty-two zero bits followed by a
// one to mean 2^32-1, with no constraint on the number of
// zeroes. The libaom reference decoder does not match this,
// instead reading thirty-two zeroes but not the following one
// to mean 2^32-1. These two interpretations are incompatible
// and other implementations may follow one or the other.
// Therefore we reject thirty-two zeroes because the intended
// behaviour is not clear.
av_log(ctx->log_ctx, AV_LOG_ERROR, "Thirty-two zero bits in "
"%s uvlc code: considered invalid due to conflicting "
"standard and reference decoder behaviour.\n", name);
return AVERROR_INVALIDDATA;
} else { } else {
if (get_bits_left(gbc) < zeroes) { if (get_bits_left(gbc) < zeroes) {
av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid uvlc code at " av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid uvlc code at "
@ -379,7 +390,7 @@ static int cbs_av1_write_increment(CodedBitstreamContext *ctx, PutBitContext *pb
} }
if (len > 0) if (len > 0)
put_bits(pbc, len, (1 << len) - 1 - (value != range_max)); put_bits(pbc, len, (1U << len) - 1 - (value != range_max));
return 0; return 0;
} }

View file

@ -166,13 +166,13 @@ static int cbs_jpeg_split_fragment(CodedBitstreamContext *ctx,
} }
} else { } else {
i = start; i = start;
if (i + 2 > frag->data_size) { if (i > frag->data_size - 2) {
av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid JPEG image: " av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid JPEG image: "
"truncated at %02x marker.\n", marker); "truncated at %02x marker.\n", marker);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
length = AV_RB16(frag->data + i); length = AV_RB16(frag->data + i);
if (i + length > frag->data_size) { if (length > frag->data_size - i) {
av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid JPEG image: " av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid JPEG image: "
"truncated at %02x marker segment.\n", marker); "truncated at %02x marker segment.\n", marker);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;

View file

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

View file

@ -258,6 +258,11 @@ static av_cold int cfhd_encode_init(AVCodecContext *avctx)
if (ret < 0) if (ret < 0)
return ret; return ret;
if (avctx->height < 32) {
av_log(avctx, AV_LOG_ERROR, "Height must be >= 32.\n");
return AVERROR_INVALIDDATA;
}
if (avctx->width & 15) { if (avctx->width & 15) {
av_log(avctx, AV_LOG_ERROR, "Width must be multiple of 16.\n"); av_log(avctx, AV_LOG_ERROR, "Width must be multiple of 16.\n");
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
@ -547,7 +552,7 @@ static int cfhd_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
width, height * 2); width, height * 2);
} }
ret = ff_alloc_packet(avctx, pkt, 64LL + s->planes * (2LL * avctx->width * avctx->height + 1000LL)); ret = ff_alloc_packet(avctx, pkt, 256LL + s->planes * (4LL * avctx->width * (avctx->height + 15) + 2048LL));
if (ret < 0) if (ret < 0)
return ret; return ret;

View file

@ -235,10 +235,14 @@ static int cri_decode_frame(AVCodecContext *avctx, AVFrame *p,
s->data_size = length; s->data_size = length;
goto skip; goto skip;
case 105: case 105:
if (length <= 0)
return AVERROR_INVALIDDATA;
hflip = bytestream2_get_byte(gb) != 0; hflip = bytestream2_get_byte(gb) != 0;
length--; length--;
goto skip; goto skip;
case 106: case 106:
if (length <= 0)
return AVERROR_INVALIDDATA;
vflip = bytestream2_get_byte(gb) != 0; vflip = bytestream2_get_byte(gb) != 0;
length--; length--;
goto skip; goto skip;

View file

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

View file

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

View file

@ -216,7 +216,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;
@ -227,14 +227,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, AVFrame *frame, static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
@ -329,7 +332,9 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
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

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

View file

@ -440,7 +440,7 @@ static int get_opcodes(GetByteContext *gb, uint32_t *table, uint8_t *dst, int op
size_in_bits = bytestream2_get_le32(gb); size_in_bits = bytestream2_get_le32(gb);
endoffset = ((size_in_bits + 7) >> 3) - 4; endoffset = ((size_in_bits + 7) >> 3) - 4;
if (endoffset <= 0 || bytestream2_get_bytes_left(gb) < endoffset) if ((int)endoffset <= 0 || bytestream2_get_bytes_left(gb) < endoffset)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
offset = endoffset; offset = endoffset;

View file

@ -138,9 +138,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

@ -62,7 +62,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;
@ -70,6 +70,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;
@ -79,6 +81,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;
@ -106,6 +110,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,
@ -165,8 +170,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

@ -89,11 +89,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;
@ -163,7 +158,7 @@ static MacroBlock decode_macroblock(Escape124Context* s, GetBitContext* gb,
// This condition can occur with invalid bitstreams and // This condition can occur with invalid bitstreams and
// *codebook_index == 2 // *codebook_index == 2
if (block_index >= s->codebooks[*codebook_index].size) if (block_index >= s->codebooks[*codebook_index].size || !s->codebooks[*codebook_index].blocks)
return (MacroBlock) { { 0 } }; return (MacroBlock) { { 0 } };
return s->codebooks[*codebook_index].blocks[block_index]; return s->codebooks[*codebook_index].blocks[block_index];
@ -225,7 +220,7 @@ static int escape124_decode_frame(AVCodecContext *avctx, AVFrame *frame,
// represent a lower bound of the space needed for skipped superblocks. Non // 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);
@ -242,7 +237,7 @@ static int escape124_decode_frame(AVCodecContext *avctx, AVFrame *frame,
if ((ret = av_frame_ref(frame, s->frame)) < 0) if ((ret = av_frame_ref(frame, s->frame)) < 0)
return ret; return ret;
return frame_size; return 0;
} }
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
@ -276,9 +271,14 @@ static int escape124_decode_frame(AVCodecContext *avctx, AVFrame *frame,
} }
av_freep(&s->codebooks[i].blocks); 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);
} }
} }
@ -371,7 +371,7 @@ static int escape124_decode_frame(AVCodecContext *avctx, AVFrame *frame,
*got_frame = 1; *got_frame = 1;
return frame_size; return 0;
} }

View file

@ -334,7 +334,10 @@ static int huf_unpack_enc_table(GetByteContext *gb,
return ret; return ret;
for (; im <= iM; im++) { for (; im <= iM; im++) {
uint64_t l = freq[im] = get_bits(&gbit, 6); int l;
if (get_bits_left(&gbit) < 6)
return AVERROR_INVALIDDATA;
l = freq[im] = get_bits(&gbit, 6);
if (l == LONG_ZEROCODE_RUN) { if (l == LONG_ZEROCODE_RUN) {
int zerun = get_bits(&gbit, 8) + SHORTEST_LONG_RUN; int zerun = get_bits(&gbit, 8) + SHORTEST_LONG_RUN;
@ -1241,7 +1244,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 */
@ -1265,7 +1269,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 */
@ -1941,18 +1946,27 @@ static int decode_header(EXRContext *s, AVFrame *frame)
bytestream2_get_buffer(gb, key, FFMIN(sizeof(key) - 1, var_size)); bytestream2_get_buffer(gb, key, FFMIN(sizeof(key) - 1, var_size));
if (strncmp("scanlineimage", key, var_size) && if (strncmp("scanlineimage", key, var_size) &&
strncmp("tiledimage", key, var_size)) strncmp("tiledimage", key, var_size)) {
return AVERROR_PATCHWELCOME; ret = AVERROR_PATCHWELCOME;
goto fail;
}
continue; continue;
} else if ((var_size = check_header_variable(s, "preview", } else if ((var_size = check_header_variable(s, "preview",
"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 * (uint64_t)ph;
if (psize > INT64_MAX / 4) {
ret = AVERROR_INVALIDDATA;
goto fail;
}
psize *= 4;
if (psize >= bytestream2_get_bytes_left(gb)) if ((int64_t)psize >= bytestream2_get_bytes_left(gb)) {
return AVERROR_INVALIDDATA; ret = AVERROR_INVALIDDATA;
goto fail;
}
bytestream2_skip(gb, psize); bytestream2_skip(gb, psize);

View file

@ -168,24 +168,31 @@ 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)) if (fs->ac == AC_GOLOMB_RICE && fs->slice_width >= (1<<23))
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
@ -303,8 +310,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;
@ -467,6 +477,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);
@ -769,21 +784,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++) {
@ -883,7 +902,14 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe,
if (buf_size < avctx->width * avctx->height / (128*8)) if (buf_size < avctx->width * avctx->height / (128*8))
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} else { } else {
if (buf_size < avctx->height / 8) int w = avctx->width;
int s = 1 + w / (1<<23);
w /= s;
for (i = 0; w > (1<<ff_log2_run[i]); i++)
w -= ff_log2_run[i];
if (buf_size < (avctx->height + i + 6) / 8 * s)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }

View file

@ -505,6 +505,8 @@ static int check_header_mismatch(FLACParseContext *fpc,
for (i = 0; i < FLAC_MAX_SEQUENTIAL_HEADERS && curr != child; i++) for (i = 0; i < FLAC_MAX_SEQUENTIAL_HEADERS && curr != child; i++)
curr = curr->next; curr = curr->next;
av_assert0(i < FLAC_MAX_SEQUENTIAL_HEADERS);
if (header->link_penalty[i] < FLAC_HEADER_CRC_FAIL_PENALTY || if (header->link_penalty[i] < FLAC_HEADER_CRC_FAIL_PENALTY ||
header->link_penalty[i] == FLAC_HEADER_NOT_PENALIZED_YET) { header->link_penalty[i] == FLAC_HEADER_NOT_PENALIZED_YET) {
FLACHeaderMarker *start, *end; FLACHeaderMarker *start, *end;

View file

@ -101,7 +101,6 @@ static int decode_type2(GetByteContext *gb, PutByteContext *pb)
continue; continue;
} }
} }
repeat = 0;
} }
repeat = 1; repeat = 1;
} }
@ -401,20 +400,17 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
GetByteContext *gb = &s->gb; GetByteContext *gb = &s->gb;
PutByteContext *pb = &s->pb; PutByteContext *pb = &s->pb;
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 +430,12 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
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 +516,12 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
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

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

View file

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

View file

@ -402,6 +402,7 @@ static inline int get_ur_golomb(GetBitContext *gb, int k, int limit,
log = av_log2(buf); log = av_log2(buf);
if (log > 31 - limit) { if (log > 31 - limit) {
av_assert2(log >= k);
buf >>= log - k; buf >>= log - k;
buf += (30U - log) << k; buf += (30U - log) << k;
LAST_SKIP_BITS(re, gb, 32 + k - log); LAST_SKIP_BITS(re, gb, 32 + k - log);
@ -424,6 +425,8 @@ static inline int get_ur_golomb(GetBitContext *gb, int k, int limit,
/** /**
* read unsigned golomb rice code (jpegls). * read unsigned golomb rice code (jpegls).
*
* @returns -1 on error
*/ */
static inline int get_ur_golomb_jpegls(GetBitContext *gb, int k, int limit, static inline int get_ur_golomb_jpegls(GetBitContext *gb, int k, int limit,
int esc_len) int esc_len)
@ -535,6 +538,8 @@ static inline int get_sr_golomb(GetBitContext *gb, int k, int limit,
/** /**
* read signed golomb rice code (flac). * read signed golomb rice code (flac).
*
* @returns INT_MIN on error
*/ */
static inline int get_sr_golomb_flac(GetBitContext *gb, int k, int limit, static inline int get_sr_golomb_flac(GetBitContext *gb, int k, int limit,
int esc_len) int esc_len)

View file

@ -307,7 +307,7 @@ static int decode_slice(MpegEncContext *s)
ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y, ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y,
s->mb_x, s->mb_y, ER_MB_ERROR & part_mask); s->mb_x, s->mb_y, ER_MB_ERROR & part_mask);
if (s->avctx->err_recognition & AV_EF_IGNORE_ERR) if ((s->avctx->err_recognition & AV_EF_IGNORE_ERR) && get_bits_left(&s->gb) > 0)
continue; continue;
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
@ -552,6 +552,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

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

View file

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

View file

@ -1551,7 +1551,7 @@ static int h264_field_start(H264Context *h, const H264SliceContext *sl,
sps = h->ps.sps; sps = h->ps.sps;
if (sps && sps->bitstream_restriction_flag && if (sps->bitstream_restriction_flag &&
h->avctx->has_b_frames < sps->num_reorder_frames) { h->avctx->has_b_frames < sps->num_reorder_frames) {
h->avctx->has_b_frames = sps->num_reorder_frames; h->avctx->has_b_frames = sps->num_reorder_frames;
} }

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

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

View file

@ -143,11 +143,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

@ -628,6 +628,10 @@ static int hls_slice_header(HEVCContext *s)
if (s->ps.pps->dependent_slice_segments_enabled_flag) if (s->ps.pps->dependent_slice_segments_enabled_flag)
sh->dependent_slice_segment_flag = get_bits1(gb); sh->dependent_slice_segment_flag = get_bits1(gb);
if (sh->dependent_slice_segment_flag && !s->slice_initialized) {
av_log(s->avctx, AV_LOG_ERROR, "Independent slice segment missing.\n");
return AVERROR_INVALIDDATA;
}
slice_address_length = av_ceil_log2(s->ps.sps->ctb_width * slice_address_length = av_ceil_log2(s->ps.sps->ctb_width *
s->ps.sps->ctb_height); s->ps.sps->ctb_height);
@ -896,9 +900,6 @@ static int hls_slice_header(HEVCContext *s)
} else { } else {
sh->slice_loop_filter_across_slices_enabled_flag = s->ps.pps->seq_loop_filter_across_slices_enabled_flag; sh->slice_loop_filter_across_slices_enabled_flag = s->ps.pps->seq_loop_filter_across_slices_enabled_flag;
} }
} else if (!s->slice_initialized) {
av_log(s->avctx, AV_LOG_ERROR, "Independent slice segment missing.\n");
return AVERROR_INVALIDDATA;
} }
sh->num_entry_point_offsets = 0; sh->num_entry_point_offsets = 0;
@ -1517,7 +1518,8 @@ static void luma_mc_uni(HEVCContext *s, uint8_t *dst, ptrdiff_t dststride,
if (x_off < QPEL_EXTRA_BEFORE || y_off < QPEL_EXTRA_AFTER || if (x_off < QPEL_EXTRA_BEFORE || y_off < QPEL_EXTRA_AFTER ||
x_off >= pic_width - block_w - QPEL_EXTRA_AFTER || x_off >= pic_width - block_w - QPEL_EXTRA_AFTER ||
y_off >= pic_height - block_h - QPEL_EXTRA_AFTER) { y_off >= pic_height - block_h - QPEL_EXTRA_AFTER ||
ref == s->frame) {
const ptrdiff_t edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->ps.sps->pixel_shift; const ptrdiff_t edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->ps.sps->pixel_shift;
int offset = QPEL_EXTRA_BEFORE * srcstride + (QPEL_EXTRA_BEFORE << s->ps.sps->pixel_shift); int offset = QPEL_EXTRA_BEFORE * srcstride + (QPEL_EXTRA_BEFORE << s->ps.sps->pixel_shift);
int buf_offset = QPEL_EXTRA_BEFORE * edge_emu_stride + (QPEL_EXTRA_BEFORE << s->ps.sps->pixel_shift); int buf_offset = QPEL_EXTRA_BEFORE * edge_emu_stride + (QPEL_EXTRA_BEFORE << s->ps.sps->pixel_shift);
@ -1665,6 +1667,7 @@ static void chroma_mc_uni(HEVCContext *s, uint8_t *dst0,
intptr_t my = av_mod_uintp2(mv->y, 2 + vshift); intptr_t my = av_mod_uintp2(mv->y, 2 + vshift);
intptr_t _mx = mx << (1 - hshift); intptr_t _mx = mx << (1 - hshift);
intptr_t _my = my << (1 - vshift); intptr_t _my = my << (1 - vshift);
int emu = src0 == s->frame->data[1] || src0 == s->frame->data[2];
x_off += mv->x >> (2 + hshift); x_off += mv->x >> (2 + hshift);
y_off += mv->y >> (2 + vshift); y_off += mv->y >> (2 + vshift);
@ -1672,7 +1675,8 @@ static void chroma_mc_uni(HEVCContext *s, uint8_t *dst0,
if (x_off < EPEL_EXTRA_BEFORE || y_off < EPEL_EXTRA_AFTER || if (x_off < EPEL_EXTRA_BEFORE || y_off < EPEL_EXTRA_AFTER ||
x_off >= pic_width - block_w - EPEL_EXTRA_AFTER || x_off >= pic_width - block_w - EPEL_EXTRA_AFTER ||
y_off >= pic_height - block_h - EPEL_EXTRA_AFTER) { y_off >= pic_height - block_h - EPEL_EXTRA_AFTER ||
emu) {
const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->ps.sps->pixel_shift; const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->ps.sps->pixel_shift;
int offset0 = EPEL_EXTRA_BEFORE * (srcstride + (1 << s->ps.sps->pixel_shift)); int offset0 = EPEL_EXTRA_BEFORE * (srcstride + (1 << s->ps.sps->pixel_shift));
int buf_offset0 = EPEL_EXTRA_BEFORE * int buf_offset0 = EPEL_EXTRA_BEFORE *
@ -1911,13 +1915,13 @@ static void hls_prediction_unit(HEVCContext *s, int x0, int y0,
if (current_mv.pred_flag & PF_L0) { if (current_mv.pred_flag & PF_L0) {
ref0 = refPicList[0].ref[current_mv.ref_idx[0]]; ref0 = refPicList[0].ref[current_mv.ref_idx[0]];
if (!ref0) if (!ref0 || !ref0->frame)
return; return;
hevc_await_progress(s, ref0, &current_mv.mv[0], y0, nPbH); hevc_await_progress(s, ref0, &current_mv.mv[0], y0, nPbH);
} }
if (current_mv.pred_flag & PF_L1) { if (current_mv.pred_flag & PF_L1) {
ref1 = refPicList[1].ref[current_mv.ref_idx[1]]; ref1 = refPicList[1].ref[current_mv.ref_idx[1]];
if (!ref1) if (!ref1 || !ref1->frame)
return; return;
hevc_await_progress(s, ref1, &current_mv.mv[1], y0, nPbH); hevc_await_progress(s, ref1, &current_mv.mv[1], y0, nPbH);
} }
@ -3176,8 +3180,11 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal)
case HEVC_NAL_RASL_N: case HEVC_NAL_RASL_N:
case HEVC_NAL_RASL_R: case HEVC_NAL_RASL_R:
ret = hls_slice_header(s); ret = hls_slice_header(s);
if (ret < 0) if (ret < 0) {
// hls_slice_header() does not cleanup on failure thus the state now is inconsistant so we cannot use it on depandant slices
s->slice_initialized = 0;
return ret; return ret;
}
if (ret == 1) { if (ret == 1) {
ret = AVERROR_INVALIDDATA; ret = AVERROR_INVALIDDATA;
goto fail; goto fail;
@ -3516,7 +3523,7 @@ static int hevc_decode_frame(AVCodecContext *avctx, AVFrame *rframe,
} }
} 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

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

View file

@ -583,7 +583,7 @@ static int decode_byterun2(uint8_t *dst, int height, int line_size,
GetByteContext *gb) GetByteContext *gb)
{ {
GetByteContext cmds; GetByteContext cmds;
unsigned count; int count;
int i, y_pos = 0, x_pos = 0; int i, y_pos = 0, x_pos = 0;
if (bytestream2_get_be32(gb) != MKBETAG('V', 'D', 'A', 'T')) if (bytestream2_get_be32(gb) != MKBETAG('V', 'D', 'A', 'T'))
@ -591,7 +591,7 @@ static int decode_byterun2(uint8_t *dst, int height, int line_size,
bytestream2_skip(gb, 4); bytestream2_skip(gb, 4);
count = bytestream2_get_be16(gb) - 2; count = bytestream2_get_be16(gb) - 2;
if (bytestream2_get_bytes_left(gb) < count) if (count < 0 || bytestream2_get_bytes_left(gb) < count)
return 0; return 0;
bytestream2_init(&cmds, gb->buffer, count); bytestream2_init(&cmds, gb->buffer, count);

View file

@ -1094,12 +1094,6 @@ static void do_plc(int16_t *plc_residual, /* (o) concealed residual */
if (s->consPLICount * s->block_samples > 320) { if (s->consPLICount * s->block_samples > 320) {
use_gain = 29491; /* 0.9 in Q15 */ use_gain = 29491; /* 0.9 in Q15 */
} else if (s->consPLICount * s->block_samples > 640) {
use_gain = 22938; /* 0.7 in Q15 */
} else if (s->consPLICount * s->block_samples > 960) {
use_gain = 16384; /* 0.5 in Q15 */
} else if (s->consPLICount * s->block_samples > 1280) {
use_gain = 0; /* 0.0 in Q15 */
} }
/* Compute mixing factor of picth repeatition and noise: /* Compute mixing factor of picth repeatition and noise:

View file

@ -221,12 +221,15 @@ static int decode_intra(AVCodecContext *avctx, GetBitContext *gb, AVFrame *frame
for (y = 0; y < avctx->height; y += 16) { for (y = 0; y < avctx->height; y += 16) {
for (x = 0; x < avctx->width; x += 16) { for (x = 0; x < avctx->width; x += 16) {
unsigned flag, cbphi, cbplo; unsigned flag, cbplo;
int cbphi;
cbplo = get_vlc2(gb, cbplo_tab.table, CBPLO_VLC_BITS, 1); cbplo = get_vlc2(gb, cbplo_tab.table, CBPLO_VLC_BITS, 1);
flag = get_bits1(gb); flag = get_bits1(gb);
cbphi = get_cbphi(gb, 1); cbphi = get_cbphi(gb, 1);
if (cbphi < 0)
return cbphi;
ret = decode_blocks(avctx, gb, cbplo | (cbphi << 2), 0, offset, flag); ret = decode_blocks(avctx, gb, cbplo | (cbphi << 2), 0, offset, flag);
if (ret < 0) if (ret < 0)
@ -274,7 +277,8 @@ static int decode_inter(AVCodecContext *avctx, GetBitContext *gb,
for (y = 0; y < avctx->height; y += 16) { for (y = 0; y < avctx->height; y += 16) {
for (x = 0; x < avctx->width; x += 16) { for (x = 0; x < avctx->width; x += 16) {
int reverse, intra_block, value; int reverse, intra_block, value;
unsigned cbphi, cbplo, flag2 = 0; unsigned cbplo, flag2 = 0;
int cbphi;
if (get_bits1(gb)) { if (get_bits1(gb)) {
copy_block16(frame->data[0] + y * frame->linesize[0] + x, copy_block16(frame->data[0] + y * frame->linesize[0] + x,
@ -300,6 +304,9 @@ static int decode_inter(AVCodecContext *avctx, GetBitContext *gb,
cbplo = value >> 4; cbplo = value >> 4;
cbphi = get_cbphi(gb, reverse); cbphi = get_cbphi(gb, reverse);
if (cbphi < 0)
return cbphi;
if (intra_block) { if (intra_block) {
ret = decode_blocks(avctx, gb, cbplo | (cbphi << 2), 0, offset, flag2); ret = decode_blocks(avctx, gb, cbplo | (cbphi << 2), 0, offset, flag2);
if (ret < 0) if (ret < 0)

View file

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

View file

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

View file

@ -69,7 +69,7 @@
#define GLOBAL(x) x #define GLOBAL(x) x
#define RIGHT_SHIFT(x, n) ((x) >> (n)) #define RIGHT_SHIFT(x, n) ((x) >> (n))
#define MULTIPLY16C16(var,const) ((var)*(const)) #define MULTIPLY16C16(var,const) ((var)*(const))
#define DESCALE(x,n) RIGHT_SHIFT((x) + (1 << ((n) - 1)), n) #define DESCALE(x,n) RIGHT_SHIFT((int)(x) + (1 << ((n) - 1)), n)
/* /*
@ -175,7 +175,7 @@
#if BITS_IN_JSAMPLE == 8 && CONST_BITS<=13 && PASS1_BITS<=2 #if BITS_IN_JSAMPLE == 8 && CONST_BITS<=13 && PASS1_BITS<=2
#define MULTIPLY(var,const) MULTIPLY16C16(var,const) #define MULTIPLY(var,const) MULTIPLY16C16(var,const)
#else #else
#define MULTIPLY(var,const) ((var) * (const)) #define MULTIPLY(var,const) (int)((var) * (unsigned)(const))
#endif #endif
@ -261,7 +261,7 @@ FUNC(ff_jpeg_fdct_islow)(int16_t *data)
{ {
int tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; int tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
int tmp10, tmp11, tmp12, tmp13; int tmp10, tmp11, tmp12, tmp13;
int z1, z2, z3, z4, z5; unsigned z1, z2, z3, z4, z5;
int16_t *dataptr; int16_t *dataptr;
int ctr; int ctr;

View file

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

View file

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

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

View file

@ -167,9 +167,9 @@ static enum AVColorTransferCharacteristic libjxl_get_trc(void *avctx, const JxlC
case JXL_TRANSFER_FUNCTION_DCI: return AVCOL_TRC_SMPTE428; case JXL_TRANSFER_FUNCTION_DCI: return AVCOL_TRC_SMPTE428;
case JXL_TRANSFER_FUNCTION_HLG: return AVCOL_TRC_ARIB_STD_B67; case JXL_TRANSFER_FUNCTION_HLG: return AVCOL_TRC_ARIB_STD_B67;
case JXL_TRANSFER_FUNCTION_GAMMA: case JXL_TRANSFER_FUNCTION_GAMMA:
if (jxl_color->gamma > 2.199 && jxl_color->gamma < 2.201) if (jxl_color->gamma > 0.45355 && jxl_color->gamma < 0.45555)
return AVCOL_TRC_GAMMA22; return AVCOL_TRC_GAMMA22;
else if (jxl_color->gamma > 2.799 && jxl_color->gamma < 2.801) else if (jxl_color->gamma > 0.35614 && jxl_color->gamma < 0.35814)
return AVCOL_TRC_GAMMA28; return AVCOL_TRC_GAMMA28;
else else
av_log(avctx, AV_LOG_WARNING, "Unsupported gamma transfer: %f\n", jxl_color->gamma); av_log(avctx, AV_LOG_WARNING, "Unsupported gamma transfer: %f\n", jxl_color->gamma);

View file

@ -190,7 +190,7 @@ static av_cold int libjxl_encode_init(AVCodecContext *avctx)
* Populate a JxlColorEncoding with the given enum AVColorPrimaries. * Populate a JxlColorEncoding with the given enum AVColorPrimaries.
* @return < 0 upon failure, >= 0 upon success * @return < 0 upon failure, >= 0 upon success
*/ */
static int libjxl_populate_primaries(JxlColorEncoding *jxl_color, enum AVColorPrimaries prm) static int libjxl_populate_primaries(void *avctx, JxlColorEncoding *jxl_color, enum AVColorPrimaries prm)
{ {
const AVColorPrimariesDesc *desc; const AVColorPrimariesDesc *desc;
@ -211,6 +211,11 @@ static int libjxl_populate_primaries(JxlColorEncoding *jxl_color, enum AVColorPr
jxl_color->primaries = JXL_PRIMARIES_P3; jxl_color->primaries = JXL_PRIMARIES_P3;
jxl_color->white_point = JXL_WHITE_POINT_D65; jxl_color->white_point = JXL_WHITE_POINT_D65;
return 0; return 0;
case AVCOL_PRI_UNSPECIFIED:
av_log(avctx, AV_LOG_WARNING, "Unknown primaries, assuming BT.709/sRGB. Colors may be wrong.\n");
jxl_color->primaries = JXL_PRIMARIES_SRGB;
jxl_color->white_point = JXL_WHITE_POINT_D65;
return 0;
} }
desc = av_csp_primaries_desc_from_id(prm); desc = av_csp_primaries_desc_from_id(prm);
@ -340,7 +345,7 @@ static int libjxl_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFra
else else
jxl_color.color_space = JXL_COLOR_SPACE_RGB; jxl_color.color_space = JXL_COLOR_SPACE_RGB;
ret = libjxl_populate_primaries(&jxl_color, ret = libjxl_populate_primaries(avctx, &jxl_color,
frame->color_primaries && frame->color_primaries != AVCOL_PRI_UNSPECIFIED frame->color_primaries && frame->color_primaries != AVCOL_PRI_UNSPECIFIED
? frame->color_primaries : avctx->color_primaries); ? frame->color_primaries : avctx->color_primaries);
if (ret < 0) if (ret < 0)

View file

@ -43,7 +43,7 @@ static av_cold int libspeex_decode_init(AVCodecContext *avctx)
LibSpeexContext *s = avctx->priv_data; LibSpeexContext *s = avctx->priv_data;
const SpeexMode *mode; const SpeexMode *mode;
SpeexHeader *header = NULL; SpeexHeader *header = NULL;
int spx_mode, channels; int spx_mode, channels = avctx->ch_layout.nb_channels;
if (avctx->extradata && avctx->extradata_size >= 80) { if (avctx->extradata && avctx->extradata_size >= 80) {
header = speex_packet_to_header(avctx->extradata, header = speex_packet_to_header(avctx->extradata,

View file

@ -124,16 +124,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));
@ -183,7 +179,10 @@ static int config_enc_params(EbSvtAv1EncConfiguration *param,
param->min_qp_allowed = avctx->qmin; param->min_qp_allowed = avctx->qmin;
} }
param->max_bit_rate = avctx->rc_max_rate; param->max_bit_rate = avctx->rc_max_rate;
param->vbv_bufsize = avctx->rc_buffer_size; if ((avctx->bit_rate > 0 || avctx->rc_max_rate > 0) && avctx->rc_buffer_size)
param->maximum_buffer_size_ms =
avctx->rc_buffer_size * 1000LL /
FFMAX(avctx->bit_rate, avctx->rc_max_rate);
if (svt_enc->crf > 0) { if (svt_enc->crf > 0) {
param->qp = svt_enc->crf; param->qp = svt_enc->crf;
@ -300,7 +299,8 @@ static int config_enc_params(EbSvtAv1EncConfiguration *param,
avctx->bit_rate = param->rate_control_mode > 0 ? avctx->bit_rate = param->rate_control_mode > 0 ?
param->target_bit_rate : 0; param->target_bit_rate : 0;
avctx->rc_max_rate = param->max_bit_rate; avctx->rc_max_rate = param->max_bit_rate;
avctx->rc_buffer_size = param->vbv_bufsize; avctx->rc_buffer_size = param->maximum_buffer_size_ms *
FFMAX(avctx->bit_rate, avctx->rc_max_rate) / 1000LL;
if (avctx->bit_rate || avctx->rc_max_rate || avctx->rc_buffer_size) { if (avctx->bit_rate || avctx->rc_max_rate || avctx->rc_buffer_size) {
AVCPBProperties *cpb_props = ff_add_cpb_side_data(avctx); AVCPBProperties *cpb_props = ff_add_cpb_side_data(avctx);
@ -424,11 +424,8 @@ static int eb_send_frame(AVCodecContext *avctx, const AVFrame *frame)
if (svt_enc->eos_flag == EOS_SENT) if (svt_enc->eos_flag == EOS_SENT)
return 0; return 0;
headerPtrLast.n_alloc_len = 0; memset(&headerPtrLast, 0, sizeof(headerPtrLast));
headerPtrLast.n_filled_len = 0; headerPtrLast.pic_type = EB_AV1_INVALID_PICTURE;
headerPtrLast.n_tick_count = 0;
headerPtrLast.p_app_private = NULL;
headerPtrLast.p_buffer = NULL;
headerPtrLast.flags = EB_BUFFERFLAG_EOS; headerPtrLast.flags = EB_BUFFERFLAG_EOS;
svt_av1_enc_send_picture(svt_enc->svt_handle, &headerPtrLast); svt_av1_enc_send_picture(svt_enc->svt_handle, &headerPtrLast);

View file

@ -56,8 +56,6 @@
struct FrameListData { struct FrameListData {
void *buf; /**< compressed data buffer */ void *buf; /**< compressed data buffer */
size_t sz; /**< length of compressed data */ size_t sz; /**< length of compressed data */
void *buf_alpha;
size_t sz_alpha;
int64_t pts; /**< time stamp to show frame int64_t pts; /**< time stamp to show frame
(in timebase units) */ (in timebase units) */
unsigned long duration; /**< duration to show frame unsigned long duration; /**< duration to show frame
@ -87,6 +85,7 @@ typedef struct VPxEncoderContext {
int have_sse; /**< true if we have pending sse[] */ int have_sse; /**< true if we have pending sse[] */
uint64_t frame_number; uint64_t frame_number;
struct FrameListData *coded_frame_list; struct FrameListData *coded_frame_list;
struct FrameListData *alpha_coded_frame_list;
int cpu_used; int cpu_used;
int sharpness; int sharpness;
@ -311,8 +310,6 @@ static void coded_frame_add(void *list, struct FrameListData *cx_frame)
static av_cold void free_coded_frame(struct FrameListData *cx_frame) static av_cold void free_coded_frame(struct FrameListData *cx_frame)
{ {
av_freep(&cx_frame->buf); av_freep(&cx_frame->buf);
if (cx_frame->buf_alpha)
av_freep(&cx_frame->buf_alpha);
av_freep(&cx_frame); av_freep(&cx_frame);
} }
@ -446,6 +443,7 @@ static av_cold int vpx_free(AVCodecContext *avctx)
av_freep(&ctx->twopass_stats.buf); av_freep(&ctx->twopass_stats.buf);
av_freep(&avctx->stats_out); av_freep(&avctx->stats_out);
free_frame_list(ctx->coded_frame_list); free_frame_list(ctx->coded_frame_list);
free_frame_list(ctx->alpha_coded_frame_list);
if (ctx->hdr10_plus_fifo) if (ctx->hdr10_plus_fifo)
free_hdr10_plus_fifo(&ctx->hdr10_plus_fifo); free_hdr10_plus_fifo(&ctx->hdr10_plus_fifo);
return 0; return 0;
@ -1205,7 +1203,6 @@ static av_cold int vpx_init(AVCodecContext *avctx,
static inline void cx_pktcpy(struct FrameListData *dst, static inline void cx_pktcpy(struct FrameListData *dst,
const struct vpx_codec_cx_pkt *src, const struct vpx_codec_cx_pkt *src,
const struct vpx_codec_cx_pkt *src_alpha,
VPxContext *ctx) VPxContext *ctx)
{ {
dst->pts = src->data.frame.pts; dst->pts = src->data.frame.pts;
@ -1229,13 +1226,6 @@ static inline void cx_pktcpy(struct FrameListData *dst,
} else { } else {
dst->frame_number = -1; /* sanity marker */ dst->frame_number = -1; /* sanity marker */
} }
if (src_alpha) {
dst->buf_alpha = src_alpha->data.frame.buf;
dst->sz_alpha = src_alpha->data.frame.sz;
} else {
dst->buf_alpha = NULL;
dst->sz_alpha = 0;
}
} }
/** /**
@ -1246,7 +1236,7 @@ static inline void cx_pktcpy(struct FrameListData *dst,
* @return a negative AVERROR on error * @return a negative AVERROR on error
*/ */
static int storeframe(AVCodecContext *avctx, struct FrameListData *cx_frame, static int storeframe(AVCodecContext *avctx, struct FrameListData *cx_frame,
AVPacket *pkt) struct FrameListData *alpha_cx_frame, AVPacket *pkt)
{ {
VPxContext *ctx = avctx->priv_data; VPxContext *ctx = avctx->priv_data;
int ret = ff_get_encode_buffer(avctx, pkt, cx_frame->sz, 0); int ret = ff_get_encode_buffer(avctx, pkt, cx_frame->sz, 0);
@ -1279,16 +1269,16 @@ static int storeframe(AVCodecContext *avctx, struct FrameListData *cx_frame,
avctx->error[i] += cx_frame->sse[i + 1]; avctx->error[i] += cx_frame->sse[i + 1];
cx_frame->have_sse = 0; cx_frame->have_sse = 0;
} }
if (cx_frame->sz_alpha > 0) { if (alpha_cx_frame) {
side_data = av_packet_new_side_data(pkt, side_data = av_packet_new_side_data(pkt,
AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL,
cx_frame->sz_alpha + 8); alpha_cx_frame->sz + 8);
if (!side_data) { if (!side_data) {
av_packet_unref(pkt); av_packet_unref(pkt);
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
} }
AV_WB64(side_data, 1); AV_WB64(side_data, 1);
memcpy(side_data + 8, cx_frame->buf_alpha, cx_frame->sz_alpha); memcpy(side_data + 8, alpha_cx_frame->buf, alpha_cx_frame->sz);
} }
if (cx_frame->frame_number != -1) { if (cx_frame->frame_number != -1) {
if (ctx->hdr10_plus_fifo) { if (ctx->hdr10_plus_fifo) {
@ -1309,40 +1299,37 @@ static int storeframe(AVCodecContext *avctx, struct FrameListData *cx_frame,
* @return AVERROR(EINVAL) on output size error * @return AVERROR(EINVAL) on output size error
* @return AVERROR(ENOMEM) on coded frame queue data allocation error * @return AVERROR(ENOMEM) on coded frame queue data allocation error
*/ */
static int queue_frames(AVCodecContext *avctx, AVPacket *pkt_out) static int queue_frames(AVCodecContext *avctx, struct vpx_codec_ctx *encoder,
struct FrameListData **frame_list, AVPacket *pkt_out)
{ {
VPxContext *ctx = avctx->priv_data; VPxContext *ctx = avctx->priv_data;
const struct vpx_codec_cx_pkt *pkt; const struct vpx_codec_cx_pkt *pkt;
const struct vpx_codec_cx_pkt *pkt_alpha = NULL;
const void *iter = NULL; const void *iter = NULL;
const void *iter_alpha = NULL;
int size = 0; int size = 0;
if (ctx->coded_frame_list) { if (!ctx->is_alpha && *frame_list) {
struct FrameListData *cx_frame = ctx->coded_frame_list; struct FrameListData *cx_frame = *frame_list;
/* return the leading frame if we've already begun queueing */ /* return the leading frame if we've already begun queueing */
size = storeframe(avctx, cx_frame, pkt_out); size = storeframe(avctx, cx_frame, NULL, pkt_out);
if (size < 0) if (size < 0)
return size; return size;
ctx->coded_frame_list = cx_frame->next; *frame_list = cx_frame->next;
free_coded_frame(cx_frame); free_coded_frame(cx_frame);
} }
/* consume all available output from the encoder before returning. buffers /* consume all available output from the encoder before returning. buffers
are only good through the next vpx_codec call */ are only good through the next vpx_codec call */
while ((pkt = vpx_codec_get_cx_data(&ctx->encoder, &iter)) && while (pkt = vpx_codec_get_cx_data(encoder, &iter)) {
(!ctx->is_alpha ||
(pkt_alpha = vpx_codec_get_cx_data(&ctx->encoder_alpha, &iter_alpha)))) {
switch (pkt->kind) { switch (pkt->kind) {
case VPX_CODEC_CX_FRAME_PKT: case VPX_CODEC_CX_FRAME_PKT:
if (!size) { if (!ctx->is_alpha && !size) {
struct FrameListData cx_frame; struct FrameListData cx_frame;
/* avoid storing the frame when the list is empty and we haven't yet /* avoid storing the frame when the list is empty and we haven't yet
provided a frame for output */ provided a frame for output */
av_assert0(!ctx->coded_frame_list); av_assert0(!ctx->coded_frame_list);
cx_pktcpy(&cx_frame, pkt, pkt_alpha, ctx); cx_pktcpy(&cx_frame, pkt, ctx);
size = storeframe(avctx, &cx_frame, pkt_out); size = storeframe(avctx, &cx_frame, NULL, pkt_out);
if (size < 0) if (size < 0)
return size; return size;
} else { } else {
@ -1353,7 +1340,7 @@ static int queue_frames(AVCodecContext *avctx, AVPacket *pkt_out)
"Frame queue element alloc failed\n"); "Frame queue element alloc failed\n");
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
} }
cx_pktcpy(cx_frame, pkt, pkt_alpha, ctx); cx_pktcpy(cx_frame, pkt, ctx);
cx_frame->buf = av_malloc(cx_frame->sz); cx_frame->buf = av_malloc(cx_frame->sz);
if (!cx_frame->buf) { if (!cx_frame->buf) {
@ -1364,23 +1351,14 @@ static int queue_frames(AVCodecContext *avctx, AVPacket *pkt_out)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
} }
memcpy(cx_frame->buf, pkt->data.frame.buf, pkt->data.frame.sz); memcpy(cx_frame->buf, pkt->data.frame.buf, pkt->data.frame.sz);
if (ctx->is_alpha) { coded_frame_add(frame_list, cx_frame);
cx_frame->buf_alpha = av_malloc(cx_frame->sz_alpha);
if (!cx_frame->buf_alpha) {
av_log(avctx, AV_LOG_ERROR,
"Data buffer alloc (%"SIZE_SPECIFIER" bytes) failed\n",
cx_frame->sz_alpha);
av_free(cx_frame);
return AVERROR(ENOMEM);
}
memcpy(cx_frame->buf_alpha, pkt_alpha->data.frame.buf, pkt_alpha->data.frame.sz);
}
coded_frame_add(&ctx->coded_frame_list, cx_frame);
} }
break; break;
case VPX_CODEC_STATS_PKT: { case VPX_CODEC_STATS_PKT: {
struct vpx_fixed_buf *stats = &ctx->twopass_stats; struct vpx_fixed_buf *stats = &ctx->twopass_stats;
int err; int err;
if (!pkt_out)
break;
if ((err = av_reallocp(&stats->buf, if ((err = av_reallocp(&stats->buf,
stats->sz + stats->sz +
pkt->data.twopass_stats.sz)) < 0) { pkt->data.twopass_stats.sz)) < 0) {
@ -1394,6 +1372,8 @@ static int queue_frames(AVCodecContext *avctx, AVPacket *pkt_out)
break; break;
} }
case VPX_CODEC_PSNR_PKT: case VPX_CODEC_PSNR_PKT:
if (!pkt_out)
break;
av_assert0(!ctx->have_sse); av_assert0(!ctx->have_sse);
ctx->sse[0] = pkt->data.psnr.sse[0]; ctx->sse[0] = pkt->data.psnr.sse[0];
ctx->sse[1] = pkt->data.psnr.sse[1]; ctx->sse[1] = pkt->data.psnr.sse[1];
@ -1788,7 +1768,24 @@ static int vpx_encode(AVCodecContext *avctx, AVPacket *pkt,
} }
} }
coded_size = queue_frames(avctx, pkt); coded_size = queue_frames(avctx, &ctx->encoder, &ctx->coded_frame_list, pkt);
if (ctx->is_alpha) {
queue_frames(avctx, &ctx->encoder_alpha, &ctx->alpha_coded_frame_list, NULL);
if (ctx->coded_frame_list && ctx->alpha_coded_frame_list) {
struct FrameListData *cx_frame = ctx->coded_frame_list;
struct FrameListData *alpha_cx_frame = ctx->alpha_coded_frame_list;
av_assert0(!coded_size);
/* return the leading frame if we've already begun queueing */
coded_size = storeframe(avctx, cx_frame, alpha_cx_frame, pkt);
if (coded_size < 0)
return coded_size;
ctx->coded_frame_list = cx_frame->next;
ctx->alpha_coded_frame_list = alpha_cx_frame->next;
free_coded_frame(cx_frame);
free_coded_frame(alpha_cx_frame);
}
}
if (!frame && avctx->flags & AV_CODEC_FLAG_PASS1) { if (!frame && avctx->flags & AV_CODEC_FLAG_PASS1) {
unsigned int b64_size = AV_BASE64_SIZE(ctx->twopass_stats.sz); unsigned int b64_size = AV_BASE64_SIZE(ctx->twopass_stats.sz);

View file

@ -504,7 +504,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;
@ -575,8 +581,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);
@ -604,10 +618,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;
@ -625,17 +645,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

@ -92,10 +92,15 @@ static inline int loco_get_rice(RICEContext *r)
if (get_bits_left(&r->gb) < 1) if (get_bits_left(&r->gb) < 1)
return INT_MIN; return INT_MIN;
v = get_ur_golomb_jpegls(&r->gb, loco_get_rice_param(r), INT_MAX, 0); v = get_ur_golomb_jpegls(&r->gb, loco_get_rice_param(r), INT_MAX, 0);
if (v == -1)
return INT_MIN;
loco_update_rice_param(r, (v + 1) >> 1); loco_update_rice_param(r, (v + 1) >> 1);
if (!v) { if (!v) {
if (r->save >= 0) { if (r->save >= 0) {
r->run = get_ur_golomb_jpegls(&r->gb, 2, INT_MAX, 0); int run = get_ur_golomb_jpegls(&r->gb, 2, INT_MAX, 0);
if (run == -1)
return INT_MIN;
r->run = run;
if (r->run > 1) if (r->run > 1)
r->save += r->run + 1; r->save += r->run + 1;
else else
@ -152,6 +157,8 @@ static int loco_decode_plane(LOCOContext *l, uint8_t *data, int width, int heigh
/* restore top left pixel */ /* restore top left pixel */
val = loco_get_rice(&rc); val = loco_get_rice(&rc);
if (val == INT_MIN)
return AVERROR_INVALIDDATA;
data[0] = 128 + val; data[0] = 128 + val;
/* restore top line */ /* restore top line */
for (i = 1; i < width; i++) { for (i = 1; i < width; i++) {

View file

@ -244,8 +244,10 @@ int ff_lpc_calc_coefs(LPCContext *s,
double av_uninit(weight); double av_uninit(weight);
memset(var, 0, FFALIGN(MAX_LPC_ORDER+1,4)*sizeof(*var)); memset(var, 0, FFALIGN(MAX_LPC_ORDER+1,4)*sizeof(*var));
for(j=0; j<max_order; j++) /* Avoids initializing with an unused value when lpc_passes == 1 */
m[0].coeff[max_order-1][j] = -lpc[max_order-1][j]; if (lpc_passes > 1)
for(j=0; j<max_order; j++)
m[0].coeff[max_order-1][j] = -lpc[max_order-1][j];
for(; pass<lpc_passes; pass++){ for(; pass<lpc_passes; pass++){
avpriv_init_lls(&m[pass&1], max_order); avpriv_init_lls(&m[pass&1], max_order);

View file

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

View file

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

View file

@ -248,7 +248,7 @@ static int mf_sample_to_avpacket(AVCodecContext *avctx, IMFSample *sample, AVPac
if ((ret = ff_get_encode_buffer(avctx, avpkt, len, 0)) < 0) if ((ret = ff_get_encode_buffer(avctx, avpkt, len, 0)) < 0)
return ret; return ret;
IMFSample_ConvertToContiguousBuffer(sample, &buffer); hr = IMFSample_ConvertToContiguousBuffer(sample, &buffer);
if (FAILED(hr)) if (FAILED(hr))
return AVERROR_EXTERNAL; return AVERROR_EXTERNAL;

View file

@ -203,12 +203,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe,
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);
@ -217,9 +212,13 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe,
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

@ -1092,6 +1092,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;
@ -1208,6 +1212,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++)
@ -1942,6 +1948,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

@ -309,7 +309,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))

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