ffmpeg.git
2 months agoavcodec/utils: free last_pkt_props on avcodec_open2() failure
James Almer [Wed, 3 Mar 2021 21:05:15 +0000 (18:05 -0300)]
avcodec/utils: free last_pkt_props on avcodec_open2() failure

Regression since b34d1de8dc

Signed-off-by: James Almer <jamrial@gmail.com>
2 months agoavcodec/decode: port last_pkt_props to AVFifoBuffer
James Almer [Mon, 1 Mar 2021 17:10:36 +0000 (14:10 -0300)]
avcodec/decode: port last_pkt_props to AVFifoBuffer

Signed-off-by: James Almer <jamrial@gmail.com>
2 months agoavformat/lxfdec: Fix multiple integer overflows related to track_size
Michael Niedermayer [Thu, 14 Jan 2021 21:08:25 +0000 (22:08 +0100)]
avformat/lxfdec: Fix multiple integer overflows related to track_size

Fixes: signed integer overflow: 538976288 * 8 cannot be represented in type 'int'
Fixes: 26910/clusterfuzz-testcase-minimized-ffmpeg_dem_LXF_fuzzer-6634030636335104

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2 months agoavformat/mccdec: Use av_sat_add64() for fs
Michael Niedermayer [Thu, 14 Jan 2021 21:15:18 +0000 (22:15 +0100)]
avformat/mccdec: Use av_sat_add64() for fs

Fixes: signed integer overflow: -9223372036854775808 + -242 cannot be represented in type 'long'
Fixes: 26910/clusterfuzz-testcase-minimized-ffmpeg_dem_MCC_fuzzer-6723018395090944

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2 months agoavutil/parseutils: Check sign in av_parse_time()
Michael Niedermayer [Thu, 14 Jan 2021 20:11:05 +0000 (21:11 +0100)]
avutil/parseutils: Check sign in av_parse_time()

Fixes: signed integer overflow: -9223372053736 * 1000000 cannot be represented in type 'long'
Fixes: 26910/clusterfuzz-testcase-minimized-ffmpeg_dem_CONCAT_fuzzer-6607924558430208

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2 months agoavformat/mspdec: Check packet_size more completely
Michael Niedermayer [Wed, 3 Mar 2021 10:00:23 +0000 (11:00 +0100)]
avformat/mspdec: Check packet_size more completely

Fixes: OOM
Fixes: 28348/clusterfuzz-testcase-minimized-ffmpeg_dem_MSP_fuzzer-4612055872831488
Fixes: 28360/clusterfuzz-testcase-minimized-ffmpeg_dem_MSP_fuzzer-6245230626078720

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>
2 months agoavformat/aiffdec: Check that SSND is at least 8 bytes
Michael Niedermayer [Wed, 3 Mar 2021 09:49:04 +0000 (10:49 +0100)]
avformat/aiffdec: Check that SSND is at least 8 bytes

Fixes: Infinite loop
Fixes: 30874/clusterfuzz-testcase-minimized-ffmpeg_dem_AIFF_fuzzer-5933710488764416

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>
2 months agoavformat/dcstr: Check sample rate
Michael Niedermayer [Wed, 3 Mar 2021 09:49:03 +0000 (10:49 +0100)]
avformat/dcstr: Check sample rate

Fixes: signed integer overflow: -1300248894420254720 * 16 cannot be represented in type 'long'
Fixes: 30879/clusterfuzz-testcase-minimized-ffmpeg_dem_DCSTR_fuzzer-5094464215449600

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>
2 months agoavformat/frmdec: Simplify finding pixel format
Andreas Rheinhardt [Mon, 1 Mar 2021 16:22:31 +0000 (17:22 +0100)]
avformat/frmdec: Simplify finding pixel format

The fourccs used by the Megalux Frame format to determine the pixel
format are actually no fourccs at all as they are a single byte.
Furthermore, their range is continuous (1-5), so they are actually
ordinary indices. So treat them as such and don't use PixelFormatTags
for them.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoavformat: Deprecate AVFMT_FLAG_PRIV_OPT, remove av_demuxer_open on bump
Andreas Rheinhardt [Fri, 26 Feb 2021 16:25:54 +0000 (17:25 +0100)]
avformat: Deprecate AVFMT_FLAG_PRIV_OPT, remove av_demuxer_open on bump

This flag was added in 492026209b9b58eaf6d2ea56423f6b1e1a8a76a5
in conjunction with av_demuxer_open() to allow to pass private
options to demuxers. It worked as follows: av_open_input_stream()
(the predecessor of avformat_open_input()) would not call the
read_header function if this flag is set. Instead the user could set
private options of the demuxer via the format's private class after
avformat_open_input() and then call av_demuxer_open() which called
the format's read_header function.

