]> git.sesse.net Git - ffmpeg/log
ffmpeg
4 years agoavcodec/smacker: Remove code duplication when decoding header trees
Andreas Rheinhardt [Sat, 25 Jul 2020 06:21:37 +0000 (08:21 +0200)]
avcodec/smacker: Remove code duplication when decoding header trees

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavcodec/vlc: Add macro for ff_init_vlc_sparse()
Andreas Rheinhardt [Thu, 30 Jul 2020 07:06:44 +0000 (09:06 +0200)]
avcodec/vlc: Add macro for ff_init_vlc_sparse()

ff_init_vlc_sparse() supports arrays of uint8_t, uint16_t and uint32_t
as input (and it also supports padding/other elements in between the
elements). This makes the typical case in which the input is a simple
array more cumbersome. E.g. for an array of uint8_t one would either
need to call the function with arguments like "array, sizeof(array[0]),
sizeof(array[0])" or with "array, 1, 1". The former is nicer, but
longer, so that the latter is mostly used. Therefore this commit adds a
macro that expands to the sizeof() construct.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavcodec/smacker: Don't warn for Huffmann tables with one element
Andreas Rheinhardt [Sat, 25 Jul 2020 05:21:49 +0000 (07:21 +0200)]
avcodec/smacker: Don't warn for Huffmann tables with one element

The Huffmann tables used by Smacker can consist of exactly one leaf only
in which case the length of the corresponding code is zero; there is
then exactly one value encoded. Our VLC can't handle this and therefore
this case needs to be treated separately; it has been implemented in
commit 48cbdaea157671d456750e00fde37c6d7595fad6. Yet said commit also
made the decoder emit an error message (despite not erroring out) in this
case, although it seems that this is rather a limitation of our VLC API.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavcodec/smacker: Remove write-only and unused variables
Andreas Rheinhardt [Thu, 25 Jun 2020 08:07:39 +0000 (10:07 +0200)]
avcodec/smacker: Remove write-only and unused variables

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavformat/3dostr: make probing more robust
Paul B Mahol [Thu, 17 Sep 2020 21:19:18 +0000 (23:19 +0200)]
avformat/3dostr: make probing more robust

4 years agoavformat/mxfdec: Read Apple private Content Light Level from MXF
Harry Mallon [Wed, 9 Sep 2020 14:56:39 +0000 (15:56 +0100)]
avformat/mxfdec: Read Apple private Content Light Level from MXF

* As embedded by Apple Compressor

Signed-off-by: Harry Mallon <harry.mallon@codex.online>
4 years agoavformat/mxfenc: Write Mastering Display Colour Volume to MXF
Harry Mallon [Wed, 9 Sep 2020 14:56:38 +0000 (15:56 +0100)]
avformat/mxfenc: Write Mastering Display Colour Volume to MXF

Described in Annex B SMPTE ST 2067-21:2020

Signed-off-by: Harry Mallon <harry.mallon@codex.online>
4 years agoavformat/mxfdec: Read Mastering Display Colour Volume from MXF
Harry Mallon [Wed, 9 Sep 2020 14:56:37 +0000 (15:56 +0100)]
avformat/mxfdec: Read Mastering Display Colour Volume from MXF

Described in Annex B SMPTE ST 2067-21:2020

Signed-off-by: Harry Mallon <harry.mallon@codex.online>
4 years agoavcodec/svq1dec: use av_malloc_array() to allocate pmv
Paul B Mahol [Thu, 17 Sep 2020 13:57:26 +0000 (15:57 +0200)]
avcodec/svq1dec: use av_malloc_array() to allocate pmv

4 years agoavfilter/vf_showinfo: add const to the AVFrameSideData instance
Limin Wang [Thu, 17 Sep 2020 10:33:19 +0000 (18:33 +0800)]
avfilter/vf_showinfo: add const to the AVFrameSideData instance

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
4 years agoavcodec/av1dec: Remove redundant second free
Andreas Rheinhardt [Sun, 13 Sep 2020 19:35:12 +0000 (21:35 +0200)]
avcodec/av1dec: Remove redundant second free

The AV1 decoder has the FF_CODEC_CAP_INIT_CLEANUP flag set and yet
the decoder's close function is called manually on some error paths.
This is unnecessary and has been removed in this commit.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavcodec/av1dec: Fix segfault upon allocation error
Andreas Rheinhardt [Mon, 14 Sep 2020 04:37:24 +0000 (06:37 +0200)]
avcodec/av1dec: Fix segfault upon allocation error

Up until now, the AV1 decoder always checks before calling its wrapper
around ff_thread_release_buffer() whether the ThreadFrame was used at
all, i.e. it checked whether the first data buffer of the AVFrame
contained therein is NULL or not. Yet this presumes that the AVFrame has
been successfully allocated, even though this can of course fail; and if
it did, one would encounter a segfault.
Fix this by removing the checks altogether: ff_thread_release_buffer()
can handle both unallocated as well as empty frames (since commit
f6774f905fb3cfdc319523ac640be30b14c1bc55).

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agodnn_backend_native_layer_conv2d.c: refine code.
Xu Jun [Wed, 16 Sep 2020 10:07:19 +0000 (18:07 +0800)]
dnn_backend_native_layer_conv2d.c: refine code.

