]> git.sesse.net Git - ffmpeg/log
ffmpeg
3 years agoavcodec: add a mention about get_encode_buffer in the old encode API doxy
James Almer [Wed, 10 Mar 2021 01:24:16 +0000 (22:24 -0300)]
avcodec: add a mention about get_encode_buffer in the old encode API doxy

Direct users to the callback that should be used to keep supporting user
provided buffers with the new encode API.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavfilter/vf_xfade: drop unused frames from inactive inputs
Paul B Mahol [Sun, 14 Mar 2021 12:06:50 +0000 (13:06 +0100)]
avfilter/vf_xfade: drop unused frames from inactive inputs

3 years agodoc/filters: note default for zoompan's duration
Gyan Doshi [Sun, 14 Mar 2021 08:37:24 +0000 (14:07 +0530)]
doc/filters: note default for zoompan's duration

3 years agoavcodec/flacdec: Avoid undefined shift in error case
Michael Niedermayer [Mon, 8 Mar 2021 23:55:38 +0000 (00:55 +0100)]
avcodec/flacdec: Avoid undefined shift in error case

Fixes: flac_1040988
Reported-by: Thomas Guilbert <tguilbert@google.com>
Reviewed-by: Thomas Guilbert <tguilbert@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavformat/cinedec: Fix index_entries size check
Michael Niedermayer [Sun, 31 Jan 2021 21:42:54 +0000 (22:42 +0100)]
avformat/cinedec: Fix index_entries size check

Fixes: out of array access
Fixes: 29868/clusterfuzz-testcase-minimized-ffmpeg_dem_CINE_fuzzer-5692001957445632
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/h264_metadata_bsf: Check nb_units before accessing the first in h264_metadata...
Michael Niedermayer [Sun, 31 Jan 2021 21:36:52 +0000 (22:36 +0100)]
avcodec/h264_metadata_bsf: Check nb_units before accessing the first in h264_metadata_update_fragment()

Fixes: null pointer dereference
Fixes: 29835/clusterfuzz-testcase-minimized-ffmpeg_BSF_H264_METADATA_fuzzer-4712125383704576
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 agoavformat/aaxdec: Check that segments table has been initialized
Michael Niedermayer [Sun, 31 Jan 2021 21:05:18 +0000 (22:05 +0100)]
avformat/aaxdec: Check that segments table has been initialized

Fixes: Timeout
Fixes: 29766/clusterfuzz-testcase-minimized-ffmpeg_dem_AAX_fuzzer-5635887566290944
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/ffv1dec: Check if trailer is available
Michael Niedermayer [Sun, 31 Jan 2021 20:22:11 +0000 (21:22 +0100)]
avcodec/ffv1dec: Check if trailer is available

Fixes: out of array read
Fixes: 29750/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFV1_fuzzer-4808377272238080.fuzz
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/exr: Check col/line for integer overflow
Michael Niedermayer [Mon, 1 Feb 2021 20:24:50 +0000 (21:24 +0100)]
avcodec/exr: Check col/line for integer overflow

Fixes: signed integer overflow: -2272 + -2147483360 cannot be represented in type 'int'
Fixes: 30009/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EXR_fuzzer-5005660322398208
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 agoavformat: add Changelog entry for librist and bump minor
Marton Balint [Sat, 6 Mar 2021 23:20:15 +0000 (00:20 +0100)]
avformat: add Changelog entry for librist and bump minor

Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agoavformat/librist: clarify and limit buffer_size
Marton Balint [Sat, 6 Mar 2021 22:36:03 +0000 (23:36 +0100)]
avformat/librist: clarify and limit buffer_size

As suggested by librist developers.

Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agoavformat/librist: increase default loglevel
Marton Balint [Sat, 6 Mar 2021 21:53:21 +0000 (22:53 +0100)]
avformat/librist: increase default loglevel

Also remove AV_LOG_SIMULATE from the list as it is not used directly, and do
not use panic level on unknown loglevel, but make them warn. Also fix mapping of
NOTICE/INFO/VERBOSE and add documentation about when the option should actually
be used.

Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agoavformat/librist: simplify secret strlcpy
Marton Balint [Sat, 6 Mar 2021 21:31:06 +0000 (22:31 +0100)]
avformat/librist: simplify secret strlcpy

Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agoavformat/librist: make packet size adjustable for writing, fix it for reading
Marton Balint [Sat, 6 Mar 2021 21:26:13 +0000 (22:26 +0100)]
avformat/librist: make packet size adjustable for writing, fix it for reading

