You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-07-16 22:42:38 +02:00
lavu: OpenCL hwcontext implementation
This commit is contained in:
4
configure
vendored
4
configure
vendored
@ -289,7 +289,7 @@ External library support:
|
|||||||
--enable-mediacodec enable Android MediaCodec support [no]
|
--enable-mediacodec enable Android MediaCodec support [no]
|
||||||
--enable-libmysofa enable libmysofa, needed for sofalizer filter [no]
|
--enable-libmysofa enable libmysofa, needed for sofalizer filter [no]
|
||||||
--enable-openal enable OpenAL 1.1 capture support [no]
|
--enable-openal enable OpenAL 1.1 capture support [no]
|
||||||
--enable-opencl enable OpenCL code
|
--enable-opencl enable OpenCL processing [no]
|
||||||
--enable-opengl enable OpenGL rendering [no]
|
--enable-opengl enable OpenGL rendering [no]
|
||||||
--enable-openssl enable openssl, needed for https support
|
--enable-openssl enable openssl, needed for https support
|
||||||
if gnutls is not used [no]
|
if gnutls is not used [no]
|
||||||
@ -1633,7 +1633,6 @@ EXTERNAL_LIBRARY_LIST="
|
|||||||
libzvbi
|
libzvbi
|
||||||
mediacodec
|
mediacodec
|
||||||
openal
|
openal
|
||||||
opencl
|
|
||||||
opengl
|
opengl
|
||||||
"
|
"
|
||||||
|
|
||||||
@ -1669,6 +1668,7 @@ HWACCEL_LIBRARY_LIST="
|
|||||||
libmfx
|
libmfx
|
||||||
mmal
|
mmal
|
||||||
omx
|
omx
|
||||||
|
opencl
|
||||||
"
|
"
|
||||||
|
|
||||||
DOCUMENT_LIST="
|
DOCUMENT_LIST="
|
||||||
|
@ -15,6 +15,10 @@ libavutil: 2017-10-21
|
|||||||
|
|
||||||
API changes, most recent first:
|
API changes, most recent first:
|
||||||
|
|
||||||
|
2017-11-xx - xxxxxxx - lavu 55.2.0 - hwcontext.h hwcontext_opencl.h
|
||||||
|
Add AV_HWDEVICE_TYPE_OPENCL and a new installed header with
|
||||||
|
OpenCL-specific hwcontext definitions.
|
||||||
|
|
||||||
2017-11-xx - xxxxxxx - lavu 55.1.0 - pixfmt.h
|
2017-11-xx - xxxxxxx - lavu 55.1.0 - pixfmt.h
|
||||||
Add AV_PIX_FMT_OPENCL.
|
Add AV_PIX_FMT_OPENCL.
|
||||||
|
|
||||||
|
@ -165,6 +165,7 @@ OBJS-$(CONFIG_QSV) += hwcontext_qsv.o
|
|||||||
OBJS-$(CONFIG_LIBDRM) += hwcontext_drm.o
|
OBJS-$(CONFIG_LIBDRM) += hwcontext_drm.o
|
||||||
OBJS-$(CONFIG_LZO) += lzo.o
|
OBJS-$(CONFIG_LZO) += lzo.o
|
||||||
OBJS-$(CONFIG_OPENCL) += opencl.o opencl_internal.o
|
OBJS-$(CONFIG_OPENCL) += opencl.o opencl_internal.o
|
||||||
|
OBJS-$(CONFIG_OPENCL) += hwcontext_opencl.o
|
||||||
OBJS-$(CONFIG_VAAPI) += hwcontext_vaapi.o
|
OBJS-$(CONFIG_VAAPI) += hwcontext_vaapi.o
|
||||||
OBJS-$(CONFIG_VIDEOTOOLBOX) += hwcontext_videotoolbox.o
|
OBJS-$(CONFIG_VIDEOTOOLBOX) += hwcontext_videotoolbox.o
|
||||||
OBJS-$(CONFIG_VDPAU) += hwcontext_vdpau.o
|
OBJS-$(CONFIG_VDPAU) += hwcontext_vdpau.o
|
||||||
@ -179,6 +180,7 @@ SKIPHEADERS-$(CONFIG_CUDA) += hwcontext_cuda_internal.h
|
|||||||
SKIPHEADERS-$(CONFIG_D3D11VA) += hwcontext_d3d11va.h
|
SKIPHEADERS-$(CONFIG_D3D11VA) += hwcontext_d3d11va.h
|
||||||
SKIPHEADERS-$(CONFIG_DXVA2) += hwcontext_dxva2.h
|
SKIPHEADERS-$(CONFIG_DXVA2) += hwcontext_dxva2.h
|
||||||
SKIPHEADERS-$(CONFIG_QSV) += hwcontext_qsv.h
|
SKIPHEADERS-$(CONFIG_QSV) += hwcontext_qsv.h
|
||||||
|
SKIPHEADERS-$(CONFIG_OPENCL) += hwcontext_opencl.h
|
||||||
SKIPHEADERS-$(CONFIG_VAAPI) += hwcontext_vaapi.h
|
SKIPHEADERS-$(CONFIG_VAAPI) += hwcontext_vaapi.h
|
||||||
SKIPHEADERS-$(CONFIG_VIDEOTOOLBOX) += hwcontext_videotoolbox.h
|
SKIPHEADERS-$(CONFIG_VIDEOTOOLBOX) += hwcontext_videotoolbox.h
|
||||||
SKIPHEADERS-$(CONFIG_VDPAU) += hwcontext_vdpau.h
|
SKIPHEADERS-$(CONFIG_VDPAU) += hwcontext_vdpau.h
|
||||||
|
@ -41,6 +41,9 @@ static const HWContextType * const hw_table[] = {
|
|||||||
#if CONFIG_DXVA2
|
#if CONFIG_DXVA2
|
||||||
&ff_hwcontext_type_dxva2,
|
&ff_hwcontext_type_dxva2,
|
||||||
#endif
|
#endif
|
||||||
|
#if CONFIG_OPENCL
|
||||||
|
&ff_hwcontext_type_opencl,
|
||||||
|
#endif
|
||||||
#if CONFIG_QSV
|
#if CONFIG_QSV
|
||||||
&ff_hwcontext_type_qsv,
|
&ff_hwcontext_type_qsv,
|
||||||
#endif
|
#endif
|
||||||
@ -61,6 +64,7 @@ static const char *const hw_type_names[] = {
|
|||||||
[AV_HWDEVICE_TYPE_DRM] = "drm",
|
[AV_HWDEVICE_TYPE_DRM] = "drm",
|
||||||
[AV_HWDEVICE_TYPE_DXVA2] = "dxva2",
|
[AV_HWDEVICE_TYPE_DXVA2] = "dxva2",
|
||||||
[AV_HWDEVICE_TYPE_D3D11VA] = "d3d11va",
|
[AV_HWDEVICE_TYPE_D3D11VA] = "d3d11va",
|
||||||
|
[AV_HWDEVICE_TYPE_OPENCL] = "opencl",
|
||||||
[AV_HWDEVICE_TYPE_QSV] = "qsv",
|
[AV_HWDEVICE_TYPE_QSV] = "qsv",
|
||||||
[AV_HWDEVICE_TYPE_VAAPI] = "vaapi",
|
[AV_HWDEVICE_TYPE_VAAPI] = "vaapi",
|
||||||
[AV_HWDEVICE_TYPE_VDPAU] = "vdpau",
|
[AV_HWDEVICE_TYPE_VDPAU] = "vdpau",
|
||||||
|
@ -34,6 +34,7 @@ enum AVHWDeviceType {
|
|||||||
AV_HWDEVICE_TYPE_VIDEOTOOLBOX,
|
AV_HWDEVICE_TYPE_VIDEOTOOLBOX,
|
||||||
AV_HWDEVICE_TYPE_D3D11VA,
|
AV_HWDEVICE_TYPE_D3D11VA,
|
||||||
AV_HWDEVICE_TYPE_DRM,
|
AV_HWDEVICE_TYPE_DRM,
|
||||||
|
AV_HWDEVICE_TYPE_OPENCL,
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct AVHWDeviceInternal AVHWDeviceInternal;
|
typedef struct AVHWDeviceInternal AVHWDeviceInternal;
|
||||||
|
@ -161,6 +161,7 @@ extern const HWContextType ff_hwcontext_type_cuda;
|
|||||||
extern const HWContextType ff_hwcontext_type_d3d11va;
|
extern const HWContextType ff_hwcontext_type_d3d11va;
|
||||||
extern const HWContextType ff_hwcontext_type_drm;
|
extern const HWContextType ff_hwcontext_type_drm;
|
||||||
extern const HWContextType ff_hwcontext_type_dxva2;
|
extern const HWContextType ff_hwcontext_type_dxva2;
|
||||||
|
extern const HWContextType ff_hwcontext_type_opencl;
|
||||||
extern const HWContextType ff_hwcontext_type_qsv;
|
extern const HWContextType ff_hwcontext_type_qsv;
|
||||||
extern const HWContextType ff_hwcontext_type_vaapi;
|
extern const HWContextType ff_hwcontext_type_vaapi;
|
||||||
extern const HWContextType ff_hwcontext_type_vdpau;
|
extern const HWContextType ff_hwcontext_type_vdpau;
|
||||||
|
1303
libavutil/hwcontext_opencl.c
Normal file
1303
libavutil/hwcontext_opencl.c
Normal file
File diff suppressed because it is too large
Load Diff
96
libavutil/hwcontext_opencl.h
Normal file
96
libavutil/hwcontext_opencl.h
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of FFmpeg.
|
||||||
|
*
|
||||||
|
* FFmpeg is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* FFmpeg is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with FFmpeg; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef AVUTIL_HWCONTEXT_OPENCL_H
|
||||||
|
#define AVUTIL_HWCONTEXT_OPENCL_H
|
||||||
|
|
||||||
|
#include <CL/cl.h>
|
||||||
|
|
||||||
|
#include "frame.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* API-specific header for AV_HWDEVICE_TYPE_OPENCL.
|
||||||
|
*
|
||||||
|
* Pools allocated internally are always dynamic, and are primarily intended
|
||||||
|
* to be used in OpenCL-only cases. If interoperation is required, it is
|
||||||
|
* typically required to allocate frames in the other API and then map the
|
||||||
|
* frames context to OpenCL with av_hwframe_ctx_create_derived().
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OpenCL frame descriptor for pool allocation.
|
||||||
|
*
|
||||||
|
* In user-allocated pools, AVHWFramesContext.pool must return AVBufferRefs
|
||||||
|
* with the data pointer pointing at an object of this type describing the
|
||||||
|
* planes of the frame.
|
||||||
|
*/
|
||||||
|
typedef struct AVOpenCLFrameDescriptor {
|
||||||
|
/**
|
||||||
|
* Number of planes in the frame.
|
||||||
|
*/
|
||||||
|
int nb_planes;
|
||||||
|
/**
|
||||||
|
* OpenCL image2d objects for each plane of the frame.
|
||||||
|
*/
|
||||||
|
cl_mem planes[AV_NUM_DATA_POINTERS];
|
||||||
|
} AVOpenCLFrameDescriptor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OpenCL device details.
|
||||||
|
*
|
||||||
|
* Allocated as AVHWDeviceContext.hwctx
|
||||||
|
*/
|
||||||
|
typedef struct AVOpenCLDeviceContext {
|
||||||
|
/**
|
||||||
|
* The primary device ID of the device. If multiple OpenCL devices
|
||||||
|
* are associated with the context then this is the one which will
|
||||||
|
* be used for all operations internal to FFmpeg.
|
||||||
|
*/
|
||||||
|
cl_device_id device_id;
|
||||||
|
/**
|
||||||
|
* The OpenCL context which will contain all operations and frames on
|
||||||
|
* this device.
|
||||||
|
*/
|
||||||
|
cl_context context;
|
||||||
|
/**
|
||||||
|
* The default command queue for this device, which will be used by all
|
||||||
|
* frames contexts which do not have their own command queue. If not
|
||||||
|
* intialised by the user, a default queue will be created on the
|
||||||
|
* primary device.
|
||||||
|
*/
|
||||||
|
cl_command_queue command_queue;
|
||||||
|
} AVOpenCLDeviceContext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OpenCL-specific data associated with a frame pool.
|
||||||
|
*
|
||||||
|
* Allocated as AVHWFramesContext.hwctx.
|
||||||
|
*/
|
||||||
|
typedef struct AVOpenCLFramesContext {
|
||||||
|
/**
|
||||||
|
* The command queue used for internal asynchronous operations on this
|
||||||
|
* device (av_hwframe_transfer_data(), av_hwframe_map()).
|
||||||
|
*
|
||||||
|
* If this is not set, the command queue from the associated device is
|
||||||
|
* used instead.
|
||||||
|
*/
|
||||||
|
cl_command_queue command_queue;
|
||||||
|
} AVOpenCLFramesContext;
|
||||||
|
|
||||||
|
#endif /* AVUTIL_HWCONTEXT_OPENCL_H */
|
@ -80,7 +80,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#define LIBAVUTIL_VERSION_MAJOR 56
|
#define LIBAVUTIL_VERSION_MAJOR 56
|
||||||
#define LIBAVUTIL_VERSION_MINOR 1
|
#define LIBAVUTIL_VERSION_MINOR 2
|
||||||
#define LIBAVUTIL_VERSION_MICRO 100
|
#define LIBAVUTIL_VERSION_MICRO 100
|
||||||
|
|
||||||
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
|
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
|
||||||
|
Reference in New Issue
Block a user