diff options
author | Paul B Mahol <onemda@gmail.com> | 2015-12-06 14:57:05 +0100 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2015-12-06 19:10:39 +0100 |
commit | 45b451c89239b85aec02f946aca4b67894a027b2 (patch) | |
tree | 1ac4555494e51279966fbf83235568dfce6fe668 /libavfilter | |
parent | b0669e7ccfef5ecaa83a0b5837c343ae198f03fe (diff) | |
download | ffmpeg-45b451c89239b85aec02f946aca4b67894a027b2.tar.gz |
avfilter/af_alimiter: add 3 more options
Signed-off-by: Paul B Mahol <onemda@gmail.com>
Diffstat (limited to 'libavfilter')
-rw-r--r-- | libavfilter/af_alimiter.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/libavfilter/af_alimiter.c b/libavfilter/af_alimiter.c index c3e3ff2942..46211a710a 100644 --- a/libavfilter/af_alimiter.c +++ b/libavfilter/af_alimiter.c @@ -41,7 +41,10 @@ typedef struct AudioLimiterContext { double attack; double release; double att; + double level_in; + double level_out; int auto_release; + int auto_level; double asc; int asc_c; int asc_pos; @@ -64,11 +67,14 @@ typedef struct AudioLimiterContext { #define F AV_OPT_FLAG_FILTERING_PARAM static const AVOption alimiter_options[] = { - { "limit", "set limit", OFFSET(limit), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0.0625, 1, A|F }, - { "attack", "set attack", OFFSET(attack), AV_OPT_TYPE_DOUBLE, {.dbl=5}, 0.1, 80, A|F }, - { "release", "set release", OFFSET(release), AV_OPT_TYPE_DOUBLE, {.dbl=50}, 1, 8000, A|F }, - { "asc", "enable asc", OFFSET(auto_release), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, A|F }, - { "asc_level", "set asc level", OFFSET(asc_coeff), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 1, A|F }, + { "level_in", "set input level", OFFSET(level_in), AV_OPT_TYPE_DOUBLE, {.dbl=1},.015625, 64, A|F }, + { "level_out", "set output level", OFFSET(level_out), AV_OPT_TYPE_DOUBLE, {.dbl=1},.015625, 64, A|F }, + { "limit", "set limit", OFFSET(limit), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0.0625, 1, A|F }, + { "attack", "set attack", OFFSET(attack), AV_OPT_TYPE_DOUBLE, {.dbl=5}, 0.1, 80, A|F }, + { "release", "set release", OFFSET(release), AV_OPT_TYPE_DOUBLE, {.dbl=50}, 1, 8000, A|F }, + { "asc", "enable asc", OFFSET(auto_release), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, A|F }, + { "asc_level", "set asc level", OFFSET(asc_coeff), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 1, A|F }, + { "level", "auto level", OFFSET(auto_level), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1, A|F }, { NULL } }; @@ -118,6 +124,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) const double release = s->release; const double limit = s->limit; double *nextdelta = s->nextdelta; + double level = s->auto_level ? 1 / limit : 1; + const double level_out = s->level_out; + const double level_in = s->level_in; int *nextpos = s->nextpos; AVFrame *out; double *buf; @@ -139,7 +148,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) double peak = 0; for (c = 0; c < channels; c++) { - double sample = src[c]; + double sample = src[c] * level_in; buffer[s->pos + c] = sample; peak = FFMAX(peak, fabs(sample)); @@ -255,7 +264,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) s->delta = 0.; for (c = 0; c < channels; c++) - dst[c] = av_clipd(dst[c], -limit, limit); + dst[c] = av_clipd(dst[c], -limit, limit) * level * level_out; s->pos = (s->pos + channels) % buffer_size; src += channels; |