[FFmpeg-cvslog] wmavoice: protect against zero-energy in adaptive gain control.
Ronald S. Bultje
git at videolan.org
Tue Dec 27 17:04:00 EET 2016
ffmpeg | branch: master | Ronald S. Bultje <rsbultje at gmail.com> | Tue Dec 20 18:01:05 2016 -0500| [33d7f822f8ed2d1870babc1d04d4d48cf8b6f240] | committer: Ronald S. Bultje
wmavoice: protect against zero-energy in adaptive gain control.
Otherwise the scale factor becomes NaN, resulting in corrupt output.
Fixes #5426.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=33d7f822f8ed2d1870babc1d04d4d48cf8b6f240
---
libavcodec/wmavoice.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c
index 90dfe20..cd5958c 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;
More information about the ffmpeg-cvslog
mailing list