Commit graph

53505 commits

Author SHA1 Message Date
James Almer
7c877b2e80 avcodec/opus/enc: rescale packet duration when calculating discarded samples
Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-17 20:17:23 -03:00
James Almer
0aa3a6fe41 avcodec/libvorbisenc: rescale packet duration when calculating discarded samples
Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-17 20:17:23 -03:00
James Almer
84bb5b0748 avcodec/libopusenc: rescale packet duration when calculating discarded samples
Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-17 20:17:23 -03:00
James Almer
5863cab885 avcodec/libmp3lame: rescale packet duration when calculating discarded samples
Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-17 20:17:23 -03:00
James Almer
e3061be971 avcodec/libfdk-aacenc: rescale packet duration when calculating discarded samples
Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-17 20:17:23 -03:00
James Almer
dd9756286d avcodec/encode: add a helper to convert from a duration to samples
Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-17 20:17:23 -03:00
Diego de Souza
cb0f4de1f5 avcodec/nvenc_av1: fix b_ref_mode "middle" help string for AV1
For AV1, NV_ENC_BFRAME_REF_MODE_MIDDLE does not use a single middle
B-frame. Per the NVENC Programming Guide, it sets every other B-frame
as an Altref2 reference except the last B-frame in the Altref interval.

Signed-off-by: Diego de Souza <ddesouza@nvidia.com>
2026-02-17 16:36:51 +00:00
Marton Balint
33b215d155 avcodec/libvpxenc: add experimental support for alpha pixel formats other than YUV 4:2:0.
I could not find any documentation which disallows the use of transparency for
pixel formats other than YUV 4:2:0, so this patch adds support for transparency
using 4:2:2, 4:4:4, RGB, and their high bit depth variants.

It is not quite clear if the alpha channel should be encoded using the
same pixel format as the normal channels, or it should be always YUV 4:2:0. I
sticked to 4:2:0.

Unfortunately the browsers I tested (chrome, firefox) only support 4:2:0
properly, so let's require an experimental flag to generate files with the new,
more exotic pixel formats.

Signed-off-by: Marton Balint <cus@passwd.hu>
2026-02-15 20:28:31 +01:00
Marton Balint
d373dfe157 avcodec/libvpxdec: add support for decoding pixel formats other than YUV420 with alpha
Signed-off-by: Marton Balint <cus@passwd.hu>
2026-02-15 20:28:31 +01:00
Michael Niedermayer
0d59620bff
avcodec/bmp: Move picture allocation after some checks
Fixes: Timeout
Fixes: 479872424/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_BMP_DEC_fuzzer-5311478919135232

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-15 20:09:54 +01:00
Michael Niedermayer
50adb62670
avcodec/bmp: fix indention
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-15 20:09:54 +01:00
Michael Niedermayer
33b3dbaf15
avcodec/exr: Handle axmax like bxmin in 04d7a6d3db
Fixes: out of array access
Fixes: 418335931/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EXR_DEC_fuzzer-6718455383654400
Fixes: 471611870/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EXR_DEC_fuzzer-6645447302381568

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-15 19:57:42 +01:00
Andreas Rheinhardt
4ef5efc2b6 avcodec/aacps_tablegen_template: Fix hardcoded tables with assert-level 2
In this case an av_assert2 in lavu/softfloat.h pulls in
a dependency on av_log(), which is not available at all,
because the tablegen tools are created for and run on
the host, not the target. This leads to linking failures.

Fix this by undefining ASSERT_LEVEL before the inclusion
of avassert.h.

Reviewed-by: Timo Rothenpieler <timo@rothenpieler.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-14 20:14:47 +01:00
Michael Niedermayer
be1fd6d9d4 avcodec/prores_raw: Tiles of width less than 16 result in undefined behavior
Fixes: passing zero to __builtin_clz(), which is not a valid argument
Fixes: 471569982/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PRORES_RAW_DEC_fuzzer-5832576221904896

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-14 18:53:08 +00:00
Michael Niedermayer
2ad078b589 avcodec/exif: Check that the values read exist in the input
Fixes: Timeout
Fixes: 471568865/clusterfuzz-testcase-minimized-ffmpeg_dem_AVI_fuzzer-4864048211755008
Fixes: 471951381/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_DEC_fuzzer-5069855998148608
Fixes: 471472005/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AMV_DEC_fuzzer-4660042365468672
Fixes: 471591900/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WEBP_fuzzer-5083936243122176
Fixes: 471593729/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MJPEG_DEC_fuzzer-5401314998943744

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-14 18:52:43 +00:00
Valerii Zapodovnikov
4eca335d94 avcodec/hevc/hevcdec: take into account YUV400 in block length
Also move some definitions around.

