Commit Graph

6217 Commits

Author SHA1 Message Date
Marton Balint 32cb4504f3 avutil/imgutils: fix av_image_fill_black() for some pixel formats
- Fixes YA formats, because previous code always assumed alpha as the 4th
  component.
- Fixes PAL format (as long as 0 is black, as in a systematic palette), because
  previous code assumed it as limited Y.
- Fixes XYZ format because it does not need nonzero chroma components
- Fixes xv30be as the bitstream mode got merged to the non-bitstream mode.

Signed-off-by: Marton Balint <cus@passwd.hu>
2023-12-13 18:51:32 +01:00
Marton Balint 1f721beeff avutil/tests/imgutils: add tests for av_image_fill_black()
Signed-off-by: Marton Balint <cus@passwd.hu>
2023-12-13 18:51:32 +01:00
Marton Balint 3c5e82316e avutil/tests/imgutils: factorize basic tests to new function
Signed-off-by: Marton Balint <cus@passwd.hu>
2023-12-13 18:51:32 +01:00
Benjamin Cheng 185871fdd3 hwcontext_vulkan: guard unistd.h include
win32 typically doesn't have unistd.h, so always including it will break
MSVC builds. The usage of those POSIX functions are already guarded by
_WIN32, so use that to guard unistd.h include as well.
2023-12-11 16:36:56 +01:00
Haihao Xiang f89cff96d0 lavu/hwcontext_qsv: Make sure hardware vendor is Intel for qsv on d3d11va
When multiple hardwares are available, the default one might not be
Intel Hardware. We can use option vendor_id to choose the required
vendor.

Tested-by: Artem Galin <artem.galin@intel.com>
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2023-12-07 10:32:16 +08:00
Artem Galin a556be69a7 lavu/hwcontext_d3d11va: Add option vendor_id
User may choose the hardware via option vendor_id when multiple
hardwares are available.

Signed-off-by: Artem Galin <artem.galin@intel.com>
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2023-12-07 10:32:16 +08:00
Haihao Xiang 05debdaa5f lavu/hwcontext_qsv: use mfxImplDescription instead of mfxExtendedDeviceId on Linux
mfxExtendedDeviceId mightn't be supported in certain configurations of
oneVPL on Linux, so we can't ensure a property filter for
mfxExtendedDeviceId.DeviceID or mfxExtendedDeviceId.VendorID works as
expected. This fixed the issue mentioned in [1]

[1] http://ffmpeg.org/pipermail/ffmpeg-user/2023-October/056983.html

Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2023-12-05 10:11:19 +08:00
Haihao Xiang d36d9994e4 lavu/hwcontext_vaapi: ignore nonexistent device in default DRM device selection
It is possible that renderD128 doesn't exist but renderD129 is
available in a system (see [1]). This change can make sure the default
DRM device selection works even if renderD128 doesn't exist.

[1] https://github.com/intel/intel-device-plugins-for-kubernetes/blob/main/cmd/gpu_plugin/README.md#issues-with-media-workloads-on-multi-gpu-setups

Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2023-12-05 10:09:55 +08:00
Rémi Denis-Courmont e33ce0d9dd lavu/fixed_dsp: R-V V fmul_window_scaled
vector_fmul_window_scaled_fixed_c:       4393.7
vector_fmul_window_scaled_fixed_rvv_i64: 1642.7
2023-11-23 18:57:18 +02:00
Rémi Denis-Courmont e49f41fb27 lavu/float_dsp: optimise R-V V fmul_reverse & fmul_window
Roll the loop to avoid slow gathers.

Before:
vector_fmul_reverse_c:       1561.7
vector_fmul_reverse_rvv_f32: 2410.2
vector_fmul_window_c:        2068.2
vector_fmul_window_rvv_f32:  1879.5

After:
vector_fmul_reverse_c:       1561.7
vector_fmul_reverse_rvv_f32:  916.2
vector_fmul_window_c:        2068.2
vector_fmul_window_rvv_f32:  1202.5
2023-11-23 18:57:18 +02:00
Rémi Denis-Courmont 3a134e8299 lavu/fixed_dsp: optimise R-V V fmul_reverse
Gathers are (unsurprisingly) a notable exception to the rule that R-V V
gets faster with larger group multipliers. So roll the function to speed
it up.

Before:
vector_fmul_reverse_fixed_c:       2840.7
vector_fmul_reverse_fixed_rvv_i32: 2430.2

After:
vector_fmul_reverse_fixed_c:       2841.0
vector_fmul_reverse_fixed_rvv_i32:  962.2

It might be possible to further optimise the function by moving the
reverse-subtract out of the loop and adding ad-hoc tail handling.
2023-11-23 18:57:18 +02:00
Rémi Denis-Courmont cd6089dc9c riscv: fix builds without Zbb support 2023-11-18 22:01:59 +02:00
Diederik de Haas via ffmpeg-devel c07ed10b0e apply spelling fixes
Fix spelling issue as reported by Debian's lintian tool:
accomodate -> accommodate
addtional -> additional
auxillary -> auxiliary
bellow -> below
betweeen -> between
Calulate -> Calculate
coefficents -> coefficients
Defalt -> Default
defaul -> default
higer -> higher
neccesary -> necessary
orignal -> original
ouput -> output
precison -> precision
processsing -> processing
substract -> subtract
Transfered -> Transferred
upto -> up to

Also add several of them to the 'common typos' check in patcheck.

Signed-off-by: Diederik de Haas <didi.debian@cknow.org>
2023-11-18 19:55:42 +01:00
Anton Khirnov acf63d5350 lavu/log: do not assume AVClass.item_name is always set 2023-11-09 11:25:17 +01:00
Víctor Manuel Jáquez Leal 854012ec59 avutil/hwcontext_vulkan: get VkFormatFeatureFlagBits2
Rather than the VkFormatFeatureFlagBits enum

Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
2023-11-09 09:13:47 +01:00
Zhao Zhili 6f39dee974 avutil/hwcontext_vulkan: fix run on macOS
VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME is required on macOS,
and VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR flag should
be set.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-11-09 19:23:01 +08:00
James Almer b82957a66a avutil: bump minor version after recent commits
Signed-off-by: James Almer <jamrial@gmail.com>
2023-11-08 10:13:50 -03:00
James Almer 04e53927ad avutil/channel_layout: add a 9.1.4 channel layout
Mapping to ITU-R BS.2051-3 "Sound System G" and ITU-R BS.1196-8 "Channel
Configuration 20".

Signed-off-by: James Almer <jamrial@gmail.com>
2023-11-08 10:09:46 -03:00
James Almer b4169760b0 avutil/channel_layout: add a 7.2.3 channel layout
Mapping to ITU-R BS.2051-3 "Sound System F" and ITU-R BS.1196-8 "Channel
Configuration 15".

Signed-off-by: James Almer <jamrial@gmail.com>
2023-11-08 10:09:46 -03:00
Henrik Gramner ed8ddf0bd3 x86inc: Add REPX macro to repeat instructions/operations
When operating on large blocks of data it's common to repeatedly use
an instruction on multiple registers. Using the REPX macro makes it
easy to quickly write dense code to achieve this without having to
explicitly duplicate the same instruction over and over.

For example,

    REPX {paddw x, m4}, m0, m1, m2, m3
    REPX {mova [r0+16*x], m5}, 0, 1, 2, 3

will expand to

    paddw       m0, m4
    paddw       m1, m4
    paddw       m2, m4
    paddw       m3, m4
    mova [r0+16*0], m5
    mova [r0+16*1], m5
    mova [r0+16*2], m5
    mova [r0+16*3], m5

Commit taken from x264:
6d10612ab0

Signed-off-by: Frank Plowman <post@frankplowman.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2023-11-08 13:49:08 +01:00
Andreas Rheinhardt 5b85ca5317 avutil/x86/pixelutils: Empty MMX state in ff_pixelutils_sad_8x8_mmxext
We currently mostly do not empty the MMX state in our MMX
DSP functions; instead we only do so before code that might
be using x87 code. This is a violation of the System V i386 ABI
(and maybe of other ABIs, too):
"The CPU shall be in x87 mode upon entry to a function. Therefore,
every function that uses the MMX registers is required to issue an
emms or femms instruction after using MMX registers, before returning
or calling another function." (See 2.2.1 in [1])
This patch does not intend to change all these functions to abide
by the ABI; it only does so for ff_pixelutils_sad_8x8_mmxext, as this
function can by called by external users, because it is exported
via the pixelutils API. Without this, the following fragment will
assert (on x86/x64):
    uint8_t src1[8 * 8], src2[8 * 8];
    av_pixelutils_sad_fn fn = av_pixelutils_get_sad_fn(3, 3, 0, NULL);
    fn(src1, 8, src2, 8);
    av_assert0_fpu();

[1]: https://raw.githubusercontent.com/wiki/hjl-tools/x86-psABI/intel386-psABI-1.1.pdf

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-11-04 01:26:03 +01:00
Reimar Döffinger 9dd49c8b52 libavutil/log.c: only include valgrind header when used.
This is cleaner, but it is also a workaround for when
the header exists, but cannot be compiled.
This will happen when the compiler has no inline asm
support.
Possibly the configure check should be improved as well.
2023-11-02 21:03:43 +01:00
Reimar Döffinger 0ea184fc39 libavutil/aarch64/cpu.c: HWCAPS requires inline asm support.
Fixes compilation with tcc, which does not have aarch64
inline asm support.
2023-11-02 21:03:43 +01:00
Niklas Haas 93f07d98d9 avutil/pixdesc: simplify xyz pixfmt check 2023-10-31 15:46:38 +01:00
Niklas Haas 57c16323f2 avutil/pixdesc: add AV_PIX_FMT_FLAG_XYZ
There are already several places in the codebase that match desc->name
against "xyz", and many downstream clients replicate this behavior.
I have no idea why this is not just a flag.

Motivated by my desire to add yet another check for XYZ to the codebase,
and I'd rather not keep copy/pasting a string comparison hack.
2023-10-31 15:46:07 +01:00
Martin Storsjö f05948ada4 aarch64: Simplify the linux runtime cpu detection code
Skip doing the whole getauxval(AT_HWCAP) if HWCAP_CPUID isn't
defined.

Signed-off-by: Martin Storsjö <martin@martin.st>
2023-10-31 12:23:27 +02:00
James Almer 4cba3e0f07 avutil/video_enc_params: fix doxy for av_video_enc_params_block()
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: James Almer <jamrial@gmail.com>
2023-10-30 10:30:05 -03:00
Rémi Denis-Courmont 04b49fb3c5 lavu/riscv: fix typo 2023-10-29 22:15:15 +02:00
Michael Niedermayer 47e784f881
Bump versions after 6.1
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-29 16:19:14 +01:00
Michael Niedermayer 9d3a7d30c4
Bump versions prior to 6.1
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-29 15:34:05 +01:00
Zhao Zhili 105657540b avutil/hwcontext_vaapi: return ENOSYS for unsupported operation
av_hwframe_transfer_data try with src_ctx first. If the operation
failed with AVERROR(ENOSYS), it will try again with dst_ctx. Return
AVERROR(EINVAL) makes the second step being skipped.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-10-29 13:58:52 +08:00
Zhao Zhili 63078b4599 avutil/hwcontext_vulkan: cuda doesn't belong to valid_sw_formats
Move it to transfer_get_formats.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-10-29 13:58:30 +08:00
Zhao Zhili 891f70c6d5 avutil/hwcontext_vulkan: fix memleak when device_create is skipped
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-10-29 13:57:43 +08:00
Lynne 1a8e766984
vulkan: return VK_NOT_READY when no queries are available
Fixes a validation issue.
The issue is that the function gets called before we've sumitted a frame
for decoding to that context. However, we cannot run queries before
they've been reset, which happens at submission time.
As we'd need to otherwise run a command queue at init-time, just check
if submissions have happened.
2023-10-28 21:16:15 +02:00
James Almer 1ad7bd0fe5 avutil/channel_layout: simplify 22.2 layout bitmask define
Signed-off-by: James Almer <jamrial@gmail.com>
2023-10-28 12:49:48 -03:00
Michael Niedermayer 907743239d
avutil/tx_template: fix integer ovberflwo in fft3()
Fixes: signed integer overflow: -1028966111 + -1314089526 cannot be represented in type 'int'
Fixes: 63174/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AAC_FIXED_fuzzer-5853273711837184

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-27 18:10:47 +02:00
James Almer 52a9764260 avutil: bump minor version after recent commits
Signed-off-by: James Almer <jamrial@gmail.com>
2023-10-27 08:52:35 -03:00
James Almer 35b06853d1 avutil/channel_layout: add a 3.1.2 channel layout
Signed-off-by: James Almer <jamrial@gmail.com>
2023-10-27 08:46:34 -03:00
Will Wolcott e9397ae054 avutil/channel_layout: add a 7.1.4 channel layout
Mapping to ITU-R BS.2051-3 "Sound System J" and ITU-R BS.1196-8 "Channel
Configuration 19".

Signed-off-by: Will Wolcott <wwolcott@netflix.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2023-10-27 08:46:34 -03:00
James Almer a41c4b923d avutil/channel_layout: add a 7.1.2 channel layout
Signed-off-by: James Almer <jamrial@gmail.com>
2023-10-27 08:46:34 -03:00
James Almer 8d46cbce4f avutil/channel_layout: add a 5.1.4 channel layout
Mapping to ITU-R BS.2051-3 "Sound System D" and ITU-R BS.1196-8 "Channel
Configuration 16".

Signed-off-by: James Almer <jamrial@gmail.com>
2023-10-27 08:46:34 -03:00
James Almer 4b8404815d avutil/channel_layout: rename 7.1(top) channel layout to 5.1.2
This layout maps to ITU-R BS.2051-3 "Sound System C" and ITU-R BS.1196-8 "Channel
Configuration 14", and it being the first layout with top layer channels, it's
best to use a different scheme to properly convey the presence and amount of said
channels.
The new name will also be a better fit for the additions in the following commits.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-10-27 08:46:34 -03:00
Martin Storsjö a4877f1ec1 aarch64: Only enable extensions in the intended files/regions
This eases actual development of the assembly functions, by only
allowing extension instructions within the sections that explicitly
enable them, instead of having all extensions enabled everywhere.

Signed-off-by: Martin Storsjö <martin@martin.st>
2023-10-24 14:46:20 +03:00
Martin Storsjö 0679e85331 aarch64: Stop using asm/hwcap.h for the HWCAP_* detection
Including sys/auxv.h should be enough (it pulls in bits/hwcap.h,
which provides the same defines).

Signed-off-by: Martin Storsjö <martin@martin.st>
2023-10-24 14:46:14 +03:00
Lynne c258623c0a
hwcontext_vulkan: improve queue family init code
When users zero-init'd the struct, or left it as-is, the encode
queue family matched the graphics queue family, which led it to be
incorrectly logged as being used for encode.

This just improves the logging so this isn't printed anymore.
2023-10-24 06:07:09 +02:00
Martin Storsjö cada4597ca aarch64: Manually tweak vertical alignment/indentation in tx_float_neon.S
Favour left aligned columns over right aligned columns.

In principle either style should be ok, but some of the cases
easily lead to incorrect indentation in the surrounding code (see
a couple of cases fixed up in the preceding patch), and show up in
automatic indentation correction attempts.

Signed-off-by: Martin Storsjö <martin@martin.st>
2023-10-21 23:25:39 +03:00
Martin Storsjö 7f905f3672 aarch64: Make the indentation more consistent
Some functions have slightly different indentation styles; try
to match the surrounding code.

libavcodec/aarch64/vc1dsp_neon.S is skipped here, as it intentionally
uses a layered indentation style to visually show how different
unrolled/interleaved phases fit together.

Signed-off-by: Martin Storsjö <martin@martin.st>
2023-10-21 23:25:29 +03:00
Martin Storsjö 184103b310 aarch64: Consistently use lowercase for vector element specifiers
Signed-off-by: Martin Storsjö <martin@martin.st>
2023-10-21 23:25:18 +03:00
Sean McGovern d799ad2404
libavutil/ppc/cpu.c: check that AT_HWCAP2 is defined
It was not introduced until glibc 2.18.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-19 20:46:55 +02:00
Rémi Denis-Courmont f39a8790e1 lavu/fixed_dsp: R-V V vector_fmul_window 2023-10-09 19:52:28 +03:00
Rémi Denis-Courmont 10eb3b9c9f lavu/fixed_dsp: R-V V vector_fmul
vector_fmul_fixed_c: 4.0
vector_fmul_fixed_rvv_i64: 0.5
2023-10-09 19:52:28 +03:00
Rémi Denis-Courmont da7a77fb0a lavu/fixed_dsp: R-V V vector_fmul_reverse 2023-10-09 19:52:28 +03:00
Rémi Denis-Courmont bf911cc1bf lavu/fixed_dsp: R-V V vector_fmul_add
vector_fmul_add_fixed_c: 2.2
vector_fmul_add_fixed_rvv_i64: 0.5
2023-10-09 19:52:28 +03:00
Rémi Denis-Courmont 9091ffb006 lavu/float_dsp: adjust multipler in R-V V fmul_window
The gather index vector is only used as double-length (due to register
pressure), so no need to initialise it for quad-length. Basically this
matches the multiplier in the prologue to the the multipler in the loop.
2023-10-09 19:52:28 +03:00
Rémi Denis-Courmont eb73d178ea lavu/fixed_dsp: R-V V scalarproduct 2023-10-07 17:45:39 +03:00
Lynne 81cc0e1345
hwcontext_vulkan: properly support STORAGE usage for mutliplane images
Fixes multiplane support on Nvidia.

Also, remove the ENCODE usage, even if the driver signals it as supported.
Currently, it's not used, and when it is used, it'll be gated behind
two extension checks.
2023-10-05 23:50:30 +02:00
Rémi Denis-Courmont 9240035c0e lavu/float_dsp: avoid reg-stride in R-V V fmul_window 2023-10-03 22:48:10 +03:00
Michael Niedermayer c42a89309a
avutil/tx_template: Fix some signed integer overflows in DECL_FFT5()
Fixes: signed integer overflow: -1364715454 + -1468954671 cannot be represented in type 'int'
Fixes: 62093/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AAC_FIXED_fuzzer-5538774254485504

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-03 20:09:27 +02:00
Rémi Denis-Courmont 446b0090cb lavu/float_dsp: avoid reg-stride in R-V V reverse_fmul
This revectors the inner loop to reverse vectors element in vectors,
thus eliminating the negative register stride. Note that RVV does not
have a vector reverse instruction, so this uses a gather.
2023-10-03 20:48:47 +03:00
Rémi Denis-Courmont cec48e3b32 riscv: factor out the bswap32 assembler 2023-10-02 22:28:21 +03:00
Roman Arzumanyan f904e60c32 libavutil/hwcontext_cuda: don't destroy external context when using current CUDA context
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2023-09-29 19:42:11 +02:00
Paul B Mahol 8e1ef7c38f avutil: add GBRAP14 format support 2023-09-28 19:36:08 +02:00
Roman Arzumanyan 05f8b2ca0f avutil/hwcontext_cuda: add option to use current device context
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2023-09-28 19:23:51 +02:00
Rémi Denis-Courmont 7a24d794f6 Revert "lavu/timer: remove gratuitous volatile"
It does not make much sense to me, but GCC somehow optimises the
inline assembler even though the output is very obviously used and
having observable side effects.

