Commit Graph

102049 Commits

Author SHA1 Message Date
Andreas Rheinhardt a64d4de0d4 avformat/westwood_audenc: Check for, not assert on invalid data
Reviewed-by: Zane van Iperen <zane@zanevaniperen.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-26 16:46:37 +02:00
Zane van Iperen a6d4ea285c
doc: update for adpcm_ima_ws encoder and wsaud muxer
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2021-04-27 00:26:10 +10:00
Gyan Doshi d57104e698 doc/muxers: add entry for ALP muxer 2021-04-26 19:22:50 +05:30
Jan Ekström b24488e727 avcodec/ttmlenc: add support for region positioning and sizing
The ASS margins are utilized to generate percentual values, as
the usage of cell-based sizing and offsetting seems to be not too
well supported by renderers.

Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
2021-04-26 16:40:31 +03:00
Jan Ekström 3ef5a8ba2b avcodec/ttmlenc: add initial support for regions and styles
Attempts to utilize the TTML cell resolution as a mapping to the
reference resolution, and maps font size to cell size. Additionally
sets the display and text alignment according to the ASS alignment
number.

Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
2021-04-26 16:40:31 +03:00
Jan Ekström 464d6ed98d avformat/ttmlenc: enable writing out additional header values
This way the encoder may pass on the following values to the muxer:
1) Additional root "tt" element attributes, such as the subtitle
   canvas reference size.
2) Anything before the body element of the document, such as regions
   in the head element, which can configure styles.

Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
2021-04-26 16:40:31 +03:00
Jan Ekström b71184faef avcodec/ttmlenc: split header writing into its own function
Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
2021-04-26 16:40:31 +03:00
Gyan Doshi 343d54a733 doc/muxers: add entry for ADTS muxer 2021-04-26 16:43:38 +05:30
Zane van Iperen 2da033be10
fate: add adpcm_ima_ws test
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2021-04-26 19:56:33 +10:00
Aidan Richmond 4236e87f50
avformat/westwoodaudenc: Adds muxer for Westwood AUD format.
Format is still used by modders of these old games.

Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: Aidan Richmond <aidan.is@hotmail.co.uk>
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2021-04-26 19:56:33 +10:00
Aidan Richmond a0fd55c206
avcodec/adpcmenc: Adds encoder for Westwood ADPCM.
Signed-off-by: Aidan Richmond <aidan.is@hotmail.co.uk>
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2021-04-26 19:56:32 +10:00
Aidan Richmond 50442540d0
avcodec/adpcm: Fixes output from Westwood ADPCM.
Fixes bug #9198

Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: Aidan Richmond <aidan.is@hotmail.co.uk>
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2021-04-26 19:56:32 +10:00
James Almer 7a6ea6ce2a x86/tx_float: remove ff_ prefix from external constant tables
Fixes compilation with some assemblers.

Reviewed-by: Lynne
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-25 18:42:38 -03:00
Chris Ribble c9fed043f1 libavformat/adtsenc: Increase ADTS_MAX_FRAME_BYTES from 8k to 16k
ADTS frames may contain up to 768 bytes per channel. With 16 channels,
this is 12k, which cannot fit into the maximum 8k buffer.

Signed-off-by: Chris Ribble <chris.ribble@resi.io>
2021-04-25 19:16:40 +02:00
James Almer c8197f73e6 avcodec/mjpegdec: postpone calling ff_get_buffer() until the SOS marker
With JPEG-LS PAL8 samples, the JPEG-LS extension parameters signaled with
the LSE marker show up after SOF but before SOS. For those, the pixel format
chosen by get_format() in SOF is GRAY8, and then replaced by PAL8 in LSE.
This has not been an issue given both pixel formats allocate the second data
plane for the palette, but after the upcoming soname bump, GRAY8 will no longer
do that. This will result in segfauls when ff_jpegls_decode_lse() attempts to
write the palette on a buffer originally allocated as a GRAY8 one.

