ffmpeg.git
7 months agoavcodec/flac_parser: Cosmetics
Andreas Rheinhardt [Sun, 6 Oct 2019 05:01:20 +0000 (07:01 +0200)]
avcodec/flac_parser: Cosmetics

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
7 months agoavcodec/flac_parser: Don't leave stale pointer in memory
Andreas Rheinhardt [Sun, 6 Oct 2019 05:01:19 +0000 (07:01 +0200)]
avcodec/flac_parser: Don't leave stale pointer in memory

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
7 months agoavcodec/flac_parser: Don't modify size of the input buffer
Andreas Rheinhardt [Sun, 6 Oct 2019 05:01:18 +0000 (07:01 +0200)]
avcodec/flac_parser: Don't modify size of the input buffer

When flushing, MAX_FRAME_HEADER_SIZE bytes (always zero) are supposed to
be written to the fifo buffer in order to be able to check the rest of
the buffer for frame headers. It was intended to write these by writing
a small buffer of size MAX_FRAME_HEADER_SIZE to the buffer. But the way
it was actually done ensured that this did not happen:

First, it would be checked whether the size of the input buffer was zero,
in which case it buf_size would be set to MAX_FRAME_HEADER_SIZE and
read_end would be set to indicate that MAX_FRAME_HEADER_SIZE bytes need
to be written. Then it would be made sure that there is enough space in
the fifo for the data to be written. Afterwards the data is written. The
check used here is for whether buf_size is zero or not. But if it was
zero initially, it is MAX_FRAME_HEADER_SIZE now, so that not the
designated buffer for writing MAX_FRAME_HEADER_SIZE is written; instead
the padded buffer (from the stack of av_parser_parse2()) is used. This
works because AV_INPUT_BUFFER_PADDING_SIZE >= MAX_FRAME_HEADER_SIZE.
Lateron, buf_size is set to zero again.

Given that since 7edbd536, the actual amount of data read is no longer
automatically equal to buf_size, it is completely unnecessary to modify
buf_size at all. Moreover, modifying it is dangerous: Some allocations
can fail and because buf_size is never reset to zero in this codepath,
the parser might return a value > 0 on flushing.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
7 months agoavcodec/flac_parser: Remove superfluous checks
Andreas Rheinhardt [Sun, 6 Oct 2019 05:01:17 +0000 (07:01 +0200)]
avcodec/flac_parser: Remove superfluous checks

For a parser, the input buffer is always != NULL: In case of flushing,
the indicated size of the input buffer will be zero and the input buffer
will point to a zeroed buffer of size 0 + AV_INPUT_BUFFER_PADDING.
Therefore one does not need to check for whether said buffer is NULL or
not.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
7 months agoavcodec/flac_parser: Fix number of buffered headers
Andreas Rheinhardt [Sun, 6 Oct 2019 05:01:16 +0000 (07:01 +0200)]
avcodec/flac_parser: Fix number of buffered headers

Only decrement the number of buffered headers if a header has actually
been freed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
7 months agoavcodec/flac_parser: Fix off-by-one error
Andreas Rheinhardt [Sun, 6 Oct 2019 05:01:15 +0000 (07:01 +0200)]
avcodec/flac_parser: Fix off-by-one error

The flac parser uses a fifo to buffer its data. Consequently, when
searching for sync codes of flac packets, one needs to take care of
the possibility of wraparound. This is done by using an optimized start
code search that works on each of the continuous buffers separately and
by explicitly checking whether the last pre-wrap byte and the first
post-wrap byte constitute a valid sync code.

Moreover, the last MAX_FRAME_HEADER_SIZE - 1 bytes ought not to be searched
for (the start of) a sync code because a header that might be found in this
region might not be completely available. These bytes ought to be searched
lateron when more data is available or when flushing.

Unfortunately there was an off-by-one error in the calculation of the
length to search of the post-wrap buffer: It was too large, because the
calculation was based on the amount of bytes available in the fifo from
the last pre-wrap byte onwards. This meant that a header might be
parsed twice (once prematurely and once regularly when more data is
available); it could also mean that an invalid header will be treated as
valid (namely if the length of said invalid header is
MAX_FRAME_HEADER_SIZE and the invalid byte that will be treated as the
last byte of this potential header happens to be the right CRC-8).

Should a header be parsed twice, the second instance will be the best child
of the first instance; the first instance's score will be
FLAC_HEADER_BASE_SCORE - FLAC_HEADER_CHANGED_PENALTY ( = 3) higher than
the second instance's score. So the frame belonging to the first
instance will be output and it will be done as a zero length frame (the
difference of the header's offset and the child's offset). This has
serious consequences when flushing, as returning a zero length buffer
signals to the caller that no more data will be output; consequently the
last frames not yet output will be dropped.

