Commit Graph

7050 Commits

Author SHA1 Message Date
Lynne
062de19095 configure: remove libshaderc and libglslang support
All of it is now gone.

(cherry picked from commit 92f2e6374d)
2026-07-14 00:14:28 +09:00
Lynne
ca089c35c4 vulkan: remove runtime shader compilation support
No longer needed.

(cherry picked from commit 9e9ac0dcd9)
2026-07-14 00:14:28 +09:00
Philip Langdale
b9aa305686 avutil/hwcontext_vulkan: declare cuda as a transfer-compatible format
The cuda hwcontext has listed AV_PIX_FMT_VULKAN among its supported
formats since Vulkan interop was first added, so a device's frame
constraints advertise Vulkan as a transfer-compatible ("sw") format.
This is what allows an hwupload targeting a cuda device to accept a
Vulkan frame as input during format negotiation.

The Vulkan hwcontext never made the reciprocal declaration, so an
hwupload targeting a Vulkan device would not accept a cuda frame, and a
cuda -> Vulkan upload could not be configured even though the transfer
itself is supported. Advertise AV_PIX_FMT_CUDA in the Vulkan frame
constraints to ensure we have consistent behaviour in both directions.

(cherry picked from commit d09d5afc3a)
2026-07-12 13:48:17 +09:00
Zhao Zhili
30ae65e506 avutil/hwcontext_vulkan: query the actual image format in try_export_flags
GetPhysicalDeviceImageFormatProperties2() must be queried with the format
that will actually be used to create the image, otherwise the external
memory export capability check answers for a different format than the one
being allocated.

When AV_VK_FRAME_FLAG_DISABLE_MULTIPLANE is set (e.g. by ffplay for CUDA
interop), vulkan_frames_init selects the per-plane fallback format via
vkfmt_from_pixfmt2(disable_multiplane=1) and stores it in hwctx->format[].
The image is then created with that fallback format. Querying the
multiplane vkf instead returns capability for a format that is never
instantiated, and on NVIDIA GPUs with OPTIMAL tiling the answer differs
between the two formats, producing broken CUDA hwaccel output.

Read hwctx->format[0], which is populated by vulkan_frames_init before
vulkan_pool_alloc runs, so the query matches the image regardless of
whether the multiplane or fallback path was taken.

Fix artifacts with `ffplay -hwaccel cuda foo.mp4`.

(cherry picked from commit 0baa71b53c)
2026-07-12 13:47:24 +09:00
Zhao Zhili
68fa1f7f48 libavutil/vulkan: fix elem_size computation in vulkan_export_to_cuda
(cherry picked from commit b4b30ff8fd)
2026-07-12 13:47:24 +09:00
Philip Langdale
63211cbec1 avutil/hwcontext_vulkan: reject unsupported semi-planar CUDA imports
Cuda currently only supports packed and single-component planar formats, but
fails to import semi-planer (eg: NV12, P010). Even though there are now
semi-planar cuda array formats, which the latest nvdec can use, these formats
are not used when mapping Vulkan imports. Maybe they'll fix that some day.

But until then, let's explicitly detect the case and return a clear error
message for the user.

Exercising this error path revealed that vulkan_free_internal() frees
f->internal on a transfer error and then runs again when the frame is
destroyed, dereferencing the freed pointer; let's make it idempotent.

(cherry picked from commit c29d710cd5)
2026-07-12 13:47:24 +09:00
Philip Langdale
6f2c280187 avutil/hwcontext_vulkan: CUDA interop semaphores are per image
The current semaphore logic dates back to a time where we did not have any
multiplane images, and it has not kept up. As a result, we currently try and
manipulate too many semaphores when dealing with multiplane images, leading to
errors and crashes. Let's fix it.

(cherry picked from commit 30ba440386)
2026-07-12 13:47:24 +09:00
Philip Langdale
f1137f1074 avutil/hwcontext_vulkan: fix CUDA interop for packed formats
The current export_to_cuda logic only works for planar and semi-planar formats.
When presented with a single plane packed format, it will incorrectly
calculate the number of channels, resulting in failures later on when cuda
code tries to access the frame. Let's fix it.

