Skip to content
Snippets Groups Projects
Commit 02f3ac22 authored by Felicia Lim's avatar Felicia Lim Committed by Jean-Marc Valin
Browse files

fix for divide by zero

parent c43b1bc8
No related branches found
No related tags found
No related merge requests found
...@@ -200,12 +200,14 @@ void silk_burg_modified_c( ...@@ -200,12 +200,14 @@ void silk_burg_modified_c(
/* Max prediction gain exceeded; set reflection coefficient such that max prediction gain is exactly hit */ /* Max prediction gain exceeded; set reflection coefficient such that max prediction gain is exactly hit */
tmp2 = ( (opus_int32)1 << 30 ) - silk_DIV32_varQ( minInvGain_Q30, invGain_Q30, 30 ); /* Q30 */ tmp2 = ( (opus_int32)1 << 30 ) - silk_DIV32_varQ( minInvGain_Q30, invGain_Q30, 30 ); /* Q30 */
rc_Q31 = silk_SQRT_APPROX( tmp2 ); /* Q15 */ rc_Q31 = silk_SQRT_APPROX( tmp2 ); /* Q15 */
/* Newton-Raphson iteration */ if( rc_Q31 > 0 ) {
rc_Q31 = silk_RSHIFT32( rc_Q31 + silk_DIV32( tmp2, rc_Q31 ), 1 ); /* Q15 */ /* Newton-Raphson iteration */
rc_Q31 = silk_LSHIFT32( rc_Q31, 16 ); /* Q31 */ rc_Q31 = silk_RSHIFT32( rc_Q31 + silk_DIV32( tmp2, rc_Q31 ), 1 ); /* Q15 */
if( num < 0 ) { rc_Q31 = silk_LSHIFT32( rc_Q31, 16 ); /* Q31 */
/* Ensure adjusted reflection coefficients has the original sign */ if( num < 0 ) {
rc_Q31 = -rc_Q31; /* Ensure adjusted reflection coefficients has the original sign */
rc_Q31 = -rc_Q31;
}
} }
invGain_Q30 = minInvGain_Q30; invGain_Q30 = minInvGain_Q30;
reached_max_gain = 1; reached_max_gain = 1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment