Commit Graph

5447 Commits

Author SHA1 Message Date
Haihao Xiang 2727ff069e lavu/fifo: fix regression
offset_w might be updated after growing the FIFO

Fix ticket #9630

Tested-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
Reviewed-by: mkver
Reviewed-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2022-02-09 11:04:47 +08:00
Alexander Kanavin 91326dc942 libavutil: include assembly with full path from source root
Otherwise nasm writes the full host-specific paths into .o
output, which breaks binary reproducibility.

Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2022-02-08 10:42:26 +01:00
Aman Karmani 2f299c0b8b avutil: use getauxval(3) for CPU capabilities on linux/android ARM
getauxval is marginally faster, and works even when procfs is not mounted

support on Linux was added in glibc 2.16
support on Android was added in 4.4 (API 20)
fixes #6578

Signed-off-by: Aman Karmani <aman@tmm1.net>
2022-02-07 13:42:40 -08:00
Lynne 04cc7a5548
lavu/tx: wrap missed string in NULL_IF_CONFIG_SMALL
It's the only one that isn't defined through the macros used elsewhere.
2022-02-07 04:23:31 +01:00
Lynne eac4c3574b
lavu/tx: disable debugging information when CONFIG_SMALL 2022-02-07 03:56:47 +01:00
Lynne 3bbe9c5e38
lavu/tx: refactor assembly codelet definition
This commit does some refactoring to make defining assembly codelets
smaller, and fixes compiler redefinition warnings. It also allows
for other assembly versions to reuse the same boilerplate code as
x86.

Finally, it also adds the out_of_place flag to all assembly codelets.
This changes nothing, as out-of-place operation was assumed to be
available anyway, but this makes it more explicit.
2022-02-07 03:56:45 +01:00
Anton Khirnov a10f1aec1f avutil/fifo: Deprecate old FIFO API
Users should switch to the superior AVFifo API.

Unfortunately AVFifoBuffer fields cannot be marked as deprecated because
it would trigger a warning wherever fifo.h is #included, due to
inlined av_fifo_peek2().
2022-02-07 00:31:49 +01:00
Anton Khirnov 90eef1c3de lavu/threadmessage: switch to new FIFO API 2022-02-07 00:31:23 +01:00
Anton Khirnov d1bd189c63 lavu/audio_fifo: switch to new FIFO API 2022-02-07 00:31:23 +01:00
Anton Khirnov 082136209c lavu/audio_fifo: drop an unnecessary include
Nothing in audio_fifo.h uses anything from fifo.h
2022-02-07 00:31:23 +01:00
Anton Khirnov 93ed375574 lavu/tests/fifo: switch to the new API 2022-02-07 00:31:23 +01:00
Anton Khirnov 14429f8fec lavu/fifo: add a flag for automatically growing the FIFO as needed
This will not increase the FIFO beyond 1MB, unless the caller explicitly
specifies otherwise.
2022-02-07 00:31:23 +01:00
Anton Khirnov 7329b22c05 lavu/fifo: Add new AVFifo API based upon the notion of element size
Many AVFifoBuffer users operate on fixed-size elements (e.g. pointers),
but the current FIFO API deals exclusively in bytes, requiring extra
complexity in all these callers.

Add a new AVFifo API creating a FIFO with an element size
that may be larger than a byte. All operations on such a FIFO then
operate on complete elements.

This API does not reuse AVFifoBuffer and its API at all, but instead uses
an opaque struct called AVFifo. The AVFifoBuffer API will be deprecated
in a future commit once all of its users have been switched to the new
API.

