]> git.sesse.net Git - ffmpeg/log
ffmpeg
3 years agofft: remove 16-bit FFT and MDCT code
Lynne [Sat, 9 Jan 2021 15:23:20 +0000 (16:23 +0100)]
fft: remove 16-bit FFT and MDCT code

No longer used by anything.
Unfortunately the old FFT_FLOAT/FFT_FIXED_32 is left as-is. It's
simply too much work for code meant to be all removed anyway.

3 years agoac3enc_fixed: drop unnecessary fixed-point DSP code
Lynne [Sat, 9 Jan 2021 02:19:18 +0000 (03:19 +0100)]
ac3enc_fixed: drop unnecessary fixed-point DSP code

3 years agoac3enc: halve the MDCT window size by using vector_fmul_reverse
Lynne [Sat, 9 Jan 2021 16:27:16 +0000 (17:27 +0100)]
ac3enc: halve the MDCT window size by using vector_fmul_reverse

This brings the encoder in-line with the rest of ours and saves
on a bit of memory.

3 years agoac3enc: do not clip coefficients after transforms
Lynne [Sat, 9 Jan 2021 08:05:18 +0000 (09:05 +0100)]
ac3enc: do not clip coefficients after transforms

In either encoder, its impossible for the coefficients to go past 25 bits
right after the MDCT. Our MDCT is numerically stable.
For the floating point encoder, in case a NaN is contained, lrintf() will
raise a floating point exception during the conversion.

3 years agoac3enc_fixed: convert to 32-bit sample format
Lynne [Sat, 9 Jan 2021 00:51:52 +0000 (01:51 +0100)]
ac3enc_fixed: convert to 32-bit sample format

The AC3 encoder used to be a separate library called "Aften", which
got merged into libavcodec (literally, SVN commits and all).
The merge preserved as much features from the library as possible.

The code had two versions - a fixed point version and a floating
point version. FFmpeg had floating point DSP code used by other
codecs, the AC3 decoder including, so the floating-point DSP was
simply replaced with FFmpeg's own functions.
However, FFmpeg had no fixed-point audio code at that point. So
the encoder brought along its own fixed-point DSP functions,
including a fixed-point MDCT.

The fixed-point MDCT itself is trivially just a float MDCT with a
different type and each multiply being a fixed-point multiply.
So over time, it got refactored, and the FFT used for all other codecs
was templated.

Due to design decisions at the time, the fixed-point version of the
encoder operates at 16-bits of precision. Although convenient, this,
even at the time, was inadequate and inefficient. The encoder is noisy,
does not produce output comparable to the float encoder, and even
rings at higher frequencies due to the badly approximated winow function.

Enter MIPS (owned by Imagination Technologies at the time). They wanted
quick fixed-point decoding on their FPUless cores. So they contributed
patches to template the AC3 decoder so it had both a fixed-point
and a floating-point version. They also did the same for the AAC decoder.
They however, used 32-bit samples. Not 16-bits. And we did not have
32-bit fixed-point DSP functions, including an MDCT. But instead of
templating our MDCT to output 3 versions (float, 32-bit fixed and 16-bit fixed),
they simply copy-pasted their own MDCT into ours, and completely
ifdeffed our own MDCT code out if a 32-bit fixed point MDCT was selected.

This is also the status quo nowadays - 2 separate MDCTs, one which
produces floating point and 16-bit fixed point versions, and one
sort-of integrated which produces 32-bit MDCT.

MIPS weren't all that interested in encoding, so they left the encoder
as-is, and they didn't care much about the ifdeffery, mess or quality - it's
not their problem.

So the MDCT/FFT code has always been a thorn in anyone looking to clean up
code's eye.

Backstory over. Internally AC3 operates on 25-bit fixed-point coefficients.
So for the floating point version, the encoder simply runs the float MDCT,
and converts the resulting coefficients to 25-bit fixed-point, as AC3 is inherently
a fixed-point codec. For the fixed-point version, the input is 16-bit samples,
so to maximize precision the frame samples are analyzed and the highest set
bit is detected via ac3_max_msb_abs_int16(), and the coefficients are then
scaled up via ac3_lshift_int16(), so the input for the FFT is always at least 14 bits,
computed in normalize_samples(). After FFT, the coefficients are scaled up to 25 bits.

This patch simply changes the encoder to accept 32-bit samples, reusing
the already well-optimized 32-bit MDCT code, allowing us to clean up and drop
a large part of a very messy code of ours, as well as prepare for the future lavu/tx
conversion. The coefficients are simply scaled down to 25 bits during windowing,
skipping 2 separate scalings, as the hacks to extend precision are simply no longer
necessary. There's no point in running the MDCT always at 32 bits when you're
going to drop 6 bits off anyway, the headroom is plenty, and the MDCT rounds
properly.

This also makes the encoder even slightly more accurate over the float version,
as there's no coefficient conversion step necessary.

SIZE SAVINGS:
ARM32:
HARDCODED TABLES:
BASE           - 10709590
DROP  DSP      - 10702872 - diff:   -6.56KiB
DROP  MDCT     - 10667932 - diff:  -34.12KiB - both:   -40.68KiB
DROP  FFT      - 10336652 - diff: -323.52KiB - all:   -364.20KiB
SOFTCODED TABLES:
BASE           -  9685096
DROP  DSP      -  9678378 - diff:   -6.56KiB
DROP  MDCT     -  9643466 - diff:  -34.09KiB - both:   -40.65KiB
DROP  FFT      -  9573918 - diff:  -67.92KiB - all:   -108.57KiB

