]> git.sesse.net Git - ffmpeg/log
ffmpeg
3 years agoavcodec/h2645_parse: skip empty NAL units earlier
James Almer [Wed, 12 Aug 2020 17:46:35 +0000 (14:46 -0300)]
avcodec/h2645_parse: skip empty NAL units earlier

No point in trying to parse nonexistent header bits.

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/h2645_parse: always return 0 on successful h{264,evc}_parse_nal_header()...
James Almer [Wed, 12 Aug 2020 17:26:50 +0000 (14:26 -0300)]
avcodec/h2645_parse: always return 0 on successful h{264,evc}_parse_nal_header() calls

HEVC NALs are no longer being skipped based on their nuh_layer_id
value since ad326379c6.

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/decode: move the ff_decode_frame_props() prototype to the proper header
James Almer [Sun, 16 Aug 2020 14:43:48 +0000 (11:43 -0300)]
avcodec/decode: move the ff_decode_frame_props() prototype to the proper header

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavformat/libsrt: close listen fd in listener mode
Nicolas Sugino [Fri, 14 Aug 2020 01:18:26 +0000 (22:18 -0300)]
avformat/libsrt: close listen fd in listener mode

In listener mode the first fd is not closed when libsrt_close() is called
because it is overwritten by the new accept fd.  Added the listen_fd to the
context to properly close it when libsrt_close() is called.

Fixes trac ticket #8372.

Signed-off-by: Nicolas Sugino <nsugino@3way.com.ar>
Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agoavformat/siff: Reject audio packets without audio stream
Michael Niedermayer [Tue, 11 Aug 2020 12:41:13 +0000 (14:41 +0200)]
avformat/siff: Reject audio packets without audio stream

Fixes: Assertion failure
Fixes: 24612/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-6600899842277376.fuzz
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agolibavformat/r3d.c: Fix Use-of-uninitialized-value in filename.
Thierry Foucu [Wed, 19 Aug 2020 22:51:02 +0000 (15:51 -0700)]
libavformat/r3d.c: Fix Use-of-uninitialized-value in filename.

While reading the filename tag, it may return a EOF and we are still
copying the file with uninitialized value.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agolibavcodec/proresdec2: Setup qmat_chroma according to RDD36
Harry Mallon [Wed, 19 Aug 2020 20:32:47 +0000 (21:32 +0100)]
libavcodec/proresdec2: Setup qmat_chroma according to RDD36

Signed-off-by: Harry Mallon <harry.mallon@codex.online>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoffplay: do not set redundant channel count on abuffersink.
Nicolas George [Fri, 14 Aug 2020 09:25:09 +0000 (11:25 +0200)]
ffplay: do not set redundant channel count on abuffersink.

3 years agolavfi/buffersink: add a summary documentation of the API.
Nicolas George [Fri, 14 Aug 2020 09:21:39 +0000 (11:21 +0200)]
lavfi/buffersink: add a summary documentation of the API.

3 years agolavfi/buffersink: clearly document that the Params struct are unused.
Nicolas George [Fri, 14 Aug 2020 08:56:50 +0000 (10:56 +0200)]
lavfi/buffersink: clearly document that the Params struct are unused.

3 years agoavutil/video_enc_params: fix code comment
leozhang [Thu, 13 Aug 2020 03:57:05 +0000 (11:57 +0800)]
avutil/video_enc_params: fix code comment

Reviewed-by: Zhao Zhili <zhilizhao@tencent.com>
Signed-off-by: leozhang <leozhang@qiyi.com>
3 years agolavc/libkvazaar: export encoded frame stats
Jun Zhao [Sun, 26 Jul 2020 02:43:10 +0000 (10:43 +0800)]
lavc/libkvazaar: export encoded frame stats

Export choosen pict_type and qp.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
3 years agoavfilter/formats: Avoid allocations when merging formats and samplerates
Andreas Rheinhardt [Thu, 13 Aug 2020 19:20:22 +0000 (21:20 +0200)]
avfilter/formats: Avoid allocations when merging formats and samplerates

This is the analogue of cfc65520324ae640299bd321ef88ae76dcee6f78 for
formats and samplerates; in contrast to said commit, one can avoid
allocating a new array for formats as well (the complications of the
generic channel layouts made this impossible for channel layouts).

This commit also starts to move the line continuation '\' chars to the
left to keep them in line with MERGE_REF() as well as with the 80 lines
limit.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/formats: Make check for buffer overflow redundant
Andreas Rheinhardt [Thu, 13 Aug 2020 16:31:04 +0000 (18:31 +0200)]
avfilter/formats: Make check for buffer overflow redundant

and remove the redundant check.

