Commit Graph

5937 Commits

Author SHA1 Message Date
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