Commit Graph

6972 Commits

Author SHA1 Message Date
Michael Niedermayer
b11729f154 avutil/samplefmt: Dont claim that av_get_sample_fmt_string checks sample_fmt
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-04-05 00:19:09 +00:00
marcos ashton
e18c8c533d tests/fate/libavutil: add FATE test for mathematics
Test the integer math utility functions: av_gcd, av_rescale,
av_rescale_rnd (all rounding modes including PASS_MINMAX),
av_rescale_q, av_compare_ts, av_compare_mod, av_rescale_delta,
and av_add_stable. Includes large-value tests that exercise the
128-bit multiply path in av_rescale_rnd.

av_bessel_i0 is not tested since it uses floating point math
that is not bitexact across platforms.

Coverage for libavutil/mathematics.c: 0.00% -> 82.03%

Remaining uncovered lines are av_bessel_i0 (float, 23 lines)
and one edge case fallback in av_rescale_delta.
2026-04-05 00:12:29 +00:00
marcos ashton
66b1dbfb98 tests/fate/libavutil: add FATE test for samplefmt
Test all public API functions: name/format round-trip lookups,
bytes_per_sample, is_planar, packed/planar conversions,
alt_sample_fmt, get_sample_fmt_string, samples_get_buffer_size,
samples_alloc, samples_alloc_array_and_samples, samples_copy,
and samples_set_silence. OOM error paths are exercised via
av_max_alloc().

Coverage for libavutil/samplefmt.c: 0.00% -> 95.28%

Remaining uncovered lines are the fill_arrays failure path
and the overlapping memmove branch in samples_copy.
2026-04-05 00:12:29 +00:00
marcos ashton
117897bcd0 tests/fate/libavutil: add FATE test for rc4
Test the three public API functions: av_rc4_alloc, av_rc4_init,
and av_rc4_crypt. Verifies keystream output against RFC 6229
test vectors for 40, 56, 64, and 128-bit keys, encrypt/decrypt
round-trip, inplace operation, and the invalid key_bits error path.

Coverage for libavutil/rc4.c: 0.00% -> 100.00%
2026-04-05 00:12:29 +00:00
Lynne
ebfd18ad03 hwcontext_vulkan: temporarily disable formats which require shader+framework processing
The main issue is that BGR formats only semi-exist in Vulkan. Unlike all
other formats, they require the user to manually remap the pixel order, and
are also forbidden from being written to without a format in shaders. The main
reason for this was conservative - Vulkan is supposed to work everywhere, including
platforms where there is no write-time remapping/swizzing support.

Sponsored-by: Sovereign Tech Fund
2026-04-02 21:15:05 +02:00
Lynne
5a6480af0c hwcontext_vulkan: do not indicate support for rgb565
It requires special handling.

Sponsored-by: Sovereign Tech Fund
2026-04-02 21:15:05 +02:00
Lynne
2bea947027 hwcontext_vulkan: don't indicate support for AV_PIX_FMT_UYVA
Uploading and downloading is broken.

Sponsored-by: Sovereign Tech Fund
2026-04-02 21:15:05 +02:00
Lynne
4b1e79f062 hwcontext_vulkan: return ENOTSUP in vulkan_frames_init
If a format is not supported, EINVAL is not the appropriate
return code.

Sponsored-by: Sovereign Tech Fund
2026-04-02 21:15:05 +02:00
Andreas Rheinhardt
f6bbd63557 avutil/tests/.gitignore: Add recently added test tools
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-01 14:04:16 +00:00
Brad Smith
e64a1d2953 libavutil/ppc: Remove mfspr-based AltiVec detection code for Linux
The getauxval() and auxv methods cover the last 25+ years of Linux.

Signed-off-by: Brad Smith <brad@comstyle.com>
2026-04-01 04:33:44 +00:00
Lynne
35c6cdb191 hwcontext_vulkan: add support for GBRPF16/GBRAPF16
Sponsored-by: Sovereign Tech Fund
2026-03-31 23:47:39 +02:00
Martin Storsjö
77ff3bcb90 aarch64: Add AARCH64_VALID_JUMP_CALL_TARGET
We currently don't have any cases where this is needed, but include
it for completeness and clarity.

These macros for BTI were added in
08b4716a9e.

A later comment in this file, added in
248986a0db, referenced the macro
AARCH64_VALID_JUMP_CALL_TARGET which never was added here before.
2026-03-31 19:57:46 +00:00
Martin Storsjö
8ed8e221bd aarch64: Fix a URL typo
This was added in 248986a0db.
2026-03-31 19:57:46 +00:00
marcos ashton
878eabdfef tests/fate/libavutil: add FATE test for video_enc_params
Unit test covering av_video_enc_params_alloc,
av_video_enc_params_block, and
av_video_enc_params_create_side_data.

Tests allocation for all three codec types (VP9, H264, MPEG2) and
the NONE type, with 0 and 4 blocks, with and without size output.
Verifies block getter indexing by writing and reading back
coordinates, dimensions, and delta_qp values. Tests frame-level qp
and delta_qp fields, and side data creation with frame attachment.

Coverage for libavutil/video_enc_params.c: 0.00% -> 86.21%
(remaining uncovered lines are OOM error paths)

Signed-off-by: marcos ashton <marcosashiglesias@gmail.com>
2026-03-31 18:05:51 +01:00
marcos ashton
c8ec660d78 tests/fate/libavutil: add FATE test for detection_bbox
Unit test covering av_detection_bbox_alloc, av_get_detection_bbox,
and av_detection_bbox_create_side_data.

Tests allocation with 0, 1, and 4 bounding boxes, with and without
size output. Verifies bbox getter indexing by writing and reading
back coordinates, labels, and confidence values. Tests classify
fields (labels and confidences), the header source field, and
side data creation with frame attachment.

Coverage for libavutil/detection_bbox.c: 0.00% -> 86.67%
(remaining uncovered lines are OOM error paths)

Signed-off-by: marcos ashton <marcosashiglesias@gmail.com>
2026-03-31 18:05:51 +01:00
marcos ashton
be2fa77344 tests/fate/libavutil: add FATE test for spherical
Unit test covering all 4 public API functions in libavutil/spherical.c:
av_spherical_alloc, av_spherical_projection_name, av_spherical_from_name,
and av_spherical_tile_bounds.

Tests allocation with and without size output, all 7 projection type
name lookups, projection name round-trip verification, out-of-range
handling, and tile bounds computation for full-frame, quarter-tile,
and centered-tile configurations.

Coverage for libavutil/spherical.c: 0.00% -> 100.00%

Signed-off-by: marcos ashton <marcosashiglesias@gmail.com>
2026-03-31 18:05:51 +01:00
Ramiro Polla
af443abe99 aarch64: Add support for indirect branch targets in the function macro
The function macro emits AARCH64_VALID_CALL_TARGET for exported symbols,
marking them as valid destinations for indirect _calls_. Functions that
are reached by indirect _branches_ (i.e. tail-call dispatch chains
where the link register is not set) require AARCH64_VALID_JUMP_TARGET
instead.

This commit adds a "jumpable" parameter to the function macro that, when
set, emits AARCH64_VALID_JUMP_TARGET instead of AARCH64_VALID_CALL_TARGET.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-03-31 11:48:52 +00:00
Dmitrii Gershenkop
8b93c94f47 avutil/hwcontext_amf: Add AMF_IFACE_CALL macro
Using AMF interfaces in C can be cumbersome and visually difficult to process in some cases: i.e.: object->function(object, args). To improve code readability, a new macro is added. This commit is instrumental for future AMF integration refactoring.
2026-03-31 11:33:00 +00:00
Dmitrii Gershenkop
6f75e879b6 avfilter/vf_vpp_amf: Minor clean up.
-vf_vpp_amf.c: Remove unused variables.
-vf_amf_common.c: Fix hdrmeta_buffer memory leak.
-hwcontext_amf.c: Fix av_amf_extract_hdr_metadata not picking up light metadata if display mastering metadata is not set.
-doc/filters.texi: Remove irrelevant example with HDR metadata for vpp_amf.
2026-03-31 11:17:51 +00:00
Kacper Michajłow
7d57621b83 avutil/x86/x86util: tone down NASM workaround and use info section
The use of code section (.text) was forced by the unreleased NASM
3.02rc3 which made the issue worse, but preventing assambling anything
without code section, including when only data was present.

This works fine for the most part, but using code (.text) section with
IMAGE_COMDAT_SELECT_ANY causes issues with lib.exe after stripping such
object:
fatal error LNK1143: invalid or corrupt file: no symbol for COMDAT section 0x2

Esentially it makes our workaround not work in all cases, and while
string could be disabled like it already is for MSVC/ICL builds, it used
to work so let's preserve that state.