This reverts commit 09731fbfc3.
2023-09-28 17:48:18 +03:00
Zhao Zhili ba9cd06c76 avutil/avutil: make AV_TIME_BASE_Q available in C++
ISO C++ forbids compound-literals. It's not available with MSVC.
This is a known issue from 10 years ago, and that's why there is a
av_get_time_base_q().

Since we have no plan to remove AV_TIME_BASE_Q, just make it
available in C++.

There are multiple choices:
1. Use C++11 syntax: AVRational{1, AV_TIME_BASE}

Users may still use C++98 to write new code. So no.

2. Use av_get_time_base_q().

It's for this purpose. But it's not compile time constants as
AV_TIME_BASE_Q in C.

So I choose av_make_q() as Anton's suggestion.

https://libav-devel.libav.narkive.com/ZQCWfTun/patch-0-2-fix-avutil-h-usage-from-c
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-09-19 00:52:21 +08:00
Andreas Rheinhardt dfac782b13 avutil/hwcontext_vulkan: Cosmetics
The alignment in vulkan_unmap_from_drm() (formerly the clone
of vulkan_frame_free()) is nicer than the in vulkan_frame_free(),
let's preserve it.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-15 02:38:14 +02:00
Andreas Rheinhardt 677635cd04 avutil/hwcontext_vulkan: Deduplicate code
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-15 02:38:05 +02:00
Andreas Rheinhardt 47b1c0d0db avutil/hwcontext_vulkan: Improve type-safety
The AVBuffer API uses uint8_t as base type for buffers
and therefore its free callbacks need to abide by this.
Therefore vulkan_frame_free() used an inappropriate signature
which caused casts whenever this function has been called
manually.

This commit changes this by making vulkan_frame_free()
use the proper type and a vulkan_frame_free_cb() that
is used as free callback for the AVBuffer API.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-15 02:37:56 +02:00
Andreas Rheinhardt a6bd2ee759 avutil/hwcontext_vulkan: Remove redundant resetting
vulkan_free_internal() already resets the AVVkFrame.internal
pointer.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-15 02:37:36 +02:00
Andreas Rheinhardt c1714a483f avcodec/libaribb24,ttmlenc, avutil/tx: Remove redundant init of AVBPrint
An AVBPrint is initialized via av_bprint_init() (or
av_bprint_init_for_buffer()) which expects uninitialized
AVBPrints; it is therefore not necessary to zero them before
the actual initialization.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-14 12:32:02 +02:00
Andreas Rheinhardt 423b6a7e49 avutil/imgutils: Add wrapper for av_image_copy() to avoid casts
av_image_copy() accepts const uint8_t* const * as source;
lots of user have uint8_t* const * and therefore either
cast (the majority) or copy the array of pointers.

This commit changes this by adding a static inline wrapper
for av_image_copy() that casts between the two types
so that we do not need to add casts everywhere else.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-12 09:42:27 +02:00
Andreas Rheinhardt 5094d1f429 avutil/fifo: Constify AVFifo pointees in peek functions
They do not modify the AVFifo state.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-12 09:20:49 +02:00
Andreas Rheinhardt fa4bf5793a avutil/audio_fifo: Constify some pointees
Also constify AVAudioFifo* in the peek functions
besides constifying intermediate pointers (void**->void * const *).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-12 09:20:13 +02:00
Andreas Rheinhardt 9bf31f6096 avutil/samplefmt: Constify some pointees
This is the samplefmt analog of the imgutils changes
from the preceding commit.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-12 09:17:28 +02:00
Andreas Rheinhardt 41285890e0 avutil/imgutils: Constify some pointees
This is done immediately without waiting for the next major bump
just as in 9546b3a1cb and
4eaaa38d3d.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-12 09:14:25 +02:00
Andreas Rheinhardt cfa47fd331 all: Use av_frame_replace() where appropriate
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-10 21:22:30 +02:00
Lynne 00e77fd21a
lavu/tx: add missing prints for the type of dctI/dstI 2023-09-08 06:56:39 +02:00
Andreas Rheinhardt 8ba7deb6c0 avutil/avstring: Remove obsolete version.h inclusion
Forgotten in 30e1e7e0f3.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-07 00:48:50 +02:00
Andreas Rheinhardt e3b355c0be avutil/mem: Don't include avutil.h
It is not necessary at all. So remove it.
This also breaks an inclusion cycle mem.h->avutil.h->common.h->mem.h.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-07 00:42:10 +02:00
Andreas Rheinhardt c3e3ea3c88 avutil: Move error.h from avutil.h to common.h
Up until now, avutil.h includes common.h which includes mem.h which
includes avutil.h, so that all these headers are in fact equivalent.
Yet mem.h does not need to include avutil.h at all and when it no longer
does, including common.h will no longer include error.h (included by
avutil.h) as well; change this by moving error.h to avutil.h, as error.h
is clearly a commonly used header.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-07 00:41:47 +02:00
Stefano Sabatini 362ebf246c lavu/avstring: fix typo in av_strireplace function doxy 2023-09-06 01:12:56 +02:00
Andreas Rheinhardt f8503b4c33 avutil/internal: Don't auto-include emms.h
Instead include emms.h wherever it is needed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-04 11:04:45 +02:00
Nuo Mi 25ecc94d58
avutil: add thread executor
The executor design pattern was introduced by java
<https://docs.oracle.com/en/java/javase/20/docs/api/java.base/java/util/concurrent/Executor.html>
it also adapted by python
<https://docs.python.org/3/library/concurrent.futures.html>
Compared to handcrafted thread pool management, it greatly simplifies the thread code.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-09-02 02:49:06 +02:00
Lynne d40672e661
lavu/tx: fix scaling of R2R transforms
Still slightly inaccurate, but it's good enough now.
2023-09-01 23:59:13 +02:00
Lynne 59b39d241e
lavu/tx: improve rdft table generation precision slightly 2023-09-01 23:59:13 +02:00
Lynne ef8fd7bc3c
lavu/tx: add DCT-I and DST-I transforms
These are true, actual DCT-I and DST-I transforms, unlike the
libavcodec versions, which are plainly not.
2023-09-01 23:59:10 +02:00
Lynne 11e22730e1
lavu/tx: add real to real and real to imaginary RDFT transforms
These are in-place transforms, required for DCT-I and DST-I.

Templated as the mod2 variant requires minor modifications, and is
required specifically for DCT-I/DST-I.
2023-09-01 23:59:08 +02:00
Lynne d0a64f9a81
vulkan: do not leak bound_buffer_indices 2023-08-28 22:29:36 +02:00
Lynne f6cf3a40e4
vulkan: check for extension rather than function pointer
The loader ensures only that functions with tagged supported extensions
exist, rather than ensuring only those with supported extensions are
loaded.
As the init function uses Vulkan functions, whose loading requires them
to have the extension flags set, the extension flags are guaranteed
to also exist at this point.
2023-08-28 22:29:33 +02:00
Lynne 747871a42c
vulkan: do not leak cooperative matrix properties 2023-08-28 22:29:29 +02:00
Lynne 358919506d
vulkan: enable VK_KHR_cooperative_matrix
It's of interest to API users, and of interest to us,
as a DCT/DST can be implemented via matrix multiplies.
2023-08-26 23:14:53 +02:00
Rémi Denis-Courmont 6f8ac298da lavu/timer: specify RISC-V time unit 2023-08-24 20:58:57 +03:00
Rémi Denis-Courmont 09731fbfc3 lavu/timer: remove gratuitous volatile
AV_READ_TIME has no side effects. It does not need to be volatile.
2023-08-24 20:58:57 +03:00
Rémi Denis-Courmont 05115a77e0 lavu/timer: use time for AV_READ_TIME on RISC-V
So far, AV_READ_TIME would return the cycle counter. This posed two
problems:
1) On recent systems, it would just raise an illegal instruction
   exception. Indeed RDCYCLE is blocked in user space to ward off some
   side channel attacks. In particular, this would cause the random
   number generator to crash.
2) It does not match the x86 behaviour and the apparent original intent
   of AV_READ_TIME in the functional code base (outside test cases).

So this replaces the cycle counter with the time counter. The unit is
a platform-dependent constant fraction of time, and the value should be
stable across harts (RISC-V lingo for physical CPU thread).
2023-08-24 20:58:57 +03:00
Chris Spencer f0b1cab538 hwcontext_vulkan: always use create_pnext in vulkan_pool_alloc
Currently, create_pnext is only used if an applicable external memory
extension is enabled. This will usually the case when used from the command
line, but may not be when the Vulkan context is created manually.

For images used in video decoding, create_pnext contains the video profile
list, which is mandatory.[1] This fixes a GPU crash when using RADV.

[1] https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkImageCreateInfo.html#VUID-VkImageCreateInfo-usage-04815

