FFmpeg
af_sidechaincompress.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2001-2010 Krzysztof Foltman, Markus Schmidt, Thor Harald Johansen and others
3  * Copyright (c) 2015 Paul B Mahol
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  * Audio (Sidechain) Compressor filter
25  */
26 
27 #include "config_components.h"
28 
29 #include "libavutil/audio_fifo.h"
31 #include "libavutil/common.h"
32 #include "libavutil/opt.h"
33 
34 #include "audio.h"
35 #include "avfilter.h"
36 #include "filters.h"
37 #include "formats.h"
38 #include "hermite.h"
39 #include "internal.h"
40 
41 typedef struct SidechainCompressContext {
42  const AVClass *class;
43 
44  double level_in;
45  double level_sc;
48  double lin_slope;
49  double ratio;
50  double threshold;
51  double makeup;
52  double mix;
53  double thres;
54  double knee;
55  double knee_start;
56  double knee_stop;
58  double lin_knee_stop;
60  double adj_knee_stop;
63  int link;
64  int detection;
65  int mode;
66 
68  int64_t pts;
70 
71 #define OFFSET(x) offsetof(SidechainCompressContext, x)
72 #define A AV_OPT_FLAG_AUDIO_PARAM
73 #define F AV_OPT_FLAG_FILTERING_PARAM
74 #define R AV_OPT_FLAG_RUNTIME_PARAM
75 
76 static const AVOption options[] = {
77  { "level_in", "set input gain", OFFSET(level_in), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0.015625, 64, A|F|R },
78  { "mode", "set mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, A|F|R, .unit = "mode" },
79  { "downward",0, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, A|F|R, .unit = "mode" },
80  { "upward", 0, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, A|F|R, .unit = "mode" },
81  { "threshold", "set threshold", OFFSET(threshold), AV_OPT_TYPE_DOUBLE, {.dbl=0.125}, 0.000976563, 1, A|F|R },
82  { "ratio", "set ratio", OFFSET(ratio), AV_OPT_TYPE_DOUBLE, {.dbl=2}, 1, 20, A|F|R },
83  { "attack", "set attack", OFFSET(attack), AV_OPT_TYPE_DOUBLE, {.dbl=20}, 0.01, 2000, A|F|R },
84  { "release", "set release", OFFSET(release), AV_OPT_TYPE_DOUBLE, {.dbl=250}, 0.01, 9000, A|F|R },
85  { "makeup", "set make up gain", OFFSET(makeup), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 1, 64, A|F|R },
86  { "knee", "set knee", OFFSET(knee), AV_OPT_TYPE_DOUBLE, {.dbl=2.82843}, 1, 8, A|F|R },
87  { "link", "set link type", OFFSET(link), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, A|F|R, .unit = "link" },
88  { "average", 0, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, A|F|R, .unit = "link" },
89  { "maximum", 0, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, A|F|R, .unit = "link" },
90  { "detection", "set detection", OFFSET(detection), AV_OPT_TYPE_INT, {.i64=1}, 0, 1, A|F|R, .unit = "detection" },
91  { "peak", 0, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, A|F|R, .unit = "detection" },
92  { "rms", 0, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, A|F|R, .unit = "detection" },
93  { "level_sc", "set sidechain gain", OFFSET(level_sc), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0.015625, 64, A|F|R },
94  { "mix", "set mix", OFFSET(mix), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, A|F|R },
95  { NULL }
96 };
97 
98 AVFILTER_DEFINE_CLASS_EXT(sidechaincompress_acompressor,
99  "acompressor/sidechaincompress",
100  options);
101 
102 // A fake infinity value (because real infinity may break some hosts)
103 #define FAKE_INFINITY (65536.0 * 65536.0)
104 
105 // Check for infinity (with appropriate-ish tolerance)
106 #define IS_FAKE_INFINITY(value) (fabs(value-FAKE_INFINITY) < 1.0)
107 
108 static double output_gain(double lin_slope, double ratio, double thres,
109  double knee, double knee_start, double knee_stop,
110  double compressed_knee_start,
111  double compressed_knee_stop,
112  int detection, int mode)
113 {
114  double slope = log(lin_slope);
115  double gain = 0.0;
116  double delta = 0.0;
117 
118  if (detection)
119  slope *= 0.5;
120 
121  if (IS_FAKE_INFINITY(ratio)) {
122  gain = thres;
123  delta = 0.0;
124  } else {
125  gain = (slope - thres) / ratio + thres;
126  delta = 1.0 / ratio;
127  }
128 
129  if (mode) {
130  if (knee > 1.0 && slope > knee_start)
131  gain = hermite_interpolation(slope, knee_stop, knee_start,
132  knee_stop, compressed_knee_start,
133  1.0, delta);
134  } else {
135  if (knee > 1.0 && slope < knee_stop)
136  gain = hermite_interpolation(slope, knee_start, knee_stop,
137  knee_start, compressed_knee_stop,
138  1.0, delta);
139  }
140 
141  return exp(gain - slope);
142 }
143 
145 {
146  AVFilterContext *ctx = outlink->src;
147  SidechainCompressContext *s = ctx->priv;
148 
149  s->thres = log(s->threshold);
150  s->lin_knee_start = s->threshold / sqrt(s->knee);
151  s->lin_knee_stop = s->threshold * sqrt(s->knee);
152  s->adj_knee_start = s->lin_knee_start * s->lin_knee_start;
153  s->adj_knee_stop = s->lin_knee_stop * s->lin_knee_stop;
154  s->knee_start = log(s->lin_knee_start);
155  s->knee_stop = log(s->lin_knee_stop);
156  s->compressed_knee_start = (s->knee_start - s->thres) / s->ratio + s->thres;
157  s->compressed_knee_stop = (s->knee_stop - s->thres) / s->ratio + s->thres;
158 
159  s->attack_coeff = FFMIN(1., 1. / (s->attack * outlink->sample_rate / 4000.));
160  s->release_coeff = FFMIN(1., 1. / (s->release * outlink->sample_rate / 4000.));
161 
162  return 0;
163 }
164 
166  const double *src, double *dst, const double *scsrc, int nb_samples,
167  double level_in, double level_sc,
168  AVFilterLink *inlink, AVFilterLink *sclink)
169 {
170  const double makeup = s->makeup;
171  const double mix = s->mix;
172  int i, c;
173 
174  for (i = 0; i < nb_samples; i++) {
175  double abs_sample, gain = 1.0;
176  double detector;
177  int detected;
178 
179  abs_sample = fabs(scsrc[0] * level_sc);
180 
181  if (s->link == 1) {
182  for (c = 1; c < sclink->ch_layout.nb_channels; c++)
183  abs_sample = FFMAX(fabs(scsrc[c] * level_sc), abs_sample);
184  } else {
185  for (c = 1; c < sclink->ch_layout.nb_channels; c++)
186  abs_sample += fabs(scsrc[c] * level_sc);
187 
188  abs_sample /= sclink->ch_layout.nb_channels;
189  }
190 
191  if (s->detection)
192  abs_sample *= abs_sample;
193 
194  s->lin_slope += (abs_sample - s->lin_slope) * (abs_sample > s->lin_slope ? s->attack_coeff : s->release_coeff);
195 
196  if (s->mode) {
197  detector = (s->detection ? s->adj_knee_stop : s->lin_knee_stop);
198  detected = s->lin_slope < detector;
199  } else {
200  detector = (s->detection ? s->adj_knee_start : s->lin_knee_start);
201  detected = s->lin_slope > detector;
202  }
203 
204  if (s->lin_slope > 0.0 && detected)
205  gain = output_gain(s->lin_slope, s->ratio, s->thres, s->knee,
206  s->knee_start, s->knee_stop,
207  s->compressed_knee_start,
208  s->compressed_knee_stop,
209  s->detection, s->mode);
210 
211  for (c = 0; c < inlink->ch_layout.nb_channels; c++)
212  dst[c] = src[c] * level_in * (gain * makeup * mix + (1. - mix));
213 
214  src += inlink->ch_layout.nb_channels;
215  dst += inlink->ch_layout.nb_channels;
216  scsrc += sclink->ch_layout.nb_channels;
217  }
218 }
219 
220 static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
221  char *res, int res_len, int flags)
222 {
223  int ret;
224 
225  ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
226  if (ret < 0)
227  return ret;
228 
229  compressor_config_output(ctx->outputs[0]);
230 
231  return 0;
232 }
233 
234 #if CONFIG_SIDECHAINCOMPRESS_FILTER
235 static int activate(AVFilterContext *ctx)
236 {
237  SidechainCompressContext *s = ctx->priv;
238  AVFrame *out = NULL, *in[2] = { NULL };
239  int ret, i, nb_samples;
240  double *dst;
241 
243  if ((ret = ff_inlink_consume_frame(ctx->inputs[0], &in[0])) > 0) {
244  av_audio_fifo_write(s->fifo[0], (void **)in[0]->extended_data,
245  in[0]->nb_samples);
246  av_frame_free(&in[0]);
247  }
248  if (ret < 0)
249  return ret;
250  if ((ret = ff_inlink_consume_frame(ctx->inputs[1], &in[1])) > 0) {
251  av_audio_fifo_write(s->fifo[1], (void **)in[1]->extended_data,
252  in[1]->nb_samples);
253  av_frame_free(&in[1]);
254  }
255  if (ret < 0)
256  return ret;
257 
258  nb_samples = FFMIN(av_audio_fifo_size(s->fifo[0]), av_audio_fifo_size(s->fifo[1]));
259  if (nb_samples) {
260  out = ff_get_audio_buffer(ctx->outputs[0], nb_samples);
261  if (!out)
262  return AVERROR(ENOMEM);
263  for (i = 0; i < 2; i++) {
264  in[i] = ff_get_audio_buffer(ctx->inputs[i], nb_samples);
265  if (!in[i]) {
266  av_frame_free(&in[0]);
267  av_frame_free(&in[1]);
268  av_frame_free(&out);
269  return AVERROR(ENOMEM);
270  }
271  av_audio_fifo_read(s->fifo[i], (void **)in[i]->data, nb_samples);
272  }
273 
274  dst = (double *)out->data[0];
275  out->pts = s->pts;
276  s->pts += av_rescale_q(nb_samples, (AVRational){1, ctx->outputs[0]->sample_rate}, ctx->outputs[0]->time_base);
277 
278  compressor(s, (double *)in[0]->data[0], dst,
279  (double *)in[1]->data[0], nb_samples,
280  s->level_in, s->level_sc,
281  ctx->inputs[0], ctx->inputs[1]);
282 
283  av_frame_free(&in[0]);
284  av_frame_free(&in[1]);
285 
286  ret = ff_filter_frame(ctx->outputs[0], out);
287  if (ret < 0)
288  return ret;
289  }
290  FF_FILTER_FORWARD_STATUS(ctx->inputs[0], ctx->outputs[0]);
291  FF_FILTER_FORWARD_STATUS(ctx->inputs[1], ctx->outputs[0]);
292  if (ff_outlink_frame_wanted(ctx->outputs[0])) {
293  if (!av_audio_fifo_size(s->fifo[0]))
294  ff_inlink_request_frame(ctx->inputs[0]);
295  if (!av_audio_fifo_size(s->fifo[1]))
296  ff_inlink_request_frame(ctx->inputs[1]);
297  }
298  return 0;
299 }
300 
301 static int query_formats(AVFilterContext *ctx)
302 {
303  static const enum AVSampleFormat sample_fmts[] = {
306  };
308  &ctx->inputs[1]->outcfg.channel_layouts);
309  if (ret < 0)
310  return ret;
311 
312  /* This will link the channel properties of the main input and the output;
313  * it won't touch the second input as its channel_layouts is already set. */
315  return ret;
316 
318  return ret;
319 
321 }
322 
323 static int config_output(AVFilterLink *outlink)
324 {
325  AVFilterContext *ctx = outlink->src;
326  SidechainCompressContext *s = ctx->priv;
327 
328  outlink->time_base = ctx->inputs[0]->time_base;
329 
330  s->fifo[0] = av_audio_fifo_alloc(ctx->inputs[0]->format, ctx->inputs[0]->ch_layout.nb_channels, 1024);
331  s->fifo[1] = av_audio_fifo_alloc(ctx->inputs[1]->format, ctx->inputs[1]->ch_layout.nb_channels, 1024);
332  if (!s->fifo[0] || !s->fifo[1])
333  return AVERROR(ENOMEM);
334 
335  compressor_config_output(outlink);
336 
337  return 0;
338 }
339 
340 static av_cold void uninit(AVFilterContext *ctx)
341 {
342  SidechainCompressContext *s = ctx->priv;
343 
344  av_audio_fifo_free(s->fifo[0]);
345  av_audio_fifo_free(s->fifo[1]);
346 }
347 
348 static const AVFilterPad sidechaincompress_inputs[] = {
349  {
350  .name = "main",
351  .type = AVMEDIA_TYPE_AUDIO,
352  },{
353  .name = "sidechain",
354  .type = AVMEDIA_TYPE_AUDIO,
355  },
356 };
357 
358 static const AVFilterPad sidechaincompress_outputs[] = {
359  {
360  .name = "default",
361  .type = AVMEDIA_TYPE_AUDIO,
362  .config_props = config_output,
363  },
364 };
365 
367  .name = "sidechaincompress",
368  .description = NULL_IF_CONFIG_SMALL("Sidechain compressor."),
369  .priv_class = &sidechaincompress_acompressor_class,
370  .priv_size = sizeof(SidechainCompressContext),
371  .activate = activate,
372  .uninit = uninit,
373  FILTER_INPUTS(sidechaincompress_inputs),
374  FILTER_OUTPUTS(sidechaincompress_outputs),
376  .process_command = process_command,
377 };
378 #endif /* CONFIG_SIDECHAINCOMPRESS_FILTER */
379 
380 #if CONFIG_ACOMPRESSOR_FILTER
381 static int acompressor_filter_frame(AVFilterLink *inlink, AVFrame *in)
382 {
383  const double *src = (const double *)in->data[0];
384  AVFilterContext *ctx = inlink->dst;
385  SidechainCompressContext *s = ctx->priv;
386  AVFilterLink *outlink = ctx->outputs[0];
387  AVFrame *out;
388  double *dst;
389 
390  if (av_frame_is_writable(in)) {
391  out = in;
392  } else {
393  out = ff_get_audio_buffer(outlink, in->nb_samples);
394  if (!out) {
395  av_frame_free(&in);
396  return AVERROR(ENOMEM);
397  }
399  }
400  dst = (double *)out->data[0];
401 
402  compressor(s, src, dst, src, in->nb_samples,
403  s->level_in, s->level_in,
404  inlink, inlink);
405 
406  if (out != in)
407  av_frame_free(&in);
408  return ff_filter_frame(outlink, out);
409 }
410 
411 static const AVFilterPad acompressor_inputs[] = {
412  {
413  .name = "default",
414  .type = AVMEDIA_TYPE_AUDIO,
415  .filter_frame = acompressor_filter_frame,
416  },
417 };
418 
419 static const AVFilterPad acompressor_outputs[] = {
420  {
421  .name = "default",
422  .type = AVMEDIA_TYPE_AUDIO,
423  .config_props = compressor_config_output,
424  },
425 };
426 
427 const AVFilter ff_af_acompressor = {
428  .name = "acompressor",
429  .description = NULL_IF_CONFIG_SMALL("Audio compressor."),
430  .priv_class = &sidechaincompress_acompressor_class,
431  .priv_size = sizeof(SidechainCompressContext),
432  FILTER_INPUTS(acompressor_inputs),
433  FILTER_OUTPUTS(acompressor_outputs),
435  .process_command = process_command,
436 };
437 #endif /* CONFIG_ACOMPRESSOR_FILTER */
av_audio_fifo_free
void av_audio_fifo_free(AVAudioFifo *af)
Free an AVAudioFifo.
Definition: audio_fifo.c:48
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:97
ff_af_sidechaincompress
const AVFilter ff_af_sidechaincompress
mix
static int mix(int c0, int c1)
Definition: 4xm.c:715
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
out
FILE * out
Definition: movenc.c:54
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1018
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
av_audio_fifo_write
int av_audio_fifo_write(AVAudioFifo *af, void *const *data, int nb_samples)
Write data to an AVAudioFifo.
Definition: audio_fifo.c:119
FILTER_SINGLE_SAMPLEFMT
#define FILTER_SINGLE_SAMPLEFMT(sample_fmt_)
Definition: internal.h:175
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:160
ff_all_channel_counts
AVFilterChannelLayouts * ff_all_channel_counts(void)
Construct an AVFilterChannelLayouts coding for any channel layout, with known or unknown disposition.
Definition: formats.c:621
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:375
SidechainCompressContext::adj_knee_stop
double adj_knee_stop
Definition: af_sidechaincompress.c:60
AVOption
AVOption.
Definition: opt.h:346
FILTER_QUERY_FUNC
#define FILTER_QUERY_FUNC(func)
Definition: internal.h:159
data
const char data[16]
Definition: mxf.c:148
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
output_gain
static double output_gain(double lin_slope, double ratio, double thres, double knee, double knee_start, double knee_stop, double compressed_knee_start, double compressed_knee_stop, int detection, int mode)
Definition: af_sidechaincompress.c:108
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
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:313
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:396
formats.h
A
#define A
Definition: af_sidechaincompress.c:72
SidechainCompressContext::lin_knee_stop
double lin_knee_stop
Definition: af_sidechaincompress.c:58
ff_inlink_consume_frame
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
Definition: avfilter.c:1445
FF_FILTER_FORWARD_STATUS_BACK_ALL
#define FF_FILTER_FORWARD_STATUS_BACK_ALL(outlink, filter)
Forward the status on an output link to all input links.
Definition: filters.h:212
AVAudioFifo
Context for an Audio FIFO Buffer.
Definition: audio_fifo.c:37
SidechainCompressContext::adj_knee_start
double adj_knee_start
Definition: af_sidechaincompress.c:59
SidechainCompressContext::ratio
double ratio
Definition: af_sidechaincompress.c:49
SidechainCompressContext::release
double release
Definition: af_sidechaincompress.c:47
SidechainCompressContext::pts
int64_t pts
Definition: af_sidechaincompress.c:68
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:33
options
static const AVOption options[]
Definition: af_sidechaincompress.c:76
compressor
static void compressor(SidechainCompressContext *s, const double *src, double *dst, const double *scsrc, int nb_samples, double level_in, double level_sc, AVFilterLink *inlink, AVFilterLink *sclink)
Definition: af_sidechaincompress.c:165
av_cold
#define av_cold
Definition: attributes.h:90
SidechainCompressContext::level_in
double level_in
Definition: af_sidechaincompress.c:44
ff_inlink_request_frame
void ff_inlink_request_frame(AVFilterLink *link)
Mark that a frame is wanted on the link.
Definition: avfilter.c:1571
s
#define s(width, name)
Definition: cbs_vp9.c:198
hermite_interpolation
static double hermite_interpolation(double x, double x0, double x1, double p0, double p1, double m0, double m1)
Definition: hermite.h:22
AV_OPT_TYPE_DOUBLE
@ AV_OPT_TYPE_DOUBLE
Definition: opt.h:237
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
SidechainCompressContext::knee_start
double knee_start
Definition: af_sidechaincompress.c:55
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
ff_af_acompressor
const AVFilter ff_af_acompressor
filters.h
SidechainCompressContext::mix
double mix
Definition: af_sidechaincompress.c:52
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
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:182
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
if
if(ret)
Definition: filter_design.txt:179
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
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:709
SidechainCompressContext::thres
double thres
Definition: af_sidechaincompress.c:53
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
av_audio_fifo_alloc
AVAudioFifo * av_audio_fifo_alloc(enum AVSampleFormat sample_fmt, int channels, int nb_samples)
Allocate an AVAudioFifo.
Definition: audio_fifo.c:62
activate
filter_frame For filters that do not use the activate() callback
SidechainCompressContext::makeup
double makeup
Definition: af_sidechaincompress.c:51
SidechainCompressContext::compressed_knee_stop
double compressed_knee_stop
Definition: af_sidechaincompress.c:62
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
exp
int8_t exp
Definition: eval.c:74
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
OFFSET
#define OFFSET(x)
Definition: af_sidechaincompress.c:71
SidechainCompressContext::link
int link
Definition: af_sidechaincompress.c:63
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
hermite.h
config_output
static int config_output(AVFilterLink *outlink)
Definition: af_aap.c:190
AV_SAMPLE_FMT_NONE
@ AV_SAMPLE_FMT_NONE
Definition: samplefmt.h:56
av_audio_fifo_read
int av_audio_fifo_read(AVAudioFifo *af, void *const *data, int nb_samples)
Read data from an AVAudioFifo.
Definition: audio_fifo.c:175
SidechainCompressContext::mode
int mode
Definition: af_sidechaincompress.c:65
av_frame_is_writable
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
Definition: frame.c:645
ff_filter_process_command
int ff_filter_process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Generic processing of user supplied commands that are set in the same way as the filter options.
Definition: avfilter.c:890
SidechainCompressContext::knee
double knee
Definition: af_sidechaincompress.c:54
SidechainCompressContext::compressed_knee_start
double compressed_knee_start
Definition: af_sidechaincompress.c:61
av_audio_fifo_size
int av_audio_fifo_size(AVAudioFifo *af)
Get the current number of samples in the AVAudioFifo available for reading.
Definition: audio_fifo.c:222
internal.h
SidechainCompressContext::detection
int detection
Definition: af_sidechaincompress.c:64
uninit
static void uninit(AVBSFContext *ctx)
Definition: pcm_rechunk.c:68
AVFrame::nb_samples
int nb_samples
number of audio samples (per channel) described by this frame
Definition: frame.h:455
R
#define R
Definition: af_sidechaincompress.c:74
compressor_config_output
static int compressor_config_output(AVFilterLink *outlink)
Definition: af_sidechaincompress.c:144
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
common.h
AVSampleFormat
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:55
SidechainCompressContext::attack_coeff
double attack_coeff
Definition: af_sidechaincompress.c:46
delta
float delta
Definition: vorbis_enc_data.h:430
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
SidechainCompressContext::level_sc
double level_sc
Definition: af_sidechaincompress.c:45
audio_fifo.h
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:39
SidechainCompressContext::lin_slope
double lin_slope
Definition: af_sidechaincompress.c:48
AVFilter
Filter definition.
Definition: avfilter.h:166
SidechainCompressContext::fifo
AVAudioFifo * fifo[2]
Definition: af_sidechaincompress.c:67
ret
ret
Definition: filter_design.txt:187
SidechainCompressContext
Definition: af_sidechaincompress.c:41
SidechainCompressContext::threshold
double threshold
Definition: af_sidechaincompress.c:50
process_command
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
Definition: af_sidechaincompress.c:220
F
#define F
Definition: af_sidechaincompress.c:73
channel_layout.h
mode
mode
Definition: ebur128.h:83
SidechainCompressContext::knee_stop
double knee_stop
Definition: af_sidechaincompress.c:56
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:235
avfilter.h
AVFilterContext
An instance of a filter.
Definition: avfilter.h:407
AVFILTER_DEFINE_CLASS_EXT
AVFILTER_DEFINE_CLASS_EXT(sidechaincompress_acompressor, "acompressor/sidechaincompress", options)
audio.h
SidechainCompressContext::lin_knee_start
double lin_knee_start
Definition: af_sidechaincompress.c:57
FF_FILTER_FORWARD_STATUS
FF_FILTER_FORWARD_STATUS(inlink, outlink)
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:183
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
IS_FAKE_INFINITY
#define IS_FAKE_INFINITY(value)
Definition: af_sidechaincompress.c:106
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: aeval.c:246
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:474
ff_outlink_frame_wanted
the definition of that something depends on the semantic of the filter The callback must examine the status of the filter s links and proceed accordingly The status of output links is stored in the status_in and status_out fields and tested by the ff_outlink_frame_wanted() function. If this function returns true
AV_SAMPLE_FMT_DBL
@ AV_SAMPLE_FMT_DBL
double
Definition: samplefmt.h:61
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:244
SidechainCompressContext::attack
double attack
Definition: af_sidechaincompress.c:46
SidechainCompressContext::release_coeff
double release_coeff
Definition: af_sidechaincompress.c:47