Not reusing AVFifoBuffer also allowed to use the full range of size_t
from the beginning.
2022-02-07 00:30:22 +01:00
Anton Khirnov 5939c8d361 lavu/fifo: disallow overly large fifo sizes
The API currently allows creating FIFOs up to
- UINT_MAX: av_fifo_alloc(), av_fifo_realloc(), av_fifo_grow()
- SIZE_MAX: av_fifo_alloc_array()
However the usable limit is determined by
- rndx/wndx being uint32_t
- av_fifo_[size,space] returning int
so no FIFO should be larger than the smallest of
- INT_MAX
- UINT32_MAX
- SIZE_MAX
(which should be INT_MAX an all commonly used platforms).
Return an error on trying to allocate FIFOs larger than this limit.
2022-02-07 00:29:05 +01:00
Andreas Rheinhardt 2d71f93c7c avutil/fifo: Use av_fifo_generic_peek_at() for av_fifo_generic_peek()
Avoids code duplication. It furthermore properly checks
for buf_size to be > 0 before doing anything.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-02-07 00:29:05 +01:00
Lynne 2e82c61055
x86/tx_float: avoid redefining macros
FFT16_FN was used for fft8 and for fft16 afterwards.
2022-02-02 07:51:45 +01:00
Zhao Zhili b5a8b3d45a hwcontext_vulkan: use VkPhysicalDeviceTimelineSemaphoreFeatures
VkPhysicalDeviceVulkan12Features isn't implemented on MoltenVK yet.
VkPhysicalDeviceTimelineSemaphoreFeatures is less versatile but
simple. None of device_features_1_1 nor device_features_1_2 has real
usage yet, keep the code for future.
2022-02-01 22:54:24 +01:00
Andreas Rheinhardt 98cef1ebbe avutil/tests/adler32: Remove unnecessary volatile
And use an ordinary stack variable.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-29 21:26:26 +01:00
Timo Rothenpieler 2f323b1978 avutil/hwcontext_qsv: fix typo 2022-01-29 15:37:38 +01:00
nyanmisaka 4cc7239d8b libavutil/hwcontext_opencl: fix a bug for mapping qsv frame to opencl
mfxHDLPair was added to qsv, so modify qsv->opencl map function as well.
Now the following commandline works:

ffmpeg -v verbose -init_hw_device vaapi=va:/dev/dri/renderD128 \
-init_hw_device qsv=qs@va -init_hw_device opencl=ocl@va -filter_hw_device ocl \
-hwaccel qsv -hwaccel_output_format qsv -hwaccel_device qs -c:v h264_qsv \
-i input.264 -vf "hwmap=derive_device=opencl,format=opencl,avgblur_opencl, \
hwmap=derive_device=qsv:reverse=1:extra_hw_frames=32,format=qsv" \
-c:v h264_qsv output.264

Signed-off-by: nyanmisaka <nst799610810@gmail.com>
Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
2022-01-29 12:02:52 +08:00
Lynne 35080149ef
x86/tx_float: mark AVX2 functions as AVXSLOW
Makes Bulldozer prefer AVX functions rather than AVX2,
which are 64% slower:

AVX:  117653 decicycles in av_tx (fft), 1048535 runs,     41 skips
AVX2: 193385 decicycles in av_tx (fft), 1048561 runs,     15 skips

The only difference between both is that vgatherdpd is used in
the former. We don't want to mark them with the new SLOW_GATHER
flag however, since gathers are still faster on Haswell/Zen 2/3
than plain loads.
2022-01-29 03:08:16 +01:00
Lynne 7e35e0224c
lavu/tx: do not unconditionally free subcontexts if initialization fails
If a codelet initializes 2 subtransforms, and the second one fails,
the failure would free all subcontexts.
Instead, if there are subcontexts still left, don't free the array.
If all initializations fail, the init() function will return,
and reset_ctx() from the previous step will clean up all contained
subtransforms.
2022-01-29 01:02:37 +01:00
Lynne 265731f201
lavu/tx: reset subcontext pointer if initialization fails
Thanks to mkver for pointing this out.
2022-01-29 00:53:35 +01:00
Lynne 95f02e43e1
lavu/tx: print debug info even if no transforms are found 2022-01-28 08:28:02 +01:00
Steven Liu 9887ec3e9b avutil/tx: add null pointer check after av_mallocz
Fix CID: 1497863
there will get null pointer in attempt to initialize each if alloc memory failed.

Signed-off-by: Steven Liu <liuqi05@kuaishou.com>
2022-01-28 08:27:48 +01:00
Steven Liu f0044d886f avutil/tx: remove deadcode of the control flow
Fix CID: 1497864
The control flow should return ENOSYS if nb_cd_matches is 0 at before
and the ret equal AVERROR(ENOMEM) or goto end label, so remove the last
control flow if (ret >= 0) before end label.