This approach was abandoned in e37f161e66e042d6c2c7470c4d9881df9427fc4a
and av_demuxer_open() deprecated; instead the AVDictionary based way of
passing private options to the demuxer was choosen. Yet
AVFMT_FLAG_PRIV_OPT has never been deprecated and av_demuxer_open()
never removed. This commit implements the deprecation of the flag and
schedules av_demuxer_open for removal on the next major bump.
Given that av_demuxer_open() has been deprecated in 2012 and that this
flag is useless without it, the flag will be ignored after the next
major version bump.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoivfenc: write duration for frame_cnt=1.
Ronald S. Bultje [Tue, 2 Mar 2021 18:52:44 +0000 (13:52 -0500)]
ivfenc: write duration for frame_cnt=1.

2 months agoavcodec/float2half: fix minor style issue
Paul B Mahol [Wed, 3 Mar 2021 11:47:56 +0000 (12:47 +0100)]
avcodec/float2half: fix minor style issue

2 months agoavcodec/half2float: fix integer overflows in convertmantissa()
Paul B Mahol [Wed, 3 Mar 2021 11:37:02 +0000 (12:37 +0100)]
avcodec/half2float: fix integer overflows in convertmantissa()

2 months agoavcodec/mobiclip: Avoid undefined integer overflow in MV computation
Michael Niedermayer [Mon, 1 Mar 2021 23:19:21 +0000 (00:19 +0100)]
avcodec/mobiclip: Avoid undefined integer overflow in MV computation

Fixes: signed integer overflow: 1 + 2147483647 cannot be represented in type 'int'
Fixes: 30877/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MOBICLIP_fuzzer-4775601145774080

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2 months agoavcodec/alsdec: Check bitstream input in read_block()
Michael Niedermayer [Mon, 1 Mar 2021 22:24:37 +0000 (23:24 +0100)]
avcodec/alsdec: Check bitstream input in read_block()

Fixes: Timeout
Fixes: 28110/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALS_fuzzer-5036338973507584

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2 months agoavcodec/exr: add lut oriented half to float conversion code
Paul B Mahol [Sun, 28 Feb 2021 11:44:25 +0000 (12:44 +0100)]
avcodec/exr: add lut oriented half to float conversion code

2 months agoavcodec/exrenc: move float2half code to own header
Paul B Mahol [Sun, 28 Feb 2021 10:57:04 +0000 (11:57 +0100)]
avcodec/exrenc: move float2half code to own header

2 months agoavcodec/exr: add DWA decompression support
Paul B Mahol [Fri, 26 Feb 2021 14:47:15 +0000 (15:47 +0100)]
avcodec/exr: add DWA decompression support

2 months agoavcodec/svq1dec: use av_fast_padded_malloc() for allocation pmv only when necessary
Paul B Mahol [Tue, 2 Mar 2021 14:03:33 +0000 (15:03 +0100)]
avcodec/svq1dec: use av_fast_padded_malloc() for allocation pmv only when necessary

2 months agoavformat/dashdec: Increase size of id buffer
Andreas Rheinhardt [Tue, 2 Mar 2021 10:34:07 +0000 (11:34 +0100)]
avformat/dashdec: Increase size of id buffer

The current size is not enough, see e.g.
http://ftp.itec.aau.at/datasets/DASHDataset2014/TearsOfSteel/1sec/TearsOfSteel_1s_simple_2014_05_09.mpd

Reviewed-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoavformat/dashdec: Ensure strings are zero-terminated
Andreas Rheinhardt [Tue, 2 Mar 2021 10:20:29 +0000 (11:20 +0100)]
avformat/dashdec: Ensure strings are zero-terminated

strncpy only ensures that one does not write beyond the end of the
destination buffer; in case of truncation it does not zero-terminate
the destination buffer. This makes using it the way it is now in the
DASH demuxer dangerous. So use av_strlcpy instead.

Also don't write anything if there is no id: The buffer has already been
zeroed initially.

The DASH testset from the Universität Klagenfurt contains samples with
ids that are too long. E.g.
http://ftp.itec.aau.at/datasets/DASHDataset2014/TearsOfSteel/1sec/TearsOfSteel_1s_simple_2014_05_09.mpd

Reviewed-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agofftools: Switch to const AVCodec * where possible
Andreas Rheinhardt [Thu, 25 Feb 2021 04:02:39 +0000 (05:02 +0100)]
fftools: Switch to const AVCodec * where possible

The obstacle to do so was in filter_codec_opts: It uses searches
the AVCodec for options via the AV_OPT_SEARCH_FAKE_OBJ method, which
requires using a void * that points to a pointer to a const AVClass.
When using const AVCodec *, one can not simply use a pointer that points
to the AVCodec's pointer to its AVClass, as said pointer is const, too.
This is fixed by using a temporary pointer to the AVClass.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoavcodec/mpegvideo: Schedule unused, deprecated rc_strategy for removal
Andreas Rheinhardt [Fri, 26 Feb 2021 08:48:27 +0000 (09:48 +0100)]
avcodec/mpegvideo: Schedule unused, deprecated rc_strategy for removal

