1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-12 19:18:44 +02:00
Commit Graph

108537 Commits

Author SHA1 Message Date
Michael Niedermayer
f05247f6a4
avcodec/apedec: Fix integer overflow in filter_3800()
Fixes: signed integer overflow: -2147448926 + -198321 cannot be represented in type 'int'
Fixes: 48798/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-5739619273015296
Fixes: 48798/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-6744428485672960

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-16 21:30:59 +02:00
Michael Niedermayer
67250ee8d2
tools/target_dec_fuzzer: Adjust threshold for Jpeg2000
Fixes: Timeout
Fixes: 50955/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-5148704872464384

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-16 21:30:59 +02:00
Michael Niedermayer
14e99cb472
avcodec/hdrdec: Update w in inner loop of decompress()
Fixes: out of array access
Fixes: 50936/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HDR_fuzzer-5423041009549312

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-16 21:30:59 +02:00
Michael Niedermayer
3993345f91
avcodec/tta: Check 24bit scaling for overflow
Fixes: signed integer overflow: -8427924 * 256 cannot be represented in type 'int'
Fixes: 48798/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TTA_fuzzer-5409428670644224

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-16 21:30:58 +02:00
Michael Niedermayer
677e27a9af
avcodec/mobiclip: Check quantizer for overflow
Fixes: signed integer overflow: 127 + 2147483536 cannot be represented in type 'int'
Fixes: 48798/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MOBICLIP_fuzzer-6014034970804224

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-16 21:30:58 +02:00
Michael Niedermayer
ac26712e35
avcodec/exr: Check preview psize
Fixes: signed integer overflow: 17121181824 * 538976288 cannot be represented in type 'long long'
Fixes: 48798/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EXR_fuzzer-5915330316206080

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-16 21:30:58 +02:00
Michael Niedermayer
43a4854510
avcodec/tiff: Fix loop detection
Fixes regression with tickets/4364/L1004220.DNG

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-16 21:30:57 +02:00
Hao Chen
fb233771ce
lavc/mips: Fix hevc decoding bugs on MIPS paltform.
The patch fixes the bugs that occurred when running
fate-checkasm-hevc_pel on MIPS paltform.

Reviewed-by: Shiyou Yin <yinshiyou-hf@loongson.cn>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-16 21:30:57 +02:00
Lu Wang
d5679d6899
lavc/mips: Fix bugs in me_cmp_msa.c file.
This patch fixes a bug where the fate-checkasm-motion fails when
h is not a multiple of 8.

Reviewed-by: Shiyou Yin <yinshiyou-hf@loongson.cn>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-16 21:30:57 +02:00
Andreas Rheinhardt
629aa5fbc0 avcodec/dca_lbr: Inline nb_bits for VLCs
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-16 18:07:29 +02:00
Andreas Rheinhardt
62d9b1195a avcodec/dca_lbr: Hardcode lpc table to save space
The code to initialize it takes more space (in .text) than
the table to be initialized (namely 86B vs 64B for GCC 11.2
with -O3 in an av_cold function), so hardcode the table.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-16 18:07:29 +02:00
Andreas Rheinhardt
465e27e0f2 avcodec/dcahuff: Replace DCAVLC by ordinary VLCs
This is possible now that the offsets are already applied
when creating the VLC.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-16 18:07:29 +02:00
Andreas Rheinhardt
3652114596 avcodec/dca_core: Don't use too big max_depth in get_vlc2()
Most of the VLCs used here have a max_depth of two;
some have a max_depth of one. Therefore one can just use two
and avoid the runtime check for whether one should
perform another round of LUT lookup in case the first read
did not read a complete codeword.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-16 18:07:29 +02:00
Andreas Rheinhardt
9dbc370769 avcodec/dca_core: Inline number of bits of scale factor VLCs
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-16 18:07:29 +02:00
Andreas Rheinhardt
597bfff342 avcodec/dcahuff, dca_core, dca_lbr: Apply offset during VLC creation
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-16 18:07:29 +02:00
Andreas Rheinhardt
97610e856a avcodec/dcahuff: Combine tables, use ff_init_vlc_from_lengths()
Up until now, initializing the dca VLC tables uses ff_init_vlc_sparse()
with length tables of type uint8_t and code tables of type uint16_t
(except for the LBR tables, which uses length and symbols of type
uint8_t; these tables are interleaved). In case of the quant index
codebooks these arrays were accessed via tables of pointers to the
individual tables.

This commit changes this: First, we switch to ff_init_vlc_from_lengths()
to replace the uint16_t code tables by uint8_t symbol tables
(this necessitates ordering the tables from left-to-right in the tree
first). These symbol tables are interleaved with the length tables.

