126007 Commits
Author SHA1 Message Date
Andreas Rheinhardt a0e01bcee1 tests/checkasm/sbcdsp: Zero-init SBCDSPContext
ff_sbcdsp_init() checks SBCDSPContext.increment to set
sbc_analyze_8s (which is not tested), leading to Valgrind
errors.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-08-09 16:31:09 +02:00
Andreas Rheinhardt 4a2c02a993 tests/checkasm/crc: Avoid static variables
This is possible because the state of the PRNG at the beginning
of every test function is the same for every cpu flag (since
the switch to libcheckasm). It also has the advantage that
random sizes are checked when using --repeat.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-08-09 16:30:34 +02:00
Andreas Rheinhardt c4a74c53c3 tests/checkasm/crc: Free allocations
The CRC test uses a linked list of containing the CRC tables
of already tested instruction sets; the head of the list
is in static storage and up until now was never freed
(i.e. reported as "still reachable" by Valgrind).
Free it properly by adding an uninit callback.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-08-09 16:29:56 +02:00
Andreas Rheinhardt 289595a834 tests/checkasm/av_tx: Fix segfault when using --repeat
The TX tests require a context that is initialized
for a specific set of CPU flags. So in order to have
a context for the reference function to use, the last
context is stored (in static storage). This works well
in normal usage, but it does not work with the --repeat
feature that has been added to checkasm by the switch
to libcheckasm: When the C functions ought to be tested
a second time, there is a mismatch between the new
function pointer (which is the C version) and the reference
context (which is initialized to optimized CPU flags;
up until now, there was no stored context when testing
the C versions, but there is with --repeat), leading to segfaults.

Fix this by adding an uninit callback for the TX test,
replacing the atexit handler.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-08-09 16:28:28 +02:00
Andreas Rheinhardt b59a4375ac checkasm: Update from upstream
This update is done because of the newly added init and uninit
callbacks which will be used to fix a segfault when repeating
the tx test; it also improves both the quality and performance
of the PRNG.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-08-09 16:24:45 +02:00
Andreas Rheinhardt 5d53a3f9cd Squashed 'tests/checkasm/ext/' changes from e13b0bb3ff..e822e429f3
e822e429f3 utils: Silence an MSVC warning about conversion from double to float
abf8fb0261 utils: Add checkasm_randomize_interval() and float equivalent
7aea236f8f utils: Simplify checkasm_randomize_range() formulation
49972c1c72 utils: Fix advertised value range of checkasm_randf()
11c569cbdc utils: Use appropriate PRNG size for checkasm_init()
6fd9bafd11 utils: Add way more PRNG helper functions
d7f10858c8 utils: Use prng() primitive for checkasm_randomize()
781f16f1ac utils: Parallelize PRNG
4681280b65 selftest: Add tests for utils.h functions
02d0b1ee4c Clear CPU state after any checkasm_call()
48821c5d14 Print cpu mask in JSON output
5d500889dc tests/selftest: Test CPU flag masking
dbf5380202 tests: Offset arch-specific CPU flags by 10
09b4c6a8c9 include/checkasm.h: Add CheckasmCpuInfo.mask
dd1ca4ed09 utils: Document PRNG re-seeding at the start of each test
c93961a221 utils: Use substantially more robust PRNG
e46c473f73 Re-order conditional (mostly cosmetic)
16738f028d Seed PRNG before running CheckasmTest.init()
9292f9cf6d Bikeshed summary line a bit more, especially for interrupted runs
0f03612ec9 Suppress non-failure output after first iteration
bfdb230dd9 checkasm: Print statusline to track current test/bench progress
c8996a284b checkasm: Move test iteration variable to global state
46e136ee0e utils: Add self-repainting statusline buffer
800053edca Route all log messages through checkasm_fprintf()
f6791fee59 utils: Redefine checkasm_fprintf() as checkasm_vfprintf()
629a211feb Add optional CheckasmTest.init() and uninit()
354f3d3e8d riscv/callcheck: Avoid out-of-range li immediate under LLVM on rv32
6e1b4cd6ca riscv/cpu: Include <asm/unistd.h> for __NR_riscv_hwprobe
8130043b32 Fix CPU detection for AVX512F
9760810b49 Support YMM copy tests on processors with only AVX
dc8c320313 Support XMM copy tests on processors with only SSE

git-subtree-dir: tests/checkasm/ext
git-subtree-split: e822e429f33e4d02e0815bd497952b3f6deb0a7d
2026-08-09 16:24:45 +02:00
Raja-89 1e0279143d doc/filters: document async, nireq, and batch_size options for dnn_processing
Add documentation for three previously undocumented common DNN options:
- async: toggle async inference (default enabled)
- nireq: number of concurrent inference requests
- batch_size: frames per inference request