Signed-off-by: Chris Spencer <spencercw@gmail.com>
2023-08-20 22:47:09 +02:00
James Almer 8c789c5da3 avutil/thread: add wrappers for pthread_cond_t functions
This abstraction is similar to the existing one for pthread_mutex_t and
pthread_once_t functions, and should reduce the amount of ifdeffery used
in future code.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-08-19 10:03:07 -03:00
Zhao Zhili ff094f5ebb avutil/channel_layout: make pre-defined channel layouts C++ friendly
C++ doesn't support designated initializers until C++20. We have
a bunch of pre-defined channel layouts, the gains to make them
usable in C++ exceed the losses.

Bump minor version so C++ project can check before use these defines.

Also initialize .opaque field explicitly to reduce warning in C++.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-08-18 08:27:24 -03:00
David Rosca 2ec58055f5 lavu/hwcontext_vaapi: Add vaapi_drm_format_map support for x2rgb10
Support for allocating frames with x2rgb10 format was added
in c00264f501, this adds support for importing DMA-BUFs.
2023-08-17 12:06:09 +08:00
L. E. Segovia ddc1cd5cdd configure: Set WIN32_LEAN_AND_MEAN at configure time
Including winsock2.h or windows.h without WIN32_LEAN_AND_MEAN cause
bzlib.h to parse as nonsense, due to an instance of #define char small
in rpcndr.h.

See:

https://stackoverflow.com/a/27794577

Signed-off-by: L. E. Segovia <amy@amyspark.me>
Signed-off-by: Martin Storsjö <martin@martin.st>
2023-08-14 22:57:28 +03:00
Andreas Rheinhardt 3fc8041b56 avutil/tests/channel_layout: Test av_channel_layout_copy()
Specifically, test copying a channel layout with custom order,
so that the allocation codepath of av_channel_layout_copy()
is executed.

Reviewed-by: Nicolas George <george@nsup.org>
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-08-10 09:10:47 +02:00
Andreas Rheinhardt bdc4553a77 avutil/tests/channel_layout: Don't include lavu/channel_layout.c
This test does not need access to the internals of said compilation
unit.

Reviewed-by: Nicolas George <george@nsup.org>
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-08-10 09:10:41 +02:00
Andreas Rheinhardt fcaff9b495 avutil/tests/channel_layout: Also test non-AVBPrint variants
Reviewed-by: Nicolas George <george@nsup.org>
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-08-10 09:10:35 +02:00
Andreas Rheinhardt c4f35ba808 avutil/channel_layout: Account for \0 in sizes
av_channel_name(), av_channel_description() and
av_channel_layout_describe() are supposed to return the size
of the needed buffer to allow the user to check for truncation;
the documentation ("If the returned value is bigger than buf_size,
then the string was truncated.") confirms that size does not
mean strlen.

Yet the AVBPrint API, i.e. AVBPrint.len, does not account for
the terminating '\0'. Therefore the returned length is off by one.

Furthermore, also check for whether the returned value actually
fits in an int (which is the return value of these functions).

Reviewed-by: Nicolas George <george@nsup.org>
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-08-10 08:55:05 +02:00
Andreas Rheinhardt 8bea4a83aa avutil/bprint: Allow size == 0 in av_bprint_init_for_buffer()
The AVBPrint API guarantees that the string buffer is always
zero-terminated; in order to honour this guarantee, there
obviously must be a string buffer at all and it must have
a size >= 1. Therefore av_bprint_init_for_buffer() treats
passing a NULL buffer or size == 0 as invalid data that
leads to undefined behaviour, namely NPD in case NULL is provided
or a write to a buffer of size 0 in case size == 0.

But it would be easy to support this, namely by using the internal
buffer with AV_BPRINT_SIZE_COUNT_ONLY in case size == 0.

There is a reason to allow this: Several functions like
av_channel_(description|name) are actually wrappers
around corresponding AVBPrint functions. They accept user
provided buffers and are supposed to return the required
size of the buffer, which would allow the user to call
it once to get the required buffer size and call it once
more after having allocated the buffer.
If av_bprint_init_for_buffer() treats size == 0 as invalid,
all these users would need to check for this themselves
and basically add the same codeblock that this patch
adds to av_bprint_init_for_buffer().

This change is in line with e.g. snprintf() which also allows
the pointer to be NULL in case size is zero.

This fixes Coverity issues #1503074, #1503076 and #1503082;
all of these issues are about providing NULL to the channel-layout
functions that are wrappers around AVBPrint versions.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-08-10 08:53:38 +02:00
Andreas Rheinhardt 8a81ecce73 avutil/bprint: Don't use value of AV_BPRINT_SIZE_AUTOMATIC directly
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-08-10 08:52:30 +02:00
Elias Carotti 5012b4ab4c lavu: add video_hint API
Add side data type to provide hint to the video encoders about
unchanged portions of each frame.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2023-08-08 09:46:11 +02:00
Martin Storsjö 62fac040c8 intreadwrite: Indicate potential aliasing in AV_RN/AV_WN for Clang/MSVC mode
Use the GCC specific codepath for Clang in MSVC mode too.
This matches the condition used in a number of other places.

MSVC doesn't have a way to signal potential aliasing, while GCC
(and Clang) can use __attribute__((may_alias)) for this purpose.

When building with Clang in MSVC mode, __GNUC__ isn't defined but
_MSC_VER is as Clang primarily impersonates MSVC - but even then it
does support the GCC style attributes.

The GCC specific codepath uses av_alias, which expands to
the may_alias attribute if supported. The MSVC specific codepath
doesn't use av_alias so far (as MSVC doesn't support any
corresponding attribute).

This fixes a couple HEVC decoder tests when built with Clang 14 or
newer in MSVC mode (with issues observed on all of x86_64, armv7
and aarch64).

Signed-off-by: Martin Storsjö <martin@martin.st>
2023-08-04 21:50:57 +03:00
Haihao Xiang e63d9ba007 lavu/hwcontext_qsv: silence the warning
libavutil/hwcontext_qsv.c: In function ‘qsv_map_to’:
libavutil/hwcontext_qsv.c:1905:47: warning: cast from pointer to integer
of different size [-Wpointer-to-int-cast]

Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2023-07-31 09:09:20 +08:00
Rémi Denis-Courmont 983af74452 macos_kperf: fix incomplete prototype 2023-07-22 21:35:15 +03:00
Rémi Denis-Courmont c644aabec8 timer: don't leak perf FD if zero 2023-07-22 21:35:15 +03:00
Michael Niedermayer 8f48a62151
avutil/tx_template: extend to 2M
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-07-22 16:18:39 +02:00
Kieran Kunhya a4e616824b libavutil: Remove TOMI CPU 2023-07-22 00:36:53 +01:00
Lynne 3e3d46309b
lavu/vulkan: remove unused field from the execution pool structure 2023-07-21 20:04:21 +02:00
Lynne 97890c2b55
lavu/vulkan: remove threadsafe buffer index load and fix a signed overflow
It's not needed anymore.
2023-07-21 20:04:20 +02:00
Jan Beich e6bd8b1323 hwcontext_vulkan: hide Linux-only header after 571756bf2f
major/minor are in <sys/types.h> on BSDs and <sys/mkdev.h> on Solaris-like.

libavutil/hwcontext_vulkan.c:55:10: fatal error: 'sys/sysmacros.h' file not found
#include <sys/sysmacros.h>
^~~~~~~~~~~~~~~~~
2023-07-21 20:04:10 +02:00
Rémi Denis-Courmont 29b9d616c2 lavu/float_dsp: rework RISC-V V scalar product
1) Take the reductive sum out of the loop,
   leaving a regular vector addition in the loop.
2) Merge the addition and the multiplication.
3) Unroll.

Before:
scalarproduct_float_rvv_f32: 832.5

After:
scalarproduct_float_rvv_f32: 275.2
2023-07-20 22:54:34 +03:00
Rémi Denis-Courmont b710f881ce lavu/float_dsp: unroll RISC-V V loops
butterflies_float_c: 1057.0
butterflies_float_rvv_f32: 351.0 (before)
butterflies_float_rvv_f32: 329.5 (after)

vector_dmac_scalar_c: 819.0
vector_dmac_scalar_rvv_f64: 670.5 (before)
vector_dmac_scalar_rvv_f64: 431.0 (after)

vector_dmul_c: 800.2
vector_dmul_rvv_f64: 541.5 (before)
vector_dmul_rvv_f64: 426.0 (after)

vector_dmul_scalar_c: 545.7
vector_dmul_scalar_rvv_f64: 670.7 (before)
vector_dmul_scalar_rvv_f64: 324.7 (after)

vector_fmac_scalar_c: 804.5
vector_fmac_scalar_rvv_f32: 412.7 (before)
vector_fmac_scalar_rvv_f32: 214.5 (after)

vector_fmul_c: 811.2
vector_fmul_rvv_f32: 285.7 (before)
vector_fmul_rvv_f32: 214.2 (after)

vector_fmul_add_c: 1313.0
vector_fmul_add_rvv_f32: 349.0 (before)
vector_fmul_add_rvv_f32: 290.2 (after)

vector_fmul_reverse_c: 815.7
vector_fmul_reverse_rvv_f32: 529.2 (before)
vector_fmul_reverse_rvv_f32: 515.7 (after)

vector_fmul_scalar_c: 546.0
vector_fmul_scalar_rvv_f32: 350.2 (before)
vector_fmul_scalar_rvv_f32: 169.5 (after)
2023-07-20 22:54:34 +03:00
Rémi Denis-Courmont b6585eb04c lavu: add/use flag for RISC-V Zba extension
The code was blindly assuming that Zbb or V implied Zba. While the
earlier is practically always true, the later broke some QEMU setups,
as V was introduced earlier than Zba.
2023-07-19 19:29:35 +03:00
Zhao Zhili 3af0dc6d05 avutil/bfin: remove dead code
The code is unused for a decade since bf6c84d7eb.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-07-19 22:42:08 +08:00
Rémi Denis-Courmont 3d79afbe70 lavu/fixed_dsp: unroll RISC-V V loop
Before:
butterflies_fixed_c: 804.7
butterflies_fixed_rvv_i32: 348.2