Move thread area allocate out of thread function into
main thread.

Signed-off-by: Xu Jun <xujunzz@sjtu.edu.cn>
4 years agodnn_backend_native_layer_conv2d.c: fix memory allocation bug in multithread function.
Xu Jun [Wed, 16 Sep 2020 10:07:17 +0000 (18:07 +0800)]
dnn_backend_native_layer_conv2d.c: fix memory allocation bug in multithread function.

Before patch, memory was allocated in each thread functions,
which may cause more than one time of memory allocation and
cause crash.

After patch, memory is allocated in the main thread once,
an index was parsed into thread functions. Bug fixed.

Signed-off-by: Xu Jun <xujunzz@sjtu.edu.cn>
4 years agoavcodec/vble: Don't free buffer known to be NULL
Andreas Rheinhardt [Sun, 13 Sep 2020 01:52:39 +0000 (03:52 +0200)]
avcodec/vble: Don't free buffer known to be NULL

Freeing a buffer allocated in the VBLE decoder's init function
is the only thing the decoder's close function does and this implies
that it is unnecessary to call it in case said allocation fails. Yet
this is what has been done.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavcodec/vb: Cleanup generically after init failure
Andreas Rheinhardt [Sun, 13 Sep 2020 01:51:23 +0000 (03:51 +0200)]
avcodec/vb: Cleanup generically after init failure

In other words: Set the FF_CODEC_CAP_INIT_CLEANUP flag.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavcodec/tscc2: Cleanup generically after init failure
Andreas Rheinhardt [Sun, 13 Sep 2020 01:34:19 +0000 (03:34 +0200)]
avcodec/tscc2: Cleanup generically after init failure

Do this by setting the FF_CODEC_CAP_INIT_CLEANUP flag.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavcodec/svq3: Avoid overhead of AVBuffer API
Andreas Rheinhardt [Sun, 13 Sep 2020 01:15:29 +0000 (03:15 +0200)]
avcodec/svq3: Avoid overhead of AVBuffer API

Up until now, the SVQ3 decoder allocated several refcounted buffers,
despite no sharing/refcounting happening at all: Their refcount never
exceeds one and they are treated like ordinary buffers (with the
exception that the pointer used to access them is in the middle of the
allocated buffer, but this does not warrant using the AVBuffer API at
all). Given that using the AVBuffer API incurs overhead, it is no longer
used at all.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavcodec/svq3: Remove unused buffer
Andreas Rheinhardt [Sun, 13 Sep 2020 00:55:25 +0000 (02:55 +0200)]
avcodec/svq3: Remove unused buffer

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavcodec/svq3: Fix memleaks upon allocation error
Andreas Rheinhardt [Sun, 13 Sep 2020 00:45:38 +0000 (02:45 +0200)]
avcodec/svq3: Fix memleaks upon allocation error

Commit b2361cfb94738298a6c4037cc348fe5015efb841e made all of the
error paths in svq3_decode_init() call svq3_decode_end(); yet several
new error paths that were added later (in merges from Libav) returned
directly without cleaning up properly. This commit fixes the resulting
potential memleaks by setting the FF_CODEC_CAP_INIT_CLEANUP flag. This
also allows to simplify freeing by returning directly.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavcodec/svq3: Fix segfault on allocation error, avoid allocations
Andreas Rheinhardt [Sun, 13 Sep 2020 00:25:16 +0000 (02:25 +0200)]
avcodec/svq3: Fix segfault on allocation error, avoid allocations

The very first thing the SVQ3 decoder currently does is allocating several
SVQ3Frames, a structure which contains members that need to be freed on
their own. If one of these allocations fails, the decoder calls its own
close function to not leak the already allocated SVQ3Frames. Yet said
function presumes that the SVQ3Frames have been successfully allocated
as there is no check before freeing the members that need to be freed.

This commit fixes this by making these frames part of the SVQ3Context,
thereby avoiding the allocations altogether. Notice that the pointers
to the frames have been retained in order to allow to just swap them as
the code already does.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavcodec/sonic: Fix leaks upon allocation errors
Andreas Rheinhardt [Sat, 12 Sep 2020 23:10:40 +0000 (01:10 +0200)]
avcodec/sonic: Fix leaks upon allocation errors

The Sonic decoder and encoders allocate several buffers in their init
function and return immediately if one of these allocations fails; this
will lead to leaks if there was an earlier successfull allocation. Fix
this by setting the FF_CODEC_CAP_INIT_CLEANUP flag.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavcodec/roqaudioenc: Avoid redundant free of unallocated buffer
Andreas Rheinhardt [Sat, 12 Sep 2020 22:22:28 +0000 (00:22 +0200)]
avcodec/roqaudioenc: Avoid redundant free of unallocated buffer

