Showing the changes to libavfilter (1 of 2 files). Show all
Unified · Split
| @@ -336,7 +336,7 @@ static int read_zp_coefficients(AVFilterContext *ctx, char *item_str, int nb_ite · 335 unmodified lines | |||
| 336 | return 0; | 336 | return 0; |
| 337 | } | 337 | } |
| 338 | 338 | ||
| 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" }; |
| 340 | 340 | ||
| 341 | static int read_channels(AVFilterContext *ctx, int channels, uint8_t *item_str, int ab) | 341 | static int read_channels(AVFilterContext *ctx, int channels, uint8_t *item_str, int ab) |
| 342 | { | 342 | { |
| @@ -696,6 +696,39 @@ static void convert_pr2zp(AVFilterContext *ctx, int channels) · 353 unmodified lines | |||
| 696 | } | 696 | } |
| 697 | } | 697 | } |
| 698 | 698 | ||
| 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 | |||
| 699 | static void convert_pd2zp(AVFilterContext *ctx, int channels) | 732 | static void convert_pd2zp(AVFilterContext *ctx, int channels) |
| 700 | { | 733 | { |
| 701 | AudioIIRContext *s = ctx->priv; | 734 | AudioIIRContext *s = ctx->priv; |
| @@ -996,6 +1029,8 @@ static int config_output(AVFilterLink *outlink) · 294 unmodified lines | |||
| 996 | convert_pr2zp(ctx, inlink->channels); | 1029 | convert_pr2zp(ctx, inlink->channels); |
| 997 | } else if (s->format == 3) { | 1030 | } else if (s->format == 3) { |
| 998 | convert_pd2zp(ctx, inlink->channels); | 1031 | convert_pd2zp(ctx, inlink->channels); |
| 1032 | } else if (s->format == 4) { | ||
| 1033 | convert_sp2zp(ctx, inlink->channels); | ||
| 999 | } | 1034 | } |
| 1000 | if (s->format > 0) { | 1035 | if (s->format > 0) { |
| 1001 | check_stability(ctx, inlink->channels); | 1036 | check_stability(ctx, inlink->channels); |
| @@ -1221,12 +1256,13 @@ static const AVOption aiir_options[] = { · 219 unmodified lines | |||
| 1221 | { "k", "set channels gains", OFFSET(g_str), AV_OPT_TYPE_STRING, {.str="1|1"}, 0, 0, AF }, | 1256 | { "k", "set channels gains", OFFSET(g_str), AV_OPT_TYPE_STRING, {.str="1|1"}, 0, 0, AF }, |
| 1222 | { "dry", "set dry gain", OFFSET(dry_gain), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, AF }, | 1257 | { "dry", "set dry gain", OFFSET(dry_gain), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, AF }, |
| 1223 | { "wet", "set wet gain", OFFSET(wet_gain), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, AF }, | 1258 | { "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" }, | 1259 | { "format", "set coefficients format", OFFSET(format), AV_OPT_TYPE_INT, {.i64=1}, 0, 4, AF, "format" }, |
| 1225 | { "f", "set coefficients format", OFFSET(format), AV_OPT_TYPE_INT, {.i64=1}, 0, 3, AF, "format" }, | 1260 | { "f", "set coefficients format", OFFSET(format), AV_OPT_TYPE_INT, {.i64=1}, 0, 4, AF, "format" }, |
| 1226 | { "tf", "digital transfer function", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, AF, "format" }, | 1261 | { "tf", "digital transfer function", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, AF, "format" }, |
| 1227 | { "zp", "Z-plane zeros/poles", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, AF, "format" }, | 1262 | { "zp", "Z-plane zeros/poles", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, AF, "format" }, |
| 1228 | { "pr", "Z-plane zeros/poles (polar radians)", 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, AF, "format" }, | 1263 | { "pr", "Z-plane zeros/poles (polar radians)", 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, AF, "format" }, |
| 1229 | { "pd", "Z-plane zeros/poles (polar degrees)", 0, AV_OPT_TYPE_CONST, {.i64=3}, 0, 0, AF, "format" }, | 1264 | { "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" }, | ||
| 1230 | { "process", "set kind of processing", OFFSET(process), AV_OPT_TYPE_INT, {.i64=1}, 0, 1, AF, "process" }, | 1266 | { "process", "set kind of processing", OFFSET(process), AV_OPT_TYPE_INT, {.i64=1}, 0, 1, AF, "process" }, |
| 1231 | { "r", "set kind of processing", OFFSET(process), AV_OPT_TYPE_INT, {.i64=1}, 0, 1, AF, "process" }, | 1267 | { "r", "set kind of processing", OFFSET(process), AV_OPT_TYPE_INT, {.i64=1}, 0, 1, AF, "process" }, |
| 1232 | { "d", "direct", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, AF, "process" }, | 1268 | { "d", "direct", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, AF, "process" }, |