Commit Graph

6106 Commits

Author SHA1 Message Date
Andreas Rheinhardt
c346c097af avutil/vulkan: Make ff_vk_set_descriptor_image() static
Only used in vulkan.c.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-03 22:56:21 +01:00
Andreas Rheinhardt
c0d31cec7f avutil/vulkan: Avoid shadowing
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-03 22:56:17 +01:00
Andreas Rheinhardt
0a05577d1e avutil/vulkan_loader: Avoid relocations for strings
To do so, concatenate all the names together to one big string
name1\0name2\0....lastname\0\0. This avoids the pointer in
the FunctionLoadInfo structure and thereby moves vk_load_info
into .rodata (and makes it smaller by 888B).

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-03 22:56:07 +01:00
Andreas Rheinhardt
674f20813d avutil/vulkan_loader: Use smaller types
Saves 16B per entry here (four of these 16 bytes are padding);
leads to 1776 B of savings in each file that uses
ff_vk_load_functions().

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-03 22:55:52 +01:00
Andreas Rheinhardt
e9b4f4461f avutil/vulkan_loader: Avoid redundant strings and relocations
There are three possible names for the functions requested;
they only differ in an extension: "", "EXT" or "KHR".
Yet vk_load_info contained pointers to all these strings.
This is wasteful and this commit changes it to avoid
the latter two strings. This saves 6353B of strings,
1776 B of .data.rel.ro as well as 5328 B due to the removed
relocations (corresponding to 2 * 111 removed pointers)
in lavc/vulkan_decode.o alone (ff_vk_load_functions()
is inlined in lavfi/vulkan_filter.c, lavu/hwcontext_vulkan.c
and lavc_vulkan_decode.c, so the savings are three times
this for shared builds; for static builds, the number may
be smaller depending upon whether strings are deduplicated).

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-03 22:55:44 +01:00
Andreas Rheinhardt
e429b0fdb7 avutil/vulkan: Don't autoinclude vulkan_loader.h
Only include it where necessary.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-03 22:55:26 +01:00
Andreas Rheinhardt
58e3ef7f54 avutil/timestamp: Constify av_ts_make_time_string()
(Actually, the time base should be passed by value.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-02 02:51:10 +01:00
Andreas Rheinhardt
e70e9b6554 avutil/hwcontext_vulkan: Allocate pub and priv frames hwctx together
This is possible because the lifetime of both coincide.
Besides reducing the number of allocations this also simplifies
access to VulkanFramesPriv as one no longer has to
go through AVHWFramesInternal.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-01 18:48:06 +01:00
Andreas Rheinhardt
2d63379cae avutil/hwcontext_vulkan: Allocate public and priv device hwctx together
This is possible because the lifetime of both coincide.
Besides reducing the number of allocations this also simplifies
access to VulkanDevicePriv as one no longer has to
go through AVHWDeviceInternal.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-01 18:48:06 +01:00
Andreas Rheinhardt
ac7e72972c avutil/hwcontext_cuda: Allocate public and internal device ctx jointly
Reviewed-by: Timo Rothenpieler <timo@rothenpieler.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-01 18:32:40 +01:00
Andreas Rheinhardt
8d277de009 avutil/hwcontext_cuda: Don't use AVHWFramesInternal.priv
Use AVHWFramesContext.hwctx instead.
This simplifies accesses to VDPAUFramesContext as one no longer has
to go through AVHWFramesInternal.

Tested-by: Timo Rothenpieler <timo@rothenpieler.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-01 18:32:01 +01:00
Andreas Rheinhardt
cb92b4bd83 avutil/hwcontext: Clarify documentation of AVHWFramesContext.hwctx
Correct the names of the format-specific headers (not hwframe_*.h)
and clarify that the user shall ignore this field if there is no
public context associated with it.
In particular, this allows to use this field for the private context
alone if there is no public context. This can't break conforming
API users, because they always have to live with the possibility
that a new public context has been introduced.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-01 18:32:01 +01:00
Anton Khirnov
200f82e3f8 lavu/opt: get rid of useless read_number() calls
The option type is known and fixed for all these, so reading the value
directly is simpler and more clear.
2024-03-01 16:57:24 +01:00
Anton Khirnov
1ffa657a03 lavu/opt: simplify error handling in get_number() 2024-03-01 16:57:24 +01:00
Anton Khirnov
84ba46fa5e lavu/opt: drop an always-NULL argument to get_number() 2024-03-01 16:57:24 +01:00
Anton Khirnov
9fabdd64b2 lavu/opt: drop useless handling of NULL return from get_bool_name()
That function always returns an actual string.
2024-03-01 16:57:24 +01:00
Anton Khirnov
333cc9bff8 lavu/opt: factor out printing option default from opt_list() 2024-03-01 16:57:24 +01:00
Anton Khirnov
8904f35133 lavu/opt: simplify printing option type in opt_list() 2024-03-01 16:57:24 +01:00
Anton Khirnov
6456dd50a6 lavu/opt: cosmetics, group option reading function together 2024-03-01 16:57:24 +01:00
Anton Khirnov
2a3a33d04b lavu/opt: cosmetics, group option setting function together 2024-03-01 16:57:24 +01:00
Anton Khirnov
cc0bd9da70 lavu/opt: cosmetics, group (un)init and management functions together 2024-03-01 16:57:24 +01:00
Anton Khirnov
067fde4966 lavu/opt: document AVOption.flags 2024-03-01 16:57:24 +01:00
Anton Khirnov
39a3a1c69b lavu/opt: cosmetics, move AV_OPT_FLAG_* out of AVOption
Also drop an obsolete FIXME.
2024-03-01 16:57:24 +01:00
Anton Khirnov
105a1bc150 lavu/opt: cosmetics, change option flags to (1 << N) style
It is easier to read. Also, change their doxy comments to use the same
style.
2024-03-01 16:57:24 +01:00
Zhao Zhili
f7545e90df avutil/hwcontext_opencl: Add map from Videotoolbox to OpenCL
For example:
./ffmpeg -hwaccel videotoolbox \
	-hwaccel_output_format videotoolbox_vld \
	-i foo.mp4 \
	-vf hwmap=derive_device=opencl,transpose_opencl=dir=clock,hwmap,format=nv12 \
	-c:v hevc_videotoolbox \
	-c:a copy \
	-b:v 2M -tag:v hvc1 bar.mp4

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2024-03-01 17:24:00 +08:00
Zhao Zhili
dcfc6089b1 avutil/hwcontext_opencl: Fix missing linesize when map from opencl
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2024-03-01 17:23:50 +08:00
Zhao Zhili
74e27d9e31 avutil/hwcontext_vulkan: Fix memleaks when transfer to vulkan
Without ff_vk_exec_discard_deps which is called by ff_vk_exec_wait,
the reference count of hwframe context cannot reach zero due to
circular reference created by ff_vk_exec_add_dep_frame.

Fix #10873

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2024-03-01 17:22:14 +08:00
Zhao Zhili
f6f06fb42a avutil/vulkan: avoid overreads in ff_vk_count_images
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2024-03-01 17:20:35 +08:00
Zhao Zhili
03275b0f09 avutil/hwcontext_vulkan: Fix leaks in map_from_drm
Also simplify error handing.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2024-03-01 17:20:29 +08:00
Zhao Zhili
6f9730cb28 avutil/hwcontext_vulkan: Fix leaks when semaphore creation fails
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2024-03-01 17:20:21 +08:00
Zhao Zhili
3bb00c0a42 avutil/hwcontext: Don't assume frames_uninit is reentrant
Fix heap use after free when vulkan_frames_init failed.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2024-03-01 17:20:00 +08:00
Zhao Zhili
90bbe1e8e2 avutil/hwcontext: Don't assume device_uninit is reentrant
device_uninit will be called by hwdevice_ctx_free. vulkan_device_uninit
is non-reentrant.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2024-03-01 17:19:52 +08:00
Andreas Rheinhardt
22dda5615e avutil/mem_internal: Remove unneeded headers
Unneeded since 21814a70db.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-01 01:35:42 +01:00
Timo Rothenpieler
7945d30e91 avutil/mem: limit alignment to maximum simd align
FFmpeg has instances of DECLARE_ALIGNED(32, ...) in a lot of structs,
which then end up heap-allocated.
By declaring any variable in a struct, or tree of structs, to be 32 byte
aligned, it allows the compiler to safely assume the entire struct
itself is also 32 byte aligned.

This might make the compiler emit code which straight up crashes or
misbehaves in other ways, and at least in one instances is now
documented to actually do (see ticket 10549 on trac).
The issue there is that an unrelated variable in SingleChannelElement is
declared to have an alignment of 32 bytes. So if the compiler does a copy
in decode_cpe() with avx instructions, but ffmpeg is built with
--disable-avx, this results in a crash, since the memory is only 16 byte
aligned.

Mind you, even if the compiler does not emit avx instructions, the code
is still invalid and could misbehave. It just happens not to. Declaring
any variable in a struct with a 32 byte alignment promises 32 byte
alignment of the whole struct to the compiler.

This patch limits the maximum alignment to the maximum possible simd
alignment according to configure.
While not perfect, it at the very least gets rid of a lot of UB, by
matching up the maximum DECLARE_ALIGNED value with the alignment of heap
allocations done by lavu.
2024-02-27 19:41:09 +01:00
Andreas Rheinhardt
2e4e424ac2 avutil/hwcontext: Don't check before av_buffer_unref()
av_buffer_unref() can handle AVBufferRef** that point
to a NULL AVBufferRef*.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-25 02:42:04 +01:00
Andreas Rheinhardt
f705b8b5b4 avutil/opt: Use correct function pointer type
av_get_sample/pix_fmt() return their respective enums
and are therefore not of the type int (*)(const char*),
yet they are called as-if they were of this type.
This works in practice, but is actually undefined behaviour.

With Clang 17 UBSan these violations are flagged, affecting lots
of tests. The number of failing tests went down from 3363 to 164
here with this patch.

Reviewed-by: Mark Thompson <sw@jkqxz.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-25 02:19:18 +01:00
James Almer
76b2bb96b4 avutil/tx: print debug log at trace level
The output of TX is extremely verbose and makes it harder to find other debug
log messages, so print most of it at trace level.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-02-22 00:29:59 -03:00
Andreas Rheinhardt
cb9f1f59a1 avutil/version: Remove outdated checks
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-21 01:07:03 +01:00
Andreas Rheinhardt
b6b33f7edd avutil/common: Move includes to the beginning of the file
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-21 00:23:39 +01:00
Andreas Rheinhardt
27cd7011bc avutil/tests/pixelutils: Remove dead code
Forgotten in e6b125e3be.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-21 00:23:20 +01:00
Andreas Rheinhardt
870d9730d6 avutil/hwcontext_vaapi: Allocate pub and priv frames hwctx together
This is possible because the lifetime of both coincide.
Besides reducing the number of allocations this also simplifies
access to VAAPIFramesContext as one no longer has to
go through AVHWFramesInternal.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-20 19:08:23 +01:00
Andreas Rheinhardt
520c1b0a7c avutil/hwcontext_vaapi: Allocate public and priv device hwctx together
This is possible because the lifetime of both coincide.
Besides reducing the number of allocations this also simplifies
access to VAAPIDeviceContext as one no longer has to
go through AVHWDeviceInternal.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-20 19:08:14 +01:00
Andreas Rheinhardt
e8cdce88e9 configure, libavutil/version: Remove unused HAVE_MMX2
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-20 00:09:05 +01:00
Andreas Rheinhardt
b96b3e291c avutil/intreadwrite: Remove obsolete warning
Obsolete since 7ec2354c38.

Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-20 00:09:05 +01:00
Lynne
c7ceff690f
lavu/tx: correctly use a default scale parameter for all transform types
This fixes the previous commit and adds more cases (DCT-I and DST-I).

I am holding off on defining a scale parameter for FFTs as I'd like
to use a complex value for them.
2024-02-18 16:21:03 +01:00
James Almer
b5911654c4 avutil/channel_layout: print known layout names in custom layout
If a custom layout is equivalent to a native one, check if it matches one of the
known layout names and print that instead.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-02-18 09:59:40 -03:00
Marton Balint
65c9c52a5a avutil/tests/channel_layout: add tests for av_channel_order_retype
Signed-off-by: Marton Balint <cus@passwd.hu>
2024-02-18 10:54:22 +01:00
Marton Balint
242901f7c2 avutil/channel_layout: add FF_CHANNEL_ORDER_NB
Signed-off-by: Marton Balint <cus@passwd.hu>
2024-02-18 10:43:12 +01:00
Marton Balint
2a12c04e35 avutil/channel_layout: change AV_CHAN_SILENCE to AV_CHAN_UNUSED in the docs
It got renamed during the API design phase.

Signed-off-by: Marton Balint <cus@passwd.hu>
2024-02-18 10:43:12 +01:00
Michael Niedermayer
eea9bd88a5
avutil/pixfmt: Add AV_VIDEO_MAX_PLANES
It seems we do not have a named identifier for the maximum planes of pixel formats

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-02-16 21:34:38 +01:00