This make it not compatible with NASM 3.02rc3 when CV debug info is
generated, but hopefully the upstream fix will be merged before release,
to avoid this regression:
https://github.com/netwide-assembler/nasm/pull/221

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-03-30 19:46:53 +02:00
Kacper Michajłow
e54e117998 avutil/x86/x86util: define .text section additionally to COMDAT one
This is needed to cover the case when assembled source doesn't have
.text section. NASM documentation suggest to add $ suffix to section
name for COMDAT in .text, but this actually requires the main .text
section to exist also. And use less generic suffix for our dummy
sub-section.

Third time's the charm.

Fixes: 80cd067715
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-03-30 01:08:45 +02:00
Soham Kute
dc8183377c avutil/tests/file: replace trivial test with error-path coverage
The original test only mapped the source file and printed its content,
exercising none of the error branches in av_file_map().

Replace it with a test that maps a real file (path via argv[1] for
out-of-tree builds) and verifies it is non-empty, then calls
av_file_map() on a nonexistent file twice: once with log_offset=0 to
confirm the error is logged at AV_LOG_ERROR, and once with log_offset=1
to confirm the level is raised by one, covering the
log_level_offset_offset path in av_vlog().  A custom av_log callback
captures the emitted level independently of the global log level.
The two error cases share a single for() loop to avoid duplication.

Add a FATE entry in tests/fate/libavutil.mak with CMP=null since
there is no fixed stdout to compare.

Signed-off-by: Soham Kute <officialsohamkute@gmail.com>
2026-03-29 23:01:39 +00:00
Kacper Michajłow
80cd067715 avutil/x86util: don't produce empty object files on win{32,64}
In cases when preprocesor would remove all code, nasm would produce
empty object files. This is technically not wrong, but often cause
issues with various tooling:

* NASM fails to emit CodeView debug info when there is no code [1]
* Older VS2022 builds hangs on empty files [2]
* GNU binutils `strip` errors when there is no sections [3]
error: the input file '.o' has no sections

Workaround those issues by adding dummy byte in COMDAT section,
which is then dropped by linker, as the `__x86util_notref` symbol is not
referenced from C. [4] IMAGE_COMDAT_SELECT_ANY (2) is used to allow
multiple symbol definition.

This is limited to win{32,64} as this is the target where issues were
observed.

[1] https://github.com/netwide-assembler/nasm/issues/216
[2] https://developercommunity.visualstudio.com/t/MSVC-Hangs-when-compiling-ffmpeg-When-l/10233953
[3] https://trac.ffmpeg.org/ticket/6711
[4] https://www.nasm.us/docs/3.01/nasm09.html#section-9.6.1

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-03-29 23:00:06 +02:00
Andreas Rheinhardt
5c88f46c92 avutil/x86/aes: Only assemble iff HAVE_AESNI_EXTERNAL
This avoids relying on DCE and works around a NASM bug [1].

[1]: https://github.com/netwide-assembler/nasm/issues/216

Reviewed-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-28 23:25:54 +01:00
marcos ashton
5d70f0844c libavutil/stereo3d: fix prefix matching in *_from_name() functions
The three *_from_name() functions used av_strstart() for prefix matching,
which returns incorrect results when one name is a prefix of another.

av_stereo3d_from_name("side by side (quincunx subsampling)") matched
"side by side" at index 1 and returned AV_STEREO3D_SIDEBYSIDE instead of
AV_STEREO3D_SIDEBYSIDE_QUINCUNX. Similarly,
av_stereo3d_primary_eye_from_name("nonexistent") matched "none" and
returned AV_PRIMARY_EYE_NONE instead of -1.

Switch all three functions 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-03-25 01:32:20 +00:00
Kacper Michajłow
9c63742425 avutil/attributes: enable av_flatten when available
This enables av_flatten on Clang in particular.

It was disabled because at the time this attribute was not supported.
It was implemented in Clang/LLVM 3.5 [1].

Use `__has_attribute` to check for availability. This has been added in
Clang 2.9 [2].

This reverts change 5858a67f13.

[1] 41af7c2fdc
[2] 274a70ed7f

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-03-22 15:55:54 +00:00
marcos ashton
345071f747 tests/fate/libavutil: add FATE test for stereo3d
Add a unit test covering av_stereo3d_alloc, av_stereo3d_alloc_size,
av_stereo3d_create_side_data, av_stereo3d_type_name,
av_stereo3d_from_name, av_stereo3d_view_name,
av_stereo3d_view_from_name, and av_stereo3d_primary_eye_name.
The from_name calls are driven by a static name table so each
string appears exactly once. Round-trip inverse checks verify
that type_name/from_name and view_name/view_from_name are
consistent with each other.