If allocating a buffer in RoQ DPCM encoder's init function failed,
the close function would be called manually; all this function does is
freeing said buffer, but given that it has not been allocated at all,
this is unnecessary.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavcodec/pcm: Avoid indirection when calling float dsp function
Andreas Rheinhardt [Sat, 12 Sep 2020 22:13:43 +0000 (00:13 +0200)]
avcodec/pcm: Avoid indirection when calling float dsp function

Do this by only keeping the only function pointer from the
AVFloatDSPContext that is needed lateron. This also allows to remove the
decoders' close function.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavcodec/ra288: Avoid indirection when calling float dsp function
Andreas Rheinhardt [Sat, 12 Sep 2020 22:09:18 +0000 (00:09 +0200)]
avcodec/ra288: Avoid indirection when calling float dsp function

Do this by only keeping the only function pointer from the
AVFloatDSPContext that is needed lateron. This also allows to remove the
decoder's close function.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavcodec/ra144enc: Don't free unnecessarily
Andreas Rheinhardt [Sat, 12 Sep 2020 21:56:50 +0000 (23:56 +0200)]
avcodec/ra144enc: Don't free unnecessarily

The init function of the real_144 encoder calls its own close function
if a call to ff_lpc_init() fails; yet nothing has been allocated before
that point and ff_lpc_init() can be expected to clean up after itself on
error (the documentation does not say anything to the contrary and the
current implementation can only fail if the only allocation fails, so
there is nothing to clean up on error anyway), so this is unnecessary.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavcodec/qtrleenc: Fix memleak upon allocation failure
Andreas Rheinhardt [Sat, 12 Sep 2020 21:52:36 +0000 (23:52 +0200)]
avcodec/qtrleenc: Fix memleak upon allocation failure

The qtrle encoder allocates several buffers and an AVFrame in its init
function. If one of these allocations fails, but others succeed, the
successfully allocated objects leak. This is fixed by setting the
FF_CODEC_CAP_INIT_CLEANUP flag.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavcodec/pcm-dvdenc: Remove empty function
Andreas Rheinhardt [Sat, 12 Sep 2020 21:48:32 +0000 (23:48 +0200)]
avcodec/pcm-dvdenc: Remove empty function

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavcodec/pcm-dvd: Avoid allocation of buffer
Andreas Rheinhardt [Sat, 12 Sep 2020 21:47:28 +0000 (23:47 +0200)]
avcodec/pcm-dvd: Avoid allocation of buffer

In this case, it also allows to remove the decoder's close function.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavcodec/ffv1: Simplify cleanup after allocation failure
Andreas Rheinhardt [Mon, 14 Sep 2020 03:39:26 +0000 (05:39 +0200)]
avcodec/ffv1: Simplify cleanup after allocation failure

Now that ff_ffv1_close() is called upon failure for both the FFV1 encoder
and decoder, the code contained therein can be used to free the partially
allocated slice contexts if allocating the slice contexts failed. One just
has to set the correct number of slice contexts on error. This allows to
remove the code for freeing partially allocated slice contexts in
ff_ffv1_init_slice_contexts().

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavcodec/ffv1enc: Fix memleaks on init failure
Andreas Rheinhardt [Mon, 14 Sep 2020 03:30:15 +0000 (05:30 +0200)]
avcodec/ffv1enc: Fix memleaks on init failure

The FFV1 encoder has so far not cleaned up after itself in this case;
but it can be done easily by setting the FF_CODEC_CAP_INIT_CLEANUP flag.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavcodec/ffv1: Fix segfaults on allocation error
Andreas Rheinhardt [Mon, 14 Sep 2020 02:58:34 +0000 (04:58 +0200)]
avcodec/ffv1: Fix segfaults on allocation error

When allocating FFV1 slice contexts fails, ff_ffv1_init_slice_contexts()
frees everything that it has allocated, yet it does not reset the
counter for the number of allocated slice contexts. This inconsistent
state leads to segfaults lateron in ff_ffv1_close(), because said
function presumes that the slice contexts have been allocated.
Fix this by making sure that the number of slice contexts on error is
consistent (namely zero).

(This issue only affected the FFV1 decoder, because the encoder does not
clean up after itself on init failure.)

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavcodec/c93: Cleanup generically after init failure
Andreas Rheinhardt [Sun, 13 Sep 2020 20:42:26 +0000 (22:42 +0200)]
avcodec/c93: Cleanup generically after init failure

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavcodec/mv30: Check remaining mask in decode_inter()
Michael Niedermayer [Sun, 13 Sep 2020 22:03:36 +0000 (00:03 +0200)]
avcodec/mv30: Check remaining mask in decode_inter()

