History

avfilter/af_aiir: add S-plane support

Paul B Mahol committed 6 years ago

Commit e2e81211 parent 327b5242 files · +41 −3Browse files

Showing the changes to libavfilter (1 of 2 files). Show all

Unified · Split

libavfilter/af_aiir.c+39−3
@@ -336,7 +336,7 @@ static int read_zp_coefficients(AVFilterContext *ctx, char *item_str, int nb_ite · 335 unmodified lines
336336 return 0;
337337 }
338338
339−static const char *format[] = { "%lf", "%lf %lfi", "%lf %lfr", "%lf %lfd" };
339+static const char *format[] = { "%lf", "%lf %lfi", "%lf %lfr", "%lf %lfd", "%lf %lfi" };
340340
341341 static int read_channels(AVFilterContext *ctx, int channels, uint8_t *item_str, int ab)
342342 {
@@ -696,6 +696,39 @@ static void convert_pr2zp(AVFilterContext *ctx, int channels) · 353 unmodified lines
696696 }
697697 }
698698
699+static void convert_sp2zp(AVFilterContext *ctx, int channels)
700+{
701+ AudioIIRContext *s = ctx->priv;
702+ int ch;
703+
704+ for (ch = 0; ch < channels; ch++) {
705+ IIRChannel *iir = &s->iir[ch];
706+ int n;
707+
708+ for (n = 0; n < iir->nb_ab[0]; n++) {
709+ double sr = iir->ab[0][2*n];
710+ double si = iir->ab[0][2*n+1];
711+ double snr = 1. + sr;
712+ double sdr = 1. - sr;
713+ double div = sdr * sdr + si * si;
714+
715+ iir->ab[0][2*n] = (snr * sdr - si * si) / div;
716+ iir->ab[0][2*n+1] = (sdr * si + snr * si) / div;
717+ }
718+
719+ for (n = 0; n < iir->nb_ab[1]; n++) {
720+ double sr = iir->ab[1][2*n];
721+ double si = iir->ab[1][2*n+1];
722+ double snr = 1. + sr;
723+ double sdr = 1. - sr;
724+ double div = sdr * sdr + si * si;
725+
726+ iir->ab[1][2*n] = (snr * sdr - si * si) / div;
727+ iir->ab[1][2*n+1] = (sdr * si + snr * si) / div;
728+ }
729+ }
730+}
731+
699732 static void convert_pd2zp(AVFilterContext *ctx, int channels)
700733 {
701734 AudioIIRContext *s = ctx->priv;
@@ -996,6 +1029,8 @@ static int config_output(AVFilterLink *outlink) · 294 unmodified lines
9961029 convert_pr2zp(ctx, inlink->channels);
9971030 } else if (s->format == 3) {
9981031 convert_pd2zp(ctx, inlink->channels);
1032+ } else if (s->format == 4) {
1033+ convert_sp2zp(ctx, inlink->channels);
9991034 }
10001035 if (s->format > 0) {
10011036 check_stability(ctx, inlink->channels);
@@ -1221,12 +1256,13 @@ static const AVOption aiir_options[] = { · 219 unmodified lines
12211256 { "k", "set channels gains", OFFSET(g_str), AV_OPT_TYPE_STRING, {.str="1|1"}, 0, 0, AF },
12221257 { "dry", "set dry gain", OFFSET(dry_gain), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, AF },
12231258 { "wet", "set wet gain", OFFSET(wet_gain), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, AF },
1224− { "format", "set coefficients format", OFFSET(format), AV_OPT_TYPE_INT, {.i64=1}, 0, 3, AF, "format" },
1225− { "f", "set coefficients format", OFFSET(format), AV_OPT_TYPE_INT, {.i64=1}, 0, 3, AF, "format" },
1259+ { "format", "set coefficients format", OFFSET(format), AV_OPT_TYPE_INT, {.i64=1}, 0, 4, AF, "format" },
1260+ { "f", "set coefficients format", OFFSET(format), AV_OPT_TYPE_INT, {.i64=1}, 0, 4, AF, "format" },
12261261 { "tf", "digital transfer function", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, AF, "format" },
12271262 { "zp", "Z-plane zeros/poles", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, AF, "format" },
12281263 { "pr", "Z-plane zeros/poles (polar radians)", 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, AF, "format" },
12291264 { "pd", "Z-plane zeros/poles (polar degrees)", 0, AV_OPT_TYPE_CONST, {.i64=3}, 0, 0, AF, "format" },
1265+ { "sp", "S-plane zeros/poles", 0, AV_OPT_TYPE_CONST, {.i64=4}, 0, 0, AF, "format" },
12301266 { "process", "set kind of processing", OFFSET(process), AV_OPT_TYPE_INT, {.i64=1}, 0, 1, AF, "process" },
12311267 { "r", "set kind of processing", OFFSET(process), AV_OPT_TYPE_INT, {.i64=1}, 0, 1, AF, "process" },
12321268 { "d", "direct", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, AF, "process" },

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