ARM64:
HARDCODED TABLES:
BASE           - 14641112
DROP  DSP      - 14633806 - diff:   -7.13KiB
DROP  MDCT     - 14604812 - diff:  -28.31KiB - both:   -35.45KiB
DROP  FFT      - 14286826 - diff: -310.53KiB - all:   -345.98KiB
SOFTCODED TABLES:
BASE           - 13636238
DROP  DSP      - 13628932 - diff:   -7.13KiB
DROP  MDCT     - 13599866 - diff:  -28.38KiB - both:   -35.52KiB
DROP  FFT      - 13542080 - diff:  -56.43KiB - all:    -91.95KiB

x86:
HARDCODED TABLES:
BASE           - 12367336
DROP  DSP      - 12354698 - diff:  -12.34KiB
DROP  MDCT     - 12331024 - diff:  -23.12KiB - both:   -35.46KiB
DROP  FFT      - 12029788 - diff: -294.18KiB - all:   -329.64KiB
SOFTCODED TABLES:
BASE           - 11358094
DROP  DSP      - 11345456 - diff:  -12.34KiB
DROP  MDCT     - 11321742 - diff:  -23.16KiB - both:   -35.50KiB
DROP  FFT      - 11276946 - diff:  -43.75KiB - all:    -79.25KiB

PERFORMANCE (10min random s32le):
ARM32 - before -  39.9x - 0m15.046s
ARM32 - after  -  28.2x - 0m21.525s
                       Speed:  -30%

ARM64 - before -  36.1x - 0m16.637s
ARM64 - after  -  36.0x - 0m16.727s
                       Speed: -0.5%

x86   - before - 184x -    0m3.277s
x86   - after  - 190x -    0m3.187s
                       Speed:   +3%

3 years agokmsgrab: Do not require the modifier to stay constant.
Bas Nieuwenhuizen [Fri, 13 Nov 2020 23:15:47 +0000 (00:15 +0100)]
kmsgrab: Do not require the modifier to stay constant.

As we get a new set of objects each frame anyway, we
do not gain anything by keeping the modifier constant.

This helps with capturing when switching your setup a
bit, e.g. from ingame to desktop or from X11 to wayland.

Signed-off-by: Mark Thompson <sw@jkqxz.net>
3 years agokmsgrab: Use invalid modifier if modifiers weren't used.
Bas Nieuwenhuizen [Fri, 13 Nov 2020 23:15:46 +0000 (00:15 +0100)]
kmsgrab: Use invalid modifier if modifiers weren't used.

The kernel defaults to initializing the field to 0 when modifiers
are not used and this happens to be linear. If we end up actually
passing the modifier to a driver, tiling issues happen.

So if the kernel doesn't return a modifier set it explicitly to
INVALID. That way later processing knows there is no explicit
modifier.

Signed-off-by: Mark Thompson <sw@jkqxz.net>
3 years agolavu: support arbitrary-point FFTs and all even (i)MDCT transforms
Lynne [Tue, 12 Jan 2021 07:11:47 +0000 (08:11 +0100)]
lavu: support arbitrary-point FFTs and all even (i)MDCT transforms

This patch adds support for arbitrary-point FFTs and all even MDCT
transforms.
Odd MDCTs are not supported yet as they're based on the DCT-II and DCT-III
and they're very niche.

With this we can now write tests.

3 years agoavformat/allformats: test pointer to be used
AlexisWilke [Mon, 4 Jan 2021 18:11:01 +0000 (10:11 -0800)]
avformat/allformats: test pointer to be used

Two tests check the opposite pointer before using it. If only one of these
is set to a valid pointer, one of these functions will crash, the other will
ignore the pointer.

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavformat/mxfdec: Free all types for both Descriptors
Michael Niedermayer [Tue, 20 Oct 2020 18:22:48 +0000 (20:22 +0200)]
avformat/mxfdec: Free all types for both Descriptors

Fixes: memleak
Fixes: 26352/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5201158714687488
Suggested-by: Tomas Härdin <tjoppen@acc.umu.se>
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/eval: Unconditionally check argument of e_div
Michael Niedermayer [Tue, 20 Oct 2020 18:33:50 +0000 (20:33 +0200)]
avutil/eval: Unconditionally check argument of e_div

Fixes: division by zero
Fixes: 26451/clusterfuzz-testcase-minimized-ffmpeg_dem_VIVO_fuzzer-4756955832516608
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/utils: wrap_timestamp() is only needed for less than 64 bits
Michael Niedermayer [Fri, 23 Oct 2020 08:53:18 +0000 (10:53 +0200)]
avformat/utils: wrap_timestamp() is only needed for less than 64 bits

Fixes: shift exponent 64 is too large for 64-bit type 'unsigned long long'
Fixes: 26497/clusterfuzz-testcase-minimized-ffmpeg_dem_AVI_fuzzer-5690188355076096
Fixes: 26903/clusterfuzz-testcase-minimized-ffmpeg_dem_LUODAT_fuzzer-5641466929741824
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 string before strcmp()
Michael Niedermayer [Fri, 23 Oct 2020 16:05:23 +0000 (18:05 +0200)]
avformat/aaxdec: Check string before strcmp()

