Commit graph

54303 commits

Author SHA1 Message Date
Andrew Kelley
8a10a8a03e opus: qualify libavcodec include paths
Removes the special -I flag specified in the avcodec/opus/ subdirectory.

This makes code copy-pastable to other parts of the ffmpeg codebase, as
well as simplifying the build script.

It also reduces ambiguity, since there are many instances of same-named
header files existing in both libavformat/ and libavcodec/
subdirectories.

Follows: b29bdd3715
2026-06-12 00:49:14 +00:00
David Korczynski
4527854281 avcodec/agm: validate actual src_y against prev plane in decode_inter_plane
Found-by: Anthropic agents; validated and reported by Ada Logics.

Signed-off-by: David Korczynski <david@adalogics.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-12 00:47:12 +00:00
Michael Niedermayer
d2dd0a0a8f avcodec/cbs_h265: allocate VPS hrd_parameters dynamically
H265RawVPS embedded hrd_parameters as an inline array of
HEVC_MAX_LAYER_SETS (1024) H265RawHRDParameters, making the structure
roughly 7.9 MB. CBS allocates the whole content structure for every VPS
NAL unit before parsing it, so a packet consisting of many tiny VPS NALs
forces gigabytes of allocations and triggers an out-of-memory condition.

Allocate hrd_parameters separately, sized to vps_num_hrd_parameters,
backed by an AVBufferRef registered as a second internal reference
offset on the VPS unit type. This shrinks the resident structure to tens
of kilobytes and bounds the hrd_parameters allocation by the amount that
is actually parsed.

Fixes: 472754452/clusterfuzz-testcase-minimized-ffmpeg_BSF_HEVC_METADATA_fuzzer-6379024978083840
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-12 00:43:44 +00:00
Michael Niedermayer
82f097c825 avcodec/hevc/ps: Check window parameters
Fixes: signed integer overflow: -1094995529 * 2 cannot be represented in type 'int'
Fixes: 484567435/clusterfuzz-testcase-minimized-ffmpeg_dem_HXVS_fuzzer-5628836988649472

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-12 01:44:34 +02:00
Michael Niedermayer
8c868a1fd2 avcodec/hevc/ps: Factor window reading out
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-12 01:44:34 +02:00
James Almer
4b23a90935 avcodec/lcevcdec: respect log level from the external library
Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-11 17:28:14 -03:00
James Almer
d024831750 avcodec/lcevcdec: don't inherit the parent decoder logging context
Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-11 17:27:19 -03:00
Romain Beauxis
f35a082ecc libavformat/{riffenc, adpcmenc}.c: export correct bitrate 2026-06-11 14:06:20 +00:00
Romain Beauxis
12dddab095 libavcodec/tests/encinfo.c: add encoder info test utility 2026-06-11 14:06:20 +00:00
David Korczynski
d30dead35e avcodec/truespeech: reject iterations count whose * 240 product overflows 32-bit
Found-by: Anthropic agents; validated and reported by Ada Logics.
Signed-off-by: David Korczynski <david@adalogics.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-11 13:58:45 +00:00
Andrew Kelley
b29bdd3715 bsf: qualify libavcodec include paths
Removes the special -I flag specified in the avcodec/bsf/ subdirectory.

This makes code copy-pastable to other parts of the ffmpeg codebase, as
well as simplifying the build script.

It also reduces ambiguity, since there are many instances of same-named
header files existing in both libavformat/ and libavcodec/
subdirectories.

Reverts: 0e4dfa4709
Reapplies: 41b73ae883
2026-06-10 18:52:32 -07:00
Timo Rothenpieler
5f998e304d avcodec/nvenc: fix b_ref_mode capability check
Turns out it's a bitfield, not straight values.

Fixes #23061
2026-06-10 20:17:44 +02:00
Martin Storsjö
d05786cf23 aarch64: vp9lpf: Fix GCS violations
The aarch64 VP9 loopfilters actually violate aarch64 GCS
(Guarded Control Stack), even though we marked the code as GCS
compliant in 846746be4b.

This means that builds with GCS enabled, after that commit,
will crash when decoding VP9, on future hardware (or current
QEMU) that supports GCS. This also goes for ffmpeg version 8.1.1
where the GCS enabling was backported.

This matches the fix that was done for hevcdsp in
1f7ed8a78d.

This issue wasn't observed if running checkasm in QEMU - therefore,
I thought all GCS issues had been fixed by
846746be4b. (If I would have
tested the full "make fate" with QEMU, the issue would
have appeared though.)

