FFmpeg
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/avassert.h"
30 #include "libavutil/avstring.h"
32 #include "libavutil/fifo.h"
33 #include "libavutil/opt.h"
34 #include "audio.h"
35 #include "avfilter.h"
36 #include "formats.h"
37 #include "internal.h"
38 
39 typedef struct MetaItem {
40  int64_t pts;
41  int nb_samples;
42 } MetaItem;
43 
44 typedef struct LADSPAContext {
45  const AVClass *class;
46  char *dl_name;
47  char *plugin;
48  char *options;
49  void *dl_handle;
50 
51  unsigned long nb_inputs;
52  unsigned long *ipmap; /* map input number to port number */
53 
54  unsigned long nb_inputcontrols;
55  unsigned long *icmap; /* map input control number to port number */
56  LADSPA_Data *ictlv; /* input controls values */
57 
58  unsigned long nb_outputs;
59  unsigned long *opmap; /* map output number to port number */
60 
61  unsigned long nb_outputcontrols;
62  unsigned long *ocmap; /* map output control number to port number */
63  LADSPA_Data *octlv; /* output controls values */
64 
65  const LADSPA_Descriptor *desc;
68  LADSPA_Handle *handles;
69 
72  int64_t next_in_pts;
73  int64_t next_out_pts;
74  int64_t pts;
75  int64_t duration;
76  int in_trim;
77  int out_pad;
78  int latency;
79 
82 
83 #define OFFSET(x) offsetof(LADSPAContext, x)
84 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
85 static const AVOption ladspa_options[] = {
86  { "file", "set library name or full path", OFFSET(dl_name), AV_OPT_TYPE_STRING, .flags = FLAGS },
87  { "f", "set library name or full path", OFFSET(dl_name), AV_OPT_TYPE_STRING, .flags = FLAGS },
88  { "plugin", "set plugin name", OFFSET(plugin), AV_OPT_TYPE_STRING, .flags = FLAGS },
89  { "p", "set plugin name", OFFSET(plugin), AV_OPT_TYPE_STRING, .flags = FLAGS },
90  { "controls", "set plugin options", OFFSET(options), AV_OPT_TYPE_STRING, .flags = FLAGS },
91  { "c", "set plugin options", OFFSET(options), AV_OPT_TYPE_STRING, .flags = FLAGS },
92  { "sample_rate", "set sample rate", OFFSET(sample_rate), AV_OPT_TYPE_INT, {.i64=44100}, 1, INT32_MAX, FLAGS },
93  { "s", "set sample rate", OFFSET(sample_rate), AV_OPT_TYPE_INT, {.i64=44100}, 1, INT32_MAX, FLAGS },
94  { "nb_samples", "set the number of samples per requested frame", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.i64=1024}, 1, INT_MAX, FLAGS },
95  { "n", "set the number of samples per requested frame", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.i64=1024}, 1, INT_MAX, FLAGS },
96  { "duration", "set audio duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64=-1}, -1, INT64_MAX, FLAGS },
97  { "d", "set audio duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64=-1}, -1, INT64_MAX, FLAGS },
98  { "latency", "enable latency compensation", OFFSET(latency), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS },
99  { "l", "enable latency compensation", OFFSET(latency), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS },
100  { NULL }
101 };
102 
103 AVFILTER_DEFINE_CLASS(ladspa);
104 
106 {
107  int latency = 0;
108 
109  for (int ctl = 0; ctl < s->nb_outputcontrols; ctl++) {
110  if (av_strcasecmp("latency", s->desc->PortNames[s->ocmap[ctl]]))
111  continue;
112 
113  latency = lrintf(s->octlv[ctl]);
114  break;
115  }
116 
117  return latency;
118 }
119 
121  LADSPAContext *s, int ctl, unsigned long *map,
122  LADSPA_Data *values, int print)
123 {
124  const LADSPA_PortRangeHint *h = s->desc->PortRangeHints + map[ctl];
125 
126  av_log(ctx, level, "c%i: %s [", ctl, s->desc->PortNames[map[ctl]]);
127 
128  if (LADSPA_IS_HINT_TOGGLED(h->HintDescriptor)) {
129  av_log(ctx, level, "toggled (1 or 0)");
130 
131  if (LADSPA_IS_HINT_HAS_DEFAULT(h->HintDescriptor))
132  av_log(ctx, level, " (default %i)", (int)values[ctl]);
133  } else {
134  if (LADSPA_IS_HINT_INTEGER(h->HintDescriptor)) {
135  av_log(ctx, level, "<int>");
136 
137  if (LADSPA_IS_HINT_BOUNDED_BELOW(h->HintDescriptor))
138  av_log(ctx, level, ", min: %i", (int)h->LowerBound);
139 
140  if (LADSPA_IS_HINT_BOUNDED_ABOVE(h->HintDescriptor))
141  av_log(ctx, level, ", max: %i", (int)h->UpperBound);
142 
143  if (print)
144  av_log(ctx, level, " (value %d)", (int)values[ctl]);
145  else if (LADSPA_IS_HINT_HAS_DEFAULT(h->HintDescriptor))
146  av_log(ctx, level, " (default %d)", (int)values[ctl]);
147  } else {
148  av_log(ctx, level, "<float>");
149 
150  if (LADSPA_IS_HINT_BOUNDED_BELOW(h->HintDescriptor))
151  av_log(ctx, level, ", min: %f", h->LowerBound);
152 
153  if (LADSPA_IS_HINT_BOUNDED_ABOVE(h->HintDescriptor))
154  av_log(ctx, level, ", max: %f", h->UpperBound);
155 
156  if (print)
157  av_log(ctx, level, " (value %f)", values[ctl]);
158  else if (LADSPA_IS_HINT_HAS_DEFAULT(h->HintDescriptor))
159  av_log(ctx, level, " (default %f)", values[ctl]);
160  }
161 
162  if (LADSPA_IS_HINT_SAMPLE_RATE(h->HintDescriptor))
163  av_log(ctx, level, ", multiple of sample rate");
164 
165  if (LADSPA_IS_HINT_LOGARITHMIC(h->HintDescriptor))
166  av_log(ctx, level, ", logarithmic scale");
167  }
168 
169  av_log(ctx, level, "]\n");
170 }
171 
173 {
174  AVFilterContext *ctx = inlink->dst;
175  LADSPAContext *s = ctx->priv;
176  AVFrame *out;
177  int i, h, p, new_out_samples;
178  int64_t out_duration;
179  int64_t in_duration;
180  int64_t in_pts;
181  MetaItem meta;
182 
183  av_assert0(in->ch_layout.nb_channels == (s->nb_inputs * s->nb_handles));
184 
185  if (!s->nb_outputs ||
186  (av_frame_is_writable(in) && s->nb_inputs == s->nb_outputs &&
187  s->in_trim == 0 && s->out_pad == 0 &&
188  !(s->desc->Properties & LADSPA_PROPERTY_INPLACE_BROKEN))) {
189  out = in;
190  } else {
191  out = ff_get_audio_buffer(ctx->outputs[0], in->nb_samples);
192  if (!out) {
193  av_frame_free(&in);
194  return AVERROR(ENOMEM);
195  }
197  }
198 
199  av_assert0(!s->nb_outputs || out->ch_layout.nb_channels == (s->nb_outputs * s->nb_handles));
200 
201  for (h = 0; h < s->nb_handles; h++) {
202  for (i = 0; i < s->nb_inputs; i++) {
203  p = s->nb_handles > 1 ? h : i;
204  s->desc->connect_port(s->handles[h], s->ipmap[i],
205  (LADSPA_Data*)in->extended_data[p]);
206  }
207 
208  for (i = 0; i < s->nb_outputs; i++) {
209  p = s->nb_handles > 1 ? h : i;
210  s->desc->connect_port(s->handles[h], s->opmap[i],
211  (LADSPA_Data*)out->extended_data[p]);
212  }
213 
214  s->desc->run(s->handles[h], in->nb_samples);
215  if (s->latency)
216  s->in_trim = s->out_pad = find_latency(ctx, s);
217  s->latency = 0;
218  }
219 
220  for (i = 0; i < s->nb_outputcontrols; i++)
221  print_ctl_info(ctx, AV_LOG_VERBOSE, s, i, s->ocmap, s->octlv, 1);
222 
223  meta = (MetaItem){ in->pts, in->nb_samples };
224  av_fifo_write(s->fifo, &meta, 1);
225 
226  if (out != in)
227  av_frame_free(&in);
228 
229  new_out_samples = out->nb_samples;
230  if (s->in_trim > 0) {
231  int trim = FFMIN(new_out_samples, s->in_trim);
232 
233  new_out_samples -= trim;
234  s->in_trim -= trim;
235  }
236 
237  if (new_out_samples <= 0) {
238  av_frame_free(&out);
239  return 0;
240  } else if (new_out_samples < out->nb_samples) {
241  int offset = out->nb_samples - new_out_samples;
242  for (int ch = 0; ch < out->ch_layout.nb_channels; ch++)
243  memmove(out->extended_data[ch], out->extended_data[ch] + sizeof(float) * offset,
244  sizeof(float) * new_out_samples);
245  out->nb_samples = new_out_samples;
246  }
247 
248  av_fifo_read(s->fifo, &meta, 1);
249 
250  out_duration = av_rescale_q(out->nb_samples, inlink->time_base, av_make_q(1, out->sample_rate));
251  in_duration = av_rescale_q(meta.nb_samples, inlink->time_base, av_make_q(1, out->sample_rate));
252  in_pts = meta.pts;
253 
254  if (s->next_out_pts != AV_NOPTS_VALUE && out->pts != s->next_out_pts &&
255  s->next_in_pts != AV_NOPTS_VALUE && in_pts == s->next_in_pts) {
256  out->pts = s->next_out_pts;
257  } else {
258  out->pts = in_pts;
259  }
260  s->next_in_pts = in_pts + in_duration;
261  s->next_out_pts = out->pts + out_duration;
262 
263  return ff_filter_frame(ctx->outputs[0], out);
264 }
265 
266 static int request_frame(AVFilterLink *outlink)
267 {
268  AVFilterContext *ctx = outlink->src;
269  LADSPAContext *s = ctx->priv;
270  AVFrame *out;
271  int64_t t;
272  int i;
273 
274  if (ctx->nb_inputs) {
275  int ret = ff_request_frame(ctx->inputs[0]);
276 
277  if (ret == AVERROR_EOF && s->out_pad > 0) {
278  AVFrame *frame = ff_get_audio_buffer(outlink, FFMIN(2048, s->out_pad));
279  if (!frame)
280  return AVERROR(ENOMEM);
281 
282  s->out_pad -= frame->nb_samples;
283  frame->pts = s->next_in_pts;
284  return filter_frame(ctx->inputs[0], frame);
285  }
286  return ret;
287  }
288 
289  t = av_rescale(s->pts, AV_TIME_BASE, s->sample_rate);
290  if (s->duration >= 0 && t >= s->duration)
291  return AVERROR_EOF;
292 
293  out = ff_get_audio_buffer(outlink, s->nb_samples);
294  if (!out)
295  return AVERROR(ENOMEM);
296 
297  for (i = 0; i < s->nb_outputs; i++)
298  s->desc->connect_port(s->handles[0], s->opmap[i],
299  (LADSPA_Data*)out->extended_data[i]);
300 
301  s->desc->run(s->handles[0], s->nb_samples);
302 
303  for (i = 0; i < s->nb_outputcontrols; i++)
304  print_ctl_info(ctx, AV_LOG_INFO, s, i, s->ocmap, s->octlv, 1);
305 
306  out->sample_rate = s->sample_rate;
307  out->pts = s->pts;
308  s->pts += s->nb_samples;
309 
310  return ff_filter_frame(outlink, out);
311 }
312 
313 static void set_default_ctl_value(LADSPAContext *s, int ctl,
314  unsigned long *map, LADSPA_Data *values)
315 {
316  const LADSPA_PortRangeHint *h = s->desc->PortRangeHints + map[ctl];
317  const LADSPA_Data lower = h->LowerBound;
318  const LADSPA_Data upper = h->UpperBound;
319 
320  if (LADSPA_IS_HINT_DEFAULT_MINIMUM(h->HintDescriptor)) {
321  values[ctl] = lower;
322  } else if (LADSPA_IS_HINT_DEFAULT_MAXIMUM(h->HintDescriptor)) {
323  values[ctl] = upper;
324  } else if (LADSPA_IS_HINT_DEFAULT_0(h->HintDescriptor)) {
325  values[ctl] = 0.0;
326  } else if (LADSPA_IS_HINT_DEFAULT_1(h->HintDescriptor)) {
327  values[ctl] = 1.0;
328  } else if (LADSPA_IS_HINT_DEFAULT_100(h->HintDescriptor)) {
329  values[ctl] = 100.0;
330  } else if (LADSPA_IS_HINT_DEFAULT_440(h->HintDescriptor)) {
331  values[ctl] = 440.0;
332  } else if (LADSPA_IS_HINT_DEFAULT_LOW(h->HintDescriptor)) {
333  if (LADSPA_IS_HINT_LOGARITHMIC(h->HintDescriptor))
334  values[ctl] = exp(log(lower) * 0.75 + log(upper) * 0.25);
335  else
336  values[ctl] = lower * 0.75 + upper * 0.25;
337  } else if (LADSPA_IS_HINT_DEFAULT_MIDDLE(h->HintDescriptor)) {
338  if (LADSPA_IS_HINT_LOGARITHMIC(h->HintDescriptor))
339  values[ctl] = exp(log(lower) * 0.5 + log(upper) * 0.5);
340  else
341  values[ctl] = lower * 0.5 + upper * 0.5;
342  } else if (LADSPA_IS_HINT_DEFAULT_HIGH(h->HintDescriptor)) {
343  if (LADSPA_IS_HINT_LOGARITHMIC(h->HintDescriptor))
344  values[ctl] = exp(log(lower) * 0.25 + log(upper) * 0.75);
345  else
346  values[ctl] = lower * 0.25 + upper * 0.75;
347  }
348 }
349 
351 {
352  LADSPAContext *s = ctx->priv;
353  int i, j;
354 
355  s->nb_handles = s->nb_inputs == 1 && s->nb_outputs == 1 ? link->ch_layout.nb_channels : 1;
356  s->handles = av_calloc(s->nb_handles, sizeof(*s->handles));
357  if (!s->handles)
358  return AVERROR(ENOMEM);
359 
360  for (i = 0; i < s->nb_handles; i++) {
361  s->handles[i] = s->desc->instantiate(s->desc, link->sample_rate);
362  if (!s->handles[i]) {
363  av_log(ctx, AV_LOG_ERROR, "Could not instantiate plugin.\n");
364  return AVERROR_EXTERNAL;
365  }
366 
367  // Connect the input control ports
368  for (j = 0; j < s->nb_inputcontrols; j++)
369  s->desc->connect_port(s->handles[i], s->icmap[j], s->ictlv + j);
370 
371  // Connect the output control ports
372  for (j = 0; j < s->nb_outputcontrols; j++)
373  s->desc->connect_port(s->handles[i], s->ocmap[j], &s->octlv[j]);
374 
375  if (s->desc->activate)
376  s->desc->activate(s->handles[i]);
377  }
378 
379  av_log(ctx, AV_LOG_DEBUG, "handles: %d\n", s->nb_handles);
380 
381  return 0;
382 }
383 
385 {
386  AVFilterContext *ctx = inlink->dst;
387 
388  return connect_ports(ctx, inlink);
389 }
390 
391 static int config_output(AVFilterLink *outlink)
392 {
393  AVFilterContext *ctx = outlink->src;
394  LADSPAContext *s = ctx->priv;
395  int ret;
396 
397  if (ctx->nb_inputs) {
398  AVFilterLink *inlink = ctx->inputs[0];
399 
400  outlink->format = inlink->format;
401  outlink->sample_rate = inlink->sample_rate;
402  if (s->nb_inputs == s->nb_outputs) {
403  if ((ret = av_channel_layout_copy(&outlink->ch_layout, &inlink->ch_layout)) < 0)
404  return ret;
405 #if FF_API_OLD_CHANNEL_LAYOUT
407  outlink->channel_layout = inlink->channel_layout;
409 #endif
410  }
411 
412  ret = 0;
413  } else {
414  outlink->sample_rate = s->sample_rate;
415  outlink->time_base = (AVRational){1, s->sample_rate};
416 
417  ret = connect_ports(ctx, outlink);
418  }
419 
420  return ret;
421 }
422 
423 static void count_ports(const LADSPA_Descriptor *desc,
424  unsigned long *nb_inputs, unsigned long *nb_outputs)
425 {
426  LADSPA_PortDescriptor pd;
427  int i;
428 
429  for (i = 0; i < desc->PortCount; i++) {
430  pd = desc->PortDescriptors[i];
431 
432  if (LADSPA_IS_PORT_AUDIO(pd)) {
433  if (LADSPA_IS_PORT_INPUT(pd)) {
434  (*nb_inputs)++;
435  } else if (LADSPA_IS_PORT_OUTPUT(pd)) {
436  (*nb_outputs)++;
437  }
438  }
439  }
440 }
441 
442 static void *try_load(const char *dir, const char *soname)
443 {
444  char *path = av_asprintf("%s/%s.so", dir, soname);
445  void *ret = NULL;
446 
447  if (path) {
448  ret = dlopen(path, RTLD_LOCAL|RTLD_NOW);
449  av_free(path);
450  }
451 
452  return ret;
453 }
454 
455 static int set_control(AVFilterContext *ctx, unsigned long port, LADSPA_Data value)
456 {
457  LADSPAContext *s = ctx->priv;
458  const char *label = s->desc->Label;
459  LADSPA_PortRangeHint *h = (LADSPA_PortRangeHint *)s->desc->PortRangeHints +
460  s->icmap[port];
461 
462  if (port >= s->nb_inputcontrols) {
463  av_log(ctx, AV_LOG_ERROR, "Control c%ld is out of range [0 - %lu].\n",
464  port, s->nb_inputcontrols);
465  return AVERROR(EINVAL);
466  }
467 
468  if (LADSPA_IS_HINT_BOUNDED_BELOW(h->HintDescriptor) &&
469  value < h->LowerBound) {
471  "%s: input control c%ld is below lower boundary of %0.4f.\n",
472  label, port, h->LowerBound);
473  return AVERROR(EINVAL);
474  }
475 
476  if (LADSPA_IS_HINT_BOUNDED_ABOVE(h->HintDescriptor) &&
477  value > h->UpperBound) {
479  "%s: input control c%ld is above upper boundary of %0.4f.\n",
480  label, port, h->UpperBound);
481  return AVERROR(EINVAL);
482  }
483 
484  s->ictlv[port] = value;
485 
486  return 0;
487 }
488 
490 {
491  LADSPAContext *s = ctx->priv;
492  LADSPA_Descriptor_Function descriptor_fn;
493  const LADSPA_Descriptor *desc;
494  LADSPA_PortDescriptor pd;
495  AVFilterPad pad = { NULL };
496  char *p, *arg, *saveptr = NULL;
497  unsigned long nb_ports;
498  int i, j = 0, ret;
499 
500  if (!s->dl_name) {
501  av_log(ctx, AV_LOG_ERROR, "No plugin name provided\n");
502  return AVERROR(EINVAL);
503  }
504 
505  if (s->dl_name[0] == '/' || s->dl_name[0] == '.') {
506  // argument is a path
507  s->dl_handle = dlopen(s->dl_name, RTLD_LOCAL|RTLD_NOW);
508  } else {
509  // argument is a shared object name
510  char *paths = av_strdup(getenv("LADSPA_PATH"));
511  const char *home_path = getenv("HOME");
512  const char *separator = ":";
513 
514  if (paths) {
515  p = paths;
516  while ((arg = av_strtok(p, separator, &saveptr)) && !s->dl_handle) {
517  s->dl_handle = try_load(arg, s->dl_name);
518  p = NULL;
519  }
520  }
521 
522  av_free(paths);
523  if (!s->dl_handle && home_path && (paths = av_asprintf("%s/.ladspa", home_path))) {
524  s->dl_handle = try_load(paths, s->dl_name);
525  av_free(paths);
526  }
527 
528  if (!s->dl_handle && home_path && (paths = av_asprintf("%s/.ladspa/lib", home_path))) {
529  s->dl_handle = try_load(paths, s->dl_name);
530  av_free(paths);
531  }
532 
533  if (!s->dl_handle)
534  s->dl_handle = try_load("/usr/local/lib/ladspa", s->dl_name);
535 
536  if (!s->dl_handle)
537  s->dl_handle = try_load("/usr/lib/ladspa", s->dl_name);
538  }
539  if (!s->dl_handle) {
540  av_log(ctx, AV_LOG_ERROR, "Failed to load '%s'\n", s->dl_name);
541  return AVERROR(EINVAL);
542  }
543 
544  descriptor_fn = dlsym(s->dl_handle, "ladspa_descriptor");
545  if (!descriptor_fn) {
546  av_log(ctx, AV_LOG_ERROR, "Could not find ladspa_descriptor: %s\n", dlerror());
547  return AVERROR(EINVAL);
548  }
549 
550  // Find the requested plugin, or list plugins
551  if (!s->plugin) {
552  av_log(ctx, AV_LOG_INFO, "The '%s' library contains the following plugins:\n", s->dl_name);
553  av_log(ctx, AV_LOG_INFO, "I = Input Channels\n");
554  av_log(ctx, AV_LOG_INFO, "O = Output Channels\n");
555  av_log(ctx, AV_LOG_INFO, "I:O %-25s %s\n", "Plugin", "Description");
556  av_log(ctx, AV_LOG_INFO, "\n");
557  for (i = 0; desc = descriptor_fn(i); i++) {
558  unsigned long inputs = 0, outputs = 0;
559 
561  av_log(ctx, AV_LOG_INFO, "%lu:%lu %-25s %s\n", inputs, outputs, desc->Label,
562  (char *)av_x_if_null(desc->Name, "?"));
563  av_log(ctx, AV_LOG_VERBOSE, "Maker: %s\n",
564  (char *)av_x_if_null(desc->Maker, "?"));
565  av_log(ctx, AV_LOG_VERBOSE, "Copyright: %s\n",
566  (char *)av_x_if_null(desc->Copyright, "?"));
567  }
568  return AVERROR_EXIT;
569  } else {
570  for (i = 0;; i++) {
571  desc = descriptor_fn(i);
572  if (!desc) {
573  av_log(ctx, AV_LOG_ERROR, "Could not find plugin: %s\n", s->plugin);
574  return AVERROR(EINVAL);
575  }
576 
577  if (desc->Label && !strcmp(desc->Label, s->plugin))
578  break;
579  }
580  }
581 
582  s->desc = desc;
583  nb_ports = desc->PortCount;
584 
585  s->ipmap = av_calloc(nb_ports, sizeof(*s->ipmap));
586  s->opmap = av_calloc(nb_ports, sizeof(*s->opmap));
587  s->icmap = av_calloc(nb_ports, sizeof(*s->icmap));
588  s->ocmap = av_calloc(nb_ports, sizeof(*s->ocmap));
589  s->ictlv = av_calloc(nb_ports, sizeof(*s->ictlv));
590  s->octlv = av_calloc(nb_ports, sizeof(*s->octlv));
591  s->ctl_needs_value = av_calloc(nb_ports, sizeof(*s->ctl_needs_value));
592  if (!s->ipmap || !s->opmap || !s->icmap ||
593  !s->ocmap || !s->ictlv || !s->octlv || !s->ctl_needs_value)
594  return AVERROR(ENOMEM);
595 
596  for (i = 0; i < nb_ports; i++) {
597  pd = desc->PortDescriptors[i];
598 
599  if (LADSPA_IS_PORT_AUDIO(pd)) {
600  if (LADSPA_IS_PORT_INPUT(pd)) {
601  s->ipmap[s->nb_inputs] = i;
602  s->nb_inputs++;
603  } else if (LADSPA_IS_PORT_OUTPUT(pd)) {
604  s->opmap[s->nb_outputs] = i;
605  s->nb_outputs++;
606  }
607  } else if (LADSPA_IS_PORT_CONTROL(pd)) {
608  if (LADSPA_IS_PORT_INPUT(pd)) {
609  s->icmap[s->nb_inputcontrols] = i;
610 
611  if (LADSPA_IS_HINT_HAS_DEFAULT(desc->PortRangeHints[i].HintDescriptor))
612  set_default_ctl_value(s, s->nb_inputcontrols, s->icmap, s->ictlv);
613  else
614  s->ctl_needs_value[s->nb_inputcontrols] = 1;
615 
616  s->nb_inputcontrols++;
617  } else if (LADSPA_IS_PORT_OUTPUT(pd)) {
618  s->ocmap[s->nb_outputcontrols] = i;
619  s->nb_outputcontrols++;
620  }
621  }
622  }
623 
624  // List Control Ports if "help" is specified
625  if (s->options && !strcmp(s->options, "help")) {
626  if (!s->nb_inputcontrols) {
628  "The '%s' plugin does not have any input controls.\n",
629  desc->Label);
630  } else {
632  "The '%s' plugin has the following input controls:\n",
633  desc->Label);
634  for (i = 0; i < s->nb_inputcontrols; i++)
635  print_ctl_info(ctx, AV_LOG_INFO, s, i, s->icmap, s->ictlv, 0);
636  }
637  return AVERROR_EXIT;
638  }
639 
640  // Parse control parameters
641  p = s->options;
642  while (s->options) {
643  LADSPA_Data val;
644  int ret;
645 
646  if (!(arg = av_strtok(p, " |", &saveptr)))
647  break;
648  p = NULL;
649 
650  if (av_sscanf(arg, "c%d=%f", &i, &val) != 2) {
651  if (av_sscanf(arg, "%f", &val) != 1) {
652  av_log(ctx, AV_LOG_ERROR, "Invalid syntax.\n");
653  return AVERROR(EINVAL);
654  }
655  i = j++;
656  }
657 
658  if ((ret = set_control(ctx, i, val)) < 0)
659  return ret;
660  s->ctl_needs_value[i] = 0;
661  }
662 
663  // Check if any controls are not set
664  for (i = 0; i < s->nb_inputcontrols; i++) {
665  if (s->ctl_needs_value[i]) {
666  av_log(ctx, AV_LOG_ERROR, "Control c%d must be set.\n", i);
667  print_ctl_info(ctx, AV_LOG_ERROR, s, i, s->icmap, s->ictlv, 0);
668  return AVERROR(EINVAL);
669  }
670  }
671 
672  pad.type = AVMEDIA_TYPE_AUDIO;
673 
674  if (s->nb_inputs) {
675  pad.name = av_asprintf("in0:%s%lu", desc->Label, s->nb_inputs);
676  if (!pad.name)
677  return AVERROR(ENOMEM);
678 
681  if ((ret = ff_append_inpad_free_name(ctx, &pad)) < 0)
682  return ret;
683  }
684 
685  av_log(ctx, AV_LOG_DEBUG, "ports: %lu\n", nb_ports);
686  av_log(ctx, AV_LOG_DEBUG, "inputs: %lu outputs: %lu\n",
687  s->nb_inputs, s->nb_outputs);
688  av_log(ctx, AV_LOG_DEBUG, "input controls: %lu output controls: %lu\n",
689  s->nb_inputcontrols, s->nb_outputcontrols);
690 
691  s->next_out_pts = AV_NOPTS_VALUE;
692  s->next_in_pts = AV_NOPTS_VALUE;
693 
694  s->fifo = av_fifo_alloc2(8, sizeof(MetaItem), AV_FIFO_FLAG_AUTO_GROW);
695  if (!s->fifo)
696  return AVERROR(ENOMEM);
697 
698  return 0;
699 }
700 
702 {
703  LADSPAContext *s = ctx->priv;
705  static const enum AVSampleFormat sample_fmts[] = {
708  if (ret < 0)
709  return ret;
710 
711  if (s->nb_inputs) {
713  if (ret < 0)
714  return ret;
715  } else {
716  int sample_rates[] = { s->sample_rate, -1 };
717 
719  if (ret < 0)
720  return ret;
721  }
722 
723  if (s->nb_inputs == 1 && s->nb_outputs == 1) {
724  // We will instantiate multiple LADSPA_Handle, one over each channel
726  if (ret < 0)
727  return ret;
728  } else if (s->nb_inputs == 2 && s->nb_outputs == 2) {
729  layouts = NULL;
731  if (ret < 0)
732  return ret;
734  if (ret < 0)
735  return ret;
736  } else {
737  AVFilterLink *outlink = ctx->outputs[0];
738 
739  if (s->nb_inputs >= 1) {
740  AVFilterLink *inlink = ctx->inputs[0];
741  AVChannelLayout inlayout = FF_COUNT2LAYOUT(s->nb_inputs);
742 
743  layouts = NULL;
744  ret = ff_add_channel_layout(&layouts, &inlayout);
745  if (ret < 0)
746  return ret;
747  ret = ff_channel_layouts_ref(layouts, &inlink->outcfg.channel_layouts);
748  if (ret < 0)
749  return ret;
750 
751  if (!s->nb_outputs) {
753  if (ret < 0)
754  return ret;
755  }
756  }
757 
758  if (s->nb_outputs >= 1) {
759  AVChannelLayout outlayout = FF_COUNT2LAYOUT(s->nb_outputs);
760 
761  layouts = NULL;
762  ret = ff_add_channel_layout(&layouts, &outlayout);
763  if (ret < 0)
764  return ret;
766  if (ret < 0)
767  return ret;
768  }
769  }
770 
771  return 0;
772 }
773 
775 {
776  LADSPAContext *s = ctx->priv;
777  int i;
778 
779  for (i = 0; i < s->nb_handles; i++) {
780  if (s->desc->deactivate)
781  s->desc->deactivate(s->handles[i]);
782  if (s->desc->cleanup)
783  s->desc->cleanup(s->handles[i]);
784  }
785 
786  if (s->dl_handle)
787  dlclose(s->dl_handle);
788 
789  av_freep(&s->ipmap);
790  av_freep(&s->opmap);
791  av_freep(&s->icmap);
792  av_freep(&s->ocmap);
793  av_freep(&s->ictlv);
794  av_freep(&s->octlv);
795  av_freep(&s->handles);
796  av_freep(&s->ctl_needs_value);
797 
798  av_fifo_freep2(&s->fifo);
799 }
800 
801 static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
802  char *res, int res_len, int flags)
803 {
804  LADSPA_Data value;
805  unsigned long port;
806 
807  if (av_sscanf(cmd, "c%ld", &port) + av_sscanf(args, "%f", &value) != 2)
808  return AVERROR(EINVAL);
809 
810  return set_control(ctx, port, value);
811 }
812 
813 static const AVFilterPad ladspa_outputs[] = {
814  {
815  .name = "default",
816  .type = AVMEDIA_TYPE_AUDIO,
817  .config_props = config_output,
818  .request_frame = request_frame,
819  },
820 };
821 
823  .name = "ladspa",
824  .description = NULL_IF_CONFIG_SMALL("Apply LADSPA effect."),
825  .priv_size = sizeof(LADSPAContext),
826  .priv_class = &ladspa_class,
827  .init = init,
828  .uninit = uninit,
830  .inputs = 0,
834 };
LADSPAContext::nb_inputs
unsigned long nb_inputs
Definition: af_ladspa.c:51
try_load
static void * try_load(const char *dir, const char *soname)
Definition: af_ladspa.c:442
ff_get_audio_buffer
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
Definition: audio.c:109
FF_ENABLE_DEPRECATION_WARNINGS
#define FF_ENABLE_DEPRECATION_WARNINGS
Definition: internal.h:73
AV_SAMPLE_FMT_FLTP
@ AV_SAMPLE_FMT_FLTP
float, planar
Definition: samplefmt.h:66
AVFilterChannelLayouts
A list of supported channel layouts.
Definition: formats.h:85
level
uint8_t level
Definition: svq3.c:204
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
opt.h
AVFilterFormatsConfig::channel_layouts
AVFilterChannelLayouts * channel_layouts
Lists of supported channel layouts, only for audio.
Definition: avfilter.h:527
out
FILE * out
Definition: movenc.c:54
AV_CHANNEL_LAYOUT_STEREO
#define AV_CHANNEL_LAYOUT_STEREO
Definition: channel_layout.h:389
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1007
sample_fmts
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:947
ff_channel_layouts_ref
int ff_channel_layouts_ref(AVFilterChannelLayouts *f, AVFilterChannelLayouts **ref)
Add *ref as a new reference to f.
Definition: formats.c:673
layouts
enum MovChannelLayoutTag * layouts
Definition: mov_chan.c:326
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
ff_set_common_samplerates_from_list
int ff_set_common_samplerates_from_list(AVFilterContext *ctx, const int *samplerates)
Equivalent to ff_set_common_samplerates(ctx, ff_make_format_list(samplerates))
Definition: formats.c:815
inlink
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
Definition: filter_design.txt:212
av_asprintf
char * av_asprintf(const char *fmt,...)
Definition: avstring.c:115
av_strcasecmp
int av_strcasecmp(const char *a, const char *b)
Locale-independent case-insensitive compare.
Definition: avstring.c:207
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(ladspa)
normalize.log
log
Definition: normalize.py:21
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:100
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:340
AVFrame::pts
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:452
AVOption
AVOption.
Definition: opt.h:294
FILTER_QUERY_FUNC
#define FILTER_QUERY_FUNC(func)
Definition: internal.h:159
AV_OPT_TYPE_DURATION
@ AV_OPT_TYPE_DURATION
Definition: opt.h:239
ff_request_frame
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
Definition: avfilter.c:451
LADSPAContext::handles
LADSPA_Handle * handles
Definition: af_ladspa.c:68
LADSPAContext::ctl_needs_value
int * ctl_needs_value
Definition: af_ladspa.c:66
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:196
ff_set_common_all_samplerates
int ff_set_common_all_samplerates(AVFilterContext *ctx)
Equivalent to ff_set_common_samplerates(ctx, ff_all_samplerates())
Definition: formats.c:821
LADSPAContext
Definition: af_ladspa.c:44
config_output
static int config_output(AVFilterLink *outlink)
Definition: af_ladspa.c:391
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:170
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: af_ladspa.c:774
AVChannelLayout::nb_channels
int nb_channels
Number of channels in this layout.
Definition: channel_layout.h:323
sample_rate
sample_rate
Definition: ffmpeg_filter.c:424
LADSPAContext::options
char * options
Definition: af_ladspa.c:48
LADSPAContext::icmap
unsigned long * icmap
Definition: af_ladspa.c:55
process_command
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
Definition: af_ladspa.c:801
formats.h
LADSPAContext::nb_outputs
unsigned long nb_outputs
Definition: af_ladspa.c:58
connect_ports
static int connect_ports(AVFilterContext *ctx, AVFilterLink *link)
Definition: af_ladspa.c:350
LADSPAContext::next_in_pts
int64_t next_in_pts
Definition: af_ladspa.c:72
fifo.h
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: af_ladspa.c:172
av_fifo_write
int av_fifo_write(AVFifo *f, const void *buf, size_t nb_elems)
Write data into a FIFO.
Definition: fifo.c:188
LADSPAContext::nb_handles
int nb_handles
Definition: af_ladspa.c:67
LADSPAContext::desc
const LADSPA_Descriptor * desc
Definition: af_ladspa.c:65
val
static double val(void *priv, double ch)
Definition: aeval.c:78
request_frame
static int request_frame(AVFilterLink *outlink)
Definition: af_ladspa.c:266
AVFrame::ch_layout
AVChannelLayout ch_layout
Channel layout of the audio data.
Definition: frame.h:802
AVFILTER_FLAG_DYNAMIC_INPUTS
#define AVFILTER_FLAG_DYNAMIC_INPUTS
The number of the filter inputs is not determined just by AVFilter.inputs.
Definition: avfilter.h:106
LADSPAContext::plugin
char * plugin
Definition: af_ladspa.c:47
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:33
LADSPAContext::out_pad
int out_pad
Definition: af_ladspa.c:77
avassert.h
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
av_cold
#define av_cold
Definition: attributes.h:90
av_fifo_read
int av_fifo_read(AVFifo *f, void *buf, size_t nb_elems)
Read data from a FIFO.
Definition: fifo.c:240
duration
int64_t duration
Definition: movenc.c:64
s
#define s(width, name)
Definition: cbs_vp9.c:198
LADSPAContext::sample_rate
int sample_rate
Definition: af_ladspa.c:70
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
av_strtok
char * av_strtok(char *s, const char *delim, char **saveptr)
Split the string into several tokens which can be accessed by successive calls to av_strtok().
Definition: avstring.c:178
ff_set_common_formats_from_list
int ff_set_common_formats_from_list(AVFilterContext *ctx, const int *fmts)
Equivalent to ff_set_common_formats(ctx, ff_make_format_list(fmts))
Definition: formats.c:873
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:40
LADSPAContext::dl_handle
void * dl_handle
Definition: af_ladspa.c:49
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
ctx
AVFormatContext * ctx
Definition: movenc.c:48
av_rescale_q
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Definition: mathematics.c:142
LADSPAContext::ipmap
unsigned long * ipmap
Definition: af_ladspa.c:52
LADSPAContext::next_out_pts
int64_t next_out_pts
Definition: af_ladspa.c:73
link
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a link
Definition: filter_design.txt:23
frame
static AVFrame * frame
Definition: demux_decode.c:54
arg
const char * arg
Definition: jacosubdec.c:67
if
if(ret)
Definition: filter_design.txt:179
av_sscanf
int av_sscanf(const char *string, const char *format,...)
See libc sscanf manual for more information.
Definition: avsscanf.c:962
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
LADSPAContext::ictlv
LADSPA_Data * ictlv
Definition: af_ladspa.c:56
NULL
#define NULL
Definition: coverity.c:32
av_frame_copy_props
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:736
LADSPAContext::in_trim
int in_trim
Definition: af_ladspa.c:76
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
ff_append_inpad_free_name
int ff_append_inpad_free_name(AVFilterContext *f, AVFilterPad *p)
Definition: avfilter.c:131
OFFSET
#define OFFSET(x)
Definition: af_ladspa.c:83
count_ports
static void count_ports(const LADSPA_Descriptor *desc, unsigned long *nb_inputs, unsigned long *nb_outputs)
Definition: af_ladspa.c:423
AVFilterPad::filter_frame
int(* filter_frame)(AVFilterLink *link, AVFrame *frame)
Filtering callback.
Definition: internal.h:88
MetaItem::pts
int64_t pts
Definition: af_alimiter.c:37
inputs
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
Definition: filter_design.txt:243
config_input
static int config_input(AVFilterLink *inlink)
Definition: af_ladspa.c:384
ff_set_common_all_channel_counts
int ff_set_common_all_channel_counts(AVFilterContext *ctx)
Equivalent to ff_set_common_channel_layouts(ctx, ff_all_channel_counts())
Definition: formats.c:803
ff_add_channel_layout
int ff_add_channel_layout(AVFilterChannelLayouts **l, const AVChannelLayout *channel_layout)
Definition: formats.c:521
exp
int8_t exp
Definition: eval.c:74
LADSPAContext::ocmap
unsigned long * ocmap
Definition: af_ladspa.c:62
print_ctl_info
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:120
AVFilterPad::config_props
int(* config_props)(AVFilterLink *link)
Link configuration callback.
Definition: internal.h:113
options
const OptionDef options[]
AVFifo
Definition: fifo.c:35
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:106
AVChannelLayout
An AVChannelLayout holds information about the channel layout of audio data.
Definition: channel_layout.h:313
LADSPAContext::nb_inputcontrols
unsigned long nb_inputcontrols
Definition: af_ladspa.c:54
set_control
static int set_control(AVFilterContext *ctx, unsigned long port, LADSPA_Data value)
Definition: af_ladspa.c:455
AVFrame::sample_rate
int sample_rate
Sample rate of the audio data.
Definition: frame.h:567
print
static void print(AVTreeNode *t, int depth)
Definition: tree.c:44
LADSPAContext::dl_name
char * dl_name
Definition: af_ladspa.c:46
AV_SAMPLE_FMT_NONE
@ AV_SAMPLE_FMT_NONE
Definition: samplefmt.h:56
av_make_q
static AVRational av_make_q(int num, int den)
Create an AVRational.
Definition: rational.h:71
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
av_frame_is_writable
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
Definition: frame.c:666
AVERROR_EXTERNAL
#define AVERROR_EXTERNAL
Generic error in an external library.
Definition: error.h:59
offset
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
Definition: writing_filters.txt:86
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:191
sample_rates
sample_rates
Definition: ffmpeg_filter.c:424
internal.h
AVFrame::nb_samples
int nb_samples
number of audio samples (per channel) described by this frame
Definition: frame.h:420
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: af_ladspa.c:701
lrintf
#define lrintf(x)
Definition: libm_mips.h:72
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
LADSPAContext::latency
int latency
Definition: af_ladspa.c:78
AV_TIME_BASE
#define AV_TIME_BASE
Internal time base represented as integer.
Definition: avutil.h:254
AVFrame::extended_data
uint8_t ** extended_data
pointers to the data planes/channels.
Definition: frame.h:401
AVSampleFormat
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:55
value
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
Definition: writing_filters.txt:86
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:39
av_rescale
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
Definition: mathematics.c:129
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:262
outputs
static const AVFilterPad outputs[]
Definition: af_aap.c:310
AVFilter
Filter definition.
Definition: avfilter.h:166
ret
ret
Definition: filter_design.txt:187
AVFilterPad::type
enum AVMediaType type
AVFilterPad type.
Definition: internal.h:44
FF_COUNT2LAYOUT
#define FF_COUNT2LAYOUT(c)
Encode a channel count as a channel layout.
Definition: formats.h:102
ff_af_ladspa
const AVFilter ff_af_ladspa
Definition: af_ladspa.c:822
av_fifo_alloc2
AVFifo * av_fifo_alloc2(size_t nb_elems, size_t elem_size, unsigned int flags)
Allocate and initialize an AVFifo with a given element size.
Definition: fifo.c:47
LADSPAContext::duration
int64_t duration
Definition: af_ladspa.c:75
channel_layout.h
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
avfilter.h
values
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return values
Definition: filter_design.txt:263
MetaItem
Definition: af_alimiter.c:36
AVFilterContext
An instance of a filter.
Definition: avfilter.h:409
MetaItem::nb_samples
int nb_samples
Definition: af_alimiter.c:38
av_channel_layout_copy
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
Definition: channel_layout.c:669
find_latency
static int find_latency(AVFilterContext *ctx, LADSPAContext *s)
Definition: af_ladspa.c:105
FF_DISABLE_DEPRECATION_WARNINGS
#define FF_DISABLE_DEPRECATION_WARNINGS
Definition: internal.h:72
av_strdup
char * av_strdup(const char *s)
Duplicate a string.
Definition: mem.c:270
set_default_ctl_value
static void set_default_ctl_value(LADSPAContext *s, int ctl, unsigned long *map, LADSPA_Data *values)
Definition: af_ladspa.c:313
desc
const char * desc
Definition: libsvtav1.c:83
audio.h
LADSPAContext::octlv
LADSPA_Data * octlv
Definition: af_ladspa.c:63
LADSPAContext::opmap
unsigned long * opmap
Definition: af_ladspa.c:59
map
const VDPAUPixFmtMap * map
Definition: hwcontext_vdpau.c:71
av_free
#define av_free(p)
Definition: tableprint_vlc.h:33
ladspa_options
static const AVOption ladspa_options[]
Definition: af_ladspa.c:85
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:244
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:183
ladspa_outputs
static const AVFilterPad ladspa_outputs[]
Definition: af_ladspa.c:813
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
FLAGS
#define FLAGS
Definition: af_ladspa.c:84
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:474
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
av_fifo_freep2
void av_fifo_freep2(AVFifo **f)
Free an AVFifo and reset pointer to NULL.
Definition: fifo.c:286
h
h
Definition: vp9dsp_template.c:2038
AVERROR_EXIT
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
Definition: error.h:58
avstring.h
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:229
LADSPAContext::fifo
AVFifo * fifo
Definition: af_ladspa.c:80
init
static av_cold int init(AVFilterContext *ctx)
Definition: af_ladspa.c:489
LADSPAContext::pts
int64_t pts
Definition: af_ladspa.c:74
LADSPAContext::nb_outputcontrols
unsigned long nb_outputcontrols
Definition: af_ladspa.c:61
AV_FIFO_FLAG_AUTO_GROW
#define AV_FIFO_FLAG_AUTO_GROW
Automatically resize the FIFO on writes, so that the data fits.
Definition: fifo.h:67
av_x_if_null
static void * av_x_if_null(const void *p, const void *x)
Return x default pointer in case p is NULL.
Definition: avutil.h:312
LADSPAContext::nb_samples
int nb_samples
Definition: af_ladspa.c:71
ff_set_common_channel_layouts
int ff_set_common_channel_layouts(AVFilterContext *ctx, AVFilterChannelLayouts *channel_layouts)
Helpers for query_formats() which set all free audio links to the same list of channel layouts/sample...
Definition: formats.c:790