Fixes: NULL ptr dereference
Fixes: 26508/clusterfuzz-testcase-minimized-ffmpeg_dem_AAX_fuzzer-5694725249826816
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 agouavformat/rsd: check for EOF in extradata
Michael Niedermayer [Fri, 23 Oct 2020 16:01:11 +0000 (18:01 +0200)]
uavformat/rsd: check for EOF in extradata

Fixes: OOM
Fixes: 26503/clusterfuzz-testcase-minimized-ffmpeg_dem_RSD_fuzzer-6530816735444992
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/cbs_h2645: Move zero_byte check to its own function
Nuo Mi [Mon, 11 Jan 2021 16:33:14 +0000 (00:33 +0800)]
avcodec/cbs_h2645: Move zero_byte check to its own function

Signed-off-by: Mark Thompson <sw@jkqxz.net>
3 years agoavcodec/cbs_h265: fix undef SEI_TYPE_X
Nuo Mi [Mon, 11 Jan 2021 16:33:13 +0000 (00:33 +0800)]
avcodec/cbs_h265: fix undef SEI_TYPE_X

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec: add vvc codec id and profiles
Nuo Mi [Mon, 11 Jan 2021 16:33:10 +0000 (00:33 +0800)]
avcodec: add vvc codec id and profiles

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/cbs: constify decompose_unit_types
James Almer [Sun, 10 Jan 2021 22:22:59 +0000 (19:22 -0300)]
avcodec/cbs: constify decompose_unit_types

CBS doesn't change its contents in any way whatsoever internally, and most
users already set it to a const array.

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavfilter/vf_convolution: use correct stride variable
Paul B Mahol [Sun, 10 Jan 2021 16:26:21 +0000 (17:26 +0100)]
avfilter/vf_convolution: use correct stride variable

3 years agodoc/ffmpeg: document max_error_rate
Gyan Doshi [Sun, 10 Jan 2021 13:44:37 +0000 (19:14 +0530)]
doc/ffmpeg: document max_error_rate

3 years agoavformat: remove some mpegts details from AVStream
Marton Balint [Mon, 28 Dec 2020 00:21:20 +0000 (01:21 +0100)]
avformat: remove some mpegts details from AVStream

These fields were added to support -merge_pmt_versions, but the mpegts demuxer
is also keeping track its programs internally, so that should be a better place
to handle it.

Also it is not a very good idea to keep fields like program_num or
pmt_stream_idx in an AVStream, because a single stream can be part of multiple
programs, multiple PMTs, so the stream attributes can refer to any program the
stream is part of.

Since they are not part of public API, lets simply remove them, or rather
replace them with placeholders for ABI compatibility with libavdevice.

Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agoavformat/mpegts: use stream index based lookup with merge_pmt_versions if stream...
Marton Balint [Sun, 27 Dec 2020 22:49:06 +0000 (23:49 +0100)]
avformat/mpegts: use stream index based lookup with merge_pmt_versions if stream identifier matches multiple streams

Also make sure we are checking the old state of the streams because otherwise
some streams might already have the newly parsed stream identifiers which
corrupts matching.

Fixes streams having the same identifier mixed up on pmt version change.

Fixes ticket #9006.

Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agoavformat/mpegts: only clear programs which no longer exist or have a new PMT
Marton Balint [Sun, 27 Dec 2020 22:05:16 +0000 (23:05 +0100)]
avformat/mpegts: only clear programs which no longer exist or have a new PMT

Otherwise there can be a small period when the programs only contain the PMT
pid.

Also make sure skip_clear only affects AVProgram clear, and that pmt_pid is
always kept as the first entry of the PID list of the programs. Also reject
PMTs for programs on the wrong PID.

Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agoavformat/mpegts: rework clearing and adding pid to program
Marton Balint [Sun, 27 Dec 2020 18:38:50 +0000 (19:38 +0100)]
avformat/mpegts: rework clearing and adding pid to program

And use better function names.

Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agoavformat/mpegts: never discard PAT pid
Marton Balint [Sun, 27 Dec 2020 16:35:36 +0000 (17:35 +0100)]
avformat/mpegts: never discard PAT pid

PID 0 was removed from the pid list when then PMT was parsed, it is better
to explictly avoid it from being discarded instead of keeing it in the list of
every program.

Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agoavformat/utils: do not overwrite already existing program with defaults in av_new_program
Marton Balint [Sun, 27 Dec 2020 19:32:54 +0000 (20:32 +0100)]
avformat/utils: do not overwrite already existing program with defaults in av_new_program

av_new_program returns the existing program if that already exists, in that
case it makes no sense to overwrite existing attributes.

Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agolavu/tx: clip when converting table values to fixed-point
Lynne [Sat, 9 Jan 2021 19:41:25 +0000 (20:41 +0100)]
lavu/tx: clip when converting table values to fixed-point

INT32_MAX (2147483647) isn't exactly representable by a floating point
value, with the closest being 2147483648.0. So when rescaling a value
of 1.0, this could overflow when casting the 64-bit value returned from
lrintf() into 32 bits.
Unfortunately the properties of integer overflows don't match up well
with how a Fourier Transform operates. So clip the value before
casting to a 32-bit int.

