]> git.sesse.net Git - ffmpeg/log
ffmpeg
3 years agoavcodec/utvideoenc: Don't use bitcounts when byte-aligned
Andreas Rheinhardt [Thu, 25 Mar 2021 09:38:12 +0000 (10:38 +0100)]
avcodec/utvideoenc: Don't use bitcounts when byte-aligned

Despite write_huff_codes() receiving an ordinary buffer (not a
PutBitContext), it returned the amount of data written in bits,
not in bytes. This has been changed: There is now no intermediate
bitcount any more.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec: Remove cumbersome way of checking for amount of bytes left
Andreas Rheinhardt [Thu, 25 Mar 2021 09:27:31 +0000 (10:27 +0100)]
avcodec: Remove cumbersome way of checking for amount of bytes left

Several encoders used code like the following to check for the amount of
bytes left in a PutBitContext:
pb->buf_end - pb->buf - (put_bits_count(pb) >> 3)
Besides the fact that using the pointers directly might pose
a maintainence burden in the future this also leads to suboptimal code:
The above code reads all three pointers (buf, buf_ptr and buf_end), but
touching buf is unnecessary and switching to put_bytes_left()
automatically fixes this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/put_bits: Add functions for amount of bytes written/left
Andreas Rheinhardt [Thu, 25 Mar 2021 08:05:49 +0000 (09:05 +0100)]
avcodec/put_bits: Add functions for amount of bytes written/left

Often a caller doesn't want the amount of bits written via a
PutBitContext, but the amount of bytes. This in particular happens
after one has flushed the PutBitContext (e.g. at the end of encoding,
when one wants to know the actual packet size). The current way of doing
this is with put_bits_count(pb)/8 (or (put_bits_count(pb) + 7)/8).

Yet this has some issues: It contains implicit multiplications and
divisions by 8 with a cast in between; it obscurs the intent; and
it restricts the size of the buffer to (currently) INT_MAX/8 (or
to 1/8 of the maximum of whatever put_bits_count() returns), although
said restriction is not really necessary for users that don't need
a bitcount.

Corresponding functions for the amount of bytes left have also been
addded.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/vorbisenc, wmavoice: Use put_bits_left() where appropriate
Andreas Rheinhardt [Thu, 25 Mar 2021 05:07:37 +0000 (06:07 +0100)]
avcodec/vorbisenc, wmavoice: Use put_bits_left() where appropriate

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/dvenc: Remove dead error message
Andreas Rheinhardt [Thu, 25 Mar 2021 04:36:22 +0000 (05:36 +0100)]
avcodec/dvenc: Remove dead error message

The PutBits API checks the available space before every write,
so this check for overread is dead.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mlpenc: Avoid redundant temporary PutBitContext
Andreas Rheinhardt [Thu, 25 Mar 2021 01:55:53 +0000 (02:55 +0100)]
avcodec/mlpenc: Avoid redundant temporary PutBitContext

We are already word-aligned here, so one can just as well flush the main
PutBitContext.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/sonic: Remove outdated outcommented line
Andreas Rheinhardt [Thu, 25 Mar 2021 01:28:45 +0000 (02:28 +0100)]
avcodec/sonic: Remove outdated outcommented line

Compilation would fail if it were outcommented as it refers to a
nonexistent PutBitContext.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/vorbisenc: Remove always-false check
Andreas Rheinhardt [Wed, 24 Mar 2021 23:59:42 +0000 (00:59 +0100)]
avcodec/vorbisenc: Remove always-false check

The PutBitContext is big enough: It has just been initialized to 8192B.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/setts_bsf: Check timebase
Michael Niedermayer [Thu, 4 Mar 2021 12:06:22 +0000 (13:06 +0100)]
avcodec/setts_bsf: Check timebase

Fixes: Division by 0
Fixes: 30952/clusterfuzz-testcase-minimized-ffmpeg_BSF_SETTS_fuzzer-6601016202100736
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavformat/wtvdec: Check size in SBE2_STREAM_DESC_EVENT / stream2_guid
Michael Niedermayer [Wed, 3 Mar 2021 23:30:45 +0000 (00:30 +0100)]
avformat/wtvdec: Check size in SBE2_STREAM_DESC_EVENT / stream2_guid

Fixes: signed integer overflow: 539033600 - -1910497124 cannot be represented in type 'int'
Fixes: 30928/clusterfuzz-testcase-minimized-ffmpeg_dem_WTV_fuzzer-5922630966312960
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavformat/utils: Fix integer overflow with duration_gcd in ff_rfps_calculate()
Michael Niedermayer [Wed, 3 Mar 2021 23:15:53 +0000 (00:15 +0100)]
avformat/utils: Fix integer overflow with duration_gcd in ff_rfps_calculate()

