History

avfilter/af_aiir: implement mix option

Paul B Mahol committed 7 years ago

Commit 2a801e81 parent 034a9d22 files · +10 −0Browse files

Unified · Split

2 files
  1. doc/filters.texi +4 −0
  2. libavfilter/af_aiir.c +6 −0
doc/filters.texi+4−0
@@ -1409,6 +1409,10 @@ single-precision floating-point · 1408 unmodified lines
14091409 16-bit integers
14101410 @end table
14111411
1412+@item mix
1413+How much to use filtered signal in output. Default is 1.
1414+Range is between 0 and 1.
1415+
14121416 @item response
14131417 Show IR frequency response, magnitude and phase in additional video stream.
14141418 By default it is disabled.
libavfilter/af_aiir.c+6−0
@@ -57,6 +57,7 @@ typedef struct AudioIIRContext { · 56 unmodified lines
5757 const AVClass *class;
5858 char *a_str, *b_str, *g_str;
5959 double dry_gain, wet_gain;
60+ double mix;
6061 int format;
6162 int process;
6263 int precision;
@@ -124,6 +125,7 @@ static int iir_ch_## name(AVFilterContext *ctx, void *arg, int ch, int nb_jobs) · 61 unmodified lines
124125 AudioIIRContext *s = ctx->priv; \
125126 const double ig = s->dry_gain; \
126127 const double og = s->wet_gain; \
128+ const double mix = s->mix; \
127129 ThreadData *td = arg; \
128130 AVFrame *in = td->in, *out = td->out; \
129131 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) · 22 unmodified lines
152154 \
153155 oc[0] = sample; \
154156 sample *= og; \
157+ sample = sample * mix + ic[0] * (1. - mix); \
155158 if (need_clipping && sample < min) { \
156159 (*clippings)++; \
157160 dst[n] = min; \
@@ -177,6 +180,7 @@ static int iir_ch_serial_## name(AVFilterContext *ctx, void *arg, int ch, int nb · 19 unmodified lines
177180 AudioIIRContext *s = ctx->priv; \
178181 const double ig = s->dry_gain; \
179182 const double og = s->wet_gain; \
183+ const double mix = s->mix; \
180184 ThreadData *td = arg; \
181185 AVFrame *in = td->in, *out = td->out; \
182186 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 · 24 unmodified lines
207211 o1 = o0; \
208212 o0 *= og; \
209213 \
214+ o0 = o0 * mix + (1. - mix) * sample; \
210215 if (need_clipping && o0 < min) { \
211216 (*clippings)++; \
212217 dst[n] = min; \
@@ -1074,6 +1079,7 @@ static const AVOption aiir_options[] = { · 861 unmodified lines
10741079 { "flt", "single-precision floating-point", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, AF, "precision" },
10751080 { "i32", "32-bit integers", 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, AF, "precision" },
10761081 { "i16", "16-bit integers", 0, AV_OPT_TYPE_CONST, {.i64=3}, 0, 0, AF, "precision" },
1082+ { "mix", "set mix", OFFSET(mix), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, AF },
10771083 { "response", "show IR frequency response", OFFSET(response), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, VF },
10781084 { "channel", "set IR channel to display frequency response", OFFSET(ir_channel), AV_OPT_TYPE_INT, {.i64=0}, 0, 1024, VF },
10791085 { "size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "hd720"}, 0, 0, VF },

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t