Deprecated in d05c3b9ceeb9d00d4500c376448230e45f6ab108.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agofate/matroska: Test remuxing tracks for hearing/visually impaired
Andreas Rheinhardt [Wed, 17 Feb 2021 04:28:31 +0000 (05:28 +0100)]
fate/matroska: Test remuxing tracks for hearing/visually impaired

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoavformat/matroskaenc: Add support for FlagOriginal
Andreas Rheinhardt [Tue, 16 Feb 2021 17:53:55 +0000 (18:53 +0100)]
avformat/matroskaenc: Add support for FlagOriginal

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoavformat/matroskadec: Add support for FlagOriginal
Andreas Rheinhardt [Tue, 16 Feb 2021 17:41:30 +0000 (18:41 +0100)]
avformat/matroskadec: Add support for FlagOriginal

Needs a CountedElement in order to distinguish the case of the element
not being present and the element being present with a value of zero.

(It has been argued by Ridley Combs that one should only ever use the
AV_DISPOSITION_DUB field for audio tracks. Yet given that there is no
definition for the disposition flags, one can also interpret it to mean
that e.g. a subtitle track is meant to be used with the dubbed audio
track or the original audio track. This commit interprets this flag in
this sense, which also allows to maintain it on remuxing.)

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Reviewed-by: Ridley Combs <rcombs@rcombs.me>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoavformat/mov: Extend data_size check in mov_read_udta_string()
Michael Niedermayer [Sat, 12 Dec 2020 23:08:46 +0000 (00:08 +0100)]
avformat/mov: Extend data_size check in mov_read_udta_string()

Fixes: signed integer overflow: -2147483634 - 16 cannot be represented in type 'int'
Fixes: 28322/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-5711888402612224

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2 months agoavformat/aadec: Check for EOF while reading chapters
Michael Niedermayer [Sat, 12 Dec 2020 21:19:22 +0000 (22:19 +0100)]
avformat/aadec: Check for EOF while reading chapters

Fixes: timeout
Fixes: 28199/clusterfuzz-testcase-minimized-ffmpeg_dem_AA_fuzzer-4896162657861632

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2 months agoavcodec/h2645_parse: Reduce the initial skipped_bytes_pos size with small inputs
Michael Niedermayer [Sat, 12 Dec 2020 15:36:04 +0000 (16:36 +0100)]
avcodec/h2645_parse: Reduce the initial skipped_bytes_pos size with small inputs

Fixes: OOM
Fixes: 23817/clusterfuzz-testcase-minimized-ffmpeg_BSF_H264_METADATA_fuzzer-6300869057576960
Fixes: 28055/clusterfuzz-testcase-minimized-ffmpeg_BSF_TRACE_HEADERS_fuzzer-5706035297517568

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2 months agoavformat/voc_packet: Add a basic check on max_size
Michael Niedermayer [Sat, 12 Dec 2020 00:24:42 +0000 (01:24 +0100)]
avformat/voc_packet: Add a basic check on max_size

Fixes: signed integer overflow: -2147483648 - 4 cannot be represented in type 'int'
Fixes: 28127/clusterfuzz-testcase-minimized-ffmpeg_dem_VOC_fuzzer-4880586455646208

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2 months agoavformat/sga: improve probing for valid files
Paul B Mahol [Mon, 1 Mar 2021 17:37:40 +0000 (18:37 +0100)]
avformat/sga: improve probing for valid files

Update variables depending on high four bits of first two bytes.

2 months agoavformat: add Digital Pictures SGA game demuxer
Paul B Mahol [Sun, 21 Feb 2021 12:33:07 +0000 (13:33 +0100)]
avformat: add Digital Pictures SGA game demuxer

2 months agoavcodec: add SGA Video decoder
Paul B Mahol [Sun, 21 Feb 2021 23:36:01 +0000 (00:36 +0100)]
avcodec: add SGA Video decoder

2 months agoavcodec: add SGA PCM decoder
Paul B Mahol [Sun, 21 Feb 2021 23:30:22 +0000 (00:30 +0100)]
avcodec: add SGA PCM decoder

2 months agoRemove double ';'
Andreas Rheinhardt [Mon, 1 Mar 2021 05:10:44 +0000 (06:10 +0100)]
Remove double ';'

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoavcodec/roqvideoenc: Avoid allocating buffers separately
Andreas Rheinhardt [Sun, 28 Feb 2021 01:44:26 +0000 (02:44 +0100)]
avcodec/roqvideoenc: Avoid allocating buffers separately

