From 37aba6e9b382f7dbdb7916adbc335704cf2992e8 Mon Sep 17 00:00:00 2001 From: Tom Denton <tomdenton@google.com> Date: Mon, 7 Feb 2022 16:34:41 -0800 Subject: [PATCH] Prevent int32 overflow when applying HARM FIR filter in NSQ.c by using a saturating sum. This matches behavior in NSQ_del_dec.c. Signed-off-by: Jean-Marc Valin <jmvalin@jmvalin.ca> --- silk/NSQ.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/silk/NSQ.c b/silk/NSQ.c index 1d64d8e25..ab8f9b6ce 100644 --- a/silk/NSQ.c +++ b/silk/NSQ.c @@ -262,7 +262,7 @@ void silk_noise_shape_quantizer( tmp1 = silk_SUB32( tmp1, n_LF_Q12 ); /* Q12 */ if( lag > 0 ) { /* Symmetric, packed FIR coefficients */ - n_LTP_Q13 = silk_SMULWB( silk_ADD32( shp_lag_ptr[ 0 ], shp_lag_ptr[ -2 ] ), HarmShapeFIRPacked_Q14 ); + n_LTP_Q13 = silk_SMULWB( silk_ADD_SAT32( shp_lag_ptr[ 0 ], shp_lag_ptr[ -2 ] ), HarmShapeFIRPacked_Q14 ); n_LTP_Q13 = silk_SMLAWT( n_LTP_Q13, shp_lag_ptr[ -1 ], HarmShapeFIRPacked_Q14 ); n_LTP_Q13 = silk_LSHIFT( n_LTP_Q13, 1 ); shp_lag_ptr++; -- GitLab