Should be noted we don't have overflows with the table values we're
currently using. However, converting a Kaiser-Bessel window function
with a length of 256 and a parameter of 5.0 to fixed point did create
overflows. So this is more of insurance to save debugging time
in case something changes in the future.
The macro is only used during init, so it being a little slower is
not a problem.

3 years agosbc: do not set sample format in parser
Arnaud Vrac [Tue, 5 Jan 2021 12:47:43 +0000 (13:47 +0100)]
sbc: do not set sample format in parser

Commit bdd31feec934 changed the SBC decoder to only set the output
sample format on init, instead of setting it explicitly on each frame,
which is correct. But the SBC parser overrides the sample format to S16,
which triggers a crash when combining the parser and the decoder.

Fix the issue by not setting the sample format anymore in the parser,
which is wrong.

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavdevice/decklink_dec: mark get_frame_timecode and get_bmd_timecode static
Christopher Degawa [Wed, 6 Jan 2021 18:09:36 +0000 (18:09 +0000)]
avdevice/decklink_dec: mark get_frame_timecode and get_bmd_timecode static

The function is not used anywhere else and is causing mingw-w64 clang
builds to fail with

ffmpeg-git/libavdevice/decklink_dec.cpp:792:5: error: no previous prototype for function 'get_bmd_timecode' [-Werror,-Wmissing-prototypes]
int get_bmd_timecode(AVFormatContext *avctx, AVTimecode *tc, AVRational frame_rate, BMDTimecodeFormat tc_format, IDeckLinkVideoInputFrame *videoFrame)

Signed-off-by: Christopher Degawa <ccom@randomderp.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agoavformat/mov: adjust skip_samples according to seek timestamp
Matthieu Bouron [Fri, 30 Oct 2020 14:38:51 +0000 (15:38 +0100)]
avformat/mov: adjust skip_samples according to seek timestamp

Currently skip_samples is set to start_pad if sample_time is lesser or
equal to 0. This can cause issues if the stream starts with packets that
have negative pts. Calling avformat_seek_file() with ts set to 0 on such
streams makes the mov demuxer return the right corresponding packets
(near the 0 timestamp) but set skip_samples to start_pad which is
incorrect as the audio decoder will discard the returned samples
according to skip_samples from the first packet it receives (which has
its timestamp near 0).

For example, considering the following audio stream with start_pad=1344:

 [PKT pts=-1344] [PKT pts=-320] [PKT pts=704] [PKT pts=1728] [...]

Calling avformat_seek_file() with ts=0 makes the next call to
av_read_frame() return the packet with pts=-320 and a skip samples
side data set to 1344 (start_pad). This makes the audio decoder
incorrectly discard (1344 - 320) samples.

This commit makes the move demuxer adjust skip_samples according to the
stream start_pad, seek timestamp and first sample timestamp.

The above example will now result in av_read_frame() still returning the
packet with pts=-320 but with a skip samples side data set to 320
(src_pad - (seek_timestamp - first_timestamp)). This makes the audio
decoder only discard 320 samples (from pts=-320 to pts=0).

Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agodoc/protocols: explain tcp listen option description
Lingjiang Fang [Sat, 2 Jan 2021 11:37:34 +0000 (19:37 +0800)]
doc/protocols: explain tcp listen option description

Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agoavcodec/nvenc: fix timestamp offset ticks logic
Timo Rothenpieler [Sat, 9 Jan 2021 15:34:59 +0000 (16:34 +0100)]
avcodec/nvenc: fix timestamp offset ticks logic

3 years agoavcodec/ac3dec: Make decoders init-threadsafe
Andreas Rheinhardt [Thu, 3 Dec 2020 15:56:36 +0000 (16:56 +0100)]
avcodec/ac3dec: Make decoders init-threadsafe

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/ac3dec: Check operations that can fail
Andreas Rheinhardt [Thu, 3 Dec 2020 15:04:13 +0000 (16:04 +0100)]
avcodec/ac3dec: Check operations that can fail

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/ac3enc: Factor common end of float/fixed encode_frame out
Andreas Rheinhardt [Thu, 3 Dec 2020 14:28:35 +0000 (15:28 +0100)]
avcodec/ac3enc: Factor common end of float/fixed encode_frame out

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/ac3enc_template: Perform compile-time checks at compile-time
Andreas Rheinhardt [Thu, 3 Dec 2020 03:44:21 +0000 (04:44 +0100)]
avcodec/ac3enc_template: Perform compile-time checks at compile-time

Runtime checks for whether the encoder is fixed-point or not are
unnecessary here as this is a template; furthermore, there is no
fixed-point EAC-3 encoder, so some checks for whether one is in EAC-3
mode can be omitted when doing fixed-point encoding.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/[e]ac3enc: Don't invade CONFIG_ namespace
Andreas Rheinhardt [Thu, 3 Dec 2020 03:13:28 +0000 (04:13 +0100)]
avcodec/[e]ac3enc: Don't invade CONFIG_ namespace

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/ac3enc: Set function pointers earlier
Andreas Rheinhardt [Thu, 3 Dec 2020 02:36:32 +0000 (03:36 +0100)]
avcodec/ac3enc: Set function pointers earlier

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/[e]ac3enc: Make encoders init-threadsafe, fix race
Andreas Rheinhardt [Thu, 3 Dec 2020 01:57:18 +0000 (02:57 +0100)]
avcodec/[e]ac3enc: Make encoders init-threadsafe, fix race

