Commit graph

124773 commits

Author SHA1 Message Date
Michael Niedermayer
cdba2d76dc avcodec/cri: propagate max_pixels to the JPEG tile decoder
Fixes: 489941776/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CRI_fuzzer-4845035614175232
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-03 20:35:41 +00:00
Michael Niedermayer
3669a742dd avcodec/jpeglsdec: only apply color transform to decoded rows
Fixes: Timeout
Fixes: 503996733/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MJPEG_DEC_fuzzer-4948713016721408
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-03 20:34:28 +00:00
David Korczynski
6d8f7882ae avcodec/adpcm: require block_align to be a multiple of channels in ADPCM_PSXC init
The ADPCM_PSXC block loop in adpcm_decode_frame() (libavcodec/adpcm.c:
2770) iterates 'block < avpkt->size / block_align' times and, for
each block, consumes
    channels * (1 + (block_align - 1) / channels)
input bytes via the *unchecked* bytestream2_get_byteu() reader. The
loop divides avpkt->size by block_align, so the loop bound is sound
only when the per-block consumption equals block_align — i.e. when
block_align is an exact multiple of channels. For any other
combination (e.g. block_align=9 with channels=8), each block consumes
more than block_align bytes; iterating avpkt->size/block_align
blocks then walks the input bytestream past avpkt->data +
avpkt->size, producing the heap-buffer-overflow READ at
libavcodec/bytestream.h:99 reported as ANT-2026-04052.

adpcm_decode_init() previously only enforced 'channels > 0' and
'block_align > 0' for PSXC. Tighten the init check to additionally
require 'block_align % channels == 0', which is the precise
invariant the decode loop depends on.

Reproducer: a crafted WAV header declaring channels=8, block_align=9
with the decoder forced via 'ffmpeg -c:a adpcm_psxc -i evil.wav'.

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

Signed-off-by: David Korczynski <david@adalogics.com>
2026-06-03 20:33:19 +00:00
Diego de Souza
6e857f12a7 avfilter/vf_scale_cuda: avoid <stdint.h> in CUDA device compilation
The device-only compilation path of vf_scale_cuda.h pulled in <stdint.h>
solely to obtain uint8_t for the CUdeviceptr typedef. On Windows-on-ARM
(aarch64 mingw) this drags in _mingw.h, whose ARM __prefetch intrinsic is
guarded by !__has_builtin(__prefetch). During clang's --cuda-device-only
pass __has_builtin has deferred/inconsistent semantics on the auxiliary
(host) target, so the guard mis-fires, the inline __prefetch definition is
emitted, and clang rejects it:

    _mingw.h: error: definition of builtin function '__prefetch'

This broke the msys2-clangarm64 FATE slot once ffnvcodec (and thus the
nvcc-compiled CUDA filters) was enabled for aarch64 Windows.

uint8_t is unsigned char, so use that directly and drop the <stdint.h>
include. Device-only code should not depend on the host C runtime headers.
No functional or ABI change.

Signed-off-by: Diego de Souza <ddesouza@nvidia.com>
2026-06-03 19:45:19 +00:00
Tim Walker
34ebcabcf1 avformat/aiffenc: write CHAN chunk after COMM
COMM is where the channel count is indicated
Channel count can be useful when parsing the CHAN chunk
2026-06-03 14:32:19 +00:00
jiale yao
e8031e5b9a avfilter/avf_showcwt: fix out-of-bounds read in du scroll
Fixes: out of array access
Found-by: jiale yao
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-03 12:25:00 +00:00
Zhao Zhili
520968debb avcodec/vc1dsp: always inline vc1_loop_filter
vc1_loop_filter() is only reached through the six C wrappers. Clang 14
keeps it out of line with plain static inline, adding a 224-byte stack
frame before the tiny bestcase path on rpi 5. gcc 12 already inlines
it.

rpi 5 clang 14:
                                before  after
vc1_v_loop_filter4_bestcase_c   27.2     8.3   (3.3x)
vc1_h_loop_filter4_bestcase_c   26.4    10.2   (2.6x)
vc1_v_loop_filter8_bestcase_c   32.5    20.3   (1.6x)
vc1_h_loop_filter8_bestcase_c   31.7    19.5   (1.6x)
vc1_v_loop_filter16_bestcase_c  42.1    33.2   (1.3x)
vc1_h_loop_filter16_bestcase_c  41.6    25.3   (1.6x)

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-06-03 10:41:08 +00:00
Zhao Zhili
200914853d aarch64/sbrdsp: unroll sum64x5 to 16 floats/iter
The C version is faster than the previous asm with clang and gcc > 12 on
rpi5, since compiler basically does the same unroll.

