1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00
Commit Graph

95245 Commits

Author SHA1 Message Date
Andreas Rheinhardt
e5e5be4c7f 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>
2019-10-07 22:27:18 +02:00
Andreas Rheinhardt
d03c3e8517 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>
2019-10-07 22:27:18 +02:00
Andreas Rheinhardt
5e546864b0 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>
2019-10-07 22:27:18 +02:00
Andreas Rheinhardt
69dd8d3a2a 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>
2019-10-07 22:27:17 +02:00
Andriy Gelman
4cb124a800 doc/formats: Update documentation for chromaprint
Silence detection can only be set with algorithm version 3.

Reviewed-by: Gyan Doshi <ffmpeg@gyani.pro>
2019-10-08 01:15:10 +05:30
Andreas Rheinhardt
361fb42e1e 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>
2019-10-07 21:15:55 +02:00
Paul B Mahol
0633d87ae6 avfilter/af_adelay: add option which changes how unset channels are delayed
Fixes #8032.
2019-10-07 18:10:28 +02:00
Paul B Mahol
9a53e01252 avfilter/formats: guard against double free 2019-10-07 17:26:59 +02:00
Paul B Mahol
c303d0979f avfilter/vf_normalize: typedef all structs 2019-10-07 12:17:14 +02:00
Paul B Mahol
651a0f6308 avfilter/vf_showpalette: remove timeline flag
This filter changes output size and thus can not have support
for timeline.
2019-10-07 12:07:00 +02:00
Paul B Mahol
0c4137bcb7 avfilter/af_afftfilt: fix possible invalid memory access 2019-10-07 11:37:05 +02:00
Paul B Mahol
5b4010e886 avfilter/vf_nnedi: fix possible double free 2019-10-07 11:15:44 +02:00
Paul B Mahol
a1e5c35a6e doc/filters: fix few more typos 2019-10-06 20:32:16 +02:00
Michael Niedermayer
81b53913bb 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>
2019-10-06 20:00:59 +02:00
Michael Niedermayer
22bec0d33f 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>
2019-10-06 20:00:59 +02:00
Andreas Rheinhardt
e3650dcfc9 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>
2019-10-06 20:00:59 +02:00
Andreas Rheinhardt
670fd3b0ec 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>
2019-10-06 20:00:59 +02:00
James Almer
5f758c31f9 avformat/matroskaenc: use r_frame_rate as fallback to set a track's DefaultDuration
Signed-off-by: James Almer <jamrial@gmail.com>
2019-10-06 13:44:52 -03:00
Paul B Mahol
66d45af13c avfilter/vf_avgblur: add support for commands 2019-10-06 15:46:06 +02:00
Paul B Mahol
da9337c911 avfilter/vf_gblur: add support for commands 2019-10-06 15:34:28 +02:00
Paul B Mahol
e37edc70bd avfilter: add anlms filter 2019-10-06 15:09:38 +02:00
Jun Zhao
a27c0781dd doc/codecs: Update documentation for flags/flags2
Update documentation for flags/flags2

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2019-10-06 17:33:00 +08:00
Jun Zhao
d9bb12ee39 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>
2019-10-06 17:31:59 +08:00
Jun Zhao
b0e6822448 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>
2019-10-06 17:29:11 +08:00
Mengye Lv
9f353e376b 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>
2019-10-06 17:28:29 +08:00
James Almer
3b4e9a31ea avformat/matroskadec: don't rescale mastering display values
Simplifies code.

Signed-off-by: James Almer <jamrial@gmail.com>
2019-10-05 22:37:41 -03:00
Paul B Mahol
7da57875b5 avformat/mpeg: better fix for MLP versus PCM-DVD misdetection 2019-10-05 11:15:42 +02:00
Zhao Zhili
7c145b6441 FATE/dnn: fix stack buffer overflow
Signed-off-by: Pedro Arthur <bygrandao@gmail.com>
2019-10-04 09:58:22 -03:00
Daniel Kolesa
e6625ca41f 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>
2019-10-04 08:58:17 +03:00
Daniel Kolesa
1bdb47b734 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>
2019-10-04 08:58:17 +03:00
Andreas Rheinhardt
581419ea39 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>
2019-10-04 00:06:30 -03:00
Michael Niedermayer
379e5d29d5 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>
2019-10-03 19:37:35 +02:00
Michael Niedermayer
2f588ccfb7 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>
2019-10-03 19:37:28 +02:00
Michael Niedermayer
9b533de28e 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>
2019-10-03 19:37:10 +02:00
Andreas Rheinhardt
be0d3a2df1 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>
2019-10-03 19:34:23 +02:00
Andreas Rheinhardt
c694fc5759 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>
2019-10-03 19:34:23 +02:00
Andreas Rheinhardt
c548b0a4c6 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>
2019-10-03 19:34:23 +02:00
Paul B Mahol
93ea21f9b7 doc/filters: fix typo 2019-10-03 17:58:46 +02:00
Paul B Mahol
d0189f8d97 avfilter/vsrc_sierpinski: add triangle type 2019-10-03 14:21:39 +02:00
Paul B Mahol
22f3b6286e avfilter: add av_cold where it is missing 2019-10-03 12:09:07 +02:00
Paul B Mahol
8ca89e52df avfilter/f_streamselect: fix memleaks of pad names 2019-10-03 11:23:23 +02:00
Paul B Mahol
d492907e78 avfilter/af_amix: fix filtering if specified weights are negative 2019-10-03 10:27:56 +02:00
Paul B Mahol
2a546fb7d5 avfilter/setpts: switch to activate
Also properly handle EOF timestamps.
Fixes #6833.
2019-10-02 21:05:25 +02:00
Michael Niedermayer
61dd2e07be 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>
2019-10-02 14:49:04 +02:00
Michael Niedermayer
9c84c162e9 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>
2019-10-02 14:49:04 +02:00
Paul B Mahol
9847380f5f avfilter/vf_elbg: stop leaking frame on error 2019-10-02 10:54:45 +02:00
Michael Niedermayer
c4de49edc4 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>
2019-10-01 22:16:20 +02:00
Carl Eugen Hoyos
87b7e141a6 lavc/x264: Use FF_CODEC_CAP_INIT_THREADSAFE if x264 is new.
Usage of strtok() was removed from x264, see also b02490a4
2019-10-01 22:07:11 +02:00
Carl Eugen Hoyos
7ffa458d60 lavfi/movie: Use filter thread count for decoding threads.
Fixes ticket #7542.
2019-10-01 21:54:53 +02:00
Lou Logan
61b7676bd5 cmdutils: trailing options may be ignored
Signed-off-by: Lou Logan <lou@lrcd.com>
Signed-off-by: mypopy <mypopy@gmail.com>
2019-10-01 10:43:37 -08:00