]> git.sesse.net Git - ffmpeg/blob - libavfilter/opencl.h
Merge commit 'b843b343d8a3210ae37a2342b1904a5bd1e5fc6e'
[ffmpeg] / libavfilter / opencl.h
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 #include "libavutil/buffer.h"
23 #include "libavutil/hwcontext.h"
24 #include "libavutil/hwcontext_opencl.h"
25 #include "libavutil/pixfmt.h"
26
27 #include "avfilter.h"
28
29 typedef struct OpenCLFilterContext {
30     const AVClass     *class;
31
32     AVBufferRef       *device_ref;
33     AVHWDeviceContext *device;
34     AVOpenCLDeviceContext *hwctx;
35
36     cl_program         program;
37
38     enum AVPixelFormat output_format;
39     int                output_width;
40     int                output_height;
41 } OpenCLFilterContext;
42
43 /**
44  * Return that all inputs and outputs support only AV_PIX_FMT_OPENCL.
45  */
46 int ff_opencl_filter_query_formats(AVFilterContext *avctx);
47
48 /**
49  * Check that the input link contains a suitable hardware frames
50  * context and extract the device from it.
51  */
52 int ff_opencl_filter_config_input(AVFilterLink *inlink);
53
54 /**
55  * Create a suitable hardware frames context for the output.
56  */
57 int ff_opencl_filter_config_output(AVFilterLink *outlink);
58
59 /**
60  * Initialise an OpenCL filter context.
61  */
62 int ff_opencl_filter_init(AVFilterContext *avctx);
63
64 /**
65  * Uninitialise an OpenCL filter context.
66  */
67 void ff_opencl_filter_uninit(AVFilterContext *avctx);
68
69 /**
70  * Load a new OpenCL program from strings in memory.
71  *
72  * Creates a new program and compiles it for the current device.
73  * Will log any build errors if compilation fails.
74  */
75 int ff_opencl_filter_load_program(AVFilterContext *avctx,
76                                   const char **program_source_array,
77                                   int nb_strings);
78
79 /**
80  * Load a new OpenCL program from a file.
81  *
82  * Same as ff_opencl_filter_load_program(), but from a file.
83  */
84 int ff_opencl_filter_load_program_from_file(AVFilterContext *avctx,
85                                             const char *filename);
86
87 #endif /* AVFILTER_OPENCL_H */