sum64x5_neon:             before          after
  Cortex-A76 (gcc 12.4):  72.3 (3.63x)    47.4 (5.56x)
  Cortex-A76 (gcc 14.2):  72.3 (0.69x)    47.4 (1.05x)
  Apple M1 (clang 16):     0.2 (0.98x)     0.2 (0.99x)

Signed-off-by: Zhao Zhili <quinkblack@foxmail.com>
2026-06-03 10:40:20 +00:00
Zhao Zhili
1e86a92a1c lavu/aarch64: unroll butterflies_float to 8 floats/iter
butterflies_float_neon:   before           after
  Cortex-A76 (gcc 12.4):  163.1 (3.95x)    147.0 (4.37x)
  Apple M1 (clang 16):      0.7 (0.85x)      0.6 (0.99x)

Signed-off-by: Zhao Zhili <quinkblack@foxmail.com>
2026-06-03 09:36:59 +00:00
Zhao Zhili
1f66f9041b lavu/aarch64: split FMLA chain in scalarproduct_float
Unroll to 16 floats per iteration with four independent accumulators
and reduce them once after the loop.

scalarproduct_float_neon:  before          after
  Apple M1 (clang 16):      0.9 (3.56x)    0.4 (9.18x)
  Cortex-A76 (gcc 12.4):  118.7 (4.43x)   85.3 (6.15x)

Signed-off-by: Zhao Zhili <quinkblack@foxmail.com>
2026-06-03 09:36:59 +00:00
Lynne
4d63e3dd4c
vulkan_ffv1: add Bayer encoder
Sponsored-by: Sovereign Tech Fund
2026-06-03 14:12:50 +09:00
Lynne
bade9e6bd0
vulkan_ffv1: detect float remap from pixfmt, not f->flt
The decode-shader picker fell over for integer remapped streams.

Sponsored-by: Sovereign Tech Fund
2026-06-03 14:12:50 +09:00
Lynne
713f191c24
vulkan_ffv1: add Bayer decoder
Sponsored-by: Sovereign Tech Fund
2026-06-03 14:12:50 +09:00
James Almer
151fe3a5ac avcodec/itut35: unref existing buffers before allocating new ones
Finishes fixing memleaks.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-02 23:24:19 -03:00
James Almer
9dd48f7d25 avcodec/itut35: add missing unref calls in ff_itut_t35_unref()
Fixes memleaks.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-02 23:23:32 -03:00
Michael Niedermayer
537e87e3c2 avfilter/f_ebur128: avoid signed-int wrap when sizing per-channel cache
Fixes: integer overflow
Fixes: out of array access

Found-by: Claude (Anthropic), reported by Omkhar Arasaratnam <omkhar@linkedin.com>.
2026-06-03 01:45:08 +00:00
Yong Yu
e1be70dcac swscale/x86/yuv2rgb: fix planar GBRP boundary check in ssse3 assembly
In yuv420_gbrp_ssse3, the boundary safeguard check "h_size * 3 >
    FFABS(dstStride[0])" was erroneously set based on probably packed RGB24
    formats (where each pixel spans 3 bytes per row).

    For GBRP (planar GBR), each plane contains only 1 component per pixel
    per row, meaning dstStride[0] corresponds exactly to width.
    Multiplying h_size by 3 mistakenly triggers the condition for normal
    widths, decreasing h_size by 8. This leaves the rightmost 8 pixels
    of every row completely uninitialized (black).

    Fix this by checking "h_size > FFABS(dstStride[0])" instead.

    How to Reproduce the error:
    1. Generate buggy and fixed outputs as PNGs using the 600x600 pipeline:

       buggy output without the fix
       $ ffmpeg -f lavfi -i color=c=red:size=600x600:rate=1 \
           -vf format=yuv420p,format=gbrp \
           -frames:v 1 -y buggy_red_600.png
       fixed output with the fix
       $ ffmpeg -f lavfi -i color=c=red:size=600x600:rate=1 \
           -vf format=yuv420p,format=gbrp \
           -frames:v 1 -y fixed_red_600.png

    2. Verify buggy_red_600.png in an image viewer:
       A strict, 8-pixel wide vertical black stripe (columns 592 to 599) is
       clearly visible running top-to-bottom down the rightmost edge of the image.

    3. Verify fixed_red_600.png in an image viewer as well:
       The output renders a perfect, uniform, fully solid red square across
       the entire 600x600 canvas, indicating the boundary bug is successfully resolved.