However with the new checkasm, some of the GCS violations
do appear even in checkasm.

The reason is that the checkasm vp9 test intentionally craft
input pixels that attempt to trigger all the individual
separate cases in each input buffer (in
randomize_loopfilter_buffers). This means that the checkasm
tests actually never test or exercise the early exit cases,
which are the ones that violate GCS.

With the new checkasm, the call to "bench_new" always test
running the code at least once, even if not benchmarking.

As the input buffers weren't reinitialized between the test
and "bench_new", the pixel differences now differ from the
initial setup, so that the code now some times (often) would
end up hitting the early exit cases.

Ideally, the vp9 checkasm test would be repeated to cover all
cases of input buffers that allow early exits, in addition to
covering the case with all different cases in one block.
2026-06-10 18:03:01 +00:00
Romain Beauxis
590d775a66 avcodec/codec_id: add .props to AV_CODEC_ID_APPLE_APAC
Signed-off-by: Romain Beauxis <romain.beauxis@gmail.com>
2026-06-10 10:08:39 -05:00
Frank Plowman
b899f7e8b5 lavc/vvc: Fix num_entry_points derivation when using RPR
Context:
1. In the case sps_subpic_info_present=0, there is a single subpicture
   which includes the entire picture.
2. When sps_subpic_info_present=0, we might be using Reference Picture
   Resampling (RPR), in which picture sizes might differ in the PPS,
   rather than in the SPS.

Because of 2., we can't rely on the sequence-level variables
sps_subpic_width_minus1 and sps_subpic_height_minus1 to derive the
picture-level variable num_entry_points, as the picture might have a
different size to the picture used when deriving those sequence-level
variables.
2026-06-10 14:02:29 +00:00
Robert Nagy
06e11c87c6 libavcodec/options_table: gamma22 and gamma28 aliases 2026-06-10 12:34:38 +00:00
Romain Beauxis
f98eaa3ea9 avcodec/codec_id: Add Apple Positional Audio Codec.
Signed-off-by: Romain Beauxis <romain.beauxis@gmail.com>
2026-06-10 11:59:35 +00:00
Lynne
f1b4b5b5f6 aacdec_usac: apply volume normalization settings 2026-06-10 18:04:22 +09:00
Lynne
71b59582e2 aacdec_usac: implement basic DRC parameter decoding 2026-06-10 18:04:22 +09:00
David Korczynski
331b3e9dea avcodec/on2avc: reject subframe count whose * SUBFRAME_SIZE product overflows 32-bit
Found-by: Anthropic agents; validated and reported by Ada Logics.
Signed-off-by: David Korczynski <david@adalogics.com>
2026-06-10 02:15:53 +00:00
Diego de Souza
0a7c5e507b avcodec/nvenc: fix compatibility with Video Codec SDK 13.1
NV_ENC_CLOCK_TIMESTAMP_SET was changed in SDK 13.1: countingType was
replaced by countingTypeLSB and countingTypeMSB.

Signed-off-by: Diego de Souza <ddesouza@nvidia.com>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2026-06-10 01:28:40 +02:00
James Almer
9eb6f2f450 avcodec/aacenc: fix PCE layouts for 7.1 and 7.1(wide)
Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-09 15:33:20 -03:00
Lynne
4406f5ba5b
prores_raw: document vendor-specific metadata location 2026-06-10 02:38:36 +09:00
Lynne
4cf96187e4
prores_raw: set frame crop fields
Some sensors or cameras put junk in the frame boundaries. We should
crop them out.
2026-06-10 02:38:35 +09:00
Lynne
0def4ceb18
prores_raw: export raw camera color data values 2026-06-10 02:38:35 +09:00
Jun Zhao
cfa3ceac7a lavc/hevc: add aarch64 NEON for angular modes 10 and 26
Add NEON-optimized implementations for HEVC angular intra prediction
modes 10 (pure horizontal) and 26 (pure vertical) at 8-bit depth.

Mode 10 (Horizontal):
- Broadcasts left[y] to fill each row using ld2r/ld4r for efficiency
- Applies edge smoothing for luma blocks smaller than 32x32

Mode 26 (Vertical):
- Copies top reference row to all output rows
- Applies edge smoothing for luma blocks smaller than 32x32

Edge smoothing uses uhsub+usqadd to compute the filtered result
directly in 8-bit, avoiding widening to 16-bit intermediates.

The C pred_angular wrappers are made non-static with ff_ prefix to
allow the NEON dispatch to fall back to C for modes not yet optimized.
This will be reverted once all angular modes are implemented.