Fixes: signed integer overflow: 136323327 * 281474976710656 cannot be represented in type 'long'
Fixes: 30913/clusterfuzz-testcase-minimized-ffmpeg_dem_IVF_fuzzer-5753392189931520
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavcodec/dvbsubdec: Support computing clut only once
Michael Niedermayer [Thu, 4 Mar 2021 13:22:31 +0000 (14:22 +0100)]
avcodec/dvbsubdec: Support computing clut only once

This avoids crafted files from consuming excessive resources recomputing the clut after each pixel change

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agotools/target_dec_fuzzer: Adjust threshold for H264
Michael Niedermayer [Thu, 4 Mar 2021 17:59:20 +0000 (18:59 +0100)]
tools/target_dec_fuzzer: Adjust threshold for H264

Fixes: Timeout (too long -> 3sec)
Fixes: 28047/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_H264_fuzzer-4662727980875776
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agotools/target_dec_fuzzer: Compute CLUT for DVBSUB only once
Michael Niedermayer [Thu, 4 Mar 2021 13:24:03 +0000 (14:24 +0100)]
tools/target_dec_fuzzer: Compute CLUT for DVBSUB only once

Fixes: Timeout
Fixes: 30845/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DVBSUB_fuzzer-5744263725973504
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavformat/cafdec: Do not build an index if all packets are the same
Michael Niedermayer [Thu, 4 Mar 2021 18:21:35 +0000 (19:21 +0100)]
avformat/cafdec: Do not build an index if all packets are the same

Fixes: Timeout
Fixes: 28214/clusterfuzz-testcase-minimized-ffmpeg_dem_CAF_fuzzer-6495999421579264
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavformat/sierravmd: Make struct smaller by reordering
Andreas Rheinhardt [Wed, 24 Mar 2021 01:17:35 +0000 (02:17 +0100)]
avformat/sierravmd: Make struct smaller by reordering

Also remove keyframe from vmd_frame, it is unused.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/sierravmd: Remove outdated check
Andreas Rheinhardt [Wed, 24 Mar 2021 00:39:50 +0000 (01:39 +0100)]
avformat/sierravmd: Remove outdated check

The check has been added at a time when the code performed the
multiplication itself instead of deferring it to av_malloc_array()
and when our allocation functions used unsigned instead of size_t.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/segafilm: Remove outdated check
Andreas Rheinhardt [Wed, 24 Mar 2021 00:21:41 +0000 (01:21 +0100)]
avformat/segafilm: Remove outdated check

The check has been added at a time when the code performed the
multiplication itself instead of deferring it to av_malloc_array()
and when our allocation functions used unsigned instead of size_t.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/utils: Remove redundant check
Andreas Rheinhardt [Wed, 24 Mar 2021 00:14:24 +0000 (01:14 +0100)]
avformat/utils: Remove redundant check

This check is outdated because the caller doesn't need to check that
the multiplication overflows when using av_realloc_array() (the code
in question used av_realloc() before that); furthermore, the check
is also a remnant of the time in which our allocation functions
didn't use size_t parameters.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/vf_paletteuse: Fix left shift outside of range of int
Andreas Rheinhardt [Wed, 22 Jan 2020 00:47:21 +0000 (01:47 +0100)]
avfilter/vf_paletteuse: Fix left shift outside of range of int

by keeping the variable uint32_t which in this situation is the natural
type anyway. This affected the FATE-test filter-paletteuse-sierra2_4a.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/asrc_sine: Fix invalid left shift of negative number
Andreas Rheinhardt [Wed, 22 Jan 2020 01:05:10 +0000 (02:05 +0100)]
avfilter/asrc_sine: Fix invalid left shift of negative number

by using a multiplication instead. The multiplication can never overflow
an int because the sin-factor is only an int16_t.

Affected the FATE-tests filter-concat and filter-concat-vfr.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/webmdashenc: Don't pass NULL to memcmp
Andreas Rheinhardt [Mon, 23 Sep 2019 21:23:10 +0000 (23:23 +0200)]
avformat/webmdashenc: Don't pass NULL to memcmp

Affects the FATE-tests webm-dash-manifest-unaligned-video-streams,
webm-dash-manifest and webm-dash-manifest-representations.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/vividas: Use equals check with n in read_sb_block()
Michael Niedermayer [Mon, 15 Feb 2021 20:29:11 +0000 (21:29 +0100)]
avformat/vividas: Use equals check with n in read_sb_block()

