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