From 48f2568d89c09c4363040cfc3cb63a1df0121955 Mon Sep 17 00:00:00 2001 From: "bjornv@webrtc.org" Date: Wed, 3 Sep 2014 07:58:37 +0000 Subject: [PATCH] audio_processing/nsx: Bug fix that could cause divide by zero In the fixed point version of the Noise Suppression. At one place we subtract a value in the wrong Q-domain, which later may cause a divide by zero. Going through the floating point code that particular variable should be zero if this happens, which is what the old code tried to accomplish, but in an awkward way. The bug has been there since development, so the likelihood of actually get a divide by zero is very small. BUG=chromium:407812 R=ljubomir.papuga@gmail.com, tina.legrand@webrtc.org Review URL: https://webrtc-codereview.appspot.com/17229004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7035 4adac7df-926f-26a2-2b94-8c16560cd09d --- webrtc/modules/audio_processing/ns/nsx_core_c.c | 2 +- webrtc/modules/audio_processing/ns/nsx_core_mips.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/webrtc/modules/audio_processing/ns/nsx_core_c.c b/webrtc/modules/audio_processing/ns/nsx_core_c.c index b50d4f8588..4472583f17 100644 --- a/webrtc/modules/audio_processing/ns/nsx_core_c.c +++ b/webrtc/modules/audio_processing/ns/nsx_core_c.c @@ -48,7 +48,7 @@ void WebRtcNsx_SpeechNoiseProb(NsxInst_t* inst, if (den > 0) { besselTmpFX32 -= num / den; // Q11 } else { - besselTmpFX32 -= num; // Q11 + besselTmpFX32 = 0; } // inst->logLrtTimeAvg[i] += LRT_TAVG * (besselTmp - log(snrLocPrior) diff --git a/webrtc/modules/audio_processing/ns/nsx_core_mips.c b/webrtc/modules/audio_processing/ns/nsx_core_mips.c index 29abe93f2f..0671627541 100644 --- a/webrtc/modules/audio_processing/ns/nsx_core_mips.c +++ b/webrtc/modules/audio_processing/ns/nsx_core_mips.c @@ -74,6 +74,7 @@ void WebRtcNsx_SpeechNoiseProb(NsxInst_t* inst, "sra %[r7], %[r7], 19 \n\t" "movz %[r3], %[r8], %[r6] \n\t" "subu %[r0], %[r0], %[r3] \n\t" + "movn %[r0], $0, %[r6] \n\t" "mul %[r1], %[r1], %[const_5412] \n\t" "sra %[r1], %[r1], 12 \n\t" "addu %[r7], %[r7], %[r1] \n\t"