(cherry picked from commit 927f205eb8)
2026-07-12 13:47:24 +09:00
nyanmisaka
a508495cd7 avutil/hwcontext_cuda: fix yuv420p V/U plane overlap in cuda_get_buffer()
Odd-height yuv420p result in incorrect calculations of the U-plane
address offset. The last row of the V-plane overlapped with and was
overwritten by the first row of the U-plane, leading to chroma artifacts.

```
ffmpeg -init_hw_device cuda=cu -filter_hw_device cu -f lavfi -i \
testsrc=s=1920x1081,format=yuv420p -vf hwupload -c:v hevc_nvenc \
-vframes 1 -y <OUTPUT>
```

Signed-off-by: nyanmisaka <nst799610810@gmail.com>
(cherry picked from commit 3f6bf150cb)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-06-29 18:11:20 +02:00
Michael Niedermayer
47e9d68e20 Bump minor for release/9.0
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-26 02:43:34 +02:00
Niklas Haas
b568f20f32 swscale/rational64: add 64-bit rational type
This is needed by the ops code, to represent intermediate values for 32-bit
formats, which can exceed the value range of int32_t (especially for
intermediate products).

I copied the math almost 1:1 from rational.c, but adapted to use the 128-bit
integer wrappers defined by int128.h. I added a generous amount of tests in
any case.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-25 01:20:15 +02:00
Niklas Haas
6a853ce327 avutil/rational: avoid signed integer overflow
Passing -INT_MIN to av_sub_q() overflows due to the negation. Writing out
the formula explicitly avoids this.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-25 01:20:15 +02:00
Niklas Haas
33e5fca2ee avutil/tests/rational: add explicit unit tests for edge cases
The existing tests don't really stress test the edge-case behavior when adding
or multiplying values that over/underflow.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-25 01:20:15 +02:00
Niklas Haas
9e3343a94d avutil/int128: add header for 128-bit integers
These can be implemented efficiently on most modern 64-bit compilers. Fallback
is only needed for 32-bit, which we do using the existing generic "integer.h"
header (currently also hard-coded as 128 bits).

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-25 01:20:15 +02:00
Diego de Souza
74db061f0a avutil/hwcontext_cuda: add P012 and P212 to supported formats
NVDEC and CUVID decode 12-bit 4:2:0 content to AV_PIX_FMT_P012 and
12-bit 4:2:2 to AV_PIX_FMT_P212, but these formats were missing from
the CUDA frames context supported format list. As a result
av_hwframe_ctx_init() rejected them ("Pixel format not supported",
AVERROR(ENOSYS)), so decoding 12-bit content to CUDA frames and
hwdownload of such frames both failed.

Add P012 and P212 next to the existing P010/P016 and P210/P216 entries.
The per-plane device transfer is derived generically from the pixel
descriptor, so no other changes are required.

Signed-off-by: Diego de Souza <ddesouza@nvidia.com>
2026-06-23 23:58:45 +00:00
marcos ashton
2985d42978 libavutil/pixdesc: fix prefix matching in *_from_name() functions
The seven *_from_name() functions in pixdesc.c (color_range,
color_primaries, color_transfer, color_space, chroma_location,
alpha_mode) used av_strstart() for prefix matching, which returns
incorrect results when one name is a prefix of another.

av_color_space_from_name("ycgco-re") matched "ycgco" at index
AVCOL_SPC_YCGCO and returned 8 instead of AVCOL_SPC_YCGCO_RE.
av_color_space_from_name("ycgco-ro") had the same issue. The
*_ext name lookups inside av_color_primaries_from_name and
av_color_transfer_from_name had the same flaw.

Switch all eight call sites from av_strstart() to strcmp() for
exact matching. No in-tree callers rely on prefix matching.

