FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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 AVFILTER_OPENCL_H
20 #define AVFILTER_OPENCL_H
21 
22 // The intended target is OpenCL 1.2, so disable warnings for APIs
23 // deprecated after that. This primarily applies to clCreateCommandQueue(),
24 // we can't use the replacement clCreateCommandQueueWithProperties() because
25 // it was introduced in OpenCL 2.0.
26 #define CL_USE_DEPRECATED_OPENCL_1_2_APIS
27 
28 #include "libavutil/buffer.h"
29 #include "libavutil/hwcontext.h"
31 #include "libavutil/pixfmt.h"
32 
33 #include "avfilter.h"
34 
35 typedef struct OpenCLFilterContext {
36  const AVClass *class;
37 
41 
42  cl_program program;
43 
48 
49 /**
50  * Return that all inputs and outputs support only AV_PIX_FMT_OPENCL.
51  */
53 
54 /**
55  * Check that the input link contains a suitable hardware frames
56  * context and extract the device from it.
57  */
59 
60 /**
61  * Create a suitable hardware frames context for the output.
62  */
64 
65 /**
66  * Initialise an OpenCL filter context.
67  */
69 
70 /**
71  * Uninitialise an OpenCL filter context.
72  */
74 
75 /**
76  * Load a new OpenCL program from strings in memory.
77  *
78  * Creates a new program and compiles it for the current device.
79  * Will log any build errors if compilation fails.
80  */
82  const char **program_source_array,
83  int nb_strings);
84 
85 /**
86  * Load a new OpenCL program from a file.
87  *
88  * Same as ff_opencl_filter_load_program(), but from a file.
89  */
91  const char *filename);
92 
93 /**
94  * Find the work size needed needed for a given plane of an image.
95  */
97  size_t *work_size,
98  AVFrame *frame, int plane,
99  int block_alignment);
100 
101 #endif /* AVFILTER_OPENCL_H */
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
Definition: hwcontext.h:60
int plane
Definition: avisynth_c.h:422
API-specific header for AV_HWDEVICE_TYPE_OPENCL.
This structure describes decoded (raw) audio or video data.
Definition: frame.h:218
Main libavfilter public API header.
int ff_opencl_filter_work_size_from_image(AVFilterContext *avctx, size_t *work_size, AVFrame *frame, int plane, int block_alignment)
Find the work size needed needed for a given plane of an image.
Definition: opencl.c:281
AVOpenCLDeviceContext * hwctx
Definition: opencl.h:40
AVHWDeviceContext * device
Definition: opencl.h:39
static AVFrame * frame
int ff_opencl_filter_load_program(AVFilterContext *avctx, const char **program_source_array, int nb_strings)
Load a new OpenCL program from strings in memory.
Definition: opencl.c:174
void ff_opencl_filter_uninit(AVFilterContext *avctx)
Uninitialise an OpenCL filter context.
Definition: opencl.c:159
int ff_opencl_filter_load_program_from_file(AVFilterContext *avctx, const char *filename)
Load a new OpenCL program from a file.
Definition: opencl.c:222
int ff_opencl_filter_config_output(AVFilterLink *outlink)
Create a suitable hardware frames context for the output.
Definition: opencl.c:99
enum AVPixelFormat output_format
Definition: opencl.h:44
int ff_opencl_filter_init(AVFilterContext *avctx)
Initialise an OpenCL filter context.
Definition: opencl.c:150
Describe the class of an AVClass context structure.
Definition: log.h:67
refcounted data buffer API
A reference to a data buffer.
Definition: buffer.h:81
AVBufferRef * device_ref
Definition: opencl.h:38
int ff_opencl_filter_query_formats(AVFilterContext *avctx)
Return that all inputs and outputs support only AV_PIX_FMT_OPENCL.
Definition: opencl.c:31
OpenCL device details.
pixel format definitions
An instance of a filter.
Definition: avfilter.h:338
int ff_opencl_filter_config_input(AVFilterLink *inlink)
Check that the input link contains a suitable hardware frames context and extract the device from it...
Definition: opencl.c:63
cl_program program
Definition: opencl.h:42
AVPixelFormat
Pixel format.
Definition: pixfmt.h:60