Commit graph

54224 commits

Author SHA1 Message Date
Michael Niedermayer
054dffd133 avcodec/bsf/dts2pts: fix binary tree invariant violation on selective dec_poc
Modifying the keys of a sorted structure, be that a tree or other
can lead to changes in the ordering and undefined behavior.
It can also lead to collisions with existing keys.

All these cases need to be handled unless there is a bug elsewhere
that would prevent them.

Fixes: out of array access
Fixes: 504281984/clusterfuzz-testcase-minimized-ffmpeg_BSF_DTS2PTS_fuzzer-6032368162111488

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-31 13:41:57 +00:00
Lynne
49a77d37be
ffv1enc: write f->flt to extradata
The parser has been reading f->flt for combined_version >= 0x40004
since commit c1b330bf24 (avcodec/ffv1: Basic float16 support), but
ff_ffv1_write_extradata() never had a matching put_symbol().
The result was that the parsed f->flt was whatever the next symbol's
worth of rangecoded bits happened to decode to — often 0, but for a
yuv420p16le -level 4 -strict experimental stream produced locally it
parses as 1.  The software decoder doesn't notice because the YUV
pixfmt-selection branches never check f->flt, but anything else that
trusts it gets garbage.

Sponsored-by: Sovereign Tech Fund
2026-05-31 20:04:02 +09:00
Lynne
0678077143
ffv1enc: add RCT coefficient search for Bayer
Sponsored-by: Sovereign Tech Fund
2026-05-31 20:04:02 +09:00
Lynne
4f509c9e43
ffv1dec: implement Bayer pixel format encoding
Sponsored-by: Sovereign Tech Fund
2026-05-31 20:04:02 +09:00
Lynne
d62686b50f
ffv1enc: implement Bayer pixel format encoding
Sponsored-by: Sovereign Tech Fund
2026-05-31 20:03:57 +09:00
James Almer
c65c8f1f49 avcodec/dcadec: output a custom channel layout when requesting coded channel ordering
Outputting an UNSPEC layout will make most callers guess the speaker layout, and
more likely than not get it wrong.
Now that we can freely export custom order layouts, lets use them.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-30 22:37:09 -03:00
Romain Beauxis
5f6dff5e7d avcodec/packet: add AV_PKT_DATA_HEVC_CONF side data type
Carries a raw HEVCDecoderConfigurationRecord for the Dolby Vision
enhancement layer, parsed from the hvcE box (ISOM) or the corresponding
BlockAdditionMapping (Matroska).
2026-05-30 17:37:28 +00:00
David Korczynski
1152139b48 avcodec/cook: bound subpacket channel sum against channel count
Fixes: out of array read
Fixes: evil.rm

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-05-30 13:57:13 +00:00
Andreas Rheinhardt
b8c5376eb4 avcodec/vorbis_parser: Improve returned error codes
av_vorbis_parse_init() doesn't return an error code which is a slight
problem in libvorbisenc.c. Fix this by making the internal
initialization function behind av_vorbis_parse_init() available. This
also avoids allocations and frees.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-30 13:10:07 +02:00
Lynne
d66552e676
vulkan/ffv1: add 32-bit float RGB encoding and a rice + remap path
This implements 32-bit float RGB encoding and makes the Vulkan implementation
on-par with the C implementation.

Sponsored-by: Sovereign Tech Fund
2026-05-30 12:10:01 +09:00
Michael Niedermayer
7a2424eb43 avcodec/apv_decode: avoid using apv_cbc
Fixes: out of array access
Fixes: evil.apv

Found-by: Claude (Anthropic). Human-verified and reported by Omkhar Arasaratnam <omkhar@linkedin.com>. on 05-20
Found-by: Anthropic agents; validated and reported by Ada Logics. on 05-26
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-29 20:10:14 +00:00
Michael Niedermayer
6631bbc5d4 avcodec/jpeg2000dec: Clear header derived variables
Fixes: NULL pointer dereference