Furthermore, a "sample/frame number mismatch in adjacent frames" warning
got output when returning the zero-length frame belonging to the first
header, because the child's sample/frame number of course didn't match
the expected sample frame/number given its parent.

filter/hdcd-mix.flac from the FATE-suite was affected by this (the last
frame was omitted) which is the reason why several FATE-tests needed to
be updated.

Fixes ticket #5937.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
7 months agoavcodec/flac_parser: Don't allocate array separately
Andreas Rheinhardt [Sun, 6 Oct 2019 05:01:14 +0000 (07:01 +0200)]
avcodec/flac_parser: Don't allocate array separately

The FLACHeaderMarker structure contained a pointer to an array of int;
said array was always allocated and freed at the same time as its
referencing FLACHeaderMarker; the pointer was never modified to point to
a different array and each FLACHeaderMarker had its own unique array.
Furthermore, all these arrays had a constant size. Therefore include
this array in the FLACHeaderMarker struct.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
7 months agoavcodec/flac_parser: Use native endianness when possible
Andreas Rheinhardt [Sun, 6 Oct 2019 05:01:13 +0000 (07:01 +0200)]
avcodec/flac_parser: Use native endianness when possible

FLAC sync codes contain a byte equal to 0xFF and so the function that
searches for sync codes first searched for this byte. It did this by
checking four bytes at once; these bytes have been read via AV_RB32, but
the test works just as well with native endianness.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
7 months agoavformat/flac_picture: Avoid allocation of AVIOContext
Andreas Rheinhardt [Sun, 6 Oct 2019 05:01:12 +0000 (07:01 +0200)]
avformat/flac_picture: Avoid allocation of AVIOContext

Put an AVIOContext whose lifetime doesn't extend beyond the function
where it is allocated on the stack instead of allocating and freeing it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
7 months agodoc/formats: Update documentation for chromaprint
Andriy Gelman [Sun, 6 Oct 2019 05:49:47 +0000 (01:49 -0400)]
doc/formats: Update documentation for chromaprint

Silence detection can only be set with algorithm version 3.

Reviewed-by: Gyan Doshi <ffmpeg@gyani.pro>
7 months agoavcodec/filter: Remove extra '; ' outside of functions
Andreas Rheinhardt [Mon, 7 Oct 2019 00:10:30 +0000 (02:10 +0200)]
avcodec/filter: Remove extra '; ' outside of functions

They are not allowed outside of functions. Fixes the warning
"ISO C does not allow extra ‘;’ outside of a function [-Wpedantic]"
when compiling with GCC and -pedantic.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
7 months agoavfilter/af_adelay: add option which changes how unset channels are delayed
Paul B Mahol [Mon, 7 Oct 2019 16:02:50 +0000 (18:02 +0200)]
avfilter/af_adelay: add option which changes how unset channels are delayed

Fixes #8032.

7 months agoavfilter/formats: guard against double free
Paul B Mahol [Mon, 7 Oct 2019 15:26:59 +0000 (17:26 +0200)]
avfilter/formats: guard against double free

7 months agoavfilter/vf_normalize: typedef all structs
Paul B Mahol [Mon, 7 Oct 2019 10:17:14 +0000 (12:17 +0200)]
avfilter/vf_normalize: typedef all structs

7 months agoavfilter/vf_showpalette: remove timeline flag
Paul B Mahol [Mon, 7 Oct 2019 10:07:00 +0000 (12:07 +0200)]
avfilter/vf_showpalette: remove timeline flag

This filter changes output size and thus can not have support
for timeline.

7 months agoavfilter/af_afftfilt: fix possible invalid memory access
Paul B Mahol [Mon, 7 Oct 2019 09:37:05 +0000 (11:37 +0200)]
avfilter/af_afftfilt: fix possible invalid memory access

7 months agoavfilter/vf_nnedi: fix possible double free
Paul B Mahol [Mon, 7 Oct 2019 09:10:45 +0000 (11:10 +0200)]
avfilter/vf_nnedi: fix possible double free

7 months agodoc/filters: fix few more typos
Paul B Mahol [Sun, 6 Oct 2019 18:31:43 +0000 (20:31 +0200)]
doc/filters: fix few more typos

7 months agoavformat/subtitles: Check nb_subs in ff_subtitles_queue_finalize()
Michael Niedermayer [Fri, 4 Oct 2019 15:10:38 +0000 (17:10 +0200)]
avformat/subtitles: Check nb_subs in ff_subtitles_queue_finalize()

Fixes: null pointer dereference
Fixes: 17828/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5645915116797952
Fixes: Ticket8147

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
7 months agoavcodec/h2645_parse: Use av_fast_realloc() for nals array
Michael Niedermayer [Sat, 5 Oct 2019 16:19:39 +0000 (18:19 +0200)]
avcodec/h2645_parse: Use av_fast_realloc() for nals array

