summaryrefslogtreecommitdiff
path: root/libavcodec/wmavoice.c
diff options
context:
space:
mode:
authorRonald S. Bultje <rsbultje@gmail.com>2016-12-20 18:01:05 -0500
committerRonald S. Bultje <rsbultje@gmail.com>2016-12-27 10:02:34 -0500
commit33d7f822f8ed2d1870babc1d04d4d48cf8b6f240 (patch)
tree7b4c6619060e1b2bcc9e74ece1dfbd09a5c89256 /libavcodec/wmavoice.c
parent7b27dd5c16de785297ce4de4b88afa0b6685f61d (diff)
wmavoice: protect against zero-energy in adaptive gain control.
Otherwise the scale factor becomes NaN, resulting in corrupt output. Fixes #5426.
Diffstat (limited to 'libavcodec/wmavoice.c')
-rw-r--r--libavcodec/wmavoice.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c
index 90dfe20240..cd5958c7bc 100644
--- a/libavcodec/wmavoice.c
+++ b/libavcodec/wmavoice.c
@@ -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;