Fixes: OOM
Fixes: 27780/clusterfuzz-testcase-minimized-ffmpeg_dem_VIVIDAS_fuzzer-5097985075314688
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavcodec/sonic: Use unsigned temporary in predictor_calc_error()
Michael Niedermayer [Wed, 10 Feb 2021 22:05:17 +0000 (23:05 +0100)]
avcodec/sonic: Use unsigned temporary in predictor_calc_error()

Fixes: signed integer overflow: -2147471366 - 18638 cannot be represented in type 'int'
Fixes: 30157/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SONIC_fuzzer-5171199746506752
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavformat/jacosubdec: Use 64bit intermediate for start/end timestamp shift
Michael Niedermayer [Thu, 11 Feb 2021 21:44:36 +0000 (22:44 +0100)]
avformat/jacosubdec: Use 64bit intermediate for start/end timestamp shift

Fixes: signed integer overflow: -1957694447 + -1620425806 cannot be represented in type 'int'
Fixes: 30207/clusterfuzz-testcase-minimized-ffmpeg_dem_JACOSUB_fuzzer-5050791771635712
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavformat/flvdec: Check array entry number
Michael Niedermayer [Thu, 11 Feb 2021 21:58:53 +0000 (22:58 +0100)]
avformat/flvdec: Check array entry number

Fixes: signed integer overflow: -2147483648 - 1 cannot be represented in type 'int'
Fixes: 30209/clusterfuzz-testcase-minimized-ffmpeg_dem_FLV_fuzzer-5724831658147840
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavformat/rtpenc_mpegts: stop leaks
Gyan Doshi [Sun, 28 Mar 2021 09:35:37 +0000 (15:05 +0530)]
avformat/rtpenc_mpegts: stop leaks

Fixes CID 1474460 & 1474461

3 years agodoc/filters: note default for elbg pal8 option
Gyan Doshi [Sun, 28 Mar 2021 09:56:56 +0000 (15:26 +0530)]
doc/filters: note default for elbg pal8 option

3 years agoavcodec/libxvid: remove unnecessary output packet data check
James Almer [Fri, 19 Mar 2021 01:45:12 +0000 (22:45 -0300)]
avcodec/libxvid: remove unnecessary output packet data check

The user buffers passed to avcodec_encode_video2() haven't been propagated to
AVCodec.encode2 implementations since 93016f5d1d280f9cb7856883af287fa66affc04c.
Also, the generic encode code already unrefs the packet if nothing was encoded.

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavformat/mov: Properly forward error codes from av_seek
Derek Buitenhuis [Thu, 25 Mar 2021 16:29:16 +0000 (16:29 +0000)]
avformat/mov: Properly forward error codes from av_seek

This is important, for example, for connection timed out events,
when used over a network, returning AVERROR(ETIMEDOUT).

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
3 years agotools/target_dec_fuzzer: Adjust threshold for flac
Michael Niedermayer [Mon, 22 Mar 2021 19:51:43 +0000 (20:51 +0100)]
tools/target_dec_fuzzer: Adjust threshold for flac

Fixes: Timeout
Fixes: 31464/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FLAC_fuzzer-4843965653319680
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavcodec/h264_slice: Check sps in h264_slice_header_init()
Michael Niedermayer [Sat, 20 Mar 2021 16:02:36 +0000 (17:02 +0100)]
avcodec/h264_slice: Check sps in h264_slice_header_init()

Fixes: null pointer dereference
Fixes: h264_slice_header_init.mp4
Found-by: Rafael Dutra <rafael.dutra@cispa.de>
Tested-by: Rafael Dutra <rafael.dutra@cispa.de>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavcodec/aacpsy: Check model_priv_data before dereferencing in psy_3gpp_end()
Michael Niedermayer [Thu, 18 Mar 2021 21:20:03 +0000 (22:20 +0100)]
avcodec/aacpsy: Check model_priv_data before dereferencing in psy_3gpp_end()

Fixes: null pointer dereference
Fixes: av_freep.mp4
Found-by: Rafael Dutra <rafael.dutra@cispa.de>
Tested-by: Rafael Dutra <rafael.dutra@cispa.de>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavformat/movenc: Avoid loosing cluster array on failure
Michael Niedermayer [Thu, 18 Mar 2021 17:01:52 +0000 (18:01 +0100)]
avformat/movenc: Avoid loosing cluster array on failure

Fixes: crash
Fixes: check_pkt.mp4
Found-by: Rafael Dutra <rafael.dutra@cispa.de>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agotools/target_dec_fuzzer: Adjust VP4 threshold
Michael Niedermayer [Thu, 18 Mar 2021 10:03:19 +0000 (11:03 +0100)]
tools/target_dec_fuzzer: Adjust VP4 threshold