Fixes: Timeout (17sec ->281ms)
Fixes: 17833/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_H264_fuzzer-5638346914660352

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
7 months agoavcodec/cinepakenc: Fix invalid shifts
Andreas Rheinhardt [Sun, 6 Oct 2019 05:23:14 +0000 (07:23 +0200)]
avcodec/cinepakenc: Fix invalid shifts

Fixes: left shift of 1 by 31 places cannot be represented in type 'int'.
Affected the FATE-tests vsynth1-cinepak, vsynth2-cinepak and
vsynth_lena-cinepak. Also fixes ticket #8220.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
7 months agoavformat/mpjpegdec: Avoid allocation of AVIOContext
Andreas Rheinhardt [Sun, 6 Oct 2019 05:01:11 +0000 (07:01 +0200)]
avformat/mpjpegdec: Avoid allocation of AVIOContext

Put an AVIOContext whose lifetime doesn't extend beyond the function where
it is allocated on the stack instead of allocating and freeing it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
7 months agoavformat/matroskaenc: use r_frame_rate as fallback to set a track's DefaultDuration
James Almer [Tue, 1 Oct 2019 15:58:20 +0000 (12:58 -0300)]
avformat/matroskaenc: use r_frame_rate as fallback to set a track's DefaultDuration

Signed-off-by: James Almer <jamrial@gmail.com>
7 months agoavfilter/vf_avgblur: add support for commands
Paul B Mahol [Sun, 6 Oct 2019 13:44:20 +0000 (15:44 +0200)]
avfilter/vf_avgblur: add support for commands

7 months agoavfilter/vf_gblur: add support for commands
Paul B Mahol [Sun, 6 Oct 2019 13:23:55 +0000 (15:23 +0200)]
avfilter/vf_gblur: add support for commands

7 months agoavfilter: add anlms filter
Paul B Mahol [Thu, 3 Oct 2019 16:09:59 +0000 (18:09 +0200)]
avfilter: add anlms filter

8 months agodoc/codecs: Update documentation for flags/flags2
Jun Zhao [Fri, 4 Oct 2019 12:43:27 +0000 (20:43 +0800)]
doc/codecs: Update documentation for flags/flags2

Update documentation for flags/flags2

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
8 months agolavc/options_table: Correct the flags for AVCodecContext.flags2
Jun Zhao [Fri, 4 Oct 2019 12:32:00 +0000 (20:32 +0800)]
lavc/options_table: Correct the flags for AVCodecContext.flags2

Correct the flags for AVCodecContext.flags2.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
8 months agoavcodec/decode: fix indentation
Jun Zhao [Fri, 4 Oct 2019 12:22:15 +0000 (20:22 +0800)]
avcodec/decode: fix indentation

fix indentation.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Reviewed-by: Gyan Doshi <ffmpeg@gyani.pro>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
8 months agoavutil/common: Fix underflow for ROUNDED_DIV with unsigned integer
Mengye Lv [Wed, 2 Oct 2019 02:30:45 +0000 (10:30 +0800)]
avutil/common: Fix underflow for ROUNDED_DIV with unsigned integer

When used ROUNDED_DIV(a,b), if a is unsigned integer zero, it's
will lead to an underflow issue(it called unsigned integer
wrapping).

Fixes #8062

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Mengye Lv <mengyelv@tencent.com>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
8 months agoavformat/matroskadec: don't rescale mastering display values
James Almer [Thu, 3 Oct 2019 23:52:20 +0000 (20:52 -0300)]
avformat/matroskadec: don't rescale mastering display values

Simplifies code.

Signed-off-by: James Almer <jamrial@gmail.com>
8 months agoavformat/mpeg: better fix for MLP versus PCM-DVD misdetection
Paul B Mahol [Tue, 1 Oct 2019 09:34:09 +0000 (11:34 +0200)]
avformat/mpeg: better fix for MLP versus PCM-DVD misdetection

8 months agoFATE/dnn: fix stack buffer overflow
Zhao Zhili [Tue, 1 Oct 2019 06:36:49 +0000 (14:36 +0800)]
FATE/dnn: fix stack buffer overflow

Signed-off-by: Pedro Arthur <bygrandao@gmail.com>
8 months agoswscale: Fix AltiVec/VSX build with recent GCC
Daniel Kolesa [Wed, 7 Aug 2019 17:39:07 +0000 (19:39 +0200)]
swscale: Fix AltiVec/VSX build with recent GCC

The argument to vec_splat_u16 must be a literal. By making the
function always inline and marking the arguments const, gcc can
turn those into literals, and avoid build errors like:

swscale_vsx.c:165:53: error: argument 1 must be a 5-bit signed literal

Fixes #7861.

