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#include <lv2/lv2plug.in/ns/ext/options/options.h>
31
32#include "libavutil/avstring.h"
34#include "libavutil/mem.h"
35#include "libavutil/opt.h"
36#include "audio.h"
37#include "avfilter.h"
38#include "filters.h"
39#include "formats.h"
40
41typedef struct URITable {
42 char **uris;
43 size_t n_uris;
44} URITable;
45
46typedef struct LV2Context {
47 const AVClass *class;
49 char *options;
50
51 unsigned nb_inputs;
53 unsigned nb_outputs;
54
59
60 LilvWorld *world;
61 const LilvPlugin *plugin;
62 uint32_t nb_ports;
63 float *values;
65 LV2_URID_Map map;
66 LV2_Feature map_feature;
67 LV2_URID_Unmap unmap;
68 LV2_Feature unmap_feature;
70 LV2_Options_Option host_options[2];
71 LV2_Feature options_feature;
72 LV2_Atom_Sequence seq_in[2];
73 LV2_Atom_Sequence *seq_out;
74 const LV2_Feature *features[7];
75
76 float *mins;
77 float *maxes;
78 float *controls;
79
80 LilvInstance *instance;
82
83 LilvNode *atom_AtomPort;
84 LilvNode *atom_Sequence;
85 LilvNode *lv2_AudioPort;
86 LilvNode *lv2_CVPort;
87 LilvNode *lv2_ControlPort;
88 LilvNode *lv2_Optional;
89 LilvNode *lv2_InputPort;
90 LilvNode *lv2_OutputPort;
91 LilvNode *urid_map;
96
97#define OFFSET(x) offsetof(LV2Context, x)
98#define FLAGS AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
99
100static const AVOption lv2_options[] = {
101 { "plugin", "set plugin uri", OFFSET(plugin_uri), AV_OPT_TYPE_STRING, .flags = FLAGS },
102 { "p", "set plugin uri", OFFSET(plugin_uri), AV_OPT_TYPE_STRING, .flags = FLAGS },
103 { "controls", "set plugin options", OFFSET(options), AV_OPT_TYPE_STRING, .flags = FLAGS },
104 { "c", "set plugin options", OFFSET(options), AV_OPT_TYPE_STRING, .flags = FLAGS },
105 { "sample_rate", "set sample rate", OFFSET(sample_rate), AV_OPT_TYPE_INT, {.i64=44100}, 1, INT32_MAX, FLAGS },
106 { "s", "set sample rate", OFFSET(sample_rate), AV_OPT_TYPE_INT, {.i64=44100}, 1, INT32_MAX, FLAGS },
107 { "nb_samples", "set the number of samples per requested frame", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.i64=1024}, 1, INT_MAX, FLAGS },
108 { "n", "set the number of samples per requested frame", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.i64=1024}, 1, INT_MAX, FLAGS },
109 { "duration", "set audio duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64=-1}, -1, INT64_MAX, FLAGS },
110 { "d", "set audio duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64=-1}, -1, INT64_MAX, FLAGS },
111 { NULL }
112};
113
115
117{
118 table->uris = NULL;
119 table->n_uris = 0;
120}
121
123{
124 int i;
125
126 for (i = 0; i < table->n_uris; i++) {
127 av_freep(&table->uris[i]);
128 }
129
130 av_freep(&table->uris);
131}
132
133static LV2_URID uri_table_map(LV2_URID_Map_Handle handle, const char *uri)
134{
135 URITable *table = (URITable*)handle;
136 const size_t len = strlen(uri);
137 size_t i;
138 char **tmp;
139
140 for (i = 0; i < table->n_uris; i++) {
141 if (!strcmp(table->uris[i], uri)) {
142 return i + 1;
143 }
144 }
145
146 tmp = av_calloc(table->n_uris + 1, sizeof(char*));
147 if (!tmp)
148 return table->n_uris;
149 memcpy(tmp, table->uris, table->n_uris * sizeof(char**));
150
151 av_free(table->uris);
152 table->uris = tmp;
153 table->uris[table->n_uris] = av_malloc(len + 1);
154 if (!table->uris[table->n_uris])
155 return table->n_uris;
156
157 memcpy(table->uris[table->n_uris], uri, len + 1);
158 table->n_uris++;
159
160 return table->n_uris;
161}
162
163static const char *uri_table_unmap(LV2_URID_Map_Handle handle, LV2_URID urid)
164{
165 URITable *table = (URITable*)handle;
166
167 if (urid > 0 && urid <= table->n_uris) {
168 return table->uris[urid - 1];
169 }
170
171 return NULL;
172}
173
175{
176 LV2Context *s = ctx->priv;
177 int ich = 0, och = 0, i;
178
179 for (i = 0; i < s->nb_ports; i++) {
180 const LilvPort *port = lilv_plugin_get_port_by_index(s->plugin, i);
181
182 if (lilv_port_is_a(s->plugin, port, s->lv2_AudioPort) ||
183 lilv_port_is_a(s->plugin, port, s->lv2_CVPort)) {
184 if (lilv_port_is_a(s->plugin, port, s->lv2_InputPort)) {
185 lilv_instance_connect_port(s->instance, i, in->extended_data[ich++]);
186 } else if (lilv_port_is_a(s->plugin, port, s->lv2_OutputPort)) {
187 lilv_instance_connect_port(s->instance, i, out->extended_data[och++]);
188 } else {
189 av_log(ctx, AV_LOG_WARNING, "port %d neither input nor output, skipping\n", i);
190 }
191 } else if (lilv_port_is_a(s->plugin, port, s->atom_AtomPort)) {
192 if (lilv_port_is_a(s->plugin, port, s->lv2_InputPort)) {
193 lilv_instance_connect_port(s->instance, i, &s->seq_in);
194 } else {
195 lilv_instance_connect_port(s->instance, i, s->seq_out);
196 }
197 } else if (lilv_port_is_a(s->plugin, port, s->lv2_ControlPort)) {
198 lilv_instance_connect_port(s->instance, i, &s->controls[i]);
199 }
200 }
201
202 s->seq_in[0].atom.size = sizeof(LV2_Atom_Sequence_Body);
203 s->seq_in[0].atom.type = uri_table_map(&s->uri_table, LV2_ATOM__Sequence);
204 s->seq_out->atom.size = 9624;
205 s->seq_out->atom.type = uri_table_map(&s->uri_table, LV2_ATOM__Chunk);
206}
207
208static int filter_frame(AVFilterLink *inlink, AVFrame *in)
209{
210 AVFilterContext *ctx = inlink->dst;
211 LV2Context *s = ctx->priv;
212 AVFrame *out;
213
214 if (!s->nb_outputs ||
215 (av_frame_is_writable(in) && s->nb_inputs == s->nb_outputs)) {
216 out = in;
217 } else {
218 out = ff_get_audio_buffer(ctx->outputs[0], in->nb_samples);
219 if (!out) {
220 av_frame_free(&in);
221 return AVERROR(ENOMEM);
222 }
224 }
225
226 connect_ports(ctx, in, out);
227
228 lilv_instance_run(s->instance, in->nb_samples);
229
230 if (out != in)
231 av_frame_free(&in);
232
233 return ff_filter_frame(ctx->outputs[0], out);
234}
235
236static int request_frame(AVFilterLink *outlink)
237{
238 AVFilterContext *ctx = outlink->src;
239 LV2Context *s = ctx->priv;
240 AVFrame *out;
241 int64_t t;
242
243 if (ctx->nb_inputs)
244 return ff_request_frame(ctx->inputs[0]);
245
246 t = av_rescale(s->pts, AV_TIME_BASE, s->sample_rate);
247 if (s->duration >= 0 && t >= s->duration)
248 return AVERROR_EOF;
249
250 out = ff_get_audio_buffer(outlink, s->nb_samples);
251 if (!out)
252 return AVERROR(ENOMEM);
253
255
256 lilv_instance_run(s->instance, out->nb_samples);
257
258 out->sample_rate = s->sample_rate;
259 out->pts = s->pts;
260 s->pts += s->nb_samples;
261
262 return ff_filter_frame(outlink, out);
263}
264
265static const LV2_Feature buf_size_features[3] = {
266 { LV2_BUF_SIZE__powerOf2BlockLength, NULL },
267 { LV2_BUF_SIZE__fixedBlockLength, NULL },
268 { LV2_BUF_SIZE__boundedBlockLength, NULL },
269};
270
271static int config_output(AVFilterLink *outlink)
272{
273 AVFilterContext *ctx = outlink->src;
274 LV2Context *s = ctx->priv;
275 char *p, *arg, *saveptr = NULL;
276 int i, sample_rate;
277
278 uri_table_init(&s->uri_table);
279 s->map.handle = &s->uri_table;
280 s->map.map = uri_table_map;
281 s->map_feature.URI = LV2_URID_MAP_URI;
282 s->map_feature.data = &s->map;
283 s->unmap.handle = &s->uri_table;
284 s->unmap.unmap = uri_table_unmap;
285 s->unmap_feature.URI = LV2_URID_UNMAP_URI;
286 s->unmap_feature.data = &s->unmap;
287 s->features[0] = &s->map_feature;
288 s->features[1] = &s->unmap_feature;
289 s->features[2] = &buf_size_features[0];
290 s->features[3] = &buf_size_features[1];
291 s->features[4] = &buf_size_features[2];
292 s->features[5] = &s->options_feature;
293 s->features[6] = NULL;
294
295 if (ctx->nb_inputs) {
296 AVFilterLink *inlink = ctx->inputs[0];
297
298 outlink->format = inlink->format;
299 outlink->sample_rate = sample_rate = inlink->sample_rate;
300 if (s->nb_inputs == s->nb_outputs) {
301 int ret;
302 if ((ret = av_channel_layout_copy(&outlink->ch_layout, &inlink->ch_layout)) < 0)
303 return ret;
304 }
305
306 if (lilv_plugin_has_feature(s->plugin, s->powerOf2BlockLength) ||
307 lilv_plugin_has_feature(s->plugin, s->fixedBlockLength) ||
308 lilv_plugin_has_feature(s->plugin, s->boundedBlockLength)) {
309 FilterLink *inl = ff_filter_link(inlink);
310
311 inl->min_samples = inl->max_samples = 4096;
312 s->max_block_length = inl->max_samples;
313 }
314 } else {
315 outlink->sample_rate = sample_rate = s->sample_rate;
316 outlink->time_base = (AVRational){1, s->sample_rate};
317 s->max_block_length = s->nb_samples;
318 }
319
320 int nb_options = 0;
321 if (s->max_block_length) {
322 s->host_options[nb_options++] = (LV2_Options_Option) {
323 LV2_OPTIONS_INSTANCE, 0,
324 uri_table_map(&s->uri_table, LV2_BUF_SIZE__maxBlockLength),
325 sizeof(s->max_block_length),
326 uri_table_map(&s->uri_table, LV2_ATOM__Int),
327 &s->max_block_length
328 };
329 }
330 s->host_options[nb_options] = (LV2_Options_Option) {
331 LV2_OPTIONS_INSTANCE, 0, 0, 0, 0, NULL
332 };
333 s->options_feature.URI = LV2_OPTIONS__options;
334 s->options_feature.data = s->host_options;
335
336 s->instance = lilv_plugin_instantiate(s->plugin, sample_rate, s->features);
337 if (!s->instance) {
338 av_log(ctx, AV_LOG_ERROR, "Failed to instantiate <%s>\n", lilv_node_as_uri(lilv_plugin_get_uri(s->plugin)));
339 return AVERROR(EINVAL);
340 }
341
342 s->mins = av_calloc(s->nb_ports, sizeof(float));
343 s->maxes = av_calloc(s->nb_ports, sizeof(float));
344 s->controls = av_calloc(s->nb_ports, sizeof(float));
345
346 if (!s->mins || !s->maxes || !s->controls)
347 return AVERROR(ENOMEM);
348
349 lilv_plugin_get_port_ranges_float(s->plugin, s->mins, s->maxes, s->controls);
350 s->seq_out = av_malloc(sizeof(LV2_Atom_Sequence) + 9624);
351 if (!s->seq_out)
352 return AVERROR(ENOMEM);
353
354 if (s->options && !strcmp(s->options, "help")) {
355 if (!s->nb_inputcontrols) {
357 "The '%s' plugin does not have any input controls.\n",
358 s->plugin_uri);
359 } else {
361 "The '%s' plugin has the following input controls:\n",
362 s->plugin_uri);
363 for (i = 0; i < s->nb_ports; i++) {
364 const LilvPort *port = lilv_plugin_get_port_by_index(s->plugin, i);
365 const LilvNode *symbol = lilv_port_get_symbol(s->plugin, port);
366 LilvNode *name = lilv_port_get_name(s->plugin, port);
367
368 if (lilv_port_is_a(s->plugin, port, s->lv2_InputPort) &&
369 lilv_port_is_a(s->plugin, port, s->lv2_ControlPort)) {
370 av_log(ctx, AV_LOG_INFO, "%s\t\t<float> (from %f to %f) (default %f)\t\t%s\n",
371 lilv_node_as_string(symbol), s->mins[i], s->maxes[i], s->controls[i],
372 lilv_node_as_string(name));
373 }
374
375 lilv_node_free(name);
376 }
377 }
378 return AVERROR_EXIT;
379 }
380
381 p = s->options;
382 while (s->options) {
383 const LilvPort *port;
384 LilvNode *sym;
385 float val;
386 char *str, *vstr;
387 int index;
388
389 if (!(arg = av_strtok(p, " |", &saveptr)))
390 break;
391 p = NULL;
392
393 vstr = strstr(arg, "=");
394 if (vstr == NULL) {
395 av_log(ctx, AV_LOG_ERROR, "Invalid syntax.\n");
396 return AVERROR(EINVAL);
397 }
398
399 vstr[0] = 0;
400 str = arg;
401 val = atof(vstr+1);
402 sym = lilv_new_string(s->world, str);
403 port = lilv_plugin_get_port_by_symbol(s->plugin, sym);
404 lilv_node_free(sym);
405 if (!port) {
406 av_log(ctx, AV_LOG_WARNING, "Unknown option: <%s>\n", str);
407 } else {
408 index = lilv_port_get_index(s->plugin, port);
409 s->controls[index] = val;
410 }
411 }
412
413 lilv_instance_activate(s->instance);
414 s->instance_activated = 1;
415
416 return 0;
417}
418
420{
421 LV2Context *s = ctx->priv;
422 const LilvPlugins *plugins;
423 const LilvPlugin *plugin;
424 AVFilterPad pad = { NULL };
425 LilvNode *uri;
426 int i, ret;
427
428 s->world = lilv_world_new();
429 if (!s->world)
430 return AVERROR(ENOMEM);
431
432 uri = lilv_new_uri(s->world, s->plugin_uri);
433 if (!uri) {
434 av_log(ctx, AV_LOG_ERROR, "Invalid plugin URI <%s>\n", s->plugin_uri);
435 return AVERROR(EINVAL);
436 }
437
438 lilv_world_load_all(s->world);
439 plugins = lilv_world_get_all_plugins(s->world);
440 plugin = lilv_plugins_get_by_uri(plugins, uri);
441 lilv_node_free(uri);
442
443 if (!plugin) {
444 av_log(ctx, AV_LOG_ERROR, "Plugin <%s> not found\n", s->plugin_uri);
445 return AVERROR(EINVAL);
446 }
447
448 s->plugin = plugin;
449 s->nb_ports = lilv_plugin_get_num_ports(s->plugin);
450
451 s->lv2_InputPort = lilv_new_uri(s->world, LV2_CORE__InputPort);
452 s->lv2_OutputPort = lilv_new_uri(s->world, LV2_CORE__OutputPort);
453 s->lv2_AudioPort = lilv_new_uri(s->world, LV2_CORE__AudioPort);
454 s->lv2_ControlPort = lilv_new_uri(s->world, LV2_CORE__ControlPort);
455 s->lv2_Optional = lilv_new_uri(s->world, LV2_CORE__connectionOptional);
456 s->atom_AtomPort = lilv_new_uri(s->world, LV2_ATOM__AtomPort);
457 s->atom_Sequence = lilv_new_uri(s->world, LV2_ATOM__Sequence);
458 s->urid_map = lilv_new_uri(s->world, LV2_URID__map);
459 s->powerOf2BlockLength = lilv_new_uri(s->world, LV2_BUF_SIZE__powerOf2BlockLength);
460 s->fixedBlockLength = lilv_new_uri(s->world, LV2_BUF_SIZE__fixedBlockLength);
461 s->boundedBlockLength = lilv_new_uri(s->world, LV2_BUF_SIZE__boundedBlockLength);
462
463 for (i = 0; i < s->nb_ports; i++) {
464 const LilvPort *lport = lilv_plugin_get_port_by_index(s->plugin, i);
465 int is_input = 0;
466 int is_optional = 0;
467
468 is_optional = lilv_port_has_property(s->plugin, lport, s->lv2_Optional);
469
470 if (lilv_port_is_a(s->plugin, lport, s->lv2_InputPort)) {
471 is_input = 1;
472 } else if (!lilv_port_is_a(s->plugin, lport, s->lv2_OutputPort) && !is_optional) {
473 return AVERROR(EINVAL);
474 }
475
476 if (lilv_port_is_a(s->plugin, lport, s->lv2_ControlPort)) {
477 if (is_input) {
478 s->nb_inputcontrols++;
479 }
480 } else if (lilv_port_is_a(s->plugin, lport, s->lv2_AudioPort)) {
481 if (is_input) {
482 s->nb_inputs++;
483 } else {
484 s->nb_outputs++;
485 }
486 }
487 }
488
490
491 if (s->nb_inputs) {
492 pad.name = av_asprintf("in0:%s:%u", s->plugin_uri, s->nb_inputs);
493 if (!pad.name)
494 return AVERROR(ENOMEM);
495
497 if ((ret = ff_append_inpad_free_name(ctx, &pad)) < 0)
498 return ret;
499 }
500
501 return 0;
502}
503
505 AVFilterFormatsConfig **cfg_in,
506 AVFilterFormatsConfig **cfg_out)
507{
508 const LV2Context *s = ctx->priv;
510 static const enum AVSampleFormat sample_fmts[] = {
512 int ret = ff_set_sample_formats_from_list2(ctx, cfg_in, cfg_out, sample_fmts);
513 if (ret < 0)
514 return ret;
515
516 if (!s->nb_inputs) {
517 int sample_rates[] = { s->sample_rate, -1 };
518
520 if (ret < 0)
521 return ret;
522 }
523
524 if (s->nb_inputs == 2 && s->nb_outputs == 2) {
525 layouts = NULL;
527 if (ret < 0)
528 return ret;
529 ret = ff_set_common_channel_layouts2(ctx, cfg_in, cfg_out, layouts);
530 if (ret < 0)
531 return ret;
532 } else {
533 if (s->nb_inputs >= 1) {
534 AVChannelLayout inlayout = FF_COUNT2LAYOUT(s->nb_inputs);
535
536 layouts = NULL;
537 ret = ff_add_channel_layout(&layouts, &inlayout);
538 if (ret < 0)
539 return ret;
541 if (ret < 0)
542 return ret;
543
544 if (!s->nb_outputs) {
546 if (ret < 0)
547 return ret;
548 }
549 }
550
551 if (s->nb_outputs >= 1) {
552 AVChannelLayout outlayout = FF_COUNT2LAYOUT(s->nb_outputs);
553
554 layouts = NULL;
555 ret = ff_add_channel_layout(&layouts, &outlayout);
556 if (ret < 0)
557 return ret;
559 if (ret < 0)
560 return ret;
561 }
562 }
563
564 return 0;
565}
566
567static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
568 char *res, int res_len, int flags)
569{
570 LV2Context *s = ctx->priv;
571 const LilvPort *port;
572 LilvNode *sym;
573 int index;
574
575 sym = lilv_new_string(s->world, cmd);
576 port = lilv_plugin_get_port_by_symbol(s->plugin, sym);
577 lilv_node_free(sym);
578 if (!port) {
579 av_log(ctx, AV_LOG_WARNING, "Unknown option: <%s>\n", cmd);
580 } else {
581 index = lilv_port_get_index(s->plugin, port);
582 s->controls[index] = atof(args);
583 }
584 return 0;
585}
586
588{
589 LV2Context *s = ctx->priv;
590
591 if (s->instance_activated)
592 lilv_instance_deactivate(s->instance);
593 lilv_node_free(s->powerOf2BlockLength);
594 lilv_node_free(s->fixedBlockLength);
595 lilv_node_free(s->boundedBlockLength);
596 lilv_node_free(s->urid_map);
597 lilv_node_free(s->atom_Sequence);
598 lilv_node_free(s->atom_AtomPort);
599 lilv_node_free(s->lv2_Optional);
600 lilv_node_free(s->lv2_ControlPort);
601 lilv_node_free(s->lv2_AudioPort);
602 lilv_node_free(s->lv2_OutputPort);
603 lilv_node_free(s->lv2_InputPort);
604 uri_table_destroy(&s->uri_table);
605 lilv_instance_free(s->instance);
606 lilv_world_free(s->world);
607 av_freep(&s->mins);
608 av_freep(&s->maxes);
609 av_freep(&s->controls);
610 av_freep(&s->seq_out);
611}
612
613static const AVFilterPad lv2_outputs[] = {
614 {
615 .name = "default",
616 .type = AVMEDIA_TYPE_AUDIO,
617 .config_props = config_output,
618 .request_frame = request_frame,
619 },
620};
621
623 .p.name = "lv2",
624 .p.description = NULL_IF_CONFIG_SMALL("Apply LV2 effect."),
625 .p.priv_class = &lv2_class,
627 .priv_size = sizeof(LV2Context),
628 .init = init,
629 .uninit = uninit,
633};
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:622
static const AVFilterPad lv2_outputs[]
Definition af_lv2.c:613
static const char * uri_table_unmap(LV2_URID_Map_Handle handle, LV2_URID urid)
Definition af_lv2.c:163
static void uri_table_init(URITable *table)
Definition af_lv2.c:116
static int request_frame(AVFilterLink *outlink)
Definition af_lv2.c:236
static const AVOption lv2_options[]
Definition af_lv2.c:100
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition af_lv2.c:208
static void uri_table_destroy(URITable *table)
Definition af_lv2.c:122
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
Definition af_lv2.c:504
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
Definition af_lv2.c:567
static av_cold void uninit(AVFilterContext *ctx)
Definition af_lv2.c:587
static void connect_ports(AVFilterContext *ctx, AVFrame *in, AVFrame *out)
Definition af_lv2.c:174
#define OFFSET(x)
Definition af_lv2.c:97
static int config_output(AVFilterLink *outlink)
Definition af_lv2.c:271
static LV2_URID uri_table_map(LV2_URID_Map_Handle handle, const char *uri)
Definition af_lv2.c:133
static const LV2_Feature buf_size_features[3]
Definition af_lv2.c:265
static FILE * out
static AVFormatContext * ctx
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
int32_t
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:1076
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
Definition avfilter.c:489
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:596
#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:399
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:1055
int ff_add_channel_layout(AVFilterChannelLayouts **l, const AVChannelLayout *channel_layout)
Definition formats.c:597
int ff_set_common_samplerates_from_list2(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out, const int *samplerates)
Definition formats.c:1088
int ff_channel_layouts_ref(AVFilterChannelLayouts *f, AVFilterChannelLayouts **ref)
Add *ref as a new reference to f.
Definition formats.c:771
int ff_set_sample_formats_from_list2(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out, const enum AVSampleFormat *fmts)
Definition formats.c:1217
#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:161
#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:280
static FilterLink * ff_filter_link(AVFilterLink *link)
Definition filters.h:199
#define AVFILTER_DEFINE_CLASS(fname)
Definition filters.h:493
#define FILTER_QUERY_FUNC2(func)
Definition filters.h:256
#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:97
void * av_calloc(size_t nmemb, size_t size)
Definition mem.c:370
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:279
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:479
int nb_samples
number of audio samples (per channel) described by this frame
Definition frame.h:559
uint8_t ** extended_data
pointers to the data planes/channels.
Definition frame.h:540
AVOption.
Definition opt.h:428
Rational number (pair of numerator and denominator).
Definition rational.h:58
float * mins
Definition af_lv2.c:76
int32_t max_block_length
Definition af_lv2.c:69
LilvNode * lv2_ControlPort
Definition af_lv2.c:87
LV2_URID_Unmap unmap
Definition af_lv2.c:67
LilvNode * lv2_InputPort
Definition af_lv2.c:89
LV2_Atom_Sequence seq_in[2]
Definition af_lv2.c:72
unsigned nb_outputs
Definition af_lv2.c:53
float * maxes
Definition af_lv2.c:77
LilvNode * atom_AtomPort
Definition af_lv2.c:83
int nb_samples
Definition af_lv2.c:56
float * values
Definition af_lv2.c:63
char * options
Definition af_lv2.c:49
int instance_activated
Definition af_lv2.c:81
LilvNode * urid_map
Definition af_lv2.c:91
LV2_Atom_Sequence * seq_out
Definition af_lv2.c:73
uint32_t nb_ports
Definition af_lv2.c:62
float * controls
Definition af_lv2.c:78
const LV2_Feature * features[7]
Definition af_lv2.c:74
LilvNode * boundedBlockLength
Definition af_lv2.c:94
LilvInstance * instance
Definition af_lv2.c:80
URITable uri_table
Definition af_lv2.c:64
LV2_Feature unmap_feature
Definition af_lv2.c:68
int64_t pts
Definition af_lv2.c:57
int64_t duration
Definition af_lv2.c:58
LilvNode * lv2_CVPort
Definition af_lv2.c:86
LilvNode * powerOf2BlockLength
Definition af_lv2.c:92
LilvNode * lv2_AudioPort
Definition af_lv2.c:85
LilvNode * lv2_OutputPort
Definition af_lv2.c:90
LV2_Feature map_feature
Definition af_lv2.c:66
LV2_Options_Option host_options[2]
Definition af_lv2.c:70
LilvNode * fixedBlockLength
Definition af_lv2.c:93
int sample_rate
Definition af_lv2.c:55
LilvNode * lv2_Optional
Definition af_lv2.c:88
LV2_URID_Map map
Definition af_lv2.c:65
LilvNode * atom_Sequence
Definition af_lv2.c:84
unsigned nb_inputs
Definition af_lv2.c:51
LilvWorld * world
Definition af_lv2.c:60
char * plugin_uri
Definition af_lv2.c:48
LV2_Feature options_feature
Definition af_lv2.c:71
unsigned nb_inputcontrols
Definition af_lv2.c:52
const LilvPlugin * plugin
Definition af_lv2.c:61
size_t n_uris
Definition af_lv2.c:43
char ** uris
Definition af_lv2.c:42
#define av_free(p)
#define av_freep(p)
#define av_log(a,...)
static uint8_t tmp[40]
Definition aes_ctr.c:52
int len