Commit Graph

35 Commits

Author SHA1 Message Date
Andreas Rheinhardt 3e669b24e2 avutil/hwcontext: Allocate AVHWFramesCtx jointly with its internals
This is possible because the lifetime of these structures coincide.
It has the advantage of allowing to remove AVHWFramesInternal
from the public header; given that AVHWFramesInternal.priv is no more,
most accesses to AVHWFramesInternal are no more; indeed, the only
field accessed of it outside of hwcontext.c is the internal frame pool,
making this commit very simple.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-07 08:53:31 -03:00
Andreas Rheinhardt c0a1ce1c40 avutil/hwcontext_opencl: 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 OpenCLFramesContext as one no longer has to
go through AVHWFramesInternal.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-04 00:05:11 +01:00
Andreas Rheinhardt c305dbf745 avutil/hwcontext_opencl: Allocate pub 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 OpenCLDeviceContext as one no longer has to
go through AVHWDeviceInternal.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-04 00:04:38 +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
Andreas Rheinhardt aa3bf6d41c avutil/hwcontext_opencl: Use proper OpenCLFramesContext
The currently used pointer when unmapping DXVA2 and D3D11
actually points to an OpenCLDeviceContext.

Reviewed-by: Mark Thompson <sw@jkqxz.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-13 15:33:30 +01:00
Haihao Xiang 3e61b7dd7f qsv: remove mfx/ prefix from mfx headers
The following Cflags has been added to libmfx.pc, so mfx/ prefix is no
longer needed when including mfx headers in FFmpeg.
   Cflags: -I${includedir} -I${includedir}/mfx

Some old versions of libmfx have the following Cflags in libmfx.pc
   Cflags: -I${includedir}

We may add -I${includedir}/mfx to CFLAGS when running 'configure
--enable-libmfx' for old versions of libmfx, if so, mfx headers without
mfx/ prefix can be included too.

If libmfx comes without pkg-config support, we may do a small change to
the settings of the environment(e.g. set -I/opt/intel/mediasdk/include/mfx
instead of -I/opt/intel/mediasdk/include to CFLAGS), then the build can
find the mfx headers without mfx/ prefix

After applying this change, we won't need to change #include for mfx
headers when mfx headers are installed under a new directory.

This is in preparation for oneVPL support (mfx headers in oneVPL are
installed under vpl directory)
2022-08-12 10:43:39 +08:00
Paul B Mahol 6ed9eaf664 avfilter: add remap opencl filter 2022-07-07 17:52:32 +02:00
Anton Khirnov 6fc5e5a52c lavu/hwcontext_opencl: clear dangling pointers on map failure 2022-02-17 11:05:44 +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
Andreas Rheinhardt 1ea3650823 Replace all occurences of av_mallocz_array() by av_calloc()
They do the same.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-20 01:03:52 +02:00
Andreas Rheinhardt ef6a9e5e31 avutil/buffer: Switch AVBuffer API to size_t
Announced in 14040a1d91.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27 10:43:13 -03:00
James Almer e36eb94048 avutil: use the buffer_size_t typedef where required
Signed-off-by: James Almer <jamrial@gmail.com>
2021-03-10 20:26:37 -03:00
Lynne 2e08b39444
hwcontext: add av_hwdevice_ctx_create_derived_opts
This allows for users who derive devices to set options for the
new device context they derive.
The main use case of this is to allow users to enable extensions
(such as surface drawing extensions) in Vulkan while deriving from
the device their frames are on. That way, users don't need to write
any initialization code themselves, since the Vulkan spec invalidates
mixing instances, physical devices and active devices.
Apart from Vulkan, other hwcontexts ignore the opts argument since they
don't support options at all (or in VAAPI and OpenCL's case, options are
currently only used for device selection, which device_derive overrides).
2020-05-23 19:07:26 +01:00
Jarek Samic 1c50d61a5a libavutil/hwcontext_opencl: Fix channel order in format support check
The `opencl_get_plane_format` function was incorrectly determining the
value used to set the image channel order. This resulted in all RGB
pixel formats being set to the `CL_RGBA` pixel format, regardless of
whether or not they actually *were* RGBA.

This patch fixes the issue by using the `offset` and depth of components
rather than the loop index to determine the value of `order`.

