54647 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
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 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
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
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
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
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
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
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 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 b6ac28aff6 vulkan: use fixed-size dependency arrays in FFVkExecContext
Execution contexts track at most a few dozen dependencies so dynamically
growing the arrays was just stupid, and ARR_REALLOC required the field
name to also exist as a local variable.
2026-08-05 16:04:36 +09:00
Lynne 1d14f9f8c3 vulkan: decouple execution pool depths from queue and thread counts
Pool depth sets how far the CPU records ahead of the GPU, and has no relation
to the number of queues in a family.
Scaling it by the queue count only multiplied command pools, fences and context state.
Use a small fixed depth everywhere, and one context per thread only for threadsafe hwaccels,
which submit from every frame thread concurrently.
2026-08-05 16:04:31 +09:00
Kacper Michajłow 9862dd83b1 avcodec/aarch64/vc1dsp_neon: reduce literal pool alignment to 16 bytes
armasm64 warns "A4228: Alignment value exceeds AREA alignment; alignment
not guaranteed" on the .Lcoeffs literal pool. gas-preprocessor.pl emits
the text section as "AREA |.text|, CODE, READONLY, ALIGN=4", i.e. a
16-byte section alignment, so a 32-byte ALIGN inside it cannot be
guaranteed by the assembler.

16 is enough here: the pool holds .quad values that are read with
"ldr d0, .Lcoeffs" literal loads, which only require 8-byte alignment.
It also matches the rest of the aarch64 asm, where the function and
const macros both default to .align 4.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-08-03 18:16:24 +00:00
Scott Kidder 883e8a6336 avcodec/libopenh264dec: implement flush callback
Cisco's ISVCDecoder retains DPB and reference state across
avcodec_flush_buffers(), causing the next IDR to be accepted but
subsequent P-frames to fail decode after a seek or loop. Cisco's
API does not expose a non-destructive reset; tear down and rebuild
the decoder via the existing close/init callbacks.

The .flush callback is void and cannot report a re-init failure, so
svc_decode_frame() guards against a NULL decoder left behind by a
failed re-init. svc_decode_init() now also tears the decoder back
down on an Initialize() failure so that path leaves the same clean
NULL state the guard expects and does not leak the ISVCDecoder.

Signed-off-by: Scott Kidder <scott@kidder.io>
2026-08-03 11:08:57 +00:00
Lynne e54f60ed1b vulkan: declare maximal reconvergence in shaders doing subgroup reductions
These shaders reduce across the subgroup after divergent control flow
and implicitly rely on invocations reconverging as written, the
MaximallyReconvergesKHR execution mode turns that assumption into a
guarantee.
2026-08-03 10:57:49 +09:00
Andreas Rheinhardt f0fc529cbe avcodec/x86/lossless_videodsp: Use memory operand where possible
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-08-02 18:36:52 +02:00
Andreas Rheinhardt 6c123e217b avcodec/x86/lossless_videodsp: Hoist calculation out of loop
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-08-02 18:36:52 +02:00
Andreas Rheinhardt b4d11f4046 avcodec/x86/lossless_videodsp: Optimize add_gradient_pred
Combinations of shift and add like
pslldq  m3, m2, 1
paddb   m2, m3
are linear in the input register m2. This implies
that instead of applying the same sequence of shifts and adds
to two different registers and adding said registers
one can just add the register first and then apply
said sequence of shifts and adds once.

Old benchmarks:
  add_gradient_pred_c:           2296.2
  add_gradient_pred_ssse3:        570.4 ( 3.95x)
  add_gradient_pred_avx2:         308.8 ( 7.29x)