Fixes: Timeout (>10sec -> <100ms)
Fixes: 31515/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP4_fuzzer-5247114134290432
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavformat/avidec: Check for dv streams before using priv_data in parse ##dc/##wb
Michael Niedermayer [Thu, 18 Mar 2021 09:59:19 +0000 (10:59 +0100)]
avformat/avidec: Check for dv streams before using priv_data in parse ##dc/##wb

Fixes: null pointer dereference
Fixes: 31588/clusterfuzz-testcase-minimized-ffmpeg_dem_AVI_fuzzer-6165716135968768
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavformat/mov: Check sample size for overflow in mov_parse_stsd_audio()
Michael Niedermayer [Wed, 17 Mar 2021 22:39:04 +0000 (23:39 +0100)]
avformat/mov: Check sample size for overflow in mov_parse_stsd_audio()

Fixes: signed integer overflow: 2 * 1914708000 cannot be represented in type 'int'
Fixes: 31639/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-6303428239294464
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavcodec/sga: Check for array end in lzss_decompress()
Michael Niedermayer [Wed, 17 Mar 2021 21:19:33 +0000 (22:19 +0100)]
avcodec/sga: Check for array end in lzss_decompress()

Fixes: out of array access
Fixes: 31640/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SGA_fuzzer-5630883286614016
Fixes: 31619/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SGA_fuzzer-5176667708456960
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavformat/sbgdec: Check for overflow in last loop in expand_timestamps()
Michael Niedermayer [Fri, 5 Mar 2021 23:10:05 +0000 (00:10 +0100)]
avformat/sbgdec: Check for overflow in last loop in expand_timestamps()

Fixes: signed integer overflow: 9223372036854775807 + 86400000000 cannot be represented in type 'long'
Fixes: 31003/clusterfuzz-testcase-minimized-ffmpeg_dem_SBG_fuzzer-6256298771480576
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavcodec/ffwavesynth: Avoid signed integer overflow in phi_at()
Michael Niedermayer [Fri, 5 Mar 2021 19:27:50 +0000 (20:27 +0100)]
avcodec/ffwavesynth: Avoid signed integer overflow in phi_at()

Fixes: signed integer overflow: 2314885530818453536 - -9070214327174160352 cannot be represented in type 'long'
Fixes: 31000/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFWAVESYNTH_fuzzer-6558389742206976
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavformat/rtpenc_mpegts: convey options for rtp muxer
Gyan Doshi [Tue, 23 Mar 2021 05:26:10 +0000 (10:56 +0530)]
avformat/rtpenc_mpegts: convey options for rtp muxer

3 years agoavformat/rtpenc_mpegts: relay streamid to mpegts muxer streams.
Gyan Doshi [Thu, 18 Mar 2021 13:22:15 +0000 (18:52 +0530)]
avformat/rtpenc_mpegts: relay streamid to mpegts muxer streams.

3 years agoavformat/rtpenc_mpegts: convey options for mpeg-ts muxer
Gyan Doshi [Thu, 18 Mar 2021 11:04:22 +0000 (16:34 +0530)]
avformat/rtpenc_mpegts: convey options for mpeg-ts muxer

Fixes #5239

3 years agoavcodec/pthread_frame: Reindentation
Andreas Rheinhardt [Sun, 21 Mar 2021 04:39:49 +0000 (05:39 +0100)]
avcodec/pthread_frame: Reindentation

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/pthread_frame: Check initializing mutexes/condition variables
Andreas Rheinhardt [Tue, 23 Mar 2021 05:34:11 +0000 (06:34 +0100)]
avcodec/pthread_frame: Check initializing mutexes/condition variables

Up until now, initializing the mutexes/condition variables wasn't
checked by ff_frame_thread_init(). This commit changes this.

Given that it is not documented to be save to destroy a zeroed but
otherwise uninitialized mutex/condition variable, one has to choose
between two approaches: Either one duplicates the code to free them
in ff_frame_thread_init() in case of errors or one records which have
been successfully initialized. This commit takes the latter approach:
For each of the two structures with mutexes/condition variables
an array containing the offsets of the members to initialize is added.
Said array is used both for initializing and freeing and the only thing
that needs to be recorded is how many of these have been successfully
initialized.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/pthread_frame: Fix cleanup during init
Andreas Rheinhardt [Thu, 11 Feb 2021 12:45:31 +0000 (13:45 +0100)]
avcodec/pthread_frame: Fix cleanup during init

