Commit graph

6561 commits

Author SHA1 Message Date
d9b773c22f
hwcontext_vulkan: add VK_EXT_layer_settings to optional instance extensions
The issue is that some compilers complain if a struct or array
is empty.

This extension does nothing by default, and can be useful, so just add it
to keep the array non-empty.
2025-01-03 14:53:37 +09:00
6ba33b50f5
avutil/timecode: Avoid fps overflow in av_timecode_get_smpte_from_framenum()
Fix from c94875471e

Found-by: Youngjae Choi <youngjaechoi@korea.ac.kr>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-12-24 02:45:13 +01:00
James Almer
f1ddba24a0 avutil/frame: add missing size dependent prop to LCEVC payload side data
Signed-off-by: James Almer <jamrial@gmail.com>
2024-12-23 17:39:57 -03:00
Niklas Haas
b88944a8aa avutil/frame: add av_frame_side_data_remove_by_props()
As discussed in the previous commit, we often need a convenient way of
stripping all side data related to a certain aspect of the frame. This helper
accomplishes just that.

I considered also adding a way to match only side data matching *all*
properties, but I think this is sufficiently useless in practise to not warrant
inclusion in the API.
2024-12-23 14:22:56 +01:00
Niklas Haas
3428a8d830 avutil/frame: add AV_SIDE_DATA_PROP_{SIZE,COLOR}_DEPENDENT
Many filters modify certain aspects of frame data, e.g. through resizing
(vf_*scale* family), color volume mapping (vf_lut*, vf_tonemap*), or
possibly others.

When this happens, we should strip all frame side data that will no
longer be correct/relevant after the operation. For example, changing
the image size should invalidate AV_FRAME_DATA_PANSCAN because the crop
window (given in pixels) no longer corresponds to the actual image size.
For another example, tone-mapping filters (e.g. from HDR to SDR) should
strip all of the dynamic HDR related metadata.

Since there are a lot of different side data types that are affected by such
operations, it makes sense to establish this information in a common, easily
accessible way. The existing side data properties enum is a perfect fit for
this.
2024-12-23 13:33:33 +01:00
Niklas Haas
01084f3d16 avutil/frame: add AVSideDataDescriptor for AV_FRAME_DATA_VIDEO_HINT
This entry was seemingly missing.
2024-12-23 13:32:48 +01:00
1b8cd00da6
configure: add option to statically link to libvulkan
This may be useful in weird setups and on platforms where
static linking to libvulkan is supported.

libplacebo also has this fallback.
2024-12-23 04:25:09 +09:00
2e06b84e27
vulkan: do not reinvent a queue context struct
We recently introduced a public field which was a superset
of the queue context we used to have.

Switch to using it entirely.

This also allows us to get rid of the NIH function which was
valid only for video queues.
2024-12-23 04:25:09 +09:00
157cd820ad
vulkan: remove pointless mutex locks
This code was simply incorrect through and through. It did not
protect what actually has to be protected in a multi-threaded setup.
Perhaps it was used to silence threading errors?

Either way, remove it, and document the correct way to use execution
pools in a threaded environment.
2024-12-23 04:25:09 +09:00
4ca2b86ed5
hwcontext_vulkan: disable validation layer threading warnings
The layer is buggy currently:
https://github.com/KhronosGroup/Vulkan-ValidationLayers/issues/9045
2024-12-23 04:25:08 +09:00
18af3a1db2
hwcontext_vulkan: do not enable portability subset by default
It doesn't make sense to, and could result in the implementation
picking emulation layers.
2024-12-23 04:25:01 +09:00
Martin Storsjö
d1e37eb0cd avutil/mem_internal: Don't include stdalign.h on MSVC
It's currently actually not used in MSVC builds, since
6e49b86996.

Older versions of MSVC (or, in particular, older versions of UCRT)
don't have stdalign.h; it's available since WinSDK 10.0.20348.0;
such a new enough version has been installed by default only since
MSVC 2022 17.4 and newer.

With this change, ffmpeg can still be built with MSVC 2019 16.8
(v19.28).

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-12-18 16:03:06 +02:00
Zhao Zhili
7b0bd6c4a7 avutil/vulkan_glslang: Fix build failure
compile_only isn't available until 13.1.0. Let default initialization set
it to zero, so the code works with version before and after 13.1.0.
2024-12-17 19:28:35 +09:00
Anton Khirnov
2e956d9c0f lavc/container_fifo: move to lavu and make public
This can be useful in other places, e.g. it can replace objpool in
fftools.

The API is modified in the following nontrivial ways:
* opaque pointers can be passed through to all user callbacks
* read and write were previously separate callbacks in order to
  accomodate the caller wishing to write a new reference to the FIFO and
  keep the original one; the two callbacks are now merged into one, and
  a flags argument is added that allows to request such behaviour on a
  per-call basis