Coverage for libavutil/stereo3d.c: 0.00% -> 100.00%

Signed-off-by: marcos ashton <marcosashiglesias@gmail.com>
2026-03-21 01:04:20 +00:00
marcos ashton
ed19c181c2 tests/fate/libavutil: add FATE test for film_grain_params
Add a unit test covering alloc, create_side_data, and select
for AV1 and H.274 film grain parameter types (22 cases).

Coverage for libavutil/film_grain_params.c: 0.00% -> 97.73%

Signed-off-by: marcos ashton <marcosashiglesias@gmail.com>
2026-03-21 01:04:20 +00:00
marcos ashton
dfa53aae5f avutil/bswap: fix implicit conversion warning in av_bswap64
Explicitly cast uint64_t arguments to uint32_t before passing them
to av_bswap32(). The truncation is intentional (extracting low and
high halves), but clang on macOS 26 warns about it.

Fixes: https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/22453
Signed-off-by: marcos ashton <marcosashiglesias@gmail.com>
2026-03-21 00:34:50 +00:00
Martin Storsjö
f72f692afa aarch64: Add PAC sign/validation of the link register
Whenever the link register is stored on the stack, sign it
before storing it and validate at a symmetrical point (with the
stack at the same level as when it was signed).

These macros only have an effect if built with PAC enabled (e.g.
through -mbranch-protection=standard), otherwise they don't
generate any extra instructions.

None of these cases were present when PAC support was added
in 248986a0db in 2022.

Without these changes, PAC still had an effect in the compiler
generated code and in the existing cases where we these macros were
used - but make it apply to the remaining cases of link register
on the stack.
2026-03-20 13:16:06 +02:00
Martin Storsjö
846746be4b aarch64: Add Armv9.3-A GCS (Guarded Control Stack) support
Signal that our assembly is compliant with the GCS feature, if
the GCS feature is enabled in the compiler (available since Clang
18 and GCC 15) - this is enabled by -mbranch-protection=standard
with a new enough compiler.

GCS doesn't require any specific modifications to the assembly
code, but requires that all functions return to the expected call
address (checked through a shadow stack).
2026-03-17 20:37:53 +00:00
Marvin Scholz
cce545a74b avutil: attributes: fix AV_HAS_STD_ATTRIBUTE checks
Attributes with the language-supported [[attr]] style are only supported
since C++11 and C23 respectively, so this needs to be accounted for in
these checks.

This solves a huge amount of warning spam of:
  warning: [[]] attributes are a C23 extension [-Wc23-extensions]
when using --enable-extra-warnings.
2026-03-16 18:32:20 +01:00
Lynne
c102e89448 hwcontext_vulkan: deprecate AVVulkanDeviceContext.lock/unlock_queue
Without replacement, as VK_KHR_internally_synchronized_queues will be required.
2026-03-14 17:05:06 +00:00
Michael Niedermayer
eb5d607861 avutil/timecode: Check for integer overflow in av_timecode_init_from_components()
Fixes: integer overflow
Fixes: testcase that calls av_timecode_init_from_components() with hh set explicitly to INT_MAX

Found-by: Youngjae Choi, Mingyoung Ban, Seunghoon Woo
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-13 22:48:32 +01:00
James Almer
927c81b569 avutil/version: bump after recent additions
Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-12 17:18:00 -03:00
Andreas Rheinhardt
9bbe1ec86f avutil/opt: Remove obsolete LIBAVUTIL_VERSION_MAJOR checks
Removing them has been forgotten during the lavu 59->60 bump.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-12 18:26:42 +01:00
Kacper Michajłow
5074d9f06e hwcontext_amf: fix version variable type and remove cast
Fixes compilation errors on newer Clang/GCC that errors out on
incompatible pointers.

error: incompatible pointer types passing 'unsigned long long *' to
parameter of type 'amf_uint64 *' (aka 'unsigned long *')
[-Wincompatible-pointer-types]

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-03-11 18:41:10 +00:00
Shreesh Adiga
5085432f8b avutil/crc: add aarch64 NEON PMULL+EOR3 SIMD implementation for av_crc
Implemented clmul algorithm for aarch64 using PMULL and EOR3 instructions.
The logic and structure is same as x86 clmul implementation with
slight rearrangement of constants as per PMULL and PMULL2 instructions.

