Commit 33d7f822 authored by Ronald S. Bultje's avatar Ronald S. Bultje

wmavoice: protect against zero-energy in adaptive gain control.

Otherwise the scale factor becomes NaN, resulting in corrupt output.
Fixes #5426.
parent 7b27dd5c
...@@ -512,7 +512,8 @@ static void adaptive_gain_control(float *out, const float *in, ...@@ -512,7 +512,8 @@ static void adaptive_gain_control(float *out, const float *in,
speech_energy += fabsf(speech_synth[i]); speech_energy += fabsf(speech_synth[i]);
postfilter_energy += fabsf(in[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++) { for (i = 0; i < size; i++) {
mem = alpha * mem + gain_scale_factor; mem = alpha * mem + gain_scale_factor;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment