[FFmpeg-cvslog] avfilter/af_aiir: normalize biquads only if divisor is big enough

Paul B Mahol git at videolan.org
Fri Nov 22 22:16:01 EET 2019


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Fri Nov 22 21:06:35 2019 +0100| [89aa1342b1e5a48d9c55d9af71e8a8151e101bf2] | committer: Paul B Mahol

avfilter/af_aiir: normalize biquads only if divisor is big enough

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=89aa1342b1e5a48d9c55d9af71e8a8151e101bf2
---

 libavfilter/af_aiir.c | 28 ++++++++++++++++------------
 1 file 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);



More information about the ffmpeg-cvslog mailing list