Signed-off-by: marcos ashton <marcosashiglesias@gmail.com>
2026-06-23 23:42:38 +00:00
Andreas Rheinhardt
762b94e672 libs: Bump major version of all libraries
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 19:15:57 +02:00
Andreas Rheinhardt
2d3776b8cc avutil/x86/emms: Unavpriv avpriv_emms_asm()
This fallback function is used if external MMX is available,
while inline MMX and intrinsics for emitting emms are unavailable.
It is implemented as an avpriv function, which has several
drawbacks for shared builds:
1. The function is so small (3 bytes; 16 with padding)
that the overhead of exporting and importing it dwarfs
the gains from code deduplication.
2. A call to an external library has more overhead than
a library-internal one.
3. It may cause linking failures when a libavutil not exporting
avpriv_emms_asm() is paired with a library needing it
(if inline assembly and intrinsics were unavailable when building
the dependent library). I am not aware of this ever happening.
4. We would be forced to keep avpriv_emms_asm() around for ABI stability
even after it is no longer needed.

This commit therefore uses the STLIBOBJS, SHLIBOBJS approach
to duplicating it into each library on its own if needed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 19:15:57 +02:00
Andreas Rheinhardt
fff992a5bc avutil/xga_font_data: Stop exporting font data directly
Commit c6c8063186 added getters for them.
Also remove av_export_avutil and the BUILDING_foo macro.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 19:15:57 +02:00
Andreas Rheinhardt
da0ea43984 avutil/hwcontext_vulkan: Move AVVkFrame.internal to the end
This allows us to remove it by allocating AVVkFrameInternal
jointly with AVVkFrame.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 19:15:57 +02:00
Lynne
61693f6c35 hwcontext_vulkan: switch to VkAccessFlagBits2 2026-06-23 19:15:57 +02:00
Andreas Rheinhardt
1c36aa8e33 avutil/opt: Remove FF_API_OPT_PTR
Deprecated on 2024-10-16.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 19:15:57 +02:00
Andreas Rheinhardt
c32a719cb2 avutil: Remove FF_API_OPT_INT_LIST
Deprecated on 2024-09-30.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 19:15:57 +02:00
Andreas Rheinhardt
38990c59d7 avutil/hwcontext_vulkan: Remove FF_API_VULKAN_FIXED_QUEUES
Deprecated on 2024-08-11.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 19:15:57 +02:00
Andreas Rheinhardt
46d52299f5 avutil/cpu: Remove FF_API_RISCV_FD_ZBA
Deprecated on 2024-08-05.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 19:15:57 +02:00
Andreas Rheinhardt
51231c5588 avutil/common: Remove FF_API_MOD_UINTP2
Deprecated on 2024-06-13.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 19:15:57 +02:00
Kacper Michajłow
64ce854ef5 avutil/hwcontext_d3d11va: support native P016 format
Map DXGI_FORMAT_P016 to AV_PIX_FMT_P016 and keep the 12-bit P012 as a
compatibility entry, matching how Y216 and Y416 already expose both their
native 16-bit and 12-bit variants.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-06-22 11:06:13 +00:00
Kirill A. Korinsky
b57ff00bcf configure/x86: split 7-register check from EBP availability
LLVM commit
0d471b3f64
made Clang save and restore EBP around inline asm that only
clobbers it. This can make the existing EBP crash probe pass even
when the compiler still cannot allocate the 7-register i386 inline
asm used behind HAVE_7REGS.

Keep ebp_available for HAVE_6REGS and add a separate
x86_32_7regs probe for HAVE_7REGS.

Discussion:
https://marc.info/?t=178015389900001&r=1&w=2
2026-06-20 11:46:49 +00:00
Andreas Rheinhardt
4bbb7d9b99 avutil/x86/x86util: Force VEX encoding when using -mavx
This avoids reg-reg moves and saves 90112B of .text here.
It also makes the code less reliant on a clean upper ymm state.

Not all functions use VEX encoding yet; besides inline assembly
functions which are not influenced by x86inc.asm there are also
functions using a mixture of xmm and mmx registers (e.g.
h264_intrapred.asm) using INIT_MMX where the automatic VEX translation
is not active. This means that some parts of the code still rely
on a clean upper ymm state.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-19 20:39:56 +02:00
Dmitrii Gershenkop
485f195690 avutil/hwcontext_amf: Implement AMF hardware memory mapping support. 2026-06-17 12:30:56 +00:00
Zhao Zhili
7338d08bcf avutil: zero size output parameter on allocation failure
Several _alloc() functions taking a size_t *size output parameter
either left it uninitialized or unconditionally set it to sizeof(...)
when the underlying av_mallocz() failed. Callers that check the
returned pointer first are unaffected, but the stale value is a trap
for any code path that inspects size without a NULL check.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-06-16 12:41:53 +00:00
Bogdan Lisman
3d1d546f70 avutil/eval: apply unary sign to print, squish, gauss and lerp
The leading sign of a (sub)expression is stored as +-1 in each node's
value field (parse_factor) and every other function multiplies its
result by it. print, squish, gauss and lerp ignored it, so e.g.
-print(1) evaluated to 1 instead of -1 and -gauss(0) to 0.398942
instead of -0.398942, while -1*print(1) was correct.

