diff --git a/lib_com/options.h b/lib_com/options.h index 4ad75910ccfd9e2908872e25569f51fc7310c2d8..e2543337aa061e9ea20e66049a42f81efd36c405 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -117,6 +117,9 @@ #define NONBE_FIX_ISM_XOVER_BR /* FhG: issue 1072: select OSBA coding method depending on number of object and bitrate */ #define FIX_1053_REVERB_RECONFIGURATION /* Philips: issue 1053: fix for dynamic switching of acoustic environment */ #define CONF_DISTATT /* Eri: Make distance attenuation configurable */ + +#define ISSUE_1866_replace_overflow_libdec /* FhG: BE - Replace BASOPoverflow operators all over the lib_dec module if Overflow result is not used*/ + #define FIX_1068_ASAN_IN_MC_2_BINAURAL_ROOM_IR /* issue 1068 : Memory leak in MC to BINAURAL_ROOM decoding with bitrate switching*/ #define NONBE_FIX_1052_SBA_EXT /* Dlb: SBA external output support */ #define NONBE_FIX_MC_LFE_LPF /* Dlb: Adding the LFE LPF filter back for MC content. */ diff --git a/lib_dec/FEC_HQ_core_fx.c b/lib_dec/FEC_HQ_core_fx.c index 1be7453ab9492386fa762903658b5ff6c66921bc..06028d6011b674a6cb68ecc935db3a6c06afea06 100644 --- a/lib_dec/FEC_HQ_core_fx.c +++ b/lib_dec/FEC_HQ_core_fx.c @@ -43,7 +43,7 @@ static void Regression_Anal_fx( Word32 L_tmp1, L_tmp2; Word16 aindex_fx[MAX_PGF + 1]; // Q0 Word32 b_p_fx[MAX_PGF + 1]; // Q10 -#ifndef ISSUE_1796_replace_shl_o +#ifndef ISSUE_1866_replace_overflow_libdec #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); @@ -80,8 +80,8 @@ static void Regression_Anal_fx( { b_p_fx[0] = L_add( b_p_fx[0], L_shr( values_fx[i], 2 ) ); /*10 */ move32(); -#ifdef ISSUE_1796_replace_shl_o - b_p_fx[1] = L_add( b_p_fx[1], Mult_32_16( values_fx[i], shl_sat( sub( num_pgf, i ), 13 ) ) ); /*10 */ +#ifdef ISSUE_1866_replace_overflow_libdec + b_p_fx[1] = L_add( b_p_fx[1], Mult_32_16( values_fx[i], shl_sat( sub( num_pgf, i ), 13 ) ) ); /*10 */ //??sat #else b_p_fx[1] = L_add( b_p_fx[1], Mult_32_16( values_fx[i], shl_o( sub( num_pgf, i ), 13, &Overflow ) ) ); /*10 */ #endif @@ -168,7 +168,7 @@ void HQ_FEC_processing_fx( Word16 energy_diff_fx; // Q10 HQ_NBFEC_HANDLE hHQ_nbfec; HQ_DEC_HANDLE hHQ_core; -#ifndef ISSUE_1796_replace_shl_o +#ifndef ISSUE_1866_replace_overflow_libdec #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); @@ -390,8 +390,8 @@ void HQ_FEC_processing_fx( FOR( j = 0; j < Num_bands_p[i]; j++ ) { -#ifdef ISSUE_1796_replace_shl_o - hHQ_nbfec->Norm_gain_fx[k] = shl_sat( tmp_fx, 1 ); +#ifdef ISSUE_1866_replace_overflow_libdec + hHQ_nbfec->Norm_gain_fx[k] = shl_sat( tmp_fx, 1 ); //??sat #else hHQ_nbfec->Norm_gain_fx[k] = shl_o( tmp_fx, 1, &Overflow ); #endif @@ -449,9 +449,11 @@ void ivas_HQ_FEC_Mem_update_fx( HQ_DEC_HANDLE hHQ_core; hHQ_nbfec = st_fx->hHQ_nbfec; hHQ_core = st_fx->hHQ_core; +#ifndef ISSUE_1866_replace_overflow_libdec #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif move32(); // for tmp_energy_fx IF( EQ_16( output_frame, L_FRAME8k ) ) @@ -530,8 +532,8 @@ void ivas_HQ_FEC_Mem_update_fx( L_tmp = L_add( L_tmp, L_shr( normq_fx[k], 3 ) ); /*11*/ k = add( k, 1 ); } -#ifdef ISSUE_1796_replace_shl_o - tmp_fx = shl_sat( inv_tbl_fx[Num_bands_p[i]], 1 ); /*16*/ +#ifdef ISSUE_1866_replace_overflow_libdec + tmp_fx = shl_sat( inv_tbl_fx[Num_bands_p[i]], 1 ); /*16*/ //??sat #else tmp_fx = shl_o( inv_tbl_fx[Num_bands_p[i]], 1, &Overflow ); /*16*/ #endif @@ -654,7 +656,11 @@ void ivas_HQ_FEC_Mem_update_fx( exp2 = norm_l( hHQ_nbfec->ynrm_values_fx[i][0] ); tmp_fx = div_s( extract_h( L_shl( en_high_fx[i], exp1 ) ), extract_h( L_shl( hHQ_nbfec->ynrm_values_fx[i][0], exp2 ) ) ); exp = add( 15, sub( exp1, exp2 ) ); +#ifdef ISSUE_1866_replace_overflow_libdec + *mean_en_high_fx = add_sat( *mean_en_high_fx, shr_sat( tmp_fx, sub( exp, 5 ) ) ); //??sat +#else *mean_en_high_fx = add_o( *mean_en_high_fx, shr_sat( tmp_fx, sub( exp, 5 ) ), &Overflow ); +#endif move16(); } *mean_en_high_fx = mult( *mean_en_high_fx, inv_tbl_fx[sub( num_Sb, k )] ); @@ -736,9 +742,11 @@ void HQ_FEC_Mem_update_fx( HQ_DEC_HANDLE hHQ_core; hHQ_nbfec = st_fx->hHQ_nbfec; hHQ_core = st_fx->hHQ_core; +#ifndef ISSUE_1866_replace_overflow_libdec #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif move32(); // tmp_energy_fx @@ -819,8 +827,8 @@ void HQ_FEC_Mem_update_fx( L_tmp = L_add( L_tmp, L_shr( normq_fx[k], 3 ) ); /*11*/ k = add( k, 1 ); } -#ifdef ISSUE_1796_replace_shl_o - tmp_fx = shl_sat( inv_tbl_fx[Num_bands_p[i]], 1 ); /*16*/ +#ifdef ISSUE_1866_replace_overflow_libdec + tmp_fx = shl_sat( inv_tbl_fx[Num_bands_p[i]], 1 ); /*16*/ //??sat #else tmp_fx = shl_o( inv_tbl_fx[Num_bands_p[i]], 1, &Overflow ); /*16*/ #endif @@ -944,7 +952,11 @@ void HQ_FEC_Mem_update_fx( exp2 = norm_l( hHQ_nbfec->ynrm_values_fx[i][0] ); tmp_fx = div_s( extract_h( L_shl( en_high_fx[i], exp1 ) ), extract_h( L_shl( hHQ_nbfec->ynrm_values_fx[i][0], exp2 ) ) ); exp = add( 15, sub( exp1, exp2 ) ); +#ifdef ISSUE_1866_replace_overflow_libdec + *mean_en_high_fx = add_sat( *mean_en_high_fx, shr_sat( tmp_fx, sub( exp, 5 ) ) ); //??sat +#else *mean_en_high_fx = add_o( *mean_en_high_fx, shr_sat( tmp_fx, sub( exp, 5 ) ), &Overflow ); +#endif move16(); } *mean_en_high_fx = mult( *mean_en_high_fx, inv_tbl_fx[sub( num_Sb, k )] ); @@ -1015,7 +1027,7 @@ static Word16 find_best_delay_fx( Word32 min_sq_cross_fx, min_corr_fx; Word32 accA_fx, accB_fx; Word32 Rxy_fx[MAXDELAY_FEC], Ryy_fx[MAXDELAY_FEC]; -#ifndef ISSUE_1796_replace_shl_o +#ifndef ISSUE_1866_replace_overflow_libdec #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); @@ -1086,10 +1098,10 @@ static Word16 find_best_delay_fx( L_tmp1 = L_shl( min_sq_cross_fx, exp1 ); L_tmp2 = L_shl( min_corr_fx, exp2 ); tmp = div_s( extract_h( L_tmp1 ), extract_h( L_tmp2 ) ); /*15 + exp1 - exp2 */ -#ifdef ISSUE_1796_replace_shl_o - tmp = shl_sat( tmp, sub( exp2, add( exp1, 1 ) ) ); /*14 */ +#ifdef ISSUE_1866_replace_overflow_libdec + tmp = shl_sat( tmp, sub( exp2, add( exp1, 1 ) ) ); /*14 */ //??sat #else - tmp = shl_o( tmp, sub( exp2, add( exp1, 1 ) ), &Overflow ); /*14 */ + tmp = shl_o( tmp, sub( exp2, add( exp1, 1 ) ), &Overflow ); /*14 */ #endif } diff --git a/lib_dec/FEC_HQ_phase_ecu_fx.c b/lib_dec/FEC_HQ_phase_ecu_fx.c index 5cb2c99dc63be84a1a2f5c060d6206b5ef741c66..b145a3aaea8455a547601b33f8aad9e6e61984cb 100644 --- a/lib_dec/FEC_HQ_phase_ecu_fx.c +++ b/lib_dec/FEC_HQ_phase_ecu_fx.c @@ -2916,13 +2916,20 @@ static Word32 mult_32_32_q( const Word32 a, const Word32 b, const Word16 q ) { Word32 hi; UWord32 lo; +#ifndef ISSUE_1866_replace_overflow_libdec #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); #endif + Mpy_32_32_ss( a, b, &hi, &lo ); return L_or( L_shl_o( hi, sub( 32 - 1, q ), &Overflow ), L_lshr( (Word32) lo, add( q, 1 ) ) ); +#else + Mpy_32_32_ss( a, b, &hi, &lo ); + + return L_or( L_shl_sat( hi, sub( 32 - 1, q ) ), L_lshr( (Word32) lo, add( q, 1 ) ) ); //??sat +#endif } static void fir_dwn_fx( diff --git a/lib_dec/FEC_fx.c b/lib_dec/FEC_fx.c index 78594558b78dae073e4c787fe15fec99d45478cd..4343c3edc7a32f90c4330b4fe896bf30516d658a 100644 --- a/lib_dec/FEC_fx.c +++ b/lib_dec/FEC_fx.c @@ -95,9 +95,11 @@ void FEC_exc_estim_fx( Word32 cond3; Word32 predPitchLag; GSC_DEC_HANDLE hGSCDec; +#ifndef ISSUE_1866_replace_overflow_libdec #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif hGSCDec = st_fx->hGSCDec; @@ -126,7 +128,7 @@ void FEC_exc_estim_fx( gainCNG = round_fx( L_shl( L_tmp, sub( exp, 12 ) ) ); /* In Q3 */ } -#ifdef ISSUE_1796_replace_shl_o +#ifdef ISSUE_1866_replace_overflow_libdec tmp1 = shl_sat( st_fx->lp_gainc_fx, 1 ); #else tmp1 = shl_o( st_fx->lp_gainc_fx, 1, &Overflow ); @@ -191,10 +193,10 @@ void FEC_exc_estim_fx( { test(); test(); -#ifdef ISSUE_1796_replace_shl_o - IF( ( LT_16( round_fx( L_shl( st_fx->old_pitch_buf_fx[2 * NB_SUBFR - 1], 6 ) ), shl_sat( mult( 29491, st_fx->bfi_pitch_fx ), 1 ) ) && - GT_16( round_fx( L_shl( st_fx->old_pitch_buf_fx[2 * NB_SUBFR - 1], 6 ) ), mult( 19661, st_fx->bfi_pitch_fx ) ) ) || /* last pitch coherent with the past */ - GE_16( st_fx->upd_cnt, MAX_UPD_CNT ) ) /* or last update too far in the past */ +#ifdef ISSUE_1866_replace_overflow_libdec + IF( ( LT_16( round_fx( L_shl( st_fx->old_pitch_buf_fx[2 * NB_SUBFR - 1], 6 ) ), shl_sat( mult( 29491, st_fx->bfi_pitch_fx ), 1 ) ) && //??sat + GT_16( round_fx( L_shl( st_fx->old_pitch_buf_fx[2 * NB_SUBFR - 1], 6 ) ), mult( 19661, st_fx->bfi_pitch_fx ) ) ) || /* last pitch coherent with the past */ + GE_16( st_fx->upd_cnt, MAX_UPD_CNT ) ) /* or last update too far in the past */ #else IF( ( LT_16( round_fx( L_shl( st_fx->old_pitch_buf_fx[2 * NB_SUBFR - 1], 6 ) ), shl_o( mult( 29491, st_fx->bfi_pitch_fx ), 1, &Overflow ) ) && GT_16( round_fx( L_shl( st_fx->old_pitch_buf_fx[2 * NB_SUBFR - 1], 6 ) ), mult( 19661, st_fx->bfi_pitch_fx ) ) ) || /* last pitch coherent with the past */ @@ -210,10 +212,10 @@ void FEC_exc_estim_fx( { test(); test(); -#ifdef ISSUE_1796_replace_shl_o - IF( ( LT_16( round_fx( L_shl( st_fx->old_pitch_buf_fx[2 * NB_SUBFR16k - 1], 6 ) ), shl_sat( mult( 29491, st_fx->bfi_pitch_fx ), 1 ) ) && - GT_16( round_fx( L_shl( st_fx->old_pitch_buf_fx[2 * NB_SUBFR16k - 1], 6 ) ), mult( 19661, st_fx->bfi_pitch_fx ) ) ) || /* last pitch coherent with the past */ - GE_16( st_fx->upd_cnt, MAX_UPD_CNT ) ) /* or last update too far in the past */ +#ifdef ISSUE_1866_replace_overflow_libdec + IF( ( LT_16( round_fx( L_shl( st_fx->old_pitch_buf_fx[2 * NB_SUBFR16k - 1], 6 ) ), shl_sat( mult( 29491, st_fx->bfi_pitch_fx ), 1 ) ) && //??sat + GT_16( round_fx( L_shl( st_fx->old_pitch_buf_fx[2 * NB_SUBFR16k - 1], 6 ) ), mult( 19661, st_fx->bfi_pitch_fx ) ) ) || /* last pitch coherent with the past */ + GE_16( st_fx->upd_cnt, MAX_UPD_CNT ) ) /* or last update too far in the past */ #else IF( ( LT_16( round_fx( L_shl( st_fx->old_pitch_buf_fx[2 * NB_SUBFR16k - 1], 6 ) ), shl_o( mult( 29491, st_fx->bfi_pitch_fx ), 1, &Overflow ) ) && GT_16( round_fx( L_shl( st_fx->old_pitch_buf_fx[2 * NB_SUBFR16k - 1], 6 ) ), mult( 19661, st_fx->bfi_pitch_fx ) ) ) || /* last pitch coherent with the past */ @@ -313,7 +315,11 @@ void FEC_exc_estim_fx( IF( LE_16( st_fx->nbLostCmpt, 1 ) ) { /* if stable, do not decrease the energy, pitch_gain = 0 */ - alpha = mac_ro( ( 1L << 16 ) * 2 * _ALPHA_U_FX, st_fx->stab_fac_fx, 32768 - 2 * _ALPHA_U_FX, &Overflow ); /*st_fx->stab_fac_fx in Q15*/ +#ifdef ISSUE_1866_replace_overflow_libdec + alpha = mac_r_sat( ( 1L << 16 ) * 2 * _ALPHA_U_FX, st_fx->stab_fac_fx, 32768 - 2 * _ALPHA_U_FX ); /*st_fx->stab_fac_fx in Q15*/ //??sat +#else + alpha = mac_ro( ( 1L << 16 ) * 2 * _ALPHA_U_FX, st_fx->stab_fac_fx, 32768 - 2 * _ALPHA_U_FX, &Overflow ); /*st_fx->stab_fac_fx in Q15*/ +#endif } ELSE IF( EQ_16( st_fx->nbLostCmpt, 2 ) ) { @@ -362,7 +368,11 @@ void FEC_exc_estim_fx( L_tmp = L_deposit_h( tmp ); L_tmp = Isqrt_lc( L_tmp, &exp ); +#ifdef ISSUE_1866_replace_overflow_libdec + gain = extract_h( L_shl_sat( L_tmp, exp ) ); //??sat +#else gain = extract_h( L_shl_o( L_tmp, exp, &Overflow ) ); +#endif gain = s_min( gain, 32113 ); /*0.98 */ gain = s_max( gain, 27853 ); /*0.85 */ @@ -768,7 +778,7 @@ static void pulseRes_preCalc( Word16 *cond1, Word16 *cond2, Word32 *cond3, Word1 { Word16 tmp_pit, tmp_pit_e, tmp_frame, tmp_frame_e; Word32 tmp_pit2; -#ifndef ISSUE_1796_replace_shl_o +#ifndef ISSUE_1866_replace_overflow_libdec #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); @@ -782,8 +792,8 @@ static void pulseRes_preCalc( Word16 *cond1, Word16 *cond2, Word32 *cond3, Word1 tmp_frame = sub( 32767 /*1.f Q15*/, tmp_frame ); /*Q15*/ BASOP_SATURATE_WARNING_OFF_EVS /*To calc Q15 threshold, overflow may happen - do negation and compare with negated value to check also highest possible value*/ -#ifdef ISSUE_1796_replace_shl_o - tmp_pit = shl_sat( negate( tmp_pit ), tmp_pit_e ); +#ifdef ISSUE_1866_replace_overflow_libdec + tmp_pit = shl_sat( negate( tmp_pit ), tmp_pit_e ); //??sat #else tmp_pit = shl_o( negate( tmp_pit ), tmp_pit_e, &Overflow ); #endif diff --git a/lib_dec/LD_music_post_filter_fx.c b/lib_dec/LD_music_post_filter_fx.c index 4c3fa372892f8ac06b81c987492a58e36e01eb4c..eb1f5eca94442fdb95b4567c9115cc3d213d9df2 100644 --- a/lib_dec/LD_music_post_filter_fx.c +++ b/lib_dec/LD_music_post_filter_fx.c @@ -69,8 +69,10 @@ void LD_music_post_filter_fx( Word16 mant, exp1, s_ave, tmp16, old_tmp16; Word16 diff_sc; Word16 old_tmp16_1; +#ifndef ISSUE_1866_replace_overflow_libdec #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; +#endif #endif move16(); move16(); @@ -186,7 +188,11 @@ void LD_music_post_filter_fx( FOR( k = j; k < mfreq_bindiv_LD[i] + j; k++ ) { /*m_ave += lf_E[k];*/ +#ifdef ISSUE_1866_replace_overflow_libdec + Ltmp = L_add_sat( lf_E[k], Ltmp ); /*2*Qdct+10*/ //??sat +#else Ltmp = L_add_o( lf_E[k], Ltmp, &Overflow ); /*2*Qdct+10*/ +#endif max_val = L_max( max_val, lf_E[k] ); } Ltmp_max = L_max( Ltmp_max, max_val ); /*2*Qdct+10*/ @@ -442,8 +448,10 @@ static void spectrum_mod_dct_fx( Word32 Lshift; Word32 dot5_scaled; const Word32 *Lpt2; +#ifndef ISSUE_1866_replace_overflow_libdec #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; +#endif #endif move16(); @@ -523,7 +531,11 @@ static void spectrum_mod_dct_fx( IF( music_flag != 0 ) /* prevent subtraction on clean speech */ { +#ifdef ISSUE_1866_replace_overflow_libdec + IF( LE_32( maxNoise, L_shl_sat( 10, scaling ) ) ) //??sat +#else IF( LE_32( maxNoise, L_shl_o( 10, scaling, &Overflow ) ) ) +#endif { minE = 18432 / 2; /*Q14*/ move16(); @@ -599,16 +611,21 @@ static void spectrum_mod_dct_fx( Ltmp = L_mult( tmpN, m_binE ); /*2*Qdct+e_binE+9*/ e_binE = sub( add( e_tmp, e_binE ), 15 ); -#ifdef ISSUE_1799_replace_L_shr_o - Ltmp = L_shr_sat( Ltmp, e_binE ); /*2*Qdct+9*/ +#ifdef ISSUE_1866_replace_overflow_libdec + Ltmp = L_shr_sat( Ltmp, e_binE ); /*2*Qdct+9*/ //??sat + Lgain = L_add_sat( Ltmp, Lshift ); /*Saturation can occure here result in Q30*/ //??sat #else - Ltmp = L_shr_o( Ltmp, e_binE, &Overflow ); /*2*Qdct+9*/ -#endif + Ltmp = L_shr_o( Ltmp, e_binE, &Overflow ); /*2*Qdct+9*/ Lgain = L_add_o( Ltmp, Lshift, &Overflow ); /*Saturation can occure here result in Q30*/ +#endif } Lpt2++; - gain = round_fx_o( Lgain, &Overflow ); /*gain in Q30-16 = Q14*/ +#ifdef ISSUE_1866_replace_overflow_libdec + gain = round_fx_sat( Lgain ); /*gain in Q30-16 = Q14*/ //??sat +#else + gain = round_fx_o( Lgain, &Overflow ); /*gain in Q30-16 = Q14*/ +#endif /*if (gain < minE)gain = minE;*/ gain = s_max( gain, minE ); /*Q14*/ /*if (gain > 1.0f+MAX_GN)gain = 1.0f+MAX_GN;*/ @@ -905,7 +922,7 @@ static Word16 norm_lfe( { Word32 Ltmp; Word16 exp2, tmp16, exp3; -#ifndef ISSUE_1796_replace_shl_o +#ifndef ISSUE_1866_replace_overflow_libdec #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; #endif @@ -929,10 +946,10 @@ static Word16 norm_lfe( exp3 = sub( exp2, 12 + 16 - 3 ); /* if exp2 < 31, means that tmp >= 1.0 */ /* Need to shl by 3 to take into account the 3 multiplications */ } -#ifdef ISSUE_1796_replace_shl_o - tmp16 = shl_sat( tmp16, exp3 ); /* Result in Q12 */ +#ifdef ISSUE_1866_replace_overflow_libdec + tmp16 = shl_sat( tmp16, exp3 ); /* Result in Q12 */ //??sat #else - tmp16 = shl_o( tmp16, exp3, &Overflow ); /* Result in Q12 */ + tmp16 = shl_o( tmp16, exp3, &Overflow ); /* Result in Q12 */ #endif return tmp16; diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c index d166e433bce2bc2e1133fac3689acd16768aa11c..c422d63e94147c7dc8f42c7aec1b3016e4e7c9c6 100644 --- a/lib_dec/acelp_core_switch_dec_fx.c +++ b/lib_dec/acelp_core_switch_dec_fx.c @@ -876,7 +876,7 @@ static void decod_gen_voic_core_switch_fx( Word16 *pt1; GSC_DEC_HANDLE hGSCDec; hGSCDec = st_fx->hGSCDec; -#ifndef ISSUE_1796_replace_shl_o +#ifndef ISSUE_1866_replace_overflow_libdec #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); @@ -972,8 +972,8 @@ static void decod_gen_voic_core_switch_fx( IF( st_fx->prev_bfi ) { /*gain_code = min(gain_code, 0.5f*gain_code+0.5f*st->lp_gainc);*/ -#ifdef ISSUE_1796_replace_shl_o - gain_code16 = s_min( gain_code16, mac_r( L_mult( 16384, gain_code16 ), shl_sat( 16384 >> 3, st_fx->Q_exc ), st_fx->lp_gainc_fx ) ); /* st_fx->lp_gainc_fx in Q3 >>3 to bring it to Q0 as gain_code16 */ +#ifdef ISSUE_1866_replace_overflow_libdec + gain_code16 = s_min( gain_code16, mac_r( L_mult( 16384, gain_code16 ), shl_sat( 16384 >> 3, st_fx->Q_exc ), st_fx->lp_gainc_fx ) ); /* st_fx->lp_gainc_fx in Q3 >>3 to bring it to Q0 as gain_code16 */ //??sat #else gain_code16 = s_min( gain_code16, mac_r( L_mult( 16384, gain_code16 ), shl_o( 16384 >> 3, st_fx->Q_exc, &Overflow ), st_fx->lp_gainc_fx ) ); /* st_fx->lp_gainc_fx in Q3 >>3 to bring it to Q0 as gain_code16 */ #endif diff --git a/lib_dec/cng_dec_fx.c b/lib_dec/cng_dec_fx.c index fdb6488db8232ce7f77edebb2a5ea5fbb61a84b6..9de2030173509eb541de4114c37a870746881399 100644 --- a/lib_dec/cng_dec_fx.c +++ b/lib_dec/cng_dec_fx.c @@ -74,9 +74,11 @@ void CNG_dec_fx( Word16 enr_new, Aq_tmp[M + 1]; Word16 LSF_Q_prediction; /* o : LSF prediction mode - just temporary variable in CNG */ TD_CNG_DEC_HANDLE hTdCngDec; +#ifndef ISSUE_1866_replace_overflow_libdec #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif hTdCngDec = st_fx->hTdCngDec; @@ -522,7 +524,11 @@ void CNG_dec_fx( FOR( i = 0; i < M; i++ ) { dev = abs_s( sub( lsp_tmp[i], lsp_new[i] ) ); /*Q15*/ - dist = add_o( dist, dev, &Overflow ); /*Q15*/ +#ifdef ISSUE_1866_replace_overflow_libdec + dist = add_sat( dist, dev ); /*Q15*/ +#else + dist = add_o( dist, dev, &Overflow ); /*Q15*/ +#endif if ( GT_16( dev, max_dev ) ) { max_dev = dev; diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 106cb0e607d8e70d73cb89197d08eef43658344c..7fd3001c0ae4db21ab6497816d24023880e5e519 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -181,9 +181,11 @@ void bw_switching_pre_proc_fx( Word16 i; Word16 syn_dct_fx[L_FRAME]; Word32 L_tmp; +#ifndef ISSUE_1866_replace_overflow_libdec #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif IF( st_fx->element_mode > EVS_MONO ) @@ -198,7 +200,11 @@ void bw_switching_pre_proc_fx( * Calculate tilt of the ACELP core synthesis *----------------------------------------------------------------------*/ +#ifdef ISSUE_1866_replace_overflow_libdec + st_fx->tilt_wb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_syn_12k8_16k_fx, -1, st_fx->L_frame ), 3 ) ); /* Q11 */ //??sat //??sat +#else st_fx->tilt_wb_fx = round_fx_o( L_shl_o( calc_tilt_bwe_fx( old_syn_12k8_16k_fx, -1, st_fx->L_frame ), 3, &Overflow ), &Overflow ); /* Q11 */ +#endif move16(); /*-------------------------------------------------------------------------------* * Calculate frequency energy of 0~3.2kHz and 3.2~6.4kHz the ACELP core synthesis @@ -209,7 +215,11 @@ void bw_switching_pre_proc_fx( L_tmp = L_deposit_l( 0 ); FOR( i = 0; i < L_FRAME / 2; i++ ) { - L_tmp = L_mac0_o( L_tmp, syn_dct_fx[i], syn_dct_fx[i], &Overflow ); /* (2 * Q_syn2) */ +#ifdef ISSUE_1866_replace_overflow_libdec + L_tmp = L_mac0_sat( L_tmp, syn_dct_fx[i], syn_dct_fx[i] ); /* (2 * Q_syn2) */ //??sat +#else + L_tmp = L_mac0_o( L_tmp, syn_dct_fx[i], syn_dct_fx[i], &Overflow ); /* (2 * Q_syn2) */ +#endif } L_tmp = L_shr( L_tmp, 7 ); /* 2 * Q_syn2 */ st_fx->enerLL_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); /* Q_syn2 */ @@ -217,7 +227,11 @@ void bw_switching_pre_proc_fx( L_tmp = L_deposit_l( 0 ); FOR( ; i < L_FRAME; i++ ) { +#ifdef ISSUE_1866_replace_overflow_libdec + L_tmp = L_mac0_sat( L_tmp, syn_dct_fx[i], syn_dct_fx[i] ); //??sat +#else L_tmp = L_mac0_o( L_tmp, syn_dct_fx[i], syn_dct_fx[i], &Overflow ); +#endif } L_tmp = L_shr( L_tmp, 7 ); /* 2 * Q_syn2 */ st_fx->enerLH_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); /* Q_syn2 */ @@ -230,7 +244,11 @@ void bw_switching_pre_proc_fx( L_tmp = L_deposit_l( 0 ); FOR( i = 0; i < 32; i++ ) { +#ifdef ISSUE_1866_replace_overflow_libdec + L_tmp = L_mac0_sat( L_tmp, st_fx->t_audio_q_fx[i], st_fx->t_audio_q_fx[i] ); /* 2 * Q_syn2 */ //??sat +#else L_tmp = L_mac0_o( L_tmp, st_fx->t_audio_q_fx[i], st_fx->t_audio_q_fx[i], &Overflow ); /* 2 * Q_syn2 */ +#endif } L_tmp = L_shr( L_tmp, 5 ); /* 2 * Q_syn2 */ st_fx->enerLL_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); /* Q_syn2 */ @@ -238,7 +256,11 @@ void bw_switching_pre_proc_fx( L_tmp = L_deposit_l( 0 ); FOR( ; i < 64; i++ ) { +#ifdef ISSUE_1866_replace_overflow_libdec + L_tmp = L_mac0_sat( L_tmp, st_fx->t_audio_q_fx[i], st_fx->t_audio_q_fx[i] ); /* 2 * Q_syn2 */ //??sat +#else L_tmp = L_mac0_o( L_tmp, st_fx->t_audio_q_fx[i], st_fx->t_audio_q_fx[i], &Overflow ); /* 2 * Q_syn2 */ +#endif } L_tmp = L_shr( L_tmp, 5 ); /* 2 * Q_syn2 */ st_fx->enerLH_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); /* Q_syn2 */ @@ -249,7 +271,11 @@ void bw_switching_pre_proc_fx( L_tmp = L_deposit_l( 0 ); FOR( i = 0; i < L_FRAME / 2; i++ ) { +#ifdef ISSUE_1866_replace_overflow_libdec + L_tmp = L_mac0_sat( L_tmp, st_fx->t_audio_q_fx[i], st_fx->t_audio_q_fx[i] ); /* 2 * Q_syn2 */ //??sat +#else L_tmp = L_mac0_o( L_tmp, st_fx->t_audio_q_fx[i], st_fx->t_audio_q_fx[i], &Overflow ); /* 2 * Q_syn2 */ +#endif } L_tmp = L_shr( L_tmp, 7 ); /* 2 * Q_syn2 */ st_fx->enerLL_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); /* Q_syn2 */ @@ -257,7 +283,11 @@ void bw_switching_pre_proc_fx( L_tmp = L_deposit_l( 0 ); FOR( ; i < L_FRAME; i++ ) { +#ifdef ISSUE_1866_replace_overflow_libdec + L_tmp = L_mac0_sat( L_tmp, st_fx->t_audio_q_fx[i], st_fx->t_audio_q_fx[i] ); /* 2 * Q_syn2 */ //??sat +#else L_tmp = L_mac0_o( L_tmp, st_fx->t_audio_q_fx[i], st_fx->t_audio_q_fx[i], &Overflow ); /* 2 * Q_syn2 */ +#endif } L_tmp = L_shr( L_tmp, 7 ); /* 2 * Q_syn2 */ st_fx->enerLH_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); /* Q_syn2 */ @@ -2980,9 +3010,10 @@ void ivas_bw_switching_pre_proc_fx( Word16 i; Word32 syn_dct_fx[L_FRAME]; - +#ifndef ISSUE_1866_replace_overflow_libdec Flag Overflow = 0; move32(); +#endif IF( st->element_mode > EVS_MONO ) { @@ -3065,7 +3096,11 @@ void ivas_bw_switching_pre_proc_fx( move32(); FOR( i = 0; i < 32; i++ ) { +#ifdef ISSUE_1866_replace_overflow_libdec + L_tmp = L_mac0_sat( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i] ); //??sat +#else L_tmp = L_mac0_o( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i], &Overflow ); +#endif } tmp = L_shr( L_tmp, 5 ); // divide by 32 tmp = getSqrtWord32( tmp ); @@ -3078,7 +3113,11 @@ void ivas_bw_switching_pre_proc_fx( move32(); FOR( ; i < 64; i++ ) { +#ifdef ISSUE_1866_replace_overflow_libdec + L_tmp = L_mac0_sat( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i] ); //??sat +#else L_tmp = L_mac0_o( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i], &Overflow ); +#endif } tmp = L_shr( L_tmp, 5 ); // divide by 32 @@ -3094,7 +3133,11 @@ void ivas_bw_switching_pre_proc_fx( move32(); FOR( i = 0; i < L_FRAME / 2; i++ ) { +#ifdef ISSUE_1866_replace_overflow_libdec + L_tmp = L_mac0_sat( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i] ); //??sat +#else L_tmp = L_mac0_o( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i], &Overflow ); +#endif } tmp = L_shr( L_tmp, 5 ); // divide by 32 tmp = getSqrtWord32( tmp ); @@ -3107,7 +3150,11 @@ void ivas_bw_switching_pre_proc_fx( move32(); FOR( ; i < L_FRAME; i++ ) { +#ifdef ISSUE_1866_replace_overflow_libdec + L_tmp = L_mac0_sat( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i] ); //??sat +#else L_tmp = L_mac0_o( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i], &Overflow ); +#endif } tmp = L_shr( L_tmp, 5 ); // divide by 32 tmp = getSqrtWord32( tmp ); diff --git a/lib_dec/dec_higher_acelp_fx.c b/lib_dec/dec_higher_acelp_fx.c index bc638b1a13e6c264bb17bb2eeb6fa32a74ad7a40..f8d2c5ec074d09713e0816093014f176d221a0ef 100644 --- a/lib_dec/dec_higher_acelp_fx.c +++ b/lib_dec/dec_higher_acelp_fx.c @@ -30,7 +30,7 @@ void transf_cdbk_dec_fx( Word32 L_tmp; Word32 dct_code32[L_SUBFR]; Word16 qdct; -#ifndef ISSUE_1796_replace_shl_o +#ifndef ISSUE_1866_replace_overflow_libdec #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); @@ -144,8 +144,8 @@ void transf_cdbk_dec_fx( } FOR( i = 0; i < L_SUBFR; i++ ) { -#ifdef ISSUE_1796_replace_shl_o - code_preQ[i] = shl_sat( code_preQ[i], q_Code_preQ ); +#ifdef ISSUE_1866_replace_overflow_libdec + code_preQ[i] = shl_sat( code_preQ[i], q_Code_preQ ); //??sat #else code_preQ[i] = shl_o( code_preQ[i], q_Code_preQ, &Overflow ); #endif diff --git a/lib_dec/dec_pit_exc_fx.c b/lib_dec/dec_pit_exc_fx.c index e82394fbbca1343d2f561f6f14b2ac09d1e11c21..1f6e837d182ace0db67ba5d7722f0c274e6c7286 100644 --- a/lib_dec/dec_pit_exc_fx.c +++ b/lib_dec/dec_pit_exc_fx.c @@ -73,7 +73,7 @@ void dec_pit_exc_fx( Word16 use_fcb; Word32 gc_mem[NB_SUBFR - 1]; /* gain_code from previous subframes */ Word16 gp_mem[NB_SUBFR - 1]; /* gain_pitch from previous subframes */ -#ifndef ISSUE_1796_replace_shl_o +#ifndef ISSUE_1866_replace_overflow_libdec #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); @@ -250,10 +250,10 @@ void dec_pit_exc_fx( gain_pit_fx = st_fx->lp_gainp_fx; move16(); } -#ifdef ISSUE_1796_replace_shl_o - gain_code_fx = L_mult0( s_max( sub( 32767, shl_sat( gain_pit_fx, 1 ) ), 16384 /*0.5.Q15*/ ), st_fx->lp_gainc_fx ); /* Use gain pitch and past gain code as an indicator to help finding the best scaling value. gain_code_fx used a temp var*/ -#else +#ifndef ISSUE_1866_replace_overflow_libdec gain_code_fx = L_mult0( s_max( sub( 32767, shl_o( gain_pit_fx, 1, &Overflow ) ), 16384 /*0.5.Q15*/ ), st_fx->lp_gainc_fx ); /* Use gain pitch and past gain code as an indicator to help finding the best scaling value. gain_code_fx used a temp var*/ +#else + gain_code_fx = L_mult0( s_max( sub( 32767, shl_sat( gain_pit_fx, 1 ) ), 16384 /*0.5.Q15*/ ), st_fx->lp_gainc_fx ); /* Use gain pitch and past gain code as an indicator to help finding the best scaling value. gain_code_fx used a temp var*/ //??sat #endif } diff --git a/lib_dec/dec_post_fx.c b/lib_dec/dec_post_fx.c index f11f851cbb6eb333caabc2d00fa28b3ddf127001..d2130cddcb1ba10e52d3a5fdbd2f751966f416ad 100644 --- a/lib_dec/dec_post_fx.c +++ b/lib_dec/dec_post_fx.c @@ -493,19 +493,21 @@ static void modify_pst_param_fx( Word16 tmp; Word16 lp_noiseQ12; Word32 L_tmp; -#ifndef ISSUE_1796_replace_shl_o +#ifndef ISSUE_1866_replace_overflow_libdec +#ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); #endif +#endif test(); IF( NE_16( coder_type, INACTIVE ) && LT_16( lp_noise, LP_NOISE_THR_FX ) ) { -#ifdef ISSUE_1796_replace_shl_o - lp_noiseQ12 = shl_sat( lp_noise, 4 ); /* to go from Q8 to Q12 */ +#ifdef ISSUE_1866_replace_overflow_libdec + lp_noiseQ12 = shl_sat( lp_noise, 4 ); /* to go from Q8 to Q12 */ //??sat #else - lp_noiseQ12 = shl_o( lp_noise, 4, &Overflow ); /* to go from Q8 to Q12 */ + lp_noiseQ12 = shl_o( lp_noise, 4, &Overflow ); /* to go from Q8 to Q12 */ #endif /* ftmp = lp_noise*BG1_FX + CG1_FX */ @@ -577,10 +579,12 @@ static void pst_ltp_fx( Word16 gain_plt; Word16 off_yup; Word16 nb_sh_sig; +#ifndef ISSUE_1866_replace_overflow_libdec #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); #endif +#endif /* i signal justified on 13 bits */ @@ -679,7 +683,11 @@ static void pst_ltp_fx( /* decrease gain in noisy condition */ /* gain_plt += (1.0f-gain_plt) * gain_factor */ /* gain_plt = gain_plt + gain_factor - gain_plt*gain_factor */ +#ifdef ISSUE_1866_replace_overflow_libdec + gain_plt = msu_r_sat( L_msu( L_deposit_h( gain_plt ), gain_plt, gain_factor ), -32768, gain_factor ); // Q15 //??sat +#else gain_plt = msu_ro( L_msu( L_deposit_h( gain_plt ), gain_plt, gain_factor ), -32768, gain_factor, &Overflow ); // Q15 +#endif /** filtering by H0(z) = harmonic filter **/ filt_plt_fx( ptr_sig_in, ptr_y_up, ptr_sig_pst0, gain_plt ); @@ -1423,10 +1431,12 @@ void Filt_mu_fx( Word16 n; Word16 mu, mu2, ga, temp; Word16 fact, sh_fact; +#ifndef ISSUE_1866_replace_overflow_libdec #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); #endif +#endif IF( parcor0 > 0 ) @@ -1452,7 +1462,11 @@ void Filt_mu_fx( temp = sub( 1, abs_s( mu ) ); BASOP_SATURATE_WARNING_OFF_EVS; - mu2 = add_o( 32767, temp, &Overflow ); /* Q15 (1 - |mu|) */ +#ifdef ISSUE_1866_replace_overflow_libdec + mu2 = add_sat( 32767, temp ); /* Q15 (1 - |mu|) */ //??sat +#else + mu2 = add_o( 32767, temp, &Overflow ); /* Q15 (1 - |mu|) */ +#endif BASOP_SATURATE_WARNING_ON_EVS; ga = div_s( fact, mu2 ); /* Q(sh_fact) / (1 - |mu|) */ @@ -1492,9 +1506,11 @@ void Filt_mu_ivas_fx( Word16 n; Word16 mu, mu2, ga, temp; Word16 fact, sh_fact; +#ifndef ISSUE_1866_replace_overflow_libdec #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif IF( EQ_16( extl, SWB_TBE ) ) @@ -1546,7 +1562,11 @@ void Filt_mu_ivas_fx( temp = sub( 1, abs_s( mu ) ); BASOP_SATURATE_WARNING_OFF_EVS; - mu2 = add_o( 32767, temp, &Overflow ); /* Q15 (1 - |mu|) */ +#ifdef ISSUE_1866_replace_overflow_libdec + mu2 = add_sat( 32767, temp ); /* Q15 (1 - |mu|) */ //??sat +#else + mu2 = add_o( 32767, temp, &Overflow ); /* Q15 (1 - |mu|) */ +#endif BASOP_SATURATE_WARNING_ON_EVS; ga = div_s( fact, mu2 ); /* Q(sh_fact) / (1 - |mu|) */ @@ -1688,18 +1708,26 @@ void blend_subfr2_fx( Word16 fac2 = 0 + 512; // 0.Q15 + ( 1.Q15 / L_SUBFR ); Word16 step = 1024; // 1.Q15 / ( L_SUBFR / 2 ); Word16 i; +#ifndef ISSUE_1866_replace_overflow_libdec #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif move16(); move16(); move16(); FOR( i = 0; i < L_SUBFR / 2; i++ ) { - sigOut[i] = mac_ro( L_mult_o( fac1, sigIn1[i], &Overflow ), fac2, sigIn2[i], &Overflow ); // Qx +#ifdef ISSUE_1866_replace_overflow_libdec + sigOut[i] = mac_r_sat( L_mult( fac1, sigIn1[i] ), fac2, sigIn2[i] ); // Qx //??sat + fac1 = sub_sat( fac1, step ); //??sat + fac2 = add_sat( fac2, step ); //??sat +#else + sigOut[i] = mac_ro( L_mult_o( fac1, sigIn1[i], &Overflow ), fac2, sigIn2[i], &Overflow ); // Qx fac1 = sub_o( fac1, step, &Overflow ); fac2 = add_o( fac2, step, &Overflow ); +#endif move16(); } diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index d1d290b86f8fd35af06008949990ac1a6b9f90f9..664b22e938163788af28a4c37e268e5bae21c435 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -547,7 +547,11 @@ void decoder_tcx_fx( st->last_gain_syn_deemph_e = add( st->last_gain_syn_deemph_e, 10 /*scaling of h1[0] and E_UTIL_synthesis * 2*/ ); move16(); tmp32 = Sqrt32( tmp32, &st->last_gain_syn_deemph_e ); +#ifdef ISSUE_1866_replace_overflow_libdec + st->last_gain_syn_deemph = round_fx_sat( tmp32 ); //??sat +#else st->last_gain_syn_deemph = round_fx_o( tmp32, &Overflow ); +#endif move16(); /*for avoiding compiler warnings*/ hTcxDec->gainHelper = 32768 / 2; @@ -1276,9 +1280,11 @@ void decoder_tcx_post_fx( Decoder_State *st_fx, Word32 tmp32; Word32 tmp32_1, tmp32_2; TCX_DEC_HANDLE hTcxDec; +#ifndef ISSUE_1866_replace_overflow_libdec #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif hTcxDec = st_fx->hTcxDec; @@ -1351,7 +1357,11 @@ void decoder_tcx_post_fx( Decoder_State *st_fx, } tmp32 = Mpy_32_16_1( tmp32, getInvFrameLen( hTcxDec->L_frameTCX ) ); tmp2 = norm_l( tmp32 ); +#ifdef ISSUE_1866_replace_overflow_libdec + tmp1 = round_fx_sat( L_shl( tmp32, tmp2 ) ); //??sat +#else tmp1 = round_fx_o( L_shl( tmp32, tmp2 ), &Overflow ); +#endif s = sub( sub( sub( 1, shl( s, 1 ) ), 6 /*table lookup for inverse framelength*/ ), tmp2 ); tmp1 = Sqrt16( tmp1, &s ); move16(); @@ -1444,18 +1454,30 @@ void decoder_tcx_post_fx( Decoder_State *st_fx, &tmp1 ); tmp2 = BASOP_Util_Add_MantExp( hTcxDec->conceal_eof_gain, 15 - 14, negate( tmp1 ), tmp2, &tmp1 ); +#ifdef ISSUE_1866_replace_overflow_libdec + step = L_shl_sat( L_mult( tmp1, getInvFrameLen( st_fx->L_frame ) ), sub( tmp2, 6 /*scaling from table lookup*/ + 1 /*go to Q30*/ ) ); /*Q30*/ //??sat +#else step = L_shl_o( L_mult( tmp1, getInvFrameLen( st_fx->L_frame ) ), sub( tmp2, 6 /*scaling from table lookup*/ + 1 /*go to Q30*/ ), &Overflow ); /*Q30*/ +#endif { Word32 stepFB; UWord32 dmy; conceal_eof_gainFB = L_deposit_h( hTcxDec->conceal_eof_gain ); /*Q30*/ Mpy_32_32_ss( step, L_shl( L_mult0( st_fx->L_frame, getInvFrameLen( hTcxDec->L_frameTCX ) ), 8 ), &stepFB, &dmy ); - stepFB = L_shl_o( stepFB, 3 - 1, &Overflow ); /*Q30*/ +#ifdef ISSUE_1866_replace_overflow_libdec + stepFB = L_shl_sat( stepFB, 3 - 1 ); /*Q30*/ //??sat +#else + stepFB = L_shl_o( stepFB, 3 - 1, &Overflow ); /*Q30*/ +#endif FOR( i = 0; i < hTcxDec->L_frameTCX; i++ ) { synthFB[i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( conceal_eof_gainFB, synthFB[i] ), 1 ) ); move16(); +#ifdef ISSUE_1866_replace_overflow_libdec + conceal_eof_gainFB = L_sub_sat( conceal_eof_gainFB, stepFB ); //??sat +#else conceal_eof_gainFB = L_sub_o( conceal_eof_gainFB, stepFB, &Overflow ); +#endif } } conceal_eof_gain32 = L_deposit_h( hTcxDec->conceal_eof_gain ); /*Q30*/ @@ -1463,17 +1485,32 @@ void decoder_tcx_post_fx( Decoder_State *st_fx, { xn_buf[i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( conceal_eof_gain32 /*Q30*/, xn_buf[i] ), 1 ) ); move16(); +#ifdef ISSUE_1866_replace_overflow_libdec + conceal_eof_gain32 = L_sub_sat( conceal_eof_gain32, step ); //??sat +#else conceal_eof_gain32 = L_sub_o( conceal_eof_gain32, step, &Overflow ); +#endif } +#ifdef ISSUE_1866_replace_overflow_libdec + hTcxDec->conceal_eof_gain = round_fx_sat( conceal_eof_gain32 ); /*Q14*/ //??sat +#else hTcxDec->conceal_eof_gain = round_fx_o( conceal_eof_gain32, &Overflow ); /*Q14*/ +#endif move16(); /* run lpc gain compensation not for waveform adjustment */ test(); IF( 0 == st_fx->enablePlcWaveadjust || EQ_16( st_fx->hPlcInfo->concealment_method, TCX_TONAL ) ) { +#ifdef ISSUE_1866_replace_overflow_libdec + st_fx->hPlcInfo->recovery_gain = extract_h( L_shl_sat( Mpy_32_16_1( conceal_eof_gainFB, + st_fx->last_concealed_gain_syn_deemph ), + st_fx->last_concealed_gain_syn_deemph_e ) ); + /*Q30->Q14*/ //??sat +#else st_fx->hPlcInfo->recovery_gain = extract_h( L_shl_o( Mpy_32_16_1( conceal_eof_gainFB, st_fx->last_concealed_gain_syn_deemph ), st_fx->last_concealed_gain_syn_deemph_e, &Overflow ) ); /*Q30->Q14*/ +#endif move16(); } ELSE @@ -1543,9 +1580,11 @@ void decoder_tcx_post_ivas_fx( Decoder_State *st_fx, Word32 tmp32; Word32 tmp32_1, tmp32_2; TCX_DEC_HANDLE hTcxDec; +#ifndef ISSUE_1866_replace_overflow_libdec #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif hTcxDec = st_fx->hTcxDec; @@ -1629,7 +1668,11 @@ void decoder_tcx_post_ivas_fx( Decoder_State *st_fx, } tmp32 = Mpy_32_16_1( tmp32, getInvFrameLen( hTcxDec->L_frameTCX ) ); tmp2 = norm_l( tmp32 ); +#ifdef ISSUE_1866_replace_overflow_libdec + tmp1 = round_fx_sat( L_shl( tmp32, tmp2 ) ); //??sat +#else tmp1 = round_fx_o( L_shl( tmp32, tmp2 ), &Overflow ); +#endif // s = sub(sub(sub(1, shl(s, 1)), 6/*table lookup for inverse framelength*/), tmp2); s = sub( 25, add( shl( add( Q_syn, s ), 1 ), tmp2 ) ); tmp1 = Sqrt16( tmp1, &s ); @@ -1802,7 +1845,11 @@ void decoder_tcx_post_ivas_fx( Decoder_State *st_fx, test(); IF( 0 == st_fx->enablePlcWaveadjust || EQ_16( st_fx->hPlcInfo->concealment_method, TCX_TONAL ) ) { +#ifdef ISSUE_1866_replace_overflow_libdec + st_fx->hPlcInfo->recovery_gain = extract_h( L_shl_sat( Mpy_32_16_1( conceal_eof_gainFB, st_fx->last_concealed_gain_syn_deemph ), st_fx->last_concealed_gain_syn_deemph_e ) ); /*Q30->Q14*/ //??sat +#else st_fx->hPlcInfo->recovery_gain = extract_h( L_shl_o( Mpy_32_16_1( conceal_eof_gainFB, st_fx->last_concealed_gain_syn_deemph ), st_fx->last_concealed_gain_syn_deemph_e, &Overflow ) ); /*Q30->Q14*/ +#endif move16(); } ELSE @@ -4410,9 +4457,11 @@ void decoder_tcx_invQ_fx( move16(); move16(); +#ifndef ISSUE_1866_replace_overflow_libdec #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif tnsSize = 0; @@ -4537,7 +4586,11 @@ void decoder_tcx_invQ_fx( FOR( i = 0; i < noiseFillingSize; ++i ) { tmp32 = L_shr( x[i], sub( 31, *x_e ) ); +#ifdef ISSUE_1866_replace_overflow_libdec + *nf_seed = add_sat( *nf_seed, extract_l( L_shl( i_mult( (Word16) L_abs( tmp32 ), i ), 1 ) ) ); // abs( tmp32 ) * i * 2 //??sat +#else *nf_seed = add_o( *nf_seed, extract_l( L_shl( i_mult( (Word16) L_abs( tmp32 ), i ), 1 ) ), &Overflow ); // abs( tmp32 ) * i * 2 +#endif move16(); } } @@ -4777,7 +4830,11 @@ void decoder_tcx_invQ_fx( st->last_gain_syn_deemph_e = add( st->last_gain_syn_deemph_e, 10 /*scaling of h1[0] and E_UTIL_synthesis * 2*/ ); move16(); tmp32 = Sqrt32( tmp32, &st->last_gain_syn_deemph_e ); - st->last_gain_syn_deemph = round_fx_o( tmp32, &Overflow ); // Q15 +#ifdef ISSUE_1866_replace_overflow_libdec + st->last_gain_syn_deemph = round_fx_sat( tmp32 ); // Q15 //??sat +#else + st->last_gain_syn_deemph = round_fx_o( tmp32, &Overflow ); // Q15 +#endif move16(); } diff --git a/lib_dec/er_dec_tcx_fx.c b/lib_dec/er_dec_tcx_fx.c index aeb4c0783a0ff156761eef9263cbc451a1a354cf..9d0a3cc44912e9a3f89342a616cfc9370ac7375d 100644 --- a/lib_dec/er_dec_tcx_fx.c +++ b/lib_dec/er_dec_tcx_fx.c @@ -36,14 +36,22 @@ static void calcGainc_fx( Word16 *exc, Word16 Q_exc, Word32 old_fpitch /*Q16*/, tmp16 = round_fx( old_fpitch ); /*Q0*/ tmp_loop = shl( L_subfr, 1 ); BASOP_SATURATE_WARNING_OFF_EVS +#ifdef ISSUE_1866_replace_overflow_libdec + tmp16_2 = round_fx_sat( L_shl_sat( lp_gainp, 2 ) ); /*Q31->Q15, no severe saturation, because st->lp_gainp here is [0,1]*/ //??sat //??sat +#else tmp16_2 = round_fx_o( L_shl_o( lp_gainp, 2, &Overflow ), &Overflow ); /*Q31->Q15, no severe saturation, because st->lp_gainp here is [0,1]*/ +#endif BASOP_SATURATE_WARNING_ON_EVS FOR( i = 0; i < tmp_loop; i++ ) { /*st->lp_gainc += ( exc[i-2*L_subfr] - st->Mode2_lp_gainp * exc[i-2*L_subfr-(int)(st->old_fpitch+0.5f)] ) * ( exc[i-2*L_subfr] - st->Mode2_lp_gainp * exc[i-2*L_subfr-(int)(st->old_fpitch+0.5f)] );*/ +#ifdef ISSUE_1866_replace_overflow_libdec + tmp16_3 = sub_sat( exc[( i - ( L_subfr * 2 ) )] /*Q1*/, mult_r( tmp16_2 /*Q15*/, exc[( ( i - ( L_subfr * 2 ) ) - tmp16 )] /*Q1*/ ) /*Q1*/ ); //??sat +#else tmp16_3 = sub_o( exc[( i - ( L_subfr * 2 ) )] /*Q1*/, mult_r( tmp16_2 /*Q15*/, exc[( ( i - ( L_subfr * 2 ) ) - tmp16 )] /*Q1*/ ) /*Q1*/, &Overflow ); +#endif L_acc = L_macNs_co( L_acc, tmp16_3, tmp16_3, &Carry, &Overflow ); /*Q3*/ Overflow = 0; move16(); diff --git a/lib_dec/er_scale_syn_fx.c b/lib_dec/er_scale_syn_fx.c index 35ad826486d758fbbaa190df3afa1374320fc238..195d79d9edac4c30a4f1d90f0aa870f7fb3e8ed3 100644 --- a/lib_dec/er_scale_syn_fx.c +++ b/lib_dec/er_scale_syn_fx.c @@ -33,10 +33,12 @@ Word16 Damping_fact_fx( /* o : damping factor Word32 lp_tmp; Word16 s_gainp; Word32 gain32; +#ifndef ISSUE_1866_replace_overflow_libdec #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); #endif +#endif IF( core == ACELP_CORE ) @@ -97,10 +99,14 @@ Word16 Damping_fact_fx( /* o : damping factor move16(); gain32 = Sqrt32( lp_tmp, &s_gainp ); /*Q31-s_gainp*/ +#ifdef ISSUE_1866_replace_overflow_libdec + gain = round_fx_sat( L_shl_sat( gain32, s_gainp ) ); /* Q15*/ //??sat //??sat +#else gain = round_fx_o( L_shl_o( gain32, s_gainp, &Overflow ), &Overflow ); /* Q15*/ - gain = s_min( gain, 32113 /*0.98f Q15*/ ); /*Q15*/ - gain = s_max( gain, 27853 /*0.85f Q15*/ ); /*Q15*/ - alpha = mult_r( alpha, gain ); /*Q14*/ +#endif + gain = s_min( gain, 32113 /*0.98f Q15*/ ); /*Q15*/ + gain = s_max( gain, 27853 /*0.85f Q15*/ ); /*Q15*/ + alpha = mult_r( alpha, gain ); /*Q14*/ } ELSE IF( EQ_16( nbLostCmpt, 2 ) ) { diff --git a/lib_dec/er_sync_exc_fx.c b/lib_dec/er_sync_exc_fx.c index 48be80d43cecd12d70b57d6f2d4d8a47c93cbe3a..77a2eb294f82685a17f29c7367802a317ac4a948 100644 --- a/lib_dec/er_sync_exc_fx.c +++ b/lib_dec/er_sync_exc_fx.c @@ -30,9 +30,11 @@ static Word16 GetMinimumPosition_fx( Word16 iMinEnergyPos, center, i; Word16 cnt, tmp_e, tmp16; Word32 energy, energy_old, tmptest; +#ifndef ISSUE_1866_replace_overflow_libdec #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif filterLength = s_min( filterLength, length ); /*Q0*/ @@ -60,8 +62,13 @@ static Word16 GetMinimumPosition_fx( BASOP_SATURATE_WARNING_ON_EVS /*if (energy == MAXVAL_WORD32)*/ - BASOP_SATURATE_WARNING_OFF_EVS /*saturates if energy < 0*/ - tmptest = L_sub_o( energy, MAXVAL_WORD32, &Overflow ); /*Q31*/ + BASOP_SATURATE_WARNING_OFF_EVS /*saturates if energy < 0*/ +#ifdef ISSUE_1866_replace_overflow_libdec + tmptest = L_sub_sat( energy, MAXVAL_WORD32 ); + /*Q31*/ //??sat +#else + tmptest = L_sub_o( energy, MAXVAL_WORD32, &Overflow ); /*Q31*/ +#endif BASOP_SATURATE_WARNING_ON_EVS IF( tmptest == 0 ) { @@ -227,10 +234,12 @@ void PulseResynchronization_fx( Word16 /*int*/ roundedPitchStart, nSamplesDelta, nSamplesDeltaRemain, iMinPos1, iMinPos[NB_PULSES_MAX + 1], iDeltaSamples[NB_PULSES_MAX + 1], maxDeltaSamples, roundedCycleDelta; Word16 tmp16, tmp16_a, freqStart_e /*exponent of freqStart*/, tmp_e, samplesDelta_e, perCycleDeltaDelta_e, cycleDelta_e, tmp2_e, tmp3_e; Word32 /* pitchDelta, */ tmp32, tmp32_a, tmp32_b, samplesDelta, absPitchDiff, cycleDelta32; +#ifndef ISSUE_1866_replace_overflow_libdec #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); #endif +#endif test(); @@ -295,7 +304,11 @@ void PulseResynchronization_fx( tmp3_e = tmp2_e; move16(); tmp32_a = L_negate( tmp32_a ); +#ifdef ISSUE_1866_replace_overflow_libdec + tmp32_a = L_add( L_shl_sat( 1, sub( 31, tmp3_e ) ), tmp32_a ); /*Q31,tmp3_e*/ /*tmp32_a= 1.0f-pitchStart*freqStart*/ //??sat +#else tmp32_a = L_add( L_shl_o( 1, sub( 31, tmp3_e ), &Overflow ), tmp32_a ); /*Q31,tmp3_e*/ /*tmp32_a= 1.0f-pitchStart*freqStart*/ +#endif tmp2_e = norm_s( nFrameLength ); tmp16_a = shl( nFrameLength, tmp2_e ); /*Q0+tmp2_e*/ tmp32_a = Mpy_32_16_1( tmp32_a /*Q31,tmp3_e*/, tmp16_a /*Q0,-tmp2_e*/ ); /*Q16,tmp3_e-tmp2_e*/ /*tmp32_a= nFrameLength*(1.0f-pitchStart*freqStart)*/ @@ -360,8 +373,12 @@ void PulseResynchronization_fx( fractionalLeft = lshr( extract_l( tmp32_a ), 1 ); /*Q15*/ tmp_e = sub( 15, norm_l( tmp32 ) ); cycleDelta_e = add( cycleDelta_e, tmp_e ); - tmp32 = L_shr( tmp32, sub( tmp_e, 15 ) ); /*Q31 frac, cycleDelta_e*/ - cycleDelta = round_fx_o( tmp32, &Overflow ); /*Q15, cycleDelta_e*/ + tmp32 = L_shr( tmp32, sub( tmp_e, 15 ) ); /*Q31 frac, cycleDelta_e*/ +#ifdef ISSUE_1866_replace_overflow_libdec + cycleDelta = round_fx_sat( tmp32 ); /*Q15, cycleDelta_e*/ //??sat +#else + cycleDelta = round_fx_o( tmp32, &Overflow ); /*Q15, cycleDelta_e*/ +#endif if ( cycleDelta == 0 ) { cycleDelta_e = 0; diff --git a/lib_dec/er_util_fx.c b/lib_dec/er_util_fx.c index 330cb5d4452ce4f80eda4d441ca7e3f0a4a931ce..72dc9387c8e6d941e6750f4d42671f8852b439a7 100644 --- a/lib_dec/er_util_fx.c +++ b/lib_dec/er_util_fx.c @@ -44,7 +44,7 @@ void minimumStatistics_fx( Word16 f, p, i; Word16 tmp, tmp2, tmp_e; Word32 tmp32; -#ifndef ISSUE_1796_replace_shl_o +#ifndef ISSUE_1866_replace_overflow_libdec #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); @@ -55,8 +55,8 @@ void minimumStatistics_fx( BASOP_SATURATE_WARNING_OFF_EVS -#ifdef ISSUE_1796_replace_shl_o - IF( LT_16( shl_sat( currentFrameLevel, currentFrameLevel_e ), PLC_MIN_CNG_LEV ) ) +#ifdef ISSUE_1866_replace_overflow_libdec + IF( LT_16( shl_sat( currentFrameLevel, currentFrameLevel_e ), PLC_MIN_CNG_LEV ) ) //??sat #else IF( LT_16( shl_o( currentFrameLevel, currentFrameLevel_e, &Overflow ), PLC_MIN_CNG_LEV ) ) #endif diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index e411da152af54a0e1f8418a05a7759f0bb3746c7..c5f2d4708b603a8ab5f95452f613ec7fe6a70e5c 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -62,9 +62,11 @@ ivas_error evs_dec_fx( push_wmops( "evs_dec_fx" ); +#ifndef ISSUE_1866_replace_overflow_libdec #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif hBWE_TD = st_fx->hBWE_TD; hHQ_core = st_fx->hHQ_core; @@ -454,7 +456,11 @@ ivas_error evs_dec_fx( /*hb_synth[i] *= (i*tmp);*/ hb_synth_fx[i] = mult_r( hb_synth_fx[i], tmp16_2 ); /*hb_synth_fx_exp*/ move16(); +#ifdef ISSUE_1866_replace_overflow_libdec + tmp16_2 = add_sat( tmp16_2, tmp16 ); //??sat +#else tmp16_2 = add_o( tmp16_2, tmp16, &Overflow ); +#endif } } diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 1e78b792becb0373958b675bf9a4995e0e4fd819..91b566fe656d904d0221e9819d43b0c6c4ae2384 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -583,7 +583,9 @@ Word16 ApplyFdCng_fx( HANDLE_FD_CNG_DEC hFdCngDec; HANDLE_FD_CNG_COM hFdCngCom; #ifdef BASOP_NOGLOB_DECLARE_LOCAL +#if !defined( ISSUE_1866_replace_overflow_libdec ) && !defined( FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW ) Flag Overflow = 0; +#endif #ifndef FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW Flag Carry = 0; #endif @@ -983,7 +985,11 @@ Word16 ApplyFdCng_fx( } L_tmp_exp = 0; move16(); +#ifdef ISSUE_1866_replace_overflow_libdec + IF( GT_32( L_tmp, 21474836 ) /*0.01f Q31*/ ) +#else IF( GT_32( L_shl_o( L_tmp, L_tmp_exp, &Overflow ), 21474836 ) /*0.01f Q31*/ ) +#endif { test(); test(); @@ -1093,7 +1099,11 @@ Word16 ApplyFdCng_fx( L_tmp_exp = add( L_tmp_exp, -7 ); /*->Q16, L_tmp_exp */ L_tmp_exp = add( L_tmp_exp, 31 - 16 ); /*->Q31, L_tmp_exp*/ +#ifdef ISSUE_1866_replace_overflow_libdec + st->cngTDLevel = round_fx_sat( Sqrt32( L_tmp, &L_tmp_exp ) ); /*Q15 - L_tmp_exp*/ //??sat +#else st->cngTDLevel = round_fx_o( Sqrt32( L_tmp, &L_tmp_exp ), &Overflow ); /*Q15 - L_tmp_exp*/ +#endif move16(); #else L_tmp = sum_array_norm( cngNoiseLevel, tmp_loop, &L_tmp_exp ); /*Q31 - L_tmp_exp*/ diff --git a/lib_dec/gain_dec_fx.c b/lib_dec/gain_dec_fx.c index db325cd80b92a8be09722e96ce43d699613736e6..267041c3703c3053932148bd6a06d22051536ede 100644 --- a/lib_dec/gain_dec_fx.c +++ b/lib_dec/gain_dec_fx.c @@ -1409,10 +1409,12 @@ void gain_dec_amr_wb_fx( Word16 tmp; Word32 L_tmp; Word16 expg, exp_gcode0, fracg; +#ifndef ISSUE_1866_replace_overflow_libdec #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); #endif +#endif /**gain_inov = 1.0f/ (float)sqrt( ( dotp( code, code, L_SUBFR ) + 0.01f ) / L_SUBFR );*/ @@ -1496,7 +1498,11 @@ void gain_dec_amr_wb_fx( /* adjust gain according to energy of code */ L_tmp = Mult_32_16( *gain_code, *gain_inov ); +#ifdef ISSUE_1866_replace_overflow_libdec + *gain_code = L_shl_sat( L_tmp, 3 ); /* gcode_inov in Q12*/ //??sat +#else *gain_code = L_shl_o( L_tmp, 3, &Overflow ); /* gcode_inov in Q12*/ +#endif move32(); /*-----------------------------------------------------------------* diff --git a/lib_dec/hf_synth_fx.c b/lib_dec/hf_synth_fx.c index 27d768f631bb7b007adeeae34f78ffe698833ad7..0bb28934412f35f7ada8abe35a6b9b78d6193010 100644 --- a/lib_dec/hf_synth_fx.c +++ b/lib_dec/hf_synth_fx.c @@ -136,9 +136,11 @@ static void hf_synthesis_fx( Word16 tmp, ener, exp1, exp2, scale; Word32 L_tmp; Word16 Ap[M16k + 1]; +#ifndef ISSUE_1866_replace_overflow_libdec #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /*-----------------------------------------------------------------* @@ -217,15 +219,22 @@ static void hf_synthesis_fx( /*-----------------------------------------------------------------* * modify energy of white noise according to synthesis tilt *-----------------------------------------------------------------*/ - /* tmp = 1.0 - fac */ +#ifdef ISSUE_1866_replace_overflow_libdec + tmp = add_sat( 1, sub( 32767 /* 1 in Q15 */, tmp ) ); //??sat +#else tmp = add_o( 1, sub( 32767 /* 1 in Q15 */, tmp ), &Overflow ); +#endif test(); if ( core_brate == FRAME_NO_DATA || EQ_32( core_brate, SID_2k40 ) ) { /* emphasize HF noise in CNG */ /*fac *= 2.0f;*/ - tmp = add_o( tmp, tmp, &Overflow ); /* Q15 */ +#ifdef ISSUE_1866_replace_overflow_libdec + tmp = add_sat( tmp, tmp ); /* Q15 */ //??sat +#else + tmp = add_o( tmp, tmp, &Overflow ); /* Q15 */ +#endif } tmp = s_max( tmp, 3277 ); /* 0.1 in Q15 */ @@ -523,9 +532,11 @@ static void filt_6k_7k_scale_fx( { Word16 i, x[L_FRAME48k / NB_SUBFR + ( L_FIR - 1 )]; Word32 L_tmp; +#ifndef ISSUE_1866_replace_overflow_libdec #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif Copy_Scale_sig( mem, x, L_FIR - 1, exp ); @@ -542,10 +553,18 @@ static void filt_6k_7k_scale_fx( move32(); FOR( j = 0; j < 31; j++ ) { +#ifdef ISSUE_1866_replace_overflow_libdec + L_tmp = L_mac_sat( L_tmp, x[i + j], fir_6k_7k_fx[j] ); /* Q16 */ //??sat +#else L_tmp = L_mac_o( L_tmp, x[i + j], fir_6k_7k_fx[j], &Overflow ); /* Q16 */ +#endif } - signal[i] = round_fx_o( L_tmp, &Overflow ); /* Q0 */ +#ifdef ISSUE_1866_replace_overflow_libdec + signal[i] = round_fx_sat( L_tmp ); /* Q0 */ //??sat +#else + signal[i] = round_fx_o( L_tmp, &Overflow ); /* Q0 */ +#endif move16(); } Copy( x + lg, mem, L_FIR - 1 ); /* Qx - 2 */ @@ -1385,8 +1404,9 @@ static Word16 EnhanceClass_fx( Word16 unvoicing_tmp_fx; Word16 tmp, tmp1; Word32 L_tmp; +#ifndef ISSUE_1866_replace_overflow_libdec Flag Overflow; - +#endif /* Decide (*unvoicing_flag) to allow BWE enhancement when qq>pp */ /**voice_fac_fx = add(mult_r(*voice_fac_fx, 24576), mult_r(voice_factor_fx, 8192)); //Q15 */ @@ -1423,13 +1443,21 @@ static Word16 EnhanceClass_fx( move16(); } +#ifdef ISSUE_1866_replace_overflow_libdec + if ( GT_16( sub_sat( *unvoicing_fx, *unvoicing_sm_fx ), 3277 /* 0.1 in Q15 */ ) ) //??sat +#else if ( GT_16( sub_o( *unvoicing_fx, *unvoicing_sm_fx, &Overflow ), 3277 /* 0.1 in Q15 */ ) ) +#endif { *unvoicing_flag = 1; move16(); } +#ifdef ISSUE_1866_replace_overflow_libdec + if ( LT_16( sub_sat( *unvoicing_fx, *unvoicing_sm_fx ), 1638 /* 0.05 in Q15 */ ) ) //??sat +#else if ( LT_16( sub_o( *unvoicing_fx, *unvoicing_sm_fx, &Overflow ), 1638 /* 0.05 in Q15 */ ) ) +#endif { *unvoicing_flag = 0; move16(); diff --git a/lib_dec/igf_dec_fx.c b/lib_dec/igf_dec_fx.c index 40b02c82315c383281a2b69656305999573e1ab0..3ae2927e82ba5fb0a5d345c95ec78c920aa849a0 100644 --- a/lib_dec/igf_dec_fx.c +++ b/lib_dec/igf_dec_fx.c @@ -1884,8 +1884,12 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in sum = shl( sum, shift ); /* exponent of sum: sub(15, shift) */ /* divide E by sum */ +#ifdef ISSUE_1866_replace_overflow_libdec + tmp = div_s( shr( round_fx_sat( E ), 1 ), sum ); /* shift E 1 bit to the right in order to make it smaller than sum */ //??sat +#else tmp = div_s( shr( round_fx_o( E, &Overflow ), 1 ), sum ); /* shift E 1 bit to the right in order to make it smaller than sum */ - tmp_e = sub( add( E_e, 1 ), sub( 15, shift ) ); /* 15Q0 | sum is 15Q0 */ +#endif + tmp_e = sub( add( E_e, 1 ), sub( 15, shift ) ); /* 15Q0 | sum is 15Q0 */ /* multiply the result by the hopsize */ L_tmp = L_mult( tmp, hopsize ); @@ -2571,8 +2575,12 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in sum = shl( sum, shift ); /* exponent of sum: sub(15, shift) */ /* divide E by sum */ +#ifdef ISSUE_1866_replace_overflow_libdec + tmp = div_s( shr( round_fx_sat( E ), 1 ), sum ); /* shift E 1 bit to the right in order to make it smaller than sum */ //??sat +#else tmp = div_s( shr( round_fx_o( E, &Overflow ), 1 ), sum ); /* shift E 1 bit to the right in order to make it smaller than sum */ - tmp_e = sub( add( E_e, 1 ), sub( 15, shift ) ); /* 15Q0 | sum is 15Q0 */ +#endif + tmp_e = sub( add( E_e, 1 ), sub( 15, shift ) ); /* 15Q0 | sum is 15Q0 */ /* multiply the result by the hopsize */ L_tmp = L_mult( tmp, hopsize ); @@ -2975,7 +2983,7 @@ static void IGF_RefineGrid( H_IGF_GRID hGrid /**< in Word16 sfb; Word16 tmp; Word16 delta; -#ifndef ISSUE_1796_replace_shl_o +#ifndef ISSUE_1866_replace_overflow_libdec #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); @@ -2994,8 +3002,8 @@ static void IGF_RefineGrid( H_IGF_GRID hGrid /**< in move16(); tmp = add( tmp, 1 ); delta = sub( hGrid->swb_offset[sfb + 1], hGrid->swb_offset[sfb] ); -#ifdef ISSUE_1796_replace_shl_o - delta = mac_r( 0x00195000, 29491 /*0.45f Q16*/, shl_sat( delta, 5 ) ); +#ifdef ISSUE_1866_replace_overflow_libdec + delta = mac_r( 0x00195000, 29491 /*0.45f Q16*/, shl_sat( delta, 5 ) ); //??sat #else delta = mac_r( 0x00195000, 29491 /*0.45f Q16*/, shl_o( delta, 5, &Overflow ) ); #endif @@ -3029,7 +3037,7 @@ static void IGF_RefineGrid_ivas_fx( H_IGF_GRID hGrid /**< in/out: | IGF grid han Word16 sfb; Word16 tmp; Word16 delta; -#ifndef ISSUE_1796_replace_shl_o +#ifndef ISSUE_1866_replace_overflow_libdec #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); @@ -3049,7 +3057,7 @@ static void IGF_RefineGrid_ivas_fx( H_IGF_GRID hGrid /**< in/out: | IGF grid han tmp = add( tmp, 1 ); delta = sub( hGrid->swb_offset[sfb + 1], hGrid->swb_offset[sfb] ); #ifdef ISSUE_1796_replace_shl_o - delta = mac_r( 0x00195000, 29491 /*0.45f Q16*/, shl_sat( delta, 5 ) ); + delta = mac_r( 0x00195000, 29491 /*0.45f Q16*/, shl_sat( delta, 5 ) ); //??sat #else delta = mac_r( 0x00195000, 29491 /*0.45f Q16*/, shl_o( delta, 5, &Overflow ) ); #endif diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index bc9adf34791b348a940a92b1b06f655352b2b1cd..cfdb13801c4887f7510b21d94b61d10f650000b9 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -116,7 +116,9 @@ ivas_error ivas_core_dec_fx( Word16 tdm_lsfQ_PCh_fx[M], tdm_lspQ_PCh_fx[M]; #endif Word32 conceal_eof_gain32; +#ifndef ISSUE_1866_replace_overflow_libdec Flag Overflow; +#endif error = IVAS_ERR_OK; move32(); @@ -1141,7 +1143,11 @@ ivas_error ivas_core_dec_fx( { hb_synth_32_fx[n][i] = Mpy_32_16_1( hb_synth_32_fx[n][i], tmp16_2 ); /* Q11 */ move32(); +#ifdef ISSUE_1866_replace_overflow_libdec + tmp16_2 = add_sat( tmp16_2, tmp16 ); /* Q15 */ //??sat +#else tmp16_2 = add_o( tmp16_2, tmp16, &Overflow ); /* Q15 */ +#endif } } diff --git a/lib_dec/pitch_extr_fx.c b/lib_dec/pitch_extr_fx.c index 73e9623f5da99fc082caae28ff4ce9c12a27bd20..4b159ee157a0e8dcb420e1ddbe51cb24dd49f5d0 100644 --- a/lib_dec/pitch_extr_fx.c +++ b/lib_dec/pitch_extr_fx.c @@ -157,7 +157,9 @@ void pitch_pred_linear_fit( { Word32 t1, t2, t3, t4, t5, t6, t7; Word16 e1, e2, e3, e4, e5, e6, e7; +#ifndef ISSUE_1866_replace_overflow_libdec Flag Overflow; +#endif t1 = L_mult0( pg[4], pg[3] ); /*Q24*/ /* t1 = pg[4]*pg[3] */ e1 = 7; move16(); @@ -180,8 +182,12 @@ void pitch_pred_linear_fit( t6 = BASOP_Util_Add_Mant32Exp( t3, e3, t4, e4, &e6 ); t7 = BASOP_Util_Add_Mant32Exp( t5, e5, t6, e6, &e7 ); /*Q31,e7*/ sum0_q = norm_l( t7 ); +#ifdef ISSUE_1866_replace_overflow_libdec + sum0 = round_fx_sat( L_shl( t7, sum0_q ) ); /*Q15,e7-sum0_q*/ //??sat +#else sum0 = round_fx_o( L_shl( t7, sum0_q ), &Overflow ); /*Q15,e7-sum0_q*/ - sum0_q = add( 15, sub( sum0_q, e7 ) ); /* sum0 is now Qsum0_q*/ +#endif + sum0_q = add( 15, sub( sum0_q, e7 ) ); /* sum0 is now Qsum0_q*/ } pit = 0; diff --git a/lib_dec/post_dec_fx.c b/lib_dec/post_dec_fx.c index cbcb225bc1c845d937119028fb6fcc025a19cfeb..02462abbd81ac342597bfd73d41e490ff05ba3c6 100644 --- a/lib_dec/post_dec_fx.c +++ b/lib_dec/post_dec_fx.c @@ -606,10 +606,12 @@ void cldfb_synth_set_bandsToZero( Word16 realQ1, imagQ1, flag, offset, WBcnt; Word16 perc_detect, perc_miss; Word16 i, k, tmp1, tmp2, tmp3, tmp, update_perc; +#ifndef ISSUE_1866_replace_overflow_libdec #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); #endif +#endif realQ1 = 0; @@ -656,8 +658,13 @@ void cldfb_synth_set_bandsToZero( /* use 16-bit precision of real and imag buffers */ realQ1 = extract_l( L_shr( rAnalysis[k][i], sub( 31 + 3 - 15, scaleFactor.lb_scale ) ) ); /*31 - (15 + scaleFactor.lb_scale) + 3 )*/ imagQ1 = extract_l( L_shr( iAnalysis[k][i], sub( 31 + 3 - 15, scaleFactor.lb_scale ) ) ); /* Q(-3), headroom */ +#ifdef ISSUE_1866_replace_overflow_libdec + nrgQ31 = L_mac0_sat( nrgQ31, realQ1, realQ1 ); //??sat + nrgQ31 = L_mac0_sat( nrgQ31, imagQ1, imagQ1 ); /* keep in Q(-6) */ //??sat +#else nrgQ31 = L_mac0_o( nrgQ31, realQ1, realQ1, &Overflow ); nrgQ31 = L_mac0_o( nrgQ31, imagQ1, imagQ1, &Overflow ); /* keep in Q(-6) */ +#endif } nrg_band[i] = ( nrgQ31 ); move16(); diff --git a/lib_dec/pvq_core_dec_fx.c b/lib_dec/pvq_core_dec_fx.c index f9c2db757dffc1b7be48fdc5fb69d973b68c41d8..d3630545f4a2a0c47c10b8b9662cb1c67578b33c 100644 --- a/lib_dec/pvq_core_dec_fx.c +++ b/lib_dec/pvq_core_dec_fx.c @@ -477,7 +477,7 @@ static void densitySymbolIndexDecode_fx( Word32 acc; Word16 alpha = 0; move16(); -#ifndef ISSUE_1796_replace_shl_o +#ifndef ISSUE_1866_replace_overflow_libdec #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); @@ -494,8 +494,8 @@ static void densitySymbolIndexDecode_fx( sym_freq = L_deposit_l( 1 ); angle = atan2_fx( SQRT_DIM_fx[opp_sz], SQRT_DIM_fx[near_sz] ); // Q13 -#ifdef ISSUE_1796_replace_shl_o - angle = shl_sat( angle, 1 ); +#ifdef ISSUE_1866_replace_overflow_libdec + angle = shl_sat( angle, 1 ); //??sat #else angle = shl_o( angle, 1, &Overflow ); #endif diff --git a/lib_dec/pvq_decode_fx.c b/lib_dec/pvq_decode_fx.c index c9ed050a2c2c8f542636bc0822c76817e5e4975a..85d4e355810de2b2e060b081b88ee90293343b6e 100644 --- a/lib_dec/pvq_decode_fx.c +++ b/lib_dec/pvq_decode_fx.c @@ -33,9 +33,11 @@ void pvq_decode_fx( Word32 L_yy, L_isqrt, L_tmp; UWord16 u16_tmp; +#ifndef ISSUE_1866_replace_overflow_libdec #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif entry = get_size_mpvq_calc_offset_fx( dim, k_val, h_mem ); /* get size & prepare H(adaptive table for entry.size=N_MPVQ(dim,k_val) */ @@ -103,12 +105,13 @@ void pvq_decode_fx( Mpy_32_16_ss( L_isqrt, shl( y[i], shift_num ), &L_tmp, &u16_tmp ); /* Q31*Q(0+x) *2*/ Mpy_32_16_ss( L_tmp, neg_gain_norm, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) *Q15 *2*/ -#ifdef ISSUE_1799_replace_L_shr_o - L_tmp = L_shr_sat( L_tmp, shift_tot ); +#ifdef ISSUE_1866_replace_overflow_libdec + L_tmp = L_shr_sat( L_tmp, shift_tot ); //??sat + xq[i] = round_fx_sat( L_tmp ); /* Q15 , array move */ //??sat #else L_tmp = L_shr_o( L_tmp, shift_tot, &Overflow ); -#endif xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15 , array move */ +#endif move16(); } } diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c index 09f5eda03dd1dc8c9749aed10a34c460acd378b1..94f18676c5bff23db0c78ccdb3be575f25c73bc6 100644 --- a/lib_dec/swb_tbe_dec_fx.c +++ b/lib_dec/swb_tbe_dec_fx.c @@ -634,9 +634,11 @@ void ivas_wb_tbe_dec_fx( Word32 dummy2[HILBERT_MEM_SIZE]; Word16 f, inc; Word64 W_tmp; +#ifndef ISSUE_1866_replace_overflow_libdec #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif TD_BWE_DEC_HANDLE hBWE_TD; hBWE_TD = st_fx->hBWE_TD; @@ -962,10 +964,10 @@ void ivas_wb_tbe_dec_fx( n = norm_s( max ); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { -#ifdef ISSUE_1796_replace_shl_o - shaped_wb_excitation_frac[i] = shl_sat( shaped_wb_excitation[i], n ); /*Q14*/ +#ifdef ISSUE_1866_replace_overflow_libdec + shaped_wb_excitation_frac[i] = shl_sat( shaped_wb_excitation[i], n ); /*Q14*/ //??sat #else - shaped_wb_excitation_frac[i] = shl_o( shaped_wb_excitation[i], n, &Overflow ); /*Q14*/ + shaped_wb_excitation_frac[i] = shl_o( shaped_wb_excitation[i], n, &Overflow ); /*Q14*/ #endif move16(); } @@ -974,8 +976,13 @@ void ivas_wb_tbe_dec_fx( move32(); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { +#ifdef ISSUE_1866_replace_overflow_libdec + L_tmp = L_mult_sat( shaped_wb_excitation_frac[i], shaped_wb_excitation_frac[i] ); /*Q29*/ //??sat + curr_frame_pow = L_add_sat( curr_frame_pow, L_shr( L_tmp, 7 ) ); /*Q22*/ //??sat +#else L_tmp = L_mult_o( shaped_wb_excitation_frac[i], shaped_wb_excitation_frac[i], &Overflow ); /*Q29*/ curr_frame_pow = L_add_o( curr_frame_pow, L_shr( L_tmp, 7 ), &Overflow ); /*Q22*/ +#endif } } curr_frame_pow_exp = add( n, n ); @@ -1169,7 +1176,11 @@ void ivas_wb_tbe_dec_fx( L_tmp = Mult_32_16( Lacc, 102 ); /* Q22 */ exp = norm_l( L_tmp ); +#ifdef ISSUE_1866_replace_overflow_libdec + tmp = round_fx_sat( L_shl( L_tmp, exp ) ); +#else tmp = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); +#endif exp = sub( add( exp, 22 ), 30 ); tmp = div_s( 16384, tmp ); L_tmp = Isqrt_lc( L_deposit_h( tmp ), &exp ); /* Q(31-exp) */ @@ -1285,9 +1296,11 @@ void wb_tbe_dec_fx( move16(); Word32 dummy2[HILBERT_MEM_SIZE]; Word16 f, inc; +#ifndef ISSUE_1866_replace_overflow_libdec #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif TD_BWE_DEC_HANDLE hBWE_TD; hBWE_TD = st_fx->hBWE_TD; @@ -1609,10 +1622,10 @@ void wb_tbe_dec_fx( n = norm_s( max ); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { -#ifdef ISSUE_1796_replace_shl_o - shaped_wb_excitation_frac[i] = shl_sat( shaped_wb_excitation[i], n ); /*Q14*/ +#ifdef ISSUE_1866_replace_overflow_libdec + shaped_wb_excitation_frac[i] = shl_sat( shaped_wb_excitation[i], n ); /*Q14*/ //??sat #else - shaped_wb_excitation_frac[i] = shl_o( shaped_wb_excitation[i], n, &Overflow ); /*Q14*/ + shaped_wb_excitation_frac[i] = shl_o( shaped_wb_excitation[i], n, &Overflow ); /*Q14*/ #endif move16(); } @@ -1621,8 +1634,13 @@ void wb_tbe_dec_fx( move32(); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { +#ifdef ISSUE_1866_replace_overflow_libdec + L_tmp = L_mult_sat( shaped_wb_excitation_frac[i], shaped_wb_excitation_frac[i] ); /*Q29*/ //??sat + curr_frame_pow = L_add_sat( curr_frame_pow, L_shr( L_tmp, 7 ) ); /*Q22*/ //??sat +#else L_tmp = L_mult_o( shaped_wb_excitation_frac[i], shaped_wb_excitation_frac[i], &Overflow ); /*Q29*/ curr_frame_pow = L_add_o( curr_frame_pow, L_shr( L_tmp, 7 ), &Overflow ); /*Q22*/ +#endif } } curr_frame_pow_exp = add( n, n ); @@ -1818,7 +1836,11 @@ void wb_tbe_dec_fx( L_tmp = Mult_32_16( Lacc, 102 ); /* Q22 */ exp = norm_l( L_tmp ); +#ifdef ISSUE_1866_replace_overflow_libdec + tmp = round_fx_sat( L_shl( L_tmp, exp ) ); //??sat +#else tmp = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); +#endif exp = sub( add( exp, 22 ), 30 ); tmp = div_s( 16384, tmp ); L_tmp = Isqrt_lc( L_deposit_h( tmp ), &exp ); /* Q(31-exp) */ diff --git a/lib_dec/syn_outp_fx.c b/lib_dec/syn_outp_fx.c index 95b98e8548b69d2c5f854bf40c1215f6bb2257ce..e5557fb99eaa7f8cc959cff5eb0deb0fa7cd9a15 100644 --- a/lib_dec/syn_outp_fx.c +++ b/lib_dec/syn_outp_fx.c @@ -67,7 +67,7 @@ void unscale_AGC( { Word16 i, fac, tmp, frame_fac, max_val; Word32 L_tmp; -#ifndef ISSUE_1796_replace_shl_o +#ifndef ISSUE_1866_replace_overflow_libdec #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); @@ -84,8 +84,8 @@ void unscale_AGC( max_val = s_max( max_val, abs_s( x[i] ) ); } BASOP_SATURATE_WARNING_OFF_EVS -#ifdef ISSUE_1796_replace_shl_o - tmp = shl_sat( 30000, Qx ); /* saturation can occur here */ +#ifdef ISSUE_1866_replace_overflow_libdec + tmp = shl_sat( 30000, Qx ); /* saturation can occur here */ //??sat #else tmp = shl_o( 30000, Qx, &Overflow ); /* saturation can occur here */ #endif diff --git a/lib_dec/tonalMDCTconcealment_fx.c b/lib_dec/tonalMDCTconcealment_fx.c index 16d445b9161bffc043c4cec8108369159970cae2..0cbecda362dedda3f55e0e61cf98eb02a0d0b320 100644 --- a/lib_dec/tonalMDCTconcealment_fx.c +++ b/lib_dec/tonalMDCTconcealment_fx.c @@ -724,9 +724,11 @@ static void ivas_CalcPowerSpecAndDetectTonalComponents_fx( Word16 invScaleFactors[FDNS_NPTS]; Word16 invScaleFactors_exp[FDNS_NPTS]; Word16 powerSpectrum_exp, tmp_exp, old_exp; +#ifndef ISSUE_1866_replace_overflow_libdec #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif Word16 nBands; @@ -857,7 +859,11 @@ static void ivas_CalcPowerSpecAndDetectTonalComponents_fx( /* 16 bits are now enough for storing the power spectrum */ FOR( i = 0; i < nSamples; i++ ) { +#ifdef ISSUE_1866_replace_overflow_libdec + hTonalMDCTConc->secondLastPowerSpectrum[i] = round_fx_sat( powerSpectrum[i] ); // Q31 - powerSpectrum_exp //??sat +#else hTonalMDCTConc->secondLastPowerSpectrum[i] = round_fx_o( powerSpectrum[i], &Overflow ); // Q31 - powerSpectrum_exp +#endif move32(); } @@ -882,10 +888,12 @@ static void CalcPowerSpecAndDetectTonalComponents( Word16 invScaleFactors[FDNS_NPTS]; Word16 invScaleFactors_exp[FDNS_NPTS]; Word16 powerSpectrum_exp, tmp_exp, old_exp; +#ifndef ISSUE_1866_replace_overflow_libdec #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); #endif +#endif nSamples = hTonalMDCTConc->nNonZeroSamples; @@ -975,7 +983,11 @@ static void CalcPowerSpecAndDetectTonalComponents( /* 16 bits are now enough for storing the power spectrum */ FOR( i = 0; i < nSamples; i++ ) { +#ifdef ISSUE_1866_replace_overflow_libdec + hTonalMDCTConc->secondLastPowerSpectrum[i] = round_fx_sat( powerSpectrum[i] ); // Q31-powerSpectrum_exp //??sat +#else hTonalMDCTConc->secondLastPowerSpectrum[i] = round_fx_o( powerSpectrum[i], &Overflow ); // Q31-powerSpectrum_exp +#endif move32(); } diff --git a/lib_dec/transition_dec_fx.c b/lib_dec/transition_dec_fx.c index 102a81b9d25868024baec7bb8b0019127d3037c5..ace403a84521f982396cf7f60940f5c1c5ede5b0 100644 --- a/lib_dec/transition_dec_fx.c +++ b/lib_dec/transition_dec_fx.c @@ -676,9 +676,11 @@ static void tc_dec_fx( Word16 j, sc; Word16 tempS; Word16 index; +#ifndef ISSUE_1866_replace_overflow_libdec #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /*----------------------------------------------------------------* * find the number of bits @@ -829,7 +831,11 @@ static void tc_dec_fx( j = s_min( L_SUBFR, add( imp_pos, L_IMPULSE2 ) ); FOR( ; i <= j; i++ ) { +#ifdef ISSUE_1866_replace_overflow_libdec + exc[i + i_subfr] = round_fx_sat( L_shl_sat( L_mult_sat( pt_shape[i], gain_trans ), sc ) ); /* (Qx * Q14 ) */ //??sat //??sat //??sat +#else exc[i + i_subfr] = round_fx_o( L_shl_o( L_mult_o( pt_shape[i], gain_trans, &Overflow ), sc, &Overflow ), &Overflow ); /* (Qx * Q14 ) */ +#endif move16(); } FOR( ; i < L_SUBFR; i++ )