126031 Commits
Author SHA1 Message Date
James Almer 0f7eec026c avcodec/cbs_lcevc: don't return an error if a Process Block is missing padding bits
Samples made following the current (for now) faulty specification may not
include alignment bits at the end of VUI parameters, so instead of erroring
out, warn about it and keep going.
In a writing scenario, like the lcevc_metadata bsf, the output bitstream will
be written with them.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-08-09 15:01:31 -03:00
qaq03101 9c176644aa avformat/scd: reject zero-channel tracks
A zero channel count can cause a division by zero in
scd_read_packet().

Reported-by: sdjasj
Fixes #23181.
Signed-off-by: qaq03101 <1440810736@qq.com>
2026-08-09 17:24:59 +00:00
James Almer afd6b8451f libswresample/tests/rematrix: rewrite into a matrix printing tool
Signed-off-by: James Almer <jamrial@gmail.com>
2026-08-09 13:55:37 -03:00
James Almer 77998c0dec swresample/rematrix: handle missing channels from 22.2 layout
Signed-off-by: James Almer <jamrial@gmail.com>
2026-08-09 13:55:37 -03:00
Andreas Rheinhardt 353deaf31e avcodec/h264qpel_template: Use ptrdiff_t for stride
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-08-09 17:30:52 +02:00
Andreas Rheinhardt 7289b00894 avcodec/dirac_dwt: Use ptrdiff_t for stride
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-08-09 17:29:55 +02:00
Andreas Rheinhardt 7d448c9709 avcodec/qpeldsp, qpel_template: Use ptrdiff_t for stride
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-08-09 17:29:30 +02:00
Andreas Rheinhardt 7637009f02 avcodec/x86/diracdsp_init: Avoid cast
put_signed_rect_clamped uses different types for differnt
8bit and >8bit content. The 8bit SSE2 function used the real
type in its function signature; this does not coincide with
the array of function pointers it gets put into and therefore
also not with how it is called which is UB. Also, casts of
function pointers to void* like it is done here are not
legal ISO-C as function pointers and object pointers need not
be convertible.

So just declare the function to have the required type for
the function pointer array.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-08-09 17:28:59 +02:00
Andreas Rheinhardt 251b43db69 avcodec/x86/diracdsp: Avoid push+pop of xmm register
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-08-09 17:28:25 +02:00
Andreas Rheinhardt 51c7563824 avcodec/x86/diracdsp_init: Name function parameters
Also fix the comment of the same function in assembly.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-08-09 17:28:05 +02:00
Andreas Rheinhardt a9cf647664 avcodec/x86/diracdsp: Avoid useless macros, init cpuflags properly
{ADD,PUT}_RECT was only used once since the removal of
mmx functions in d29a9c2aa6.
Furthermore, several of the INIT_XMM calls lacked the
actual cpuflags. Therefore the cpu flag suffix has been
manually added to the function names; furthermore, cpuflags()
as well as the check for supported instructions wouldn't work.
So add the cpu flags to INIT_XMM.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-08-09 17:27:43 +02:00
Andreas Rheinhardt 0654b34370 avcodec/x86/diracdsp: Fix clipping
packusdw saturates to uint16_t, yet CLIPW is designed for signed values.
If any of the saturated unsigned values were >= 2^16*, the macro would
return 0. Anyway, given that packusdw already saturates below,
clipping from both sides again is simply wasteful.

*: I don't know whether this can happen at all.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-08-09 17:26:55 +02:00
Andreas Rheinhardt af87713f8a avcodec/diracdec: Fix shadowing
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-08-09 17:26:53 +02:00
Andreas Rheinhardt fc866eaab3 avcodec/diracdsp: Use ptrdiff_t for stride
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-08-09 17:26:51 +02:00
Andreas Rheinhardt 7635b501b8 avcodec/x86/diracdsp: Properly sign-extend strides
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-08-09 17:26:48 +02:00
Andreas Rheinhardt 1f276a42db avcodec/tta{,enc}dsp: Avoid stack
Pass the input value by value and return the output value
as return value and not by passing the input value by reference.
This improves decoding speed by 2% here.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-08-09 17:25:23 +02:00
Andreas Rheinhardt ee83c175f8 avcodec/x86/ttadsp: Optimize updating dl[4..7]
ttaencdsp old:
  filter_process_c:         15.0
  filter_process_ssse3:      9.0 ( 1.66x)
  filter_process_sse4:       6.9 ( 2.18x)

ttaencdsp new:
  filter_process_c:         14.9
  filter_process_ssse3:      8.3 ( 1.79x)
  filter_process_sse4:       6.4 ( 2.32x)

ttadsp old:
  filter_process_c:         14.7
  filter_process_ssse3:      8.7 ( 1.70x)
  filter_process_sse4:       6.6 ( 2.24x)

ttadsp new:
  filter_process_c:         14.6
  filter_process_ssse3:      8.1 ( 1.81x)
  filter_process_sse4:       6.3 ( 2.30x)

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-08-09 17:23:06 +02:00
Andreas Rheinhardt a8d3ae2a71 avcodec/x86/ttadsp: Reduce number of registers used
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-08-09 17:23:00 +02:00
Andreas Rheinhardt d7ce8c30e0 tests/checkasm/ttadsp: Also test ttaencdsp
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-08-09 17:22:57 +02:00
Andreas Rheinhardt de1bc8ea1d avcodec/ttaencdsp: Use unsigned to avoid UB
The decoder has been made to use unsigned values after
the fuzzer encountered signed integer overflow;
the same can probably happen in the encoder (I don't know),
but it definitely can happen in the checkasm test that
will be added soon. So use unsigned here, too.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-08-09 17:22:53 +02:00
Andreas Rheinhardt 7a906e31d9 avcodec/x86/ttaencdsp: Merge into ttadsp
This allows to avoid duplication of (source) code and constants.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-08-09 17:22:47 +02:00
Andreas Rheinhardt 4d151c37e0 avcodec/ttadata: Explicitly specify alignment
x86 assembly relies on it.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-08-09 17:22:44 +02:00
Andreas Rheinhardt 9612684bad avcodec/ttadata: Don't use too big arrays
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-08-09 17:21:34 +02:00
Andreas Rheinhardt ee89beda21 tests/checkasm: Add ttadsp test
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-08-09 17:10:52 +02:00
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