aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter/af_aiir.c
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2019-11-22 21:06:35 +0100
committerPaul B Mahol <onemda@gmail.com>2019-11-22 21:10:43 +0100
commit89aa1342b1e5a48d9c55d9af71e8a8151e101bf2 (patch)
treecdd94986fe6ab3314e214b2cc6375e2b327ed32e /libavfilter/af_aiir.c
parentf46b04c4c32849a789a5aadc27fff3c3c60fc596 (diff)
downloadffmpeg-89aa1342b1e5a48d9c55d9af71e8a8151e101bf2.tar.gz
avfilter/af_aiir: normalize biquads only if divisor is big enough
Diffstat (limited to 'libavfilter/af_aiir.c')
-rw-r--r--libavfilter/af_aiir.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/libavfilter/af_aiir.c b/libavfilter/af_aiir.c
index 55828c1a82..717388f450 100644
--- a/libavfilter/af_aiir.c
+++ b/libavfilter/af_aiir.c
@@ -601,18 +601,22 @@ static int decompose_zp2biquads(AVFilterContext *ctx, int channels)
iir->biquads[current_biquad].b[1] = b[2] / a[4];
iir->biquads[current_biquad].b[2] = b[0] / a[4];
- factor = (iir->biquads[current_biquad].a[0] +
- iir->biquads[current_biquad].a[1] +
- iir->biquads[current_biquad].a[2]) /
- (iir->biquads[current_biquad].b[0] +
- iir->biquads[current_biquad].b[1] +
- iir->biquads[current_biquad].b[2]);
-
- av_log(ctx, AV_LOG_VERBOSE, "factor=%f\n", factor);
-
- iir->biquads[current_biquad].b[0] *= factor;
- iir->biquads[current_biquad].b[1] *= factor;
- iir->biquads[current_biquad].b[2] *= factor;
+ if (fabs(iir->biquads[current_biquad].b[0] +
+ iir->biquads[current_biquad].b[1] +
+ iir->biquads[current_biquad].b[2]) > 1e-6) {
+ factor = (iir->biquads[current_biquad].a[0] +
+ iir->biquads[current_biquad].a[1] +
+ iir->biquads[current_biquad].a[2]) /
+ (iir->biquads[current_biquad].b[0] +
+ iir->biquads[current_biquad].b[1] +
+ iir->biquads[current_biquad].b[2]);
+
+ av_log(ctx, AV_LOG_VERBOSE, "factor=%f\n", factor);
+
+ 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);