2026-06-02 23:42:01 +00:00
James Almer
361c1079c4 fate/lavf-container: add an ADTS muxing test
This covers writing a ChannelConfig of 0, plus parsing the stream's PCE
bits in a 5.1.2(back) sample.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-02 20:06:21 -03:00
James Almer
a1e4aee2f0 avcodec/aac/aacdec: support height channels signaled with PCE
Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-02 20:06:00 -03:00
James Almer
070bd112be avcodec/h2645_sei: use the ITU-T T35 parsing helpers
Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-02 19:50:39 -03:00
James Almer
cf5284b491 avcodec/itut35: add support for HDR Vivid
Needed by h2645_sei.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-02 19:50:39 -03:00
James Almer
04ae5788df avcodec/itut35: add support for Active Format Description
Needed by h2645_sei.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-02 19:50:39 -03:00
James Almer
f1929d75a2 avcodec/itut35: add support for AOM film graim
Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-02 19:50:39 -03:00
James Almer
c500c786ab avcodec/libaomdec: use the ITU-T T35 parsing helpers
Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-02 19:50:39 -03:00
James Almer
e40dd45f0d avcodec/libdav1d: use the ITU-T T35 parsing helpers
Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-02 19:50:39 -03:00
James Almer
19b3d47007 avcodec/av1dec: use the ITU-T T35 parsing helpers
Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-02 19:50:39 -03:00
James Almer
4fcd2349ff avcodec/itut35: add ITU-T T35 parsing helpers
Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-02 19:50:39 -03:00
Omkhar Arasaratnam
711cdae64f avformat/mov: cap HEIF ICC profile copies via c*max_streams to bound CPU and memory
Found-by: Claude (Anthropic). Human-verified and reported by
Omkhar Arasaratnam <omkhar@linkedin.com>.
Signed-off-by: Omkhar Arasaratnam <omkhar@linkedin.com>
2026-06-02 20:55:14 +00:00
Anton Kesy
344a9ce2da avcodec/qsvenc: add unsupported codec level log
Adds missing log of struct mfxInfoMFX member: codec level.

Signed-off-by: Anton Kesy <anton@kesy.de>
2026-06-02 20:51:32 +00:00
zhanghongyuan
02da2c46d2 fftools/opt_common: print encoder-specific capabilities in print_codec()
Add printing of AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
AV_CODEC_CAP_ENCODER_FLUSH, and AV_CODEC_CAP_ENCODER_RECON_FRAME
capabilities that were defined but not displayed.
2026-06-02 20:39:56 +00:00
Niklas Haas
8a6027a54f swscale/x86/ops_int: fix write_bits over-write
This writes 4 bytes but in SSE4 mode only produces 2 bytes per vector. We
can avoid over-writing by using the appropriately sized register.

Reproducible by:
  make libswscale/tests/swscale
  libswscale/tests/swscale -dst monob -unscaled 1 -flags unstable -align_src 1 -align_dst 1

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-02 15:37:54 +02:00
Niklas Haas
8f38703323 swscale/ops_dispatch: calculate correct slice line count for tail copy
These loops were both assuming that `h` lines need to be copied; but this
varies. First of all, for plane subsampling; but more importantly, when
vertically scaling, the input line count may be substantially lower than the
actual line count.

This fixes an out-of-bounds read/write when vertically upscaling with a tail
buffer.

Verifiable via e.g.:
  make libswscale/tests/swscale
  valgrind -- libswscale/tests/swscale -s 63x63 -src yuv444p -dst rgb24 \
              -flags unstable -align_src 1 -align_dst 1

(As well as the SSIM scores, which drop from ~e-5 to ~e-3 without this fix)

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-02 15:36:42 +02:00
Niklas Haas
a00db63da7 swscale/tests/swscale: add option to force specific buffer alignment
Useful to make sure the memcpy_in/out paths work as expected.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-02 15:35:00 +02:00
Niklas Haas
bb5c461a47 avfilter/vf_libplacebo: setup pl_vulkan_queue.flags on import params
libplacebo versions before v365 passed .flags = 0 when retrieving the queues
from imported Vulkan devices, so we have to error out in the case of a mismatch
to avoid undefined behavior (Vulkan spec).

See-Also: https://code.videolan.org/videolan/libplacebo/-/merge_requests/856
Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-02 13:32:44 +02:00
Niklas Haas
9b9d29e09a avfilter/vf_libplacebo: don't unnecessarily set fields to 0 (cosmetic)
Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-02 13:32:44 +02:00
Niklas Haas
9fe5758da5 avutil/hwcontext_vulkan: publicly expose queue device creation flags
These are needed for interop with e.g. libplacebo, which needs to know the
correct flags to call vkGetDeviceQueue2.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-02 13:32:43 +02:00
Romain Beauxis
80375ca773 avformat/mpegts: update stream metadata from timed_id3 packets
Set AVSTREAM_EVENT_FLAG_METADATA_UPDATED so applications can detect
mid-stream metadata changes without inspecting packet side data.
2026-06-01 21:53:36 -05:00
Romain Beauxis
f6838b8636 tests/fate/demux.mak: add FATE test for timed ID3 packet demuxing in HLS
streams.
2026-06-01 21:53:36 -05:00
Michael Niedermayer
69c9f1158c avcodec/aac/aacdec_usac: avoid signed overflow in decode_tsd
decode_tsd() computes the binomial coefficient c = C(k, p) incrementally.
this commit makes it less overflow prone

