summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--silk/sum_sqr_shift.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/silk/sum_sqr_shift.c b/silk/sum_sqr_shift.c
index e387391a..43c6b5aa 100644
--- a/silk/sum_sqr_shift.c
+++ b/silk/sum_sqr_shift.c
@@ -70,6 +70,11 @@ void silk_sum_sqr_shift(
/* One sample left to process */
nrg_tmp = silk_SMULBB( x[ i ], x[ i ] );
nrg = (opus_int32)silk_ADD_RSHIFT_uint( nrg, nrg_tmp, shft );
+ if( nrg < 0 ) {
+ /* Scale down */
+ nrg = (opus_int32)silk_RSHIFT_uint( (opus_uint32)nrg, 1 );
+ shft++;
+ }
}
/* Make sure to have at least 10% headroom */