Signed-off-by: Jarek Samic <cldfire3@gmail.com>
Signed-off-by: Mark Thompson <sw@jkqxz.net>
2019-04-09 22:16:01 +01:00
Ruiling Song 61cb505d18 lavu/opencl: replace va_ext.h with standard name
Khronos OpenCL header (https://github.com/KhronosGroup/OpenCL-Headers)
uses cl_va_api_media_sharing_intel.h. And Intel's official OpenCL driver
for Intel GPU (https://github.com/intel/compute-runtime) was compiled
against Khronos OpenCL header. So it's better to align with Khronos.

Signed-off-by: Ruiling Song <ruiling.song@intel.com>
2019-03-22 09:33:28 +08:00
Mark Thompson 21608bc303 hwcontext_opencl: Use correct function to enumerate devices
Also assert that all required functions are present.
2018-12-02 23:39:19 +00:00
Mark Thompson b9aff7a53d hwcontext_opencl: Only release command queue if it exists
If the frames context creation fails then the command queue reference
need not exist when uninit is called.
2018-11-28 00:05:09 +00:00
Jun Zhao 6b453a81bc hwcontext_opencl: remove an unused variable
remove an unused variable

Signed-off-by: Jun Zhao <mypopydev@gmail.com>
2018-06-29 05:23:49 +08:00
Jun Zhao e6ac328b79 hwcontext_opencl: Remove the opencl_device_init in opencl_device_derive
In opencl device derived case, don't need to call opencl_device_init.

Signed-off-by: Jun Zhao <mypopydev@gmail.com>
2018-06-29 05:23:20 +08:00
Jun Zhao 2730a0fdf4 configure: fix check for opencl_vaapi_intel_media.
opencl_vaapi_intel_media doesn't depend on libmfx, OpenCL™ Drivers
and Runtimes for Intel® Architectureis is a standalone release, more
information can be found in the link:
https://software.intel.com/en-us/articles/opencl-drivers.

Signed-off-by: Jun Zhao <mypopydev@gmail.com>
2018-06-29 05:17:36 +08:00
Mark Thompson 7ff5310068 hwcontext_opencl: Remove unused variable
Unused since a2613647c4.
2018-06-24 19:37:39 +01:00
Rostislav Pehlivanov a2613647c4 hwcontext_opencl: use ff_hwframe_map_replace()
Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
2018-06-21 16:34:10 +01:00
Jun Zhao 3bab7b70da lavu/hwcontext_opecl: fix the build warning
fix the build warning when use Portable Computing Language (pocl).

Signed-off-by: Jun Zhao <mypopydev@gmail.com>
2018-06-07 19:38:58 +08:00
Ruiling Song e4006a474f lavu: add calling convention for OpenCL callback.
This fix a build error on Windows:
C2440: connot convert from 'void (__cdecl *) (...)' to 'void (__stdcall *)(...)'.

Signed-off-by: Ruiling Song <ruiling.song@intel.com>
2018-06-06 23:13:00 +01:00
Mark Thompson ac993e73de hwcontext_opencl: Add support for mapping DRM objects to Beignet
Also use that to support mapping VAAPI to Beignet.
2018-03-22 23:19:00 +00:00
Mark Thompson 9313422dfc hwcontext_opencl: Avoid deprecation warnings when built with post-1.2 headers
Matching the previous commit.  This is not applied to the installed header
because it could incorrectly suppress the warning inside user programs.
2018-03-22 23:14:30 +00:00
Carl Eugen Hoyos 9b79c65ec0 lavu/lavc/lavf/lavfi: Do not use type modifier %zu on Windows MSVCRT. 2017-12-17 18:05:42 +01:00
Mark Thompson f4e319d8a9 hwcontext_opencl: Reset internal command queue on device_uninit
device_uninit can be called twice if device_init fails.
2017-11-25 15:44:31 +00:00
Mark Thompson 7faae6e745 hwcontext_opencl: DRM to OpenCL mapping for ARM
Using cl_arm_import_memory.  Unfortunately, despite this not being a
standard extension, the function clImportMemoryARM() is not accessible
via clGetExtensionFunctionAddressForPlatform().  This means that it has
to be linked directly to the ARM OpenCL binary, so making a portable
binary is not possible as it is with all other mapping extensions.
2017-11-22 23:02:33 +00:00
Mark Thompson f06754e4f3 hwcontext_opencl: D3D11 to OpenCL mapping
Using cl_khr_d3d11_sharing and cl_intel_d3d11_nv12_media_sharing.
2017-11-22 23:02:33 +00:00
Mark Thompson 9e7cda1b1e hwcontext_opencl: DXVA2 to OpenCL mapping
Using cl_khr_dx9_media_sharing.
2017-11-22 23:02:33 +00:00
Mark Thompson 403cde8e85 hwcontext_opencl: QSV to OpenCL mapping for Intel Media SDK
Uses the cl_intel_va_api_media_sharing extension, which supports only
NV12 surfaces and only mapping from QSV to OpenCL.
2017-11-22 23:02:33 +00:00
Mark Thompson eb3e9f469a hwcontext_opencl: VAAPI to OpenCL mapping for Intel i965+beignet
Supports all surface formats in common between the two.
2017-11-22 23:02:33 +00:00
Mark Thompson b25d8ef0a7 lavu: OpenCL hwcontext implementation 2017-11-22 23:02:29 +00:00