Signed-off-by: Steven Liu <liuqi05@kuaishou.com>
2022-01-28 08:27:46 +01:00
Lynne 3c831847a8
hwcontext_vulkan: avoid using 64-bit enums
MSVC (2016, but possibly more) still force enums to be basic ints.
2022-01-27 10:27:09 +01:00
Lynne 238e11b71f
lavu/tx: avoid using 64-bit enums
MSVC (2016, but possibly more) still force enums to be basic ints.
2022-01-27 10:21:25 +01:00
Lynne 6c397f6bb5
x86/tx_float: add missing FF_TX_OUT_OF_PLACE flag to functions
This caused smaller length dedicated transforms to not be picked up.
2022-01-27 02:18:35 +01:00
Lynne 008c131d68
lavu/tx: clean up CPU flags check
Just makes it more readable.
2022-01-27 02:18:06 +01:00
Lynne 9787005846
x86/tx_float: do not build tx_float_init.c if x86 assembly is disabled
This broke builds with --disable-mmx, which also disabled assembly
entirely, but ARCH_X86 was still true, so the init file tried to find
assembly that didn't exist.
Instead of checking for architecture, check if external x86 assembly
is enabled.
2022-01-27 02:17:46 +01:00
Lynne 6c8e841824
lavu/tx: do not mix declarations and code 2022-01-26 04:55:23 +01:00
Lynne 28bff6ae54
x86/tx_float: add permute-free FFT versions
These are used in the PFA transforms and MDCTs.
2022-01-26 04:13:58 +01:00
Lynne 350142560b
lavu: bump minor and add APIchanges for new lavu/tx additions 2022-01-26 04:13:57 +01:00
Lynne af94ab7c7c
lavu/tx: add an RDFT implementation
RDFTs are full of conventions that vary between implementations.
What I've gone for here is what's most common between
both fftw, avcodec's rdft and what we use, the equivalent of
which is DFT_R2C for forward and IDFT_C2R for inverse. The
other 2 conventions (IDFT_R2C and DFT_C2R) were not used at
all in our code, and their names are also not appropriate.
If there's a use for either, we can easily add a flag which
would just flip the sign on one exptab.

For some unknown reason, possibly to allow reusing FFT's exp tables,
av_rdft's C2R output is 0.5x lower than what it should be to ensure
a proper back-and-forth conversion.
This code outputs its real samples at the correct level, which
matches FFTW's level, and allows the user to change the level
and insert arbitrary multiplies for free by setting the scale option.
2022-01-26 04:12:46 +01:00
Lynne ef4bd81615
lavu/tx: rewrite internal code as a tree-based codelet constructor
This commit rewrites the internal transform code into a constructor
that stitches transforms (codelets).
This allows for transforms to reuse arbitrary parts of other
transforms, and allows transforms to be stacked onto one
another (such as a full iMDCT using a half-iMDCT which in turn
uses an FFT). It also permits for each step to be individually
replaced by assembly or a custom implementation (such as an ASIC).
2022-01-26 04:12:44 +01:00
Lynne c14976be04
lavu/tx: improve documentation for existing transforms 2022-01-26 04:12:37 +01:00
Diederick Niehorster 7247a6fed8 avutil/pixfmt.h: typo
Signed-off-by: Diederick Niehorster <dcnieho@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-21 11:58:23 +01:00
Anton Khirnov 137c808f1a lavu/hwcontext_vulkan: clear dangling pointers on map failure 2022-01-21 09:44:01 +01:00
Limin Wang 8b9ef5a516 avutil/parseutils: use quadhd for Quad HD
qHD is 960x540 (q stands for quarter) and QHD is 2560x1440 (Q is quad).
use quadhd for QHD for abbreviation.

Fix ticket#9591

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2022-01-12 13:42:26 +08:00
Anton Khirnov f480c43dfa lavu/fifo: return errors on trying to read/write too much
Trying to write too much will currently overwrite previous data. Trying
to read too much will either av_assert2() in av_fifo_drain() or return
old data. Trying to peek too much will either av_assert2() in
av_fifo_generic_peek_at() or return old data.