Signed-off-by: Daniel Kolesa <daniel@octaforge.org>
Signed-off-by: Lauri Kasanen <cand@gmx.com>
8 months agoswscale: Replace illegal vector keyword usage in altivec code
Daniel Kolesa [Wed, 7 Aug 2019 17:39:06 +0000 (19:39 +0200)]
swscale: Replace illegal vector keyword usage in altivec code

While this technically compiles in current ffmpeg, this is only
because ffmpeg is compiled in strict ISO C mode, which disables
the builtin 'vector' keyword for AltiVec/VSX. Instead this gets
replaced with a macro inside altivec.h, which defines vector to
be actually __vector, which accepts random types.

Normally, the vector keyword should be used only with plain
scalar non-typedef types, such as unsigned int. But we have the
vec_(s|u)(8|16|32) macros, which can be used in a portable manner,
in util_altivec.h in libavutil.

This is also consistent with other AltiVec/VSX code elsewhere in
the tree.

Fixes #7861.

Signed-off-by: Daniel Kolesa <daniel@octaforge.org>
Signed-off-by: Lauri Kasanen <cand@gmx.com>
8 months agoavformat/matroskadec: Fix demuxing ProRes
Andreas Rheinhardt [Sat, 28 Sep 2019 17:54:25 +0000 (19:54 +0200)]
avformat/matroskadec: Fix demuxing ProRes

The structure of a ProRes frame in mov/mp4 is that of a typical atom:
First a 32 bit BE size field, then a tag detailling the content. Said
size field includes the eight bytes of the atom header.

This header is actually redundant, as the size of the atom is already
known from the containing atom. It is therefore stripped away when muxed
into Matroska and so the Matroska demuxer has to recreate upon demuxing.
But it did not account for the fact that the size field includes the
size of the header and this can lead to problems when a decoder uses the
in-band size field.

Fixes ticket #8210.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
8 months agoavcodec/tiff: Set FF_CODEC_CAP_INIT_CLEANUP
Michael Niedermayer [Wed, 2 Oct 2019 19:14:17 +0000 (21:14 +0200)]
avcodec/tiff: Set FF_CODEC_CAP_INIT_CLEANUP

Fixes: memleaks
Fixes: 17813/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-5145600206569472

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>
8 months agoavcodec/vc1_block: Fix invalid left shift in vc1_decode_p_mb()
Michael Niedermayer [Wed, 2 Oct 2019 17:53:44 +0000 (19:53 +0200)]
avcodec/vc1_block: Fix invalid left shift in vc1_decode_p_mb()

Fixes: left shift of negative value -6
Fixes: 17810/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC1_fuzzer-5638541240958976

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>
8 months agoavcodec/wmaprodec: Check if there is a stream
Michael Niedermayer [Wed, 2 Oct 2019 17:26:51 +0000 (19:26 +0200)]
avcodec/wmaprodec: Check if there is a stream

Fixes: null pointer dereference
Fixes: signed integer overflow: 512 * 2147483647 cannot be represented in type 'int'
Fixes: 17809/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_XMA1_fuzzer-5634409947987968

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>
8 months agoavformat/aiffenc: Remove wrong and redundant check
Andreas Rheinhardt [Wed, 2 Oct 2019 04:04:12 +0000 (06:04 +0200)]
avformat/aiffenc: Remove wrong and redundant check

The check "if (!pb->seekable & AVIO_SEEKABLE_NORMAL)" is wrong, because
! has higher precendence than &. But it is also redundant, because this
part of the code is only ever reached when the AVIO_SEEKABLE_NORMAL flag
is set for pb. So simply remove the check.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Reviewed-by: Matthieu Bouron <matthieu.bouron@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
8 months agoavformat/aiffenc: Fix potential memleak upon failure
Andreas Rheinhardt [Wed, 2 Oct 2019 04:04:11 +0000 (06:04 +0200)]
avformat/aiffenc: Fix potential memleak upon failure

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Reviewed-by: Matthieu Bouron <matthieu.bouron@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
8 months agoavformat/aiffenc: Use standard packet list functions
Andreas Rheinhardt [Wed, 2 Oct 2019 04:04:10 +0000 (06:04 +0200)]
avformat/aiffenc: Use standard packet list functions

Up until now, aiffenc didn't rely on the standard functions for adding
an element to a linked list and freeing the list, but instead
reimplemented them. This has been changed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Reviewed-by: Matthieu Bouron <matthieu.bouron@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
8 months agodoc/filters: fix typo
Paul B Mahol [Thu, 3 Oct 2019 15:58:46 +0000 (17:58 +0200)]
doc/filters: fix typo

8 months agoavfilter/vsrc_sierpinski: add triangle type
Paul B Mahol [Thu, 3 Oct 2019 12:21:39 +0000 (14:21 +0200)]
avfilter/vsrc_sierpinski: add triangle type