ff_eac3_exponent_init() set values twice when initializing a static
table; ergo the initialization code must not run concurrently with
a running EAC-3 encoder. Yet this code is executed every time an EAC-3
encoder is initialized. So use ff_thread_once() for this and also for a
similar initialization performed for all AC-3 encoders to make them all
init-threadsafe.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/wmaprodec: Check packet size
Michael Niedermayer [Thu, 3 Dec 2020 23:52:47 +0000 (00:52 +0100)]
avcodec/wmaprodec: Check packet size

Fixes: left shift of negative value -25824
Fixes: 27754/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_XMA2_fuzzer-5760255962906624
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/dhav: Check position for overflow
Michael Niedermayer [Thu, 3 Dec 2020 23:30:12 +0000 (00:30 +0100)]
avformat/dhav: Check position for overflow

Fixes: signed integer overflow: 9223372036854775807 + 32768 cannot be represented in type 'long'
Fixes: 27744/clusterfuzz-testcase-minimized-ffmpeg_dem_DHAV_fuzzer-5179319491756032
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/rasc: Check frame before clearing
Michael Niedermayer [Thu, 3 Dec 2020 22:41:10 +0000 (23:41 +0100)]
avcodec/rasc: Check frame before clearing

Fixes: null pointer dereference
Fixes: 27737/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RASC_fuzzer-5769028685266944
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/utils: Change compute_chapters_end() from O(n²) to O(n log n)
Michael Niedermayer [Sat, 21 Nov 2020 13:51:25 +0000 (14:51 +0100)]
avformat/utils: Change compute_chapters_end() from O(n²) to O(n log n)

Fixes: Timeout (49sec -> 9sec)
Fixes: 27427/clusterfuzz-testcase-minimized-ffmpeg_dem_FFMETADATA_fuzzer-5140589838073856
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/fft_template: Only check for FF_FFT_PERM_AVX on ARCH_X86
Andreas Rheinhardt [Wed, 6 Jan 2021 20:09:14 +0000 (21:09 +0100)]
avcodec/fft_template: Only check for FF_FFT_PERM_AVX on ARCH_X86

Also do it for FFT_FLOAT only, as this is the only combination for which
it can be set.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/vsrc_testsrc: Deduplicate options
Andreas Rheinhardt [Sun, 3 Jan 2021 17:54:14 +0000 (18:54 +0100)]
avfilter/vsrc_testsrc: Deduplicate options

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/af_biquads: Don't redundantly set AVClass
Andreas Rheinhardt [Sun, 3 Jan 2021 17:13:25 +0000 (18:13 +0100)]
avfilter/af_biquads: Don't redundantly set AVClass

It is already set generically in ff_filter_alloc().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/af_biquads: Deduplicate options
Andreas Rheinhardt [Sun, 3 Jan 2021 17:01:13 +0000 (18:01 +0100)]
avfilter/af_biquads: Deduplicate options

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/vf_blend: Deduplicate options
Andreas Rheinhardt [Sun, 3 Jan 2021 16:06:14 +0000 (17:06 +0100)]
avfilter/vf_blend: Deduplicate options

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/af_asupercut: Deduplicate options
Andreas Rheinhardt [Sun, 3 Jan 2021 15:49:36 +0000 (16:49 +0100)]
avfilter/af_asupercut: Deduplicate options

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/vf_neighbor: Deduplicate options
Andreas Rheinhardt [Sun, 3 Jan 2021 15:41:39 +0000 (16:41 +0100)]
avfilter/vf_neighbor: Deduplicate options

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/vf_convolution: Deduplicate filter options
Andreas Rheinhardt [Sun, 3 Jan 2021 15:10:19 +0000 (16:10 +0100)]
avfilter/vf_convolution: Deduplicate filter options

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/hashenc: Deduplicate (stream)hash options
Andreas Rheinhardt [Sun, 3 Jan 2021 15:00:16 +0000 (16:00 +0100)]
avformat/hashenc: Deduplicate (stream)hash options

Also saves relocations.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/wavpack: Deduplicate exp and log tables
Andreas Rheinhardt [Sun, 3 Jan 2021 14:50:43 +0000 (15:50 +0100)]
avcodec/wavpack: Deduplicate exp and log tables

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/mxf: Deduplicate random_index_pack_key
Andreas Rheinhardt [Sun, 3 Jan 2021 01:21:51 +0000 (02:21 +0100)]
avformat/mxf: Deduplicate random_index_pack_key

Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/vf_qp: Deduplicate variable names arrays
Andreas Rheinhardt [Sun, 3 Jan 2021 01:02:28 +0000 (02:02 +0100)]
avfilter/vf_qp: Deduplicate variable names arrays

