Commit Graph

124638 Commits

Author SHA1 Message Date
marcos ashton
0bdda94ccc tests/fate/libavutil: add FATE test for csp
Test the five public functions not already covered by
tests/color_utils: av_csp_luma_coeffs_from_avcsp,
av_csp_primaries_desc_from_id, av_csp_primaries_id_from_desc,
av_csp_approximate_trc_gamma, and av_csp_approximate_eotf_gamma.
Iterates every AVCOL_SPC, AVCOL_PRI, and AVCOL_TRC value including
the extended ranges, round-trips primaries via desc_eq so the
canonical first-match (e.g. smpte170m for smpte240m) is accepted,
checks that a garbage desc returns AVCOL_PRI_UNSPECIFIED, and that
out-of-range enum values return NULL or 0.0 as documented. The
trc/eotf gamma values come from static lookup tables so the
floating point output is bitexact across platforms.

Coverage for libavutil/csp.c: 88.50% -> 94.46%
2026-05-25 21:18:34 +00:00
marcos ashton
907b738995 tests/fate/libavutil: add FATE test for ambient_viewing_environment
Test av_ambient_viewing_environment_alloc with and without the size
out-parameter, and av_ambient_viewing_environment_create_side_data.
Verifies the {0, 1} rational defaults set by get_defaults(),
write/read-back of the three AVRational fields, frame side data
attachment, and OOM paths via av_max_alloc.

Coverage for libavutil/ambient_viewing_environment.c: 60.00% -> 100.00%
2026-05-25 21:18:34 +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
Zhao Zhili
78a0309735 avformat/movenc: don't overwrite track_duration on every src_track
When a tmcd or similar metadata track references multiple source
tracks, the per-iteration assignment overwrote track->track_duration
on each loop step, leaving it set to whatever the last source happened
to be.
2026-05-25 02:31:09 +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
Michael Niedermayer
8f1769703c avformat/mxfdec: zero-init Sony MPEG-4 extradata and add padding
Found-by: Calm (AI security-research agent, for John Bradley / Credex)
2026-05-25 01:34:28 +00:00
Michael Niedermayer
d2d79dca9a avformat/soxdec: Check sample_rate for nan
Found-by: iceray-Li
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-25 01:15:28 +00:00
Nicolas Gaullier
b79a7422f5 fftools/ffprobe: print downmix_info frame side data
Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
2026-05-25 00:55:19 +00:00
Nicolas Gaullier
6b401344e8 fftools/textformat: add support for decibel formatting
Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
2026-05-25 00:55:19 +00:00
Nicolas Gaullier
0099a5fbdd fftools/textformat: stop using char * as identifiers
Add an enum instead.
As a result, fix honor -byte_binary_prefix.
In value_string(), add support for float values (beyond seconds),
and allow unit to be null or empty.
Also remove unused variable unit_second_str in ffprobe.

Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
2026-05-25 00:55:19 +00:00
Balling
8cd7465565 tests/tiny_ssim: fixed mistake in ssim_c1 calculation
Reporter uses this code in production.

Signed-off-by: Valerii Zapodovnikov <val.zapod.vz@gmail.com>
2026-05-25 00:35:22 +00:00
Michael Niedermayer
c2047918e6 avformat/hls: Check url_offset and size
Fixes: integer overflow

Found-by: jiale yao
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-25 00:10:18 +00:00
Michael Niedermayer
59094859a8 avformat/hls: Check TIME-OFFSET value
Fixes: UB with out of range values
Fixes: poc_overflow.m3u8

Found-by: jiale yao
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-25 00:10:18 +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
Zhao Zhili
a0def8f915 avformat/movenc: skip the metadata stream itself when populating tref
A tref stream group lists the metadata stream (e.g. tmcd) alongside the
streams it references. The init loop iterated over every stream in the
group and added it to the metadata track's src_track array, which made
the tmcd track reference itself.

Regression since 4444a755.

Signed-off-by: Zhao Zhili <quinkblack@foxmail.com>
2026-05-24 21:14:31 +00:00
Timo Rothenpieler
3baab604db forgejo/workflows: run at least one test out-of-tree 2026-05-24 00:12:16 +02:00
Timo Rothenpieler
0b52ae8aa6 tests/fate/generic-tags: fix out-of-tree testing 2026-05-23 23:16:57 +02:00
Romain Beauxis
2bae6f9d52 avformat/ogg: drop CELT support 2026-05-23 10:16:38 -05:00
RossWang
bce8d61d12 avformat/libsrt: fix ipv6 wildcard listener
For now it fails on srt://[::]:1234?mode=listener

This modification makes it accept a new option "ipv6only"

Reference:
https://github.com/Haivision/srt/pull/2608
https://github.com/Haivision/srt/blob/master/docs/API/API-socket-options.md#SRTO_IPV6ONLY