Also add usage examples for the Libtorch backend showing basic
CPU inference and batch inference pipelines.

Signed-off-by: Raja Rathour <rajarathour1829@gmail.com>
2026-08-09 02:13:24 +00:00
Raja-89 09bf8dab5b avfilter/dnn: implement zero-copy CUDA tensor mapping for Torch backend
When a CUDA frame with a supported RGB sw_format is received, map the
GPU device pointer directly into a LibTorch tensor using
torch::from_blob() with CUDA device options, bypassing cudaMemcpy
entirely.

Changes:

 - Add fill_model_input_cuda() that extracts the CUdeviceptr from the
   AVHWFramesContext and wraps it in a PyTorch GPU tensor with a no-op
   deleter (memory owned by FFmpeg AVBuffer ref-counting).
 - Handle GPU memory alignment padding via custom strides derived from
   AVFrame linesize.
 - Permute the mapped NHWC tensor to NCHW (PyTorch convention).
 - Manage CUDA context explicitly with cuCtxPushCurrent/cuCtxPopCurrent
   for thread safety in async filter graphs.
 - Implement zero-copy Device-to-Device output mapping that writes the
   model result directly into the output frame's VRAM, bypassing
   ff_proc_from_dnn_to_frame / sws_scale entirely for CUDA frames.
 - Add torch::cuda::synchronize() to prevent async race conditions
   with downstream encoders (e.g. NVENC reading uninitialized frames).
 - Add format validation in ff_dnn_zero_copy_supported_cuda() to reject
   unsupported sw_formats and batching with CUDA zero-copy early.
 - Register AV_PIX_FMT_CUDA in vf_dnn_processing pixel format list.
 - Gracefully fall back to CPU path when sw_format is not a supported
   RGB variant or when CONFIG_CUDA is not enabled.

Signed-off-by: Raja-89 <imraja729@gmail.com>
2026-08-09 02:13:24 +00:00
Kacper Michajłow 2a20737f66 Revert "lavfi/bwdif: fix heap-buffer-overflow with small height videos"
This reverts commit 795bccdaf5.

The heap-buffer-overflow was a symptom of the >8 bit boundary
conditions bug fixed in the previous commit. This workaround is no
longer needed.

This restores spatial-only interpolation of the whole frame for the
first and last fields, instead of running the temporal edge filter
against cloned reference frames on the outermost lines. Because of that
first frame references are updated to pre-fix values.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-08-08 21:46:08 +00:00
Kacper Michajłow 5e6d663c94 avfilter/vf_bwdif: fix line boundary checks for >8 bits content
The mrefs/prefs boundary conditions scaled the y limits by the number of
bytes per sample, even though the ref offsets are already expressed in
elements. For content deeper than 8 bits this clamped perfectly valid
in-bounds line taps.

Found by validating the libplacebo GPU port against this filter, which
matches exactly on 16-bit content everywhere except these lines.

This changes the output for >8 bit content on the affected lines.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-08-08 21:46:08 +00:00
Jeongkeun Kim 280fd60916 avcodec/aarch64: add NEON lfe_x96_fixed for DCA DSP
Implement the fixed-point LFE x96 interpolation filter in AArch64
NEON. Four input samples are processed per iteration. The history
sample is kept in a vector lane, and ext constructs the delayed input.

Benchmarks by Martin Storsjö using checkasm:
               a53     a55    a520     a72     a76    a720
              1.86x   1.88x   1.24x   1.99x   1.62x   2.30x

Author's measurement on Neoverse-N1 (Oracle Cloud, clang 14): 1.29x.

Signed-off-by: Jeongkeun Kim <variety0724@gmail.com>
2026-08-09 00:18:08 +03:00
Jeongkeun Kim d920566afe tests/checkasm/dcadsp: add test for lfe_x96_fixed 2026-08-09 00:18:08 +03:00
Andreas Rheinhardt f944afd040 avutil/opt: Use correct enum size
AV_OPT_TYPE_PIXEL_FMT and AV_OPT_TYPE_SAMPLE_FMT are documented
to use the corresponding enum type. This matters when using
-fshort-enums.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-08-08 02:33:43 +02:00
Romain Beauxis 23fccd657c avformat/mp3enc: keep trailing padding spanning several packets
The trailing padding is read from the AV_PKT_DATA_SKIP_SAMPLES side data of
every packet, overwriting the previous value, so only the last packet was
ever accounted for. A single packet holds at most one frame, which caps the
padding that can be written at 1152 + 528 + 1 samples.