Fixes: timeout (too long -> 4sec)
Fixes: 25129/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MV30_fuzzer-5642089713631232
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavcodec/wmalosslessdec: Check remaining space before padding and channel residue
Michael Niedermayer [Sun, 13 Sep 2020 19:12:17 +0000 (21:12 +0200)]
avcodec/wmalosslessdec: Check remaining space before padding and channel residue

Fixes: Timeout (1101sec -> 0.4sec)
Fixes: 24491/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMALOSSLESS_fuzzer-5725337036783616
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavcodec/lscr: stop returning error if size of packet is 2 bytes
Paul B Mahol [Wed, 16 Sep 2020 13:20:21 +0000 (15:20 +0200)]
avcodec/lscr: stop returning error if size of packet is 2 bytes

4 years agoavformat/argo_asf: initialise file header inline
Zane van Iperen [Mon, 14 Sep 2020 23:22:22 +0000 (09:22 +1000)]
avformat/argo_asf: initialise file header inline

Garbage was left-over in the ArgoASFFileHeader::name field if the url
was too short. This zero-initialises it.

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
4 years agoavutil/cuda_check: add missing dynlink_loader.h include
James Almer [Tue, 15 Sep 2020 22:29:07 +0000 (19:29 -0300)]
avutil/cuda_check: add missing dynlink_loader.h include

Fixes make checkheaders

Signed-off-by: James Almer <jamrial@gmail.com>
4 years agoavcodec/Makefile: add vaapi_hevc.h to the SKIPHEADERS list
James Almer [Tue, 15 Sep 2020 22:28:20 +0000 (19:28 -0300)]
avcodec/Makefile: add vaapi_hevc.h to the SKIPHEADERS list

Fixes make checkheaders when vaapi is disabled

Signed-off-by: James Almer <jamrial@gmail.com>
4 years agoavformat/argo_asf: add missing avformat.h include
James Almer [Tue, 15 Sep 2020 22:27:45 +0000 (19:27 -0300)]
avformat/argo_asf: add missing avformat.h include

Fixes make checkheaders

Signed-off-by: James Almer <jamrial@gmail.com>
4 years agoavcodec/mpc7, mpc7data: Avoid gaps in array
Andreas Rheinhardt [Tue, 15 Sep 2020 03:23:07 +0000 (05:23 +0200)]
avcodec/mpc7, mpc7data: Avoid gaps in array

The Musepack decoder uses static VLC tables to parse the bitstream.
There are 14 different quant tables VLCs and each of them has a varying
number of codes. The maximum number is 63, the average number is 25.3.
Up until now, the array containing the raw data was of type
uint16_t [7][2][64 * 2] (the 14 tables come in pairs of two, hence [7][2]
instead of [14]) and from this it follows that there were large gaps in
said array. This commit changes this by making it a continuous array
instead. Doing so saves about 2KB.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavcodec/mpc7, mpc7data: Make overlong arrays smaller
Andreas Rheinhardt [Tue, 15 Sep 2020 01:45:22 +0000 (03:45 +0200)]
avcodec/mpc7, mpc7data: Make overlong arrays smaller

For the VLC table arrays in mpc7_decode_init() this fixes
a regression introduced in 1e40dc920a838e35f1483b20bfcd417437e68741.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavdevice/decklink_dec: fix build with older SDK
Marton Balint [Mon, 14 Sep 2020 19:22:29 +0000 (21:22 +0200)]
avdevice/decklink_dec: fix build with older SDK

Apparently bmdFormatUnspecified needs SDK 11.0. It is just a fancy way of
checking for zero, so let's do that instead.

Fixes build issue since f1b908d20a8.

Signed-off-by: Marton Balint <cus@passwd.hu>
4 years agoavcodec/mpc7: Don't pretend initializing static VLC tables can fail
Andreas Rheinhardt [Tue, 15 Sep 2020 02:26:37 +0000 (04:26 +0200)]
avcodec/mpc7: Don't pretend initializing static VLC tables can fail

It can't if one hasn't made a mistake at calculating the sizes;
and this is checked by asserts/aborts.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavcodec/motionpixels: Cleanup generically after init failure
Andreas Rheinhardt [Tue, 15 Sep 2020 01:22:36 +0000 (03:22 +0200)]
avcodec/motionpixels: Cleanup generically after init failure

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavcodec/mobiclip: Fix heap-buffer-overflow
Andreas Rheinhardt [Tue, 15 Sep 2020 01:03:18 +0000 (03:03 +0200)]
avcodec/mobiclip: Fix heap-buffer-overflow

The MobiClip decoder uses adjacent pixels for prediction; yet when
accessing the left pixel, it was forgotten to clip the x coordinate.
This results in an heap-buffer-overflow. It can e.g. be reproduced with
the sample from https://samples.ffmpeg.org/V-codecs/MOHD/crap.avi when
forcing the video decoder to mobiclip.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavcodec/mlpenc: Fix memleak upon init failure
Andreas Rheinhardt [Tue, 15 Sep 2020 00:35:27 +0000 (02:35 +0200)]
avcodec/mlpenc: Fix memleak upon init failure