fix #10539
2026-05-23 10:03:33 -05:00
Tau Gärtli
8d817a1150 libavformat: Add generic disc_subtitle tag mapping for Vorbis
The mapping is taken from Picard's [1] and taglib's [2] documentation.

The official list [3] of standard field names is pretty short and
does not include one for a disc/part subtitle. Some taggers use
SETSUBTITLE here instead. However, I think DISCSUBTITLE is much more
consistent with the already existing DISCNUMBER field and it matches
what Picard and taglib do.

[1]: https://picard-docs.musicbrainz.org/en/appendices/tag_mapping.html#disc-subtitle
[2]: https://taglib.org/api/p_propertymapping.html
[3]: https://xiph.org/vorbis/doc/v-comment.html
2026-05-23 16:09:55 +02:00
Tau Gärtli
504c135f8c libavformat: Add generic disc_subtitle tag mapping for MOV/MP4
The mapping is taken from Picard's [1] and taglib's [2] documentation.

[1]: https://picard-docs.musicbrainz.org/en/appendices/tag_mapping.html#disc-subtitle
[2]: https://taglib.org/api/p_propertymapping.html
2026-05-23 16:07:57 +02:00
Tau Gärtli
752abe97ab libavformat: Add generic disc_subtitle tag mapping for ID3v2
The mapping is taken from Picard's [1] and taglib's [2] documentation.

The `TSST` frame is part of ID3v2.4.0:
> The 'Set subtitle' frame is intended for the subtitle of the part
> of a set this track belongs to.

[1]: https://picard-docs.musicbrainz.org/en/appendices/tag_mapping.html#disc-subtitle
[2]: https://taglib.org/api/p_propertymapping.html
2026-05-23 16:07:50 +02:00
Tau Gärtli
0abe230566 libavformat: Add generic disc_subtitle tag mapping for asf
The mapping is taken from Picard's [1] and taglib's [2] documentation.

The mapping in Microsoft's docs [3] maps `TSST` from ID3 to
`WM/SetSubTitle`. However, some taggers [4] [5] use `WM/SubTitle` instead.
I believe this to be an error, especially since the official docs say otherwise.

[1]: https://picard-docs.musicbrainz.org/en/appendices/tag_mapping.html#disc-subtitle
[2]: https://taglib.org/api/p_propertymapping.html
[3]: https://learn.microsoft.com/en-gb/windows/win32/wmformat/id3-tag-support
[4]: db95540de6/quodlibet/formats/wma.py (L43)
[5]: 989fb5b8f9/src/plugins/taglibmetadata/taglibasfsupport.cpp (L93)
2026-05-23 16:07:39 +02:00
Tau Gärtli
ac4fc01d6f libavformat: Add generic disc_subtitle tag 2026-05-23 16:07:21 +02:00
Tau Gärtli
b64d0c6db6 tests/fate: Add tests for generic metadata tags 2026-05-23 16:07:18 +02:00
Daniil Cherednik
dfd11985e8 Add silence ut 2026-05-23 10:38:28 +00: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
Niklas Haas
aa08cf8112 swscale/options: add missing option value for SWS_STRICT
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-05-23 11:31:54 +02:00
Niklas Haas
03dfac5630 fftools/ffmpeg_sched: allow throttling decoder outputs
This is a departure from the conventional idea of decoders always outputting
data as fast as possible. Instead, this allows decoders to be throttled in the
same way filter graphs can be.

This comes into play when e.g. a demuxer is feeding into two decoders, but
only one of the two decoders is actually currently needed (e.g. due to
A/V misalignment). In that case, what typically happens is that the unneeded
decoder alse decodes all frames, and then piles them up on the "buffersrc"
filter's downstream link (growing indefinitely).

Another issue this solves manifests when e.g. a single demuxer is feeding many
decoders that all try to feed frames to the same filter graph. In this case,
all decoders run as fast as posssible, leading to lock contention on the
filter graph input queue; resulting in (again) many frames piling up on the
buffersrc (or downstream filters) for the unneeded inputs that are not actually
the bottleneck, while the input that's actually undersatisfied can end up
starved for CPU time, possibly for long enough to exhaust memory limits. The
normal rate limiting fails to apply in this scenario because all decoders share
a single demuxer, and are hence rate-limited only by the demuxer speed; whereas
the demuxer is not choked because from the PoV of the scheduler, the filter
graph is simply not getting enough frames.

In a more general sense, there's a philosophical argument to be made here.
Since a decoder is typically also a decompressor, it produces more data than
it consumes. So, it a sense, it's acting like a type of producer also - in
the same way that a filter graph can produce more input that outputs.

Solve all of these issues by allowing decoders to be output-choked, which
gives the scheduler control over when decoders are allowed to output frames.
This does mean we have to add some sort of internal packet queue, because the
decoder thread may need to continue *accepting* upstream packets from the
demuxer (or else we risk stalling the demuxer), but defer the actual decoding
by placing them inside an internal "overflow" queue.