Found-by: Oguzhan Akkaya with AFL++ fuzzing (May 2026)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-28 22:31:36 +00:00
Michael Niedermayer
0834dbed1c avcodec/bsf/smpte436m_to_eia608: properly frees stuff on errors in ff_smpte436m_to_eia608_filter()
Fixes: memleaks
Fixes: 501913473/clusterfuzz-testcase-minimized-ffmpeg_BSF_SMPTE436M_TO_EIA608_fuzzer-5607133705207808

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-28 22:24:58 +00:00
James Almer
af4caa17a7 avcodec/libfdk_aac: simplify setting the layout mask
We can combine some cases in these switches as they set the same flags.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-28 13:23:42 +00:00
James Almer
3e402514e5 avcodec/aacencdsp: move init methods outside of the header
Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-28 00:04:06 -03:00
Tim Walker
5f14108864 avcodec/libfdk-aacdec: support streams with 5 front channels 2026-05-27 21:06:41 +02:00
Ramiro Polla
0ac3b00a18 avcodec/mjpegdec: simplify bayer width handling
Double s->avctx->width directly, simplifying width-related code in
ljpeg_decode_rgb_scan().
2026-05-26 11:19:14 +02:00
Ramiro Polla
2065ead16e avcodec/mjpegdec: remove redundant vpred variable for bayer
The vpred variable in ljpeg_decode_rgb_scan() is redundant with
buffer[0][i], which is used by the generic codepath.
2026-05-26 11:19:14 +02:00
Lynne
9a6b5ca197
vulkan/ffv1_enc_rct_search: fix slice dimension iterations
This was a mess, we were using incorrect pixels outside of the image boundaries as
valid, the iteration had undefined behaviour since it was non-uniform across the workgroup.

Calculate the per-invoc iterations from the slice dimensions instead, making all of
them identical. And add a valid flag to decide whether to use them or not. And fix the
synchronization.

Sponsored-by: Sovereign Tech Fund
2026-05-26 17:47:04 +09:00
Lynne
9cabb12f74
vulkan/ffv1_enc_rct_search: write slice_rct_coef directly by main invoc
The issue is that SliceContext was passed as an inout, which caused all
invocs to locally copy and modify it.
When the main invoc wrote it, only the very last written value was used,
choosing the wrong coeffs.

Sponsored-by: Sovereign Tech Fund
2026-05-26 17:47:04 +09:00
Lynne
5fc56fbf96
vulkan/ffv1_enc_rct_search: barrier before reading score_mode
There was a race condition where the main invocation would race ahead and use
values not yet written by other invocs.

Sponsored-by: Sovereign Tech Fund
2026-05-26 17:47:04 +09:00
Lynne
2806afd28f
vulkan/ffv1: read raw 16-bit float images via R16_UINT view to preserve denormals
GPUs filter out denormals when reading floats via imageLoad. Denormals shouldn't
be present in general, but if they are, this is a lossless codec, and we have to
preserve them. This allows reading the exact values.

Sponsored-by: Sovereign Tech Fund
2026-05-26 17:47:04 +09:00
Lynne
50e6668c83
vulkan/ffv1_enc: skip GOLOMB encode_line when !bits for FLOAT formats
Same as the arithmetic coded path. I skipped out on adding this here.

Sponsored-by: Sovereign Tech Fund
2026-05-26 17:47:04 +09:00
Lynne
e14e43aeaa
vulkan/ffv1_enc: pass the correct base and offset to OFFBUF in init_golomb
Ugh, my previous fix on this was only right in some cases, this is a general fix.

Sponsored-by: Sovereign Tech Fund
2026-05-26 17:47:03 +09:00
Lynne
d1e0a292ce
vulkan/ffv1_enc_remap: clear the full 65536-entry fltmap
Float pixfmts are meant to be normalized between [0, 1], but in case they
were not, and negative numbers were present, then the top bits would be
filled with garbage.

Sponsored-by: Sovereign Tech Fund
2026-05-26 17:47:03 +09:00
Lynne
4675271e7a
vulkan/rangecoder: fix encoding issue when -1 != 0xFF
This was an oversight while microoptimizing. The outstanding_byte can
reach 0xFF in some situations, which was causing errors when encoding,
particularly with 32-bit floats.

Sponsored-by: Sovereign Tech Fund
2026-05-26 17:46:59 +09:00
Hassan Hany
9288681068 avcodec/x86/vorbisdsp: change cmpleps to cmpltps in inverse coupling
Changed the comparison from cmpleps to strictly less than
(cmpltps) to strictly follow the Vorbis spec

Fixes https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/21501
2026-05-26 04:46:04 +00:00
Soham Kute
8885116f4d avcodec/liboapvenc: derive and validate APV profile from pixel format 2026-05-25 23:12:05 +00:00
Zuxy Meng
3921b435fc avcodec/x86/h264_intrapred: cosmetic fix
Mark needed xmm regs for pred8x8_top_dc_8; fix indentation for pred8x8_dc_8.