If an error happens during init after an allocation has succeeded,
the already allocated data leaked up until now. Fix this by setting the
FF_CODEC_CAP_INIT_CLEANUP flag.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavcodec/indeo5: Fix memleaks upon allocation error
Andreas Rheinhardt [Mon, 14 Sep 2020 18:59:12 +0000 (20:59 +0200)]
avcodec/indeo5: Fix memleaks upon allocation error

ff_ivi_init_planes() might error out after having allocated some arrays.
Set the FF_CODEC_CAP_INIT_CLEANUP flag in order to free these arrays in
this case.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavcodec/ivi: Fix segfault on allocation error
Andreas Rheinhardt [Mon, 14 Sep 2020 18:32:33 +0000 (20:32 +0200)]
avcodec/ivi: Fix segfault on allocation error

If allocating the tiles array for indeo 4/5 fails, the context is in an
inconsistent state, because the counter for the number of tiles is > 0.
This will lead to a segfault when freeing the tiles' substructures.
Fix this by setting the number of tiles to zero if the allocation was
unsuccessful.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavcodec/mobiclip: Fix memleak upon init failure
Andreas Rheinhardt [Tue, 15 Sep 2020 00:44:36 +0000 (02:44 +0200)]
avcodec/mobiclip: Fix memleak upon init failure

If an error happens during init after an allocation has succeeded,
the already allocated data leaked up until now. Fix this by setting the
FF_CODEC_CAP_INIT_CLEANUP flag.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavcodec/magicyuvenc: Fix memleak upon init failure
Andreas Rheinhardt [Tue, 15 Sep 2020 00:13:56 +0000 (02:13 +0200)]
avcodec/magicyuvenc: Fix memleak upon init failure

If an error happens during init after an allocation has succeeded,
the already allocated data leaked up until now. Fix this by setting the
FF_CODEC_CAP_INIT_CLEANUP flag.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavcodec/hcom: Cleanup generically upon init failure
Andreas Rheinhardt [Mon, 14 Sep 2020 15:39:55 +0000 (17:39 +0200)]
avcodec/hcom: Cleanup generically upon init failure

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavcodec/gif: Fix leaks upon allocation error
Andreas Rheinhardt [Mon, 14 Sep 2020 15:30:34 +0000 (17:30 +0200)]
avcodec/gif: Fix leaks upon allocation error

If one of several allocations the gif encoder performs in its init
function fails, the successful allocations leak. Fix this by adding the
FF_CODEC_CAP_INIT_CLEANUP flag.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavcodec/dsicinvideo: Remove redundant code for freeing
Andreas Rheinhardt [Mon, 14 Sep 2020 00:26:37 +0000 (02:26 +0200)]
avcodec/dsicinvideo: Remove redundant code for freeing

The dsicinvideo decoder already has the FF_CODEC_CAP_INIT_CLEANUP flag
set, so it is unnecessary to directly clean up some already allocated
buffers in case another one could not be allocated in the init function,
as all buffers will be freed anyway later in the decoder's close
function.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavcodec/avrndec: Fix memleak on error
Andreas Rheinhardt [Sun, 13 Sep 2020 20:05:25 +0000 (22:05 +0200)]
avcodec/avrndec: Fix memleak on error

If ff_codec_open2_recursive() fails, the already allocated
AVCodecContext leaks. Fix this by setting the FF_CODEC_CAP_INIT_CLEANUP
flag.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavcodec/avrndec: Check allocation for success
Andreas Rheinhardt [Sun, 13 Sep 2020 19:57:50 +0000 (21:57 +0200)]
avcodec/avrndec: Check allocation for success

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavcodec/atrac1: Cleanup generically after init failure
Andreas Rheinhardt [Sun, 13 Sep 2020 18:54:18 +0000 (20:54 +0200)]
avcodec/atrac1: Cleanup generically after init failure

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavcodec/atrac1: Check allocation of AVFloatDSPContext
Andreas Rheinhardt [Sun, 13 Sep 2020 18:53:46 +0000 (20:53 +0200)]
avcodec/atrac1: Check allocation of AVFloatDSPContext

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agolibavcodec/exr: fix incorrect translation of denorm mantissa
Mark Reid [Tue, 15 Sep 2020 02:14:46 +0000 (19:14 -0700)]
libavcodec/exr: fix incorrect translation of denorm mantissa

4 years agoavfilter/f_interleave: fix some issues with interleaving
Paul B Mahol [Tue, 15 Sep 2020 15:17:15 +0000 (17:17 +0200)]
avfilter/f_interleave: fix some issues with interleaving

4 years agoavcodec/decode: use a packet list to store packet properties
James Almer [Mon, 17 Aug 2020 15:06:55 +0000 (12:06 -0300)]
avcodec/decode: use a packet list to store packet properties

