Index: silk/fixed/schur_FIX.c |
diff --git a/silk/fixed/schur_FIX.c b/silk/fixed/schur_FIX.c |
index 43db5018bbbbd9d53eae668211aaf3c7c40bb53b..c4c0ef23b47804e5f56c7c5d58c66556eef5a01e 100644 |
--- a/silk/fixed/schur_FIX.c |
+++ b/silk/fixed/schur_FIX.c |
@@ -8,11 +8,11 @@ this list of conditions and the following disclaimer. |
- Redistributions in binary form must reproduce the above copyright |
notice, this list of conditions and the following disclaimer in the |
documentation and/or other materials provided with the distribution. |
-- Neither the name of Internet Society, IETF or IETF Trust, nor the |
+- Neither the name of Internet Society, IETF or IETF Trust, nor the |
names of specific contributors, may be used to endorse or promote |
products derived from this software without specific prior written |
permission. |
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” |
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
@@ -68,6 +68,16 @@ opus_int32 silk_schur( /* O Returns residual ene |
} |
for( k = 0; k < order; k++ ) { |
+ /* Check that we won't be getting an unstable rc, otherwise stop here. */ |
+ if (silk_abs_int32(C[ k + 1 ][ 0 ]) >= C[ 0 ][ 1 ]) { |
+ if ( C[ k + 1 ][ 0 ] > 0 ) { |
+ rc_Q15[ k ] = -SILK_FIX_CONST( .99f, 15 ); |
+ } else { |
+ rc_Q15[ k ] = SILK_FIX_CONST( .99f, 15 ); |
+ } |
+ k++; |
+ break; |
+ } |
/* Get reflection coefficient */ |
rc_tmp_Q15 = -silk_DIV32_16( C[ k + 1 ][ 0 ], silk_max_32( silk_RSHIFT( C[ 0 ][ 1 ], 15 ), 1 ) ); |
@@ -87,6 +97,10 @@ opus_int32 silk_schur( /* O Returns residual ene |
} |
} |
+ for(; k < order; k++ ) { |
+ rc_Q15[ k ] = 0; |
+ } |
+ |
/* return residual energy */ |
- return C[ 0 ][ 1 ]; |
+ return silk_max_32( 1, C[ 0 ][ 1 ] ); |
} |