In case an error happened when setting up the child threads,
ff_frame_thread_init() would up until now call ff_frame_thread_free()
to clean up all threads set up so far, including the current, not
properly initialized one.
But a half-allocated context needs special handling which
ff_frame_thread_frame_free() doesn't provide.
Notably, if allocating the AVCodecInternal, the codec's private data
or setting the options fails, the codec's close function will be
called (if there is one); it will also be called if the codec's init
function fails, regardless of whether the FF_CODEC_CAP_INIT_CLEANUP
is set. This is not supported by all codecs; in ticket #9099 it led
to a crash.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/pthread_frame: Factor initializing single thread out
Andreas Rheinhardt [Sun, 21 Mar 2021 04:00:09 +0000 (05:00 +0100)]
avcodec/pthread_frame: Factor initializing single thread out

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/libmodplug: Fix memleaks on error
Andreas Rheinhardt [Wed, 24 Mar 2021 05:31:16 +0000 (06:31 +0100)]
avformat/libmodplug: Fix memleaks on error

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/libgme: Remove redundant setting of packet size
Andreas Rheinhardt [Wed, 24 Mar 2021 04:26:37 +0000 (05:26 +0100)]
avformat/libgme: Remove redundant setting of packet size

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/libgme: Actually set the duration
Andreas Rheinhardt [Wed, 24 Mar 2021 04:24:03 +0000 (05:24 +0100)]
avformat/libgme: Actually set the duration

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/libgme: Fix memleaks on errors
Andreas Rheinhardt [Wed, 24 Mar 2021 03:41:58 +0000 (04:41 +0100)]
avformat/libgme: Fix memleaks on errors

Also free the gme_info_t structure immediately after its use.
This simplifies cleanup, because it might be unsafe to call
gme_free_info(NULL) (or even worse, gme_track_info() might even
on error set the pointer to the gme_info_t structure to something
else than NULL).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/aadec: Fix leak on error
Andreas Rheinhardt [Wed, 24 Mar 2021 02:23:37 +0000 (03:23 +0100)]
avformat/aadec: Fix leak on error

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/jacosubdec: Fix leak on error
Andreas Rheinhardt [Wed, 24 Mar 2021 02:15:33 +0000 (03:15 +0100)]
avformat/jacosubdec: Fix leak on error

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agolavfi/dnn_backend_tensorflow.c: fix mem leak in execute_model_tf
Ting Fu [Wed, 24 Mar 2021 07:39:28 +0000 (15:39 +0800)]
lavfi/dnn_backend_tensorflow.c: fix mem leak in execute_model_tf

Signed-off-by: Ting Fu <ting.fu@intel.com>
3 years agolavfi/dnn_backend_tensorflow.c: fix mem leak in load_native_model
Ting Fu [Wed, 24 Mar 2021 07:39:27 +0000 (15:39 +0800)]
lavfi/dnn_backend_tensorflow.c: fix mem leak in load_native_model

Signed-off-by: Ting Fu <ting.fu@intel.com>
3 years agolavfi/dnn_backend_tensorflow.c: fix mem leak in load_tf_model
Ting Fu [Wed, 24 Mar 2021 07:39:26 +0000 (15:39 +0800)]
lavfi/dnn_backend_tensorflow.c: fix mem leak in load_tf_model

Signed-off-by: Ting Fu <ting.fu@intel.com>
3 years agoavfilter/overlay_cuda: fix framesync with embedded PGS subtitle
nyanmisaka [Tue, 2 Feb 2021 17:10:11 +0000 (01:10 +0800)]
avfilter/overlay_cuda: fix framesync with embedded PGS subtitle

Signed-off-by: nyanmisaka <nst799610810@gmail.com>
3 years agoavfilter/hwupload_cuda: add YUVA420P format support
nyanmisaka [Tue, 2 Feb 2021 17:09:52 +0000 (01:09 +0800)]
avfilter/hwupload_cuda: add YUVA420P format support

Signed-off-by: nyanmisaka <nst799610810@gmail.com>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
3 years agoMAINTAINERS: add myself as adpcm maintainer
Zane van Iperen [Tue, 23 Mar 2021 11:20:22 +0000 (21:20 +1000)]
MAINTAINERS: add myself as adpcm maintainer

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
3 years agoavformat/pp_bnk: allow seeking to start
Zane van Iperen [Tue, 23 Mar 2021 11:51:57 +0000 (21:51 +1000)]
avformat/pp_bnk: allow seeking to start

Allows "ffplay -loop" to work.

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
3 years agoavformat/alp: allow seeking to start
Zane van Iperen [Mon, 22 Mar 2021 13:12:34 +0000 (23:12 +1000)]
avformat/alp: allow seeking to start

Allows "ffplay -loop" to work.

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
3 years agoavformat/kvag: allow seeking to start
Zane van Iperen [Mon, 22 Mar 2021 12:44:56 +0000 (22:44 +1000)]
avformat/kvag: allow seeking to start

