Skip to content
Snippets Groups Projects
Commit 7252c258 authored by Jean-Marc Valin's avatar Jean-Marc Valin
Browse files

Fixes signed integer overflow in fixed-point Burg

We just explicitly allow the overflow with silk_MLA_ovflw() since the result
seems to be correct because the overflows cancel each other.
parent ddea3a6f
No related branches found
No related tags found
No related merge requests found
...@@ -150,8 +150,11 @@ void silk_burg_modified_c( ...@@ -150,8 +150,11 @@ void silk_burg_modified_c(
C_first_row[ k ] = silk_MLA( C_first_row[ k ], x1, x_ptr[ n - k - 1 ] ); /* Q( -rshifts ) */ C_first_row[ k ] = silk_MLA( C_first_row[ k ], x1, x_ptr[ n - k - 1 ] ); /* Q( -rshifts ) */
C_last_row[ k ] = silk_MLA( C_last_row[ k ], x2, x_ptr[ subfr_length - n + k ] ); /* Q( -rshifts ) */ C_last_row[ k ] = silk_MLA( C_last_row[ k ], x2, x_ptr[ subfr_length - n + k ] ); /* Q( -rshifts ) */
Atmp1 = silk_RSHIFT_ROUND( Af_QA[ k ], QA - 17 ); /* Q17 */ Atmp1 = silk_RSHIFT_ROUND( Af_QA[ k ], QA - 17 ); /* Q17 */
tmp1 = silk_MLA( tmp1, x_ptr[ n - k - 1 ], Atmp1 ); /* Q17 */ /* We sometimes have get overflows in the multiplications (even beyond +/- 2^32),
tmp2 = silk_MLA( tmp2, x_ptr[ subfr_length - n + k ], Atmp1 ); /* Q17 */ but they cancel each other and the real result seems to always fit in a 32-bit
signed integer. This was determined experimentally, not theoretically (unfortunately). */
tmp1 = silk_MLA_ovflw( tmp1, x_ptr[ n - k - 1 ], Atmp1 ); /* Q17 */
tmp2 = silk_MLA_ovflw( tmp2, x_ptr[ subfr_length - n + k ], Atmp1 ); /* Q17 */
} }
tmp1 = -tmp1; /* Q17 */ tmp1 = -tmp1; /* Q17 */
tmp2 = -tmp2; /* Q17 */ tmp2 = -tmp2; /* Q17 */
......
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