Note: since pred_angular[] is a per-size function pointer (not
per-mode), checkasm benchmarks will show '_neon' for all 33 modes
even though only modes 10/26 are truly accelerated; unoptimized
modes show ~1.0x speedup as they pass through the NEON wrapper to
the C fallback with negligible overhead.

Speedup over C on Apple M4 (checkasm --bench, 15-run average):

  Mode 10 (Horizontal):
    4x4: 4.66x    8x8: 5.80x    16x16: 16.86x    32x32: 24.89x

  Mode 26 (Vertical):
    4x4: 1.16x    8x8: 1.83x    16x16: 2.45x    32x32: 4.50x

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-06-07 23:29:33 +00:00
Jun Zhao
3ec0f14f7d avcodec/h264_ps: set default SAR, remove stale workaround
Set sps->vui.sar to {0,1} (unspecified) before the VUI parsing
block, matching the HEVC pattern at hevc_ps.c.  The old
zero-init-to-1 workaround is now unreachable and is removed.

Suggested-by: James Almer <jamrial@gmail.com>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-06-07 18:55:16 +00:00
Jun Zhao
e598463b3d avcodec/h2645_vui: interpret a degenerate SAR as unspecified
Per ITU-T H.264 (ISO/IEC 14496-10) Annex E.2.1 and ITU-T H.265
(ISO/IEC 23008-2) Annex E.3.1, when sar_width or sar_height is zero
the sample aspect ratio shall be considered unspecified. Internally
ffmpeg represents an unspecified SAR as 0/1, while fractions with a
zero denominator are not handled properly (den=0 is silently changed
to den=1 in h264_ps.c, turning an invalid 20480/0 into a "valid" but
impossibly extreme 20480/1); so we bridge the gap by replacing x/0
with 0/1 at the VUI parsing layer.

An av_log warning is added so an invalid SAR in the bitstream is
diagnosed rather than silently overwritten.

This fixes a problem with some video files provided by game
OddBallers when executed with Wine/Proton, which report SAR 20480/0.

Based on patch by Giovanni Mascellani <gmascellani@codeweavers.com>.
Fixes: ticket #23321

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-06-07 18:55:16 +00:00
Andreas Rheinhardt
bb49197ede avcodec/liboapvenc: Remove dimension change check
If this were to be checked, it should be checked generically,
not in every single encoder.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-07 17:53:44 +02:00
Andreas Rheinhardt
0faa43ae6c avcodec/liboapvenc: Use av_image_copy2() to avoid cast
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-07 17:53:44 +02:00
Andreas Rheinhardt
bf47563bd8 avcodec/liboapvenc: Remove always-false checks
Already checked in encode_preinit_video().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-07 17:53:44 +02:00
Andreas Rheinhardt
80ea2d1487 avcodec/liboapvenc: Return directly when possible
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-07 17:53:44 +02:00
Andreas Rheinhardt
67855a7234 avcodec/liboapvenc: Use av_unreachable for unreachable default cases
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-07 17:53:44 +02:00
Andreas Rheinhardt
9791c4d183 avcodec/liboapvenc: Don't set AVCodec.pix_fmts directly
Instead use CODEC_PIXFMTS. Avoids deprecation warnings
from Clang and simplifies the removal of AVCodec.pix_fmts.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-07 17:53:44 +02:00
James Almer
d1faab734d avcodec/dcadec: map Lw/Rw to FLC/FRC
Some 7.1 DTS files seem to signal Lw/Rw channels that the decoder has been
mapping to SL/SR, despite the macro for the mask being called 7_1_WIDE.
This resulted in said samples reporting the same native layout as actual 7.1
samples with Lsr/Rsr/Lss/Rss (mapped to BL/BR/SL/SR).

If we were to be strict, Lw/Rw would map to WR/WL, but that would result in an
unusual native layout. Instead, lets map them to FLC/FRC, which will result in
the more common 7.1(wide) native layout.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-07 10:24:42 -03:00
Michael Niedermayer
04e2341056 avcodec/adpcm: fix signed integer overflow in get_nb_samples()
Fixes: signed integer overflow: 314572800 * 8 cannot be represented in type 'int'

Tighten the guard to INT_MAX/14, which covers the largest expansion
factor used in the function currently.

Found-by: Jiale Yao <19888972804@163.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-07 02:57:25 +00:00
David Korczynski
1e9984772b avcodec/fastaudio: reject subframes count whose * 256 product overflows 32-bit
fastaudio_decode() computes
    subframes = pkt->size / (40 * channels);
    frame->nb_samples = subframes * 256;