This is possible because their size is known at compile-time; so they
can be put directly into the context and don't need to be allocated for
every frame.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoavcodec/roqvideoenc: Avoid intermediate buffer
Andreas Rheinhardt [Sat, 27 Feb 2021 16:56:04 +0000 (17:56 +0100)]
avcodec/roqvideoenc: Avoid intermediate buffer

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoavcodec/roqvideoenc: Reuse buffers instead of alloc+free for each frame
Andreas Rheinhardt [Sat, 27 Feb 2021 15:10:09 +0000 (16:10 +0100)]
avcodec/roqvideoenc: Reuse buffers instead of alloc+free for each frame

In case of the cel evaluators it even allows to perform the
initialization of the source coordinates only once instead of for each
frame.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoavcodec/roqvideo: Use dedicated context for encoder
Andreas Rheinhardt [Sat, 27 Feb 2021 14:42:33 +0000 (15:42 +0100)]
avcodec/roqvideo: Use dedicated context for encoder

Up until now, the RoQ video decoder and encoder used the same context;
and said context contained several fields that are only used by the
encoder. This commit changes this and uses a dedicated context for the
encoder; it contains the common context as first element in order to use
functions common to the de- and encoder.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoavcodec/exr: add fast path for case when powf() isn't needed
Paul B Mahol [Sun, 28 Feb 2021 22:14:40 +0000 (23:14 +0100)]
avcodec/exr: add fast path for case when powf() isn't needed

2 months agoavcodec/dxtory: Fix undefined shift with negative linesize
Michael Niedermayer [Mon, 22 Feb 2021 16:51:56 +0000 (17:51 +0100)]
avcodec/dxtory: Fix undefined shift with negative linesize

Fixes: left shift of negative value -128
Fixes: 30746/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DXTORY_fuzzer-5906271469436928

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>
2 months agodoc/codecs.texi: Remove removed or ineffective options
Andreas Rheinhardt [Fri, 26 Feb 2021 08:49:45 +0000 (09:49 +0100)]
doc/codecs.texi: Remove removed or ineffective options

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoavcodec/libx264: Don't use init_static_data for newer versions
Andreas Rheinhardt [Thu, 25 Feb 2021 08:25:51 +0000 (09:25 +0100)]
avcodec/libx264: Don't use init_static_data for newer versions

x264 versions >= 153 can support multiple bitdepths; they also don't
export x264_bit_depth any more. The actual check whether a bitdepth
is supported is therefore performed at runtime in x264_encoder_open.
Ergo it is unnecessary to use init_static_data for these versions:
One can already set ff_libx264_encoder.pix_fmts to the value that
X264_init_static always sets it to.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoavformat/webmdashenc: Use av_strstart instead of strncmp
Andreas Rheinhardt [Wed, 24 Feb 2021 06:46:22 +0000 (07:46 +0100)]
avformat/webmdashenc: Use av_strstart instead of strncmp

It makes the intent clearer and avoids calculating the length
separately.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoavformat/matroskadec: Use av_strstart instead of strncmp
Andreas Rheinhardt [Wed, 24 Feb 2021 06:44:31 +0000 (07:44 +0100)]
avformat/matroskadec: Use av_strstart instead of strncmp

It makes the intent clearer and avoids calculating the length
separately.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoavformat/avio: Use av_strstart instead of strncmp
Andreas Rheinhardt [Wed, 24 Feb 2021 06:43:37 +0000 (07:43 +0100)]
avformat/avio: Use av_strstart instead of strncmp

It makes the intent clearer and avoids calculating the length
in advance.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agofftools/cmdutils: Use av_strstart instead of strncmp
Andreas Rheinhardt [Wed, 24 Feb 2021 06:41:27 +0000 (07:41 +0100)]
fftools/cmdutils: Use av_strstart instead of strncmp

It makes the intent clearer and avoids searching for a delimiter
in advance.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoavutil/spherical: Use av_strstart instead of strncmp
Andreas Rheinhardt [Wed, 24 Feb 2021 02:37:26 +0000 (03:37 +0100)]
avutil/spherical: Use av_strstart instead of strncmp

It makes the intent clearer and avoids calculating the length
separately.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoavutil/stereo3d: Use av_strstart instead of strncmp
Andreas Rheinhardt [Wed, 24 Feb 2021 02:34:15 +0000 (03:34 +0100)]
avutil/stereo3d: Use av_strstart instead of strncmp

It makes the intent clearer and avoids calculating the length
separately.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoavutil/pixdesc: Use av_strstart where appropriate
Andreas Rheinhardt [Wed, 24 Feb 2021 02:26:36 +0000 (03:26 +0100)]
avutil/pixdesc: Use av_strstart where appropriate

It makes the intent clearer and allows to avoid calculating the strlen
separately.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoavformat/pcmdec: Beautify pcm_read_header
Andreas Rheinhardt [Wed, 24 Feb 2021 02:14:36 +0000 (03:14 +0100)]
avformat/pcmdec: Beautify pcm_read_header

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoavformat/pcmdec: Simplify parsing MIME type
Andreas Rheinhardt [Wed, 24 Feb 2021 01:45:58 +0000 (02:45 +0100)]
avformat/pcmdec: Simplify parsing MIME type

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoavformat/pcmdec: Fix NULL + 1
Andreas Rheinhardt [Wed, 24 Feb 2021 01:08:32 +0000 (02:08 +0100)]
avformat/pcmdec: Fix NULL + 1