Keeping only the latest packet fed to the decoder works only for decoders that
return a frame immediately after every consumed packet. Decoders that consume
several packets before they return a frame will fill said frame with properties
taken from the last consumed packet instead of the earliest.

Signed-off-by: James Almer <jamrial@gmail.com>
4 years agoavcodec/packet: move AVPacketList definition and function helpers over from libavformat
James Almer [Mon, 17 Aug 2020 15:03:50 +0000 (12:03 -0300)]
avcodec/packet: move AVPacketList definition and function helpers over from libavformat

And replace the flags parameter with a function callback that can be used to
copy the contents of the packet (e.g, av_packet_ref and av_packet_copy_props).

Signed-off-by: James Almer <jamrial@gmail.com>
4 years agoavfilter/x86/vf_convolution_init: there is asm only for 8bit depth
Paul B Mahol [Tue, 15 Sep 2020 06:10:47 +0000 (08:10 +0200)]
avfilter/x86/vf_convolution_init: there is asm only for 8bit depth

4 years agoavfilter/avf_concat: check for possible integer overflow
Paul B Mahol [Sun, 13 Sep 2020 11:33:49 +0000 (13:33 +0200)]
avfilter/avf_concat: check for possible integer overflow

Also check that segment delta pts is always bigger than input pts.

There is nothing much currently that can be done to recover from
this situation so just return AVERROR_INVALIDDATA error code.

4 years agoavfilter/af_amix: do not leave unset PTS for frames after first stream is over
Paul B Mahol [Sun, 13 Sep 2020 12:00:27 +0000 (14:00 +0200)]
avfilter/af_amix: do not leave unset PTS for frames after first stream is over

First stream is used only to get number of samples to put into each output frame.

4 years agoavcodec/cfhdenc: Fix leaks on allocation errors
Andreas Rheinhardt [Sun, 13 Sep 2020 23:37:07 +0000 (01:37 +0200)]
avcodec/cfhdenc: Fix leaks on allocation errors

The CineForm HD encoder attempts to allocate several buffers in its init
function; yet if only some of these allocations succeed, the
successfully allocated buffers leak. This is fixed by setting the
FF_CODEC_CAP_INIT_CLEANUP flag.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavcodec/snowdec: Use ff_snow_common_init() directly
Andreas Rheinhardt [Sat, 12 Sep 2020 21:40:02 +0000 (23:40 +0200)]
avcodec/snowdec: Use ff_snow_common_init() directly

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavfilter/vf_premultiply: add missing AV_PIX_FMT_YUVA444P12
Mark Reid [Mon, 14 Sep 2020 02:55:01 +0000 (19:55 -0700)]
avfilter/vf_premultiply: add missing AV_PIX_FMT_YUVA444P12

query_formats says its supported, but is missing from switch statement leading to segfault

4 years agoavformat: add Argonaut Games BRP demuxer
Zane van Iperen [Mon, 7 Sep 2020 10:44:23 +0000 (20:44 +1000)]
avformat: add Argonaut Games BRP demuxer

Used in FMVs for FX Fighter and Croc. Supports BVID and BASF streams,
requests samples for anything else.

Due to the way BASF streams are contained in the file, only one is
supported. I have yet to see a BRP file with multiple.

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
4 years agoavformat/argo_asf: add ASF_MIN_BUFFER_SIZE #define
Zane van Iperen [Fri, 4 Sep 2020 03:54:09 +0000 (13:54 +1000)]
avformat/argo_asf: add ASF_MIN_BUFFER_SIZE #define

For future use by the argo_brp demuxer

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
4 years agoavformat/argo_asf: split functionality into a header
Zane van Iperen [Sat, 5 Sep 2020 07:24:17 +0000 (17:24 +1000)]
avformat/argo_asf: split functionality into a header

For future use by the argo_brp demuxer.

Adds:
  - void ff_argo_asf_parse_file_header(ArgoASFFileHeader *hdr, const uint8_t *buf);
  - int  ff_argo_asf_validate_file_header(AVFormatContext *s, const ArgoASFFileHeader *hdr);
  - void ff_argo_asf_parse_chunk_header(ArgoASFChunkHeader *hdr, const uint8_t *buf);
  - int  ff_argo_asf_fill_stream(AVStream *st, const ArgoASFChunkHeader *ckhdr);

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
4 years agoavformat/argo_asf: bail if invalid tag
Zane van Iperen [Sun, 6 Sep 2020 01:00:17 +0000 (11:00 +1000)]
avformat/argo_asf: bail if invalid tag

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
4 years agoavdevice/decklink_dec: add support for querying RP188 High Frame Rate timecode
Marton Balint [Sat, 5 Sep 2020 19:18:17 +0000 (21:18 +0200)]
avdevice/decklink_dec: add support for querying RP188 High Frame Rate timecode