This check for whether the allocated buffer is sufficient has been added
in commit 1cbf7fb4345a3e5b7791d483241bf4759bde4ece (merging commit
5775a1832c4165e6acc1d307004b38701bb463f4). It is not sufficient to
detect invalid input lists (namely lists with duplicates); its only use
is to avoid buffer overflows. And this can be achieved by simpler means:
Make sure that one allocates space for so many elements as the outer loop
ranges over and break out of the inner loop if a match has been found.
For valid input without duplicates, no further match will be found anyway.

This change will temporarily make the allocated formats array larger
than before and larger than necessary; this will be fixed in a later
commit that avoids the allocation altogether.

If a check for duplicates in the lists is deemed necessary, it should be
done properly somewhere else.

Finally, the error message that is removed in this commit used
__FUNCTION__, which is a GCC extension (C99 added __func__ for this).
So this commit removes a warning when compiling in -pedantic mode.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/af_afir: Fix leak of AVFilterChannelLayout in case of error
Andreas Rheinhardt [Fri, 7 Aug 2020 02:58:56 +0000 (04:58 +0200)]
avfilter/af_afir: Fix leak of AVFilterChannelLayout in case of error

If an error happens between the allocation of an AVFilterChannelLayout
and its usage (which involves attaching said object to a more permanent
object), the channel layout array leaks. This can simply be fixed by
making sure that nothing is between the allocation and the
aforementioned usage.

Fixes Coverity issue #1250334.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoswresample/rematrix: handle 22.2 as a 9 channel layout
Jan Ekström [Thu, 6 Aug 2020 21:35:55 +0000 (00:35 +0300)]
swresample/rematrix: handle 22.2 as a 9 channel layout

This is as far as 22.2 follows the same channel order as
WaveFormatExtensible's channel mask (and the AV_CH_* defines).

After LFE2 the side channels would follow, but that offset of
one stops us from utilizing them without further tweaks.

This change was verified by using swresample to downmix to 5.1,
and then feeding that to WASAPI.

3 years agoavformat/mpegts: only reset timestamps to NOPTS for DVB teletext
Jan Ekström [Wed, 12 Aug 2020 21:27:09 +0000 (00:27 +0300)]
avformat/mpegts: only reset timestamps to NOPTS for DVB teletext

While having the possibility of non-NOPTS values that can suddenly
jump in time due to adjustments to match PCR is not nice for DVB
subtitles, apparently the parser for this format bases its behavior on
whether the packets' timestamps are NOPTS or not. Thus while we can
adjust timestamps, we should exclude DVB subtitles from the timestamp
unsetting logic.

Fixes #8844

3 years agoavformat/mpeg: Check avio_read() return value in get_pts()
Michael Niedermayer [Fri, 14 Aug 2020 23:07:44 +0000 (01:07 +0200)]
avformat/mpeg: Check avio_read() return value in get_pts()

Found-by: Thierry Foucu <tfoucu@gmail.com>
Fixes: Use-of-uninitialized-value
Reviewed-by: Thierry Foucu <tfoucu@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agotools/target_dec_fuzzer: Adjust threshold for DST
Michael Niedermayer [Sun, 16 Aug 2020 18:04:08 +0000 (20:04 +0200)]
tools/target_dec_fuzzer: Adjust threshold for DST

Fixes: Timeout (too long -> 3sec)
Fixes: 24239/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DST_fuzzer-5189061015502848
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>
3 years agoavformat/mlvdec: Only store dimensions after having validated them
Andreas Rheinhardt [Mon, 10 Aug 2020 00:33:19 +0000 (02:33 +0200)]
avformat/mlvdec: Only store dimensions after having validated them

Otherwise it might happen that invalid dimensions are used when reading
a video packet; this might lead to undefined overflow.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/mlvdec: Don't leak open AVIOContexts on error
Andreas Rheinhardt [Mon, 10 Aug 2020 00:19:35 +0000 (02:19 +0200)]
avformat/mlvdec: Don't leak open AVIOContexts on error

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/mlvdec: Check for existence of AVIOContext before using it
Andreas Rheinhardt [Sun, 9 Aug 2020 23:32:42 +0000 (01:32 +0200)]
avformat/mlvdec: Check for existence of AVIOContext before using it

The mlv demuxer supports input split into multiple files; if invalid
data is encountered when parsing one of the subsequent files, that file
is closed. But at this point some index entries belonging to this file
might already have been added. In this case, the read_packet function
might try to use the AVIOContext (which is NULL) to read data which will
of course crash. This commit fixes this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/hls: Use av_init_pkt() directly
Andreas Rheinhardt [Fri, 14 Aug 2020 20:59:57 +0000 (22:59 +0200)]
avformat/hls: Use av_init_pkt() directly

and remove reset_packet(). The packet's data pointer is already zeroed,
so the only thing that reset_packet() does that av_init_pkt() doesn't is
redundant.

Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/hls: Remove redundant resetting of AVPacket
Andreas Rheinhardt [Fri, 14 Aug 2020 20:36:22 +0000 (22:36 +0200)]
avformat/hls: Remove redundant resetting of AVPacket