8 months agoavfilter: add av_cold where it is missing
Paul B Mahol [Thu, 3 Oct 2019 10:09:07 +0000 (12:09 +0200)]
avfilter: add av_cold where it is missing

8 months agoavfilter/f_streamselect: fix memleaks of pad names
Paul B Mahol [Thu, 3 Oct 2019 09:23:23 +0000 (11:23 +0200)]
avfilter/f_streamselect: fix memleaks of pad names

8 months agoavfilter/af_amix: fix filtering if specified weights are negative
Paul B Mahol [Thu, 3 Oct 2019 08:27:56 +0000 (10:27 +0200)]
avfilter/af_amix: fix filtering if specified weights are negative

8 months agoavfilter/setpts: switch to activate
Paul B Mahol [Mon, 30 Sep 2019 11:53:59 +0000 (13:53 +0200)]
avfilter/setpts: switch to activate

Also properly handle EOF timestamps.
Fixes #6833.

8 months agoavcodec/g2meet: Check for end of input in jpg_decode_block()
Michael Niedermayer [Mon, 9 Sep 2019 18:30:32 +0000 (20:30 +0200)]
avcodec/g2meet: Check for end of input in jpg_decode_block()

Fixes: Timeout (100sec -> 0.7sec)
Fixes: 8668/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_G2M_fuzzer-5174143888130048

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
8 months agoavcodec/g2meet: Check if adjusted pixel was on the stack
Michael Niedermayer [Mon, 9 Sep 2019 18:05:09 +0000 (20:05 +0200)]
avcodec/g2meet: Check if adjusted pixel was on the stack

This basically checks if a pixel that was coded with prediction
and residual could have been stored using a previous case.
This avoids basically a string of 0 symbols stored in less than
50 bytes to hit a O(n²) codepath.

Fixes: Timeout (too slow to wait -> immediately)
Fixes: 8668/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_G2M_fuzzer-4895946310680576

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
8 months agoavfilter/vf_elbg: stop leaking frame on error
Paul B Mahol [Wed, 2 Oct 2019 08:54:45 +0000 (10:54 +0200)]
avfilter/vf_elbg: stop leaking frame on error

8 months agoavformat/electronicarts: If no packet has been read at the end do not treat it as...
Michael Niedermayer [Mon, 30 Sep 2019 21:42:41 +0000 (23:42 +0200)]
avformat/electronicarts: If no packet has been read at the end do not treat it as if theres a packet

Fixes: Assertion failure
Fixes: 17770/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5700606668308480

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>
8 months agolavc/x264: Use FF_CODEC_CAP_INIT_THREADSAFE if x264 is new.
Carl Eugen Hoyos [Sun, 25 Aug 2019 14:12:28 +0000 (16:12 +0200)]
lavc/x264: Use FF_CODEC_CAP_INIT_THREADSAFE if x264 is new.

Usage of strtok() was removed from x264, see also b02490a4

8 months agolavfi/movie: Use filter thread count for decoding threads.
Carl Eugen Hoyos [Sun, 25 Aug 2019 16:42:02 +0000 (18:42 +0200)]
lavfi/movie: Use filter thread count for decoding threads.

Fixes ticket #7542.

8 months agocmdutils: trailing options may be ignored
Lou Logan [Fri, 27 Sep 2019 20:19:24 +0000 (12:19 -0800)]
cmdutils: trailing options may be ignored

Signed-off-by: Lou Logan <lou@lrcd.com>
Signed-off-by: mypopy <mypopy@gmail.com>
8 months agoavfilter/vf_drawbox: implement process_command
Paul B Mahol [Tue, 1 Oct 2019 18:17:50 +0000 (20:17 +0200)]
avfilter/vf_drawbox: implement process_command

8 months agoavfilter/vf_drawbox: reduce code duplication
Paul B Mahol [Tue, 1 Oct 2019 17:22:17 +0000 (19:22 +0200)]
avfilter/vf_drawbox: reduce code duplication

8 months agolavf/avio: Print https warning also for avio_find_protocol_name().
Carl Eugen Hoyos [Wed, 25 Sep 2019 09:32:57 +0000 (11:32 +0200)]
lavf/avio: Print https warning also for avio_find_protocol_name().

Helps to fix ticket #8197.

8 months agoavfilter/f_streamselect: add check case when nothing is done
Paul B Mahol [Tue, 1 Oct 2019 16:46:20 +0000 (18:46 +0200)]
avfilter/f_streamselect: add check case when nothing is done

Fixes #7955.

8 months agoavfilter/vsink_nullsink: cosmetics
Paul B Mahol [Tue, 1 Oct 2019 12:57:41 +0000 (14:57 +0200)]
avfilter/vsink_nullsink: cosmetics