This also avoids relocations.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/vp3data: Deduplicate coeff_tables
Andreas Rheinhardt [Sun, 3 Jan 2021 00:42:13 +0000 (01:42 +0100)]
avcodec/vp3data: Deduplicate coeff_tables

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/twinvq, metasound_data: Deduplicate lsp tables
Andreas Rheinhardt [Sun, 3 Jan 2021 20:07:47 +0000 (21:07 +0100)]
avcodec/twinvq, metasound_data: Deduplicate lsp tables

Saves about 24KB.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/metasound: Deduplicate data
Andreas Rheinhardt [Sat, 2 Jan 2021 22:08:00 +0000 (23:08 +0100)]
avcodec/metasound: Deduplicate data

Saves about 13KB; also reduces the amount of relocations.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/g723_1: Move tables to their only user
Andreas Rheinhardt [Sat, 2 Jan 2021 19:34:32 +0000 (20:34 +0100)]
avcodec/g723_1: Move tables to their only user

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/g723_1: Deduplicate arrays
Andreas Rheinhardt [Sat, 2 Jan 2021 19:18:22 +0000 (20:18 +0100)]
avcodec/g723_1: Deduplicate arrays

Saves about 17KB.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/libopusenc: Fix for header pre-skip value
Arthur Taylor [Thu, 7 Jan 2021 20:55:59 +0000 (12:55 -0800)]
avcodec/libopusenc: Fix for header pre-skip value

The Opus header initial padding preskip amount is always to be expressed
relative to 48kHz. However, the encoder delay returned from querying
libopus is relative to the encoding samplerate. Multiply by the
samplerate conversion factor to correct.

Signed-off-by: Arthur Taylor <art@ified.ca>
3 years agoavformat/vividas: Check number of audio channels
Michael Niedermayer [Sat, 26 Dec 2020 10:50:28 +0000 (11:50 +0100)]
avformat/vividas: Check number of audio channels

Fixes: division by 0
Fixes: 28597/clusterfuzz-testcase-minimized-ffmpeg_dem_VIVIDAS_fuzzer-5752201490333696
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/alsdec: Fix integer overflow with quant_cof
Michael Niedermayer [Sat, 26 Dec 2020 17:55:08 +0000 (18:55 +0100)]
avcodec/alsdec: Fix integer overflow with quant_cof

Fixes: signed integer overflow: -210824 * 16384 cannot be represented in type 'int'
Fixes: 28670/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALS_fuzzer-5682310846480384
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_dem_fuzzer.c: Decrease maxblocks
Michael Niedermayer [Sat, 26 Dec 2020 15:53:27 +0000 (16:53 +0100)]
tools/target_dem_fuzzer.c: Decrease maxblocks

Fixes: Timeout
Fixes: 28606/clusterfuzz-testcase-minimized-ffmpeg_dem_FRM_fuzzer-5123311424110592
Fixes: 28796/clusterfuzz-testcase-minimized-ffmpeg_dem_R3D_fuzzer-5945803411685376
Fixes: 28821/clusterfuzz-testcase-minimized-ffmpeg_dem_BRSTM_fuzzer-6044239834251264
Fixes: 28841/clusterfuzz-testcase-minimized-ffmpeg_dem_SIFF_fuzzer-5485368388485120
Fixes: 28862/clusterfuzz-testcase-minimized-ffmpeg_dem_AST_fuzzer-5081306790756352
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/av1dec: add an option to select an operating point
James Almer [Sun, 15 Nov 2020 21:55:41 +0000 (18:55 -0300)]
avcodec/av1dec: add an option to select an operating point

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/cbs_av1: add an option to select an operating point
James Almer [Sun, 15 Nov 2020 21:55:40 +0000 (18:55 -0300)]
avcodec/cbs_av1: add an option to select an operating point

This implements the function drop_obu() as defined in Setion 6.2.1 from the
spec.
In a reading only scenario, units that belong to an operating point the
caller doesn't want should not be parsed.

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/cbs: allow cbs_read_fragment_content() to skip decomposition of units
James Almer [Sun, 15 Nov 2020 21:55:39 +0000 (18:55 -0300)]
avcodec/cbs: allow cbs_read_fragment_content() to skip decomposition of units

The caller may not need all units in a fragment in reading only scenarios.
They could in fact alter global state stored in the private CodedBitstreamType
fields in an undesirable way.
With this change, unit decomposition can be skipped based on parsed values
within the unit.

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/cbs: add an AVClass to CodedBitstreamType for option handling
James Almer [Sun, 15 Nov 2020 21:55:38 +0000 (18:55 -0300)]
avcodec/cbs: add an AVClass to CodedBitstreamType for option handling

So unit parsing may be configured with caller set options.

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/libkvazaar: Set default ratecontrol algorithm for libkvazaar
Joose Sainio [Fri, 1 Jan 2021 14:31:17 +0000 (22:31 +0800)]
avcodec/libkvazaar: Set default ratecontrol algorithm for libkvazaar

The standalone version of Kvazaar sets a default ratecontrol algorithm when
bitrate is set. Mirror this behaviour.

Signed-off-by: Joose Sainio <joose.sainio@tuni.fi>
Signed-off-by: Linjie Fu <linjie.justin.fu@gmail.com>
3 years agoavcodec/hevcdec: fix stat_coeff save/load for persistent_rice_adaptation_enabled_flag
Xu Guangxin [Sun, 15 Nov 2020 02:36:22 +0000 (10:36 +0800)]
avcodec/hevcdec: fix stat_coeff save/load for persistent_rice_adaptation_enabled_flag

