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 <dlfcn.h>
26 #include <frei0r.h>
27 #include <stdio.h>
28 #include <string.h>
29 #include <stdlib.h>
30 #include "config.h"
31 #include "libavutil/avstring.h"
32 #include "libavutil/common.h"
33 #include "libavutil/eval.h"
34 #include "libavutil/imgutils.h"
35 #include "libavutil/internal.h"
36 #include "libavutil/mathematics.h"
37 #include "libavutil/mem.h"
38 #include "libavutil/opt.h"
39 #include "libavutil/parseutils.h"
40 #include "avfilter.h"
41 #include "formats.h"
42 #include "internal.h"
43 #include "video.h"
44 
45 typedef f0r_instance_t (*f0r_construct_f)(unsigned int width, unsigned int height);
46 typedef void (*f0r_destruct_f)(f0r_instance_t instance);
47 typedef void (*f0r_deinit_f)(void);
48 typedef int (*f0r_init_f)(void);
49 typedef void (*f0r_get_plugin_info_f)(f0r_plugin_info_t *info);
50 typedef void (*f0r_get_param_info_f)(f0r_param_info_t *info, int param_index);
51 typedef void (*f0r_update_f)(f0r_instance_t instance, double time, const uint32_t *inframe, uint32_t *outframe);
52 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);
53 typedef void (*f0r_set_param_value_f)(f0r_instance_t instance, f0r_param_t param, int param_index);
54 typedef void (*f0r_get_param_value_f)(f0r_instance_t instance, f0r_param_t param, int param_index);
55 
56 typedef struct Frei0rContext {
57  const AVClass *class;
59  void *dl_handle; /* dynamic library handle */
60  f0r_instance_t instance;
61  f0r_plugin_info_t plugin_info;
62 
69 
70  char *dl_name;
71  char *params;
73 
74  /* only used by the source */
75  int w, h;
77  uint64_t pts;
79 
80 static void *load_sym(AVFilterContext *ctx, const char *sym_name)
81 {
82  Frei0rContext *s = ctx->priv;
83  void *sym = dlsym(s->dl_handle, sym_name);
84  if (!sym)
85  av_log(ctx, AV_LOG_ERROR, "Could not find symbol '%s' in loaded module.\n", sym_name);
86  return sym;
87 }
88 
89 static int set_param(AVFilterContext *ctx, f0r_param_info_t info, int index, char *param)
90 {
91  Frei0rContext *s = ctx->priv;
92  union {
93  double d;
94  f0r_param_color_t col;
95  f0r_param_position_t pos;
96  f0r_param_string str;
97  } val;
98  char *tail;
99  uint8_t rgba[4];
100 
101  switch (info.type) {
102  case F0R_PARAM_BOOL:
103  if (!strcmp(param, "y")) val.d = 1.0;
104  else if (!strcmp(param, "n")) val.d = 0.0;
105  else goto fail;
106  break;
107 
108  case F0R_PARAM_DOUBLE:
109  val.d = av_strtod(param, &tail);
110  if (*tail || val.d == HUGE_VAL)
111  goto fail;
112  break;
113 
114  case F0R_PARAM_COLOR:
115  if (sscanf(param, "%f/%f/%f", &val.col.r, &val.col.g, &val.col.b) != 3) {
116  if (av_parse_color(rgba, param, -1, ctx) < 0)
117  goto fail;
118  val.col.r = rgba[0] / 255.0;
119  val.col.g = rgba[1] / 255.0;
120  val.col.b = rgba[2] / 255.0;
121  }
122  break;
123 
124  case F0R_PARAM_POSITION:
125  if (sscanf(param, "%lf/%lf", &val.pos.x, &val.pos.y) != 2)
126  goto fail;
127  break;
128 
129  case F0R_PARAM_STRING:
130  val.str = param;
131  break;
132  }
133 
134  s->set_param_value(s->instance, &val, index);
135  return 0;
136 
137 fail:
138  av_log(ctx, AV_LOG_ERROR, "Invalid value '%s' for parameter '%s'.\n",
139  param, info.name);
140  return AVERROR(EINVAL);
141 }
142 
143 static int set_params(AVFilterContext *ctx, const char *params)
144 {
145  Frei0rContext *s = ctx->priv;
146  int i;
147 
148  if (!params)
149  return 0;
150 
151  for (i = 0; i < s->plugin_info.num_params; i++) {
152  f0r_param_info_t info;
153  char *param;
154  int ret;
155 
156  s->get_param_info(&info, i);
157 
158  if (*params) {
159  if (!(param = av_get_token(&params, "|")))
160  return AVERROR(ENOMEM);
161  if (*params)
162  params++; /* skip ':' */
163  ret = set_param(ctx, info, i, param);
164  av_free(param);
165  if (ret < 0)
166  return ret;
167  }
168  }
169 
170  return 0;
171 }
172 
173 static int load_path(AVFilterContext *ctx, void **handle_ptr, const char *prefix, const char *name)
174 {
175  char *path = av_asprintf("%s%s%s", prefix, name, SLIBSUF);
176  if (!path)
177  return AVERROR(ENOMEM);
178  av_log(ctx, AV_LOG_DEBUG, "Looking for frei0r effect in '%s'.\n", path);
179  *handle_ptr = dlopen(path, RTLD_NOW|RTLD_LOCAL);
180  av_free(path);
181  return 0;
182 }
183 
185  const char *dl_name, int type)
186 {
187  Frei0rContext *s = ctx->priv;
188  f0r_init_f f0r_init;
189  f0r_get_plugin_info_f f0r_get_plugin_info;
190  f0r_plugin_info_t *pi;
191  char *path;
192  int ret = 0;
193  int i;
194  static const char* const frei0r_pathlist[] = {
195  "/usr/local/lib/frei0r-1/",
196  "/usr/lib/frei0r-1/",
197  "/usr/local/lib64/frei0r-1/",
198  "/usr/lib64/frei0r-1/"
199  };
200 
201  if (!dl_name) {
202  av_log(ctx, AV_LOG_ERROR, "No filter name provided.\n");
203  return AVERROR(EINVAL);
204  }
205 
206  /* see: http://frei0r.dyne.org/codedoc/html/group__pluglocations.html */
207  if ((path = av_strdup(getenv("FREI0R_PATH")))) {
208 #ifdef _WIN32
209  const char *separator = ";";
210 #else
211  const char *separator = ":";
212 #endif
213  char *p, *ptr = NULL;
214  for (p = path; p = av_strtok(p, separator, &ptr); p = NULL) {
215  /* add additional trailing slash in case it is missing */
216  char *p1 = av_asprintf("%s/", p);
217  if (!p1) {
218  ret = AVERROR(ENOMEM);
219  goto check_path_end;
220  }
221  ret = load_path(ctx, &s->dl_handle, p1, dl_name);
222  av_free(p1);
223  if (ret < 0)
224  goto check_path_end;
225  if (s->dl_handle)
226  break;
227  }
228 
229  check_path_end:
230  av_free(path);
231  if (ret < 0)
232  return ret;
233  }
234  if (!s->dl_handle && (path = getenv("HOME"))) {
235  char *prefix = av_asprintf("%s/.frei0r-1/lib/", path);
236  if (!prefix)
237  return AVERROR(ENOMEM);
238  ret = load_path(ctx, &s->dl_handle, prefix, dl_name);
239  av_free(prefix);
240  if (ret < 0)
241  return ret;
242  }
243  for (i = 0; !s->dl_handle && i < FF_ARRAY_ELEMS(frei0r_pathlist); i++) {
244  ret = load_path(ctx, &s->dl_handle, frei0r_pathlist[i], dl_name);
245  if (ret < 0)
246  return ret;
247  }
248  if (!s->dl_handle) {
249  av_log(ctx, AV_LOG_ERROR, "Could not find module '%s'.\n", dl_name);
250  return AVERROR(EINVAL);
251  }
252 
253  if (!(f0r_init = load_sym(ctx, "f0r_init" )) ||
254  !(f0r_get_plugin_info = load_sym(ctx, "f0r_get_plugin_info")) ||
255  !(s->get_param_info = load_sym(ctx, "f0r_get_param_info" )) ||
256  !(s->get_param_value = load_sym(ctx, "f0r_get_param_value")) ||
257  !(s->set_param_value = load_sym(ctx, "f0r_set_param_value")) ||
258  !(s->update = load_sym(ctx, "f0r_update" )) ||
259  !(s->construct = load_sym(ctx, "f0r_construct" )) ||
260  !(s->destruct = load_sym(ctx, "f0r_destruct" )) ||
261  !(s->deinit = load_sym(ctx, "f0r_deinit" )))
262  return AVERROR(EINVAL);
263 
264  if (f0r_init() < 0) {
265  av_log(ctx, AV_LOG_ERROR, "Could not init the frei0r module.\n");
266  return AVERROR(EINVAL);
267  }
268 
269  f0r_get_plugin_info(&s->plugin_info);
270  pi = &s->plugin_info;
271  if (pi->plugin_type != type) {
273  "Invalid type '%s' for this plugin\n",
274  pi->plugin_type == F0R_PLUGIN_TYPE_FILTER ? "filter" :
275  pi->plugin_type == F0R_PLUGIN_TYPE_SOURCE ? "source" :
276  pi->plugin_type == F0R_PLUGIN_TYPE_MIXER2 ? "mixer2" :
277  pi->plugin_type == F0R_PLUGIN_TYPE_MIXER3 ? "mixer3" : "unknown");
278  return AVERROR(EINVAL);
279  }
280 
282  "name:%s author:'%s' explanation:'%s' color_model:%s "
283  "frei0r_version:%d version:%d.%d num_params:%d\n",
284  pi->name, pi->author, pi->explanation,
285  pi->color_model == F0R_COLOR_MODEL_BGRA8888 ? "bgra8888" :
286  pi->color_model == F0R_COLOR_MODEL_RGBA8888 ? "rgba8888" :
287  pi->color_model == F0R_COLOR_MODEL_PACKED32 ? "packed32" : "unknown",
288  pi->frei0r_version, pi->major_version, pi->minor_version, pi->num_params);
289 
290  return 0;
291 }
292 
294 {
295  Frei0rContext *s = ctx->priv;
296 
297  return frei0r_init(ctx, s->dl_name, F0R_PLUGIN_TYPE_FILTER);
298 }
299 
301 {
302  Frei0rContext *s = ctx->priv;
303 
304  if (s->destruct && s->instance)
305  s->destruct(s->instance);
306  if (s->deinit)
307  s->deinit();
308  if (s->dl_handle)
309  dlclose(s->dl_handle);
310 }
311 
313 {
314  AVFilterContext *ctx = inlink->dst;
315  Frei0rContext *s = ctx->priv;
316 
317  if (s->destruct && s->instance)
318  s->destruct(s->instance);
319  if (!(s->instance = s->construct(inlink->w, inlink->h))) {
320  av_log(ctx, AV_LOG_ERROR, "Impossible to load frei0r instance.\n");
321  return AVERROR(EINVAL);
322  }
323 
324  return set_params(ctx, s->params);
325 }
326 
328 {
329  Frei0rContext *s = ctx->priv;
331  int ret;
332 
333  if (s->plugin_info.color_model == F0R_COLOR_MODEL_BGRA8888) {
334  if ((ret = ff_add_format(&formats, AV_PIX_FMT_BGRA)) < 0)
335  return ret;
336  } else if (s->plugin_info.color_model == F0R_COLOR_MODEL_RGBA8888) {
337  if ((ret = ff_add_format(&formats, AV_PIX_FMT_RGBA)) < 0)
338  return ret;
339  } else { /* F0R_COLOR_MODEL_PACKED32 */
340  static const enum AVPixelFormat pix_fmts[] = {
342  };
344  }
345 
346  if (!formats)
347  return AVERROR(ENOMEM);
348 
350 }
351 
353 {
354  Frei0rContext *s = inlink->dst->priv;
355  AVFilterLink *outlink = inlink->dst->outputs[0];
356  AVFrame *out;
357 
358  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
359  if (!out) {
360  av_frame_free(&in);
361  return AVERROR(ENOMEM);
362  }
364 
365  s->update(s->instance, in->pts * av_q2d(inlink->time_base) * 1000,
366  (const uint32_t *)in->data[0],
367  (uint32_t *)out->data[0]);
368 
369  av_frame_free(&in);
370 
371  return ff_filter_frame(outlink, out);
372 }
373 
374 #define OFFSET(x) offsetof(Frei0rContext, x)
375 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
376 static const AVOption frei0r_options[] = {
377  { "filter_name", NULL, OFFSET(dl_name), AV_OPT_TYPE_STRING, .flags = FLAGS },
378  { "filter_params", NULL, OFFSET(params), AV_OPT_TYPE_STRING, .flags = FLAGS },
379  { NULL }
380 };
381 
382 AVFILTER_DEFINE_CLASS(frei0r);
383 
385  {
386  .name = "default",
387  .type = AVMEDIA_TYPE_VIDEO,
388  .config_props = config_input_props,
389  .filter_frame = filter_frame,
390  },
391  { NULL }
392 };
393 
395  {
396  .name = "default",
397  .type = AVMEDIA_TYPE_VIDEO,
398  },
399  { NULL }
400 };
401 
403  .name = "frei0r",
404  .description = NULL_IF_CONFIG_SMALL("Apply a frei0r effect."),
405  .query_formats = query_formats,
406  .init = filter_init,
407  .uninit = uninit,
408  .priv_size = sizeof(Frei0rContext),
409  .priv_class = &frei0r_class,
412 };
413 
415 {
416  Frei0rContext *s = ctx->priv;
417 
418  s->time_base.num = s->framerate.den;
419  s->time_base.den = s->framerate.num;
420 
421  return frei0r_init(ctx, s->dl_name, F0R_PLUGIN_TYPE_SOURCE);
422 }
423 
424 static int source_config_props(AVFilterLink *outlink)
425 {
426  AVFilterContext *ctx = outlink->src;
427  Frei0rContext *s = ctx->priv;
428 
429  if (av_image_check_size(s->w, s->h, 0, ctx) < 0)
430  return AVERROR(EINVAL);
431  outlink->w = s->w;
432  outlink->h = s->h;
433  outlink->time_base = s->time_base;
434  outlink->frame_rate = av_inv_q(s->time_base);
435  outlink->sample_aspect_ratio = (AVRational){1,1};
436 
437  if (s->destruct && s->instance)
438  s->destruct(s->instance);
439  if (!(s->instance = s->construct(outlink->w, outlink->h))) {
440  av_log(ctx, AV_LOG_ERROR, "Impossible to load frei0r instance.\n");
441  return AVERROR(EINVAL);
442  }
443  if (!s->params) {
444  av_log(ctx, AV_LOG_ERROR, "frei0r filter parameters not set.\n");
445  return AVERROR(EINVAL);
446  }
447 
448  return set_params(ctx, s->params);
449 }
450 
451 static int source_request_frame(AVFilterLink *outlink)
452 {
453  Frei0rContext *s = outlink->src->priv;
454  AVFrame *frame = ff_get_video_buffer(outlink, outlink->w, outlink->h);
455 
456  if (!frame)
457  return AVERROR(ENOMEM);
458 
459  frame->sample_aspect_ratio = (AVRational) {1, 1};
460  frame->pts = s->pts++;
461 
462  s->update(s->instance, av_rescale_q(frame->pts, s->time_base, (AVRational){1,1000}),
463  NULL, (uint32_t *)frame->data[0]);
464 
465  return ff_filter_frame(outlink, frame);
466 }
467 
468 static const AVOption frei0r_src_options[] = {
469  { "size", "Dimensions of the generated video.", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, { .str = "320x240" }, .flags = FLAGS },
470  { "framerate", NULL, OFFSET(framerate), AV_OPT_TYPE_VIDEO_RATE, { .str = "25" }, 0, INT_MAX, .flags = FLAGS },
471  { "filter_name", NULL, OFFSET(dl_name), AV_OPT_TYPE_STRING, .flags = FLAGS },
472  { "filter_params", NULL, OFFSET(params), AV_OPT_TYPE_STRING, .flags = FLAGS },
473  { NULL },
474 };
475 
476 AVFILTER_DEFINE_CLASS(frei0r_src);
477 
479  {
480  .name = "default",
481  .type = AVMEDIA_TYPE_VIDEO,
482  .request_frame = source_request_frame,
483  .config_props = source_config_props
484  },
485  { NULL }
486 };
487 
489  .name = "frei0r_src",
490  .description = NULL_IF_CONFIG_SMALL("Generate a frei0r source."),
491  .priv_size = sizeof(Frei0rContext),
492  .priv_class = &frei0r_src_class,
493  .init = source_init,
494  .uninit = uninit,
496  .inputs = NULL,
498 };
formats
formats
Definition: signature.h:48
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:99
Frei0rContext
Definition: vf_frei0r.c:56
load_sym
static void * load_sym(AVFilterContext *ctx, const char *sym_name)
Definition: vf_frei0r.c:80
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
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:53
init
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
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:300
out
FILE * out
Definition: movenc.c:54
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:149
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1075
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:354
AV_OPT_TYPE_VIDEO_RATE
@ AV_OPT_TYPE_VIDEO_RATE
offset must point to AVRational
Definition: opt.h:236
Frei0rContext::deinit
f0r_deinit_f deinit
Definition: vf_frei0r.c:68
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
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_frei0r.c:300
set_params
static int set_params(AVFilterContext *ctx, const char *params)
Definition: vf_frei0r.c:143
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(frei0r)
source_init
static av_cold int source_init(AVFilterContext *ctx)
Definition: vf_frei0r.c:414
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:203
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:300
w
uint8_t w
Definition: llviddspenc.c:38
AVOption
AVOption.
Definition: opt.h:246
Frei0rContext::params
char * params
Definition: vf_frei0r.c:71
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:54
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:192
AV_PIX_FMT_BGRA
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition: pixfmt.h:95
mathematics.h
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:148
video.h
Frei0rContext::dl_name
char * dl_name
Definition: vf_frei0r.c:70
AVFilterFormats
A list of supported formats for one end of a filter link.
Definition: formats.h:64
ff_vsrc_frei0r_src
AVFilter ff_vsrc_frei0r_src
Definition: vf_frei0r.c:488
formats.h
framerate
int framerate
Definition: h264_levels.c:65
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:52
AVFilterContext::priv
void * priv
private data for use by the filter
Definition: avfilter.h:353
fail
#define fail()
Definition: checkasm.h:123
source_request_frame
static int source_request_frame(AVFilterLink *outlink)
Definition: vf_frei0r.c:451
Frei0rContext::plugin_info
f0r_plugin_info_t plugin_info
Definition: vf_frei0r.c:61
val
static double val(void *priv, double ch)
Definition: aeval.c:76
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:184
f0r_construct_f
f0r_instance_t(* f0r_construct_f)(unsigned int width, unsigned int height)
Definition: vf_frei0r.c:45
set_param
static int set_param(AVFilterContext *ctx, f0r_param_info_t info, int index, char *param)
Definition: vf_frei0r.c:89
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:54
OFFSET
#define OFFSET(x)
Definition: vf_frei0r.c:374
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
av_cold
#define av_cold
Definition: attributes.h:90
ff_set_common_formats
int ff_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats)
A helper for query_formats() which sets all links to the same list of formats.
Definition: formats.c:605
width
#define width
s
#define s(width, name)
Definition: cbs_vp9.c:257
source_config_props
static int source_config_props(AVFilterLink *outlink)
Definition: vf_frei0r.c:424
Frei0rContext::time_base
AVRational time_base
Definition: vf_frei0r.c:76
Frei0rContext::dl_handle
void * dl_handle
Definition: vf_frei0r.c:59
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:184
Frei0rContext::get_param_info
f0r_get_param_info_f get_param_info
Definition: vf_frei0r.c:63
outputs
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:275
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_frei0r.c:352
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:197
ctx
AVFormatContext * ctx
Definition: movenc.c:48
Frei0rContext::get_param_value
f0r_get_param_value_f get_param_value
Definition: vf_frei0r.c:64
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:77
config_input_props
static int config_input_props(AVFilterLink *inlink)
Definition: vf_frei0r.c:312
AV_PIX_FMT_RGBA
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:93
AVClass
Describe the class of an AVClass context structure.
Definition: log.h: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:659
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
AV_OPT_TYPE_IMAGE_SIZE
@ AV_OPT_TYPE_IMAGE_SIZE
offset must point to two consecutive integers
Definition: opt.h:233
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:350
parseutils.h
filter_init
static av_cold int filter_init(AVFilterContext *ctx)
Definition: vf_frei0r.c:293
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
AV_PIX_FMT_ABGR
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
Definition: pixfmt.h:94
index
int index
Definition: gxfenc.c:89
Frei0rContext::destruct
f0r_destruct_f destruct
Definition: vf_frei0r.c:67
eval.h
ff_vf_frei0r
AVFilter ff_vf_frei0r
Definition: vf_frei0r.c:402
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:188
f0r_destruct_f
void(* f0r_destruct_f)(f0r_instance_t instance)
Definition: vf_frei0r.c:46
frei0r_options
static const AVOption frei0r_options[]
Definition: vf_frei0r.c:376
Frei0rContext::update
f0r_update_f update
Definition: vf_frei0r.c:58
load_path
static int load_path(AVFilterContext *ctx, void **handle_ptr, const char *prefix, const char *name)
Definition: vf_frei0r.c:173
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: vf_frei0r.c:327
height
#define height
FLAGS
#define FLAGS
Definition: vf_frei0r.c:375
avfilter_vf_frei0r_outputs
static const AVFilterPad avfilter_vf_frei0r_outputs[]
Definition: vf_frei0r.c:394
internal.h
AV_PIX_FMT_ARGB
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
Definition: pixfmt.h:92
in
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method !=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2) { ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc) { av_free(ac);return NULL;} return ac;} in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar) { ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar ? ac->channels :1;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
Definition: audio_convert.c:326
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
f0r_get_param_info_f
void(* f0r_get_param_info_f)(f0r_param_info_t *info, int param_index)
Definition: vf_frei0r.c:50
internal.h
common.h
uint8_t
uint8_t
Definition: audio_convert.c:194
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:60
AVFilter
Filter definition.
Definition: avfilter.h:144
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:106
Frei0rContext::construct
f0r_construct_f construct
Definition: vf_frei0r.c:66
pos
unsigned int pos
Definition: spdifenc.c:412
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen_template.c:38
f0r_init_f
int(* f0r_init_f)(void)
Definition: vf_frei0r.c:48
f0r_get_plugin_info_f
void(* f0r_get_plugin_info_f)(f0r_plugin_info_t *info)
Definition: vf_frei0r.c:49
Frei0rContext::instance
f0r_instance_t instance
Definition: vf_frei0r.c:60
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
f0r_deinit_f
void(* f0r_deinit_f)(void)
Definition: vf_frei0r.c:47
Frei0rContext::h
int h
Definition: vf_frei0r.c:75
avfilter.h
f0r_update_f
void(* f0r_update_f)(f0r_instance_t instance, double time, const uint32_t *inframe, uint32_t *outframe)
Definition: vf_frei0r.c:51
AVFilterContext
An instance of a filter.
Definition: avfilter.h:338
av_strdup
char * av_strdup(const char *s)
Duplicate a string.
Definition: mem.c:253
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:478
av_free
#define av_free(p)
Definition: tableprint_vlc.h:34
Frei0rContext::w
int w
Definition: vf_frei0r.c:75
Frei0rContext::framerate
AVRational framerate
Definition: vf_frei0r.c:72
convert_header.str
string str
Definition: convert_header.py:20
imgutils.h
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
Frei0rContext::set_param_value
f0r_set_param_value_f set_param_value
Definition: vf_frei0r.c:65
avfilter_vf_frei0r_inputs
static const AVFilterPad avfilter_vf_frei0r_inputs[]
Definition: vf_frei0r.c:384
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:282
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:227
int
int
Definition: ffmpeg_filter.c:192
frei0r_src_options
static const AVOption frei0r_src_options[]
Definition: vf_frei0r.c:468