]> git.sesse.net Git - ffmpeg/log
ffmpeg
3 years agoavformat/argo_asf: fix enforcement of chunk count
Zane van Iperen [Sat, 19 Sep 2020 02:35:42 +0000 (12:35 +1000)]
avformat/argo_asf: fix enforcement of chunk count

Enforcing num_chunks == 1 only makes sense when demuxing from an ASF
file. When embedded in a BRP file, an ASF stream can have multiple chunks.

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
3 years agoavformat/swfdec: Avoid unnecessary skip
Andreas Rheinhardt [Sun, 20 Sep 2020 06:46:16 +0000 (08:46 +0200)]
avformat/swfdec: Avoid unnecessary skip

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/swfenc: Fix memleak upon write_header error
Andreas Rheinhardt [Sun, 20 Sep 2020 06:05:58 +0000 (08:05 +0200)]
avformat/swfenc: Fix memleak upon write_header error

The SWF muxer accepts at most one mp3 audio and at most one VP6F, FLV1
or MJPEG stream. Upon encountering an mp3 stream, a fifo is allocated
that leaks if one of the subsequent streams is incompliant with the
restrictions mentioned above or if the framerate or samplerate are
invalid. This is fixed by adding a deinit function to free said fifo.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agodnn_backend_native_layer_conv2d.c: fix bug of loop boundary in single thread mode.
Xu Jun [Sat, 19 Sep 2020 15:24:25 +0000 (23:24 +0800)]
dnn_backend_native_layer_conv2d.c: fix bug of loop boundary in single thread mode.

Before patch, fate test for dnn may fail in some Windows environment
while succeed in my Linux. The bug was caused by a wrong loop boundary.
After patch, fate test succeed in my windows mingw 64-bit.

Signed-off-by: Xu Jun <xujunzz@sjtu.edu.cn>
Signed-off-by: Guo, Yejun <yejun.guo@intel.com>
3 years agoavformat/rmdec: Fix potential crash on allocation failure
Andreas Rheinhardt [Mon, 20 Jul 2020 20:44:42 +0000 (22:44 +0200)]
avformat/rmdec: Fix potential crash on allocation failure

The RealMedia demuxer uses the priv_data of its streams to store a
structure containing an AVPacket. These packets are unreferenced in the
read_close function, yet said function simply presumed that the
priv_data has been successfully allocated. This implies that it mustn't
be called when an allocation of priv_data fails; but this can happen
since commit 35bbc1955a58ba74552c50d9161084644f00bbd3 if one has a
stream with multiple substreams (also exported as AVStream) and if
allocating the priv_data for one of these substreams fails.

This has been fixed by making sure that read_close can handle the case
in which priv_data has not been successfully allocated.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/rmdec: Actually return value < 0 on read_header failure
Andreas Rheinhardt [Mon, 20 Jul 2020 19:14:15 +0000 (21:14 +0200)]
avformat/rmdec: Actually return value < 0 on read_header failure

The RealMedia demuxer's read_header function initially initializes ret,
the variable designated for the return variable to -1. Afterwards, chunks
of the file are parsed in a loop until an error happens or until the actual
frame data is encountered. If the first function whose return
value is put into ret doesn't fail, then ret contains a value >= 0
(actually == 0) and this is what will be returned if an error is
encountered afterwards.

This is a regression since 35bbc1955a58ba74552c50d9161084644f00bbd3.
Before that, ret had never been overwritten with a nonnegative value.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/avidec: Fix memleak when error happens after creating DV stream
Andreas Rheinhardt [Tue, 18 Aug 2020 21:21:31 +0000 (23:21 +0200)]
avformat/avidec: Fix memleak when error happens after creating DV stream

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mpegaudiodec*: Cleanup generically on init failure
Andreas Rheinhardt [Tue, 15 Sep 2020 06:33:22 +0000 (08:33 +0200)]
avcodec/mpegaudiodec*: Cleanup generically on init failure

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mpegaudiodec_float: Avoid indirection with float dsp function
Andreas Rheinhardt [Tue, 15 Sep 2020 06:16:13 +0000 (08:16 +0200)]
avcodec/mpegaudiodec_float: Avoid indirection with 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>
3 years agoavcodec/mpegaudiodec_template: Check return value of subdecoder
Andreas Rheinhardt [Tue, 15 Sep 2020 05:13:46 +0000 (07:13 +0200)]
avcodec/mpegaudiodec_template: Check return value of subdecoder

