summaryrefslogtreecommitdiff
path: root/libavfilter/af_aiir.c
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2019-07-08 16:44:53 +0200
committerPaul B Mahol <onemda@gmail.com>2019-07-08 16:48:10 +0200
commit2a801e8856da46d6ec4a33fce367dbb5a32b08c0 (patch)
tree7ce9bfe6823f947b5226c97a0b04b643af34cac6 /libavfilter/af_aiir.c
parent034a9d2507e124c7fd9269afbbbdc8b1b7b70e88 (diff)
downloadffmpeg-2a801e8856da46d6ec4a33fce367dbb5a32b08c0.tar.gz
avfilter/af_aiir: implement mix option
Diffstat (limited to 'libavfilter/af_aiir.c')
-rw-r--r--libavfilter/af_aiir.c6
1 files changed, 6 insertions, 0 deletions
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 },