av_read_frame() already returns blank packets on error.

Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/hls: Fix memleak when url is empty
Andreas Rheinhardt [Fri, 14 Aug 2020 20:06:54 +0000 (22:06 +0200)]
avformat/hls: Fix memleak when url is empty

Fixes Coverity ID 1465888.

Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoFATE: fix copy & paste for minterpolate test
Limin Wang [Fri, 14 Aug 2020 00:30:49 +0000 (08:30 +0800)]
FATE: fix copy & paste for minterpolate test

Reported-by: Nicolas George <george@nsup.org>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
3 years agodoc/encoders: Add all options for JPEG2000 encoder
Gautam Ramakrishnan [Mon, 10 Aug 2020 16:44:00 +0000 (22:14 +0530)]
doc/encoders: Add all options for JPEG2000 encoder

This patch updates the documentation by adding all options
for JPEG2000 encoder.

Revised-by: Gyan Doshi <ffmpeg@gyani.pro>
3 years agoavcodec/v4l2_context: return EAGAIN to signal full buffers
Andriy Gelman [Sun, 16 Aug 2020 21:39:13 +0000 (17:39 -0400)]
avcodec/v4l2_context: return EAGAIN to signal full buffers

Return proper error when frame buffers are full. This path is triggered
on the DragonBoard 410c since the encoding API change in commit
827d6fe73d2f5472c1c2.

Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
Reviewed-by: Mark Thompson <sw@jkqxz.net>
3 years agoavcodec/utils: calculate frame number of HEVC if the framerate > 30FPS
Limin Wang [Sun, 12 Jul 2020 14:19:31 +0000 (22:19 +0800)]
avcodec/utils: calculate frame number of HEVC if the framerate > 30FPS

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
3 years agodoc/general: fix ADPCM typos
Paul B Mahol [Sun, 16 Aug 2020 14:23:54 +0000 (16:23 +0200)]
doc/general: fix ADPCM typos

3 years agoavformat/av1dec: don't update temporal_unit_size after it's no longer used
James Almer [Sun, 16 Aug 2020 02:27:44 +0000 (23:27 -0300)]
avformat/av1dec: don't update temporal_unit_size after it's no longer used

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavdevice/xcbgrab: check return values of xcb query functions
Moritz Barsnick [Wed, 5 Aug 2020 12:06:53 +0000 (14:06 +0200)]
avdevice/xcbgrab: check return values of xcb query functions

Fixes #7312, segmentation fault on close of X11 server

xcb_query_pointer_reply() and xcb_get_geometry_reply() can return NULL
if e.g. the X server closes or the connection is lost. This needs to
be checked in order to cleanly exit, because the returned pointers are
dereferenced later.

Signed-off-by: Moritz Barsnick <barsnick@gmx.net>
Reviewed-by: Andriy Gelman <andriy.gelman@gmail.com>
3 years agoavcodec/bsf: improve the doxy for av_bsf_flush()
James Almer [Mon, 10 Aug 2020 18:03:46 +0000 (15:03 -0300)]
avcodec/bsf: improve the doxy for av_bsf_flush()

Mention an example scenario where the function should be used.

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/qsvenc_h264: add missing atsc_a53.h include
James Almer [Sat, 15 Aug 2020 17:43:11 +0000 (14:43 -0300)]
avcodec/qsvenc_h264: add missing atsc_a53.h include

Regression since 0de01da1d2

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavformat/av1dec: inline obu_read_data() and obu_prefetch() into obu_get_packet()
James Almer [Fri, 14 Aug 2020 03:43:17 +0000 (00:43 -0300)]
avformat/av1dec: inline obu_read_data() and obu_prefetch() into obu_get_packet()

They don't really help making the demuxer more readable.

Reviewed-by: Guangxin Xu <oddstone@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec: move ff_alloc_a53_sei() to atsc_53
James Almer [Sun, 9 Aug 2020 17:01:16 +0000 (14:01 -0300)]
avcodec: move ff_alloc_a53_sei() to atsc_53

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/hevc_sei: use ff_parse_a53_cc() to parse A53 Closed Captions
James Almer [Sun, 9 Aug 2020 20:53:38 +0000 (17:53 -0300)]
avcodec/hevc_sei: use ff_parse_a53_cc() to parse A53 Closed Captions

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/h264_sei: use ff_parse_a53_cc() to parse A53 Closed Captions
James Almer [Fri, 7 Aug 2020 19:04:24 +0000 (16:04 -0300)]
avcodec/h264_sei: use ff_parse_a53_cc() to parse A53 Closed Captions

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/libdav1d: add support for A53 Closed Captions
James Almer [Fri, 7 Aug 2020 19:05:13 +0000 (16:05 -0300)]
avcodec/libdav1d: add support for A53 Closed Captions

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec: split off A53 Closed Caption parsing code into its own file
James Almer [Fri, 7 Aug 2020 19:03:29 +0000 (16:03 -0300)]
avcodec: split off A53 Closed Caption parsing code into its own file

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/libsvtav1: remove unneeded svt_av1_enc_deinit_handle()
Limin Wang [Sat, 1 Aug 2020 05:51:59 +0000 (13:51 +0800)]
avcodec/libsvtav1: remove unneeded svt_av1_enc_deinit_handle()