It is undefined behaviour.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoavformat/pcm(dec|enc): Don't include disabled (de)muxers
Andreas Rheinhardt [Wed, 24 Feb 2021 00:02:30 +0000 (01:02 +0100)]
avformat/pcm(dec|enc): Don't include disabled (de)muxers

Also make the macro used for the demuxers spec-compliant. The earlier
macro was not, because the ... argument of a variadic macro must not be
left out. GCC and Clang warn about this when using -pedantic.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoavformat/movenc: Only check for timecodes if they are used
Andreas Rheinhardt [Tue, 23 Feb 2021 21:42:41 +0000 (22:42 +0100)]
avformat/movenc: Only check for timecodes if they are used

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agofftools/ffmpeg, ffplay: Don't set refcounted_frames
Andreas Rheinhardt [Wed, 24 Feb 2021 10:51:35 +0000 (11:51 +0100)]
fftools/ffmpeg, ffplay: Don't set refcounted_frames

It only affects the old and deprecated avcodec_decode_(video2|audio4)
API which is no longer used here.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoavformat/movenc: Don't check for disabled muxers
Andreas Rheinhardt [Tue, 23 Feb 2021 21:32:44 +0000 (22:32 +0100)]
avformat/movenc: Don't check for disabled muxers

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoavformat/movenc: Remove always true check
Andreas Rheinhardt [Tue, 23 Feb 2021 20:19:26 +0000 (21:19 +0100)]
avformat/movenc: Remove always true check

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoavcodec/exr: handle case when |im - IM| == 1 for huff compression
Paul B Mahol [Sun, 28 Feb 2021 01:03:11 +0000 (02:03 +0100)]
avcodec/exr: handle case when |im - IM| == 1 for huff compression

2 months agoavformat/movenccenc: Fix memory leak for muxing CENC-encrypted files
Vadym Bezdushnyi [Sun, 31 Jan 2021 14:52:45 +0000 (16:52 +0200)]
avformat/movenccenc: Fix memory leak for muxing CENC-encrypted files

Memory for auxillary_info was not freed after usage.

Leak can be reproduced with following commands:

Optionally, generate input video:
ffmpeg -f lavfi -i testsrc=duration=10:size=1280x720:rate=30 input.mp4

Run ffmpeg with valgrind:
valgrind --leak-check=full --show-leak-kinds=all \
ffmpeg -y -i input.mp4 -vcodec copy -acodec copy \
-encryption_scheme cenc-aes-ctr \
-encryption_key 00000000000000000000000000000000 \
-encryption_kid 00000000000000000000000000000000 \
ffmpeg_encrypted.mp4

For test video which has duration of 10 sec, leak is 4 Kb.
For 100 sec video, leak will be 33 Kb. Most likely,
leaked memory will grow linearly to the number of input frames.

Signed-off-by: Vadym Bezdushnyi <vadim.bezdush@gmail.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2 months agoavdevice: use av_gettime_relative() for elapsed time calculations
Marton Balint [Sat, 6 Feb 2021 23:55:25 +0000 (00:55 +0100)]
avdevice: use av_gettime_relative() for elapsed time calculations

av_gettime_relative() is using the monotonic clock therefore more suitable for
elapsed time calculations. Packet timestamps are still kept absolute, although
that should be configurable in the future.

Related to ticket #9089.

Signed-off-by: Marton Balint <cus@passwd.hu>
2 months agoavdevice/timefilter: remove obsolete comments from the docs
Marton Balint [Sat, 6 Feb 2021 10:16:57 +0000 (11:16 +0100)]
avdevice/timefilter: remove obsolete comments from the docs

Also rename the parameters of the function to match with the implementation.

Signed-off-by: Marton Balint <cus@passwd.hu>
2 months agoavfilter/avf_showcqt: use av_gettime_relative() instead of av_gettime()
Marton Balint [Sat, 6 Feb 2021 09:17:30 +0000 (10:17 +0100)]
avfilter/avf_showcqt: use av_gettime_relative() instead of av_gettime()

av_gettime_relative() is using the monotonic clock therefore more suitable for
relative time calculations.

Signed-off-by: Marton Balint <cus@passwd.hu>
2 months agoavcodec/x86: add cfhdenc SIMD
Paul B Mahol [Tue, 9 Feb 2021 18:46:59 +0000 (19:46 +0100)]
avcodec/x86: add cfhdenc SIMD

2 months agoavcodec/options: deprecate avcodec_get_frame_class()
James Almer [Thu, 25 Feb 2021 20:30:28 +0000 (17:30 -0300)]
avcodec/options: deprecate avcodec_get_frame_class()