After all, allocating an AVFloatDSPContext might have failed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/ljpegenc: Don't free buffer known to be NULL
Andreas Rheinhardt [Tue, 15 Sep 2020 00:09:42 +0000 (02:09 +0200)]
avcodec/ljpegenc: Don't free buffer known to be NULL

The lossless JPEG encoder allocates one buffer in its init function
and freeing said buffer is the only thing done in its close function.
Despite this the init function called the close function if allocating
said buffer fails, although there is nothing to free in this case.
This commit stops doing this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/j2kenc: Fix leaks on init failure
Andreas Rheinhardt [Mon, 14 Sep 2020 23:29:58 +0000 (01:29 +0200)]
avcodec/j2kenc: Fix leaks on init failure

The JPEG2000 encoder did not clean up after itself on error.
This commit fixes this by modifying the cleanup function to be able to
handle only partially allocated structures and 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>
3 years agoavcodec/indeo3: Cleanup generically after init failure
Andreas Rheinhardt [Mon, 14 Sep 2020 17:58:07 +0000 (19:58 +0200)]
avcodec/indeo3: Cleanup generically after init failure

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/imc: Avoid indirection when calling float dsp function
Andreas Rheinhardt [Mon, 14 Sep 2020 17:43:49 +0000 (19:43 +0200)]
avcodec/imc: Avoid indirection when calling float dsp function

Do this by only keeping the only function pointer from
the AVFloatDSPContext that is needed lateron.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/hq_hqadata: Make local arrays static
Andreas Rheinhardt [Mon, 14 Sep 2020 16:59:56 +0000 (18:59 +0200)]
avcodec/hq_hqadata: Make local arrays static

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/hnm4video: Don't reimplement FFSWAP()
Andreas Rheinhardt [Mon, 14 Sep 2020 16:09:09 +0000 (18:09 +0200)]
avcodec/hnm4video: Don't reimplement FFSWAP()

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/hnm4video: Don't return nonsense error messages
Andreas Rheinhardt [Mon, 14 Sep 2020 15:53:58 +0000 (17:53 +0200)]
avcodec/hnm4video: Don't return nonsense error messages

The HNM 4 video decoder's init function claimed that an allocation
failed if the image dimensions are wrong. This is fixed in this commit:
The dimensions are checked before the allocations are attempted.
The check whether width * height is zero is redundant as
av_image_check_size() already checks for this; it has been removed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/hnm4video: Cleanup generically on init failure
Andreas Rheinhardt [Mon, 14 Sep 2020 15:48:20 +0000 (17:48 +0200)]
avcodec/hnm4video: Cleanup generically on init failure

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/g722enc: Cleanup generically on init failure
Andreas Rheinhardt [Mon, 14 Sep 2020 15:21:12 +0000 (17:21 +0200)]
avcodec/g722enc: Cleanup generically on init failure

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/flashsv2enc: Return better error codes
Andreas Rheinhardt [Mon, 14 Sep 2020 15:02:04 +0000 (17:02 +0200)]
avcodec/flashsv2enc: Return better error codes

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/flashsv2enc: Cleanup generically after init failure
Andreas Rheinhardt [Mon, 14 Sep 2020 14:57:49 +0000 (16:57 +0200)]
avcodec/flashsv2enc: Cleanup generically after init failure

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/flashsv2enc: Check allocations for success before usage
Andreas Rheinhardt [Mon, 14 Sep 2020 14:56:13 +0000 (16:56 +0200)]
avcodec/flashsv2enc: Check allocations for success before usage

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/flashsvenc: Remove unused z_stream
Andreas Rheinhardt [Mon, 14 Sep 2020 14:37:58 +0000 (16:37 +0200)]
avcodec/flashsvenc: Remove unused z_stream

This encoder uses the compress2 utility function provided by zlib
instead of using a z_stream.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/flashsvenc: Avoid allocation of buffer, fix memleak
Andreas Rheinhardt [Mon, 14 Sep 2020 14:28:32 +0000 (16:28 +0200)]
avcodec/flashsvenc: Avoid allocation of buffer, fix memleak