It's for FF_CODEC_CAP_INIT_CLEANUP flag.

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
3 years agoavcodec/mpeg12enc: support mpeg2 encoder const level
Limin Wang [Sun, 2 Aug 2020 13:07:04 +0000 (21:07 +0800)]
avcodec/mpeg12enc: support mpeg2 encoder const level

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
3 years agoavcodec: extend CFHD description
Paul B Mahol [Fri, 14 Aug 2020 08:50:07 +0000 (10:50 +0200)]
avcodec: extend CFHD description

3 years agodoc/general: move Cineform HD and Canopus codecs to correct section
Paul B Mahol [Fri, 14 Aug 2020 08:44:48 +0000 (10:44 +0200)]
doc/general: move Cineform HD and Canopus codecs to correct section

3 years agoavformat/av1dec: fix return value on some code paths
James Almer [Fri, 14 Aug 2020 03:09:43 +0000 (00:09 -0300)]
avformat/av1dec: fix return value on some code paths

If avio_read() returns a value of bytes read that's lower than the
expected, return an error instead. And when there are zero bytes in
the prefetch buffer, return 0 in order for the frame merge bsf to
drain all potentially buffered packets.

Missed by mistake when amending and committing 9a7bdb6d71.

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavformat/av1dec: add missing preprocessor wrappers to annexb and obu demuxers
James Almer [Thu, 13 Aug 2020 17:06:44 +0000 (14:06 -0300)]
avformat/av1dec: add missing preprocessor wrappers to annexb and obu demuxers

Ensure the modules are compiled only if enabled.

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavformat/av1dec: add low-overhead bitstream format
Xu Guangxin [Thu, 13 Aug 2020 06:51:02 +0000 (14:51 +0800)]
avformat/av1dec: add low-overhead bitstream format

It's defined in Section 5.2, used by netflix.

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/av1_parse: use macro for MAX_OBU_HEADER_SIZE
Xu Guangxin [Mon, 10 Aug 2020 09:34:30 +0000 (17:34 +0800)]
avcodec/av1_parse: use macro for MAX_OBU_HEADER_SIZE

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agodnn_backend_tf.c: fix build issue for tensorflow backend
Guo, Yejun [Thu, 13 Aug 2020 06:48:11 +0000 (14:48 +0800)]
dnn_backend_tf.c: fix build issue for tensorflow backend

Signed-off-by: Guo, Yejun <yejun.guo@intel.com>
3 years agoavfilter/formats: Avoid allocations when merging channel layouts
Andreas Rheinhardt [Wed, 12 Aug 2020 20:31:50 +0000 (22:31 +0200)]
avfilter/formats: Avoid allocations when merging channel layouts

When one merges two AVFilterChannelLayouts structs, there is no need to
allocate a new one. Instead one can reuse one of the two given ones.
If one does this, one also doesn't need to update the references of the
AVFilterChannelLayouts that is reused. Therefore this commit reuses the
structure with the higher refcount.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/formats: Fix heap-buffer overflow when merging channel layouts
Andreas Rheinhardt [Thu, 13 Aug 2020 02:02:26 +0000 (04:02 +0200)]
avfilter/formats: Fix heap-buffer overflow when merging channel layouts

The channel layouts accepted by ff_merge_channel_layouts() are of two
types: Ordinary channel layouts and generic channel layouts. These are
layouts that match all layouts with a certain number of channels.
Therefore parsing these channel layouts is not done in one go; instead
first the intersection of the ordinary layouts of the first input
list of channel layouts with the ordinary layouts of the second list is
determined, then the intersection of the ordinary layouts of the first
one and the generic layouts of the second one etc. In order to mark the
ordinary channel layouts that have already been matched as used they are
zeroed. The inner loop that does this is as follows:

for (j = 0; j < b->nb_channel_layouts; j++) {
    if (a->channel_layouts[i] == b->channel_layouts[j]) {
        ret->channel_layouts[ret_nb++] = a->channel_layouts[i];
        a->channel_layouts[i] = b->channel_layouts[j] = 0;
    }
}

(Here ret->channel_layouts is the array containing the intersection of
the two input arrays.)

Yet the problem with this code is that after a match has been found, the
loop continues the search with the new value a->channel_layouts[i].
The intention of zeroing these elements was to make sure that elements
already paired at this stage are ignored later. And while they are indeed
ignored when pairing ordinary and generic channel layouts later, it has
the exact opposite effect when pairing ordinary channel layouts.

