diff options
author | Paul B Mahol <onemda@gmail.com> | 2019-07-08 16:44:53 +0200 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2019-07-08 16:48:10 +0200 |
commit | 2a801e8856da46d6ec4a33fce367dbb5a32b08c0 (patch) | |
tree | 7ce9bfe6823f947b5226c97a0b04b643af34cac6 | |
parent | 034a9d2507e124c7fd9269afbbbdc8b1b7b70e88 (diff) | |
download | ffmpeg-2a801e8856da46d6ec4a33fce367dbb5a32b08c0.tar.gz |
avfilter/af_aiir: implement mix option
-rw-r--r-- | doc/filters.texi | 4 | ||||
-rw-r--r-- | libavfilter/af_aiir.c | 6 |
2 files changed, 10 insertions, 0 deletions
diff --git a/doc/filters.texi b/doc/filters.texi index 502c06a20f..b0c49265e2 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -1409,6 +1409,10 @@ single-precision floating-point 16-bit integers @end table +@item mix +How much to use filtered signal in output. Default is 1. +Range is between 0 and 1. + @item response Show IR frequency response, magnitude and phase in additional video stream. By default it is disabled. diff --git a/libavfilter/af_aiir.c b/libavfilter/af_aiir.c index 20dea98cbb..5a3b9e849d 100644 --- a/libavfilter/af_aiir.c +++ b/libavfilter/af_aiir.c @@ -57,6 +57,7 @@ typedef struct AudioIIRContext { const AVClass *class; char *a_str, *b_str, *g_str; double dry_gain, wet_gain; + double mix; int format; int process; int precision; @@ -124,6 +125,7 @@ static int iir_ch_## name(AVFilterContext *ctx, void *arg, int ch, int nb_jobs) AudioIIRContext *s = ctx->priv; \ const double ig = s->dry_gain; \ const double og = s->wet_gain; \ + const double mix = s->mix; \ ThreadData *td = arg; \ AVFrame *in = td->in, *out = td->out; \ const type *src = (const type *)in->extended_data[ch]; \ @@ -152,6 +154,7 @@ static int iir_ch_## name(AVFilterContext *ctx, void *arg, int ch, int nb_jobs) \ oc[0] = sample; \ sample *= og; \ + sample = sample * mix + ic[0] * (1. - mix); \ if (need_clipping && sample < min) { \ (*clippings)++; \ dst[n] = min; \ @@ -177,6 +180,7 @@ static int iir_ch_serial_## name(AVFilterContext *ctx, void *arg, int ch, int nb AudioIIRContext *s = ctx->priv; \ const double ig = s->dry_gain; \ const double og = s->wet_gain; \ + const double mix = s->mix; \ ThreadData *td = arg; \ AVFrame *in = td->in, *out = td->out; \ const type *src = (const type *)in->extended_data[ch]; \ @@ -207,6 +211,7 @@ static int iir_ch_serial_## name(AVFilterContext *ctx, void *arg, int ch, int nb o1 = o0; \ o0 *= og; \ \ + o0 = o0 * mix + (1. - mix) * sample; \ if (need_clipping && o0 < min) { \ (*clippings)++; \ dst[n] = min; \ @@ -1074,6 +1079,7 @@ static const AVOption aiir_options[] = { { "flt", "single-precision floating-point", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, AF, "precision" }, { "i32", "32-bit integers", 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, AF, "precision" }, { "i16", "16-bit integers", 0, AV_OPT_TYPE_CONST, {.i64=3}, 0, 0, AF, "precision" }, + { "mix", "set mix", OFFSET(mix), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, AF }, { "response", "show IR frequency response", OFFSET(response), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, VF }, { "channel", "set IR channel to display frequency response", OFFSET(ir_channel), AV_OPT_TYPE_INT, {.i64=0}, 0, 1024, VF }, { "size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "hd720"}, 0, 0, VF }, |