After:
butterflies_fixed_rvv_i32: 308.7
2023-07-17 18:48:42 +03:00
Marton Balint 9a7f060c32 avutil/random_seed: turn off buffering when reading from random
Signed-off-by: Marton Balint <cus@passwd.hu>
2023-07-16 11:48:31 +02:00
Rémi Denis-Courmont f032234953 aarch64: remove VFP feature check
This is not actually used for anything. The configure check causes the
CPU feature flag to be set, but nothing consumes it at all.

While AArch64 does have VFP, it is only used for the scalar C code.
Conversely, it is still possible to disable VFP, by changing the
C compiler flags as before (though that only makes sense for an
hypothetical non-standard Armv8 platform without VFP).

Note that this retains the "vfp" option flag, for backward
compatibility and on the very remote but theoretically possible chance
that FFmpeg actually makes use of it in the future.

AV_CPU_FLAG_VFP is retained as it is actually used by AArch32.
2023-07-15 22:56:30 +03:00
Nicolas George ca9ec4e7ed lavu/avassert: include config.h
Fix setting the assert level.
2023-07-12 15:35:37 +02:00
Anton Khirnov 551a9af5a1 lavu/tests/cpu: stop processing the thread count
Just print it as it is.

Needed by the following commit.
2023-07-11 19:15:04 +02:00
Pavel Koshevoy 0056d9f176 avutil: fix build failure on osx 10.4
libavutil/random_seed.c calls arc4random_buf which is
not available on OSX 10.4 Tiger, but the configuration
script tests for arc4random which is available.

Fix the configuration test to match the actual API used.

Co-authored-by: James Almer <jamrial@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2023-07-08 14:51:15 -03:00
James Almer b7f4d5fa7e avutil/random_seed: add support for gcrypt and OpenSSL as source of randomness
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: James Almer <jamrial@gmail.com>
2023-07-06 15:30:27 -03:00
Philip Langdale 0e7fa8b3ca avutil/random_seed: include stddef.h
The new function uses size_t, which has to be defined.
2023-07-05 10:25:12 -07:00
James Almer d694c25b44 avutil/random_seed: add av_random_bytes()
Uses the existing code for av_get_random_seed() to return a buffer with
cryptographically secure random data, or an error if none could be generated.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-07-05 10:06:05 -03:00
James Almer 7a1128ca07 avutil/random_seed: use fread() in read_random()
This ensures the requested amount of bytes is read.
Also remove /dev/random as it's no longer necessary.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-07-05 08:58:50 -03:00
Tong Wu d51b0580e4 lavu/hwcontext_qsv: fix memory leak for d3d9 impl
Signed-off-by: Tong Wu <tong1.wu@intel.com>
2023-06-25 10:01:51 +08:00
Tong Wu 8ea31f694a lavu/hwcontext_qsv: fix memory leak for d3d11va impl
Signed-off-by: Tong Wu <tong1.wu@intel.com>
2023-06-25 10:01:51 +08:00
Tong Wu 28ed898ac6 avutil/hwcontext_qsv: register free function for device_derive
When qsv device is created by device_derive, the ctx->free function is
not registered, causing potential memory leak because of not properly
closing the MFX session.

Signed-off-by: Tong Wu <tong1.wu@intel.com>
Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
2023-06-25 10:01:51 +08:00
Michael Niedermayer 4aa1a42a91
avutil/softfloat: Basic documentation for av_sincos_sf()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-06-23 02:06:46 +02:00
Michael Niedermayer d84677abd8
avutil/softfloat: fix av_sincos_sf()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-06-23 02:06:46 +02:00
Lynne d0f1d937fe
hwcontext_vulkan: free temporary array once unneeded
Fixes a small memory leak.
This also prevents leaks on malloc/mutex init errors.
2023-06-15 22:00:41 +02:00
Lynne b4d5baa8b0
hwcontext_vulkan: call ff_vk_uninit() on device uninit
This fixes three memory leaks from ff_vk_load_props().
2023-06-15 22:00:41 +02:00
Philip Langdale 41be6a5593 lavu/hwcontext_cuda: declare support for rgb32/bgr32
nvenc declares support for these formats, but if hwcontext_cuda doesn't
do that as well, then it's not possible to hwupload them for use in a
possible cuda pipeline before encoding.
2023-06-15 12:29:52 -07:00
Martin Storsjö d78bffbf3d libavutil: Add version bump for new aarch64 cpu flags
This was missed in 397cb623c8.

Signed-off-by: Martin Storsjö <martin@martin.st>
2023-06-10 00:21:58 +03:00
Lynne eff565dc19
hwcontext_vulkan: tune execution pools
Having less in-flight resources is better in this case.
2023-06-07 23:59:17 +02:00
Lynne 5f1be341c2
vulkan: discard dependencies when explicitly waiting for execution
This reduces memory needed dramatically, as unneeded resources
can be immediately returned to the pool.
Although waitforfences is threadsafe, we add a mutex wait around
it, as the mutex fence in combination with waitforfences assures
us that no other thread will reset the fence in the meanwhile
whilst the mutex is locked. This allows is to call
ff_vk_exec_discard_deps.
2023-06-07 23:59:16 +02:00
Lynne 975cd48bb3
vulkan: synchronize access to execution pool fences
vkResetFences is specified as being user-synchronized
(yet vkWaitFences, is not).
2023-06-07 23:59:16 +02:00
Martin Storsjö c76643021e aarch64: Add Windows runtime detection of the dotprod instructions
For Windows, there's no publicly defined constant for checking for
the i8mm extension yet.

Signed-off-by: Martin Storsjö <martin@martin.st>
2023-06-06 12:50:15 +03:00
Martin Storsjö 9b0052200a aarch64: Add Apple runtime detection of dotprod and i8mm using sysctl
For now, there's not much value in this since Clang don't support
enabling the dotprod or i8mm features with either .arch_extension
or .arch (it has to be enabled by the base arch flags passed to
the compiler). But it may be supported in the future.

Signed-off-by: Martin Storsjö <martin@martin.st>
2023-06-06 12:41:20 +03:00
Martin Storsjö 493fcde50a aarch64: Add Linux runtime cpu feature detection using HWCAP_CPUID
Based partially on code by Janne Grunau.

Signed-off-by: Martin Storsjö <martin@martin.st>
2023-06-06 12:40:57 +03:00
Martin Storsjö 397cb623c8 aarch64: Add cpu flags for the dotprod and i8mm extensions
Set these available if they are available unconditionally for
the compiler.

Signed-off-by: Martin Storsjö <martin@martin.st>
2023-06-06 12:40:42 +03:00
Martin Storsjö fb1b88af77 configure: aarch64: Support assembling the dotprod and i8mm arch extensions
These are available since ARMv8.4-a and ARMv8.6-a respectively,
but can also be available optionally since ARMv8.2-a.

Check if ".arch armv8.2-a" and ".arch_extension {dotprod,i8mm}" are
supported, and check if the instructions can be assembled.

Current clang versions fail to support the dotprod and i8mm
features in the .arch_extension directive, but do support them
if enabled with -march=armv8.4-a on the command line. (Curiously,
lowering the arch level with ".arch armv8.2-a" doesn't make the
extensions unavailable if they were enabled with -march; if that
changes, Clang should also learn to support these extensions via
.arch_extension for them to remain usable here.)

Signed-off-by: Martin Storsjö <martin@martin.st>
2023-06-06 12:40:26 +03:00
Philip Langdale 378fb40282 avutil/hwcontext_vulkan: disable multiplane when deriving from cuda
Today, cuda is not able to import multiplane images, and cuda requires
images to be imported whether you trying to import to cuda or export
from cuda (in the later case, the image is imported and then copied
into on the cuda side). So any interop between cuda and vulkan requires
that multiplane be disabled.

The existing option for this is not sufficient, because when deriving
devices it is not possible to specify any options.

And, it is necessary to derive the Vulkan device, because any pipeline
that involves uploading from cuda to vulkan and then back to cuda must
use the same cuda context on both sides, and the only way to propagate
the cuda context all the way through is to derive the device at each
stage.

ie:

