FFmpeg
vf_frei0r.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010 Stefano Sabatini
3  * This file is part of FFmpeg.
4  *
5  * FFmpeg is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * FFmpeg is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with FFmpeg; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 /**
21  * @file
22  * frei0r wrapper
23  */
24 
25 #include <frei0r.h>
26 #include <stdio.h>
27 #include <string.h>
28 #include <stdlib.h>
29 #include "config.h"
30 #include "compat/w32dlfcn.h"
31 #include "libavutil/avstring.h"
32 #include "libavutil/common.h"
33 #include "libavutil/eval.h"
34 #include "libavutil/getenv_utf8.h"
35 #include "libavutil/imgutils.h"
36 #include "libavutil/internal.h"
37 #include "libavutil/mathematics.h"
38 #include "libavutil/mem.h"
39 #include "libavutil/opt.h"
40 #include "libavutil/parseutils.h"
41 #include "avfilter.h"
42 #include "filters.h"
43 #include "formats.h"
44 #include "video.h"
45 
46 typedef f0r_instance_t (*f0r_construct_f)(unsigned int width, unsigned int height);
47 typedef void (*f0r_destruct_f)(f0r_instance_t instance);
48 typedef void (*f0r_deinit_f)(void);
49 typedef int (*f0r_init_f)(void);
50 typedef void (*f0r_get_plugin_info_f)(f0r_plugin_info_t *info);
51 typedef void (*f0r_get_param_info_f)(f0r_param_info_t *info, int param_index);
52 typedef void (*f0r_update_f)(f0r_instance_t instance, double time, const uint32_t *inframe, uint32_t *outframe);
53 typedef void (*f0r_update2_f)(f0r_instance_t instance, double time, const uint32_t *inframe1, const uint32_t *inframe2, const uint32_t *inframe3, uint32_t *outframe);
54 typedef void (*f0r_set_param_value_f)(f0r_instance_t instance, f0r_param_t param, int param_index);
55 typedef void (*f0r_get_param_value_f)(f0r_instance_t instance, f0r_param_t param, int param_index);
56 
57 typedef struct Frei0rContext {
58  const AVClass *class;
60  void *dl_handle; /* dynamic library handle */
61  f0r_instance_t instance;
62  f0r_plugin_info_t plugin_info;
63 
70 
71  char *dl_name;
72  char *params;
74 
75  /* only used by the source */
76  int w, h;
78  uint64_t pts;
80 
81 static void *load_sym(AVFilterContext *ctx, const char *sym_name)
82 {
83  Frei0rContext *s = ctx->priv;
84  void *sym = dlsym(s->dl_handle, sym_name);
85  if (!sym)
86  av_log(ctx, AV_LOG_ERROR, "Could not find symbol '%s' in loaded module.\n", sym_name);
87  return sym;
88 }
89 
90 static int set_param(AVFilterContext *ctx, f0r_param_info_t info, int index, char *param)
91 {
92  Frei0rContext *s = ctx->priv;
93  union {
94  double d;
95  f0r_param_color_t col;
96  f0r_param_position_t pos;
97  f0r_param_string str;
98  } val;
99  char *tail;
100  uint8_t rgba[4];
101 
102  switch (info.type) {
103  case F0R_PARAM_BOOL:
104  if (!strcmp(param, "y")) val.d = 1.0;
105  else if (!strcmp(param, "n")) val.d = 0.0;
106  else goto fail;
107  break;
108 
109  case F0R_PARAM_DOUBLE:
110  val.d = av_strtod(param, &tail);
111  if (*tail || val.d == HUGE_VAL)
112  goto fail;
113  break;
114 
115  case F0R_PARAM_COLOR:
116  if (sscanf(param, "%f/%f/%f", &val.col.r, &val.col.g, &val.col.b) != 3) {
117  if (av_parse_color(rgba, param, -1, ctx) < 0)
118  goto fail;
119  val.col.r = rgba[0] / 255.0;
120  val.col.g = rgba[1] / 255.0;
121  val.col.b = rgba[2] / 255.0;
122  }
123  break;
124 
125  case F0R_PARAM_POSITION:
126  if (sscanf(param, "%lf/%lf", &val.pos.x, &val.pos.y) != 2)
127  goto fail;
128  break;
129 
130  case F0R_PARAM_STRING:
131  val.str = param;
132  break;
133  }
134 
135  s->set_param_value(s->instance, &val, index);
136  return 0;
137 
138 fail:
139  av_log(ctx, AV_LOG_ERROR, "Invalid value '%s' for parameter '%s'.\n",
140  param, info.name);
141  return AVERROR(EINVAL);
142 }
143 
144 static int set_params(AVFilterContext *ctx, const char *params)
145 {
146  Frei0rContext *s = ctx->priv;
147  int i;
148 
149  if (!params)
150  return 0;
151 
152  for (i = 0; i < s->plugin_info.num_params; i++) {
153  f0r_param_info_t info;
154  char *param;
155  int ret;
156 
157  s->get_param_info(&info, i);
158 
159  if (*params) {
160  if (!(param = av_get_token(&params, "|")))
161  return AVERROR(ENOMEM);
162  if (*params)
163  params++; /* skip ':' */
164  ret = set_param(ctx, info, i, param);
165  av_free(param);
166  if (ret < 0)
167  return ret;
168  }
169  }
170 
171  return 0;
172 }
173 
174 static int load_path(AVFilterContext *ctx, void **handle_ptr, const char *prefix, const char *name)
175 {
176  char *path = av_asprintf("%s%s%s", prefix, name, SLIBSUF);
177  if (!path)
178  return AVERROR(ENOMEM);
179  av_log(ctx, AV_LOG_DEBUG, "Looking for frei0r effect in '%s'.\n", path);
180  *handle_ptr = dlopen(path, RTLD_NOW|RTLD_LOCAL);
181  av_free(path);
182  return 0;
183 }
184 
186  const char *dl_name, int type)
187 {
188  Frei0rContext *s = ctx->priv;
189  f0r_init_f f0r_init;
190  f0r_get_plugin_info_f f0r_get_plugin_info;
191  f0r_plugin_info_t *pi;
192  char *path;
193  int ret = 0;
194  int i;
195  static const char* const frei0r_pathlist[] = {
196  "/usr/local/lib/frei0r-1/",
197  "/usr/lib/frei0r-1/",
198  "/usr/local/lib64/frei0r-1/",
199  "/usr/lib64/frei0r-1/"
200  };
201 
202  if (!dl_name) {
203  av_log(ctx, AV_LOG_ERROR, "No filter name provided.\n");
204  return AVERROR(EINVAL);
205  }
206 
207  /* see: http://frei0r.dyne.org/codedoc/html/group__pluglocations.html */
208  if (path = getenv_dup("FREI0R_PATH")) {
209 #ifdef _WIN32
210  const char *separator = ";";
211 #else
212  const char *separator = ":";
213 #endif
214  char *p, *ptr = NULL;
215  for (p = path; p = av_strtok(p, separator, &ptr); p = NULL) {
216  /* add additional trailing slash in case it is missing */
217  char *p1 = av_asprintf("%s/", p);
218  if (!p1) {
219  ret = AVERROR(ENOMEM);
220  goto check_path_end;
221  }
222  ret = load_path(ctx, &s->dl_handle, p1, dl_name);
223  av_free(p1);
224  if (ret < 0)
225  goto check_path_end;
226  if (s->dl_handle)
227  break;
228  }
229 
230  check_path_end:
231  av_free(path);
232  if (ret < 0)
233  return ret;
234  }
235  if (!s->dl_handle && (path = getenv_utf8("HOME"))) {
236  char *prefix = av_asprintf("%s/.frei0r-1/lib/", path);
237  if (!prefix) {
238  ret = AVERROR(ENOMEM);
239  goto home_path_end;
240  }
241  ret = load_path(ctx, &s->dl_handle, prefix, dl_name);
242  av_free(prefix);
243 
244  home_path_end:
245  freeenv_utf8(path);
246  if (ret < 0)
247  return ret;
248  }
249  for (i = 0; !s->dl_handle && i < FF_ARRAY_ELEMS(frei0r_pathlist); i++) {
250  ret = load_path(ctx, &s->dl_handle, frei0r_pathlist[i], dl_name);
251  if (ret < 0)
252  return ret;
253  }
254  if (!s->dl_handle) {
255  av_log(ctx, AV_LOG_ERROR, "Could not find module '%s'.\n", dl_name);
256  return AVERROR(EINVAL);
257  }
258 
259  if (!(f0r_init = load_sym(ctx, "f0r_init" )) ||
260  !(f0r_get_plugin_info = load_sym(ctx, "f0r_get_plugin_info")) ||
261  !(s->get_param_info = load_sym(ctx, "f0r_get_param_info" )) ||
262  !(s->get_param_value = load_sym(ctx, "f0r_get_param_value")) ||
263  !(s->set_param_value = load_sym(ctx, "f0r_set_param_value")) ||
264  !(s->update = load_sym(ctx, "f0r_update" )) ||
265  !(s->construct = load_sym(ctx, "f0r_construct" )) ||
266  !(s->destruct = load_sym(ctx, "f0r_destruct" )) ||
267  !(s->deinit = load_sym(ctx, "f0r_deinit" )))
268  return AVERROR(EINVAL);
269 
270  if (f0r_init() < 0) {
271  av_log(ctx, AV_LOG_ERROR, "Could not init the frei0r module.\n");
272  return AVERROR(EINVAL);
273  }
274 
275  f0r_get_plugin_info(&s->plugin_info);
276  pi = &s->plugin_info;
277  if (pi->plugin_type != type) {
279  "Invalid type '%s' for this plugin\n",
280  pi->plugin_type == F0R_PLUGIN_TYPE_FILTER ? "filter" :
281  pi->plugin_type == F0R_PLUGIN_TYPE_SOURCE ? "source" :
282  pi->plugin_type == F0R_PLUGIN_TYPE_MIXER2 ? "mixer2" :
283  pi->plugin_type == F0R_PLUGIN_TYPE_MIXER3 ? "mixer3" : "unknown");
284  return AVERROR(EINVAL);
285  }
286 
288  "name:%s author:'%s' explanation:'%s' color_model:%s "
289  "frei0r_version:%d version:%d.%d num_params:%d\n",
290  pi->name, pi->author, pi->explanation,
291  pi->color_model == F0R_COLOR_MODEL_BGRA8888 ? "bgra8888" :
292  pi->color_model == F0R_COLOR_MODEL_RGBA8888 ? "rgba8888" :
293  pi->color_model == F0R_COLOR_MODEL_PACKED32 ? "packed32" : "unknown",
294  pi->frei0r_version, pi->major_version, pi->minor_version, pi->num_params);
295 
296  return 0;
297 }
298 
300 {
301  Frei0rContext *s = ctx->priv;
302 
303  return frei0r_init(ctx, s->dl_name, F0R_PLUGIN_TYPE_FILTER);
304 }
305 
307 {
308  Frei0rContext *s = ctx->priv;
309 
310  if (s->destruct && s->instance)
311  s->destruct(s->instance);
312  if (s->deinit)
313  s->deinit();
314  if (s->dl_handle)
315  dlclose(s->dl_handle);
316 }
317 
319 {
320  AVFilterContext *ctx = inlink->dst;
321  Frei0rContext *s = ctx->priv;
322 
323  if (s->destruct && s->instance)
324  s->destruct(s->instance);
325  if (!(s->instance = s->construct(inlink->w, inlink->h))) {
326  av_log(ctx, AV_LOG_ERROR, "Impossible to load frei0r instance.\n");
327  return AVERROR(EINVAL);
328  }
329 
330  return set_params(ctx, s->params);
331 }
332 
334  AVFilterFormatsConfig **cfg_in,
335  AVFilterFormatsConfig **cfg_out)
336 {
337  const Frei0rContext *s = ctx->priv;
339  int ret;
340 
341  if (s->plugin_info.color_model == F0R_COLOR_MODEL_BGRA8888) {
342  if ((ret = ff_add_format(&formats, AV_PIX_FMT_BGRA)) < 0)
343  return ret;
344  } else if (s->plugin_info.color_model == F0R_COLOR_MODEL_RGBA8888) {
345  if ((ret = ff_add_format(&formats, AV_PIX_FMT_RGBA)) < 0)
346  return ret;
347  } else { /* F0R_COLOR_MODEL_PACKED32 */
348  static const enum AVPixelFormat pix_fmts[] = {
350  };
352  }
353 
354  if (!formats)
355  return AVERROR(ENOMEM);
356 
357  return ff_set_common_formats2(ctx, cfg_in, cfg_out, formats);
358 }
359 
361 {
362  Frei0rContext *s = inlink->dst->priv;
363  AVFilterLink *outlink = inlink->dst->outputs[0];
364  /* align parameter is the line alignment, not the buffer alignment.
365  * frei0r expects line size to be width*4 so we want an align of 1
366  * to ensure lines aren't padded out. */
367  AVFrame *out = ff_default_get_video_buffer2(outlink, outlink->w, outlink->h, 1);
368  if (!out)
369  goto fail;
370 
372 
373  if (in->linesize[0] != out->linesize[0]) {
374  AVFrame *in2 = ff_default_get_video_buffer2(outlink, outlink->w, outlink->h, 1);
375  if (!in2)
376  goto fail;
377  av_frame_copy(in2, in);
378  av_frame_free(&in);
379  in = in2;
380  }
381 
382  s->update(s->instance, in->pts * av_q2d(inlink->time_base) * 1000,
383  (const uint32_t *)in->data[0],
384  (uint32_t *)out->data[0]);
385 
386  av_frame_free(&in);
387 
388  return ff_filter_frame(outlink, out);
389 fail:
390  av_frame_free(&in);
391  av_frame_free(&out);
392  return AVERROR(ENOMEM);
393 }
394 
395 static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
396  char *res, int res_len, int flags)
397 {
398  Frei0rContext *s = ctx->priv;
399  int ret;
400 
401  ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
402  if (ret < 0)
403  return ret;
404 
405  return set_params(ctx, s->params);
406 }
407 
408 #define OFFSET(x) offsetof(Frei0rContext, x)
409 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
410 #define TFLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_RUNTIME_PARAM
411 static const AVOption frei0r_options[] = {
412  { "filter_name", NULL, OFFSET(dl_name), AV_OPT_TYPE_STRING, .flags = FLAGS },
413  { "filter_params", NULL, OFFSET(params), AV_OPT_TYPE_STRING, .flags = TFLAGS },
414  { NULL }
415 };
416 
417 AVFILTER_DEFINE_CLASS(frei0r);
418 
420  {
421  .name = "default",
422  .type = AVMEDIA_TYPE_VIDEO,
423  .config_props = config_input_props,
424  .filter_frame = filter_frame,
425  },
426 };
427 
429  .name = "frei0r",
430  .description = NULL_IF_CONFIG_SMALL("Apply a frei0r effect."),
431  .init = filter_init,
432  .uninit = uninit,
433  .priv_size = sizeof(Frei0rContext),
434  .priv_class = &frei0r_class,
438  .process_command = process_command,
440 };
441 
443 {
444  Frei0rContext *s = ctx->priv;
445 
446  s->time_base.num = s->framerate.den;
447  s->time_base.den = s->framerate.num;
448 
449  return frei0r_init(ctx, s->dl_name, F0R_PLUGIN_TYPE_SOURCE);
450 }
451 
452 static int source_config_props(AVFilterLink *outlink)
453 {
454  AVFilterContext *ctx = outlink->src;
455  FilterLink *l = ff_filter_link(outlink);
456  Frei0rContext *s = ctx->priv;
457 
458  if (av_image_check_size(s->w, s->h, 0, ctx) < 0)
459  return AVERROR(EINVAL);
460  outlink->w = s->w;
461  outlink->h = s->h;
462  outlink->time_base = s->time_base;
463  l->frame_rate = av_inv_q(s->time_base);
464  outlink->sample_aspect_ratio = (AVRational){1,1};
465 
466  if (s->destruct && s->instance)
467  s->destruct(s->instance);
468  if (!(s->instance = s->construct(outlink->w, outlink->h))) {
469  av_log(ctx, AV_LOG_ERROR, "Impossible to load frei0r instance.\n");
470  return AVERROR(EINVAL);
471  }
472  if (!s->params) {
473  av_log(ctx, AV_LOG_ERROR, "frei0r filter parameters not set.\n");
474  return AVERROR(EINVAL);
475  }
476 
477  return set_params(ctx, s->params);
478 }
479 
480 static int source_request_frame(AVFilterLink *outlink)
481 {
482  Frei0rContext *s = outlink->src->priv;
483  AVFrame *frame = ff_default_get_video_buffer2(outlink, outlink->w, outlink->h, 1);
484 
485  if (!frame)
486  return AVERROR(ENOMEM);
487 
488  frame->sample_aspect_ratio = (AVRational) {1, 1};
489  frame->pts = s->pts++;
490  frame->duration = 1;
491 
492  s->update(s->instance, av_rescale_q(frame->pts, s->time_base, (AVRational){1,1000}),
493  NULL, (uint32_t *)frame->data[0]);
494 
495  return ff_filter_frame(outlink, frame);
496 }
497 
498 static const AVOption frei0r_src_options[] = {
499  { "size", "Dimensions of the generated video.", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, { .str = "320x240" }, .flags = FLAGS },
500  { "framerate", NULL, OFFSET(framerate), AV_OPT_TYPE_VIDEO_RATE, { .str = "25" }, 0, INT_MAX, .flags = FLAGS },
501  { "filter_name", NULL, OFFSET(dl_name), AV_OPT_TYPE_STRING, .flags = FLAGS },
502  { "filter_params", NULL, OFFSET(params), AV_OPT_TYPE_STRING, .flags = FLAGS },
503  { NULL },
504 };
505 
506 AVFILTER_DEFINE_CLASS(frei0r_src);
507 
509  {
510  .name = "default",
511  .type = AVMEDIA_TYPE_VIDEO,
512  .request_frame = source_request_frame,
513  .config_props = source_config_props
514  },
515 };
516 
518  .name = "frei0r_src",
519  .description = NULL_IF_CONFIG_SMALL("Generate a frei0r source."),
520  .priv_size = sizeof(Frei0rContext),
521  .priv_class = &frei0r_src_class,
522  .init = source_init,
523  .uninit = uninit,
524  .inputs = NULL,
527 };
formats
formats
Definition: signature.h:47
ff_default_get_video_buffer2
AVFrame * ff_default_get_video_buffer2(AVFilterLink *link, int w, int h, int align)
Definition: video.c:49
Frei0rContext
Definition: vf_frei0r.c:57
load_sym
static void * load_sym(AVFilterContext *ctx, const char *sym_name)
Definition: vf_frei0r.c:81
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
name
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
Definition: writing_filters.txt:88
f0r_set_param_value_f
void(* f0r_set_param_value_f)(f0r_instance_t instance, f0r_param_t param, int param_index)
Definition: vf_frei0r.c:54
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_make_format_list
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:435
out
FILE * out
Definition: movenc.c:55
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1061
av_parse_color
int av_parse_color(uint8_t *rgba_color, const char *color_string, int slen, void *log_ctx)
Put the RGBA values that correspond to color_string in rgba_color.
Definition: parseutils.c:359
AV_OPT_TYPE_VIDEO_RATE
@ AV_OPT_TYPE_VIDEO_RATE
Underlying C type is AVRational.
Definition: opt.h:315
Frei0rContext::deinit
f0r_deinit_f deinit
Definition: vf_frei0r.c:69
ff_set_common_formats2
int ff_set_common_formats2(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out, AVFilterFormats *formats)
Definition: formats.c:1007
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
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_frei0r.c:306
set_params
static int set_params(AVFilterContext *ctx, const char *params)
Definition: vf_frei0r.c:144
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(frei0r)
source_init
static av_cold int source_init(AVFilterContext *ctx)
Definition: vf_frei0r.c:442
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:162
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:262
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:389
AVFrame::pts
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:501
w
uint8_t w
Definition: llviddspenc.c:38
AVOption
AVOption.
Definition: opt.h:429
Frei0rContext::params
char * params
Definition: vf_frei0r.c:72
f0r_get_param_value_f
void(* f0r_get_param_value_f)(f0r_instance_t instance, f0r_param_t param, int param_index)
Definition: vf_frei0r.c:55
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:225
freeenv_utf8
static void freeenv_utf8(char *var)
Definition: getenv_utf8.h:72
AV_PIX_FMT_BGRA
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition: pixfmt.h:102
mathematics.h
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:205
video.h
Frei0rContext::dl_name
char * dl_name
Definition: vf_frei0r.c:71
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:410
AVFilterFormats
A list of supported formats for one end of a filter link.
Definition: formats.h:64
formats.h
f0r_update2_f
void(* f0r_update2_f)(f0r_instance_t instance, double time, const uint32_t *inframe1, const uint32_t *inframe2, const uint32_t *inframe3, uint32_t *outframe)
Definition: vf_frei0r.c:53
AVFilterContext::priv
void * priv
private data for use by the filter
Definition: avfilter.h:472
fail
#define fail()
Definition: checkasm.h:189
source_request_frame
static int source_request_frame(AVFilterLink *outlink)
Definition: vf_frei0r.c:480
Frei0rContext::plugin_info
f0r_plugin_info_t plugin_info
Definition: vf_frei0r.c:62
val
static double val(void *priv, double ch)
Definition: aeval.c:77
type
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
Definition: writing_filters.txt:86
frei0r_init
static av_cold int frei0r_init(AVFilterContext *ctx, const char *dl_name, int type)
Definition: vf_frei0r.c:185
f0r_construct_f
f0r_instance_t(* f0r_construct_f)(unsigned int width, unsigned int height)
Definition: vf_frei0r.c:46
set_param
static int set_param(AVFilterContext *ctx, f0r_param_info_t info, int index, char *param)
Definition: vf_frei0r.c:90
AVFilterPad
A filter pad used for either input or output.
Definition: filters.h:38
OFFSET
#define OFFSET(x)
Definition: vf_frei0r.c:408
TFLAGS
#define TFLAGS
Definition: vf_frei0r.c:410
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:209
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
av_cold
#define av_cold
Definition: attributes.h:90
ff_video_default_filterpad
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.
Definition: video.c:37
ff_vf_frei0r
const AVFilter ff_vf_frei0r
Definition: vf_frei0r.c:428
s
#define s(width, name)
Definition: cbs_vp9.c:198
source_config_props
static int source_config_props(AVFilterLink *outlink)
Definition: vf_frei0r.c:452
Frei0rContext::time_base
AVRational time_base
Definition: vf_frei0r.c:77
Frei0rContext::dl_handle
void * dl_handle
Definition: vf_frei0r.c:60
av_q2d
static double av_q2d(AVRational a)
Convert an AVRational to a double.
Definition: rational.h:104
info
MIPS optimizations info
Definition: mips.txt:2
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:178
Frei0rContext::get_param_info
f0r_get_param_info_f get_param_info
Definition: vf_frei0r.c:64
filters.h
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:304
process_command
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
Definition: vf_frei0r.c:395
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_frei0r.c:360
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:230
ctx
AVFormatContext * ctx
Definition: movenc.c:49
Frei0rContext::get_param_value
f0r_get_param_value_f get_param_value
Definition: vf_frei0r.c:65
av_rescale_q
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Definition: mathematics.c:142
Frei0rContext::pts
uint64_t pts
Definition: vf_frei0r.c:78
config_input_props
static int config_input_props(AVFilterLink *inlink)
Definition: vf_frei0r.c:318
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
AV_PIX_FMT_RGBA
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:100
framerate
float framerate
Definition: av1_levels.c:29
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:75
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:725
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
AV_OPT_TYPE_IMAGE_SIZE
@ AV_OPT_TYPE_IMAGE_SIZE
Underlying C type is two consecutive integers.
Definition: opt.h:303
ff_add_format
int ff_add_format(AVFilterFormats **avff, int64_t fmt)
Add fmt to the list of media formats contained in *avff.
Definition: formats.c:504
parseutils.h
getenv_utf8
static char * getenv_utf8(const char *varname)
Definition: getenv_utf8.h:67
filter_init
static av_cold int filter_init(AVFilterContext *ctx)
Definition: vf_frei0r.c:299
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
query_formats
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
Definition: vf_frei0r.c:333
AV_PIX_FMT_ABGR
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
Definition: pixfmt.h:101
index
int index
Definition: gxfenc.c:90
AVFilterFormatsConfig
Lists of formats / etc.
Definition: avfilter.h:111
ff_filter_link
static FilterLink * ff_filter_link(AVFilterLink *link)
Definition: filters.h:197
Frei0rContext::destruct
f0r_destruct_f destruct
Definition: vf_frei0r.c:68
eval.h
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:368
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
height
#define height
Definition: dsp.h:85
av_frame_copy
int av_frame_copy(AVFrame *dst, const AVFrame *src)
Copy the frame data from src to dst.
Definition: frame.c:1015
f0r_destruct_f
void(* f0r_destruct_f)(f0r_instance_t instance)
Definition: vf_frei0r.c:47
frei0r_options
static const AVOption frei0r_options[]
Definition: vf_frei0r.c:411
Frei0rContext::update
f0r_update_f update
Definition: vf_frei0r.c:59
load_path
static int load_path(AVFilterContext *ctx, void **handle_ptr, const char *prefix, const char *name)
Definition: vf_frei0r.c:174
getenv_dup
static char * getenv_dup(const char *varname)
Definition: getenv_utf8.h:76
ff_filter_process_command
int ff_filter_process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Generic processing of user supplied commands that are set in the same way as the filter options.
Definition: avfilter.c:900
getenv_utf8.h
FLAGS
#define FLAGS
Definition: vf_frei0r.c:409
AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
Definition: avfilter.h:182
AV_PIX_FMT_ARGB
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
Definition: pixfmt.h:99
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
f0r_get_param_info_f
void(* f0r_get_param_info_f)(f0r_param_info_t *info, int param_index)
Definition: vf_frei0r.c:51
internal.h
common.h
FILTER_QUERY_FUNC2
#define FILTER_QUERY_FUNC2(func)
Definition: filters.h:239
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: filters.h:44
AVFilter
Filter definition.
Definition: avfilter.h:201
ret
ret
Definition: filter_design.txt:187
frame
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 the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:264
av_strtod
double av_strtod(const char *numstr, char **tail)
Parse the string in numstr and return its value as a double.
Definition: eval.c:107
Frei0rContext::construct
f0r_construct_f construct
Definition: vf_frei0r.c:67
pos
unsigned int pos
Definition: spdifenc.c:414
f0r_init_f
int(* f0r_init_f)(void)
Definition: vf_frei0r.c:49
f0r_get_plugin_info_f
void(* f0r_get_plugin_info_f)(f0r_plugin_info_t *info)
Definition: vf_frei0r.c:50
Frei0rContext::instance
f0r_instance_t instance
Definition: vf_frei0r.c:61
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
f0r_deinit_f
void(* f0r_deinit_f)(void)
Definition: vf_frei0r.c:48
Frei0rContext::h
int h
Definition: vf_frei0r.c:76
avfilter.h
av_get_token
char * av_get_token(const char **buf, const char *term)
Unescape the given string until a non escaped terminating char, and return the token corresponding to...
Definition: avstring.c:143
ff_vsrc_frei0r_src
const AVFilter ff_vsrc_frei0r_src
Definition: vf_frei0r.c:517
f0r_update_f
void(* f0r_update_f)(f0r_instance_t instance, double time, const uint32_t *inframe, uint32_t *outframe)
Definition: vf_frei0r.c:52
AVFilterContext
An instance of a filter.
Definition: avfilter.h:457
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
mem.h
avfilter_vsrc_frei0r_src_outputs
static const AVFilterPad avfilter_vsrc_frei0r_src_outputs[]
Definition: vf_frei0r.c:508
av_free
#define av_free(p)
Definition: tableprint_vlc.h:33
Frei0rContext::w
int w
Definition: vf_frei0r.c:76
Frei0rContext::framerate
AVRational framerate
Definition: vf_frei0r.c:73
imgutils.h
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:482
AVFrame::linesize
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Definition: frame.h:434
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
Frei0rContext::set_param_value
f0r_set_param_value_f set_param_value
Definition: vf_frei0r.c:66
avfilter_vf_frei0r_inputs
static const AVFilterPad avfilter_vf_frei0r_inputs[]
Definition: vf_frei0r.c:419
avstring.h
av_image_check_size
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
Definition: imgutils.c:318
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition: opt.h:276
width
#define width
Definition: dsp.h:85
w32dlfcn.h
frei0r_src_options
static const AVOption frei0r_src_options[]
Definition: vf_frei0r.c:498