FFmpeg
vf_program_opencl.c
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 #include "libavutil/avstring.h"
20 #include "libavutil/log.h"
21 #include "libavutil/mem.h"
22 #include "libavutil/opt.h"
23 #include "libavutil/pixdesc.h"
24 
25 #include "avfilter.h"
26 #include "framesync.h"
27 #include "internal.h"
28 #include "opencl.h"
29 #include "video.h"
30 
31 typedef struct ProgramOpenCLContext {
33 
34  int loaded;
35  cl_uint index;
36  cl_kernel kernel;
37  cl_command_queue command_queue;
38 
41 
42  const char *source_file;
43  const char *kernel_name;
44  int nb_inputs;
45  int width, height;
49 
51 {
52  ProgramOpenCLContext *ctx = avctx->priv;
53  cl_int cle;
54  int err;
55 
56  err = ff_opencl_filter_load_program_from_file(avctx, ctx->source_file);
57  if (err < 0)
58  return err;
59 
60  ctx->command_queue = clCreateCommandQueue(ctx->ocf.hwctx->context,
61  ctx->ocf.hwctx->device_id,
62  0, &cle);
63  if (!ctx->command_queue) {
64  av_log(avctx, AV_LOG_ERROR, "Failed to create OpenCL "
65  "command queue: %d.\n", cle);
66  return AVERROR(EIO);
67  }
68 
69  ctx->kernel = clCreateKernel(ctx->ocf.program, ctx->kernel_name, &cle);
70  if (!ctx->kernel) {
71  if (cle == CL_INVALID_KERNEL_NAME) {
72  av_log(avctx, AV_LOG_ERROR, "Kernel function '%s' not found in "
73  "program.\n", ctx->kernel_name);
74  } else {
75  av_log(avctx, AV_LOG_ERROR, "Failed to create kernel: %d.\n", cle);
76  }
77  return AVERROR(EIO);
78  }
79 
80  ctx->loaded = 1;
81  return 0;
82 }
83 
85 {
86  AVFilterLink *outlink = avctx->outputs[0];
87  ProgramOpenCLContext *ctx = avctx->priv;
88  AVFrame *output = NULL;
89  cl_int cle;
90  size_t global_work[2];
91  cl_mem src, dst;
92  int err, input, plane;
93 
94  if (!ctx->loaded) {
95  err = program_opencl_load(avctx);
96  if (err < 0)
97  return err;
98  }
99 
100  output = ff_get_video_buffer(outlink, outlink->w, outlink->h);
101  if (!output) {
102  err = AVERROR(ENOMEM);
103  goto fail;
104  }
105 
106  for (plane = 0; plane < FF_ARRAY_ELEMS(output->data); plane++) {
107  dst = (cl_mem)output->data[plane];
108  if (!dst)
109  break;
110 
111  cle = clSetKernelArg(ctx->kernel, 0, sizeof(cl_mem), &dst);
112  if (cle != CL_SUCCESS) {
113  av_log(avctx, AV_LOG_ERROR, "Failed to set kernel "
114  "destination image argument: %d.\n", cle);
115  err = AVERROR_UNKNOWN;
116  goto fail;
117  }
118  cle = clSetKernelArg(ctx->kernel, 1, sizeof(cl_uint), &ctx->index);
119  if (cle != CL_SUCCESS) {
120  av_log(avctx, AV_LOG_ERROR, "Failed to set kernel "
121  "index argument: %d.\n", cle);
122  err = AVERROR_UNKNOWN;
123  goto fail;
124  }
125 
126  for (input = 0; input < ctx->nb_inputs; input++) {
127  av_assert0(ctx->frames[input]);
128 
129  src = (cl_mem)ctx->frames[input]->data[plane];
130  av_assert0(src);
131 
132  cle = clSetKernelArg(ctx->kernel, 2 + input, sizeof(cl_mem), &src);
133  if (cle != CL_SUCCESS) {
134  av_log(avctx, AV_LOG_ERROR, "Failed to set kernel "
135  "source image argument %d: %d.\n", input, cle);
136  err = AVERROR_UNKNOWN;
137  goto fail;
138  }
139  }
140 
141  err = ff_opencl_filter_work_size_from_image(avctx, global_work,
142  output, plane, 0);
143  if (err < 0)
144  goto fail;
145 
146  av_log(avctx, AV_LOG_DEBUG, "Run kernel on plane %d "
147  "(%"SIZE_SPECIFIER"x%"SIZE_SPECIFIER").\n",
148  plane, global_work[0], global_work[1]);
149 
150  cle = clEnqueueNDRangeKernel(ctx->command_queue, ctx->kernel, 2, NULL,
151  global_work, NULL, 0, NULL, NULL);
152  CL_FAIL_ON_ERROR(AVERROR(EIO), "Failed to enqueue kernel: %d.\n", cle);
153  }
154 
155  cle = clFinish(ctx->command_queue);
156  CL_FAIL_ON_ERROR(AVERROR(EIO), "Failed to finish command queue: %d.\n", cle);
157 
158  if (ctx->nb_inputs > 0) {
159  err = av_frame_copy_props(output, ctx->frames[0]);
160  if (err < 0)
161  goto fail;
162  } else {
163  output->pts = ctx->index;
164  }
165  ++ctx->index;
166 
167  av_log(ctx, AV_LOG_DEBUG, "Filter output: %s, %ux%u (%"PRId64").\n",
168  av_get_pix_fmt_name(output->format),
169  output->width, output->height, output->pts);
170 
171  return ff_filter_frame(outlink, output);
172 
173 fail:
174  clFinish(ctx->command_queue);
176  return err;
177 }
178 
180 {
181  AVFilterContext *avctx = outlink->src;
182 
183  return program_opencl_run(avctx);
184 }
185 
187 {
188  AVFilterContext *avctx = fs->parent;
189  ProgramOpenCLContext *ctx = avctx->priv;
190  int err, i;
191 
192  for (i = 0; i < ctx->nb_inputs; i++) {
193  err = ff_framesync_get_frame(&ctx->fs, i, &ctx->frames[i], 0);
194  if (err < 0)
195  return err;
196  }
197 
198  return program_opencl_run(avctx);
199 }
200 
202 {
203  ProgramOpenCLContext *ctx = avctx->priv;
204 
205  av_assert0(ctx->nb_inputs > 0);
206 
207  return ff_framesync_activate(&ctx->fs);
208 }
209 
211 {
212  AVFilterContext *avctx = outlink->src;
213  ProgramOpenCLContext *ctx = avctx->priv;
214  int err;
215 
216  err = ff_opencl_filter_config_output(outlink);
217  if (err < 0)
218  return err;
219 
220  if (ctx->nb_inputs > 0) {
221  FFFrameSyncIn *in;
222  int i;
223 
224  err = ff_framesync_init(&ctx->fs, avctx, ctx->nb_inputs);
225  if (err < 0)
226  return err;
227 
228  ctx->fs.opaque = ctx;
229  ctx->fs.on_event = &program_opencl_filter;
230 
231  in = ctx->fs.in;
232  for (i = 0; i < ctx->nb_inputs; i++) {
233  const AVFilterLink *inlink = avctx->inputs[i];
234 
235  in[i].time_base = inlink->time_base;
236  in[i].sync = 1;
237  in[i].before = EXT_STOP;
238  in[i].after = EXT_INFINITY;
239  }
240 
241  err = ff_framesync_configure(&ctx->fs);
242  if (err < 0)
243  return err;
244 
245  } else {
246  outlink->time_base = av_inv_q(ctx->source_rate);
247  }
248 
249  return 0;
250 }
251 
253 {
254  ProgramOpenCLContext *ctx = avctx->priv;
255  int err;
256 
257  ff_opencl_filter_init(avctx);
258 
259  ctx->ocf.output_width = ctx->width;
260  ctx->ocf.output_height = ctx->height;
261 
262  if (!strcmp(avctx->filter->name, "openclsrc")) {
263  if (!ctx->ocf.output_width || !ctx->ocf.output_height) {
264  av_log(avctx, AV_LOG_ERROR, "OpenCL source requires output "
265  "dimensions to be specified.\n");
266  return AVERROR(EINVAL);
267  }
268 
269  ctx->nb_inputs = 0;
270  ctx->ocf.output_format = ctx->source_format;
271  } else {
272  int i;
273 
274  ctx->frames = av_calloc(ctx->nb_inputs, sizeof(*ctx->frames));
275  if (!ctx->frames)
276  return AVERROR(ENOMEM);
277 
278  for (i = 0; i < ctx->nb_inputs; i++) {
280  memset(&input, 0, sizeof(input));
281 
282  input.type = AVMEDIA_TYPE_VIDEO;
283  input.name = av_asprintf("input%d", i);
284  if (!input.name)
285  return AVERROR(ENOMEM);
286 
287  input.config_props = &ff_opencl_filter_config_input;
288 
289  err = ff_append_inpad_free_name(avctx, &input);
290  if (err < 0)
291  return err;
292  }
293  }
294 
295  return 0;
296 }
297 
299 {
300  ProgramOpenCLContext *ctx = avctx->priv;
301  cl_int cle;
302 
303  if (ctx->nb_inputs > 0) {
304  ff_framesync_uninit(&ctx->fs);
305 
306  av_freep(&ctx->frames);
307  }
308 
309  if (ctx->kernel) {
310  cle = clReleaseKernel(ctx->kernel);
311  if (cle != CL_SUCCESS)
312  av_log(avctx, AV_LOG_ERROR, "Failed to release "
313  "kernel: %d.\n", cle);
314  }
315 
316  if (ctx->command_queue) {
317  cle = clReleaseCommandQueue(ctx->command_queue);
318  if (cle != CL_SUCCESS)
319  av_log(avctx, AV_LOG_ERROR, "Failed to release "
320  "command queue: %d.\n", cle);
321  }
322 
324 }
325 
326 #define OFFSET(x) offsetof(ProgramOpenCLContext, x)
327 #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM)
328 
329 #if CONFIG_PROGRAM_OPENCL_FILTER
330 
331 static const AVOption program_opencl_options[] = {
332  { "source", "OpenCL program source file", OFFSET(source_file),
333  AV_OPT_TYPE_STRING, { .str = NULL }, .flags = FLAGS },
334  { "kernel", "Kernel name in program", OFFSET(kernel_name),
335  AV_OPT_TYPE_STRING, { .str = NULL }, .flags = FLAGS },
336 
337  { "inputs", "Number of inputs", OFFSET(nb_inputs),
338  AV_OPT_TYPE_INT, { .i64 = 1 }, 1, INT_MAX, FLAGS },
339 
340  { "size", "Video size", OFFSET(width),
341  AV_OPT_TYPE_IMAGE_SIZE, { .str = NULL }, 0, 0, FLAGS },
342  { "s", "Video size", OFFSET(width),
343  AV_OPT_TYPE_IMAGE_SIZE, { .str = NULL }, 0, 0, FLAGS },
344 
345  { NULL },
346 };
347 
349 
350 static const AVFilterPad program_opencl_outputs[] = {
351  {
352  .name = "default",
353  .type = AVMEDIA_TYPE_VIDEO,
354  .config_props = &program_opencl_config_output,
355  },
356 };
357 
359  .name = "program_opencl",
360  .description = NULL_IF_CONFIG_SMALL("Filter video using an OpenCL program"),
361  .priv_size = sizeof(ProgramOpenCLContext),
362  .priv_class = &program_opencl_class,
364  .preinit = &program_opencl_framesync_preinit,
368  .inputs = NULL,
369  FILTER_OUTPUTS(program_opencl_outputs),
371  .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
372 };
373 
374 #endif
375 
376 #if CONFIG_OPENCLSRC_FILTER
377 
378 static const AVOption openclsrc_options[] = {
379  { "source", "OpenCL program source file", OFFSET(source_file),
380  AV_OPT_TYPE_STRING, { .str = NULL }, .flags = FLAGS },
381  { "kernel", "Kernel name in program", OFFSET(kernel_name),
382  AV_OPT_TYPE_STRING, { .str = NULL }, .flags = FLAGS },
383 
384  { "size", "Video size", OFFSET(width),
385  AV_OPT_TYPE_IMAGE_SIZE, { .str = NULL }, 0, 0, FLAGS },
386  { "s", "Video size", OFFSET(width),
387  AV_OPT_TYPE_IMAGE_SIZE, { .str = NULL }, 0, 0, FLAGS },
388 
389  { "format", "Video format", OFFSET(source_format),
390  AV_OPT_TYPE_PIXEL_FMT, { .i64 = AV_PIX_FMT_NONE }, -1, INT_MAX, FLAGS },
391 
392  { "rate", "Video frame rate", OFFSET(source_rate),
393  AV_OPT_TYPE_VIDEO_RATE, { .str = "25" }, 0, INT_MAX, FLAGS },
394  { "r", "Video frame rate", OFFSET(source_rate),
395  AV_OPT_TYPE_VIDEO_RATE, { .str = "25" }, 0, INT_MAX, FLAGS },
396 
397  { NULL },
398 };
399 
400 AVFILTER_DEFINE_CLASS(openclsrc);
401 
402 static const AVFilterPad openclsrc_outputs[] = {
403  {
404  .name = "default",
405  .type = AVMEDIA_TYPE_VIDEO,
406  .config_props = &program_opencl_config_output,
407  .request_frame = &program_opencl_request_frame,
408  },
409 };
410 
411 const AVFilter ff_vsrc_openclsrc = {
412  .name = "openclsrc",
413  .description = NULL_IF_CONFIG_SMALL("Generate video using an OpenCL program"),
414  .priv_size = sizeof(ProgramOpenCLContext),
415  .priv_class = &openclsrc_class,
418  .inputs = NULL,
419  FILTER_OUTPUTS(openclsrc_outputs),
421  .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
422 };
423 
424 #endif
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
ProgramOpenCLContext
Definition: vf_program_opencl.c:31
FFFrameSyncIn::time_base
AVRational time_base
Time base for the incoming frames.
Definition: framesync.h:96
ff_framesync_configure
int ff_framesync_configure(FFFrameSync *fs)
Configure a frame sync structure.
Definition: framesync.c:119
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
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
ff_framesync_uninit
void ff_framesync_uninit(FFFrameSync *fs)
Free all memory currently allocated.
Definition: framesync.c:285
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
AV_OPT_TYPE_VIDEO_RATE
@ AV_OPT_TYPE_VIDEO_RATE
offset must point to AVRational
Definition: opt.h:237
ff_framesync_get_frame
int ff_framesync_get_frame(FFFrameSync *fs, unsigned in, AVFrame **rframe, unsigned get)
Get the current frame in an input.
Definition: framesync.c:248
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_asprintf
char * av_asprintf(const char *fmt,...)
Definition: avstring.c:113
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
program_opencl_activate
static int program_opencl_activate(AVFilterContext *avctx)
Definition: vf_program_opencl.c:201
opencl.h
AVOption
AVOption.
Definition: opt.h:247
FRAMESYNC_DEFINE_CLASS
#define FRAMESYNC_DEFINE_CLASS(name, context, field)
Definition: framesync.h:328
program_opencl_load
static int program_opencl_load(AVFilterContext *avctx)
Definition: vf_program_opencl.c:50
preinit
static av_cold int preinit(AVFilterContext *ctx)
Definition: af_aresample.c:46
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:153
FFFrameSync
Frame sync structure.
Definition: framesync.h:146
EXT_INFINITY
@ EXT_INFINITY
Extend the frame to infinity.
Definition: framesync.h:75
program_opencl_uninit
static av_cold void program_opencl_uninit(AVFilterContext *avctx)
Definition: vf_program_opencl.c:298
AVERROR_UNKNOWN
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
Definition: error.h:73
video.h
ProgramOpenCLContext::loaded
int loaded
Definition: vf_program_opencl.c:34
program_opencl_request_frame
static int program_opencl_request_frame(AVFilterLink *outlink)
Definition: vf_program_opencl.c:179
ff_vf_program_opencl
const AVFilter ff_vf_program_opencl
EXT_STOP
@ EXT_STOP
Completely stop all streams with this one.
Definition: framesync.h:65
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
AVFilterContext::priv
void * priv
private data for use by the filter
Definition: avfilter.h:401
fail
#define fail()
Definition: checkasm.h:127
FFFrameSyncIn
Input stream structure.
Definition: framesync.h:81
FFFrameSyncIn::sync
unsigned sync
Synchronization level: frames on input at the highest sync level will generate output frame events.
Definition: framesync.h:139
AVFILTER_FLAG_DYNAMIC_INPUTS
#define AVFILTER_FLAG_DYNAMIC_INPUTS
The number of the filter inputs is not determined just by AVFilter.inputs.
Definition: avfilter.h:110
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
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
inputs
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
Definition: filter_design.txt:243
program_opencl_config_output
static int program_opencl_config_output(AVFilterLink *outlink)
Definition: vf_program_opencl.c:210
width
#define width
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
ctx
AVFormatContext * ctx
Definition: movenc.c:48
AVFormatContext::opaque
void * opaque
User data.
Definition: avformat.h:1614
ProgramOpenCLContext::nb_inputs
int nb_inputs
Definition: vf_program_opencl.c:44
if
if(ret)
Definition: filter_design.txt:179
program_opencl_run
static int program_opencl_run(AVFilterContext *avctx)
Definition: vf_program_opencl.c:84
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
fs
#define fs(width, name, subs,...)
Definition: cbs_vp9.c:259
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
ff_append_inpad_free_name
int ff_append_inpad_free_name(AVFilterContext *f, AVFilterPad *p)
Definition: avfilter.c:144
activate
filter_frame For filters that do not use the activate() callback
AV_OPT_TYPE_IMAGE_SIZE
@ AV_OPT_TYPE_IMAGE_SIZE
offset must point to two consecutive integers
Definition: opt.h:234
AVFilterContext::inputs
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:394
src
#define src
Definition: vp8dsp.c:255
ProgramOpenCLContext::index
cl_uint index
Definition: vf_program_opencl.c:35
AV_PIX_FMT_OPENCL
@ AV_PIX_FMT_OPENCL
Hardware surfaces for OpenCL.
Definition: pixfmt.h:325
OFFSET
#define OFFSET(x)
Definition: vf_program_opencl.c:326
ProgramOpenCLContext::width
int width
Definition: vf_program_opencl.c:45
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
ff_vsrc_openclsrc
const AVFilter ff_vsrc_openclsrc
ProgramOpenCLContext::frames
AVFrame ** frames
Definition: vf_program_opencl.c:40
ProgramOpenCLContext::fs
FFFrameSync fs
Definition: vf_program_opencl.c:39
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
FILTER_SINGLE_PIXFMT
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
Definition: internal.h:181
log.h
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:271
program_opencl_filter
static int program_opencl_filter(FFFrameSync *fs)
Definition: vf_program_opencl.c:186
av_inv_q
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
Definition: rational.h:159
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:56
ProgramOpenCLContext::ocf
OpenCLFilterContext ocf
Definition: vf_program_opencl.c:32
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:271
ProgramOpenCLContext::source_format
enum AVPixelFormat source_format
Definition: vf_program_opencl.c:46
ProgramOpenCLContext::command_queue
cl_command_queue command_queue
Definition: vf_program_opencl.c:37
AVFilter
Filter definition.
Definition: avfilter.h:149
ff_opencl_filter_init
int ff_opencl_filter_init(AVFilterContext *avctx)
Initialise an OpenCL filter context.
Definition: opencl.c:132
ff_framesync_init
int ff_framesync_init(FFFrameSync *fs, AVFilterContext *parent, unsigned nb_in)
Initialize a frame sync structure.
Definition: framesync.c:79
FLAGS
#define FLAGS
Definition: vf_program_opencl.c:327
ProgramOpenCLContext::height
int height
Definition: vf_program_opencl.c:45
SIZE_SPECIFIER
#define SIZE_SPECIFIER
Definition: internal.h:193
FFFrameSyncIn::before
enum FFFrameSyncExtMode before
Extrapolation mode for timestamps before the first frame.
Definition: framesync.h:86
framesync.h
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:224
ProgramOpenCLContext::source_rate
AVRational source_rate
Definition: vf_program_opencl.c:47
avfilter.h
ff_opencl_filter_load_program_from_file
int ff_opencl_filter_load_program_from_file(AVFilterContext *avctx, const char *filename)
Load a new OpenCL program from a file.
Definition: opencl.c:204
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
AV_OPT_TYPE_PIXEL_FMT
@ AV_OPT_TYPE_PIXEL_FMT
Definition: opt.h:235
AVFilterContext
An instance of a filter.
Definition: avfilter.h:386
ProgramOpenCLContext::kernel
cl_kernel kernel
Definition: vf_program_opencl.c:36
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
mem.h
program_opencl_init
static av_cold int program_opencl_init(AVFilterContext *avctx)
Definition: vf_program_opencl.c:252
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:192
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561
ProgramOpenCLContext::kernel_name
const char * kernel_name
Definition: vf_program_opencl.c:43
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
FFFrameSyncIn::after
enum FFFrameSyncExtMode after
Extrapolation mode for timestamps after the last frame.
Definition: framesync.h:91
CL_FAIL_ON_ERROR
#define CL_FAIL_ON_ERROR(errcode,...)
A helper macro to handle OpenCL errors.
Definition: opencl.h:74
uninit
static av_cold int uninit(AVCodecContext *avctx)
Definition: crystalhd.c:279
ff_framesync_activate
int ff_framesync_activate(FFFrameSync *fs)
Examine the frames in the filter's input and try to produce output.
Definition: framesync.c:336
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
ProgramOpenCLContext::source_file
const char * source_file
Definition: vf_program_opencl.c:42
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
AVFilterContext::outputs
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:398