diff options
author | Paul B Mahol <onemda@gmail.com> | 2019-11-22 17:42:04 +0100 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2019-11-22 17:42:04 +0100 |
commit | eecc45cea50fedc918fc7cac908fdfc6baefd241 (patch) | |
tree | 12865bb6fae082643ccb63d6e8579aff18e825e3 /libavfilter | |
parent | 2f5fb9e60fa62a6b1e9b7ab874d6814ab1fed6b6 (diff) | |
download | ffmpeg-eecc45cea50fedc918fc7cac908fdfc6baefd241.tar.gz |
avfilter/af_aiir: add missing normalization of biquads gains
Diffstat (limited to 'libavfilter')
-rw-r--r-- | libavfilter/af_aiir.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/libavfilter/af_aiir.c b/libavfilter/af_aiir.c index 1120afdd12..e22f814cc7 100644 --- a/libavfilter/af_aiir.c +++ b/libavfilter/af_aiir.c @@ -499,6 +499,7 @@ static int decompose_zp2biquads(AVFilterContext *ctx, int channels) double a[6] = { 0 }; double min_distance = DBL_MAX; double max_mag = 0; + double factor; int i; for (i = 0; i < iir->nb_ab[0]; i++) { @@ -593,12 +594,24 @@ static int decompose_zp2biquads(AVFilterContext *ctx, int channels) iir->ab[1][2 * nearest_zero.a] = iir->ab[1][2 * nearest_zero.a + 1] = NAN; iir->ab[1][2 * nearest_zero.b] = iir->ab[1][2 * nearest_zero.b + 1] = NAN; - iir->biquads[current_biquad].a[0] = 1.0; - iir->biquads[current_biquad].a[1] = a[2] / a[4]; - iir->biquads[current_biquad].a[2] = a[0] / a[4]; - iir->biquads[current_biquad].b[0] = (b[4] / a[4]) * (current_biquad ? 1.0 : iir->g); - iir->biquads[current_biquad].b[1] = (b[2] / a[4]) * (current_biquad ? 1.0 : iir->g); - iir->biquads[current_biquad].b[2] = (b[0] / a[4]) * (current_biquad ? 1.0 : iir->g); + iir->biquads[current_biquad].a[0] = a[4]; + iir->biquads[current_biquad].a[1] = a[2]; + iir->biquads[current_biquad].a[2] = a[0]; + iir->biquads[current_biquad].b[0] = b[4]; + iir->biquads[current_biquad].b[1] = b[2]; + iir->biquads[current_biquad].b[2] = b[0]; + + factor = (iir->biquads[current_biquad].a[0] + + iir->biquads[current_biquad].a[1] + + iir->biquads[current_biquad].a[2]) / 4; + + iir->biquads[current_biquad].b[0] *= factor; + iir->biquads[current_biquad].b[1] *= factor; + iir->biquads[current_biquad].b[2] *= factor; + + iir->biquads[current_biquad].b[0] *= (current_biquad ? 1.0 : iir->g); + iir->biquads[current_biquad].b[1] *= (current_biquad ? 1.0 : iir->g); + iir->biquads[current_biquad].b[2] *= (current_biquad ? 1.0 : iir->g); av_log(ctx, AV_LOG_VERBOSE, "a=%f %f %f:b=%f %f %f\n", iir->biquads[current_biquad].a[0], |