To see this consider the channel layouts A B C D E and E D C B A. In the
first round, A and A will be paired and added to ret->channel_layouts.
In the second round, the input arrays are 0 B C D E and E D C B 0.
At first B and B will be matched and zeroed, but after doing so matching
continues, but this time it will search for 0, which will match with the
last entry of the second array. ret->channel_layouts now contains A B 0.
In the third round, C 0 0 will be added to ret->channel_layouts etc.
This gives a quadratic amount of elements, yet the amount of elements
allocated for said array is only the sum of the sizes of a and b.

This issue can e.g. be reproduced by
ffmpeg -f lavfi -i anullsrc=cl=7.1 \
-af 'aformat=cl=mono|stereo|2.1|3.0|4.0,aformat=cl=4.0|3.0|2.1|stereo|mono' \
-f null -

The fix is easy: break out of the inner loop after having found a match.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agocbs: Mention all codecs in unit type comment
Mark Thompson [Mon, 27 Jul 2020 16:32:16 +0000 (17:32 +0100)]
cbs: Mention all codecs in unit type comment

3 years agoRevert "lavfi/avfiltergraph: add check before free the format"
Andreas Rheinhardt [Fri, 7 Aug 2020 02:28:07 +0000 (04:28 +0200)]
Revert "lavfi/avfiltergraph: add check before free the format"

This reverts commit f156f4ab2317f22bfef33c7eaead0d5d5f162903.

The checks added by said commit are nonsense because they did not help
in case ff_merge_samplerates() or ff_merge_formats() returned NULL
while freeing one of its arguments: Said freeing does not change
the local variables of can_merge_formats().

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/formats: Simplify cleanup for ff_merge_* functions
Andreas Rheinhardt [Fri, 7 Aug 2020 02:10:05 +0000 (04:10 +0200)]
avfilter/formats: Simplify cleanup for ff_merge_* functions

Now that the output's refs-array is only allocated once, it is NULL in
any error case and therefore needn't be freed at all; Instead an
av_assert1() has been added to guarantee it to be NULL.

Furthermore, it is unnecessary to av_freep(&ptr) when ptr == NULL.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/formats: Leave lists' ownership unchanged upon merge failure
Andreas Rheinhardt [Fri, 7 Aug 2020 01:41:18 +0000 (03:41 +0200)]
avfilter/formats: Leave lists' ownership unchanged upon merge failure

ff_merge_formats(), ff_merge_samplerates() and ff_merge_channel_layouts()
share common semantics: If merging succeeds, a non-NULL pointer is
returned and both input lists (of type AVFilterFormats resp.
AVFilterChannelLayouts) are to be treated as if they had been freed;
the owners of the input parameters (if any) become owners of the
returned list. If merging does not succeed, NULL is returned and both
input lists are supposed to be unchanged.

The problem is that the functions did not abide by these semantics:
In case of reallocation failure, it is possible for these functions
to return NULL after having already freed one of the two input list.
This happens because sometimes the refs-array of the destined output
gets reallocated twice to its final size and if the second of these
reallocations fails, the first of the two inputs has already been freed
and its refs updated to point to the destined output which in this case
will be freed immediately so that all of the already updated pointers
are now dangling. This leads to use-after-frees and memory corruptions
lateron (when these owners get cleaned up, the lists they own get
unreferenced). Should the input lists don't have owners at all, the
caller (namely can_merge_formats() in avfiltergraph.c) thinks that both
the input lists are unchanged and need to be freed, leading to a double
free.

The solution to this is simple: Don't reallocate twice; do it just once.
This also saves a reallocation.

This commit fixes the issue behind Coverity issue #1452636. It might
also make Coverity realize that the issue has been fixed.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/formats: Schedule avfilter_make_format64_list() for removal
Andreas Rheinhardt [Fri, 7 Aug 2020 22:37:46 +0000 (00:37 +0200)]
avfilter/formats: Schedule avfilter_make_format64_list() for removal

Despite its name, this function is not part of the public API, as
formats.h, the header containing its declaration, is a private header.
The formats API was once public API, but that changed long ago
(b74a1da49db5ebed51aceae6cacc2329288a92c1, the commit scheduling it to
become private, is from 2012). That avfilter_make_format64_list() was
forgotten is probably a result of the confusion resulting from the
libav-ffmpeg split.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/avf_showcqt: Mark arrays as static const
Andreas Rheinhardt [Fri, 7 Aug 2020 22:24:06 +0000 (00:24 +0200)]
avfilter/avf_showcqt: Mark arrays as static const

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/formats: Remove ff_make_formatu64_list()
Andreas Rheinhardt [Fri, 7 Aug 2020 15:21:58 +0000 (17:21 +0200)]
avfilter/formats: Remove ff_make_formatu64_list()

It is unused since 8cbb055760c725d0fb99fb759caabb5f4e37e340 and it
actually coincides with avfilter_make_format64_list().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agolavc/snowenc: Expose an option to set the rc_eq expression
Alexander Strasser [Fri, 7 Aug 2020 19:40:40 +0000 (21:40 +0200)]
lavc/snowenc: Expose an option to set the rc_eq expression