-vf hwupload=derive_device=vulkan,<filters>,hwupload=derive_device=cuda
2023-06-03 16:29:38 -07:00
Lynne 58f82fc26a
vulkan: replace usage of %lu with %"SIZE_SPECIFIER" 2023-05-29 03:22:58 +02:00
Michael Niedermayer 75918016ab
Move bessel_i0() from swresample/resample to avutil/mathematics
0th order modified bessel function of the first kind are used in multiple
places, lets avoid having 3+ different implementations
I picked this one as its accurate and quite fast, it can be replaced if
a better one is found

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-05-29 00:45:28 +02:00
Lynne db1d022781
APIchanges: add hwcontext_vulkan changes and bump lavu minor 2023-05-29 00:42:02 +02:00
Lynne bef86ba86c
APIchanges: add new pixel formats supported and bump lavu minor 2023-05-29 00:42:02 +02:00
Lynne 160a415e22
lavfi: add nlmeans_vulkan filter 2023-05-29 00:42:01 +02:00
Lynne dfff3877b7
vulkan: add support for the atomic float ops extension 2023-05-29 00:42:01 +02:00
Lynne 77478f6793
av1dec: add Vulkan hwaccel 2023-05-29 00:42:00 +02:00
Niklas Haas 9675e54b02
avutil/hwcontext_vulkan: add libplacebo required features
For compatibility with vf_libplacebo
2023-05-29 00:41:55 +02:00
Lynne 05ce6473ac
lavfi: add lavfi-only Vulkan infrastructure 2023-05-29 00:41:51 +02:00
Lynne 51b7fe81be
hwcontext_vulkan: enable additional device properties 2023-05-29 00:41:51 +02:00
Lynne 33fc919bb7
hwcontext_vulkan: remove duplicate code, port to use generic vulkan utils
The temporary AVFrame on staack enables us to use the common
dependency/dispatch code in prepare_frame().
The prepare_frame() function is used for both frame initialization
and frame import/export queue family transfer operations.
In the former case, no AVFrame exists yet, so, as this is purely
libavutil code, we create a temporary frame on stack. Otherwise,
we'd need to allocate multiple frames somewhere, one for each
possible command buffer dispatch.
2023-05-29 00:41:51 +02:00
Lynne 94e17a63a4
hwcontext_vulkan: don't change properties if prepare_frame fails 2023-05-29 00:41:50 +02:00
Lynne 32fc36ee61
hwcontext_vulkan: remove linear+host_visible "fast" path
The idea was that it's faster to map linear images and copy them
via regular memcpy. This is a very niche use, plus very inconsistently
useful, as it would only really be faster on a few Intel GPUs.
Even then, using the non-cached memcpy would've been better.

Instead, scrap this code. Drivers are better at figuring out
what copy to use, and if we're host-mapping, it should actually be
just as fast, if not faster.
2023-05-29 00:41:50 +02:00
Lynne 48f85de0e7
hwcontext_vulkan: rewrite to support multiplane surfaces
This commit adds proper handling of multiplane images throughout
all of the hwcontext code. To avoid breakage of individual
components, the change is performed as a single commit.
2023-05-29 00:41:49 +02:00
Lynne a4d63b46d9
vulkan: make GLSL macro functions semicolumn-safe 2023-05-29 00:41:49 +02:00
Lynne 83024beec2
vulkan: enable forcing of full subgroups 2023-05-29 00:41:49 +02:00
Lynne 758f8b26b9
vulkan: add ff_vk_count_images() 2023-05-29 00:41:48 +02:00
Lynne b5eaeb1f13
vulkan: rewrite to support all necessary features
This commit rewrites the majority of vulkan.c to enable its use
as a general-purpose high-level utility code, usable for decoding,
encoding, and filtering of video frames.

The dependency system was rewritten to simplify management of
execution.

The image handling system was rewritten to accomodate multiplane
images.

Due to how related all the new features were, this is a single
commit.
2023-05-29 00:41:48 +02:00
Lynne 721b71da4a
vulkan: return current queue index from ff_vk_qf_rotate() 2023-05-29 00:41:48 +02:00
Lynne b15104ed97
vulkan: add support for retrieving queue, query and video properties 2023-05-29 00:41:47 +02:00
Lynne 6eaf3fe69c
vulkan: add support for queries 2023-05-29 00:41:47 +02:00
Lynne f3fb1b50bb
vulkan: minor indent fix, add support for synchronous submission/waiting 2023-05-29 00:41:46 +02:00
Lynne d386988c39
vulkan: use device properties 2 and add a convenience loader function 2023-05-29 00:41:46 +02:00
Lynne bf69a64135
vulkan: add size tracking to buffer structs 2023-05-29 00:41:46 +02:00
Lynne b18e20a4ee
vulkan: do not wait for device idle when destroying buffers
This should be done explicitly.
2023-05-29 00:41:45 +02:00
Lynne 15de0af8f0
vulkan: allow alloc pNext in ff_vk_create_buf 2023-05-29 00:41:45 +02:00
Lynne af48790465
vulkan: support ignoring memory properties when allocating 2023-05-29 00:41:45 +02:00
Lynne 3c2f43d8ee
vulkan: expose ff_vk_alloc_mem() 2023-05-29 00:41:44 +02:00
Lynne fa67ccee37
vulkan: add ff_vk_image_create() 2023-05-29 00:41:44 +02:00
Lynne e8fce74abf
vulkan: add ff_vk_qf_fill() 2023-05-29 00:41:43 +02:00
Lynne b5e333bba7
vulkan: add pNext argument to ff_vk_create_buf() 2023-05-29 00:41:43 +02:00
Lynne a0d47a2ad9
vulkan: fix comment statement about exec_queue blocking 2023-05-29 00:41:43 +02:00
Lynne 619b1265a2
vulkan: add additional error codes 2023-05-29 00:41:42 +02:00
Lynne 0c9c0e40fb
vulkan: define VK_NO_PROTOTYPES
This just disables the vulkan headers from defining any symbols
like vkCmdPipelineBarrier2(). Instead, all functions must be loaded
via the loader and used as function pointers as vk->CmdPipelineBarrier2.

Mostly just forces developers to write correct code, as using the
symbols can be undesirable in case API users define their own
function wrappers via the loader API.
2023-05-29 00:41:42 +02:00
Lynne 92ddd415bc
vulkan: lock queues before submitting operations 2023-05-29 00:41:42 +02:00
Lynne 9b385b480f
hwcontext_vulkan: enable GPU-assisted validation when debugging 2023-05-29 00:41:41 +02:00
Lynne e5e12c5078
hwcontext_vulkan: load query-related functions
Needed for both encoding and decoding.
2023-05-29 00:41:41 +02:00
Lynne d4cb48dd00
hwcontext_vulkan: support PREP_MODE_DECODING in prepare_frame() 2023-05-29 00:41:41 +02:00
Lynne 6dfa29a58d
hwcontext_vulkan: add functions for video decoding 2023-05-29 00:41:40 +02:00
Lynne 571756bf2f
hwcontext_vulkan: use VK_EXT_physical_device_drm to derive DRM to Vulkan
Finally, a way to directly identify a Vulkan device from a DRM device!
2023-05-29 00:41:40 +02:00
Lynne e11fd1abdb
hwcontext_vulkan: do not require libdrm to map VAAPI devices
VAAPI is sadly on the way of becoming multiplaform.
2023-05-29 00:41:39 +02:00
Lynne f50bc930a4
hwcontext_vulkan: add support for descriptor buffers 2023-05-29 00:41:39 +02:00
Lynne c5702abf71
hwcontext_vulkan: report nonCoherentAtomSize 2023-05-29 00:41:39 +02:00
Lynne b0af92572f
hwcontext_vulkan: fix minor type issue in VulkanQueueCtx.buf_deps_alloc_size 2023-05-29 00:41:38 +02:00
Lynne 211c910aca
hwcontext_vulkan: rename and expand vk_pixfmt_map to append VK_NULL_FORMAT 2023-05-29 00:41:38 +02:00
Lynne e0f2d2e702
hwcontext_vulkan: remove contiguous memory path/mode
The hack was added to enable exporting of vulkan images to DRM.
On Intel hardware, specifically for DRM images, all planes must be
allocated next to each other, due to hardware limitation, so the hack
used a single large allocation and suballocated all planes from it.

By natively supporting multiplane images, the driver is what decides
the layout, so exporting just works.

It's a hack because it conflicted heavily with image allocation, and
with the whole ecosystem in general, before multiplane images were
supported, which just made it redundant.

This is also the commit which broke the hwcontext hardest and prompted
the entire rewrite in the first place.
2023-05-29 00:41:37 +02:00
Lynne 46a77c6496
hwcontext_vulkan: support threadsafe queue and frame operations 2023-05-29 00:41:37 +02:00
Lynne 2a1fd2814f
hwcontext_vulkan: use portability subset if available 2023-05-29 00:41:37 +02:00
Lynne 74b202b839
hwcontext_vulkan: enable VK_KHR_synchronization2 if supported 2023-05-29 00:41:36 +02:00
Lynne fddfb0ebf8
hwcontext_vulkan: enable support for YCbCr samplers 2023-05-29 00:41:36 +02:00
Lynne 59707cc485
hwcontext_vulkan: initialize and require instance version 1.3
This just bumps the required loader library version (libvulkan).
All device-related features, such as video decoding, atomics, etc.
are still optional and the code deals with their loss on a local level
(e.g. the decoder or filter checks for the features it needs, not
the hwcontext).

Bumping the required version essentially packs all maintenance
extensions which correct the spec rather than requiring to enable
them individually.
2023-05-29 00:41:36 +02:00
Lynne 0bda3340a3
lavu: add 12-bit 2-plane 422 and 444 pixel formats 2023-05-29 00:41:35 +02:00
yuanhecai 82278e8749
avutil/la: Add function performance testing
This patch supports the use of the "checkasm --bench" testing feature
on loongarch platform.