Signed-off-by: Marton Balint <cus@passwd.hu>
4 years agoavdevice/decklink_dec: add support for rgb/yuv pixel format autodetection
Marton Balint [Wed, 15 Jul 2020 18:45:22 +0000 (20:45 +0200)]
avdevice/decklink_dec: add support for rgb/yuv pixel format autodetection

Signed-off-by: Marton Balint <cus@passwd.hu>
4 years agoavdevice/decklink_dec: use decklink_ctx->raw_format as bmdPixelFormat
Marton Balint [Wed, 15 Jul 2020 18:23:12 +0000 (20:23 +0200)]
avdevice/decklink_dec: use decklink_ctx->raw_format as bmdPixelFormat

Signed-off-by: Marton Balint <cus@passwd.hu>
4 years agoavdevice/decklink_common.h: remove unsupported decklink version ifdef
Marton Balint [Wed, 15 Jul 2020 18:06:22 +0000 (20:06 +0200)]
avdevice/decklink_common.h: remove unsupported decklink version ifdef

Signed-off-by: Marton Balint <cus@passwd.hu>
4 years agoavformat: use av_timecode_make_smpte_tc_string2
Marton Balint [Fri, 24 Jul 2020 14:26:58 +0000 (16:26 +0200)]
avformat: use av_timecode_make_smpte_tc_string2

WSD format has no frames stored for playback time.

Signed-off-by: Marton Balint <cus@passwd.hu>
4 years agoavfilter/vf_showinfo: use av_timecode_make_smpte_tc_string2
Marton Balint [Fri, 24 Jul 2020 14:26:25 +0000 (16:26 +0200)]
avfilter/vf_showinfo: use av_timecode_make_smpte_tc_string2

Signed-off-by: Marton Balint <cus@passwd.hu>
4 years agoavcodec: use av_timecode_make_smpte_tc_string2 in hevc and h264 decoder
Marton Balint [Fri, 24 Jul 2020 14:26:04 +0000 (16:26 +0200)]
avcodec: use av_timecode_make_smpte_tc_string2 in hevc and h264 decoder

Signed-off-by: Marton Balint <cus@passwd.hu>
4 years agofftools/ffprobe: use av_timecode_make_smpte_tc_string2
Marton Balint [Fri, 24 Jul 2020 14:25:45 +0000 (16:25 +0200)]
fftools/ffprobe: use av_timecode_make_smpte_tc_string2

Signed-off-by: Marton Balint <cus@passwd.hu>
4 years agoavutil/timecode: add av_timecode_make_smpte_tc_string2
Marton Balint [Fri, 24 Jul 2020 13:09:32 +0000 (15:09 +0200)]
avutil/timecode: add av_timecode_make_smpte_tc_string2

Signed-off-by: Marton Balint <cus@passwd.hu>
4 years agoavutil/timecode: do not trash bits on invalid av_timecode_get_smpte arguments
Marton Balint [Sat, 5 Sep 2020 15:46:42 +0000 (17:46 +0200)]
avutil/timecode: do not trash bits on invalid av_timecode_get_smpte arguments

The function has no way to return error, so let's clip or calculate modulo.

Signed-off-by: Marton Balint <cus@passwd.hu>
4 years agoavutil/timecode: cosmetics on av_timecode_get_smpte
Marton Balint [Mon, 20 Jul 2020 20:33:20 +0000 (22:33 +0200)]
avutil/timecode: cosmetics on av_timecode_get_smpte

Signed-off-by: Marton Balint <cus@passwd.hu>
4 years agoavutil/timecode: fix av_timecode_get_smpte_from_framenum with 50/60 fps
Marton Balint [Mon, 20 Jul 2020 19:38:21 +0000 (21:38 +0200)]
avutil/timecode: fix av_timecode_get_smpte_from_framenum with 50/60 fps

SMPTE 12M timecode can only count frames up to 39, because the tens-of-frames
value is stored in 2 bit. In order to resolve this 50/60 fps SMPTE timecode is
using the field bit (which is the same bit as the phase correction bit) to
signal the least significant bit of a 50/60 fps timecode. See SMPTE ST
12-1:2014 section 12.1.

Therefore we slightly change the format of the return value of
av_timecode_get_smpte_from_framenum and AV_FRAME_DATA_S12M_TIMECODE and start
using the previously unused Phase Correction bit as Field bit. (As the SMPTE
standard suggests)

We add 50/60 fps support to av_timecode_get_smpte_from_framenum by calling the
recently added av_timecode_get_smpte function in it which already handles this
properly.

This change affects the decklink indev and the DV and MXF muxers. MXF has no
fate test for 50/60fps content, DV does, therefore the changes.

MediaInfo (a recent version) confirms that half-frame timecode must be inserted
to DV. MXFInspect confirms valid timecode insertion to the System Item of MXF
files. For MXF, also see EBU R122.

Note that for DV the field flag is not used because in the HDV specs (SMPTE
370M) it is still defined as biphase mark polarity correction flag. So it
should not matter that the DV muxer overrides the field bit.