LAME regularly reports more than that: gapless/gapless.mp3 carries 1984 and
comes out of a stream copy with 1681, decoding to 303 samples more than the
file it was copied from.

Accumulate instead, and add the decoder delay once the total is known.

Fixes: https://trac.ffmpeg.org/ticket/9755
2026-08-07 21:18:03 +00:00
softworkz 63d0237033 avutil/hwcontext_vulkan: Query export support with the real image flags
Query with the flags the images are actually created with. The
DRM-modifier path is unchanged.

Signed-off-by: softworkz <softworkz@hotmail.com>
2026-08-07 19:51:37 +02:00
Gabriel Balaich a81b23a85a avdevice/avfoundation: fix build with deployment targets below macOS 12
c2802e520a selected kIOMainPortDefault whenever the SDK is new enough
(__MAC_OS_X_VERSION_MAX_ALLOWED), but that symbol is only available
since macOS 12, so building with a newer SDK against an older
deployment target failed with -Wunguarded-availability-new.

Check the deployment target (__MAC_OS_X_VERSION_MIN_REQUIRED) instead
and keep using the equivalent kIOMasterPortDefault when targeting
older releases.

See: https://lists.ffmpeg.org/archives/list/ffmpeg-devel@ffmpeg.org/thread/S7PGVSGNLIZ2WRYV6VOBAD3RWYUNWA3H/
Reported-by: Helmut K. C. Tessarek <tessarek@evermeet.cx>
Signed-off-by: Gabriel Balaich <ffmpeg@ninbura.com>
2026-08-07 13:55:36 +00:00
Ayoub Nabil Boubagrat 5c395992f9 swresample/rematrix: handle top-back channels
top-back channels are currently left unaccounted and can be dropped during downmixing.

when the output retains top-front channels, follow IAMF 1.1.0 and fold top-back into top-front at 0.707. prefer this path over ear-level rear channels to preserve the height layer in x.1.4 to x.1.2 downmixes.

when no matching height output remains, map top-back to back or side channels, then fall back to front or mono outputs. handle top-back center separately and add direct tests for every matrix path.

Signed-off-by: Ayoub Nabil Boubagrat <237098474+ayoubnabil@users.noreply.github.com>
2026-08-07 02:33:33 +00:00
Ayoub Nabil Boubagrat c717827955 swresample/rematrix: use unity gain for top-front downmix
ITU-R BS.2127-1 maps U+030 and U-030 to the matching ear-level front channels at unity gain.

the current matrix uses 0.707 when the input also contains front channels. use 1.0 instead.

Signed-off-by: Ayoub Nabil Boubagrat <237098474+ayoubnabil@users.noreply.github.com>
2026-08-07 02:33:33 +00:00
Zuxy Meng 06deae14bf avcodec/x86/h264_intrapred_10bit: Replace MMX with SSE2
Replace MMX implementation of pred4x4_dc_10 and pred4x4_horizontal_up_10
with SSE2.

  pred4x4_dc_10_c:                          9.7
  pred4x4_dc_10_mmxext:                     3.7 ( 2.63x)
  pred4x4_dc_10_sse2:                       3.6 ( 2.71x)

  pred4x4_horizontal_up_10_c:              13.7
  pred4x4_horizontal_up_10_mmxext:          5.5 ( 2.52x)
  pred4x4_horizontal_up_10_sse2:            4.6 ( 2.96x)