Snow uses the ratecontrol module, but does not expose a way to set
the rc_eq expression. The default expression, set in the ratecontrol
module, will always be used.

Make it possible to set rc_eq by adding an AVOption to snowenc.

The option definition is mostly a copy from the mpegvideo common
options definition of rc_eq (libavcodec/mpegvideo.h), with some
minor style adjustments to be closer to the other snowenc option
initializer expressions.

Signed-off-by: Alexander Strasser <eclipse7@gmx.net>
3 years agolavc/aac_ac3_parser: fix potential overflow when averaging bitrate
Alexander Strasser [Fri, 17 Jul 2020 18:51:43 +0000 (20:51 +0200)]
lavc/aac_ac3_parser: fix potential overflow when averaging bitrate

The new code is analog to how it's done in our mpegaudio parser.

Acked-by: Jun Zhao <barryjzhao@tencent.com>
Signed-off-by: Alexander Strasser <eclipse7@gmx.net>
3 years agolavf/url: rewrite ff_make_absolute_url() using ff_url_decompose().
Nicolas George [Wed, 29 Jul 2020 22:02:10 +0000 (00:02 +0200)]
lavf/url: rewrite ff_make_absolute_url() using ff_url_decompose().

Also add and update some tests.

Change the semantic a little, because for filesytem paths
symlinks complicate things.
See the comments in the code for detail.

Fix trac tickets #8813 and 8814.

3 years agolavf/url: add ff_url_decompose().
Nicolas George [Wed, 29 Jul 2020 12:39:20 +0000 (14:39 +0200)]
lavf/url: add ff_url_decompose().

3 years agoavformat/mxfenc: Write color metadata to MXF
Harry Mallon [Thu, 6 Aug 2020 14:27:48 +0000 (15:27 +0100)]
avformat/mxfenc: Write color metadata to MXF

Writes color_primaries, color_trc and color_space to mxf
headers. ULs are from https://registry.smpte-ra.org/ site.

Signed-off-by: Harry Mallon <harry.mallon@codex.online>
3 years agoavcodec/sheervideo: reduce size of vlc tables to normal values
Paul B Mahol [Wed, 12 Aug 2020 06:14:08 +0000 (08:14 +0200)]
avcodec/sheervideo: reduce size of vlc tables to normal values

3 years agodnn: add backend options when load the model
Guo, Yejun [Fri, 7 Aug 2020 06:32:55 +0000 (14:32 +0800)]
dnn: add backend options when load the model

different backend might need different options for a better performance,
so, add the parameter into dnn interface, as a preparation.

Signed-off-by: Guo, Yejun <yejun.guo@intel.com>
3 years agodnn_backend_native_layer_mathunary: add round support
Mingyu Yin [Mon, 10 Aug 2020 11:05:42 +0000 (19:05 +0800)]
dnn_backend_native_layer_mathunary: add round support

Signed-off-by: Mingyu Yin <mingyu.yin@intel.com>
Reviewed-by: Guo, Yejun <yejun.guo@intel.com>
3 years agoavcodec/libsvtav1: fix copy and paste error
Limin Wang [Sat, 1 Aug 2020 04:34:29 +0000 (12:34 +0800)]
avcodec/libsvtav1: fix copy and paste error

Reviewed-by: Mark Thompson <sw@jkqxz.net>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
3 years agoavformat/ty: Remove write-only array and variable
Andreas Rheinhardt [Tue, 11 Aug 2020 00:28:16 +0000 (02:28 +0200)]
avformat/ty: Remove write-only array and variable

Up until now, the TiVo demuxer parse an array of SEQ entries, yet it has
never ever made any use of them. In fact, parse_master, the function
parsing said table, only influenced the outside world in three ways: Via
an excessive amount of error message in case a certain parameter is not
what it expected; via an allocation (the aforementioned write-only
array); and by setting a certain parameter (ty->cur_chunk_pos), but that
parameter is always overwritten before it is used (it is overwritten
in get_chunk() on success and if get_chunk() fails, the error is
returned to the caller anyway). So remove the array and the function
used to parse it.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agotools/target_dec_fuzzer: Adjust threshold for AGM
Michael Niedermayer [Mon, 10 Aug 2020 21:58:06 +0000 (23:58 +0200)]
tools/target_dec_fuzzer: Adjust threshold for AGM

Fixes: Timeout (142sec -> 2sec)
Fixes: 24426/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AGM_fuzzer-5639724379930624
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/agm: Mark fill_pixels() as av_always_inline
Michael Niedermayer [Mon, 10 Aug 2020 21:47:29 +0000 (23:47 +0200)]
avcodec/agm: Mark fill_pixels() as av_always_inline

