shithub: opus

Download patch

ref: 37aba6e9b382f7dbdb7916adbc335704cf2992e8
parent: 66d060c7734c9b780d0183f6565d474fc246b84b
author: Tom Denton <tomdenton@google.com>
date: Mon Feb 7 11:34:41 EST 2022

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>

--- a/silk/NSQ.c
+++ b/silk/NSQ.c
@@ -262,7 +262,7 @@
         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++;