aboutsummaryrefslogtreecommitdiff
path: root/silk
diff options
context:
space:
mode:
authorFelicia Lim <flim@google.com>2016-06-04 10:10:52 -0400
committerJean-Marc Valin <jmvalin@jmvalin.ca>2016-06-04 10:12:30 -0400
commit5ead149cf49cc8d2fd0e1fb3c7cd564ecbbce100 (patch)
tree19cd0fc41bbbf94eee2c6244639569e02a983358 /silk
parente26abfaca8fef5188abb9f65b72ddf8b087486cd (diff)
downloadlibopus-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.c3
-rw-r--r--silk/decode_core.c2
2 files changed, 3 insertions, 2 deletions
diff --git a/silk/PLC.c b/silk/PLC.c
index 34a94bc3..fb6ea887 100644
--- a/silk/PLC.c
+++ b/silk/PLC.c
@@ -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 ) );