It's required by the 9.3.1 TableStatCoeff* section.

Following clips have this feature:
WPP_HIGH_TP_444_8BIT_RExt_Apple_2.bit
Bitdepth_A_RExt_Sony_1.bin
Bitdepth_B_RExt_Sony_1.bin
EXTPREC_HIGHTHROUGHPUT_444_16_INTRA_10BIT_RExt_Sony_1.bit
EXTPREC_HIGHTHROUGHPUT_444_16_INTRA_12BIT_RExt_Sony_1.bit
EXTPREC_HIGHTHROUGHPUT_444_16_INTRA_8BIT_RExt_Sony_1.bit
EXTPREC_MAIN_444_16_INTRA_10BIT_RExt_Sony_1.bit
EXTPREC_MAIN_444_16_INTRA_12BIT_RExt_Sony_1.bit
EXTPREC_MAIN_444_16_INTRA_8BIT_RExt_Sony_1.bit
WPP_AND_TILE_10Bit422Test_HIGH_TP_444_10BIT_RExt_Apple_2.bit
WPP_AND_TILE_AND_CABAC_BYPASS_ALIGN_0_HIGH_TP_444_14BIT_RExt_Apple_2.bit
WPP_AND_TILE_AND_CABAC_BYPASS_ALIGN_1_HIGH_TP_444_14BIT_RExt_Apple_2.bit
WPP_AND_TILE_HIGH_TP_444_8BIT_RExt_Apple_2.bit

you can download them from:
https://www.itu.int/wftp3/av-arch/jctvc-site/bitstream_exchange/draft_conformance/RExt/

Signed-off-by: Xu Guangxin <oddstone@gmail.com>
Signed-off-by: Linjie Fu <linjie.justin.fu@gmail.com>
3 years agoavfilter/af_astats: clip input value to prevent overflow
Paul B Mahol [Mon, 4 Jan 2021 10:11:26 +0000 (11:11 +0100)]
avfilter/af_astats: clip input value to prevent overflow

3 years agoavformat/rtpdec: export Opus extradata in ff_rtp_parse_open()
Jonathan Baudanza [Tue, 29 Dec 2020 18:07:11 +0000 (10:07 -0800)]
avformat/rtpdec: export Opus extradata in ff_rtp_parse_open()

3 years agoavfilter/vf_w3fdif: not interlaced frames are filtered like tff
Paul B Mahol [Sun, 3 Jan 2021 21:48:40 +0000 (22:48 +0100)]
avfilter/vf_w3fdif: not interlaced frames are filtered like tff

3 years agoavfilter/vf_w3fdif: add two more useful options
Paul B Mahol [Sun, 3 Jan 2021 21:20:55 +0000 (22:20 +0100)]
avfilter/vf_w3fdif: add two more useful options

3 years agoavformat/http: support retry on connection error
erankor [Thu, 3 Dec 2020 08:42:52 +0000 (10:42 +0200)]
avformat/http: support retry on connection error

Add 2 new options:
- reconnect_on_http_error - a list of http status codes that should be
    retried. the list can contain explicit status codes / the strings
    4xx/5xx.
- reconnect_on_network_error - reconnects on arbitrary errors during
    connect, e.g. ECONNRESET/ETIMEDOUT

the retry employs the same exponential backoff logic as the existing
reconnect/reconnect_at_eof flags.

related tickets:
https://trac.ffmpeg.org/ticket/6066
https://trac.ffmpeg.org/ticket/7768

Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agoavformat/wavdec: Avoid zeroing written to array
Michael Niedermayer [Mon, 9 Nov 2020 19:53:27 +0000 (20:53 +0100)]
avformat/wavdec: Avoid zeroing written to array

Fixes: OOM
Fixes: 26934/clusterfuzz-testcase-minimized-ffmpeg_dem_W64_fuzzer-5996784213819392
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/notchlc: Check uncompressed size against input for LZ4
Michael Niedermayer [Wed, 14 Oct 2020 15:53:07 +0000 (17:53 +0200)]
avcodec/notchlc: Check uncompressed size against input for LZ4

Fixes: OOM
Fixes: 26168/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_NOTCHLC_fuzzer-6019839015256064
Fixes: 28397/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_NOTCHLC_fuzzer-5649039941042176
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/videotoolbox: make FFmpeg-to-VT mapping error more informative
Jan Ekström [Sat, 2 Jan 2021 12:30:36 +0000 (14:30 +0200)]
avcodec/videotoolbox: make FFmpeg-to-VT mapping error more informative

Now logs the actual failed-to-map pixel format as well as range.

3 years agoMark some pointers as const
Andreas Rheinhardt [Sun, 27 Dec 2020 16:36:59 +0000 (17:36 +0100)]
Mark some pointers as const

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agolavc/mjpegdec: cosmetics, org->orig
Anton Khirnov [Sat, 12 Dec 2020 13:53:30 +0000 (14:53 +0100)]
lavc/mjpegdec: cosmetics, org->orig

3 years agofate: add tests for AVID
Anton Khirnov [Sat, 12 Dec 2020 12:40:47 +0000 (13:40 +0100)]
fate: add tests for AVID

Samples cut from tickets 971 and 4741

