FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
hwcontext_opencl.h
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #ifndef AVUTIL_HWCONTEXT_OPENCL_H
20 #define AVUTIL_HWCONTEXT_OPENCL_H
21 
22 #ifdef __APPLE__
23 #include <OpenCL/cl.h>
24 #else
25 #include <CL/cl.h>
26 #endif
27 
28 #include "frame.h"
29 
30 /**
31  * @file
32  * API-specific header for AV_HWDEVICE_TYPE_OPENCL.
33  *
34  * Pools allocated internally are always dynamic, and are primarily intended
35  * to be used in OpenCL-only cases. If interoperation is required, it is
36  * typically required to allocate frames in the other API and then map the
37  * frames context to OpenCL with av_hwframe_ctx_create_derived().
38  */
39 
40 /**
41  * OpenCL frame descriptor for pool allocation.
42  *
43  * In user-allocated pools, AVHWFramesContext.pool must return AVBufferRefs
44  * with the data pointer pointing at an object of this type describing the
45  * planes of the frame.
46  */
47 typedef struct AVOpenCLFrameDescriptor {
48  /**
49  * Number of planes in the frame.
50  */
51  int nb_planes;
52  /**
53  * OpenCL image2d objects for each plane of the frame.
54  */
57 
58 /**
59  * OpenCL device details.
60  *
61  * Allocated as AVHWDeviceContext.hwctx
62  */
63 typedef struct AVOpenCLDeviceContext {
64  /**
65  * The primary device ID of the device. If multiple OpenCL devices
66  * are associated with the context then this is the one which will
67  * be used for all operations internal to FFmpeg.
68  */
69  cl_device_id device_id;
70  /**
71  * The OpenCL context which will contain all operations and frames on
72  * this device.
73  */
74  cl_context context;
75  /**
76  * The default command queue for this device, which will be used by all
77  * frames contexts which do not have their own command queue. If not
78  * intialised by the user, a default queue will be created on the
79  * primary device.
80  */
81  cl_command_queue command_queue;
83 
84 /**
85  * OpenCL-specific data associated with a frame pool.
86  *
87  * Allocated as AVHWFramesContext.hwctx.
88  */
89 typedef struct AVOpenCLFramesContext {
90  /**
91  * The command queue used for internal asynchronous operations on this
92  * device (av_hwframe_transfer_data(), av_hwframe_map()).
93  *
94  * If this is not set, the command queue from the associated device is
95  * used instead.
96  */
97  cl_command_queue command_queue;
99 
100 #endif /* AVUTIL_HWCONTEXT_OPENCL_H */
#define AV_NUM_DATA_POINTERS
Definition: frame.h:227
OpenCL frame descriptor for pool allocation.
cl_device_id device_id
The primary device ID of the device.
cl_command_queue command_queue
The command queue used for internal asynchronous operations on this device (av_hwframe_transfer_data(...
reference-counted frame API
int nb_planes
Number of planes in the frame.
OpenCL-specific data associated with a frame pool.
cl_mem planes[AV_NUM_DATA_POINTERS]
OpenCL image2d objects for each plane of the frame.
cl_command_queue command_queue
The default command queue for this device, which will be used by all frames contexts which do not hav...
OpenCL device details.
cl_context context
The OpenCL context which will contain all operations and frames on this device.