Allows "ffplay -loop" to work.

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
3 years agoavcodec/adpcm_ima_cunning: reset state on flush
Zane van Iperen [Tue, 23 Mar 2021 11:42:46 +0000 (21:42 +1000)]
avcodec/adpcm_ima_cunning: reset state on flush

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
3 years agoavcodec/adpcm_ima_alp: reset state on flush
Zane van Iperen [Tue, 23 Mar 2021 11:05:42 +0000 (21:05 +1000)]
avcodec/adpcm_ima_alp: reset state on flush

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
3 years agoavcodec/adpcm_ima_ssi: reset state on flush
Zane van Iperen [Tue, 23 Mar 2021 11:05:16 +0000 (21:05 +1000)]
avcodec/adpcm_ima_ssi: reset state on flush

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
3 years agoavcodec/adpcm_argo: reset state on flush
Zane van Iperen [Tue, 23 Mar 2021 10:58:33 +0000 (20:58 +1000)]
avcodec/adpcm_argo: reset state on flush

Commit 003b5c800fef909fa84dd2fae43d66bd434d3f7e introduced seeking in argo_asf,
but this was missed, leading to non-deterministic output.

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
3 years agoavcodec/adpcm_aica: reset state in flush callback
Zane van Iperen [Tue, 23 Mar 2021 10:55:17 +0000 (20:55 +1000)]
avcodec/adpcm_aica: reset state in flush callback

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
3 years agoavcodec/adpcm_zork: reset state in flush callback
Zane van Iperen [Tue, 23 Mar 2021 10:52:16 +0000 (20:52 +1000)]
avcodec/adpcm_zork: reset state in flush callback

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
3 years agoavcodec/adpcm: add comment to has_status field
Zane van Iperen [Tue, 23 Mar 2021 11:01:16 +0000 (21:01 +1000)]
avcodec/adpcm: add comment to has_status field

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
3 years agoavcodec/kmvc: Avoid branch when swapping pointers
Andreas Rheinhardt [Mon, 22 Mar 2021 01:40:20 +0000 (02:40 +0100)]
avcodec/kmvc: Avoid branch when swapping pointers

Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/kmvc: Move commonly used variables to the front of the context
Andreas Rheinhardt [Mon, 22 Mar 2021 01:28:11 +0000 (02:28 +0100)]
avcodec/kmvc: Move commonly used variables to the front of the context

Reduces codesize because the offset in pointer+offset addressing
requires less bytes to encode. Reduces the size of .text from 8871B
to 8146B (GCC 10, -O3, x64).

Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/kmvc: Prefer in-band palette
Andreas Rheinhardt [Mon, 22 Mar 2021 01:14:35 +0000 (02:14 +0100)]
avcodec/kmvc: Prefer in-band palette

Fixes decoding of https://samples.ffmpeg.org/V-codecs/KMVC/LOGO2.AVI

Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/vc1dec: Postpone allocating sprite frame to avoid segfault
Andreas Rheinhardt [Tue, 22 Dec 2020 16:21:48 +0000 (17:21 +0100)]
avcodec/vc1dec: Postpone allocating sprite frame to avoid segfault

Up until now, the VC-1 decoders allocated an AVFrame for usage with
sprites during vc1_decode_init(); yet said AVFrame can be freed if
(re)initializing the context (which happens ordinarily during decoding)
fails. The AVFrame does not get allocated again lateron in this case,
leading to segfaults.

Fix this by moving the allocation of said frame immediately before it is
used (this also means that said frame won't be allocated at all any more
in case of a regular (i.e. non-image) stream).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agodoc/filters: fix option name for mix filter
Gyan Doshi [Wed, 24 Mar 2021 11:22:02 +0000 (16:52 +0530)]
doc/filters: fix option name for mix filter

Corrected from nb_inputs to inputs

3 years agoavutil/frame: Deprecate av_get_colorspace_name()
Andreas Rheinhardt [Sun, 21 Mar 2021 09:15:44 +0000 (10:15 +0100)]
avutil/frame: Deprecate av_get_colorspace_name()

Contrary to av_color_space_name() it doesn't even support newer
colorspaces.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/avcodec: Use AVBPrint in avcodec_string()
Andreas Rheinhardt [Sun, 21 Mar 2021 07:05:14 +0000 (08:05 +0100)]
avcodec/avcodec: Use AVBPrint in avcodec_string()

It automatically records the current length of the string,
whereas the current code contains lots of instances of
snprintf(buf + strlen(buf), buf_size - strlen(buf), ...).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/avcodec: Update check for identical colorspace/primaries/trc names
Andreas Rheinhardt [Sun, 21 Mar 2021 06:26:17 +0000 (07:26 +0100)]
avcodec/avcodec: Update check for identical colorspace/primaries/trc names