Signed-off-by: Valerii Zapodovnikov <val.zapod.vz@gmail.com>
2026-02-14 16:23:16 +00:00
James Almer
a7522f3fef avcodec/libvorbisenc: export padding samples if needed
Based on code from libopus encoder wrapper.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-13 11:50:32 -03:00
James Almer
23dce39d5a avcodec/libvorbisenc: export initial padding during init()
Priming samples don't depend on the contents of the first frame passed to the
encoder but rather on encoder configuration, so use dummy vorbis_dsp_state and
vorbis_block with the main encoder vorbis_info to generate a packet we can then
parse to derive the initial padding.

Muxers will now be aware of the initial padding before receiving packets, which
will allow them to write proper container headers during init without any extra
considerations like having to do a second pass or rewrite during write_trailer.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-13 11:50:32 -03:00
Andreas Rheinhardt
0a629df0a8 avcodec/ratecontrol: Move emms_c() to the only callsite needing it
Namely to one of the three callsites in snowenc.c.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-13 09:21:33 +01:00
Andreas Rheinhardt
059654a73b avcodec/ratecontrol: Remove unnecessary emms_c()
ff_rate_control_init/uninit() are only called during
codec init or close and no DSP calls happen in these,
so there is no need to reset the floating point state.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-13 09:21:33 +01:00
Andreas Rheinhardt
fe1742618d avcodec/snowenc: Remove redundant emms_c()
This emms_c() has been superseded by the one added
a few lines above in 2c1d38d1e1.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-13 09:21:33 +01:00
Andreas Rheinhardt
c5d9711be4 avcodec/mpegvideoenc: Remove MMX from comment
The MMX code has been removed in 5ef613bcb0
and MMX was not used for most cpus even before then.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-13 09:21:33 +01:00
Andreas Rheinhardt
fe0d8cb3e4 avcodec/x86/dirac_dwt: Remove MMX in comment
Forgotten in 5e332fe35c.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-13 09:21:33 +01:00
James Almer
ff98352c3d avcodec: set skip_samples in generic code
Decoders should only worry about exporting AVCodeContext->delay during init.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-12 09:59:54 -03:00
Andreas Rheinhardt
afb374f109 avcodec/dpcm: Remove unnecessary flush callbacks
{INTERPLAY,ROQ,XAN}_DPCM does not use the stored samples at all.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-12 11:06:33 +01:00
Andreas Rheinhardt
e3ec6322bb avcodec/dpcm: Avoid trailing '_' in macro parameters
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-12 11:06:33 +01:00
Andreas Rheinhardt
66c7bf3bf8 avcodec/adpcmenc: Don't advertise ineffective options
ADPCM_ARGO, ADPCM_IMA_QT and ADPCM_SWF don't use
the block_size option at all.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-12 10:34:19 +01:00
Andreas Rheinhardt
b764f40eaa avcodec/adpcmenc: Check sample rates, ch layouts generically
This also advertises the supported sample rates/channel layouts.
For ADPCM_IMA_AMV, it actually fixes the advertised channel layouts.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-12 10:34:19 +01:00
Andreas Rheinhardt
77d7891052 avcodec/adpcmenc: Mark unreachable code as such
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-12 10:34:19 +01:00
James Almer
10acab8df5 avcodec/hevc/hevcdec: report unparsed unknown NALUs types at verbose level
Reduces spamming at default log level.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-11 21:57:20 -03:00
Kacper Michajłow
3b4281e919 avcodec/hevc/hevcdec: skip logging 'Skipping NAL unit 63'
We know that this is Dolby Vision Enhancement Layer and while it's not
handled, we can just reduce log spam for this, as it's if fact
recognized.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-02-12 00:56:21 +00:00
Kacper Michajłow
fa36645f7e avcodec/bsf/dovi_rpu: fix typo
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-02-12 00:56:21 +00:00
John Chadwick
a469598191 avcodec/psd: Support auxiliary channels
Photoshop documents can contain additional "auxiliary" channels that
don't take part in layer compositing, therefore, using the channel count
to determine the presence of an alpha channel in the merged image is
incorrect. Instead, as per the PSD specification, use the sign of the
layer count (present in the layers and masks section) to determine if
there is an alpha channel, then determine the number of primary channels
using both the presence of the alpha channel and the pixel format.
2026-02-11 20:35:20 +00:00
Andreas Rheinhardt
7e3781e3ca avcodec/libcodec2: Remove always-false checks
Already checked via CODEC_SAMPLERATES and CODEC_SAMPLEFMTS.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-11 12:07:38 +01:00
Andreas Rheinhardt
12c2a4e117 avcodec: Don't set AVCodec.sample_fmts,ch_layouts for decoders
It is pointless for them given that these values will
be overridden by the decoder lateron anyway.
The only exceptions to this are scenarios where the decoder
actually checks request_sample_fmt or where there are both
fixed- and floating point decoders.