Signed-off-by: Zuxy Meng <zuxy.meng@gmail.com>
2026-05-25 12:18:09 -07:00
Franciszek Kalinowski
69bdb05f36 avcodec/pngdec: bound decompressed zTXt/iCCP size (decompression-bomb guard)
decode_zbuf() inflates zTXt (compressed text) and iCCP (ICC profile) chunk
payloads into an AVBPrint created with AV_BPRINT_SIZE_UNLIMITED and never
checks the decompressed size. A ~100 KB zTXt chunk of compressed zeros
expands to 100 MB; larger ratios or multiple chunks can exhaust memory.

Abort with AVERROR_INVALIDDATA once the decompressed output crosses a hard
cap (16 MiB).

Verified with a crafted PNG (1 KB compressed -> 100 MB decompressed): without
the patch the chunk fully decompresses, taking >100 MB; with the patch the
inflate loop aborts and the decoder logs "Compressed PNG chunk expands
beyond 16777216 bytes" / "Broken zTXt chunk" while the rest of the image
decodes normally.

Reported by Franciszek Kalinowski (isec.pl / striga.ai) and Bartosz Smigielski.
2026-05-25 15:09:20 +00:00
Franciszek Kalinowski
c79dfd29e6 avcodec/h264_slice: guard color_frame() against chroma-width underflow
In the >= 9 bit path, color_frame() does
`av_memcpy_backptr(dst + 2, 2, bytes - 2)`. When the effective chroma width
is 1 pixel (bytes == 1) the count becomes -1 and the underlying fill16()
loop runs roughly 2^32 times, producing a heap overflow. The original count
was also wrong in units (pixels rather than bytes); fix that at the same
time so the 2-pixel case still fills both pixels.

Confirmed via a standalone harness reproducing av_memcpy_backptr's fill16
loop with cnt = -1; reaching the call from a crafted H.264 bitstream
requires Hi10P plus a frame_num gap on a frame whose effective chroma width
is 1 pixel, which is hard to express but is reachable via mid-stream SPS
changes. Compiles cleanly; no regressions seen running existing crafted
H.264 PoCs and trivial transcodes.

Reported by Franciszek Kalinowski (isec.pl / striga.ai) and Bartosz Smigielski.
2026-05-25 13:16:03 +00:00
Zuxy Meng
34dfa8bf2b avcodec/x86/h264_intrapred: SSE2 impl. of pred8x8l_top_dc_8
Deprecate MMX with less instruction count. Remove the SSSE3 impl. as we
no longer use palignr.

pred8x8l_top_dc_8_mmxext:                                8.7 ( 2.29x)
pred8x8l_top_dc_8_ssse3:                                 7.9 ( 2.51x)
pred8x8l_top_dc_8_sse2:                                  6.7 ( 3.01x)

Signed-off-by: Zuxy Meng <zuxy.meng@gmail.com>
2026-05-25 07:05:09 +00:00
Macdu
f16c3cc5aa avcodec/atrac9dec: improve output of atrac9_decode_frame 2026-05-25 03:18:53 +00:00
Michael Niedermayer
c23d4da312 avcodec/magicyuv: Fix 1 line MEDIAN slices
No testcase

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-25 02:05:30 +00:00
Michael Niedermayer
5806e8b9f3 avcodec/magicyuv: Expand the s->interlaced slice-height sanity check
Fixes: poc_magicyuv.avi
Fixes: out of array access

Found-by: Ori Hollander of the JFrog Vulnerability Research team
2026-05-25 02:05:30 +00:00
Ori Hollander
374b726ffa avcodec/magicyuv: reject slice_height misaligned with chroma vshift
Fixes: poc_magicyuv.avi
Fixes: out of array access

Found-by: Ori Hollander of the JFrog Vulnerability Research team
2026-05-25 02:05:30 +00:00
amhurtado
d3f59f9b7f avcodec/prores_raw: reject invalid tile alignment values
Fixes: out of array access

