FFmpeg
af_alimiter.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  * Lookahead limiter filter
25  */
26 
28 #include "libavutil/common.h"
29 #include "libavutil/fifo.h"
30 #include "libavutil/opt.h"
31 
32 #include "audio.h"
33 #include "avfilter.h"
34 #include "internal.h"
35 
36 typedef struct MetaItem {
37  int64_t pts;
39 } MetaItem;
40 
41 typedef struct AudioLimiterContext {
42  const AVClass *class;
43 
44  double limit;
45  double attack;
46  double release;
47  double att;
48  double level_in;
49  double level_out;
52  double asc;
53  int asc_c;
54  int asc_pos;
55  double asc_coeff;
56 
57  double *buffer;
59  int pos;
60  int *nextpos;
61  double *nextdelta;
62 
63  int in_trim;
64  int out_pad;
65  int64_t next_in_pts;
66  int64_t next_out_pts;
67  int latency;
68 
70 
71  double delta;
72  int nextiter;
73  int nextlen;
76 
77 #define OFFSET(x) offsetof(AudioLimiterContext, x)
78 #define AF AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_RUNTIME_PARAM
79 
80 static const AVOption alimiter_options[] = {
81  { "level_in", "set input level", OFFSET(level_in), AV_OPT_TYPE_DOUBLE, {.dbl=1},.015625, 64, AF },
82  { "level_out", "set output level", OFFSET(level_out), AV_OPT_TYPE_DOUBLE, {.dbl=1},.015625, 64, AF },
83  { "limit", "set limit", OFFSET(limit), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0.0625, 1, AF },
84  { "attack", "set attack", OFFSET(attack), AV_OPT_TYPE_DOUBLE, {.dbl=5}, 0.1, 80, AF },
85  { "release", "set release", OFFSET(release), AV_OPT_TYPE_DOUBLE, {.dbl=50}, 1, 8000, AF },
86  { "asc", "enable asc", OFFSET(auto_release), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, AF },
87  { "asc_level", "set asc level", OFFSET(asc_coeff), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 1, AF },
88  { "level", "auto level", OFFSET(auto_level), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1, AF },
89  { "latency", "compensate delay", OFFSET(latency), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, AF },
90  { NULL }
91 };
92 
93 AVFILTER_DEFINE_CLASS(alimiter);
94 
96 {
97  AudioLimiterContext *s = ctx->priv;
98 
99  s->attack /= 1000.;
100  s->release /= 1000.;
101  s->att = 1.;
102  s->asc_pos = -1;
103  s->asc_coeff = pow(0.5, s->asc_coeff - 0.5) * 2 * -1;
104 
105  return 0;
106 }
107 
108 static double get_rdelta(AudioLimiterContext *s, double release, int sample_rate,
109  double peak, double limit, double patt, int asc)
110 {
111  double rdelta = (1.0 - patt) / (sample_rate * release);
112 
113  if (asc && s->auto_release && s->asc_c > 0) {
114  double a_att = limit / (s->asc_coeff * s->asc) * (double)s->asc_c;
115 
116  if (a_att > patt) {
117  double delta = FFMAX((a_att - patt) / (sample_rate * release), rdelta / 10);
118 
119  if (delta < rdelta)
120  rdelta = delta;
121  }
122  }
123 
124  return rdelta;
125 }
126 
128 {
129  AVFilterContext *ctx = inlink->dst;
130  AudioLimiterContext *s = ctx->priv;
131  AVFilterLink *outlink = ctx->outputs[0];
132  const double *src = (const double *)in->data[0];
133  const int channels = inlink->ch_layout.nb_channels;
134  const int buffer_size = s->buffer_size;
135  double *dst, *buffer = s->buffer;
136  const double release = s->release;
137  const double limit = s->limit;
138  double *nextdelta = s->nextdelta;
139  double level = s->auto_level ? 1 / limit : 1;
140  const double level_out = s->level_out;
141  const double level_in = s->level_in;
142  int *nextpos = s->nextpos;
143  AVFrame *out;
144  double *buf;
145  int n, c, i;
146  int new_out_samples;
147  int64_t out_duration;
148  int64_t in_duration;
149  int64_t in_pts;
150  MetaItem meta;
151 
152  if (av_frame_is_writable(in)) {
153  out = in;
154  } else {
155  out = ff_get_audio_buffer(outlink, in->nb_samples);
156  if (!out) {
157  av_frame_free(&in);
158  return AVERROR(ENOMEM);
159  }
161  }
162  dst = (double *)out->data[0];
163 
164  for (n = 0; n < in->nb_samples; n++) {
165  double peak = 0;
166 
167  for (c = 0; c < channels; c++) {
168  double sample = src[c] * level_in;
169 
170  buffer[s->pos + c] = sample;
171  peak = FFMAX(peak, fabs(sample));
172  }
173 
174  if (s->auto_release && peak > limit) {
175  s->asc += peak;
176  s->asc_c++;
177  }
178 
179  if (peak > limit) {
180  double patt = FFMIN(limit / peak, 1.);
181  double rdelta = get_rdelta(s, release, inlink->sample_rate,
182  peak, limit, patt, 0);
183  double delta = (limit / peak - s->att) / buffer_size * channels;
184  int found = 0;
185 
186  if (delta < s->delta) {
187  s->delta = delta;
188  nextpos[0] = s->pos;
189  nextpos[1] = -1;
190  nextdelta[0] = rdelta;
191  s->nextlen = 1;
192  s->nextiter= 0;
193  } else {
194  for (i = s->nextiter; i < s->nextiter + s->nextlen; i++) {
195  int j = i % buffer_size;
196  double ppeak = 0, pdelta;
197 
198  for (c = 0; c < channels; c++) {
199  ppeak = FFMAX(ppeak, fabs(buffer[nextpos[j] + c]));
200  }
201  pdelta = (limit / peak - limit / ppeak) / (((buffer_size - nextpos[j] + s->pos) % buffer_size) / channels);
202  if (pdelta < nextdelta[j]) {
203  nextdelta[j] = pdelta;
204  found = 1;
205  break;
206  }
207  }
208  if (found) {
209  s->nextlen = i - s->nextiter + 1;
210  nextpos[(s->nextiter + s->nextlen) % buffer_size] = s->pos;
211  nextdelta[(s->nextiter + s->nextlen) % buffer_size] = rdelta;
212  nextpos[(s->nextiter + s->nextlen + 1) % buffer_size] = -1;
213  s->nextlen++;
214  }
215  }
216  }
217 
218  buf = &s->buffer[(s->pos + channels) % buffer_size];
219  peak = 0;
220  for (c = 0; c < channels; c++) {
221  double sample = buf[c];
222 
223  peak = FFMAX(peak, fabs(sample));
224  }
225 
226  if (s->pos == s->asc_pos && !s->asc_changed)
227  s->asc_pos = -1;
228 
229  if (s->auto_release && s->asc_pos == -1 && peak > limit) {
230  s->asc -= peak;
231  s->asc_c--;
232  }
233 
234  s->att += s->delta;
235 
236  for (c = 0; c < channels; c++)
237  dst[c] = buf[c] * s->att;
238 
239  if ((s->pos + channels) % buffer_size == nextpos[s->nextiter]) {
240  if (s->auto_release) {
241  s->delta = get_rdelta(s, release, inlink->sample_rate,
242  peak, limit, s->att, 1);
243  if (s->nextlen > 1) {
244  double ppeak = 0, pdelta;
245  int pnextpos = nextpos[(s->nextiter + 1) % buffer_size];
246 
247  for (c = 0; c < channels; c++) {
248  ppeak = FFMAX(ppeak, fabs(buffer[pnextpos + c]));
249  }
250  pdelta = (limit / ppeak - s->att) /
251  (((buffer_size + pnextpos -
252  ((s->pos + channels) % buffer_size)) %
253  buffer_size) / channels);
254  if (pdelta < s->delta)
255  s->delta = pdelta;
256  }
257  } else {
258  s->delta = nextdelta[s->nextiter];
259  s->att = limit / peak;
260  }
261 
262  s->nextlen -= 1;
263  nextpos[s->nextiter] = -1;
264  s->nextiter = (s->nextiter + 1) % buffer_size;
265  }
266 
267  if (s->att > 1.) {
268  s->att = 1.;
269  s->delta = 0.;
270  s->nextiter = 0;
271  s->nextlen = 0;
272  nextpos[0] = -1;
273  }
274 
275  if (s->att <= 0.) {
276  s->att = 0.0000000000001;
277  s->delta = (1.0 - s->att) / (inlink->sample_rate * release);
278  }
279 
280  if (s->att != 1. && (1. - s->att) < 0.0000000000001)
281  s->att = 1.;
282 
283  if (s->delta != 0. && fabs(s->delta) < 0.00000000000001)
284  s->delta = 0.;
285 
286  for (c = 0; c < channels; c++)
287  dst[c] = av_clipd(dst[c], -limit, limit) * level * level_out;
288 
289  s->pos = (s->pos + channels) % buffer_size;
290  src += channels;
291  dst += channels;
292  }
293 
294  in_duration = av_rescale_q(in->nb_samples, inlink->time_base, av_make_q(1, in->sample_rate));
295  in_pts = in->pts;
296  meta = (MetaItem){ in->pts, in->nb_samples };
297  av_fifo_write(s->fifo, &meta, 1);
298  if (in != out)
299  av_frame_free(&in);
300 
301  new_out_samples = out->nb_samples;
302  if (s->in_trim > 0) {
303  int trim = FFMIN(new_out_samples, s->in_trim);
304  new_out_samples -= trim;
305  s->in_trim -= trim;
306  }
307 
308  if (new_out_samples <= 0) {
309  av_frame_free(&out);
310  return 0;
311  } else if (new_out_samples < out->nb_samples) {
312  int offset = out->nb_samples - new_out_samples;
313  memmove(out->extended_data[0], out->extended_data[0] + sizeof(double) * offset * out->ch_layout.nb_channels,
314  sizeof(double) * new_out_samples * out->ch_layout.nb_channels);
315  out->nb_samples = new_out_samples;
316  s->in_trim = 0;
317  }
318 
319  av_fifo_read(s->fifo, &meta, 1);
320 
321  out_duration = av_rescale_q(out->nb_samples, inlink->time_base, av_make_q(1, out->sample_rate));
322  in_duration = av_rescale_q(meta.nb_samples, inlink->time_base, av_make_q(1, out->sample_rate));
323  in_pts = meta.pts;
324 
325  if (s->next_out_pts != AV_NOPTS_VALUE && out->pts != s->next_out_pts &&
326  s->next_in_pts != AV_NOPTS_VALUE && in_pts == s->next_in_pts) {
327  out->pts = s->next_out_pts;
328  } else {
329  out->pts = in_pts;
330  }
331  s->next_in_pts = in_pts + in_duration;
332  s->next_out_pts = out->pts + out_duration;
333 
334  return ff_filter_frame(outlink, out);
335 }
336 
337 static int request_frame(AVFilterLink* outlink)
338 {
339  AVFilterContext *ctx = outlink->src;
341  int ret;
342 
343  ret = ff_request_frame(ctx->inputs[0]);
344 
345  if (ret == AVERROR_EOF && s->out_pad > 0) {
346  AVFrame *frame = ff_get_audio_buffer(outlink, FFMIN(1024, s->out_pad));
347  if (!frame)
348  return AVERROR(ENOMEM);
349 
350  s->out_pad -= frame->nb_samples;
351  frame->pts = s->next_in_pts;
352  return filter_frame(ctx->inputs[0], frame);
353  }
354  return ret;
355 }
356 
358 {
359  AVFilterContext *ctx = inlink->dst;
360  AudioLimiterContext *s = ctx->priv;
361  int obuffer_size;
362 
363  obuffer_size = inlink->sample_rate * inlink->ch_layout.nb_channels * 100 / 1000. + inlink->ch_layout.nb_channels;
364  if (obuffer_size < inlink->ch_layout.nb_channels)
365  return AVERROR(EINVAL);
366 
367  s->buffer = av_calloc(obuffer_size, sizeof(*s->buffer));
368  s->nextdelta = av_calloc(obuffer_size, sizeof(*s->nextdelta));
369  s->nextpos = av_malloc_array(obuffer_size, sizeof(*s->nextpos));
370  if (!s->buffer || !s->nextdelta || !s->nextpos)
371  return AVERROR(ENOMEM);
372 
373  memset(s->nextpos, -1, obuffer_size * sizeof(*s->nextpos));
374  s->buffer_size = inlink->sample_rate * s->attack * inlink->ch_layout.nb_channels;
375  s->buffer_size -= s->buffer_size % inlink->ch_layout.nb_channels;
376  if (s->latency)
377  s->in_trim = s->out_pad = s->buffer_size / inlink->ch_layout.nb_channels - 1;
378  s->next_out_pts = AV_NOPTS_VALUE;
379  s->next_in_pts = AV_NOPTS_VALUE;
380 
381  s->fifo = av_fifo_alloc2(8, sizeof(MetaItem), AV_FIFO_FLAG_AUTO_GROW);
382  if (!s->fifo) {
383  return AVERROR(ENOMEM);
384  }
385 
386  if (s->buffer_size <= 0) {
387  av_log(ctx, AV_LOG_ERROR, "Attack is too small.\n");
388  return AVERROR(EINVAL);
389  }
390 
391  return 0;
392 }
393 
395 {
396  AudioLimiterContext *s = ctx->priv;
397 
398  av_freep(&s->buffer);
399  av_freep(&s->nextdelta);
400  av_freep(&s->nextpos);
401 
402  av_fifo_freep2(&s->fifo);
403 }
404 
405 static const AVFilterPad alimiter_inputs[] = {
406  {
407  .name = "main",
408  .type = AVMEDIA_TYPE_AUDIO,
409  .filter_frame = filter_frame,
410  .config_props = config_input,
411  },
412 };
413 
414 static const AVFilterPad alimiter_outputs[] = {
415  {
416  .name = "default",
417  .type = AVMEDIA_TYPE_AUDIO,
418  .request_frame = request_frame,
419  },
420 };
421 
423  .name = "alimiter",
424  .description = NULL_IF_CONFIG_SMALL("Audio lookahead limiter."),
425  .priv_size = sizeof(AudioLimiterContext),
426  .priv_class = &alimiter_class,
427  .init = init,
428  .uninit = uninit,
432  .process_command = ff_filter_process_command,
434 };
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
alimiter_options
static const AVOption alimiter_options[]
Definition: af_alimiter.c:80
AudioLimiterContext::next_out_pts
int64_t next_out_pts
Definition: af_alimiter.c:66
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
out
FILE * out
Definition: movenc.c:54
init
static av_cold int init(AVFilterContext *ctx)
Definition: af_alimiter.c:95
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:978
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
AudioLimiterContext::asc_c
int asc_c
Definition: af_alimiter.c:53
AudioLimiterContext::attack
double attack
Definition: af_alimiter.c:45
FILTER_SINGLE_SAMPLEFMT
#define FILTER_SINGLE_SAMPLEFMT(sample_fmt_)
Definition: internal.h:185
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_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
alimiter_inputs
static const AVFilterPad alimiter_inputs[]
Definition: af_alimiter.c:405
AVOption
AVOption.
Definition: opt.h:251
alimiter_outputs
static const AVFilterPad alimiter_outputs[]
Definition: af_alimiter.c:414
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
AudioLimiterContext::auto_level
int auto_level
Definition: af_alimiter.c:51
ff_af_alimiter
const AVFilter ff_af_alimiter
Definition: af_alimiter.c:422
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:170
AudioLimiterContext::pos
int pos
Definition: af_alimiter.c:59
sample_rate
sample_rate
Definition: ffmpeg_filter.c:372
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:361
fifo.h
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
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:47
AudioLimiterContext::asc_coeff
double asc_coeff
Definition: af_alimiter.c:55
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
s
#define s(width, name)
Definition: cbs_vp9.c:198
AudioLimiterContext::fifo
AVFifo * fifo
Definition: af_alimiter.c:69
AV_OPT_TYPE_DOUBLE
@ AV_OPT_TYPE_DOUBLE
Definition: opt.h:227
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: af_alimiter.c:394
ctx
AVFormatContext * ctx
Definition: movenc.c:48
channels
channels
Definition: aptx.h:31
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:192
frame
static AVFrame * frame
Definition: demux_decode.c:54
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: af_alimiter.c:127
if
if(ret)
Definition: filter_design.txt:179
AudioLimiterContext::level_in
double level_in
Definition: af_alimiter.c:48
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:736
AudioLimiterContext
Definition: af_alimiter.c:41
MetaItem::pts
int64_t pts
Definition: af_alimiter.c:37
AudioLimiterContext::nextlen
int nextlen
Definition: af_alimiter.c:73
AudioLimiterContext::out_pad
int out_pad
Definition: af_alimiter.c:64
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
AudioLimiterContext::asc
double asc
Definition: af_alimiter.c:52
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
AVFrame::sample_rate
int sample_rate
Sample rate of the audio data.
Definition: frame.h:567
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:425
AudioLimiterContext::buffer
double * buffer
Definition: af_alimiter.c:57
sample
#define sample
Definition: flacdsp_template.c:44
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
AF
#define AF
Definition: af_alimiter.c:78
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:851
AudioLimiterContext::release
double release
Definition: af_alimiter.c:46
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
internal.h
AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
Definition: avfilter.h:147
AudioLimiterContext::delta
double delta
Definition: af_alimiter.c:71
AVFrame::nb_samples
int nb_samples
number of audio samples (per channel) described by this frame
Definition: frame.h:420
AudioLimiterContext::in_trim
int in_trim
Definition: af_alimiter.c:63
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:245
AudioLimiterContext::buffer_size
int buffer_size
Definition: af_alimiter.c:58
av_malloc_array
#define av_malloc_array(a, b)
Definition: tableprint_vlc.h:31
common.h
delta
float delta
Definition: vorbis_enc_data.h:430
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
AudioLimiterContext::nextpos
int * nextpos
Definition: af_alimiter.c:60
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
limit
static double limit(double x)
Definition: vf_pseudocolor.c:142
AVFilter
Filter definition.
Definition: avfilter.h:166
ret
ret
Definition: filter_design.txt:187
request_frame
static int request_frame(AVFilterLink *outlink)
Definition: af_alimiter.c:337
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
AudioLimiterContext::nextiter
int nextiter
Definition: af_alimiter.c:72
OFFSET
#define OFFSET(x)
Definition: af_alimiter.c:77
channel_layout.h
buffer
the frame and frame reference mechanism is intended to as much as expensive copies of that data while still allowing the filters to produce correct results The data is stored in buffers represented by AVFrame structures Several references can point to the same frame buffer
Definition: filter_design.txt:49
patt
static const int8_t patt[4]
Definition: vf_noise.c:68
avfilter.h
AudioLimiterContext::asc_pos
int asc_pos
Definition: af_alimiter.c:54
MetaItem
Definition: af_alimiter.c:36
AudioLimiterContext::level_out
double level_out
Definition: af_alimiter.c:49
get_rdelta
static double get_rdelta(AudioLimiterContext *s, double release, int sample_rate, double peak, double limit, double patt, int asc)
Definition: af_alimiter.c:108
AVFilterContext
An instance of a filter.
Definition: avfilter.h:397
MetaItem::nb_samples
int nb_samples
Definition: af_alimiter.c:38
AudioLimiterContext::auto_release
int auto_release
Definition: af_alimiter.c:50
audio.h
AudioLimiterContext::asc_changed
int asc_changed
Definition: af_alimiter.c:74
AudioLimiterContext::att
double att
Definition: af_alimiter.c:47
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(alimiter)
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:244
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
AudioLimiterContext::limit
double limit
Definition: af_alimiter.c:44
AudioLimiterContext::latency
int latency
Definition: af_alimiter.c:67
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
AudioLimiterContext::next_in_pts
int64_t next_in_pts
Definition: af_alimiter.c:65
config_input
static int config_input(AVFilterLink *inlink)
Definition: af_alimiter.c:357
AV_SAMPLE_FMT_DBL
@ AV_SAMPLE_FMT_DBL
double
Definition: samplefmt.h:61
AudioLimiterContext::nextdelta
double * nextdelta
Definition: af_alimiter.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_clipd
av_clipd
Definition: af_crystalizer.c:131