Up until now, the flashsv encoder tried to allocate two buffers in its
init function; if only one of these allocations succeeds, the other
buffer leaks. Fix this by making one of these buffers part of the
context (its size is a compile-time constant).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/vf_datascope: fix oscilloscope with gray>8 depth
Paul B Mahol [Sat, 19 Sep 2020 14:34:55 +0000 (16:34 +0200)]
avfilter/vf_datascope: fix oscilloscope with gray>8 depth

3 years agoavformat/argo_{asf,brp}: use variable frame sizes when (de)muxing adpcm_argo
Zane van Iperen [Tue, 15 Sep 2020 21:39:51 +0000 (07:39 +1000)]
avformat/argo_{asf,brp}: use variable frame sizes when (de)muxing adpcm_argo

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
3 years agoavcodec/adpcm_{psx,argo}: add missing indent
Zane van Iperen [Wed, 16 Sep 2020 07:09:57 +0000 (17:09 +1000)]
avcodec/adpcm_{psx,argo}: add missing indent

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
3 years agoavcodec/adpcm_argo: support decoding multiple frames
Zane van Iperen [Sat, 12 Sep 2020 12:02:26 +0000 (22:02 +1000)]
avcodec/adpcm_argo: support decoding multiple frames

Increases decode speed significantly.

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
3 years agoavformat/3dostr: Check remaining buffer in probe before 8 byte step
Michael Niedermayer [Fri, 18 Sep 2020 22:11:59 +0000 (00:11 +0200)]
avformat/3dostr: Check remaining buffer in probe before 8 byte step

Fixes: segfault
Fixes: signal_sigabrt_7ffff6ae7cc9_7213_0d6457b9d6897fa7c78507fa5de53510.ts
Regression since: 3ac45bf66561a667260cac37223c0393f7333fca

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavcodec/tiff: Fix default white level
Michael Niedermayer [Thu, 16 Jul 2020 20:42:14 +0000 (22:42 +0200)]
avcodec/tiff: Fix default white level

According to the spec bits per sample should be used

Fix invalid shift with bpp=32
Fixes: shift exponent 32 is too large for 32-bit type 'unsigned int'
Fixes: 23507/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-4815432665268224
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavcodec/diracdsp: Fix integer anomaly in dequant_subband_*
Michael Niedermayer [Sat, 18 Jul 2020 12:30:19 +0000 (14:30 +0200)]
avcodec/diracdsp: Fix integer anomaly in dequant_subband_*

Fixes: negation of -2147483648 cannot be represented in type 'int32_t' (aka 'int'); cast to an unsigned type to negate this value to itself
Fixes: 23760/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DIRAC_fuzzer-604209011412172
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agotools/target_dec_fuzzer: Adjust VQA threshold
Michael Niedermayer [Sat, 18 Jul 2020 19:58:36 +0000 (21:58 +0200)]
tools/target_dec_fuzzer: Adjust VQA threshold

Fixes: Timeout (169sec -> 9sec)
Fixes: 23745/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VQA_fuzzer-5638172179693568
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavutil/fixed_dsp: Fix integer overflows in butterflies_fixed_c()
Michael Niedermayer [Thu, 16 Jul 2020 20:58:13 +0000 (22:58 +0200)]
avutil/fixed_dsp: Fix integer overflows in butterflies_fixed_c()

Fixes: signed integer overflow: 0 - -2147483648 cannot be represented in type 'int'
Fixes: 23646/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AAC_FIXED_fuzzer-5480991098667008
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoRevert "avcodec/vlc: Add macro for ff_init_vlc_sparse()"
Andreas Rheinhardt [Fri, 18 Sep 2020 06:16:36 +0000 (08:16 +0200)]
Revert "avcodec/vlc: Add macro for ff_init_vlc_sparse()"

This reverts commit 61669b7c40b8dc3a0841768fb39c7567513b7cfc.

This commit broke building with MSVC due to its spec-incompliant handling
of ',' in __VA_ARGS__: These are not treated as argument separators for
further macros, so that in our case the init_vlc2() macro is treated as
having only one argument whenever the init_vlc() macro is used. See [1]
for further details.