AVFrame hasn't been a struct defined in libavcodec for a decade now, when
it was moved to libavutil.

Found-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2 months agoavcodec/avrndec: remove max_lowres value
James Almer [Sat, 27 Feb 2021 03:12:18 +0000 (00:12 -0300)]
avcodec/avrndec: remove max_lowres value

The decoder does not support lowres since 9e4225cf7f.

Signed-off-by: James Almer <jamrial@gmail.com>
2 months agoavformat/matroskadec: Add webm file extension
Andreas Rheinhardt [Sat, 28 Dec 2019 03:05:44 +0000 (04:05 +0100)]
avformat/matroskadec: Add webm file extension

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agolavu/tx: do not invert permutes on MDCTs
Lynne [Sat, 27 Feb 2021 03:59:21 +0000 (04:59 +0100)]
lavu/tx: do not invert permutes on MDCTs

2 months agoavformat/concat: Remove unnecessary check
Andreas Rheinhardt [Mon, 22 Feb 2021 08:54:23 +0000 (09:54 +0100)]
avformat/concat: Remove unnecessary check

This code was written when the allocation functions used parameters of
type unsigned. This is no longer true today and therefore we only need
to check whether the multiplication of the array's size stays within
a size_t -- and this can be offloaded to av_realloc_array.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoavformat/spdifenc: Fix leak upon error
Andreas Rheinhardt [Mon, 22 Feb 2021 08:10:40 +0000 (09:10 +0100)]
avformat/spdifenc: Fix leak upon error

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoavformat/wavenc: Fix leak and segfault on reallocation error
Andreas Rheinhardt [Mon, 22 Feb 2021 07:31:50 +0000 (08:31 +0100)]
avformat/wavenc: Fix leak and segfault on reallocation error

Up until now, the wav muxer used a reallocation of the form ptr =
av_realloc(ptr, size); that leaks upon error. Furthermore, if a
failed reallocation happened when writing the trailer, a segfault
would occur due to avio_write(NULL, size) because the muxer only
prints an error message upon allocation error, but does not return
the error.

Moreover setting the pointer to the buffer to NULL on error seems to
be done on purpose in order to record that an error has occured so that
outputting the peak values is no longer attempted. This behaviour has
been retained by simply disabling whether peak data should be written
if an error occurs.

Finally, the reallocation is now done once per peak block and not once
per peak block per channel; it is also done with av_fast_realloc and not
with a linear size increase.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agolavu/tx: invert permutation lookups
Lynne [Sat, 27 Feb 2021 03:11:04 +0000 (04:11 +0100)]
lavu/tx: invert permutation lookups

out[lut[i]] = in[i] lookups were 4.04 times(!) slower than
out[i] = in[lut[i]] lookups for an out-of-place FFT of length 4096.

The permutes remain unchanged for anything but out-of-place monolithic
FFT, as those benefit quite a lot from the current order (it means
there's only 1 lookup necessary to add to an offset, rather than
a full gather).

The code was based around non-power-of-two FFTs, so this wasn't
benchmarked early on.

2 months agolavu/tx: simplify in-place permute search function
Lynne [Sat, 27 Feb 2021 03:19:55 +0000 (04:19 +0100)]
lavu/tx: simplify in-place permute search function

2 months agoavcodec/exrenc: add half-float support
Paul B Mahol [Fri, 26 Feb 2021 23:28:54 +0000 (00:28 +0100)]
avcodec/exrenc: add half-float support

2 months agoavcodec: add missing FF_API_OLD_ENCDEC wrappers to xmm clobber functions
James Almer [Fri, 26 Feb 2021 22:22:42 +0000 (19:22 -0300)]
avcodec: add missing FF_API_OLD_ENCDEC wrappers to xmm clobber functions

Signed-off-by: James Almer <jamrial@gmail.com>
2 months agoavcodec: Add missing FF_API define for libavcodec pix fmt API
Andreas Rheinhardt [Fri, 26 Feb 2021 06:38:33 +0000 (07:38 +0100)]
avcodec: Add missing FF_API define for libavcodec pix fmt API

avcodec_find_best_pix_fmt2 has been deprecated and replaced by
avcodec_find_best_pix_fmt_of_2 in 2a54ae9df8cbc1717b3929222ac75f384e2ff240.
avcodec_find_best_pix_fmt_of_2 and avcodec_get_pix_fmt_loss meanwhile
were deprecated in 617e866e25b72fa5d9f9d6bbcbd7e4bd69e63a54 when these
functions were de facto moved to libavutil; this has been mentioned in
APIchanges in f7a1c5e4d2294a8970ede7f6deb2fe0a64e202a5. Yet the
attribute_deprecated was never set for the latter two functions and they
were not wrapped in an FF_API define. This commit does this.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agofftools/ffmpeg_filter: Don't use deprecated function
Andreas Rheinhardt [Fri, 26 Feb 2021 07:38:26 +0000 (08:38 +0100)]
fftools/ffmpeg_filter: Don't use deprecated function

