2 * Copyright (c) 2013 Paul B Mahol
3 * Copyright (c) 2011 Mina Nagy Zaki
5 * This file is part of FFmpeg.
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.
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.
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
29 #include "libavutil/avassert.h"
30 #include "libavutil/avstring.h"
31 #include "libavutil/channel_layout.h"
32 #include "libavutil/opt.h"
37 typedef struct LADSPAContext {
44 unsigned long nb_inputs;
45 unsigned long *ipmap; /* map input number to port number */
47 unsigned long nb_inputcontrols;
48 unsigned long *icmap; /* map input control number to port number */
49 LADSPA_Data *ictlv; /* input controls values */
51 unsigned long nb_outputs;
52 unsigned long *opmap; /* map output number to port number */
54 unsigned long nb_outputcontrols;
55 unsigned long *ocmap; /* map output control number to port number */
56 LADSPA_Data *octlv; /* output controls values */
58 const LADSPA_Descriptor *desc;
61 LADSPA_Handle *handles;
69 #define OFFSET(x) offsetof(LADSPAContext, x)
70 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
71 static const AVOption ladspa_options[] = {
72 { "file", "set library name or full path", OFFSET(dl_name), AV_OPT_TYPE_STRING, .flags = FLAGS },
73 { "f", "set library name or full path", OFFSET(dl_name), AV_OPT_TYPE_STRING, .flags = FLAGS },
74 { "plugin", "set plugin name", OFFSET(plugin), AV_OPT_TYPE_STRING, .flags = FLAGS },
75 { "p", "set plugin name", OFFSET(plugin), AV_OPT_TYPE_STRING, .flags = FLAGS },
76 { "controls", "set plugin options", OFFSET(options), AV_OPT_TYPE_STRING, .flags = FLAGS },
77 { "c", "set plugin options", OFFSET(options), AV_OPT_TYPE_STRING, .flags = FLAGS },
78 { "sample_rate", "set sample rate", OFFSET(sample_rate), AV_OPT_TYPE_INT, {.i64=44100}, 1, INT32_MAX, FLAGS },
79 { "s", "set sample rate", OFFSET(sample_rate), AV_OPT_TYPE_INT, {.i64=44100}, 1, INT32_MAX, FLAGS },
80 { "nb_samples", "set the number of samples per requested frame", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.i64=1024}, 1, INT_MAX, FLAGS },
81 { "n", "set the number of samples per requested frame", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.i64=1024}, 1, INT_MAX, FLAGS },
82 { "duration", "set audio duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64=-1}, -1, INT64_MAX, FLAGS },
83 { "d", "set audio duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64=-1}, -1, INT64_MAX, FLAGS },
87 AVFILTER_DEFINE_CLASS(ladspa);
89 static void print_ctl_info(AVFilterContext *ctx, int level,
90 LADSPAContext *s, int ctl, unsigned long *map,
91 LADSPA_Data *values, int print)
93 const LADSPA_PortRangeHint *h = s->desc->PortRangeHints + map[ctl];
95 av_log(ctx, level, "c%i: %s [", ctl, s->desc->PortNames[map[ctl]]);
97 if (LADSPA_IS_HINT_TOGGLED(h->HintDescriptor)) {
98 av_log(ctx, level, "toggled (1 or 0)");
100 if (LADSPA_IS_HINT_HAS_DEFAULT(h->HintDescriptor))
101 av_log(ctx, level, " (default %i)", (int)values[ctl]);
103 if (LADSPA_IS_HINT_INTEGER(h->HintDescriptor)) {
104 av_log(ctx, level, "<int>");
106 if (LADSPA_IS_HINT_BOUNDED_BELOW(h->HintDescriptor))
107 av_log(ctx, level, ", min: %i", (int)h->LowerBound);
109 if (LADSPA_IS_HINT_BOUNDED_ABOVE(h->HintDescriptor))
110 av_log(ctx, level, ", max: %i", (int)h->UpperBound);
113 av_log(ctx, level, " (value %d)", (int)values[ctl]);
114 else if (LADSPA_IS_HINT_HAS_DEFAULT(h->HintDescriptor))
115 av_log(ctx, level, " (default %d)", (int)values[ctl]);
117 av_log(ctx, level, "<float>");
119 if (LADSPA_IS_HINT_BOUNDED_BELOW(h->HintDescriptor))
120 av_log(ctx, level, ", min: %f", h->LowerBound);
122 if (LADSPA_IS_HINT_BOUNDED_ABOVE(h->HintDescriptor))
123 av_log(ctx, level, ", max: %f", h->UpperBound);
126 av_log(ctx, level, " (value %f)", values[ctl]);
127 else if (LADSPA_IS_HINT_HAS_DEFAULT(h->HintDescriptor))
128 av_log(ctx, level, " (default %f)", values[ctl]);
131 if (LADSPA_IS_HINT_SAMPLE_RATE(h->HintDescriptor))
132 av_log(ctx, level, ", multiple of sample rate");
134 if (LADSPA_IS_HINT_LOGARITHMIC(h->HintDescriptor))
135 av_log(ctx, level, ", logarithmic scale");
138 av_log(ctx, level, "]\n");
141 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
143 AVFilterContext *ctx = inlink->dst;
144 LADSPAContext *s = ctx->priv;
148 av_assert0(in->channels == (s->nb_inputs * s->nb_handles));
150 if (!s->nb_outputs ||
151 (av_frame_is_writable(in) && s->nb_inputs == s->nb_outputs &&
152 !(s->desc->Properties & LADSPA_PROPERTY_INPLACE_BROKEN))) {
155 out = ff_get_audio_buffer(ctx->outputs[0], in->nb_samples);
158 return AVERROR(ENOMEM);
160 av_frame_copy_props(out, in);
163 av_assert0(!s->nb_outputs || out->channels == (s->nb_outputs * s->nb_handles));
165 for (h = 0; h < s->nb_handles; h++) {
166 for (i = 0; i < s->nb_inputs; i++) {
167 p = s->nb_handles > 1 ? h : i;
168 s->desc->connect_port(s->handles[h], s->ipmap[i],
169 (LADSPA_Data*)in->extended_data[p]);
172 for (i = 0; i < s->nb_outputs; i++) {
173 p = s->nb_handles > 1 ? h : i;
174 s->desc->connect_port(s->handles[h], s->opmap[i],
175 (LADSPA_Data*)out->extended_data[p]);
178 s->desc->run(s->handles[h], in->nb_samples);
181 for (i = 0; i < s->nb_outputcontrols; i++)
182 print_ctl_info(ctx, AV_LOG_VERBOSE, s, i, s->ocmap, s->octlv, 1);
187 return ff_filter_frame(ctx->outputs[0], out);
190 static int request_frame(AVFilterLink *outlink)
192 AVFilterContext *ctx = outlink->src;
193 LADSPAContext *s = ctx->priv;
199 return ff_request_frame(ctx->inputs[0]);
201 t = av_rescale(s->pts, AV_TIME_BASE, s->sample_rate);
202 if (s->duration >= 0 && t >= s->duration)
205 out = ff_get_audio_buffer(outlink, s->nb_samples);
207 return AVERROR(ENOMEM);
209 for (i = 0; i < s->nb_outputs; i++)
210 s->desc->connect_port(s->handles[0], s->opmap[i],
211 (LADSPA_Data*)out->extended_data[i]);
213 s->desc->run(s->handles[0], s->nb_samples);
215 for (i = 0; i < s->nb_outputcontrols; i++)
216 print_ctl_info(ctx, AV_LOG_INFO, s, i, s->ocmap, s->octlv, 1);
218 out->sample_rate = s->sample_rate;
220 s->pts += s->nb_samples;
222 return ff_filter_frame(outlink, out);
225 static void set_default_ctl_value(LADSPAContext *s, int ctl,
226 unsigned long *map, LADSPA_Data *values)
228 const LADSPA_PortRangeHint *h = s->desc->PortRangeHints + map[ctl];
229 const LADSPA_Data lower = h->LowerBound;
230 const LADSPA_Data upper = h->UpperBound;
232 if (LADSPA_IS_HINT_DEFAULT_MINIMUM(h->HintDescriptor)) {
234 } else if (LADSPA_IS_HINT_DEFAULT_MAXIMUM(h->HintDescriptor)) {
236 } else if (LADSPA_IS_HINT_DEFAULT_0(h->HintDescriptor)) {
238 } else if (LADSPA_IS_HINT_DEFAULT_1(h->HintDescriptor)) {
240 } else if (LADSPA_IS_HINT_DEFAULT_100(h->HintDescriptor)) {
242 } else if (LADSPA_IS_HINT_DEFAULT_440(h->HintDescriptor)) {
244 } else if (LADSPA_IS_HINT_DEFAULT_LOW(h->HintDescriptor)) {
245 if (LADSPA_IS_HINT_LOGARITHMIC(h->HintDescriptor))
246 values[ctl] = exp(log(lower) * 0.75 + log(upper) * 0.25);
248 values[ctl] = lower * 0.75 + upper * 0.25;
249 } else if (LADSPA_IS_HINT_DEFAULT_MIDDLE(h->HintDescriptor)) {
250 if (LADSPA_IS_HINT_LOGARITHMIC(h->HintDescriptor))
251 values[ctl] = exp(log(lower) * 0.5 + log(upper) * 0.5);
253 values[ctl] = lower * 0.5 + upper * 0.5;
254 } else if (LADSPA_IS_HINT_DEFAULT_HIGH(h->HintDescriptor)) {
255 if (LADSPA_IS_HINT_LOGARITHMIC(h->HintDescriptor))
256 values[ctl] = exp(log(lower) * 0.25 + log(upper) * 0.75);
258 values[ctl] = lower * 0.25 + upper * 0.75;
262 static int connect_ports(AVFilterContext *ctx, AVFilterLink *link)
264 LADSPAContext *s = ctx->priv;
267 s->nb_handles = s->nb_inputs == 1 && s->nb_outputs == 1 ? link->channels : 1;
268 s->handles = av_calloc(s->nb_handles, sizeof(*s->handles));
270 return AVERROR(ENOMEM);
272 for (i = 0; i < s->nb_handles; i++) {
273 s->handles[i] = s->desc->instantiate(s->desc, link->sample_rate);
274 if (!s->handles[i]) {
275 av_log(ctx, AV_LOG_ERROR, "Could not instantiate plugin.\n");
276 return AVERROR_EXTERNAL;
279 // Connect the input control ports
280 for (j = 0; j < s->nb_inputcontrols; j++)
281 s->desc->connect_port(s->handles[i], s->icmap[j], s->ictlv + j);
283 // Connect the output control ports
284 for (j = 0; j < s->nb_outputcontrols; j++)
285 s->desc->connect_port(s->handles[i], s->ocmap[j], &s->octlv[j]);
287 if (s->desc->activate)
288 s->desc->activate(s->handles[i]);
291 av_log(ctx, AV_LOG_DEBUG, "handles: %d\n", s->nb_handles);
296 static int config_input(AVFilterLink *inlink)
298 AVFilterContext *ctx = inlink->dst;
300 return connect_ports(ctx, inlink);
303 static int config_output(AVFilterLink *outlink)
305 AVFilterContext *ctx = outlink->src;
306 LADSPAContext *s = ctx->priv;
309 if (ctx->nb_inputs) {
310 AVFilterLink *inlink = ctx->inputs[0];
312 outlink->format = inlink->format;
313 outlink->sample_rate = inlink->sample_rate;
314 if (s->nb_inputs == s->nb_outputs) {
315 outlink->channel_layout = inlink->channel_layout;
316 outlink->channels = inlink->channels;
321 outlink->sample_rate = s->sample_rate;
322 outlink->time_base = (AVRational){1, s->sample_rate};
324 ret = connect_ports(ctx, outlink);
330 static void count_ports(const LADSPA_Descriptor *desc,
331 unsigned long *nb_inputs, unsigned long *nb_outputs)
333 LADSPA_PortDescriptor pd;
336 for (i = 0; i < desc->PortCount; i++) {
337 pd = desc->PortDescriptors[i];
339 if (LADSPA_IS_PORT_AUDIO(pd)) {
340 if (LADSPA_IS_PORT_INPUT(pd)) {
342 } else if (LADSPA_IS_PORT_OUTPUT(pd)) {
349 static void *try_load(const char *dir, const char *soname)
351 char *path = av_asprintf("%s/%s.so", dir, soname);
355 ret = dlopen(path, RTLD_LOCAL|RTLD_NOW);
362 static int set_control(AVFilterContext *ctx, unsigned long port, LADSPA_Data value)
364 LADSPAContext *s = ctx->priv;
365 const char *label = s->desc->Label;
366 LADSPA_PortRangeHint *h = (LADSPA_PortRangeHint *)s->desc->PortRangeHints +
369 if (port >= s->nb_inputcontrols) {
370 av_log(ctx, AV_LOG_ERROR, "Control c%ld is out of range [0 - %lu].\n",
371 port, s->nb_inputcontrols);
372 return AVERROR(EINVAL);
375 if (LADSPA_IS_HINT_BOUNDED_BELOW(h->HintDescriptor) &&
376 value < h->LowerBound) {
377 av_log(ctx, AV_LOG_ERROR,
378 "%s: input control c%ld is below lower boundary of %0.4f.\n",
379 label, port, h->LowerBound);
380 return AVERROR(EINVAL);
383 if (LADSPA_IS_HINT_BOUNDED_ABOVE(h->HintDescriptor) &&
384 value > h->UpperBound) {
385 av_log(ctx, AV_LOG_ERROR,
386 "%s: input control c%ld is above upper boundary of %0.4f.\n",
387 label, port, h->UpperBound);
388 return AVERROR(EINVAL);
391 s->ictlv[port] = value;
396 static av_cold int init(AVFilterContext *ctx)
398 LADSPAContext *s = ctx->priv;
399 LADSPA_Descriptor_Function descriptor_fn;
400 const LADSPA_Descriptor *desc;
401 LADSPA_PortDescriptor pd;
402 AVFilterPad pad = { NULL };
403 char *p, *arg, *saveptr = NULL;
404 unsigned long nb_ports;
408 av_log(ctx, AV_LOG_ERROR, "No plugin name provided\n");
409 return AVERROR(EINVAL);
412 if (s->dl_name[0] == '/' || s->dl_name[0] == '.') {
413 // argument is a path
414 s->dl_handle = dlopen(s->dl_name, RTLD_LOCAL|RTLD_NOW);
416 // argument is a shared object name
417 char *paths = av_strdup(getenv("LADSPA_PATH"));
418 const char *separator = ":";
422 while ((arg = av_strtok(p, separator, &saveptr)) && !s->dl_handle) {
423 s->dl_handle = try_load(arg, s->dl_name);
429 if (!s->dl_handle && (paths = av_asprintf("%s/.ladspa/lib", getenv("HOME")))) {
430 s->dl_handle = try_load(paths, s->dl_name);
435 s->dl_handle = try_load("/usr/local/lib/ladspa", s->dl_name);
438 s->dl_handle = try_load("/usr/lib/ladspa", s->dl_name);
441 av_log(ctx, AV_LOG_ERROR, "Failed to load '%s'\n", s->dl_name);
442 return AVERROR(EINVAL);
445 descriptor_fn = dlsym(s->dl_handle, "ladspa_descriptor");
446 if (!descriptor_fn) {
447 av_log(ctx, AV_LOG_ERROR, "Could not find ladspa_descriptor: %s\n", dlerror());
448 return AVERROR(EINVAL);
451 // Find the requested plugin, or list plugins
453 av_log(ctx, AV_LOG_INFO, "The '%s' library contains the following plugins:\n", s->dl_name);
454 av_log(ctx, AV_LOG_INFO, "I = Input Channels\n");
455 av_log(ctx, AV_LOG_INFO, "O = Output Channels\n");
456 av_log(ctx, AV_LOG_INFO, "I:O %-25s %s\n", "Plugin", "Description");
457 av_log(ctx, AV_LOG_INFO, "\n");
458 for (i = 0; desc = descriptor_fn(i); i++) {
459 unsigned long inputs = 0, outputs = 0;
461 count_ports(desc, &inputs, &outputs);
462 av_log(ctx, AV_LOG_INFO, "%lu:%lu %-25s %s\n", inputs, outputs, desc->Label,
463 (char *)av_x_if_null(desc->Name, "?"));
464 av_log(ctx, AV_LOG_VERBOSE, "Maker: %s\n",
465 (char *)av_x_if_null(desc->Maker, "?"));
466 av_log(ctx, AV_LOG_VERBOSE, "Copyright: %s\n",
467 (char *)av_x_if_null(desc->Copyright, "?"));
472 desc = descriptor_fn(i);
474 av_log(ctx, AV_LOG_ERROR, "Could not find plugin: %s\n", s->plugin);
475 return AVERROR(EINVAL);
478 if (desc->Label && !strcmp(desc->Label, s->plugin))
484 nb_ports = desc->PortCount;
486 s->ipmap = av_calloc(nb_ports, sizeof(*s->ipmap));
487 s->opmap = av_calloc(nb_ports, sizeof(*s->opmap));
488 s->icmap = av_calloc(nb_ports, sizeof(*s->icmap));
489 s->ocmap = av_calloc(nb_ports, sizeof(*s->ocmap));
490 s->ictlv = av_calloc(nb_ports, sizeof(*s->ictlv));
491 s->octlv = av_calloc(nb_ports, sizeof(*s->octlv));
492 s->ctl_needs_value = av_calloc(nb_ports, sizeof(*s->ctl_needs_value));
493 if (!s->ipmap || !s->opmap || !s->icmap ||
494 !s->ocmap || !s->ictlv || !s->octlv || !s->ctl_needs_value)
495 return AVERROR(ENOMEM);
497 for (i = 0; i < nb_ports; i++) {
498 pd = desc->PortDescriptors[i];
500 if (LADSPA_IS_PORT_AUDIO(pd)) {
501 if (LADSPA_IS_PORT_INPUT(pd)) {
502 s->ipmap[s->nb_inputs] = i;
504 } else if (LADSPA_IS_PORT_OUTPUT(pd)) {
505 s->opmap[s->nb_outputs] = i;
508 } else if (LADSPA_IS_PORT_CONTROL(pd)) {
509 if (LADSPA_IS_PORT_INPUT(pd)) {
510 s->icmap[s->nb_inputcontrols] = i;
512 if (LADSPA_IS_HINT_HAS_DEFAULT(desc->PortRangeHints[i].HintDescriptor))
513 set_default_ctl_value(s, s->nb_inputcontrols, s->icmap, s->ictlv);
515 s->ctl_needs_value[s->nb_inputcontrols] = 1;
517 s->nb_inputcontrols++;
518 } else if (LADSPA_IS_PORT_OUTPUT(pd)) {
519 s->ocmap[s->nb_outputcontrols] = i;
520 s->nb_outputcontrols++;
525 // List Control Ports if "help" is specified
526 if (s->options && !strcmp(s->options, "help")) {
527 if (!s->nb_inputcontrols) {
528 av_log(ctx, AV_LOG_INFO,
529 "The '%s' plugin does not have any input controls.\n",
532 av_log(ctx, AV_LOG_INFO,
533 "The '%s' plugin has the following input controls:\n",
535 for (i = 0; i < s->nb_inputcontrols; i++)
536 print_ctl_info(ctx, AV_LOG_INFO, s, i, s->icmap, s->ictlv, 0);
541 // Parse control parameters
547 if (!(arg = av_strtok(p, " |", &saveptr)))
551 if (sscanf(arg, "c%d=%f", &i, &val) != 2) {
552 if (sscanf(arg, "%f", &val) != 1) {
553 av_log(ctx, AV_LOG_ERROR, "Invalid syntax.\n");
554 return AVERROR(EINVAL);
559 if ((ret = set_control(ctx, i, val)) < 0)
561 s->ctl_needs_value[i] = 0;
564 // Check if any controls are not set
565 for (i = 0; i < s->nb_inputcontrols; i++) {
566 if (s->ctl_needs_value[i]) {
567 av_log(ctx, AV_LOG_ERROR, "Control c%d must be set.\n", i);
568 print_ctl_info(ctx, AV_LOG_ERROR, s, i, s->icmap, s->ictlv, 0);
569 return AVERROR(EINVAL);
573 pad.type = AVMEDIA_TYPE_AUDIO;
576 pad.name = av_asprintf("in0:%s%lu", desc->Label, s->nb_inputs);
578 return AVERROR(ENOMEM);
580 pad.filter_frame = filter_frame;
581 pad.config_props = config_input;
582 if (ff_insert_inpad(ctx, ctx->nb_inputs, &pad) < 0) {
584 return AVERROR(ENOMEM);
588 av_log(ctx, AV_LOG_DEBUG, "ports: %lu\n", nb_ports);
589 av_log(ctx, AV_LOG_DEBUG, "inputs: %lu outputs: %lu\n",
590 s->nb_inputs, s->nb_outputs);
591 av_log(ctx, AV_LOG_DEBUG, "input controls: %lu output controls: %lu\n",
592 s->nb_inputcontrols, s->nb_outputcontrols);
597 static int query_formats(AVFilterContext *ctx)
599 LADSPAContext *s = ctx->priv;
600 AVFilterFormats *formats;
601 AVFilterChannelLayouts *layouts;
602 static const enum AVSampleFormat sample_fmts[] = {
603 AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE };
606 formats = ff_make_format_list(sample_fmts);
608 return AVERROR(ENOMEM);
609 ret = ff_set_common_formats(ctx, formats);
614 formats = ff_all_samplerates();
616 return AVERROR(ENOMEM);
618 ret = ff_set_common_samplerates(ctx, formats);
622 int sample_rates[] = { s->sample_rate, -1 };
624 ret = ff_set_common_samplerates(ctx, ff_make_format_list(sample_rates));
629 if (s->nb_inputs == 1 && s->nb_outputs == 1) {
630 // We will instantiate multiple LADSPA_Handle, one over each channel
631 layouts = ff_all_channel_counts();
633 return AVERROR(ENOMEM);
635 ret = ff_set_common_channel_layouts(ctx, layouts);
638 } else if (s->nb_inputs == 2 && s->nb_outputs == 2) {
640 ret = ff_add_channel_layout(&layouts, AV_CH_LAYOUT_STEREO);
643 ret = ff_set_common_channel_layouts(ctx, layouts);
647 AVFilterLink *outlink = ctx->outputs[0];
649 if (s->nb_inputs >= 1) {
650 AVFilterLink *inlink = ctx->inputs[0];
651 uint64_t inlayout = FF_COUNT2LAYOUT(s->nb_inputs);
654 ret = ff_add_channel_layout(&layouts, inlayout);
657 ret = ff_channel_layouts_ref(layouts, &inlink->out_channel_layouts);
661 if (!s->nb_outputs) {
662 ret = ff_channel_layouts_ref(layouts, &outlink->in_channel_layouts);
668 if (s->nb_outputs >= 1) {
669 uint64_t outlayout = FF_COUNT2LAYOUT(s->nb_outputs);
672 ret = ff_add_channel_layout(&layouts, outlayout);
675 ret = ff_channel_layouts_ref(layouts, &outlink->in_channel_layouts);
684 static av_cold void uninit(AVFilterContext *ctx)
686 LADSPAContext *s = ctx->priv;
689 for (i = 0; i < s->nb_handles; i++) {
690 if (s->desc->deactivate)
691 s->desc->deactivate(s->handles[i]);
692 if (s->desc->cleanup)
693 s->desc->cleanup(s->handles[i]);
697 dlclose(s->dl_handle);
705 av_freep(&s->handles);
706 av_freep(&s->ctl_needs_value);
709 av_freep(&ctx->input_pads[0].name);
712 static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
713 char *res, int res_len, int flags)
718 if (sscanf(cmd, "c%ld", &port) + sscanf(args, "%f", &value) != 2)
719 return AVERROR(EINVAL);
721 return set_control(ctx, port, value);
724 static const AVFilterPad ladspa_outputs[] = {
727 .type = AVMEDIA_TYPE_AUDIO,
728 .config_props = config_output,
729 .request_frame = request_frame,
734 AVFilter ff_af_ladspa = {
736 .description = NULL_IF_CONFIG_SMALL("Apply LADSPA effect."),
737 .priv_size = sizeof(LADSPAContext),
738 .priv_class = &ladspa_class,
741 .query_formats = query_formats,
742 .process_command = process_command,
744 .outputs = ladspa_outputs,
745 .flags = AVFILTER_FLAG_DYNAMIC_INPUTS,