Change-Id: I42790388d057c9ade0dfa38a19d9c1fd44ca0bc3
Reviewed-by: Shiyou Yin <yinshiyou-hf@loongson.cn>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-05-25 21:05:21 +02:00
James Almer 4d885271bb avutil/mathematics: add missing constants
Including float variants for all of them.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-05-19 17:10:58 -03:00
James Almer 4adb6da7a6 avutil/frame: remove one layer of indirection in av_frame_replace()
And don't force copy side data.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-05-18 11:52:16 -03:00
James Almer 01d444c077 avutil/frame: add av_frame_replace
Signed-off-by: James Almer <jamrial@gmail.com>
2023-05-18 10:15:59 -03:00
James Almer 63767b79a5 avutil/frame: deprecate palette_has_changed
Not only this is information that relies on the concept of a sequence of
frames, which is completely out of place as a field in AVFrame, but there are
no known or intended uses of this field.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-05-18 08:45:23 -03:00
Anton Khirnov d45a296732 lavu/frame: extend AVFrame.repeat_pict documentation 2023-05-15 10:31:55 +02:00
James Almer 0fc9c1f682 avutil/version: bump minor after recent changes
Signed-off-by: James Almer <jamrial@gmail.com>
2023-05-04 19:20:06 -03:00
James Almer 3e06f6f040 avutil/frame: deprecate key_frame
Signed-off-by: James Almer <jamrial@gmail.com>
2023-05-04 19:20:03 -03:00
James Almer cc11191fda avutil/frame: add a keyframe flag to AVFrame
Signed-off-by: James Almer <jamrial@gmail.com>
2023-05-04 18:16:47 -03:00
James Almer 599abc0f3a avutil/frame: deprecate interlaced_frame and top_field_first
Signed-off-by: James Almer <jamrial@gmail.com>
2023-05-04 18:15:00 -03:00
James Almer 2df4e054d4 avutil/frame: add new interlaced and top_field_first flags
Signed-off-by: James Almer <jamrial@gmail.com>
2023-05-04 17:40:24 -03:00
Rémi Denis-Courmont 0e580806d8 riscv/intmath: use builtins for counting ones
As with the earlier bswap change, all versions of GCC and Clang that
support RISC-V support the popcount built-ins, so we can just use them
instead of inline assembler.
2023-05-02 22:08:25 +02:00
Rémi Denis-Courmont 7dcb5e1ab0 riscv/bswap: use compiler builtins
av_bswapXX() are used in context that expect exact size types, notably
variable arguments to av_log(). On Linux RV64, uint_fast32_t is an
unsigned long, so the current inline assembler does not work properly.

Since GCC and Clang gained their byte-swap built-ins before they
supported RISC-V, we can simply defer to them. As an added bonus, the
compiler can do instruction scheduling, which it couldn't with the Zbb
inline assembler.
2023-05-02 22:08:21 +02:00
Sil Vilerino a9a2ddaea8 lavu/hwcontext_qsv: Update after adding support for VAAPI on Windows
- qsv_internal.h: Remove unnecessary include va_drm.h
- qsv_internal.h: Enable AVCODEC_QSV_LINUX_SESSION_HANDLE on Linux/VA only
- hwcontext_qsv.c: Do not allow child_device_type VAAPI for Windows until
  support is added, keep D3D11/DXVA2 as more prioritary defaults.

Initial review at https://github.com/intel-media-ci/ffmpeg/pull/619/

Signed-off-by: Sil Vilerino <sivileri@microsoft.com>
Reviewed-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com>
Reviewed-by: Wu, Tong1 <tong1.wu@intel.com>
2023-04-24 13:24:41 +08:00
Sil Vilerino d54127c41a lavu/hwcontext_vaapi: Add Windows/VAAPI support with vaGetDisplayWin32
Libva 2.17+ adds a new libva-win32 node and Mesa 22.3 adds a VAAPI driver
based on Direct3D 12 for Windows. Both of them are available at:
https://www.nuget.org/packages/Microsoft.Direct3D.VideoAccelerationCompatibilityPack

Initial review at https://github.com/intel-media-ci/ffmpeg/pull/619/

Signed-off-by: Sil Vilerino <sivileri@microsoft.com>
Reviewed-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com>
Reviewed-by: Wu, Tong1 <tong1.wu@intel.com>
2023-04-24 13:24:41 +08:00
Michael Niedermayer eddf7e2a3e
avutil/tx_priv: Use unsigned in BF() to avoid signed overflows
Fixes: signed integer overflow: 100183269 - -2132769113 cannot be represented in type 'int'
Fixes: 55063/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AAC_FIXED_fuzzer-5039294027005952

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-04-22 21:17:07 +02:00
James Almer 92885f2681 avutil/wchar_filename: propagate MultiByteToWideChar() and WideCharToMultiByte() failures
Don't return success if the string could not be converted.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-04-14 10:04:47 -03:00
Zhao Zhili f0f596dbc6 avutil/internal: remove timer.h again
timer.h has been removed from internal.h, and then added back with
3e6088f for convenience. This patch removed it again for the
following reasons:

1. Only includes what's necessary is a common and safe strategy.

2. It fixed some build errors on Android:
  a. libavutil/timer.h includes sys/ioctl.h, and ioctl.h includes
     termios.h on Android.
  b. termios.h reserves names prefixed with ‘c_’, ‘V’, ‘I’, ‘O’, and
     ‘TC’; and names prefixed with ‘B’ followed by a digit.
  c. libavcodec uses B0 B1 and so on as variable names a lot. So
     the code failed to build with --enable-linux-perf, or
     --target-os=Linux.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-04-15 04:21:33 +08:00