Work around this by calling ff_get_buffer() after the actual pixel format is
known.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-25 10:57:29 -03:00
James Almer bc27269694 avfilter/af_adelay: make per channel delay argument an int64_t
Should fix ticket #9196

Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-25 09:22:09 -03:00
Zane van Iperen ff946633a3
avcodec/adpcm: init from extradata before setting sample formats
Fixes a crash when decoding VQA files.

Regression since c012f9b265.

Reported-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2021-04-25 21:32:26 +10:00
shubhanshu02 d98884be41 lavfi/dnn_backend_openvino.c: Spelling Correction in OpenVino Backend
Correct Spelling of the word `descibe` to `describe`
in init_model_ov

Signed-off-by: shubhanshu02 <shubhanshu.e01@gmail.com>
2021-04-25 09:02:54 +08:00
Lynne bb40f800bd
x86/tx_float: fix forgotten 2-argument mulps
Yasm *really* cannot deal with any omitted arguments at all.
2021-04-24 22:33:42 +02:00
Lynne e2cf0a1f68
x86/tx_float: use all arguments on vperm2f and vpermilps and reindent comments
Apparently even old nasm isn't required to accept incomplete instructions.
2021-04-24 22:21:13 +02:00
James Almer fddddc7ec2 x86/tx_float: Fixes compilation with old yasm
Use three operand format on some instructions, and lea to load effective
addresses of tables.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-24 17:02:31 -03:00
Lynne e448a4b4ea
lavu/x86/tx_float: fix FMA3 implying AVX2 is available
It's the other way around - AVX2 implies FMA3 is available.
2021-04-24 19:00:27 +02:00
James Almer a5f996de4f fate: add tests for JPEG-LS PAL8
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-24 12:32:06 -03:00
Lynne 119a3f7e8d
lavu/x86: add FFT assembly
This commit adds a pure x86 assembly SIMD version of the FFT in libavutil/tx.
The design of this pure assembly FFT is pretty unconventional.

On the lowest level, instead of splitting the complex numbers into
real and imaginary parts, we keep complex numbers together but split
them in terms of parity. This saves a number of shuffles in each transform,
but more importantly, it splits each transform into two independent
paths, which we process using separate registers in parallel.
This allows us to keep all units saturated and lets us use all available
registers to avoid dependencies.
Moreover, it allows us to double the granularity of our per-load permutation,
skipping many expensive lookups and allowing us to use just 4 loads per register,
rather than 8, or in case FMA3 (and by extension, AVX2), use the vgatherdpd
instruction, which is at least as fast as 4 separate loads on old hardware,
and quite a bit faster on modern CPUs).

Higher up, we go for a bottom-up construction of large transforms, foregoing
the traditional per-transform call-return recursion chains. Instead, we always
start at the bottom-most basis transform (in this case, a 32-point transform),
and continue constructing larger and larger transforms until we return to the
top-most transform.
This way, we only touch the stack 3 times per a complete target transform:
once for the 1/2 length transform and two times for the 1/4 length transform.

The combination algorithm we use is a standard Split-Radix algorithm,
as used in our C code. Although a version with less operations exists
(Steven G. Johnson and Matteo Frigo's "A modified split-radix FFT with fewer
arithmetic operations", IEEE Trans. Signal Process. 55 (1), 111–119 (2007),
which is the one FFTW uses), it only has 2% less operations and requires at least 4x
the binary code (due to it needing 4 different paths to do a single transform).
That version also has other issues which prevent it from being implemented
with SIMD code as efficiently, which makes it lose the marginal gains it offered,
and cannot be performed bottom-up, requiring many recursive call-return chains,
whose overhead adds up.

We go through a lot of effort to minimize load/stores by keeping as much in
registers in between construcring transforms. This saves us around 32 cycles,
on paper, but in reality a lot more due to load/store aliasing (a load from a
memory location cannot be issued while there's a store pending, and there are
only so many (2 for Zen 3) load/store units in a CPU).
Also, we interleave coefficients during the last stage to save on a store+load
per register.

