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 
27 #include "libavutil/avassert.h"
29 #include "libavutil/common.h"
30 #include "libavutil/opt.h"
31 
32 #include "audio.h"
33 #include "avfilter.h"
34 #include "formats.h"
35 #include "internal.h"
36 
37 typedef struct AudioLimiterContext {
38  const AVClass *class;
39 
40  double limit;
41  double attack;
42  double release;
43  double att;
44  double level_in;
45  double level_out;
48  double asc;
49  int asc_c;
50  int asc_pos;
51  double asc_coeff;
52 
53  double *buffer;
55  int pos;
56  int *nextpos;
57  double *nextdelta;
58 
59  double delta;
60  int nextiter;
61  int nextlen;
64 
65 #define OFFSET(x) offsetof(AudioLimiterContext, x)
66 #define A AV_OPT_FLAG_AUDIO_PARAM
67 #define F AV_OPT_FLAG_FILTERING_PARAM
68 
69 static const AVOption alimiter_options[] = {
70  { "level_in", "set input level", OFFSET(level_in), AV_OPT_TYPE_DOUBLE, {.dbl=1},.015625, 64, A|F },
71  { "level_out", "set output level", OFFSET(level_out), AV_OPT_TYPE_DOUBLE, {.dbl=1},.015625, 64, A|F },
72  { "limit", "set limit", OFFSET(limit), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0.0625, 1, A|F },
73  { "attack", "set attack", OFFSET(attack), AV_OPT_TYPE_DOUBLE, {.dbl=5}, 0.1, 80, A|F },
74  { "release", "set release", OFFSET(release), AV_OPT_TYPE_DOUBLE, {.dbl=50}, 1, 8000, A|F },
75  { "asc", "enable asc", OFFSET(auto_release), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, A|F },
76  { "asc_level", "set asc level", OFFSET(asc_coeff), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 1, A|F },
77  { "level", "auto level", OFFSET(auto_level), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1, A|F },
78  { NULL }
79 };
80 
81 AVFILTER_DEFINE_CLASS(alimiter);
82 
84 {
85  AudioLimiterContext *s = ctx->priv;
86 
87  s->attack /= 1000.;
88  s->release /= 1000.;
89  s->att = 1.;
90  s->asc_pos = -1;
91  s->asc_coeff = pow(0.5, s->asc_coeff - 0.5) * 2 * -1;
92 
93  return 0;
94 }
95 
96 static double get_rdelta(AudioLimiterContext *s, double release, int sample_rate,
97  double peak, double limit, double patt, int asc)
98 {
99  double rdelta = (1.0 - patt) / (sample_rate * release);
100 
101  if (asc && s->auto_release && s->asc_c > 0) {
102  double a_att = limit / (s->asc_coeff * s->asc) * (double)s->asc_c;
103 
104  if (a_att > patt) {
105  double delta = FFMAX((a_att - patt) / (sample_rate * release), rdelta / 10);
106 
107  if (delta < rdelta)
108  rdelta = delta;
109  }
110  }
111 
112  return rdelta;
113 }
114 
116 {
117  AVFilterContext *ctx = inlink->dst;
118  AudioLimiterContext *s = ctx->priv;
119  AVFilterLink *outlink = ctx->outputs[0];
120  const double *src = (const double *)in->data[0];
121  const int channels = inlink->channels;
122  const int buffer_size = s->buffer_size;
123  double *dst, *buffer = s->buffer;
124  const double release = s->release;
125  const double limit = s->limit;
126  double *nextdelta = s->nextdelta;
127  double level = s->auto_level ? 1 / limit : 1;
128  const double level_out = s->level_out;
129  const double level_in = s->level_in;
130  int *nextpos = s->nextpos;
131  AVFrame *out;
132  double *buf;
133  int n, c, i;
134 
136  out = in;
137  } else {
138  out = ff_get_audio_buffer(outlink, in->nb_samples);
139  if (!out) {
140  av_frame_free(&in);
141  return AVERROR(ENOMEM);
142  }
144  }
145  dst = (double *)out->data[0];
146 
147  for (n = 0; n < in->nb_samples; n++) {
148  double peak = 0;
149 
150  for (c = 0; c < channels; c++) {
151  double sample = src[c] * level_in;
152 
153  buffer[s->pos + c] = sample;
154  peak = FFMAX(peak, fabs(sample));
155  }
156 
157  if (s->auto_release && peak > limit) {
158  s->asc += peak;
159  s->asc_c++;
160  }
161 
162  if (peak > limit) {
163  double patt = FFMIN(limit / peak, 1.);
164  double rdelta = get_rdelta(s, release, inlink->sample_rate,
165  peak, limit, patt, 0);
166  double delta = (limit / peak - s->att) / buffer_size * channels;
167  int found = 0;
168 
169  if (delta < s->delta) {
170  s->delta = delta;
171  nextpos[0] = s->pos;
172  nextpos[1] = -1;
173  nextdelta[0] = rdelta;
174  s->nextlen = 1;
175  s->nextiter= 0;
176  } else {
177  for (i = s->nextiter; i < s->nextiter + s->nextlen; i++) {
178  int j = i % buffer_size;
179  double ppeak, pdelta;
180 
181  ppeak = fabs(buffer[nextpos[j]]) > fabs(buffer[nextpos[j] + 1]) ?
182  fabs(buffer[nextpos[j]]) : fabs(buffer[nextpos[j] + 1]);
183  pdelta = (limit / peak - limit / ppeak) / (((buffer_size - nextpos[j] + s->pos) % buffer_size) / channels);
184  if (pdelta < nextdelta[j]) {
185  nextdelta[j] = pdelta;
186  found = 1;
187  break;
188  }
189  }
190  if (found) {
191  s->nextlen = i - s->nextiter + 1;
192  nextpos[(s->nextiter + s->nextlen) % buffer_size] = s->pos;
193  nextdelta[(s->nextiter + s->nextlen) % buffer_size] = rdelta;
194  nextpos[(s->nextiter + s->nextlen + 1) % buffer_size] = -1;
195  s->nextlen++;
196  }
197  }
198  }
199 
200  buf = &s->buffer[(s->pos + channels) % buffer_size];
201  peak = 0;
202  for (c = 0; c < channels; c++) {
203  double sample = buf[c];
204 
205  peak = FFMAX(peak, fabs(sample));
206  }
207 
208  if (s->pos == s->asc_pos && !s->asc_changed)
209  s->asc_pos = -1;
210 
211  if (s->auto_release && s->asc_pos == -1 && peak > limit) {
212  s->asc -= peak;
213  s->asc_c--;
214  }
215 
216  s->att += s->delta;
217 
218  for (c = 0; c < channels; c++)
219  dst[c] = buf[c] * s->att;
220 
221  if ((s->pos + channels) % buffer_size == nextpos[s->nextiter]) {
222  if (s->auto_release) {
223  s->delta = get_rdelta(s, release, inlink->sample_rate,
224  peak, limit, s->att, 1);
225  if (s->nextlen > 1) {
226  int pnextpos = nextpos[(s->nextiter + 1) % buffer_size];
227  double ppeak = fabs(buffer[pnextpos]) > fabs(buffer[pnextpos + 1]) ?
228  fabs(buffer[pnextpos]) :
229  fabs(buffer[pnextpos + 1]);
230  double pdelta = (limit / ppeak - s->att) /
231  (((buffer_size + pnextpos -
232  ((s->pos + channels) % buffer_size)) %
233  buffer_size) / channels);
234  if (pdelta < s->delta)
235  s->delta = pdelta;
236  }
237  } else {
238  s->delta = nextdelta[s->nextiter];
239  s->att = limit / peak;
240  }
241 
242  s->nextlen -= 1;
243  nextpos[s->nextiter] = -1;
244  s->nextiter = (s->nextiter + 1) % buffer_size;
245  }
246 
247  if (s->att > 1.) {
248  s->att = 1.;
249  s->delta = 0.;
250  s->nextiter = 0;
251  s->nextlen = 0;
252  nextpos[0] = -1;
253  }
254 
255  if (s->att <= 0.) {
256  s->att = 0.0000000000001;
257  s->delta = (1.0 - s->att) / (inlink->sample_rate * release);
258  }
259 
260  if (s->att != 1. && (1. - s->att) < 0.0000000000001)
261  s->att = 1.;
262 
263  if (s->delta != 0. && fabs(s->delta) < 0.00000000000001)
264  s->delta = 0.;
265 
266  for (c = 0; c < channels; c++)
267  dst[c] = av_clipd(dst[c], -limit, limit) * level * level_out;
268 
269  s->pos = (s->pos + channels) % buffer_size;
270  src += channels;
271  dst += channels;
272  }
273 
274  if (in != out)
275  av_frame_free(&in);
276 
277  return ff_filter_frame(outlink, out);
278 }
279 
281 {
284  static const enum AVSampleFormat sample_fmts[] = {
287  };
288  int ret;
289 
291  if (!layouts)
292  return AVERROR(ENOMEM);
294  if (ret < 0)
295  return ret;
296 
298  if (!formats)
299  return AVERROR(ENOMEM);
301  if (ret < 0)
302  return ret;
303 
305  if (!formats)
306  return AVERROR(ENOMEM);
308 }
309 
311 {
312  AVFilterContext *ctx = inlink->dst;
313  AudioLimiterContext *s = ctx->priv;
314  int obuffer_size;
315 
316  obuffer_size = inlink->sample_rate * inlink->channels * 100 / 1000. + inlink->channels;
317  if (obuffer_size < inlink->channels)
318  return AVERROR(EINVAL);
319 
320  s->buffer = av_calloc(obuffer_size, sizeof(*s->buffer));
321  s->nextdelta = av_calloc(obuffer_size, sizeof(*s->nextdelta));
322  s->nextpos = av_malloc_array(obuffer_size, sizeof(*s->nextpos));
323  if (!s->buffer || !s->nextdelta || !s->nextpos)
324  return AVERROR(ENOMEM);
325 
326  memset(s->nextpos, -1, obuffer_size * sizeof(*s->nextpos));
327  s->buffer_size = inlink->sample_rate * s->attack * inlink->channels;
328  s->buffer_size -= s->buffer_size % inlink->channels;
329 
330  if (s->buffer_size <= 0) {
331  av_log(ctx, AV_LOG_ERROR, "Attack is too small.\n");
332  return AVERROR(EINVAL);
333  }
334 
335  return 0;
336 }
337 
339 {
340  AudioLimiterContext *s = ctx->priv;
341 
342  av_freep(&s->buffer);
343  av_freep(&s->nextdelta);
344  av_freep(&s->nextpos);
345 }
346 
347 static const AVFilterPad alimiter_inputs[] = {
348  {
349  .name = "main",
350  .type = AVMEDIA_TYPE_AUDIO,
351  .filter_frame = filter_frame,
352  .config_props = config_input,
353  },
354  { NULL }
355 };
356 
357 static const AVFilterPad alimiter_outputs[] = {
358  {
359  .name = "default",
360  .type = AVMEDIA_TYPE_AUDIO,
361  },
362  { NULL }
363 };
364 
366  .name = "alimiter",
367  .description = NULL_IF_CONFIG_SMALL("Audio lookahead limiter."),
368  .priv_size = sizeof(AudioLimiterContext),
369  .priv_class = &alimiter_class,
370  .init = init,
371  .uninit = uninit,
375 };
formats
formats
Definition: signature.h: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:86
alimiter_options
static const AVOption alimiter_options[]
Definition: af_alimiter.c:69
AVFilterChannelLayouts
A list of supported channel layouts.
Definition: formats.h:86
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
ff_make_format_list
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:286
out
FILE * out
Definition: movenc.c:54
ff_af_alimiter
AVFilter ff_af_alimiter
Definition: af_alimiter.c:365
init
static av_cold int init(AVFilterContext *ctx)
Definition: af_alimiter.c:83
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1094
sample_fmts
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:926
layouts
enum MovChannelLayoutTag * layouts
Definition: mov_chan.c:434
AudioLimiterContext::asc_c
int asc_c
Definition: af_alimiter.c:49
AudioLimiterContext::attack
double attack
Definition: af_alimiter.c:41
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:204
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:436
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:324
alimiter_inputs
static const AVFilterPad alimiter_inputs[]
Definition: af_alimiter.c:347
AVOption
AVOption.
Definition: opt.h:248
alimiter_outputs
static const AVFilterPad alimiter_outputs[]
Definition: af_alimiter.c:357
AudioLimiterContext::auto_level
int auto_level
Definition: af_alimiter.c:47
F
#define F
Definition: af_alimiter.c:67
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:149
AudioLimiterContext::pos
int pos
Definition: af_alimiter.c:55
sample_rate
sample_rate
Definition: ffmpeg_filter.c:158
AVFilterFormats
A list of supported formats for one end of a filter link.
Definition: formats.h:65
formats.h
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: af_alimiter.c:280
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:54
avassert.h
AudioLimiterContext::asc_coeff
double asc_coeff
Definition: af_alimiter.c:51
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:194
av_cold
#define av_cold
Definition: attributes.h:90
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
ff_set_common_formats
int ff_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats)
A helper for query_formats() which sets all links to the same list of formats.
Definition: formats.c:587
s
#define s(width, name)
Definition: cbs_vp9.c:257
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:338
outputs
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
ctx
AVFormatContext * ctx
Definition: movenc.c:48
channels
channels
Definition: aptx.h:33
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: af_alimiter.c:115
if
if(ret)
Definition: filter_design.txt:179
AudioLimiterContext::level_in
double level_in
Definition: af_alimiter.c:44
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:67
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:659
AudioLimiterContext
Definition: af_alimiter.c:37
src
#define src
Definition: vp8dsp.c:255
AudioLimiterContext::nextlen
int nextlen
Definition: af_alimiter.c:61
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
for
for(j=16;j >0;--j)
Definition: h264pred_template.c:469
AudioLimiterContext::asc
double asc
Definition: af_alimiter.c:48
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:117
av_clipd
#define av_clipd
Definition: common.h:173
AudioLimiterContext::buffer
double * buffer
Definition: af_alimiter.c:53
FFMAX
#define FFMAX(a, b)
Definition: common.h:103
AV_SAMPLE_FMT_NONE
@ AV_SAMPLE_FMT_NONE
Definition: samplefmt.h:59
sample
#define sample
Definition: flacdsp_template.c:44
av_frame_is_writable
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
Definition: frame.c:595
A
#define A
Definition: af_alimiter.c:66
FFMIN
#define FFMIN(a, b)
Definition: common.h:105
AudioLimiterContext::release
double release
Definition: af_alimiter.c:42
internal.h
AudioLimiterContext::delta
double delta
Definition: af_alimiter.c:59
in
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method !=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2) { ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc) { av_free(ac);return NULL;} return ac;} in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar) { ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar ? ac->channels :1;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
Definition: audio_convert.c:326
i
int i
Definition: input.c:407
AudioLimiterContext::buffer_size
int buffer_size
Definition: af_alimiter.c:54
av_malloc_array
#define av_malloc_array(a, b)
Definition: tableprint_vlc.h:32
common.h
AVSampleFormat
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:58
delta
float delta
Definition: vorbis_enc_data.h:457
AudioLimiterContext::nextpos
int * nextpos
Definition: af_alimiter.c:56
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:60
AVFilter
Filter definition.
Definition: avfilter.h:145
ret
ret
Definition: filter_design.txt:187
AudioLimiterContext::nextiter
int nextiter
Definition: af_alimiter.c:60
ff_all_samplerates
AVFilterFormats * ff_all_samplerates(void)
Definition: formats.c:421
OFFSET
#define OFFSET(x)
Definition: af_alimiter.c:65
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
Definition: mem.c:245
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:67
avfilter.h
AudioLimiterContext::asc_pos
int asc_pos
Definition: af_alimiter.c:50
AudioLimiterContext::level_out
double level_out
Definition: af_alimiter.c:45
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:96
AVFilterContext
An instance of a filter.
Definition: avfilter.h:341
AudioLimiterContext::auto_release
int auto_release
Definition: af_alimiter.c:46
audio.h
AudioLimiterContext::asc_changed
int asc_changed
Definition: af_alimiter.c:62
AudioLimiterContext::att
double att
Definition: af_alimiter.c:43
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(alimiter)
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:242
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
AudioLimiterContext::limit
double limit
Definition: af_alimiter.c:40
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
ff_set_common_samplerates
int ff_set_common_samplerates(AVFilterContext *ctx, AVFilterFormats *samplerates)
Definition: formats.c:575
config_input
static int config_input(AVFilterLink *inlink)
Definition: af_alimiter.c:310
AV_SAMPLE_FMT_DBL
@ AV_SAMPLE_FMT_DBL
double
Definition: samplefmt.h:64
AudioLimiterContext::nextdelta
double * nextdelta
Definition: af_alimiter.c:57
ff_set_common_channel_layouts
int ff_set_common_channel_layouts(AVFilterContext *ctx, AVFilterChannelLayouts *channel_layouts)
A helper for query_formats() which sets all links to the same list of channel layouts/sample rates.
Definition: formats.c:568