Regression since d8cb567 ("prores_raw: fix tile alignment
issues").

Found-by: amhurtado <amhurtado@pm.me>
Signed-off-by: amhurtado <amhurtado@pm.me>
2026-05-24 22:27:08 +00:00
Romain Beauxis
2bae6f9d52 avformat/ogg: drop CELT support 2026-05-23 10:16:38 -05:00
Daniil Cherednik
816d74e0bb avcodec/opus/enc: fix CELT psy analysis and packet sizing
The CELT psychoacoustic path was effectively broken: analysis could use
the wrong queued audio and stale scratch samples, and raw band scores were
folded into the frame bit budget, where they could overflow instead of
only driving alloc_boost.

On top of that, c3aea7628c changed avctx->frame_size from fixed
120-sample steps to a configuration-derived value, while the CELT input
and psy paths still treated queue entries as 120-sample steps. That could
misalign psy analysis, read before a short overlap frame, stall silent
flushes, poison rate control with zero-bit silent frames, and overrun the
range coder on EOF or short tails.

This commit fixes these cases by using avctx->frame_size for psy step
accounting, aligning bufqueue analysis with actual audio, padding short
overlaps, and avoiding invalid bit-budget updates for silent or EOF
packets. This lets CELT produce valid packets again.
2026-05-23 10:38:28 +00:00
James Almer
3a042a5ab8 avcodec/libfdk-aacdec: support streams with more than six channels
Before this change, the decoder was forcing downmixing everything to a max of
six channels.
Layouts 6.1(back), 7.1(wide), 7.1 and 5.1.2 (Channel Configurations 11, 7, 12,
and 14 respectively, as well as the equivalent PCE version) should be supported
now.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-22 23:10:05 +00:00
James Almer
7755d264bd avcodec/libfdk-aacdec: fix the check for downmix layout order
The code reads a mask afer this check, meaning it expects NATIVE order, not
others.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-22 23:10:05 +00:00
Lynne
5b38e6eafb
apv_decode: add update_thread_context callback
An earliear commit added hwaccel hooks and a pix_fmt internal state
but did not synchronize its state when using frame threading with
a hwaccel.
2026-05-22 23:06:42 +09:00
Marvin Scholz
61a0b8fb41 avcodec: remove CELT decoder
libcelt, which it depends on, was not updated in a very long time and is
considered deprecated, as Opus exists which has a CELT mode. Therefore
remove standalone CELT decoding support.

It was already broken since b8604a9761,
11 years ago, and no one noticed and complained.
2026-05-22 09:33:52 +00:00
Michael Niedermayer
59367afc3d avcodec/jpeg2000dec: compute mask in decode_clnpass() like in decode_sigpass()
Fixes: integer overflow

Found by: Jiale Yao
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-21 01:08:30 +00:00
James Almer
79e30c18e6 avcodec/aacdec_tab: add side channels to ff_aac_channel_map
Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-20 13:05:57 -03:00
James Almer
2bad226f89 avcodec/aacenc: add missing default Channel Configurations
And stop writing 7.1 as 7.1(wide) (channel conf 7). Lets not create any more
non-spec compliant files that the native decoder needs to work around with now
that we can use PCE configuration for it, getting rid of the ambiguity.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-20 10:59:02 -03:00
James Almer
c92c6cbf19 avcodec/aacenc: fix PCE configs for known native layouts
Many of the entries were downright wrong, like mistagging LFE elements as
SCE, as well as trying to match the native channel ordering in the PCE
by placing CPE elements before SCE ones in some cases (like with FRONT
elements), which is not spec compliant and results in unparseable streams.

Remove the three layouts that define top channels. It's not clear how they
should be signaled in PCE.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-20 10:59:01 -03:00
Diego de Souza
197f854a2e avcodec/nvenc: warn when av1_nvenc qp_cr_offset differs from qp_cb_offset
The NVENC driver currently forces deltaQ_v_ac equal to deltaQ_u_ac for
AV1, so crQPIndexOffset is silently ignored. The SDK header annotates
the field as "for future use only" (nvEncodeAPI.h, NV_ENC_RC_PARAMS).

Reported in #22737

Signed-off-by: Diego de Souza <ddesouza@nvidia.com>
2026-05-19 14:22:13 +00:00
Ramiro Polla
a3d8ba6613 avcodec/webp: add support for Animated WebP decoding
Fixes: 4907

Adds Animated WebP feature according to spec:
https://developers.google.com/speed/webp/docs/riff_container#animation

Original work by Josef Zlomek <josef@pex.com>
and Thilo Borgmann <thilo.borgmann@mail.de>

Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-05-19 11:36:10 +02:00
Ramiro Polla
2ca634f5db avcodec/codec_id: add Animated WebP codec ID and descriptor
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-05-19 11:36:10 +02:00