* new peek and drain functions
2024-12-15 14:05:15 +01:00
Anton Khirnov
56ba57b672 lavc/refstruct: move to lavu and make public
It is highly versatile and generally useful.
2024-12-15 14:03:47 +01:00
Kacper Michajłow
92deed9732 avutil/file: fix av_file_map file mapping on Windows
This makes the behavior of av_file_map() the same on Windows as it is on
other platforms. The file is opened as read-only, but the mapping is
copy-on-write, allowing the user to write to the memory pages returned
by av_file_map().

This commit fixes libavutil\tests\file.c test, which would crash when
trying to write to a read-only memory page.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2024-12-15 14:02:29 +01:00
James Almer
21d3dab31c avutil/channel_layout: simplify the 22.2 layout definition
Signed-off-by: James Almer <jamrial@gmail.com>
2024-12-13 16:36:10 -03:00
James Almer
6eb4bf04e9 avutil/channel_layout: add a 9.1.6 layout
Signed-off-by: James Almer <jamrial@gmail.com>
2024-12-13 16:35:47 -03:00
Hendrik Leppkes
5215ec677c
avutil/tests/color_utils: reduce accuracy threshold to pass to 1e-7
Fixes FATE on a variety of configurations due to accuracy problems in
floating point math. Most constants tested against here are not even
specified with 7 decimal digits.

Reviewed-by: Niklas Haas <git@haasn.dev>
2024-12-07 14:51:49 +01:00
Niklas Haas
7b73ea501d avutil/tests/color_utils: add tests for av_csp_itu_eotf 2024-12-05 12:27:33 +01:00
Niklas Haas
06f084468e avutil/csp: add EOTF function definitions
The existing av_csp_trc_func_from_id() mostly implements the OETF, except for
PQ. As such, we are currently missing a precise definition of an ITU-R EOTF.
Introduce the new functions av_csp_itu_eotf() and av_csp_itu_eotf_inv(), to fill
this void. Note that this is not possible in all cases, e.g. AVCOL_TRC_LOG which
has no corresponding EOTF definition in any ITU-R standard.

Note that we cannot implement the proper HLG and SMPTE 428 OOTFs without access
to all three color channels, because they are not independent per channel. As a
result, we need to define them on double[3] instead of double (*func)(double).
2024-12-05 12:27:32 +01:00
Niklas Haas
bf0a6c4111 avutil/csp: add av_csp_trc_inv_from_id()
Mathematical inverse of av_csp_trc_from_id(), plus testing to make sure it
roundtrips correctly with the corresponding TRC.
2024-12-05 12:26:49 +01:00
Niklas Haas
28f217780b avutil/tests/color_utils: clean up slightly (cosmetic)
Rewrite this test slightly to fix the formatting, improve the readability of
the output, and eliminate some unnecessary branching.
2024-12-05 11:51:18 +01:00
Niklas Haas
feb5982f43 avutil/csp: eliminate redundant branch 2024-12-05 11:51:18 +01:00
Niklas Haas
ec0489e35c avutil/csp: fix documentation of av_csp_trc_function
This explanation was inaccurate and highly misleading. The new wording is taken
more or less directly from ITU-T H.273, and also matches my understanding of
these functions.
2024-12-05 11:51:18 +01:00
Zhao Zhili
2dc55f5993 configure: Add wasm as a fake arch
And add wasm simd128 flag, so we can add simd128 optimizations.
It can be enabled by put -msimd128 to extra cflags. There is
no runtime detection on simd128 support yet. I think that needs to
be done with JavaScript.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2024-12-04 16:43:06 +08:00
Zhao Zhili
6e49b86996 avutil/mem_internal: Don't use alignas for MSVC
MSVC messed up standard C features, again.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
Reviewed-by: James Almer <jamrial@gmail.com>
2024-12-02 20:37:47 +08:00
Zhao Zhili
59057aa807 avutil/mem_internal: local align should always work
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2024-11-29 12:33:03 +08:00
Zhao Zhili
57861911a3 avutil/mem_internal: define DECLARE_ALIGNED as C11's alignas
alignas is portable than compiler's specific __attribute__. It do
have a limitation, that alignas don't support specify aligment on
the declarations of struct (it works for specify alignment on struct
fields), which only used by avcodec/cavs, and is removed now.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2024-11-29 12:32:57 +08:00
187fd52864
vulkan: fix use of atomics for the current context index
The code used to use atomic, but over time, this got broken.
This commit also remmoves the is-the-last-submission-ready
shortcut, which rarely did anything.
There's also value in relying on the fact that contexts
always carry their frames in a strictly incremental order
with no gaps.
2024-11-28 01:29:21 +09:00
d8f301cdf2
ffv1enc_vulkan: switch to receive_packet
This allows the encoder to fully saturate all queues the GPU
has, giving a good 10% in certain cases and resolutions.

