FFmpeg  2.8.15
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
af_ladspa.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Paul B Mahol
3  * Copyright (c) 2011 Mina Nagy Zaki
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  * LADSPA wrapper
25  */
26 
27 #include <dlfcn.h>
28 #include <ladspa.h>
29 #include "libavutil/avstring.h"
31 #include "libavutil/opt.h"
32 #include "audio.h"
33 #include "avfilter.h"
34 #include "internal.h"
35 
36 typedef struct LADSPAContext {
37  const AVClass *class;
38  char *dl_name;
39  char *plugin;
40  char *options;
41  void *dl_handle;
42 
43  unsigned long nb_inputs;
44  unsigned long *ipmap; /* map input number to port number */
45 
46  unsigned long nb_inputcontrols;
47  unsigned long *icmap; /* map input control number to port number */
48  LADSPA_Data *ictlv; /* input controls values */
49 
50  unsigned long nb_outputs;
51  unsigned long *opmap; /* map output number to port number */
52 
53  unsigned long nb_outputcontrols;
54  unsigned long *ocmap; /* map output control number to port number */
55  LADSPA_Data *octlv; /* output controls values */
56 
57  const LADSPA_Descriptor *desc;
60  LADSPA_Handle *handles;
61 
64  int64_t pts;
65  int64_t duration;
67 
68 #define OFFSET(x) offsetof(LADSPAContext, x)
69 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
70 static const AVOption ladspa_options[] = {
71  { "file", "set library name or full path", OFFSET(dl_name), AV_OPT_TYPE_STRING, .flags = FLAGS },
72  { "f", "set library name or full path", OFFSET(dl_name), AV_OPT_TYPE_STRING, .flags = FLAGS },
73  { "plugin", "set plugin name", OFFSET(plugin), AV_OPT_TYPE_STRING, .flags = FLAGS },
74  { "p", "set plugin name", OFFSET(plugin), AV_OPT_TYPE_STRING, .flags = FLAGS },
75  { "controls", "set plugin options", OFFSET(options), AV_OPT_TYPE_STRING, .flags = FLAGS },
76  { "c", "set plugin options", OFFSET(options), AV_OPT_TYPE_STRING, .flags = FLAGS },
77  { "sample_rate", "set sample rate", OFFSET(sample_rate), AV_OPT_TYPE_INT, {.i64=44100}, 1, INT32_MAX, FLAGS },
78  { "s", "set sample rate", OFFSET(sample_rate), AV_OPT_TYPE_INT, {.i64=44100}, 1, INT32_MAX, FLAGS },
79  { "nb_samples", "set the number of samples per requested frame", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.i64=1024}, 1, INT_MAX, FLAGS },
80  { "n", "set the number of samples per requested frame", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.i64=1024}, 1, INT_MAX, FLAGS },
81  { "duration", "set audio duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64=-1}, -1, INT64_MAX, FLAGS },
82  { "d", "set audio duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64=-1}, -1, INT64_MAX, FLAGS },
83  { NULL }
84 };
85 
86 AVFILTER_DEFINE_CLASS(ladspa);
87 
88 static void print_ctl_info(AVFilterContext *ctx, int level,
89  LADSPAContext *s, int ctl, unsigned long *map,
90  LADSPA_Data *values, int print)
91 {
92  const LADSPA_PortRangeHint *h = s->desc->PortRangeHints + map[ctl];
93 
94  av_log(ctx, level, "c%i: %s [", ctl, s->desc->PortNames[map[ctl]]);
95 
96  if (LADSPA_IS_HINT_TOGGLED(h->HintDescriptor)) {
97  av_log(ctx, level, "toggled (1 or 0)");
98 
99  if (LADSPA_IS_HINT_HAS_DEFAULT(h->HintDescriptor))
100  av_log(ctx, level, " (default %i)", (int)values[ctl]);
101  } else {
102  if (LADSPA_IS_HINT_INTEGER(h->HintDescriptor)) {
103  av_log(ctx, level, "<int>");
104 
105  if (LADSPA_IS_HINT_BOUNDED_BELOW(h->HintDescriptor))
106  av_log(ctx, level, ", min: %i", (int)h->LowerBound);
107 
108  if (LADSPA_IS_HINT_BOUNDED_ABOVE(h->HintDescriptor))
109  av_log(ctx, level, ", max: %i", (int)h->UpperBound);
110 
111  if (print)
112  av_log(ctx, level, " (value %d)", (int)values[ctl]);
113  else if (LADSPA_IS_HINT_HAS_DEFAULT(h->HintDescriptor))
114  av_log(ctx, level, " (default %d)", (int)values[ctl]);
115  } else {
116  av_log(ctx, level, "<float>");
117 
118  if (LADSPA_IS_HINT_BOUNDED_BELOW(h->HintDescriptor))
119  av_log(ctx, level, ", min: %f", h->LowerBound);
120 
121  if (LADSPA_IS_HINT_BOUNDED_ABOVE(h->HintDescriptor))
122  av_log(ctx, level, ", max: %f", h->UpperBound);
123 
124  if (print)
125  av_log(ctx, level, " (value %f)", values[ctl]);
126  else if (LADSPA_IS_HINT_HAS_DEFAULT(h->HintDescriptor))
127  av_log(ctx, level, " (default %f)", values[ctl]);
128  }
129 
130  if (LADSPA_IS_HINT_SAMPLE_RATE(h->HintDescriptor))
131  av_log(ctx, level, ", multiple of sample rate");
132 
133  if (LADSPA_IS_HINT_LOGARITHMIC(h->HintDescriptor))
134  av_log(ctx, level, ", logarithmic scale");
135  }
136 
137  av_log(ctx, level, "]\n");
138 }
139 
140 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
141 {
142  AVFilterContext *ctx = inlink->dst;
143  LADSPAContext *s = ctx->priv;
144  AVFrame *out;
145  int i, h, p;
146 
147  if (!s->nb_outputs ||
148  (av_frame_is_writable(in) && s->nb_inputs == s->nb_outputs &&
149  !(s->desc->Properties & LADSPA_PROPERTY_INPLACE_BROKEN))) {
150  out = in;
151  } else {
152  out = ff_get_audio_buffer(ctx->outputs[0], in->nb_samples);
153  if (!out) {
154  av_frame_free(&in);
155  return AVERROR(ENOMEM);
156  }
157  av_frame_copy_props(out, in);
158  }
159 
160  for (h = 0; h < s->nb_handles; h++) {
161  for (i = 0; i < s->nb_inputs; i++) {
162  p = s->nb_handles > 1 ? h : i;
163  s->desc->connect_port(s->handles[h], s->ipmap[i],
164  (LADSPA_Data*)in->extended_data[p]);
165  }
166 
167  for (i = 0; i < s->nb_outputs; i++) {
168  p = s->nb_handles > 1 ? h : i;
169  s->desc->connect_port(s->handles[h], s->opmap[i],
170  (LADSPA_Data*)out->extended_data[p]);
171  }
172 
173  s->desc->run(s->handles[h], in->nb_samples);
174  }
175 
176  for (i = 0; i < s->nb_outputcontrols; i++)
177  print_ctl_info(ctx, AV_LOG_VERBOSE, s, i, s->ocmap, s->octlv, 1);
178 
179  if (out != in)
180  av_frame_free(&in);
181 
182  return ff_filter_frame(ctx->outputs[0], out);
183 }
184 
185 static int request_frame(AVFilterLink *outlink)
186 {
187  AVFilterContext *ctx = outlink->src;
188  LADSPAContext *s = ctx->priv;
189  AVFrame *out;
190  int64_t t;
191  int i;
192 
193  if (ctx->nb_inputs)
194  return ff_request_frame(ctx->inputs[0]);
195 
196  t = av_rescale(s->pts, AV_TIME_BASE, s->sample_rate);
197  if (s->duration >= 0 && t >= s->duration)
198  return AVERROR_EOF;
199 
200  out = ff_get_audio_buffer(outlink, s->nb_samples);
201  if (!out)
202  return AVERROR(ENOMEM);
203 
204  for (i = 0; i < s->nb_outputs; i++)
205  s->desc->connect_port(s->handles[0], s->opmap[i],
206  (LADSPA_Data*)out->extended_data[i]);
207 
208  s->desc->run(s->handles[0], s->nb_samples);
209 
210  for (i = 0; i < s->nb_outputcontrols; i++)
211  print_ctl_info(ctx, AV_LOG_INFO, s, i, s->ocmap, s->octlv, 1);
212 
213  out->sample_rate = s->sample_rate;
214  out->pts = s->pts;
215  s->pts += s->nb_samples;
216 
217  return ff_filter_frame(outlink, out);
218 }
219 
220 static void set_default_ctl_value(LADSPAContext *s, int ctl,
221  unsigned long *map, LADSPA_Data *values)
222 {
223  const LADSPA_PortRangeHint *h = s->desc->PortRangeHints + map[ctl];
224  const LADSPA_Data lower = h->LowerBound;
225  const LADSPA_Data upper = h->UpperBound;
226 
227  if (LADSPA_IS_HINT_DEFAULT_MINIMUM(h->HintDescriptor)) {
228  values[ctl] = lower;
229  } else if (LADSPA_IS_HINT_DEFAULT_MAXIMUM(h->HintDescriptor)) {
230  values[ctl] = upper;
231  } else if (LADSPA_IS_HINT_DEFAULT_0(h->HintDescriptor)) {
232  values[ctl] = 0.0;
233  } else if (LADSPA_IS_HINT_DEFAULT_1(h->HintDescriptor)) {
234  values[ctl] = 1.0;
235  } else if (LADSPA_IS_HINT_DEFAULT_100(h->HintDescriptor)) {
236  values[ctl] = 100.0;
237  } else if (LADSPA_IS_HINT_DEFAULT_440(h->HintDescriptor)) {
238  values[ctl] = 440.0;
239  } else if (LADSPA_IS_HINT_DEFAULT_LOW(h->HintDescriptor)) {
240  if (LADSPA_IS_HINT_LOGARITHMIC(h->HintDescriptor))
241  values[ctl] = exp(log(lower) * 0.75 + log(upper) * 0.25);
242  else
243  values[ctl] = lower * 0.75 + upper * 0.25;
244  } else if (LADSPA_IS_HINT_DEFAULT_MIDDLE(h->HintDescriptor)) {
245  if (LADSPA_IS_HINT_LOGARITHMIC(h->HintDescriptor))
246  values[ctl] = exp(log(lower) * 0.5 + log(upper) * 0.5);
247  else
248  values[ctl] = lower * 0.5 + upper * 0.5;
249  } else if (LADSPA_IS_HINT_DEFAULT_HIGH(h->HintDescriptor)) {
250  if (LADSPA_IS_HINT_LOGARITHMIC(h->HintDescriptor))
251  values[ctl] = exp(log(lower) * 0.25 + log(upper) * 0.75);
252  else
253  values[ctl] = lower * 0.25 + upper * 0.75;
254  }
255 }
256 
258 {
259  LADSPAContext *s = ctx->priv;
260  int i, j;
261 
262  s->nb_handles = s->nb_inputs == 1 && s->nb_outputs == 1 ? link->channels : 1;
263  s->handles = av_calloc(s->nb_handles, sizeof(*s->handles));
264  if (!s->handles)
265  return AVERROR(ENOMEM);
266 
267  for (i = 0; i < s->nb_handles; i++) {
268  s->handles[i] = s->desc->instantiate(s->desc, link->sample_rate);
269  if (!s->handles[i]) {
270  av_log(ctx, AV_LOG_ERROR, "Could not instantiate plugin.\n");
271  return AVERROR_EXTERNAL;
272  }
273 
274  // Connect the input control ports
275  for (j = 0; j < s->nb_inputcontrols; j++)
276  s->desc->connect_port(s->handles[i], s->icmap[j], s->ictlv + j);
277 
278  // Connect the output control ports
279  for (j = 0; j < s->nb_outputcontrols; j++)
280  s->desc->connect_port(s->handles[i], s->ocmap[j], &s->octlv[j]);
281 
282  if (s->desc->activate)
283  s->desc->activate(s->handles[i]);
284  }
285 
286  av_log(ctx, AV_LOG_DEBUG, "handles: %d\n", s->nb_handles);
287 
288  return 0;
289 }
290 
291 static int config_input(AVFilterLink *inlink)
292 {
293  AVFilterContext *ctx = inlink->dst;
294 
295  return connect_ports(ctx, inlink);
296 }
297 
298 static int config_output(AVFilterLink *outlink)
299 {
300  AVFilterContext *ctx = outlink->src;
301  int ret;
302 
303  if (ctx->nb_inputs) {
304  AVFilterLink *inlink = ctx->inputs[0];
305 
306  outlink->format = inlink->format;
307  outlink->sample_rate = inlink->sample_rate;
308 
309  ret = 0;
310  } else {
311  LADSPAContext *s = ctx->priv;
312 
313  outlink->sample_rate = s->sample_rate;
314  outlink->time_base = (AVRational){1, s->sample_rate};
315 
316  ret = connect_ports(ctx, outlink);
317  }
318 
319  return ret;
320 }
321 
322 static void count_ports(const LADSPA_Descriptor *desc,
323  unsigned long *nb_inputs, unsigned long *nb_outputs)
324 {
325  LADSPA_PortDescriptor pd;
326  int i;
327 
328  for (i = 0; i < desc->PortCount; i++) {
329  pd = desc->PortDescriptors[i];
330 
331  if (LADSPA_IS_PORT_AUDIO(pd)) {
332  if (LADSPA_IS_PORT_INPUT(pd)) {
333  (*nb_inputs)++;
334  } else if (LADSPA_IS_PORT_OUTPUT(pd)) {
335  (*nb_outputs)++;
336  }
337  }
338  }
339 }
340 
341 static void *try_load(const char *dir, const char *soname)
342 {
343  char *path = av_asprintf("%s/%s.so", dir, soname);
344  void *ret = NULL;
345 
346  if (path) {
347  ret = dlopen(path, RTLD_LOCAL|RTLD_NOW);
348  av_free(path);
349  }
350 
351  return ret;
352 }
353 
354 static int set_control(AVFilterContext *ctx, unsigned long port, LADSPA_Data value)
355 {
356  LADSPAContext *s = ctx->priv;
357  const char *label = s->desc->Label;
358  LADSPA_PortRangeHint *h = (LADSPA_PortRangeHint *)s->desc->PortRangeHints +
359  s->icmap[port];
360 
361  if (port >= s->nb_inputcontrols) {
362  av_log(ctx, AV_LOG_ERROR, "Control c%ld is out of range [0 - %lu].\n",
363  port, s->nb_inputcontrols);
364  return AVERROR(EINVAL);
365  }
366 
367  if (LADSPA_IS_HINT_BOUNDED_BELOW(h->HintDescriptor) &&
368  value < h->LowerBound) {
369  av_log(ctx, AV_LOG_ERROR,
370  "%s: input control c%ld is below lower boundary of %0.4f.\n",
371  label, port, h->LowerBound);
372  return AVERROR(EINVAL);
373  }
374 
375  if (LADSPA_IS_HINT_BOUNDED_ABOVE(h->HintDescriptor) &&
376  value > h->UpperBound) {
377  av_log(ctx, AV_LOG_ERROR,
378  "%s: input control c%ld is above upper boundary of %0.4f.\n",
379  label, port, h->UpperBound);
380  return AVERROR(EINVAL);
381  }
382 
383  s->ictlv[port] = value;
384 
385  return 0;
386 }
387 
388 static av_cold int init(AVFilterContext *ctx)
389 {
390  LADSPAContext *s = ctx->priv;
391  LADSPA_Descriptor_Function descriptor_fn;
392  const LADSPA_Descriptor *desc;
393  LADSPA_PortDescriptor pd;
394  AVFilterPad pad = { NULL };
395  char *p, *arg, *saveptr = NULL;
396  unsigned long nb_ports;
397  int i;
398 
399  if (!s->dl_name) {
400  av_log(ctx, AV_LOG_ERROR, "No plugin name provided\n");
401  return AVERROR(EINVAL);
402  }
403 
404  if (s->dl_name[0] == '/' || s->dl_name[0] == '.') {
405  // argument is a path
406  s->dl_handle = dlopen(s->dl_name, RTLD_LOCAL|RTLD_NOW);
407  } else {
408  // argument is a shared object name
409  char *paths = av_strdup(getenv("LADSPA_PATH"));
410  const char *separator = ":";
411 
412  if (paths) {
413  p = paths;
414  while ((arg = av_strtok(p, separator, &saveptr)) && !s->dl_handle) {
415  s->dl_handle = try_load(arg, s->dl_name);
416  p = NULL;
417  }
418  }
419 
420  av_free(paths);
421  if (!s->dl_handle && (paths = av_asprintf("%s/.ladspa/lib", getenv("HOME")))) {
422  s->dl_handle = try_load(paths, s->dl_name);
423  av_free(paths);
424  }
425 
426  if (!s->dl_handle)
427  s->dl_handle = try_load("/usr/local/lib/ladspa", s->dl_name);
428 
429  if (!s->dl_handle)
430  s->dl_handle = try_load("/usr/lib/ladspa", s->dl_name);
431  }
432  if (!s->dl_handle) {
433  av_log(ctx, AV_LOG_ERROR, "Failed to load '%s'\n", s->dl_name);
434  return AVERROR(EINVAL);
435  }
436 
437  descriptor_fn = dlsym(s->dl_handle, "ladspa_descriptor");
438  if (!descriptor_fn) {
439  av_log(ctx, AV_LOG_ERROR, "Could not find ladspa_descriptor: %s\n", dlerror());
440  return AVERROR(EINVAL);
441  }
442 
443  // Find the requested plugin, or list plugins
444  if (!s->plugin) {
445  av_log(ctx, AV_LOG_INFO, "The '%s' library contains the following plugins:\n", s->dl_name);
446  av_log(ctx, AV_LOG_INFO, "I = Input Channels\n");
447  av_log(ctx, AV_LOG_INFO, "O = Output Channels\n");
448  av_log(ctx, AV_LOG_INFO, "I:O %-25s %s\n", "Plugin", "Description");
449  av_log(ctx, AV_LOG_INFO, "\n");
450  for (i = 0; desc = descriptor_fn(i); i++) {
451  unsigned long inputs = 0, outputs = 0;
452 
453  count_ports(desc, &inputs, &outputs);
454  av_log(ctx, AV_LOG_INFO, "%lu:%lu %-25s %s\n", inputs, outputs, desc->Label,
455  (char *)av_x_if_null(desc->Name, "?"));
456  av_log(ctx, AV_LOG_VERBOSE, "Maker: %s\n",
457  (char *)av_x_if_null(desc->Maker, "?"));
458  av_log(ctx, AV_LOG_VERBOSE, "Copyright: %s\n",
459  (char *)av_x_if_null(desc->Copyright, "?"));
460  }
461  return AVERROR_EXIT;
462  } else {
463  for (i = 0;; i++) {
464  desc = descriptor_fn(i);
465  if (!desc) {
466  av_log(ctx, AV_LOG_ERROR, "Could not find plugin: %s\n", s->plugin);
467  return AVERROR(EINVAL);
468  }
469 
470  if (desc->Label && !strcmp(desc->Label, s->plugin))
471  break;
472  }
473  }
474 
475  s->desc = desc;
476  nb_ports = desc->PortCount;
477 
478  s->ipmap = av_calloc(nb_ports, sizeof(*s->ipmap));
479  s->opmap = av_calloc(nb_ports, sizeof(*s->opmap));
480  s->icmap = av_calloc(nb_ports, sizeof(*s->icmap));
481  s->ocmap = av_calloc(nb_ports, sizeof(*s->ocmap));
482  s->ictlv = av_calloc(nb_ports, sizeof(*s->ictlv));
483  s->octlv = av_calloc(nb_ports, sizeof(*s->octlv));
484  s->ctl_needs_value = av_calloc(nb_ports, sizeof(*s->ctl_needs_value));
485  if (!s->ipmap || !s->opmap || !s->icmap ||
486  !s->ocmap || !s->ictlv || !s->octlv || !s->ctl_needs_value)
487  return AVERROR(ENOMEM);
488 
489  for (i = 0; i < nb_ports; i++) {
490  pd = desc->PortDescriptors[i];
491 
492  if (LADSPA_IS_PORT_AUDIO(pd)) {
493  if (LADSPA_IS_PORT_INPUT(pd)) {
494  s->ipmap[s->nb_inputs] = i;
495  s->nb_inputs++;
496  } else if (LADSPA_IS_PORT_OUTPUT(pd)) {
497  s->opmap[s->nb_outputs] = i;
498  s->nb_outputs++;
499  }
500  } else if (LADSPA_IS_PORT_CONTROL(pd)) {
501  if (LADSPA_IS_PORT_INPUT(pd)) {
502  s->icmap[s->nb_inputcontrols] = i;
503 
504  if (LADSPA_IS_HINT_HAS_DEFAULT(desc->PortRangeHints[i].HintDescriptor))
506  else
508 
509  s->nb_inputcontrols++;
510  } else if (LADSPA_IS_PORT_OUTPUT(pd)) {
511  s->ocmap[s->nb_outputcontrols] = i;
512  s->nb_outputcontrols++;
513  }
514  }
515  }
516 
517  // List Control Ports if "help" is specified
518  if (s->options && !strcmp(s->options, "help")) {
519  if (!s->nb_inputcontrols) {
520  av_log(ctx, AV_LOG_INFO,
521  "The '%s' plugin does not have any input controls.\n",
522  desc->Label);
523  } else {
524  av_log(ctx, AV_LOG_INFO,
525  "The '%s' plugin has the following input controls:\n",
526  desc->Label);
527  for (i = 0; i < s->nb_inputcontrols; i++)
528  print_ctl_info(ctx, AV_LOG_INFO, s, i, s->icmap, s->ictlv, 0);
529  }
530  return AVERROR_EXIT;
531  }
532 
533  // Parse control parameters
534  p = s->options;
535  while (s->options) {
536  LADSPA_Data val;
537  int ret;
538 
539  if (!(arg = av_strtok(p, "|", &saveptr)))
540  break;
541  p = NULL;
542 
543  if (sscanf(arg, "c%d=%f", &i, &val) != 2) {
544  av_log(ctx, AV_LOG_ERROR, "Invalid syntax.\n");
545  return AVERROR(EINVAL);
546  }
547 
548  if ((ret = set_control(ctx, i, val)) < 0)
549  return ret;
550  s->ctl_needs_value[i] = 0;
551  }
552 
553  // Check if any controls are not set
554  for (i = 0; i < s->nb_inputcontrols; i++) {
555  if (s->ctl_needs_value[i]) {
556  av_log(ctx, AV_LOG_ERROR, "Control c%d must be set.\n", i);
557  print_ctl_info(ctx, AV_LOG_ERROR, s, i, s->icmap, s->ictlv, 0);
558  return AVERROR(EINVAL);
559  }
560  }
561 
562  pad.type = AVMEDIA_TYPE_AUDIO;
563 
564  if (s->nb_inputs) {
565  pad.name = av_asprintf("in0:%s%lu", desc->Label, s->nb_inputs);
566  if (!pad.name)
567  return AVERROR(ENOMEM);
568 
571  if (ff_insert_inpad(ctx, ctx->nb_inputs, &pad) < 0) {
572  av_freep(&pad.name);
573  return AVERROR(ENOMEM);
574  }
575  }
576 
577  av_log(ctx, AV_LOG_DEBUG, "ports: %lu\n", nb_ports);
578  av_log(ctx, AV_LOG_DEBUG, "inputs: %lu outputs: %lu\n",
579  s->nb_inputs, s->nb_outputs);
580  av_log(ctx, AV_LOG_DEBUG, "input controls: %lu output controls: %lu\n",
582 
583  return 0;
584 }
585 
587 {
588  LADSPAContext *s = ctx->priv;
591  static const enum AVSampleFormat sample_fmts[] = {
593 
594  formats = ff_make_format_list(sample_fmts);
595  if (!formats)
596  return AVERROR(ENOMEM);
597  ff_set_common_formats(ctx, formats);
598 
599  if (s->nb_inputs) {
600  formats = ff_all_samplerates();
601  if (!formats)
602  return AVERROR(ENOMEM);
603 
604  ff_set_common_samplerates(ctx, formats);
605  } else {
606  int sample_rates[] = { s->sample_rate, -1 };
607 
609  }
610 
611  if (s->nb_inputs == 1 && s->nb_outputs == 1) {
612  // We will instantiate multiple LADSPA_Handle, one over each channel
613  layouts = ff_all_channel_layouts();
614  if (!layouts)
615  return AVERROR(ENOMEM);
616 
617  ff_set_common_channel_layouts(ctx, layouts);
618  } else {
619  AVFilterLink *outlink = ctx->outputs[0];
620 
621  if (s->nb_inputs >= 1) {
622  AVFilterLink *inlink = ctx->inputs[0];
623  int64_t inlayout = FF_COUNT2LAYOUT(s->nb_inputs);
624 
625  layouts = NULL;
626  ff_add_channel_layout(&layouts, inlayout);
627  ff_channel_layouts_ref(layouts, &inlink->out_channel_layouts);
628 
629  if (!s->nb_outputs)
630  ff_channel_layouts_ref(layouts, &outlink->in_channel_layouts);
631  }
632 
633  if (s->nb_outputs >= 1) {
634  int64_t outlayout = FF_COUNT2LAYOUT(s->nb_outputs);
635 
636  layouts = NULL;
637  ff_add_channel_layout(&layouts, outlayout);
638  ff_channel_layouts_ref(layouts, &outlink->in_channel_layouts);
639  }
640  }
641 
642  return 0;
643 }
644 
645 static av_cold void uninit(AVFilterContext *ctx)
646 {
647  LADSPAContext *s = ctx->priv;
648  int i;
649 
650  for (i = 0; i < s->nb_handles; i++) {
651  if (s->desc->deactivate)
652  s->desc->deactivate(s->handles[i]);
653  if (s->desc->cleanup)
654  s->desc->cleanup(s->handles[i]);
655  }
656 
657  if (s->dl_handle)
658  dlclose(s->dl_handle);
659 
660  av_freep(&s->ipmap);
661  av_freep(&s->opmap);
662  av_freep(&s->icmap);
663  av_freep(&s->ocmap);
664  av_freep(&s->ictlv);
665  av_freep(&s->octlv);
666  av_freep(&s->handles);
668 
669  if (ctx->nb_inputs)
670  av_freep(&ctx->input_pads[0].name);
671 }
672 
673 static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
674  char *res, int res_len, int flags)
675 {
676  LADSPA_Data value;
677  unsigned long port;
678 
679  if (sscanf(cmd, "c%ld", &port) + sscanf(args, "%f", &value) != 2)
680  return AVERROR(EINVAL);
681 
682  return set_control(ctx, port, value);
683 }
684 
685 static const AVFilterPad ladspa_outputs[] = {
686  {
687  .name = "default",
688  .type = AVMEDIA_TYPE_AUDIO,
689  .config_props = config_output,
690  .request_frame = request_frame,
691  },
692  { NULL }
693 };
694 
696  .name = "ladspa",
697  .description = NULL_IF_CONFIG_SMALL("Apply LADSPA effect."),
698  .priv_size = sizeof(LADSPAContext),
699  .priv_class = &ladspa_class,
700  .init = init,
701  .uninit = uninit,
704  .inputs = 0,
705  .outputs = ladspa_outputs,
707 };
static void set_default_ctl_value(LADSPAContext *s, int ctl, unsigned long *map, LADSPA_Data *values)
Definition: af_ladspa.c:220
float, planar
Definition: samplefmt.h:70
#define NULL
Definition: coverity.c:32
int ff_set_common_channel_layouts(AVFilterContext *ctx, AVFilterChannelLayouts *layouts)
A helper for query_formats() which sets all links to the same list of channel layouts/sample rates...
Definition: formats.c:523
const char const char void * val
Definition: avisynth_c.h:634
unsigned long * opmap
Definition: af_ladspa.c:51
const char * s
Definition: avisynth_c.h:631
AVFilter ff_af_ladspa
Definition: af_ladspa.c:695
void * dl_handle
Definition: af_ladspa.c:41
static int request_frame(AVFilterLink *outlink)
Definition: af_ladspa.c:185
This structure describes decoded (raw) audio or video data.
Definition: frame.h:171
AVOption.
Definition: opt.h:255
static int config_output(AVFilterLink *outlink)
Definition: af_ladspa.c:298
#define OFFSET(x)
Definition: af_ladspa.c:68
static const AVFilterPad outputs[]
Definition: af_ashowinfo.c:248
Main libavfilter public API header.
#define FLAGS
Definition: af_ladspa.c:69
int sample_rate
Definition: af_ladspa.c:62
#define AVFILTER_FLAG_DYNAMIC_INPUTS
The number of the filter inputs is not determined just by AVFilter.inputs.
Definition: avfilter.h:431
unsigned long nb_outputs
Definition: af_ladspa.c:50
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
Definition: af_ladspa.c:673
enum AVMediaType type
AVFilterPad type.
Definition: internal.h:74
static enum AVSampleFormat formats[]
char * options
Definition: af_ladspa.c:40
char * dl_name
Definition: af_ladspa.c:38
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:283
LADSPA_Handle * handles
Definition: af_ladspa.c:60
LADSPA_Data * ictlv
Definition: af_ladspa.c:48
const char * name
Pad name.
Definition: internal.h:69
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:641
int ff_channel_layouts_ref(AVFilterChannelLayouts *f, AVFilterChannelLayouts **ref)
Add *ref as a new reference to f.
Definition: formats.c:417
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1158
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: af_ladspa.c:140
#define av_cold
Definition: attributes.h:74
AVOptions.
static void count_ports(const LADSPA_Descriptor *desc, unsigned long *nb_inputs, unsigned long *nb_outputs)
Definition: af_ladspa.c:322
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:257
int64_t duration
Definition: af_ladspa.c:65
#define AVERROR_EOF
End of file.
Definition: error.h:55
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:192
int nb_handles
Definition: af_ladspa.c:59
static int64_t duration
Definition: ffplay.c:326
const OptionDef options[]
Definition: ffserver.c:3810
AVFILTER_DEFINE_CLASS(ladspa)
#define av_log(a,...)
A filter pad used for either input or output.
Definition: internal.h:63
static void * av_x_if_null(const void *p, const void *x)
Return x default pointer in case p is NULL.
Definition: avutil.h:300
AVFilterPad * input_pads
array of input pads
Definition: avfilter.h:640
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
int ff_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats)
A helper for query_formats() which sets all links to the same list of formats.
Definition: formats.c:542
int ff_add_channel_layout(AVFilterChannelLayouts **l, uint64_t channel_layout)
Definition: formats.c:329
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
#define AVERROR(e)
Definition: error.h:43
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:148
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:178
void * priv
private data for use by the filter
Definition: avfilter.h:654
const LADSPA_Descriptor * desc
Definition: af_ladspa.c:57
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:197
int(* filter_frame)(AVFilterLink *link, AVFrame *frame)
Filtering callback.
Definition: internal.h:102
const char * arg
Definition: jacosubdec.c:66
static const int sample_rates[]
Definition: dcaenc.h:32
int * ctl_needs_value
Definition: af_ladspa.c:58
char * av_asprintf(const char *fmt,...)
Definition: avstring.c:113
audio channel layout utility functions
unsigned nb_inputs
number of input pads
Definition: avfilter.h:645
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:134
#define AV_TIME_BASE
Internal time base represented as integer.
Definition: avutil.h:246
static av_cold int init(AVFilterContext *ctx)
Definition: af_ladspa.c:388
GLsizei GLboolean const GLfloat * value
Definition: opengl_enc.c:109
static int set_control(AVFilterContext *ctx, unsigned long port, LADSPA_Data value)
Definition: af_ladspa.c:354
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
Definition: error.h:56
AVFilterChannelLayouts * ff_all_channel_layouts(void)
Construct an empty AVFilterChannelLayouts/AVFilterFormats struct – representing any channel layout (...
Definition: formats.c:385
static av_cold void uninit(AVFilterContext *ctx)
Definition: af_ladspa.c:645
A list of supported channel layouts.
Definition: formats.h:85
static int config_input(AVFilterLink *inlink)
Definition: af_ladspa.c:291
static void * try_load(const char *dir, const char *soname)
Definition: af_ladspa.c:341
static const AVOption ladspa_options[]
Definition: af_ladspa.c:70
sample_rate
#define AV_LOG_INFO
Standard information.
Definition: log.h:187
unsigned long nb_outputcontrols
Definition: af_ladspa.c:53
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:59
unsigned long * ipmap
Definition: af_ladspa.c:44
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
Definition: frame.c:494
char * av_strdup(const char *s)
Duplicate the string s.
Definition: mem.c:267
unsigned long nb_inputs
Definition: af_ladspa.c:43
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
Describe the class of an AVClass context structure.
Definition: log.h:67
int sample_rate
Sample rate of the audio data.
Definition: frame.h:422
Filter definition.
Definition: avfilter.h:470
static const AVFilterPad inputs[]
Definition: af_ashowinfo.c:239
rational number numerator/denominator
Definition: rational.h:43
char * plugin
Definition: af_ladspa.c:39
static int query_formats(AVFilterContext *ctx)
Definition: af_ladspa.c:586
const char * name
Filter name.
Definition: avfilter.h:474
static int connect_ports(AVFilterContext *ctx, AVFilterLink *link)
Definition: af_ladspa.c:257
int nb_samples
Definition: af_ladspa.c:63
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:648
enum MovChannelLayoutTag * layouts
Definition: mov_chan.c:434
unsigned long * ocmap
Definition: af_ladspa.c:54
AVFilterFormats * ff_all_samplerates(void)
Definition: formats.c:379
void * av_calloc(size_t nmemb, size_t size)
Allocate a block of nmemb * size bytes with alignment suitable for all memory accesses (including vec...
Definition: mem.c:260
static int flags
Definition: cpu.c:47
static void print_ctl_info(AVFilterContext *ctx, int level, LADSPAContext *s, int ctl, unsigned long *map, LADSPA_Data *values, int print)
Definition: af_ladspa.c:88
uint8_t level
Definition: svq3.c:150
char * av_strtok(char *s, const char *delim, char **saveptr)
Split the string into several tokens which can be accessed by successive calls to av_strtok()...
Definition: avstring.c:184
if(ret< 0)
Definition: vf_mcdeint.c:280
unsigned long * icmap
Definition: af_ladspa.c:47
int64_t pts
Definition: af_ladspa.c:64
#define av_free(p)
A list of supported formats for one end of a filter link.
Definition: formats.h:64
static const AVFilterPad ladspa_outputs[]
Definition: af_ladspa.c:685
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> out
An instance of a filter.
Definition: avfilter.h:633
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:701
#define av_freep(p)
int(* config_props)(AVFilterLink *link)
Link configuration callback.
Definition: internal.h:138
#define FF_COUNT2LAYOUT(c)
Encode a channel count as a channel layout.
Definition: formats.h:102
LADSPA_Data * octlv
Definition: af_ladspa.c:55
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
Definition: avfilter.c:343
internal API functions
uint8_t ** extended_data
pointers to the data planes/channels.
Definition: frame.h:215
#define AVERROR_EXTERNAL
Generic error in an external library.
Definition: error.h:57
unsigned long nb_inputcontrols
Definition: af_ladspa.c:46
int nb_samples
number of audio samples (per channel) described by this frame
Definition: frame.h:225
int ff_set_common_samplerates(AVFilterContext *ctx, AVFilterFormats *samplerates)
Definition: formats.c:530
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:554
static int ff_insert_inpad(AVFilterContext *f, unsigned index, AVFilterPad *p)
Insert a new input pad for the filter.
Definition: internal.h:271