Maximum packet size is 10000 (RIST_MAX_PACKET_SIZE, which is unfortunately
private) minus the RIST protocol overhead which is 28 bytes for the unencrypted
case, 36 for the encrypted case.

Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agoavformat/librist: rework librist_read
Marton Balint [Sat, 6 Mar 2021 20:48:57 +0000 (21:48 +0100)]
avformat/librist: rework librist_read

Queue tracking makes no difference so remove it, return EAGAIN of no data is
available and rist data block needs to be freed even for zero sized packets.

Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agolibavformat: add librist protocol
Paul B Mahol [Sun, 28 Feb 2021 19:56:55 +0000 (20:56 +0100)]
libavformat: add librist protocol

This work is sponsored by Open Broadcast Systems.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
3 years agolibavutil/timer: Fix clang reserved-user-defined-literal
Christopher Degawa [Sat, 13 Mar 2021 04:20:37 +0000 (22:20 -0600)]
libavutil/timer: Fix clang reserved-user-defined-literal

clang errors when compiling with C++11 about needing spaces between
literal and identifier

Signed-off-by: Christopher Degawa <ccom@randomderp.com>
Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavdevice/pulse_audio_dec: do not read undersized frames
Marton Balint [Sat, 6 Feb 2021 18:48:51 +0000 (19:48 +0100)]
avdevice/pulse_audio_dec: do not read undersized frames

Keep on reading fragments until we got fragment_size amount of data, otherwise
we might get frames with 1-2 samples only if pa_stream_peek is called slightly
less frequently than sample rate.

Note that fragments might contain a lot less data than fragment_size, so
reading multiple fragments to get fragment_size amount of data is intentional.

Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agoavdevice/pulse_audio_dec: only set adjust latency flag if fragment_size is not set
Marton Balint [Thu, 11 Feb 2021 22:03:26 +0000 (23:03 +0100)]
avdevice/pulse_audio_dec: only set adjust latency flag if fragment_size is not set

Otherwise fragment_size is ignored.

Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agoavdevice/pulse_audio_dec: query actual fragment size
Marton Balint [Tue, 9 Feb 2021 23:15:00 +0000 (00:15 +0100)]
avdevice/pulse_audio_dec: query actual fragment size

Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agoavdevice/alsa_dec: make sure we have enough data in non-blocking mode
Marton Balint [Tue, 9 Feb 2021 21:24:50 +0000 (22:24 +0100)]
avdevice/alsa_dec: make sure we have enough data in non-blocking mode

Otherwise we might return 1-2 samples per packet if av_read_frame() call rate is
only sligthly less than the stream sample rate.

Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agoavcodec: add a get_encode_buffer() callback to AVCodecContext
James Almer [Sat, 20 Feb 2021 19:01:52 +0000 (16:01 -0300)]
avcodec: add a get_encode_buffer() callback to AVCodecContext

This callback is functionally the same as get_buffer2() is for decoders, and
implements for the new encode API the functionality of the old encode API had
where the user could provide their own buffers.

Reviewed-by: Lynne <dev@lynne.ee>
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Reviewed-by: Mark Thompson <sw@jkqxz.net>
Signed-off-by: James Almer <jamrial@gmail.com>
3 years agocbs_sei: Detect payload overflows when reading SEI messages
Mark Thompson [Tue, 2 Feb 2021 20:58:11 +0000 (20:58 +0000)]
cbs_sei: Detect payload overflows when reading SEI messages

The top-level GetBitContext is sized for the whole NAL unit, so it fails
to detect overflows where a payload continues into the following message.
To fix that, we make a new context on the stack for reading each payload.

Fixes: 29892/clusterfuzz-testcase-minimized-ffmpeg_BSF_H264_REDUNDANT_PPS_fuzzer-6310830956216320
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Tested-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agocbs_h265: Detect more reference combinations which would overflow the DPB
Mark Thompson [Wed, 3 Feb 2021 21:34:07 +0000 (21:34 +0000)]
cbs_h265: Detect more reference combinations which would overflow the DPB

In total, the number of short term references (from the selected short
term ref pic set), the number of long term references (combining both the
used candidates from the SPS and those defined in the slice header) and
the number of instances of the current picture (usually one, but can be
two if current picture reference is enabled) must never exceed the size
of the DPB.  This is a generalisation of the condition associated with
num_long_term_pics in 7.4.7.1.

We use this to apply tighter bounds to the number of long term pictures
referred to in the slice header, and also to detect the invalid case where
the second reference to the current picture would not fit in the DPB (this
case can't be detected earlier because an STRPS with 15 pictures can still
be valid in the same stream when used with a different PPS which does not
require two DPB slots for the current picture).