Signed-off-by: Zuxy Meng <zuxy.meng@gmail.com>
2026-08-06 19:01:29 -07:00
Andreas Rheinhardt fda0cb5cf8 avfilter/x86/vf_atadenoise: Test earlier
ptest has quite a bit of latency, so it should be scheduled earlier.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-08-06 19:59:16 +00:00
Andreas Rheinhardt 5ccfaa872a avfilter/x86/vf_atadenoise: Avoid shifting unnecessarily
For a word mask register (where all the values are either
0x0 or 0xFFFF) a right logical shift by 15 is equivalent
to negating, so instead of negating the mask and then adding
it to another register one can simply subtract the mask from
the other register.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-08-06 19:59:16 +00:00
Andreas Rheinhardt 698f0d22bf avfilter/x86/vf_atadenoise: Avoid negating mask
Possible by using pandn.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-08-06 19:59:16 +00:00
Andreas Rheinhardt bab7f937a6 avfilter/x86/vf_atadenoise: Combine stores
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-08-06 19:59:16 +00:00
Andreas Rheinhardt e4f2d7595b avfilter/x86/vf_atadenoise: Don't load too much data
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-08-06 19:59:16 +00:00
Andreas Rheinhardt fb15c5dd4f avfilter/x86/vf_atadenoise: Reduce number of registers used
Saves a push+pop on Win64 and some REX prefixes everywhere.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-08-06 19:59:16 +00:00
Andreas Rheinhardt 91188e6ae0 avfilter/x86/vf_pullup: Avoid addition
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-08-06 19:58:49 +00:00
Nicolas Gaullier 73aa056f49 avcodec/dolby_e: Add error recovery when parse_mantissas run out of bits
Mantissas are the last data in the channel subsegment and it appears it
is sometimes missing a very few bits for the parsing to complete.
This must not be confused with data corruption.
In standard conditions with certified products, it has been observed
that the occurence of this issue is pretty steady and about once every 2
hours. The truncation is at about 950 out of the 1024 values (923 is the
minimum I have seen so far).
The current code raises a severe 'Read past end' error and all data is
lost resulting in 20ms(@25fps) of silence for the affected channel.
This patch introduces a tolerance: if 800 out of the 1024 mantissas have
been parsed, a simple warning is raised and the data is preserved.

Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
2026-08-06 15:19:52 +00:00
James Almer a72b9465cd configure: make _WIN32_WINNT == 0x0601 the minimum supported version
Every hardware accel implementation and now Vulkan require API present
stating with Windows 7, so it's about time we stop pretending to support
Vista.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-08-06 13:52:46 +00:00
Andreas Rheinhardt 95c43d7df7 avcodec/fmtconvert: Remove int32_to_float_fmul_array8
Unused since aebf07075f.

Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-08-06 11:26:35 +02:00
Ayoub Nabil fc02470c62 avfilter/f_ebur128: fix top-back channel weighting
ITU-R BS.1770 assigns a weight of 1.0 to height channels, but the
filter included the top-back channels in the 1.41 surround mask.

remove the top-back channels from that mask and add a FATE test for
the resulting loudness measurement.

fixes #23968.

Signed-off-by: Ayoub Nabil <237098474+ayoubnabil@users.noreply.github.com>
2026-08-06 00:30:00 +00:00
Lynne 85c857a7c3 compat/w32pthreads: add pthread_mutex_trylock 2026-08-05 22:28:51 +00:00
iSold Leo f9ed016d42 fate/filter-audio: add test for pan named input channel id rejection
"pan=stereo|FL=UNK" resolves to AVChannel id 768, which was used as an
index into a 64 element array before the previous commit.

UNK is used because it was the only one of the three reachable high ids
that exited with 0 before the fix; AMBI (1024) aborted and UNSD (512)
failed with an unrelated message, so a test that only checked for a
non-zero exit status would have passed before the fix as well.

For the same reason the test greps the error message on stderr instead of
only looking at the exit status: a crash also exits non-zero.

Signed-off-by: iSold Leo <s@qwqlog.com>
2026-08-05 19:37:11 +00:00
iSold Leo f02c4372ed avfilter/af_pan: check the id of named input channels before use
parse_channel_name() only rejects negative values on the named channel
path, while the numbered "c%d" path also checks against MAX_CHANNELS.
av_channel_from_string() accepts UNSD (512), UNK (768) and AMBI (1024),
and the id was then used directly to index used_in_ch[MAX_CHANNELS] on
the stack and pan->gain[out_ch_id][in_ch_id].

Before this change:

  ffmpeg -f lavfi -i "anullsrc=cl=stereo" -af "pan=stereo|FL=AMBI" -f null -
  af_pan.c:214:17: runtime error: index 1024 out of bounds for type 'int[64]'

The first out of bounds access is the read at the "reference twice"
check, so the symptom depends on what happens to be on the stack:
FL=UNK is silently accepted and produces silence, FL=UNSD reports
"Can not reference in channel 512 twice", and FL=AMBI aborts.

The check has to be at the caller and not in parse_channel_name(), which
is shared with the out channel path: there the named id is converted by
av_channel_layout_index_from_channel() into a layout index, so high ids
are legitimately supported and "pan=AMBI|AMBI=FL" works.

AVERROR_PATCHWELCOME is used because these are valid AVChannel values
that af_pan cannot represent: for named input channels the gain matrix is
indexed by the raw id, and the renumbering loop in config_props() is
bounded by MAX_CHANNELS as well, so such a mapping never worked.

The in_ch_id < 0 half is currently unreachable and only kept for symmetry
with the out channel check above.

Regression since 1f96db959c, which dropped
the "channel_id >= MAX_CHANNELS" part of the check when converting to the
new channel layout API.