This also improves error resilience if an allocation fails,
and properly cleans up after itself if it does.
2024-11-26 14:14:15 +01:00
ce8a070cf3
vulkan: only wait for fences on uninit if the context had a submission
This fixes a potential deadlock on exit.
2024-11-26 14:14:14 +01:00
86e552506d
vulkan: zero out AVBufferRef in case of failure
This resulted in uninit errors and was never caught as
we generally did not use massive allocations before.
2024-11-26 14:14:14 +01:00
f582de8f34
vulkan: only apply shortcut for next context selection if selection has a submission 2024-11-26 14:14:14 +01:00
8ac49ae9e0
vulkan: add opaque field to execution contexts
Helps keep track of what dispatch happened where.
2024-11-26 14:14:14 +01:00
d485420237
hwcontext_vulkan: take disable_multiplane into account when checking for formats 2024-11-26 14:14:13 +01:00
cf0961a527
hwcontext_vulkan: require storage properties to claim formats as supported
This function dates back a long time ago, before vkfmt_from_pixfmt2.
When it was converted over, the thought was that this was far too
restrictive to demand storage images for each format.
With the new clever function, it makes sure to check that the compatible
subformats a format can be used as support storage capabilities.

This gets rid of fake support for RGB48/RGB96 which some implementations
offer but don't support using as storage images.
2024-11-26 14:14:13 +01:00
f65e51293a
hwcontext_vulkan: add support for AV_PIX_FMT_GBRAP10/12/14 2024-11-26 14:14:13 +01:00
7c52dda55f
hwcontext_vulkan: add support for AV_PIX_FMT_GBRP12/14/16 2024-11-26 14:14:12 +01:00
08fb505a66
hwcontext_vulkan: add support for AV_PIX_FMT_GRAY10/12/14 2024-11-26 14:14:07 +01:00
Rémi Denis-Courmont
63922ba5dc lavu/float_dsp: fix compilation with RISC-V ILP32 ABI 2024-11-25 19:29:21 +02:00
Pavel Koshevoy
46cb7b8d9d avutil/frame: also align data pointers in av_frame_get_buffer()
This avoids unpleasant surprises to av_frame_get_buffer callers
that explicitly specified 64-byte alignment and didn't get
AVFrame.data pointers that are 64-byte aligned.

For example, see https://github.com/sekrit-twc/zimg/issues/212

Although the zscale issue has already been resolved by other means
it would still be prudent to improve the behavior of av_frame_get_buffer
to fix any unknown and future instances of similar issues.

Co-authored-by: James Almer <jamrial@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2024-11-22 10:43:55 -03:00
James Almer
ea91d978e3 avutil/frame: fix setting plane_padding
STRIDE_ALIGN is a lavc define and is not necessarely 32. And align may be <= 0 at the
point plane_padding is being set.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-11-22 10:43:55 -03:00
James Almer
09122bd15c avutil/frame: use size_t for total_size in get_video_buffer()
Signed-off-by: James Almer <jamrial@gmail.com>
2024-11-22 10:43:55 -03:00
aad40fed33
vulkan: fix sw_frame_deps counter
The code used as a basis was the buffer dependency code, where the
counter was incremented after each buffer, but for the sw_frame dep
API, we only support adding individual frames at a time.
2024-11-20 05:47:41 +01:00
Brad Smith
f3eca3f387 libavutil/riscv: Make use of elf_aux_info() on FreeBSD / OpenBSD riscv
libavutil/riscv: Make use of elf_aux_info() on FreeBSD / OpenBSD riscv

FreeBSD/OpenBSD riscv have elf_aux_info().

Signed-off-by: Brad Smith <brad@comstyle.com>
Signed-off-by: Rémi Denis-Courmont <remi@remlab.net>
2024-11-18 22:09:07 +02:00
Rémi Denis-Courmont
e29432e6bb lavu/riscv: fix compilation without Vector support
The half-baked assembler in Clang 16 and earlier can't process our
RISC-V assembler. This adds yet another work around that.

If you must use Clang, please use version 17 or later.
2024-11-18 20:04:38 +02:00
d0ab49e3e7
hwcontext_vulkan: add the mapped software frame as an upload dependency
We do uploads asynchronously, and we map the software frames in
order to avoid 2-stage copying. However, whilst we added a dependency
upon the mapped buffers, we did not add the original frame backing
those buffers as a dependency.

This caused issues on RADV, particularly with RGB images.
2024-11-18 07:54:20 +01:00
1876026f83
vulkan: add ff_vk_exec_add_dep_sw_frame
Some software frames may be mapped, and we'd like to have
them as proper dependencies.
2024-11-18 07:54:20 +01:00
c918b42dcd
vulkan: retrieve Vulkan 1.1 properties
Required to know the subgroup size.
2024-11-18 07:45:46 +01:00