Signed-off-by: Marton Balint <cus@passwd.hu>
4 years agoavformat: add Square SVS demuxer
Paul B Mahol [Fri, 11 Sep 2020 09:47:34 +0000 (11:47 +0200)]
avformat: add Square SVS demuxer

4 years agoavformat/moflex: make seeking more useful
Paul B Mahol [Thu, 10 Sep 2020 20:36:48 +0000 (22:36 +0200)]
avformat/moflex: make seeking more useful

4 years agoavcodec/mobiclip: add missing flush
Paul B Mahol [Thu, 10 Sep 2020 20:37:56 +0000 (22:37 +0200)]
avcodec/mobiclip: add missing flush

4 years agoavformat/flic: add support for seeking to start
Paul B Mahol [Thu, 10 Sep 2020 11:55:50 +0000 (13:55 +0200)]
avformat/flic: add support for seeking to start

4 years agoavcodec/cdgraphics: fix decoded output when seeking to start of file
Paul B Mahol [Wed, 9 Sep 2020 22:39:47 +0000 (00:39 +0200)]
avcodec/cdgraphics: fix decoded output when seeking to start of file

Also in cdg demuxer do not skip packets data, and remove
private context which is not really needed.

4 years agoavfilter/asrc_anullsrc: actually return correct EOF pts
Paul B Mahol [Sun, 13 Sep 2020 11:25:05 +0000 (13:25 +0200)]
avfilter/asrc_anullsrc: actually return correct EOF pts

4 years agoavfilter/asrc_anullsrc: give better limits to number of samples per frame
Paul B Mahol [Sun, 13 Sep 2020 11:10:54 +0000 (13:10 +0200)]
avfilter/asrc_anullsrc: give better limits to number of samples per frame

4 years agoavfilter/asrc_anullsrc: make number of output samples match duration
Paul B Mahol [Sun, 13 Sep 2020 11:08:35 +0000 (13:08 +0200)]
avfilter/asrc_anullsrc: make number of output samples match duration

4 years agoavformat/cdg: Fix integer overflow in duration computation
Michael Niedermayer [Sun, 19 Jul 2020 14:54:28 +0000 (16:54 +0200)]
avformat/cdg: Fix integer overflow in duration computation

Fixes: signed integer overflow: 8398407 * 300 cannot be represented in type 'int'
Fixes: 23914/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-4702539290509312
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agotools:target_dem_fuzzer: Split into a fuzzer fuzzing at the protocol level and one...
Michael Niedermayer [Sun, 19 Jul 2020 15:54:10 +0000 (17:54 +0200)]
tools:target_dem_fuzzer: Split into a fuzzer fuzzing at the protocol level and one fuzzing a fixed demuxer input

This should improve coverage and should improve the efficiency of seed files

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavcodec/crystalhd: Remove unused packet
Andreas Rheinhardt [Fri, 11 Sep 2020 14:28:25 +0000 (16:28 +0200)]
avcodec/crystalhd: Remove unused packet

Unused since 41b0561dc7246b72a834067da539ae98b1ec6631.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavcodec/av1dec: fix setting pix_fmt
James Almer [Sat, 12 Sep 2020 20:39:45 +0000 (17:39 -0300)]
avcodec/av1dec: fix setting pix_fmt

Fill the array with the software pix_fmt and move the avctx->hwaccel
check back to the proper place.
Also remove the avoid probing flag to ensure an external av1 decoder
will not set a pix_fmt we don't want during format probing.

Signed-off-by: James Almer <jamrial@gmail.com>
4 years agoavcodec/av1dec: update reference frame state on show_existing_frame
James Almer [Wed, 9 Sep 2020 22:14:01 +0000 (19:14 -0300)]
avcodec/av1dec: update reference frame state on show_existing_frame

As defined in Section 7.4

Signed-off-by: James Almer <jamrial@gmail.com>
4 years agoavcodec/av1dec: set chroma_sample_location
James Almer [Wed, 9 Sep 2020 21:42:00 +0000 (18:42 -0300)]
avcodec/av1dec: set chroma_sample_location

Signed-off-by: James Almer <jamrial@gmail.com>
4 years agoavcodec/av1dec: use av_cmp_q() to compare aspect ratio
James Almer [Wed, 9 Sep 2020 19:57:50 +0000 (16:57 -0300)]
avcodec/av1dec: use av_cmp_q() to compare aspect ratio

Signed-off-by: James Almer <jamrial@gmail.com>
4 years agoavcodec/av1_parser: don't set AVCodecContext frame dimensions
James Almer [Wed, 9 Sep 2020 18:40:07 +0000 (15:40 -0300)]
avcodec/av1_parser: don't set AVCodecContext frame dimensions

Let the internal decoder take care of it, as frame reordering
may result in different values exported by either module.

Signed-off-by: James Almer <jamrial@gmail.com>