Fixes: ticket #9833
Reported-by: Player701
Signed-off-by: Bogdan Lisman <bogdan@pydevsolutions.com>
2026-06-15 19:11:59 +00:00
WyattBlue
b1d2190f5f avutil/riscv: Include unistd.h for musl Linux
Before, glibc appears to transitively pull in the syscall number
definitions, but musl does not do this. Thus, `__NR_riscv_hwprobe`
is undeclared and an error is emitted.

Fix this by including `<asm/unistd.h>`, which makes the macro
visible on musl.
2026-06-14 13:51:25 +00:00
Lynne
03be563053 hwcontext_vulkan: fix BGRA/BGR0 images
The fix was a lot simpler than I thought it was.
2026-06-12 10:14:33 +09:00
Kacper Michajłow
f43f609bb8 avutil/x86/tx_float: add missing vzeroupper to 15xM PFA FFT
The AVX2 15xM PFA FFT calls its second-dimension subtransform with dirty
YMM. That subtransform may be a legacy-SSE codelet (fft4 is SSE2 only),
causing AVX<->SSE transition penalties. Clear them after the first
dimension, before the calls.

Detected with `sde64 -ast` FATE job.

Fixes: ace42cf581
2026-06-09 17:54:21 +00:00
Lynne
12dc67b6fe lavu/frame: add camera raw codec side data
Required to correctly present raw video.
Codec-specific since I'd like to support ARRIRAW in the future, which
has a different format.
2026-06-10 02:38:35 +09: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
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
Lynne
2806afd28f vulkan/ffv1: read raw 16-bit float images via R16_UINT view to preserve denormals
GPUs filter out denormals when reading floats via imageLoad. Denormals shouldn't
be present in general, but if they are, this is a lossless codec, and we have to
preserve them. This allows reading the exact values.

Sponsored-by: Sovereign Tech Fund
2026-05-26 17:47:04 +09:00
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
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
Lynne
5f2877b532 hwcontext_vulkan: enable X2BGR10
The format itself was working perfectly. Unlike BGR0/BGRA, all known
Vulkan implementations support storage images just fine.
2026-05-19 03:22:29 +09:00
Lynne
561e32c9cf hwcontext_vulkan: reenable X2RGB10
Now that all issues are fixed, we can go ahead with it.

Sponsored-by: Sovereign Tech Fund
2026-05-19 03:22:29 +09:00
Lynne
f73acb8618 hwcontext_vulkan: reenable and remap XV30
The issue was that XV30 is a native 444 10-bit format, rather than
16-bits. This resulted in padding leaking into bits where it shouldn't.

Sponsored-by: Sovereign Tech Fund
2026-05-19 03:22:24 +09:00
wangbin
239c679c54 lavc: add ProRes RAW videotoolbox hwaccel 2026-05-17 03:47:23 +00:00
Lynne
0e8cf39541 hwcontext_vulkan: add support for AV_PIX_FMT_RGBAF16 2026-05-17 12:02:51 +09:00
Marvin Scholz
99908c6e05 avutil: add IAMF frame side data types
These contain the same data as the packet side data equivalents.
2026-05-13 15:19:11 +02:00
Marvin Scholz
4851060ccd avutil: hdr_dynamic_metadata: fix error code
When s is NULL in av_dynamic_hdr_smpte2094_app5_from_t35, that's not an
allocation error but just invalid API usage. If there is any allocation
failure beforehand that would lead to this, the caller has to check it,
like is already done in all usages of this function in FFmpeg itself.
2026-05-12 17:18:38 +02:00