Furthermore, these tables are combined in order to remove the table of
pointers to individual tables, thereby avoiding relocations (for x64
elf systems this amounts to 96*24B = 2304B saved in .rela.dyn) and
saving 1280B from .data.rel.ro (for 64bit systems). Meanwhile the
savings in .rodata amount to 2709 + 2 * 334 = 3377B. Due to padding
the actual savings are higher: The ELF x64 ABI requires objects >= 16B
to be padded to 16B and lots of the tables have 2^n + 1 elements
of these were from replacing uint16_t codes with uint8_t symbols;
the rest was due to the fact that combining the tables eliminated
padding (the ELF x64 ABI requires objects >= 16B to be padded to 16B
and lots of the tables have 2^n + 1 elements)). Taking this into
account gives savings of 4548B. (GCC by default uses an even higher
alignment (controlled by -malign-data); for it the savings are 5748B.)

These changes also necessitated to modify the init code for
the encoder tables.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-16 18:07:29 +02:00
Andreas Rheinhardt
2339f63eac avcodec/dcaenc: Create encoder-adapted tables
Up until now, the encoder used the same tables that the decoder
uses to create its VLCs. These have the downside of requiring
the encoder to offset the tables at runtime as well as having
to read from separate tables for the length as well as the code
of the symbol to encode. The former are uint8_t, the latter uint16_t,
so using a joint table would require padding, but this doesn't
matter when these tables are generated at runtime, because they
live in the .bss segment.

