From 98f539f8a018913e67b82285f4ca23bee697d4ae Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Sun, 14 Apr 2024 21:25:24 +0530 Subject: [PATCH 1/2] BASOP no glob extreme saturation changes pulled in. --- lib_com/basop_util.c | 13 + lib_com/bitalloc_fx.c | 7 +- lib_com/cldfb_evs.c | 18 + lib_com/cng_exc_fx.c | 24 + lib_com/codec_tcx_common.c | 8 + lib_com/enhancer_fx.c | 31 +- lib_com/env_stab.c | 10 + lib_com/est_tilt_fx.c | 18 + lib_com/fft_fx_evs.c | 18 +- lib_com/fft_rel_fx.c | 88 +- lib_com/gs_inact_switching_fx.c | 10 + lib_com/hp50.c | 4 + lib_com/hq2_noise_inject_fx.c | 8 + lib_com/hq_tools_fx.c | 36 +- lib_com/igf_base_fx.c | 4 + lib_com/lpc_tools_fx.c | 5 + lib_com/lsf_tools_fx.c | 4 + lib_com/modif_fs_fx.c | 53 +- lib_com/oper_32b.c | 5 +- lib_com/re8_util_fx.c | 5 +- lib_com/residu_fx.c | 4 + lib_com/stab_est_fx.c | 4 + lib_com/stat_noise_uv_mod_fx.c | 19 +- lib_com/swb_bwe_com_fx.c | 76 +- lib_com/swb_bwe_com_lr_fx.c | 19 +- lib_com/swb_tbe_com_fx.c | 127 +- lib_com/syn_filt_fx.c | 4 + lib_com/tcx_ltp_fx.c | 4 + lib_com/tcx_utils_fx.c | 34 +- lib_com/tec_com.c | 4 + lib_com/tools_fx.c | 24 +- lib_com/trans_inv_fx.c | 18 +- lib_com/wi_fx.c | 50 +- lib_com/window_ola_fx.c | 14 + lib_dec/FEC_HQ_core_fx.c | 17 +- lib_dec/FEC_HQ_phase_ecu_fx.c | 42 +- lib_dec/FEC_clas_estim_fx.c | 4 + lib_dec/FEC_fx.c | 24 + lib_dec/FEC_scale_syn_fx.c | 18 + lib_dec/LD_music_post_filter_fx.c | 21 +- lib_dec/acelp_core_switch_dec_fx.c | 4 + lib_dec/bass_psfilter_fx.c | 17 +- lib_dec/cng_dec_fx.c | 24 + lib_dec/d_gain2p_fx.c | 8 + lib_dec/dec_ace_fx.c | 13 +- lib_dec/dec_gen_voic_fx.c | 27 +- lib_dec/dec_higher_acelp_fx.c | 5 + lib_dec/dec_pit_exc_fx.c | 9 + lib_dec/dec_post_fx.c | 21 +- lib_dec/dec_tcx_fx.c | 79 +- lib_dec/er_dec_acelp_fx.c | 27 +- lib_dec/er_dec_tcx_fx.c | 53 +- lib_dec/er_sync_exc_fx.c | 8 + lib_dec/evs_dec_fx.c | 32 + lib_dec/fd_cng_dec_fx.c | 37 +- lib_dec/gain_dec_fx.c | 29 +- lib_dec/hq_hr_dec_fx.c | 4 + lib_dec/hq_lr_dec_fx.c | 21 +- lib_dec/igf_dec_fx.c | 17 + lib_dec/nelp_dec_fx.c | 12 + lib_dec/post_dec_fx.c | 27 + lib_dec/rst_dec_fx.c | 4 + lib_dec/swb_bwe_dec_fx.c | 4 + lib_dec/swb_bwe_dec_hr_fx.c | 8 + lib_dec/swb_tbe_dec_fx.c | 48 +- lib_dec/tonalMDCTconcealment_fx.c | 16 + lib_dec/voiced_dec_fx.c | 5 + lib_dec/waveadjust_fec_dec_fx.c | 13 +- lib_enc/SNR_calc_fx.c | 4 + lib_enc/acelp_core_switch_enc_fx.c | 11 + lib_enc/acelp_enc_util_fx.c | 15 + lib_enc/amr_wb_enc_fx.c | 4 + lib_enc/analy_sp_fx.c | 5 +- lib_enc/arith_coder_enc_fx.c | 4 + lib_enc/avq_cod_fx.c | 4 + lib_enc/bass_psfilter_enc_fx.c | 5 + lib_enc/cng_enc_fx.c | 3190 ++++++++++++++-------------- lib_enc/cod_ace_fx.c | 11 +- lib_enc/cod_tcx_fx.c | 28 + lib_enc/core_enc_init_fx.c | 9 + lib_enc/core_enc_ol_fx.c | 8 + lib_enc/detect_transient_fx.c | 6 +- lib_enc/dtx_fx.c | 4 + lib_enc/enc_acelp_fx.c | 5 + lib_enc/enc_acelpx_fx.c | 9 +- lib_enc/enc_amr_wb_fx.c | 11 +- lib_enc/enc_gen_voic_fx.c | 6 +- lib_enc/enc_higher_acelp_fx.c | 26 +- lib_enc/enc_nelp_fx.c | 4 + lib_enc/enc_pit_exc_fx.c | 16 + lib_enc/enc_tran_fx.c | 10 +- lib_enc/enc_uv_fx.c | 9 + lib_enc/energy_fx.c | 5 + lib_enc/ext_sig_ana_fx.c | 4 + lib_enc/fd_cng_enc_fx.c | 12 + lib_enc/find_tilt_fx.c | 9 + lib_enc/find_uv_fx.c | 5 +- lib_enc/gain_enc_fx.c | 16 + lib_enc/gaus_enc_fx.c | 18 + lib_enc/hf_cod_amrwb_fx.c | 2 +- lib_enc/hq_lr_enc_fx.c | 37 + lib_enc/igf_enc_fx.c | 23 + lib_enc/lp_exc_e_fx.c | 4 + lib_enc/lsf_msvq_ma_enc_fx.c | 24 + lib_enc/ltd_stable_fx.c | 12 + lib_enc/nelp_enc_fx.c | 55 + lib_enc/pit_enc_fx.c | 4 + lib_enc/pitch_ol2_fx.c | 5 + lib_enc/pvq_encode_fx.c | 4 + lib_enc/q_gain2p_fx.c | 8 + lib_enc/scale_enc_fx.c | 15 +- lib_enc/set_impulse_fx.c | 3 +- lib_enc/spec_flatness_fx.c | 4 + lib_enc/speech_music_classif_fx.c | 4 + lib_enc/swb_bwe_enc_fx.c | 45 +- lib_enc/swb_bwe_enc_hr_fx.c | 8 + lib_enc/swb_tbe_enc_fx.c | 56 +- lib_enc/tcq_core_enc_fx.c | 4 + lib_enc/tcx_ltp_enc_fx.c | 10 + lib_enc/tcx_utils_enc_fx.c | 18 +- lib_enc/tfa_enc_fx.c | 4 + lib_enc/tns_base_enc_fx.c | 8 + lib_enc/transient_detection_fx.c | 8 + lib_enc/updt_tar_fx.c | 3 +- lib_enc/vlpc_1st_cod_fx.c | 12 + lib_enc/voiced_enc_fx.c | 4 + lib_enc/waveadjust_fec_cod_fx.c | 4 + 127 files changed, 3661 insertions(+), 1668 deletions(-) diff --git a/lib_com/basop_util.c b/lib_com/basop_util.c index df9361b8b..40a3c3baa 100644 --- a/lib_com/basop_util.c +++ b/lib_com/basop_util.c @@ -370,7 +370,11 @@ static Word32 Sqrt32_common(Word32 m, if (m != 0) { BASOP_SATURATE_WARNING_OFF_EVS; +#ifdef BASOP_NOGLOB + m = L_mac_sat( SqrtTable[index], SqrtDiffTable[index], frac ); +#else m = L_mac(SqrtTable[index], SqrtDiffTable[index], frac); +#endif BASOP_SATURATE_WARNING_ON_EVS; } @@ -654,8 +658,13 @@ void BASOP_Util_Sqrt_InvSqrt_MantExp(Word16 mantissa, /*!< mantissa */ /* interpolate */ BASOP_SATURATE_WARNING_OFF_EVS; +#ifdef BASOP_NOGLOB + m = mac_r_sat( SqrtTable[index], SqrtDiffTable[index], frac ); + mi = msu_r_sat(ISqrtTable[index], ISqrtDiffTable[index], frac); +#else m = mac_r(SqrtTable[index], SqrtDiffTable[index], frac); mi = msu_r(ISqrtTable[index], ISqrtDiffTable[index], frac); +#endif BASOP_SATURATE_WARNING_ON_EVS; /* handle even/odd exponents */ @@ -2040,7 +2049,11 @@ Word16 BASOP_Util_Cmp_Mant32Exp /*!< o: flag: result of compari } BASOP_SATURATE_WARNING_OFF_EVS +#ifdef BASOP_NOGLOB + diff_m = L_sub_sat( a_m, b_m ); +#else diff_m = L_sub(a_m, b_m); +#endif BASOP_SATURATE_WARNING_ON_EVS diff_e = sub(a_e, b_e); diff --git a/lib_com/bitalloc_fx.c b/lib_com/bitalloc_fx.c index f27606273..8cb434f72 100644 --- a/lib_com/bitalloc_fx.c +++ b/lib_com/bitalloc_fx.c @@ -371,8 +371,11 @@ Word16 BitAllocF_fx ( exp1 = sub(norm_l(L_tmp1), 1); exp2 = norm_s(n); tmp = div_s(extract_h(L_shl(L_tmp1, exp1)), shl(n, exp2));/*15 + 15 + exp1 - 16 - exp2*/ - m_fx = shl(tmp, sub(exp2, exp1));/*Q14*/ - +#ifdef BASOP_NOGLOB + m_fx = shl_sat( tmp, sub( exp2, exp1 ) ); /*Q14*/ +#else + m_fx = shl( tmp, sub( exp2, exp1 ) ); /*Q14*/ +#endif t_fx = L_deposit_l(0); n = 0; move16(); diff --git a/lib_com/cldfb_evs.c b/lib_com/cldfb_evs.c index 63b3030fa..ee87b7c14 100644 --- a/lib_com/cldfb_evs.c +++ b/lib_com/cldfb_evs.c @@ -505,7 +505,11 @@ void cldfbAnalysisFiltering( HANDLE_CLDFB_FILTER_BANK cldfbBank, /* move and scale filter states */ FOR (i=0; iFilterStates_eg); FOR (i=0; ino_channels; j++) { +#ifdef BASOP_NOGLOB + rSubband16[i][j] = round_fx_sat( L_shl_sat( rSubband32[i][j], headRoom ) ); + iSubband16[i][j] = round_fx_sat(L_shl_sat(iSubband32[i][j], headRoom)); +#else rSubband16[i][j] = round_fx(L_shl(rSubband32[i][j], headRoom)); iSubband16[i][j] = round_fx(L_shl(iSubband32[i][j], headRoom)); +#endif } } @@ -1404,8 +1417,13 @@ GetEnergyCldfb( Word32 *energyLookahead, /*!< o: Q(*sf_energyLookahead) | p sm = sub(s_min(s, 44), 1); BASOP_SATURATE_WARNING_OFF_EVS /* nrg + 6.1e-5f => value 0x40000000, scale 44 */ +#ifdef BASOP_NOGLOB + *energyLookahead = L_add_sat( L_shr_sat( nrg, sub( s, sm ) ), + L_shr_sat(0x40000000, s_max(-31, s_min(31, sub(44, sm))))); +#else *energyLookahead = L_add(L_shr(nrg, sub(s, sm)), L_shr(0x40000000, s_max(-31, s_min(31, sub(44, sm))))); +#endif move32(); BASOP_SATURATE_WARNING_ON_EVS *sf_energyLookahead = sm; diff --git a/lib_com/cng_exc_fx.c b/lib_com/cng_exc_fx.c index 3873a8eb5..42c28af9e 100644 --- a/lib_com/cng_exc_fx.c +++ b/lib_com/cng_exc_fx.c @@ -199,7 +199,11 @@ void CNG_exc_fx( *------------------------------------------------------------*/ L_tmp = Mult_32_16(*lp_ener, Random(cng_ener_seed)); L_tmp = Mult_32_16(L_tmp, GAIN_VAR); +#ifdef BASOP_NOGLOB + L_tmp = L_add_sat( L_tmp, *lp_ener ); +#else L_tmp = L_add(L_tmp, *lp_ener); +#endif L_tmp = L_max(L_tmp, 1); /* enr = dot_product( exc2, exc2, L_SUBFR ) + 0.01f */ @@ -327,7 +331,11 @@ void CNG_exc_fx( #endif L_tmp = L_shr(L_tmp,1);/* 2*Q_exc+6 */ tmp = add(Q_exc,Q_exc); +#ifdef BASOP_NOGLOB + env[i] = L_shr_sat( L_tmp, tmp ); +#else env[i] = L_shr(L_tmp,tmp); +#endif move32();/* Q6 */ ptR++; ptI--; @@ -336,8 +344,13 @@ void CNG_exc_fx( FOR ( i=0; i Q25 */ L_tmp = L_msu(L_tmp, code[1], tmp); /* Q12 * Q15 -> Q28 */ +#ifdef BASOP_NOGLOB + L_tmp = L_shl_sat( L_mult( gain_code_hi, extract_h( L_tmp ) ), sc ); + pt_exc2[0] = msu_r_sat(L_tmp, -32768, pt_exc2[0]); +#else L_tmp = L_shl(L_mult(gain_code_hi, extract_h(L_tmp)), sc); pt_exc2[0] = msu_r(L_tmp, -32768, pt_exc2[0]); +#endif move16();/* in Q_exc */ FOR (i = 1; i < L_SUBFR-1; i++) @@ -243,11 +248,13 @@ void enhancer_fx( /* pt_exc2[i] += code[i] - tmp * code[i-1] - tmp * code[i+1] */ L_tmp = L_msu(-32768, code[i], -32768); L_tmp = L_msu(L_tmp, code[i + 1], tmp); - tmp16 = msu_r(L_tmp, code[i - 1], tmp); - L_tmp = L_shl(L_mult(gain_code_hi, tmp16), sc); #ifdef BASOP_NOGLOB + tmp16 = msu_r_sat( L_tmp, code[i - 1], tmp ); + L_tmp = L_shl_sat( L_mult( gain_code_hi, tmp16 ), sc ); pt_exc2[i] = msu_r_sat( L_tmp, -32768, pt_exc2[i] ); #else + tmp16 = msu_r( L_tmp, code[i - 1], tmp ); + L_tmp = L_shl( L_mult( gain_code_hi, tmp16 ), sc ); pt_exc2[i] = msu_r( L_tmp, -32768, pt_exc2[i] ); #endif move16(); /* in Q_exc */ @@ -257,7 +264,11 @@ void enhancer_fx( L_tmp = L_deposit_h(code[L_SUBFR - 1]);/*Q28 */ L_tmp = L_msu(L_tmp, code[L_SUBFR - 2], tmp);/*Q28 */ L_tmp = L_shl(L_mult(gain_code_hi, extract_h(L_tmp)), sc); +#ifdef BASOP_NOGLOB + pt_exc2[L_SUBFR - 1] = msu_r_sat( L_tmp, -32768, pt_exc2[L_SUBFR - 1] ); +#else pt_exc2[L_SUBFR - 1] = msu_r(L_tmp, -32768, pt_exc2[L_SUBFR - 1]); +#endif move16();/* in Q_exc */ test(); test(); @@ -268,7 +279,11 @@ void enhancer_fx( FOR (i = 0; i < L_SUBFR; i++) { /* excp[i] += pt_exc2[i] */ +#ifdef BASOP_NOGLOB + excp[i] = add_sat( excp[i], pt_exc2[i] ); +#else excp[i] = add(excp[i], pt_exc2[i]); +#endif move16(); } agc2_fx(pt_exc2, excp, L_SUBFR); @@ -694,9 +709,17 @@ Word16 E_UTIL_enhancer( L_tmp = L_msu0(L_tmp,tmp,code[1]); if (gain) { +#ifdef BASOP_NOGLOB + L_tmp = L_shl_sat( L_tmp, gain ); +#else L_tmp = L_shl(L_tmp,gain); +#endif } +#ifdef BASOP_NOGLOB + exc2[0] = msu_r_sat( L_tmp, -32768, exc2[0] ); +#else exc2[0] = msu_r(L_tmp,-32768, exc2[0]); +#endif move16(); FOR (i=1; i= 0) { ener = L_shr(ener,1); +#ifdef BASOP_NOGLOB + tmp = L_shr_sat( tmp, add( 1, i ) ); +#else tmp = L_shr(tmp, add(1,i)); +#endif } ELSE { tmp = L_shr(tmp,1); BASOP_SATURATE_WARNING_OFF_EVS +#ifdef BASOP_NOGLOB + ener = L_shr_sat( ener, sub( 1, i ) ); +#else ener = L_shr(ener, sub(1,i)); +#endif BASOP_SATURATE_WARNING_ON_EVS } diff --git a/lib_com/fft_fx_evs.c b/lib_com/fft_fx_evs.c index 9dec4315f..c7f310669 100644 --- a/lib_com/fft_fx_evs.c +++ b/lib_com/fft_fx_evs.c @@ -1071,7 +1071,11 @@ static void fft5_shift4_16fx( move16(); T3 = zRe[i4]; move16(); +#ifdef BASOP_NOGLOB + T4 = add_sat( T2, T3 ); +#else T4 = add(T2,T3); +#endif T5 = zRe[i2]; move16(); T6 = zRe[i3]; @@ -1179,13 +1183,19 @@ static void fft5_shift4_16fx( /* T2 = KP951056516 * Ts + KP587785252 * Tt; */ L_tmp = Mult_32_16(KP951056516_16FX,Ts); L_tmp = Madd_32_16(L_tmp,KP587785252_16FX,Tt); +#ifdef BASOP_NOGLOB + T2 = round_fx_sat( L_tmp ); +#else T2 = round_fx(L_tmp); - +#endif /* T3 = KP951056516 * Tt - KP587785252 * Ts; */ L_tmp = Mult_32_16(KP951056516_16FX,Tt); L_tmp = Msub_32_16(L_tmp,KP587785252_16FX,Ts); +#ifdef BASOP_NOGLOB + T3 = round_fx_sat( L_tmp ); +#else T3 = round_fx(L_tmp); - +#endif #ifdef BASOP_NOGLOB T6 = sub_sat(To, shr(Tp, 2)); T4 = add_sat(Tn, T6); @@ -2779,7 +2789,11 @@ void fft3_fx(const Word16 X[], Word16 Y[], const Word16 n) /* special case: i = 0 */ acc = L_mult(*RZ0++, 0x4000); acc = L_mac(acc, *RZ1++, 0x4000); +#ifdef BASOP_NOGLOB + *RY++ = mac_r_sat( acc, *RZ2++, 0x4000 ); +#else *RY++ = mac_r(acc, *RZ2++, 0x4000); +#endif move16(); /* first 3/12-- from 1 to (3*m/8)-1 */ diff --git a/lib_com/fft_rel_fx.c b/lib_com/fft_rel_fx.c index 49ae18103..04144515d 100644 --- a/lib_com/fft_rel_fx.c +++ b/lib_com/fft_rel_fx.c @@ -132,17 +132,34 @@ static void c_fft_fx( input_ptr1 = in_ptr + (const Word16)((uintptr_t)(*table_ptr++) >> (uintptr_t)shift); +#ifdef BASOP_NOGLOB + tmp1 = msu_r_sat( L_tmp1, *input_ptr1, 16384 ); + tmp3 = mac_r_sat(L_tmp1, *input_ptr1++, 16384); +#else tmp1 = msu_r(L_tmp1, *input_ptr1, 16384); tmp3 = mac_r(L_tmp1, *input_ptr1++, 16384); - +#endif input_ptr2 = in_ptr + (const Word16)((uintptr_t)(*table_ptr++) >> (uintptr_t)shift); input_ptr3 = in_ptr + (const Word16)((uintptr_t)(*table_ptr++) >> (uintptr_t)shift); L_tmp1 = L_mult(*input_ptr2++, 16384); +#ifdef BASOP_NOGLOB + tmp2 = mac_r_sat( L_tmp1, *input_ptr3, 16384 ); + tmp4 = msu_r_sat(L_tmp1, *input_ptr3++, 16384); +#else tmp2 = mac_r(L_tmp1, *input_ptr3, 16384); tmp4 = msu_r(L_tmp1, *input_ptr3++, 16384); - +#endif L_tmp1 = L_mult(tmp3, 16384); +#ifdef BASOP_NOGLOB + out_ptr[k] = mac_r_sat( L_tmp1, tmp2, 16384 ); + move16(); + out_ptr[k+4] = msu_r_sat(L_tmp1, tmp2, 16384); + move16(); + + tmp2 = mac_r_sat(L_tmp2, *input_ptr1, 16384); + tmp3 = msu_r_sat(L_tmp2, *input_ptr1, 16384); +#else out_ptr[k] = mac_r(L_tmp1, tmp2, 16384); move16(); out_ptr[k+4] = msu_r(L_tmp1, tmp2, 16384); @@ -150,28 +167,49 @@ static void c_fft_fx( tmp2 = mac_r(L_tmp2, *input_ptr1, 16384); tmp3 = msu_r(L_tmp2, *input_ptr1, 16384); - +#endif L_tmp2 = L_mult(*input_ptr2, 16384); L_tmp1 = L_mult(tmp1, 16384); +#ifdef BASOP_NOGLOB + tmp1 = msu_r_sat( L_tmp2, *input_ptr3, 16384 ); + out_ptr[k + 2] = mac_r_sat( L_tmp1, tmp1, 16384 ); + move16(); + out_ptr[k + 6] = msu_r_sat( L_tmp1, tmp1, 16384 ); + move16(); +#else tmp1 = msu_r(L_tmp2, *input_ptr3, 16384); out_ptr[k+2] = mac_r(L_tmp1, tmp1, 16384); move16(); out_ptr[k+6] = msu_r(L_tmp1, tmp1, 16384); move16(); - +#endif L_tmp1 = L_mult(tmp2, 16384); +#ifdef BASOP_NOGLOB + tmp2 = mac_r_sat( L_tmp2, *input_ptr3, 16384 ); + out_ptr[k+1] = mac_r_sat(L_tmp1, tmp2, 16384); + move16(); + out_ptr[k+5] = msu_r_sat(L_tmp1, tmp2, 16384); + move16(); +#else tmp2 = mac_r(L_tmp2, *input_ptr3, 16384); out_ptr[k+1] = mac_r(L_tmp1, tmp2, 16384); move16(); out_ptr[k+5] = msu_r(L_tmp1, tmp2, 16384); move16(); - +#endif L_tmp1 = L_mult(tmp3, 16384); +#ifdef BASOP_NOGLOB + out_ptr[k + 3] = msu_r_sat( L_tmp1, tmp4, 16384 ); + move16(); + out_ptr[k+7] = mac_r_sat(L_tmp1, tmp4, 16384); + move16(); +#else out_ptr[k+3] = msu_r(L_tmp1, tmp4, 16384); move16(); out_ptr[k+7] = mac_r(L_tmp1, tmp4, 16384); move16(); +#endif } /* Remaining Stages */ @@ -378,6 +416,26 @@ void r_fft_fx_lc( FOR (i = 2; i <= SIZE2; i += 2) { Ltmp1_imag = L_mult(temp[i+1], 16384); +#ifdef BASOP_NOGLOB + Ltmp1_imag = L_msu_sat( Ltmp1_imag, *ptrDn, 16384 ); + tmp2_real = add_sat( temp[i + 1], *ptrDn-- ); + + Ltmp1_real = L_mult(temp[i], 16384); + Ltmp1_real = L_mac_sat( Ltmp1_real, *ptrDn, 16384 ); + tmp2_imag = sub(*ptrDn--, temp[i]); + + + *ptRealUp++ = msu_r_sat( L_mac_sat( Ltmp1_real, tmp2_real, phs_tbl[i] ), tmp2_imag, phs_tbl[i + 1] ); + move16(); + *ptImaDn-- = mac_r_sat( L_mac_sat( Ltmp1_imag, tmp2_imag, phs_tbl[i] ), tmp2_real, phs_tbl[i + 1] ); + move16(); + Ltmp1 = L_mac_sat( L_negate( Ltmp1_imag ), tmp2_real, *phstbl_ptrDn ); + Ltmp1_real = L_mac_sat( Ltmp1_real, tmp2_imag, *phstbl_ptrDn-- ); + *ptImaUp++ = msu_r_sat( Ltmp1, tmp2_imag, *phstbl_ptrDn ); + move16(); + *ptRealDn-- = mac_r_sat( Ltmp1_real, tmp2_real, *phstbl_ptrDn-- ); + move16(); +#else Ltmp1_imag = L_msu(Ltmp1_imag, *ptrDn, 16384); tmp2_real = add(temp[i+1], *ptrDn--); @@ -396,6 +454,7 @@ void r_fft_fx_lc( move16(); *ptRealDn-- = mac_r(Ltmp1_real, tmp2_real, *phstbl_ptrDn--); move16(); +#endif } } ELSE /* The ifFT part */ @@ -423,6 +482,24 @@ void r_fft_fx_lc( /* Now, handle the remaining positive frequencies */ FOR (i = 2; i <= SIZE2; i += 2) { +#ifdef BASOP_NOGLOB + Ltmp1_imag = L_mult( *ptImaDn, 16384 ); + Ltmp1_imag = L_msu_sat( Ltmp1_imag, *ptImaUp, 16384 ); + tmp2_real = add_sat( *ptImaDn--, *ptImaUp++ ); + Ltmp1_real = L_mult( *ptRealUp, 16384 ); + Ltmp1_real = L_mac_sat( Ltmp1_real, *ptRealDn, 16384 ); + tmp2_imag = sub_sat( *ptRealUp++, *ptRealDn-- ); + temp[i] = mac_r_sat( L_msu_sat( Ltmp1_real, tmp2_real, phs_tbl[i] ), tmp2_imag, phs_tbl[i + 1] ); + move16(); + temp[i + 1] = mac_r_sat( L_mac_sat( Ltmp1_imag, tmp2_imag, phs_tbl[i] ), tmp2_real, phs_tbl[i + 1] ); + move16(); + Ltmp1 = L_mac_sat( L_negate( Ltmp1_imag ), tmp2_real, *phstbl_ptrDn ); + Ltmp1_real = L_msu_sat( Ltmp1_real, tmp2_imag, *phstbl_ptrDn-- ); + *ptrDn-- = msu_r_sat( Ltmp1, tmp2_imag, *phstbl_ptrDn ); + move16(); + *ptrDn-- = msu_r_sat( Ltmp1_real, tmp2_real, *phstbl_ptrDn-- ); + move16(); +#else Ltmp1_imag = L_mult(*ptImaDn, 16384); Ltmp1_imag = L_msu(Ltmp1_imag, *ptImaUp, 16384); tmp2_real = add(*ptImaDn--, *ptImaUp++); @@ -441,6 +518,7 @@ void r_fft_fx_lc( move16(); *ptrDn-- = msu_r(Ltmp1_real, tmp2_real, *phstbl_ptrDn--); move16(); +#endif } /* Perform the complex ifFT */ diff --git a/lib_com/gs_inact_switching_fx.c b/lib_com/gs_inact_switching_fx.c index 8a52a8efc..5a9c9a62f 100644 --- a/lib_com/gs_inact_switching_fx.c +++ b/lib_com/gs_inact_switching_fx.c @@ -129,8 +129,13 @@ void Inac_swtch_ematch_fx( FOR (j = 0; j < 8; j ++) { L_tmp = L_mult(*pt_exc,ftmp); /* Q_exc*Q0 -> Q(Q_exc+1) */ +#ifdef BASOP_NOGLOB + L_tmp = L_shl_sat( L_tmp, add( exp, 15 ) ); /* Q(Q_exc+1) -> Q(16+Q_exc)*/ + *pt_exc = round_fx_sat(L_tmp); +#else L_tmp = L_shl(L_tmp, add(exp,15)); /* Q(Q_exc+1) -> Q(16+Q_exc)*/ *pt_exc = round_fx(L_tmp); +#endif pt_exc++; } } @@ -139,8 +144,13 @@ void Inac_swtch_ematch_fx( FOR (j = 0; j < 16; j ++) { L_tmp = L_mult(*pt_exc,ftmp); /* Q_exc*Q0 -> Q(Q_exc+1) */ +#ifdef BASOP_NOGLOB + L_tmp = L_shl_sat( L_tmp, add( exp, 15 ) ); /* Q(Q_exc+1) -> Q(16+Q_exc)*/ + *pt_exc = round_fx_sat(L_tmp); /*Q_exc*/ +#else L_tmp = L_shl(L_tmp, add(exp,15)); /* Q(Q_exc+1) -> Q(16+Q_exc)*/ *pt_exc = round_fx(L_tmp); /*Q_exc*/ +#endif pt_exc++; } } diff --git a/lib_com/hp50.c b/lib_com/hp50.c index cfedfc045..48c3de609 100644 --- a/lib_com/hp50.c +++ b/lib_com/hp50.c @@ -322,7 +322,11 @@ void hp20(Word16 signal[], /* i/o: signal to filter any * prescale = getScaleFactor16(signal, lg); prescaleOld = extract_l(mem[4]); +#ifdef BASOP_NOGLOB + diff = norm_l( L_shl_sat( mem[2], prescaleOld ) ); +#else diff = norm_l(L_shl(mem[2], prescaleOld)); +#endif if (mem[2] != 0) { prescale = s_min(prescale, diff); diff --git a/lib_com/hq2_noise_inject_fx.c b/lib_com/hq2_noise_inject_fx.c index f83584a06..9763255a2 100644 --- a/lib_com/hq2_noise_inject_fx.c +++ b/lib_com/hq2_noise_inject_fx.c @@ -450,7 +450,11 @@ void hq2_noise_inject_fx( tmp = sub(Q_env_fx[k],Q_Ep_fx[k]); tmp = sub(tmp,Q_speech); tmp = add(tmp,25); +#ifdef BASOP_NOGLOB + L_tmp = L_shr_sat( L_tmp2, tmp ); /*Q7 */ +#else L_tmp = L_shr(L_tmp2,tmp);/*Q7 */ +#endif tmp = extract_l(L_min(L_tmp,192));/* */ fac_fx = extract_h(L_shl(L_mult(fac_fx,tmp),8));/*Q12 */ } @@ -460,7 +464,11 @@ void hq2_noise_inject_fx( L_tmp2 = Mult_32_16(env_fx[k],tmp);/*Q(Q_env_fx[k]+0-15 = Q_env_fx[k]-15) */ L_tmp2 = Mult_32_16(L_tmp2,20480);/*Q(Q_env_fx[k]-15+14-15 = Q_env_fx[k]-16) */ tmp = sub(Q_env_fx[k],23); +#ifdef BASOP_NOGLOB + L_tmp = L_shr_sat( L_tmp2, tmp ); /*Q7 */ +#else L_tmp = L_shr(L_tmp2,tmp);/*Q7 */ +#endif tmp = extract_l((L_min(L_tmp,192)));/* */ fac_fx = extract_h(L_shl(L_mult(fac_fx,tmp),8));/*Q12 */ } diff --git a/lib_com/hq_tools_fx.c b/lib_com/hq_tools_fx.c index 88b4340a4..2fedf796b 100644 --- a/lib_com/hq_tools_fx.c +++ b/lib_com/hq_tools_fx.c @@ -88,7 +88,11 @@ void hq_swb_harmonic_calc_norm_envelop_fx( FOR(n_lag = 0; n_lag < n_lag_now; n_lag++) { L_tmp = L_abs(L_SWB_signal[n_lag]); +#ifdef BASOP_NOGLOB + L_envelope[env_index] = L_add_sat( L_envelope[env_index], L_tmp ); +#else L_envelope[env_index] = L_add(L_envelope[env_index], L_tmp); +#endif move32(); } env_index = add(env_index, 1); @@ -105,7 +109,11 @@ void hq_swb_harmonic_calc_norm_envelop_fx( FOR(n_lag = 0; n_lag < n_lag_now; n_lag++) { L_tmp = L_abs(L_SWB_signal[add(n_freq, n_lag)]); +#ifdef BASOP_NOGLOB + L_envelope[env_index] = L_add_sat( L_envelope[env_index], L_tmp ); +#else L_envelope[env_index] = L_add(L_envelope[env_index], L_tmp); +#endif move32(); } env_index = add(env_index, 1); @@ -122,7 +130,11 @@ void hq_swb_harmonic_calc_norm_envelop_fx( FOR(n_lag = 0; n_lag < n_lag_now; n_lag++) { L_tmp = L_abs(L_SWB_signal[add(n_freq, n_lag)]); +#ifdef BASOP_NOGLOB + L_envelope[env_index] = L_add_sat( L_envelope[env_index], L_tmp ); +#else L_envelope[env_index] = L_add(L_envelope[env_index], L_tmp); +#endif move32(); } env_index = add(env_index, 1); @@ -2336,7 +2348,11 @@ void hq_wb_nf_bwe_fx( #endif } +#ifdef BASOP_NOGLOB + IF( GT_32( L_tmp2, L_shl_sat( min_coef_fx, sub( exp, 13 ) ) ) ) /*exp */ +#else IF(GT_32(L_tmp2, L_shl(min_coef_fx, sub(exp, 13))))/*exp */ +#endif { L_tmp2 = L_shr(min_coef_fx, 1); exp = 12; @@ -2353,7 +2369,11 @@ void hq_wb_nf_bwe_fx( /* smooth the noise magnitudes between inter-frame */ test(); test(); +#ifdef BASOP_NOGLOB + IF( GT_32( prev_avrg_norm_fx, L_shr( avrg_norm_fx, 1 ) ) && LT_32( prev_avrg_norm_fx, L_shl_sat( avrg_norm_fx, 1 ) ) && prev_is_transient == 0 ) +#else IF(GT_32(prev_avrg_norm_fx, L_shr(avrg_norm_fx, 1)) && LT_32(prev_avrg_norm_fx, L_shl(avrg_norm_fx, 1)) && prev_is_transient == 0) +#endif { exp1 = norm_l(prev_env_fx[sfm]); L_tmp1 = L_shl(prev_env_fx[sfm], exp1);/* prev_env_Q[sfm] +exp1 */ @@ -2411,8 +2431,13 @@ void hq_wb_nf_bwe_fx( test(); test(); test(); +#ifdef BASOP_NOGLOB + IF( EQ_16( sfm, sub( SFM_N_WB, 1 ) ) && prev_is_transient == 0 && GT_32( prev_normq_fx[sfm], L_shr( L_normq_v[sfm], 1 ) ) + && LT_32(prev_normq_fx[sfm], L_shl_sat(L_normq_v[sfm], 1)) && LE_16(bitalloc_var_fx, 4915)) +#else IF(EQ_16(sfm, sub(SFM_N_WB, 1)) && prev_is_transient == 0 && GT_32(prev_normq_fx[sfm], L_shr(L_normq_v[sfm], 1)) && LT_32(prev_normq_fx[sfm], L_shl(L_normq_v[sfm], 1)) && LE_16(bitalloc_var_fx, 4915)) +#endif { Word32 *p_prev_coeff_out = prev_coeff_out_fx; FOR(i = add(sfm_start[sfm], 12); i < sfm_end[sfm]; i++) @@ -2421,12 +2446,21 @@ void hq_wb_nf_bwe_fx( test(); test(); test(); +#ifdef BASOP_NOGLOB + IF( GT_32( L_abs( L_coeff_out[i] ), L_shl_sat( L_abs( *p_prev_coeff_out ), 2 ) ) + || LT_32(L_abs(L_coeff_out[i]), L_shr(L_abs(*p_prev_coeff_out), 2)) + || ((R[sfm] == 0 || *prev_R == 0) && add_sat(R[sfm], *prev_R) != 0)) +#else IF(GT_32(L_abs(L_coeff_out[i]), L_shl(L_abs(*p_prev_coeff_out), 2)) || LT_32(L_abs(L_coeff_out[i]), L_shr(L_abs(*p_prev_coeff_out), 2)) || ((R[sfm] == 0 || *prev_R == 0) && add(R[sfm], *prev_R) != 0)) +#endif { +#ifdef BASOP_NOGLOB + L_tmp = L_add_sat( L_shr( L_abs( L_coeff_out[i] ), 1 ), L_shr( L_abs( *p_prev_coeff_out ), 1 ) ); +#else L_tmp = L_add(L_shr(L_abs(L_coeff_out[i]), 1), L_shr(L_abs(*p_prev_coeff_out), 1)); - +#endif if (L_coeff_out[i] <= 0) { L_tmp = L_negate(L_tmp); diff --git a/lib_com/igf_base_fx.c b/lib_com/igf_base_fx.c index c10429a84..95008e3b0 100644 --- a/lib_com/igf_base_fx.c +++ b/lib_com/igf_base_fx.c @@ -1116,7 +1116,11 @@ void IGFCommonFuncsMDCTSquareSpec(const Word16 sqrtBgn, FOR (i = sqrtBgn; i < sqrtEnd; i++) { +#ifdef BASOP_NOGLOB + tmp = round_fx_sat( L_shl_sat( mdctSpec[i], s1 ) ); +#else tmp = round_fx(L_shl(mdctSpec[i], s1)); +#endif mdctSquareSpec[j++] = L_mult0(tmp, tmp); move32(); } diff --git a/lib_com/lpc_tools_fx.c b/lib_com/lpc_tools_fx.c index 1733137c7..3059e4a45 100644 --- a/lib_com/lpc_tools_fx.c +++ b/lib_com/lpc_tools_fx.c @@ -1404,8 +1404,13 @@ void E_LPC_a_lsf_isf_conversion(Word16 *lpcCoeffs, Word16 *lsf, const Word16 * Word16 ImAr = extract_h(L_sub(ImagFFT[i], ImagFFT[N/2-i])); Word16 ImBr = extract_h((L_negate(L_add(ImagFFT[i], ImagFFT[N/2-i])))); BASOP_SATURATE_WARNING_OFF_EVS +#ifdef BASOP_NOGLOB + tmpw15.v.re = mac_r_sat( L_mult( ptwiddle->v.im, pwn17->v.re ), ptwiddle->v.re, pwn17->v.im ); + tmpw15.v.im = msu_r_sat(L_mult(ptwiddle->v.im, pwn17->v.im), ptwiddle->v.re, pwn17->v.re); +#else tmpw15.v.re = mac_r(L_mult(ptwiddle->v.im, pwn17->v.re), ptwiddle->v.re, pwn17->v.im); tmpw15.v.im = msu_r(L_mult(ptwiddle->v.im, pwn17->v.im), ptwiddle->v.re, pwn17->v.re); +#endif BASOP_SATURATE_WARNING_ON_EVS RealOut[i] = msu_r(L_msu(L_msu(L_mult(ReAr, pwn17->v.re), ImAr, pwn17->v.im), ReBr, pwn15->v.im), ImBr, pwn15->v.re); move16(); diff --git a/lib_com/lsf_tools_fx.c b/lib_com/lsf_tools_fx.c index 24586a23c..d1aa039b5 100644 --- a/lib_com/lsf_tools_fx.c +++ b/lib_com/lsf_tools_fx.c @@ -2534,7 +2534,11 @@ void lsf2lsp_fx( { offset = negate(offset); } +#ifdef BASOP_NOGLOB + L_tmp = L_mult( sub_sat( offset, lsf_tmp ), round_fx( L_shl( L_and( L_tmp, 0xFFFF ), 15 ) ) ); +#else L_tmp = L_mult(sub(offset, lsf_tmp), round_fx(L_shl(L_and(L_tmp, 0xFFFF), 15))); +#endif L_tmp = L_msu(L_tmp, lsf_tmp, -32768); lsp[i] = round_fx(L_tmp); } diff --git a/lib_com/modif_fs_fx.c b/lib_com/modif_fs_fx.c index 7d42b2689..8cd86a314 100644 --- a/lib_com/modif_fs_fx.c +++ b/lib_com/modif_fs_fx.c @@ -207,8 +207,13 @@ Word16 modify_Fs_fx( /* o : length of output Q0 */ sigPtr = signal_fx+lg+mem_len+i; move16(); /*+i*/ L_tmp = syn_kern_16(0, A_fx, sigPtr); +#ifdef BASOP_NOGLOB + L_tmp = L_shl_sat( L_tmp, 3 ); + *sigPtr = round_fx_sat(L_tmp); /* AZ ringing padding */ +#else L_tmp = L_shl(L_tmp, 3); *sigPtr = round_fx(L_tmp); /* AZ ringing padding */ +#endif } mem_preemph_fx = signal_fx[mem_len+lg-LEN_WIN_SSS - 1]; move16(); @@ -232,8 +237,11 @@ Word16 modify_Fs_fx( /* o : length of output Q0 */ FOR(i=0; ifilter_fx, frac, fac_num, filt_len_tmp ) ); +#else sigOut_fx[i] = round_fx(Interpol_lc_fx( sigIn_ptr, cfg_ptr_fx->filter_fx, frac, fac_num, filt_len_tmp )); - +#endif frac = add(frac,fracstep); j = sub(fac_num, frac); @@ -747,7 +755,12 @@ void Decimate_allpass_steep_fx( mem[ 2*ALLPASSSECTIONS_STEEP-1 ] = extract_h( Lacc1 ); /* Qx */ sum = mult_r( out_fx[0], 16384 ); /* Qx */ - out_fx[0] = add( sum, mult_r(temp[ALLPASSSECTIONS_STEEP-1], 16384 )); /* Qx */ move16(); +#ifdef BASOP_NOGLOB + out_fx[0] = add_sat( sum, mult_r( temp[ALLPASSSECTIONS_STEEP - 1], 16384 ) ); /* Qx */ +#else + out_fx[0] = add( sum, mult_r( temp[ALLPASSSECTIONS_STEEP - 1], 16384 ) ); /* Qx */ +#endif + move16(); FOR ( k = 1; k < N/2; k++) @@ -807,7 +820,11 @@ void Decimate_allpass_steep_fx( sum = mult_r( out_fx[k], 16384 ); /* Qx */ +#ifdef BASOP_NOGLOB + out_fx[k] = add_sat( sum, mult_r( temp[ALLPASSSECTIONS_STEEP - 1], 16384 ) ); +#else out_fx[k] = add( sum, mult_r( temp[ALLPASSSECTIONS_STEEP-1], 16384 ) ); +#endif move16(); /* Qx */ } @@ -1228,11 +1245,23 @@ void interpolate_3_over_1_allpass_fx( Vu[1] = mem[1] + filt_coeff[1] * ( Vu[0] - mem[2] ); mem[3] = mem[2] + filt_coeff[2] * ( Vu[1] - mem[3] );*/ +#ifdef BASOP_NOGLOB + Vu[0] = add_sat( mem_fx[0], mult_r( filt_coeff_fx[0], sub_sat( input_fx[i], mem_fx[1] ) ) ); +#else Vu[0] = add(mem_fx[0], mult_r(filt_coeff_fx[0], sub(input_fx[i], mem_fx[1]))); +#endif move16();/* all Vu's in : Q_current*/ +#ifdef BASOP_NOGLOB + Vu[1] = add_sat( mem_fx[1], mult_r( filt_coeff_fx[1], sub_sat( Vu[0], mem_fx[2] ) ) ); +#else Vu[1] = add(mem_fx[1], mult_r(filt_coeff_fx[1], sub(Vu[0], mem_fx[2]))); +#endif move16(); +#ifdef BASOP_NOGLOB + mem_fx[3] = add_sat( mem_fx[2], mult_r( filt_coeff_fx[2], sub_sat( Vu[1], mem_fx[3] ) ) ); +#else mem_fx[3] = add(mem_fx[2], mult_r(filt_coeff_fx[2], sub(Vu[1], mem_fx[3]))); +#endif move16(); @@ -1247,9 +1276,17 @@ void interpolate_3_over_1_allpass_fx( /* Vm[0] = mem[0] + filt_coeff[3] * (input[i]-mem[4]); Vm[1] = mem[4] + filt_coeff[4] * (Vm[0]-mem[5]); mem[6] = mem[5] + filt_coeff[5] * (Vm[1]-mem[6]); */ +#ifdef BASOP_NOGLOB + Vm[0] = add_sat( mem_fx[0], mult_r( filt_coeff_fx[3], sub_sat( input_fx[i], mem_fx[4] ) ) ); +#else Vm[0] = add(mem_fx[0], mult_r(filt_coeff_fx[3], sub(input_fx[i], mem_fx[4]))); +#endif move16(); +#ifdef BASOP_NOGLOB + Vm[1] = add_sat( mem_fx[4], mult_r( filt_coeff_fx[4], sub_sat( Vm[0], mem_fx[5] ) ) ); +#else Vm[1] = add(mem_fx[4], mult_r(filt_coeff_fx[4], sub(Vm[0], mem_fx[5]))); +#endif move16(); #ifdef BASOP_NOGLOB mem_fx[6] = add_sat( mem_fx[5], mult_r( filt_coeff_fx[5], sub_sat( Vm[1], mem_fx[6] ) ) ); @@ -1269,9 +1306,17 @@ void interpolate_3_over_1_allpass_fx( /* Vl[0] = mem[0] + filt_coeff[6] * (input[i]-mem[7]); Vl[1] = mem[7] + filt_coeff[7] * (Vl[0]-mem[8]); mem[9] = mem[8] + filt_coeff[8] * (Vl[1]-mem[9]); */ +#ifdef BASOP_NOGLOB + Vl[0] = add_sat( mem_fx[0], mult_r( filt_coeff_fx[6], sub_sat( input_fx[i], mem_fx[7] ) ) ); +#else Vl[0] = add(mem_fx[0], mult_r(filt_coeff_fx[6], sub(input_fx[i], mem_fx[7]))); +#endif move16(); +#ifdef BASOP_NOGLOB + Vl[1] = add_sat( mem_fx[7], mult_r( filt_coeff_fx[7], sub_sat( Vl[0], mem_fx[8] ) ) ); +#else Vl[1] = add(mem_fx[7], mult_r(filt_coeff_fx[7], sub(Vl[0], mem_fx[8]))); +#endif move16(); #ifdef BASOP_NOGLOB mem_fx[9] = add_sat( mem_fx[8], mult_r( filt_coeff_fx[8], sub_sat( Vl[1], mem_fx[9] ) ) ); @@ -1294,7 +1339,11 @@ void interpolate_3_over_1_allpass_fx( { mem_temp = out_fx[i]; move16(); +#ifdef BASOP_NOGLOB + out_fx[i] = sub_sat( mult_r( 18768 /*0.57276865021499168f Q15*/, add_sat( mem_fx[12], mem_fx[11] ) ), mult_r( 2425 /*0.074004974641176793f Q15*/, add_sat( mem_temp, mem_fx[10] ) ) ); +#else out_fx[i] = sub(mult_r(18768/*0.57276865021499168f Q15*/, add(mem_fx[12], mem_fx[11])), mult_r(2425/*0.074004974641176793f Q15*/,add(mem_temp,mem_fx[10]))); +#endif mem_fx[10] = mem_fx[11]; move16(); mem_fx[11] = mem_fx[12]; diff --git a/lib_com/oper_32b.c b/lib_com/oper_32b.c index de85bc267..f08783a2e 100644 --- a/lib_com/oper_32b.c +++ b/lib_com/oper_32b.c @@ -400,8 +400,11 @@ Word32 Div_32 (Word32 L_num, Word16 denom_hi, Word16 denom_lo) lo = L_Extract_lc (L_32, &hi); n_lo = L_Extract_lc (L_num, &n_hi); L_32 = Mpy_32 (n_hi, n_lo, hi, lo); +#ifdef BASOP_NOGLOB + L_32 = L_shl_sat( L_32, 2 ); +#else L_32 = L_shl (L_32, 2); - +#endif return (L_32); } diff --git a/lib_com/re8_util_fx.c b/lib_com/re8_util_fx.c index 012441be6..aea7581da 100644 --- a/lib_com/re8_util_fx.c +++ b/lib_com/re8_util_fx.c @@ -276,8 +276,11 @@ static Word16 re8_identify_absolute_leader_fx( /* o : integer indicating if y i { Ls = L_mac( Ls, y[i], y[i]); } +#ifdef BASOP_NOGLOB + s = extract_h( L_shl_sat( Ls, 16 - ( 3 + 1 ) ) ); /* s can saturate here */ +#else s = extract_h(L_shl(Ls, 16-(3+1))); /* s can saturate here */ - +#endif /*-----------------------------------------------------------------------* * compute the index 0 <= ka <= NB_LEADER+1 which identifies an absolute leader of Q0, Q2, Q3 or Q4 * diff --git a/lib_com/residu_fx.c b/lib_com/residu_fx.c index 2c3624a5d..bf076d4d0 100644 --- a/lib_com/residu_fx.c +++ b/lib_com/residu_fx.c @@ -127,7 +127,11 @@ void Residu3_10_fx( s64 = W_mac_16_16(s64, x[i-j], a[j]); } s = W_shl_sat_l(s64, q); +#ifdef BASOP_NOGLOB + y[i] = round_fx_sat( s ); +#else y[i] = round_fx(s); +#endif } } /*--------------------------------------------------------------------* diff --git a/lib_com/stab_est_fx.c b/lib_com/stab_est_fx.c index e6b55fe71..a5b36f54a 100644 --- a/lib_com/stab_est_fx.c +++ b/lib_com/stab_est_fx.c @@ -74,7 +74,11 @@ Word16 stab_est_fx( { /*fcorr += ftmp_c*ftmp_c;*/ tmp16 = sub(lt_diff_etot[i], mean_diff); +#ifdef BASOP_NOGLOB + L_tmp = L_mac0_sat( L_tmp, tmp16, tmp16 ); +#else L_tmp = L_mac0(L_tmp, tmp16, tmp16); +#endif } /*------------------------------------------------------------------------* * Update diff --git a/lib_com/stat_noise_uv_mod_fx.c b/lib_com/stat_noise_uv_mod_fx.c index 32be86394..70f083523 100644 --- a/lib_com/stat_noise_uv_mod_fx.c +++ b/lib_com/stat_noise_uv_mod_fx.c @@ -264,7 +264,11 @@ void stat_noise_uv_mod_fx( tmp_res = div_s(1<<14, tmp_den); /* 15+14-Q_local-tmp_shift-Q_ge+16 */ L_tmp_res = Mult_32_16(*ge_sm, tmp_res); /* Q_stat_noise_ge+45-Q_local-Q_ge-tmp_shift-15 */ L_tmp_res = Mult_32_16(L_tmp_res, sub(32767, beta)); /*30-Q_local-tmp_shift+15-15 */ +#ifdef BASOP_NOGLOB + L_tmp_res = L_add_sat( L_shl_sat( L_tmp_res, sub( add( Q_local, tmp_shift ), 15 ) ), beta ); /* Q15 */ +#else L_tmp_res = L_add(L_shl(L_tmp_res, sub(add(Q_local, tmp_shift), 15)), beta); /* Q15 */ +#endif #ifdef BASOP_NOGLOB tmp_res = extract_h(L_shl_o(L_tmp_res, 15, &Overflow)); /* 15+15-16=14 */ #else @@ -290,8 +294,11 @@ void stat_noise_uv_mod_fx( L_tmp = L_mult(Exc2_local[i], alpha); /* Q_local + 16 */ L_tmp = L_mac(L_tmp, randval, alpha_m1); /* Q_local + 16 */ L_tmp3 = Mult_32_16(L_tmp, Noimix_fract); /* Q_local+16+15-15 */ +#ifdef BASOP_NOGLOB + L_tmp = L_add_sat( L_tmp3, L_shl_sat( Mult_32_16( L_tmp, tmp_res ), 1 ) ); /* Q_local+16+14-15+1 */ +#else L_tmp = L_add(L_tmp3, L_shl(Mult_32_16(L_tmp, tmp_res), 1)); /* Q_local+16+14-15+1 */ - +#endif Exc2_local[i] = extract_h(L_tmp); /*Q_local */ } *Q_stat_noise = Q_local; /* update for next call, routine can only be called once every frame */ @@ -376,11 +383,17 @@ static Word16 calc_tilt_fx( /* o : Excitation tilt Q15*/ { /* r0 = L_mac(r0,x[i],x[i]) */ /* r1 = L_mac(r1,x[i],x[i+1]) -> correlation loop can be optimized */ +#ifdef BASOP_NOGLOB + r0 = L_mac_sat( r0, xi, xi ); +#else r0 = L_mac(r0,xi,xi); - +#endif xi_p1 = shr(x[i+1], Q_shift); +#ifdef BASOP_NOGLOB + r1 = L_mac_sat( r1, xi, xi_p1 ); +#else r1 = L_mac(r1, xi, xi_p1); - +#endif xi = xi_p1; move16(); } diff --git a/lib_com/swb_bwe_com_fx.c b/lib_com/swb_bwe_com_fx.c index 25745fe32..7afef321b 100644 --- a/lib_com/swb_bwe_com_fx.c +++ b/lib_com/swb_bwe_com_fx.c @@ -442,7 +442,11 @@ void calc_norm_envelop_lf_fx( tmp = add(lookback, n_freq); FOR(n_lag = 0; n_lag < tmp; n_lag++) { +#ifdef BASOP_NOGLOB + L_tmp = L_add_sat( L_tmp, L_abs( SWB_signal[n_lag] ) ); +#else L_tmp = L_add(L_tmp, L_abs(SWB_signal[n_lag])); +#endif } envelope[env_index] = L_tmp; move32(); @@ -455,7 +459,11 @@ void calc_norm_envelop_lf_fx( Word32 L_tmp = L_deposit_l(1); FOR(n_lag = 0; n_lag < n_lag_now; n_lag++) { +#ifdef BASOP_NOGLOB + L_tmp = L_add_sat(L_tmp, L_abs(SWB_signal[add(sub(n_freq, lookback), n_lag)])); +#else L_tmp = L_add(L_tmp, L_abs(SWB_signal[add(sub(n_freq, lookback), n_lag)])); +#endif } envelope[env_index] = L_tmp; @@ -705,13 +713,20 @@ Word32 calc_tilt_bwe_fx( /* o : Tilt in Q24 */ /* *tilt_flt = (float)(r1/sqrt(r0)); */ exp2 = norm_l(L_ener); +#ifdef BASOP_NOGLOB + L_temp = Mult_32_16( L_temp, round_fx_sat( L_shl_sat( L_ener, exp2 ) ) ); +#else L_temp = Mult_32_16(L_temp, round_fx(L_shl(L_ener, exp2))); +#endif exp2 = sub(exp2, tmp1); exp2 = add(exp2, exp_sp); /* Put in Q24 */ +#ifdef BASOP_NOGLOB + L_temp = L_shr_sat( L_temp, sub( exp2, 24 ) ); +#else L_temp = L_shr(L_temp, sub(exp2, 24)); - +#endif BASOP_SATURATE_WARNING_ON_EVS return L_temp; @@ -1551,7 +1566,11 @@ void SWB_BWE_decoding_fx( Energy_16 = round_fx(L_shl(L_tmp,add(exp,4))); /*Q3 */ #endif #else - Energy_16 = round_fx(L_shl(L_tmp, add(exp, 4))); /*Q3 */ +#ifdef BASOP_NOGLOB + EnergyL_16 = round_fx_sat( L_shl_sat( L_tmp, add( exp, 4 ) ) ); /* Q3 */ +#else + EnergyL_16 = round_fx( L_shl( L_tmp, add( exp, 4 ) ) ); /*Q3 */ +#endif #endif // EVS_FLOAT IF(NE_16(last_extl, SWB_BWE) && NE_16(last_extl,FB_BWE)) @@ -1677,7 +1696,11 @@ void SWB_BWE_decoding_fx( /*20480 = 5 in Q12 */ FOR(tmp3 = 20480; tmp3 > 4096; tmp3 -= 2048) { +#ifdef BASOP_NOGLOB + *pit1 = round_fx_sat( L_shl_sat( L_mult( *pit1, tmp3 ), 3 ) ); /*Q_syn */ +#else *pit1 = round_fx(L_shl(L_mult(*pit1,tmp3),3)); /*Q_syn */ +#endif pit1--; } } @@ -1919,7 +1942,11 @@ void SWB_BWE_decoding_fx( } } +#ifdef BASOP_NOGLOB + IF(GT_16(*prev_Energy,add_sat(Energy_16,shr(Energy_16,2))) && Energy_16 > 0) +#else IF(GT_16(*prev_Energy,add(Energy_16,shr(Energy_16,2))) && Energy_16 > 0) +#endif { weight = shr(div_s(Energy_16,*prev_Energy),1); /*Q15 */ } @@ -1953,7 +1980,11 @@ void SWB_BWE_decoding_fx( FOR(n_freq = add(swb_bwe_subband[0],st_offset); n_freq < tmp2; n_freq++) { L_tmp1 = Mult_32_16(SWB_signal_32[n_freq], factor); +#ifdef BASOP_NOGLOB + SWB_signal_32[n_freq] = L_shl_sat( L_tmp1, tmp - 1 ); +#else SWB_signal_32[n_freq] = L_shl(L_tmp1, tmp - 1); +#endif move32();/*15+Qsyn */ factor = add(factor, factor1); /*Q3 */ } @@ -1984,9 +2015,17 @@ void SWB_BWE_decoding_fx( FOR(; n_freq < tmp2; n_freq++) { L_tmp1 = Mult_32_16(SWB_signal_32[n_freq], factor); +#ifdef BASOP_NOGLOB + SWB_signal_32[n_freq] = L_shl_sat( L_tmp1, tmp - 1 ); +#else SWB_signal_32[n_freq] = L_shl(L_tmp1, tmp - 1); +#endif move32(); /*15+Qsyn */ +#ifdef BASOP_NOGLOB + factor = add_sat( factor, factor1 ); /*Q1 */ +#else factor = add(factor, factor1); /*Q1 */ +#endif } } L_tmp = L_mult(weight, prev_SWB_fenv[13]); /*Q17 */ @@ -1999,7 +2038,11 @@ void SWB_BWE_decoding_fx( FOR(; n_freq < tmp2; n_freq++) { L_tmp1 = Mult_32_16(SWB_signal_32[n_freq], factor); +#ifdef BASOP_NOGLOB + SWB_signal_32[n_freq] = L_shl_sat( L_tmp1, 13 ); +#else SWB_signal_32[n_freq] = L_shl(L_tmp1,13); +#endif move32();/*15+Qsyn */ factor = add(factor,factor1); /*Q1 */ } @@ -2013,7 +2056,11 @@ void SWB_BWE_decoding_fx( FOR(; n_freq < tmp2; n_freq++) { L_tmp1 = Mult_32_16(SWB_signal_32[n_freq], factor); +#ifdef BASOP_NOGLOB + SWB_signal_32[n_freq] = L_shl_sat( L_tmp1, 13 ); +#else SWB_signal_32[n_freq] = L_shl(L_tmp1,13); +#endif move32(); /*15+Qsyn */ } } @@ -2195,7 +2242,11 @@ void time_reduce_pre_echo_fx( L_tmp = L_deposit_l(0); FOR(j = 0; j < L; j++) { +#ifdef BASOP_NOGLOB + L_tmp = L_mac0_sat( L_tmp, synth[Len + j], synth[Len + j] ); /*2*Q_syn */ +#else L_tmp = L_mac0(L_tmp, synth[Len + j], synth[Len + j]); /*2*Q_syn */ +#endif } energyL[i] = Mult_32_16(L_shr(L_tmp, sub(14, exp_L)), inv_L); move32(); /*Q(2*Q_syn +29-exp_L-15 - (14-exp_L) ) -> Q(2*Q_syn) */ @@ -2335,7 +2386,11 @@ void time_reduce_pre_echo_fx( L_tmp = L_sub(L_tmp1, Ltmp_ener); /*Q(30-exp) */ L_tmp = Mult_32_16(L_tmp, tmpi); /*Q(30-exp) */ L_tmp = L_add(Ltmp_ener, L_tmp); /*Q(30-exp) */ +#ifdef BASOP_NOGLOB + tmp = round_fx_sat( L_shl_sat( Mult_32_16( L_tmp, *pit ), add( 1, exp ) ) ); /*Q0 */ +#else tmp = round_fx(L_shl(Mult_32_16(L_tmp, *pit), add(1, exp))); /*Q0 */ +#endif *pit++ = tmp; } } @@ -2403,7 +2458,11 @@ void calc_normal_length_fx_32( peak = mag; move16(); } +#ifdef BASOP_NOGLOB + mean = L_add_sat( mean, mag ); +#else mean = L_add(mean, mag); +#endif pit++; } @@ -2492,7 +2551,11 @@ void calc_norm_envelop_fx_32( move16(); FOR(n_lag = 0; n_lag < n_lag_now; n_lag++) { +#ifdef BASOP_NOGLOB + envelope_fx[env_index] = L_add_sat( envelope_fx[env_index], L_abs( SWB_signal_fx[add( n_freq, n_lag )] ) ); +#else envelope_fx[env_index] = L_add(envelope_fx[env_index], L_abs(SWB_signal_fx[add(n_freq, n_lag)])); +#endif move32(); } env_index++; @@ -2602,7 +2665,11 @@ void hq_generic_decoding_fx( tmp = div_s(16384, frac);/*15 + 14 - (cs+exp-16) */ exp = sub(add(cs, exp), 30); L_tmp = Isqrt_lc(L_deposit_h(tmp), &exp);/*Q31 - exp */ +#ifdef BASOP_NOGLOB + fenvL_fx = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 14 ) ) ); /*Q1 */ +#else fenvL_fx = round_fx(L_shl(L_tmp, sub(exp, 14)));/*Q1 */ +#endif } calc_normal_length_fx_32(HQ_CORE, coeff_out1_fx, HQ_GEN_SWB, -1, &L_swb_norm, prev_L_swb_norm); @@ -2902,8 +2969,11 @@ void hq_generic_decoding_fx( tmp1_fx = extract_h(L_shl(L_tmp1, exp1)); tmp2_fx = extract_h(L_shl(L_tmp2, exp2)); tmp3_fx = div_s(tmp2_fx, tmp1_fx);/*15 + exp2 + 15 - (exp1 + 15) */ +#ifdef BASOP_NOGLOB + tmp3_fx = shr_sat( tmp3_fx, add( 5, sub( exp2, exp1 ) ) ); /*10 */ +#else tmp3_fx = shr(tmp3_fx, add(5, sub(exp2, exp1)));/*10 */ - +#endif if (LT_16(tmp3_fx, 307)) { tmp3_fx = 307; diff --git a/lib_com/swb_bwe_com_lr_fx.c b/lib_com/swb_bwe_com_lr_fx.c index e44c342df..d4cefb99b 100644 --- a/lib_com/swb_bwe_com_lr_fx.c +++ b/lib_com/swb_bwe_com_lr_fx.c @@ -2290,8 +2290,11 @@ void ton_ene_est_fx( exp_pow = sub(14, temp_hi_fx); L_band_energy_Linear[i] = Pow2(14, temp_lo_fx); move32(); /* Qexp_pow */ +#ifdef BASOP_NOGLOB + L_band_energy_Linear[i] = L_shl_sat( L_band_energy_Linear[i], sub( *QbeL, exp_pow ) ); +#else L_band_energy_Linear[i] = L_shl(L_band_energy_Linear[i], sub(*QbeL, exp_pow)); - +#endif /* Div Part */ E_r_fx = 0x7fff; move16(); @@ -2380,7 +2383,11 @@ void ton_ene_est_fx( L_E = sum2_fx(&xSynth_har_fx[sub(band_start[i], fLenLow)], band_width[i]); QE = add(shl(QxSynth_sft, 1), 1); +#ifdef BASOP_NOGLOB + L_E = L_shl_sat( L_E, sub( *QbeL, QE ) ); +#else L_E = L_shl(L_E, sub(*QbeL, QE)); +#endif QE = *QbeL; } ELSE @@ -2584,16 +2591,22 @@ void Gettonl_scalfact_fx exp_pow = sub(14, temp_hi_fx); L_band_energy_Linear[band_pos_fx] = Pow2(14, temp_lo_fx); move32(); /* Qexp_pow */ +#ifdef BASOP_NOGLOB + L_band_energy_Linear[band_pos_fx] = L_shl_sat( L_band_energy_Linear[band_pos_fx], sub( QbeL, exp_pow ) ); +#else L_band_energy_Linear[band_pos_fx] = L_shl(L_band_energy_Linear[band_pos_fx], sub(QbeL, exp_pow)); - +#endif /* Div Part */ exp_normd = norm_l(L_be_tonal[band_pos_fx]); exp_normd = sub(exp_normd, 1); exp_normn = norm_l(L_band_energy_Linear[band_pos_fx]); temp_fx = div_l(L_shl(L_be_tonal[band_pos_fx], exp_normd), extract_h(L_shl(L_band_energy_Linear[band_pos_fx], exp_normn))); /* QbeL+exp_normd-(QbeL+exp_normn-16)-1 */ sqrt_32n_16_fx(L_deposit_h(temp_fx), add(sub(exp_normd, exp_normn), 31), &temp_fx, &Qtemp); +#ifdef BASOP_NOGLOB + enrd_r_fx = extract_h( L_shl_sat( L_mult( enrd_r_fx, temp_fx ), sub( 15, Qtemp ) ) ); +#else enrd_r_fx = extract_h(L_shl(L_mult(enrd_r_fx, temp_fx), sub(15, Qtemp))); - +#endif enrd_r_fx = sub(enrd_r_fx, step_fx); } ELSE diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index 4cdb96a23..a04f3c5ae 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -3917,23 +3917,38 @@ void ScaleShapedWB_fx( { /* mod_syn in (16+Q_bwe_exc), frame_gain in Q18 */ L_tmp = Mult_32_32( mod_syn[i], frame_gain ); /* L_tmp in (Q_bwe_exc+3) */ +#ifdef BASOP_NOGLOB + synSHB[i] = round_fx_sat( L_shl_sat( Mult_32_16( L_tmp, win[i] ), shift ) ); /* Qx */ + synSHB[i] = add_sat( synSHB[i], overlap[i] ); + move16(); /* Qx */ + synSHB[i + l_shb_lahead] = round_fx_sat( L_shl_sat( L_tmp, shift ) ); /* Qx */ +#else synSHB[i] = round_fx( L_shl( Mult_32_16( L_tmp, win[i] ), shift) ); /* Qx */ synSHB[i] = add( synSHB[i], overlap[i] ); move16(); /* Qx */ synSHB[i + l_shb_lahead] = round_fx( L_shl( L_tmp, shift) ); /* Qx */ +#endif } FOR ( ; i < l_frame; i++ ) { L_tmp = Mult_32_32( mod_syn[i], frame_gain); /* L_tmp in (Q_bwe_exc+3) */ +#ifdef BASOP_NOGLOB + synSHB[i] = round_fx_sat( L_shl_sat( L_tmp, shift ) ); /* Qx; */ +#else synSHB[i] = round_fx( L_shl(L_tmp, shift) ); /* Qx; */ +#endif } l_frame_tmp = add(l_frame, l_shb_lahead); FOR ( ; i < l_frame_tmp; i++ ) { L_tmp = Mult_32_32( mod_syn[i], frame_gain ); /* (Q_bwe_exc+3) */ +#ifdef BASOP_NOGLOB + overlap[i - l_frame] = round_fx_sat( L_shl_sat( Mult_32_16( L_tmp, win[l_frame + l_shb_lahead - 1 - i] ), shift ) ); /* Qx */ +#else overlap[i - l_frame] = round_fx( L_shl( Mult_32_16( L_tmp, win[l_frame + l_shb_lahead - 1 - i] ), shift ) ); /* Qx */ +#endif } return; @@ -3963,7 +3978,11 @@ static Word32 non_linearity_scaled_copy( { FOR ( i = 0; i < j; i++ ) { +#ifdef BASOP_NOGLOB + L_tmp = L_mult_sat( input[i], input[i] ); /* 2*Q_inp+1 */ +#else L_tmp = L_mult( input[i], input[i] ); /* 2*Q_inp+1 */ +#endif L_tmp = Mult_32_32( L_tmp, prev_scale ); /* 2*Q_inp */ output[i] = L_tmp; move32(); @@ -3973,7 +3992,11 @@ static Word32 non_linearity_scaled_copy( } FOR ( ; i < length; i++ ) { +#ifdef BASOP_NOGLOB + L_tmp = L_mult_sat( input[i], input[i] ); /* 2*Q_inp+1 */ +#else L_tmp = L_mult( input[i], input[i] ); /* 2*Q_inp+1 */ +#endif L_tmp = Mult_32_32( L_tmp, prev_scale ); /* 2*Q_inp */ output[i] = L_tmp; move32(); @@ -3983,7 +4006,11 @@ static Word32 non_linearity_scaled_copy( { FOR ( i = 0; i < j; i++ ) { +#ifdef BASOP_NOGLOB + L_tmp = L_mult_sat( input[i], input[i] ); /* 2*Q_inp+1 */ +#else L_tmp = L_mult( input[i], input[i] ); /* 2*Q_inp+1 */ +#endif L_tmp = Mult_32_32( L_tmp, prev_scale ); /* 2*Q_inp */ if ( input[i] < 0 ) @@ -5142,9 +5169,81 @@ void elliptic_bpf_48k_generic_fx( FOR( j=0; j<4; j++ ) { +#ifdef BASOP_NOGLOB + memory2_fx_2[j] = L_shl_sat( memory_fx2[2][j], sub( add( add( *Q_input_fx, 6 ), Q_temp ), memory_fx_Q[2] ) ); + memory2_fx_3[j] =L_shl_sat(memory_fx2[3][j],sub(add(add(*Q_input_fx,1) ,Q_temp) ,memory_fx_Q[3])); +#else memory2_fx_2[j] =L_shl(memory_fx2[2][j],sub(add(add(*Q_input_fx,6),Q_temp) ,memory_fx_Q[2])); memory2_fx_3[j] =L_shl(memory_fx2[3][j],sub(add(add(*Q_input_fx,1) ,Q_temp) ,memory_fx_Q[3])); +#endif + } +#ifdef BASOP_NOGLOB + L_tmpX = L_shr( Mult_32_16( memory2_fx_2[0], full_band_bpf_fx[2][4] ), 3 ); /* *Q_input_fx+6 +Q_temp +13 -15 -3 */ + L_tmpX = L_add_sat( L_shr( Mult_32_16( memory2_fx_2[1], full_band_bpf_fx[2][3] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp+13 -15 -3*/ + L_tmpX = L_add_sat( L_shr( Mult_32_16( memory2_fx_2[2], full_band_bpf_fx[2][2] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp+13 -15 -3*/ + L_tmpX = L_add_sat( L_shr( Mult_32_16( memory2_fx_2[3], full_band_bpf_fx[2][1] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp+13 -15 -3*/ + L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp2[0], full_band_bpf_fx[2][0] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp+13 -15 -3*/ + L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx_3[3], full_band_bpf_fx[5][1] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2 */ + L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx_3[2], full_band_bpf_fx[5][2] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2 */ + L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx_3[1], full_band_bpf_fx[5][3] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2 */ + L_output[0] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx_3[0], full_band_bpf_fx[5][4] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2 */ + move32(); + L_tmpMax = L_abs(L_output[0]); + + L_tmpX = L_shr(Mult_32_16(memory2_fx_2[1],full_band_bpf_fx[2][4]),3);/*Q_input_fx + 6 +Q_temp +13 -15 -3 */ + L_tmpX = L_add_sat( L_shr( Mult_32_16( memory2_fx_2[2], full_band_bpf_fx[2][3] ), 3 ), L_tmpX ); /*Q_input_fx +Q_temp+ 6 +13 -15 -3*/ + L_tmpX = L_add_sat( L_shr( Mult_32_16( memory2_fx_2[3], full_band_bpf_fx[2][2] ), 3 ), L_tmpX ); /*Q_input_fx +Q_temp+ 6 +13 -15 -3*/ + L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp2[0], full_band_bpf_fx[2][1] ), 3 ), L_tmpX ); /*Q_input_fx +Q_temp+ 6 +13 -15 -3*/ + L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp2[1], full_band_bpf_fx[2][0] ), 3 ), L_tmpX ); /*Q_input_fx+Q_temp + 6 +13 -15 -3*/ + L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_output[0], full_band_bpf_fx[5][1] ), 2 ) ); /*Q_input_fx + 1 +13 -15 + 2+Q_temp*/ + L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx_3[3], full_band_bpf_fx[5][2] ), 2 ) ); /*Q_input_fx + 1 +13 -15 + 2+Q_temp*/ + L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx_3[2], full_band_bpf_fx[5][3] ), 2 ) ); /*Q_input_fx + 1 +13 -15 + 2+Q_temp*/ + L_output[1] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx_3[1], full_band_bpf_fx[5][4] ), 2 ) ); /*Q_input_fx + 1 +13 -15 + 2+Q_temp*/ + move32(); + L_tmpMax = L_max(L_tmpMax,L_abs(L_output[1])); + + L_tmpX = L_shr(Mult_32_16(memory2_fx_2[2],full_band_bpf_fx[2][4]),3);/*Q_input_fx + 6 +Q_temp+13 -15 -3 */ + L_tmpX = L_add_sat( L_shr( Mult_32_16( memory2_fx_2[3], full_band_bpf_fx[2][3] ), 3 ), L_tmpX ); /*Q_input_fx +Q_temp+ 6 +13 -15 -3*/ + L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp2[0], full_band_bpf_fx[2][2] ), 3 ), L_tmpX ); /*Q_input_fx +Q_temp+ 6 +13 -15 -3*/ + L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp2[1], full_band_bpf_fx[2][1] ), 3 ), L_tmpX ); /*Q_input_fx +Q_temp + 6 +13 -15 -3*/ + L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp2[2], full_band_bpf_fx[2][0] ), 3 ), L_tmpX ); /*Q_input_fx +Q_temp + 6 +13 -15 -3*/ + L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_output[1], full_band_bpf_fx[5][1] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2*/ + L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_output[0], full_band_bpf_fx[5][2] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2*/ + L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx_3[3], full_band_bpf_fx[5][3] ), 2 ) ); /*Q_input_fx + 1+Q_temp +13 -15 + 2*/ + L_output[2] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx_3[2], full_band_bpf_fx[5][4] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2*/ + move32(); + L_tmpMax = L_max(L_tmpMax,L_abs(L_output[2])); + + L_tmpX = L_shr(Mult_32_16(memory2_fx_2[3],full_band_bpf_fx[2][4]),3);/*Q_input_fx + 6 +Q_temp +13 -15 -3 */ + L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp2[0], full_band_bpf_fx[2][3] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp+13 -15 -3*/ + L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp2[1], full_band_bpf_fx[2][2] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp+13 -15 -3*/ + L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp2[2], full_band_bpf_fx[2][1] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp+13 -15 -3*/ + L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp2[3], full_band_bpf_fx[2][0] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp+13 -15 -3*/ + L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_output[2], full_band_bpf_fx[5][1] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2*/ + L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_output[1], full_band_bpf_fx[5][2] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2*/ + L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_output[0], full_band_bpf_fx[5][3] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2*/ + L_output[3] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx_3[3], full_band_bpf_fx[5][4] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2*/ + move32(); + L_tmpMax = L_max(L_tmpMax,L_abs(L_output[3])); + + FOR( i=4; i 0) r = L_shr(r, 2); tmp = shl(x[j], s); +#ifdef BASOP_NOGLOB + r = L_mac0_sat( r, tmp, tmp ); +#else r = L_mac0(r, tmp, tmp); +#endif } r = L_max(r, L_shl(100, shl(s, 1))); r = Mpy_32_16_1(r, 16386/*1.0001f Q14*/); diff --git a/lib_com/tcx_utils_fx.c b/lib_com/tcx_utils_fx.c index 3f0d0887c..3107ee760 100644 --- a/lib_com/tcx_utils_fx.c +++ b/lib_com/tcx_utils_fx.c @@ -393,11 +393,17 @@ void tcx_windowing_synthesis_current_frame( tmp2 = mult_r(signal[i+overlap-acelp_mem_len], window_trans[i].v.im); /*Time TDAC: 1)forward part of ACELP*/ +#ifdef BASOP_NOGLOB + tmp2 = add_sat( tmp2, mult_r( old_syn[acelp_zir_len - tmp + i], mult_r( window_trans[i].v.re, window_trans[i].v.re ) ) ); + + /*Time TDAC: 1)reward part of ACELP*/ + tmp2 = add_sat(tmp2, mult_r(old_syn[acelp_zir_len-i-1], mult_r(window_trans[i].v.im, window_trans[i].v.re))); +#else tmp2 = add(tmp2, mult_r(old_syn[acelp_zir_len-tmp+i], mult_r(window_trans[i].v.re, window_trans[i].v.re))); /*Time TDAC: 1)reward part of ACELP*/ tmp2 = add(tmp2, mult_r(old_syn[acelp_zir_len-i-1], mult_r(window_trans[i].v.im, window_trans[i].v.re))); - +#endif move16(); signal[i+overlap-acelp_mem_len] = tmp2; } @@ -408,11 +414,17 @@ void tcx_windowing_synthesis_current_frame( tmp2 = mult_r(signal[i+overlap-acelp_mem_len], window_trans[tmp-1-i].v.re); /*Time TDAC: 1)forward part of ACELP*/ +#ifdef BASOP_NOGLOB + tmp2 = add_sat( tmp2, mult_r( old_syn[acelp_zir_len - tmp + i], mult_r( window_trans[tmp - 1 - i].v.im, window_trans[tmp - 1 - i].v.im ) ) ); +#else tmp2 = add(tmp2, mult_r(old_syn[acelp_zir_len-tmp+i], mult_r(window_trans[tmp-1-i].v.im, window_trans[tmp-1-i].v.im))); - +#endif /*Time TDAC: 1)reward part of ACELP*/ +#ifdef BASOP_NOGLOB + tmp2 = add_sat( tmp2, mult_r( old_syn[acelp_zir_len - i - 1], mult_r( window_trans[tmp - 1 - i].v.re, window_trans[tmp - 1 - i].v.im ) ) ); +#else tmp2 = add(tmp2, mult_r(old_syn[acelp_zir_len-i-1], mult_r(window_trans[tmp-1-i].v.re, window_trans[tmp-1-i].v.im))); - +#endif move16(); signal[i+overlap-acelp_mem_len] = tmp2; } @@ -420,7 +432,11 @@ void tcx_windowing_synthesis_current_frame( FOR (i=0; i= 0; j-- ) +#ifdef BASOP_NOGLOB + Lacc = L_mac_sat( Lacc, buf[j], b[j + 1] ); + Lacc = L_mac_sat( Lacc, s_mem, b[0] ); +#else Lacc = L_mac( Lacc, buf[j], b[j + 1] ); Lacc = L_mac( Lacc, s_mem, b[0] ); +#endif /* Lacc in Q(1+Qc+Qn-Qa)*/ FOR ( j = s_max(PDR, PNR ) - 1; j > 0; j-- ) @@ -2506,8 +2511,11 @@ void pz_filter_dp_fx ( FOR ( j = PDR - 1; j >= 0; j-- ) Lacc = Msub_32_16( Lacc, buf[j], a[j + 1] ); /*Q(16+Qn-2Qa+1)*/ +#ifdef BASOP_NOGLOB + s_mem = L_shl_sat( Lacc, sub( Qa, 1 ) ); /*Qn-Qa+16=Qn+Qc*/ +#else s_mem = L_shl( Lacc, sub( Qa, 1 ) ); /*Qn-Qa+16=Qn+Qc*/ - +#endif Lacc = L_deposit_l(0); FOR ( j = PNR - 1; j >= 0; j-- ) Lacc = Madd_32_16( Lacc, buf[j], b[j + 1] ); @@ -2523,7 +2531,11 @@ void pz_filter_dp_fx ( buf[0] = s_mem; move16(); +#ifdef BASOP_NOGLOB + Ltemp1 = L_shr_sat( Lacc, s ); /* Ltemp1 in Qc+Qa+Qn=Q(16+Qn) */ +#else Ltemp1 = L_shr( Lacc, s ); /* Ltemp1 in Qc+Qa+Qn=Q(16+Qn) */ +#endif y[i] = extract_h( Ltemp1 ); /* y[i] in Qn */ } } @@ -2546,16 +2558,26 @@ void Copy_Scale_sig32_16( { FOR (i = 0; i < len; i++ ) { +#ifdef BASOP_NOGLOB + *dst++ = round_fx_sat( *src++ ); +#else *dst++ = round_fx(*src++); +#endif } return; } FOR (i = 0; i < len; i++ ) { +#ifdef BASOP_NOGLOB + L_temp = L_shl_sat( *src++, exp0 ); + + *dst++ = round_fx_sat(L_temp); +#else L_temp = L_shl(*src++, exp0); *dst++ = round_fx(L_temp); +#endif } } diff --git a/lib_com/trans_inv_fx.c b/lib_com/trans_inv_fx.c index 67fc70bfe..0db3ca732 100644 --- a/lib_com/trans_inv_fx.c +++ b/lib_com/trans_inv_fx.c @@ -147,12 +147,20 @@ void preecho_sb_fx( fx32ptr1 = wtda_audio_fx + len3xLp20 - 1; FOR( i = 0; i < len3xLp20; i++ ) { +#ifdef BASOP_NOGLOB + *fxptr1++ = negate( extract_h( L_shl_sat( *fx32ptr1--, 15 - q_sig32 ) ) ); +#else *fxptr1++ = negate(extract_h(L_shl(*fx32ptr1--,15-q_sig32))); +#endif move16(); /*convert to Word16 Q-1 with saturation (saturation not a problem here) */ } FOR( i = 0; i < L_shr(framelength, 1); i++ ) { +#ifdef BASOP_NOGLOB + *fxptr1++ = negate( extract_h( L_shl_sat( wtda_audio_fx[i], 15 - q_sig32 ) ) ); +#else *fxptr1++ = negate(extract_h(L_shl(wtda_audio_fx[i], 15-q_sig32))); +#endif move16(); /*convert to Word16 Q-1 with saturation (saturation not a problem here) */ } qmemp1 = 0; /*already in q-1*/ @@ -253,11 +261,16 @@ void preecho_sb_fx( FOR (j = 0; j < NUMSF; j++) /* 8 present subframes */ { tmp_fx2 = sub(j, 1); +#ifdef BASOP_NOGLOB + tmp_fx1 = shr_sat( *fxptr2, q16p1 ); /*q-1 to avoisd saturation in energy*/ + tmp_fxL1 = L_mac0_sat(25, tmp_fx1, tmp_fx1); + tmp_fxL2 = L_mac0_sat(100, *fxptr3, *fxptr3); +#else tmp_fx1 = shr(*fxptr2, q16p1); /*q-1 to avoisd saturation in energy*/ tmp_fxL1 = L_mac0(25, tmp_fx1, tmp_fx1); tmp_fxL2 = L_mac0(100, *fxptr3, *fxptr3); - +#endif sptr2_loc = 0; move16(); @@ -277,11 +290,12 @@ void preecho_sb_fx( *fx32ptr6 = tmp_fxL1; move32(); } - tmp_fx1 = shr(*fxptr2, q16p1); /*q-1 to avoisd saturation in energy*/ #ifdef BASOP_NOGLOB + tmp_fx1 = shr_sat( *fxptr2, q16p1 ); /*q-1 to avoisd saturation in energy*/ tmp_fxL1 = L_mac0_sat(tmp_fxL1, tmp_fx1, tmp_fx1); tmp_fxL2 = L_mac0_sat(tmp_fxL2, *fxptr3, *fxptr3); #else + tmp_fx1 = shr( *fxptr2, q16p1 ); /*q-1 to avoisd saturation in energy*/ tmp_fxL1 = L_mac0(tmp_fxL1, tmp_fx1, tmp_fx1); tmp_fxL2 = L_mac0(tmp_fxL2, *fxptr3, *fxptr3); #endif diff --git a/lib_com/wi_fx.c b/lib_com/wi_fx.c index 9dd61d2da..3ffc76834 100644 --- a/lib_com/wi_fx.c +++ b/lib_com/wi_fx.c @@ -442,11 +442,18 @@ Word16 DTFS_alignment_full_fx( /* Calculating the expected alignment shift */ Eshift = mult_r(ph_offset_fx, shl(X2_DTFS_fx.lag_fx, 7)); /* confirmed I<2 by smv12.org, Q7 */ find_rem((Word16)L_FRAME, shr(add(X2_DTFS_fx.lag_fx, X1_DTFS_fx.lag_fx), 1), &temp); +#ifdef BASOP_NOGLOB + temp = add_sat( shl( temp, 7 ), Eshift ); /* Q7 */ +#else temp = add(shl(temp, 7), Eshift); /* Q7 */ - +#endif IF (temp<0) { +#ifdef BASOP_NOGLOB + temp = add_sat( temp, shl_sat( X1_DTFS_fx.lag_fx, 7 ) ); /* Q7 */ +#else temp = add(temp, shl(X1_DTFS_fx.lag_fx, 7)); /* Q7 */ +#endif } find_rem(temp, shl(X1_DTFS_fx.lag_fx, 7), &Eshift); /* Q7 */ Eshift=shl(shr(Eshift,7),1); /* Q1 but integer */ @@ -1217,7 +1224,11 @@ static void DTFS_transform_fx( tmptmp3_40_fx=L_add(tmptmp3_40_fx, Mult_32_16(x_r_fx[m],sinc_fx[k][j])); } +#ifdef BASOP_NOGLOB + out_fx[i] = round_fx_sat( L_shl_sat( tmptmp3_40_fx, 2 ) ); +#else out_fx[i] = round_fx(L_shl(tmptmp3_40_fx,2)); +#endif } @@ -1765,7 +1776,11 @@ static Word32 DTFS_setEngy_fx( expb = norm_l(en1_fx); +#ifdef BASOP_NOGLOB + fracb = round_fx_sat( L_shl_sat( en1_fx, expb ) ); +#else fracb = round_fx(L_shl(en1_fx,expb)); +#endif expb = sub(30, add(expb, shl(X_DTFS_FX->Q, 1))); @@ -2560,9 +2575,14 @@ void DTFS_to_erb_fx( tmp = div_s(fracb,fraca); exp = sub(expb,expa); +#ifdef BASOP_NOGLOB + L_tmp = L_shl_sat( tmp, add( exp, 14 ) ); + out_fx[i] = round_fx_sat(L_tmp); +#else L_tmp = L_shl(tmp, add(exp,14)); out_fx[i] = round_fx(L_tmp); +#endif } } return; @@ -3381,7 +3401,11 @@ Word16 ppp_extract_pitch_period_fx( spike=i; move16(); } +#ifdef BASOP_NOGLOB + en1 = L_mac0_sat( en1, ptr[i], ptr[i] ); /* Q0 */ +#else en1 =L_mac0(en1, ptr[i], ptr[i]); /* Q0 */ +#endif } IF (ptr[spike]>0) @@ -3508,7 +3532,11 @@ Word16 ppp_extract_pitch_period_fx( Lacc = L_deposit_l(0); FOR (i=0; i= 0) { if (GT_32(L_temp,maxPosEn_fx)) @@ -3980,6 +4015,16 @@ static void c_fft_wi_fx(Word16 * farray_ptr_fx, Word16 size, Word16 stage, Word1 tmp1 = round_fx(ftmp_real_fx); tmp2 = round_fx(ftmp_imag_fx); +#ifdef BASOP_NOGLOB + *( farray_ptr_fx + kj ) = sub_sat( *( farray_ptr_fx + k ), tmp1 ); + move16(); + *(farray_ptr_fx + kj + 1) = sub_sat(*(farray_ptr_fx + k + 1), tmp2); + move16(); + *(farray_ptr_fx + k) = add_sat(*(farray_ptr_fx + k), tmp1); + move16(); + *(farray_ptr_fx + k + 1) = add_sat(*(farray_ptr_fx + k + 1), tmp2); + move16(); +#else *(farray_ptr_fx + kj) = sub(*(farray_ptr_fx + k), tmp1); move16(); *(farray_ptr_fx + kj + 1) = sub(*(farray_ptr_fx + k + 1), tmp2); @@ -3988,6 +4033,7 @@ static void c_fft_wi_fx(Word16 * farray_ptr_fx, Word16 size, Word16 stage, Word1 move16(); *(farray_ptr_fx + k + 1) = add(*(farray_ptr_fx + k + 1), tmp2); move16(); +#endif } } } diff --git a/lib_com/window_ola_fx.c b/lib_com/window_ola_fx.c index c0171dbb3..a9b11c5b3 100644 --- a/lib_com/window_ola_fx.c +++ b/lib_com/window_ola_fx.c @@ -29,7 +29,11 @@ void sinq_fx( tmp2 = round_fx(L_tmp); /*Q15 */ x[1] = sub(tmp1, tmp2); move16(); /* sin(x) approximated by (x-x^3/3!); Q15 */ +#ifdef BASOP_NOGLOB + tmp1 = add_sat( shl_sat( tmp, 1 ), phi ); /*Q15 */ +#else tmp1 = add(shl(tmp,1), phi); /*Q15 */ +#endif L_tmp = L_mult(tmp1, tmp1); /*Q31 */ L_tmp = Mult_32_16(L_tmp, tmp1); /*Q31 */ L_tmp = Mult_32_16(L_tmp, 5461); /*Q31; division by 6 */ @@ -857,9 +861,15 @@ void core_switching_OLA_fx( temp_len = i_mult2(shr(R2_16,2), delta); FOR( i=0 ; i Q15 */ + *pt2 = shl_sat( mult_r_sat( *pt2, *pt4 ), 1 ); +#else *pt= shl( mult_r(*pt,*pt5),1); move16();/* // Q14* Q15 + shl ==> Q15 */ *pt2 = shl( mult_r(*pt2,*pt4),1); +#endif move16();/*/= win[(3*L_FRAME16k/2-1-i/2)*decimate+decay-L_FRAME48k*14/20]; */ pt+=2; pt2+=2; @@ -929,7 +939,11 @@ void core_switching_OLA_fx( temp_len = sub(L,tmp); FOR( i=0; i< temp_len; i++ ) { +#ifdef BASOP_NOGLOB + *pt = add_sat( add_sat( *pt, *pt2++ ), *pt3++ ); +#else *pt = add(add(*pt,*pt2++),*pt3++); +#endif move16(); pt++; } diff --git a/lib_dec/FEC_HQ_core_fx.c b/lib_dec/FEC_HQ_core_fx.c index ac61b2fcd..e101096e9 100644 --- a/lib_dec/FEC_HQ_core_fx.c +++ b/lib_dec/FEC_HQ_core_fx.c @@ -359,8 +359,11 @@ void HQ_FEC_processing_fx( exp2 = norm_l(norm_values_fx[0]); tmp_fx = div_s(extract_h(L_shl(norm_p_fx[i], exp1)), extract_h(L_shl(norm_values_fx[0], exp2)));/*15 + (5 + exp1 - 16) - (12 + exp2 - 16)*/ +#ifdef BASOP_NOGLOB + tmp_fx = shl_sat( tmp_fx, add( 6, sub( exp2, exp1 ) ) ); /*14*/ +#else tmp_fx = shl(tmp_fx, add(6, sub(exp2, exp1)));/*14*/ - +#endif if (GT_16(tmp_fx, 16384)) { tmp_fx = 16384; @@ -830,7 +833,11 @@ void HQ_FEC_Mem_update_fx( move16();/*15*/ L_tmp = Mult_32_16(tmp_energy_fx, tmp_fx);/*8 + 15 - 15*/ +#ifdef BASOP_NOGLOB + hHQ_nbfec->energy_MA_Curr_fx[1] = extract_h( L_shl_sat( L_tmp, 16 - 8 ) ); +#else hHQ_nbfec->energy_MA_Curr_fx[1] = extract_h(L_shl(L_tmp, 16-8)); +#endif /* Moving Average */ hHQ_nbfec->energy_MA_Curr_fx[0] = s_max(1,add(mult_r(26214, hHQ_nbfec->energy_MA_Curr_fx[0]), mult_r(6554, hHQ_nbfec->energy_MA_Curr_fx[1]))); @@ -1535,7 +1542,11 @@ static void Repetition_smoothing_nextgood_fx( /*mvr2r(&ImdctOutWin[L], OldauOut, L);*/ FOR (i = 0; i < L; i++) { +#ifdef BASOP_NOGLOB + auOut_fx[i] = add_sat( ImdctOutWin_fx[N_ZERO_NB + i], OldauOut_fx[i] ); +#else auOut_fx[i] = add(ImdctOutWin_fx[N_ZERO_NB + i], OldauOut_fx[i]); +#endif move16(); } Copy(&ImdctOutWin_fx[L], OldauOut_fx, L); @@ -1626,7 +1637,11 @@ static void common_overlapping_fx( FOR (i=0 ; i < end1; i++) { /*auOut_fx[i] = L_add(ImdctOutWin_fx[i+7*L/20], OldauOut_fx[i+offset1]);*/ +#ifdef BASOP_NOGLOB + auOut_fx[i] = add_sat( ImdctOutWin_fx[i + N_ZERO_NB], OldauOut_fx[i + offset1] ); +#else auOut_fx[i] = add(ImdctOutWin_fx[i+N_ZERO_NB], OldauOut_fx[i+offset1]); +#endif move16(); } FOR (i=start2 ; i < end2; i++) diff --git a/lib_dec/FEC_HQ_phase_ecu_fx.c b/lib_dec/FEC_HQ_phase_ecu_fx.c index 08c2955f2..70e7bbab2 100644 --- a/lib_dec/FEC_HQ_phase_ecu_fx.c +++ b/lib_dec/FEC_HQ_phase_ecu_fx.c @@ -549,14 +549,22 @@ static void trans_ana_fx( tr_dec[k] = 0; move16(); Mpy_32_16_ss(*pGrPowLeft, THRESH_TR_LIN_BY2_FX, &acc, &lsb); /* To facilitate fixed-point implementation, divide threshold by 2. */ +#ifdef BASOP_NOGLOB + acc = L_or( L_shl_sat( acc, 16 ), L_and( 0xffffL, lsb ) ); /* Equivalent to concatenate acc and lsb, and then down shift by 16 bits. */ +#else acc = L_or(L_shl(acc,16), L_and(0xffffL,lsb)); /* Equivalent to concatenate acc and lsb, and then down shift by 16 bits. */ +#endif if (GT_32(*pGrPowRight, acc)) /* gr_pow_right > thres_tr_lin*gr_pow_left */ { tr_dec[k] = 1; move16(); } Mpy_32_16_ss(*pGrPowRight, THRESH_TR_LIN_BY2_FX, &acc, &lsb); +#ifdef BASOP_NOGLOB + acc = L_or( L_shl_sat( acc, 16 ), L_and( 0xffffL, lsb ) ); /* Equivalent to concatenate acc and lsb, and then down shift by 16 bits. */ +#else acc = L_or(L_shl(acc,16), L_and(0xffffL,lsb)); /* Equivalent to concatenate acc and lsb, and then down shift by 16 bits. */ +#endif if (GT_32(*pGrPowLeft, acc)) /* gr_pow_left > thres_tr_lin*gr_pow_right */ { tr_dec[k] = 1; @@ -1885,7 +1893,11 @@ static void spec_ana_fx( man = mult_r(man,FEC_HQ_ECU_ROOT2); /* FEC_HQ_ECU_ROOT2 is sqrt(2) in Q14 */ expoBy2 = sub(expoBy2, 1); } +#ifdef BASOP_NOGLOB + *pXfp++ = shr_sat( man, expoBy2 ); +#else *pXfp++ = shr(man, expoBy2); +#endif move16();/* Denormalize the mantissa back to Q0. */ } } @@ -2763,8 +2775,13 @@ static void subst_spec_fx( IF(EQ_16(element_mode, EVS_MONO)) #endif { +#ifdef BASOP_NOGLOB + tmp = sub_sat( mult_r( re, cos_F ), mult_r( im, sin_F ) ); + im = add_sat(mult_r(re, sin_F), mult_r(im, cos_F)); +#else tmp = sub(mult_r(re, cos_F), mult_r(im, sin_F)); im = add(mult_r(re, sin_F), mult_r(im, cos_F)); +#endif } #ifdef IVAS_FEC_ECU_TO_COMPLETE ELSE @@ -3705,8 +3722,11 @@ Word16 abs_iter_fx(Word16 re, Word16 im, Word16 N) i = s_min(sub(i,1), 9); tmp = abs_s(re); /*A = round_fx(L_shr(L_mult(tmp, cor[i]), exp)); //this can be ommited, if we don't need the exact abs value */ +#ifdef BASOP_NOGLOB + A = shr_sat( tmp, exp ); +#else A = shr(tmp, exp); - +#endif return A; } /*-------------------------------------------------------------------------- @@ -3967,7 +3987,11 @@ void singenerator_fx( ptr = xx; +#ifdef BASOP_NOGLOB + *ptr = L_add_sat( *ptr, L_C0 ); +#else *ptr = L_add(*ptr, L_C0); +#endif move32(); ptr++; @@ -3978,7 +4002,11 @@ void singenerator_fx( L_C1 = L_msu(L_C1, S0, sinfreq); /*Qin+16 */ L_S1 = L_mult(C0, sinfreq); S1 = mac_r(L_S1, S0, cosfreq); +#ifdef BASOP_NOGLOB + *ptr = L_add_sat( *ptr, L_C1 ); +#else *ptr = L_add(*ptr, L_C1); +#endif move32(); /*Qin+16 */ ptr++; @@ -3987,7 +4015,11 @@ void singenerator_fx( L_C0 = L_msu(L_C0, S1, sinfreq); L_S0 = L_mult(C1, sinfreq); S0 = mac_r(L_S0, S1, cosfreq); +#ifdef BASOP_NOGLOB + *ptr = L_add_sat( *ptr, L_C0 ); +#else *ptr = L_add(*ptr, L_C0); +#endif move32(); ptr++; } @@ -3996,7 +4028,11 @@ void singenerator_fx( S0 = extract_h(L_S0); L_C1 = L_mult(C0, cosfreq); L_C1 = L_msu(L_C1, S0, sinfreq); +#ifdef BASOP_NOGLOB + *ptr = L_add_sat( *ptr, L_C1 ); +#else *ptr = L_add(*ptr, L_C1); +#endif move32(); ptr++; @@ -4508,7 +4544,11 @@ void fec_noise_filling_fx( tmp_fx = div_s(1, Rnd_N_noise); /*Q15 */ +#ifdef BASOP_NOGLOB + tmp_fx = round_fx_sat( L_shl_sat( L_mult( tmp_fx, 25736 ), 2 ) ); /*Q15 */ +#else tmp_fx = round_fx(L_shl(L_mult(tmp_fx, 25736),2)); /*Q15 */ +#endif #ifdef IVAS_FEC_ECU_TO_COMPLETE if (element_mode == EVS_MONO) { diff --git a/lib_dec/FEC_clas_estim_fx.c b/lib_dec/FEC_clas_estim_fx.c index 47a0e307a..e5f9f34b7 100644 --- a/lib_dec/FEC_clas_estim_fx.c +++ b/lib_dec/FEC_clas_estim_fx.c @@ -353,7 +353,11 @@ void FEC_clas_estim_fx( tmp_x = extract_h(L_shl(Ltmp, exp2)); exp2 = sub(31-1+3, exp2); BASOP_SATURATE_WARNING_OFF_EVS +#ifdef BASOP_NOGLOB + tmpS = shr( sub_sat( tmp_x, tmp_y ), 16 ); /* if tmp_x >= tmp_y tmpS = 0, -1 otherwise */ +#else tmpS = shr(sub(tmp_x, tmp_y), 16); /* if tmp_x >= tmp_y tmpS = 0, -1 otherwise */ +#endif BASOP_SATURATE_WARNING_ON_EVS tmp_y = shl(tmp_y, tmpS); exp1 = sub(exp1, tmpS); diff --git a/lib_dec/FEC_fx.c b/lib_dec/FEC_fx.c index df091bd70..7b4b7fe98 100644 --- a/lib_dec/FEC_fx.c +++ b/lib_dec/FEC_fx.c @@ -655,7 +655,11 @@ void FEC_exc_estim_fx( /* non-causal ringing of the FIR filter */ /**pt_exc++ *= (gain_inov * gain);*/ L_tmp = L_mult(tmp, *pt_exc); /* Q_exc+18 * Q-3 -> Q_exc+16 */ +#ifdef BASOP_NOGLOB + *pt_exc++ = round_fx_sat( L_shl_sat( L_tmp, exp ) ); +#else *pt_exc++ = round_fx(L_shl(L_tmp, exp)); +#endif } FOR( i=0; i< L_frame; i++ ) @@ -663,7 +667,11 @@ void FEC_exc_estim_fx( /* the inner part of the FIR filter */ /* *pt_exc++ *= (gain_inov * gain); */ L_tmp = L_mult(tmp, *pt_exc); +#ifdef BASOP_NOGLOB + *pt_exc++ = round_fx_sat( L_shl_sat( L_tmp, exp ) ); +#else *pt_exc++ = round_fx(L_shl(L_tmp, exp)); +#endif /* gain -= step; */ L_tmp2 = L_sub(L_tmp2, L_step); tmp = round_fx(L_tmp2); @@ -674,7 +682,11 @@ void FEC_exc_estim_fx( { /* *pt_exc++ *= (gain_inov * gain) */ L_tmp = L_mult(tmp, *pt_exc); +#ifdef BASOP_NOGLOB + *pt_exc++ = round_fx_sat( L_shl_sat( L_tmp, exp ) ); +#else *pt_exc++ = round_fx(L_shl(L_tmp, exp)); +#endif } } @@ -711,9 +723,17 @@ void FEC_exc_estim_fx( L_tmp = L_mult(hp_filt[0], pt_exc[0]); FOR (j = 1; j < MODE1_L_FIR_FER; j++) { +#ifdef BASOP_NOGLOB + L_tmp = L_mac_sat( L_tmp, hp_filt[j], pt_exc[j] ); +#else L_tmp = L_mac(L_tmp, hp_filt[j], pt_exc[j]); +#endif } +#ifdef BASOP_NOGLOB + exc2[i] = msu_r_sat( L_tmp, -32768, exc[i] ); +#else exc2[i] = msu_r(L_tmp, -32768, exc[i]); +#endif move16(); pt_exc++; } @@ -802,7 +822,11 @@ static void pulseRes_preCalc(Word16* cond1, Word16* cond2, Word32* cond3 ,Word16 tmp_pit2 = L_mult(Tc,4915/*0.15f Q15*/);/*Q16*/ 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 BASOP_NOGLOB + tmp_pit2 = L_shl_sat( L_negate( tmp_pit2 ), sub( 15 - 16, tmp_pit_e ) ); +#else tmp_pit2 = L_shl(L_negate(tmp_pit2),sub(15-16,tmp_pit_e)); +#endif BASOP_SATURATE_WARNING_ON_EVS *cond3 = L_sub(L_mult0(-1, tmp_pit),tmp_pit2); } diff --git a/lib_dec/FEC_scale_syn_fx.c b/lib_dec/FEC_scale_syn_fx.c index 0502417be..a547be7e7 100644 --- a/lib_dec/FEC_scale_syn_fx.c +++ b/lib_dec/FEC_scale_syn_fx.c @@ -257,7 +257,11 @@ void FEC_scale_syn_fx( ( (prev_bfi) || ( (EQ_16(coder_type,GENERIC) ) && (EQ_16(LSF_Q_prediction,AUTO_REGRESSIVE) ) ) ) ) { /*if( enr_q > scaling * enr_old ){enr_q = scaling * enr_old;}*/ +#ifdef BASOP_NOGLOB + L_enr_q = L_min( L_enr_q, L_shl_sat( Mult_32_16( L_enr_old, scaling ), 1 ) ); /* scaling in Q14*/ +#else L_enr_q = L_min(L_enr_q, L_shl(Mult_32_16(L_enr_old, scaling),1)); /* scaling in Q14*/ +#endif } ELSE { @@ -351,7 +355,11 @@ void FEC_scale_syn_fx( exc[i] = mac_r(L_mult(exc[i], gain1), exc[i], gain1); move16(); /*exc2[i] *= gain1;*/ +#ifdef BASOP_NOGLOB + exc2[i] = mac_r_sat( L_mult( exc2[i], gain1 ), exc2[i], gain1 ); +#else exc2[i] = mac_r(L_mult(exc2[i], gain1), exc2[i], gain1); +#endif move16(); } /* smoothing is done in excitation domain, so redo synthesis */ @@ -398,7 +406,11 @@ void FEC_scale_syn_fx( ( (EQ_16(clas,UNVOICED_CLAS))||(EQ_16(clas,INACTIVE_CLAS))))) /* unvoiced classification */ { /*if( enr_q > scaling * enr_old )enr_q = scaling * enr_old;*/ +#ifdef BASOP_NOGLOB + L_enr_q = L_min( L_enr_q, L_shl_sat( Mult_32_16( L_enr_old, scaling ), 1 ) ); /* scaling in Q14*/ +#else L_enr_q = L_min(L_enr_q, L_shl(Mult_32_16(L_enr_old, scaling),1)); /* scaling in Q14*/ +#endif } ELSE IF( GE_16(last_good,VOICED_TRANSITION)&<_16(last_good,INACTIVE_CLAS)&&GE_16(clas,VOICED_TRANSITION)&<_16(clas,INACTIVE_CLAS)) { @@ -594,9 +606,15 @@ void FEC_scale_syn_fx( FOR( i=0; ifilt_lfE_fx[i]); tmp16 = s_max(min_g_2k, tmp16); /*DCT_buf[i] *= ftmp;*/ +#ifdef BASOP_NOGLOB + dtc_out[i] = round_fx_sat( L_shl_sat( L_mult( dtc_out[i], tmp16 ), 3 ) ); +#else dtc_out[i] = round_fx(L_shl(L_mult(dtc_out[i], tmp16),3)); - +#endif } FOR(; i < BIN_4KHZ; i++) @@ -344,7 +347,11 @@ void LD_music_post_filter_fx tmp16 = s_min(max_ovf_4k, hMusicPF->filt_lfE_fx[i]); tmp16 = s_max(min_g_4k, tmp16); /*DCT_buf[i] *= ftmp;*/ +#ifdef BASOP_NOGLOB + dtc_out[i] = round_fx_sat( L_shl_sat( L_mult_sat( dtc_out[i], tmp16 ), 3 ) ); +#else dtc_out[i] = round_fx(L_shl(L_mult(dtc_out[i], tmp16),3)); +#endif } test(); @@ -356,7 +363,11 @@ void LD_music_post_filter_fx tmp16 = s_min(max_ovf_6k, hMusicPF->filt_lfE_fx[i]); tmp16 = s_max(min_g_6k, tmp16); /*DCT_buf[i] *= ftmp;*/ +#ifdef BASOP_NOGLOB + dtc_out[i] = round_fx_sat( L_shl_sat( L_mult_sat( dtc_out[i], tmp16 ), 3 ) ); +#else dtc_out[i] = round_fx(L_shl(L_mult(dtc_out[i], tmp16),3)); +#endif } } } @@ -367,7 +378,11 @@ void LD_music_post_filter_fx { tmp16 = s_min(4096, hMusicPF->filt_lfE_fx[i]); /*DCT_buf[i] *= ftmp;*/ +#ifdef BASOP_NOGLOB + dtc_out[i] = round_fx_sat( L_shl_sat( L_mult_sat( dtc_out[i], tmp16 ), 3 ) ); +#else dtc_out[i] = round_fx(L_shl(L_mult(dtc_out[i], tmp16),3)); +#endif } } } @@ -743,7 +758,11 @@ static void find_enr_dct_fx( FOR( i = min_band; i <= NB_LIMIT_BAND; i++ ) { /* total channel energy */ +#ifdef BASOP_NOGLOB + Ltmp = L_add_sat( band[i], Ltmp ); +#else Ltmp = L_add(band[i],Ltmp); +#endif } *Etot = Ltmp; diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c index 1f45db97c..234a7b78e 100644 --- a/lib_dec/acelp_core_switch_dec_fx.c +++ b/lib_dec/acelp_core_switch_dec_fx.c @@ -328,7 +328,11 @@ ivas_error acelp_core_switch_dec_fx( pt2 = &hb_synth_tmp[tmp]; FOR( i=0; ilp_ener_fx; */ IF(EQ_16(m1,1)) { +#ifdef BASOP_NOGLOB + L_tmp = L_sub_sat( L_tmp, L_add_sat( st_fx->lp_ener_fx, st_fx->lp_ener_fx ) ); +#else L_tmp = L_sub(L_tmp,L_add(st_fx->lp_ener_fx,st_fx->lp_ener_fx)); +#endif } ELSE { tmp1 = div_s(1,m1); L_tmp = Mult_32_16(L_tmp,tmp1); +#ifdef BASOP_NOGLOB + L_tmp = L_sub_sat( L_tmp, L_add_sat( st_fx->lp_ener_fx, st_fx->lp_ener_fx ) ); +#else L_tmp = L_sub(L_tmp,L_add(st_fx->lp_ener_fx,st_fx->lp_ener_fx)); +#endif } env[i] = L_tmp; move32(); @@ -581,7 +593,11 @@ void CNG_dec_fx( { /* Update hangover memory during CNG */ test(); +#ifdef BASOP_NOGLOB + IF( *allow_cn_step == 0 && LT_32( hTdCngDec->Enew_fx, L_add_sat( st_fx->lp_ener_fx, L_shr( st_fx->lp_ener_fx, 1 ) ) ) ) +#else IF ( *allow_cn_step == 0 && LT_32(hTdCngDec->Enew_fx,L_add(st_fx->lp_ener_fx,L_shr(st_fx->lp_ener_fx,1)))) +#endif { /* update the pointer to circular buffer of old LSP vectors */ hTdCngDec->ho_hist_ptr = add(hTdCngDec->ho_hist_ptr, 1); @@ -964,7 +980,11 @@ static void shb_CNG_decod_fx( IF ( st_fx->trans_cnt_fx > 0 ) { i = extract_l(L_mult0(st_fx->trans_cnt_fx, 17)); /*Q0 */ +#ifdef BASOP_NOGLOB + ener_fx = add_sat( st_fx->shb_cng_ener_fx, mult( sin_table256_fx[i], sub_sat( st_fx->last_shb_ener_fx, st_fx->shb_cng_ener_fx ) ) ); /*Q8 */ +#else ener_fx = add(st_fx->shb_cng_ener_fx, mult(sin_table256_fx[i], sub(st_fx->last_shb_ener_fx, st_fx->shb_cng_ener_fx))); /*Q8 */ +#endif st_fx->trans_cnt_fx = sub(st_fx->trans_cnt_fx, 1); } @@ -978,7 +998,11 @@ static void shb_CNG_decod_fx( move32(); } fra = L_Extract_lc(L_tmp, &exp); +#ifdef BASOP_NOGLOB + L_tmp = L_shl_sat( Pow2( exp, fra ), 5 ); /*Q5 */ +#else L_tmp = L_shl(Pow2(exp, fra), 5); /*Q5 */ +#endif L_tmp = L_shr(L_tmp, 10); if( L_tmp == 0 ) { diff --git a/lib_dec/d_gain2p_fx.c b/lib_dec/d_gain2p_fx.c index ce1f1b908..48e2df97f 100644 --- a/lib_dec/d_gain2p_fx.c +++ b/lib_dec/d_gain2p_fx.c @@ -198,7 +198,11 @@ static void gain_dec_uv( *-----------------------------------------------------------------*/ *past_gpit = *gain_pit; *past_gcode = L_tmp; +#ifdef BASOP_NOGLOB + L_tmp = L_shl_sat( Mpy_32_16_1( L_tmp, *gain_inov ), 3 ); /* Q16*Q12 -> Q13 -> Q16 */ +#else L_tmp = L_shl(Mpy_32_16_1(L_tmp, *gain_inov), 3); /* Q16*Q12 -> Q13 -> Q16 */ +#endif *gain_code = L_tmp; move32(); @@ -304,7 +308,11 @@ static void gain_dec_gacelp_uv( *past_gcode = L_shl(L_tmp1, sub(exp_L_tmp1, 15)); /* Q16 */ move32(); +#ifdef BASOP_NOGLOB + *gain_code = L_shl_sat( Mpy_32_16_1( *past_gcode, *gain_inov ), 3 ); +#else *gain_code = L_shl(Mpy_32_16_1(*past_gcode, *gain_inov), 3); +#endif move32(); diff --git a/lib_dec/dec_ace_fx.c b/lib_dec/dec_ace_fx.c index 110e09167..d613763cc 100644 --- a/lib_dec/dec_ace_fx.c +++ b/lib_dec/dec_ace_fx.c @@ -463,15 +463,26 @@ void decoder_acelp( Ltmp = Mpy_32_16_1(gain_code2, code2[i]); Ltmp = L_shl(Ltmp, add(5,st->Q_exc)); Ltmp = L_mac(Ltmp, gain_pit, exc[i+i_subfr]); +#ifdef BASOP_NOGLOB + exc2[i + i_subfr] = round_fx_sat( L_shl_sat( Ltmp, 1 ) ); +#else exc2[i + i_subfr] = round_fx(L_shl(Ltmp, 1)); - +#endif Ltmp2 = Mpy_32_16_1(gain_code, code[i]); Ltmp2 = L_shl(Ltmp2, add(5,st->Q_exc)); Ltmp = L_add(Ltmp, Ltmp2); BASOP_SATURATE_WARNING_OFF_EVS +#ifdef BASOP_NOGLOB + Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here */ +#else Ltmp = L_shl(Ltmp, 1); /* saturation can occur here */ +#endif BASOP_SATURATE_WARNING_ON_EVS +#ifdef BASOP_NOGLOB + exc[i + i_subfr] = round_fx_sat( Ltmp ); +#else exc[i + i_subfr] = round_fx(Ltmp); +#endif } tmp2 = L_SUBFR; move16(); diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index 37d61e921..f27403cdb 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -251,16 +251,28 @@ ivas_error decod_gen_voic_fx( Ltmp1 = L_shl(Ltmp1,tmp1_fx); /* Q16 + Q_exc */ /* Compute exc2 */ +#ifdef BASOP_NOGLOB + L_tmp = L_shl_sat( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1 ); + exc2_fx[i+i_subfr_fx] = round_fx_sat(L_add_sat(L_tmp, Ltmp1)); +#else L_tmp = L_shl(L_mult(gain_pit_fx,exc_fx[i+i_subfr_fx]),1); exc2_fx[i+i_subfr_fx] = round_fx(L_add(L_tmp, Ltmp1)); - +#endif /* code in Q9, gain_pit in Q14 */ L_tmp = L_mult(gain_code16, code_fx[i]); +#ifdef BASOP_NOGLOB + L_tmp = L_shl_sat( L_tmp, 5 ); + L_tmp = L_mac_sat(L_tmp, exc_fx[i + i_subfr_fx], gain_pit_fx); + L_tmp = L_shl_sat(L_tmp, 1); /* saturation can occur here */ + + exc_fx[i+i_subfr_fx] = round_fx_sat(L_add_sat(L_tmp, Ltmp1)); +#else L_tmp = L_shl(L_tmp, 5); L_tmp = L_mac(L_tmp, exc_fx[i + i_subfr_fx], gain_pit_fx); L_tmp = L_shl(L_tmp, 1); /* saturation can occur here */ exc_fx[i+i_subfr_fx] = round_fx(L_add(L_tmp, Ltmp1)); +#endif } } ELSE @@ -345,8 +357,13 @@ ivas_error decod_gen_voic_fx( curr_spch_nrg = L_deposit_l(1); FOR( i=0; iQ_exc */ + curr_spch_nrg = L_mac0_sat(curr_spch_nrg, *p_syn, *p_syn); /* 2*st_fx->Q_syn */ +#else curr_res_nrg = L_mac0(curr_res_nrg, *p_exc, *p_exc); /* 2*st_fx->Q_exc */ curr_spch_nrg = L_mac0(curr_spch_nrg, *p_syn, *p_syn); /* 2*st_fx->Q_syn */ +#endif p_exc++; p_syn++; } @@ -359,7 +376,11 @@ ivas_error decod_gen_voic_fx( expa = sub(30,expa+(2*st_fx->prev_Q_exc_fr)); expb = norm_l(curr_res_nrg); +#ifdef BASOP_NOGLOB + fracb = round_fx_sat( L_shl_sat( curr_res_nrg, expb ) ); +#else fracb = round_fx(L_shl(curr_res_nrg,expb)); +#endif expb = sub(30,expb+(2*st_fx->Q_exc)); scale = shr(sub(fraca,fracb),15); @@ -384,7 +405,11 @@ ivas_error decod_gen_voic_fx( expa = sub(30,expa+(2*st_fx->prev_Q_syn_fr)); expb = norm_l(curr_spch_nrg); +#ifdef BASOP_NOGLOB + fracb = round_fx_sat( L_shl_sat( curr_spch_nrg, expb ) ); +#else fracb = round_fx(L_shl(curr_spch_nrg,expb)); +#endif expb = sub(30,expb+(2*st_fx->Q_syn)); scale = shr(sub(fraca,fracb),15); diff --git a/lib_dec/dec_higher_acelp_fx.c b/lib_dec/dec_higher_acelp_fx.c index 5f5a3970f..af41df508 100644 --- a/lib_dec/dec_higher_acelp_fx.c +++ b/lib_dec/dec_higher_acelp_fx.c @@ -81,8 +81,13 @@ void transf_cdbk_dec_fx( } L_tmp = Mult_32_16(gain_code,gain16); /* Q16 * Q12 - 15 -> Q13*/ +#ifdef BASOP_NOGLOB + L_tmp = L_shl_sat( L_tmp, 5 ); /* Q13 -> Q18*/ + *gain_preQ = round_fx_sat(L_tmp); /* Q2*/ +#else L_tmp = L_shl(L_tmp,5); /* Q13 -> Q18*/ *gain_preQ = round_fx(L_tmp); /* Q2*/ +#endif } ELSE { diff --git a/lib_dec/dec_pit_exc_fx.c b/lib_dec/dec_pit_exc_fx.c index e92a41c5c..42940687d 100644 --- a/lib_dec/dec_pit_exc_fx.c +++ b/lib_dec/dec_pit_exc_fx.c @@ -262,8 +262,13 @@ void dec_pit_exc_fx( { FOR (i = 0; i < L_subfr_fx; i++) { +#ifdef BASOP_NOGLOB + L_tmp = L_shl_sat( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1 ); /*Q16+Q_exc*/ + exc_fx[i + i_subfr_fx] = round_fx_sat( L_tmp ); /*Q_exc*/ +#else L_tmp = L_shl(L_mult(gain_pit_fx, exc_fx[i+i_subfr_fx]), 1); /*Q16+Q_exc*/ exc_fx[i+i_subfr_fx] = round_fx(L_tmp); /*Q_exc*/ +#endif } } ELSE @@ -273,7 +278,11 @@ void dec_pit_exc_fx( FOR (i = 0; i < L_subfr_fx; i++) { L_tmp = L_mult(gain_pitx2, exc_fx[i+i_subfr_fx]); /*Q16+Q_exc*/ +#ifdef BASOP_NOGLOB + exc_fx[i + i_subfr_fx] = round_fx_sat( L_tmp ); /*Q_exc*/ +#else exc_fx[i+i_subfr_fx] = round_fx(L_tmp); /*Q_exc*/ +#endif } } } diff --git a/lib_dec/dec_post_fx.c b/lib_dec/dec_post_fx.c index 80385bcfb..3a8f3bd33 100644 --- a/lib_dec/dec_post_fx.c +++ b/lib_dec/dec_post_fx.c @@ -856,7 +856,11 @@ static void pst_ltp( FOR (i = 0; i < L_SUBFR; i++) { /* nb_sh_sig may be >0, <0 or =0 */ +#ifdef BASOP_NOGLOB + ptr_y_up[i] = shl_sat( ptr_y_up[i], nb_sh_sig ); +#else ptr_y_up[i] = shl(ptr_y_up[i], nb_sh_sig); +#endif move16(); } } @@ -1467,7 +1471,11 @@ static void compute_ltp_l( L_acc = L_mult(y_up[0], y_up[0]); FOR (n = 1; n < L_SUBFR; n++) { +#ifdef BASOP_NOGLOB + L_acc = L_mac_sat( L_acc, y_up[n], y_up[n] ); +#else L_acc = L_mac(L_acc, y_up[n], y_up[n]); +#endif } temp = sub(16, norm_l(L_acc)); temp = s_max(temp, 0); @@ -1720,11 +1728,18 @@ void Filt_mu( L_temp = L_mac(L_acc, 16384, *ptrs); /* sig_in(n) * 2**15 */ L_temp = Madd_32_16(L_fact, L_temp, ga); +#ifdef BASOP_NOGLOB + L_temp = L_shr_sat( L_temp, sh_fact ); /* mult. temp x ga */ +#else L_temp = L_shr(L_temp, sh_fact); /* mult. temp x ga */ - +#endif BASOP_SATURATE_WARNING_OFF_EVS; /*sig_out[n] = saturate(L_temp); move16();*/ +#ifdef BASOP_NOGLOB + sig_out[n] = round_fx_sat( L_temp ); +#else sig_out[n] = round_fx(L_temp); +#endif BASOP_SATURATE_WARNING_ON_EVS; } @@ -1823,7 +1838,11 @@ void Filt_mu_fx( BASOP_SATURATE_WARNING_OFF_EVS; /*sig_out[n] = saturate(L_temp); move16();*/ +#ifdef BASOP_NOGLOB + sig_out[n] = round_fx_sat( L_temp ); +#else sig_out[n] = round_fx(L_temp); +#endif BASOP_SATURATE_WARNING_ON_EVS; } diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 5c744fd7e..acdba363c 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -574,7 +574,11 @@ void decoder_tcx( /* gainCompensate = st->last_gain_syn_deemph/(float)sqrt(dot_product( h1, h1, L_SUBFR)); */ tmp32 = Dot_productSq16HQ( 0, h1, L_SUBFR, &gainCompensate_e)/*Q15, gainCompensate_e*/; gainCompensate_e = add(gainCompensate_e,10/*scaling of h1[0] and E_UTIL:synthesis*/); +#ifdef BASOP_NOGLOB + gainCompensate = round_fx_sat( Sqrt32( tmp32, &gainCompensate_e ) ) /*Q15, gainCompensate_e*/; +#else gainCompensate = round_fx(Sqrt32(tmp32,&gainCompensate_e))/*Q15, gainCompensate_e*/; +#endif BASOP_Util_Divide_MantExp ( st->last_gain_syn_deemph, st->last_gain_syn_deemph_e, gainCompensate, @@ -1491,7 +1495,11 @@ void decoder_tcx_post(Decoder_State *st_fx, #endif FOR( i=0; i < hTcxDec->L_frameTCX; i++ ) { +#ifdef BASOP_NOGLOB + synthFB[i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( conceal_eof_gainFB, synthFB[i] ), 1 ) ); +#else synthFB[i] = round_fx(L_shl(Mpy_32_16_1(conceal_eof_gainFB, synthFB[i]),1)); +#endif move16(); #ifdef BASOP_NOGLOB conceal_eof_gainFB = L_sub_o(conceal_eof_gainFB, stepFB, &Overflow); @@ -1503,7 +1511,11 @@ void decoder_tcx_post(Decoder_State *st_fx, conceal_eof_gain32 = L_deposit_h(hTcxDec->conceal_eof_gain); /*Q30*/ FOR( i=0; i < st_fx->L_frame; i++ ) { - xn_buf[i] = round_fx(L_shl(Mpy_32_16_1(conceal_eof_gain32 /*Q30*/, xn_buf[i]),1)); +#ifdef BASOP_NOGLOB + xn_buf[i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( conceal_eof_gain32 /*Q30*/, xn_buf[i] ), 1 ) ); +#else + xn_buf[i] = round_fx( L_shl( Mpy_32_16_1( conceal_eof_gain32 /*Q30*/, xn_buf[i] ), 1 ) ); +#endif move16(); #ifdef BASOP_NOGLOB conceal_eof_gain32 = L_sub_o(conceal_eof_gain32, step, &Overflow); @@ -2452,7 +2464,11 @@ void IMDCT(Word32 *x, Word16 x_e, tmp1 = sub(overlap, tcx_mdct_window_min_length); FOR (i=0; i < tmp1; i++) { +#ifdef BASOP_NOGLOB + xn_buf[i + tmp4] = shl_sat( add_sat( xn_buf[i + tmp4], shr_sat( old_out[i + nz], tmp2 ) ), TCX_IMDCT_HEADROOM ); +#else xn_buf[i+tmp4] = shl(add(xn_buf[i+tmp4], shr(old_out[i+nz], tmp2)), TCX_IMDCT_HEADROOM); +#endif move16(); } @@ -2461,19 +2477,31 @@ void IMDCT(Word32 *x, Word16 x_e, FOR ( ; i < tmp1; i++) { tmp3 = mult_r(shr(old_out[i+nz], tmp2), tcx_mdct_window_minimum[i-overlap+tcx_mdct_window_min_length].v.re); +#ifdef BASOP_NOGLOB + xn_buf[i + tmp4] = shl_sat( add_sat( xn_buf[i + tmp4], tmp3 ), TCX_IMDCT_HEADROOM ); +#else xn_buf[i+tmp4] = shl(add(xn_buf[i+tmp4], tmp3), TCX_IMDCT_HEADROOM); +#endif move16(); } FOR ( ; i < overlap; i++) { tmp3 = mult_r(shr(old_out[i+nz], tmp2), tcx_mdct_window_minimum[overlap-1-i].v.im); +#ifdef BASOP_NOGLOB + xn_buf[i + tmp4] = shl_sat( add_sat( xn_buf[i + tmp4], tmp3 ), TCX_IMDCT_HEADROOM ); +#else xn_buf[i+tmp4] = shl(add(xn_buf[i+tmp4], tmp3), TCX_IMDCT_HEADROOM); +#endif move16(); } FOR (i = add(i, tmp4) ; i < L_frame; i++) { +#ifdef BASOP_NOGLOB + xn_buf[i] = shl_sat( xn_buf[i], TCX_IMDCT_HEADROOM ); +#else xn_buf[i] = shl(xn_buf[i], TCX_IMDCT_HEADROOM); +#endif move16(); } } @@ -2506,26 +2534,43 @@ void IMDCT(Word32 *x, Word16 x_e, tmp3 = shr(tcx_mdct_window_half_length, 1); FOR (i=0; i < tmp1; i++) { +#ifdef BASOP_NOGLOB + xn_buf[i] = shl_sat( xn_buf[i], TCX_IMDCT_HEADROOM ); +#else xn_buf[i] = shl(xn_buf[i], TCX_IMDCT_HEADROOM); +#endif move16(); } FOR (i = 0; i < tmp3; i++) { +#ifdef BASOP_NOGLOB + tmp2 = add_sat( xn_buf[i + tmp1], mult_r( old_syn_overl[i], tcx_mdct_window_half[i].v.re ) ); + xn_buf[i + tmp1] = shl_sat( tmp2, TCX_IMDCT_HEADROOM ); +#else tmp2 = add(xn_buf[i+tmp1], mult_r(old_syn_overl[i], tcx_mdct_window_half[i].v.re)); xn_buf[i+tmp1] = shl(tmp2, TCX_IMDCT_HEADROOM); +#endif move16(); } FOR ( ; i < tcx_mdct_window_half_length; i++) { tmp2 = add(xn_buf[i+tmp1], mult_r(old_syn_overl[i], tcx_mdct_window_half[tcx_mdct_window_half_length-1-i].v.im)); +#ifdef BASOP_NOGLOB + xn_buf[i + tmp1] = shl_sat( tmp2, TCX_IMDCT_HEADROOM ); +#else xn_buf[i+tmp1] = shl(tmp2, TCX_IMDCT_HEADROOM); +#endif move16(); } IF (LT_16(add(i, tmp1), L_frame)) { FOR (i = add(i, tmp1); i < L_frame; i++) { +#ifdef BASOP_NOGLOB + xn_buf[i] = shl_sat( xn_buf[i], TCX_IMDCT_HEADROOM ); +#else xn_buf[i] = shl(xn_buf[i], TCX_IMDCT_HEADROOM); +#endif move16(); } } @@ -2561,14 +2606,22 @@ void IMDCT(Word32 *x, Word16 x_e, tmp1 = shr(overlap, 1); FOR (i=0; i < tmp1; i++) { +#ifdef BASOP_NOGLOB + xn_buf[i] = shl_sat( xn_buf[i], TCX_IMDCT_HEADROOM ); +#else xn_buf[i] = shl(xn_buf[i], TCX_IMDCT_HEADROOM); +#endif move16(); } tmpP16 = xn_buf + tmp1; FOR (i=0; i < overlap; i++) { +#ifdef BASOP_NOGLOB + tmpP16[i] = shl_sat( add( tmpP16[i], old_syn_overl[i] ), TCX_IMDCT_HEADROOM ); +#else tmpP16[i] = shl(add(tmpP16[i], old_syn_overl[i]), TCX_IMDCT_HEADROOM); +#endif move16(); } @@ -2576,7 +2629,11 @@ void IMDCT(Word32 *x, Word16 x_e, { FOR (i = add(i, tmp1); i < L_frame; i++) { +#ifdef BASOP_NOGLOB + xn_buf[i] = shl_sat( xn_buf[i], TCX_IMDCT_HEADROOM ); +#else xn_buf[i] = shl(xn_buf[i], TCX_IMDCT_HEADROOM); +#endif move16(); } } @@ -2666,14 +2723,24 @@ void IMDCT(Word32 *x, Word16 x_e, tmp3 = shr(tcx_mdct_window_half_length, 1); FOR (i = 0; i < tmp3; i++) { +#ifdef BASOP_NOGLOB + xn_buf[i + tmp1] = mult_r_sat( xn_buf[i + tmp1], tcx_mdct_window_half[i].v.im ); + xn_buf[i+tmp1] = add_sat( xn_buf[i+tmp1], mult_r_sat(hTcxDec->syn_OverlFB[i], mult_r_sat( tcx_mdct_window_half[i].v.re, tcx_mdct_window_half[i].v.re ) ) ); +#else xn_buf[i+tmp1] = mult_r( xn_buf[i+tmp1], tcx_mdct_window_half[i].v.im ); xn_buf[i+tmp1] = add( xn_buf[i+tmp1], mult_r(hTcxDec->syn_OverlFB[i], mult_r( tcx_mdct_window_half[i].v.re, tcx_mdct_window_half[i].v.re ) ) ); +#endif move16(); } FOR ( ; i < tcx_mdct_window_half_length; i++) { +#ifdef BASOP_NOGLOB + xn_buf[i + tmp1] = mult_r_sat( xn_buf[i + tmp1], tcx_mdct_window_half[tcx_mdct_window_half_length - 1 - i].v.re ); + xn_buf[i+tmp1] = add_sat( xn_buf[i+tmp1], mult_r_sat(hTcxDec->syn_OverlFB[i], mult_r_sat( tcx_mdct_window_half[tcx_mdct_window_half_length-1-i].v.im, tcx_mdct_window_half[tcx_mdct_window_half_length-1-i].v.im ) ) ); +#else xn_buf[i+tmp1] = mult_r( xn_buf[i+tmp1], tcx_mdct_window_half[tcx_mdct_window_half_length-1-i].v.re ); xn_buf[i+tmp1] = add( xn_buf[i+tmp1], mult_r(hTcxDec->syn_OverlFB[i], mult_r( tcx_mdct_window_half[tcx_mdct_window_half_length-1-i].v.im, tcx_mdct_window_half[tcx_mdct_window_half_length-1-i].v.im ) ) ); +#endif move16(); } } @@ -2683,14 +2750,24 @@ void IMDCT(Word32 *x, Word16 x_e, tmp3 = shr(tcx_mdct_window_half_length, 1); FOR (i = 0; i < tmp3; i++) { +#ifdef BASOP_NOGLOB + xn_buf[i + tmp1] = mult_r_sat( xn_buf[i + tmp1], tcx_mdct_window_half[i].v.im ); + xn_buf[i + tmp1] = add_sat( xn_buf[i + tmp1], mult_r_sat( hTcxDec->syn_Overl[i], mult_r_sat( tcx_mdct_window_half[i].v.re, tcx_mdct_window_half[i].v.re ) ) ); +#else xn_buf[i+tmp1] = mult_r( xn_buf[i+tmp1], tcx_mdct_window_half[i].v.im ); xn_buf[i+tmp1] = add( xn_buf[i+tmp1], mult_r(hTcxDec->syn_Overl[i], mult_r( tcx_mdct_window_half[i].v.re, tcx_mdct_window_half[i].v.re ) ) ); +#endif move16(); } FOR ( ; i < tcx_mdct_window_half_length; i++) { +#ifdef BASOP_NOGLOB + xn_buf[i + tmp1] = mult_r_sat( xn_buf[i + tmp1], tcx_mdct_window_half[tcx_mdct_window_half_length - 1 - i].v.re ); + xn_buf[i + tmp1] = add_sat( xn_buf[i + tmp1], mult_r_sat( hTcxDec->syn_Overl[i], mult_r_sat( tcx_mdct_window_half[tcx_mdct_window_half_length - 1 - i].v.im, tcx_mdct_window_half[tcx_mdct_window_half_length - 1 - i].v.im ) ) ); +#else xn_buf[i+tmp1] = mult_r( xn_buf[i+tmp1], tcx_mdct_window_half[tcx_mdct_window_half_length-1-i].v.re ); xn_buf[i+tmp1] = add( xn_buf[i+tmp1], mult_r(hTcxDec->syn_Overl[i], mult_r( tcx_mdct_window_half[tcx_mdct_window_half_length-1-i].v.im, tcx_mdct_window_half[tcx_mdct_window_half_length-1-i].v.im ) ) ); +#endif move16(); } } diff --git a/lib_dec/er_dec_acelp_fx.c b/lib_dec/er_dec_acelp_fx.c index b51e8268d..acaddaad9 100644 --- a/lib_dec/er_dec_acelp_fx.c +++ b/lib_dec/er_dec_acelp_fx.c @@ -205,7 +205,11 @@ void con_acelp( Tc = round_fx(tmp_tc); BASOP_SATURATE_WARNING_OFF_EVS /*if this ever saturates, it doesn't matter*/ +#ifdef BASOP_NOGLOB + tmp = sub( shl_sat( abs_s( sub( T0, Tc ) ), 6 ), mult( 19661 /*0.15f Q17*/, shl_sat( Tc, 4 ) ) /*Q6*/ ); +#else tmp = sub(shl(abs_s(sub(T0,Tc)),6) , mult(19661/*0.15f Q17*/,shl(Tc,4)) /*Q6*/); +#endif BASOP_SATURATE_WARNING_ON_EVS test(); test(); @@ -531,8 +535,11 @@ void con_acelp( gain_32 = st->Mode2_lp_gainc; /*15Q16 *//* start-of-the-frame gain */ move16(); +#ifdef BASOP_NOGLOB + ftmp = round_fx_sat( L_shl_sat( gain_32, 1 ) ); /*Q0*/ +#else ftmp = round_fx(L_shl(gain_32,1));/*Q0*/ - +#endif BASOP_SATURATE_WARNING_OFF_EVS #ifdef BASOP_NOGLOB tmp_16 = sub(shl_sat(gainCNG,sub(gainCNG_e,5/*Q5*/)),ftmp); @@ -649,14 +656,23 @@ void con_acelp( /* gain_16 = gain_32 = gain_inov * gain */ gain_32 = Mpy_32_16_1(gain_32, gain_inov); /* 15Q16 * Q15 * 2^s_gain_inov */ +#ifdef BASOP_NOGLOB + gain_32 = L_shl_sat( gain_32, add( 15, s_gain_inov ) ); /* Q31 */ + gain_16 = round_fx_sat( gain_32 ); /* Q15 */ +#else gain_32 = L_shl(gain_32, add(15, s_gain_inov)); /* Q31 */ gain_16 = round_fx(gain_32); /* Q15 */ +#endif /* step_32 = gain_inov * step */ step_32 = Mpy_32_16_1(step_32, gain_inov); /* 15Q16 * Q15 * 2^s_gain_inov */ step_32 = L_shl(step_32, add(15, s_gain_inov)); /* Q31 */ +#ifdef BASOP_NOGLOB + g_e = norm_s( round_fx_sat( L_shl_sat( Mpy_32_16_1( st->Mode2_lp_gainc, gain_inov ), add( 15, s_gain_inov ) ) ) ); /* norm_s for gain*gain_inov at the end of the following loops */ +#else g_e = norm_s(round_fx(L_shl(Mpy_32_16_1(st->Mode2_lp_gainc, gain_inov), add(15, s_gain_inov)))); /* norm_s for gain*gain_inov at the end of the following loops */ +#endif g_e = s_min(norm_s(gain_16), g_e); gain_16 = shl(gain_16, g_e); gain_32 = L_shl(gain_32, g_e); @@ -947,7 +963,11 @@ void con_acelp( { FOR( i=0 ; i < st->L_frame; i++ ) { +#ifdef BASOP_NOGLOB + syn[i] = add_sat( syn[i], syn_unv[i] ); +#else syn[i] = add(syn[i], syn_unv[i]); +#endif move16(); } } @@ -1002,8 +1022,11 @@ void con_acelp( /*updating enr_old parameters*/ frame_ener_fx( st->L_frame, st->last_good, syn, round_fx(tmp_tc), &(st->enr_old_fx), 1, 0, 0, 0 ); +#ifdef BASOP_NOGLOB + st->enr_old_fx = L_shl_sat( st->enr_old_fx, shl( negate( Qf_syn ), 1 ) ); +#else st->enr_old_fx = L_shl(st->enr_old_fx,shl(negate(Qf_syn),1)); - +#endif /* update ACELP synthesis memory */ Copy(mem_syn, st->mem_syn2_fx , M); Copy(syn+st->L_frame-L_SYN_MEM, st->mem_syn_r , L_SYN_MEM); diff --git a/lib_dec/er_dec_tcx_fx.c b/lib_dec/er_dec_tcx_fx.c index 1a38df1ff..1fe4f1bba 100644 --- a/lib_dec/er_dec_tcx_fx.c +++ b/lib_dec/er_dec_tcx_fx.c @@ -395,6 +395,20 @@ void con_tcx( FOR( i=0 ; i< Tc; i++ ) { move16(); +#ifdef BASOP_NOGLOB + *pt_exc++ = mac_r_sat( L_mac_sat( L_mac_sat( L_mac_sat( L_mac_sat( L_mac_sat( L_mac_sat( L_mac_sat( L_mac_sat( L_mac_sat( + L_mult(174/* 0.0053f Q15*/, pt1_exc[-5]), + 0/* 0.0000f Q15*/, pt1_exc[-4]), + -1442/*-0.0440f Q15*/, pt1_exc[-3]), + 0/* 0.0000f Q15*/, pt1_exc[-2]), + 8641/* 0.2637f Q15*/, pt1_exc[-1]), + 18022/* 0.5500f Q15*/, pt1_exc[0] ), + 8641/* 0.2637f Q15*/, pt1_exc[1] ), + 0/* 0.0000f Q15*/, pt1_exc[2] ), + -1442/*-0.0440f Q15*/, pt1_exc[3] ), + 0/* 0.0000f Q15*/, pt1_exc[4] ), + 174/* 0.0053f Q15*/, pt1_exc[5] ); +#else *pt_exc++ = mac_r(L_mac(L_mac(L_mac(L_mac(L_mac(L_mac(L_mac(L_mac(L_mac( L_mult(174/* 0.0053f Q15*/, pt1_exc[-5]), 0/* 0.0000f Q15*/, pt1_exc[-4]), @@ -407,6 +421,7 @@ void con_tcx( -1442/*-0.0440f Q15*/, pt1_exc[3] ), 0/* 0.0000f Q15*/, pt1_exc[4] ), 174/* 0.0053f Q15*/, pt1_exc[5] ); +#endif pt1_exc++; } } @@ -415,6 +430,20 @@ void con_tcx( FOR( i=0 ; i< Tc; i++ ) { move16(); +#ifdef BASOP_NOGLOB + *pt_exc++ = mac_r_sat( L_mac_sat( L_mac_sat( L_mac_sat( L_mac_sat( L_mac_sat( L_mac_sat( L_mac_sat( L_mac_sat( L_mac_sat( + L_mult(-174/*-0.0053f Q15*/, pt1_exc[-5]), + -121/*-0.0037f Q15*/, pt1_exc[-4]), + -459/*-0.0140f Q15*/, pt1_exc[-3]), + 590/* 0.0180f Q15*/, pt1_exc[-2]), + 8743/* 0.2668f Q15*/, pt1_exc[-1]), + 16355/* 0.4991f Q15*/, pt1_exc[0] ), + 8743/* 0.2668f Q15*/, pt1_exc[1] ), + 590/* 0.0180f Q15*/, pt1_exc[2] ), + -459/*-0.0140f Q15*/, pt1_exc[3] ), + -121/*-0.0037f Q15*/, pt1_exc[4] ), + -174/*-0.0053f Q15*/, pt1_exc[5] ); +#else *pt_exc++ = mac_r(L_mac(L_mac(L_mac(L_mac(L_mac(L_mac(L_mac(L_mac(L_mac( L_mult(-174/*-0.0053f Q15*/, pt1_exc[-5]), -121/*-0.0037f Q15*/, pt1_exc[-4]), @@ -427,6 +456,7 @@ void con_tcx( -459/*-0.0140f Q15*/, pt1_exc[3] ), -121/*-0.0037f Q15*/, pt1_exc[4] ), -174/*-0.0053f Q15*/, pt1_exc[5] ); +#endif pt1_exc++; } } @@ -775,8 +805,11 @@ void con_tcx( { gain32 = Mpy_32_16_1(gain32, 22938/*0.7f Q15*/); } +#ifdef BASOP_NOGLOB /* Critical Overflow */ + L_tmp = L_shl_sat( gain32, 1 ); +#else L_tmp = L_shl(gain32,1); - +#endif IF (GT_32(L_shl(L_deposit_h(gainCNG),sub(gainCNG_e,31-16)/*Q16*/) , L_tmp)) { gainCNG_e = sub(15+1,norm_l(L_tmp)); @@ -822,7 +855,11 @@ void con_tcx( tmp_e = norm_l(L_tmp); L_tmp = L_shl(L_tmp,tmp_e); gain_inov_e = add(sub(gain_inov_e,tmp_e),31-29);/*->Q31*/ +#ifdef BASOP_NOGLOB /* Critical Overflow */ + gain_inov = round_fx_sat( L_tmp ); /*Q15,gain_inov_e*/ +#else gain_inov = round_fx(L_tmp);/*Q15,gain_inov_e*/ +#endif } st->Mode2_lp_gainp = L_shr(L_deposit_h(alpha/*Q14*/)/*Q14+16*/,1);/*Q29*/ @@ -870,7 +907,7 @@ void con_tcx( FOR( i=0 ; i< tmp16; i++ ) { #ifdef BASOP_NOGLOB - exc[i] = add_sat(exc[i], shl(noise[i + (L_FIR_FER2 / 2)], Q_exc + noise_e));/*Q1*/ move16(); + exc[i] = add_sat(exc[i], shl_sat(noise[i + (L_FIR_FER2 / 2)], Q_exc + noise_e));/*Q1*/ move16(); #else exc[i] = add(exc[i] , shl(noise[i+(L_FIR_FER2/2)],Q_exc+noise_e));/*Q1*/ move16(); #endif @@ -1043,13 +1080,21 @@ void con_tcx( FOR (i=0; isyn_Overl_TDACFB[i] = add(buf[i] , buf[W1-1-i]); +#ifdef BASOP_NOGLOB + hTcxDec->syn_Overl_TDACFB[i] = add_sat( buf[i], buf[W1 - 1 - i] ); +#else + hTcxDec->syn_Overl_TDACFB[i] = add( buf[i], buf[W1 - 1 - i] ); +#endif move16(); } FOR (i=0; isyn_Overl_TDACFB[W2+i] = add(buf[W2+i] , buf[W1-1-W2-i]); +#ifdef BASOP_NOGLOB + hTcxDec->syn_Overl_TDACFB[W2 + i] = add_sat( buf[W2 + i], buf[W1 - 1 - W2 - i] ); +#else + hTcxDec->syn_Overl_TDACFB[W2 + i] = add( buf[W2 + i], buf[W1 - 1 - W2 - i] ); +#endif move16(); } diff --git a/lib_dec/er_sync_exc_fx.c b/lib_dec/er_sync_exc_fx.c index 23145a7d0..cf9534f33 100644 --- a/lib_dec/er_sync_exc_fx.c +++ b/lib_dec/er_sync_exc_fx.c @@ -54,10 +54,18 @@ static Word16 GetMinimumPosition( FOR (i = 0; i < cnt; i++) { tmp16 = shr(x[i],tmp_e); +#ifdef BASOP_NOGLOB + energy = L_msu_sat( energy_old, tmp16, tmp16 ); +#else energy = L_msu(energy_old,tmp16,tmp16); +#endif tmp16 = shr(x[i+filterLength],tmp_e); BASOP_SATURATE_WARNING_OFF_EVS /*Saturation will be handled*/ +#ifdef BASOP_NOGLOB + energy = L_mac_sat( energy, tmp16, tmp16 ); +#else energy = L_mac(energy,tmp16,tmp16); +#endif BASOP_SATURATE_WARNING_ON_EVS /*if (energy == MAXVAL_WORD32)*/ diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index cd52ac0e8..68e486d6b 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -156,11 +156,19 @@ ivas_error evs_dec_fx( /* st_fx->old_out_fx, st_fx->L_frameTCX); */ FOR( i = 0; i < hTcxDec->L_frameTCX; i++ ) { +#ifdef BASOP_NOGLOB + hHQ_core->old_out_fx[i] = shl_sat( mult_r( hHQ_core->old_out_fx[i], st_fx->plcInfo.recovery_gain ), 1 ); +#else hHQ_core->old_out_fx[i] = shl(mult_r(hHQ_core->old_out_fx[i] , st_fx->plcInfo.recovery_gain), 1); +#endif } FOR( i = 0; i < st_fx->L_frame; i++ ) { +#ifdef BASOP_NOGLOB + hHQ_core->old_out_LB_fx[i] = shl_sat( mult_r( hHQ_core->old_out_LB_fx[i], st_fx->plcInfo.recovery_gain ), 1 ); +#else hHQ_core->old_out_LB_fx[i] = shl(mult_r(hHQ_core->old_out_LB_fx[i], st_fx->plcInfo.recovery_gain), 1); +#endif } /* attenuate PLC buffers, if no aldo window is used and if no sid or zero frame is received */ @@ -176,7 +184,11 @@ ivas_error evs_dec_fx( FOR( i=0; i < st_fx->hTcxCfg->tcx_mdct_window_lengthFB; i++ ) { +#ifdef BASOP_NOGLOB + hTcxDec->syn_OverlFB[i] = shl_sat( mult_sat( tmp1, hTcxDec->syn_OverlFB[i] ), add( s, 1 ) ); +#else hTcxDec->syn_OverlFB[i] = shl(mult(tmp1, hTcxDec->syn_OverlFB[i]), add(s,1)); +#endif move16(); } @@ -185,7 +197,11 @@ ivas_error evs_dec_fx( tmp1 = extract_l(L_shr_r(f,s)); FOR( i=0; i < st_fx->hTcxCfg->tcx_mdct_window_length; i++ ) { +#ifdef BASOP_NOGLOB + hTcxDec->syn_Overl[i] = shl_sat( mult_sat( tmp1, hTcxDec->syn_Overl[i] ), s ); +#else hTcxDec->syn_Overl[i] = shl(mult(tmp1, hTcxDec->syn_Overl[i]),s); +#endif move16(); } } @@ -1018,7 +1034,11 @@ ivas_error evs_dec_fx( { FOR (i=0; i < st_fx->L_frame/2; i++) { +#ifdef BASOP_NOGLOB + output_sp[i] = add_sat( output_sp[i], st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2[i + 5 * st_fx->L_frame / 4] ); +#else output_sp[i] = add( output_sp[i], st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2[i+5*st_fx->L_frame/4] ); +#endif move16(); } } @@ -1184,7 +1204,11 @@ ivas_error evs_dec_fx( FOR (i = 0; i < tmps; i++) { +#ifdef BASOP_NOGLOB + output_sp[i + delay_comp] = msu_r_sat( L_mult_sat( output_sp[i + delay_comp], alpha ), shr( hHQ_core->old_out_fx[i + nz], timeIn_e ), add( alpha, -32768 ) ); +#else output_sp[i+delay_comp] = msu_r(L_mult(output_sp[i+delay_comp], alpha), shr(hHQ_core->old_out_fx[i+nz], timeIn_e), add(alpha, -32768)); +#endif move16(); alpha = add(alpha, step); } @@ -1307,7 +1331,11 @@ ivas_error evs_dec_fx( FOR (i = 0; i < tmps; i++) { +#ifdef BASOP_NOGLOB + output_sp[i + tmps] = msu_r_sat( L_mult_sat( shr( pcmbufFB[i], timeIn_e ), alpha ), output_sp[i + tmps], add( alpha, -32768 ) ); +#else output_sp[i+tmps] = msu_r(L_mult(shr(pcmbufFB[i], timeIn_e), alpha), output_sp[i+tmps], add(alpha, -32768)); +#endif move16(); alpha = add(alpha, step); } @@ -1345,7 +1373,11 @@ ivas_error evs_dec_fx( FOR (i = delta; i < tmps; i++) { +#ifdef BASOP_NOGLOB + output_sp[i] = msu_r_sat( L_mult( output_sp[i], alpha ), shr_sat( hTcxDec->FBTCXdelayBuf[i], timeIn_e ), add( alpha, -32768 ) ); +#else output_sp[i] = msu_r(L_mult(output_sp[i], alpha), shr(hTcxDec->FBTCXdelayBuf[i], timeIn_e), add(alpha, -32768)); +#endif move16(); #ifdef BASOP_NOGLOB alpha = add_sat(alpha, step); diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index dfad52f14..1970f0eed 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -1540,6 +1540,7 @@ Word16 ApplyFdCng_fx( st->hTonalMDCTConc->psychParams = EQ_16( st->core, TCX_20_CORE ) ? &st->hTonalMDCTConc->psychParamsTCX20 : &st->hTonalMDCTConc->psychParamsTCX10; } /* update isf cng estimate for concealment. Do that during concealment, in order to avoid addition clean channel complexity*/ + W_tmp = 0; FOR( j = hFdCngCom->startBand; j < hFdCngCom->stopFFTbin; j++ ) { @@ -1553,22 +1554,22 @@ Word16 ApplyFdCng_fx( IF( L_shl( L_tmp, L_tmp_exp ) > 21474836 /*0.01f Q31*/ ) #endif { - IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && NE_16( st->core, ACELP_CORE ) ) - { - TonalMdctConceal_whiten_noise_shape_ivas_fx( st, L_frame, ON_FIRST_LOST_FRAME ); - } - ELSE IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) || EQ_16(st->core, ACELP_CORE)) - { - lpc_from_spectrum( hFdCngCom, hFdCngCom->startBand, hFdCngCom->stopFFTbin, 0 ); - E_LPC_a_lsp_conversion( hFdCngCom->A_cng, lsp_cng, st->lspold_cng, M ); - Copy( lsp_cng, st->lspold_cng, M ); + IF(EQ_16(st->element_mode, IVAS_CPE_MDCT) && NE_16(st->core, ACELP_CORE)) + { + TonalMdctConceal_whiten_noise_shape_ivas_fx(st, L_frame, ON_FIRST_LOST_FRAME); + } + ELSE IF(NE_16(st->element_mode, IVAS_CPE_MDCT) || EQ_16(st->core, ACELP_CORE)) + { + lpc_from_spectrum(hFdCngCom, hFdCngCom->startBand, hFdCngCom->stopFFTbin, 0); + E_LPC_a_lsp_conversion(hFdCngCom->A_cng, lsp_cng, st->lspold_cng, M); + Copy(lsp_cng, st->lspold_cng, M); - lsp2lsf_fx( lsp_cng, st->lsf_cng, M, st->sr_core ); - } + lsp2lsf_fx(lsp_cng, st->lsf_cng, M, st->sr_core); + } - st->plcBackgroundNoiseUpdated = 1; - move16(); - } + st->plcBackgroundNoiseUpdated = 1; + move16(); + } } BREAK; @@ -3565,7 +3566,11 @@ generate_comfort_noise_dec ( s = sub(15-NOISE_HEADROOM,noiseExp); FOR (i=0; i Q14 */ +#ifdef BASOP_NOGLOB + *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 2 ) ); +#else *gain_code_fx= L_shl(L_tmp, add(exp_gcode0, 2)); +#endif move32(); /* Q14 -> Q16 */ /**norm_gain_code = *gain_code / *gain_inov;*/ @@ -464,7 +472,11 @@ void gain_dec_mless_fx( /**gain_code *= gcode0;*/ L_tmp = L_mult(gain_code16,gcode0_fx); /*Q0*Q0 -> Q1*/ +#ifdef BASOP_NOGLOB + *gain_code_fx = L_shl_sat( L_tmp, add( add( expg, exp_gcode0 ), 15 ) ); +#else *gain_code_fx = L_shl(L_tmp,add(add(expg,exp_gcode0),15)); +#endif move32(); /*Q16*/ } ELSE @@ -733,7 +745,11 @@ void gain_dec_lbr_fx( move16(); L_tmp = L_mult(cdbk_fx[add(shl(index,1),1)] , gcode0_fx); /* Q9*Q0 -> Q10 */ +#ifdef BASOP_NOGLOB + *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 6 ) ); +#else *gain_code_fx = L_shl(L_tmp, add(exp_gcode0, 6)); +#endif move16(); /* Q10 -> Q16*/ gc_mem[0] = *gain_code_fx; @@ -882,8 +898,11 @@ void gain_dec_lbr_fx( move16(); L_tmp = L_mult(cdbk_fx[add(shl(index,1),1)] , gcode0_fx); /* Q9*Q0 -> Q10 */ +#ifdef BASOP_NOGLOB + *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 6 ) ); /* Q10 -> Q16*/ +#else *gain_code_fx = L_shl(L_tmp, add(exp_gcode0, 6)); /* Q10 -> Q16*/ - +#endif gc_mem[2] = *gain_code_fx; move32(); gp_mem[2] = *gain_pit_fx; @@ -962,7 +981,11 @@ void gain_dec_lbr_fx( move16(); L_tmp = L_mult(cdbk_fx[add(shl(index,1),1)] , gcode0_fx); /* Q9*Q0 -> Q10 */ +#ifdef BASOP_NOGLOB + *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 6 ) ); +#else *gain_code_fx = L_shl(L_tmp, add(exp_gcode0, 6)); +#endif move32(); /* Q10 -> Q16*/ } @@ -1257,7 +1280,11 @@ void gain_dec_SQ_fx( /**gain_code *= gcode0;*/ L_tmp = L_mult(tmp16,gcode0); /* Q0*Q0 -> Q1*/ /**gain_code = L_shl(L_tmp,add(expg,15)); Q16*/ +#ifdef BASOP_NOGLOB + *gain_code = L_shl_sat( L_tmp, add( add( expg, exp_gcode0 ), 15 ) ); +#else *gain_code = L_shl(L_tmp,add(add(expg,exp_gcode0),15)); +#endif move32(); /*Q16*/ /**norm_gain_code = *gain_code / *gain_inov;*/ diff --git a/lib_dec/hq_hr_dec_fx.c b/lib_dec/hq_hr_dec_fx.c index 165136356..abd15b6a7 100644 --- a/lib_dec/hq_hr_dec_fx.c +++ b/lib_dec/hq_hr_dec_fx.c @@ -93,7 +93,11 @@ void hq_pred_hb_bws_fx( L_tmp = L_deposit_l(0); FOR(i=25; iprev_ener_shb_fx = extract_l(L_tmp);/*Q1*/ diff --git a/lib_dec/hq_lr_dec_fx.c b/lib_dec/hq_lr_dec_fx.c index 21f7faa35..a7b4d7041 100644 --- a/lib_dec/hq_lr_dec_fx.c +++ b/lib_dec/hq_lr_dec_fx.c @@ -344,7 +344,11 @@ void hq_lr_dec_fx( frac1 = L_Extract_lc(L_tmp, &exp); /* Extract exponent of L_tmp */ L_tmp = Pow2(30, frac1); exp = sub(exp, 30); +#ifdef BASOP_NOGLOB + Ep_fx[i] = L_shl_sat( L_tmp, s_max( sub( exp, 6 ), -31 ) ); /* Q -6 */ +#else Ep_fx[i] = L_shl(L_tmp , s_max(sub(exp,6), -31)); /* Q -6 */ +#endif } FOR( i = 0; i < bands_fx; i++ ) @@ -419,13 +423,21 @@ void hq_lr_dec_fx( { IF( GE_16(i,lowband)) { +#ifdef BASOP_NOGLOB + Ep_vari_fx = L_add_sat( Ep_vari_fx, L_abs( L_sub_sat( Ep_tmp_fx[i], Ep_tmp_fx[sub( i, 1 )] ) ) ); /*Q15 */ + Ep_avrg_fx = L_add_sat(Ep_avrg_fx,Ep_tmp_fx[i]);/*Q15 */ +#else Ep_vari_fx = L_add(Ep_vari_fx,L_abs(L_sub(Ep_tmp_fx[i],Ep_tmp_fx[sub(i,1)])));/*Q15 */ Ep_avrg_fx = L_add(Ep_avrg_fx,Ep_tmp_fx[i]);/*Q15 */ - +#endif } ELSE { +#ifdef BASOP_NOGLOB + Ep_avrgL_fx = L_add_sat( Ep_avrgL_fx, Ep_tmp_fx[i] ); /*Q15 */ +#else Ep_avrgL_fx = L_add(Ep_avrgL_fx,Ep_tmp_fx[i]);/*Q15 */ +#endif if(GT_32(Ep_tmp_fx[i],Ep_peak_fx)) { Ep_peak_fx = L_add(Ep_tmp_fx[i], 0); /*Q15 */ @@ -499,10 +511,11 @@ void hq_lr_dec_fx( IF(EQ_16(last_bitalloc_max_band[j++], 1)) { L_tmp = Mult_32_16(Ep_tmp_fx[i],sub(bands_fx,lowband));/*Q(13+0-15 = -2) */ - tmp = Calc_inv(L_shl(L_tmp,14), &exp); #ifdef BASOP_NOGLOB + tmp = Calc_inv( L_shl_sat( L_tmp, 14 ), &exp ); L_tmp = L_shl_sat(Mult_32_16(Ep_avrg_fx, tmp), sub(14, exp));/*Q(13+exp-15 +14-exp+2 = 14) */ #else + tmp = Calc_inv( L_shl( L_tmp, 14 ), &exp ); L_tmp = L_shl(Mult_32_16(Ep_avrg_fx,tmp),sub(14,exp));/*Q(13+exp-15 +14-exp+2 = 14) */ #endif L_tmp =L_max(L_tmp,16384); /*14 */ @@ -545,7 +558,11 @@ void hq_lr_dec_fx( { IF(GE_16(i,lowband)) { +#ifdef BASOP_NOGLOB + Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ +#else Ep_avrg_fx = L_add(Ep_avrg_fx,Ep_tmp_fx[i]);/*Q15 */ +#endif } ELSE { diff --git a/lib_dec/igf_dec_fx.c b/lib_dec/igf_dec_fx.c index 938e3b780..bfbda82c7 100644 --- a/lib_dec/igf_dec_fx.c +++ b/lib_dec/igf_dec_fx.c @@ -1643,7 +1643,11 @@ static void IGF_appl(IGF_DEC_PRIVATE_DATA_HANDLE hPrivate /* calc square root of L_tmp and store result in dN */ L_tmp = Sqrt32(L_tmp, &L_tmp_e); +#ifdef BASOP_NOGLOB + dN[sfb] = round_fx_sat( L_tmp ); +#else dN[sfb] = round_fx(L_tmp); +#endif dN_e[sfb] = L_tmp_e; move16(); dN[sfb+1] = dN[sfb]; @@ -1699,8 +1703,13 @@ static void IGF_appl(IGF_DEC_PRIVATE_DATA_HANDLE hPrivate /* Build a threshold and compare with L_tmp. Build negated threshold and compare with negated L_tmp to cover also fullscale L_tmp case */ BASOP_SATURATE_WARNING_OFF_EVS +#ifdef BASOP_NOGLOB + L_tmp2 = L_shl_sat( L_negate( Mpy_32_16_1( sNlocal, 33 /*0.001f Q15*/ ) ), sub( sNlocal_e, L_tmp_e ) ); + L_tmp2 = L_sub_sat(L_tmp2, L_negate(L_tmp)); +#else L_tmp2 = L_shl(L_negate(Mpy_32_16_1(sNlocal, 33/*0.001f Q15*/)), sub(sNlocal_e,L_tmp_e)); L_tmp2 = L_sub(L_tmp2, L_negate(L_tmp)); +#endif BASOP_SATURATE_WARNING_ON_EVS IF (L_tmp2 < 0 ) @@ -1968,7 +1977,11 @@ static void IGF_appl(IGF_DEC_PRIVATE_DATA_HANDLE hPrivate /* gain[sfb] = min(gain[sfb], 12.f); */ BASOP_SATURATE_WARNING_OFF_EVS /* threshold, may overflow */ +#ifdef BASOP_NOGLOB + tmp = shl_sat( gain[sfb], sub( gain_e[sfb], 15 - 5 ) ); /* 10Q5 | tmp is in 10Q5 */ +#else tmp = shl(gain[sfb], sub(gain_e[sfb], 15 - 5)); /* 10Q5 | tmp is in 10Q5 */ +#endif BASOP_SATURATE_WARNING_ON_EVS IF (tmp > 384) /* 10Q5 | 384 = 12 in 10Q5 */ @@ -2615,7 +2628,11 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in /* gain[sfb] = min(gain[sfb], 12.f); */ BASOP_SATURATE_WARNING_OFF_EVS /* threshold, may overflow */ +#ifdef BASOP_NOGLOB + tmp = shl_sat( gain[sfb], sub( gain_e[sfb], 15 - 5 ) ); /* 10Q5 | tmp is in 10Q5 */ +#else tmp = shl( gain[sfb], sub( gain_e[sfb], 15 - 5 ) ); /* 10Q5 | tmp is in 10Q5 */ +#endif BASOP_SATURATE_WARNING_ON_EVS IF( tmp > 384 ) /* 10Q5 | 384 = 12 in 10Q5 */ diff --git a/lib_dec/nelp_dec_fx.c b/lib_dec/nelp_dec_fx.c index bcafca8b4..8330ef1a9 100644 --- a/lib_dec/nelp_dec_fx.c +++ b/lib_dec/nelp_dec_fx.c @@ -318,7 +318,11 @@ void nelp_decoder_fx( Decoder_State *st_fx, Word16 *exc_nelp, Word16 *exc, Word1 E3 = L_deposit_l(1); FOR (i=0 ; ilp_gainc_fx = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 12 ) ) ); /* In Q3 */ +#else st_fx->lp_gainc_fx = round_fx(L_shl(L_tmp, sub(exp, 12))); /* In Q3 */ +#endif } /* reset the pitch buffer in case of FRAME_NO_DATA or SID frames */ IF( EQ_16(st_fx->L_frame,L_FRAME)) diff --git a/lib_dec/swb_bwe_dec_fx.c b/lib_dec/swb_bwe_dec_fx.c index f5f679035..44b2e84ef 100644 --- a/lib_dec/swb_bwe_dec_fx.c +++ b/lib_dec/swb_bwe_dec_fx.c @@ -876,7 +876,11 @@ Word16 swb_bwe_gain_deq_fx( /* o : BWE class */ /* output of Pow2() will be: */ /* 16384 < Pow2() <= 32767 */ exp = sub(exp, 13); +#ifdef BASOP_NOGLOB + SWB_fenv[n_band] = shl_sat( tmp, add( exp, 1 ) ); +#else SWB_fenv[n_band] = shl(tmp, add(exp,1)); +#endif move16();/*Q1 */ } diff --git a/lib_dec/swb_bwe_dec_hr_fx.c b/lib_dec/swb_bwe_dec_hr_fx.c index 0307a5797..63ac2236c 100644 --- a/lib_dec/swb_bwe_dec_hr_fx.c +++ b/lib_dec/swb_bwe_dec_hr_fx.c @@ -914,7 +914,11 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB synthesis */ move16(); FOR( i = 0; i < Nsv*WIDTH_BAND; i++ ) { +#ifdef BASOP_NOGLOB + t_audio_tmp[i] = shl_sat( x_norm[i], t_audio_exp ); +#else t_audio_tmp[i] = shl(x_norm[i], t_audio_exp); +#endif move16(); } @@ -1262,7 +1266,11 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB synthesis */ FOR( i=0; istate_syn_shbexc_fx[i], hBWE_TD->state_syn_shbexc_fx[i] ); /*Q(2*(st_fx->prev_Q_bwe_exc-16))*/ +#else prev_pow = L_mac0( prev_pow, hBWE_TD->state_syn_shbexc_fx[i], hBWE_TD->state_syn_shbexc_fx[i] ); /*Q(2*(st_fx->prev_Q_bwe_exc-16))*/ +#endif } rescale_genWB_mem( st_fx, sub( Q_bwe_exc, st_fx->prev_Q_bwe_exc ) ); @@ -1377,7 +1381,11 @@ void wb_tbe_dec_fx( sc = sub( Q_bwe_exc, add( Q_exc, Q_exc ) ); FOR( cnt = 0; cnt < L_FRAME32k; cnt++ ) { +#ifdef BASOP_NOGLOB + bwe_exc_extended_16[cnt + NL_BUFF_OFFSET] = round_fx_sat( L_shl_sat( bwe_exc_extended[cnt], sc ) ); +#else bwe_exc_extended_16[cnt + NL_BUFF_OFFSET] = round_fx( L_shl( bwe_exc_extended[cnt], sc ) ); +#endif } Copy( bwe_exc_extended_16 + L_FRAME32k, hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET ); @@ -1395,8 +1403,13 @@ void wb_tbe_dec_fx( curr_pow = 0; FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ ) { +#ifdef BASOP_NOGLOB + curr_pow = L_mac0_sat( curr_pow, shaped_wb_excitation[i + L_SHB_LAHEAD / 4], shaped_wb_excitation[i + + L_SHB_LAHEAD / 4] ); /* Q(2*Q_bwe_exc_ext) */ +#else curr_pow = L_mac0( curr_pow, shaped_wb_excitation[i + L_SHB_LAHEAD / 4], shaped_wb_excitation[i + L_SHB_LAHEAD / 4] ); /* Q(2*Q_bwe_exc_ext) */ +#endif } if( GT_16( voice_factors[0], 24576 )) @@ -1660,7 +1673,11 @@ void wb_tbe_dec_fx( exp = sub( add( exp, 22 ), 30 ); tmp = div_s( 16384, tmp ); L_tmp = Isqrt_lc( L_deposit_h( tmp ), &exp ); /* Q(31-exp) */ +#ifdef BASOP_NOGLOB + st_fx->last_wb_bwe_ener_fx = round_fx_sat( L_shl_sat( L_tmp, add( exp, n - 12 ) ) ); /* Q3 */ +#else st_fx->last_wb_bwe_ener_fx = round_fx( L_shl( L_tmp, add( exp, n - 12 ) ) ); /* Q3 */ +#endif } @@ -2599,8 +2616,11 @@ void swb_tbe_dec_fx( #endif } } +#ifdef BASOP_NOGLOB + ener = s_max( 1, round_fx_sat( L_shl_sat( L_ener, sub( 19, shl( Q_bwe_exc, 1 ) ) ) ) ); /* Q3: 2*Q_bwe_exc+19-2*Q_bwe_exc-16 */ +#else ener = s_max(1, round_fx( L_shl( L_ener, sub(19, shl(Q_bwe_exc, 1)) ) )); /* Q3: 2*Q_bwe_exc+19-2*Q_bwe_exc-16 */ - +#endif /* WB/SWB bandwidth switching */ IF( st_fx->bws_cnt > 0 ) { @@ -2677,7 +2697,11 @@ void swb_tbe_dec_fx( /*st_fx->Q_syn2 -1 + 26- exp_ener -15 -(st_fx->Q_syn2 -exp_ener -15 ) -16 = (11) 0.25*/ } L_tmp = L_mult0(st_fx->prev_ener_shb_fx, inv_ener); /*Q(1+15+14-3-exp_ener) = 27 -exp_ener*/ +#ifdef BASOP_NOGLOB + GainFrame_prevfrm_fx = L_shr_sat( L_tmp, sub( 9, exp_ener ) ); /*27 -exp_ener -(9-exp_ener )= Q18*/ +#else GainFrame_prevfrm_fx = L_shr(L_tmp, sub(9, exp_ener)); /*27 -exp_ener -(9-exp_ener )= Q18*/ +#endif } ELSE { @@ -2739,7 +2763,11 @@ void swb_tbe_dec_fx( exp_ener = norm_s(ener); tmp = shl(ener, exp_ener);/*Q(3+exp)*/ inv_ener = div_s(16384, tmp);/*Q(15+14-3-exp)*/ +#ifdef BASOP_NOGLOB + prev_ener_ratio_fx = L_shr_sat( L_mult0( st_fx->prev_ener_shb_fx, inv_ener ), sub( 9, exp_ener ) ); /*Q: 1+26-exp-9+exp = 18 */ +#else prev_ener_ratio_fx = L_shr(L_mult0(st_fx->prev_ener_shb_fx, inv_ener), sub(9, exp_ener)); /*Q: 1+26-exp-9+exp = 18 */ +#endif } IF(EQ_16(st_fx->nbLostCmpt, 1)) @@ -3163,7 +3191,11 @@ void swb_tbe_dec_fx( move16(); FOR( i = 0; i < 40; i++ ) { +#ifdef BASOP_NOGLOB + shaped_shb_excitation[add( i, i_mult( j, 40 ) )] = shl_sat( mult_r( shaped_shb_excitation[add( i, i_mult( j, 40 ) )], scale ), 3 ); +#else shaped_shb_excitation[add(i,i_mult(j,40))] = shl(mult_r( shaped_shb_excitation[add(i,i_mult(j,40))], scale) ,3); +#endif move16(); /* Q_bwe_exc +12+3 -15 =Q_bwe_exc*/ } @@ -3220,7 +3252,11 @@ void swb_tbe_dec_fx( tmp = div_s( 16384, tmp ); L_tmp = L_deposit_h( tmp ); L_tmp = Isqrt_lc( L_tmp, &exp ); +#ifdef BASOP_NOGLOB + st_fx->prev_ener_shb_fx = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 14 ) ) ); /* Q1 */ +#else st_fx->prev_ener_shb_fx = round_fx( L_shl( L_tmp, sub( exp, 14 ) ) ); /* Q1 */ +#endif } /* st->prev_SWB_fenv[i] = sqrt(curr_frame_pow/L_FRAME16k); */ L_tmp = Mult_32_16( curr_frame_pow, 26214 ); /* curr_frame_pow_exp+8; 26214=(1/L_FRAME16k) in Q23 */ @@ -3234,7 +3270,11 @@ void swb_tbe_dec_fx( tmp = div_s( 16384, tmp ); L_tmp = L_deposit_h( tmp ); L_tmp = Isqrt_lc( L_tmp, &exp ); +#ifdef BASOP_NOGLOB + tmp = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 14 ) ) ); /* Q1 */ +#else tmp = round_fx( L_shl( L_tmp, sub( exp, 14 ) ) ); /* Q1 */ +#endif } set16_fx(st_fx->prev_SWB_fenv_fx, tmp, SWB_FENV); /* Q1 */ @@ -4450,7 +4490,11 @@ void fb_tbe_dec_fx( /* v_add_fx( hb_synth, fb_synth, hb_synth, L_FRAME48k );*/ FOR (i=0; ilastBlockData.nSamples, &inv_exp ); tiltFactor = round_fx( BASOP_Util_fPow( L_max( L_tmp, L_deposit_h( tiltCompFactor ) ), 0, L_deposit_h( inv_samples ), inv_exp, &exp ) ); BASOP_SATURATE_WARNING_OFF_EVS /*next op may result in 32768*/ +#ifdef BASOP_NOGLOB + tiltFactor = shl_sat( tiltFactor, exp ); +#else tiltFactor = shl( tiltFactor, exp ); +#endif BASOP_SATURATE_WARNING_ON_EVS tilt = MAX16B; move16(); @@ -1916,7 +1920,11 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( tmp = round_fx( BASOP_Util_fPow( L_deposit_h( tiltFactor ), 0, L_deposit_h( hTonalMDCTConc->pTCI_float->upperIndex[hTonalMDCTConc->pTCI_float->numIndexes - 1] - hTonalMDCTConc->pTCI_float->lowerIndex[hTonalMDCTConc->pTCI_float->numIndexes - 1] + 1 ), 15, &exp ) ); BASOP_SATURATE_WARNING_OFF_EVS /*next op may result in 32768*/ +#ifdef BASOP_NOGLOB + tmp = shl_sat( tmp, exp ); +#else tmp = shl( tmp, exp ); +#endif BASOP_SATURATE_WARNING_ON_EVS tilt = mult_r( tilt, tmp ); @@ -2326,7 +2334,11 @@ void TonalMDCTConceal_InsertNoise( inv_samples = Inv16(hTonalMDCTConc->lastBlockData.nSamples, &inv_exp); tiltFactor = round_fx(BASOP_Util_fPow(L_max(L_tmp, L_deposit_h(tiltCompFactor)), 0, L_deposit_h(inv_samples),inv_exp, &exp)); BASOP_SATURATE_WARNING_OFF_EVS /*next op may result in 32768*/ +#ifdef BASOP_NOGLOB + tiltFactor = shl_sat( tiltFactor, exp ); +#else tiltFactor = shl(tiltFactor, exp); +#endif BASOP_SATURATE_WARNING_ON_EVS tilt = 32767/*1.0f Q15*/; @@ -2501,7 +2513,11 @@ void TonalMDCTConceal_InsertNoise( tmp = round_fx(BASOP_Util_fPow(L_deposit_h(tiltFactor), 0, L_deposit_h(hTonalMDCTConc->pTCI_float->upperIndex[hTonalMDCTConc->pTCI_float->numIndexes-1]-hTonalMDCTConc->pTCI_float->lowerIndex[hTonalMDCTConc->pTCI_float->numIndexes-1]+1),15, &exp)); BASOP_SATURATE_WARNING_OFF_EVS /*next op may result in 32768*/ +#ifdef BASOP_NOGLOB + tmp = shl_sat( tmp, exp ); +#else tmp = shl(tmp, exp); +#endif BASOP_SATURATE_WARNING_ON_EVS tilt = mult_r(tilt,tmp); diff --git a/lib_dec/voiced_dec_fx.c b/lib_dec/voiced_dec_fx.c index 3dadaf71c..607939b6d 100644 --- a/lib_dec/voiced_dec_fx.c +++ b/lib_dec/voiced_dec_fx.c @@ -323,8 +323,13 @@ ivas_error ppp_voiced_decoder_fx( /* temp32_fx = (Word32)divide_dp((Word40)819200,(Word40)L_shl((Word32)CURRP_Q_D_FX->lag_fx,6),-23,1);//Q6 */ exp = norm_s(CURRP_Q_D_FX->lag_fx); tmp = div_s(shl(1,sub(14,exp)),CURRP_Q_D_FX->lag_fx);/*29-exp */ +#ifdef BASOP_NOGLOB + L_tmp = L_shl_sat( L_mult0( tmp, 12800 ), exp - 7 ); + temp32_fx = round_fx_sat( L_tmp ); +#else L_tmp =L_shl(L_mult0(tmp,12800),exp - 7); temp32_fx = round_fx(L_tmp); +#endif diff = round_fx(L_shl(temp32_fx,16-6));/*Q0 */ CURRP_Q_D_FX->nH_fx = find_rem(upper_cut_off_freq,diff,&rem_fx);/*Q0 */ diff --git a/lib_dec/waveadjust_fec_dec_fx.c b/lib_dec/waveadjust_fec_dec_fx.c index 323cd536a..ec7abe07b 100644 --- a/lib_dec/waveadjust_fec_dec_fx.c +++ b/lib_dec/waveadjust_fec_dec_fx.c @@ -1538,15 +1538,26 @@ void waveform_adj2_fix( Word16 *overlapbuf, ratio = extract_l(L_shr(L_mult(i, ptable), tablescale)); dat= shl(sbuf[i],s16MaxCoefNorm); temp_OUT= mult(*recovery_gain, sub(32767,ratio)); +#ifdef BASOP_NOGLOB + outx_new[i] = round_fx_sat( L_add_sat( L_shr_sat( L_mult( temp_OUT, dat ), s16MaxCoefNorm - 1 ), L_shr_sat( L_mult( shl( outx_new[i], s16MaxCoefNorm2 ), ratio ), s16MaxCoefNorm2 ) ) ); +#else outx_new[i]= round_fx(L_add(L_shr(L_mult(temp_OUT,dat ),s16MaxCoefNorm-1), L_shr(L_mult(shl(outx_new[i],s16MaxCoefNorm2),ratio),s16MaxCoefNorm2))); +#endif move16(); +#ifdef BASOP_NOGLOB + *recovery_gain = sub_sat( *recovery_gain, shr_r( step_concealgain, 1 ) ); /* q14 */ +#else *recovery_gain =sub(*recovery_gain,shr_r(step_concealgain,1)); /* q14 */ +#endif } FOR (i = gain_zero_start; i < Framesize; i++) { ratio = extract_l(L_shr(L_mult(i, ptable), tablescale)); +#ifdef BASOP_NOGLOB + outx_new[i] = round_fx_sat( L_shr_sat( L_mult( shl( outx_new[i], s16MaxCoefNorm2 ), ratio ), s16MaxCoefNorm2 ) ); +#else outx_new[i] = round_fx(L_shr(L_mult(shl(outx_new[i],s16MaxCoefNorm2),ratio),s16MaxCoefNorm2)); - +#endif } if (*recovery_gain < 0) diff --git a/lib_enc/SNR_calc_fx.c b/lib_enc/SNR_calc_fx.c index eea94dea1..90fee4382 100644 --- a/lib_enc/SNR_calc_fx.c +++ b/lib_enc/SNR_calc_fx.c @@ -320,7 +320,11 @@ void snr_calc( } *tsnr = VAD_Log2(tmp, minscale2); move32(); +#ifdef BASOP_NOGLOB + *tsnr = L_add_sat( *tsnr, MUL_F( *tsnr, 6226 ) ); /* *tsnr *= 1.2; */ +#else *tsnr = L_add(*tsnr, MUL_F(*tsnr, 6226)); /* *tsnr *= 1.2; */ +#endif move32(); } ELSE diff --git a/lib_enc/acelp_core_switch_enc_fx.c b/lib_enc/acelp_core_switch_enc_fx.c index ce7dfa212..178f90d39 100644 --- a/lib_enc/acelp_core_switch_enc_fx.c +++ b/lib_enc/acelp_core_switch_enc_fx.c @@ -365,10 +365,17 @@ static void encod_gen_voic_core_switch_fx( { /* code in Q9, gain_pit in Q14 */ L_tmp = L_mult(gcode16, code[i]); +#ifdef BASOP_NOGLOB + L_tmp = L_shl_sat( L_tmp, 5 ); + L_tmp = L_mac_sat(L_tmp, exc[i ], gain_pit); + L_tmp = L_shl_sat(L_tmp, 1); /* saturation can occur here */ + exc[i ] = round_fx_sat(L_tmp); +#else L_tmp = L_shl(L_tmp, 5); L_tmp = L_mac(L_tmp, exc[i ], gain_pit); L_tmp = L_shl(L_tmp, 1); /* saturation can occur here */ exc[i ] = round_fx(L_tmp); +#endif } /* write reserved bits */ @@ -385,7 +392,11 @@ static void encod_gen_voic_core_switch_fx( FOR( i = L_SUBFR; i < 2*L_SUBFR; i++ ) { +#ifdef BASOP_NOGLOB + exc[i] = round_fx_sat( L_shl_sat( L_mult_sat( exc[i], gain_pit ), 1 ) ); +#else exc[i] = round_fx(L_shl(L_mult(exc[i], gain_pit), 1)); +#endif } return; diff --git a/lib_enc/acelp_enc_util_fx.c b/lib_enc/acelp_enc_util_fx.c index 89399a711..4cd28a324 100644 --- a/lib_enc/acelp_enc_util_fx.c +++ b/lib_enc/acelp_enc_util_fx.c @@ -78,6 +78,20 @@ Word16 E_ACELP_toeplitz_mul_fx( L_maxloc = L_shr(L_maxloc, 2); /* Do not warn saturation of L_tot, since its for headroom estimation. */ BASOP_SATURATE_WARNING_OFF_EVS +#ifdef BASOP_NOGLOB + L_tot = L_add_sat( L_tot, L_maxloc ); /* +max/4 */ + L_maxloc = L_shr(L_maxloc, 1); + L_tot = L_add_sat(L_tot, L_maxloc); /* +max/8 */ + if ( highrate ) + { + L_tot = L_add_sat(L_tot, L_maxloc); /* +max/8 */ + } + L_maxloc = L_shr(L_maxloc, 1); + if ( highrate ) + { + L_tot = L_add_sat(L_tot, L_maxloc); /* +max/16 */ + } +#else L_tot = L_add(L_tot, L_maxloc); /* +max/4 */ L_maxloc = L_shr(L_maxloc, 1); L_tot = L_add(L_tot, L_maxloc); /* +max/8 */ @@ -90,6 +104,7 @@ Word16 E_ACELP_toeplitz_mul_fx( { L_tot = L_add(L_tot, L_maxloc); /* +max/16 */ } +#endif BASOP_SATURATE_WARNING_ON_EVS } diff --git a/lib_enc/amr_wb_enc_fx.c b/lib_enc/amr_wb_enc_fx.c index 23e72016c..7c468d561 100644 --- a/lib_enc/amr_wb_enc_fx.c +++ b/lib_enc/amr_wb_enc_fx.c @@ -361,7 +361,11 @@ void amr_wb_enc_fx( { lp_bckr = Mean32(hNoiseEst->bckr_fx+1, 9 ); } +#ifdef BASOP_NOGLOB + hp_bckr = L_shr( L_add_sat( hNoiseEst->bckr_fx[st->max_band - 1], hNoiseEst->bckr_fx[st->max_band] ), 1 ); +#else hp_bckr = L_shr(L_add(hNoiseEst->bckr_fx[st->max_band -1] , hNoiseEst->bckr_fx[st->max_band]),1); +#endif if( hp_bckr == 0 ) /* Avoid division by zero. */ { hp_bckr = L_deposit_l(1); diff --git a/lib_enc/analy_sp_fx.c b/lib_enc/analy_sp_fx.c index 0e115ffa5..a1c7a4427 100644 --- a/lib_enc/analy_sp_fx.c +++ b/lib_enc/analy_sp_fx.c @@ -427,8 +427,11 @@ static void find_enr( * Find the total energy over the input bandwidth *-----------------------------------------------------------------*/ +#ifdef BASOP_NOGLOB + etot = L_add_sat( *LEtot, L_shl_sat( etot, sub( exp_etot, 4 ) ) ); +#else etot = L_add(*LEtot, L_shl(etot, sub(exp_etot, 4))); - +#endif *LEtot = etot; move32(); diff --git a/lib_enc/arith_coder_enc_fx.c b/lib_enc/arith_coder_enc_fx.c index 9a6bb3e77..da9de9b92 100644 --- a/lib_enc/arith_coder_enc_fx.c +++ b/lib_enc/arith_coder_enc_fx.c @@ -92,7 +92,11 @@ static Word16 tcx_arith_estimate_scale( /* scale and accumulate */ BASOP_SATURATE_WARNING_OFF_EVS; +#ifdef BASOP_NOGLOB + accu = L_add_sat( accu, L_shr( L_tmp, sub( tmp, s ) ) ); +#else accu = L_add(accu, L_shr(L_tmp, sub(tmp, s))); +#endif BASOP_SATURATE_WARNING_ON_EVS; } s = sub(shl(add(abs_spectrum_e, envelope_e), 1), s); diff --git a/lib_enc/avq_cod_fx.c b/lib_enc/avq_cod_fx.c index b05b84536..de85c7755 100644 --- a/lib_enc/avq_cod_fx.c +++ b/lib_enc/avq_cod_fx.c @@ -123,7 +123,11 @@ void AVQ_cod_fx( /* o: comfort noise gain factor */ /* estimated gain (when offset=0, estimated gain=1) */ f_tmp = L_Extract_lc(Ltmp, &e_tmp); tmp16 = extract_l(Pow2(14, f_tmp)); +#ifdef BASOP_NOGLOB + Lgain = L_shl_sat( tmp16, e_tmp ); +#else Lgain = L_shl(tmp16, e_tmp); +#endif /* gain_inv = 1.0f / gain */ e_tmp = norm_l(Lgain); tmp16 = extract_h(L_shl(Lgain, e_tmp)); diff --git a/lib_enc/bass_psfilter_enc_fx.c b/lib_enc/bass_psfilter_enc_fx.c index 4173a2ac6..42927271e 100644 --- a/lib_enc/bass_psfilter_enc_fx.c +++ b/lib_enc/bass_psfilter_enc_fx.c @@ -399,8 +399,13 @@ Word16 bass_pf_enc_fx( /* *gain_factor_param = (int)(-2.f*(cross_n_d/nrg_n)+0.5f); */ tmp16 = BASOP_Util_Divide3232_Scale(cross_n_d, nrg_n, &st); /* Q15-st-s3+s4 */ BASOP_SATURATE_WARNING_OFF_EVS; +#ifdef BASOP_NOGLOB + tmp16 = shl_sat( negate( tmp16 ), add( sub( add( st, s3 ), s4 ), 1 - 14 ) ); /* Q1 */ + tmp16 = shr(add_sat(tmp16, 1), 1); /* Q0 */ +#else tmp16 = shl(negate(tmp16), add(sub(add(st, s3), s4), 1-14)); /* Q1 */ tmp16 = shr(add(tmp16, 1), 1); /* Q0 */ +#endif BASOP_SATURATE_WARNING_ON_EVS; *gain_factor_param = tmp16; diff --git a/lib_enc/cng_enc_fx.c b/lib_enc/cng_enc_fx.c index e18b66d00..23a31264b 100644 --- a/lib_enc/cng_enc_fx.c +++ b/lib_enc/cng_enc_fx.c @@ -1,1579 +1,1611 @@ -/*==================================================================================== - EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0 - ====================================================================================*/ -#include -#include "options.h" /* Compilation switches */ -#include "cnst.h" /* Common constants */ -#include "rom_enc.h" /* Encoder static table prototypes */ -#include "rom_com.h" /* Static table prototypes */ -//#include "prot_fx.h" /* Function prototypes */ -#include "prot_fx1.h" /* Function prototypes */ -#include "prot_fx2.h" /* Function prototypes */ -#include "prot_fx_enc.h" /* Function prototypes */ -//#include "basop_mpy.h" - -#include -/*---------------------------------------------------------------------* -* Local constants -*---------------------------------------------------------------------*/ - -#define MAX_DELTA 1 -#define MIN_CNT 50 /* Minimum frame number before SID interval adaptation */ -#define INT_H 50 -#define INT_L 8 - -/*---------------------------------------------------------------------* - * Local function prototypes - *---------------------------------------------------------------------*/ -static void shb_CNG_encod_fx(Encoder_State *st_fx, const Word16 update_fx ); -static Word16 shb_DTX_fx(Encoder_State *st_fx, const Word16 *shb_speech_fx, const Word16 *syn_12k8_16k ); -/*---------------------------------------------------------------------* -* CNG_enc() -* -* Confort noise generation for the coder -*---------------------------------------------------------------------*/ -void CNG_enc_fx( - Encoder_State *st_fx,/* i/o: State structure */ - Word16 Aq[], /* o : LP coefficients Q12 */ - const Word16 *speech, /* i : pointer to current frame input speech buffer Q_new */ - Word32 L_enr, /* i : residual energy from Levinson-Durbin Q6 */ - const Word16* lsp_mid, /* i : mid frame LSPs Q15 */ - Word16 *lsp_new, /* i/o: current frame ISPs Q15 */ - Word16 *lsf_new, /* i/o: current frame ISFs Qlog2(2.56) */ - Word16 *allow_cn_step, /* o : allow CN step Q0 */ - Word16 Q_new, /* i : Q value of speech */ - Word32 *q_env, - Word16 *sid_bw -) -{ - Word16 enr_index; - Word16 i, j, ptr; - Word16 m1; - Word16 res[L_FRAME16k]; - Word16 step_inv=0; - Word16 hi, lo; - Word16 maxl=0; - Word16 num_bits=0; - Word16 step=0; - Word16 *pt_res; - const Word16 *pt_sp; - Word16 enr; - Word32 L_tmp, L_ener; - Word16 k, tmp1; - Word16 weights; - Word16 sp_enr; - Word32 L_tmp1; - Word16 exp; - Word16 m = 0; - Word16 tmp[HO_HIST_SIZE*M]; - Word16 ll, s_ptr; - Word16 tmpv, maxv, scale, att = 1; - Word16 lsf_tmp[M]; - Word32 C[M]; - Word32 max_val[2]; - Word16 max_idx[2]; - Word16 ftmp_fx; - Word16 lsp_tmp[M]; - Word16 dev; - Word16 max_dev; - Word16 dist; - Word16 max_idx1[2]= {0,0}; - Word16 fft_io[L_FRAME16k]; - Word16 *ptR,*ptI; - Word32 enr1=0; - Word32 env[NUM_ENV_CNG]; - Word32 min1; - Word16 min1_idx; - Word32 d; - Word16 res1[L_FRAME16k]; - Word32 tmp_env[HO_HIST_SIZE*NUM_ENV_CNG]; - Word16 fra; - Word16 temp_lo_fx, temp_hi_fx; - Word16 exp_pow; - Word16 force_cn_step=0; - Word16 tmp_loop; - Word16 st_lp_sp_enr; - DTX_ENC_HANDLE hDtxEnc = st_fx->hDtxEnc; - TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc; - BSTR_ENC_HANDLE hBstr = st_fx->hBstr; - st_lp_sp_enr = hTdCngEnc->lp_sp_enr_fx; - Word16 lp_ener_thr_scale; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL - Flag Overflow = 0; -#endif - /* Temp variables for floating point functions */ - - lp_ener_thr_scale = 8; /* 4.0f*/ /*IVAS_CODE Q2 */ - move16(); - if (NE_16(st_fx->element_mode, EVS_MONO)) - { - lp_ener_thr_scale = 7; /* 3.5f;*/ - move16(); - } - /*sp_enr = (float) log10( sum2_f( speech, L_frame )/L_frame + 0.1f )/ (float)log10(2.0f);*//*9.1 */ - pt_sp = speech; - L_ener = L_deposit_l(1); - /* L_ener = L_add(L_shr(sum2_f_fx( speech, L_frame ), 8) , L_ener);*/ - IF( EQ_16(st_fx->L_frame, L_FRAME)) - { - FOR (j=0; j<128; j++) - { - L_tmp = L_mult0(*pt_sp, *pt_sp); - pt_sp++; - L_tmp = L_mac0(L_tmp, *pt_sp, *pt_sp); - pt_sp++; - L_ener = L_add(L_ener, L_shr(L_tmp, 7)); /* 2*Q_new + 1, divide by L_frame done here */ - } - } - ELSE /* L_FRAME16k */ - { - FOR (i=0; i<2; i++) - { - FOR (j=0; j<80; j++) - { - L_tmp = L_mult0(*pt_sp, *pt_sp); - pt_sp++; - L_tmp = L_mac0(L_tmp, *pt_sp, *pt_sp); - pt_sp++; - L_ener = L_add(L_ener, L_shr(Mult_32_16(L_tmp,26214 /* 256/320, Q15 */), 7)); /* 2*Q_new + 1, divide by L_frame done here */ - } - } - } - - hi = norm_l(L_ener); - lo = Log2_norm_lc(L_shl(L_ener, hi)); - hi = sub(29, hi); /* log2 exp in Q2*Q_new */ - hi = sub(hi, shl(Q_new, 1)); /* Q0 */ - L_tmp = L_Comp(hi, lo); /* Q16 */ - sp_enr = round_fx(L_shl(L_tmp, 8)); /* Q8 (16+8-16) */ - - if (sp_enr < 0) - { - sp_enr = 0; - move16(); - } - test(); - IF (hDtxEnc->first_CNG == 0 || hTdCngEnc->old_enr_index < 0 ) - { - hTdCngEnc->lp_sp_enr_fx = sp_enr; - move16(); /* Q8 */ - } - ELSE - { - test(); - test(); - test(); - test(); - IF( GT_32(st_fx->last_core_brate, SID_2k40) && ( EQ_16( st_fx->last_core, HQ_CORE ) || st_fx->hTdCngEnc->burst_ho_cnt > 0 ) && LT_16(hTdCngEnc->lp_sp_enr_fx, 1536) && - GT_16(sub(sp_enr, hTdCngEnc->lp_sp_enr_fx), 1024) && GT_16(sp_enr, 1536) ) - { - hTdCngEnc->lp_sp_enr_fx = sp_enr; - move16(); - force_cn_step = 1; - move16(); - } - ELSE - { - hTdCngEnc->lp_sp_enr_fx = round_fx(L_mac(L_mult(29491 /* 0.9, Q15 */,hTdCngEnc->lp_sp_enr_fx), 3277 /* 0.1, Q15 */,sp_enr)); /* Q8 (8+15+1-16) */ - } - } - /* update the pointer to circular buffer of old LSP vectors */ - hTdCngEnc->cng_hist_ptr = add(hTdCngEnc->cng_hist_ptr,1); - if(EQ_16(hTdCngEnc->cng_hist_ptr, DTX_HIST_SIZE)) - { - hTdCngEnc->cng_hist_ptr = 0; - move16(); - } - - /* update the circular buffer of old LSP vectors with the new LSP vector */ - Copy( lsp_new, &(hTdCngEnc->cng_lsp_hist_fx[(hTdCngEnc->cng_hist_ptr)*M]), M ); - - /*-----------------------------------------------------------------* - * Find CNG spectral envelope - * Find LSP median - *-----------------------------------------------------------------*/ - test(); - test(); - IF( (EQ_32(st_fx->core_brate, SID_2k40) || EQ_32(st_fx->core_brate,SID_1k75)) && GE_16(hDtxEnc->cng_cnt,sub(hDtxEnc->cng_hist_size,1))) - { - set32_fx( max_val, 0, 2 ); - set16_fx( max_idx, 0, 2 ); - - FOR( i=0; i< hDtxEnc->cng_hist_size; i++ ) - { - IF ( EQ_16(st_fx->L_frame,L_FRAME)) - { - lsp2lsf_fx( &hTdCngEnc->cng_lsp_hist_fx[i*M], lsf_tmp, M, INT_FS_FX ); - ftmp_fx = 964; - move16();/*QX2.56 */ - tmpv = sub(16384,add(lsf_tmp[M-1],ftmp_fx)); /*QX2.56 */ - L_tmp = L_mult0(tmpv,tmpv); /*QX6.5536 */ - } - ELSE - { - lsp2lsf_fx( &hTdCngEnc->cng_lsp_hist_fx[i*M], lsf_tmp, M, INT_FS_16k ); - ftmp_fx = 1205; - move16();/*QX2.56 */ - tmpv = sub(20480,add(lsf_tmp[M-1],ftmp_fx)); /*QX2.56 */ - L_tmp = L_mult0(tmpv,tmpv); /*QX6.5536 */ - } - - tmpv = sub(lsf_tmp[0],ftmp_fx); /*QX2.56 */ - L_tmp = L_mac0(L_tmp,tmpv,tmpv); /*QX6.5536 */ - FOR ( j=0; jcng_hist_size; j++ ) - { - L_tmp = L_add(L_tmp,L_deposit_l(hTdCngEnc->cng_lsp_hist_fx[j*M+i])); /*Q15 */ - } - - L_tmp = L_sub(L_tmp,L_add(L_deposit_l(hTdCngEnc->cng_lsp_hist_fx[max_idx[0]*M+i]),L_deposit_l(hTdCngEnc->cng_lsp_hist_fx[max_idx[1]*M+i]))); /*Q15 */ - tmpv= div_s(1,sub(hDtxEnc->cng_hist_size,2)); /*Q15 */ - L_tmp = Mpy_32_16_1(L_tmp,tmpv); /*Q15 */ - lsp_new[i] = extract_l(L_tmp); /*Q15 */ - } - max_idx1[0] = max_idx[0]; - move16(); - max_idx1[1] = max_idx[1]; - move16(); - } - - /*-----------------------------------------------------------------* - * Quantize CNG spectral envelope (only in SID frame) - * Quantize the LSF vector - *-----------------------------------------------------------------*/ - *allow_cn_step = 0; - move16(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( ((hDtxEnc->cng_cnt == 0) && - GT_16(hTdCngEnc->lp_sp_enr_fx, 1536) && - (LT_16(add(st_lp_sp_enr, 1024 /* 4.0, Q8 */), sp_enr)) && - (hDtxEnc->first_CNG != 0) && - (hTdCngEnc->old_enr_index >= 0) && - (GT_32(st_fx->last_core_brate, SID_2k40))) || - EQ_16(force_cn_step, 1)) - { - *allow_cn_step = 1; - move16(); - } - - /* Initialize the CNG spectral envelope in case of the very first CNG frame */ - IF(hDtxEnc->first_CNG == 0) - { - Copy(st_fx->lsp_old_fx, hDtxEnc->lspCNG_fx, M); - - /* Average the CNG spectral envelope in case of the very first CNG frame */ - IF (NE_16(st_fx->element_mode, EVS_MONO)) - { - FOR (i = 0; i < M; i++) - { - /*lsp_new[i] = 0.5f * (lsp_mid[i] + lsp_new[i]);*/ - lsp_new[i] = mac_r(L_mult(lsp_mid[i], 16384), lsp_new[i], 16384); - move16(); - } - } - } - - - test(); - IF( EQ_32(st_fx->core_brate, SID_2k40) || EQ_32(st_fx->core_brate,SID_1k75)) - { - /* LSF quantization */ - IF ( st_fx->Opt_AMR_WB != 0 ) - { - isf_enc_amr_wb_fx( st_fx, lsf_new, lsp_new, 0); - } - ELSE - { -#ifdef LSF_RE_USE_SECONDARY_CHANNEL - lsf_enc_fx(st_fx, lsf_new, lsp_new, NULL, NULL, 100, 0, 0, NULL, Q_new); -#else - lsf_enc_fx( st_fx, lsf_new, lsp_new, NULL, NULL,100, 0, 0, Q_new ); -#endif - } - /* Reset CNG history if CNG frame length is changed */ - test(); - test(); - if ( EQ_16(st_fx->bwidth,WB) && hDtxEnc->first_CNG!=0 && NE_16(st_fx->L_frame, hDtxEnc->last_CNG_L_frame)) - { - hTdCngEnc->ho_hist_size = 0; - move16(); - } - } - ELSE - { - /* Use old LSP vector */ - Copy( st_fx->lsp_old_fx, lsp_new, M ); - Copy( st_fx->lsf_old_fx, lsf_new, M ); - } - - /*---------------------------------------------------------------------* - * CNG spectral envelope update - * Find A(z) coefficients - *---------------------------------------------------------------------*/ - - IF( LE_32(st_fx->last_core_brate, SID_2k40)) - { - /* Reset hangover counter if not first SID period */ - if( GT_32(st_fx->core_brate,FRAME_NO_DATA)) - { - hTdCngEnc->num_ho = 0; - move16(); - } - /* Update LSPs if last SID energy not outlier or insufficient number of hangover frames */ - test(); - IF( LT_16(hTdCngEnc->num_ho,3) || LT_32(Mult_32_16(hTdCngEnc->Enew_fx,21845 /*1/1.5f, Q15*/), hTdCngEnc->lp_ener_fx)) - { - FOR( i=0; ilspCNG_fx[i] = mac_r(L_mult(CNG_ISF_FACT_FX, hDtxEnc->lspCNG_fx[i]),32768-CNG_ISF_FACT_FX,lsp_new[i]); - move16(); /* Q15 (15+15+1-16) */ - } - } - } - ELSE - { - /* Update CNG_mode if allowed */ - test(); - test(); - test(); - IF( EQ_16(st_fx->element_mode, EVS_MONO) && (( st_fx->Opt_AMR_WB || EQ_16(st_fx->bwidth,WB)) - && ( !hDtxEnc->first_CNG || GE_16(hTdCngEnc->act_cnt2,MIN_ACT_CNG_UPD) ) ) ) - { - IF (GT_32(hDtxEnc->last_active_brate, ACELP_16k40)) - { - hDtxEnc->CNG_mode = -1; - move16(); - } - ELSE - { - hDtxEnc->CNG_mode = get_cng_mode(hDtxEnc->last_active_brate); - } - } - - /* If first sid after active burst update LSF history from circ buffer */ - hTdCngEnc->burst_ho_cnt = s_min(hTdCngEnc->burst_ho_cnt, hTdCngEnc->ho_circ_size); - hTdCngEnc->act_cnt = 0; - move16(); - s_ptr = add(sub(hTdCngEnc->ho_circ_ptr, hTdCngEnc->burst_ho_cnt),1); - - if( s_ptr < 0 ) - { - s_ptr = add(s_ptr, hTdCngEnc->ho_circ_size); - } - - FOR( ll = hTdCngEnc->burst_ho_cnt; ll > 0; ll-- ) - { - hTdCngEnc->ho_hist_ptr = add(hTdCngEnc->ho_hist_ptr,1); - if( EQ_16(hTdCngEnc->ho_hist_ptr, HO_HIST_SIZE)) - { - hTdCngEnc->ho_hist_ptr = 0; - move16(); - } - - /* Conversion between 12.8k and 16k LSPs */ - test(); - test(); - IF( EQ_16(st_fx->L_frame,L_FRAME )&&EQ_16(hTdCngEnc->ho_16k_lsp[s_ptr],1)) - { - /* Conversion from 16k LPSs to 12k8 */ - lsp_convert_poly_fx( &(hTdCngEnc->ho_lsp_circ_fx[s_ptr*M]), st_fx->L_frame, 0 ); - } - ELSE IF ( EQ_16(st_fx->L_frame,L_FRAME16k)&& hTdCngEnc->ho_16k_lsp[s_ptr]==0) - { - /* 16k LSPs already converted and stored, just copy to the other buffer */ - Copy(&(hTdCngEnc->ho_lsp_circ2_fx[s_ptr*M]), &(hTdCngEnc->ho_lsp_circ_fx[s_ptr*M]), M ); - } - /* update the circular buffers */ - Copy(&(hTdCngEnc->ho_lsp_circ_fx[s_ptr*M]), &(hTdCngEnc->ho_lsp_hist_fx[hTdCngEnc->ho_hist_ptr*M]), M ); - Copy32(&(hTdCngEnc->ho_ener_circ_fx[s_ptr]), &(hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr]), 1 ); - hTdCngEnc->ho_sid_bw = L_shl(L_and(hTdCngEnc->ho_sid_bw, (Word32) 0x3fffffffL ), 1); - Copy32(&(hTdCngEnc->ho_env_circ_fx[s_ptr*NUM_ENV_CNG]), &(hTdCngEnc->ho_env_hist_fx[hTdCngEnc->ho_hist_ptr*NUM_ENV_CNG]), NUM_ENV_CNG ); - - hTdCngEnc->ho_hist_size = add(hTdCngEnc->ho_hist_size,1); - if (GT_16(hTdCngEnc->ho_hist_size, HO_HIST_SIZE)) - { - hTdCngEnc->ho_hist_size = HO_HIST_SIZE; - move16(); - } - - s_ptr = add(s_ptr,1); - - if( EQ_16(s_ptr, hTdCngEnc->ho_circ_size)) - { - s_ptr = 0; - move16(); - } - } - - IF(hTdCngEnc->burst_ho_cnt > 0) - { - /**allow_cn_step |= ( hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr] > 4 * hTdCngEnc->lp_ener_fx ); */ -#if 1 - /*allow_cn_step |= (hDtxEnc->first_CNG || st->element_mode == EVS_MONO) && (hTdCngEnc->ho_ener_hist[hTdCngEnc->ho_hist_ptr] > lp_ener_thr_scale * hTdCngEnc->lp_ener);*/ - /* (hTdCngEnc->ho_ener_hist[hTdCngEnc->ho_hist_ptr] > lp_ener_thr_scale * hTdCngEnc->lp_ener); */ - L_tmp1 = L_shr(hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr], 2); - IF(NE_16(lp_ener_thr_scale, 8)) - { - L_tmp1 = L_add(L_tmp1, L_shr(hTdCngEnc->lp_ener_fx, 8)); - } - L_tmp1 = L_sub(L_tmp1, hTdCngEnc->lp_ener_fx); -#else - L_tmp1 = L_shr(hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr],2); - L_tmp1 = L_sub(L_tmp1,hTdCngEnc->lp_ener_fx); -#endif - test();test(); - IF((hDtxEnc->first_CNG > 0 || EQ_16(st_fx->element_mode, EVS_MONO)) && L_tmp1>0) - { - *allow_cn_step = s_or(*allow_cn_step,1); - } - } - test(); - IF ( *allow_cn_step == 0 && hTdCngEnc->ho_hist_size > 0 ) - { - /* Use average of energies below last energy */ - ptr = hTdCngEnc->ho_hist_ptr; - move16(); - Copy( &(hTdCngEnc->ho_lsp_hist_fx[ptr*M]), tmp, M ); - m1 = 0; - move16(); - IF( L_and(hTdCngEnc->ho_sid_bw, (Word32) 0x1) == 0 ) - { - Copy32( &hTdCngEnc->ho_env_hist_fx[ptr*NUM_ENV_CNG], tmp_env, NUM_ENV_CNG ); - m1 = 1; - move16(); - } - L_enr = Mult_32_16(hTdCngEnc->ho_ener_hist_fx[ptr],W_DTX_HO_FX[0]) ;/* Q6+15-15->Q6 */ - - weights = W_DTX_HO_FX[0]; /* Q15 */ - - m = 1; - move16(); - FOR( k=1; kho_hist_size; k++ ) - { - ptr = sub(ptr,1); - if( ptr < 0 ) - { - ptr = HO_HIST_SIZE - 1; - move16(); - } - - test(); - IF ( LT_32(Mult_32_16(hTdCngEnc->ho_ener_hist_fx[ptr],ONE_OVER_BUF_H_NRG_FX),hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr])&& - GT_32(hTdCngEnc->ho_ener_hist_fx[ptr],Mult_32_16(hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr], BUF_L_NRG_FX)) ) - { - /*enr += W_DTX_HO[k] * st_fx->ho_ener_hist[ptr]; */ - L_tmp1 = Mult_32_16(hTdCngEnc->ho_ener_hist_fx[ptr],W_DTX_HO_FX[k]) ; /* Q6+15-15->Q6 */ - L_enr = L_add(L_enr,L_tmp1); /* Q6 */ - - /*weights += W_DTX_HO[k]; */ - weights = add( weights, W_DTX_HO_FX[k]); /* Q15 */ - - Copy( &hTdCngEnc->ho_lsp_hist_fx[ptr*M], &tmp[m*M], M ); - IF( L_and(hTdCngEnc->ho_sid_bw, L_shl((Word32)0x1,k)) == 0 ) - { - Copy32( &hTdCngEnc->ho_env_hist_fx[ptr*NUM_ENV_CNG], &tmp_env[m1*NUM_ENV_CNG], NUM_ENV_CNG ); - m1 = add(m1,1); - } - m = add(m,1); - } - } - - /*enr /= weights; */ - exp = norm_s(weights); - tmp1 = div_s(shl(1,sub(14,exp)),weights); /* Q(15+14-exp-15) */ - L_tmp1 = Mult_32_16(L_enr,tmp1); /* Q(14-exp+6-15)->Q(5-exp) */ - L_enr = L_shl(L_tmp1,add(exp,1)); /* Q6 */ - - hTdCngEnc->lp_ener_fx = L_enr; - move32();/* Q6 */ - - set32_fx( max_val, 0, 2 ); - set16_fx( max_idx, 0, 2 ); - - FOR( i=0; iL_frame,L_FRAME)) - { - lsp2lsf_fx( &tmp[i*M], lsf_tmp, M, INT_FS_FX ); - ftmp_fx = 964; - move16();/*QX2.56 */ - tmpv = sub(16384,add(lsf_tmp[M-1],ftmp_fx)); /*QX2.56 */ - L_tmp = L_mult0(tmpv,tmpv); /*QX6.5536 */ - } - ELSE - { - lsp2lsf_fx( &tmp[i*M], lsf_tmp, M, INT_FS_16k ); - ftmp_fx = 1205; - move16();/*QX2.56 */ - tmpv = sub(20480,add(lsf_tmp[M-1],ftmp_fx)); /*QX2.56 */ - L_tmp = L_mult0(tmpv,tmpv); /*QX6.5536 */ - } - - tmpv = sub(lsf_tmp[0],ftmp_fx); /*QX2.56 */ - L_tmp = L_mac0(L_tmp,tmpv,tmpv); /*QX6.5536 */ - FOR ( j=0; jlspCNG_fx[i] = lsp_tmp[i]; - move16(); /*Q15 */ - } - } - ELSE - { - FOR( i=0; ilspCNG_fx[i] = add(mult_r(26214,lsp_tmp[i]),mult_r(6554,lsp_new[i])); - move16(); - } - } - IF( m1 > 0 ) - { - FOR ( i=0; ilp_ener_fx; */ - IF(EQ_16(m1,1)) - { - L_tmp = L_sub(L_tmp,L_add(hTdCngEnc->lp_ener_fx,hTdCngEnc->lp_ener_fx)); - } - ELSE - { - tmp1 = div_s(1,m1); - L_tmp = Mult_32_16(L_tmp,tmp1); - L_tmp = L_sub(L_tmp,L_add(hTdCngEnc->lp_ener_fx,hTdCngEnc->lp_ener_fx)); - } - - env[i] = L_tmp; - move32(); - } - Copy32(env, hTdCngEnc->lp_env_fx, NUM_ENV_CNG); - } - } - ELSE - { - Copy( lsp_new, hDtxEnc->lspCNG_fx, M ); /* use newly analyzed ISFs */ - } - } - IF ( st_fx->Opt_AMR_WB != 0 ) - { - E_LPC_f_isp_a_conversion(hDtxEnc->lspCNG_fx, Aq, M ); - } - ELSE - { - E_LPC_f_lsp_a_conversion(hDtxEnc->lspCNG_fx, Aq, M ); /* Find A(z) (not interpolated) */ - } - - tmp_loop = shr(st_fx->L_frame,6); - FOR( i=1; iL_frame, 0); - Copy(res, res1, st_fx->L_frame); - test(); - IF (EQ_16(st_fx->element_mode, IVAS_CPE_DFT) || EQ_16(st_fx->element_mode, IVAS_CPE_TD)) - { - //PMT("Code to be completed") -#ifdef IVAS_CODE - att = powf(10.0f, hTdCngEnc->CNG_att / 20.0f); - v_multc(res1, att, res1, st->L_frame); -#endif - } - ELSE IF( NE_16(st_fx->bwidth,NB)) - { - test(); - IF( EQ_16(st_fx->bwidth,WB) && hDtxEnc->CNG_mode>=0) - { - ftmp_fx = HO_ATT_FX[hDtxEnc->CNG_mode]; - } - ELSE - { - ftmp_fx = 19661; - move16(); - } - - att = mult(ftmp_fx,5461);/* Q15 */ - L_tmp = L_mult(att,8);/* Q16 */ - tmp1 = extract_l(L_shr(L_tmp,2));/* Q14 */ - tmp1 = add(16384,tmp1); - att = div_s(16374,tmp1); /* Q15 */ - - att = s_max(att, ftmp_fx); - FOR( i = 0; i < st_fx->L_frame; i++ ) - { - /*res1[i] *= att;*/ - res1[i] = mult(res1[i],att); - move16();/* Q_new */ - } - att = shr(att,7);/* Q8 */ - } - - /* calculate the spectrum of residual signal */ - Copy(res1, fft_io, st_fx->L_frame); - - IF ( EQ_16(st_fx->L_frame,L_FRAME16k)) - { - modify_Fs_fx( fft_io, L_FRAME16k, 16000, fft_io, 12800, hTdCngEnc->exc_mem2_fx,0); - } - - fft_rel_fx(fft_io, L_FFT, LOG2_L_FFT); - ptR = &fft_io[1]; - ptI = &fft_io[L_FFT-1]; - FOR ( i=0; icng_res_env_fx[(hTdCngEnc->cng_hist_ptr)*NUM_ENV_CNG]), NUM_ENV_CNG ); - - /* calculate the residual signal energy */ - /*enr = dotp( res, res, L_frame ) / L_frame; */ - maxv = 0; - move16(); - FOR(i = 0; i < st_fx->L_frame; i++) - { - maxv = s_max(maxv, abs_s(res[i])); - } - scale = norm_s(maxv); - pt_res = res; - L_ener = L_deposit_l(1); - IF( EQ_16(st_fx->L_frame, L_FRAME)) - { - FOR (j=0; j<128; j++) - { - tmpv = shl(*pt_res,scale); - L_tmp = L_mult0(tmpv, tmpv); - pt_res++; - tmpv = shl(*pt_res,scale); - L_tmp = L_mac0(L_tmp, tmpv, tmpv); /* 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 */ - } - } - ELSE /* L_FRAME16k */ - { - FOR (j=0; j<160; j++) - { - tmpv = shl(*pt_res,scale); - L_tmp = L_mult0(tmpv, tmpv); - pt_res++; - tmpv = shl(*pt_res,scale); - L_tmp = L_mac0(L_tmp, tmpv, tmpv); /* 2*(Q_new+scale) */ - pt_res++; - L_ener = L_add(L_ener, L_shr(Mult_32_16(L_tmp,26214 /* 256/320, Q15 */), 7)); /* 2*(Q_new+scale)+15+1-16+1, divide by L_frame done here */ - } - } - /* convert log2 of residual signal energy */ - /*enr = (float)log10( enr + 0.1f ) / (float)log10( 2.0f ); */ - hi = norm_l(L_ener); - lo = Log2_norm_lc(L_shl(L_ener, hi)); - hi = sub(29, hi); /* log2 exp in Q2*(Q_new+scale) */ - hi = sub(hi, shl(add(Q_new,scale), 1)); /* Q0 */ - L_tmp = L_Comp(hi, lo); /* Q16 */ - enr = round_fx(L_shl(L_tmp, 8)); /* Q8 (16+8-16) */ - - /* update the circular buffer of old energies */ - hTdCngEnc->cng_ener_hist_fx[hTdCngEnc->cng_hist_ptr] = enr; - move16(); /* Q8 */ - - /*-----------------------------------------------------------------* - * Quantize residual signal energy (only in SID frame) - *-----------------------------------------------------------------*/ - test(); - IF( EQ_32(st_fx->core_brate, SID_2k40)||EQ_32(st_fx->core_brate,SID_1k75)) - { - IF( GE_16(hDtxEnc->cng_cnt,sub(hDtxEnc->cng_hist_size,1))) - { - /* average the envelope except outliers */ - FOR ( i=0; icng_hist_size; j++ ) - { - L_tmp1 = L_add(L_tmp1,hTdCngEnc->cng_res_env_fx[j*NUM_ENV_CNG+i]); - } - L_tmp = L_add(hTdCngEnc->cng_res_env_fx[max_idx1[0]*NUM_ENV_CNG+i],hTdCngEnc->cng_res_env_fx[max_idx1[1]*NUM_ENV_CNG+i]); - L_tmp1 = L_sub(L_tmp1,L_tmp); - - /* env[i] /= (float)(st_fx->cng_hist_size - 2); */ - tmp1 = sub(hDtxEnc->cng_hist_size,2); - IF(GT_16(tmp1,1)) - { - tmp1 = div_s(1,tmp1); - L_tmp1 = Mult_32_16(L_tmp1,tmp1); - } - - env[i] = L_tmp1; - move32(); - } - /* compute average excitation energy */ - L_tmp = L_deposit_l(0); - ptr = hTdCngEnc->cng_hist_ptr; - move16(); - - FOR (k=0; k< hDtxEnc->cng_hist_size; k++) - { - /* enr += W_HIST[k]*cng_ener_hist[ptr] */ - L_tmp = L_mac0(L_tmp, W_HIST_FX[k], hTdCngEnc->cng_ener_hist_fx[ptr]); /* Q24 (8+16) */ - ptr = sub(ptr, 1); - if (ptr < 0) /* check for circular pointer */ - { - ptr = DTX_HIST_SIZE - 1; - move16(); - } - } - /*----------------------------------------------------------- - * here we want to divide L_tmp by the sum - * of all the coefs used W_HIST[0..cng_hist_size-1] - * The table W_HIST_S already contains the inverted sum. - * That is - * W_HIST_S[k] 1 - * ------------- = --------------------------- - * 4096 W_HIST[0] + ... + W_HIST[k] - * - * 1 / Sum(W_HIST[0..k]) is always > 1 since the sum - * of the coefs 0..k is always < 1 but > 0 - * enr is in Q8 since the history buffer constains Q8 energies - *-----------------------------------------------------------*/ - /*L_tmp = Mpy_32_16_1(L_tmp, W_HIST_S_FX[k-1]); */ /* normalize average value */ - L_tmp = Mult_32_16(L_tmp, W_HIST_S_FX[k-1]); /* Q21 (24+12+1-16) */ - L_tmp = L_shl(L_tmp, 3); /* Q24 */ - enr = round_fx(L_tmp); /* Q8 */ - } - /* decrease the energy in case of WB input */ - IF ( EQ_16(st_fx->element_mode, IVAS_SCE) || EQ_16(st_fx->element_mode, IVAS_CPE_DFT)) - { - //PMT("CNG IVAS_SCE and IVAS_CPE_DFT code missing") - //IVAS_CODE - //enr += hTdCngEnc->CNG_att * FAC_LOG2 / 10.0f; - } - ELSE IF( NE_16(st_fx->bwidth, NB)) - { - IF( EQ_16(st_fx->bwidth,WB)) - { - IF(hDtxEnc->CNG_mode >= 0 ) - { - /* Bitrate adapted attenuation */ - att = ENR_ATT_fx[hDtxEnc->CNG_mode]; - move16(); - } - ELSE - { - /* Use least attenuation for higher bitrates */ - att = ENR_ATT_fx[4]; - move16(); - } - } - ELSE - { - att = 384; - move16();/*Q8*/ - } - enr = sub(enr, att ); - } - /* intialize the energy quantization parameters */ - IF( st_fx->Opt_AMR_WB == 0 ) - { - step = STEP_SID_FX; - move16(); - step_inv = ISTEP_SID_FX; - move16(); - maxl = 127; - move16(); - num_bits = 7; - move16(); - } - ELSE - { - step = STEP_AMR_WB_SID_FX; - move16(); - step_inv = ISTEP_AMR_WB_SID_FX; - move16(); - maxl = 63; - move16(); - num_bits = 6; - move16(); - } - - /* calculate the energy quantization index */ - enr_index = add(enr, 512 /* Q8(2.0) */); /* enr + 2.0 */ - enr_index = extract_l(L_shr(L_mult0(enr_index, step), 12+8)); /* Q0 (8+12-(8+12)) */ - - /* limit the energy quantization index */ - enr_index = s_min(enr_index, maxl); - enr_index = s_max(enr_index, 0); - - /* allow only slow energy increase */ - test(); - IF( hTdCngEnc->old_enr_index >= 0 && GT_16(enr_index, add(hTdCngEnc->old_enr_index, MAX_DELTA))) - { - IF( *allow_cn_step != 0 ) - { - tmp1 = mult(27853 /* Q15(0.85) */,sub(enr_index,hTdCngEnc->old_enr_index)); - enr_index = add(hTdCngEnc->old_enr_index,tmp1); - } - ELSE - { - enr_index = add(hTdCngEnc->old_enr_index, MAX_DELTA); - } - } - hTdCngEnc->old_enr_index = enr_index; - move16(); - - push_indice_fx( hBstr, IND_ENERGY, enr_index, num_bits ); - if ( enr_index == 0 ) - { - enr_index = -5; - move16(); - } - /* Find quantized energy */ - /* *Enew = (float)enr_index / step - 2.0 */ - /* *Enew = (float)pow(2.0, *Enew) */ - L_tmp = L_mult(enr_index, step_inv); /* Q16(0+15+1) */ - /* substract by 2 not done to leave Energy in Q2 */ - lo = L_Extract_lc(L_tmp, &hi); - hTdCngEnc->Enew_fx = Pow2(add(hi, 4), lo); /* Q6 */ - IF ( EQ_32(st_fx->core_brate, SID_2k40)) - { - /* enr1 = (float)log10( st->Enew*L_frame + 0.1f ) / (float)log10( 2.0f );*/ - exp = norm_l(hTdCngEnc->Enew_fx); - L_tmp = L_shl(hTdCngEnc->Enew_fx,exp); /*Q(exp+6) */ - L_tmp = Mult_32_16(L_tmp,shl(st_fx->L_frame,5));/* Q(exp+6+5-15=exp-4) */ - -#ifdef BASOP_NOGLOB - L_tmp = L_shr_sat(L_tmp,sub(exp,10)); /* Q6 */ -#else - L_tmp = L_shr(L_tmp,sub(exp,10)); /* Q6 */ -#endif - - exp = norm_l(L_tmp); - fra = Log2_norm_lc(L_shl(L_tmp,exp)); - exp = sub(sub(30,exp),6); - L_tmp = L_Comp(exp,fra); - enr1 = L_shr(L_tmp,10);/* Q6 */ - - FOR ( i=0; iEnew;*/ - L_tmp1 = L_add(env[i], 0); - L_tmp = L_add(hTdCngEnc->Enew_fx,hTdCngEnc->Enew_fx); - L_tmp1 = L_sub(L_tmp1,L_tmp); /*Q6*/ - - IF ( L_tmp1 < 0 ) - { - L_tmp1 = L_deposit_l(6); /* (0.1)Q6 */ - } - /* env[i] = (float)log10( env[i] + 0.1f ) / (float)log10( 2.0f ); */ - exp = norm_l(L_tmp1); - fra = Log2_norm_lc(L_shl(L_tmp1,exp)); - exp = sub(sub(30,exp),6); - L_tmp = L_Comp(exp,fra); - L_tmp1 = L_shr(L_tmp,10); /* Q6 */ - - L_tmp = L_shr(L_deposit_l(att),2);/* Q6 */ - L_tmp1 = L_sub(L_tmp1,L_tmp); - - IF ( L_tmp1 < 0 ) - { - L_tmp1 = L_deposit_l(0); - } - - L_tmp1 = L_sub(enr1,L_tmp1); - - env[i] = L_tmp1; - move32(); - } - - /* codebook search */ - min1 = L_add(1310588928, 0); /* Q17 */ - min1_idx = 0; - move16(); - - FOR ( i=0; i<64; i++ ) - { - d = L_deposit_l(0); - FOR ( j=0; jEnew_fx,21845 /*1/1.5f, Q15*/), hTdCngEnc->lp_ener_fx)) - { - /* update the pointer to circular buffer of old LSP vectors */ - hTdCngEnc->ho_hist_ptr = add(hTdCngEnc->ho_hist_ptr, 1); - if( EQ_16(hTdCngEnc->ho_hist_ptr,HO_HIST_SIZE)) - { - hTdCngEnc->ho_hist_ptr = 0; - move16(); - } - - /* update the circular buffer of old LSP vectors with the new LSP vector */ - Copy( lsp_new, &(hTdCngEnc->ho_lsp_hist_fx[(hTdCngEnc->ho_hist_ptr)*M]), M ); - - /* update the hangover energy buffer */ - hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr] = hTdCngEnc->Enew_fx; - move32(); - IF ( EQ_32(st_fx->core_brate, SID_2k40)) - { - FOR ( i=0; iEnew;*/ - L_tmp = L_sub(enr1,q_env[i]);/* Q6 */ - L_tmp = L_shl(L_tmp, 10);/* 16 */ - temp_lo_fx = L_Extract_lc(L_tmp, &temp_hi_fx); - - exp_pow = sub(14, temp_hi_fx); - L_tmp = Pow2(14, temp_lo_fx); /* Qexp_pow */ - env[i] = L_shl(L_tmp, sub(6, exp_pow)); - move32(); /* Q6 */ - L_tmp = L_add(hTdCngEnc->Enew_fx,hTdCngEnc->Enew_fx); - env[i] = L_add(env[i],L_tmp); - move32();/* Q6 */ - } - Copy32( env, &(hTdCngEnc->ho_env_hist_fx[(hTdCngEnc->ho_hist_ptr)*NUM_ENV_CNG]), NUM_ENV_CNG ); - } - hTdCngEnc->ho_hist_size = add(hTdCngEnc->ho_hist_size,1); - if( GT_16(hTdCngEnc->ho_hist_size,HO_HIST_SIZE)) - { - hTdCngEnc->ho_hist_size = HO_HIST_SIZE; - move16(); - } - } - } - /* dithering bit for AMR-WB IO mode is always set to 0 */ - IF( EQ_32(st_fx->core_brate, SID_1k75)) - { - push_indice_fx( hBstr, IND_DITHERING, 0, 1 ); - } - IF ( EQ_32(st_fx->core_brate, SID_2k40)) - { - IF(EQ_16(st_fx->L_frame, L_FRAME16k)) - { - push_indice_fx( hBstr, IND_ACELP_16KHZ, 1, 1 ); - } - ELSE - { - push_indice_fx( hBstr, IND_ACELP_16KHZ, 0, 1 ); - } - - push_indice_fx( hBstr, IND_CNG_HO, s_min(hTdCngEnc->burst_ho_cnt, 7 ), 3 ); - hTdCngEnc->num_ho = m; - move16(); - push_indice_fx( hBstr, IND_SID_TYPE, 0, 1 ); - - IF ( LT_32(st_fx->input_Fs, 32000) && NE_16(st_fx->element_mode, IVAS_CPE_DFT)) - { - push_indice_fx( hBstr, IND_SID_BW, 0, 1 ); - *sid_bw = 0; - move16(); - } - } - - /*-----------------------------------------------------------------* - * Updates - *-----------------------------------------------------------------*/ - /* update the SID frames counter */ - test(); - IF( EQ_32(st_fx->core_brate, SID_2k40)||EQ_32(st_fx->core_brate,SID_1k75)) - { - hDtxEnc->cng_cnt = 0; - move16(); - hTdCngEnc->cng_hist_ptr = -1; - move16(); - /* update frame length memory */ - hDtxEnc->last_CNG_L_frame = st_fx->L_frame; - move16(); - } - ELSE - { - hDtxEnc->cng_cnt = add(hDtxEnc->cng_cnt,1); - } - - return; -} -/*---------------------------------------------------------------------* - * swb_CNG_enc() - * - * SWB DTX/CNG encoding - *---------------------------------------------------------------------*/ -void swb_CNG_enc_fx( - Encoder_State *st_fx, /* i/o: State structure */ - const Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz (Q0) */ - const Word16 *syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz (st_fx->Q_syn = 0) */ -) -{ - Word16 shb_SID_updt_fx=0; - TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc; - - test(); - IF ( EQ_32(st_fx->core_brate, SID_2k40)||st_fx->core_brate==FRAME_NO_DATA) - { - IF (EQ_16(st_fx->cng_type,LP_CNG)) - { - IF (GE_32(st_fx->input_Fs, L_FRAME32k * FRAMES_PER_SEC)) - { - /* decide if SHB SID encoding or not */ - shb_SID_updt_fx = shb_DTX_fx(st_fx, shb_speech_fx, syn_12k8_16k_fx); - - /* SHB CNG encoding */ - shb_CNG_encod_fx(st_fx, shb_SID_updt_fx); - } - ELSE IF (EQ_16(st_fx->element_mode, IVAS_CPE_DFT) && EQ_32(st_fx->core_brate, SID_2k40)) - { - //PMT("CNG IVAS_CPE_DFT code not implemented") -#ifdef IVAS_CODE - /* LF-boost not used in DFT-stereo, instead the bandwidth is transmitted */ - delete_indice(st->hBstr, IND_CNG_ENV1); - push_indice(st->hBstr, IND_BWIDTH, st->bwidth, 2); - push_indice(st->hBstr, IND_UNUSED, 0, 4); - push_indice(st->hBstr, IND_SID_BW, 1, 1); -#endif - } - } - hTdCngEnc->last_vad = 0; - move16(); - } - ELSE - { - hTdCngEnc->last_vad = 1; - move16(); - } - - return; -} - -/*---------------------------------------------------------------------* - * shb_CNG_encod() - * - * SID parameters encoding for SHB signal - *---------------------------------------------------------------------*/ -static void shb_CNG_encod_fx( - Encoder_State *st_fx, /* i/o: State structure */ - const Word16 update_fx /* i : SID update flag */ -) -{ - Word16 idx_ener_fx; - TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc; - BSTR_ENC_HANDLE hBstr = st_fx->hBstr; -#ifdef IVAS_CODE - Word16 ener_mid_dec_thr; -#endif - - idx_ener_fx = 0; - move16(); - IF ( EQ_16(update_fx, 1)) - { - /* SHB energy quantization */ - IF (EQ_16(st_fx->element_mode, EVS_MONO)) - { - idx_ener_fx = shr(add(mult(hTdCngEnc->mov_shb_cng_ener_fx, 9797), 1510), 8); /* Q0 */ - } - ELSE - { - /*idx_ener = (int16_t)(0.7f * (0.1f * st->hTdCngEnc->mov_shb_cng_ener / (float)log10(2.0f) + 6.0f) + 0.5f);*/ - //PMT("shb_CNG_encod_fx quantization in missing") -#if 0 - idx_ener_fx = shr(add(mult(hTdCngEnc->mov_shb_cng_ener_fx, 9797), 1510), 8); /* Q0 */ -#endif - } - - if ( LT_16(st_fx->bwidth, SWB)) - { - idx_ener_fx = 0; - move16(); - } - - IF ( GT_16(idx_ener_fx, 15)) - { - idx_ener_fx = 15; - move16(); - } - ELSE - { - idx_ener_fx = s_max(idx_ener_fx,0); - } -#ifdef IVAS_CODE - /* prevent toggling of idx_ener by adding small dead-zone interval around decision thresholds */ - if (st->element_mode != EVS_MONO) - { - if (abs(idx_ener - st->hTdCngEnc->last_idx_ener) == 1) - { - ener_mid_dec_thr = 0.5f * ((st->hTdCngEnc->last_idx_ener / 0.7f - 6.0f) / 0.1f) * (float)log10(2.0f); - ener_mid_dec_thr += 0.5f * ((idx_ener / 0.7f - 6.0f) / 0.1f) * (float)log10(2.0f); - - if (fabs(st->hTdCngEnc->mov_shb_cng_ener - ener_mid_dec_thr) / ener_mid_dec_thr < ENER_MID_DEAD_ZONE) - { - idx_ener = st->hTdCngEnc->last_idx_ener; - } - } - } - - st->hTdCngEnc->last_idx_ener = idx_ener; -#endif - push_indice_fx( hBstr, IND_SHB_CNG_GAIN, idx_ener_fx, 4); - push_indice_fx( hBstr, IND_SID_BW, 1, 1 ); -#ifndef IVAS_CODE - hBstr->nb_bits_tot_fx = sub(hBstr->nb_bits_tot_fx, hBstr->ind_list_fx[IND_CNG_ENV1].nb_bits); - hBstr->ind_list_fx[IND_CNG_ENV1].nb_bits = -1; -#else - delete_indice(hBstr, IND_CNG_ENV1); -#endif - move16(); -#ifdef IVAS_CODE - if (st->element_mode == IVAS_CPE_DFT) - { - push_indice(st->hBstr, IND_BWIDTH, st->bwidth, 2); - } - else -#endif - { - push_indice_fx(hBstr, IND_UNUSED, 0, 2); - } - hTdCngEnc->ho_sid_bw = L_shl(L_and(hTdCngEnc->ho_sid_bw, (Word32) 0x3fffffffL ), 1); - hTdCngEnc->ho_sid_bw = L_or(hTdCngEnc->ho_sid_bw, 0x1L); - } - ELSE - { - IF ( EQ_32(st_fx->core_brate, SID_2k40)) - { - hTdCngEnc->ho_sid_bw = L_shl(L_and(hTdCngEnc->ho_sid_bw, (Word32) 0x3fffffffL ), 1); - push_indice_fx( hBstr, IND_SID_BW, 0, 1 ); - } - } - - return; -} - -/*---------------------------------------------------------------------* -* shb_DTX() -* -* Decide if encoding SHB SID or not -*---------------------------------------------------------------------*/ -static Word16 shb_DTX_fx( - Encoder_State *st_fx, /* i/o: State structure */ - const Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz (Q0) */ - const Word16 *syn_12k8_16k /* i : ACELP core synthesis at 12.8kHz or 16kHz (st_fx->Q_syn = 0) */ -) -{ - Word16 i; - Word16 update_fx; - Word16 shb_old_speech_fx[(ACELP_LOOK_12k8 + L_SUBFR + L_FRAME) * 5/4]; - Word16 *shb_new_speech_fx; - Word32 wb_ener_fx; - Word32 shb_ener_fx; - Word16 log_wb_ener_fx; - Word16 log_shb_ener_fx; - Word16 tmp; - Word16 exp; - Word16 fra; - Word16 att; /*Q8*/ - Word16 allow_cn_step_fx=0; - DTX_ENC_HANDLE hDtxEnc = st_fx->hDtxEnc; - TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc; - TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL - Flag Overflow = 0; -#endif - shb_new_speech_fx = shb_old_speech_fx + (ACELP_LOOK_12k8 + L_SUBFR) * 5/4; - Copy(hBWE_TD->old_speech_shb_fx, shb_old_speech_fx, (ACELP_LOOK_12k8 + L_SUBFR) * 5/4 ); - Copy( shb_speech_fx, shb_new_speech_fx, L_FRAME16k ); - Copy( shb_old_speech_fx + L_FRAME16k, hBWE_TD->old_speech_shb_fx, (ACELP_LOOK_12k8 + L_SUBFR) * 5/4 ); - - shb_ener_fx = L_deposit_l(0); - FOR ( i=0; iL_frame; i++ ) - { -#ifdef BASOP_NOGLOB - wb_ener_fx = L_mac_o(wb_ener_fx, syn_12k8_16k[i], syn_12k8_16k[i], &Overflow); -#else - wb_ener_fx = L_mac(wb_ener_fx, syn_12k8_16k[i], syn_12k8_16k[i]); -#endif - } - - wb_ener_fx = L_add(Mpy_32_16_1(wb_ener_fx, 128), 1); /* 128 in Q15, wb_ener_fx in Q1 */ - - exp = norm_l(wb_ener_fx); - fra = Log2_norm_lc(L_shl(wb_ener_fx, exp)); - exp = sub(30-1, exp); - wb_ener_fx = Mpy_32_16(exp, fra, LG10); -#ifdef BASOP_NOGLOB - log_wb_ener_fx = round_fx_o(L_shl_o(wb_ener_fx, 10, &Overflow), &Overflow); /* log_wb_ener_fx in Q8 */ -#else - log_wb_ener_fx = round_fx(L_shl(wb_ener_fx, 10)); /* log_wb_ener_fx in Q8 */ -#endif - exp = norm_l(shb_ener_fx); - fra = Log2_norm_lc(L_shl(shb_ener_fx, exp)); - exp = sub(30-1, exp); - shb_ener_fx = Mpy_32_16(exp, fra, LG10); - - test(); - IF (EQ_16(st_fx->element_mode, IVAS_SCE) || EQ_16(st_fx->element_mode, IVAS_CPE_DFT)) - { - att = 0; - move16(); - //PMT("apply_scale is not implemented") -#if 0 - apply_scale(&att, st->hFdCngEnc->hFdCngCom->CngBandwidth, st->hFdCngEnc->hFdCngCom->CngBitrate, scaleTableStereo, SIZE_SCALE_TABLE_STEREO); -#endif - } - else - { - att = 1664; /*6.5 in Q8*/ - move16(); - } - -#ifdef BASOP_NOGLOB - log_shb_ener_fx = sub_o(round_fx_o(L_shl_o(shb_ener_fx, 10, &Overflow), &Overflow), att, &Overflow); /* log_shb_ener_fx in Q8 */ -#else - log_shb_ener_fx = sub(round_fx(L_shl(shb_ener_fx, 10)), att); /* log_shb_ener_fx in Q8 */ -#endif - IF (hDtxEnc->first_CNG == 0 ) - { - hTdCngEnc->mov_wb_cng_ener_fx = log_wb_ener_fx; - move16(); - hTdCngEnc->mov_shb_cng_ener_fx = log_shb_ener_fx; - move16(); - hTdCngEnc->last_wb_cng_ener_fx = log_wb_ener_fx; - move16(); - hTdCngEnc->last_shb_cng_ener_fx = log_shb_ener_fx; - move16(); - } - - if ( GT_16(abs_s(sub(log_wb_ener_fx, hTdCngEnc->mov_wb_cng_ener_fx)), 3072)) - { - allow_cn_step_fx = 1; - move16(); - } -#ifdef IVAS_CODE - /* Also allow step if shb energy has dropped 12 dB */ - if ((st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD) && ((hTdCngEnc->mov_shb_cng_ener - log_shb_ener) > 12.0f)) - { - allow_cn_step = 1; - } -#endif - IF ( EQ_16(allow_cn_step_fx, 1)) - { - hTdCngEnc->mov_wb_cng_ener_fx = log_wb_ener_fx; - move16(); - hTdCngEnc->mov_shb_cng_ener_fx = log_shb_ener_fx; - move16(); - } - ELSE - { - tmp = sub(log_wb_ener_fx, hTdCngEnc->mov_wb_cng_ener_fx); /* Q8 */ - tmp = mult(tmp, 29491); /* Q8 */ - hTdCngEnc->mov_wb_cng_ener_fx = add(hTdCngEnc->mov_wb_cng_ener_fx, tmp); /* Q8 */ - - tmp = sub(log_shb_ener_fx, hTdCngEnc->mov_shb_cng_ener_fx); - tmp = mult(tmp, 8192); /* Q8 */ - hTdCngEnc->mov_shb_cng_ener_fx = add(hTdCngEnc->mov_shb_cng_ener_fx, tmp); /* Q8 */ - } - hTdCngEnc->shb_NO_DATA_cnt = add(hTdCngEnc->shb_NO_DATA_cnt, 1); - - update_fx = 0; - move16(); - IF ( EQ_32(st_fx->core_brate, SID_2k40)) - { - test(); - test(); - IF (hDtxEnc->first_CNG == 0 || EQ_16(hTdCngEnc->last_vad, 1)||GE_16(hTdCngEnc->shb_NO_DATA_cnt,100)) - { - update_fx = 1; - move16(); - } - ELSE - { - IF ( hTdCngEnc->shb_cng_ini_cnt > 0 ) - { - update_fx = 1; - move16(); - hTdCngEnc->shb_cng_ini_cnt = sub(hTdCngEnc->shb_cng_ini_cnt, 1); - } - ELSE - { - IF ( GT_16(abs_s(sub(sub(hTdCngEnc->mov_wb_cng_ener_fx, hTdCngEnc->mov_shb_cng_ener_fx), sub(hTdCngEnc->last_wb_cng_ener_fx, hTdCngEnc->last_shb_cng_ener_fx))), 768)) - { - update_fx = 1; - move16(); - } - ELSE - { - test(); - IF ( GE_16(st_fx->bwidth, SWB)&<_16(hTdCngEnc->last_SID_bwidth,SWB)) - { - update_fx = 1; - move16(); - } - ELSE - { - test(); - IF ( LT_16(st_fx->bwidth, SWB)&&GE_16(hTdCngEnc->last_SID_bwidth,SWB)) - { - update_fx = 1; - move16(); - } - } - } - } - } - - hTdCngEnc->last_SID_bwidth = st_fx->bwidth; - move16(); - } - /* LF-boost not yet implemented in decoder which means that the specific wb_sid information is not used */ - test();test(); - if ((EQ_16(st_fx->element_mode, IVAS_CPE_DFT) || EQ_16(st_fx->element_mode, IVAS_CPE_TD)) && EQ_32(st_fx->core_brate, SID_2k40)) - { - update_fx = 1; - move16(); - } - - IF ( EQ_16(update_fx, 1)) - { - hTdCngEnc->last_wb_cng_ener_fx = hTdCngEnc->mov_wb_cng_ener_fx; - move16(); - hTdCngEnc->last_shb_cng_ener_fx = hTdCngEnc->mov_shb_cng_ener_fx; - move16(); - hTdCngEnc->shb_NO_DATA_cnt = 0; - move16(); - } - - - return (update_fx); -} - -/*---------------------------------------------------------------------* - * calculate_hangover_attenuation_gain_fx() - * - * - *---------------------------------------------------------------------*/ - -void calculate_hangover_attenuation_gain_fx( - Encoder_State* st, /* i : encoder state structure */ - Word16* att, /* o : attenuation factor */ - const Word16 vad_hover_flag /* i : VAD hangover flag */ -) -{ - Word16 offset; - TD_CNG_ENC_HANDLE hTdCngEnc = st->hTdCngEnc; - - *att = 32767; - - move16(); - /* smoothing in case of CNG */ - IF (hTdCngEnc != NULL) - { - test();test();test(); - IF( hTdCngEnc->burst_ho_cnt > 0 && (vad_hover_flag != 0) && (NE_16(st->bwidth, NB) || GT_16(st->element_mode, EVS_MONO))) /* corresponds to line 504 in FLT acelp_core_enc.c */ - { -#ifdef IVAS_CODE - if (st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD) - { - *att = powf(10.0f, (st->hTdCngEnc->CNG_att / 160.0f) * st->hTdCngEnc->burst_ho_cnt); - } - else -#endif - { - offset = 5; - test(); - if (EQ_16(st->bwidth, WB) && st->hDtxEnc->CNG_mode >= 0) - { - offset = st->hDtxEnc->CNG_mode; - move16(); - } - assert(hTdCngEnc->burst_ho_cnt > 0); - *att = CNG_burst_att_fx[offset][sub(hTdCngEnc->burst_ho_cnt, 1)]; /*Q15*/ - move16(); - } - } - - - } - return; -} +/*==================================================================================== + EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0 + ====================================================================================*/ +#include +#include "options.h" /* Compilation switches */ +#include "cnst.h" /* Common constants */ +#include "rom_enc.h" /* Encoder static table prototypes */ +#include "rom_com.h" /* Static table prototypes */ +//#include "prot_fx.h" /* Function prototypes */ +#include "prot_fx1.h" /* Function prototypes */ +#include "prot_fx2.h" /* Function prototypes */ +#include "prot_fx_enc.h" /* Function prototypes */ +//#include "basop_mpy.h" + +#include +/*---------------------------------------------------------------------* +* Local constants +*---------------------------------------------------------------------*/ + +#define MAX_DELTA 1 +#define MIN_CNT 50 /* Minimum frame number before SID interval adaptation */ +#define INT_H 50 +#define INT_L 8 + +/*---------------------------------------------------------------------* + * Local function prototypes + *---------------------------------------------------------------------*/ +static void shb_CNG_encod_fx(Encoder_State *st_fx, const Word16 update_fx ); +static Word16 shb_DTX_fx(Encoder_State *st_fx, const Word16 *shb_speech_fx, const Word16 *syn_12k8_16k ); +/*---------------------------------------------------------------------* +* CNG_enc() +* +* Confort noise generation for the coder +*---------------------------------------------------------------------*/ +void CNG_enc_fx( + Encoder_State *st_fx,/* i/o: State structure */ + Word16 Aq[], /* o : LP coefficients Q12 */ + const Word16 *speech, /* i : pointer to current frame input speech buffer Q_new */ + Word32 L_enr, /* i : residual energy from Levinson-Durbin Q6 */ + const Word16* lsp_mid, /* i : mid frame LSPs Q15 */ + Word16 *lsp_new, /* i/o: current frame ISPs Q15 */ + Word16 *lsf_new, /* i/o: current frame ISFs Qlog2(2.56) */ + Word16 *allow_cn_step, /* o : allow CN step Q0 */ + Word16 Q_new, /* i : Q value of speech */ + Word32 *q_env, + Word16 *sid_bw +) +{ + Word16 enr_index; + Word16 i, j, ptr; + Word16 m1; + Word16 res[L_FRAME16k]; + Word16 step_inv=0; + Word16 hi, lo; + Word16 maxl=0; + Word16 num_bits=0; + Word16 step=0; + Word16 *pt_res; + const Word16 *pt_sp; + Word16 enr; + Word32 L_tmp, L_ener; + Word16 k, tmp1; + Word16 weights; + Word16 sp_enr; + Word32 L_tmp1; + Word16 exp; + Word16 m = 0; + Word16 tmp[HO_HIST_SIZE*M]; + Word16 ll, s_ptr; + Word16 tmpv, maxv, scale, att = 1; + Word16 lsf_tmp[M]; + Word32 C[M]; + Word32 max_val[2]; + Word16 max_idx[2]; + Word16 ftmp_fx; + Word16 lsp_tmp[M]; + Word16 dev; + Word16 max_dev; + Word16 dist; + Word16 max_idx1[2]= {0,0}; + Word16 fft_io[L_FRAME16k]; + Word16 *ptR,*ptI; + Word32 enr1=0; + Word32 env[NUM_ENV_CNG]; + Word32 min1; + Word16 min1_idx; + Word32 d; + Word16 res1[L_FRAME16k]; + Word32 tmp_env[HO_HIST_SIZE*NUM_ENV_CNG]; + Word16 fra; + Word16 temp_lo_fx, temp_hi_fx; + Word16 exp_pow; + Word16 force_cn_step=0; + Word16 tmp_loop; + Word16 st_lp_sp_enr; + DTX_ENC_HANDLE hDtxEnc = st_fx->hDtxEnc; + TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc; + BSTR_ENC_HANDLE hBstr = st_fx->hBstr; + st_lp_sp_enr = hTdCngEnc->lp_sp_enr_fx; + Word16 lp_ener_thr_scale; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + /* Temp variables for floating point functions */ + + lp_ener_thr_scale = 8; /* 4.0f*/ /*IVAS_CODE Q2 */ + move16(); + if (NE_16(st_fx->element_mode, EVS_MONO)) + { + lp_ener_thr_scale = 7; /* 3.5f;*/ + move16(); + } + /*sp_enr = (float) log10( sum2_f( speech, L_frame )/L_frame + 0.1f )/ (float)log10(2.0f);*//*9.1 */ + pt_sp = speech; + L_ener = L_deposit_l(1); + /* L_ener = L_add(L_shr(sum2_f_fx( speech, L_frame ), 8) , L_ener);*/ + IF( EQ_16(st_fx->L_frame, L_FRAME)) + { + FOR (j=0; j<128; j++) + { + L_tmp = L_mult0(*pt_sp, *pt_sp); + pt_sp++; + L_tmp = L_mac0(L_tmp, *pt_sp, *pt_sp); + pt_sp++; + L_ener = L_add(L_ener, L_shr(L_tmp, 7)); /* 2*Q_new + 1, divide by L_frame done here */ + } + } + ELSE /* L_FRAME16k */ + { + FOR (i=0; i<2; i++) + { + FOR (j=0; j<80; j++) + { + L_tmp = L_mult0(*pt_sp, *pt_sp); + pt_sp++; + L_tmp = L_mac0(L_tmp, *pt_sp, *pt_sp); + pt_sp++; + L_ener = L_add(L_ener, L_shr(Mult_32_16(L_tmp,26214 /* 256/320, Q15 */), 7)); /* 2*Q_new + 1, divide by L_frame done here */ + } + } + } + + hi = norm_l(L_ener); + lo = Log2_norm_lc(L_shl(L_ener, hi)); + hi = sub(29, hi); /* log2 exp in Q2*Q_new */ + hi = sub(hi, shl(Q_new, 1)); /* Q0 */ + L_tmp = L_Comp(hi, lo); /* Q16 */ + sp_enr = round_fx(L_shl(L_tmp, 8)); /* Q8 (16+8-16) */ + + if (sp_enr < 0) + { + sp_enr = 0; + move16(); + } + test(); + IF (hDtxEnc->first_CNG == 0 || hTdCngEnc->old_enr_index < 0 ) + { + hTdCngEnc->lp_sp_enr_fx = sp_enr; + move16(); /* Q8 */ + } + ELSE + { + test(); + test(); + test(); + test(); + IF( GT_32(st_fx->last_core_brate, SID_2k40) && ( EQ_16( st_fx->last_core, HQ_CORE ) || st_fx->hTdCngEnc->burst_ho_cnt > 0 ) && LT_16(hTdCngEnc->lp_sp_enr_fx, 1536) && + GT_16(sub(sp_enr, hTdCngEnc->lp_sp_enr_fx), 1024) && GT_16(sp_enr, 1536) ) + { + hTdCngEnc->lp_sp_enr_fx = sp_enr; + move16(); + force_cn_step = 1; + move16(); + } + ELSE + { + hTdCngEnc->lp_sp_enr_fx = round_fx(L_mac(L_mult(29491 /* 0.9, Q15 */,hTdCngEnc->lp_sp_enr_fx), 3277 /* 0.1, Q15 */,sp_enr)); /* Q8 (8+15+1-16) */ + } + } + /* update the pointer to circular buffer of old LSP vectors */ + hTdCngEnc->cng_hist_ptr = add(hTdCngEnc->cng_hist_ptr,1); + if(EQ_16(hTdCngEnc->cng_hist_ptr, DTX_HIST_SIZE)) + { + hTdCngEnc->cng_hist_ptr = 0; + move16(); + } + + /* update the circular buffer of old LSP vectors with the new LSP vector */ + Copy( lsp_new, &(hTdCngEnc->cng_lsp_hist_fx[(hTdCngEnc->cng_hist_ptr)*M]), M ); + + /*-----------------------------------------------------------------* + * Find CNG spectral envelope + * Find LSP median + *-----------------------------------------------------------------*/ + test(); + test(); + IF( (EQ_32(st_fx->core_brate, SID_2k40) || EQ_32(st_fx->core_brate,SID_1k75)) && GE_16(hDtxEnc->cng_cnt,sub(hDtxEnc->cng_hist_size,1))) + { + set32_fx( max_val, 0, 2 ); + set16_fx( max_idx, 0, 2 ); + + FOR( i=0; i< hDtxEnc->cng_hist_size; i++ ) + { + IF ( EQ_16(st_fx->L_frame,L_FRAME)) + { + lsp2lsf_fx( &hTdCngEnc->cng_lsp_hist_fx[i*M], lsf_tmp, M, INT_FS_FX ); + ftmp_fx = 964; + move16();/*QX2.56 */ + tmpv = sub(16384,add(lsf_tmp[M-1],ftmp_fx)); /*QX2.56 */ + L_tmp = L_mult0(tmpv,tmpv); /*QX6.5536 */ + } + ELSE + { + lsp2lsf_fx( &hTdCngEnc->cng_lsp_hist_fx[i*M], lsf_tmp, M, INT_FS_16k ); + ftmp_fx = 1205; + move16();/*QX2.56 */ + tmpv = sub(20480,add(lsf_tmp[M-1],ftmp_fx)); /*QX2.56 */ + L_tmp = L_mult0(tmpv,tmpv); /*QX6.5536 */ + } + + tmpv = sub(lsf_tmp[0],ftmp_fx); /*QX2.56 */ + L_tmp = L_mac0(L_tmp,tmpv,tmpv); /*QX6.5536 */ + FOR ( j=0; jcng_hist_size; j++ ) + { + L_tmp = L_add(L_tmp,L_deposit_l(hTdCngEnc->cng_lsp_hist_fx[j*M+i])); /*Q15 */ + } + + L_tmp = L_sub(L_tmp,L_add(L_deposit_l(hTdCngEnc->cng_lsp_hist_fx[max_idx[0]*M+i]),L_deposit_l(hTdCngEnc->cng_lsp_hist_fx[max_idx[1]*M+i]))); /*Q15 */ + tmpv= div_s(1,sub(hDtxEnc->cng_hist_size,2)); /*Q15 */ + L_tmp = Mpy_32_16_1(L_tmp,tmpv); /*Q15 */ + lsp_new[i] = extract_l(L_tmp); /*Q15 */ + } + max_idx1[0] = max_idx[0]; + move16(); + max_idx1[1] = max_idx[1]; + move16(); + } + + /*-----------------------------------------------------------------* + * Quantize CNG spectral envelope (only in SID frame) + * Quantize the LSF vector + *-----------------------------------------------------------------*/ + *allow_cn_step = 0; + move16(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( ((hDtxEnc->cng_cnt == 0) && + GT_16(hTdCngEnc->lp_sp_enr_fx, 1536) && + (LT_16(add(st_lp_sp_enr, 1024 /* 4.0, Q8 */), sp_enr)) && + (hDtxEnc->first_CNG != 0) && + (hTdCngEnc->old_enr_index >= 0) && + (GT_32(st_fx->last_core_brate, SID_2k40))) || + EQ_16(force_cn_step, 1)) + { + *allow_cn_step = 1; + move16(); + } + + /* Initialize the CNG spectral envelope in case of the very first CNG frame */ + IF(hDtxEnc->first_CNG == 0) + { + Copy(st_fx->lsp_old_fx, hDtxEnc->lspCNG_fx, M); + + /* Average the CNG spectral envelope in case of the very first CNG frame */ + IF (NE_16(st_fx->element_mode, EVS_MONO)) + { + FOR (i = 0; i < M; i++) + { + /*lsp_new[i] = 0.5f * (lsp_mid[i] + lsp_new[i]);*/ + lsp_new[i] = mac_r(L_mult(lsp_mid[i], 16384), lsp_new[i], 16384); + move16(); + } + } + } + + + test(); + IF( EQ_32(st_fx->core_brate, SID_2k40) || EQ_32(st_fx->core_brate,SID_1k75)) + { + /* LSF quantization */ + IF ( st_fx->Opt_AMR_WB != 0 ) + { + isf_enc_amr_wb_fx( st_fx, lsf_new, lsp_new, 0); + } + ELSE + { +#ifdef LSF_RE_USE_SECONDARY_CHANNEL + lsf_enc_fx(st_fx, lsf_new, lsp_new, NULL, NULL, 100, 0, 0, NULL, Q_new); +#else + lsf_enc_fx( st_fx, lsf_new, lsp_new, NULL, NULL,100, 0, 0, Q_new ); +#endif + } + /* Reset CNG history if CNG frame length is changed */ + test(); + test(); + if ( EQ_16(st_fx->bwidth,WB) && hDtxEnc->first_CNG!=0 && NE_16(st_fx->L_frame, hDtxEnc->last_CNG_L_frame)) + { + hTdCngEnc->ho_hist_size = 0; + move16(); + } + } + ELSE + { + /* Use old LSP vector */ + Copy( st_fx->lsp_old_fx, lsp_new, M ); + Copy( st_fx->lsf_old_fx, lsf_new, M ); + } + + /*---------------------------------------------------------------------* + * CNG spectral envelope update + * Find A(z) coefficients + *---------------------------------------------------------------------*/ + + IF( LE_32(st_fx->last_core_brate, SID_2k40)) + { + /* Reset hangover counter if not first SID period */ + if( GT_32(st_fx->core_brate,FRAME_NO_DATA)) + { + hTdCngEnc->num_ho = 0; + move16(); + } + /* Update LSPs if last SID energy not outlier or insufficient number of hangover frames */ + test(); + IF( LT_16(hTdCngEnc->num_ho,3) || LT_32(Mult_32_16(hTdCngEnc->Enew_fx,21845 /*1/1.5f, Q15*/), hTdCngEnc->lp_ener_fx)) + { + FOR( i=0; ilspCNG_fx[i] = mac_r(L_mult(CNG_ISF_FACT_FX, hDtxEnc->lspCNG_fx[i]),32768-CNG_ISF_FACT_FX,lsp_new[i]); + move16(); /* Q15 (15+15+1-16) */ + } + } + } + ELSE + { + /* Update CNG_mode if allowed */ + test(); + test(); + test(); + IF( EQ_16(st_fx->element_mode, EVS_MONO) && (( st_fx->Opt_AMR_WB || EQ_16(st_fx->bwidth,WB)) + && ( !hDtxEnc->first_CNG || GE_16(hTdCngEnc->act_cnt2,MIN_ACT_CNG_UPD) ) ) ) + { + IF (GT_32(hDtxEnc->last_active_brate, ACELP_16k40)) + { + hDtxEnc->CNG_mode = -1; + move16(); + } + ELSE + { + hDtxEnc->CNG_mode = get_cng_mode(hDtxEnc->last_active_brate); + } + } + + /* If first sid after active burst update LSF history from circ buffer */ + hTdCngEnc->burst_ho_cnt = s_min(hTdCngEnc->burst_ho_cnt, hTdCngEnc->ho_circ_size); + hTdCngEnc->act_cnt = 0; + move16(); + s_ptr = add(sub(hTdCngEnc->ho_circ_ptr, hTdCngEnc->burst_ho_cnt),1); + + if( s_ptr < 0 ) + { + s_ptr = add(s_ptr, hTdCngEnc->ho_circ_size); + } + + FOR( ll = hTdCngEnc->burst_ho_cnt; ll > 0; ll-- ) + { + hTdCngEnc->ho_hist_ptr = add(hTdCngEnc->ho_hist_ptr,1); + if( EQ_16(hTdCngEnc->ho_hist_ptr, HO_HIST_SIZE)) + { + hTdCngEnc->ho_hist_ptr = 0; + move16(); + } + + /* Conversion between 12.8k and 16k LSPs */ + test(); + test(); + IF( EQ_16(st_fx->L_frame,L_FRAME )&&EQ_16(hTdCngEnc->ho_16k_lsp[s_ptr],1)) + { + /* Conversion from 16k LPSs to 12k8 */ + lsp_convert_poly_fx( &(hTdCngEnc->ho_lsp_circ_fx[s_ptr*M]), st_fx->L_frame, 0 ); + } + ELSE IF ( EQ_16(st_fx->L_frame,L_FRAME16k)&& hTdCngEnc->ho_16k_lsp[s_ptr]==0) + { + /* 16k LSPs already converted and stored, just copy to the other buffer */ + Copy(&(hTdCngEnc->ho_lsp_circ2_fx[s_ptr*M]), &(hTdCngEnc->ho_lsp_circ_fx[s_ptr*M]), M ); + } + /* update the circular buffers */ + Copy(&(hTdCngEnc->ho_lsp_circ_fx[s_ptr*M]), &(hTdCngEnc->ho_lsp_hist_fx[hTdCngEnc->ho_hist_ptr*M]), M ); + Copy32(&(hTdCngEnc->ho_ener_circ_fx[s_ptr]), &(hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr]), 1 ); + hTdCngEnc->ho_sid_bw = L_shl(L_and(hTdCngEnc->ho_sid_bw, (Word32) 0x3fffffffL ), 1); + Copy32(&(hTdCngEnc->ho_env_circ_fx[s_ptr*NUM_ENV_CNG]), &(hTdCngEnc->ho_env_hist_fx[hTdCngEnc->ho_hist_ptr*NUM_ENV_CNG]), NUM_ENV_CNG ); + + hTdCngEnc->ho_hist_size = add(hTdCngEnc->ho_hist_size,1); + if (GT_16(hTdCngEnc->ho_hist_size, HO_HIST_SIZE)) + { + hTdCngEnc->ho_hist_size = HO_HIST_SIZE; + move16(); + } + + s_ptr = add(s_ptr,1); + + if( EQ_16(s_ptr, hTdCngEnc->ho_circ_size)) + { + s_ptr = 0; + move16(); + } + } + + IF(hTdCngEnc->burst_ho_cnt > 0) + { + /**allow_cn_step |= ( hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr] > 4 * hTdCngEnc->lp_ener_fx ); */ +#if 1 + /*allow_cn_step |= (hDtxEnc->first_CNG || st->element_mode == EVS_MONO) && (hTdCngEnc->ho_ener_hist[hTdCngEnc->ho_hist_ptr] > lp_ener_thr_scale * hTdCngEnc->lp_ener);*/ + /* (hTdCngEnc->ho_ener_hist[hTdCngEnc->ho_hist_ptr] > lp_ener_thr_scale * hTdCngEnc->lp_ener); */ + L_tmp1 = L_shr(hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr], 2); + IF(NE_16(lp_ener_thr_scale, 8)) + { + L_tmp1 = L_add(L_tmp1, L_shr(hTdCngEnc->lp_ener_fx, 8)); + } + L_tmp1 = L_sub(L_tmp1, hTdCngEnc->lp_ener_fx); +#else + L_tmp1 = L_shr(hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr],2); + L_tmp1 = L_sub(L_tmp1,hTdCngEnc->lp_ener_fx); +#endif + test();test(); + IF((hDtxEnc->first_CNG > 0 || EQ_16(st_fx->element_mode, EVS_MONO)) && L_tmp1>0) + { + *allow_cn_step = s_or(*allow_cn_step,1); + } + } + test(); + IF ( *allow_cn_step == 0 && hTdCngEnc->ho_hist_size > 0 ) + { + /* Use average of energies below last energy */ + ptr = hTdCngEnc->ho_hist_ptr; + move16(); + Copy( &(hTdCngEnc->ho_lsp_hist_fx[ptr*M]), tmp, M ); + m1 = 0; + move16(); + IF( L_and(hTdCngEnc->ho_sid_bw, (Word32) 0x1) == 0 ) + { + Copy32( &hTdCngEnc->ho_env_hist_fx[ptr*NUM_ENV_CNG], tmp_env, NUM_ENV_CNG ); + m1 = 1; + move16(); + } + L_enr = Mult_32_16(hTdCngEnc->ho_ener_hist_fx[ptr],W_DTX_HO_FX[0]) ;/* Q6+15-15->Q6 */ + + weights = W_DTX_HO_FX[0]; /* Q15 */ + + m = 1; + move16(); + FOR( k=1; kho_hist_size; k++ ) + { + ptr = sub(ptr,1); + if( ptr < 0 ) + { + ptr = HO_HIST_SIZE - 1; + move16(); + } + + test(); + IF ( LT_32(Mult_32_16(hTdCngEnc->ho_ener_hist_fx[ptr],ONE_OVER_BUF_H_NRG_FX),hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr])&& + GT_32(hTdCngEnc->ho_ener_hist_fx[ptr],Mult_32_16(hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr], BUF_L_NRG_FX)) ) + { + /*enr += W_DTX_HO[k] * st_fx->ho_ener_hist[ptr]; */ + L_tmp1 = Mult_32_16(hTdCngEnc->ho_ener_hist_fx[ptr],W_DTX_HO_FX[k]) ; /* Q6+15-15->Q6 */ + L_enr = L_add(L_enr,L_tmp1); /* Q6 */ + + /*weights += W_DTX_HO[k]; */ + weights = add( weights, W_DTX_HO_FX[k]); /* Q15 */ + + Copy( &hTdCngEnc->ho_lsp_hist_fx[ptr*M], &tmp[m*M], M ); + IF( L_and(hTdCngEnc->ho_sid_bw, L_shl((Word32)0x1,k)) == 0 ) + { + Copy32( &hTdCngEnc->ho_env_hist_fx[ptr*NUM_ENV_CNG], &tmp_env[m1*NUM_ENV_CNG], NUM_ENV_CNG ); + m1 = add(m1,1); + } + m = add(m,1); + } + } + + /*enr /= weights; */ + exp = norm_s(weights); + tmp1 = div_s(shl(1,sub(14,exp)),weights); /* Q(15+14-exp-15) */ + L_tmp1 = Mult_32_16(L_enr,tmp1); /* Q(14-exp+6-15)->Q(5-exp) */ + L_enr = L_shl(L_tmp1,add(exp,1)); /* Q6 */ + + hTdCngEnc->lp_ener_fx = L_enr; + move32();/* Q6 */ + + set32_fx( max_val, 0, 2 ); + set16_fx( max_idx, 0, 2 ); + + FOR( i=0; iL_frame,L_FRAME)) + { + lsp2lsf_fx( &tmp[i*M], lsf_tmp, M, INT_FS_FX ); + ftmp_fx = 964; + move16();/*QX2.56 */ + tmpv = sub(16384,add(lsf_tmp[M-1],ftmp_fx)); /*QX2.56 */ + L_tmp = L_mult0(tmpv,tmpv); /*QX6.5536 */ + } + ELSE + { + lsp2lsf_fx( &tmp[i*M], lsf_tmp, M, INT_FS_16k ); + ftmp_fx = 1205; + move16();/*QX2.56 */ + tmpv = sub(20480,add(lsf_tmp[M-1],ftmp_fx)); /*QX2.56 */ + L_tmp = L_mult0(tmpv,tmpv); /*QX6.5536 */ + } + + tmpv = sub(lsf_tmp[0],ftmp_fx); /*QX2.56 */ + L_tmp = L_mac0(L_tmp,tmpv,tmpv); /*QX6.5536 */ + FOR ( j=0; jlspCNG_fx[i] = lsp_tmp[i]; + move16(); /*Q15 */ + } + } + ELSE + { + FOR( i=0; ilspCNG_fx[i] = add(mult_r(26214,lsp_tmp[i]),mult_r(6554,lsp_new[i])); + move16(); + } + } + IF( m1 > 0 ) + { + FOR ( i=0; ilp_ener_fx; */ + IF(EQ_16(m1,1)) + { +#ifdef BASOP_NOGLOB + L_tmp = L_sub_sat( L_tmp, L_add_sat( hTdCngEnc->lp_ener_fx, hTdCngEnc->lp_ener_fx ) ); +#else + L_tmp = L_sub(L_tmp,L_add(hTdCngEnc->lp_ener_fx,hTdCngEnc->lp_ener_fx)); +#endif + } + ELSE + { + tmp1 = div_s(1,m1); + L_tmp = Mult_32_16(L_tmp,tmp1); +#ifdef BASOP_NOGLOB + L_tmp = L_sub_sat( L_tmp, L_add_sat( hTdCngEnc->lp_ener_fx, hTdCngEnc->lp_ener_fx ) ); +#else + L_tmp = L_sub(L_tmp,L_add(hTdCngEnc->lp_ener_fx,hTdCngEnc->lp_ener_fx)); +#endif + } + + env[i] = L_tmp; + move32(); + } + Copy32(env, hTdCngEnc->lp_env_fx, NUM_ENV_CNG); + } + } + ELSE + { + Copy( lsp_new, hDtxEnc->lspCNG_fx, M ); /* use newly analyzed ISFs */ + } + } + IF ( st_fx->Opt_AMR_WB != 0 ) + { + E_LPC_f_isp_a_conversion(hDtxEnc->lspCNG_fx, Aq, M ); + } + ELSE + { + E_LPC_f_lsp_a_conversion(hDtxEnc->lspCNG_fx, Aq, M ); /* Find A(z) (not interpolated) */ + } + + tmp_loop = shr(st_fx->L_frame,6); + FOR( i=1; iL_frame, 0); + Copy(res, res1, st_fx->L_frame); + test(); + IF (EQ_16(st_fx->element_mode, IVAS_CPE_DFT) || EQ_16(st_fx->element_mode, IVAS_CPE_TD)) + { + //PMT("Code to be completed") +#ifdef IVAS_CODE + att = powf(10.0f, hTdCngEnc->CNG_att / 20.0f); + v_multc(res1, att, res1, st->L_frame); +#endif + } + ELSE IF( NE_16(st_fx->bwidth,NB)) + { + test(); + IF( EQ_16(st_fx->bwidth,WB) && hDtxEnc->CNG_mode>=0) + { + ftmp_fx = HO_ATT_FX[hDtxEnc->CNG_mode]; + } + ELSE + { + ftmp_fx = 19661; + move16(); + } + + att = mult(ftmp_fx,5461);/* Q15 */ + L_tmp = L_mult(att,8);/* Q16 */ + tmp1 = extract_l(L_shr(L_tmp,2));/* Q14 */ + tmp1 = add(16384,tmp1); + att = div_s(16374,tmp1); /* Q15 */ + + att = s_max(att, ftmp_fx); + FOR( i = 0; i < st_fx->L_frame; i++ ) + { + /*res1[i] *= att;*/ + res1[i] = mult(res1[i],att); + move16();/* Q_new */ + } + att = shr(att,7);/* Q8 */ + } + + /* calculate the spectrum of residual signal */ + Copy(res1, fft_io, st_fx->L_frame); + + IF ( EQ_16(st_fx->L_frame,L_FRAME16k)) + { + modify_Fs_fx( fft_io, L_FRAME16k, 16000, fft_io, 12800, hTdCngEnc->exc_mem2_fx,0); + } + + fft_rel_fx(fft_io, L_FFT, LOG2_L_FFT); + ptR = &fft_io[1]; + ptI = &fft_io[L_FFT-1]; + FOR ( i=0; icng_res_env_fx[(hTdCngEnc->cng_hist_ptr)*NUM_ENV_CNG]), NUM_ENV_CNG ); + + /* calculate the residual signal energy */ + /*enr = dotp( res, res, L_frame ) / L_frame; */ + maxv = 0; + move16(); + FOR(i = 0; i < st_fx->L_frame; i++) + { + maxv = s_max(maxv, abs_s(res[i])); + } + scale = norm_s(maxv); + pt_res = res; + L_ener = L_deposit_l(1); + IF( EQ_16(st_fx->L_frame, L_FRAME)) + { + FOR (j=0; j<128; j++) + { + tmpv = shl(*pt_res,scale); + L_tmp = L_mult0(tmpv, tmpv); + pt_res++; + tmpv = shl(*pt_res,scale); +#ifdef BASOP_NOGLOB + L_tmp = L_mac0_sat( L_tmp, tmpv, tmpv ); /* 2*(Q_new+scale) */ + pt_res++; + L_ener = L_add_sat(L_ener, L_shr(L_tmp, 7)); /* 2*(Q_new+scale)+1, divide by L_frame done here */ +#else + L_tmp = L_mac0(L_tmp, tmpv, tmpv); /* 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 */ +#endif + } + } + ELSE /* L_FRAME16k */ + { + FOR (j=0; j<160; j++) + { + tmpv = shl(*pt_res,scale); + L_tmp = L_mult0(tmpv, tmpv); + pt_res++; + tmpv = shl(*pt_res,scale); +#ifdef BASOP_NOGLOB + L_tmp = L_mac0_sat( L_tmp, tmpv, tmpv ); /* 2*(Q_new+scale) */ + pt_res++; + L_ener = L_add_sat(L_ener, L_shr(Mult_32_16(L_tmp,26214 /* 256/320, Q15 */), 7)); /* 2*(Q_new+scale)+15+1-16+1, divide by L_frame done here */ +#else + L_tmp = L_mac0(L_tmp, tmpv, tmpv); /* 2*(Q_new+scale) */ + pt_res++; + L_ener = L_add(L_ener, L_shr(Mult_32_16(L_tmp,26214 /* 256/320, Q15 */), 7)); /* 2*(Q_new+scale)+15+1-16+1, divide by L_frame done here */ +#endif + } + } + /* convert log2 of residual signal energy */ + /*enr = (float)log10( enr + 0.1f ) / (float)log10( 2.0f ); */ + hi = norm_l(L_ener); + lo = Log2_norm_lc(L_shl(L_ener, hi)); + hi = sub(29, hi); /* log2 exp in Q2*(Q_new+scale) */ + hi = sub(hi, shl(add(Q_new,scale), 1)); /* Q0 */ + L_tmp = L_Comp(hi, lo); /* Q16 */ + enr = round_fx(L_shl(L_tmp, 8)); /* Q8 (16+8-16) */ + + /* update the circular buffer of old energies */ + hTdCngEnc->cng_ener_hist_fx[hTdCngEnc->cng_hist_ptr] = enr; + move16(); /* Q8 */ + + /*-----------------------------------------------------------------* + * Quantize residual signal energy (only in SID frame) + *-----------------------------------------------------------------*/ + test(); + IF( EQ_32(st_fx->core_brate, SID_2k40)||EQ_32(st_fx->core_brate,SID_1k75)) + { + IF( GE_16(hDtxEnc->cng_cnt,sub(hDtxEnc->cng_hist_size,1))) + { + /* average the envelope except outliers */ + FOR ( i=0; icng_hist_size; j++ ) + { +#ifdef BASOP_NOGLOB + L_tmp1 = L_add_sat( L_tmp1, hTdCngEnc->cng_res_env_fx[j * NUM_ENV_CNG + i] ); +#else + L_tmp1 = L_add(L_tmp1,hTdCngEnc->cng_res_env_fx[j*NUM_ENV_CNG+i]); +#endif + } + L_tmp = L_add(hTdCngEnc->cng_res_env_fx[max_idx1[0]*NUM_ENV_CNG+i],hTdCngEnc->cng_res_env_fx[max_idx1[1]*NUM_ENV_CNG+i]); + L_tmp1 = L_sub(L_tmp1,L_tmp); + + /* env[i] /= (float)(st_fx->cng_hist_size - 2); */ + tmp1 = sub(hDtxEnc->cng_hist_size,2); + IF(GT_16(tmp1,1)) + { + tmp1 = div_s(1,tmp1); + L_tmp1 = Mult_32_16(L_tmp1,tmp1); + } + + env[i] = L_tmp1; + move32(); + } + /* compute average excitation energy */ + L_tmp = L_deposit_l(0); + ptr = hTdCngEnc->cng_hist_ptr; + move16(); + + FOR (k=0; k< hDtxEnc->cng_hist_size; k++) + { + /* enr += W_HIST[k]*cng_ener_hist[ptr] */ + L_tmp = L_mac0(L_tmp, W_HIST_FX[k], hTdCngEnc->cng_ener_hist_fx[ptr]); /* Q24 (8+16) */ + ptr = sub(ptr, 1); + if (ptr < 0) /* check for circular pointer */ + { + ptr = DTX_HIST_SIZE - 1; + move16(); + } + } + /*----------------------------------------------------------- + * here we want to divide L_tmp by the sum + * of all the coefs used W_HIST[0..cng_hist_size-1] + * The table W_HIST_S already contains the inverted sum. + * That is + * W_HIST_S[k] 1 + * ------------- = --------------------------- + * 4096 W_HIST[0] + ... + W_HIST[k] + * + * 1 / Sum(W_HIST[0..k]) is always > 1 since the sum + * of the coefs 0..k is always < 1 but > 0 + * enr is in Q8 since the history buffer constains Q8 energies + *-----------------------------------------------------------*/ + /*L_tmp = Mpy_32_16_1(L_tmp, W_HIST_S_FX[k-1]); */ /* normalize average value */ + L_tmp = Mult_32_16(L_tmp, W_HIST_S_FX[k-1]); /* Q21 (24+12+1-16) */ + L_tmp = L_shl(L_tmp, 3); /* Q24 */ + enr = round_fx(L_tmp); /* Q8 */ + } + /* decrease the energy in case of WB input */ + IF ( EQ_16(st_fx->element_mode, IVAS_SCE) || EQ_16(st_fx->element_mode, IVAS_CPE_DFT)) + { + //PMT("CNG IVAS_SCE and IVAS_CPE_DFT code missing") + //IVAS_CODE + //enr += hTdCngEnc->CNG_att * FAC_LOG2 / 10.0f; + } + ELSE IF( NE_16(st_fx->bwidth, NB)) + { + IF( EQ_16(st_fx->bwidth,WB)) + { + IF(hDtxEnc->CNG_mode >= 0 ) + { + /* Bitrate adapted attenuation */ + att = ENR_ATT_fx[hDtxEnc->CNG_mode]; + move16(); + } + ELSE + { + /* Use least attenuation for higher bitrates */ + att = ENR_ATT_fx[4]; + move16(); + } + } + ELSE + { + att = 384; + move16();/*Q8*/ + } + enr = sub(enr, att ); + } + /* intialize the energy quantization parameters */ + IF( st_fx->Opt_AMR_WB == 0 ) + { + step = STEP_SID_FX; + move16(); + step_inv = ISTEP_SID_FX; + move16(); + maxl = 127; + move16(); + num_bits = 7; + move16(); + } + ELSE + { + step = STEP_AMR_WB_SID_FX; + move16(); + step_inv = ISTEP_AMR_WB_SID_FX; + move16(); + maxl = 63; + move16(); + num_bits = 6; + move16(); + } + + /* calculate the energy quantization index */ + enr_index = add(enr, 512 /* Q8(2.0) */); /* enr + 2.0 */ + enr_index = extract_l(L_shr(L_mult0(enr_index, step), 12+8)); /* Q0 (8+12-(8+12)) */ + + /* limit the energy quantization index */ + enr_index = s_min(enr_index, maxl); + enr_index = s_max(enr_index, 0); + + /* allow only slow energy increase */ + test(); + IF( hTdCngEnc->old_enr_index >= 0 && GT_16(enr_index, add(hTdCngEnc->old_enr_index, MAX_DELTA))) + { + IF( *allow_cn_step != 0 ) + { + tmp1 = mult(27853 /* Q15(0.85) */,sub(enr_index,hTdCngEnc->old_enr_index)); + enr_index = add(hTdCngEnc->old_enr_index,tmp1); + } + ELSE + { + enr_index = add(hTdCngEnc->old_enr_index, MAX_DELTA); + } + } + hTdCngEnc->old_enr_index = enr_index; + move16(); + + push_indice_fx( hBstr, IND_ENERGY, enr_index, num_bits ); + if ( enr_index == 0 ) + { + enr_index = -5; + move16(); + } + /* Find quantized energy */ + /* *Enew = (float)enr_index / step - 2.0 */ + /* *Enew = (float)pow(2.0, *Enew) */ + L_tmp = L_mult(enr_index, step_inv); /* Q16(0+15+1) */ + /* substract by 2 not done to leave Energy in Q2 */ + lo = L_Extract_lc(L_tmp, &hi); + hTdCngEnc->Enew_fx = Pow2(add(hi, 4), lo); /* Q6 */ + IF ( EQ_32(st_fx->core_brate, SID_2k40)) + { + /* enr1 = (float)log10( st->Enew*L_frame + 0.1f ) / (float)log10( 2.0f );*/ + exp = norm_l(hTdCngEnc->Enew_fx); + L_tmp = L_shl(hTdCngEnc->Enew_fx,exp); /*Q(exp+6) */ + L_tmp = Mult_32_16(L_tmp,shl(st_fx->L_frame,5));/* Q(exp+6+5-15=exp-4) */ + +#ifdef BASOP_NOGLOB + L_tmp = L_shr_sat(L_tmp,sub(exp,10)); /* Q6 */ +#else + L_tmp = L_shr(L_tmp,sub(exp,10)); /* Q6 */ +#endif + + exp = norm_l(L_tmp); + fra = Log2_norm_lc(L_shl(L_tmp,exp)); + exp = sub(sub(30,exp),6); + L_tmp = L_Comp(exp,fra); + enr1 = L_shr(L_tmp,10);/* Q6 */ + + FOR ( i=0; iEnew;*/ + L_tmp1 = L_add(env[i], 0); + L_tmp = L_add(hTdCngEnc->Enew_fx,hTdCngEnc->Enew_fx); + L_tmp1 = L_sub(L_tmp1,L_tmp); /*Q6*/ + + IF ( L_tmp1 < 0 ) + { + L_tmp1 = L_deposit_l(6); /* (0.1)Q6 */ + } + /* env[i] = (float)log10( env[i] + 0.1f ) / (float)log10( 2.0f ); */ + exp = norm_l(L_tmp1); + fra = Log2_norm_lc(L_shl(L_tmp1,exp)); + exp = sub(sub(30,exp),6); + L_tmp = L_Comp(exp,fra); + L_tmp1 = L_shr(L_tmp,10); /* Q6 */ + + L_tmp = L_shr(L_deposit_l(att),2);/* Q6 */ + L_tmp1 = L_sub(L_tmp1,L_tmp); + + IF ( L_tmp1 < 0 ) + { + L_tmp1 = L_deposit_l(0); + } + + L_tmp1 = L_sub(enr1,L_tmp1); + + env[i] = L_tmp1; + move32(); + } + + /* codebook search */ + min1 = L_add(1310588928, 0); /* Q17 */ + min1_idx = 0; + move16(); + + FOR ( i=0; i<64; i++ ) + { + d = L_deposit_l(0); + FOR ( j=0; jEnew_fx,21845 /*1/1.5f, Q15*/), hTdCngEnc->lp_ener_fx)) + { + /* update the pointer to circular buffer of old LSP vectors */ + hTdCngEnc->ho_hist_ptr = add(hTdCngEnc->ho_hist_ptr, 1); + if( EQ_16(hTdCngEnc->ho_hist_ptr,HO_HIST_SIZE)) + { + hTdCngEnc->ho_hist_ptr = 0; + move16(); + } + + /* update the circular buffer of old LSP vectors with the new LSP vector */ + Copy( lsp_new, &(hTdCngEnc->ho_lsp_hist_fx[(hTdCngEnc->ho_hist_ptr)*M]), M ); + + /* update the hangover energy buffer */ + hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr] = hTdCngEnc->Enew_fx; + move32(); + IF ( EQ_32(st_fx->core_brate, SID_2k40)) + { + FOR ( i=0; iEnew;*/ + L_tmp = L_sub(enr1,q_env[i]);/* Q6 */ + L_tmp = L_shl(L_tmp, 10);/* 16 */ + temp_lo_fx = L_Extract_lc(L_tmp, &temp_hi_fx); + + exp_pow = sub(14, temp_hi_fx); + L_tmp = Pow2(14, temp_lo_fx); /* Qexp_pow */ + env[i] = L_shl(L_tmp, sub(6, exp_pow)); + move32(); /* Q6 */ + L_tmp = L_add(hTdCngEnc->Enew_fx,hTdCngEnc->Enew_fx); + env[i] = L_add(env[i],L_tmp); + move32();/* Q6 */ + } + Copy32( env, &(hTdCngEnc->ho_env_hist_fx[(hTdCngEnc->ho_hist_ptr)*NUM_ENV_CNG]), NUM_ENV_CNG ); + } + hTdCngEnc->ho_hist_size = add(hTdCngEnc->ho_hist_size,1); + if( GT_16(hTdCngEnc->ho_hist_size,HO_HIST_SIZE)) + { + hTdCngEnc->ho_hist_size = HO_HIST_SIZE; + move16(); + } + } + } + /* dithering bit for AMR-WB IO mode is always set to 0 */ + IF( EQ_32(st_fx->core_brate, SID_1k75)) + { + push_indice_fx( hBstr, IND_DITHERING, 0, 1 ); + } + IF ( EQ_32(st_fx->core_brate, SID_2k40)) + { + IF(EQ_16(st_fx->L_frame, L_FRAME16k)) + { + push_indice_fx( hBstr, IND_ACELP_16KHZ, 1, 1 ); + } + ELSE + { + push_indice_fx( hBstr, IND_ACELP_16KHZ, 0, 1 ); + } + + push_indice_fx( hBstr, IND_CNG_HO, s_min(hTdCngEnc->burst_ho_cnt, 7 ), 3 ); + hTdCngEnc->num_ho = m; + move16(); + push_indice_fx( hBstr, IND_SID_TYPE, 0, 1 ); + + IF ( LT_32(st_fx->input_Fs, 32000) && NE_16(st_fx->element_mode, IVAS_CPE_DFT)) + { + push_indice_fx( hBstr, IND_SID_BW, 0, 1 ); + *sid_bw = 0; + move16(); + } + } + + /*-----------------------------------------------------------------* + * Updates + *-----------------------------------------------------------------*/ + /* update the SID frames counter */ + test(); + IF( EQ_32(st_fx->core_brate, SID_2k40)||EQ_32(st_fx->core_brate,SID_1k75)) + { + hDtxEnc->cng_cnt = 0; + move16(); + hTdCngEnc->cng_hist_ptr = -1; + move16(); + /* update frame length memory */ + hDtxEnc->last_CNG_L_frame = st_fx->L_frame; + move16(); + } + ELSE + { + hDtxEnc->cng_cnt = add(hDtxEnc->cng_cnt,1); + } + + return; +} +/*---------------------------------------------------------------------* + * swb_CNG_enc() + * + * SWB DTX/CNG encoding + *---------------------------------------------------------------------*/ +void swb_CNG_enc_fx( + Encoder_State *st_fx, /* i/o: State structure */ + const Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz (Q0) */ + const Word16 *syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz (st_fx->Q_syn = 0) */ +) +{ + Word16 shb_SID_updt_fx=0; + TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc; + + test(); + IF ( EQ_32(st_fx->core_brate, SID_2k40)||st_fx->core_brate==FRAME_NO_DATA) + { + IF (EQ_16(st_fx->cng_type,LP_CNG)) + { + IF (GE_32(st_fx->input_Fs, L_FRAME32k * FRAMES_PER_SEC)) + { + /* decide if SHB SID encoding or not */ + shb_SID_updt_fx = shb_DTX_fx(st_fx, shb_speech_fx, syn_12k8_16k_fx); + + /* SHB CNG encoding */ + shb_CNG_encod_fx(st_fx, shb_SID_updt_fx); + } + ELSE IF (EQ_16(st_fx->element_mode, IVAS_CPE_DFT) && EQ_32(st_fx->core_brate, SID_2k40)) + { + //PMT("CNG IVAS_CPE_DFT code not implemented") +#ifdef IVAS_CODE + /* LF-boost not used in DFT-stereo, instead the bandwidth is transmitted */ + delete_indice(st->hBstr, IND_CNG_ENV1); + push_indice(st->hBstr, IND_BWIDTH, st->bwidth, 2); + push_indice(st->hBstr, IND_UNUSED, 0, 4); + push_indice(st->hBstr, IND_SID_BW, 1, 1); +#endif + } + } + hTdCngEnc->last_vad = 0; + move16(); + } + ELSE + { + hTdCngEnc->last_vad = 1; + move16(); + } + + return; +} + +/*---------------------------------------------------------------------* + * shb_CNG_encod() + * + * SID parameters encoding for SHB signal + *---------------------------------------------------------------------*/ +static void shb_CNG_encod_fx( + Encoder_State *st_fx, /* i/o: State structure */ + const Word16 update_fx /* i : SID update flag */ +) +{ + Word16 idx_ener_fx; + TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc; + BSTR_ENC_HANDLE hBstr = st_fx->hBstr; +#ifdef IVAS_CODE + Word16 ener_mid_dec_thr; +#endif + + idx_ener_fx = 0; + move16(); + IF ( EQ_16(update_fx, 1)) + { + /* SHB energy quantization */ + IF (EQ_16(st_fx->element_mode, EVS_MONO)) + { + idx_ener_fx = shr(add(mult(hTdCngEnc->mov_shb_cng_ener_fx, 9797), 1510), 8); /* Q0 */ + } + ELSE + { + /*idx_ener = (int16_t)(0.7f * (0.1f * st->hTdCngEnc->mov_shb_cng_ener / (float)log10(2.0f) + 6.0f) + 0.5f);*/ + //PMT("shb_CNG_encod_fx quantization in missing") +#if 0 + idx_ener_fx = shr(add(mult(hTdCngEnc->mov_shb_cng_ener_fx, 9797), 1510), 8); /* Q0 */ +#endif + } + + if ( LT_16(st_fx->bwidth, SWB)) + { + idx_ener_fx = 0; + move16(); + } + + IF ( GT_16(idx_ener_fx, 15)) + { + idx_ener_fx = 15; + move16(); + } + ELSE + { + idx_ener_fx = s_max(idx_ener_fx,0); + } +#ifdef IVAS_CODE + /* prevent toggling of idx_ener by adding small dead-zone interval around decision thresholds */ + if (st->element_mode != EVS_MONO) + { + if (abs(idx_ener - st->hTdCngEnc->last_idx_ener) == 1) + { + ener_mid_dec_thr = 0.5f * ((st->hTdCngEnc->last_idx_ener / 0.7f - 6.0f) / 0.1f) * (float)log10(2.0f); + ener_mid_dec_thr += 0.5f * ((idx_ener / 0.7f - 6.0f) / 0.1f) * (float)log10(2.0f); + + if (fabs(st->hTdCngEnc->mov_shb_cng_ener - ener_mid_dec_thr) / ener_mid_dec_thr < ENER_MID_DEAD_ZONE) + { + idx_ener = st->hTdCngEnc->last_idx_ener; + } + } + } + + st->hTdCngEnc->last_idx_ener = idx_ener; +#endif + push_indice_fx( hBstr, IND_SHB_CNG_GAIN, idx_ener_fx, 4); + push_indice_fx( hBstr, IND_SID_BW, 1, 1 ); +#ifndef IVAS_CODE + hBstr->nb_bits_tot_fx = sub(hBstr->nb_bits_tot_fx, hBstr->ind_list_fx[IND_CNG_ENV1].nb_bits); + hBstr->ind_list_fx[IND_CNG_ENV1].nb_bits = -1; +#else + delete_indice(hBstr, IND_CNG_ENV1); +#endif + move16(); +#ifdef IVAS_CODE + if (st->element_mode == IVAS_CPE_DFT) + { + push_indice(st->hBstr, IND_BWIDTH, st->bwidth, 2); + } + else +#endif + { + push_indice_fx(hBstr, IND_UNUSED, 0, 2); + } + hTdCngEnc->ho_sid_bw = L_shl(L_and(hTdCngEnc->ho_sid_bw, (Word32) 0x3fffffffL ), 1); + hTdCngEnc->ho_sid_bw = L_or(hTdCngEnc->ho_sid_bw, 0x1L); + } + ELSE + { + IF ( EQ_32(st_fx->core_brate, SID_2k40)) + { + hTdCngEnc->ho_sid_bw = L_shl(L_and(hTdCngEnc->ho_sid_bw, (Word32) 0x3fffffffL ), 1); + push_indice_fx( hBstr, IND_SID_BW, 0, 1 ); + } + } + + return; +} + +/*---------------------------------------------------------------------* +* shb_DTX() +* +* Decide if encoding SHB SID or not +*---------------------------------------------------------------------*/ +static Word16 shb_DTX_fx( + Encoder_State *st_fx, /* i/o: State structure */ + const Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz (Q0) */ + const Word16 *syn_12k8_16k /* i : ACELP core synthesis at 12.8kHz or 16kHz (st_fx->Q_syn = 0) */ +) +{ + Word16 i; + Word16 update_fx; + Word16 shb_old_speech_fx[(ACELP_LOOK_12k8 + L_SUBFR + L_FRAME) * 5/4]; + Word16 *shb_new_speech_fx; + Word32 wb_ener_fx; + Word32 shb_ener_fx; + Word16 log_wb_ener_fx; + Word16 log_shb_ener_fx; + Word16 tmp; + Word16 exp; + Word16 fra; + Word16 att; /*Q8*/ + Word16 allow_cn_step_fx=0; + DTX_ENC_HANDLE hDtxEnc = st_fx->hDtxEnc; + TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc; + TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + shb_new_speech_fx = shb_old_speech_fx + (ACELP_LOOK_12k8 + L_SUBFR) * 5/4; + Copy(hBWE_TD->old_speech_shb_fx, shb_old_speech_fx, (ACELP_LOOK_12k8 + L_SUBFR) * 5/4 ); + Copy( shb_speech_fx, shb_new_speech_fx, L_FRAME16k ); + Copy( shb_old_speech_fx + L_FRAME16k, hBWE_TD->old_speech_shb_fx, (ACELP_LOOK_12k8 + L_SUBFR) * 5/4 ); + + shb_ener_fx = L_deposit_l(0); + FOR ( i=0; iL_frame; i++ ) + { +#ifdef BASOP_NOGLOB + wb_ener_fx = L_mac_o(wb_ener_fx, syn_12k8_16k[i], syn_12k8_16k[i], &Overflow); +#else + wb_ener_fx = L_mac(wb_ener_fx, syn_12k8_16k[i], syn_12k8_16k[i]); +#endif + } + + wb_ener_fx = L_add(Mpy_32_16_1(wb_ener_fx, 128), 1); /* 128 in Q15, wb_ener_fx in Q1 */ + + exp = norm_l(wb_ener_fx); + fra = Log2_norm_lc(L_shl(wb_ener_fx, exp)); + exp = sub(30-1, exp); + wb_ener_fx = Mpy_32_16(exp, fra, LG10); +#ifdef BASOP_NOGLOB + log_wb_ener_fx = round_fx_o(L_shl_o(wb_ener_fx, 10, &Overflow), &Overflow); /* log_wb_ener_fx in Q8 */ +#else + log_wb_ener_fx = round_fx(L_shl(wb_ener_fx, 10)); /* log_wb_ener_fx in Q8 */ +#endif + exp = norm_l(shb_ener_fx); + fra = Log2_norm_lc(L_shl(shb_ener_fx, exp)); + exp = sub(30-1, exp); + shb_ener_fx = Mpy_32_16(exp, fra, LG10); + + test(); + IF (EQ_16(st_fx->element_mode, IVAS_SCE) || EQ_16(st_fx->element_mode, IVAS_CPE_DFT)) + { + att = 0; + move16(); + //PMT("apply_scale is not implemented") +#if 0 + apply_scale(&att, st->hFdCngEnc->hFdCngCom->CngBandwidth, st->hFdCngEnc->hFdCngCom->CngBitrate, scaleTableStereo, SIZE_SCALE_TABLE_STEREO); +#endif + } + else + { + att = 1664; /*6.5 in Q8*/ + move16(); + } + +#ifdef BASOP_NOGLOB + log_shb_ener_fx = sub_o(round_fx_o(L_shl_o(shb_ener_fx, 10, &Overflow), &Overflow), att, &Overflow); /* log_shb_ener_fx in Q8 */ +#else + log_shb_ener_fx = sub(round_fx(L_shl(shb_ener_fx, 10)), att); /* log_shb_ener_fx in Q8 */ +#endif + IF (hDtxEnc->first_CNG == 0 ) + { + hTdCngEnc->mov_wb_cng_ener_fx = log_wb_ener_fx; + move16(); + hTdCngEnc->mov_shb_cng_ener_fx = log_shb_ener_fx; + move16(); + hTdCngEnc->last_wb_cng_ener_fx = log_wb_ener_fx; + move16(); + hTdCngEnc->last_shb_cng_ener_fx = log_shb_ener_fx; + move16(); + } + + if ( GT_16(abs_s(sub(log_wb_ener_fx, hTdCngEnc->mov_wb_cng_ener_fx)), 3072)) + { + allow_cn_step_fx = 1; + move16(); + } +#ifdef IVAS_CODE + /* Also allow step if shb energy has dropped 12 dB */ + if ((st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD) && ((hTdCngEnc->mov_shb_cng_ener - log_shb_ener) > 12.0f)) + { + allow_cn_step = 1; + } +#endif + IF ( EQ_16(allow_cn_step_fx, 1)) + { + hTdCngEnc->mov_wb_cng_ener_fx = log_wb_ener_fx; + move16(); + hTdCngEnc->mov_shb_cng_ener_fx = log_shb_ener_fx; + move16(); + } + ELSE + { + tmp = sub(log_wb_ener_fx, hTdCngEnc->mov_wb_cng_ener_fx); /* Q8 */ + tmp = mult(tmp, 29491); /* Q8 */ + hTdCngEnc->mov_wb_cng_ener_fx = add(hTdCngEnc->mov_wb_cng_ener_fx, tmp); /* Q8 */ + + tmp = sub(log_shb_ener_fx, hTdCngEnc->mov_shb_cng_ener_fx); + tmp = mult(tmp, 8192); /* Q8 */ + hTdCngEnc->mov_shb_cng_ener_fx = add(hTdCngEnc->mov_shb_cng_ener_fx, tmp); /* Q8 */ + } + hTdCngEnc->shb_NO_DATA_cnt = add(hTdCngEnc->shb_NO_DATA_cnt, 1); + + update_fx = 0; + move16(); + IF ( EQ_32(st_fx->core_brate, SID_2k40)) + { + test(); + test(); + IF (hDtxEnc->first_CNG == 0 || EQ_16(hTdCngEnc->last_vad, 1)||GE_16(hTdCngEnc->shb_NO_DATA_cnt,100)) + { + update_fx = 1; + move16(); + } + ELSE + { + IF ( hTdCngEnc->shb_cng_ini_cnt > 0 ) + { + update_fx = 1; + move16(); + hTdCngEnc->shb_cng_ini_cnt = sub(hTdCngEnc->shb_cng_ini_cnt, 1); + } + ELSE + { + IF ( GT_16(abs_s(sub(sub(hTdCngEnc->mov_wb_cng_ener_fx, hTdCngEnc->mov_shb_cng_ener_fx), sub(hTdCngEnc->last_wb_cng_ener_fx, hTdCngEnc->last_shb_cng_ener_fx))), 768)) + { + update_fx = 1; + move16(); + } + ELSE + { + test(); + IF ( GE_16(st_fx->bwidth, SWB)&<_16(hTdCngEnc->last_SID_bwidth,SWB)) + { + update_fx = 1; + move16(); + } + ELSE + { + test(); + IF ( LT_16(st_fx->bwidth, SWB)&&GE_16(hTdCngEnc->last_SID_bwidth,SWB)) + { + update_fx = 1; + move16(); + } + } + } + } + } + + hTdCngEnc->last_SID_bwidth = st_fx->bwidth; + move16(); + } + /* LF-boost not yet implemented in decoder which means that the specific wb_sid information is not used */ + test();test(); + if ((EQ_16(st_fx->element_mode, IVAS_CPE_DFT) || EQ_16(st_fx->element_mode, IVAS_CPE_TD)) && EQ_32(st_fx->core_brate, SID_2k40)) + { + update_fx = 1; + move16(); + } + + IF ( EQ_16(update_fx, 1)) + { + hTdCngEnc->last_wb_cng_ener_fx = hTdCngEnc->mov_wb_cng_ener_fx; + move16(); + hTdCngEnc->last_shb_cng_ener_fx = hTdCngEnc->mov_shb_cng_ener_fx; + move16(); + hTdCngEnc->shb_NO_DATA_cnt = 0; + move16(); + } + + + return (update_fx); +} + +/*---------------------------------------------------------------------* + * calculate_hangover_attenuation_gain_fx() + * + * + *---------------------------------------------------------------------*/ + +void calculate_hangover_attenuation_gain_fx( + Encoder_State* st, /* i : encoder state structure */ + Word16* att, /* o : attenuation factor */ + const Word16 vad_hover_flag /* i : VAD hangover flag */ +) +{ + Word16 offset; + TD_CNG_ENC_HANDLE hTdCngEnc = st->hTdCngEnc; + + *att = 32767; + + move16(); + /* smoothing in case of CNG */ + IF (hTdCngEnc != NULL) + { + test();test();test(); + IF( hTdCngEnc->burst_ho_cnt > 0 && (vad_hover_flag != 0) && (NE_16(st->bwidth, NB) || GT_16(st->element_mode, EVS_MONO))) /* corresponds to line 504 in FLT acelp_core_enc.c */ + { +#ifdef IVAS_CODE + if (st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD) + { + *att = powf(10.0f, (st->hTdCngEnc->CNG_att / 160.0f) * st->hTdCngEnc->burst_ho_cnt); + } + else +#endif + { + offset = 5; + test(); + if (EQ_16(st->bwidth, WB) && st->hDtxEnc->CNG_mode >= 0) + { + offset = st->hDtxEnc->CNG_mode; + move16(); + } + assert(hTdCngEnc->burst_ho_cnt > 0); + *att = CNG_burst_att_fx[offset][sub(hTdCngEnc->burst_ho_cnt, 1)]; /*Q15*/ + move16(); + } + } + + + } + return; +} diff --git a/lib_enc/cod_ace_fx.c b/lib_enc/cod_ace_fx.c index e33f32092..0bfdc51b1 100644 --- a/lib_enc/cod_ace_fx.c +++ b/lib_enc/cod_ace_fx.c @@ -340,7 +340,11 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision */ hLPDmem->mem_w0 =sub(xn[L_SUBFR-1], round_fx(L_shl(Ltmp, 1))); move16(); BASOP_SATURATE_WARNING_OFF_EVS; +#ifdef BASOP_NOGLOB + hLPDmem->mem_w0 = shr_sat( hLPDmem->mem_w0, shift ); /*Qnew-1*/ +#else hLPDmem->mem_w0 =shr(hLPDmem->mem_w0, shift); /*Qnew-1*/ +#endif BASOP_SATURATE_WARNING_ON_EVS; /*-------------------------------------------------------* @@ -379,7 +383,7 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision */ Ltmp = L_shl(Ltmp, Q_new_p5); Ltmp = L_mac(Ltmp, gain_pit, exc[i+i_subfr]); #ifdef BASOP_NOGLOB - exc2[i] = round_fx(L_shl_o(Ltmp, 1, &Overflow)); + exc2[i] = round_fx_sat(L_shl_o(Ltmp, 1, &Overflow)); #else BASOP_SATURATE_WARNING_OFF_EVS exc2[i] = round_fx(L_shl(Ltmp, 1)); @@ -387,8 +391,13 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision */ #endif Ltmp2 = Mpy_32_16_1(gain_code, code[i]); +#ifdef BASOP_NOGLOB + Ltmp2 = L_shl_sat( Ltmp2, Q_new_p5 ); + Ltmp = L_add_sat( Ltmp, Ltmp2 ); +#else Ltmp2 = L_shl(Ltmp2, Q_new_p5); Ltmp = L_add(Ltmp, Ltmp2); +#endif #ifdef BASOP_NOGLOB Ltmp = L_shl_o(Ltmp, 1, &Overflow); /* saturation can occur here */ exc[i + i_subfr] = round_fx_o(Ltmp, &Overflow); diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index 035e03000..c4d441304 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -1688,7 +1688,11 @@ void QuantizeSpectrum_fx( IF (tmp2 >= 0) { BASOP_SATURATE_WARNING_OFF_EVS; +#ifdef BASOP_NOGLOB + tmp2 = sub_sat( sqGain, shr_sat( tmp1, tmp2 ) ); +#else tmp2 = sub(sqGain, shr(tmp1, tmp2)); +#endif BASOP_SATURATE_WARNING_ON_EVS; } ELSE @@ -2304,7 +2308,11 @@ void QuantizeSpectrum_fx( /* add part of current sub-window overlapping with previous window */ FOR (i = 0; i < L_ola; i++) { +#ifdef BASOP_NOGLOB + tmpP16[i] = add_sat( tmpP16[i], win[i] ); +#else tmpP16[i] = add(tmpP16[i], win[i]); +#endif move16(); } /* copy new sub-window region not overlapping with previous window */ @@ -2387,7 +2395,11 @@ void QuantizeSpectrum_fx( /* add part of current sub-window overlapping with previous window */ FOR (i = 0; i < L_ola; i++) { +#ifdef BASOP_NOGLOB + tmpP16[i] = add_sat( tmpP16[i], win[i] ); +#else tmpP16[i] = add(tmpP16[i], win[i]); +#endif move16(); } @@ -2581,7 +2593,11 @@ void QuantizeSpectrum_fx( tmp1 = sub(overlap, hTcxCfg->tcx_mdct_window_min_length); FOR (i=0; i < tmp1; i++) { +#ifdef BASOP_NOGLOB + xn_buf16[i] = shl_sat( add_sat( xn_buf16[i], shr_sat( hTcxEnc->old_out_fx[i + nz], tmp2 ) ), TCX_IMDCT_HEADROOM ); +#else xn_buf16[i] = shl(add(xn_buf16[i], shr(hTcxEnc->old_out_fx[i+nz], tmp2)), TCX_IMDCT_HEADROOM); +#endif move16(); } @@ -2590,19 +2606,31 @@ void QuantizeSpectrum_fx( FOR ( ; i < tmp1; i++) { tmp3 = mult_r(shr(hTcxEnc->old_out_fx[i+nz], tmp2), hTcxCfg->tcx_mdct_window_minimum[i-overlap+hTcxCfg->tcx_mdct_window_min_length].v.re); +#ifdef BASOP_NOGLOB + xn_buf16[i] = shl_sat( add_sat( xn_buf16[i], tmp3 ), TCX_IMDCT_HEADROOM ); +#else xn_buf16[i] = shl(add(xn_buf16[i], tmp3), TCX_IMDCT_HEADROOM); +#endif move16(); } FOR ( ; i < overlap; i++) { tmp3 = mult_r(shr(hTcxEnc->old_out_fx[i+nz], tmp2), hTcxCfg->tcx_mdct_window_minimum[overlap-1-i].v.im); +#ifdef BASOP_NOGLOB + xn_buf16[i] = shl_sat( add_sat( xn_buf16[i], tmp3 ), TCX_IMDCT_HEADROOM ); +#else xn_buf16[i] = shl(add(xn_buf16[i], tmp3), TCX_IMDCT_HEADROOM); +#endif move16(); } FOR ( ; i < L_frame; i++) { +#ifdef BASOP_NOGLOB + xn_buf16[i] = shl_sat( xn_buf16[i], TCX_IMDCT_HEADROOM ); +#else xn_buf16[i] = shl(xn_buf16[i], TCX_IMDCT_HEADROOM); +#endif move16(); } } diff --git a/lib_enc/core_enc_init_fx.c b/lib_enc/core_enc_init_fx.c index 4252372b6..f56cb3ca6 100644 --- a/lib_enc/core_enc_init_fx.c +++ b/lib_enc/core_enc_init_fx.c @@ -414,8 +414,13 @@ static void init_tcx_fx( move16(); } +#ifdef BASOP_NOGLOB /*pit = pit_old * (float)st->L_frame/(float)L_frame_old;*/ + pit = shl_sat(mult_r(pit_old, div_s(st->L_frame, shl(L_frame_old, 2))), 2); +/* Note : the saturation here that can happens when FS == 32kHz*/ +#else pit = shl(mult_r(pit_old, div_s(st->L_frame, shl(L_frame_old, 2))), 2); +#endif /* assert(pit <= st->L_frame);*/ hTcxEnc->tcxltp_pitch_int_past = pit; @@ -722,7 +727,11 @@ static void init_acelp_fx( Encoder_State *st, Word16 L_frame_old , const Word16 Copy( hLPDmem->mem_syn2, tmp_buf+1, M ); deemph_fx( tmp_buf+1, st->preemph_fac, M, &tmp ); Residu3_fx( Ap, tmp_buf+M, &tmp, 1, 1 ); +#ifdef BASOP_NOGLOB + hLPDmem->mem_w0 = sub_sat( shr_sat( st->wspeech_enc[-1], shift ), tmp ); +#else hLPDmem->mem_w0 = sub(shr(st->wspeech_enc[-1],shift), tmp); +#endif } } ELSE IF((NE_16(st->L_frame,L_frame_old))) diff --git a/lib_enc/core_enc_ol_fx.c b/lib_enc/core_enc_ol_fx.c index a9f8dfafb..a603c3fcc 100644 --- a/lib_enc/core_enc_ol_fx.c +++ b/lib_enc/core_enc_ol_fx.c @@ -1233,7 +1233,11 @@ void core_acelp_tcx20_switching_fx( #else /* BASOP_NOGLOB */ (LT_16(add(st->prevTempFlatness_fx, currFlatness), 416/*3.25f Q7*/) || EQ_16(stab_fac, 0x7fff) || #endif +#ifdef BASOP_NOGLOB + ( EQ_32( st->sr_core, INT_FS_12k8 ) && EQ_16( st->sp_aud_decision0, 1 ) && LT_16( add_sat( st->prevTempFlatness_fx, currFlatness ), 2560 /*20.f Q7*/ ) ) ) && +#else (EQ_32(st->sr_core, INT_FS_12k8) && EQ_16(st->sp_aud_decision0,1) && LT_16(add(st->prevTempFlatness_fx, currFlatness), 2560/*20.f Q7*/) )) && +#endif (LE_16(st->acelpFramesCount, 6) )) { dsnr = -512/*-2.0f Q8*/; @@ -1244,7 +1248,11 @@ void core_acelp_tcx20_switching_fx( test();test();test(); if ((LT_16(snr_acelp, snr_tcx))&& (GT_16(snr_acelp, sub(snr_tcx, 512/*2.0f Q8*/)) ) && +#ifdef BASOP_NOGLOB + ( GT_16( add_sat( st->prevTempFlatness_fx, currFlatness ), 416 /*3.25f Q7*/ ) ) && +#else (GT_16(add(st->prevTempFlatness_fx, currFlatness), 416/*3.25f Q7*/) ) && +#endif (GE_16(st->acelpFramesCount, 6) )) { dsnr = 512/*2.0f Q8*/; diff --git a/lib_enc/detect_transient_fx.c b/lib_enc/detect_transient_fx.c index 8cad74f96..6c430921f 100644 --- a/lib_enc/detect_transient_fx.c +++ b/lib_enc/detect_transient_fx.c @@ -75,9 +75,13 @@ static void hp_filter_fx( #else /* BASOP_NOGLOB */ L_tmp = L_mult(sub(x[0], *oldx), 24465);/*Q_new+16 */ #endif /* BASOP_NOGLOB */ +#ifdef BASOP_NOGLOB + L_tmp = L_mac_sat( L_tmp, *oldy, 16158 ); /*Q_new+16 */ + y[0] = round_fx_sat(L_tmp);/*Q_new */ +#else L_tmp = L_mac(L_tmp, *oldy, 16158);/*Q_new+16 */ y[0] = round_fx(L_tmp);/*Q_new */ - +#endif FOR(i = 1; i < L; i++) { /*y[i] = 0.4931f*y[i-1] + 0.7466f*(x[i] - x[i-1]); */ diff --git a/lib_enc/dtx_fx.c b/lib_enc/dtx_fx.c index 1fb6f1feb..477070405 100644 --- a/lib_enc/dtx_fx.c +++ b/lib_enc/dtx_fx.c @@ -780,7 +780,11 @@ void dtx_hangover_control_fx( } exp = norm_l(enr_est); +#ifdef BASOP_NOGLOB + fra = round_fx_sat( L_shl_sat( enr_est, exp ) ); +#else fra = round_fx(L_shl(enr_est,exp)); +#endif exp2 = norm_s(weights); fra2 = shl(weights,exp2); exp = sub(sub(exp,16),exp2); diff --git a/lib_enc/enc_acelp_fx.c b/lib_enc/enc_acelp_fx.c index d234a1dd9..4ab5dc0a1 100644 --- a/lib_enc/enc_acelp_fx.c +++ b/lib_enc/enc_acelp_fx.c @@ -466,8 +466,13 @@ static void E_ACELP_xh_corr(Word16 *x, Word16 *y, Word16 *h, Word16 L_subfr) L_maxloc = L_shr(L_maxloc, 2); /* Do not warn saturation of L_tot, since its for headroom estimation. */ BASOP_SATURATE_WARNING_OFF_EVS +#ifdef BASOP_NOGLOB + L_tot = L_add_sat( L_tot, L_maxloc ); /* +max/4 */ + L_tot = L_add_sat(L_tot, L_shr(L_maxloc, 1)); /* +max/8 */ +#else L_tot = L_add(L_tot, L_maxloc); /* +max/4 */ L_tot = L_add(L_tot, L_shr(L_maxloc, 1)); /* +max/8 */ +#endif BASOP_SATURATE_WARNING_ON_EVS } diff --git a/lib_enc/enc_acelpx_fx.c b/lib_enc/enc_acelpx_fx.c index b7e8fbb21..ae65423eb 100644 --- a/lib_enc/enc_acelpx_fx.c +++ b/lib_enc/enc_acelpx_fx.c @@ -196,7 +196,11 @@ static void E_ACELP_2pulse_searchx( move16(); /* dn[x] has only nb_pos_ix positions saved */ /*ps1 = ps0 + dn[x]; INDIRECT(1);ADD(1);*/ +#ifdef BASOP_NOGLOB + ps1 = add_sat( ps0, dn[x] ); +#else ps1 = add(ps0, dn[x]); +#endif /*alp1 = alp0 + 2*sgnx*cor[x]; INDIRECT(1);MULT(1); MAC(1);*/ #ifdef BASOP_NOGLOB alp1 = L_mac_o(alp0, cor[x], sgnx, &Overflow); /* Qalp = (Q_R=Q_cor)*Q_signval */ @@ -208,8 +212,11 @@ static void E_ACELP_2pulse_searchx( FOR (y = track_y; y < L_SUBFR; y += 4) { /*ps2 = ps1 + dn[y]; ADD(1);*/ +#ifdef BASOP_NOGLOB + ps2 = add_sat( ps1, dn[y] ); +#else ps2 = add(ps1, dn[y]); - +#endif /*alp2 = alp1 + 2.0f*sign[y]*(cor[y] + sgnx*pR[y]); MULT(1); MAC(2);*/ /*alp2 = alp1 + 2.0f*sign[y]*cor[y] + 2.0f*sign[y]*sgnx*pR[y]; MULT(1); MAC(2);*/ assert(sign[y] == sign_val_2 || sign[y] == -sign_val_2); diff --git a/lib_enc/enc_amr_wb_fx.c b/lib_enc/enc_amr_wb_fx.c index be7d3bd07..461b742af 100644 --- a/lib_enc/enc_amr_wb_fx.c +++ b/lib_enc/enc_amr_wb_fx.c @@ -216,17 +216,26 @@ void encod_amr_wb_fx( Ltmp = L_negate(Ltmp); Ltmp = L_mac(Ltmp, xn[L_SUBFR - 1], 16384); Ltmp = L_msu(Ltmp, y1[L_SUBFR - 1], gain_pit); +#ifdef BASOP_NOGLOB + Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); + hLPDmem->mem_w0 = round_fx_sat(Ltmp); /*Q_new-1 */ +#else Ltmp = L_shl(Ltmp, sub(1, shift)); hLPDmem->mem_w0 = round_fx(Ltmp); /*Q_new-1 */ - +#endif /*-----------------------------------------------------------------* * Find the total excitation *-----------------------------------------------------------------*/ FOR (i = 0; i < L_SUBFR; i++) { L_tmp = L_mult(gcode16, code[i]); +#ifdef BASOP_NOGLOB + L_tmp = L_shl_sat( L_tmp, 5 ); + L_tmp = L_mac_sat( L_tmp, exc[i + i_subfr], gain_pit ); +#else L_tmp = L_shl(L_tmp, 5); L_tmp = L_mac(L_tmp, exc[i + i_subfr], gain_pit); +#endif #ifdef BASOP_NOGLOB L_tmp = L_shl_o(L_tmp, 1, &Overflow); /* saturation can occur here */ exc[i + i_subfr] = round_fx_o(L_tmp, &Overflow); diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index bbe55a384..477074839 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -323,9 +323,13 @@ void encod_gen_voic_fx( Ltmp = L_negate(Ltmp); Ltmp = L_mac(Ltmp, xn_fx[L_SUBFR - 1], 16384); Ltmp = L_msu(Ltmp, y1_fx[L_SUBFR - 1], gain_pit_fx); +#ifdef BASOP_NOGLOB + Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); + hLPDmem->mem_w0 = round_fx_sat(Ltmp); /*Q_new-1 */ +#else Ltmp = L_shl(Ltmp, sub(1, shift)); hLPDmem->mem_w0 = round_fx(Ltmp); /*Q_new-1 */ - +#endif IF(gain_preQ_fx != 0 ) { tmp1_fx = add(16-(2+Q_AVQ_OUT_DEC+1),Q_new); diff --git a/lib_enc/enc_higher_acelp_fx.c b/lib_enc/enc_higher_acelp_fx.c index 1cf16e5d5..939632ebc 100644 --- a/lib_enc/enc_higher_acelp_fx.c +++ b/lib_enc/enc_higher_acelp_fx.c @@ -99,8 +99,13 @@ void transf_cdbk_enc_fx( Ltmp = L_negate(Ltmp); Ltmp = L_mac(Ltmp, xn[i], 16384); Ltmp = L_msu(Ltmp, y1[i], *gain_pit); +#ifdef BASOP_NOGLOB + Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); + x_tran[i] = round_fx_sat(Ltmp); /*Q_new-1 */ +#else Ltmp = L_shl(Ltmp, sub(1, shift)); x_tran[i] = round_fx(Ltmp); /*Q_new-1 */ +#endif } find_cn_fx( x_tran, Ap, p_Aq, x_in ); } @@ -148,11 +153,12 @@ void transf_cdbk_enc_fx( { /*fcorr += fx_tran[i]*(float)ix_norm[i];*/ /*fener += (float)ix_norm[i]*(float)ix_norm[i];*/ - stmp = shl(x_norm[i],Q_AVQ_OUT ); #ifdef BASOP_NOGLOB + stmp = shl_sat( x_norm[i], Q_AVQ_OUT ); L_corr = L_mac_sat( L_corr, x_tran[i], stmp ); L_ener = L_mac_sat(L_ener, stmp, stmp); #else + stmp = shl( x_norm[i], Q_AVQ_OUT ); L_corr = L_mac( L_corr, x_tran[i], stmp ); L_ener = L_mac(L_ener, stmp, stmp); #endif @@ -176,12 +182,20 @@ void transf_cdbk_enc_fx( } m_corr = div_s(m_corr, m_ener); e_corr = sub(e_corr, e_ener); +#ifdef BASOP_NOGLOB + Ltmp = L_shl_sat( m_corr, s_min( add( e_corr, 1 ), 31 ) ); /* Lgain in Q16 */ +#else Ltmp = L_shl(m_corr, s_min(add(e_corr,1),31)); /* Lgain in Q16 */ +#endif IF ( EQ_16(st_fx->coder_type,INACTIVE)) { Ltmp1 = L_max(gain_code,1); e_den = norm_l(Ltmp1); +#ifdef BASOP_NOGLOB + m_den = extract_h( L_shl_sat( Ltmp1, e_den ) ); +#else m_den = extract_h(L_shl(Ltmp1, e_den)); +#endif /* ensure m_corr < m_den */ test(); IF( m_corr>0 && m_den >0) @@ -213,8 +227,13 @@ void transf_cdbk_enc_fx( index = usquant_fx( stmp, &stmp, G_AVQ_MIN_INACT_Q12, G_AVQ_DELTA_INACT_Q12>>1, (1 << G_AVQ_BITS) ); } Ltmp = Mult_32_16(gain_code,stmp); /* Q16 * Q12 - 15 -> Q13*/ +#ifdef BASOP_NOGLOB + Ltmp = L_shl_sat( Ltmp, 5 ); /* Q13 -> Q18*/ + *gain_preQ = round_fx_sat(Ltmp); /* Q2*/ +#else Ltmp = L_shl(Ltmp,5); /* Q13 -> Q18*/ *gain_preQ = round_fx(Ltmp); /* Q2*/ +#endif } ELSE { @@ -468,8 +487,13 @@ Word16 gain_quant_fx( /* o: quantization index */ /*tmp1 = sub(c_max,c_min); Q14*/ /*tmp2 = sub(c_gain,c_min); Q14*/ +#ifdef BASOP_NOGLOB + tmp1 = msu_r_sat( L_deposit_h( c_max /*in Q13 already*/ ), c_min, 16384 ); /*Q13*/ + tmp2 = msu_r_sat(L_deposit_h(c_gain/*in Q13 already*/),c_min,16384); /*Q13*/ +#else tmp1 = msu_r(L_deposit_h(c_max/*in Q13 already*/),c_min, 16384); /*Q13*/ tmp2 = msu_r(L_deposit_h(c_gain/*in Q13 already*/),c_min,16384); /*Q13*/ +#endif IF(tmp1 != 0) { exp = norm_s(tmp1); diff --git a/lib_enc/enc_nelp_fx.c b/lib_enc/enc_nelp_fx.c index f3a72bed2..1ba66f9bf 100644 --- a/lib_enc/enc_nelp_fx.c +++ b/lib_enc/enc_nelp_fx.c @@ -145,7 +145,11 @@ void encod_nelp_fx( * Updates: last value of new target is stored in mem_w0 *-----------------------------------------------------------------*/ +#ifdef BASOP_NOGLOB + hLPDmem->mem_w0 = sub_sat( shr_sat( xn_fx[L_SUBFR - 1], shift ), shr( exc_fx[L_FRAME - 1], 1 ) ); +#else hLPDmem->mem_w0 = sub(shr(xn_fx[L_SUBFR-1],shift), shr(exc_fx[L_FRAME-1],1)); +#endif move16();/*Q_new-1 */ hLPDmem->tilt_code = 0; move16();/* purely unvoiced */ diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index c5718ff8a..d20e133da 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -343,8 +343,13 @@ void enc_pit_exc_fx( } gp_clip_test_gain_pit_fx(st_fx->element_mode, st_fx->core_brate, gain_pit, st_fx->clip_var_fx ); +#ifdef BASOP_NOGLOB + Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ + gcode16 = round_fx_sat( Lgcode ); +#else Lgcode = L_shl(gain_code, Q_new); /* scaled gain_code with Qnew -> Q16*/ gcode16 = round_fx(Lgcode); +#endif IF( use_fcb != 0) { hLPDmem->tilt_code = Est_tilt2(&exc[i_subfr], gain_pit, code, Lgcode, &voice_fac, shift); @@ -381,9 +386,15 @@ void enc_pit_exc_fx( ELSE { Ltmp = L_mult(xn[L_subfr - 1], 16384); +#ifdef BASOP_NOGLOB + Ltmp = L_msu_sat( Ltmp, y1[L_subfr - 1], gain_pit ); + Ltmp = L_shl_sat(Ltmp, sub(1, shift)); + hLPDmem->mem_w0 = round_fx_sat(Ltmp); /*Q_new-1 */ +#else Ltmp = L_msu(Ltmp, y1[L_subfr - 1], gain_pit); Ltmp = L_shl(Ltmp, sub(1, shift)); hLPDmem->mem_w0 = round_fx(Ltmp); /*Q_new-1 */ +#endif } /*-----------------------------------------------------------------* @@ -416,8 +427,13 @@ void enc_pit_exc_fx( { Ltmp = L_mult(exc[i + i_subfr], gain_pit); +#ifdef BASOP_NOGLOB + Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here */ + exc[i + i_subfr] = round_fx_sat(Ltmp); +#else Ltmp = L_shl(Ltmp, 1); /* saturation can occur here */ exc[i + i_subfr] = round_fx(Ltmp); +#endif } } diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c index dad3acf3b..879d391cf 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -246,9 +246,13 @@ Word16 encod_tran_fx( L_tmp = L_negate(L_tmp); L_tmp = L_mac(L_tmp, xn[L_SUBFR - 1], 16384); L_tmp = L_msu(L_tmp, y1[L_SUBFR - 1], gain_pit); +#ifdef BASOP_NOGLOB + L_tmp = L_shl_sat( L_tmp, sub( 1, shift ) ); + hLPDmem->mem_w0 = round_fx_sat(L_tmp); /*Q_new-1*/ +#else L_tmp = L_shl(L_tmp, sub(1, shift)); hLPDmem->mem_w0 = round_fx(L_tmp); /*Q_new-1*/ - +#endif /*-----------------------------------------------------------------* * Construct adaptive part of the excitation * Save the non-enhanced excitation for FEC_exc @@ -264,7 +268,11 @@ Word16 encod_tran_fx( { FOR (i = 0; i < L_SUBFR; i++) { +#ifdef BASOP_NOGLOB + exc2_fx[i + i_subfr] = round_fx_sat( L_shl_sat( L_mult_sat( gain_pit, exc_fx[i + i_subfr] ), 1 ) ); +#else exc2_fx[i+i_subfr] = round_fx(L_shl(L_mult(gain_pit,exc_fx[i+i_subfr]),1)); +#endif } } ELSE diff --git a/lib_enc/enc_uv_fx.c b/lib_enc/enc_uv_fx.c index d17bbb113..418b12f53 100644 --- a/lib_enc/enc_uv_fx.c +++ b/lib_enc/enc_uv_fx.c @@ -196,7 +196,11 @@ void encod_unvoiced_fx( hLPDmem->mem_w0 = sub(xn_fx[L_SUBFR - 1], round_fx(L_shl(Ltmp, 1))); move16(); BASOP_SATURATE_WARNING_OFF_EVS; +#ifdef BASOP_NOGLOB + hLPDmem->mem_w0 = shr_sat( hLPDmem->mem_w0, shift ); /*Qnew-1*/ +#else hLPDmem->mem_w0 = shr(hLPDmem->mem_w0, shift); /*Qnew-1*/ +#endif BASOP_SATURATE_WARNING_ON_EVS; /*-------------------------------------------------------* @@ -220,10 +224,15 @@ void encod_unvoiced_fx( Ltmp2 = Mpy_32_16_1(gain_code_vect[j], code_fx[i]); Ltmp2 = L_shl(Ltmp2, Q_new_p5); Ltmp = L_add(Ltmp, Ltmp2); +#ifdef BASOP_NOGLOB + Ltmp = L_shl_sat(Ltmp, 1); /* saturation can occur here */ + exc_fx[i + i_subfr] = round_fx_sat(Ltmp); +#else BASOP_SATURATE_WARNING_OFF_EVS Ltmp = L_shl(Ltmp, 1); /* saturation can occur here */ BASOP_SATURATE_WARNING_ON_EVS exc_fx[i + i_subfr] = round_fx(Ltmp); +#endif } tmp2 = L_SUBFR; move16(); diff --git a/lib_enc/energy_fx.c b/lib_enc/energy_fx.c index 06638aa5e..ca455bf55 100644 --- a/lib_enc/energy_fx.c +++ b/lib_enc/energy_fx.c @@ -62,8 +62,13 @@ void est_energy_fx( FOR(i = 2; i < BandNum; i++) { Ltmp32 = L_shr(sb_power[i],shr_tmp); +#ifdef BASOP_NOGLOB + frame_energy2 = L_add_sat( frame_energy2, Ltmp32 ); + if(i > 6) HB_Power = L_add_sat(HB_Power, Ltmp32 ); +#else frame_energy2 = L_add(frame_energy2, Ltmp32 ); if(i > 6) HB_Power = L_add(HB_Power, Ltmp32 ); +#endif } frame_energy2 = L_sub(frame_energy2, Ltmp32 ); diff --git a/lib_enc/ext_sig_ana_fx.c b/lib_enc/ext_sig_ana_fx.c index d31267152..5b086e5d7 100644 --- a/lib_enc/ext_sig_ana_fx.c +++ b/lib_enc/ext_sig_ana_fx.c @@ -310,7 +310,11 @@ void core_signal_analysis_high_bitrate_fx( /* Outter left folding */ FOR(i = 0; i < folding_offset; i++) { +#ifdef BASOP_NOGLOB + tcx20Win[folding_offset + i] = sub_sat( tcx20Win[folding_offset + i], tcx20Win[folding_offset - 1 - i] ); +#else tcx20Win[folding_offset + i] = sub(tcx20Win[folding_offset + i], tcx20Win[folding_offset - 1 - i]); +#endif move16(); } #ifdef IVAS_CODE diff --git a/lib_enc/fd_cng_enc_fx.c b/lib_enc/fd_cng_enc_fx.c index 25e610e3d..83b4a1b38 100644 --- a/lib_enc/fd_cng_enc_fx.c +++ b/lib_enc/fd_cng_enc_fx.c @@ -808,7 +808,11 @@ static void msvq_encoder (const Word16 * const cb[], /* i : Codebook (indexed c tmp = L_add(dist[0][c], L_sub(en, L_shl(t1, 1))); BASOP_SATURATE_WARNING_OFF_EVS +#ifdef BASOP_NOGLOB + t1 = L_sub_sat( tmp, dist[1][p_max] ); +#else t1 = L_sub(tmp,dist[1][p_max]); +#endif BASOP_SATURATE_WARNING_ON_EVS IF ( t1 <= 0 ) /* IF (L_sub(L_shr(tmp,1), L_shr(dist[1][p_max],1) ) <= 0 ) */ @@ -1498,7 +1502,11 @@ void generate_comfort_noise_enc_fx(Encoder_State *stcod, s = sub(15-NOISE_HEADROOM,noiseExp); FOR (i=0; i Q1*/ +#ifdef BASOP_NOGLOB + *gain_code = L_shl_sat( L_tmp, add( add( expg, exp_gcode0 ), 15 ) ); +#else *gain_code = L_shl(L_tmp,add(add(expg,exp_gcode0),15)); +#endif move32(); /*Q16*/ /* *norm_gain_code = *gain_code / *gain_inov; */ @@ -954,7 +962,11 @@ void gain_enc_tc_fx( i = sub(exp_num, exp_den); /* Gain_trans in Q7 */ g_code_fx = i_mult2(g_code_fx, tmp16); /* apply sign */ +#ifdef BASOP_NOGLOB + *gain_code_fx = L_shr_sat( L_deposit_l( g_code_fx ), i ); +#else *gain_code_fx = L_shr(L_deposit_l(g_code_fx),i); +#endif move32(); /*----------------------------------------------------------------* @@ -1058,7 +1070,11 @@ void gain_enc_tc_fx( move16(); /**gain_code *= gcode0;*/ L_tmp = L_mult(wgain_code, gcode0_fx); /* Q13*Q0 -> Q14 */ +#ifdef BASOP_NOGLOB + *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 2 ) ); +#else *gain_code_fx= L_shl(L_tmp, add(exp_gcode0, 2)); +#endif move32(); /* Q14 -> Q16 */ push_indice_fx( hBstr, IND_GAIN_CODE, index, nBits ); } diff --git a/lib_enc/gaus_enc_fx.c b/lib_enc/gaus_enc_fx.c index 5d6d2ed18..e004d110f 100644 --- a/lib_enc/gaus_enc_fx.c +++ b/lib_enc/gaus_enc_fx.c @@ -117,8 +117,13 @@ Word16 gaus_encode_fx( Ltmp = L_shl(Ltmp, add(5, shift)); Ltmp = L_negate(Ltmp); Ltmp = L_mac(Ltmp, xn[L_SUBFR - 1], 16384); +#ifdef BASOP_NOGLOB + Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); + *mem_w0 = round_fx_sat( Ltmp ); +#else Ltmp = L_shl(Ltmp, sub(1, shift)); *mem_w0 = round_fx(Ltmp); +#endif init_gp_clip_fx(clip_gain); /* reset pitch clipping parameters */ *gain_pit = 0; @@ -211,8 +216,13 @@ void gauss2v_fx( { /* fc0 += xn[i]*xn[i] */ /* fc1 += xn[i]*xn[i-1] */ +#ifdef BASOP_NOGLOB + Lc0 = L_mac_sat( Lc0, xn[i], xn[i] ); + Lc1 = L_mac_sat(Lc1, xn[i], xn[i-1]); +#else Lc0 = L_mac(Lc0, xn[i], xn[i]); Lc1 = L_mac(Lc1, xn[i], xn[i-1]); +#endif } /* fgxx = fc1/fc0 */ exp_num = sub(norm_l(Lc1), 1); @@ -599,10 +609,18 @@ void gauss2v_fx( div_result = div_s(Num, Den); /* Q15 */ /* Re-scale to compensate for normalization*/ +#ifdef BASOP_NOGLOB + GainPortion2 = L_shr_sat( L_deposit_l( div_result ), sub( exp_num, exp_den ) ); +#else GainPortion2 = L_shr(L_deposit_l(div_result), sub(exp_num, exp_den)); +#endif } +#ifdef BASOP_NOGLOB + ener_sqrt = Isqrt( L_shl_sat( GainPortion2, 1 ) ); /* Make value a Q16 prior to division (align on power of 4) */ +#else ener_sqrt = Isqrt(L_shl(GainPortion2, 1)); /* Make value a Q16 prior to division (align on power of 4) */ +#endif ener_sqrt = L_shr(ener_sqrt, 8); /* Left-shift Q23 result to make a Q15 result */ Portion = Mult_32_16(GainPortion1, 19661); /* Performs GainPortion1*.6 */ diff --git a/lib_enc/hf_cod_amrwb_fx.c b/lib_enc/hf_cod_amrwb_fx.c index ac65954d2..20a1296f9 100644 --- a/lib_enc/hf_cod_amrwb_fx.c +++ b/lib_enc/hf_cod_amrwb_fx.c @@ -193,7 +193,7 @@ void hf_cod_fx( L_tmp = L_mult(ener_hf_fx, HF_calc_gain_fx); /*30-q1+q2 */ q2 = sub(q1, q2); /*30-q2 */ #ifdef BASOP_NOGLOB - HF_calc_gain_fx = round_fx_o(Isqrt(L_shl(L_tmp, sub(q2, 20))), &Overflow); /*Q10 */ + HF_calc_gain_fx = round_fx_o(Isqrt(L_shl_sat(L_tmp, sub(q2, 20))), &Overflow); /*Q10 */ #else /* BASOP_NOGLOB */ HF_calc_gain_fx = round_fx(Isqrt(L_shl(L_tmp, sub(q2, 20)))); /*Q10 */ #endif diff --git a/lib_enc/hq_lr_enc_fx.c b/lib_enc/hq_lr_enc_fx.c index 4906be8fc..d080107ee 100644 --- a/lib_enc/hq_lr_enc_fx.c +++ b/lib_enc/hq_lr_enc_fx.c @@ -349,7 +349,11 @@ void hq_lr_enc_fx( frac1 = L_Extract_lc(L_tmp, &exp); /* Extract exponent of L_tmp */ L_tmp = Pow2(30, frac1); exp = sub(exp, 30); +#ifdef BASOP_NOGLOB + Ep_fx[i] = L_shl_sat( L_tmp, s_max( sub( exp, 6 ), -31 ) ); /* Q -6 */ +#else Ep_fx[i] = L_shl(L_tmp , s_max(sub(exp,6), -31)); /* Q -6 */ +#endif } FOR( i = 0; i < bands_fx; i++ ) @@ -416,13 +420,22 @@ void hq_lr_enc_fx( { IF( GE_16(i,lowband)) { +#ifdef BASOP_NOGLOB + Ep_vari_fx = L_add_sat( Ep_vari_fx, L_abs( L_sub( Ep_tmp_fx[i], Ep_tmp_fx[sub( i, 1 )] ) ) ); /*Q15 */ + Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ +#else Ep_vari_fx = L_add(Ep_vari_fx,L_abs(L_sub(Ep_tmp_fx[i],Ep_tmp_fx[sub(i,1)])));/*Q15 */ Ep_avrg_fx = L_add(Ep_avrg_fx,Ep_tmp_fx[i]);/*Q15 */ +#endif } ELSE { +#ifdef BASOP_NOGLOB + Ep_avrgL_fx = L_add_sat( Ep_avrgL_fx, Ep_tmp_fx[i] ); /*Q15 */ +#else Ep_avrgL_fx = L_add(Ep_avrgL_fx,Ep_tmp_fx[i]);/*Q15 */ +#endif IF(GT_32(Ep_tmp_fx[i],Ep_peak_fx)) { Ep_peak_fx = L_add(Ep_tmp_fx[i], 0); /*Q15 */ @@ -532,7 +545,11 @@ void hq_lr_enc_fx( IF(EQ_16(hHQ_core->last_bitalloc_max_band[j++], 1)) { L_tmp = Mult_32_16(Ep_tmp_fx[i],sub(bands_fx,lowband));/*Q(13+0-15 = -2) */ +#ifdef BASOP_NOGLOB + tmp = extract_h( L_shl_sat( L_tmp, 14 ) ); /*Q-2 */ +#else tmp = extract_h(L_shl(L_tmp,14));/*Q-2 */ +#endif IF(tmp != 0) { exp = norm_s(tmp); @@ -596,11 +613,19 @@ void hq_lr_enc_fx( { IF(GE_16(i,lowband)) { +#ifdef BASOP_NOGLOB + Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ +#else Ep_avrg_fx = L_add(Ep_avrg_fx,Ep_tmp_fx[i]);/*Q15 */ +#endif } ELSE { +#ifdef BASOP_NOGLOB + Ep_avrgL_fx = L_add_sat( Ep_avrgL_fx, L_shr( Ep_tmp_fx[i], 1 ) ); /*Q12 */ +#else Ep_avrgL_fx = L_add(Ep_avrgL_fx,L_shr(Ep_tmp_fx[i],1));/*Q12 */ +#endif IF(GT_32(Ep_tmp_fx[i],Ep_peak_fx)) { Ep_peak_fx = L_add(Ep_tmp_fx[i], 0); /*Q13 */ @@ -690,7 +715,11 @@ void hq_lr_enc_fx( test(); IF( GE_16(i,lowband)&&add(sub(i,bands_fx),p2a_bands_fx)<0) { +#ifdef BASOP_NOGLOB + Ep_vari_fx = L_add_sat( Ep_vari_fx, L_abs( L_sub_sat( Ep_tmp_fx[i], Ep_tmp_fx[sub( i, 1 )] ) ) ); /*Q15 */ +#else Ep_vari_fx = L_add(Ep_vari_fx,L_abs(L_sub(Ep_tmp_fx[i],Ep_tmp_fx[sub(i,1)])));/*Q15 */ +#endif #ifdef BASOP_NOGLOB Ep_avrg_fx = L_add_o(Ep_avrg_fx,Ep_tmp_fx[i], &Overflow);/*Q15 */ #else /* BASOP_NOGLOB */ @@ -700,11 +729,19 @@ void hq_lr_enc_fx( IF(GE_16(i,highband)) { +#ifdef BASOP_NOGLOB + enerH_fx = L_add_sat( enerH_fx, L_shl_sat( Ep_fx[i], 2 ) ); /*Q0 */ +#else enerH_fx = L_add(enerH_fx,L_shl(Ep_fx[i],2));/*Q0 */ +#endif } ELSE IF(GE_16(i,lowband)) { +#ifdef BASOP_NOGLOB + enerL_fx = L_add_sat( enerL_fx, L_shl_sat( Ep_fx[i], 2 ) ); /*Q0 */ +#else enerL_fx = L_add(enerL_fx,L_shl(Ep_fx[i],2));/*Q0 */ +#endif } } diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c index 7ff0116c4..109f85ff0 100644 --- a/lib_enc/igf_enc_fx.c +++ b/lib_enc/igf_enc_fx.c @@ -253,7 +253,11 @@ static void IGF_CalculateEnvelope(const IGF_ENC_INSTANCE_HANDLE hInstanc zeroNrg = 1; move16(); } +#ifdef BASOP_NOGLOB + BASOP_Util_Divide_MantExp( round_fx_sat( sfbEnergyR[sfb] ), +#else BASOP_Util_Divide_MantExp(round_fx(sfbEnergyR[sfb]), +#endif sfbEnergyR_exp[sfb], width, 15, @@ -490,7 +494,11 @@ static void IGF_ErodeSpectrum(Word16 *highPassEner_e { /* May overflow - just for threshold comparison */ BASOP_SATURATE_WARNING_OFF_EVS +#ifdef BASOP_NOGLOB + L_tmp = L_add_sat( pPowerSpectrum[i], highPassEner_Ovfl ); +#else L_tmp = L_add(pPowerSpectrum[i], highPassEner_Ovfl); +#endif BASOP_SATURATE_WARNING_ON_EVS IF (L_tmp < 0) @@ -515,7 +523,11 @@ static void IGF_ErodeSpectrum(Word16 *highPassEner_e /* May overflow - just for threshold comparison */ BASOP_SATURATE_WARNING_OFF_EVS +#ifdef BASOP_NOGLOB + L_tmp = L_add_sat( pPowerSpectrum[i], highPassEner_Ovfl ); +#else L_tmp = L_add(pPowerSpectrum[i], highPassEner_Ovfl); +#endif BASOP_SATURATE_WARNING_ON_EVS IF (L_tmp < 0) { @@ -622,8 +634,13 @@ static Word16 IGF_getCrest( /* limit crest factor to a lower bound of 1, may overflow */ BASOP_SATURATE_WARNING_OFF_EVS +#ifdef BASOP_NOGLOB + tmp = shl_sat( -1, sub( 15, *crest_exp ) ); /* build negative threshold */ + tmp = add_sat( crest, tmp ); +#else tmp = shl(-1, sub(15, *crest_exp)); /* build negative threshold */ tmp = add(crest, tmp); +#endif BASOP_SATURATE_WARNING_ON_EVS if (tmp < 0) { @@ -855,7 +872,13 @@ static void IGF_Whitening(const IGF_ENC_INSTANCE_HANDLE hInstanc BASOP_SATURATE_WARNING_OFF_EVS /*SFM = min(2.7f, SFM);*/ /*Overflow possible in shift, intended*/ +#ifdef BASOP_NOGLOB + tmp = add_sat( crest, tmp ); + SFM = s_min( 22118 /*2.7f Q13*/, extract_h( L_shr_sat( SFM32, 16 - 29 ) /*->Q29*/ ) /*->Q13*/ ); +#else + tmp = add( crest, tmp ); SFM = s_min(22118/*2.7f Q13*/,extract_h(L_shr(SFM32,16-29)/*->Q29*/)/*->Q13*/ ); +#endif BASOP_SATURATE_WARNING_ON_EVS hPrivateData->prevSFM_FIR[p] = tmp32; /*15Q16*/ move32(); diff --git a/lib_enc/lp_exc_e_fx.c b/lib_enc/lp_exc_e_fx.c index b118da9d7..5d36d4b4d 100644 --- a/lib_enc/lp_exc_e_fx.c +++ b/lib_enc/lp_exc_e_fx.c @@ -419,7 +419,11 @@ Word16 corr_xy1_fx( /* o : pitch gain (0..GAIN_PIT_MAX) */ /* Note: shl works as shl or shr. */ exp_xx = sub(exp_xx,1); BASOP_SATURATE_WARNING_OFF_EVS +#ifdef BASOP_NOGLOB + gain_p_snr = round_fx_sat( L_shl_sat( Mpy_32_16_1( 1717986944l /*ACELP_GAINS_CONST Q31*/, tmp ), exp_xx ) ); +#else gain_p_snr = round_fx(L_shl(Mpy_32_16_1( 1717986944l/*ACELP_GAINS_CONST Q31*/, tmp), exp_xx)); +#endif BASOP_SATURATE_WARNING_ON_EVS gain = s_min(gain, gain_p_snr); diff --git a/lib_enc/lsf_msvq_ma_enc_fx.c b/lib_enc/lsf_msvq_ma_enc_fx.c index 57106caa0..296e3b8af 100644 --- a/lib_enc/lsf_msvq_ma_enc_fx.c +++ b/lib_enc/lsf_msvq_ma_enc_fx.c @@ -44,6 +44,20 @@ FOR (i = 0; i < N; i+=4) { depack_4_values(cbp+i_mult(shr(i,2),3), val0, val1, val2, val3) +#ifdef BASOP_NOGLOB + Tmp[i + 0] = mult_r( shl_sat( w[i + 0], 2 ), val0 ); + move16(); + en = L_mac_sat( en, val0, Tmp[i + 0] ); + Tmp[i + 1] = mult_r( shl_sat( w[i + 1], 2 ), val1 ); + move16(); + en = L_mac_sat( en, val1, Tmp[i + 1] ); + Tmp[i + 2] = mult_r( shl_sat( w[i + 2], 2 ), val2 ); + move16(); + en = L_mac_sat( en, val2, Tmp[i + 2] ); + Tmp[i + 3] = mult_r( shl_sat( w[i + 3], 2 ), val3 ); + move16(); + en = L_mac_sat( en, val3, Tmp[i + 3] ); +#else Tmp[i+0] = mult_r(shl(w[i+0],2),val0); move16(); en = L_mac(en, val0, Tmp[i+0]); @@ -56,6 +70,7 @@ Tmp[i+3] = mult_r(shl(w[i+3],2),val3); move16(); en = L_mac(en, val3, Tmp[i+3]); +#endif } return en; @@ -245,7 +260,11 @@ void msvq_enc_fx move16(); FOR (j=1; jy1y1 + 2 * (*gain_code) * g_coeff->y1y2); */ s = norm_l(L_tmp1); +#ifdef BASOP_NOGLOB + tmp = round_fx_sat( L_shl_sat( L_tmp1, s ) ); +#else tmp = round_fx(L_shl(L_tmp1, s)); +#endif s = sub(15, s); c_e = BASOP_Util_Add_MantExp(mult_r(tmp, g_coeff->y1y1), add(s, g_coeff->y1y1_e), diff --git a/lib_enc/scale_enc_fx.c b/lib_enc/scale_enc_fx.c index 31ef140c4..a831229ec 100644 --- a/lib_enc/scale_enc_fx.c +++ b/lib_enc/scale_enc_fx.c @@ -111,7 +111,11 @@ void Preemph_scaled( /* get max of new preemphased samples (L_FRAME+L_FILT) */ L_tmp = L_mult(new_speech[0], QVal); +#ifdef BASOP_NOGLOB + L_tmp = L_msu_sat( L_tmp, *mem_preemph, mu ); +#else L_tmp = L_msu(L_tmp, *mem_preemph, mu); +#endif L_maxloc = L_abs(L_tmp); FOR (i = 1; i < Lframe; i++) @@ -179,14 +183,23 @@ void Preemph_scaled( L_tmp = L_msu(L_tmp, new_speech[i - 1], mu); #endif /* BASOP_NOGLOB */ L_tmp = L_shl(L_tmp, *Q_new); +#ifdef BASOP_NOGLOB + new_speech[i] = round_fx_sat( L_tmp ); +#else new_speech[i] = round_fx(L_tmp); +#endif } L_tmp = L_mult(new_speech[0], QVal); +#ifdef BASOP_NOGLOB + L_tmp = L_msu_sat( L_tmp, *mem_preemph, mu ); + L_tmp = L_shl_sat(L_tmp, *Q_new); + new_speech[0] = round_fx_sat(L_tmp); +#else L_tmp = L_msu(L_tmp, *mem_preemph, mu); L_tmp = L_shl(L_tmp, *Q_new); new_speech[0] = round_fx(L_tmp); - +#endif *mem_preemph = tmp_fixed; move16(); } diff --git a/lib_enc/set_impulse_fx.c b/lib_enc/set_impulse_fx.c index ad603ae7e..fdc92195d 100644 --- a/lib_enc/set_impulse_fx.c +++ b/lib_enc/set_impulse_fx.c @@ -161,11 +161,12 @@ void set_impulse_fx( #ifdef BASOP_NOGLOB Lrr = L_mac_o(Lrr, gh_fx[0], gh_fx[0], &Overflow); Ldd = L_mac_o(Ldd, gh_fx[0], xn_fx[0], &Overflow); + dd_fx[i] = round_fx_sat( Ldd ); #else /* BASOP_NOGLOB */ Lrr = L_mac(Lrr, gh_fx[0], gh_fx[0]); Ldd = L_mac(Ldd, gh_fx[0], xn_fx[0]); + dd_fx[i] = round_fx( Ldd ); #endif - dd_fx[i] = round_fx(Ldd); rr_fx[i] = L_max(Lrr, 1); move32(); /* move rr and dd into rr[i] and dd[i] */ diff --git a/lib_enc/spec_flatness_fx.c b/lib_enc/spec_flatness_fx.c index 2d07bc15f..115e86545 100644 --- a/lib_enc/spec_flatness_fx.c +++ b/lib_enc/spec_flatness_fx.c @@ -301,7 +301,11 @@ SFM_Qtmp = sub(SFM_Qtmp, SPEC_AMP_Q); SFM_Qtmp = sub(SFM_Qtmp, SFM_Q); +#ifdef BASOP_NOGLOB + sSFM[2] = add_sat( mult( sSFM[2], 0x6ccc ), shr_sat( mult( SFM, 0x1333 ), SFM_Qtmp ) ); +#else sSFM[2] = add(mult(sSFM[2],0x6ccc),shr(mult(SFM,0x1333),SFM_Qtmp)); +#endif move16(); } diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index 794d13bef..ae1de1ddb 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -2767,7 +2767,11 @@ static void flux_fx( { IF ( p2v_map[i] != 0 ) { +#ifdef BASOP_NOGLOB + L_flux = L_add_sat( L_flux, abs_s( sub_sat( Bin_E[i], old_Bin_E[i] ) ) ); /*Q7 */ +#else L_flux = L_add(L_flux,abs_s(sub(Bin_E[i],old_Bin_E[i]))); /*Q7 */ +#endif } if ( p2v_map[i] != 0 ) { diff --git a/lib_enc/swb_bwe_enc_fx.c b/lib_enc/swb_bwe_enc_fx.c index c3420d2e4..9785eb061 100644 --- a/lib_enc/swb_bwe_enc_fx.c +++ b/lib_enc/swb_bwe_enc_fx.c @@ -469,10 +469,15 @@ static Word16 WB_BWE_fenv_q_fx( /* o: quantized gain index */ dist = L_deposit_l(0); FOR (j=0; jQ20 */ + dist = L_add_sat(dist, L_tmp); +#else tmp = sub(x[j], *pit);/*Q10 */ L_tmp = L_mult0(tmp, tmp);/*Q(10+10)->Q20 */ dist = L_add(dist, L_tmp); - +#endif pit++; } @@ -929,7 +934,11 @@ static void freq_weights_fx( { exp = norm_s(tmp); tmp = div_s(shl(1,sub(14,exp)), tmp); /*(21-exp) */ +#ifdef BASOP_NOGLOB + tmp = shl_sat( tmp, sub( exp, 6 ) ); /*Q15 */ +#else tmp = shl(tmp, sub(exp, 6)); /*Q15 */ +#endif } ELSE { @@ -1628,7 +1637,11 @@ static void calculate_Tonality_fx( l_shift = norm_s(max); FOR( n_coeff=0; n_coeff= 0; i--) { offs32 = Mpy_32_16_1(L_abs(x[i]), gain); /* multiply */ +#ifdef BASOP_NOGLOB + offs32 = L_shl_sat( offs32, s ); /* convert to 15Q16 */ + tmp16 = mac_r_sat(offs32, offset, 1); /* add offset and truncate */ +#else offs32 = L_shl(offs32, s); /* convert to 15Q16 */ tmp16 = mac_r(offs32, offset, 1); /* add offset and truncate */ +#endif if (x[i] < 0) tmp16 = negate(tmp16); /* restore sign */ xq[i] = tmp16; @@ -869,7 +874,11 @@ Word16 tcx_scalar_quantization_rateloop_fx( /* convert to normalized 16 bit */ tmp = norm_l(tmp32); +#ifdef BASOP_NOGLOB + sqGain = round_fx_sat( L_shl( tmp32, tmp ) ); +#else sqGain = round_fx(L_shl(tmp32, tmp)); +#endif sqGain_e = sub(sqGain_e, tmp); /* divide */ @@ -1446,7 +1455,11 @@ void tcx_encoder_memory_update_fx( Residu3_fx(Ai+(st->nb_subfr-1)*(M+1), synth + sub(L_frame_glob, 1), &tmp, 1, Q_new+shift-1); LPDmem->mem_w0 =sub(wsig[sub(L_frame_glob, 1)], tmp); move16(); +#ifdef BASOP_NOGLOB + LPDmem->mem_w0 = shr_sat( LPDmem->mem_w0, shift ); /*Qnew-1*/ +#else LPDmem->mem_w0 =shr(LPDmem->mem_w0, shift); /*Qnew-1*/ +#endif } @@ -1643,8 +1656,11 @@ Word16 tcx_res_Q_gain_fx( } /* bring sqGain to same exponent */ +#ifdef BASOP_NOGLOB + sqGain = shr_sat( sqGain, sub( gain_reQ_e, sqGain_e ) ); +#else sqGain = shr(sqGain, sub(gain_reQ_e, sqGain_e)); - +#endif FOR (bits=0; bits < TCX_RES_Q_BITS_GAIN; bits++) { IF (LT_16(sqGain, gain_reQ)) diff --git a/lib_enc/tfa_enc_fx.c b/lib_enc/tfa_enc_fx.c index 66ee96687..d7ef4fc67 100644 --- a/lib_enc/tfa_enc_fx.c +++ b/lib_enc/tfa_enc_fx.c @@ -31,7 +31,11 @@ void tfaCalcEnv_fx( enr[i] = L_deposit_l(0); FOR (j=0; j= 0x2000000 */ +#else L_tmp = L_shl(L_tmp, sub(shift, tmp)); /* shift L_tmp to that exponent */ /* calc factor (with 2 bits headroom for sum of 3 subdivisions) */ move16(); facs[iFilter][iSubdivisions] = div_s(0x2000, round_fx(L_tmp)); /* L_tmp is >= 0x2000000 */ +#endif } } diff --git a/lib_enc/transient_detection_fx.c b/lib_enc/transient_detection_fx.c index 321dfbd08..fc02ea7ec 100644 --- a/lib_enc/transient_detection_fx.c +++ b/lib_enc/transient_detection_fx.c @@ -713,7 +713,11 @@ static void CalculateSubblockEnergies(Word16 const * input, Word16 nSamplesAvail FOR (k = 0; k < w; k++) { tmp = shr(input[k], SUBBLOCK_NRG_E/2); +#ifdef BASOP_NOGLOB + accu = L_mac0_sat( accu, tmp, tmp ); +#else accu = L_mac0(accu, tmp, tmp); +#endif } move32(); @@ -730,7 +734,11 @@ static void CalculateSubblockEnergies(Word16 const * input, Word16 nSamplesAvail FOR (; k < k2; k++) { tmp = shr(input[k], SUBBLOCK_NRG_E/2); +#ifdef BASOP_NOGLOB + accu = L_mac0_sat( accu, tmp, tmp ); +#else accu = L_mac0(accu, tmp, tmp); +#endif } move32(); pSubblockNrg[w] = accu; diff --git a/lib_enc/updt_tar_fx.c b/lib_enc/updt_tar_fx.c index 3183b6521..b6b87b4cf 100644 --- a/lib_enc/updt_tar_fx.c +++ b/lib_enc/updt_tar_fx.c @@ -33,10 +33,11 @@ void updt_tar_fx( { /*x2[i] = x[i] - gain*y[i];*/ L_tmp = L_mult(x[i], 16384); - L_tmp = L_msu(L_tmp, y[i], gain); #ifdef BASOP_NOGLOB + L_tmp = L_msu_sat( L_tmp, y[i], gain ); x2[i] = extract_h(L_shl_o(L_tmp, 1, &Overflow)); #else /* BASOP_NOGLOB */ + L_tmp = L_msu( L_tmp, y[i], gain ); x2[i] = extract_h(L_shl(L_tmp, 1)); #endif } diff --git a/lib_enc/vlpc_1st_cod_fx.c b/lib_enc/vlpc_1st_cod_fx.c index 7c633039b..691d088cb 100644 --- a/lib_enc/vlpc_1st_cod_fx.c +++ b/lib_enc/vlpc_1st_cod_fx.c @@ -55,14 +55,26 @@ static void lsf_weight( FOR (i=1; i<(M-2); i+=2) /*for (i=1; i<(M-2); i+=2)*/ { inv_di1 = div_s(ISF_ONE,s_max(ISF_ONE, sub(lsfq[i],lsfq[i-1]))); /*0Q15*/ /*inv_di1 = 1.0f / (lsfq[i] - lsfq[i-1]);*/ +#ifdef BASOP_NOGLOB + w[i - 1] = add_sat( inv_di0, inv_di1 ); +#else w[i-1] = add(inv_di0,inv_di1); +#endif move16(); /*0Q15*/ /*w[i-1] = inv_di0 + inv_di1;*/ inv_di0 = div_s(ISF_ONE,s_max(ISF_ONE, sub(lsfq[i+1],lsfq[i]))); /*0Q15*/ /*inv_di0 = 1.0f / (lsfq[i+1] - lsfq[i]);*/ +#ifdef BASOP_NOGLOB + w[i] = add_sat( inv_di1, inv_di0 ); +#else w[i] = add(inv_di1,inv_di0); +#endif move16(); /*0Q15*/ /*w[i] = inv_di1 + inv_di0;*/ } inv_di1 = div_s(ISF_ONE, s_max(ISF_ONE, sub(lsfq[i],lsfq[i-1]))); /*inv_di1 = 1.0f / (lsfq[i] - lsfq[i-1]);*/ +#ifdef BASOP_NOGLOB + w[i - 1] = add_sat( inv_di0, inv_di1 ); +#else w[i-1] = add(inv_di0,inv_di1); +#endif move16(); /*w[i-1] = inv_di0 + inv_di1;*/ inv_di0 = div_s(ISF_ONE, s_max(ISF_ONE, sub(FREQ_MAX,lsfq[i]))); /*inv_di0 = 1.0f / (FREQ_MAX - lsfq[i]);*/ #ifdef BASOP_NOGLOB diff --git a/lib_enc/voiced_enc_fx.c b/lib_enc/voiced_enc_fx.c index 3281637ee..054356449 100644 --- a/lib_enc/voiced_enc_fx.c +++ b/lib_enc/voiced_enc_fx.c @@ -515,7 +515,11 @@ ivas_error ppp_voiced_encoder_fx( tmp = div_s(fracb,fraca); exp = sub(expb,expa); +#ifdef BASOP_NOGLOB + sp_enratio_fx = L_shl_sat( tmp, exp ); /* Q15 */ +#else sp_enratio_fx = L_shl(tmp, exp); /* Q15 */ +#endif } } ELSE diff --git a/lib_enc/waveadjust_fec_cod_fx.c b/lib_enc/waveadjust_fec_cod_fx.c index 988d7564c..364a831f4 100644 --- a/lib_enc/waveadjust_fec_cod_fx.c +++ b/lib_enc/waveadjust_fec_cod_fx.c @@ -38,7 +38,11 @@ Word32 SFM_Cal_fx(Word32 magn[], Word16 n) /* sum(log2(magn(i))) */ sumLogMagn =L_add(sumLogMagn, logMagn); /* Q8 */ +#ifdef BASOP_NOGLOB + sumMagn = L_add_sat( sumMagn, magn_abs ); +#else sumMagn =L_add(sumMagn, magn_abs); +#endif } IF(EQ_32(sumMagn,MAX_32)) -- GitLab From 158033e35db65e618b72916033dad0fb6057e03e Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 15 Apr 2024 15:18:35 +0530 Subject: [PATCH 2/2] swb_bwe_com.c variable update. --- lib_com/swb_bwe_com_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/swb_bwe_com_fx.c b/lib_com/swb_bwe_com_fx.c index 7afef321b..bcf974cde 100644 --- a/lib_com/swb_bwe_com_fx.c +++ b/lib_com/swb_bwe_com_fx.c @@ -1567,7 +1567,7 @@ void SWB_BWE_decoding_fx( #endif #else #ifdef BASOP_NOGLOB - EnergyL_16 = round_fx_sat( L_shl_sat( L_tmp, add( exp, 4 ) ) ); /* Q3 */ + Energy_16 = round_fx_sat( L_shl_sat( L_tmp, add( exp, 4 ) ) ); /* Q3 */ #else EnergyL_16 = round_fx( L_shl( L_tmp, add( exp, 4 ) ) ); /*Q3 */ #endif -- GitLab