From ac7ec88246bdd2004a6b43a22af90a6db2078d0f Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 4 Oct 2024 19:10:24 +0530 Subject: [PATCH] Fix for EVS encoder crashes (asserts) for 8 kHz input --- lib_com/tools_fx.c | 2 +- lib_enc/fd_cng_enc_fx.c | 2 +- lib_enc/spec_flatness_fx.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c index 88f0a896f..3015cdf21 100644 --- a/lib_com/tools_fx.c +++ b/lib_com/tools_fx.c @@ -3519,7 +3519,7 @@ Word16 erb_diff_search_fx( Word16 *prev_erb, const Word16 *curr_erb, Word16 *dif Lacc = L_deposit_l( 0 ); FOR( i = 0; i < cb_dim; i++ ) { - IF( add( cb_fx[j * cb_dim + i], prev_erb[i + offset] ) < 0 ) + IF( add_sat( cb_fx[j * cb_dim + i], prev_erb[i + offset] ) < 0 ) { Ltemp1 = L_mult( curr_erb[i + offset], curr_erb[i + offset] ); /* Q27 */ dh = extract_h( Ltemp1 ); diff --git a/lib_enc/fd_cng_enc_fx.c b/lib_enc/fd_cng_enc_fx.c index a2644946b..8ef56f72f 100644 --- a/lib_enc/fd_cng_enc_fx.c +++ b/lib_enc/fd_cng_enc_fx.c @@ -2128,7 +2128,7 @@ Word16 cng_energy_fx( L_tmp = L_mult0( tmp16, tmp16 ); pt_res++; tmp16 = shl( *pt_res, scale ); - L_tmp = L_mac0( L_tmp, tmp16, tmp16 ); /* 2*(Q_new+scale) */ + L_tmp = L_mac0_sat( L_tmp, tmp16, tmp16 ); /* 2*(Q_new+scale) */ pt_res++; L_ener = L_add( L_ener, L_shr( L_tmp, 7 ) ); /* 2*(Q_new+scale)+1, divide by L_frame done here */ } diff --git a/lib_enc/spec_flatness_fx.c b/lib_enc/spec_flatness_fx.c index 271f7ba1b..2ee10bf06 100644 --- a/lib_enc/spec_flatness_fx.c +++ b/lib_enc/spec_flatness_fx.c @@ -133,7 +133,7 @@ void spec_flatness_fx( SFM_Qtmp = sub( SFM_Qtmp, SPEC_AMP_Q ); SFM_Qtmp = sub( SFM_Qtmp, SFM_Q ); - sSFM[0] = add( mult( sSFM[0], 0x6ccc ), shr( mult( SFM, 0x1333 ), SFM_Qtmp ) ); + sSFM[0] = add_sat( mult( sSFM[0], 0x6ccc ), shr( mult( SFM, 0x1333 ), SFM_Qtmp ) ); move16(); /*sSFM2*/ -- GitLab