Benchmarking in Android (Termux) on a MediaTek Dimensity 9400 SoC:

./tests/checkasm/checkasm --test=crc --bench --runs=12
benchmarking with native FFmpeg timers
nop: 0.2
checkasm: SVE 128 bits, using random seed 2502847808
checkasm: bench runs 4096 (1 << 12)
CRC:
 - crc.crc [OK]
PMULL:
 - crc.crc [OK]
checkasm: all 10 tests passed
crc_8_ATM_c:                                            26.0 ( 1.00x)
crc_8_ATM_pmull_eor3:                                    0.7 (37.17x)
crc_8_EBU_c:                                            46.4 ( 1.00x)
crc_8_EBU_pmull_eor3:                                    1.5 (31.47x)
crc_16_ANSI_c:                                          36.3 ( 1.00x)
crc_16_ANSI_pmull_eor3:                                  1.1 (31.70x)
crc_16_ANSI_LE_c:                                       90.9 ( 1.00x)
crc_16_ANSI_LE_pmull_eor3:                               2.8 (32.30x)
crc_16_CCITT_c:                                        118.0 ( 1.00x)
crc_16_CCITT_pmull_eor3:                                 3.7 (32.00x)
crc_24_IEEE_c:                                           1.6 ( 1.00x)
crc_24_IEEE_pmull_eor3:                                  0.1 (12.19x)
crc_32_IEEE_c:                                          45.2 ( 1.00x)
crc_32_IEEE_pmull_eor3:                                  1.4 (31.39x)
crc_32_IEEE_LE_c:                                       49.1 ( 1.00x)
crc_32_IEEE_LE_crc:                                      2.5 (19.51x)
crc_32_IEEE_LE_pmull_eor3:                               1.5 (32.84x)
crc_custom_polynomial_c:                                45.3 ( 1.00x)
crc_custom_polynomial_pmull_eor3:                        1.3 (35.16x)
2026-03-11 14:03:36 +00:00
Shreesh Adiga
952e588600 avutil/crc: refactor helper functions to separate header file
Move the reverse and xnmodp functions to a separate header
so that it can be reused for aarch64 implementation of av_crc.
2026-03-11 14:03:36 +00:00
Shreesh Adiga
b19bd0de6c avutil/cpu: add aarch64 CPU feature flag for PMULL and EOR3 2026-03-11 14:03:36 +00:00
Dmitrii Gershenkop
910000fe59 avfilter/vf_vpp_amf: Extend AMF Color Converter HDR capabilities 2026-03-11 10:23:35 +01:00
Andreas Rheinhardt
999c04db35 avutil/channel_layout: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:18 +01:00
Andreas Rheinhardt
3fbe80d17e avutil/aes: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:18 +01:00
Andreas Rheinhardt
df7b8cae7b avutil/slicethread: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-10 13:52:18 +01:00
Andreas Rheinhardt
1a9c345ee8 avutil/mips: Add msa optimizations for pixelutils
Adapted from the corresponding me_cmp code. Only the width 16 function
has been adapted, because it seems that the width 8 function actually
reads 16 bytes per line.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-09 10:17:26 +01:00
Andreas Rheinhardt
471db1d323 avutil/arm: Add armv6 optimizations for pixelutils
Adapted from the corresponding me_cmp code.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-09 10:17:26 +01:00
Andreas Rheinhardt
9b84b8682f avutil/riscv: Add rvv optimizations for pixelutils
Adapted from the corresponding me_cmp code.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-09 10:17:26 +01:00
Andreas Rheinhardt
022c42649c avutil/aarch64: Add neon optimizations for pixelutils
Adapted from the corresponding me_cmp code.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-09 10:17:26 +01:00
Andreas Rheinhardt
e114c63234 avutil/x86/pixelutils: Avoid near-empty header
lavu/x86/pixelutils.h only declares exactly one function,
namely the arch-specific init function. Such declarations
are usually contained in the ordinary header providing
the generic init function, yet the latter is public in this case.

Given that said function is called from exactly one callsite,
the header can be made more useful by moving the actual x86-init
function to it (as a static inline function) and removing
pixelutils_init.c.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-09 10:17:26 +01:00
Andreas Rheinhardt
085f06a13f avutil/pixelutils: Don't unconditionally include arch-specific header
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-09 10:17:26 +01:00