wmavoice: protect against zero-energy in adaptive gain control.
authorRonald S. Bultje <rsbultje@gmail.com>
Tue, 20 Dec 2016 23:01:05 +0000 (18:01 -0500)
committerRonald S. Bultje <rsbultje@gmail.com>
Tue, 27 Dec 2016 15:02:34 +0000 (10:02 -0500)
Otherwise the scale factor becomes NaN, resulting in corrupt output.
Fixes #5426.

libavcodec/wmavoice.c

index 90dfe20..cd5958c 100644 (file)
@@ -512,7 +512,8 @@ static void adaptive_gain_control(float *out, const float *in,
         speech_energy     += fabsf(speech_synth[i]);
         postfilter_energy += fabsf(in[i]);
     }
-    gain_scale_factor = (1.0 - alpha) * speech_energy / postfilter_energy;
+    gain_scale_factor = postfilter_energy == 0.0 ? 0.0 :
+                        (1.0 - alpha) * speech_energy / postfilter_energy;
 
     for (i = 0; i < size; i++) {
         mem = alpha * mem + gain_scale_factor;