Fixes: 515703905/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AAC_DEC_fuzzer-4890954254581760
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-02 00:59:38 +00:00
Michael Niedermayer
e711e60827 avcodec/aac/aacdec: reject decoded frame without a valid sample rate
Later code will turn this into AVERROR_BUG

When returning sample_rate == 0 samples is considered a bug, we have no
nice choice but to error out cleanly

Fixes: assertion failure
Fixes: ffmpeg_AV_CODEC_ID_AAC_DEC_fuzzer crash-0a86d46fef2442b222ee34403c21f7f582ffccb0
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-02 00:59:38 +00:00
Michael Niedermayer
620e59bbec avcodec/aac/aacdec: More detailed warning about sample rates
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-02 00:59:38 +00:00
Michael Niedermayer
263374ac7d avcodec/aac/aacdec_usac: reject explicit usacSamplingFrequency of 0
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-02 00:59:38 +00:00
Jun Zhao
d092269996 lavfi/vf_drawtext: log inferred shaping properties at verbose
Log the script and direction picked by HarfBuzz, plus codepoint and
glyph counts, so the shaper choice can be verified. Differing
codepoint and glyph counts indicate reordering / ligation /
decomposition.

Codepoints are sampled before hb_shape(), which flips the buffer
content type to GLYPHS.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-06-02 00:52:03 +00:00
Jun Zhao
1f9888beb0 lavfi/vf_drawtext: fix HarfBuzz shaping of Bengali / Indic scripts
shape_text_hb() set HB_SCRIPT_LATIN and called
hb_buffer_guess_segment_properties() on an empty buffer, so the
inference was a no-op. Bengali and other Indic / USE scripts reached
the default OT shaper instead of their script-specific shaper,
leaving the virama visible and consonants disjointed (e.g. স্টারমার
rendered as স্ টারমার).

Add the UTF-8 text first, keep the existing LTR direction used by the
FriBidi visual-order pipeline, then guess segment properties so the
script comes from the actual Unicode contents.

Fixes: https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/23014
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-06-02 00:52:03 +00:00
Michael Niedermayer
43f712d917 avformat/iff: check av_get_packet() result in ANIM branch
Fixes: 494958338/clusterfuzz-testcase-minimized-ffmpeg_dem_IFF_fuzzer-6265824670449664
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-01 22:56:47 +00:00
Diego de Souza
93f653f95c configure: enable ffnvcodec, nvenc, nvdec for aarch64 Windows
Adding support to build FFmpeg with HW accelerated decode (nvdec) and
encode (nvenc) on aarch64 Windows, covering both the MinGW (mingw32/
mingw64) and MSVC (win32/win64) toolchains. The dynamically-loaded
NVIDIA codec headers and the CUDA loader are architecture-agnostic, so
the only gate was the target_os check in the aarch64/ppc64 branch.

Signed-off-by: Diego de Souza <ddesouza@nvidia.com>
2026-06-01 17:00:46 +00:00
Romain Beauxis
dba111c34d .forgejo: add pull request template with fate-samples section 2026-06-01 10:40:57 -05:00
Romain Beauxis
78fff004f0 .forgejo: add support for ephemeral FATE samples via PR attachments
Developers can attach sample files to a PR and list their target paths
within the fate-suite in a fate-samples block in the PR description:

  ```fate-samples
  vorbis/tos.ogg
  mov/some-new-sample.mov
  ```

A new inject-pr-samples.py script fetches the PR metadata from the
Forgejo API, resolves each listed path to its matching attachment by
filename, and downloads the files into the fate-suite directory before
FATE runs.

The script validates that pr-number is an integer, that paths are
relative, contain no '..', and are at most 3 components deep (matching
the deepest paths in the existing fate-suite).  Attachment URLs are
restricted to the code.ffmpeg.org domain.

The script exports a new_samples=true/false output via $FORGEJO_OUTPUT.
After FATE completes, a final workflow step fails the run if any new
sample was injected, reminding contributors to add their samples to the
official fate-suite before the PR can be merged.

The script can also be used locally:
  SAMPLES=/path/to/fate-suite .forgejo/inject-pr-samples.py <pr-number>
2026-06-01 10:40:57 -05:00
Zhao Zhili
6f1de91492 fftools/ffmpeg_filter: free input filter channel layout
Fixes the LeakSanitizer failure in fate-dca-xll-coded. It was exposed
by c65c8f1f49.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-06-01 14:31:21 +00:00
James Almer
95fe0658d7 avformat/mov: don't abort on unsupported or invalid chnl boxes
They are optional and just define a channel layout, which may also be defined
by the underlying codec.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-01 09:53:54 -03:00