Speedup from 275sec to 142sec
Testcase: 24426/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AGM_fuzzer-5639724379930624

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agodoc/general: mark that CFHD have encoder now
Paul B Mahol [Tue, 11 Aug 2020 10:25:33 +0000 (12:25 +0200)]
doc/general: mark that CFHD have encoder now

3 years agodoc/general: mention AGM codecs
Paul B Mahol [Tue, 11 Aug 2020 10:31:25 +0000 (12:31 +0200)]
doc/general: mention AGM codecs

3 years agoavfilter/vf_xfade: check that fps between inputs are valid
Paul B Mahol [Tue, 11 Aug 2020 08:55:16 +0000 (10:55 +0200)]
avfilter/vf_xfade: check that fps between inputs are valid

3 years agoavcodec/cfhdenc: mark filter as always inline
Paul B Mahol [Tue, 11 Aug 2020 07:56:19 +0000 (09:56 +0200)]
avcodec/cfhdenc: mark filter as always inline

3 years agoavcodec/cfhdenc: optimize writting of small runcodes
Paul B Mahol [Mon, 10 Aug 2020 07:35:10 +0000 (09:35 +0200)]
avcodec/cfhdenc: optimize writting of small runcodes

3 years agoavcodec/cfhdenc: improve quality vs size ratio
Paul B Mahol [Tue, 11 Aug 2020 07:49:24 +0000 (09:49 +0200)]
avcodec/cfhdenc: improve quality vs size ratio

3 years agoavformat/argo_asf: strip file extension from name
Zane van Iperen [Fri, 7 Aug 2020 23:44:48 +0000 (09:44 +1000)]
avformat/argo_asf: strip file extension from name

Only when the user hasn't manually specified one.
Matches the original files more closely.

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
3 years agoavformat/argo_asf: add name option
Zane van Iperen [Fri, 7 Aug 2020 23:17:51 +0000 (09:17 +1000)]
avformat/argo_asf: add name option

Reviewed-by: Alexander Strasser <eclipse7@gmx.net>
Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
3 years agoavformat/argo_asf: add version_major and version_minor options
Zane van Iperen [Wed, 5 Aug 2020 02:15:30 +0000 (12:15 +1000)]
avformat/argo_asf: add version_major and version_minor options

Reviewed-by: Alexander Strasser <eclipse7@gmx.net>
Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
3 years agoavformat/argo_asf: don't check file version
Zane van Iperen [Sun, 9 Aug 2020 22:37:47 +0000 (08:37 +1000)]
avformat/argo_asf: don't check file version

It has no bearing on structure. Determined by looking at the ASF
files from several Argonaut games:
  - FX Fighter,
  - Croc,
  - Croc 2,
  - The Emperor's New Groove, and
  - Disney's Aladdin in Nasira's Revenge

The only versions that appear are 1.1, 1.2, and 2.1, and their
structure is identical.

Reviewed-by: Alexander Strasser <eclipse7@gmx.net>
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
3 years agoavformat/argo_asf: add games to version list
Zane van Iperen [Sun, 9 Aug 2020 22:20:48 +0000 (08:20 +1000)]
avformat/argo_asf: add games to version list

Reviewed-by: Alexander Strasser <eclipse7@gmx.net>
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
3 years agoavformat/mpegts: Don't leave context in inconsistent state upon error
Andreas Rheinhardt [Mon, 10 Aug 2020 12:20:58 +0000 (14:20 +0200)]
avformat/mpegts: Don't leave context in inconsistent state upon error

Up until now, opening a section filter works as follows: A filter is
opened and (on success) attached to the MpegTSContext. Then a buffer for
said filter is allocated and upon success attached to the section
filter; on error, the filter is simply freed without removing it from
the MpegTSContext, leaving the latter in an inconsistent state. This
leads to use-after-frees lateron.

This commit fixes this by allocating the buffer first; the filter is
only opened if the buffer could be successfully allocated.

Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/jpeg2000dec: Check remaining data in packed_headers_stream before use
Michael Niedermayer [Sat, 1 Aug 2020 23:15:34 +0000 (01:15 +0200)]
avcodec/jpeg2000dec: Check remaining data in packed_headers_stream before use

Fixes: out of array read
Fixes: 24487/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-5165847820369920
Fixes: 24636/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-5700973918683136
Fixes: 24683/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-6202883897556992
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 agoFATE/dnn: add unit test for dnn avgpool layer
Ting Fu [Sun, 9 Aug 2020 16:33:14 +0000 (00:33 +0800)]
FATE/dnn: add unit test for dnn avgpool layer

'make fate-dnn-layer-avgpool' to run the test

Signed-off-by: Ting Fu <ting.fu@intel.com>
Reviewed-by: Guo, Yejun <yejun.guo@intel.com>
3 years agodnn/native: add native support for avg_pool
Ting Fu [Sun, 9 Aug 2020 16:33:13 +0000 (00:33 +0800)]
dnn/native: add native support for avg_pool

