Compare commits

...

90 Commits

Author SHA1 Message Date
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 5663301560d77486c7f7c03c1aa5f542fab23c24.)

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
129 changed files with 806 additions and 407 deletions

View File

@@ -1,6 +1,83 @@
Entries are sorted chronologically from oldest to youngest within each release,
releases are sorted from youngest to oldest.
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:
- add ipfs/ipns protocol support
- dialogue enhance audio filter

View File

@@ -625,6 +625,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
Lynne FE50 139C 6805 72CA FD52 1F8D A2FE A5F0 3F03 4464
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
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

View File

@@ -1 +1 @@
4.4.git
5.1.2

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.

4
configure vendored
View File

@@ -2781,7 +2781,7 @@ atrac3al_decoder_select="mdct"
atrac3p_decoder_select="mdct sinewin"
atrac3pal_decoder_select="mdct sinewin"
atrac9_decoder_select="mdct"
av1_decoder_select="cbs_av1"
av1_decoder_select="av1_frame_split_bsf cbs_av1"
bink_decoder_select="blockdsp hpeldsp"
binkaudio_dct_decoder_select="mdct rdft dct sinewin wma_freqs"
binkaudio_rdft_decoder_select="mdct rdft sinewin wma_freqs"
@@ -6666,7 +6666,7 @@ enabled libvpx && {
enabled libwebp && {
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 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" && {
[ "$toolchain" != "msvc" ] ||
require_cpp_condition libx264 x264.h "X264_BUILD >= 158"; } &&

View File

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

View File

@@ -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
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})
Set the input time offset.

View File

@@ -187,11 +187,18 @@ to make sure you don't have untracked files or deletions.
git add [-i|-p|-A] <filenames/dirnames>
@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
git config --global user.name "My Name"
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
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.
@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
Once you have a set of commits that you feel are ready for pushing,

View File

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

View File

@@ -235,6 +235,7 @@ static void init_options(OptionsContext *o)
o->chapters_input_file = INT_MAX;
o->accurate_seek = 1;
o->thread_queue_size = -1;
o->input_sync_ref = -1;
}
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;
}
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)
{
av_free(filter_nbthreads);
@@ -1305,6 +1358,7 @@ static int open_input_file(OptionsContext *o, const char *filename)
f->ist_index = nb_input_streams - ic->nb_streams;
f->start_time = o->start_time;
f->recording_time = o->recording_time;
f->input_sync_ref = o->input_sync_ref;
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->nb_streams = ic->nb_streams;
@@ -2318,6 +2372,43 @@ static int init_complex_filters(void)
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)
{
AVFormatContext *oc;
@@ -2720,7 +2811,7 @@ loop_end:
f->sample_rates = ost->enc->supported_samplerates;
}
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) {
f->ch_layouts = ost->enc->ch_layouts;
}
@@ -3489,6 +3580,8 @@ int ffmpeg_parse_options(int argc, char **argv)
goto fail;
}
apply_sync_offsets();
/* create the complex filtergraphs */
ret = init_complex_filters();
if (ret < 0) {
@@ -3603,6 +3696,9 @@ const OptionDef options[] = {
{ "accurate_seek", OPT_BOOL | OPT_OFFSET | OPT_EXPERT |
OPT_INPUT, { .off = OFFSET(accurate_seek) },
"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 |
OPT_EXPERT | OPT_INPUT, { .off = OFFSET(input_ts_offset) },
"set the input ts offset", "time_off" },

View File

@@ -4026,7 +4026,7 @@ int main(int argc, char **argv)
WriterContext *wctx;
char *buf;
char *w_name = NULL, *w_args = NULL;
int ret, i;
int ret, input_ret, i;
init_dynload();
@@ -4150,10 +4150,14 @@ int main(int argc, char **argv)
show_error(wctx, ret);
}
input_ret = ret;
writer_print_section_footer(wctx);
ret = writer_close(&wctx);
if (ret < 0)
av_log(NULL, AV_LOG_ERROR, "Writing output failed: %s\n", av_err2str(ret));
ret = FFMIN(ret, input_ret);
}
end:

View File

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

View File

@@ -574,13 +574,15 @@ static av_cold int alac_decode_init(AVCodecContext * avctx)
avctx->bits_per_raw_sample = alac->sample_size;
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");
if (avctx->ch_layout.nb_channels < 1)
return AVERROR(EINVAL);
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",
avctx->ch_layout.nb_channels);
alac->channels);
return AVERROR_PATCHWELCOME;
}
av_channel_layout_uninit(&avctx->ch_layout);

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][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);
return p->filterA[filter];

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
* function) in order to have only aligned reads from 'in' array
* and reduce number of load instructions */
vld1.16 {d4, d5}, [r0, :64]!
vld1.16 {d8, d9}, [r2, :128]!
vld1.16 {d16, d17}, [r0, :64]!
vld1.16 {d20, d21}, [r2, :128]!
vmull.s16 q0, d4, d8
vld1.16 {d6, d7}, [r0, :64]!
vmull.s16 q1, d5, d9
vld1.16 {d10, d11}, [r2, :128]!
vmull.s16 q0, d16, d20
vld1.16 {d18, d19}, [r0, :64]!
vmull.s16 q1, d17, d21
vld1.16 {d22, d23}, [r2, :128]!
vmlal.s16 q0, d6, d10
vld1.16 {d4, d5}, [r0, :64]!
vmlal.s16 q1, d7, d11
vld1.16 {d8, d9}, [r2, :128]!
vmlal.s16 q0, d18, d22
vld1.16 {d16, d17}, [r0, :64]!
vmlal.s16 q1, d19, d23
vld1.16 {d20, d21}, [r2, :128]!
vmlal.s16 q0, d4, d8
vld1.16 {d6, d7}, [r0, :64]!
vmlal.s16 q1, d5, d9
vld1.16 {d10, d11}, [r2, :128]!
vmlal.s16 q0, d16, d20
vld1.16 {d18, d19}, [r0, :64]!
vmlal.s16 q1, d17, d21
vld1.16 {d22, d23}, [r2, :128]!
vmlal.s16 q0, d6, d10
vld1.16 {d4, d5}, [r0, :64]!
vmlal.s16 q1, d7, d11
vld1.16 {d8, d9}, [r2, :128]!
vmlal.s16 q0, d18, d22
vld1.16 {d16, d17}, [r0, :64]!
vmlal.s16 q1, d19, d23
vld1.16 {d20, d21}, [r2, :128]!
vmlal.s16 q0, d4, d8
vmlal.s16 q1, d5, d9
vmlal.s16 q0, d16, d20
vmlal.s16 q1, d17, d21
vpadd.s32 d0, d0, d1
vpadd.s32 d1, d2, d3
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 d0, d0[0] /* TODO: can be eliminated */
vmull.s16 q3, d2, d0
vmull.s16 q4, d3, d0
vmlal.s16 q3, d4, d1
vmlal.s16 q4, d5, d1
vmull.s16 q10, d16, d0
vmull.s16 q11, d17, d0
vmlal.s16 q10, d18, d1
vmlal.s16 q11, d19, d1
vpadd.s32 d0, d6, d7 /* TODO: can be eliminated */
vpadd.s32 d1, d8, d9 /* TODO: can be eliminated */
vpadd.s32 d0, d20, d21 /* TODO: can be eliminated */
vpadd.s32 d1, d22, d23 /* TODO: can be eliminated */
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
* function) in order to have only aligned reads from 'in' array
* and reduce number of load instructions */
vld1.16 {d4, d5}, [r0, :64]!
vld1.16 {d8, d9}, [r2, :128]!
vld1.16 {d16, d17}, [r0, :64]!
vld1.16 {d20, d21}, [r2, :128]!
vmull.s16 q6, d4, d8
vld1.16 {d6, d7}, [r0, :64]!
vmull.s16 q7, d5, d9
vld1.16 {d10, d11}, [r2, :128]!
vmull.s16 q8, d6, d10
vld1.16 {d4, d5}, [r0, :64]!
vmull.s16 q9, d7, d11
vld1.16 {d8, d9}, [r2, :128]!
vmull.s16 q12, d16, d20
vld1.16 {d18, d19}, [r0, :64]!
vmull.s16 q13, d17, d21
vld1.16 {d22, d23}, [r2, :128]!
vmull.s16 q14, d18, d22
vld1.16 {d16, d17}, [r0, :64]!
vmull.s16 q15, d19, d23
vld1.16 {d20, d21}, [r2, :128]!
vmlal.s16 q6, d4, d8
vld1.16 {d6, d7}, [r0, :64]!
vmlal.s16 q7, d5, d9
vld1.16 {d10, d11}, [r2, :128]!
vmlal.s16 q8, d6, d10
vld1.16 {d4, d5}, [r0, :64]!
vmlal.s16 q9, d7, d11
vld1.16 {d8, d9}, [r2, :128]!
vmlal.s16 q12, d16, d20
vld1.16 {d18, d19}, [r0, :64]!
vmlal.s16 q13, d17, d21
vld1.16 {d22, d23}, [r2, :128]!
vmlal.s16 q14, d18, d22
vld1.16 {d16, d17}, [r0, :64]!
vmlal.s16 q15, d19, d23
vld1.16 {d20, d21}, [r2, :128]!
vmlal.s16 q6, d4, d8
vld1.16 {d6, d7}, [r0, :64]!
vmlal.s16 q7, d5, d9
vld1.16 {d10, d11}, [r2, :128]!
vmlal.s16 q8, d6, d10
vld1.16 {d4, d5}, [r0, :64]!
vmlal.s16 q9, d7, d11
vld1.16 {d8, d9}, [r2, :128]!
vmlal.s16 q12, d16, d20
vld1.16 {d18, d19}, [r0, :64]!
vmlal.s16 q13, d17, d21
vld1.16 {d22, d23}, [r2, :128]!
vmlal.s16 q14, d18, d22
vld1.16 {d16, d17}, [r0, :64]!
vmlal.s16 q15, d19, d23
vld1.16 {d20, d21}, [r2, :128]!
vmlal.s16 q6, d4, d8
vld1.16 {d6, d7}, [r0, :64]!
vmlal.s16 q7, d5, d9
vld1.16 {d10, d11}, [r2, :128]!
vmlal.s16 q8, d6, d10
vld1.16 {d4, d5}, [r0, :64]!
vmlal.s16 q9, d7, d11
vld1.16 {d8, d9}, [r2, :128]!
vmlal.s16 q12, d16, d20
vld1.16 {d18, d19}, [r0, :64]!
vmlal.s16 q13, d17, d21
vld1.16 {d22, d23}, [r2, :128]!
vmlal.s16 q14, d18, d22
vld1.16 {d16, d17}, [r0, :64]!
vmlal.s16 q15, d19, d23
vld1.16 {d20, d21}, [r2, :128]!
vmlal.s16 q6, d4, d8
vld1.16 {d6, d7}, [r0, :64]!
vmlal.s16 q7, d5, d9
vld1.16 {d10, d11}, [r2, :128]!
vmlal.s16 q12, d16, d20
vld1.16 {d18, d19}, [r0, :64]!
vmlal.s16 q13, d17, d21
vld1.16 {d22, d23}, [r2, :128]!
vmlal.s16 q8, d6, d10
vmlal.s16 q9, d7, d11
vmlal.s16 q14, d18, d22
vmlal.s16 q15, d19, d23
vpadd.s32 d0, d12, d13
vpadd.s32 d1, d14, d15
vpadd.s32 d2, d16, d17
vpadd.s32 d3, d18, d19
vpadd.s32 d0, d24, d25
vpadd.s32 d1, d26, d27
vpadd.s32 d2, d28, d29
vpadd.s32 d3, d30, d31
vrshr.s32 q0, q0, 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 d0, d0[0] /* TODO: can be eliminated */
vld1.16 {d4, d5}, [r2, :128]!
vmull.s16 q6, d4, d0
vld1.16 {d6, d7}, [r2, :128]!
vmull.s16 q7, d5, d0
vmull.s16 q8, d6, d0
vmull.s16 q9, d7, d0
vld1.16 {d16, d17}, [r2, :128]!
vmull.s16 q12, d16, d0
vld1.16 {d18, d19}, [r2, :128]!
vmull.s16 q13, d17, d0
vmull.s16 q14, d18, d0
vmull.s16 q15, d19, d0
vld1.16 {d4, d5}, [r2, :128]!
vmlal.s16 q6, d4, d1
vld1.16 {d6, d7}, [r2, :128]!
vmlal.s16 q7, d5, d1
vmlal.s16 q8, d6, d1
vmlal.s16 q9, d7, d1
vld1.16 {d16, d17}, [r2, :128]!
vmlal.s16 q12, d16, d1
vld1.16 {d18, d19}, [r2, :128]!
vmlal.s16 q13, d17, d1
vmlal.s16 q14, d18, d1
vmlal.s16 q15, d19, d1
vld1.16 {d4, d5}, [r2, :128]!
vmlal.s16 q6, d4, d2
vld1.16 {d6, d7}, [r2, :128]!
vmlal.s16 q7, d5, d2
vmlal.s16 q8, d6, d2
vmlal.s16 q9, d7, d2
vld1.16 {d16, d17}, [r2, :128]!
vmlal.s16 q12, d16, d2
vld1.16 {d18, d19}, [r2, :128]!
vmlal.s16 q13, d17, d2
vmlal.s16 q14, d18, d2
vmlal.s16 q15, d19, d2
vld1.16 {d4, d5}, [r2, :128]!
vmlal.s16 q6, d4, d3
vld1.16 {d6, d7}, [r2, :128]!
vmlal.s16 q7, d5, d3
vmlal.s16 q8, d6, d3
vmlal.s16 q9, d7, d3
vld1.16 {d16, d17}, [r2, :128]!
vmlal.s16 q12, d16, d3
vld1.16 {d18, d19}, [r2, :128]!
vmlal.s16 q13, d17, d3
vmlal.s16 q14, d18, d3
vmlal.s16 q15, d19, d3
vpadd.s32 d0, d12, d13 /* TODO: can be eliminated */
vpadd.s32 d1, d14, d15 /* TODO: can be eliminated */
vpadd.s32 d2, d16, d17 /* TODO: can be eliminated */
vpadd.s32 d3, d18, d19 /* TODO: can be eliminated */
vpadd.s32 d0, d24, d25 /* TODO: can be eliminated */
vpadd.s32 d1, d26, d27 /* TODO: can be eliminated */
vpadd.s32 d2, d28, d29 /* TODO: can be eliminated */
vpadd.s32 d3, d30, d31 /* TODO: can be eliminated */
vst1.32 {d0, d1, d2, d3}, [r1, :128]