[1]: https://reviews.llvm.org/D69626

Reviewed-by: Hendrik Leppkes <h.leppkes@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat: add CRI AAX demuxer
Paul B Mahol [Sat, 12 Sep 2020 15:42:16 +0000 (17:42 +0200)]
avformat: add CRI AAX demuxer

3 years agoavformat: add DAT CCTV demuxer
Paul B Mahol [Fri, 11 Sep 2020 22:56:11 +0000 (00:56 +0200)]
avformat: add DAT CCTV demuxer

3 years agoavcodec/ffwavesynth: Cleanup generically after init failure
Andreas Rheinhardt [Mon, 14 Sep 2020 04:03:04 +0000 (06:03 +0200)]
avcodec/ffwavesynth: Cleanup generically after init failure

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/escape130: Cleanup generically on init failure
Andreas Rheinhardt [Mon, 14 Sep 2020 02:04:27 +0000 (04:04 +0200)]
avcodec/escape130: Cleanup generically on init failure

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/ac3enc_float, eac3enc: Fix leaks on init error
Andreas Rheinhardt [Mon, 14 Sep 2020 01:35:52 +0000 (03:35 +0200)]
avcodec/ac3enc_float, eac3enc: Fix leaks on init error

The AC-3 encoders (both floating- as well as fixed-point) as well as
the EAC-3 encoder share code: All use ff_ac3_encode_init() as well as
ff_ac3_encode_close(). Until ee726e777b851cdd4e28cdab36b38f0c39e35ea9
ff_ac3_encode_init() called ff_ac3_encode_close() to clean up on error.
Said commit removed this and instead set the FF_CODEC_CAP_INIT_CLEANUP
flag; but it did the latter only for the fixed-point AC-3 encoder and
not for the other two users of ff_ac3_encode_init(). This caused any
already allocated buffer to leak upon a subsequent error for the two
other encoders.

This commit fixes this by adding the FF_CODEC_CAP_INIT_CLEANUP flag
to the other two encoders using ff_ac3_encode_init().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/ac3enc_template: Don't free uninitialized pointers on error
Andreas Rheinhardt [Mon, 14 Sep 2020 00:59:51 +0000 (02:59 +0200)]
avcodec/ac3enc_template: Don't free uninitialized pointers on error

The ac3 encoders (fixed- and floating-point AC-3 as well as the EAC-3
encoder) all allocate an array whose elements are pointers to other
buffers. The array is not zeroed initially so that if an allocation of
one of the subbuffers fails, the other pointers are uninitialized.
This causes problems when cleaning, so zero the array initially.