avcodec_find_best_pix_fmt_of_2 has been moved to libavutil in
617e866e25b72fa5d9f9d6bbcbd7e4bd69e63a54.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agolavu/tx: require output argument to match input for inplace transforms
Lynne [Fri, 26 Feb 2021 04:40:07 +0000 (05:40 +0100)]
lavu/tx: require output argument to match input for inplace transforms

This simplifies some assembly code by a lot, by either saving a branch
or saving an entire duplicated function.

2 months agoavformat/imx: set video stream duration
Paul B Mahol [Thu, 25 Feb 2021 22:04:55 +0000 (23:04 +0100)]
avformat/imx: set video stream duration

2 months agoavcodec/imx: use ff_reget_buffer()
Paul B Mahol [Thu, 25 Feb 2021 20:42:02 +0000 (21:42 +0100)]
avcodec/imx: use ff_reget_buffer()

Also flush internal stuff upon seeking.
This codec is not intra only.

2 months agoavformat/avlanguage: Remove long disabled av_convert_lang_to
Andreas Rheinhardt [Thu, 25 Feb 2021 17:27:50 +0000 (18:27 +0100)]
avformat/avlanguage: Remove long disabled av_convert_lang_to

1582e306a47977b09fddb029b999f99eb03cd485 scheduled it for removal with
libavformat major version 58, but it was never removed.

Reviewed-by: Paul B Mahol <onemda@gmail.com
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoavfilter/lavfutils.h: Don't include avformat.h
Andreas Rheinhardt [Thu, 25 Feb 2021 15:30:01 +0000 (16:30 +0100)]
avfilter/lavfutils.h: Don't include avformat.h

Only lavfutils.c needs avformat.h, not lavfutils.h.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoavcodec/avcodec: Add missing deprecation to AVCodecParser.next
Andreas Rheinhardt [Thu, 25 Feb 2021 00:45:11 +0000 (01:45 +0100)]
avcodec/avcodec: Add missing deprecation to AVCodecParser.next

The whole old next API has been deprecated in commit
7e8eba2d8755962d9dca5eade57bf8f591a73c0c, yet deprecating the next
pointer has been forgotten (the next pointers of other structures are
below the public API delimiter, but such a delimiter doesn't exist for
AVCodecParser).

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoavcodec: unschedule removing some functions with FF_API_COPY_CONTEXT
James Almer [Thu, 25 Feb 2021 20:17:33 +0000 (17:17 -0300)]
avcodec: unschedule removing some functions with FF_API_COPY_CONTEXT

These functions were never deprecated. The merge from commit 6988cf2969
included them by mistake.

Found-by: mkver
Signed-off-by: James Almer <jamrial@gmail.com>
2 months agoRevert "avcodec/options: add missing FF_API_COPY_CONTEXT checks"
James Almer [Thu, 25 Feb 2021 20:15:21 +0000 (17:15 -0300)]
Revert "avcodec/options: add missing FF_API_COPY_CONTEXT checks"

This reverts commit 0191f2d29c2a62b8699ac75f09708187e943814c.

These functions were never deprecated. The merge from commit 6988cf2969
included them by mistake.

Found-by: mkver
Signed-off-by: James Almer <jamrial@gmail.com>
2 months agodoc/encoders: Add documentation for the GIF encoder
Derek Buitenhuis [Sun, 21 Feb 2021 13:11:37 +0000 (13:11 +0000)]
doc/encoders: Add documentation for the GIF encoder

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2 months agoavcodec/gifenc: Only write frame palette entries that actually used
Derek Buitenhuis [Thu, 4 Feb 2021 16:44:44 +0000 (16:44 +0000)]
avcodec/gifenc: Only write frame palette entries that actually used

GIF palette entries are not compressed, and writing 256 entries,
which can be up to every frame, uses a significant amount of
space, especially in extreme cases, where palettes can be very
small.

Example, first six seconds of Tears of Steel, palette generated
with libimagequant, 320x240 resolution, and with transparency
optimization + per frame palette:

    * Before patch: 186765 bytes
    * After patch: 77895 bytes

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2 months agoavcodec/gifenc: Add global_palette option
Derek Buitenhuis [Sat, 20 Feb 2021 17:22:51 +0000 (17:22 +0000)]
avcodec/gifenc: Add global_palette option

This option will disable the writing of the global palette in global
GIF header if it is set to 0, causing only the frame-level palette
to ever be written.

This will be useful later on when further frame-level palette
optimizations are introduced.