both as 32-bit signed multiplications. When pkt->size is large enough
to make subframes >= 2^24, the second multiplication overflows the
signed int range and frame->nb_samples wraps to a small value.
ff_get_buffer() then sizes the audio plane for that wrapped sample
count, while the decoder loop at line 152 still iterates the full
(unwrapped) subframes count, performing a 1024-byte memcpy per
subframe per channel. The 27th iteration (or first iteration with
nb_samples=0) writes one byte past the per-plane allocation,
yielding the ASan heap-buffer-overflow WRITE at libavcodec/fastaudio
.c:171 reported as ANT-2026-03891.

Reject the subframes value whose *256 product would overflow before
performing the multiplication. The bound INT_MAX / 256 (= 8388607)
keeps the existing two's-complement semantics of every reachable
input and rejects only the configurations that would have wrapped.

Reproducer: a crafted AVI declaring one mono audio chunk of
671_088_680 bytes (sparse) with the decoder forced via
'ffmpeg -c:a fastaudio -i evil.avi'.

Found-by: Anthropic agents; validated and reported by Ada Logics.

Signed-off-by: David Korczynski <david@adalogics.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-06 21:32:08 +00:00
Michael Niedermayer
7c7ca349bc avcodec/vc2enc_dwt: avoid signed overflow in the 5/3 and Haar DWT
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-06 19:07:39 +00:00
Michael Niedermayer
5f91556215 avcodec/vc2enc_dwt: avoid signed overflow in the 9/7 DWT lifting
Fixes: 490488944/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC2_fuzzer-5310290362433536
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-06 19:07:39 +00:00
Michael Niedermayer
b355200263 avcodec/mjpegdec: require progress in AVRn interlaced field loop
Fixes: Timeout
Fixes: 500554625/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MEDIA100_fuzzer-5094103347167232
Fixes: 511253447/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SMVJPEG_fuzzer-5780722463080448
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-05 11:49:42 +00:00
Andreas Rheinhardt
56124f1e68 avcodec/exif: Remove version_major.h inclusion
Forgotten in d151d3aecb.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-05 03:02:04 +00:00
Andreas Rheinhardt
447a07fc12 avcodec/decode: Move exif declarations to exif_internal.h
It is (arguably) a slightly better place for them and avoids
a forward declaration of enum AVExifHeaderMode which is not possible
in ISO C before C23 (and requires specifying the underlying type
with C23).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-05 03:02:04 +00:00
Michael Niedermayer
ba825ce85f avcodec/mwsc: do not dereference a missing reference frame
Fixes: 493841393/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MWSC_fuzzer-5079884677578752
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-05 01:27:39 +00:00
Michael Niedermayer
32eb07bb83 avcodec/misc4: reject invalid sample rate
Fixes: AVERROR_BUG

Fixes: 493055111/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MISC4_fuzzer-5752676962074624
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-05 01:16:31 +00:00
Hendrik Leppkes
89bdd9e1a5 avcodec/hevc: look for the DOVI RPU in all NALs, not just the last one
Some encoders seem to place the SEI suffix NAL at the very end, with the
RPU before it.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-05 01:08:08 +00:00
Andreas Rheinhardt
8c2c31f80c avcodec/utils: Don't attempt to derive CodecID name from de/encoders
The list of codec descriptors is supposed to encompass all codec IDs;
it certainly encompasses all codec IDs used by de/encoders (this is
checked in the avcodec test program which is run via FATE).
So the avcodec_find_decoder()/avcodec_find_encoder() are pointless.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-04 19:44:02 +00:00
Andreas Rheinhardt
e816b39fb2 avcodec/aacenc: Make AACPCEInfo smaller
Reduces sizeof(AACPCEInfo) from 296 to 120 bytes.
This reduces .rodata by 4576B here.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-04 19:17:43 +00:00
James Almer
1d45522806 avcodec/aacenc: remove excess initializers
pairing has only three elements.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-04 13:44:28 -03:00
James Almer
bca473e155 avcodec/aacenc: don't write SIDE position elements
Most parsers outright dislike anything being signaled as SIDE, as they expect layouts
to follow how ordering is pre-defined in non-0 channel_config values.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-04 14:18:35 +00:00
James Almer
55b510c702 avcodec/aacenc: fix signaled channel pairing for 6.1 PCE layout
Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-04 14:18:35 +00:00