(IMO something like get_format() for audio would be better for
both cases.)

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-11 12:07:35 +01:00
Andreas Rheinhardt
028d9d3997 avcodec/sbcdec: Don't set encoder-only fields
ch_layouts, sample_fmts and supported_samplerates
are of no use for a decoder, so don't set them.
In this case this fixes an inconsistency:
ch_layouts contained mono and stereo, yet lateron
the AVCodecContext's ch_layout is always populated
with an AV_CHANNEL_ORDER_UNSPEC layout.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-11 12:07:31 +01:00
Andreas Rheinhardt
f648dd0e8a avcodec/adpcm: Don't set AVCodec.sample_fmts
It is unnecessary for a decoder (the sample fmt is
set lateron during init and the user has no choice
over this (even for the decoders where sample_fmts
contains two entries).

(This also fixes the ADPCM_DECODER macro: It's second
and third parameters were called "name" and "sample_fmts",
yet the second argument always contained the sample fmts.)

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-11 12:07:07 +01:00
Andreas Rheinhardt
3a7c09eb39 avcodec/x86/mpegvideoencdsp_init: Port draw_edges to SSSE3
Benchmarks:
draw_edges_8_1724_4_c:                                2672.2 ( 1.00x)
draw_edges_8_1724_4_mmx:                              3191.5 ( 0.84x)
draw_edges_8_1724_4_ssse3:                            2179.6 ( 1.23x)
draw_edges_8_1724_8_c:                                2852.3 ( 1.00x)
draw_edges_8_1724_8_mmx:                              3683.0 ( 0.77x)
draw_edges_8_1724_8_ssse3:                            2225.7 ( 1.28x)
draw_edges_8_1724_16_c:                               4169.4 ( 1.00x)
draw_edges_8_1724_16_mmx:                             4665.9 ( 0.89x)
draw_edges_8_1724_16_ssse3:                           2765.8 ( 1.51x)
draw_edges_128_407_4_c:                               1126.6 ( 1.00x)
draw_edges_128_407_4_mmx:                              943.9 ( 1.19x)
draw_edges_128_407_4_ssse3:                            925.7 ( 1.22x)
draw_edges_128_407_8_c:                               1208.8 ( 1.00x)
draw_edges_128_407_8_mmx:                             1119.1 ( 1.08x)
draw_edges_128_407_8_ssse3:                            997.8 ( 1.21x)
draw_edges_128_407_16_c:                              1352.4 ( 1.00x)
draw_edges_128_407_16_mmx:                            1368.7 ( 0.99x)
draw_edges_128_407_16_ssse3:                          1148.3 ( 1.18x)
draw_edges_1080_31_4_c:                                228.5 ( 1.00x)
draw_edges_1080_31_4_mmx:                              240.8 ( 0.95x)
draw_edges_1080_31_4_ssse3:                            226.7 ( 1.01x)
draw_edges_1080_31_8_c:                                411.1 ( 1.00x)
draw_edges_1080_31_8_mmx:                              432.9 ( 0.95x)
draw_edges_1080_31_8_ssse3:                            403.2 ( 1.02x)
draw_edges_1080_31_16_c:                              1121.2 ( 1.00x)
draw_edges_1080_31_16_mmx:                            1124.9 ( 1.00x)
draw_edges_1080_31_16_ssse3:                          1125.4 ( 1.00x)
draw_edges_1920_4_4_c:                                 310.8 ( 1.00x)
draw_edges_1920_4_4_mmx:                               311.6 ( 1.00x)
draw_edges_1920_4_4_ssse3:                             311.6 ( 1.00x)
draw_edges_1920_4_4_negstride_c:                       307.0 ( 1.00x)
draw_edges_1920_4_4_negstride_mmx:                     306.7 ( 1.00x)
draw_edges_1920_4_4_negstride_ssse3:                   306.7 ( 1.00x)
draw_edges_1920_4_8_c:                                 724.2 ( 1.00x)
draw_edges_1920_4_8_mmx:                               724.9 ( 1.00x)
draw_edges_1920_4_8_ssse3:                             717.3 ( 1.01x)
draw_edges_1920_4_8_negstride_c:                       719.2 ( 1.00x)
draw_edges_1920_4_8_negstride_mmx:                     717.1 ( 1.00x)
draw_edges_1920_4_8_negstride_ssse3:                   710.9 ( 1.01x)
draw_edges_1920_4_16_c:                               1752.9 ( 1.00x)
draw_edges_1920_4_16_mmx:                             1754.6 ( 1.00x)
draw_edges_1920_4_16_ssse3:                           1751.1 ( 1.00x)
draw_edges_1920_4_16_negstride_c:                     1783.2 ( 1.00x)
draw_edges_1920_4_16_negstride_mmx:                   1778.2 ( 1.00x)
draw_edges_1920_4_16_negstride_ssse3:                 1768.3 ( 1.01x)

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-11 11:15:06 +01:00
Andreas Rheinhardt
f0392c908c avcodec/flacenc: Use int for AV_OPT_TYPE_INT
Necessary for -fshort-enums.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-10 19:44:46 +01:00
Michael Niedermayer
38230db7b9
avcodec/vp9: Reallocate on resolution change which does not change tile_cols
Fixes: out of array access on resolution change with slices threads
Fixes: VULN-10/poc.ivf

Found-by: Zhenpeng (Leo) Lin from depthfirst
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-10 01:30:42 +01:00
Ramiro Polla
9ee6136ece avcodec/mjpegdec: remove start_code field from MJpegDecodeContext
Instead, pass it as a parameter to the only function that uses it.
2026-02-09 17:52:01 +00:00
Andreas Rheinhardt
1218a8a922 avcodec/rangecoder: Fix indentation
Forgotten after 832649986c
and d147b3d7ec.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-09 17:36:40 +00:00
Hassan Hany
273b161a98 avcodec/exif: skip EXIF entries with invalid TIFF field type 0
EXIF IFD entries with TIFF field type 0 are invalid per the specification.
Without a check, exif_read_values() fails to allocate entry->value,
causing an out of memory error.

This patch skips such entries early during parsing, allowing decoding
to continue normally.

Fixes: https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/21623
2026-02-08 19:56:20 +00:00
Michael Niedermayer
5f84a7263e avcodec/adpcm: Check input buffer size
Larger values will lead to integer overflows in intermediates
No testcase

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-08 14:46:56 +00:00
Andreas Rheinhardt
0fefecd53f Revert "avcodec/opus/parse: export the packet and extradata parsing functions"
This reverts commit aa20d7b3e8.

Adding these avpriv functions is absolutely overblown: Muxers
can get the desired duration in a few lines themselves.
In particular, using the parse functions from this file
necessitated parsing the extradata (and entailed exporting
the parsing function), although it was only used to know
whether the frames are self-delimiting, but everything of
interest to a muxer does not depend on this at all.

The commit to be reverted also made several structures
part of the ABI, which should be avoided in general.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-06 14:09:15 +01:00
Andreas Rheinhardt
12747e6296 avformat/matroskaenc: Parse Opus packet durations ourselves
This avoids avpriv functions from lavc/opus/parse.c
(which parse way more than we need, necessitating
parsing the extradata).
It furthermore makes the output of the muxer consistent,
i.e. no longer depending upon whether the Opus parser
or decoder are enabled (the avpriv functions would just
return AVERROR(ENOSYS)).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-06 14:05:14 +01:00
Andreas Rheinhardt
853843d86f avcodec/opus/parse: Move frame_duration tab into a file of its own
This is in preparation for duplicating it into libavformat.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-06 14:04:50 +01:00
James Almer
aa20d7b3e8 avcodec/opus/parse: export the packet and extradata parsing functions
Needed for the following commit.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-05 23:21:49 -03:00
Michael Niedermayer
8f57b04fe5 avcodec/hevc/sei: Use get_bits64() in decode_nal_sei_3d_reference_displays_info()
Fixes: Assertion n>=0 && n<=32 failed at ./libavcodec/get_bits.h:426
Fixes: 468435217/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-4644127078940672

Found-by:  continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-05 20:20:08 +00:00
Michael Niedermayer
af86f0ffcc
avcodec/dca_xll: Clear padding in ff_dca_xll_parse()
Fixes: Use of uninitialized memory
Fixes: 472020020/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DCA_DEC_fuzzer-6433045331902464

Found-by:  continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-05 18:12:46 +01:00