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