Each of the smallest, basis transforms (4, 8 and 16-point in our case)
has been extremely optimized. Our 8-point transform is barely 20 instructions
in total, beating our old implementation 8-point transform by 1 instruction.
Our 2x8-point transform is 23 instructions, beating our old implementation by
6 instruction and needing 50% less cycles. Our 16-point transform's combination
code takes slightly more instructions than our old implementation, but makes up
for it by requiring a lot less arithmetic operations.

Overall, the transform was optimized for the timings of Zen 3, which at the
time of writing has the most IPC from all documented CPUs. Shuffles were
preferred over arithmetic operations due to their 1/0.5 latency/throughput.

On average, this code is 30% faster than our old libavcodec implementation.
It's able to trade blows with the previously-untouchable FFTW on small transforms,
and due to its tiny size and better prediction, outdoes FFTW on larger transforms
by 11% on the largest currently supported size.
2021-04-24 17:19:18 +02:00
Lynne 68dfb87035
doc/transforms: add documentation for the FFT transforms
Makes the code far easier to follow, and makes creating new SIMD
for the transforms far, far easier.
2021-04-24 17:19:17 +02:00
Lynne 1978b143eb
checkasm: add av_tx FFT SIMD testing code
This sadly required making changes to the code itself,
due to the same context needing to be reused for both versions.
The lookup table had to be duplicated for both versions.
2021-04-24 17:19:17 +02:00
Lynne ff71671d88
lavu/tx: add parity revtab generator version
This will be used for SIMD support.
2021-04-24 17:17:30 +02:00
Lynne 18af1ea8d1
lavu: bump minor and add APIchanges entry for the lavu/tx changes 2021-04-24 17:17:28 +02:00
Lynne 0072a42388
lavu/tx: add full-sized iMDCT transform flag 2021-04-24 17:17:27 +02:00
Lynne aa6c757d50
lavu/tx: add unaligned flag to the API 2021-04-24 17:17:26 +02:00
Lynne 8c55c82583
lavu/tx: add a 9-point FFT and (i)MDCT 2021-04-24 17:17:25 +02:00
Lynne bd9ea917a3
lavu/tx: add a 7-point FFT and (i)MDCT 2021-04-24 17:17:23 +02:00
Lynne 89da62f2fc
lavu/tx: refactor power-of-two FFT
This commit refactors the power-of-two FFT, making it faster and
halving the size of all tables, making the code much smaller on
all systems.
This removes the big/small pass split, because on modern systems
the "big" pass is always faster, and even on older machines there
is no measurable speed difference.
2021-04-24 17:17:20 +02:00
Lynne aa910a7ecd
lavu/tx: minor code style improvements and additional comments 2021-04-24 17:17:15 +02:00
Andreas Rheinhardt da6e137cb6 avcodec/exr: Return correct error code on allocation failure
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-24 14:03:29 +02:00
Andreas Rheinhardt a1ed984e04 avcodec/avcodec: Actually honour the documentation of subtitle_header
It is only supposed to be freed by libavcodec for decoders, yet
avcodec_open2() always frees it on failure.
Furthermore, avcodec_close() doesn't free it for decoders.
Both of this has been changed.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-24 13:56:43 +02:00
Anton Khirnov 878e45e0fb tests/fate: add a test for APNG_DISPOSE_OP_BACKGROUND 2021-04-24 13:02:54 +02:00
Michael Niedermayer 098314e1e5 avformat/asfdec_o: Use ff_get_extradata()
Fixes: OOM
Fixes: 27240/clusterfuzz-testcase-minimized-ffmpeg_dem_ASF_O_fuzzer-5937469859823616

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-04-24 11:36:47 +02:00
James Almer 33f2144d2f avcodec/av1_metadata: don't store the inserted TD OBU in stack
Fixes: stack-use-after-return
Fixes: clusterfuzz-testcase-minimized-ffmpeg_BSF_AV1_METADATA_fuzzer-5931515701755904
Fixes: clusterfuzz-testcase-minimized-ffmpeg_BSF_AV1_METADATA_fuzzer-6105676541722624

Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-23 17:21:13 -03:00
Michael Niedermayer efdb564504 avformat/id3v2: Check end for overflow in id3v2_parse()
Fixes: signed integer overflow: 9223372036840103978 + 67637280 cannot be represented in type 'long'
Fixes: 33341/clusterfuzz-testcase-minimized-ffmpeg_dem_DSF_fuzzer-6408154041679872

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-04-23 11:35:40 +02:00
Michael Niedermayer f7c3484b26 avformat/mxfdec: Fix file position addition
Fixes: signed integer overflow: 9223372036854775805 + 4 cannot be represented in type 'long'
Fixes: 29927/clusterfuzz-testcase-minimized-ffmpeg_dem_MXF_fuzzer-5579985228267520

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-04-22 16:22:22 +02:00
Michael Niedermayer f8ec1da8ac avformat/wtvdec: Improve size overflow checks in parse_chunks()
Fixes: signed integer overflow: 32 + 2147483647 cannot be represented in type 'int
Fixes: 32967/clusterfuzz-testcase-minimized-ffmpeg_dem_WTV_fuzzer-5132856218222592

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-04-22 16:01:21 +02:00
Michael Niedermayer 7b3881f0da avcodec/faxcompr: Check remaining bits on error in decode_group3_1d_line()
Fixes: Timeout
Fixes: 32886/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-4779761466474496

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-04-22 15:06:55 +02:00
Michael Niedermayer 09be23ccf8 tools/target_dec_fuzzer: Adjust threshold for paf video
Fixes: Timeout (long -> 2sec)
Fixes: 32790/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PAF_VIDEO_fuzzer-5497584169910272

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-04-22 15:06:55 +02:00
Michael Niedermayer ee53bb2399 avformat/mov: check for pts overflow in mov_read_sidx()
Fixes: signed integer overflow: 9223372036846336888 + 4278255871 cannot be represented in type 'long'
Fixes: 32782/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-6059216516284416

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-04-22 15:06:55 +02:00
Andreas Rheinhardt 718e03e5f2 avcodec/jpeglsdec: Don't presume the context to contain a JLSState
Before 9b3c46a081 every call to
ff_jpegls_decode_picture() allocated and freed a JLSState. This commit
instead put said structure into the context of the JPEG-LS decoder to
avoid said allocation. But said function can also be called from other
MJPEG-based decoders and their contexts doesn't contain said structure,
leading to segfaults. This commit fixes this: The JLSState is now
allocated on the first call to ff_jpegls_decode_picture() and stored in
the context.

Found-by: Michael Niedermayer <michael@niedermayer.cc>
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-20 21:19:29 +02:00
Michael Niedermayer f40e9b1355 avcodec/utils: Check ima wav duration for overflow
Fixes: signed integer overflow: 44331634 * 65 cannot be represented in type 'int'
Fixes: 32120/clusterfuzz-testcase-minimized-ffmpeg_dem_RSD_fuzzer-5760221223583744

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-04-20 16:58:20 +02:00
Michael Niedermayer b6eedee529 tools/target_dec_fuzzer: adjust threshold for arbc
Fixes: Timeout (63sec -> 48ms)
Fixes: 31886/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ARBC_fuzzer-5287235705503744

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-04-20 16:58:20 +02:00
Michael Niedermayer fe584d6002 tools/target_dec_fuzzer: Adjust threshold for TSCC
Fixes: Timeout
Fixes: 31850/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TSCC_fuzzer-5940231289307136

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-04-20 16:58:20 +02:00
Michael Niedermayer f8556b632f avcodec/rv10: Execute whole size check earlier for rv20
Fixes: Timeout
Fixes: 31380/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RV20_fuzzer-5230899257016320

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-04-20 16:58:20 +02:00