diff options
author | Felicia Lim <flim@google.com> | 2016-06-04 10:10:52 -0400 |
---|---|---|
committer | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2016-06-04 10:12:30 -0400 |
commit | 5ead149cf49cc8d2fd0e1fb3c7cd564ecbbce100 (patch) | |
tree | 19cd0fc41bbbf94eee2c6244639569e02a983358 /silk | |
parent | e26abfaca8fef5188abb9f65b72ddf8b087486cd (diff) | |
download | opus-5ead149cf49cc8d2fd0e1fb3c7cd564ecbbce100.tar.gz |
Saturate when adding prediction to LPC excitation to avoid integer overflow
Slightly modified by Jean-Marc Valin
Signed-off-by: Jean-Marc Valin <jmvalin@jmvalin.ca>
Diffstat (limited to 'silk')
-rw-r--r-- | silk/PLC.c | 3 | ||||
-rw-r--r-- | silk/decode_core.c | 2 |
2 files changed, 3 insertions, 2 deletions
@@ -365,7 +365,8 @@ static OPUS_INLINE void silk_PLC_conceal( } /* Add prediction to LPC excitation */ - sLPC_Q14_ptr[ MAX_LPC_ORDER + i ] = silk_ADD_LSHIFT32( sLPC_Q14_ptr[ MAX_LPC_ORDER + i ], LPC_pred_Q10, 4 ); + sLPC_Q14_ptr[ MAX_LPC_ORDER + i ] = silk_ADD_SAT32( sLPC_Q14_ptr[ MAX_LPC_ORDER + i ], + silk_LSHIFT_SAT32( LPC_pred_Q10, 4 )); /* Scale with Gain */ frame[ i ] = (opus_int16)silk_SAT16( silk_SAT16( silk_RSHIFT_ROUND( silk_SMULWW( sLPC_Q14_ptr[ MAX_LPC_ORDER + i ], prevGain_Q10[ 1 ] ), 8 ) ) ); diff --git a/silk/decode_core.c b/silk/decode_core.c index b88991e3..e569c0e7 100644 --- a/silk/decode_core.c +++ b/silk/decode_core.c @@ -219,7 +219,7 @@ void silk_decode_core( } /* Add prediction to LPC excitation */ - sLPC_Q14[ MAX_LPC_ORDER + i ] = silk_ADD_LSHIFT32( pres_Q14[ i ], LPC_pred_Q10, 4 ); + sLPC_Q14[ MAX_LPC_ORDER + i ] = silk_ADD_SAT32( pres_Q14[ i ], silk_LSHIFT_SAT32( LPC_pred_Q10, 4 ) ); /* Scale with gain */ pxq[ i ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( silk_SMULWW( sLPC_Q14[ MAX_LPC_ORDER + i ], Gain_Q10 ), 8 ) ); |