FFmpeg
af_compand.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 1999 Chris Bagwell
3  * Copyright (c) 1999 Nick Bailey
4  * Copyright (c) 2007 Rob Sykes <robs@users.sourceforge.net>
5  * Copyright (c) 2013 Paul B Mahol
6  * Copyright (c) 2014 Andrew Kelley
7  *
8  * This file is part of FFmpeg.
9  *
10  * FFmpeg is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2.1 of the License, or (at your option) any later version.
14  *
15  * FFmpeg is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with FFmpeg; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23  */
24 
25 /**
26  * @file
27  * audio compand filter
28  */
29 
30 #include "libavutil/avassert.h"
31 #include "libavutil/avstring.h"
32 #include "libavutil/ffmath.h"
33 #include "libavutil/opt.h"
34 #include "libavutil/samplefmt.h"
35 #include "audio.h"
36 #include "avfilter.h"
37 #include "internal.h"
38 
39 typedef struct ChanParam {
40  double attack;
41  double decay;
42  double volume;
43 } ChanParam;
44 
45 typedef struct CompandSegment {
46  double x, y;
47  double a, b;
49 
50 typedef struct CompandContext {
51  const AVClass *class;
53  char *attacks, *decays, *points;
56  double in_min_lin;
57  double out_min_lin;
58  double curve_dB;
59  double gain_dB;
61  double delay;
66  int64_t pts;
67 
70 
71 #define OFFSET(x) offsetof(CompandContext, x)
72 #define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
73 
74 static const AVOption compand_options[] = {
75  { "attacks", "set time over which increase of volume is determined", OFFSET(attacks), AV_OPT_TYPE_STRING, { .str = "0" }, 0, 0, A },
76  { "decays", "set time over which decrease of volume is determined", OFFSET(decays), AV_OPT_TYPE_STRING, { .str = "0.8" }, 0, 0, A },
77  { "points", "set points of transfer function", OFFSET(points), AV_OPT_TYPE_STRING, { .str = "-70/-70|-60/-20|1/0" }, 0, 0, A },
78  { "soft-knee", "set soft-knee", OFFSET(curve_dB), AV_OPT_TYPE_DOUBLE, { .dbl = 0.01 }, 0.01, 900, A },
79  { "gain", "set output gain", OFFSET(gain_dB), AV_OPT_TYPE_DOUBLE, { .dbl = 0 }, -900, 900, A },
80  { "volume", "set initial volume", OFFSET(initial_volume), AV_OPT_TYPE_DOUBLE, { .dbl = 0 }, -900, 0, A },
81  { "delay", "set delay for samples before sending them to volume adjuster", OFFSET(delay), AV_OPT_TYPE_DOUBLE, { .dbl = 0 }, 0, 20, A },
82  { NULL }
83 };
84 
85 AVFILTER_DEFINE_CLASS(compand);
86 
88 {
89  CompandContext *s = ctx->priv;
90  s->pts = AV_NOPTS_VALUE;
91  return 0;
92 }
93 
95 {
96  CompandContext *s = ctx->priv;
97 
98  av_freep(&s->channels);
99  av_freep(&s->segments);
100  av_frame_free(&s->delay_frame);
101 }
102 
103 static void count_items(char *item_str, int *nb_items)
104 {
105  char *p;
106 
107  *nb_items = 1;
108  for (p = item_str; *p; p++) {
109  if (*p == ' ' || *p == '|')
110  (*nb_items)++;
111  }
112 }
113 
114 static void update_volume(ChanParam *cp, double in)
115 {
116  double delta = in - cp->volume;
117 
118  if (delta > 0.0)
119  cp->volume += delta * cp->attack;
120  else
121  cp->volume += delta * cp->decay;
122 }
123 
124 static double get_volume(CompandContext *s, double in_lin)
125 {
126  CompandSegment *cs;
127  double in_log, out_log;
128  int i;
129 
130  if (in_lin < s->in_min_lin)
131  return s->out_min_lin;
132 
133  in_log = log(in_lin);
134 
135  for (i = 1; i < s->nb_segments; i++)
136  if (in_log <= s->segments[i].x)
137  break;
138  cs = &s->segments[i - 1];
139  in_log -= cs->x;
140  out_log = cs->y + in_log * (cs->a * in_log + cs->b);
141 
142  return exp(out_log);
143 }
144 
146 {
147  CompandContext *s = ctx->priv;
148  AVFilterLink *inlink = ctx->inputs[0];
149  const int channels = inlink->ch_layout.nb_channels;
150  const int nb_samples = frame->nb_samples;
151  AVFrame *out_frame;
152  int chan, i;
153  int err;
154 
156  out_frame = frame;
157  } else {
158  out_frame = ff_get_audio_buffer(ctx->outputs[0], nb_samples);
159  if (!out_frame) {
161  return AVERROR(ENOMEM);
162  }
163  err = av_frame_copy_props(out_frame, frame);
164  if (err < 0) {
165  av_frame_free(&out_frame);
167  return err;
168  }
169  }
170 
171  for (chan = 0; chan < channels; chan++) {
172  const double *src = (double *)frame->extended_data[chan];
173  double *dst = (double *)out_frame->extended_data[chan];
174  ChanParam *cp = &s->channels[chan];
175 
176  for (i = 0; i < nb_samples; i++) {
177  update_volume(cp, fabs(src[i]));
178 
179  dst[i] = src[i] * get_volume(s, cp->volume);
180  }
181  }
182 
183  if (frame != out_frame)
185 
186  return ff_filter_frame(ctx->outputs[0], out_frame);
187 }
188 
189 #define MOD(a, b) (((a) >= (b)) ? (a) - (b) : (a))
190 
192 {
193  CompandContext *s = ctx->priv;
194  AVFilterLink *inlink = ctx->inputs[0];
195  const int channels = inlink->ch_layout.nb_channels;
196  const int nb_samples = frame->nb_samples;
197  int chan, i, av_uninit(dindex), oindex, av_uninit(count);
198  AVFrame *out_frame = NULL;
199  int err;
200 
201  if (s->pts == AV_NOPTS_VALUE) {
202  s->pts = (frame->pts == AV_NOPTS_VALUE) ? 0 : frame->pts;
203  }
204 
205  av_assert1(channels > 0); /* would corrupt delay_count and delay_index */
206 
207  for (chan = 0; chan < channels; chan++) {
208  AVFrame *delay_frame = s->delay_frame;
209  const double *src = (double *)frame->extended_data[chan];
210  double *dbuf = (double *)delay_frame->extended_data[chan];
211  ChanParam *cp = &s->channels[chan];
212  double *dst;
213 
214  count = s->delay_count;
215  dindex = s->delay_index;
216  for (i = 0, oindex = 0; i < nb_samples; i++) {
217  const double in = src[i];
218  update_volume(cp, fabs(in));
219 
220  if (count >= s->delay_samples) {
221  if (!out_frame) {
222  out_frame = ff_get_audio_buffer(ctx->outputs[0], nb_samples - i);
223  if (!out_frame) {
225  return AVERROR(ENOMEM);
226  }
227  err = av_frame_copy_props(out_frame, frame);
228  if (err < 0) {
229  av_frame_free(&out_frame);
231  return err;
232  }
233  out_frame->pts = s->pts;
234  s->pts += av_rescale_q(nb_samples - i,
235  (AVRational){ 1, inlink->sample_rate },
236  inlink->time_base);
237  }
238 
239  dst = (double *)out_frame->extended_data[chan];
240  dst[oindex++] = dbuf[dindex] * get_volume(s, cp->volume);
241  } else {
242  count++;
243  }
244 
245  dbuf[dindex] = in;
246  dindex = MOD(dindex + 1, s->delay_samples);
247  }
248  }
249 
250  s->delay_count = count;
251  s->delay_index = dindex;
252 
254 
255  if (out_frame) {
256  err = ff_filter_frame(ctx->outputs[0], out_frame);
257  return err;
258  }
259 
260  return 0;
261 }
262 
263 static int compand_drain(AVFilterLink *outlink)
264 {
265  AVFilterContext *ctx = outlink->src;
266  CompandContext *s = ctx->priv;
267  const int channels = outlink->ch_layout.nb_channels;
268  AVFrame *frame = NULL;
269  int chan, i, dindex;
270 
271  /* 2048 is to limit output frame size during drain */
272  frame = ff_get_audio_buffer(outlink, FFMIN(2048, s->delay_count));
273  if (!frame)
274  return AVERROR(ENOMEM);
275  frame->pts = s->pts;
276  s->pts += av_rescale_q(frame->nb_samples,
277  (AVRational){ 1, outlink->sample_rate }, outlink->time_base);
278 
279  av_assert0(channels > 0);
280  for (chan = 0; chan < channels; chan++) {
281  AVFrame *delay_frame = s->delay_frame;
282  double *dbuf = (double *)delay_frame->extended_data[chan];
283  double *dst = (double *)frame->extended_data[chan];
284  ChanParam *cp = &s->channels[chan];
285 
286  dindex = s->delay_index;
287  for (i = 0; i < frame->nb_samples; i++) {
288  dst[i] = dbuf[dindex] * get_volume(s, cp->volume);
289  dindex = MOD(dindex + 1, s->delay_samples);
290  }
291  }
292  s->delay_count -= frame->nb_samples;
293  s->delay_index = dindex;
294 
295  return ff_filter_frame(outlink, frame);
296 }
297 
298 static int config_output(AVFilterLink *outlink)
299 {
300  AVFilterContext *ctx = outlink->src;
301  CompandContext *s = ctx->priv;
302  const int sample_rate = outlink->sample_rate;
303  double radius = s->curve_dB * M_LN10 / 20.0;
304  char *p, *saveptr = NULL;
305  const int channels = outlink->ch_layout.nb_channels;
306  int nb_attacks, nb_decays, nb_points;
307  int new_nb_items, num;
308  int i;
309 
310  count_items(s->attacks, &nb_attacks);
311  count_items(s->decays, &nb_decays);
312  count_items(s->points, &nb_points);
313 
314  if (channels <= 0) {
315  av_log(ctx, AV_LOG_ERROR, "Invalid number of channels: %d\n", channels);
316  return AVERROR(EINVAL);
317  }
318 
319  if (nb_attacks > channels || nb_decays > channels) {
321  "Number of attacks/decays bigger than number of channels. Ignoring rest of entries.\n");
322  nb_attacks = FFMIN(nb_attacks, channels);
323  nb_decays = FFMIN(nb_decays, channels);
324  }
325 
326  uninit(ctx);
327 
328  s->channels = av_calloc(channels, sizeof(*s->channels));
329  s->nb_segments = (nb_points + 4) * 2;
330  s->segments = av_calloc(s->nb_segments, sizeof(*s->segments));
331 
332  if (!s->channels || !s->segments) {
333  uninit(ctx);
334  return AVERROR(ENOMEM);
335  }
336 
337  p = s->attacks;
338  for (i = 0, new_nb_items = 0; i < nb_attacks; i++) {
339  char *tstr = av_strtok(p, " |", &saveptr);
340  if (!tstr) {
341  uninit(ctx);
342  return AVERROR(EINVAL);
343  }
344  p = NULL;
345  new_nb_items += sscanf(tstr, "%lf", &s->channels[i].attack) == 1;
346  if (s->channels[i].attack < 0) {
347  uninit(ctx);
348  return AVERROR(EINVAL);
349  }
350  }
351  nb_attacks = new_nb_items;
352 
353  p = s->decays;
354  for (i = 0, new_nb_items = 0; i < nb_decays; i++) {
355  char *tstr = av_strtok(p, " |", &saveptr);
356  if (!tstr) {
357  uninit(ctx);
358  return AVERROR(EINVAL);
359  }
360  p = NULL;
361  new_nb_items += sscanf(tstr, "%lf", &s->channels[i].decay) == 1;
362  if (s->channels[i].decay < 0) {
363  uninit(ctx);
364  return AVERROR(EINVAL);
365  }
366  }
367  nb_decays = new_nb_items;
368 
369  if (nb_attacks != nb_decays) {
371  "Number of attacks %d differs from number of decays %d.\n",
372  nb_attacks, nb_decays);
373  uninit(ctx);
374  return AVERROR(EINVAL);
375  }
376 
377  for (i = nb_decays; i < channels; i++) {
378  s->channels[i].attack = s->channels[nb_decays - 1].attack;
379  s->channels[i].decay = s->channels[nb_decays - 1].decay;
380  }
381 
382 #define S(x) s->segments[2 * ((x) + 1)]
383  p = s->points;
384  for (i = 0, new_nb_items = 0; i < nb_points; i++) {
385  char *tstr = av_strtok(p, " |", &saveptr);
386  p = NULL;
387  if (!tstr || sscanf(tstr, "%lf/%lf", &S(i).x, &S(i).y) != 2) {
389  "Invalid and/or missing input/output value.\n");
390  uninit(ctx);
391  return AVERROR(EINVAL);
392  }
393  if (i && S(i - 1).x > S(i).x) {
395  "Transfer function input values must be increasing.\n");
396  uninit(ctx);
397  return AVERROR(EINVAL);
398  }
399  S(i).y -= S(i).x;
400  av_log(ctx, AV_LOG_DEBUG, "%d: x=%f y=%f\n", i, S(i).x, S(i).y);
401  new_nb_items++;
402  }
403  num = new_nb_items;
404 
405  /* Add 0,0 if necessary */
406  if (num == 0 || S(num - 1).x)
407  num++;
408 
409 #undef S
410 #define S(x) s->segments[2 * (x)]
411  /* Add a tail off segment at the start */
412  S(0).x = S(1).x - 2 * s->curve_dB;
413  S(0).y = S(1).y;
414  num++;
415 
416  /* Join adjacent colinear segments */
417  for (i = 2; i < num; i++) {
418  double g1 = (S(i - 1).y - S(i - 2).y) * (S(i - 0).x - S(i - 1).x);
419  double g2 = (S(i - 0).y - S(i - 1).y) * (S(i - 1).x - S(i - 2).x);
420  int j;
421 
422  if (fabs(g1 - g2))
423  continue;
424  num--;
425  for (j = --i; j < num; j++)
426  S(j) = S(j + 1);
427  }
428 
429  for (i = 0; i < s->nb_segments; i += 2) {
430  s->segments[i].y += s->gain_dB;
431  s->segments[i].x *= M_LN10 / 20;
432  s->segments[i].y *= M_LN10 / 20;
433  }
434 
435 #define L(x) s->segments[i - (x)]
436  for (i = 4; i < s->nb_segments; i += 2) {
437  double x, y, cx, cy, in1, in2, out1, out2, theta, len, r;
438 
439  L(4).a = 0;
440  L(4).b = (L(2).y - L(4).y) / (L(2).x - L(4).x);
441 
442  L(2).a = 0;
443  L(2).b = (L(0).y - L(2).y) / (L(0).x - L(2).x);
444 
445  theta = atan2(L(2).y - L(4).y, L(2).x - L(4).x);
446  len = hypot(L(2).x - L(4).x, L(2).y - L(4).y);
447  r = FFMIN(radius, len);
448  L(3).x = L(2).x - r * cos(theta);
449  L(3).y = L(2).y - r * sin(theta);
450 
451  theta = atan2(L(0).y - L(2).y, L(0).x - L(2).x);
452  len = hypot(L(0).x - L(2).x, L(0).y - L(2).y);
453  r = FFMIN(radius, len / 2);
454  x = L(2).x + r * cos(theta);
455  y = L(2).y + r * sin(theta);
456 
457  cx = (L(3).x + L(2).x + x) / 3;
458  cy = (L(3).y + L(2).y + y) / 3;
459 
460  L(2).x = x;
461  L(2).y = y;
462 
463  in1 = cx - L(3).x;
464  out1 = cy - L(3).y;
465  in2 = L(2).x - L(3).x;
466  out2 = L(2).y - L(3).y;
467  L(3).a = (out2 / in2 - out1 / in1) / (in2 - in1);
468  L(3).b = out1 / in1 - L(3).a * in1;
469  }
470  L(3).x = 0;
471  L(3).y = L(2).y;
472 
473  s->in_min_lin = exp(s->segments[1].x);
474  s->out_min_lin = exp(s->segments[1].y);
475 
476  for (i = 0; i < channels; i++) {
477  ChanParam *cp = &s->channels[i];
478 
479  if (cp->attack > 1.0 / sample_rate)
480  cp->attack = 1.0 - exp(-1.0 / (sample_rate * cp->attack));
481  else
482  cp->attack = 1.0;
483  if (cp->decay > 1.0 / sample_rate)
484  cp->decay = 1.0 - exp(-1.0 / (sample_rate * cp->decay));
485  else
486  cp->decay = 1.0;
487  cp->volume = ff_exp10(s->initial_volume / 20);
488  }
489 
490  s->delay_samples = s->delay * sample_rate;
491  if (s->delay_samples <= 0) {
492  s->compand = compand_nodelay;
493  return 0;
494  }
495 
496  s->delay_frame = ff_get_audio_buffer(outlink, s->delay_samples);
497  if (!s->delay_frame)
498  return AVERROR(ENOMEM);
499 
500  s->compand = compand_delay;
501  return 0;
502 }
503 
505 {
506  AVFilterContext *ctx = inlink->dst;
507  CompandContext *s = ctx->priv;
508 
509  return s->compand(ctx, frame);
510 }
511 
512 static int request_frame(AVFilterLink *outlink)
513 {
514  AVFilterContext *ctx = outlink->src;
515  CompandContext *s = ctx->priv;
516  int ret = 0;
517 
518  ret = ff_request_frame(ctx->inputs[0]);
519 
520  if (ret == AVERROR_EOF && !ctx->is_disabled && s->delay_count)
521  ret = compand_drain(outlink);
522 
523  return ret;
524 }
525 
526 static const AVFilterPad compand_inputs[] = {
527  {
528  .name = "default",
529  .type = AVMEDIA_TYPE_AUDIO,
530  .filter_frame = filter_frame,
531  },
532 };
533 
534 static const AVFilterPad compand_outputs[] = {
535  {
536  .name = "default",
537  .request_frame = request_frame,
538  .config_props = config_output,
539  .type = AVMEDIA_TYPE_AUDIO,
540  },
541 };
542 
543 
545  .name = "compand",
546  .description = NULL_IF_CONFIG_SMALL(
547  "Compress or expand audio dynamic range."),
548  .priv_size = sizeof(CompandContext),
549  .priv_class = &compand_class,
550  .init = init,
551  .uninit = uninit,
555 };
CompandContext::delay
double delay
Definition: af_compand.c:61
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:107
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
ff_exp10
static av_always_inline double ff_exp10(double x)
Compute 10^x for floating point values.
Definition: ffmath.h:42
r
const char * r
Definition: vf_curves.c:126
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
compand_delay
static int compand_delay(AVFilterContext *ctx, AVFrame *frame)
Definition: af_compand.c:191
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:978
ff_af_compand
const AVFilter ff_af_compand
Definition: af_compand.c:544
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
FILTER_SINGLE_SAMPLEFMT
#define FILTER_SINGLE_SAMPLEFMT(sample_fmt_)
Definition: internal.h:185
CompandSegment::b
double b
Definition: af_compand.c:47
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
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:251
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:431
OFFSET
#define OFFSET(x)
Definition: af_compand.c:71
CompandContext::out_min_lin
double out_min_lin
Definition: af_compand.c:57
init
static av_cold int init(AVFilterContext *ctx)
Definition: af_compand.c:87
CompandSegment::x
double x
Definition: af_compand.c:46
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:170
AVChannelLayout::nb_channels
int nb_channels
Number of channels in this layout.
Definition: channel_layout.h:317
CompandSegment
Definition: af_compand.c:45
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(compand)
sample_rate
sample_rate
Definition: ffmpeg_filter.c:368
CompandContext
Definition: af_compand.c:50
request_frame
static int request_frame(AVFilterLink *outlink)
Definition: af_compand.c:512
samplefmt.h
config_output
static int config_output(AVFilterLink *outlink)
Definition: af_compand.c:298
CompandContext::attacks
char * attacks
Definition: af_compand.c:53
ChanParam::attack
double attack
Definition: af_compand.c:40
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:47
compand_options
static const AVOption compand_options[]
Definition: af_compand.c:74
CompandContext::delay_frame
AVFrame * delay_frame
Definition: af_compand.c:62
avassert.h
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
CompandContext::curve_dB
double curve_dB
Definition: af_compand.c:58
av_cold
#define av_cold
Definition: attributes.h:90
s
#define s(width, name)
Definition: cbs_vp9.c:198
AV_OPT_TYPE_DOUBLE
@ AV_OPT_TYPE_DOUBLE
Definition: opt.h:227
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
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:40
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
channels
channels
Definition: aptx.h:31
CompandContext::delay_samples
int delay_samples
Definition: af_compand.c:63
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
compand_nodelay
static int compand_nodelay(AVFilterContext *ctx, AVFrame *frame)
Definition: af_compand.c:145
compand_inputs
static const AVFilterPad compand_inputs[]
Definition: af_compand.c:526
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:192
frame
static AVFrame * frame
Definition: demux_decode.c:54
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
fabs
static __device__ float fabs(float a)
Definition: cuda_runtime.h:182
NULL
#define NULL
Definition: coverity.c:32
CompandContext::channels
ChanParam * channels
Definition: af_compand.c:55
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
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
get_volume
static double get_volume(CompandContext *s, double in_lin)
Definition: af_compand.c:124
CompandContext::decays
char * decays
Definition: af_compand.c:53
update_volume
static void update_volume(ChanParam *cp, double in)
Definition: af_compand.c:114
CompandContext::compand
int(* compand)(AVFilterContext *ctx, AVFrame *frame)
Definition: af_compand.c:68
exp
int8_t exp
Definition: eval.c:72
CompandContext::segments
CompandSegment * segments
Definition: af_compand.c:54
compand_drain
static int compand_drain(AVFilterLink *outlink)
Definition: af_compand.c:263
CompandContext::in_min_lin
double in_min_lin
Definition: af_compand.c:56
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
L
#define L(x)
MOD
#define MOD(a, b)
Definition: af_compand.c:189
CompandContext::nb_segments
int nb_segments
Definition: af_compand.c:52
hypot
static av_const double hypot(double x, double y)
Definition: libm.h:366
CompandContext::delay_index
int delay_index
Definition: af_compand.c:65
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
Definition: af_compand.c:504
av_frame_is_writable
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
Definition: frame.c:666
CompandContext::delay_count
int delay_count
Definition: af_compand.c:64
CompandContext::points
char * points
Definition: af_compand.c:53
A
#define A
Definition: af_compand.c:72
CompandContext::gain_dB
double gain_dB
Definition: af_compand.c:59
internal.h
AVFrame::nb_samples
int nb_samples
number of audio samples (per channel) described by this frame
Definition: frame.h:420
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
CompandContext::pts
int64_t pts
Definition: af_compand.c:66
AVFrame::extended_data
uint8_t ** extended_data
pointers to the data planes/channels.
Definition: frame.h:401
av_assert1
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
Definition: avassert.h:56
delta
float delta
Definition: vorbis_enc_data.h:430
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
len
int len
Definition: vorbis_enc_data.h:426
CompandSegment::y
double y
Definition: af_compand.c:46
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:53
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:262
AVFilter
Filter definition.
Definition: avfilter.h:166
av_uninit
#define av_uninit(x)
Definition: attributes.h:154
ret
ret
Definition: filter_design.txt:187
S
#define S(x)
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: af_compand.c:94
avfilter.h
AV_SAMPLE_FMT_DBLP
@ AV_SAMPLE_FMT_DBLP
double, planar
Definition: samplefmt.h:67
ffmath.h
AVFilterContext
An instance of a filter.
Definition: avfilter.h:397
count_items
static void count_items(char *item_str, int *nb_items)
Definition: af_compand.c:103
audio.h
M_LN10
#define M_LN10
Definition: mathematics.h:49
ChanParam
Definition: af_compand.c:39
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:193
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
avstring.h
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:229
int
int
Definition: ffmpeg_filter.c:368
ChanParam::decay
double decay
Definition: af_compand.c:41
CompandSegment::a
double a
Definition: af_compand.c:47
CompandContext::initial_volume
double initial_volume
Definition: af_compand.c:60
ChanParam::volume
double volume
Definition: af_compand.c:42
compand_outputs
static const AVFilterPad compand_outputs[]
Definition: af_compand.c:534