View File

@@ -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) {
blk = get_value(c, BINK_SRC_BLOCK_TYPES);
// 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++;
dst += 8;
prev += 8;

View File

@@ -216,7 +216,7 @@ static uint8_t prob_dst_x_bit(int c)
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;
@@ -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);
for (k = 0; k < 256; k++) {
int v = 0;
int64_t v = 0;
for (l = 0; l < total; 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;
}
}
}
return 0;
}
static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
@@ -329,7 +332,9 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
return AVERROR_INVALIDDATA;
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(dsd, 0, frame->nb_samples * 4 * channels);

View File

@@ -1241,7 +1241,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->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;
td->channel_line_size = td->xsize * s->current_channel_offset;/* uncompress size of one line */
@@ -1265,7 +1266,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->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;
td->channel_line_size = td->xsize * s->current_channel_offset;/* uncompress size of one line */
@@ -1949,9 +1951,12 @@ static int decode_header(EXRContext *s, AVFrame *frame)
"preview", 16)) >= 0) {
uint32_t pw = bytestream2_get_le32(gb);
uint32_t ph = bytestream2_get_le32(gb);
int64_t psize = 4LL * pw * ph;
uint64_t psize = pw * ph;
if (psize > INT64_MAX / 4)
return AVERROR_INVALIDDATA;
psize *= 4;
if (psize >= bytestream2_get_bytes_left(gb))
if ((int64_t)psize >= bytestream2_get_bytes_left(gb))
return AVERROR_INVALIDDATA;
bytestream2_skip(gb, psize);

View File

@@ -883,7 +883,14 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe,
if (buf_size < avctx->width * avctx->height / (128*8))
return AVERROR_INVALIDDATA;
} 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;
}

View File

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

View File

