FFmpeg
vf_convolution_opencl.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 Danil Iashchenko
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include "libavutil/common.h"
22 #include "libavutil/imgutils.h"
23 #include "libavutil/mem.h"
24 #include "libavutil/opt.h"
25 #include "libavutil/pixdesc.h"
26 #include "libavutil/avstring.h"
27 
28 
29 #include "avfilter.h"
30 #include "internal.h"
31 #include "opencl.h"
32 #include "opencl_source.h"
33 #include "video.h"
34 
35 typedef struct ConvolutionOpenCLContext {
37 
39  cl_kernel kernel;
40  cl_command_queue command_queue;
41 
42  char *matrix_str[4];
43 
44  cl_mem matrix[4];
45  cl_int matrix_sizes[4];
46  cl_int dims[4];
47  cl_float rdivs[4];
48  cl_float biases[4];
49 
50  cl_int planes;
51  cl_float scale;
52  cl_float delta;
53 
55 
57 {
59  const char *kernel_name;
60  cl_int cle;
61  int err;
62 
64  if (err < 0)
65  goto fail;
66 
67  ctx->command_queue = clCreateCommandQueue(ctx->ocf.hwctx->context,
68  ctx->ocf.hwctx->device_id,
69  0, &cle);
70  CL_FAIL_ON_ERROR(AVERROR(EIO), "Failed to create OpenCL "
71  "command queue %d.\n", cle);
72 
73  if (!strcmp(avctx->filter->name, "convolution_opencl")) {
74  kernel_name = "convolution_global";
75  } else if (!strcmp(avctx->filter->name, "sobel_opencl")) {
76  kernel_name = "sobel_global";
77  } else if (!strcmp(avctx->filter->name, "prewitt_opencl")){
78  kernel_name = "prewitt_global";
79  } else if (!strcmp(avctx->filter->name, "roberts_opencl")){
80  kernel_name = "roberts_global";
81  }
82  ctx->kernel = clCreateKernel(ctx->ocf.program, kernel_name, &cle);
83  CL_FAIL_ON_ERROR(AVERROR(EIO), "Failed to create "
84  "kernel %d.\n", cle);
85 
86  ctx->initialised = 1;
87  return 0;
88 
89 fail:
90  if (ctx->command_queue)
91  clReleaseCommandQueue(ctx->command_queue);
92  if (ctx->kernel)
93  clReleaseKernel(ctx->kernel);
94  return err;
95 }
96 
97 
98 
100 {
102  float *matrix = NULL;
103  size_t matrix_bytes;
104  cl_mem buffer;
105  cl_int cle;
106  int i, j;
107  int sscanf_err;
108  char *p, *arg, *saveptr = NULL;
109  float input_matrix[4][49];
110 
111  for (i = 0; i < 4; i++) {
112  ctx->biases[i] = ctx->biases[i] / 255.0;
113  }
114 
115  for (i = 0; i < 4; i++) {
116  p = ctx->matrix_str[i];
117  while (ctx->matrix_sizes[i] < 49) {
118  arg = av_strtok(p, " ", &saveptr);
119  if (!arg) {
120  break;
121  }
122  p = NULL;
123  sscanf_err = sscanf(arg, "%f", &input_matrix[i][ctx->matrix_sizes[i]]);
124  if (sscanf_err != 1) {
125  av_log(ctx, AV_LOG_ERROR, "Matrix is sequence of 9, 25 or 49 signed numbers\n");
126  return AVERROR(EINVAL);
127  }
128  ctx->matrix_sizes[i]++;
129  }
130  if (ctx->matrix_sizes[i] == 9) {
131  ctx->dims[i] = 3;
132  } else if (ctx->matrix_sizes[i] == 25) {
133  ctx->dims[i] = 5;
134  } else if (ctx->matrix_sizes[i] == 49) {
135  ctx->dims[i] = 7;
136  } else {
137  av_log(ctx, AV_LOG_ERROR, "Invalid matrix size:%d\n", ctx->matrix_sizes[i]);
138  return AVERROR(EINVAL);
139  }
140 
141  }
142 
143  for (j = 0; j < 4; j++) {
144  matrix_bytes = sizeof(float)*ctx->matrix_sizes[j];
145  matrix = av_malloc(matrix_bytes);
146  if (!matrix) {
147  av_freep(&matrix);
148  return AVERROR(ENOMEM);
149  }
150 
151  for (i = 0; i < ctx->matrix_sizes[j]; i++)
152  matrix[i] = input_matrix[j][i];
153 
154  buffer = clCreateBuffer(ctx->ocf.hwctx->context,
155  CL_MEM_READ_ONLY |
156  CL_MEM_COPY_HOST_PTR |
157  CL_MEM_HOST_NO_ACCESS,
158  matrix_bytes, matrix, &cle);
159  if (!buffer) {
160  av_log(avctx, AV_LOG_ERROR, "Failed to create matrix buffer: "
161  "%d.\n", cle);
162  av_freep(&matrix);
163  return AVERROR(EIO);
164  }
165  ctx->matrix[j] = buffer;
166  av_freep(&matrix);
167  }
168 
169  return 0;
170 }
171 
173 {
174  AVFilterContext *avctx = inlink->dst;
175  AVFilterLink *outlink = avctx->outputs[0];
177  AVFrame *output = NULL;
178  cl_int cle;
179  size_t global_work[2];
180  cl_mem src, dst;
181  int err, p;
182  size_t origin[3] = {0, 0, 0};
183  size_t region[3] = {0, 0, 1};
184 
185  av_log(ctx, AV_LOG_DEBUG, "Filter input: %s, %ux%u (%"PRId64").\n",
186  av_get_pix_fmt_name(input->format),
187  input->width, input->height, input->pts);
188 
189  if (!input->hw_frames_ctx)
190  return AVERROR(EINVAL);
191 
192  if (!ctx->initialised) {
193  err = convolution_opencl_init(avctx);
194  if (err < 0)
195  goto fail;
196 
197  if (!strcmp(avctx->filter->name, "convolution_opencl")) {
199  if (err < 0)
200  goto fail;
201  } else {
202  ctx->delta /= 255.0;
203  }
204 
205  }
206 
207  output = ff_get_video_buffer(outlink, outlink->w, outlink->h);
208  if (!output) {
209  err = AVERROR(ENOMEM);
210  goto fail;
211  }
212 
213  for (p = 0; p < FF_ARRAY_ELEMS(output->data); p++) {
214  src = (cl_mem) input->data[p];
215  dst = (cl_mem)output->data[p];
216 
217  if (!dst)
218  break;
219 
220  if (!strcmp(avctx->filter->name, "convolution_opencl")) {
221  CL_SET_KERNEL_ARG(ctx->kernel, 0, cl_mem, &dst);
222  CL_SET_KERNEL_ARG(ctx->kernel, 1, cl_mem, &src);
223  CL_SET_KERNEL_ARG(ctx->kernel, 2, cl_int, &ctx->dims[p]);
224  CL_SET_KERNEL_ARG(ctx->kernel, 3, cl_mem, &ctx->matrix[p]);
225  CL_SET_KERNEL_ARG(ctx->kernel, 4, cl_float, &ctx->rdivs[p]);
226  CL_SET_KERNEL_ARG(ctx->kernel, 5, cl_float, &ctx->biases[p]);
227 
228  err = ff_opencl_filter_work_size_from_image(avctx, global_work, output, p, 0);
229  if (err < 0)
230  goto fail;
231 
232  av_log(avctx, AV_LOG_DEBUG, "Run kernel on plane %d "
233  "(%"SIZE_SPECIFIER"x%"SIZE_SPECIFIER").\n",
234  p, global_work[0], global_work[1]);
235 
236  cle = clEnqueueNDRangeKernel(ctx->command_queue, ctx->kernel, 2, NULL,
237  global_work, NULL,
238  0, NULL, NULL);
239  CL_FAIL_ON_ERROR(AVERROR(EIO), "Failed to enqueue "
240  "kernel: %d.\n", cle);
241  } else {
242  if (!(ctx->planes & (1 << p))) {
243  err = ff_opencl_filter_work_size_from_image(avctx, region, output, p, 0);
244  if (err < 0)
245  goto fail;
246 
247  cle = clEnqueueCopyImage(ctx->command_queue, src, dst,
248  origin, origin, region, 0, NULL, NULL);
249  CL_FAIL_ON_ERROR(AVERROR(EIO), "Failed to copy plane %d: %d.\n",
250  p, cle);
251  } else {
252  CL_SET_KERNEL_ARG(ctx->kernel, 0, cl_mem, &dst);
253  CL_SET_KERNEL_ARG(ctx->kernel, 1, cl_mem, &src);
254  CL_SET_KERNEL_ARG(ctx->kernel, 2, cl_float, &ctx->scale);
255  CL_SET_KERNEL_ARG(ctx->kernel, 3, cl_float, &ctx->delta);
256 
257  err = ff_opencl_filter_work_size_from_image(avctx, global_work, output, p, 0);
258  if (err < 0)
259  goto fail;
260 
261  av_log(avctx, AV_LOG_DEBUG, "Run kernel on plane %d "
262  "(%"SIZE_SPECIFIER"x%"SIZE_SPECIFIER").\n",
263  p, global_work[0], global_work[1]);
264 
265  cle = clEnqueueNDRangeKernel(ctx->command_queue, ctx->kernel, 2, NULL,
266  global_work, NULL,
267  0, NULL, NULL);
268  CL_FAIL_ON_ERROR(AVERROR(EIO), "Failed to enqueue "
269  "kernel: %d.\n", cle);
270  }
271  }
272  }
273 
274  cle = clFinish(ctx->command_queue);
275  CL_FAIL_ON_ERROR(AVERROR(EIO), "Failed to finish command queue: %d.\n", cle);
276 
278  if (err < 0)
279  goto fail;
280 
282 
283  av_log(ctx, AV_LOG_DEBUG, "Filter output: %s, %ux%u (%"PRId64").\n",
284  av_get_pix_fmt_name(output->format),
285  output->width, output->height, output->pts);
286 
287  return ff_filter_frame(outlink, output);
288 
289 fail:
290  clFinish(ctx->command_queue);
293  return err;
294 }
295 
297 {
299  cl_int cle;
300  int i;
301 
302  for (i = 0; i < 4; i++) {
303  clReleaseMemObject(ctx->matrix[i]);
304  }
305 
306  if (ctx->kernel) {
307  cle = clReleaseKernel(ctx->kernel);
308  if (cle != CL_SUCCESS)
309  av_log(avctx, AV_LOG_ERROR, "Failed to release "
310  "kernel: %d.\n", cle);
311  }
312 
313  if (ctx->command_queue) {
314  cle = clReleaseCommandQueue(ctx->command_queue);
315  if (cle != CL_SUCCESS)
316  av_log(avctx, AV_LOG_ERROR, "Failed to release "
317  "command queue: %d.\n", cle);
318  }
319 
321 }
322 
324  {
325  .name = "default",
326  .type = AVMEDIA_TYPE_VIDEO,
327  .filter_frame = &convolution_opencl_filter_frame,
328  .config_props = &ff_opencl_filter_config_input,
329  },
330 };
331 
333  {
334  .name = "default",
335  .type = AVMEDIA_TYPE_VIDEO,
336  .config_props = &ff_opencl_filter_config_output,
337  },
338 };
339 
340 #define OFFSET(x) offsetof(ConvolutionOpenCLContext, x)
341 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
342 
343 #if CONFIG_CONVOLUTION_OPENCL_FILTER
344 
345 static const AVOption convolution_opencl_options[] = {
346  { "0m", "set matrix for 2nd plane", OFFSET(matrix_str[0]), AV_OPT_TYPE_STRING, {.str="0 0 0 0 1 0 0 0 0"}, 0, 0, FLAGS },
347  { "1m", "set matrix for 2nd plane", OFFSET(matrix_str[1]), AV_OPT_TYPE_STRING, {.str="0 0 0 0 1 0 0 0 0"}, 0, 0, FLAGS },
348  { "2m", "set matrix for 3rd plane", OFFSET(matrix_str[2]), AV_OPT_TYPE_STRING, {.str="0 0 0 0 1 0 0 0 0"}, 0, 0, FLAGS },
349  { "3m", "set matrix for 4th plane", OFFSET(matrix_str[3]), AV_OPT_TYPE_STRING, {.str="0 0 0 0 1 0 0 0 0"}, 0, 0, FLAGS },
350  { "0rdiv", "set rdiv for 1nd plane", OFFSET(rdivs[0]), AV_OPT_TYPE_FLOAT, {.dbl=1.0}, 0.0, INT_MAX, FLAGS},
351  { "1rdiv", "set rdiv for 2nd plane", OFFSET(rdivs[1]), AV_OPT_TYPE_FLOAT, {.dbl=1.0}, 0.0, INT_MAX, FLAGS},
352  { "2rdiv", "set rdiv for 3rd plane", OFFSET(rdivs[2]), AV_OPT_TYPE_FLOAT, {.dbl=1.0}, 0.0, INT_MAX, FLAGS},
353  { "3rdiv", "set rdiv for 4th plane", OFFSET(rdivs[3]), AV_OPT_TYPE_FLOAT, {.dbl=1.0}, 0.0, INT_MAX, FLAGS},
354  { "0bias", "set bias for 1st plane", OFFSET(biases[0]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS},
355  { "1bias", "set bias for 2nd plane", OFFSET(biases[1]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS},
356  { "2bias", "set bias for 3rd plane", OFFSET(biases[2]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS},
357  { "3bias", "set bias for 4th plane", OFFSET(biases[3]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS},
358  { NULL }
359 };
360 
361 AVFILTER_DEFINE_CLASS(convolution_opencl);
362 
364  .name = "convolution_opencl",
365  .description = NULL_IF_CONFIG_SMALL("Apply convolution mask to input video"),
366  .priv_size = sizeof(ConvolutionOpenCLContext),
367  .priv_class = &convolution_opencl_class,
373  .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
374 };
375 
376 #endif /* CONFIG_CONVOLUTION_OPENCL_FILTER */
377 
378 #if CONFIG_SOBEL_OPENCL_FILTER
379 
380 static const AVOption sobel_opencl_options[] = {
381  { "planes", "set planes to filter", OFFSET(planes), AV_OPT_TYPE_INT, {.i64=15}, 0, 15, FLAGS},
382  { "scale", "set scale", OFFSET(scale), AV_OPT_TYPE_FLOAT, {.dbl=1.0}, 0.0, 65535, FLAGS},
383  { "delta", "set delta", OFFSET(delta), AV_OPT_TYPE_FLOAT, {.dbl=0}, -65535, 65535, FLAGS},
384  { NULL }
385 };
386 
387 AVFILTER_DEFINE_CLASS(sobel_opencl);
388 
390  .name = "sobel_opencl",
391  .description = NULL_IF_CONFIG_SMALL("Apply sobel operator"),
392  .priv_size = sizeof(ConvolutionOpenCLContext),
393  .priv_class = &sobel_opencl_class,
399  .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
400 };
401 
402 #endif /* CONFIG_SOBEL_OPENCL_FILTER */
403 
404 #if CONFIG_PREWITT_OPENCL_FILTER
405 
406 static const AVOption prewitt_opencl_options[] = {
407  { "planes", "set planes to filter", OFFSET(planes), AV_OPT_TYPE_INT, {.i64=15}, 0, 15, FLAGS},
408  { "scale", "set scale", OFFSET(scale), AV_OPT_TYPE_FLOAT, {.dbl=1.0}, 0.0, 65535, FLAGS},
409  { "delta", "set delta", OFFSET(delta), AV_OPT_TYPE_FLOAT, {.dbl=0}, -65535, 65535, FLAGS},
410  { NULL }
411 };
412 
413 AVFILTER_DEFINE_CLASS(prewitt_opencl);
414 
416  .name = "prewitt_opencl",
417  .description = NULL_IF_CONFIG_SMALL("Apply prewitt operator"),
418  .priv_size = sizeof(ConvolutionOpenCLContext),
419  .priv_class = &prewitt_opencl_class,
425  .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
426 };
427 
428 #endif /* CONFIG_PREWITT_OPENCL_FILTER */
429 
430 #if CONFIG_ROBERTS_OPENCL_FILTER
431 
432 static const AVOption roberts_opencl_options[] = {
433  { "planes", "set planes to filter", OFFSET(planes), AV_OPT_TYPE_INT, {.i64=15}, 0, 15, FLAGS},
434  { "scale", "set scale", OFFSET(scale), AV_OPT_TYPE_FLOAT, {.dbl=1.0}, 0.0, 65535, FLAGS},
435  { "delta", "set delta", OFFSET(delta), AV_OPT_TYPE_FLOAT, {.dbl=0}, -65535, 65535, FLAGS},
436  { NULL }
437 };
438 
439 AVFILTER_DEFINE_CLASS(roberts_opencl);
440 
442  .name = "roberts_opencl",
443  .description = NULL_IF_CONFIG_SMALL("Apply roberts operator"),
444  .priv_size = sizeof(ConvolutionOpenCLContext),
445  .priv_class = &roberts_opencl_class,
451  .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
452 };
453 
454 #endif /* CONFIG_ROBERTS_OPENCL_FILTER */
ff_get_video_buffer
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:98
init
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:31
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
opt.h
CL_SET_KERNEL_ARG
#define CL_SET_KERNEL_ARG(kernel, arg_num, type, arg)
set argument to specific Kernel.
Definition: opencl.h:61
convolution_opencl_filter_frame
static int convolution_opencl_filter_frame(AVFilterLink *inlink, AVFrame *input)
Definition: vf_convolution_opencl.c:172
FF_FILTER_FLAG_HWFRAME_AWARE
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
Definition: internal.h:371
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1018
ConvolutionOpenCLContext::kernel
cl_kernel kernel
Definition: vf_convolution_opencl.c:39
output
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce output
Definition: filter_design.txt:225
inlink
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
Definition: filter_design.txt:212
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:112
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:303
pixdesc.h
opencl.h
AVOption
AVOption.
Definition: opt.h:247
ff_opencl_filter_load_program
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:156
ConvolutionOpenCLContext::ocf
OpenCLFilterContext ocf
Definition: vf_convolution_opencl.c:36
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:153
video.h
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:31
planes
static const struct @320 planes[]
ff_opencl_filter_work_size_from_image
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:263
ConvolutionOpenCLContext::matrix
cl_mem matrix[4]
Definition: vf_convolution_opencl.c:44
AVFilterContext::priv
void * priv
private data for use by the filter
Definition: avfilter.h:401
fail
#define fail()
Definition: checkasm.h:127
ConvolutionOpenCLContext::delta
cl_float delta
Definition: vf_convolution_opencl.c:52
scale
static av_always_inline float scale(float x, float s)
Definition: vf_v360.c:1377
ff_opencl_source_convolution
const char * ff_opencl_source_convolution
ConvolutionOpenCLContext::dims
cl_int dims[4]
Definition: vf_convolution_opencl.c:46
ff_opencl_filter_config_output
int ff_opencl_filter_config_output(AVFilterLink *outlink)
Create a suitable hardware frames context for the output.
Definition: opencl.c:81
convolution_opencl_inputs
static const AVFilterPad convolution_opencl_inputs[]
Definition: vf_convolution_opencl.c:323
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:50
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
av_cold
#define av_cold
Definition: attributes.h:90
convolution_opencl_outputs
static const AVFilterPad convolution_opencl_outputs[]
Definition: vf_convolution_opencl.c:332
ConvolutionOpenCLContext::matrix_sizes
cl_int matrix_sizes[4]
Definition: vf_convolution_opencl.c:45
av_strtok
char * av_strtok(char *s, const char *delim, char **saveptr)
Split the string into several tokens which can be accessed by successive calls to av_strtok().
Definition: avstring.c:186
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
ConvolutionOpenCLContext
Definition: vf_convolution_opencl.c:35
ctx
AVFormatContext * ctx
Definition: movenc.c:48
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:191
arg
const char * arg
Definition: jacosubdec.c:67
NULL
#define NULL
Definition: coverity.c:32
av_frame_copy_props
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:537
ConvolutionOpenCLContext::matrix_str
char * matrix_str[4]
Definition: vf_convolution_opencl.c:42
ConvolutionOpenCLContext::command_queue
cl_command_queue command_queue
Definition: vf_convolution_opencl.c:40
src
#define src
Definition: vp8dsp.c:255
AV_PIX_FMT_OPENCL
@ AV_PIX_FMT_OPENCL
Hardware surfaces for OpenCL.
Definition: pixfmt.h:325
ConvolutionOpenCLContext::rdivs
cl_float rdivs[4]
Definition: vf_convolution_opencl.c:47
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
ConvolutionOpenCLContext::initialised
int initialised
Definition: vf_convolution_opencl.c:38
opencl_source.h
input
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some input
Definition: filter_design.txt:172
ff_opencl_filter_config_input
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:45
internal.h
AVFILTER_DEFINE_CLASS
#define AVFILTER_DEFINE_CLASS(fname)
Definition: internal.h:326
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:227
FILTER_SINGLE_PIXFMT
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
Definition: internal.h:181
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:271
common.h
delta
float delta
Definition: vorbis_enc_data.h:430
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:56
AVFilter
Filter definition.
Definition: avfilter.h:149
ConvolutionOpenCLContext::planes
cl_int planes
Definition: vf_convolution_opencl.c:50
ff_opencl_filter_init
int ff_opencl_filter_init(AVFilterContext *avctx)
Initialise an OpenCL filter context.
Definition: opencl.c:132
ff_vf_roberts_opencl
const AVFilter ff_vf_roberts_opencl
ConvolutionOpenCLContext::scale
cl_float scale
Definition: vf_convolution_opencl.c:51
SIZE_SPECIFIER
#define SIZE_SPECIFIER
Definition: internal.h:193
ff_vf_convolution_opencl
const AVFilter ff_vf_convolution_opencl
ConvolutionOpenCLContext::biases
cl_float biases[4]
Definition: vf_convolution_opencl.c:48
OFFSET
#define OFFSET(x)
Definition: vf_convolution_opencl.c:340
buffer
the frame and frame reference mechanism is intended to as much as expensive copies of that data while still allowing the filters to produce correct results The data is stored in buffers represented by AVFrame structures Several references can point to the same frame buffer
Definition: filter_design.txt:49
ff_vf_sobel_opencl
const AVFilter ff_vf_sobel_opencl
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:224
avfilter.h
convolution_opencl_init
static int convolution_opencl_init(AVFilterContext *avctx)
Definition: vf_convolution_opencl.c:56
OpenCLFilterContext
Definition: opencl.h:36
ff_opencl_filter_uninit
void ff_opencl_filter_uninit(AVFilterContext *avctx)
Uninitialise an OpenCL filter context.
Definition: opencl.c:141
FLAGS
#define FLAGS
Definition: vf_convolution_opencl.c:341
AVFilterContext
An instance of a filter.
Definition: avfilter.h:386
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
mem.h
convolution_opencl_make_filter_params
static int convolution_opencl_make_filter_params(AVFilterContext *avctx)
Definition: vf_convolution_opencl.c:99
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:192
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
imgutils.h
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
CL_FAIL_ON_ERROR
#define CL_FAIL_ON_ERROR(errcode,...)
A helper macro to handle OpenCL errors.
Definition: opencl.h:74
convolution_opencl_uninit
static av_cold void convolution_opencl_uninit(AVFilterContext *avctx)
Definition: vf_convolution_opencl.c:296
uninit
static av_cold int uninit(AVCodecContext *avctx)
Definition: crystalhd.c:279
avstring.h
AVFilterContext::filter
const AVFilter * filter
the AVFilter of which this is an instance
Definition: avfilter.h:389
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:228
av_get_pix_fmt_name
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
Definition: pixdesc.c:2484
ff_vf_prewitt_opencl
const AVFilter ff_vf_prewitt_opencl
AVFilterContext::outputs
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:398