If the numerical constants for colorspace, transfer characteristics
and color primaries coincide, the current code presumes the
corresponding names to be identical and prints only one of them obtained
via av_get_colorspace_name(). There are two issues with this: The first
is that the underlying assumption is wrong: The names only coincide in
the 0-7 range, they differ for more recent additions. The second is that
av_get_colorspace_name() is outdated itself; it has not been updated
with the names of the newly defined colorspaces.

Fix both of this by using the names from
av_color_(space|primaries|transfer)_name() and comparing them via
strcmp; don't use av_get_colorspace_name() at all.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/avcodec: Don't use NULL for %s printf specifier
Andreas Rheinhardt [Sun, 21 Mar 2021 05:29:13 +0000 (06:29 +0100)]
avcodec/avcodec: Don't use NULL for %s printf specifier

Our "get name" functions can return NULL for invalid/unknown
arguments. So check for this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/avcodec: Use dedicated pointer to access AVCodecInternal
Andreas Rheinhardt [Sun, 21 Mar 2021 05:06:12 +0000 (06:06 +0100)]
avcodec/avcodec: Use dedicated pointer to access AVCodecInternal

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agotests/dnn/dnn-layer-mathunary-test: add unit test for exp
Wenlong Ding [Mon, 22 Mar 2021 08:20:12 +0000 (16:20 +0800)]
tests/dnn/dnn-layer-mathunary-test: add unit test for exp

Signed-off-by: Wenlong Ding <wenlong.ding@intel.com>
3 years agolavfi/dnn/dnn_backend_native_layer_mathunary: add exp support
Wenlong Ding [Mon, 22 Mar 2021 08:20:11 +0000 (16:20 +0800)]
lavfi/dnn/dnn_backend_native_layer_mathunary: add exp support

Signed-off-by: Wenlong Ding <wenlong.ding@intel.com>
3 years agoavformat/amvenc: Remove unnecessary av_packet_free()
Andreas Rheinhardt [Thu, 18 Mar 2021 05:29:35 +0000 (06:29 +0100)]
avformat/amvenc: Remove unnecessary av_packet_free()

The muxer's deinit function takes care of cleaning up when init fails.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/webpenc: Fix memleak when trailer is never written
Andreas Rheinhardt [Thu, 18 Mar 2021 22:27:57 +0000 (23:27 +0100)]
avformat/webpenc: Fix memleak when trailer is never written

When the trailer is never written (or when a stream switches from
non-animation mode to animation mode mid-stream), a cached packet
(if existing) would leak. Fix this by adding a deinit function.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/webpenc: Reindentation
Andreas Rheinhardt [Thu, 18 Mar 2021 22:16:30 +0000 (23:16 +0100)]
avformat/webpenc: Reindentation

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/webpenc: Fix memleak when using invalid packets
Andreas Rheinhardt [Thu, 18 Mar 2021 22:04:37 +0000 (23:04 +0100)]
avformat/webpenc: Fix memleak when using invalid packets

The WebP muxer sometimes caches a packet it receives to write it later;
yet if a cached packet is too small (so small as to be invalid),
it is cached, but not written and not unreferenced. Such a packet leaks,
either by being overwritten by the next packet or because it is never
unreferenced at all.

Fix this by not caching unusable packets at all; and error out on
invalid packets.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/webpenc: Use init instead of write_header function
Andreas Rheinhardt [Thu, 18 Mar 2021 21:15:36 +0000 (22:15 +0100)]
avformat/webpenc: Use init instead of write_header function

webp_write_header() didn't write anything.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/ipmovie: Avoid stack packet
Andreas Rheinhardt [Thu, 18 Mar 2021 20:35:58 +0000 (21:35 +0100)]
avformat/ipmovie: Avoid stack packet

Replace it in ipmovie_read_header() by AVFormatInternal.parse_pkt
which is unused when reading the header.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/ipmovie: Remove redundant initializations
Andreas Rheinhardt [Thu, 18 Mar 2021 20:42:26 +0000 (21:42 +0100)]
avformat/ipmovie: Remove redundant initializations

The demuxer's context has already been zeroed generically.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/ipmovie: Fix indentation
Andreas Rheinhardt [Thu, 18 Mar 2021 20:11:43 +0000 (21:11 +0100)]
avformat/ipmovie: Fix indentation

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/ipmovie: Deduplicate parsing video data opcodes
Andreas Rheinhardt [Thu, 18 Mar 2021 20:03:15 +0000 (21:03 +0100)]
avformat/ipmovie: Deduplicate parsing video data opcodes

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/ipmovie: Avoid reading packets during read_header
Andreas Rheinhardt [Thu, 18 Mar 2021 19:29:42 +0000 (20:29 +0100)]
avformat/ipmovie: Avoid reading packets during read_header