@@ -552,6 +552,8 @@ retry:
avctx->has_b_frames = !s->low_delay;
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)
goto retry;
if (s->studio_profile != (s->idsp.idct == NULL))

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) {
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);
dst += stride_dst;
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 {
for (i = 0; i < height; i++) {
for (j = 0; j < width; j+=16)

View File

@@ -3516,7 +3516,7 @@ static int hevc_decode_frame(AVCodecContext *avctx, AVFrame *rframe,
}
} else {
/* 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) {
ret = verify_md5(s, s->ref->frame);
if (ret < 0 && avctx->err_recognition & AV_EF_EXPLODE) {

View File

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

View File

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

View File

@@ -424,11 +424,8 @@ static int eb_send_frame(AVCodecContext *avctx, const AVFrame *frame)
if (svt_enc->eos_flag == EOS_SENT)
return 0;
headerPtrLast.n_alloc_len = 0;
headerPtrLast.n_filled_len = 0;
headerPtrLast.n_tick_count = 0;
headerPtrLast.p_app_private = NULL;
headerPtrLast.p_buffer = NULL;
memset(&headerPtrLast, 0, sizeof(headerPtrLast));
headerPtrLast.pic_type = EB_AV1_INVALID_PICTURE;
headerPtrLast.flags = EB_BUFFERFLAG_EOS;
svt_av1_enc_send_picture(svt_enc->svt_handle, &headerPtrLast);

View File

@@ -56,8 +56,6 @@
struct FrameListData {
void *buf; /**< compressed data buffer */
size_t sz; /**< length of compressed data */
void *buf_alpha;
size_t sz_alpha;
int64_t pts; /**< time stamp to show frame
(in timebase units) */
unsigned long duration; /**< duration to show frame
@@ -87,6 +85,7 @@ typedef struct VPxEncoderContext {
int have_sse; /**< true if we have pending sse[] */
uint64_t frame_number;
struct FrameListData *coded_frame_list;
struct FrameListData *alpha_coded_frame_list;
int cpu_used;
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)
{
av_freep(&cx_frame->buf);
if (cx_frame->buf_alpha)
av_freep(&cx_frame->buf_alpha);
av_freep(&cx_frame);
}
@@ -446,6 +443,7 @@ static av_cold int vpx_free(AVCodecContext *avctx)
av_freep(&ctx->twopass_stats.buf);
av_freep(&avctx->stats_out);
free_frame_list(ctx->coded_frame_list);
free_frame_list(ctx->alpha_coded_frame_list);
if (ctx->hdr10_plus_fifo)
free_hdr10_plus_fifo(&ctx->hdr10_plus_fifo);
return 0;
@@ -1205,7 +1203,6 @@ static av_cold int vpx_init(AVCodecContext *avctx,
static inline void cx_pktcpy(struct FrameListData *dst,
const struct vpx_codec_cx_pkt *src,
const struct vpx_codec_cx_pkt *src_alpha,
VPxContext *ctx)
{
dst->pts = src->data.frame.pts;
@@ -1229,13 +1226,6 @@ static inline void cx_pktcpy(struct FrameListData *dst,
} else {
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
*/
static int storeframe(AVCodecContext *avctx, struct FrameListData *cx_frame,
AVPacket *pkt)
struct FrameListData *alpha_cx_frame, AVPacket *pkt)
{
VPxContext *ctx = avctx->priv_data;
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];
cx_frame->have_sse = 0;
}
if (cx_frame->sz_alpha > 0) {
if (alpha_cx_frame) {
side_data = av_packet_new_side_data(pkt,
AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL,
cx_frame->sz_alpha + 8);
alpha_cx_frame->sz + 8);
if (!side_data) {
av_packet_unref(pkt);
return AVERROR(ENOMEM);
}
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 (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(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;
const struct vpx_codec_cx_pkt *pkt;
const struct vpx_codec_cx_pkt *pkt_alpha = NULL;
const void *iter = NULL;
const void *iter_alpha = NULL;
int size = 0;
if (ctx->coded_frame_list) {
struct FrameListData *cx_frame = ctx->coded_frame_list;
if (!ctx->is_alpha && *frame_list) {
struct FrameListData *cx_frame = *frame_list;
/* 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)
return size;
ctx->coded_frame_list = cx_frame->next;
*frame_list = cx_frame->next;
free_coded_frame(cx_frame);
}
/* consume all available output from the encoder before returning. buffers
are only good through the next vpx_codec call */
while ((pkt = vpx_codec_get_cx_data(&ctx->encoder, &iter)) &&
(!ctx->is_alpha ||
(pkt_alpha = vpx_codec_get_cx_data(&ctx->encoder_alpha, &iter_alpha)))) {
while (pkt = vpx_codec_get_cx_data(encoder, &iter)) {
switch (pkt->kind) {
case VPX_CODEC_CX_FRAME_PKT:
if (!size) {
if (!ctx->is_alpha && !size) {
struct FrameListData cx_frame;
/* avoid storing the frame when the list is empty and we haven't yet
provided a frame for output */
av_assert0(!ctx->coded_frame_list);
cx_pktcpy(&cx_frame, pkt, pkt_alpha, ctx);
size = storeframe(avctx, &cx_frame, pkt_out);
cx_pktcpy(&cx_frame, pkt, ctx);
size = storeframe(avctx, &cx_frame, NULL, pkt_out);
if (size < 0)
return size;
} else {
@@ -1353,7 +1340,7 @@ static int queue_frames(AVCodecContext *avctx, AVPacket *pkt_out)
"Frame queue element alloc failed\n");
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);
if (!cx_frame->buf) {
@@ -1364,23 +1351,14 @@ static int queue_frames(AVCodecContext *avctx, AVPacket *pkt_out)
return AVERROR(ENOMEM);
}
memcpy(cx_frame->buf, pkt->data.frame.buf, pkt->data.frame.sz);
if (ctx->is_alpha) {
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);
coded_frame_add(frame_list, cx_frame);
}
break;
case VPX_CODEC_STATS_PKT: {
struct vpx_fixed_buf *stats = &ctx->twopass_stats;
int err;
if (!pkt_out)
break;
if ((err = av_reallocp(&stats->buf,
stats->sz +
pkt->data.twopass_stats.sz)) < 0) {
@@ -1394,6 +1372,8 @@ static int queue_frames(AVCodecContext *avctx, AVPacket *pkt_out)
break;
}
case VPX_CODEC_PSNR_PKT:
if (!pkt_out)
break;
av_assert0(!ctx->have_sse);
ctx->sse[0] = pkt->data.psnr.sse[0];
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) {
unsigned int b64_size = AV_BASE64_SIZE(ctx->twopass_stats.sz);

View File

@@ -203,12 +203,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe,
bytestream2_skip(gb, 8);
uncompressed = bytestream2_get_le32(gb);
if ((ret = ff_reget_buffer(avctx, s->frame, 0)) < 0)
return ret;
if (uncompressed) {
ret = decode_mvdv(s, avctx, frame);
} else {
if (!uncompressed) {
av_fast_padded_malloc(&s->uncompressed, &s->uncompressed_size, 16LL * (avpkt->size - 12));
if (!s->uncompressed)
return AVERROR(ENOMEM);
@@ -217,9 +212,13 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe,
if (ret < 0)
return 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)
return 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;
if (s->v_max != 1 || s->h_max != 1 || !s->lossless)
return AVERROR_INVALIDDATA;
if (s->bayer) {
if (s->rct || s->pegasus_rct)
return AVERROR_INVALIDDATA;
}
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];
}
} else if (s->bayer) {
if (s->bits <= 8)
return AVERROR_PATCHWELCOME;
if (nb_components == 1) {
/* Leave decoding to the TIFF/DNG decoder (see comment in ff_mjpeg_decode_sof) */
for (mb_x = 0; mb_x < width; mb_x++)
@@ -1942,6 +1948,8 @@ static int mjpeg_decode_app(MJpegDecodeContext *s)
}
len -= 9;
if (s->bayer)
goto out;
if (s->got_picture)
if (rgb != s->rgb || pegasus_rct != s->pegasus_rct) {
av_log(s->avctx, AV_LOG_WARNING, "Mismatching LJIF tag\n");

View File

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

View File

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

View File

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

View File

@@ -78,11 +78,8 @@ typedef struct PNGDecContext {
enum PNGImageState pic_state;
int width, height;
int cur_w, cur_h;
int last_w, last_h;
int x_offset, y_offset;
int last_x_offset, last_y_offset;
uint8_t dispose_op, blend_op;
uint8_t last_dispose_op;
int bit_depth;
int color_type;
int compression_type;
@@ -94,8 +91,6 @@ typedef struct PNGDecContext {
int has_trns;
uint8_t transparent_color_be[6];
uint8_t *background_buf;
unsigned background_buf_allocated;
uint32_t palette[256];
uint8_t *crow_buf;
uint8_t *last_row;
@@ -725,9 +720,30 @@ static int decode_idat_chunk(AVCodecContext *avctx, PNGDecContext *s,
}
ff_thread_release_ext_buffer(avctx, &s->picture);
if ((ret = ff_thread_get_ext_buffer(avctx, &s->picture,
AV_GET_BUFFER_FLAG_REF)) < 0)
return ret;
if (s->dispose_op == APNG_DISPOSE_OP_PREVIOUS) {
/* We only need a buffer for the current picture. */
ret = ff_thread_get_buffer(avctx, p, 0);
if (ret < 0)
return ret;
} else if (s->dispose_op == APNG_DISPOSE_OP_BACKGROUND) {
/* We need a buffer for the current picture as well as
* a buffer for the reference to retain. */
ret = ff_thread_get_ext_buffer(avctx, &s->picture,
AV_GET_BUFFER_FLAG_REF);
if (ret < 0)
return ret;
ret = ff_thread_get_buffer(avctx, p, 0);
if (ret < 0)
return ret;
} else {
/* The picture output this time and the reference to retain coincide. */
if ((ret = ff_thread_get_ext_buffer(avctx, &s->picture,
AV_GET_BUFFER_FLAG_REF)) < 0)
return ret;
ret = av_frame_ref(p, s->picture.f);
if (ret < 0)
return ret;
}
p->pict_type = AV_PICTURE_TYPE_I;
p->key_frame = 1;
@@ -985,12 +1001,6 @@ static int decode_fctl_chunk(AVCodecContext *avctx, PNGDecContext *s,
return AVERROR_INVALIDDATA;
}
s->last_w = s->cur_w;
s->last_h = s->cur_h;
s->last_x_offset = s->x_offset;
s->last_y_offset = s->y_offset;
s->last_dispose_op = s->dispose_op;
sequence_number = bytestream2_get_be32(gb);
cur_w = bytestream2_get_be32(gb);
cur_h = bytestream2_get_be32(gb);
@@ -1086,23 +1096,6 @@ static int handle_p_frame_apng(AVCodecContext *avctx, PNGDecContext *s,
ff_thread_await_progress(&s->last_picture, INT_MAX, 0);
// need to reset a rectangle to background:
if (s->last_dispose_op == APNG_DISPOSE_OP_BACKGROUND) {
av_fast_malloc(&s->background_buf, &s->background_buf_allocated,
src_stride * p->height);
if (!s->background_buf)
return AVERROR(ENOMEM);
memcpy(s->background_buf, src, src_stride * p->height);
for (y = s->last_y_offset; y < s->last_y_offset + s->last_h; y++) {
memset(s->background_buf + src_stride * y +
bpp * s->last_x_offset, 0, bpp * s->last_w);
}
src = s->background_buf;
}
// copy unchanged rectangles from the last frame
for (y = 0; y < s->y_offset; y++)
memcpy(dst + y * dst_stride, src + y * src_stride, p->width * bpp);
@@ -1171,6 +1164,22 @@ static int handle_p_frame_apng(AVCodecContext *avctx, PNGDecContext *s,
return 0;
}
static void apng_reset_background(PNGDecContext *s, const AVFrame *p)
{
// need to reset a rectangle to black
av_unused int ret = av_frame_copy(s->picture.f, p);
const int bpp = s->color_type == PNG_COLOR_TYPE_PALETTE ? 4 : s->bpp;
const ptrdiff_t dst_stride = s->picture.f->linesize[0];
uint8_t *dst = s->picture.f->data[0] + s->y_offset * dst_stride + bpp * s->x_offset;
av_assert1(ret >= 0);
for (size_t y = 0; y < s->cur_h; y++) {
memset(dst, 0, bpp * s->cur_w);
dst += dst_stride;
}
}
static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s,
AVFrame *p, const AVPacket *avpkt)
{
@@ -1434,6 +1443,9 @@ exit_loop:
goto fail;
}
}
if (CONFIG_APNG_DECODER && s->dispose_op == APNG_DISPOSE_OP_BACKGROUND)
apng_reset_background(s, p);
ff_thread_report_progress(&s->picture, INT_MAX, 0);
return 0;
@@ -1456,15 +1468,10 @@ static void clear_frame_metadata(PNGDecContext *s)
av_dict_free(&s->frame_metadata);
}
static int output_frame(PNGDecContext *s, AVFrame *f,
const AVFrame *src)
static int output_frame(PNGDecContext *s, AVFrame *f)
{
int ret;
ret = av_frame_ref(f, src);
if (ret < 0)
return ret;
if (s->iccp_data) {
AVFrameSideData *sd = av_frame_new_side_data(f, AV_FRAME_DATA_ICC_PROFILE, s->iccp_data_len);
if (!sd) {
@@ -1515,13 +1522,12 @@ fail:
}
#if CONFIG_PNG_DECODER
static int decode_frame_png(AVCodecContext *avctx, AVFrame *dst_frame,
static int decode_frame_png(AVCodecContext *avctx, AVFrame *p,
int *got_frame, AVPacket *avpkt)
{
PNGDecContext *const s = avctx->priv_data;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
AVFrame *p = s->picture.f;
int64_t sig;
int ret;
@@ -1555,7 +1561,7 @@ static int decode_frame_png(AVCodecContext *avctx, AVFrame *dst_frame,
goto the_end;
}
ret = output_frame(s, dst_frame, s->picture.f);
ret = output_frame(s, p);
if (ret < 0)
goto the_end;
@@ -1574,12 +1580,11 @@ the_end:
#endif
#if CONFIG_APNG_DECODER
static int decode_frame_apng(AVCodecContext *avctx, AVFrame *dst_frame,
static int decode_frame_apng(AVCodecContext *avctx, AVFrame *p,
int *got_frame, AVPacket *avpkt)
{
PNGDecContext *const s = avctx->priv_data;
int ret;
AVFrame *p = s->picture.f;
clear_frame_metadata(s);
@@ -1608,7 +1613,7 @@ static int decode_frame_apng(AVCodecContext *avctx, AVFrame *dst_frame,
if (!(s->pic_state & (PNG_ALLIMAGE|PNG_IDAT)))
return AVERROR_INVALIDDATA;
ret = output_frame(s, dst_frame, s->picture.f);
ret = output_frame(s, p);
if (ret < 0)
return ret;
@@ -1646,15 +1651,9 @@ static int update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
pdst->compression_type = psrc->compression_type;
pdst->interlace_type = psrc->interlace_type;
pdst->filter_type = psrc->filter_type;
pdst->cur_w = psrc->cur_w;
pdst->cur_h = psrc->cur_h;
pdst->x_offset = psrc->x_offset;
pdst->y_offset = psrc->y_offset;
pdst->has_trns = psrc->has_trns;
memcpy(pdst->transparent_color_be, psrc->transparent_color_be, sizeof(pdst->transparent_color_be));
pdst->dispose_op = psrc->dispose_op;
memcpy(pdst->palette, psrc->palette, sizeof(pdst->palette));
pdst->hdr_state |= psrc->hdr_state;
@@ -1705,7 +1704,6 @@ static av_cold int png_dec_end(AVCodecContext *avctx)
s->last_row_size = 0;
av_freep(&s->tmp_row);
s->tmp_row_size = 0;
av_freep(&s->background_buf);
av_freep(&s->iccp_data);
av_dict_free(&s->frame_metadata);

View File

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

View File

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

View File

@@ -965,6 +965,9 @@ static int dng_decode_tiles(AVCodecContext *avctx, AVFrame *frame,
int pos_x = 0, pos_y = 0;
int ret;
if (s->tile_width <= 0 || s->tile_length <= 0)
return AVERROR_INVALIDDATA;
has_width_leftover = (s->width % s->tile_width != 0);
has_height_leftover = (s->height % s->tile_length != 0);
@@ -1747,7 +1750,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *p,
int *got_frame, AVPacket *avpkt)
{
TiffContext *const s = avctx->priv_data;
unsigned off, last_off;
unsigned off, last_off = 0;
int le, ret, plane, planes;
int i, j, entries, stride;
unsigned soff, ssize;
@@ -1812,7 +1815,6 @@ again:
/** whether we should process this multi-page IFD's next page */
retry_for_page = s->get_page && s->cur_page + 1 < s->get_page; // get_page is 1-indexed
last_off = off;
if (retry_for_page) {
// set offset to the next IFD
off = ff_tget_long(&s->gb, le);
@@ -1830,6 +1832,7 @@ again:
avpriv_request_sample(s->avctx, "non increasing IFD offset");
return AVERROR_INVALIDDATA;
}
last_off = off;
if (off >= UINT_MAX - 14 || avpkt->size < off + 14) {
av_log(avctx, AV_LOG_ERROR, "IFD offset is greater than image size\n");
return AVERROR_INVALIDDATA;

View File

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

View File

@@ -690,8 +690,7 @@ static void videotoolbox_decoder_callback(void *opaque,
CMTime pts,
CMTime duration)
{
AVCodecContext *avctx = opaque;
VTContext *vtctx = avctx->internal->hwaccel_priv_data;
VTContext *vtctx = opaque;
if (vtctx->frame) {
CVPixelBufferRelease(vtctx->frame);
@@ -699,7 +698,8 @@ static void videotoolbox_decoder_callback(void *opaque,
}
if (!image_buffer) {
av_log(avctx, status ? AV_LOG_WARNING : AV_LOG_DEBUG, "vt decoder cb: output image buffer is null: %i\n", status);
av_log(vtctx->logctx, status ? AV_LOG_WARNING : AV_LOG_DEBUG,
"vt decoder cb: output image buffer is null: %i\n", status);
return;
}
@@ -949,7 +949,7 @@ static int videotoolbox_start(AVCodecContext *avctx)
videotoolbox->cv_pix_fmt_type);
decoder_cb.decompressionOutputCallback = videotoolbox_decoder_callback;
decoder_cb.decompressionOutputRefCon = avctx;
decoder_cb.decompressionOutputRefCon = avctx->internal->hwaccel_priv_data;
status = VTDecompressionSessionCreate(NULL, // allocator
videotoolbox->cm_fmt_desc, // videoFormatDescription
@@ -1179,6 +1179,8 @@ int ff_videotoolbox_common_init(AVCodecContext *avctx)
AVHWFramesContext *hw_frames;
int err;
vtctx->logctx = avctx;
// Old API - do nothing.
if (avctx->hwaccel_context)
return 0;

View File

@@ -45,6 +45,8 @@ typedef struct VTContext {
// Current H264 parameters (used to trigger decoder restart on SPS changes).
uint8_t sps[3];
bool reconfig_needed;
void *logctx;
} VTContext;
int ff_videotoolbox_alloc_frame(AVCodecContext *avctx, AVFrame *frame);

View File

@@ -75,9 +75,11 @@ int avdevice_list_devices(AVFormatContext *s, AVDeviceInfoList **device_list)
ret = s->oformat->get_device_list(s, *device_list);
else
ret = s->iformat->get_device_list(s, *device_list);
if (ret < 0)
if (ret < 0) {
avdevice_free_list_devices(device_list);
return ret;
return ret;
}
return (*device_list)->nb_devices;
}
static int list_devices_for_context(AVFormatContext *s, AVDictionary *options,

View File

@@ -491,19 +491,19 @@ static int config_props(AVFilterLink *outlink)
if ((ret = scale_eval_dimensions(ctx)) < 0)
goto fail;
ff_scale_adjust_dimensions(inlink, &scale->w, &scale->h,
outlink->w = scale->w;
outlink->h = scale->h;
ff_scale_adjust_dimensions(inlink, &outlink->w, &outlink->h,
scale->force_original_aspect_ratio,
scale->force_divisible_by);
if (scale->w > INT_MAX ||
scale->h > INT_MAX ||
(scale->h * inlink->w) > INT_MAX ||
(scale->w * inlink->h) > INT_MAX)
if (outlink->w > INT_MAX ||
outlink->h > INT_MAX ||
(outlink->h * inlink->w) > INT_MAX ||
(outlink->w * inlink->h) > INT_MAX)
av_log(ctx, AV_LOG_ERROR, "Rescaled value for width or height is too big.\n");
outlink->w = scale->w;
outlink->h = scale->h;
/* TODO: make algorithm configurable */
scale->input_is_pal = desc->flags & AV_PIX_FMT_FLAG_PAL;
@@ -718,9 +718,9 @@ static int scale_frame(AVFilterLink *link, AVFrame *in, AVFrame **frame_out)
goto scale;
if (scale->eval_mode == EVAL_MODE_INIT) {
snprintf(buf, sizeof(buf)-1, "%d", outlink->w);
snprintf(buf, sizeof(buf) - 1, "%d", scale->w);
av_opt_set(scale, "w", buf, 0);
snprintf(buf, sizeof(buf)-1, "%d", outlink->h);
snprintf(buf, sizeof(buf) - 1, "%d", scale->h);
av_opt_set(scale, "h", buf, 0);
ret = scale_parse_expr(ctx, NULL, &scale->w_pexpr, "width", scale->w_expr);

View File

@@ -730,12 +730,15 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
av_log(ctx, AV_LOG_INFO, " %08"PRIX32, plane_checksum[plane]);
av_log(ctx, AV_LOG_INFO, "] mean:[");
for (plane = 0; plane < 4 && frame->data[plane] && frame->linesize[plane]; plane++)
av_log(ctx, AV_LOG_INFO, "%"PRId64" ", (sum[plane] + pixelcount[plane]/2) / pixelcount[plane]);
av_log(ctx, AV_LOG_INFO, "\b] stdev:[");
av_log(ctx, AV_LOG_INFO, "%s%"PRId64,
plane ? " ":"",
(sum[plane] + pixelcount[plane]/2) / pixelcount[plane]);
av_log(ctx, AV_LOG_INFO, "] stdev:[");
for (plane = 0; plane < 4 && frame->data[plane] && frame->linesize[plane]; plane++)
av_log(ctx, AV_LOG_INFO, "%3.1f ",
av_log(ctx, AV_LOG_INFO, "%s%3.1f",
plane ? " ":"",
sqrt((sum2[plane] - sum[plane]*(double)sum[plane]/pixelcount[plane])/pixelcount[plane]));
av_log(ctx, AV_LOG_INFO, "\b]");
av_log(ctx, AV_LOG_INFO, "]");
}
av_log(ctx, AV_LOG_INFO, "\n");

View File

@@ -372,6 +372,8 @@ got_sound:
av_log(s, AV_LOG_ERROR, "could not find COMM tag or invalid block_align value\n");
return AVERROR_INVALIDDATA;
}
if (aiff->block_duration < 0)
return AVERROR_INVALIDDATA;
/* Now positioned, get the sound data start and end */
avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
@@ -426,7 +428,7 @@ static int aiff_read_packet(AVFormatContext *s,
pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
/* Only one stream in an AIFF file */
pkt->stream_index = 0;
pkt->duration = (res / st->codecpar->block_align) * aiff->block_duration;
pkt->duration = (res / st->codecpar->block_align) * (int64_t) aiff->block_duration;
return 0;
}

View File

@@ -298,6 +298,8 @@ static int ape_read_header(AVFormatContext * s)
ape->frames[i].pos -= ape->frames[i].skip;
ape->frames[i].size += ape->frames[i].skip;
}
if (ape->frames[i].size > INT_MAX - 3)
return AVERROR_INVALIDDATA;
ape->frames[i].size = (ape->frames[i].size + 3) & ~3;
}
if (ape->fileversion < 3810) {

View File

@@ -148,7 +148,7 @@ static int apm_read_header(AVFormatContext *s)
par->codec_id = AV_CODEC_ID_ADPCM_IMA_APM;
par->format = AV_SAMPLE_FMT_S16;
par->bit_rate = par->ch_layout.nb_channels *
par->sample_rate *
(int64_t)par->sample_rate *
par->bits_per_coded_sample;
if ((ret = avio_read(s->pb, buf, APM_FILE_EXTRADATA_SIZE)) < 0)

View File

@@ -104,7 +104,7 @@ typedef struct ASFContext {
int ts_is_pts;
int packet_multi_size;
int packet_time_delta;
int packet_time_start;
int64_t packet_time_start;
int64_t packet_pos;
int stream_index;

View File

@@ -109,6 +109,7 @@ typedef struct ASFContext {
int64_t data_offset;
int64_t first_packet_offset; // packet offset
int64_t unknown_offset; // for top level header objects or subobjects without specified behavior
int in_asf_read_unknown;
// ASF file must not contain more than 128 streams according to the specification
ASFStream *asf_st[ASF_MAX_STREAMS];
@@ -173,7 +174,7 @@ static int asf_read_unknown(AVFormatContext *s, const GUIDParseTable *g)
uint64_t size = avio_rl64(pb);
int ret;
if (size > INT64_MAX)
if (size > INT64_MAX || asf->in_asf_read_unknown > 5)
return AVERROR_INVALIDDATA;
if (asf->is_header)
@@ -182,8 +183,11 @@ static int asf_read_unknown(AVFormatContext *s, const GUIDParseTable *g)
if (!g->is_subobject) {
if (!(ret = strcmp(g->name, "Header Extension")))
avio_skip(pb, 22); // skip reserved fields and Data Size
if ((ret = detect_unknown_subobject(s, asf->unknown_offset,
asf->unknown_size)) < 0)
asf->in_asf_read_unknown ++;
ret = detect_unknown_subobject(s, asf->unknown_offset,
asf->unknown_size);
asf->in_asf_read_unknown --;
if (ret < 0)
return ret;
} else {
if (size < 24) {
@@ -1238,6 +1242,8 @@ static int asf_read_packet_header(AVFormatContext *s)
unsigned char error_flags, len_flags, pay_flags;
asf->packet_offset = avio_tell(pb);
if (asf->packet_offset > INT64_MAX/2)
asf->packet_offset = 0;
error_flags = avio_r8(pb); // read Error Correction Flags
if (error_flags & ASF_PACKET_FLAG_ERROR_CORRECTION_PRESENT) {
if (!(error_flags & ASF_ERROR_CORRECTION_LENGTH_TYPE)) {

View File

@@ -82,6 +82,8 @@ typedef struct AVIContext {
int stream_index;
DVDemuxContext *dv_demux;
int odml_depth;
int64_t odml_read;
int64_t odml_max_pos;
int use_odml;
#define MAX_ODML_DEPTH 1000
int64_t dts_max;
@@ -200,7 +202,7 @@ static int read_odml_index(AVFormatContext *s, int64_t frame_num)
st = s->streams[stream_id];
ast = st->priv_data;
if (index_sub_type)
if (index_sub_type || entries_in_use < 0)
return AVERROR_INVALIDDATA;
avio_rl32(pb);
@@ -221,11 +223,18 @@ static int read_odml_index(AVFormatContext *s, int64_t frame_num)
}
for (i = 0; i < entries_in_use; i++) {
avi->odml_max_pos = FFMAX(avi->odml_max_pos, avio_tell(pb));
// If we read more than there are bytes then we must have been reading something twice
if (avi->odml_read > avi->odml_max_pos)
return AVERROR_INVALIDDATA;
if (index_type) {
int64_t pos = avio_rl32(pb) + base - 8;
int len = avio_rl32(pb);
int key = len >= 0;
len &= 0x7FFFFFFF;
avi->odml_read += 8;
av_log(s, AV_LOG_TRACE, "pos:%"PRId64", len:%X\n", pos, len);
@@ -244,6 +253,7 @@ static int read_odml_index(AVFormatContext *s, int64_t frame_num)
int64_t offset, pos;
int duration;
int ret;
avi->odml_read += 16;
offset = avio_rl64(pb);
avio_rl32(pb); /* size */

View File

@@ -752,7 +752,7 @@ static int avisynth_create_stream_audio(AVFormatContext *s, AVStream *st)
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->sample_rate = avs->vi->audio_samples_per_second;
st->codecpar->channels = avs->vi->nchannels;
st->codecpar->ch_layout.nb_channels = avs->vi->nchannels;
st->duration = avs->vi->num_audio_samples;
avpriv_set_pts_info(st, 64, 1, avs->vi->audio_samples_per_second);

View File

@@ -387,7 +387,7 @@ static int read_header(AVFormatContext *s)
found_data:
if (caf->bytes_per_packet > 0 && caf->frames_per_packet > 0) {
if (caf->data_size > 0)
if (caf->data_size > 0 && caf->data_size / caf->bytes_per_packet < INT64_MAX / caf->frames_per_packet)
st->nb_frames = (caf->data_size / caf->bytes_per_packet) * caf->frames_per_packet;
} else if (ffstream(st)->nb_index_entries && st->duration > 0) {
if (st->codecpar->sample_rate && caf->data_size / st->duration > INT64_MAX / st->codecpar->sample_rate / 8) {

View File

@@ -53,7 +53,11 @@ static uint32_t codec_flags(enum AVCodecID codec_id) {
}
}
static uint32_t samples_per_packet(enum AVCodecID codec_id, int channels, int block_align) {
static uint32_t samples_per_packet(const AVCodecParameters *par) {
enum AVCodecID codec_id = par->codec_id;
int channels = par->ch_layout.nb_channels, block_align = par->block_align;
int frame_size = par->frame_size, sample_rate = par->sample_rate;
switch (codec_id) {
case AV_CODEC_ID_PCM_S8:
case AV_CODEC_ID_PCM_S16LE:
@@ -83,6 +87,8 @@ static uint32_t samples_per_packet(enum AVCodecID codec_id, int channels, int bl
return 320;
case AV_CODEC_ID_MP1:
return 384;
case AV_CODEC_ID_OPUS:
return frame_size * 48000 / sample_rate;
case AV_CODEC_ID_MP2:
case AV_CODEC_ID_MP3:
return 1152;
@@ -110,7 +116,7 @@ static int caf_write_header(AVFormatContext *s)
AVDictionaryEntry *t = NULL;
unsigned int codec_tag = ff_codec_get_tag(ff_codec_caf_tags, par->codec_id);
int64_t chunk_size = 0;
int frame_size = par->frame_size;
int frame_size = par->frame_size, sample_rate = par->sample_rate;
if (s->nb_streams != 1) {
av_log(s, AV_LOG_ERROR, "CAF files have exactly one stream\n");
@@ -139,7 +145,10 @@ static int caf_write_header(AVFormatContext *s)
}
if (par->codec_id != AV_CODEC_ID_MP3 || frame_size != 576)
frame_size = samples_per_packet(par->codec_id, par->ch_layout.nb_channels, par->block_align);
frame_size = samples_per_packet(par);
if (par->codec_id == AV_CODEC_ID_OPUS)
sample_rate = 48000;
ffio_wfourcc(pb, "caff"); //< mFileType
avio_wb16(pb, 1); //< mFileVersion
@@ -147,7 +156,7 @@ static int caf_write_header(AVFormatContext *s)
ffio_wfourcc(pb, "desc"); //< Audio Description chunk
avio_wb64(pb, 32); //< mChunkSize
avio_wb64(pb, av_double2int(par->sample_rate)); //< mSampleRate
avio_wb64(pb, av_double2int(sample_rate)); //< mSampleRate
avio_wl32(pb, codec_tag); //< mFormatID
avio_wb32(pb, codec_flags(par->codec_id)); //< mFormatFlags
avio_wb32(pb, par->block_align); //< mBytesPerPacket
@@ -248,7 +257,7 @@ static int caf_write_trailer(AVFormatContext *s)
avio_seek(pb, caf->data, SEEK_SET);
avio_wb64(pb, file_size - caf->data - 8);
if (!par->block_align) {
int packet_size = samples_per_packet(par->codec_id, par->ch_layout.nb_channels, par->block_align);
int packet_size = samples_per_packet(par);
if (!packet_size) {
packet_size = st->duration / (caf->packets - 1);
avio_seek(pb, FRAME_SIZE_OFFSET, SEEK_SET);

View File

@@ -956,7 +956,11 @@ static int parse_manifest_representation(AVFormatContext *s, const char *url,
xmlFree(val);
}
if (adaptionset_supplementalproperty_node) {
if (!av_strcasecmp(xmlGetProp(adaptionset_supplementalproperty_node,"schemeIdUri"), "http://dashif.org/guidelines/last-segment-number")) {
char *scheme_id_uri = xmlGetProp(adaptionset_supplementalproperty_node, "schemeIdUri");
if (scheme_id_uri) {
int is_last_segment_number = !av_strcasecmp(scheme_id_uri, "http://dashif.org/guidelines/last-segment-number");
xmlFree(scheme_id_uri);
if (is_last_segment_number) {
val = xmlGetProp(adaptionset_supplementalproperty_node,"value");
if (!val) {
av_log(s, AV_LOG_ERROR, "Missing value attribute in adaptionset_supplementalproperty_node\n");
@@ -965,6 +969,7 @@ static int parse_manifest_representation(AVFormatContext *s, const char *url,
xmlFree(val);
}
}
}
}
fragment_timeline_node = find_child_node_by_name(representation_segmenttemplate_node, "SegmentTimeline");

View File

@@ -242,7 +242,7 @@ static int64_t get_duration(AVFormatContext *s)
avio_seek(s->pb, avio_size(s->pb) - 8, SEEK_SET);
while (avio_tell(s->pb) > 12 && max_interations--) {
if (avio_rl32(s->pb) == MKTAG('d','h','a','v')) {
int seek_back = avio_rl32(s->pb);
int64_t seek_back = avio_rl32(s->pb);
avio_seek(s->pb, -seek_back, SEEK_CUR);
read_chunk(s);

View File

@@ -118,9 +118,12 @@ static int dxa_read_header(AVFormatContext *s)
if(tag == MKTAG('d', 'a', 't', 'a')) break;
avio_skip(pb, fsize);
}
c->bpc = (fsize + c->frames - 1) / c->frames;
if(ast->codecpar->block_align)
c->bpc = (fsize + (int64_t)c->frames - 1) / c->frames;
if(ast->codecpar->block_align) {
if (c->bpc > INT_MAX - ast->codecpar->block_align + 1)
return AVERROR_INVALIDDATA;
c->bpc = ((c->bpc + ast->codecpar->block_align - 1) / ast->codecpar->block_align) * ast->codecpar->block_align;
}
c->bytes_left = fsize;
c->wavpos = avio_tell(pb);
avio_seek(pb, c->vidpos, SEEK_SET);

View File

@@ -65,7 +65,7 @@ typedef struct FLVContext {
uint8_t resync_buffer[2*RESYNC_BUFFER_SIZE];
int broken_sizes;
int sum_flv_tag_size;
int64_t sum_flv_tag_size;
int last_keyframe_stream_index;
int keyframe_count;
@@ -463,6 +463,8 @@ static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc, int64_t m
goto invalid;
if (current_array == &times && (d <= INT64_MIN / 1000 || d >= INT64_MAX / 1000))
goto invalid;
if (avio_feof(ioc))
goto invalid;
current_array[0][i] = d;
}
if (times && filepositions) {
@@ -1028,7 +1030,7 @@ retry:
type = (avio_r8(s->pb) & 0x1F);
orig_size =
size = avio_rb24(s->pb);
flv->sum_flv_tag_size += size + 11;
flv->sum_flv_tag_size += size + 11LL;
dts = avio_rb24(s->pb);
dts |= (unsigned)avio_r8(s->pb) << 24;
av_log(s, AV_LOG_TRACE, "type:%d, size:%d, last:%d, dts:%"PRId64" pos:%"PRId64"\n", type, size, last, dts, avio_tell(s->pb));
@@ -1328,7 +1330,7 @@ leave:
!avio_feof(s->pb) &&
(last != orig_size || !last) && last != flv->sum_flv_tag_size &&
!flv->broken_sizes) {
av_log(s, AV_LOG_ERROR, "Packet mismatch %d %d %d\n", last, orig_size + 11, flv->sum_flv_tag_size);
av_log(s, AV_LOG_ERROR, "Packet mismatch %d %d %"PRId64"\n", last, orig_size + 11, flv->sum_flv_tag_size);
avio_seek(s->pb, pos + 1, SEEK_SET);
ret = resync(s);
av_packet_unref(pkt);

View File

@@ -78,6 +78,8 @@ static int genh_read_header(AVFormatContext *s)
case 0: st->codecpar->codec_id = AV_CODEC_ID_ADPCM_PSX; break;
case 1:
case 11: st->codecpar->bits_per_coded_sample = 4;
if (st->codecpar->ch_layout.nb_channels > INT_MAX / 36)
return AVERROR_INVALIDDATA;
st->codecpar->block_align = 36 * st->codecpar->ch_layout.nb_channels;
st->codecpar->codec_id = AV_CODEC_ID_ADPCM_IMA_WAV; break;
case 2: st->codecpar->codec_id = AV_CODEC_ID_ADPCM_DTK; break;

View File

@@ -250,6 +250,7 @@ static void free_init_section_list(struct playlist *pls)
{
int i;
for (i = 0; i < pls->n_init_sections; i++) {
av_freep(&pls->init_sections[i]->key);
av_freep(&pls->init_sections[i]->url);
av_freep(&pls->init_sections[i]);
}

View File

@@ -196,6 +196,9 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
AV_WL32(buf + 32, image->nb_pal);
}
if (image->nb_pal > INT_MAX / 4 - 14 - 40)
return AVERROR_INVALIDDATA;
AV_WL32(buf - 4, 14 + 40 + image->nb_pal * 4);
AV_WL32(buf + 8, AV_RL32(buf + 8) / 2);
}

View File

@@ -501,6 +501,9 @@ static int iff_read_header(AVFormatContext *s)
case ID_DST:
case ID_MDAT:
iff->body_pos = avio_tell(pb);
if (iff->body_pos < 0 || iff->body_pos + data_size > INT64_MAX)
return AVERROR_INVALIDDATA;
iff->body_end = iff->body_pos + data_size;
iff->body_size = data_size;
if (chunk_id == ID_DST) {

View File

@@ -240,13 +240,8 @@ static int translate_ipfs_to_http(URLContext *h, const char *uri, int flags, AVD
ret = populate_ipfs_gateway(h);
if (ret < 1) {
// We fallback on dweb.link (managed by Protocol Labs).
snprintf(c->gateway_buffer, sizeof(c->gateway_buffer), "https://dweb.link");
av_log(h, AV_LOG_WARNING,
"IPFS does not appear to be running. "
"Youre now using the public gateway at dweb.link.\n");
av_log(h, AV_LOG_INFO,
av_log(h, AV_LOG_ERROR,
"IPFS does not appear to be running.\n\n"
"Installing IPFS locally is recommended to "
"improve performance and reliability, "
"and not share all your activity with a single IPFS gateway.\n"
@@ -259,6 +254,8 @@ static int translate_ipfs_to_http(URLContext *h, const char *uri, int flags, AVD
"3. Define an $IPFS_PATH environment variable "
"and point it to the IPFS data path "
"- this is typically ~/.ipfs\n");
ret = AVERROR(EINVAL);
goto err;
}
}

View File

@@ -144,7 +144,7 @@ static int get_shift(int timeres, const char *buf)
ret = 0;
switch (n) {
case 4:
ret = sign * (((int64_t)a*3600 + b*60 + c) * timeres + d);
ret = sign * (((int64_t)a*3600 + (int64_t)b*60 + c) * timeres + d);
break;
case 3:
ret = sign * (( (int64_t)a*60 + b) * timeres + c);

View File

@@ -3949,8 +3949,11 @@ static int build_open_gop_key_points(AVStream *st)
/* Build an unrolled index of the samples */
sc->sample_offsets_count = 0;
for (uint32_t i = 0; i < sc->ctts_count; i++)
for (uint32_t i = 0; i < sc->ctts_count; i++) {
if (sc->ctts_data[i].count > INT_MAX - sc->sample_offsets_count)
return AVERROR(ENOMEM);
sc->sample_offsets_count += sc->ctts_data[i].count;
}
av_freep(&sc->sample_offsets);
sc->sample_offsets = av_calloc(sc->sample_offsets_count, sizeof(*sc->sample_offsets));
if (!sc->sample_offsets)
@@ -3969,8 +3972,11 @@ static int build_open_gop_key_points(AVStream *st)
/* Build a list of open-GOP key samples */
sc->open_key_samples_count = 0;
for (uint32_t i = 0; i < sc->sync_group_count; i++)
if (sc->sync_group[i].index == cra_index)
if (sc->sync_group[i].index == cra_index) {
if (sc->sync_group[i].count > INT_MAX - sc->open_key_samples_count)
return AVERROR(ENOMEM);
sc->open_key_samples_count += sc->sync_group[i].count;
}
av_freep(&sc->open_key_samples);
sc->open_key_samples = av_calloc(sc->open_key_samples_count, sizeof(*sc->open_key_samples));
if (!sc->open_key_samples)
@@ -3981,6 +3987,8 @@ static int build_open_gop_key_points(AVStream *st)
if (sg->index == cra_index)
for (uint32_t j = 0; j < sg->count; j++)
sc->open_key_samples[k++] = sample_id;
if (sg->count > INT_MAX - sample_id)
return AVERROR_PATCHWELCOME;
sample_id += sg->count;
}
@@ -7540,6 +7548,8 @@ static int mov_read_iloc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
for (int i = 0; i < item_count; i++) {
int item_id = (version < 2) ? avio_rb16(pb) : avio_rb32(pb);
if (avio_feof(pb))
return AVERROR_INVALIDDATA;
if (version > 0)
avio_rb16(pb); // construction_method.
avio_rb16(pb); // data_reference_index.

View File

@@ -64,6 +64,7 @@
#include "mxf.h"
#define MXF_MAX_CHUNK_SIZE (32 << 20)
#define RUN_IN_MAX (65535+1) // S377m-2004 section 5.5 and S377-1-2009 section 6.5, the +1 is to be slightly more tolerant
typedef enum {
Header,
@@ -3632,6 +3633,7 @@ static int mxf_read_header(AVFormatContext *s)
KLVPacket klv;
int64_t essence_offset = 0;
int ret;
int64_t run_in;
mxf->last_forward_tell = INT64_MAX;
@@ -3641,7 +3643,10 @@ static int mxf_read_header(AVFormatContext *s)
}
avio_seek(s->pb, -14, SEEK_CUR);
mxf->fc = s;
mxf->run_in = avio_tell(s->pb);
run_in = avio_tell(s->pb);
if (run_in < 0 || run_in > RUN_IN_MAX)
return AVERROR_INVALIDDATA;
mxf->run_in = run_in;
mxf_read_random_index_pack(s);
@@ -4047,7 +4052,7 @@ static int mxf_read_close(AVFormatContext *s)
static int mxf_probe(const AVProbeData *p) {
const uint8_t *bufp = p->buf;
const uint8_t *end = p->buf + p->buf_size;
const uint8_t *end = p->buf + FFMIN(p->buf_size, RUN_IN_MAX + 1 + sizeof(mxf_header_partition_pack_key));
if (p->buf_size < sizeof(mxf_header_partition_pack_key))
return 0;

View File

@@ -200,6 +200,8 @@ static int decode_main_header(NUTContext *nut)
int tmp_stream, tmp_mul, tmp_pts, tmp_size, tmp_res, tmp_head_idx;
length = get_packetheader(nut, bc, 1, MAIN_STARTCODE);
if (length == (uint64_t)-1)
return AVERROR_INVALIDDATA;
end = length + avio_tell(bc);
nut->version = ffio_read_varlen(bc);
@@ -243,6 +245,11 @@ static int decode_main_header(NUTContext *nut)
for (i = 0; i < 256;) {
int tmp_flags = ffio_read_varlen(bc);
int tmp_fields = ffio_read_varlen(bc);
if (tmp_fields < 0) {
av_log(s, AV_LOG_ERROR, "fields %d is invalid\n", tmp_fields);
ret = AVERROR_INVALIDDATA;
goto fail;
}
if (tmp_fields > 0)
tmp_pts = get_s(bc);

View File

@@ -102,6 +102,8 @@ int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb,
return AVERROR_INVALIDDATA;
}
av_channel_layout_uninit(&par->ch_layout);
par->codec_type = AVMEDIA_TYPE_AUDIO;
if (!big_endian) {
id = avio_rl16(pb);
@@ -189,9 +191,12 @@ int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb,
if (par->codec_id == AV_CODEC_ID_ADPCM_G726 && par->sample_rate)
par->bits_per_coded_sample = par->bit_rate / par->sample_rate;
av_channel_layout_uninit(&par->ch_layout);
par->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC;
par->ch_layout.nb_channels = channels;
/* ignore WAVEFORMATEXTENSIBLE layout if different from channel count */
if (channels != par->ch_layout.nb_channels) {
av_channel_layout_uninit(&par->ch_layout);
par->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC;
par->ch_layout.nb_channels = channels;
}
return 0;
}

View File

@@ -563,6 +563,8 @@ static int rm_read_header(AVFormatContext *s)
}
tag_size = avio_rb32(pb);
if (tag_size < 0)
return AVERROR_INVALIDDATA;
avio_skip(pb, tag_size - 8);
for(;;) {

View File

@@ -279,7 +279,7 @@ static int rpl_read_header(AVFormatContext *s)
error |= read_line(pb, line, sizeof(line)); // size of "helpful" sprite
if (vst) {
error |= read_line(pb, line, sizeof(line)); // offset to key frame list
vst->duration = number_of_chunks * rpl->frames_per_chunk;
vst->duration = number_of_chunks * (int64_t)rpl->frames_per_chunk;
}
// Read the index

View File

@@ -1317,6 +1317,8 @@ static int generate_intervals(void *log, struct sbg_script *s, int sample_rate,
/* Pseudo event before the first one */
ev0 = s->events[s->nb_events - 1];
if (av_sat_sub64(ev0.ts_int, period) != (uint64_t)ev0.ts_int - period)
return AVERROR_INVALIDDATA;
ev0.ts_int -= period;
ev0.ts_trans -= period;
ev0.ts_next -= period;
@@ -1478,7 +1480,7 @@ static int sbg_read_packet(AVFormatContext *avf, AVPacket *packet)
int ret;
ts = ffstream(avf->streams[0])->cur_dts;
end_ts = ts + avf->streams[0]->codecpar->frame_size;
end_ts = av_sat_add64(ts, avf->streams[0]->codecpar->frame_size);
if (avf->streams[0]->duration != AV_NOPTS_VALUE)
end_ts = FFMIN(avf->streams[0]->start_time + avf->streams[0]->duration,
end_ts);

View File

@@ -112,7 +112,7 @@ static int sds_read_header(AVFormatContext *ctx)
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->ch_layout.nb_channels = 1;
st->codecpar->sample_rate = sample_period ? 1000000000 / sample_period : 16000;
st->duration = (avio_size(pb) - 21) / (127) * s->size / 4;
st->duration = av_rescale((avio_size(pb) - 21) / 127, s->size, 4);
avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);

View File

@@ -226,7 +226,7 @@ int ff_spdif_read_packet(AVFormatContext *s, AVPacket *pkt)
if (!s->bit_rate && s->streams[0]->codecpar->sample_rate)
/* stream bitrate matches 16-bit stereo PCM bitrate for currently
supported codecs */
s->bit_rate = 2 * 16 * s->streams[0]->codecpar->sample_rate;
s->bit_rate = 2 * 16LL * s->streams[0]->codecpar->sample_rate;
return 0;
}

View File

@@ -50,26 +50,32 @@ static int subviewer_probe(const AVProbeData *p)
return 0;
}
static int get_multiplier(int e) {
switch (e) {
case 1 : return 100;
case 2 : return 10;
case 3 : return 1;
default : return -1;
}
}
static int read_ts(const char *s, int64_t *start, int *duration)
{
int64_t end;
int hh1, mm1, ss1, ms1;
int hh2, mm2, ss2, ms2;
int multiplier = 1;
int multiplier1, multiplier2;
int ms1p1, ms1p2, ms2p1, ms2p2;
if (sscanf(s, "%u:%u:%u.%2u,%u:%u:%u.%2u",
&hh1, &mm1, &ss1, &ms1, &hh2, &mm2, &ss2, &ms2) == 8) {
multiplier = 10;
} else if (sscanf(s, "%u:%u:%u.%1u,%u:%u:%u.%1u",
&hh1, &mm1, &ss1, &ms1, &hh2, &mm2, &ss2, &ms2) == 8) {
multiplier = 100;
}
if (sscanf(s, "%u:%u:%u.%u,%u:%u:%u.%u",
&hh1, &mm1, &ss1, &ms1, &hh2, &mm2, &ss2, &ms2) == 8) {
ms1 = FFMIN(ms1, 999);
ms2 = FFMIN(ms2, 999);
end = (hh2*3600LL + mm2*60LL + ss2) * 1000LL + ms2 * multiplier;
*start = (hh1*3600LL + mm1*60LL + ss1) * 1000LL + ms1 * multiplier;
if (sscanf(s, "%u:%u:%u.%n%u%n,%u:%u:%u.%n%u%n",
&hh1, &mm1, &ss1, &ms1p1, &ms1, &ms1p2, &hh2, &mm2, &ss2, &ms2p1, &ms2, &ms2p2) == 8) {
multiplier1 = get_multiplier(ms1p2 - ms1p1);
multiplier2 = get_multiplier(ms2p2 - ms2p1);
if (multiplier1 <= 0 ||multiplier2 <= 0)
return -1;
end = (hh2*3600LL + mm2*60LL + ss2) * 1000LL + ms2 * multiplier2;
*start = (hh1*3600LL + mm1*60LL + ss1) * 1000LL + ms1 * multiplier1;
*duration = end - *start;
return 0;
}

View File

@@ -278,7 +278,7 @@ static int xwma_read_header(AVFormatContext *s)
* the total duration using the average bits per sample and the
* total data length.
*/
st->duration = (size<<3) * st->codecpar->sample_rate / st->codecpar->bit_rate;
st->duration = av_rescale((size<<3), st->codecpar->sample_rate, st->codecpar->bit_rate);
}
fail:

View File

@@ -166,6 +166,17 @@ static AVBufferRef *wrap_texture_buf(AVHWFramesContext *ctx, ID3D11Texture2D *te
return NULL;
}
if (s->nb_surfaces <= s->nb_surfaces_used) {
frames_hwctx->texture_infos = av_realloc_f(frames_hwctx->texture_infos,
s->nb_surfaces_used + 1,
sizeof(*frames_hwctx->texture_infos));
if (!frames_hwctx->texture_infos) {
ID3D11Texture2D_Release(tex);
return NULL;
}
s->nb_surfaces = s->nb_surfaces_used + 1;
}
frames_hwctx->texture_infos[s->nb_surfaces_used].texture = tex;
frames_hwctx->texture_infos[s->nb_surfaces_used].index = index;
s->nb_surfaces_used++;
@@ -284,7 +295,7 @@ static int d3d11va_frames_init(AVHWFramesContext *ctx)
}
}
hwctx->texture_infos = av_calloc(ctx->initial_pool_size, sizeof(*hwctx->texture_infos));
hwctx->texture_infos = av_realloc_f(NULL, ctx->initial_pool_size, sizeof(*hwctx->texture_infos));
if (!hwctx->texture_infos)
return AVERROR(ENOMEM);
s->nb_surfaces = ctx->initial_pool_size;

View File

@@ -9,6 +9,7 @@
/bprint
/camellia
/cast5
/channel_layout
/color_utils
/cpu
/cpu_init

View File

@@ -385,8 +385,8 @@ av_cold int swr_init(struct SwrContext *s){
goto fail;
}
av_channel_layout_describe(&s->out_ch_layout, l2, sizeof(l2));
#if FF_API_OLD_CHANNEL_LAYOUT
av_channel_layout_describe(&s->out_ch_layout, l1, sizeof(l1));
if (s->out_ch_layout.order != AV_CHANNEL_ORDER_UNSPEC && s->out.ch_count != s->out_ch_layout.nb_channels) {
av_log(s, AV_LOG_ERROR, "Output channel layout %s mismatches specified channel count %d\n", l2, s->out.ch_count);
ret = AVERROR(EINVAL);

View File

@@ -362,6 +362,7 @@ lavf_container_fate()
}
lavf_image(){
no_file_checksums="$3"
nb_frames=13
t="${test#lavf-}"
outdir="tests/data/images/$t"
@@ -374,9 +375,11 @@ lavf_image(){
done
fi
run_avconv $DEC_OPTS -f image2 -c:v pgmyuv -i $raw_src $1 "$ENC_OPTS -metadata title=lavftest" -vf scale -frames $nb_frames -y -qscale 10 $target_path/$file
do_md5sum ${outdir}/02.$t
if [ -z "$no_file_checksums" ]; then
do_md5sum ${outdir}/02.$t
echo $(wc -c ${outdir}/02.$t)
fi
do_avconv_crc $file -auto_conversion_filters $DEC_OPTS $2 -i $target_path/$file $2
echo $(wc -c ${outdir}/02.$t)
}
lavf_image2pipe(){

View File

@@ -3,4 +3,4 @@ fate-imf-cpl-with-repeat: CMD = framecrc -f imf -i $(TARGET_SAMPLES)/imf/countdo
FATE_SAMPLES_FFMPEG-$(CONFIG_IMF_DEMUXER) += $(FATE_IMF)
fate-imf: $(FATE_IMF)
fate-imfdec: $(FATE_IMF)

View File

@@ -59,18 +59,18 @@ $(FATE_LAVF_IMAGES): CMD = lavf_image
$(FATE_LAVF_IMAGES): REF = $(SRC_PATH)/tests/ref/lavf/$(@:fate-lavf-%=%)
$(FATE_LAVF_IMAGES): $(VREF)
fate-lavf-none.grayf32le.exr: CMD = lavf_image "-compression none -pix_fmt grayf32le"
fate-lavf-rle.grayf32le.exr: CMD = lavf_image "-compression rle -pix_fmt grayf32le"
fate-lavf-zip1.grayf32le.exr: CMD = lavf_image "-compression zip1 -pix_fmt grayf32le"
fate-lavf-zip16.grayf32le.exr: CMD = lavf_image "-compression zip16 -pix_fmt grayf32le"
fate-lavf-none.gbrpf32le.exr: CMD = lavf_image "-compression none -pix_fmt gbrpf32le"
fate-lavf-rle.gbrpf32le.exr: CMD = lavf_image "-compression rle -pix_fmt gbrpf32le"
fate-lavf-zip1.gbrpf32le.exr: CMD = lavf_image "-compression zip1 -pix_fmt gbrpf32le"
fate-lavf-zip16.gbrpf32le.exr: CMD = lavf_image "-compression zip16 -pix_fmt gbrpf32le"
fate-lavf-none.gbrapf32le.exr: CMD = lavf_image "-compression none -pix_fmt gbrapf32le"
fate-lavf-rle.gbrapf32le.exr: CMD = lavf_image "-compression rle -pix_fmt gbrapf32le"
fate-lavf-zip1.gbrapf32le.exr: CMD = lavf_image "-compression zip1 -pix_fmt gbrapf32le"
fate-lavf-zip16.gbrapf32le.exr: CMD = lavf_image "-compression zip16 -pix_fmt gbrapf32le"
fate-lavf-none.grayf32le.exr: CMD = lavf_image "-compression none -pix_fmt grayf32le" "" "no_file_checksums"
fate-lavf-rle.grayf32le.exr: CMD = lavf_image "-compression rle -pix_fmt grayf32le" "" "no_file_checksums"
fate-lavf-zip1.grayf32le.exr: CMD = lavf_image "-compression zip1 -pix_fmt grayf32le" "" "no_file_checksums"
fate-lavf-zip16.grayf32le.exr: CMD = lavf_image "-compression zip16 -pix_fmt grayf32le" "" "no_file_checksums"
fate-lavf-none.gbrpf32le.exr: CMD = lavf_image "-compression none -pix_fmt gbrpf32le" "" "no_file_checksums"
fate-lavf-rle.gbrpf32le.exr: CMD = lavf_image "-compression rle -pix_fmt gbrpf32le" "" "no_file_checksums"
fate-lavf-zip1.gbrpf32le.exr: CMD = lavf_image "-compression zip1 -pix_fmt gbrpf32le" "" "no_file_checksums"
fate-lavf-zip16.gbrpf32le.exr: CMD = lavf_image "-compression zip16 -pix_fmt gbrpf32le" "" "no_file_checksums"
fate-lavf-none.gbrapf32le.exr: CMD = lavf_image "-compression none -pix_fmt gbrapf32le" "" "no_file_checksums"
fate-lavf-rle.gbrapf32le.exr: CMD = lavf_image "-compression rle -pix_fmt gbrapf32le" "" "no_file_checksums"
fate-lavf-zip1.gbrapf32le.exr: CMD = lavf_image "-compression zip1 -pix_fmt gbrapf32le" "" "no_file_checksums"
fate-lavf-zip16.gbrapf32le.exr: CMD = lavf_image "-compression zip16 -pix_fmt gbrapf32le" "" "no_file_checksums"
fate-lavf-jpg: CMD = lavf_image "-pix_fmt yuvj420p"
fate-lavf-tiff: CMD = lavf_image "-pix_fmt rgb24"
fate-lavf-gbrp10le.dpx: CMD = lavf_image "-pix_fmt gbrp10le" "-pix_fmt gbrp10le"

View File

@@ -1,3 +1,3 @@
71f4d64a6b3c71f43a4eff526f84841c *tests/data/images/bmp/02.bmp
tests/data/images/bmp/%02d.bmp CRC=0xe6c71946
304182 tests/data/images/bmp/02.bmp
tests/data/images/bmp/%02d.bmp CRC=0xe6c71946

View File

@@ -1,3 +1,3 @@
4c8880d5835ffb5fe37c1ed8c8d404de *tests/data/images/dpx/02.dpx
tests/data/images/dpx/%02d.dpx CRC=0x6da01946
305792 tests/data/images/dpx/02.dpx
tests/data/images/dpx/%02d.dpx CRC=0x6da01946

View File

@@ -1,3 +1,3 @@
7ca935d5d5e00c54acbc85565d3039b6 *tests/data/images/gbrp10le.dpx/02.gbrp10le.dpx
tests/data/images/gbrp10le.dpx/%02d.gbrp10le.dpx CRC=0xe6663fba
407168 tests/data/images/gbrp10le.dpx/02.gbrp10le.dpx
tests/data/images/gbrp10le.dpx/%02d.gbrp10le.dpx CRC=0xe6663fba

View File

@@ -1,3 +1,3 @@
a4cfea1797c928f2eff73573e559675d *tests/data/images/gbrp12le.dpx/02.gbrp12le.dpx
tests/data/images/gbrp12le.dpx/%02d.gbrp12le.dpx CRC=0x1c755633
609920 tests/data/images/gbrp12le.dpx/02.gbrp12le.dpx
tests/data/images/gbrp12le.dpx/%02d.gbrp12le.dpx CRC=0x1c755633

View File

@@ -1,3 +1,3 @@
6d470f8d6018b95b45afafc14b7d161a *tests/data/images/gbrpf32be.pfm/02.gbrpf32be.pfm
tests/data/images/gbrpf32be.pfm/%02d.gbrpf32be.pfm CRC=0x4b73053f
1216532 tests/data/images/gbrpf32be.pfm/02.gbrpf32be.pfm
tests/data/images/gbrpf32be.pfm/%02d.gbrpf32be.pfm CRC=0x4b73053f

View File

@@ -1,3 +1,3 @@
892c5a05e1cbb3d2f7761d51e18b9c4c *tests/data/images/gbrpf32le.pfm/02.gbrpf32le.pfm
tests/data/images/gbrpf32le.pfm/%02d.gbrpf32le.pfm CRC=0x95e1053f
1216533 tests/data/images/gbrpf32le.pfm/02.gbrpf32le.pfm
tests/data/images/gbrpf32le.pfm/%02d.gbrpf32le.pfm CRC=0x95e1053f

View File

@@ -1,3 +1,3 @@
35cb9e42b2d3181be494f8693af1ddea *tests/data/images/gray.pam/02.gray.pam
tests/data/images/gray.pam/%02d.gray.pam CRC=0x0ff205be
101445 tests/data/images/gray.pam/02.gray.pam
tests/data/images/gray.pam/%02d.gray.pam CRC=0x0ff205be

View File

@@ -1,3 +1,3 @@
85e9b8b814a1dea71d143aac2e487037 *tests/data/images/gray.xwd/02.gray.xwd
tests/data/images/gray.xwd/%02d.gray.xwd CRC=0x0ff205be
101487 tests/data/images/gray.xwd/02.gray.xwd
tests/data/images/gray.xwd/%02d.gray.xwd CRC=0x0ff205be

View File

@@ -1,3 +1,3 @@
740eb42157af9e9eed46b70ba6a6cf4d *tests/data/images/gray16be.pam/02.gray16be.pam
tests/data/images/gray16be.pam/%02d.gray16be.pam CRC=0x893f10ef
202823 tests/data/images/gray16be.pam/02.gray16be.pam
tests/data/images/gray16be.pam/%02d.gray16be.pam CRC=0x893f10ef

View File

@@ -1,3 +1,3 @@
6cf54c13aa407b77547cf6dfe23ecba3 *tests/data/images/gray16be.png/02.gray16be.png
tests/data/images/gray16be.png/%02d.gray16be.png CRC=0x893f10ef
47365 tests/data/images/gray16be.png/02.gray16be.png
tests/data/images/gray16be.png/%02d.gray16be.png CRC=0x893f10ef

View File

@@ -1,3 +1,3 @@
0f6df0d68d7dd30e67386b1255f443c9 *tests/data/images/grayf32be.pfm/02.grayf32be.pfm
tests/data/images/grayf32be.pfm/%02d.grayf32be.pfm CRC=0xe3fda443
405524 tests/data/images/grayf32be.pfm/02.grayf32be.pfm
tests/data/images/grayf32be.pfm/%02d.grayf32be.pfm CRC=0xe3fda443

View File

@@ -1,3 +1,3 @@
145715872a894b1fde0105d8a0106191 *tests/data/images/grayf32le.pfm/02.grayf32le.pfm
tests/data/images/grayf32le.pfm/%02d.grayf32le.pfm CRC=0x5443a443
405525 tests/data/images/grayf32le.pfm/02.grayf32le.pfm
tests/data/images/grayf32le.pfm/%02d.grayf32le.pfm CRC=0x5443a443

View File

@@ -1,3 +1,3 @@
1e7c6d937f21c045e0b238a83f62f3c5 *tests/data/images/jpg/02.jpg
tests/data/images/jpg/%02d.jpg CRC=0xe3509f33
26037 tests/data/images/jpg/02.jpg
tests/data/images/jpg/%02d.jpg CRC=0xe3509f33

View File

@@ -1,3 +1,3 @@
d2f5eb2f959ca3a90c02f1887b6e0c4f *tests/data/images/monob.pam/02.monob.pam
tests/data/images/monob.pam/%02d.monob.pam CRC=0xab19200d
101447 tests/data/images/monob.pam/02.monob.pam
tests/data/images/monob.pam/%02d.monob.pam CRC=0xab19200d

View File

@@ -1,3 +1,3 @@
796e2e309ac0844cfb2f4959816508ee *tests/data/images/monow.xwd/02.monow.xwd
tests/data/images/monow.xwd/%02d.monow.xwd CRC=0xc9a20204
12783 tests/data/images/monow.xwd/02.monow.xwd
tests/data/images/monow.xwd/%02d.monow.xwd CRC=0xc9a20204

View File

@@ -1,3 +1 @@
c586035e67f9ba7f2a3777933b5b22a0 *tests/data/images/none.gbrapf32le.exr/02.none.gbrapf32le.exr
tests/data/images/none.gbrapf32le.exr/%02d.none.gbrapf32le.exr CRC=0x068aca4e
1627003 tests/data/images/none.gbrapf32le.exr/02.none.gbrapf32le.exr

View File

@@ -1,3 +1 @@
10f42423c6585fe5053c5457fba7b235 *tests/data/images/none.gbrpf32le.exr/02.none.gbrpf32le.exr
tests/data/images/none.gbrpf32le.exr/%02d.none.gbrpf32le.exr CRC=0x95e1053f
1221481 tests/data/images/none.gbrpf32le.exr/02.none.gbrpf32le.exr

View File

@@ -1,3 +1 @@
8aa28b10bf2591b7030b78bc29907293 *tests/data/images/none.grayf32le.exr/02.none.grayf32le.exr
tests/data/images/none.grayf32le.exr/%02d.none.grayf32le.exr CRC=0x5443a443
410437 tests/data/images/none.grayf32le.exr/02.none.grayf32le.exr

View File

@@ -1,3 +1,3 @@
0dce5565222cf0f8b309467f279aecd2 *tests/data/images/pam/02.pam
tests/data/images/pam/%02d.pam CRC=0x6da01946
304191 tests/data/images/pam/02.pam
tests/data/images/pam/%02d.pam CRC=0x6da01946

View File

@@ -1,3 +1,3 @@
c4faf65ecc812ec8412cc26140c13bd5 *tests/data/images/pcx/02.pcx
tests/data/images/pcx/%02d.pcx CRC=0x6da01946
364147 tests/data/images/pcx/02.pcx
tests/data/images/pcx/%02d.pcx CRC=0x6da01946

View File

@@ -1,3 +1,3 @@
cc777c5fc4d116d4c5a996eac8d3133e *tests/data/images/pgm/02.pgm
tests/data/images/pgm/%02d.pgm CRC=0x0ff205be
101391 tests/data/images/pgm/02.pgm
tests/data/images/pgm/%02d.pgm CRC=0x0ff205be

View File

@@ -1,3 +1,3 @@
2af72da4468e61a37c220b25cb28618a *tests/data/images/png/02.png
tests/data/images/png/%02d.png CRC=0x6da01946
248633 tests/data/images/png/02.png
tests/data/images/png/%02d.png CRC=0x6da01946

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