Not support pooling strides in channel dimension yet.

Signed-off-by: Ting Fu <ting.fu@intel.com>
Reviewed-by: Guo, Yejun <yejun.guo@intel.com>
3 years agoavformat/hlsenc: write temp file for append single file by encryption mode
Steven Liu [Wed, 22 Jul 2020 09:15:29 +0000 (17:15 +0800)]
avformat/hlsenc: write temp file for append single file by encryption mode

fix ticket: 8783
Because in single file by encryption mode, it cannot get the last one
block of the file, it need ff_format_io_close for get full file size,
then hlsenc can get the total size of the encryption content,
so write the content into temp file first, and get the temp file content
append the temp file content into append to single file, then hlsenc can
get the correct file/content size and offset.

Signed-off-by: Steven Liu <liuqi05@kuaishou.com>
3 years agoavformat/hls: support avio_seek in encryption mode
Steven Liu [Wed, 22 Jul 2020 09:15:28 +0000 (17:15 +0800)]
avformat/hls: support avio_seek in encryption mode

Signed-off-by: Steven Liu <liuqi05@kuaishou.com>
3 years agokmsgrab: Add more supported formats
Mark Thompson [Sat, 1 Aug 2020 17:57:35 +0000 (18:57 +0100)]
kmsgrab: Add more supported formats

X2RGB10 tested on both Intel Gen9 and AMD Polaris 11.  NV12 tested on
Intel Gen9 only - since it has multiple planes, this requires GetFB2.

Also add some comments to split the list up a bit.

3 years agodoc/indevs: Note improved behaviour of kmsgrab with Linux 5.7
Mark Thompson [Sun, 5 Jul 2020 15:49:46 +0000 (16:49 +0100)]
doc/indevs: Note improved behaviour of kmsgrab with Linux 5.7

3 years agokmsgrab: Don't require the user to set framebuffer format
Mark Thompson [Sun, 5 Jul 2020 15:49:45 +0000 (16:49 +0100)]
kmsgrab: Don't require the user to set framebuffer format

This is provided by GetFB2, but we still need the option for cases where
that isn't available.

3 years agokmsgrab: Use GetFB2 if available
Mark Thompson [Sun, 5 Jul 2020 15:49:44 +0000 (16:49 +0100)]
kmsgrab: Use GetFB2 if available

The most useful feature here is the ability to automatically extract the
framebuffer format and modifiers.  It also makes support for multi-plane
framebuffers possible, though none are added to the format table in this
patch.

This requires libdrm 2.4.101 (from April 2020) to build, so it includes a
configure check to allow compatibility with existing distributions.  Even
with libdrm support, it still won't do anything at runtime if you are
running Linux < 5.7 (before June 2020).

3 years agokmsgrab: Refactor and clean error cases
Mark Thompson [Sun, 5 Jul 2020 15:49:43 +0000 (16:49 +0100)]
kmsgrab: Refactor and clean error cases

3 years agoavformat/sierravmd: Don't return packets for non-existing stream
Andreas Rheinhardt [Wed, 5 Aug 2020 23:21:38 +0000 (01:21 +0200)]
avformat/sierravmd: Don't return packets for non-existing stream

It leads to an assert in ff_read_packet().

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/vividas: Check allocation for success
Andreas Rheinhardt [Wed, 5 Aug 2020 22:59:37 +0000 (00:59 +0200)]
avformat/vividas: Check allocation for success

Reviewed-by: Zane van Iperen <zane@zanevaniperen.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/vividas: Check return value before storing it in smaller type
Andreas Rheinhardt [Wed, 5 Aug 2020 22:44:55 +0000 (00:44 +0200)]
avformat/vividas: Check return value before storing it in smaller type

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/cfhd: improve SampleIndex tag output
Paul B Mahol [Sun, 9 Aug 2020 11:26:55 +0000 (13:26 +0200)]
avcodec/cfhd: improve SampleIndex tag output

This tag is used for jumping to different channels in bitstream.

3 years agoavcodec/cfhd: log version tags too
Paul B Mahol [Sun, 9 Aug 2020 11:21:34 +0000 (13:21 +0200)]
avcodec/cfhd: log version tags too

3 years agoavcodec/cfhd: read prescale table tag
Paul B Mahol [Sun, 9 Aug 2020 11:02:46 +0000 (13:02 +0200)]
avcodec/cfhd: read prescale table tag

Currently unused. Remove prescale shift tag as it
is not part of this codec.

3 years agoavcodec/cfhd: use init_get_bits8()
Paul B Mahol [Sun, 9 Aug 2020 09:54:52 +0000 (11:54 +0200)]
avcodec/cfhd: use init_get_bits8()

3 years agoavcodec/cfhd: reindent
Paul B Mahol [Sun, 9 Aug 2020 09:48:28 +0000 (11:48 +0200)]
avcodec/cfhd: reindent