8 months agoavfilter/copy: add forgotten check
Paul B Mahol [Tue, 1 Oct 2019 12:55:43 +0000 (14:55 +0200)]
avfilter/copy: add forgotten check

8 months agoavfilter/asink_anullsink: cosmetics
Paul B Mahol [Tue, 1 Oct 2019 12:38:58 +0000 (14:38 +0200)]
avfilter/asink_anullsink: cosmetics

8 months agoavfilter/vf_copy: check for error cases and handle them
Paul B Mahol [Tue, 1 Oct 2019 11:45:29 +0000 (13:45 +0200)]
avfilter/vf_copy: check for error cases and handle them

8 months agoavfilter/af_acopy: check for error cases and handle them
Paul B Mahol [Tue, 1 Oct 2019 11:42:18 +0000 (13:42 +0200)]
avfilter/af_acopy: check for error cases and handle them

8 months agoavfilter/vf_showpalette: fix small cosmetics issue
Paul B Mahol [Tue, 1 Oct 2019 11:24:35 +0000 (13:24 +0200)]
avfilter/vf_showpalette: fix small cosmetics issue

8 months agoavfilter/vf_alphamere: use the name 's' for the pointer to the private context
Paul B Mahol [Tue, 1 Oct 2019 11:17:43 +0000 (13:17 +0200)]
avfilter/vf_alphamere: use the name 's' for the pointer to the private context

This is shorter and consistent across filters.

8 months agoavcodec/dxv: Check op_offset in dxv_decompress_yo()
Michael Niedermayer [Mon, 30 Sep 2019 06:02:11 +0000 (08:02 +0200)]
avcodec/dxv: Check op_offset in dxv_decompress_yo()

Fixes: signed integer overflow: -2147483648 - 8 cannot be represented in type 'int'
Fixes: 17745/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DXV_fuzzer-5734628463214592

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>
8 months agoavcodec/utils: Check sample_rate before opening the decoder
Michael Niedermayer [Fri, 27 Sep 2019 10:31:39 +0000 (12:31 +0200)]
avcodec/utils: Check sample_rate before opening the decoder

Fixes: signed integer overflow: 2 * -1306460384 cannot be represented in type 'int'
Fixes: 17685/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AAC_fuzzer-5747390337777664
Fixes: 17688/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_INTERPLAY_ACM_fuzzer-5739287210885120
Fixes: 17699/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_INTERPLAY_ACM_fuzzer-5678394531905536
Fixes: 17738/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TAK_fuzzer-5763415733174272
Fixes: 17746/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_BINKAUDIO_RDFT_fuzzer-5703008159006720

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
8 months agoavcodec/aptx: Fix multiple shift anomalies
Michael Niedermayer [Fri, 27 Sep 2019 16:36:16 +0000 (18:36 +0200)]
avcodec/aptx: Fix multiple shift anomalies

Fixes: left shift of negative value -24576
Fixes: 17719/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APTX_fuzzer-5710508002377728

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>
8 months agoavfilter/vf_photosensitivity: fix memleak
Paul B Mahol [Mon, 30 Sep 2019 18:37:25 +0000 (20:37 +0200)]
avfilter/vf_photosensitivity: fix memleak

8 months agolibavfilter: add photosensitivity filter
Vladimir Panteleev [Fri, 8 Mar 2019 06:47:42 +0000 (06:47 +0000)]
libavfilter: add photosensitivity filter

8 months agoavfilter: add scroll video filter
Paul B Mahol [Sun, 29 Sep 2019 10:43:32 +0000 (12:43 +0200)]
avfilter: add scroll video filter

8 months agoavfilter/af_join: cosmetics
Paul B Mahol [Mon, 30 Sep 2019 14:52:52 +0000 (16:52 +0200)]
avfilter/af_join: cosmetics

8 months agoavfilter/af_join: use av_asprintf()
Paul B Mahol [Mon, 30 Sep 2019 14:45:31 +0000 (16:45 +0200)]
avfilter/af_join: use av_asprintf()

8 months agoavfilter/split: use av_asprintf()
Paul B Mahol [Mon, 30 Sep 2019 14:39:39 +0000 (16:39 +0200)]
avfilter/split: use av_asprintf()

8 months agoavfilter/trim: drop all audio frames instead of asserting
Paul B Mahol [Mon, 30 Sep 2019 10:57:26 +0000 (12:57 +0200)]
avfilter/trim: drop all audio frames instead of asserting

8 months agoavfilter/f_metadata: do not memleak expr
Paul B Mahol [Mon, 30 Sep 2019 10:24:06 +0000 (12:24 +0200)]
avfilter/f_metadata: do not memleak expr

8 months agoavfilter/f_metadata: add ends_with() function for comparing ends of strings
Paul B Mahol [Mon, 30 Sep 2019 10:13:46 +0000 (12:13 +0200)]
avfilter/f_metadata: add ends_with() function for comparing ends of strings