The default is 1, which maintains current default behavior.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2 months agoavformat/wavenc: Improve unsupported codec error messages
Andreas Rheinhardt [Thu, 25 Feb 2021 06:37:54 +0000 (07:37 +0100)]
avformat/wavenc: Improve unsupported codec error messages

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoavfilter/vf_vif: add support for more formats
Paul B Mahol [Thu, 25 Feb 2021 15:36:08 +0000 (16:36 +0100)]
avfilter/vf_vif: add support for more formats

2 months agoavfilter/vf_vif: simplify case comparing same inputs
Paul B Mahol [Thu, 25 Feb 2021 14:52:33 +0000 (15:52 +0100)]
avfilter/vf_vif: simplify case comparing same inputs

2 months agotests/api-band-test: simplify code
Anton Khirnov [Wed, 27 Jan 2021 10:08:29 +0000 (11:08 +0100)]
tests/api-band-test: simplify code

2 months agoHandle AVID MJPEG streams directly in the MJPEG decoder.
Anton Khirnov [Sat, 12 Dec 2020 14:09:10 +0000 (15:09 +0100)]
Handle AVID MJPEG streams directly in the MJPEG decoder.

AVID streams - currently handled by the AVRN decoder - can be (depending
on extradata contents) either MJPEG or raw video. To decode the MJPEG
variant, the AVRN decoder currently instantiates a MJPEG decoder
internally and forwards decoded frames to the caller (possibly after
cropping them).

This is suboptimal, because the AVRN decoder does not forward all the
features of the internal MJPEG decoder, such as direct rendering.
Handling such forwarding in a full and generic manner would be quite
hard, so it is simpler to just handle those streams in the MJPEG decoder
directly.

The AVRN decoder, which now handles only the raw streams, can now be
marked as supporting direct rendering.

This also removes the last remaining internal use of the obsolete
decoding API.

2 months agoavfilter/vf_vif.c: fix build warning for [-Wmain]
Guo, Yejun [Thu, 25 Feb 2021 06:38:12 +0000 (14:38 +0800)]
avfilter/vf_vif.c: fix build warning for [-Wmain]

src/libavfilter/vf_vif.c: In function ‘process_frame’:
src/libavfilter/vf_vif.c:542:20: warning: ‘main’ is usually a function [-Wmain]
     AVFrame *out, *main = NULL, *ref = NULL;
                    ^~~~

Signed-off-by: Guo, Yejun <yejun.guo@intel.com>
2 months agoavfilter/vf_ssim.c: fix build warning for [-Wmain]
Guo, Yejun [Thu, 25 Feb 2021 06:38:11 +0000 (14:38 +0800)]
avfilter/vf_ssim.c: fix build warning for [-Wmain]

The build warning message:
src/libavfilter/vf_ssim.c: In function ‘ssim_plane_16bit’:
src/libavfilter/vf_ssim.c:246:24: warning: ‘main’ is usually a function [-Wmain]
         const uint8_t *main = td->main_data[c];
                        ^~~~
src/libavfilter/vf_ssim.c: In function ‘ssim_plane’:
src/libavfilter/vf_ssim.c:289:24: warning: ‘main’ is usually a function [-Wmain]
         const uint8_t *main = td->main_data[c];
                        ^~~~

Signed-off-by: Guo, Yejun <yejun.guo@intel.com>
2 months agolavc/lscrdec: use ff_reget_buffer()
Anton Khirnov [Wed, 24 Feb 2021 08:38:22 +0000 (09:38 +0100)]
lavc/lscrdec: use ff_reget_buffer()

It is simpler and more efficient.

Suggested-by: James Almer <jamrial@gmail.com>
2 months agotests/fate/apng: add a test for APNG_DISPOSE_OP_PREVIOUS
Anton Khirnov [Tue, 16 Feb 2021 20:19:38 +0000 (21:19 +0100)]
tests/fate/apng: add a test for APNG_DISPOSE_OP_PREVIOUS

2 months agopngdec: fix and simplify apng reference handling
Anton Khirnov [Sun, 14 Feb 2021 15:37:33 +0000 (16:37 +0100)]
pngdec: fix and simplify apng reference handling

Current code is very confused and confusing. It uses two different
reference frames - "previous" and "last" - when only one is really
necessary. It also confuses the two, leading to incorrect output with
APNG_DISPOSE_OP_PREVIOUS mode.

Fixes #9017.

2 months agolavc/lscrdec: drop unapplicable private capabilities
Anton Khirnov [Sun, 14 Feb 2021 15:12:39 +0000 (16:12 +0100)]
lavc/lscrdec: drop unapplicable private capabilities

FF_CODEC_CAP_ALLOCATE_PROGRESS makes no sense because the decoder does
not support frame threading.
FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM makes no sense because the decoder
does not handle skip_frame.

2 months agolavc: split LSCR decoder out of PNG decoder
Anton Khirnov [Sun, 14 Feb 2021 14:50:10 +0000 (15:50 +0100)]
lavc: split LSCR decoder out of PNG decoder

It shares very little code with pngdec, so keeping them together only
makes the code harder to read.