FFmpeg
af_lv2.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 Paul B Mahol
3  * Copyright (c) 2007-2016 David Robillard <http://drobilla.net>
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 /**
23  * @file
24  * LV2 wrapper
25  */
26 
27 #include <lilv/lilv.h>
28 #include <lv2/lv2plug.in/ns/ext/atom/atom.h>
29 #include <lv2/lv2plug.in/ns/ext/buf-size/buf-size.h>
30 
31 #include "libavutil/avstring.h"
33 #include "libavutil/opt.h"
34 #include "audio.h"
35 #include "avfilter.h"
36 #include "formats.h"
37 #include "internal.h"
38 
39 typedef struct URITable {
40  char **uris;
41  size_t n_uris;
42 } URITable;
43 
44 typedef struct LV2Context {
45  const AVClass *class;
46  char *plugin_uri;
47  char *options;
48 
49  unsigned nb_inputs;
50  unsigned nb_inputcontrols;
51  unsigned nb_outputs;
52 
55  int64_t pts;
56  int64_t duration;
57 
58  LilvWorld *world;
59  const LilvPlugin *plugin;
60  uint32_t nb_ports;
61  float *values;
63  LV2_URID_Map map;
64  LV2_Feature map_feature;
65  LV2_URID_Unmap unmap;
66  LV2_Feature unmap_feature;
67  LV2_Atom_Sequence seq_in[2];
68  LV2_Atom_Sequence *seq_out;
69  const LV2_Feature *features[5];
70 
71  float *mins;
72  float *maxes;
73  float *controls;
74 
75  LilvInstance *instance;
76 
77  LilvNode *atom_AtomPort;
78  LilvNode *atom_Sequence;
79  LilvNode *lv2_AudioPort;
80  LilvNode *lv2_CVPort;
81  LilvNode *lv2_ControlPort;
82  LilvNode *lv2_Optional;
83  LilvNode *lv2_InputPort;
84  LilvNode *lv2_OutputPort;
85  LilvNode *urid_map;
87  LilvNode *fixedBlockLength;
88  LilvNode *boundedBlockLength;
89 } LV2Context;
90 
91 #define OFFSET(x) offsetof(LV2Context, x)
92 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
93 
94 static const AVOption lv2_options[] = {
95  { "plugin", "set plugin uri", OFFSET(plugin_uri), AV_OPT_TYPE_STRING, .flags = FLAGS },
96  { "p", "set plugin uri", OFFSET(plugin_uri), AV_OPT_TYPE_STRING, .flags = FLAGS },
97  { "controls", "set plugin options", OFFSET(options), AV_OPT_TYPE_STRING, .flags = FLAGS },
98  { "c", "set plugin options", OFFSET(options), AV_OPT_TYPE_STRING, .flags = FLAGS },
99  { "sample_rate", "set sample rate", OFFSET(sample_rate), AV_OPT_TYPE_INT, {.i64=44100}, 1, INT32_MAX, FLAGS },
100  { "s", "set sample rate", OFFSET(sample_rate), AV_OPT_TYPE_INT, {.i64=44100}, 1, INT32_MAX, FLAGS },
101  { "nb_samples", "set the number of samples per requested frame", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.i64=1024}, 1, INT_MAX, FLAGS },
102  { "n", "set the number of samples per requested frame", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.i64=1024}, 1, INT_MAX, FLAGS },
103  { "duration", "set audio duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64=-1}, -1, INT64_MAX, FLAGS },
104  { "d", "set audio duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64=-1}, -1, INT64_MAX, FLAGS },
105  { NULL }
106 };
107 
109 
111 {
112  table->uris = NULL;
113  table->n_uris = 0;
114 }
115 
117 {
118  int i;
119 
120  for (i = 0; i < table->n_uris; i++) {
121  av_freep(&table->uris[i]);
122  }
123 
124  av_freep(&table->uris);
125 }
126 
127 static LV2_URID uri_table_map(LV2_URID_Map_Handle handle, const char *uri)
128 {
129  URITable *table = (URITable*)handle;
130  const size_t len = strlen(uri);
131  size_t i;
132  char **tmp;
133 
134  for (i = 0; i < table->n_uris; i++) {
135  if (!strcmp(table->uris[i], uri)) {
136  return i + 1;
137  }
138  }
139 
140  tmp = av_calloc(table->n_uris + 1, sizeof(char*));
141  if (!tmp)
142  return table->n_uris;
143  memcpy(tmp, table->uris, table->n_uris * sizeof(char**));
144 
145  av_free(table->uris);
146  table->uris = tmp;
147  table->uris[table->n_uris] = av_malloc(len + 1);
148  if (!table->uris[table->n_uris])
149  return table->n_uris;
150 
151  memcpy(table->uris[table->n_uris], uri, len + 1);
152  table->n_uris++;
153 
154  return table->n_uris;
155 }
156 
157 static const char *uri_table_unmap(LV2_URID_Map_Handle handle, LV2_URID urid)
158 {
159  URITable *table = (URITable*)handle;
160 
161  if (urid > 0 && urid <= table->n_uris) {
162  return table->uris[urid - 1];
163  }
164 
165  return NULL;
166 }
167 
169 {
170  int ich = 0, och = 0, i;
171 
172  for (i = 0; i < s->nb_ports; i++) {
173  const LilvPort *port = lilv_plugin_get_port_by_index(s->plugin, i);
174 
175  if (lilv_port_is_a(s->plugin, port, s->lv2_AudioPort) ||
176  lilv_port_is_a(s->plugin, port, s->lv2_CVPort)) {
177  if (lilv_port_is_a(s->plugin, port, s->lv2_InputPort)) {
178  lilv_instance_connect_port(s->instance, i, in->extended_data[ich++]);
179  } else if (lilv_port_is_a(s->plugin, port, s->lv2_OutputPort)) {
180  lilv_instance_connect_port(s->instance, i, out->extended_data[och++]);
181  } else {
182  av_log(s, AV_LOG_WARNING, "port %d neither input nor output, skipping\n", i);
183  }
184  } else if (lilv_port_is_a(s->plugin, port, s->atom_AtomPort)) {
185  if (lilv_port_is_a(s->plugin, port, s->lv2_InputPort)) {
186  lilv_instance_connect_port(s->instance, i, &s->seq_in);
187  } else {
188  lilv_instance_connect_port(s->instance, i, s->seq_out);
189  }
190  } else if (lilv_port_is_a(s->plugin, port, s->lv2_ControlPort)) {
191  lilv_instance_connect_port(s->instance, i, &s->controls[i]);
192  }
193  }
194 
195  s->seq_in[0].atom.size = sizeof(LV2_Atom_Sequence_Body);
196  s->seq_in[0].atom.type = uri_table_map(&s->uri_table, LV2_ATOM__Sequence);
197  s->seq_out->atom.size = 9624;
198  s->seq_out->atom.type = uri_table_map(&s->uri_table, LV2_ATOM__Chunk);
199 }
200 
202 {
203  AVFilterContext *ctx = inlink->dst;
204  LV2Context *s = ctx->priv;
205  AVFrame *out;
206 
207  if (!s->nb_outputs ||
208  (av_frame_is_writable(in) && s->nb_inputs == s->nb_outputs)) {
209  out = in;
210  } else {
211  out = ff_get_audio_buffer(ctx->outputs[0], in->nb_samples);
212  if (!out) {
213  av_frame_free(&in);
214  return AVERROR(ENOMEM);
215  }
217  }
218 
219  connect_ports(s, in, out);
220 
221  lilv_instance_run(s->instance, in->nb_samples);
222 
223  if (out != in)
224  av_frame_free(&in);
225 
226  return ff_filter_frame(ctx->outputs[0], out);
227 }
228 
229 static int request_frame(AVFilterLink *outlink)
230 {
231  AVFilterContext *ctx = outlink->src;
232  LV2Context *s = ctx->priv;
233  AVFrame *out;
234  int64_t t;
235 
236  if (ctx->nb_inputs)
237  return ff_request_frame(ctx->inputs[0]);
238 
239  t = av_rescale(s->pts, AV_TIME_BASE, s->sample_rate);
240  if (s->duration >= 0 && t >= s->duration)
241  return AVERROR_EOF;
242 
243  out = ff_get_audio_buffer(outlink, s->nb_samples);
244  if (!out)
245  return AVERROR(ENOMEM);
246 
247  connect_ports(s, out, out);
248 
249  lilv_instance_run(s->instance, out->nb_samples);
250 
251  out->sample_rate = s->sample_rate;
252  out->pts = s->pts;
253  s->pts += s->nb_samples;
254 
255  return ff_filter_frame(outlink, out);
256 }
257 
258 static const LV2_Feature buf_size_features[3] = {
259  { LV2_BUF_SIZE__powerOf2BlockLength, NULL },
260  { LV2_BUF_SIZE__fixedBlockLength, NULL },
261  { LV2_BUF_SIZE__boundedBlockLength, NULL },
262 };
263 
264 static int config_output(AVFilterLink *outlink)
265 {
266  AVFilterContext *ctx = outlink->src;
267  LV2Context *s = ctx->priv;
268  char *p, *arg, *saveptr = NULL;
269  int i, sample_rate;
270 
271  uri_table_init(&s->uri_table);
272  s->map.handle = &s->uri_table;
273  s->map.map = uri_table_map;
274  s->map_feature.URI = LV2_URID_MAP_URI;
275  s->map_feature.data = &s->map;
276  s->unmap.handle = &s->uri_table;
277  s->unmap.unmap = uri_table_unmap;
278  s->unmap_feature.URI = LV2_URID_UNMAP_URI;
279  s->unmap_feature.data = &s->unmap;
280  s->features[0] = &s->map_feature;
281  s->features[1] = &s->unmap_feature;
282  s->features[2] = &buf_size_features[0];
283  s->features[3] = &buf_size_features[1];
284  s->features[4] = &buf_size_features[2];
285 
286  if (ctx->nb_inputs) {
287  AVFilterLink *inlink = ctx->inputs[0];
288 
289  outlink->format = inlink->format;
290  outlink->sample_rate = sample_rate = inlink->sample_rate;
291  if (s->nb_inputs == s->nb_outputs) {
292  int ret;
293  if ((ret = av_channel_layout_copy(&outlink->ch_layout, &inlink->ch_layout)) < 0)
294  return ret;
295 #if FF_API_OLD_CHANNEL_LAYOUT
297  outlink->channel_layout = inlink->channel_layout;
299 #endif
300  }
301 
302  } else {
303  outlink->sample_rate = sample_rate = s->sample_rate;
304  outlink->time_base = (AVRational){1, s->sample_rate};
305  }
306 
307  s->instance = lilv_plugin_instantiate(s->plugin, sample_rate, s->features);
308  if (!s->instance) {
309  av_log(s, AV_LOG_ERROR, "Failed to instantiate <%s>\n", lilv_node_as_uri(lilv_plugin_get_uri(s->plugin)));
310  return AVERROR(EINVAL);
311  }
312 
313  s->mins = av_calloc(s->nb_ports, sizeof(float));
314  s->maxes = av_calloc(s->nb_ports, sizeof(float));
315  s->controls = av_calloc(s->nb_ports, sizeof(float));
316 
317  if (!s->mins || !s->maxes || !s->controls)
318  return AVERROR(ENOMEM);
319 
320  lilv_plugin_get_port_ranges_float(s->plugin, s->mins, s->maxes, s->controls);
321  s->seq_out = av_malloc(sizeof(LV2_Atom_Sequence) + 9624);
322  if (!s->seq_out)
323  return AVERROR(ENOMEM);
324 
325  if (s->options && !strcmp(s->options, "help")) {
326  if (!s->nb_inputcontrols) {
328  "The '%s' plugin does not have any input controls.\n",
329  s->plugin_uri);
330  } else {
332  "The '%s' plugin has the following input controls:\n",
333  s->plugin_uri);
334  for (i = 0; i < s->nb_ports; i++) {
335  const LilvPort *port = lilv_plugin_get_port_by_index(s->plugin, i);
336  const LilvNode *symbol = lilv_port_get_symbol(s->plugin, port);
337  LilvNode *name = lilv_port_get_name(s->plugin, port);
338 
339  if (lilv_port_is_a(s->plugin, port, s->lv2_InputPort) &&
340  lilv_port_is_a(s->plugin, port, s->lv2_ControlPort)) {
341  av_log(ctx, AV_LOG_INFO, "%s\t\t<float> (from %f to %f) (default %f)\t\t%s\n",
342  lilv_node_as_string(symbol), s->mins[i], s->maxes[i], s->controls[i],
343  lilv_node_as_string(name));
344  }
345 
346  lilv_node_free(name);
347  }
348  }
349  return AVERROR_EXIT;
350  }
351 
352  p = s->options;
353  while (s->options) {
354  const LilvPort *port;
355  LilvNode *sym;
356  float val;
357  char *str, *vstr;
358  int index;
359 
360  if (!(arg = av_strtok(p, " |", &saveptr)))
361  break;
362  p = NULL;
363 
364  vstr = strstr(arg, "=");
365  if (vstr == NULL) {
366  av_log(ctx, AV_LOG_ERROR, "Invalid syntax.\n");
367  return AVERROR(EINVAL);
368  }
369 
370  vstr[0] = 0;
371  str = arg;
372  val = atof(vstr+1);
373  sym = lilv_new_string(s->world, str);
374  port = lilv_plugin_get_port_by_symbol(s->plugin, sym);
375  lilv_node_free(sym);
376  if (!port) {
377  av_log(s, AV_LOG_WARNING, "Unknown option: <%s>\n", str);
378  } else {
379  index = lilv_port_get_index(s->plugin, port);
380  s->controls[index] = val;
381  }
382  }
383 
384  if (s->nb_inputs &&
385  (lilv_plugin_has_feature(s->plugin, s->powerOf2BlockLength) ||
386  lilv_plugin_has_feature(s->plugin, s->fixedBlockLength) ||
387  lilv_plugin_has_feature(s->plugin, s->boundedBlockLength))) {
388  AVFilterLink *inlink = ctx->inputs[0];
389 
390  inlink->min_samples = inlink->max_samples = 4096;
391  }
392 
393  return 0;
394 }
395 
397 {
398  LV2Context *s = ctx->priv;
399  const LilvPlugins *plugins;
400  const LilvPlugin *plugin;
401  AVFilterPad pad = { NULL };
402  LilvNode *uri;
403  int i, ret;
404 
405  s->world = lilv_world_new();
406  if (!s->world)
407  return AVERROR(ENOMEM);
408 
409  uri = lilv_new_uri(s->world, s->plugin_uri);
410  if (!uri) {
411  av_log(s, AV_LOG_ERROR, "Invalid plugin URI <%s>\n", s->plugin_uri);
412  return AVERROR(EINVAL);
413  }
414 
415  lilv_world_load_all(s->world);
416  plugins = lilv_world_get_all_plugins(s->world);
417  plugin = lilv_plugins_get_by_uri(plugins, uri);
418  lilv_node_free(uri);
419 
420  if (!plugin) {
421  av_log(s, AV_LOG_ERROR, "Plugin <%s> not found\n", s->plugin_uri);
422  return AVERROR(EINVAL);
423  }
424 
425  s->plugin = plugin;
426  s->nb_ports = lilv_plugin_get_num_ports(s->plugin);
427 
428  s->lv2_InputPort = lilv_new_uri(s->world, LV2_CORE__InputPort);
429  s->lv2_OutputPort = lilv_new_uri(s->world, LV2_CORE__OutputPort);
430  s->lv2_AudioPort = lilv_new_uri(s->world, LV2_CORE__AudioPort);
431  s->lv2_ControlPort = lilv_new_uri(s->world, LV2_CORE__ControlPort);
432  s->lv2_Optional = lilv_new_uri(s->world, LV2_CORE__connectionOptional);
433  s->atom_AtomPort = lilv_new_uri(s->world, LV2_ATOM__AtomPort);
434  s->atom_Sequence = lilv_new_uri(s->world, LV2_ATOM__Sequence);
435  s->urid_map = lilv_new_uri(s->world, LV2_URID__map);
436  s->powerOf2BlockLength = lilv_new_uri(s->world, LV2_BUF_SIZE__powerOf2BlockLength);
437  s->fixedBlockLength = lilv_new_uri(s->world, LV2_BUF_SIZE__fixedBlockLength);
438  s->boundedBlockLength = lilv_new_uri(s->world, LV2_BUF_SIZE__boundedBlockLength);
439 
440  for (i = 0; i < s->nb_ports; i++) {
441  const LilvPort *lport = lilv_plugin_get_port_by_index(s->plugin, i);
442  int is_input = 0;
443  int is_optional = 0;
444 
445  is_optional = lilv_port_has_property(s->plugin, lport, s->lv2_Optional);
446 
447  if (lilv_port_is_a(s->plugin, lport, s->lv2_InputPort)) {
448  is_input = 1;
449  } else if (!lilv_port_is_a(s->plugin, lport, s->lv2_OutputPort) && !is_optional) {
450  return AVERROR(EINVAL);
451  }
452 
453  if (lilv_port_is_a(s->plugin, lport, s->lv2_ControlPort)) {
454  if (is_input) {
455  s->nb_inputcontrols++;
456  }
457  } else if (lilv_port_is_a(s->plugin, lport, s->lv2_AudioPort)) {
458  if (is_input) {
459  s->nb_inputs++;
460  } else {
461  s->nb_outputs++;
462  }
463  }
464  }
465 
466  pad.type = AVMEDIA_TYPE_AUDIO;
467 
468  if (s->nb_inputs) {
469  pad.name = av_asprintf("in0:%s:%u", s->plugin_uri, s->nb_inputs);
470  if (!pad.name)
471  return AVERROR(ENOMEM);
472 
474  if ((ret = ff_append_inpad_free_name(ctx, &pad)) < 0)
475  return ret;
476  }
477 
478  return 0;
479 }
480 
482 {
483  LV2Context *s = ctx->priv;
485  AVFilterLink *outlink = ctx->outputs[0];
486  static const enum AVSampleFormat sample_fmts[] = {
489  if (ret < 0)
490  return ret;
491 
492  if (s->nb_inputs) {
494  if (ret < 0)
495  return ret;
496  } else {
497  int sample_rates[] = { s->sample_rate, -1 };
498 
500  if (ret < 0)
501  return ret;
502  }
503 
504  if (s->nb_inputs == 2 && s->nb_outputs == 2) {
505  layouts = NULL;
507  if (ret < 0)
508  return ret;
510  if (ret < 0)
511  return ret;
512  } else {
513  if (s->nb_inputs >= 1) {
514  AVFilterLink *inlink = ctx->inputs[0];
515  AVChannelLayout inlayout = FF_COUNT2LAYOUT(s->nb_inputs);
516 
517  layouts = NULL;
518  ret = ff_add_channel_layout(&layouts, &inlayout);
519  if (ret < 0)
520  return ret;
521  ret = ff_channel_layouts_ref(layouts, &inlink->outcfg.channel_layouts);
522  if (ret < 0)
523  return ret;
524 
525  if (!s->nb_outputs) {
527  if (ret < 0)
528  return ret;
529  }
530  }
531 
532  if (s->nb_outputs >= 1) {
533  AVChannelLayout outlayout = FF_COUNT2LAYOUT(s->nb_outputs);
534 
535  layouts = NULL;
536  ret = ff_add_channel_layout(&layouts, &outlayout);
537  if (ret < 0)
538  return ret;
540  if (ret < 0)
541  return ret;
542  }
543  }
544 
545  return 0;
546 }
547 
548 static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
549  char *res, int res_len, int flags)
550 {
551  LV2Context *s = ctx->priv;
552  const LilvPort *port;
553  LilvNode *sym;
554  int index;
555 
556  sym = lilv_new_string(s->world, cmd);
557  port = lilv_plugin_get_port_by_symbol(s->plugin, sym);
558  lilv_node_free(sym);
559  if (!port) {
560  av_log(s, AV_LOG_WARNING, "Unknown option: <%s>\n", cmd);
561  } else {
562  index = lilv_port_get_index(s->plugin, port);
563  s->controls[index] = atof(args);
564  }
565  return 0;
566 }
567 
569 {
570  LV2Context *s = ctx->priv;
571 
572  lilv_node_free(s->powerOf2BlockLength);
573  lilv_node_free(s->fixedBlockLength);
574  lilv_node_free(s->boundedBlockLength);
575  lilv_node_free(s->urid_map);
576  lilv_node_free(s->atom_Sequence);
577  lilv_node_free(s->atom_AtomPort);
578  lilv_node_free(s->lv2_Optional);
579  lilv_node_free(s->lv2_ControlPort);
580  lilv_node_free(s->lv2_AudioPort);
581  lilv_node_free(s->lv2_OutputPort);
582  lilv_node_free(s->lv2_InputPort);
583  uri_table_destroy(&s->uri_table);
584  lilv_instance_free(s->instance);
585  lilv_world_free(s->world);
586  av_freep(&s->mins);
587  av_freep(&s->maxes);
588  av_freep(&s->controls);
589  av_freep(&s->seq_out);
590 }
591 
592 static const AVFilterPad lv2_outputs[] = {
593  {
594  .name = "default",
595  .type = AVMEDIA_TYPE_AUDIO,
596  .config_props = config_output,
597  .request_frame = request_frame,
598  },
599 };
600 
602  .name = "lv2",
603  .description = NULL_IF_CONFIG_SMALL("Apply LV2 effect."),
604  .priv_size = sizeof(LV2Context),
605  .priv_class = &lv2_class,
606  .init = init,
607  .uninit = uninit,
609  .inputs = 0,
613 };
ff_get_audio_buffer
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
Definition: audio.c:109
FF_ENABLE_DEPRECATION_WARNINGS
#define FF_ENABLE_DEPRECATION_WARNINGS
Definition: internal.h:73
AV_SAMPLE_FMT_FLTP
@ AV_SAMPLE_FMT_FLTP
float, planar
Definition: samplefmt.h:66
AVFilterChannelLayouts
A list of supported channel layouts.
Definition: formats.h:85
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
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
process_command
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
Definition: af_lv2.c:548
LV2Context::lv2_OutputPort
LilvNode * lv2_OutputPort
Definition: af_lv2.c:84
LV2Context::sample_rate
int sample_rate
Definition: af_lv2.c:53
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
LV2Context::options
char * options
Definition: af_lv2.c:47
AVFilterFormatsConfig::channel_layouts
AVFilterChannelLayouts * channel_layouts
Lists of supported channel layouts, only for audio.
Definition: avfilter.h:527
out
FILE * out
Definition: movenc.c:54
AV_CHANNEL_LAYOUT_STEREO
#define AV_CHANNEL_LAYOUT_STEREO
Definition: channel_layout.h:389
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1007
sample_fmts
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:947
ff_channel_layouts_ref
int ff_channel_layouts_ref(AVFilterChannelLayouts *f, AVFilterChannelLayouts **ref)
Add *ref as a new reference to f.
Definition: formats.c:673
layouts
enum MovChannelLayoutTag * layouts
Definition: mov_chan.c:326
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
LV2Context::world
LilvWorld * world
Definition: af_lv2.c:58
ff_set_common_samplerates_from_list
int ff_set_common_samplerates_from_list(AVFilterContext *ctx, const int *samplerates)
Equivalent to ff_set_common_samplerates(ctx, ff_make_format_list(samplerates))
Definition: formats.c:815
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:100
lv2_outputs
static const AVFilterPad lv2_outputs[]
Definition: af_lv2.c:592
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:340
tmp
static uint8_t tmp[11]
Definition: aes_ctr.c:28
OFFSET
#define OFFSET(x)
Definition: af_lv2.c:91
AVOption
AVOption.
Definition: opt.h:251
FILTER_QUERY_FUNC
#define FILTER_QUERY_FUNC(func)
Definition: internal.h:159
table
static const uint16_t table[]
Definition: prosumer.c:205
AV_OPT_TYPE_DURATION
@ AV_OPT_TYPE_DURATION
Definition: opt.h:239
init
static av_cold int init(AVFilterContext *ctx)
Definition: af_lv2.c:396
ff_request_frame
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
Definition: avfilter.c:451
ff_set_common_all_samplerates
int ff_set_common_all_samplerates(AVFilterContext *ctx)
Equivalent to ff_set_common_samplerates(ctx, ff_all_samplerates())
Definition: formats.c:821
connect_ports
static void connect_ports(LV2Context *s, AVFrame *in, AVFrame *out)
Definition: af_lv2.c:168
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:170
lv2_options
static const AVOption lv2_options[]
Definition: af_lv2.c:94
sample_rate
sample_rate
Definition: ffmpeg_filter.c:424
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:30
formats.h
LV2Context::lv2_ControlPort
LilvNode * lv2_ControlPort
Definition: af_lv2.c:81
ff_af_lv2
const AVFilter ff_af_lv2
Definition: af_lv2.c:601
URITable
Definition: af_lv2.c:39
LV2Context::lv2_AudioPort
LilvNode * lv2_AudioPort
Definition: af_lv2.c:79
val
static double val(void *priv, double ch)
Definition: aeval.c:78
LV2Context::fixedBlockLength
LilvNode * fixedBlockLength
Definition: af_lv2.c:87
LV2Context::nb_inputs
unsigned nb_inputs
Definition: af_lv2.c:49
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
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:33
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: af_lv2.c:481
LV2Context::duration
int64_t duration
Definition: af_lv2.c:56
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
av_cold
#define av_cold
Definition: attributes.h:90
duration
int64_t duration
Definition: movenc.c:64
s
#define s(width, name)
Definition: cbs_vp9.c:198
LV2Context::pts
int64_t pts
Definition: af_lv2.c:55
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
LV2Context::nb_outputs
unsigned nb_outputs
Definition: af_lv2.c:51
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
ff_set_common_formats_from_list
int ff_set_common_formats_from_list(AVFilterContext *ctx, const int *fmts)
Equivalent to ff_set_common_formats(ctx, ff_make_format_list(fmts))
Definition: formats.c:873
LV2Context::features
const LV2_Feature * features[5]
Definition: af_lv2.c:69
URITable::n_uris
size_t n_uris
Definition: af_lv2.c:41
ctx
AVFormatContext * ctx
Definition: movenc.c:48
FLAGS
#define FLAGS
Definition: af_lv2.c:92
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: af_lv2.c:568
LV2Context::lv2_Optional
LilvNode * lv2_Optional
Definition: af_lv2.c:82
arg
const char * arg
Definition: jacosubdec.c:67
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
NULL
#define NULL
Definition: coverity.c:32
LV2Context::boundedBlockLength
LilvNode * boundedBlockLength
Definition: af_lv2.c:88
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:736
LV2Context::lv2_InputPort
LilvNode * lv2_InputPort
Definition: af_lv2.c:83
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:131
LV2Context::map
LV2_URID_Map map
Definition: af_lv2.c:63
AVFilterPad::filter_frame
int(* filter_frame)(AVFilterLink *link, AVFrame *frame)
Filtering callback.
Definition: internal.h:88
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
ff_add_channel_layout
int ff_add_channel_layout(AVFilterChannelLayouts **l, const AVChannelLayout *channel_layout)
Definition: formats.c:521
uri_table_init
static void uri_table_init(URITable *table)
Definition: af_lv2.c:110
index
int index
Definition: gxfenc.c:89
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: af_lv2.c:201
uri_table_destroy
static void uri_table_destroy(URITable *table)
Definition: af_lv2.c:116
LV2Context::seq_out
LV2_Atom_Sequence * seq_out
Definition: af_lv2.c:68
LV2Context::nb_inputcontrols
unsigned nb_inputcontrols
Definition: af_lv2.c:50
options
const OptionDef options[]
LV2Context::lv2_CVPort
LilvNode * lv2_CVPort
Definition: af_lv2.c:80
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:106
LV2Context::uri_table
URITable uri_table
Definition: af_lv2.c:62
AVChannelLayout
An AVChannelLayout holds information about the channel layout of audio data.
Definition: channel_layout.h:313
AV_SAMPLE_FMT_NONE
@ AV_SAMPLE_FMT_NONE
Definition: samplefmt.h:56
uri_table_map
static LV2_URID uri_table_map(LV2_URID_Map_Handle handle, const char *uri)
Definition: af_lv2.c:127
av_frame_is_writable
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
Definition: frame.c:666
request_frame
static int request_frame(AVFilterLink *outlink)
Definition: af_lv2.c:229
LV2Context::map_feature
LV2_Feature map_feature
Definition: af_lv2.c:64
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:191
sample_rates
sample_rates
Definition: ffmpeg_filter.c:424
internal.h
URITable::uris
char ** uris
Definition: af_lv2.c:40
AVFrame::nb_samples
int nb_samples
number of audio samples (per channel) described by this frame
Definition: frame.h:420
LV2Context::nb_ports
uint32_t nb_ports
Definition: af_lv2.c:60
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
LV2Context
Definition: af_lv2.c:44
AV_TIME_BASE
#define AV_TIME_BASE
Internal time base represented as integer.
Definition: avutil.h:254
AVFrame::extended_data
uint8_t ** extended_data
pointers to the data planes/channels.
Definition: frame.h:401
AVSampleFormat
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:55
LV2Context::atom_AtomPort
LilvNode * atom_AtomPort
Definition: af_lv2.c:77
len
int len
Definition: vorbis_enc_data.h:426
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:39
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(lv2)
LV2Context::powerOf2BlockLength
LilvNode * powerOf2BlockLength
Definition: af_lv2.c:86
av_rescale
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
Definition: mathematics.c:129
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:262
LV2Context::values
float * values
Definition: af_lv2.c:61
AVFilter
Filter definition.
Definition: avfilter.h:166
ret
ret
Definition: filter_design.txt:187
AVFilterPad::type
enum AVMediaType type
AVFilterPad type.
Definition: internal.h:44
FF_COUNT2LAYOUT
#define FF_COUNT2LAYOUT(c)
Encode a channel count as a channel layout.
Definition: formats.h:102
config_output
static int config_output(AVFilterLink *outlink)
Definition: af_lv2.c:264
buf_size_features
static const LV2_Feature buf_size_features[3]
Definition: af_lv2.c:258
LV2Context::urid_map
LilvNode * urid_map
Definition: af_lv2.c:85
LV2Context::plugin_uri
char * plugin_uri
Definition: af_lv2.c:46
uri_table_unmap
static const char * uri_table_unmap(LV2_URID_Map_Handle handle, LV2_URID urid)
Definition: af_lv2.c:157
channel_layout.h
LV2Context::atom_Sequence
LilvNode * atom_Sequence
Definition: af_lv2.c:78
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
avfilter.h
LV2Context::nb_samples
int nb_samples
Definition: af_lv2.c:54
AVFilterContext
An instance of a filter.
Definition: avfilter.h:409
av_channel_layout_copy
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
Definition: channel_layout.c:669
FF_DISABLE_DEPRECATION_WARNINGS
#define FF_DISABLE_DEPRECATION_WARNINGS
Definition: internal.h:72
audio.h
av_free
#define av_free(p)
Definition: tableprint_vlc.h:33
LV2Context::mins
float * mins
Definition: af_lv2.c:71
LV2Context::controls
float * controls
Definition: af_lv2.c:73
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:183
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:474
LV2Context::instance
LilvInstance * instance
Definition: af_lv2.c:75
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
LV2Context::seq_in
LV2_Atom_Sequence seq_in[2]
Definition: af_lv2.c:67
AVERROR_EXIT
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
Definition: error.h:58
avstring.h
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:229
LV2Context::maxes
float * maxes
Definition: af_lv2.c:72
LV2Context::unmap
LV2_URID_Unmap unmap
Definition: af_lv2.c:65
LV2Context::plugin
const LilvPlugin * plugin
Definition: af_lv2.c:59
ff_set_common_channel_layouts
int ff_set_common_channel_layouts(AVFilterContext *ctx, AVFilterChannelLayouts *channel_layouts)
Helpers for query_formats() which set all free audio links to the same list of channel layouts/sample...
Definition: formats.c:790
LV2Context::unmap_feature
LV2_Feature unmap_feature
Definition: af_lv2.c:66