summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelicia Lim <flim@google.com>2016-03-18 08:52:05 +0800
committerKoen Vos <koenvos@users.noreply.github.com>2016-03-18 08:52:05 +0800
commit43539f74b37cb0ff112267d3f4ebab3ce4ce7dff (patch)
tree96707319bdaa0165c88012072bf5cc116d92ee15
parent403b1f736646fd946c3e0577c763856cc5aaee31 (diff)
downloadopus-silk_tunings.tar.gz
fix for divide by zerosilk_tunings
-rw-r--r--silk/fixed/burg_modified_FIX.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/silk/fixed/burg_modified_FIX.c b/silk/fixed/burg_modified_FIX.c
index 9c35c94c..53d92fa1 100644
--- a/silk/fixed/burg_modified_FIX.c
+++ b/silk/fixed/burg_modified_FIX.c
@@ -219,12 +219,14 @@ void silk_burg_modified_c(
/* Max prediction gain exceeded; set reflection coefficient such that max prediction gain is exactly hit */
tmp2 = SILK_FIX_CONST( 1, 30 ) - silk_DIV32_varQ( minInvGain_Q30, invGain_Q30, 30 ); /* Q30 */
rc_Q31 = silk_SQRT_APPROX( tmp2 ); /* Q15 */
- /* Newton-Raphson iteration */
- rc_Q31 = silk_RSHIFT32( rc_Q31 + silk_DIV32( tmp2, rc_Q31 ), 1 ); /* Q15 */
- rc_Q31 = silk_LSHIFT32( rc_Q31, 16 ); /* Q31 */
- if( num < 0 ) {
- /* Ensure adjusted reflection coefficients has the original sign */
- rc_Q31 = -rc_Q31;
+ if( rc_Q31 > 0 ) {
+ /* Newton-Raphson iteration */
+ rc_Q31 = silk_RSHIFT32( rc_Q31 + silk_DIV32( tmp2, rc_Q31 ), 1 ); /* Q15 */
+ rc_Q31 = silk_LSHIFT32( rc_Q31, 16 ); /* Q31 */
+ if( num < 0 ) {
+ /* Ensure adjusted reflection coefficients has the original sign */
+ rc_Q31 = -rc_Q31;
+ }
}
invGain_Q30 = minInvGain_Q30;
reached_max_gain = 1;