Also move these init functions as well as the functions that
actually use them to dcaenc.c, because they are encoder-specific.
This also allows to remove an inclusion of PutBitContext from
dcahuff.h (and indirectly from all dca-decoder files).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-16 18:07:29 +02:00
Andreas Rheinhardt
077880ad88 avcodec/dcahuff: Always use three bits for transition mode VLCs
It increases the size of one VLC from two to three bits, thereby
requiring four more VLCEntries (16 bytes .bss), but it allows to
inline the number of bits used when reading them.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-16 18:07:29 +02:00
Andreas Rheinhardt
8819860f34 avcodec/dca_core, dcahuff: Don't use DCAVLC unnecessarily
The ff_dca_vlc_transition_mode VLCs don't use an offset at all,
so just use ordinary VLCs for them.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-16 18:07:29 +02:00
Andreas Rheinhardt
649a2d8d52 avcodec/dcahuff: Avoid redundant offset table
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-16 18:07:29 +02:00
Andreas Rheinhardt
13cddfc453 avcodec/dcahuff: Remove unused define
In reality, the bit allocation VLCs do not use the same number
of bits at all.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-16 18:07:29 +02:00
Andreas Rheinhardt
0b1b93823f avcodec/dolby_e_parser: Remove unnecessary headers
Possible since 81d070dd09.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-16 18:07:29 +02:00
Paul B Mahol
9c05f178a6 avformat/ape: fix overflow in total_blocks 2022-09-16 18:04:20 +02:00
Paul B Mahol
8f11512273 avformat/ape: set packet duration 2022-09-16 18:04:20 +02:00
Andreas Rheinhardt
2c23cd0181 avformat/bonk: Don't set data_offset to what it would be set to anyway
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-16 17:49:40 +02:00
Andreas Rheinhardt
aaf6d85283 avcodec/Makefile: Remove obsolete adx_parser->adx.c dependency
Obsolete since b024209b1f.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-16 11:21:22 +02:00
Andreas Rheinhardt
b15a2f2504 avcodec/adx: Move ff_adx_decode_header() to adxdec.c
Possible since 9325d88eba.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-16 11:14:32 +02:00
Paul B Mahol
53523ed530 avcodec/tak*: use cached bitstream reader on !x86_32
Increases single thread decoding speed in one example from 85x to 90x
2022-09-16 10:02:19 +02:00
Paul B Mahol
dd2a01ef5c avformat: add LAF demuxer 2022-09-16 10:02:19 +02:00
Paul B Mahol
e91bc521af avcodec: add Micronas SC-4 parser 2022-09-16 10:02:19 +02:00
Paul B Mahol
ea93943bee avcodec: add MI-SC4 audio decoder 2022-09-16 10:02:19 +02:00
Rémi Denis-Courmont
6df3ad9687 lavu/riscv: fix off-by-one in bit-magnitude clip 2022-09-15 18:11:12 -03:00
Andreas Rheinhardt
a2c6bf2314 avcodec/intrax8: Remove reference to inexistent parameter
Forgotten in eb5c5ae658.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-15 21:34:59 +02:00
Andreas Rheinhardt
4cd1d3e3b7 avcodec/iff: Use unsigned to avoid compiler warning
GCC 12 apparently believes that negative palette sizes are
possible (they are not, as this has already been checked during
init) and therefore emits a -Wstringop-overflow= for the memcpy.
Using unsigned avoids this.
(To be honest, there might be a compiler bug involved.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-15 21:29:59 +02:00
Andreas Rheinhardt
487fc61cb2 avcodec/iff: Remove transient objects from the context
This avoids keeping invalid pointers in the context.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-15 21:29:59 +02:00
Andreas Rheinhardt
828a0c4254 avcodec/iff: Reindent after the previous commits
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-15 21:29:59 +02:00
Andreas Rheinhardt
8612b26202 avcodec/iff: Pass extradata and extradata_size explicitly
This might be useful in case this decoder were changed to support
new extradata passed via side-data.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-15 21:29:59 +02:00
Andreas Rheinhardt
d0df74553b avcodec/iff: Return early when possible
It allows to save one level of indentation.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-15 21:29:59 +02:00
Andreas Rheinhardt
46b586e5b2 avcodec/iff: Avoid redundant frees
This code is only called once during init, so none of the buffers
here have been allocated already.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-15 21:29:59 +02:00
Andreas Rheinhardt
f0be9129ad avcodec/iff: Split extract_header into extradata and packet part
183132872a made the iff demuxer
output extradata and made the decoder parse said extradata.
To make this extradata extensible, it came with its own internal
length field (containing the offset of the palette at the end
of the extradata). Furthermore, in order to support mid-stream
extradata changes, the packets returned by the demuxer also have
such a length field (containing the offset of the actual packet
data). Therefore the packet parsing the extradata accepted its
input from both AVPackets as well as from ordinary extradata.

Yet the demuxer never made use of this "feature": The packet's
length field always indicated that the packet data starts
immediately after the length field.

Later, commit cb928fc448 stopped
appending the length field to the packets' data; of course,
it also stopped searching for extradata in this data.

Instead it added code to parse the packet's header to the function
that parses extradata. This made this function consist of two disjoint
parts, one of which is only reachable if this function is called
from init (when parsing extradata) and one of which is reachable
when parsing packet headers.

Therefore this commit splits this function into two.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-15 21:29:59 +02:00
Andreas Rheinhardt
bffc8f9af1 avcodec/adpcmenc: Round up required buffer size
Otherwise the buffer might be too small. Fixes assert violations
when encoding mono audio with exactly one sample.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-15 21:15:27 +02:00
Timo Rothenpieler
c9bd6ee5cb avfilter/vf_colorspace_cuda: mark fall-through 2022-09-15 19:35:30 +02:00
Rémi Denis-Courmont
a90e5335b3 avutil/lfg: fix comment typo 2022-09-15 20:56:23 +05:30
James Almer
0e0f74b632 avfilter/vf_drawbox: use the correct macro to fill rgb plane pointers
Fixes ticket #9924

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2022-09-15 09:13:29 -03:00
Wang Yaqiang
3f0fac9303 fftools/ffplay: fix rotation incorrect when frame contains the displaymatrix
For example, if the jpeg contains exif information
and the rotation direction is included in the exif,
the displaymatrix will be set on the side_data of the frame when decoding.
However, when ffplay is used to play the image,
only the side data in the stream will be determined.
It does not check whether the frame also contains rotation information,
causing it to play in the wrong direction

Reviewed-by: Zhao Zhili <zhilizhao@tencent.com>
Signed-off-by: Wang Yaqiang <wangyaqiang03@kuaishou.com>
2022-09-15 16:16:16 +08:00
Andreas Rheinhardt
859b31de50 avfilter/video: Fix newline in trace output
Forgotten in 7e350379f8.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-14 21:49:00 +02:00
Andreas Rheinhardt
e10774a8cc avfilter/avfilter: #if ff_tlog_link() away when empty
It is currently calling av_channel_layout_describe()
unnecessarily.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-14 21:48:48 +02:00
Andreas Rheinhardt
f4af504a1f avfilter/avfilter: Don't use AVFrame.channel_layout
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-14 21:48:11 +02:00
Christian Feldmann
8357d4790f avfilter/vf_libvmaf: copy all values also for 10 bit input 2022-09-14 19:42:59 +02:00
Jyrki Vesterinen
8fc2dedfe6 avcodec/vorbisdec: don't use a flag to determine if frames have been output
If a developer using FFmpeg libraries seeks into an earlier position and calls
avcodec_flush_buffers() afterwards as recommended, the Vorbis decoder will drop
the next frame, since buffer flushing clears the first_frame flag. As a result,
the audio samples the calling code receives may be ahead of the requested seek
position, which is unacceptable in some use cases such as playing a looping
sound effect.

This commit records the presentation timestamp of the first frame and
determines after that if the new frame is the first frame (possible after
seeking to the start) by comparing its pts to the stored pts.
2022-09-14 19:42:59 +02:00