New benchmarks:
  add_gradient_pred_c:           2315.6
  add_gradient_pred_ssse3:        344.0 ( 6.72x)
  add_gradient_pred_avx2:         205.2 (11.28x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-08-02 18:36:51 +02:00
Michael Niedermayer afd059c340 avcodec/nvenc: write AV1 timecode metadata in AV1 syntax
Fixes: https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/20610

Tested on 5090 by claude
2026-08-02 16:06:47 +00:00
Michael Niedermayer 5589dfd9bc avcodec/utils: add ff_alloc_timecode_metadata_av1() 2026-08-02 16:06:47 +00:00
Michael Niedermayer a290dec0bf avcodec/utils: factor the timecode fields out of ff_alloc_timecode_sei 2026-08-02 16:06:47 +00:00
Lynne 0da8f2f4ee vulkan_encode_av1: set primary_ref_frame to a reference name, not a slot
primary_ref_frame is an index into the seven reference names, but the
code assigned it the reference's DPB slot. The two coincide only while
the reference sits in slot 0; once it rotates to slot 1,
referenceNameSlotIndices[primary_ref_frame] is -1, which is invalid,
and NVIDIA drivers lose the device. Inherited from vaapi_encode_av1,
where the same confusion is harmless as the raw frame header maps
every reference name to the same slot.

Have set_name_slot() return the name it picked and use that.

Fixes #20540.
2026-08-02 22:11:28 +09:00
Lynne 2dd3328240 vulkan: give ff_vk_host_map_buffer an explicit import length
The function sized every import from src_data to the end of the source
buffer. For packets which are small views of a much larger allocation,
this pinned and mapped every page of the underlying allocation, at
around 1.6us per page, regardless of what the GPU ever touches.

Take the import length as a VkDeviceSize, clamped to the end of the
source buffer; the clamp doubles as the implementation of
VK_WHOLE_SIZE.
2026-08-02 22:11:28 +09:00
Lynne d42cd604d0 vulkan_ffv1: always keep the decoder's fltmap descriptor valid
The setup shader statically uses the fltmap binding, but the decoder
only bound a buffer to it for float formats, leaving a dangling
descriptor on everything else, with the write reachable by any
bitstream signalling remap.

Gate remap on a new push-constant flag, so that streams signalling it
without a fltmap buffer error out, and point the descriptor at the
slice feedback buffer when no fltmap exists; the gate guarantees it is
never written through this binding.
2026-08-02 22:11:27 +09:00
Lynne b27f276bdd vulkan_ffv1: use the extradata slice structure in the low-slice-count warning
slice_count is only set while decoding a frame, so the warning always
printed a slice count of 0 at init time, and fired on streams with
plenty of slices.
2026-08-02 22:11:27 +09:00
Lynne 898b8aa922 vulkan_ffv1: survive setup failures on preceding frames
A frame's private data is allocated before start_frame(), and its free
callback runs even if setup failed partway, so partially-initialized
private data has to be tolerated everywhere: inter frames reffed the
previous frame's slice state without checking it exists, end_frame()
waited on a semaphore that was never created, and the free callback
read a feedback buffer that was never allocated or written. Inter
frames after a failed frame now error out until the next keyframe.

Also set the device function pointers before anything can fail, as the
free callback needs them.
2026-08-02 22:11:23 +09:00
Andreas Rheinhardt a59498db08 avcodec/huffyuvdsp: Remove pix_fmt parameter from ff_huffyuvdsp_init()
It is unused since the mmx add_hfyu_median_pred_int16 function
has been removed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-08-02 02:19:05 +02:00
Andreas Rheinhardt c8fb970a92 avcodec/x86/huffyuvdsp: Remove ff_add_hfyu_median_prediction_mmxext
Superseded by SSE4. This makes the huffyuv decoders ABI compliant,
e.g. nothing messes up the FPU state at all any more. Therefore
the emms_c() can be removed from huffyuvdec.c.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-08-02 02:19:04 +02:00
Andreas Rheinhardt 0127016c41 avcodec/x86/huffyuvdsp: Add SSE4 add_hfyu_median_pred_int16
Heavily based upon the existing mmxext function, but
it allows to use p{max,min}uw, so also supports 16bpp
pixel formats. It is also faster:

  add_hfyu_median_pred_int16_c:       14368.1
  add_hfyu_median_pred_int16_mmxext:   7384.2 ( 1.94x)
  add_hfyu_median_pred_int16_sse4:     6474.4 ( 2.21x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-08-02 02:12:51 +02:00
Andreas Rheinhardt d8cb1ef0e5 avcodec/x86/huffyuvdsp: Remove remnants of MMX
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-08-02 02:00:49 +02:00