This effectively simulates a sort of "filter graph"-type semantics but
for the decoder queue.

This overflow logic is fairly self-contained inside `sch_dec_receive`, though
it is quite nontrivial. I have added as much documentation as is hopefully
needed to understand the logic.

Importantly, we cannot simply unlimit the decoder input thread queue because
the demuxer relies on backpressure from the decoder to rate limit itself. (Note
that demuxers may only be active if there is at least one downstream decoder
that is alse active, so we always have at least one decoder providing
backpressure)

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-05-23 08:41:12 +00:00
Niklas Haas
2b72d5243c fftools/ffmpeg_sched: drain incoming frames before blocking filters
When a filter is choked, but upstream threads are trying to write to its input,
this can result in the filter's input queue getting stuck. Normally, the
unchoke_downstream() logic would prevent this from happening, since the
filter would itself get unchoked as a result of upstream decoders receiving
pressure from the demuxer.

However, upcoming changes to this logic will require weakening this upstream
unchoking logic, so preventing the deadlock in a more elegant way helps with
making the code more robust.

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-05-23 08:41:12 +00:00
Niklas Haas
95391352b5 fftools/thread_queue: add THREAD_QUEUE_FLAG_NO_BLOCK
Exactly what it says on the tin. There is some ambiguity as to whether this
should also prevent reading from *choked*, as opposed to empty queue, but
I think it makes sense to consider them equivalent, as I struggle to think
of a use case where it would be beneficial to allow draining a queue that
was explicitly choked by the upstream (to e.g. prevent further reads).

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-05-23 08:41:12 +00:00
Niklas Haas
321b0e36a3 fftools/thread_queue: add flags parameter to tq_receive()
I want to use this to allow a non-blocking use of this function.

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-05-23 08:41:12 +00:00
Marton Balint
f48e5d4db4 fftools/ffmpeg_filter: rate control all filter graphs
It was never reliable to detect if a filtergraph have sources, because a filter
can act as a source only after some time, for example the loop filter.

So it is better to remove the source detection entirely and always give the
scheduler an oppurtunity to stop processing.

Fixes ticket #11604.

Signed-off-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-05-23 08:41:12 +00:00
Niklas Haas
6a563dab71 fftools/ffmpeg_sched: allow choosing nodes to unchoke
This level of granularity will help for the upcoming patch.

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-05-23 08:41:12 +00:00
Niklas Haas
04888287b3 fftools/ffmpeg_sched: fix sch_stop() and schedule_update_locked() race
schedule_update_locked() is supposed to be a no-op when `sch->terminate`
is 1. However, there is a TOCTOU error here, where a different thread may
currently be executing schedule_update_locked(), having successfully passed
the sch->terminate check but without actually updating the choke status.

This does not matter for the current code, but will matter with the following
commit, where it creates the theoretical possibility of a race where sch_stop()
is trying to choke the demuxers (and unchoke the decoders) while
schedule_update_locked() is simultaneously trying to choke the decoders,
leading to a deadlock if the last decoder is left choked and unable to
propagate EOF downstream.

The cleanest solution is to just take the scheduler lock while updating the
choke status here. This ensures that any other schedule_update_locked() calls
will have completed.

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-05-23 08:41:12 +00:00
Niklas Haas
0d123a3c23 fftools/ffmpeg_sched: use macros for schedule_update_locked() loops
Instead of awkwardly looping over the type, just split this up into
multiple loops. The loss in complexity seems worth the loss in conciseness
to me, and more importantly, this allows us to easily add more waiter types.

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-05-23 08:41:12 +00:00
Michael Niedermayer
4492ad7228 avformat/ty: check rec_size
Fixes: ada-4-poc.ty

change is based on the suggested fix

Found-by: Claude and Ada Logics. This issue was found by Anthropic from using agents to study security of open source projects
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-23 00:04:46 +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
Zhao Zhili
268c37fdae avformat/iamf_writer: fix stream id log argument
Signed-off-by: Zhao Zhili <quinkblack@foxmail.com>
2026-05-23 02:41:31 +08: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
Lynne
dd0ac641a5 vulkan: properly check if the internally synchronized queue extension is supported
libplacebo enables the extension string but does not enable the extension flag
if it's unsupported.
2026-05-22 23:06:38 +09:00
Dale Curtis
6e0e13b0bf avformat/ogg: Fix overflow and stale oggvorbis_private values
- Prevent integer overflow when summing header lengths; add bounds check.
- Re-initialize priv->vp with the new stream's extradata once all chained
  stream headers are collected.

Signed-off-by: Dale Curtis <dalecurtis@chromium.org>
2026-05-22 13:27:18 +00:00
Romain Beauxis
cd02463dc6 lavf: wire id3v2 fdebug option
Signed-off-by: Romain Beauxis <romain.beauxis@gmail.com>
2026-05-22 08:20:13 -05:00