Reported-by: karnakarreddi
Fixes: #22963
Signed-off-by: iSold Leo <s@qwqlog.com>
2026-08-05 19:37:11 +00:00
iSold Leo ec2a4105e2 swscale: avoid overflow in fast bilinear edge handling
The final edge clamp computes the source position using int
multiplication before shifting. With sufficiently wide inputs this
overflows, which may suppress the clamp and leave the last output
pixels interpolated with the padding byte.

Promote the multiplication to int64_t in the C, MMXEXT and VSX
implementations.

Add a regression test covering the rightmost pixel of a wide upscale,
which is wrong before this change on both the C and the MMXEXT path.

Fixes: signed integer overflow: 15 * 255918080 cannot be represented in type 'int'
Fixes: #21591
Signed-off-by: iSold Leo <s@qwqlog.com>
2026-08-05 19:34:30 +00:00
Guo Yejun e13b2e00e8 avfilter/dnn: fix object detection of openvino backend
update ctx->ov_option.layout to the explict value which will be
used in function init_model_ov.

also move the code before input_resizable which uses the layout
2026-08-05 21:11:34 +08:00
Kacper Michajłow 8f80421b2d swscale/aarch64/ops_static: fix av_assert0 on NDEBUG builds
av_assert0 suppose to run always.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-08-05 13:06:18 +00:00
Zhao Zhili f1dbe5252b avcodec/aarch64: rewrite lfe_fir1 to remove faddp reduction
The original implementation was a regression on Cortex-X925 (0.88x).

               X925 clang    X925 gcc      A725 clang   A725 gcc     A510 clang
c:              891          1638          792          1475         8084
neon_original: 1015 (0.88x)  1016 (1.61x)  747 (1.06x)  747 (1.97x)  6126 (1.31x)
neon_new:       696 (1.28x)   696 (2.35x)  623 (1.27x)  623 (2.37x)  3697 (2.18x)

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-08-05 11:49:17 +00:00
Steve Lhomme 87f17b68a8 swscale/x86: use HOSTCPPFLAGS instead of CPPFLAGS for native code
Similar to 976e18fdef.
2026-08-05 11:06:22 +00:00
Lynne d295add222 vulkan: fix typo when printing the SPIR-V/binary size 2026-08-05 16:04:38 +09:00
Lynne 9287eb62b5 vulkan_ffv1: fall back to host memory for the fltmap buffer
A megabyte per slice, systems without resizable BAR can run out of
mappable device memory to place it in.
2026-08-05 16:04:38 +09:00
Lynne 709a72c374 vulkan_decode: prefer device-local memory for the bitstream buffer
Fixes #23865
2026-08-05 16:04:37 +09:00
Lynne eed19eefda vulkan: use only coherency to flush mapped memory when needed
Host map'd bufs skipped flushes unconditionally, always forcing the coherent flag
regardless of the memory type actually chosen for the import.
All known implementations import host memory as coherent, in which case nothing changes.
2026-08-05 16:04:37 +09:00
Lynne 9548d68e5b vulkan: remove ff_vk_exec_add_dep_buf 2026-08-05 16:04:37 +09:00
Lynne 73cc45ef0d vulkan_decode: manage session parameters with AVRefStruct
Ditto.
2026-08-05 16:04:37 +09:00
Lynne 56d60b5419 proresenc_kostya_vulkan: gather slices on the GPU
Same as with APV, and FFv1.
1080p on RADV goes from 34 to 48 fps, 4K goes from 20 to 31 fps.
2026-08-05 16:04:37 +09:00
Lynne 4e14153676 vulkan: manage image views with AVRefStruct
The biggest gain is no longer needing to spin on the CPU on a semaphore
waiting for the image to become freeable. This was awful.
2026-08-05 16:04:37 +09:00
Lynne 318e2e3943 vulkan: manage buffer pools and host mappings with AVRefStruct
This converts all buffers/buffer pools into refstructs/refstruct pools,
saving allocs and making them easier to work with.
2026-08-05 16:04:37 +09:00
Lynne d4bc34a070 vulkan: track semaphores/views directly as deps
There's no need for them to live in bufferrefs.
2026-08-05 16:04:36 +09:00
Lynne 24170896fa vulkan: allow tracking AVRefStruct objects as execution dependencies
RefStructs > BufferRefs. We're converting everything.
2026-08-05 16:04:36 +09:00
Lynne 7c5dddc2bb vulkan: release dependencies of completed execution contexts eagerly
Dependencies were only released when a context was about to be reused, so
all buffers and deps got held up and piled up in the queue.

Release them as soon as they're done instead. Cuts RAM usage down by a ton.
2026-08-05 16:04:36 +09:00