8 months agolavf/utils: support duration estimate method dump
Jun Zhao [Sun, 29 Sep 2019 03:58:43 +0000 (11:58 +0800)]
lavf/utils: support duration estimate method dump

add new function duration_estimate_name to dump duration estimate
method, it's will help to debug some duration issue.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
8 months agolavf/utils: Cosmetics: fix indentation for estimate_timings
Jun Zhao [Sat, 28 Sep 2019 03:01:54 +0000 (11:01 +0800)]
lavf/utils: Cosmetics: fix indentation for estimate_timings

fix indentation for estimate_timings when dump start_time/duartion.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
8 months agolavf/utils: correct the duration estimation method for nut demuxer
Jun Zhao [Sat, 28 Sep 2019 02:45:31 +0000 (10:45 +0800)]
lavf/utils: correct the duration estimation method for nut demuxer

in fact, nut demuxer use the PTS for duration estimation.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
8 months agolavf/nutdec: add logging context to log
Jun Zhao [Sat, 28 Sep 2019 02:21:11 +0000 (10:21 +0800)]
lavf/nutdec: add logging context to log

Add logging context to log, it's will help debuging.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
8 months agolavf/utils: change the log level to warning if can't get duration
Jun Zhao [Thu, 26 Sep 2019 05:16:24 +0000 (13:16 +0800)]
lavf/utils: change the log level to warning if can't get duration

change the log level to warning if can't get duration, it's will help
to debug some duration issue

Signed-off-by: vacingfang <vacingfang@tencent.com>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
8 months agotools/target_dec_fuzzer: Adjust VP7 threshold
Michael Niedermayer [Sat, 28 Sep 2019 23:53:43 +0000 (01:53 +0200)]
tools/target_dec_fuzzer: Adjust VP7 threshold

Fixes: Timeout (110sec -> 10sec)
Fixes: 17705/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP7_fuzzer-5765834135306240

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>
8 months agoavcodec/qtrleenc: fix undefined behaviour
Paul B Mahol [Wed, 25 Sep 2019 15:18:32 +0000 (17:18 +0200)]
avcodec/qtrleenc: fix undefined behaviour

Fixes #7991.

8 months agodoc/examples/muxing: fix underflow in duration of encoded streams
Paul B Mahol [Fri, 27 Sep 2019 09:41:38 +0000 (11:41 +0200)]
doc/examples/muxing: fix underflow in duration of encoded streams

Now they are exactly 10 seconds long.

Fixes #5684.

8 months agoavcodec/cbs_av1: Make overread check more robust
Andreas Rheinhardt [Wed, 18 Sep 2019 03:26:01 +0000 (05:26 +0200)]
avcodec/cbs_av1: Make overread check more robust

When performing a comparison of a signed int and an unsigned int, the
signed int is first converted to an unsigned int, so that negative
values are being treated as big, positive values. This can become a
problem in an overread check, namely when an overread already happened.
So change the type of the variable containing the amount of bits that
need to be left to signed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
8 months agoavcodec/cbs_h2645: Fix potential out-of-bounds array access
Andreas Rheinhardt [Wed, 18 Sep 2019 03:25:58 +0000 (05:25 +0200)]
avcodec/cbs_h2645: Fix potential out-of-bounds array access

The maximum allowed index for an array access is FF_ARRAY_ELEMS - 1; yet
the current code allowed FF_ARRAY_ELEMS. This wasn't dangerous in practice,
as parameter sets with invalid ids were already filtered out during
reading.