Fixes: 24913/clusterfuzz-testcase-minimized-ffmpeg_BSF_HEVC_METADATA_fuzzer-6261760693370880
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Tested-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavcodec/cbs_h26[45]: Remove redundant enum constants
Andreas Rheinhardt [Wed, 10 Mar 2021 10:26:52 +0000 (11:26 +0100)]
avcodec/cbs_h26[45]: Remove redundant enum constants

Unused since 8843607f495c95c1e67a3ce3d6f15dca6e252439.

Reviewed-by: Mark Thompson <sw@jkqxz.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/cbs_sei: Fix leak of AVBufferRef on error
Andreas Rheinhardt [Tue, 9 Mar 2021 21:11:52 +0000 (22:11 +0100)]
avcodec/cbs_sei: Fix leak of AVBufferRef on error

An AVBufferRef (and the corresponding AVBuffer and the underlying actual
buffer) would leak in ff_cbs_sei_add_message() on error in case an error
happened after its creation and before it has been attached to more
permanent storage. Fix this by only creating the AVBufferRef immediately
before attaching it to its intended target position.

(Given that no SEI message currently created is refcounted, the above
can't happen at the moment. But Coverity already nevertheless noticed:
This commit fixes Coverity issue #1473521.)

Reviewed-by: Mark Thompson <sw@jkqxz.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/cbs_sei: Don't use -1th element of array
Andreas Rheinhardt [Tue, 9 Mar 2021 20:29:24 +0000 (21:29 +0100)]
avcodec/cbs_sei: Don't use -1th element of array

(This affected only suffix SEI messages; yet no such SEI messages are
currently inserted.)

Reviewed-by: Mark Thompson <sw@jkqxz.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/cbs: Remove redundant checks for CodedBitstreamContext.codec
Andreas Rheinhardt [Tue, 9 Mar 2021 19:16:04 +0000 (20:16 +0100)]
avcodec/cbs: Remove redundant checks for CodedBitstreamContext.codec

Setting this field happens immediately after the allocation in
ff_cbs_init(), so the whole CBS code may presume that any
CodedBitstreamContext has this set. Lots of code already presumed this,
yet ff_cbs_close() did it inconsistently: It checked before checking
whether the CodedBitstreamType has a close function; yet it simply
unconditionally read ctx->codec->priv_class. Coverity complained about
this in issue #1473564, which this commit fixes.

Reviewed-by: Mark Thompson <sw@jkqxz.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/nvenc: base timestamps on frameIntervalP
Martin Storsjö [Fri, 12 Mar 2021 20:42:02 +0000 (22:42 +0200)]
avcodec/nvenc: base timestamps on frameIntervalP

If b-frames were enabled implicitly (if max_b_frames wasn't set by
the caller at all, since a0949d0bcb0eee2f3fffcf9a4810c0295d14c0dc),
we wouldn't offset dts at all, producing invalid pts/dts combinations
(causing loud warnings by ffmpeg, or muxer errors if passed without
an extra cleanup pass).

Instead use frameIntervalP for offsetting, which should always be
accurate.

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
3 years agoavfilter/vf_uspp: Fix leak of packet side data
Andreas Rheinhardt [Fri, 12 Mar 2021 14:07:33 +0000 (15:07 +0100)]
avfilter/vf_uspp: Fix leak of packet side data

The uspp filter uses a special option ("no_bitstream") of
the Snow encoder to suppress it from generating output.
The filter therefore did not unref the packet after usage,
believing it to be blank. But this is wrong, as the Snow encoder
attaches quality stats side data to the packet.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/vf_uspp: Fix leak of qp-table on error
Andreas Rheinhardt [Fri, 12 Mar 2021 13:55:53 +0000 (14:55 +0100)]
avfilter/vf_uspp: Fix leak of qp-table on error

Fixes Coverity issue #1473500.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/decode: Reindentation
Andreas Rheinhardt [Fri, 12 Mar 2021 16:40:07 +0000 (17:40 +0100)]
avcodec/decode: Reindentation

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/decode: Remove always-true check
Andreas Rheinhardt [Fri, 12 Mar 2021 16:29:28 +0000 (17:29 +0100)]
avcodec/decode: Remove always-true check

Forgotten in 1fd76277708cf83572ba243e98f9e848c652f83d.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/adp, svs: Remove redundant av_shrink_packet()
Andreas Rheinhardt [Fri, 12 Mar 2021 08:23:46 +0000 (09:23 +0100)]
avformat/adp, svs: Remove redundant av_shrink_packet()

av_get_packet() already makes sure that the packet size is accurate
and that the packet data is zero-padded even when one could not read as
much as desired.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/gopher: Add support for Gopher over TLS
parazyd [Sun, 28 Feb 2021 22:47:05 +0000 (23:47 +0100)]
avformat/gopher: Add support for Gopher over TLS

This commit adds a "gophers" handler to the gopher protocol. gophers
is a community-adopted protocol that acts the same way like normal
gopher with the added TLS encapsulation.

The gophers protocol is supported by gopher servers like geomydae(8),
and clients like curl(1), clic(1), and hurl(1).

This commit also adds compilation guards to both gopher and gophers,
since now there are two protocols in the file it makes sense to
have this addition.

Signed-off-by: parazyd <parazyd@dyne.org>
Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agoavformat/gopher: Add default_whitelist to ff_gopher_protocol
parazyd [Sun, 28 Feb 2021 22:47:03 +0000 (23:47 +0100)]
avformat/gopher: Add default_whitelist to ff_gopher_protocol

Signed-off-by: parazyd <parazyd@dyne.org>
Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agoavcodec/gifenc: Actually use the shrunk palette
Derek Buitenhuis [Wed, 10 Mar 2021 15:18:41 +0000 (15:18 +0000)]
avcodec/gifenc: Actually use the shrunk palette

I have no idea how nobody, including myself, noticed this.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
3 years agoavcodec/h264_slice: don't copy frame data during error concealment
James Almer [Tue, 9 Mar 2021 02:10:10 +0000 (23:10 -0300)]
avcodec/h264_slice: don't copy frame data during error concealment

In addition to the fact that av_image_copy() cannot handle hardware pixel formats,
h->short_ref[0]->f may not be writable at this point.

Based on a patch by Hendrik Leppkes.

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavdevice/decklink: add missing include for buffer_size_t
James Almer [Thu, 11 Mar 2021 16:39:36 +0000 (13:39 -0300)]
avdevice/decklink: add missing include for buffer_size_t

Should fix compilation broken in f7abb53cb427515faac582f114ab97cbbd590280.

Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavisynth: fix audio on big endian
Stephen Hutchinson [Sun, 3 Jan 2021 22:58:36 +0000 (17:58 -0500)]
avisynth: fix audio on big endian

AviSynth+ outputs audio in the same format as the
OS, so assuming little endian formats as input
on big endian OSes results in nothing but static.

Signed-off-by: Stephen Hutchinson <qyot27@gmail.com>
3 years agoavisynth: populate field order
emcodem [Thu, 21 Jan 2021 17:59:45 +0000 (18:59 +0100)]
avisynth: populate field order

Fixes Trac ticket #8757

Signed-off-by: Stephen Hutchinson <qyot27@gmail.com>
3 years agoavisynth: more intelligent RGB flipping
Stephen Hutchinson [Tue, 7 Apr 2020 23:47:43 +0000 (19:47 -0400)]
avisynth: more intelligent RGB flipping

avs_is_color_space provides a generic way of checking whether the
video is RGB, and has been available through AVSC_API since 2.6.
This means that GetProcAddress doesn't have to run on every frame.

Signed-off-by: Stephen Hutchinson <qyot27@gmail.com>
3 years agoavformat/rawenc: Use init instead of write_header function
Andreas Rheinhardt [Mon, 8 Mar 2021 15:16:09 +0000 (16:16 +0100)]
avformat/rawenc: Use init instead of write_header function

force_one_stream() does not write anything.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/4xm: Check pre_gb in decode_i_block()
Michael Niedermayer [Tue, 9 Mar 2021 20:39:30 +0000 (21:39 +0100)]
avcodec/4xm: Check pre_gb in decode_i_block()

Fixes: Timeout
Fixes: 31257/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FOURXM_fuzzer-5150866229297152
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/buffer_internal: Include internal for buffer_size_t
Andreas Rheinhardt [Thu, 11 Mar 2021 10:39:58 +0000 (11:39 +0100)]
avutil/buffer_internal: Include internal for buffer_size_t

Fixes checkheaders.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agodnn/dnn_backend_native_layer_mathbinary: Fix leak upon error
Andreas Rheinhardt [Wed, 10 Mar 2021 17:45:07 +0000 (18:45 +0100)]
dnn/dnn_backend_native_layer_mathbinary: Fix leak upon error

Fixes Coverity issue #1473568.

Reviewed-by: Guo, Yejun <yejun.guo@intel.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agodnn/dnn_backend_native_layer_conv2d: Don't pretend convolution can fail
Andreas Rheinhardt [Wed, 10 Mar 2021 20:58:15 +0000 (21:58 +0100)]
dnn/dnn_backend_native_layer_conv2d: Don't pretend convolution can fail

It can't; these are just remnants of commit
3c7cad69f233252e5178f7732baa0da950d74bbd which let the worker threads
do the reallocation.

Reviewed-by: Guo, Yejun <yejun.guo@intel.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agodnn/dnn_backend_native_layer_conv2d: Check thread creation for errors
Andreas Rheinhardt [Wed, 10 Mar 2021 17:08:10 +0000 (18:08 +0100)]
dnn/dnn_backend_native_layer_conv2d: Check thread creation for errors

Fixes Coverity issue #1473533.

Reviewed-by: Guo, Yejun <yejun.guo@intel.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agodnn/dnn_backend_native_layer_conv2d: Check allocation
Andreas Rheinhardt [Wed, 10 Mar 2021 16:42:43 +0000 (17:42 +0100)]
dnn/dnn_backend_native_layer_conv2d: Check allocation

Reviewed-by: Guo, Yejun <yejun.guo@intel.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agodnn/dnn_backend_native_layer_conv2d: Avoid separate, unchecked allocations
Andreas Rheinhardt [Wed, 10 Mar 2021 16:38:36 +0000 (17:38 +0100)]
dnn/dnn_backend_native_layer_conv2d: Avoid separate, unchecked allocations

Reviewed-by: Guo, Yejun <yejun.guo@intel.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agodnn/dnn_backend_native_layer_conv2d: Fix memleak on error
Andreas Rheinhardt [Wed, 10 Mar 2021 16:22:29 +0000 (17:22 +0100)]
dnn/dnn_backend_native_layer_conv2d: Fix memleak on error

If an error happens when preparing the output data buffer, an already
allocated array would leak. Fix this by postponing its allocation.

Fixes Coverity issue #1473531.

Reviewed-by: Guo, Yejun <yejun.guo@intel.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agodnn/dnn_backend_native_layer_conv2d: Avoid allocation when single-threaded
Andreas Rheinhardt [Wed, 10 Mar 2021 16:03:01 +0000 (17:03 +0100)]
dnn/dnn_backend_native_layer_conv2d: Avoid allocation when single-threaded

Also fixes a memleak in single-threaded mode when an error happens
in preparing the output data buffer; and also removes an unchecked
allocation.

Reviewed-by: Guo, Yejun <yejun.guo@intel.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agodnn/dnn_backend_native_layer_conv2d: Join two arrays, avoid allocation
Andreas Rheinhardt [Wed, 10 Mar 2021 15:21:13 +0000 (16:21 +0100)]
dnn/dnn_backend_native_layer_conv2d: Join two arrays, avoid allocation

Fixes Coverity issue #1473507.

Reviewed-by: Guo, Yejun <yejun.guo@intel.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agodnn/dnn_backend_native_layer_conv2d: Fix memleak on realloc failure
Andreas Rheinhardt [Wed, 10 Mar 2021 14:40:36 +0000 (15:40 +0100)]
dnn/dnn_backend_native_layer_conv2d: Fix memleak on realloc failure

Reviewed-by: Guo, Yejun <yejun.guo@intel.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agodnn/dnn_backend_native: Fix typo in log message
Andreas Rheinhardt [Wed, 10 Mar 2021 14:27:52 +0000 (15:27 +0100)]
dnn/dnn_backend_native: Fix typo in log message

Reviewed-by: Guo, Yejun <yejun.guo@intel.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agodnn/dnn_backend_native: Don't use asserts for checks
Andreas Rheinhardt [Wed, 10 Mar 2021 13:00:26 +0000 (14:00 +0100)]
dnn/dnn_backend_native: Don't use asserts for checks

asserts should not be used instead of ordinary input checks.
Yet the native DNN backend did it: get_input_native() asserted that
the first dimension was one, despite this value coming directly from
the input file without having been sanitized.

Reviewed-by: Guo, Yejun <yejun.guo@intel.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agodnn/dnn_backend_native: Fix leak in case parsing options fails
Andreas Rheinhardt [Wed, 10 Mar 2021 01:59:47 +0000 (02:59 +0100)]
dnn/dnn_backend_native: Fix leak in case parsing options fails

Reviewed-by: Guo, Yejun <yejun.guo@intel.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agodnn/dnn_backend_native: Avoid allocation for checking file magic
Andreas Rheinhardt [Wed, 10 Mar 2021 01:34:14 +0000 (02:34 +0100)]
dnn/dnn_backend_native: Avoid allocation for checking file magic

Reviewed-by: Guo, Yejun <yejun.guo@intel.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoDoc: Tech Resolution Process
Jean-Baptiste Kempf [Wed, 10 Mar 2021 20:40:22 +0000 (21:40 +0100)]
Doc: Tech Resolution Process

3 years agoavcodec/libilbc: Support newer libiLBC versions
Andreas Rheinhardt [Thu, 11 Mar 2021 00:43:44 +0000 (01:43 +0100)]
avcodec/libilbc: Support newer libiLBC versions

Beginning with version 3.0, libiLBC switched the types of some parts
of their public API to size_t and renamed some types; the old names
continue to work as typedefs, but are deprecated. It furthermore
added version macros.

This commit uses said version macro to use the new types when using
newer libiLBC versions.

Reviewed-by: Timothy Gu <timothygu99@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavutil: use the buffer_size_t typedef where required
James Almer [Sat, 6 Mar 2021 16:58:26 +0000 (13:58 -0300)]
avutil: use the buffer_size_t typedef where required

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavfilter: use the buffer_size_t typedef where required
James Almer [Sat, 6 Mar 2021 17:16:45 +0000 (14:16 -0300)]
avfilter: use the buffer_size_t typedef where required

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavdevice: use the buffer_size_t typedef where required
James Almer [Sat, 6 Mar 2021 16:30:00 +0000 (13:30 -0300)]
avdevice: use the buffer_size_t typedef where required

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavformat: use the buffer_size_t typedef where required
James Almer [Sat, 6 Mar 2021 16:29:54 +0000 (13:29 -0300)]
avformat: use the buffer_size_t typedef where required

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec: use the buffer_size_t typedef where required
James Almer [Sat, 6 Mar 2021 16:29:37 +0000 (13:29 -0300)]
avcodec: use the buffer_size_t typedef where required

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavformat/utils: change AVStream side data related public function and struct size...
James Almer [Sat, 6 Mar 2021 18:40:58 +0000 (15:40 -0300)]
avformat/utils: change AVStream side data related public function and struct size types to size_t

av_stream_add_side_data() already defines size as a size_t, so this makes it
consistent across all side data functions.

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/packet: change side data related public function and struct size types to...
James Almer [Sat, 6 Mar 2021 15:43:52 +0000 (12:43 -0300)]
avcodec/packet: change side data related public function and struct size types to size_t

av_packet_add_side_data() already defines size as a size_t, so this makes it
consistent across all side data functions

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavutil/frame: change av_frame_new_side_data() size parameter type to size_t
James Almer [Sat, 6 Mar 2021 15:35:48 +0000 (12:35 -0300)]
avutil/frame: change av_frame_new_side_data() size parameter type to size_t

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavutil/buffer: change public function and struct size parameter types to size_t
James Almer [Sat, 6 Mar 2021 15:26:16 +0000 (12:26 -0300)]
avutil/buffer: change public function and struct size parameter types to size_t

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavfilter/af_dynaudnorm: make better check for available samples
Paul B Mahol [Wed, 10 Mar 2021 22:48:44 +0000 (23:48 +0100)]
avfilter/af_dynaudnorm: make better check for available samples

Also report more correct EOF timestamp.

3 years agoavfilter/vf_nnedi: Fix use of uninitialized value
Andreas Rheinhardt [Tue, 9 Mar 2021 21:43:13 +0000 (22:43 +0100)]
avfilter/vf_nnedi: Fix use of uninitialized value

Fixes Coverity issue #1473546.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agofftools/ffplay: do not write out of rdft visualization texture
Marton Balint [Wed, 3 Mar 2021 22:23:10 +0000 (23:23 +0100)]
fftools/ffplay: do not write out of rdft visualization texture

If the window is resized it was possible that xpos pointed outside the
visualization texture. By rearranging the overflow check we make sure this (and
a crash) does not happen.

We also don't have to use xleft for start position, as that is 0 anyways, and
if we ever want to take into account xleft then the texture should be
positioned accordingly when rendering.

Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agoavcodec/mediacodec_wrapper: use MediaCodecInfo.isSoftwareOnly() when available
sfan5 [Wed, 17 Feb 2021 15:51:09 +0000 (16:51 +0100)]
avcodec/mediacodec_wrapper: use MediaCodecInfo.isSoftwareOnly() when available

Added in Android 10 it provides a reliable way of filtering out
software decoders, unlike existing string-based checks.

3 years agoavcodec/mediacodec_wrapper: check if codec is software earlier
sfan5 [Wed, 17 Feb 2021 15:50:00 +0000 (16:50 +0100)]
avcodec/mediacodec_wrapper: check if codec is software earlier

3 years agoavformat/mvdec: Allocate extradata only once
Michael Niedermayer [Fri, 1 Jan 2021 23:36:39 +0000 (00:36 +0100)]
avformat/mvdec: Allocate extradata only once

Fixes: memleak
Fixes: 28686/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5822961932173312
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 agolibavcodec/amfenc_hevc: Recommend values for min and max video quantizer scale.
Ovchinnikov Dmitrii [Tue, 9 Mar 2021 19:05:07 +0000 (22:05 +0300)]
libavcodec/amfenc_hevc: Recommend values for min and max video quantizer scale.

Current settings makes bitrate larger than expected, more information:
https://github.com/HandBrake/HandBrake/issues/3447#issue-820490736

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/decode: Reindent after previous commits
Andreas Rheinhardt [Thu, 4 Mar 2021 13:04:08 +0000 (14:04 +0100)]
avcodec/decode: Reindent after previous commits

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/decode: Don't needlessly copy side-data for subtitles
Andreas Rheinhardt [Thu, 4 Mar 2021 12:49:20 +0000 (13:49 +0100)]
avcodec/decode: Don't needlessly copy side-data for subtitles

AVCodecInternal.last_pkt_props is not used when decoding subtitles;
ergo it makes no sense to set it at all.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/decode: Avoid stack packets when decoding subtitles
Andreas Rheinhardt [Thu, 4 Mar 2021 09:53:26 +0000 (10:53 +0100)]
avcodec/decode: Avoid stack packets when decoding subtitles

Use AVCodecInternal.buffer_pkt (previously only used in
avcodec_send_packet) instead of stack packets when decoding subtitles.
Also stop sharing side-data between packets and use the user-supplied
packet directly for decoding when possible (no subtitle decoder ever
modifies the packet it is given).
Reusing AVCodecInternal.buffer_pkt is based upon an idea from James
Almer.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/qsvdec: Make functions used only here static, remove header
Andreas Rheinhardt [Thu, 4 Mar 2021 15:08:41 +0000 (16:08 +0100)]
avcodec/qsvdec: Make functions used only here static, remove header

Forgotten after d78ecf10bd745cb69a71b32419e0661bfdcfb1fd.

(Also mark some AVPackets as const.)

Reviewed-by: Mark Thompson <sw@jkqxz.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec: Constify some AVPackets
Andreas Rheinhardt [Thu, 4 Mar 2021 12:13:20 +0000 (13:13 +0100)]
avcodec: Constify some AVPackets

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agomailmap: add entry for myself
Linjie Fu [Mon, 8 Mar 2021 15:06:10 +0000 (15:06 +0000)]
mailmap: add entry for myself

Signed-off-by: Linjie Fu <linjie.justin.fu@gmail.com>
3 years agoavcodec/dcadsp: Fix integer overflow in dmix_add_c()
Michael Niedermayer [Sat, 30 Jan 2021 18:09:36 +0000 (19:09 +0100)]
avcodec/dcadsp: Fix integer overflow in dmix_add_c()

Fixes: signed integer overflow: 1515225320 + 759416059 cannot be represented in type 'int'
Fixes: 29256/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DCA_fuzzer-5719088561258496
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 agoavformat/flvdec: Check double before cast in parse_keyframes_index()
Michael Niedermayer [Tue, 26 Jan 2021 15:50:10 +0000 (16:50 +0100)]
avformat/flvdec: Check double before cast in parse_keyframes_index()

Fixes: -2.21166e+304 is outside the range of representable values of type 'long'
Fixes: 29169/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5725452796821504
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 agoavformat/paf: Check for EOF before allocation in read_header()
Michael Niedermayer [Tue, 19 Jan 2021 23:11:34 +0000 (00:11 +0100)]
avformat/paf: Check for EOF before allocation in read_header()

Fixes: OOM
Fixes: 26584/clusterfuzz-testcase-minimized-ffmpeg_dem_PAF_fuzzer-5172661183053824
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 flv1 threshold
Michael Niedermayer [Wed, 20 Jan 2021 23:44:48 +0000 (00:44 +0100)]
tools/target_dec_fuzzer: Adjust flv1 threshold

Fixes: Timeout (long -> 95ms)
Fixes: 29068/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FLV_fuzzer-6509662832820224
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/aacdec_template: Avoid undefined negation in imdct_and_windowing_eld()
Michael Niedermayer [Wed, 20 Jan 2021 22:56:43 +0000 (23:56 +0100)]
avcodec/aacdec_template: Avoid undefined negation in imdct_and_windowing_eld()

Fixes: negation of -2147483648 cannot be represented in type 'INTFLOAT' (aka 'int'); cast to an unsigned type to negate this value to itself
Fixes: 29057/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AAC_FIXED_fuzzer-5642758933053440
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 agoavformat/swfdec: Check outlen before allocation
Michael Niedermayer [Thu, 21 Jan 2021 23:39:19 +0000 (00:39 +0100)]
avformat/swfdec: Check outlen before allocation

Fixes: Timeout (too long -> 241ms)
Fixes: 29083/clusterfuzz-testcase-minimized-ffmpeg_dem_SWF_fuzzer-6273684478230528
The source of the magic number is
A very quick simulation of the best case compression for "compress"
below is not nice written code as i did not expect I or anyone else
would ever see it again

I would have preferred some nicer expression or course, but thats
what it seems to be asymptotically. For smaller amounts of data a
tighter bound is possible but i saw no nice way to consider that
and it seems also overkill to try to do it more fine grained for
just this

main(){
    int64_t bits = 0;
    int bank = 256;
    int bitbank = 8;
    for(unsigned i = 0; i<1024*1024*1024*4U-100000;) {
        int word_size = bank-255;
        i += word_size;
        bits += bitbank;

        if (!(bank & (bank-1)))
            bitbank ++;
        bank++;
        if (bitbank > 16) {
            printf("BEST %f \n", 8.0 * i / bits );
            bank = 256;
            bitbank = 8;
        }
    }
}

above assumes i remembered correctly how the algorithm works but the
value was close to what actual compession of zeros gave

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/mpeg4videodec: add forgotten flags to mpeg4_options
Paul B Mahol [Tue, 2 Mar 2021 18:52:18 +0000 (19:52 +0100)]
avcodec/mpeg4videodec: add forgotten flags to mpeg4_options

3 years agomobiclip: fix copyright headers
Florian Nouwt [Mon, 8 Mar 2021 10:54:04 +0000 (11:54 +0100)]
mobiclip: fix copyright headers

The Mobiclip related code was based on Mobius (https://github.com/adibsurani/Mobius),
which was based on my original reverse engineering efforts (https://github.com/Gericom/MobiclipDecoder).
This commit adds the appropriate copyright headers on the related files.

Signed-off-by: Florian Nouwt <fnouwt2@gmail.com>
3 years agoavcodec/ylc: Reindent after previous commit
Andreas Rheinhardt [Mon, 8 Mar 2021 15:08:52 +0000 (16:08 +0100)]
avcodec/ylc: Reindent after previous commit

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/ylc: Avoid code duplication when creating and freeing VLCs
Andreas Rheinhardt [Mon, 8 Mar 2021 15:05:26 +0000 (16:05 +0100)]
avcodec/ylc: Avoid code duplication when creating and freeing VLCs

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/ylc: Use only one temporary buffer
Andreas Rheinhardt [Mon, 8 Mar 2021 13:12:06 +0000 (14:12 +0100)]
avcodec/ylc: Use only one temporary buffer

The effective lifetime of the buffer used to build the VLCs and
the buffer containing the bitstream is disjoint, so that one can use
a common buffer for both.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/ylc: Remove write-only variable
Andreas Rheinhardt [Mon, 8 Mar 2021 12:59:54 +0000 (13:59 +0100)]
avcodec/ylc: Remove write-only variable

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/h261dec: Remove parse_context cruft
Andreas Rheinhardt [Tue, 22 Dec 2020 17:54:12 +0000 (18:54 +0100)]
avcodec/h261dec: Remove parse_context cruft

The H.261 decoder doesn't use the ParseContext of its
MpegEncContext since e7316976650b429345da619c3acff38004aaf6b8.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agolavc: clarify thread_safe_callbacks doxy
Anton Khirnov [Tue, 2 Mar 2021 09:08:08 +0000 (10:08 +0100)]
lavc: clarify thread_safe_callbacks doxy

State explicitly when this field will be removed and how to access it in
a forward compatible way.

3 years agolscrdec: add copyright header
Anton Khirnov [Thu, 4 Mar 2021 09:02:49 +0000 (10:02 +0100)]
lscrdec: add copyright header

As requested by the author.

3 years agolavc: remove tests/options
Anton Khirnov [Mon, 14 Dec 2020 14:32:41 +0000 (15:32 +0100)]
lavc: remove tests/options

It tests deprecated avcodec_copy_context().

3 years agotests/api-flac-test: reindent
Anton Khirnov [Wed, 27 Jan 2021 12:38:00 +0000 (13:38 +0100)]
tests/api-flac-test: reindent

3 years agotests/api-flac-test: convert to new encoding/decoding API
Anton Khirnov [Wed, 27 Jan 2021 12:38:00 +0000 (13:38 +0100)]
tests/api-flac-test: convert to new encoding/decoding API