They will be discarded anyway because this can only happen
for invalid data. This already implies that the pkt won't be used
at all when parsing the very first chunk when reading the header,
so one can use NULL as argument and remove the av_packet_unref()
on error.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/ipmovie: Remove redundant av_packet_unref()
Andreas Rheinhardt [Thu, 18 Mar 2021 18:55:55 +0000 (19:55 +0100)]
avformat/ipmovie: Remove redundant av_packet_unref()

When one of these errors happens during ipmovie_read_packet(),
an error is returned and the packet is cleaned up generically.
And since 712d3ac539f30239b764d8621829dc9dc913da61 the same happens
in ipmovie_read_header().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/asfdec_f: Avoid stack packet
Andreas Rheinhardt [Thu, 18 Mar 2021 18:11:40 +0000 (19:11 +0100)]
avformat/asfdec_f: Avoid stack packet

Replace it by using AVFormatInternal.parse_pkt which is otherwise unused
when reading a header.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/moflex: Simplify freeing packets
Andreas Rheinhardt [Thu, 18 Mar 2021 14:43:54 +0000 (15:43 +0100)]
avformat/moflex: Simplify freeing packets

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/matroskadec: Reuse AVFormatInternal.parse_pkt
Andreas Rheinhardt [Thu, 18 Mar 2021 05:04:17 +0000 (06:04 +0100)]
avformat/matroskadec: Reuse AVFormatInternal.parse_pkt

Before 8d78e90a6ba96646f7f25aff6ca3e12e71cec164 the Matroska demuxer
used stack packets to hold temporary packets; now it uses a temporary
packet allocated by the Matroska demuxer. Yet because it used stack
packets the code has always properly reset the packet on error, while
on success these temporary packets were put into a packet list via
avpriv_packet_list_put(), which already resets the source packet.
This means that this code is compatible with just reusing
AVFormatInternal.parse_pkt (which is unused while one is in the
demuxer's read_packet() function). Compared to before 8d78e90a6
this no longer wastes one initialization per AVPacket read
(the resetting of the stack packet performed by av_packet_move_ref()
in avpriv_packet_list_put() was for naught).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/rtpdec: attach producer reference time if available
Alok Priyadarshi [Tue, 23 Mar 2021 21:29:48 +0000 (14:29 -0700)]
avformat/rtpdec: attach producer reference time if available

This produces true wallclock time at rtp source instead of the
local wallclock time at rtp client.

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agolavc/mjpegdec: Decode format 211121 as YUV 4:4:4
Carl Eugen Hoyos [Sun, 21 Mar 2021 00:36:32 +0000 (01:36 +0100)]
lavc/mjpegdec: Decode format 211121 as YUV 4:4:4

Fixes ticket #8930.

3 years agoavformat/utils: Don't allocate separate packet for extract_extradata
Andreas Rheinhardt [Thu, 18 Mar 2021 04:23:54 +0000 (05:23 +0100)]
avformat/utils: Don't allocate separate packet for extract_extradata

One can simply reuse AVFormatInternal.parse_pkt instead.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agolibavformat/utils: Fix indentation
Andreas Rheinhardt [Fri, 19 Mar 2021 03:32:41 +0000 (04:32 +0100)]
libavformat/utils: Fix indentation

Originally added in 12f996edfab67b65af0ff1ee829f9eeabb025b0f
behind #if 0; aebb56e1844d61965c97e95534c3ae0da69df028 then
removed the #if and replaced it by using av_dlog. Then commit
1a3eb042c704dea190c644def5b32c9cee8832b8 replaced this with av_log
at trace level. Yet the code block always stayed within { }
at an increased level of indentation.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/svq3: Don't copy watermarked frame data twice
Andreas Rheinhardt [Sat, 20 Mar 2021 17:58:23 +0000 (18:58 +0100)]
avcodec/svq3: Don't copy watermarked frame data twice

The SVQ3 decoder modifies the input bitstream at two places.
One of them is only reached when the file is watermarked.
Therefore commit 2264c1108135380c49fdf0aef97520bf77a6ed37
made a copy of all the frame data in this case.

But there is a second possibility for modifying the frame and
therefore Libav commit 1098f5c0495c61a98d4ff6b8e24c17974d4bace5
made the decoder always copy the data. This of course makes
the additional copy for watermarked frames redundant, but it hasn't
been removed. This commit does so.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>