Found via PVS-Studio (see ticket #8156).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
8 months agoavcodec/fitsdec: fix use of uninitialised values
James Almer [Sun, 29 Sep 2019 02:11:06 +0000 (23:11 -0300)]
avcodec/fitsdec: fix use of uninitialised values

header.data_max and header.data_min are not necessarely set on all decoding scenarios.

Fixes a Valgrind reported regression since cfa193779103c97bbfc28273a0ab12c114b6786d.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
8 months agoavformat/utils: Remove unnecessary initializations
Andreas Rheinhardt [Fri, 20 Sep 2019 20:39:16 +0000 (22:39 +0200)]
avformat/utils: Remove unnecessary initializations

Up until now, read_frame_internal always initialized the packet it
received. But since the recent changes to ff_read_packet, this is no
longer needed: If the parsing queue is initially empty upon entering
read_frame_internal, the packet will now either contain content upon
success or be blank upon failure of ff_read_packet. If the parsing
queue is initially not empty, the packet will be overwritten with the
oldest one from the parsing queue.

Similarly, it is unnecessary to initialize ret in read_frame_internal.

In parse_packet, it is easily possible to only initialize the packet
used as temporary storage for the output if said packet is used at all;
furthermore, this packet doesn't need to be zero-initialized, because
av_init_packet will initialize every field except size and data and
those fields will be set by av_parser_parse2.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
8 months agoavformat/utils: Improve parsing packets
Andreas Rheinhardt [Fri, 20 Sep 2019 20:39:15 +0000 (22:39 +0200)]
avformat/utils: Improve parsing packets

Up until now, parse_packet() used a stack packet in case the stream is
flushed. But using such a packet is unnecessary as there is an AVPacket
readily available, it just needs to be used. Whether flushing is intended
or not will now be signalled by an explicit parameter rather than by
whether the packet parameter is NULL. This removes a few checks in
parse_packet(), gets rid of the initialization of the stack packet and
also reduces usage of sizeof(AVPacket) in libavformat.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
8 months agoavformat/utils: Avoid copying packets unnecessarily
Andreas Rheinhardt [Fri, 20 Sep 2019 20:39:14 +0000 (22:39 +0200)]
avformat/utils: Avoid copying packets unnecessarily

Up until now, read_frame_internal in avformat/utils.c uses a spare
packet on the stack that serves no real purpose: At no point in this
function is there a need for another packet besides the packet destined
for output:
1. If the packet doesn't need a parser, but is output as is, the content
of the spare packet (that at this point contains a freshly read packet)
is simply copied into the output packet (via simple assignment, not
av_packet_move_ref, thereby confusing ownership).
2. If the packet needs parsing, the spare packet will be reset after
parsing and any packets resulting from the packet read will be put into
a packet list; the output packet is not used here at all.
3. If the stream should be discarded, the spare packet will be
unreferenced; the output packet is not used here at all either.

Therefore the spare packet and the copies can be removed in principle.
In practice, one more thing needs to be taken care of: If ff_read_packet
failed, the output packet was not affected, now it is. But given that
ff_read_packet returns a blank (as if reset via av_packet_unref) packet
on failure, there is no problem from this side either.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
8 months agoavformat/utils: Don't create unnecessary references
Andreas Rheinhardt [Sat, 28 Sep 2019 02:42:24 +0000 (04:42 +0200)]
avformat/utils: Don't create unnecessary references

When AVFMT_FLAG_GENPTS is set, av_read_frame would put a reference to a
packet in the packet list (via av_packet_ref) and then immediately
thereafter unreference the original packet. This has been changed to
move the reference instead.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
8 months agoavformat/utils: Fix memleaks II
Andreas Rheinhardt [Fri, 20 Sep 2019 20:39:12 +0000 (22:39 +0200)]
avformat/utils: Fix memleaks II

Up until now, avformat_find_stream_info had a potential for memleaks:
When everything was fine, it read packets and (depending upon whether
AVFMT_FLAG_NOBUFFER was set) put them in a packet list or unreferenced
them when they were no longer needed. But upon failure, said packets
would leak if they were not already on the packet list. This patch fixes
this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
8 months agoavformat/utils: Don't initialize in loops
Andreas Rheinhardt [Fri, 20 Sep 2019 20:39:11 +0000 (22:39 +0200)]
avformat/utils: Don't initialize in loops

Since the recent changes to ff_packet_list_put, the source packet will
be automatically reset when the reference is moved to the packet list,
so that it is unnecessary to reinitialize the packet in the loops in
parse_packet and ff_read_packet; initializing once at the beginning is
enough.

This also fixes a potential, but currently unexisting problem: If the
raw packet buffer was initially not empty and probe_codec() failed,
then the packet returned would not be initialized. But given that
probe_codec() currently can't fail (always returns 0) this was not an
acute danger.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
8 months agodoc/filters: add more advanced silenceremove example
Paul B Mahol [Sat, 28 Sep 2019 21:04:07 +0000 (23:04 +0200)]
doc/filters: add more advanced silenceremove example

8 months agoavfilter/fifo: use the name 's' for the pointer to the private context
Paul B Mahol [Sat, 28 Sep 2019 20:06:50 +0000 (22:06 +0200)]
avfilter/fifo: use the name 's' for the pointer to the private context

This is shorter and consistent across filters.

8 months agoavfilter/fifo: cosmetics
Paul B Mahol [Sat, 28 Sep 2019 19:57:52 +0000 (21:57 +0200)]
avfilter/fifo: cosmetics

8 months agoavfilter/vf_framerate: remove duplicate code with macro-based function
Limin Wang [Tue, 24 Sep 2019 10:18:09 +0000 (18:18 +0800)]
avfilter/vf_framerate: remove duplicate code with macro-based function

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
8 months agoavfilter/vf_framerate: refine the filter_slice code for better readiablity
Limin Wang [Tue, 24 Sep 2019 10:18:08 +0000 (18:18 +0800)]
avfilter/vf_framerate: refine the filter_slice code for better readiablity

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
Signed-off-by: Marton Balint <cus@passwd.hu>