3 years agoapi-seek-test: use non-obsolete decoding API
Anton Khirnov [Thu, 10 Dec 2020 19:55:43 +0000 (20:55 +0100)]
api-seek-test: use non-obsolete decoding API

3 years agoapi-band-test: use non-obsolete decoding API
Anton Khirnov [Thu, 10 Dec 2020 19:55:43 +0000 (20:55 +0100)]
api-band-test: use non-obsolete decoding API

3 years agoapi-h264-test: use non-obsolete decoding API
Anton Khirnov [Thu, 10 Dec 2020 19:55:43 +0000 (20:55 +0100)]
api-h264-test: use non-obsolete decoding API

3 years agolavfi/vf_uspp: convert to the video_enc_params API
Anton Khirnov [Fri, 17 Apr 2020 08:32:12 +0000 (10:32 +0200)]
lavfi/vf_uspp: convert to the video_enc_params API

3 years agolavfi/vf_codecview: convert to the video_enc_params API
Anton Khirnov [Fri, 17 Apr 2020 08:32:12 +0000 (10:32 +0200)]
lavfi/vf_codecview: convert to the video_enc_params API

3 years agolavfi/vf_fspp: convert to the video_enc_params API
Anton Khirnov [Fri, 17 Apr 2020 08:32:12 +0000 (10:32 +0200)]
lavfi/vf_fspp: convert to the video_enc_params API

3 years agolavfi/vf_pp7: convert to the video_enc_params API
Anton Khirnov [Fri, 17 Apr 2020 08:32:12 +0000 (10:32 +0200)]
lavfi/vf_pp7: convert to the video_enc_params API

Re-enable fate-filter-pp7

3 years agolavfi/vf_spp: convert to the video_enc_params API
Anton Khirnov [Fri, 17 Apr 2020 08:32:12 +0000 (10:32 +0200)]
lavfi/vf_spp: convert to the video_enc_params API

Re-enable fate-filter-spp

3 years agolavfi/vf_pp: convert to the video_enc_params API
Anton Khirnov [Fri, 17 Apr 2020 08:32:12 +0000 (10:32 +0200)]
lavfi/vf_pp: convert to the video_enc_params API

Re-enable fate-filter-qp and fate-filter-pp.

3 years agolavfi: add common code to handle QP tables
Anton Khirnov [Mon, 14 Dec 2020 13:36:05 +0000 (14:36 +0100)]
lavfi: add common code to handle QP tables

It will be used for converting the *pp filters to the new
AVVideoEncParams API.

3 years agolavfi/vf_qp: convert to the video_enc_params API
Anton Khirnov [Fri, 17 Apr 2020 08:32:12 +0000 (10:32 +0200)]
lavfi/vf_qp: convert to the video_enc_params API

Temporarily disable fate-filter-qp until vf_pp is converted.

3 years agompegvideo: use the AVVideoEncParams API for exporting QP tables
Anton Khirnov [Tue, 10 Mar 2020 10:45:55 +0000 (11:45 +0100)]
mpegvideo: use the AVVideoEncParams API for exporting QP tables

Do it only when requested with the AV_CODEC_EXPORT_DATA_VIDEO_ENC_PARAMS
flag.

Drop previous code using the long-deprecated AV_FRAME_DATA_QP_TABLE*
API. Temporarily disable fate-filter-pp, fate-filter-pp7,
fate-filter-spp. They will be reenabled once these filters are converted
in following commits.

3 years agolavu/mem: move the DECLARE_ALIGNED macro family to mem_internal on next+1 bump
Anton Khirnov [Wed, 27 May 2020 12:54:38 +0000 (14:54 +0200)]
lavu/mem: move the DECLARE_ALIGNED macro family to mem_internal on next+1 bump

They are not properly namespaced and not intended for public use.

3 years agolavu: move LOCAL_ALIGNED from internal.h to mem_internal.h
Anton Khirnov [Wed, 10 Jun 2020 13:38:08 +0000 (15:38 +0200)]
lavu: move LOCAL_ALIGNED from internal.h to mem_internal.h

That is a more appropriate place for it.

3 years agoavfilter: add temporal midway equalizer filter
Paul B Mahol [Sat, 26 Dec 2020 12:52:24 +0000 (13:52 +0100)]
avfilter: add temporal midway equalizer filter

3 years agoconfigure: update copyright year
Lynne [Thu, 31 Dec 2020 23:00:00 +0000 (00:00 +0100)]
configure: update copyright year

3 years agoavcodec/svq1dec: Increase nb_bits of VLC to read it in one go
Andreas Rheinhardt [Tue, 29 Dec 2020 19:34:01 +0000 (20:34 +0100)]
avcodec/svq1dec: Increase nb_bits of VLC to read it in one go

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/dirac_arith: Make table only used here static
Andreas Rheinhardt [Tue, 29 Dec 2020 14:33:03 +0000 (15:33 +0100)]
avcodec/dirac_arith: Make table only used here static

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/qdmc: Mark decoder as init-threadsafe
Andreas Rheinhardt [Mon, 28 Dec 2020 19:01:47 +0000 (20:01 +0100)]
avcodec/qdmc: Mark decoder as init-threadsafe

It already uses ff_thread_once() to initialize its static data.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>