(Only the fixed-point AC-3 encoder was affected by this, because
the other two don't clean up at all in case of errors during init.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/dxa: Cleanup generically after init failure
Andreas Rheinhardt [Mon, 14 Sep 2020 00:31:46 +0000 (02:31 +0200)]
avcodec/dxa: Cleanup generically after init failure

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/cngenc: Cleanup generically after init failure
Andreas Rheinhardt [Mon, 14 Sep 2020 00:00:11 +0000 (02:00 +0200)]
avcodec/cngenc: Cleanup generically after init failure

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/cngenc: Replace av_free() by av_freep() in close function
Andreas Rheinhardt [Sun, 13 Sep 2020 23:56:44 +0000 (01:56 +0200)]
avcodec/cngenc: Replace av_free() by av_freep() in close function

This avoids leaving pointers to already freed memory in memory.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/atrac3: Avoid indirection when calling float dsp function
Andreas Rheinhardt [Sun, 13 Sep 2020 19:10:20 +0000 (21:10 +0200)]
avcodec/atrac3: Avoid indirection when calling float dsp function

Do this by only keeping the only function pointer from
the AVFloatDSPContext that is needed lateron.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/atrac3: Cleanup generically after init failure
Andreas Rheinhardt [Sun, 13 Sep 2020 19:05:52 +0000 (21:05 +0200)]
avcodec/atrac3: Cleanup generically after init failure

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/atrac1: Avoid indirection when calling float dsp function
Andreas Rheinhardt [Sun, 13 Sep 2020 18:59:11 +0000 (20:59 +0200)]
avcodec/atrac1: Avoid indirection when calling float dsp function

Do this by only keeping the only function pointer from
the AVFloatDSPContext that is needed lateron.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/alacenc: Don't free unnecessarily
Andreas Rheinhardt [Sun, 13 Sep 2020 18:27:34 +0000 (20:27 +0200)]
avcodec/alacenc: Don't free unnecessarily

The init function of the ALAC encoder calls its own close function
if a call to ff_lpc_init() fails; yet nothing has been allocated before
that point (except extradata which is freed generically) 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.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/alacenc: Remove redundant code to free extradata
Andreas Rheinhardt [Sun, 13 Sep 2020 18:16:30 +0000 (20:16 +0200)]
avcodec/alacenc: Remove redundant code to free extradata

It is already freed generically for encoders.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/av1dec: Check tiles sizes, fix assert, don't read bytes bitwise
Andreas Rheinhardt [Thu, 17 Sep 2020 03:09:19 +0000 (05:09 +0200)]
avcodec/av1dec: Check tiles sizes, fix assert, don't read bytes bitwise

Tiles have a size field with a length from one to four bytes. As such it
is not possible to read it all at once with a call to get_bits() as this
only allows to read up to 25 bits; this is guarded by an av_assert2. Yet
this is done by the AV1 decoder in get_tiles_info(). It has been done
despite said size fields being byte-aligned. This commit fixes this by
using the bytestream2 API instead.

Furthermore, it is now explicitly checked whether the data is
consistent, i.e. whether the data that is supposed to be there extends
beyond the end of the data actually present.

Reviewed-by: Wang, Fei W <fei.w.wang@intel.com>
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/smacker: Avoid code duplication
Andreas Rheinhardt [Fri, 24 Jul 2020 13:51:09 +0000 (15:51 +0200)]
avcodec/smacker: Avoid code duplication

Besides the obvious advantage of less code this also has a performance
impact: For GCC 9 the time spent on one call to smka_decode_frame() for
the sample from ticket #2425 decreased from 1693619 to 1498127
decicycles. For Clang 9, it decreased from 1369089 to 1366465
decicycles.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/smacker: Use unsigned for prediction values
Andreas Rheinhardt [Fri, 26 Jun 2020 09:36:57 +0000 (11:36 +0200)]
avcodec/smacker: Use unsigned for prediction values

Up until now, the Smacker decoder has pretended that the prediction
values are signed in code like 'pred[0] += (unsigned)sign_extend(val, 16)'
(the cast has been added to this code later to fix undefined behaviour).
This has been even done in case the PCM format is u8.

Yet in case of 8/16 bit samples, only the lower 8/16 bit of the predicition
values are ever used, so one can just as well just use unsigned and
remove the sign extensions. This is what this commit does.

For GCC 9 the time for one call to smka_decode_frame() for the sample from
ticket #2425 decreased from 1709043 to 1693619 decicycles; for Clang 9
it went up from 1355273 to 1369089 decicycles.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/smacker: Avoid allocations for decoding Smacker
Andreas Rheinhardt [Fri, 24 Jul 2020 19:28:34 +0000 (21:28 +0200)]
avcodec/smacker: Avoid allocations for decoding Smacker

by using buffers on the stack instead. The fact that the effective
lifetime of most of the allocated buffers doesn't overlap enables one to
limit the stack space used to a fairly modest size (about 1.5 KiB).

That all the buffers used in HuffContexts have always the same number of
elements (namely 256) makes it possible to include the buffers directly
in the HuffContext. Doing so also makes the length field redundant; it has
therefore been removed.

This is beneficial for performance: For GCC 9 the time for one call to
smka_decode_frame() for the sample in ticket #2425 went down from
1794494 to 1709043 decicyles; for Clang 9 it decreased from 1449420 to
1355273 decicycles.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/smacker: Use symbols table
Andreas Rheinhardt [Fri, 24 Jul 2020 17:57:56 +0000 (19:57 +0200)]
avcodec/smacker: Use symbols table

Up until now, the return value of get_vlc2() has been used as an index
in an array that contained the value one is really interested in. Yet
since b613bacca9c256f1483c46847f713e47a0e9a5f6 this is no longer
necessary, as one can store the value that is right now stored in the
array in the VLC internal table.

This also means that all the information from the eight bit Huffman trees
are now stored in the corresponding VLC table; this will enable us to
remove several allocations lateron.

This improved performance: For GCC 9 the time for one call of
smka_decode_frame() for the sample from ticket #2425 decreased from
1811706 to 1794494 decicycles; for Clang 9 the number went from 1471663
to 1449420 decicycles.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/smacker: Use smaller types
Andreas Rheinhardt [Thu, 25 Jun 2020 19:23:52 +0000 (21:23 +0200)]
avcodec/smacker: Use smaller types

This will mean that we will need less stack space lateron when these
arrays are no longer heap-allocated.

No discernible speed impact.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/smacker: Disentangle two contexts
Andreas Rheinhardt [Thu, 25 Jun 2020 18:46:00 +0000 (20:46 +0200)]
avcodec/smacker: Disentangle two contexts

Smacker uses two types of Huffman trees: Those for eight bit values and
those for 16 bit values. Given that both return their values via arrays
and that both need to check not to overrun their array, the context for
parsing eight bit values (HuffContext) will necessarily exhibit certain
similarities with the context used for parsing 16 bit values (DBCtx).
These similarities led to using a HuffContext in addition a DBCtx for
parsing 16 bit trees.

This stands in the way of further developments for the HuffContext struct
(when parsing eight bit trees, the length of the arrays are always 256,
so that one can inline said value and move the currently heap-allocated
tables directly in the structure).

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/smacker: Replace implicit checks for overread by explicit ones
Andreas Rheinhardt [Sat, 25 Jul 2020 17:00:28 +0000 (19:00 +0200)]
avcodec/smacker: Replace implicit checks for overread by explicit ones

Using explicit checks has the advantage that one can combine several
checks into one and does not have to check every time. E.g. reading a
16bit PCM sample involves two calls to get_vlc2(), each of which may
read up to three times up to SMKTREE_BITS (= 9) bits. But given that the
padding that the input packet is supposed to have is large enough, it is
no problem to only check once for each sample.

This turned out to be beneficial for performance: For GCC 9, the time for
one call of smka_decode_frame() for the sample from ticket #2425 went down
from 2055905 to 1804751 decicycles; for Clang 9 it went down from 1510538
to 1479680 decicycles.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/smacker: Remove redundant checks for NULL before freeing
Andreas Rheinhardt [Sun, 26 Jul 2020 07:13:16 +0000 (09:13 +0200)]
avcodec/smacker: Remove redundant checks for NULL before freeing

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/smacker: Remove redundant checks when reading VLC codes
Andreas Rheinhardt [Sat, 25 Jul 2020 13:14:53 +0000 (15:14 +0200)]
avcodec/smacker: Remove redundant checks when reading VLC codes

The VLC codes in question originate from a Huffmann tree and so every
sequence of bits that is longer than the longest code contains an
initial sequence that is a valid code. Given that it has been checked
during reading said tree (and once again in ff_init_vlc_sparse()) that
the length of each code is <= 3 * the number of bits read at once when
reading codes, get_vlc2() will always find a matching entry.

These checks have been added in 71d3c25a7ef442ac2dd7b6fbf7c489ebc0b58e9b
at a time when the length of the codes had not been checked when parsing
the tree.

For GCC 9 and the sample from ticket #2425 this led to a slight
performance regression: The time for one call to smka_decode_frame()
increased from 2053671 to 2064529 decicycles; for Clang 9, performance
improved from 1521288 to 1508459 decicycles.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/smacker: Remove redundant check when decoding header trees
Andreas Rheinhardt [Fri, 24 Jul 2020 18:56:46 +0000 (20:56 +0200)]
avcodec/smacker: Remove redundant check when decoding header trees

When length is zero for a leaf node (which happens iff the Huffman tree
consists of one leaf node only), prefix is also automatically zero.

Performance impact is negligible: For GCC 9 and the sample from #2425,
the time for one call to smka_decode_frame() decreased from 2053758 to
2053671 decicycles; for Clang 9 it went from 1523153 to 1521288.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/smacker: Don't zero-initialize unnecessarily
Andreas Rheinhardt [Thu, 25 Jun 2020 14:59:13 +0000 (16:59 +0200)]
avcodec/smacker: Don't zero-initialize unnecessarily

With the possible exception of the "last" values when decoding video,
only the part that is actually initialized with values derived from the
bitstream is used afterwards, so it is unnecessary to zero everything at
the beginning. This is also no problem for the "last" values at all,
because they are reset for every frame anyway.

While at it, use sizeof(variable) instead of sizeof(type).

Performance increased slightly: For GCC, from 2068389 decicycles per call
to smka_decode_frame() when decoding the sample from ticket #2425 to 2053758
decicycles; for Clang, from 1534188 to 1523153 decicycles.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/smacker: Use better nb_codes estimate when initializing VLC
Andreas Rheinhardt [Thu, 25 Jun 2020 14:50:24 +0000 (16:50 +0200)]
avcodec/smacker: Use better nb_codes estimate when initializing VLC

Using the real number of read codes allows to leave a loop in
ff_init_vlc_sparse earlier; notice that all codes not explicitly
set by reading data have been set to zero earlier (i.e. they are
zero-length codes) and such codes are ignored by ff_init_vlc_sparse.

This improves performance: When compiled with GCC 9, the time spent on
one call to smka_decode_frame() for the sample from ticket #2425
decreased from 2195367 decicycles to 2068389 decicycles. For Clang 9,
it improved from 1602075 to 1534188 decicycles. These tests have been
performed 20 times and each times the input file has been looped
32 times to get a sufficient number of frames.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/smacker: Use unsigned for shift
Andreas Rheinhardt [Thu, 30 Jul 2020 11:20:09 +0000 (13:20 +0200)]
avcodec/smacker: Use unsigned for shift

Given that the code currently accepts only 27 bits long Huffman codes,
the shift 1 << (length - 1) with length in 1..28 that is performed when
parsing the tree is safe. Yet if this limit were ever expanded to the
full 32 bits, this shift would be potentially undefined. So simply use
unsigned.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/smacker: Forward error codes
Andreas Rheinhardt [Wed, 29 Jul 2020 20:00:31 +0000 (22:00 +0200)]
avcodec/smacker: Forward error codes

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/smacker: Use same variable for return values and errors
Andreas Rheinhardt [Sat, 25 Jul 2020 11:29:52 +0000 (13:29 +0200)]
avcodec/smacker: Use same variable for return values and errors

smacker_decode_header_tree() uses different variables for return values
(res) and for errors (err) leading to code like
res = foo(bar);
if (res < 0) {
    err = res;
    goto error;
}
Given that no positive return value is ever used at all one can simplify
the above by removing the intermediate res.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/smacker: Directly goto error in case of error
Andreas Rheinhardt [Sat, 25 Jul 2020 11:05:06 +0000 (13:05 +0200)]
avcodec/smacker: Directly goto error in case of error

The earlier version did not error out directly in case an error happens,
because it would lead to a leak: An allocated array is only reachable
via a local variable at that time; it is only attached to more permanent
storage at the end. While it would be possible to add custom code for
freeing on error (instead of reusing the ordinary code for doing so),
this commit takes the opposite approach and attaches the newly allocated
array to its permanent place immediately after its allocation.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/smacker: Improve header table error checks
Andreas Rheinhardt [Wed, 29 Jul 2020 15:25:16 +0000 (17:25 +0200)]
avcodec/smacker: Improve header table error checks

The extradata for Smacker video contains Huffman trees as well as a
field containing the size (in bytes) of said Huffman tree when stored
as a table. Due to three special values the decoder allocates more than
the size field indicates; yet when it parses the table it only errors
out if the number of elements exceeds the number of allocated elements
and not the number of elements as indicated by the size field. As a
consequence, there might be less than three elements available at the
end, so that another check for this is necessary.

This commit changes this: It is always made sure that the three elements
reserved to (potentially) use them to store the special values are not
used to store ordinary tree entries. This allows to remove the extra
check at the end.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 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>
3 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>
3 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>
3 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>
3 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

3 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>
3 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>
3 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>
3 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

3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>