Niklas Haas 4eaaa38d3d avutil: make av_frame_get_plane_buffer accept a const AVFrame*
Signed-off-by: Niklas Haas <git@haasn.dev>
2023-04-14 10:53:28 +02:00
James Almer 61b27b15fc avutil/hdr_dynamic_metadata: allow av_dynamic_hdr_plus_to_t35() to accept an existing buffer
The function now accepts an existing buffer to avoid unnecessary allocations,
as well as only reporting the needed amount of bytes if you pass a NULL pointer
as input for data.
For this, both parameters become input and output, as well as making data
optional. This is backwards compatible, and as such not breaking any existing
use of the function in external code (if there's any).

Signed-off-by: James Almer <jamrial@gmail.com>
2023-04-05 09:47:12 -03:00
Junxian Zhu 5ffe18bcea
mips: fix build fail on MIPS R6
Add macro define to avoid causing build fail with incompatible assembler code on MIPS R6.

Signed-off-by: Junxian Zhu <zhujunxian@oss.cipunited.com>
Reviewed-by: Shiyou Yin <yinshiyou-hf@loongson.cn>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-03-26 01:46:39 +01:00
Jan Ekström 90488e1440 avutil/frame: move counters utilized in loops to their scope
This way we can clean up separate definitions in functions with
just a single loop, as well as have no reuse between different
loops' counters in functions with multiple.
2023-03-24 13:56:10 +02:00
Raphaël Zumer 0a3ce5f738 avutil: add HDR10+ dynamic metadata serialization function
Co-authored-by: Mohammad Izadi <moh.izadi@gmail.com>
Signed-off-by: Raphaël Zumer <rzumer@tebako.net>
Signed-off-by: James Almer <jamrial@gmail.com>
2023-03-21 13:52:39 -03:00
Raphaël Zumer 6f2413a203 avcodec/avutil: move dynamic HDR10+ metadata parsing to libavutil
Signed-off-by: Raphaël Zumer <rzumer@tebako.net>
Signed-off-by: James Almer <jamrial@gmail.com>
2023-03-21 13:52:36 -03:00
Anton Khirnov 27f8c9b27b lavu/frame: deprecate AVFrame.pkt_{pos,size}
These fields are supposed to store information about the packet the
frame was decoded from, specifically the byte offset it was stored at
and its size.

However,
- the fields are highly ad-hoc - there is no strong reason why
  specifically those (and not any other) packet properties should have a
  dedicated field in AVFrame; unlike e.g. the timestamps, there is no
  fundamental link between coded packet offset/size and decoded frames
- they only make sense for frames produced by decoding demuxed packets,
  and even then it is not always the case that the encoded data was
  stored in the file as a contiguous sequence of bytes (in order for pos
  to be well-defined)
- pkt_pos was added without much explanation, apparently to allow
  passthrough of this information through lavfi in order to handle byte
  seeking in ffplay. That is now implemented using arbitrary user data
  passthrough in AVFrame.opaque_ref.
- several filters use pkt_pos as a variable available to user-supplied
  expressions, but there seems to be no established motivation for using them.
- pkt_size was added for use in ffprobe, but that too is now handled
  without using this field. Additonally, the values of this field
  produced by libavcodec are flawed, as described in the previous
  ffprobe conversion commit.

In summary - these fields are ill-defined and insufficiently motivated,
so deprecate them.
2023-03-20 10:42:09 +01:00
Zhao Zhili 3be46ee767 libavutil/hdr_dynamic_vivid_metadata: fix three spline params
There are two group of three_Spline params.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-03-17 18:51:16 +08:00
Anton Khirnov d732db3a38 lavu/frame: improve AVFrame.opaque[_ref] documentation
Make them match each other, mention interaction with
AV_CODEC_FLAG_COPY_OPAQUE.
2023-03-10 13:00:53 +01:00
Kacper Michajłow cc76e8340d lavu/vulkan: fix handle type for 32-bit targets
Fixes compilation with clang which errors out on Wint-conversion.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Martin Storsjö <martin@martin.st>
2023-03-07 22:55:07 +02:00
Martin Storsjö f9620d74cd vulkan: Fix win/i386 calling convention
This fixes the following error when compiling with a modern
version of Clang for Windows/i386:

src/libavutil/hwcontext_vulkan.c:738:32: error: incompatible function pointer types initializing 'PFN_vkDebugUtilsMessengerCallbackEXT' (aka 'unsigned int (*)(enum VkDebugUtilsMessageSeverityFlagBitsEXT, unsigned int, const struct VkDebugUtilsMessengerCallbackDataEXT *, void *) __attribute__((stdcall))') with an expression of type 'VkBool32 (VkDebugUtilsMessageSeverityFlagBitsEXT, VkDebugUtilsMessageTypeFlagsEXT, const VkDebugUtilsMessengerCallbackDataEXT *, void *)' (aka 'unsigned int (enum VkDebugUtilsMessageSeverityFlagBitsEXT, unsigned int, const struct VkDebugUtilsMessengerCallbackDataEXT *, void *)') [-Wincompatible-function-pointer-types]
            .pfnUserCallback = vk_dbg_callback,
                               ^~~~~~~~~~~~~~~

Signed-off-by: Martin Storsjö <martin@martin.st>
2023-03-07 18:16:02 +02:00
Fei Wang 15992a040d lavu/hwcontext_vaapi: sync surface before export its DRM handle
According to description of vaExportSurfaceHandle in libva, vaSyncSurface
must be called if the contents of the surface will be read.

Fixes ticket #9967.

Reviewed-by: Zhao Zhili <zhilizhao@tencent.com>
Signed-off-by: Fei Wang <fei.w.wang@intel.com>
2023-02-27 13:42:06 +08:00
Shiyou Yin b09f31af1b avutil: [LA] use getauxval to do runtime check.
Replace cpucfg with getauxval to avoid crash in case of
some processor capabilities are not supportted by kernel used.

Reviewed-by: Steven Liu <liuqi05@kuaishou.com>
2023-02-27 11:26:42 +08:00
Tong Wu d5cc7acff1 qsv: remove CONFIG_VAAPI for mutiple formats
Remove CONFIG_VAAPI for VUYX, YUYV422, Y210, XV30, Y212, XV36.

Make 8-bit, 10-bit, 12-bit YUV 4:2:2 video sources as well as YUV 4:4:4
video sources supported by d3d11va and dxva2 just like what VAAPI does.

Sign-off-by: Tong Wu <tong1.wu@intel.com>
2023-02-22 12:15:59 +08:00
Tong Wu 417eb7d50e hwcontext_dxva2: add mutiple supported formats
Add support for VUYX, YUYV422, Y210, XV30, P012, Y212, XV36.
The added formats work with qsv acceleration and will not have
impact on dxva2 acceleration(-hwaccel dxva2) since so far
these formats are still not supported by using dxva2 acceleration.

Hwupload and hwdownload can work with the added formats.

Signed-off-by: Tong Wu <tong1.wu@intel.com>
2023-02-22 12:15:59 +08:00
Tong Wu 98d03e528f hwcontext_d3d11va: add mutiple supported DXGI formats
Add support for VUYX, YUYV422, Y210, XV30, P012, Y212, XV36.

The added formats work with qsv acceleration and will not have
impact on d3d11va acceleration(-hwaccel d3d11va) since so far
these formats are still not supported by using d3d11va acceleration.

Hwupload and hwdownload can work with the added formats.

Signed-off-by: Tong Wu <tong1.wu@intel.com>
2023-02-22 12:15:59 +08:00
Michael Niedermayer 47ac3e6065
version.h: Bump minor post 6.0 branch
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-19 18:37:36 +01:00
Michael Niedermayer 62efa096af
version.h: Bump minor for 6.0 branch
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-19 18:32:07 +01:00
Marton Balint 2296078397 avutil/frame: deprecate AVFrame.coded_picture_number and display_picture_number
Their usefulness is questionable, very few decoders set them, and their type
should have been int64_t. A replacement field can be added later if a valid use
case is found.

Signed-off-by: Marton Balint <cus@passwd.hu>
2023-02-13 00:37:50 +01:00
James Almer 5bad485603 Bump major versions of all libraries
Signed-off-by: James Almer <jamrial@gmail.com>
2023-02-09 15:35:14 +01:00
James Almer 0a95e4af99 avutil/version: postpone the remaining API deprecations
They are too recent.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-02-09 15:35:14 +01:00
Leo Izen 719a93f4e4 avutil/{color_utils, csp}: merge color_utils into csp and expose API
libavutil/color_utils contains some avpriv_ symbols that map
enum AVTransferCharacteristic values to gamma-curve approximations and
to the actual transfer functions to invert them (i.e. -> linear).

There's two issues with this:
(1) avpriv is evil and should be avoided whenever possible
(2) libavutil/csp.h exposes a public API for handling color that
    already handles primaries and matricies

I don't see any reason this API has to be private, so this commit takes
the functionality from avutil/color_utils and merges it into avutil/csp
with an exposed av_ API rather than the previous avpriv_ API.

Every reference to the previous API has been updated to point to the
new one. color_utils.h has been deleted as well. This should not break
any applications as it only contained avpriv_ symbols in the first
place, so nothing in that header could be referenced by other
applications.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2023-02-09 15:35:14 +01:00
James Almer dc1b8135e0 avutil: remove FF_API_AV_MALLOCZ_ARRAY
Signed-off-by: James Almer <jamrial@gmail.com>
2023-02-09 15:35:14 +01:00
James Almer 16c4e8f9c1 avutil: remove FF_API_COLORSPACE_NAME
Signed-off-by: James Almer <jamrial@gmail.com>
2023-02-09 15:35:14 +01:00
James Almer 21814a70db avutil: remove FF_API_DECLARE_ALIGNED
Signed-off-by: James Almer <jamrial@gmail.com>
2023-02-09 15:35:14 +01:00
James Almer 30e1e7e0f3 avutil: remove FF_API_D2STR
Signed-off-by: James Almer <jamrial@gmail.com>
2023-02-09 15:35:14 +01:00
Haihao Xiang f1355ec9f6 lavu/hwcontext_qsv: add support for UYVY
The SDK supports UYVY from version 1.17, and VPP may support UYVY
input on Linux [1]

$ ffmpeg -loglevel verbose -init_hw_device qsv=intel -f lavfi -i \
yuvtestsrc -vf \
"format=uyvy422,hwupload=extra_hw_frames=32,vpp_qsv=format=nv12" \
-f null -

[1] https://github.com/Intel-Media-SDK/MediaSDK/blob/master/doc/samples/readme-vpp_linux.md

Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2023-02-07 09:51:37 +08:00
Anton Khirnov bdc76f467f lavu/frame: deprecate reordered_opaque
It is only used in libavcodec, where it's been superseded by
AV_CODEC_CAP_COPY_OPAQUE.
2023-02-04 13:40:20 +01:00
Lynne bbe95f7353
x86: replace explicit REP_RETs with RETs
From x86inc:
> On AMD cpus <=K10, an ordinary ret is slow if it immediately follows either
> a branch or a branch target. So switch to a 2-byte form of ret in that case.
> We can automatically detect "follows a branch", but not a branch target.
> (SSSE3 is a sufficient condition to know that your cpu doesn't have this problem.)

x86inc can automatically determine whether to use REP_RET rather than
REP in most of these cases, so impact is minimal. Additionally, a few
REP_RETs were used unnecessary, despite the return being nowhere near a
branch.

The only CPUs affected were AMD K10s, made between 2007 and 2011, 16
years ago and 12 years ago, respectively.

In the future, everyone involved with x86inc should consider dropping
REP_RETs altogether.
2023-02-01 04:23:55 +01:00
Martin Storsjö 01f58f3646 lavu/video_enc_params: Avoid relying on an undefined C construct
The construct of using offsetof on a (potentially anonymous) struct
defined within the offsetof expression, while supported by all
current compilers, has been declared explicitly undefined by the
C standards committee [1].

Clang recently got a change to identify this as an issue [2];
initially it was treated as a hard error, but it was soon after
softened into a warning under the -Wgnu-offsetof-extensions option
(not enabled automatically as part of -Wall though).

Nevertheless - in this particular case, it's trivial to fix the
code not to rely on the construct that the standards committee has
explicitly called out as undefined.

[1] https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2350.htm
[2] https://reviews.llvm.org/D133574

Signed-off-by: Martin Storsjö <martin@martin.st>
2023-01-31 14:22:54 +02:00
Anton Khirnov 5c36f4ef84 lavu/opt: use AV_DICT_MULTIKEY in av_opt_set_dict2()
If the dictionary provided on input contains multiple entries for an
option (relevant for flags modifying the previous value with '+' or
'-') and the option is not found in the target object, only the last
entry would be returned to the caller.

Pass AV_DICT_MULTIKEY to av_dict_set() to make sure all such entries are
returned.
2023-01-31 09:08:03 +01:00
Zhao Zhili 1263b0a6ca avutil/hwcontext_mediacodec: fix backward compatibility
AVMediaCodecDeviceContext without surface or native_window is
useless, it shouldn't be created at all. Such dummy AVHWDeviceContext
is allowed before, and it's used by mpv player. Creating a ANativeWindow
automatically breaks such usecases.

So disable creating a ANativeWindow by default. It can be enabled
via the create_window flag, or by set the AVDictionary of
av_hwdevice_ctx_create(). The downside is that

ffmpeg -hwaccel mediacodec -i input.mp4 \
	-c:a copy -c:v hevc_mediacodec output.mp4

use ByteBuffer mode which isn't as efficient as before. The upside
is libavfilter works now, which should be less surprise.

To enable create_window on ffmpeg command line, use
ffmpeg -hwaccel mediacodec \
	-init_hw_device mediacodec=mediacodec,create_window=1 \
	-i input.mp4 -c:a copy -c:v hevc_mediacodec output.mp4

Users should know what it is to enable create_window. It should
be OK to take sometime to figure out the option. And there are comments
inside hwcontext_mediacodec.h to help user figure it out.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-01-26 23:31:37 +08:00
Jan Ekström 002d0ec740 avutil: introduce AVAmbientViewingEnvironment side data
This enables exposing H.274 Ambient Viewing Environment
metadata in the framework.
2023-01-13 21:26:13 +02:00