diff options
author | Mark Thompson <sw@jkqxz.net> | 2017-06-27 22:50:49 +0100 |
---|---|---|
committer | Mark Thompson <sw@jkqxz.net> | 2017-11-22 23:15:48 +0000 |
commit | 5c21c41b7da2bac069b09d5a30da6a53f72dbe96 (patch) | |
tree | 0f70fcbe6268a4ef32eb5023e690b2b8f2a117ed /libavfilter/opencl.h | |
parent | 7faae6e745a3b22f81d522ea19164d3b2b3aa2cc (diff) | |
download | ffmpeg-5c21c41b7da2bac069b09d5a30da6a53f72dbe96.tar.gz |
lavfi: Add some common code for OpenCL filtering
Diffstat (limited to 'libavfilter/opencl.h')
-rw-r--r-- | libavfilter/opencl.h | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/libavfilter/opencl.h b/libavfilter/opencl.h new file mode 100644 index 0000000000..4d740c18ab --- /dev/null +++ b/libavfilter/opencl.h @@ -0,0 +1,87 @@ +/* + * 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 AVFILTER_OPENCL_H +#define AVFILTER_OPENCL_H + +#include "libavutil/buffer.h" +#include "libavutil/hwcontext.h" +#include "libavutil/hwcontext_opencl.h" +#include "libavutil/pixfmt.h" + +#include "avfilter.h" + +typedef struct OpenCLFilterContext { + const AVClass *class; + + AVBufferRef *device_ref; + AVHWDeviceContext *device; + AVOpenCLDeviceContext *hwctx; + + cl_program program; + + enum AVPixelFormat output_format; + int output_width; + int output_height; +} OpenCLFilterContext; + +/** + * Return that all inputs and outputs support only AV_PIX_FMT_OPENCL. + */ +int ff_opencl_filter_query_formats(AVFilterContext *avctx); + +/** + * Check that the input link contains a suitable hardware frames + * context and extract the device from it. + */ +int ff_opencl_filter_config_input(AVFilterLink *inlink); + +/** + * Create a suitable hardware frames context for the output. + */ +int ff_opencl_filter_config_output(AVFilterLink *outlink); + +/** + * Initialise an OpenCL filter context. + */ +int ff_opencl_filter_init(AVFilterContext *avctx); + +/** + * Uninitialise an OpenCL filter context. + */ +void ff_opencl_filter_uninit(AVFilterContext *avctx); + +/** + * Load a new OpenCL program from strings in memory. + * + * Creates a new program and compiles it for the current device. + * Will log any build errors if compilation fails. + */ +int ff_opencl_filter_load_program(AVFilterContext *avctx, + const char **program_source_array, + int nb_strings); + +/** + * Load a new OpenCL program from a file. + * + * Same as ff_opencl_filter_load_program(), but from a file. + */ +int ff_opencl_filter_load_program_from_file(AVFilterContext *avctx, + const char *filename); + +#endif /* AVFILTER_OPENCL_H */ |