Return an error code in all these cases, which is safer and more
consistent.
2022-01-10 16:11:34 +01:00
Anton Khirnov 53f513c60b lavu/fifo: drop useless comments
This object was never intended to be thread-safe, so these carry no
useful information.
2022-01-10 16:11:18 +01:00
Anton Khirnov 549ccea54e lavu/fifo: do not copy the whole fifo when reallocating
av_realloc() the buffer and only move the part of the ring buffer that
needs it. Also avoids allocating a temporary fifo.
2022-01-10 16:05:57 +01:00
Anton Khirnov 5010c481d1 lavu/fifo: simplify av_fifo_alloc()
Turn it into a wrapper around av_fifo_alloc_array().
2022-01-10 16:05:20 +01:00
Anton Khirnov 63b013aa68 lavu/fifo: deprecate av_fifo_peek2()
It returns a pointer inside the fifo's buffer, which cannot be safely
used without accessing AVFifoBuffer internals. It is easier and safer to
use av_fifo_generic_peek_at().
2022-01-10 16:04:19 +01:00
Cameron Gutman 242ed971cb lavu/videotoolbox: add support for memory mapping frames
Signed-off-by: Cameron Gutman <aicommander@gmail.com>
Signed-off-by: Aman Karmani <aman@tmm1.net>
2022-01-06 19:17:42 -08:00
Wu Jianhua c4ecc643bb avutil/hwcontext_vulkan: fixed incorrect memory offset
This commit fixed hwupload in Vulkan:

ffmpeg -init_hw_device vulkan -i test.jpg -vf hwupload,hwdownload,format=yuv420p -y out.jpg

Signed-off-by: Wu Jianhua <jianhua.wu@intel.com>
2022-01-05 14:13:39 +01:00
Haihao Xiang 7c6f9b9d63 Revert "avutils/hwcontext: When deriving a hwdevice, search for existing device in both directions"
This reverts commit a428949775.
There were objections on ML (see
https://ffmpeg.org/pipermail/ffmpeg-devel/2021-December/290530.html)

Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2022-01-05 11:56:58 +08:00
Soft Works a428949775 avutils/hwcontext: When deriving a hwdevice, search for existing device in both directions
The test /libavutil/tests/hwdevice checks that when deriving a device
from a source device and then deriving back to the type of the source
device, the result is matching the original source device, i.e. the
derivation mechanism doesn't create a new device in this case.

Previously, this test was usually passed, but only due to two different
kind of flaws:

1. The test covers only a single level of derivation (and back)

It derives device Y from device X and then Y back to the type of X and
checks whether the result matches X.

What it doesn't check for, are longer chains of derivation like:

CUDA1 > OpenCL2 > CUDA3 and then back to OpenCL4

In that case, the second derivation returns the first device (CUDA3 ==
CUDA1), but when deriving OpenCL4, hwcontext.c was creating a new
OpenCL4 context instead of returning OpenCL2, because there was no link
from CUDA1 to OpenCL2 (only backwards from OpenCL2 to CUDA1)

If the test would check for two levels of derivation, it would have
failed.

This patch fixes those (yet untested) cases by introducing forward
references (derived_device) in addition to the existing back references
(source_device).

2. hwcontext_qsv didn't properly set the source_device

In case of QSV, hwcontext_qsv creates a source context internally
(vaapi, dxva2 or d3d11va) without calling av_hwdevice_ctx_create_derived
and without setting source_device.

This way, the hwcontext test ran successful, but what practically
happened, was that - for example - deriving vaapi from qsv didn't return
the original underlying vaapi device and a new one was created instead:
Exactly what the test is intended to detect and prevent. It just
couldn't do so, because the original device was hidden (= not set as the
source_device of the QSV device).

This patch properly makes these setting and fixes all derivation
scenarios.

(at a later stage, /libavutil/tests/hwdevice should be extended to check
longer derivation chains as well)

Reviewed-by: Lynne <dev@lynne.ee>
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Tested-by: Wenbin Chen <wenbin.chen@intel.com>
Signed-off-by: softworkz <softworkz@hotmail.com>
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2022-01-05 11:05:06 +08:00
Andreas Rheinhardt b189550137 lib*/version.h: Bump Versions after release/5.0 branch
This is done a second time for 5.0 because master was
merged into 5.0 so that it contains the recent DOVI additions.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-04 14:29:06 +01:00