From 46a792389fe488965146282e9d1288bac1be9a48 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 12 Jun 2024 11:46:07 +0530 Subject: [PATCH 1/3] BASOP and instrumentation changes [x] Added missed BASOPs and instrumentation code [x] Few BASOPs are to be updated as per discussion with PC group. Changes will be made through subsequent MRs. --- lib_dec/core_switching_dec.c | 114 +++++++- lib_dec/core_switching_dec_fx.c | 35 ++- lib_dec/dec2t32_fx.c | 4 +- lib_dec/dec4t64_fx.c | 50 ++-- lib_dec/dec_ace_fx.c | 92 ++++-- lib_dec/dec_acelp_fx.c | 22 +- lib_dec/dec_acelp_tcx_main_fx.c | 58 ++-- lib_dec/dec_amr_wb_fx.c | 11 +- lib_dec/dec_gen_voic_fx.c | 79 ++++-- lib_dec/decision_matrix_dec_fx.c | 29 +- lib_dec/er_dec_acelp_fx.c | 206 ++++++++------ lib_dec/er_dec_tcx_fx.c | 324 ++++++++++++---------- lib_dec/er_scale_syn_fx.c | 20 +- lib_dec/er_sync_exc.c | 2 +- lib_dec/er_sync_exc_fx.c | 84 +++--- lib_dec/er_util_fx.c | 121 ++++---- lib_dec/hq_core_dec_fx.c | 2 +- lib_dec/hq_env_dec_fx.c | 7 +- lib_dec/hq_lr_dec_fx.c | 16 +- lib_dec/igf_dec_fx.c | 160 ++++++----- lib_dec/igf_scf_dec_fx.c | 27 +- lib_dec/init_dec_fx.c | 120 +++++--- lib_dec/inov_dec_fx.c | 53 ++-- lib_dec/ivas_dirac_output_synthesis_cov.c | 105 ++----- lib_dec/updt_dec_fx.c | 6 +- 25 files changed, 1031 insertions(+), 716 deletions(-) diff --git a/lib_dec/core_switching_dec.c b/lib_dec/core_switching_dec.c index 653ef2523..d2d4f6669 100644 --- a/lib_dec/core_switching_dec.c +++ b/lib_dec/core_switching_dec.c @@ -81,8 +81,12 @@ ivas_error core_switching_pre_dec_ivas_fx( Word16 exp = 25; error = IVAS_ERR_OK; + move32(); /* Codec mode switching */ + test(); + test(); + test(); IF( EQ_16( st->last_codec_mode, MODE2 ) || ( ( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) ) && GT_16( st->element_mode, EVS_MONO ) ) ) { #ifndef FIX_770_DISCONTINUITIES_SW_TCX2ACELP @@ -119,6 +123,7 @@ ivas_error core_switching_pre_dec_ivas_fx( { st->hBPF->pst_lp_ener_fx = round_fx( L_shl( Mpy_32_16_1( st->lp_error_ener, 0x6054 ), 2 + 8 ) ); /* convert from 15Q16, log2 -> 7Q8 10*log10 */ st->hBPF->pst_mem_deemp_err_fx = 0; + move16(); } #endif st->psf_lp_noise_fx = round_fx( L_shl( st->lp_noise, 1 ) ); @@ -136,6 +141,7 @@ ivas_error core_switching_pre_dec_ivas_fx( move16(); set16_fx( st->hb_prev_synth_buffer_fx, 0, NS2SA( 48000, DELAY_BWE_TOTAL_NS ) ); + test(); IF( st->hBWE_TD != NULL && NE_16( st->last_core, ACELP_CORE ) ) { #ifdef MSAN_FIX @@ -155,6 +161,7 @@ ivas_error core_switching_pre_dec_ivas_fx( st->igf = 0; move16(); + test(); IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) { hf_synth_reset_fx( st->hBWE_zero ); @@ -196,6 +203,7 @@ ivas_error core_switching_pre_dec_ivas_fx( move32(); } + test(); IF( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) ) { IF( EQ_16( st->element_mode, EVS_MONO ) ) @@ -238,6 +246,8 @@ ivas_error core_switching_pre_dec_ivas_fx( delay_comp = NS2SA( st->output_Fs, DELAY_CLDFB_NS ); /*TODO To be tested:control not entering the block*/ + test(); + test(); IF( !st->last_con_tcx && EQ_16( st->last_core_bfi, ACELP_CORE ) && EQ_16( st->core, HQ_CORE ) ) { /*TODO None of the test dtreams are entering this block,hence enabled assert(0)*/ @@ -281,6 +291,8 @@ ivas_error core_switching_pre_dec_ivas_fx( Copy_Scale_sig_32_16( fer_samples_fx, st->hHQ_core->fer_samples_fx, 960, 9 ); } + test(); + test(); IF( !st->last_con_tcx && EQ_16( st->last_core_bfi, ACELP_CORE ) && EQ_16( st->core, HQ_CORE ) ) { lerp( st->hTcxDec->syn_Overl, st->hHQ_core->fer_samples_fx + delay_comp, output_frame / 2, st->last_L_frame / 2 ); @@ -298,6 +310,7 @@ ivas_error core_switching_pre_dec_ivas_fx( /*FEC*/ IF( LE_16( st->L_frame, L_FRAME16k ) ) { + test(); IF( LE_16( st->last_L_frame, L_FRAME16k ) && NE_16( st->core, HQ_CORE ) ) { IF( NE_16( st->L_frame, st->last_L_frame ) ) @@ -325,6 +338,8 @@ ivas_error core_switching_pre_dec_ivas_fx( /* Here we only handle cases where last_ppp and last_nelp not updated when coming from CodecB or other cores within ACELP_CORE if switching from another bitarate to vbr, last_ppp and last_nelp is always updated in the previous frame */ + test(); + test(); IF( EQ_16( st->core, ACELP_CORE ) && ( NE_16( st->last_core, ACELP_CORE ) || NE_16( st->last_codec_mode, MODE2 ) ) ) { st->last_ppp_mode_dec = 0; @@ -334,6 +349,9 @@ ivas_error core_switching_pre_dec_ivas_fx( } /* Handle state reset of stat_noise_uv_mod memory */ + test(); + test(); + test(); IF( EQ_16( st->core, ACELP_CORE ) && ( NE_16( st->last_core, ACELP_CORE ) || EQ_16( st->last_codec_mode, MODE2 ) || LE_32( st->last_total_brate, PPP_NELP_2k80 ) ) ) { st->act_count = 3; @@ -342,9 +360,21 @@ ivas_error core_switching_pre_dec_ivas_fx( move16(); } + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); IF( ( ( EQ_16( st->core, ACELP_CORE ) || EQ_16( st->core, AMR_WB_CORE ) ) && EQ_16( st->last_core, HQ_CORE ) ) || ( ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && EQ_16( last_element_mode, IVAS_CPE_DFT ) ) ) && EQ_16( nchan_out, 2 ) && NE_32( st->core_brate, SID_2k40 ) && NE_32( st->core_brate, FRAME_NO_DATA ) && ( EQ_32( last_core_brate_st0, FRAME_NO_DATA ) || EQ_32( last_core_brate_st0, SID_2k40 ) ) ) ) { + test(); IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) { st->hPFstat->reset = 1; @@ -368,6 +398,12 @@ ivas_error core_switching_pre_dec_ivas_fx( lsf2lsp_fx( st->lsf_old_fx, st->lsp_old_fx, M, INT_FS_12k8 ); } + test(); + test(); + test(); + test(); + test(); + test(); IF( ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && EQ_16( nchan_out, 2 ) && GT_32( st->core_brate, SID_2k40 ) && ( EQ_32( last_core_brate_st0, FRAME_NO_DATA ) || EQ_32( last_core_brate_st0, SID_2k40 ) ) && st->hTcxDec != NULL ) { /* Last frame was Stereo CNG and the synthesis memory is outdated -- reset */ @@ -430,6 +466,8 @@ ivas_error core_switching_pre_dec_ivas_fx( cldfb_reset_memory_fx( st->cldfbSyn ); /* reset TBE memories */ + test(); + test(); IF( !st->last_con_tcx && !( ( EQ_16( st->last_core, HQ_CORE ) ) && GT_16( st->element_mode, EVS_MONO ) ) ) { set16_fx( st->old_exc_fx, 0, L_EXC_MEM_DEC ); @@ -445,6 +483,7 @@ ivas_error core_switching_pre_dec_ivas_fx( set16_fx( st->hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); } + test(); IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) { hf_synth_reset_fx( st->hBWE_zero ); @@ -459,6 +498,9 @@ ivas_error core_switching_pre_dec_ivas_fx( } } + test(); + test(); + test(); IF( ( EQ_16( st->core, ACELP_CORE ) || EQ_16( st->core, AMR_WB_CORE ) ) && ( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) ) ) { IF( st->hBWE_TD != NULL ) @@ -491,6 +533,7 @@ ivas_error core_switching_pre_dec_ivas_fx( move16(); move16(); + test(); IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) { hf_synth_reset_fx( st->hBWE_zero ); @@ -504,6 +547,9 @@ ivas_error core_switching_pre_dec_ivas_fx( set16_fx( st->hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); } + test(); + test(); + test(); IF( EQ_16( nchan_out, 1 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) && LE_32( st->element_brate, IVAS_24k4 ) && GT_32( last_element_brate, IVAS_24k4 ) ) { /* update cldbf state with previous frame TCX synthesis when going from a bitrate with residual coding to a bitrate without it */ @@ -514,14 +560,19 @@ ivas_error core_switching_pre_dec_ivas_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for old_synth_lenFB (32 bit) \n" ) ); } - Copy_Scale_sig_16_32( st->hTcxDec->old_synthFB_fx, old_synthFB_fx, st->hTcxDec->old_synth_lenFB, Q10 - Q_old_synthFB ); + Copy_Scale_sig_16_32( st->hTcxDec->old_synthFB_fx, old_synthFB_fx, st->hTcxDec->old_synth_lenFB, sub( Q10, Q_old_synthFB ) ); Copy32( old_synthFB_fx + st->hTcxDec->old_synth_lenFB - offset, st->cldfbAna->cldfb_state_fx, offset ); st->cldfbAna->Q_cldfb_state = Q10; + move16(); IF( old_synthFB_fx ) free( old_synthFB_fx ); } } + test(); + test(); + test(); + test(); IF( EQ_16( st->core, HQ_CORE ) && ( EQ_16( st->last_core, ACELP_CORE ) || EQ_16( st->last_core, AMR_WB_CORE ) || ( ( NE_16( st->element_mode, EVS_MONO ) ) && ( NE_16( st->last_core, HQ_CORE ) ) ) ) ) { set32_fx( st->hHQ_core->prev_env_fx, 0, SFM_N_WB ); @@ -545,7 +596,7 @@ ivas_error core_switching_pre_dec_ivas_fx( IF( NE_16( st->element_mode, EVS_MONO ) ) { /* Estimate mem_env_delta to reinit env_stab */ - tmp_fx = L_max( 0, ENV_STAB_EST1_FX + Mult_32_16( st->stab_fac_smooth_lt_fx, ENV_STAB_EST2_FX ) + Mult_32_16( st->log_energy_diff_lt_fx, ENV_STAB_EST3_FX ) ); /*Q12*/ + tmp_fx = L_max( 0, L_add( ENV_STAB_EST1_FX, L_add( Mult_32_16( st->stab_fac_smooth_lt_fx, ENV_STAB_EST2_FX ), Mult_32_16( st->log_energy_diff_lt_fx, ENV_STAB_EST3_FX ) ) ) ); /*Q12*/ st->hHQ_core->mem_env_delta = extract_l( L_min( MAX16B, tmp_fx ) ); /* Convert to Q12 and handle saturation */ @@ -609,6 +660,12 @@ ivas_error core_switching_pre_dec_ivas_fx( /*switch on CNA on active frames*/ IF( EQ_16( st->element_mode, EVS_MONO ) ) /* for IVAS modes, st->flag_cna is set earlier */ { + test(); + test(); + test(); + test(); + test(); + test(); IF( st->VAD && ( ( NE_16( st->core, AMR_WB_CORE ) && LE_32( st->total_brate, CNA_MAX_BRATE ) ) || ( EQ_16( st->core, AMR_WB_CORE ) && LE_32( st->total_brate, ACELP_8k85 ) ) ) ) { st->flag_cna = 1; @@ -628,6 +685,10 @@ ivas_error core_switching_pre_dec_ivas_fx( } /* Reconfigure CNG */ + test(); + test(); + test(); + test(); IF( st->hFdCngDec && ( NE_16( st->last_L_frame, st->L_frame ) || NE_16( st->hFdCngDec->hFdCngCom->frameSize, st->L_frame ) || EQ_16( st->ini_frame, 0 ) || NE_16( st->bwidth, st->last_bwidth ) ) ) { /* || st->last_core == AMR_WB_CORE || st->last_codec_mode == MODE2)){*/ @@ -645,24 +706,29 @@ ivas_error core_switching_pre_dec_ivas_fx( move32(); } } + test(); + test(); IF( NE_16( st->last_L_frame, st->L_frame ) && LE_16( st->L_frame, L_FRAME16k ) && LE_16( st->last_L_frame, L_FRAME16k ) ) { + test(); IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) { lerp( st->hFdCngDec->hFdCngCom->olapBufferAna_fx + st->last_L_frame, st->hFdCngDec->hFdCngCom->olapBufferAna_fx + st->L_frame, st->L_frame, st->last_L_frame ); } - L_lerp_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->L_frame * 2, st->last_L_frame * 2, Q_olapBufferSynth2 ); + L_lerp_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ), Q_olapBufferSynth2 ); + test(); IF( LE_32( st->total_brate, SID_2k40 ) && LE_32( st->last_total_brate, SID_2k40 ) ) { - L_lerp_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, st->L_frame * 2, st->last_L_frame * 2, Q_olapBufferSynth ); + L_lerp_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ), Q_olapBufferSynth ); IF( EQ_16( st->L_frame, L_FRAME ) ) { FOR( i = 0; i < shl( st->L_frame, 1 ); i++ ) { st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i] = Mult_32_16( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i], (Word16) 20480 /* 0.6250f in Q15 */ ); + move32(); } } ELSE @@ -670,6 +736,7 @@ ivas_error core_switching_pre_dec_ivas_fx( FOR( i = 0; i < shl( st->L_frame, 1 ); i++ ) { st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i] = Mult_32_16( L_shl( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i], 1 ), (Word16) 26214 /* 1.6f in Q14 */ ); + move32(); } } } @@ -1682,6 +1749,8 @@ void bandwidth_switching_detect_ivas_fx( Decoder_State *st_fx /* i/o: encoder state structure */ ) { + test(); + test(); IF( ( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && EQ_16( st_fx->idchan, 1 ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) { /* there is no BWE in TD stereo secondary channel and in MDCT stereo, IGF is part of the core decoding -> no BW switching -> reset BWS counters */ @@ -1698,6 +1767,7 @@ void bandwidth_switching_detect_ivas_fx( test(); test(); test(); + test(); IF( GE_16( st_fx->bws_cnt1, N_NS2W_FRAMES ) ) { st_fx->bws_cnt1 = 0; @@ -1932,6 +2002,9 @@ void ivas_bw_switching_pre_proc_fx( return; } + test(); + test(); + test(); IF( EQ_16( st->core, ACELP_CORE ) && !( EQ_16( st->bfi, 1 ) && EQ_16( st->con_tcx, 1 ) ) ) { /*----------------------------------------------------------------------* @@ -1958,9 +2031,10 @@ void ivas_bw_switching_pre_proc_fx( tmp = getSqrtWord32( tmp ); st->enerLL_fx = tmp; - st->enerLL_fx_Q = ( Q + shift - 32 ) / 2; + st->enerLL_fx_Q = shr( sub( add( Q, shift ), 32 ), 1 ); W_tmp = 0; + move64(); FOR( ; i < L_FRAME; i++ ) { W_tmp = W_add( W_tmp, W_shr( W_mult0_32_32( syn_dct_fx[i], syn_dct_fx[i] ), Q ) ); @@ -1971,7 +2045,8 @@ void ivas_bw_switching_pre_proc_fx( tmp = L_shr( tmp, 7 ); // divide by 128 tmp = getSqrtWord32( tmp ); st->enerLH_fx = tmp; - st->enerLH_fx_Q = ( Q + shift - 32 ) / 2; + move32(); + st->enerLH_fx_Q = shr( sub( add( Q, shift ), 32 ), 1 ); } ELSE { @@ -1985,9 +2060,12 @@ void ivas_bw_switching_pre_proc_fx( tmp = L_shr( L_tmp, 5 ); // divide by 32 tmp = getSqrtWord32( tmp ); st->enerLL_fx = tmp; + move32(); st->enerLL_fx_Q = Q_audio; + move16(); L_tmp = 0; + move32(); FOR( ; i < 64; i++ ) { L_tmp = L_mac0_o( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i], &Overflow ); @@ -1996,12 +2074,15 @@ void ivas_bw_switching_pre_proc_fx( tmp = L_shr( L_tmp, 5 ); // divide by 32 tmp = getSqrtWord32( tmp ); st->enerLH_fx = tmp; + move32(); st->enerLH_fx_Q = Q_audio; + move16(); } ELSE { Word32 tmp, L_tmp = 0; L_tmp = 0; + move32(); FOR( i = 0; i < L_FRAME / 2; i++ ) { L_tmp = L_mac0_o( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i], &Overflow ); @@ -2009,9 +2090,12 @@ void ivas_bw_switching_pre_proc_fx( tmp = L_shr( L_tmp, 5 ); // divide by 32 tmp = getSqrtWord32( tmp ); st->enerLL_fx = tmp; + move32(); st->enerLL_fx_Q = Q_audio; + move16(); L_tmp = 0; + move32(); FOR( ; i < L_FRAME; i++ ) { L_tmp = L_mac0_o( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i], &Overflow ); @@ -2019,15 +2103,25 @@ void ivas_bw_switching_pre_proc_fx( tmp = L_shr( L_tmp, 5 ); // divide by 32 tmp = getSqrtWord32( tmp ); st->enerLL_fx = tmp; + move32(); st->enerLL_fx_Q = Q_audio; + move16(); } } + test(); + test(); + test(); + test(); + test(); + test(); + test(); IF( EQ_16( st->last_bwidth, 0 ) && LE_16( st->extl, SWB_CNG ) ) { // st->prev_ener_shb = 0.0f; st->prev_ener_shb_fx = 0; + move16(); IF( st->hBWE_FD != NULL ) { // set_f( st->hBWE_FD->prev_SWB_fenv, 0, SWB_FENV ); @@ -2037,12 +2131,18 @@ void ivas_bw_switching_pre_proc_fx( ELSE IF( ( ( EQ_16( st->core, ACELP_CORE ) && ( EQ_16( st->last_core, HQ_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) || EQ_16( st->last_core, TCX_20_CORE ) ) ) || ( EQ_16( st->core, st->last_core ) && NE_16( st->extl, st->last_extl ) ) ) && GE_16( st->last_bwidth, SWB ) ) { st->attenu_fx = 3277; + move16(); } + test(); + test(); + test(); + test(); + test(); IF( EQ_16( st->last_core, HQ_CORE ) || ( EQ_16( st->last_core, ACELP_CORE ) && !( EQ_16( st->last_extl, WB_TBE ) || EQ_16( st->last_extl, SWB_TBE ) || EQ_16( st->last_extl, FB_TBE ) ) && GT_32( st->core_brate, ACELP_8k00 ) ) ) { st->prev_fractive = 0; - st->prev_fractive = 0; + move16(); } return; diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 5cd563a2f..4f8854d7c 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -513,6 +513,9 @@ ivas_error core_switching_pre_dec_fx( hTcxDec = st_fx->hTcxDec; error = IVAS_ERR_OK; + test(); + test(); + test(); /* Codec switching */ IF( EQ_16( st_fx->last_codec_mode, MODE2 ) || ( ( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) ) && GT_16( st_fx->element_mode, EVS_MONO ) ) ) { @@ -555,6 +558,7 @@ ivas_error core_switching_pre_dec_fx( move16(); + test(); IF( hBWE_TD != NULL && NE_16( st_fx->last_core, ACELP_CORE ) ) { hBWE_TD->prev_hb_synth_fx_exp = 31; @@ -564,6 +568,7 @@ ivas_error core_switching_pre_dec_fx( hBWE_TD->bwe_non_lin_prev_scale_fx = L_deposit_l( 0 ); } + test(); IF( GE_32( st_fx->output_Fs, 16000 ) && st_fx->hBWE_zero != NULL ) { hf_synth_reset_fx( st_fx->hBWE_zero ); @@ -678,6 +683,9 @@ ivas_error core_switching_pre_dec_fx( cldfb_restore_memory( st_fx->cldfbSyn ); } + test(); + test(); + test(); IF( !st_fx->last_con_tcx && st_fx->last_core_bfi == ACELP_CORE && EQ_16( st_fx->core, HQ_CORE ) ) { lerp( hTcxDec->syn_Overl, hHQ_core->fer_samples_fx + delay_comp, shr( st_fx->output_frame_fx, 1 ), shr( st_fx->last_L_frame, 1 ) ); @@ -857,6 +865,7 @@ ivas_error core_switching_pre_dec_fx( /* reset TBE memories */ test(); + test(); IF( !st_fx->last_con_tcx && !( ( EQ_16( st_fx->last_core, HQ_CORE ) ) && GT_16( st_fx->element_mode, EVS_MONO ) ) ) { @@ -984,7 +993,7 @@ ivas_error core_switching_pre_dec_fx( /* handle switching cases where preecho_sb was not called in the last frame (memory not up to date) */ IF( hHQ_core != NULL ) { - hHQ_core->pastpre--; + hHQ_core->pastpre = sub( hHQ_core->pastpre, 1 ); IF( hHQ_core->pastpre <= 0 ) { reset_preecho_dec_fx( hHQ_core ); @@ -1420,7 +1429,7 @@ ivas_error core_switching_post_dec_fx( set16_fx( hBWE_FD->L_old_wtda_swb_fx, 0, output_frame ); test(); - if ( NE_16( st_fx->last_extl, SWB_BWE ) && NE_16( st_fx->last_extl, FB_BWE ) ) + IF( NE_16( st_fx->last_extl, SWB_BWE ) && NE_16( st_fx->last_extl, FB_BWE ) ) { hBWE_FD->prev_mode = NORMAL; move16(); @@ -1578,7 +1587,7 @@ ivas_error core_switching_post_dec_ivas_fx( delta = 1; move16(); - if ( GE_16( output_frame, L_FRAME16k ) ) + IF( GE_16( output_frame, L_FRAME16k ) ) { delta = shr( Fs_kHz, 3 ); } @@ -2015,7 +2024,7 @@ ivas_error core_switching_post_dec_ivas_fx( } /* reset TBE buffers */ - if ( hBWE_TD != NULL ) + IF( hBWE_TD != NULL ) { /* reset SWB TBE buffers */ test(); @@ -2143,13 +2152,13 @@ void core_switching_hq_prepare_dec_fx( IF( EQ_16( st_fx->last_L_frame, L_FRAME ) ) { cbrate = L_add( st_fx->core_brate, 0 ); - if ( GT_32( st_fx->core_brate, ACELP_24k40 ) ) + IF( GT_32( st_fx->core_brate, ACELP_24k40 ) ) { cbrate = L_add( ACELP_24k40, 0 ); } /* subtract ACELP switching frame bits */ - if ( GE_32( st_fx->core_brate, ACELP_11k60 ) ) + IF( GE_32( st_fx->core_brate, ACELP_11k60 ) ) { ( *num_bits ) = sub( ( *num_bits ), 1 ); /* LP_FLAG bit */ } @@ -2173,7 +2182,7 @@ void core_switching_hq_prepare_dec_fx( } /* subtract ACELP switching frame bits */ - if ( GE_32( st_fx->core_brate, ACELP_11k60 ) ) + IF( GE_32( st_fx->core_brate, ACELP_11k60 ) ) { ( *num_bits ) = sub( ( *num_bits ), 1 ); /* LP_FLAG bit */ } @@ -2298,31 +2307,36 @@ static void smoothTransitionDtxToTcx_fx( #endif filter_len = TRANSITION_SMOOTHING_LEN_16k; + move16(); IF( EQ_16( output_frame, L_FRAME32k ) ) { filter_len = TRANSITION_SMOOTHING_LEN_32k; + move16(); } ELSE IF( EQ_16( output_frame, L_FRAME48k ) ) { filter_len = TRANSITION_SMOOTHING_LEN_48k; + move16(); } /* prepare buffer */ FOR( i = 0; i < filter_len / 2; i++ ) { smoothing_input_buffer[i] = synth[0]; + move16(); } - Copy( synth, smoothing_input_buffer + filter_len / 2, add( shl( delay_comp, 1 ), shr( filter_len, 1 ) ) ); + Copy( synth, smoothing_input_buffer + shr( filter_len, 1 ), add( shl( delay_comp, 1 ), shr( filter_len, 1 ) ) ); /* apply Mean filter */ w = div_s( 1, filter_len ); mem = 0; + move32(); FOR( i = 0; i < filter_len; i++ ) { mem = L_add( mem, L_deposit_l( smoothing_input_buffer[i] ) ); } // mem = sum32_fx( smoothing_input_buffer, filter_len ); - FOR( i = 0; i < 2 * delay_comp; i++ ) + FOR( i = 0; i < shl( delay_comp, 1 ); i++ ) { smoothing_out_buffer[i] = extract_l( Mpy_32_16_1( mem, w ) ); move16(); @@ -2343,7 +2357,8 @@ static void smoothTransitionDtxToTcx_fx( } fade_in = 0; - FOR( ; i < 2 * delay_comp; i++ ) + move16(); + FOR( ; i < shl( delay_comp, 1 ); i++ ) { synth[i] = add( mult_r( synth[i], fade_in ), mult_r( smoothing_out_buffer[i], sub( ONE_IN_Q15 - 1, fade_in ) ) ); move16(); diff --git a/lib_dec/dec2t32_fx.c b/lib_dec/dec2t32_fx.c index 519d8ed87..e62814cc6 100644 --- a/lib_dec/dec2t32_fx.c +++ b/lib_dec/dec2t32_fx.c @@ -58,7 +58,7 @@ void dec_acelp_2t32_fx( code[i0] = -512; move16(); - if ( s_and( index, 0x800 ) == 0 ) + IF( s_and( index, 0x800 ) == 0 ) { code[i0] = 512; move16(); @@ -66,7 +66,7 @@ void dec_acelp_2t32_fx( code[i1] = -512; move16(); - if ( s_and( index, 0x20 ) == 0 ) + IF( s_and( index, 0x20 ) == 0 ) { code[i1] = 512; move16(); diff --git a/lib_dec/dec4t64_fx.c b/lib_dec/dec4t64_fx.c index 6186891de..882dd67f9 100644 --- a/lib_dec/dec4t64_fx.c +++ b/lib_dec/dec4t64_fx.c @@ -180,6 +180,7 @@ void dec_acelp_4t64_fx( FOR( k = 0; k < NB_TRACK_FCB_4T; k++ ) { ind1[k] = get_next_indice( st_fx, 2 ); + move32(); } FOR( k = 0; k < NB_TRACK_FCB_4T; k++ ) { @@ -194,10 +195,12 @@ void dec_acelp_4t64_fx( FOR( k = 0; k < NB_TRACK_FCB_4T - 2; k++ ) { ind1[k] = get_next_indice( st_fx, 10 ); + move32(); } FOR( k = 2; k < NB_TRACK_FCB_4T; k++ ) { ind1[k] = get_next_indice( st_fx, 2 ); + move32(); } FOR( k = 0; k < NB_TRACK_FCB_4T - 2; k++ ) { @@ -255,7 +258,7 @@ static void add_pulses_fx( { /* i = ((pos[k] & (NB_POS-1))*NB_TRACK) + track */ logic16(); - i = shl( (Word16) ( pos[k] & ( NB_POS_FCB_4T - 1 ) ), 2 ); + i = shl( s_and( pos[k], ( NB_POS_FCB_4T - 1 ) ), 2 ); logic16(); IF( ( pos[k] & NB_POS_FCB_4T ) == 0 ) @@ -296,7 +299,7 @@ void dec_1p_N1_fx( /* i = ((index >> N) & 1); */ i = L_shr( index, N ) & 1L; - if ( i != 0 ) + IF ( i != 0 ) { pos1 = add( pos1, NB_POS_FCB_4T ); } @@ -557,7 +560,7 @@ static void dec_6p_6N2_fx( offsetA = offsetB = j; move16(); logic16(); - IF( ( L_shr( index, sub( n_6, 5 ) ) & 1L ) == 0 ) + IF( L_and( L_shr( index, sub( n_6, 5 ) ), 1L ) == 0 ) { /* IF (((index >> ((6*N)-5)) & 1) == 0) */ offsetA = offset; @@ -649,7 +652,7 @@ IF( ( LT_16( pulse_pos_num, pulse_num ) ) && ( GT_16( pulse_pos_num, 1 ) ) ) sector_6p_num[i] = 1; move16(); } - sector_6p_num[k]++; + sector_6p_num[k] = add( sector_6p_num[k], 1 ); move16(); } ELSE{ @@ -690,20 +693,23 @@ static void fcb_decode_position_fx( FOR( i = 0; i < pos_num - 1; i++ ) { /* k = PI_select_table[16-l][temp] - k ;*/ - k = L_sub( PI_select_table[16 - l][temp], k ); + k = L_sub( PI_select_table[L_sub( 16, l )][temp], k ); - FOR( ; PI_select_table[16 - l][temp] >= k; l += 2 ); + FOR( ; PI_select_table[L_sub( 16, l )][temp] >= k; l += 2 ); - if ( GT_32( k, PI_select_table[L_sub( 17, l )][temp] ) ) + IF ( GT_32( k, PI_select_table[L_sub( 17, l )][temp] ) ) { l = L_sub( l, 1 ); } /* k = PI_select_table[17-l][temp--] - k ;*/ - k = L_sub( PI_select_table[L_sub( 17, l )][temp--], k ); + k = L_sub( PI_select_table[L_sub( 17, l )][temp], k ); + temp = sub( temp, 1 ); pos_vector[i] = extract_l( L_sub( l, 1 ) ); + move16(); } pos_vector[i] = extract_l( L_add( l, k ) ); + move16(); return; } @@ -768,10 +774,12 @@ void D_ACELP_decode_43bit_fx( UWord16 idxs[], Word16 code[], Word16 *pulsestrack set16_fx( code, 0, L_SUBFR ); ps[3] = L_deposit_l( s_and( idxs[0], 0x1ff ) ); + move32(); ps[2] = L_add( L_shl( s_and( idxs[1], 3 ), 7 ), L_shr( idxs[0], 9 ) ); + move32(); joint_index = L_shr( L_add( L_shl( (Word32) idxs[2], 16 ), (Word32) idxs[1] ), 2 ); - if ( GE_32( joint_index, joint_offset ) ) + IF ( GE_32( joint_index, joint_offset ) ) { joint_index = L_sub( joint_index, joint_offset ); } @@ -1052,6 +1060,7 @@ static void dec_1p_N1_L_subfr_fx( } pos[0] = pos1; + move16(); return; } @@ -1070,15 +1079,16 @@ static void add_pulses_L_subfr_fx( FOR( k = 0; k < nb_pulse; k++ ) { - i = shl( ( pos[k] & ( nb_pos - 1 ) ), 2 ); - IF( EQ_16( ( pos[k] & nb_pos ), 0 ) ) + i = shl( s_and( pos[k], sub( nb_pos, 1 ) ), 2 ); + IF( EQ_16( sub( pos[k], nb_pos ), 0 ) ) { - ptr[i] = add( ptr[i], 512 ); + move16(); } ELSE { ptr[i] = sub( ptr[i], 512 ); + move16(); } } @@ -1097,6 +1107,7 @@ void dec_acelp_fast_fx( PulseConfig config; skip_track = -1; + move16(); set16_fx( code, 0, L_subfr ); st->total_num_bits = extract_l( st->total_brate / FRAMES_PER_SEC ); @@ -1151,10 +1162,12 @@ void dec_acelp_fast_fx( IF( EQ_16( config.bits, 20 ) ) { skip_track = -1; + move16(); } ELSE IF( EQ_16( (Word16) config.codetrackpos, (Word16) TRACKPOS_FIXED_FIRST ) ) { skip_track = 0; + move16(); } ELSE IF( EQ_16( (Word16) config.codetrackpos, (Word16) TRACKPOS_FREE_ONE ) ) { @@ -1181,6 +1194,7 @@ void dec_acelp_fast_fx( ELSE /* L_subfr == 2*L_SUBFR */ { config.bits = cdk_index; + move16(); IF( EQ_16( cdk_index, 14 ) ) { @@ -1190,19 +1204,23 @@ void dec_acelp_fast_fx( index = get_next_indice_fx( st, 14 ); - i0 = shl( shr( index, 7 ) & ( NB_POS_FCB_2T_128 - 1 ), 1 ); - i1 = add( shl( index & ( NB_POS_FCB_2T_128 - 1 ), 1 ), 1 ); + i0 = shl( s_and( shr( index, 7 ), ( NB_POS_FCB_2T_128 - 1 ) ), 1 ); + i1 = add( shl( s_and( index, ( NB_POS_FCB_2T_128 - 1 ) ), 1 ), 1 ); code[i0] = -512; - IF( EQ_16( ( index & 0x2000 ), 0 ) ) + move16(); + IF( EQ_16( s_and( index, 0x2000 ), 0 ) ) { code[i0] = 512; + move16(); } code[i1] = -512; - IF( EQ_16( ( index & 0x40 ), 0 ) ) + move16(); + IF( EQ_16( s_and( index, 0x40 ), 0 ) ) { code[i1] = 512; + move16(); } } ELSE IF( EQ_16( cdk_index, 12 ) ) diff --git a/lib_dec/dec_ace_fx.c b/lib_dec/dec_ace_fx.c index 0f623af53..8764b1d2a 100644 --- a/lib_dec/dec_ace_fx.c +++ b/lib_dec/dec_ace_fx.c @@ -140,7 +140,7 @@ void decoder_acelp_fx( move16(); test(); test(); - if ( st->last_con_tcx && ( NE_16( st->L_frameTCX_past, st->L_frame ) ) && ( st->last_core != 0 ) ) + IF( st->last_con_tcx && ( NE_16( st->L_frameTCX_past, st->L_frame ) ) && ( st->last_core != 0 ) ) { avoid_lpc_burst_on_recovery = 1; move16(); @@ -153,7 +153,7 @@ void decoder_acelp_fx( /* Reset phase dispersion */ - IF( st->last_core_bfi > ACELP_CORE ) + IF( GT_16( st->last_core_bfi, ACELP_CORE ) ) { st->dm_fx.prev_gain_code = L_deposit_l( 0 ); set16_fx( st->dm_fx.prev_gain_pit, 0, 6 ); @@ -169,6 +169,7 @@ void decoder_acelp_fx( synth_mem_updt2( st->L_frame, L_FRAME16k, st->old_exc_fx, st->mem_syn_r, st->mem_syn2_fx, NULL, DEC ); } + test(); IF( st->last_con_tcx && st->old_enr_LP ) { Word16 enr_LP, ratio; @@ -184,6 +185,7 @@ void decoder_acelp_fx( FOR( i = 0; i < L_EXC_MEM_DEC; i++ ) { st->old_exc_fx[i] = mult_r( st->old_exc_fx[i], ratio ); + move16(); } } } @@ -211,7 +213,7 @@ void decoder_acelp_fx( * Fast recovery flag *------------------------------------------------------------------------*/ test(); - if ( st->prev_bfi && EQ_16( st->coder_type, VOICED ) ) + IF( st->prev_bfi && EQ_16( st->coder_type, VOICED ) ) { /*Force BPF to be applied fully*/ st->bpf_gain_param = 3; @@ -252,6 +254,12 @@ void decoder_acelp_fx( FOR( i_subfr = 0; i_subfr < st->L_frame; i_subfr += L_SUBFR ) { + Word16 idx = 0; + IF( i_subfr != 0 ) + { + idx = idiv1616( i_subfr, L_SUBFR ); + } + test(); IF( EQ_16( st->use_partial_copy, 1 ) && EQ_16( st->rf_frame_type, RF_NELP ) ) { @@ -270,16 +278,18 @@ void decoder_acelp_fx( *-------------------------------------------------------*/ test(); - IF( EQ_16( st->use_partial_copy, 1 ) && st->acelp_cfg.gains_mode[i_subfr / L_SUBFR] == 0 ) + IF( EQ_16( st->use_partial_copy, 1 ) && st->acelp_cfg.gains_mode[idx] == 0 ) { gain_pit = prev_gain_pit; + move16(); } IF( acelp_cfg.ltp_bits != 0 ) { /* pitch lag decoding */ - pitch_buf[i_subfr / L_SUBFR] = Mode2_pit_decode( acelp_cfg.ltp_mode, i_subfr, L_SUBFR, &prm, &T0, &T0_frac, &T0_res, - &T0_min, &T0_min_frac, &T0_max, &T0_max_frac, st->pit_min, st->pit_fr1, st->pit_fr1b, st->pit_fr2, st->pit_max, st->pit_res_max ); + pitch_buf[idx] = Mode2_pit_decode( acelp_cfg.ltp_mode, i_subfr, L_SUBFR, &prm, &T0, &T0_frac, &T0_res, + &T0_min, &T0_min_frac, &T0_max, &T0_max_frac, st->pit_min, st->pit_fr1, st->pit_fr1b, st->pit_fr2, st->pit_max, st->pit_res_max ); + move32(); /* find pitch excitation */ test(); IF( EQ_16( st->pit_res_max, 6 ) && !( st->use_partial_copy ) ) @@ -324,9 +334,13 @@ void decoder_acelp_fx( set16_fx( &exc[i_subfr], 0, L_SUBFR ); T0 = L_SUBFR; + move16(); T0_frac = 0; + move16(); T0_res = 1; - pitch_buf[i_subfr / L_SUBFR] = L_deposit_h( L_SUBFR ); + move16(); + pitch_buf[idx] = L_deposit_h( L_SUBFR ); + move32(); } IF( st->igf != 0 ) @@ -334,7 +348,8 @@ void decoder_acelp_fx( tbe_celp_exc( st->L_frame, i_subfr, T0, T0_frac, &error, bwe_exc ); } - pitch_buffer[i_subfr / L_SUBFR] = shl( add( shl( T0, 2 ), T0_frac ), 4 ); + pitch_buffer[idx] = shl( add( shl( T0, 2 ), T0_frac ), 4 ); + move16(); /*-------------------------------------------------------* * - Decode innovative codebook. * @@ -352,7 +367,7 @@ void decoder_acelp_fx( } ELSE { - config = PulseConfTable[acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR]]; + config = PulseConfTable[acelp_cfg.fixed_cdk_index[idx]]; D_ACELP_indexing_fx( code, config, NB_TRACK_FCB_4T, prm, &st->BER_detect ); ( prm ) += 8; /*-------------------------------------------------------* @@ -366,7 +381,7 @@ void decoder_acelp_fx( * - Generate Gaussian excitation * *-------------------------------------------------------*/ test(); - IF( EQ_16( acelp_cfg.gains_mode[i_subfr / L_SUBFR], 7 ) && !st->use_partial_copy ) + IF( EQ_16( acelp_cfg.gains_mode[idx], 7 ) && !st->use_partial_copy ) { gaus_L2_dec( code2, st->tilt_code_fx, p_A, acelp_cfg.formant_enh_num, &( st->seed_acelp ) ); } @@ -379,18 +394,20 @@ void decoder_acelp_fx( /*-------------------------------------------------* * - Decode codebooks gains. * *-------------------------------------------------*/ - IF( st->acelp_cfg.gains_mode[i_subfr / L_SUBFR] != 0 ) + IF( st->acelp_cfg.gains_mode[idx] != 0 ) { - decode_acelp_gains_fx( code, acelp_cfg.gains_mode[i_subfr / L_SUBFR], Es_pred, &gain_pit, &gain_code, &prm, &( st->past_gpit ), + decode_acelp_gains_fx( code, acelp_cfg.gains_mode[idx], Es_pred, &gain_pit, &gain_code, &prm, &( st->past_gpit ), &( st->past_gcode ), &gain_inov, L_SUBFR, code2, &gain_code2 ); } IF( st->use_partial_copy && st->rf_frame_type == RF_ALLPRED ) { st->past_gcode = 0; + move32(); } IF( st->use_partial_copy && st->rf_frame_type == RF_NOPRED ) { st->past_gpit = 67; + move32(); } IF( st->igf != 0 ) { @@ -400,12 +417,14 @@ void decoder_acelp_fx( /* 5/2 times resampled past memories*/ reScaleLen_fx = add( shl( i_subfr, 1 ), shr( i_subfr, 1 ) ); reSampLen = ( L_SUBFR * HIBND_ACB_L_FAC ); + move16(); } ELSE { /* 2 times resampled past memories*/ reScaleLen_fx = shl( i_subfr, 1 ); reSampLen = ( L_SUBFR * 2 ); + move16(); } Rescale_exc( NULL, &exc[i_subfr], &bwe_exc[reScaleLen_fx], @@ -424,7 +443,7 @@ void decoder_acelp_fx( *----------------------------------------------------------*/ E_UTIL_voice_factor( exc, i_subfr, code, gain_pit, gain_code, &( st->voice_fac ), &( st->tilt_code_fx ), L_SUBFR, acelp_cfg.voice_tilt, st->Q_exc, 0 ); - pgainT[i_subfr / L_SUBFR] = gain_pit; + pgainT[idx] = gain_pit; move16(); /*-------------------------------------------------------* @@ -449,7 +468,9 @@ void decoder_acelp_fx( } } gain_code_pre = gain_code; - st->tilt_code_dec_fx[i_subfr / L_SUBFR] = st->tilt_code_fx; + move32(); + st->tilt_code_dec_fx[idx] = st->tilt_code_fx; + move16(); tmp2 = shr( L_SUBFR, 1 ); @@ -462,7 +483,7 @@ void decoder_acelp_fx( 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 ) ); + exc2[add( i, i_subfr )] = round_fx_sat( L_shl_sat( Ltmp, 1 ) ); #else exc2[i + i_subfr] = round_fx( L_shl( Ltmp, 1 ) ); #endif @@ -477,7 +498,7 @@ void decoder_acelp_fx( #endif BASOP_SATURATE_WARNING_ON_EVS #ifdef BASOP_NOGLOB - exc[i + i_subfr] = round_fx_sat( Ltmp ); + exc[add( i, i_subfr )] = round_fx_sat( Ltmp ); #else exc[i + i_subfr] = round_fx( Ltmp ); #endif @@ -490,14 +511,16 @@ void decoder_acelp_fx( * Prepare TBE excitation *-----------------------------------------------------------------*/ gain_code = gain_code_tmp; + move32(); gain_pit = gain_pit_tmp; + move16(); IF( st->igf != 0 ) { prep_tbe_exc_fx( st->L_frame, #ifdef ADD_IVAS_TBE_CODE L_SUBFR, #endif - i_subfr, gain_pit, gain_code, code, st->voice_fac, &voice_factors[i_subfr / L_SUBFR], bwe_exc, + i_subfr, gain_pit, gain_code, code, st->voice_fac, &voice_factors[idx], bwe_exc, gain_preQ, code_preQ, st->Q_exc, T0, T0_frac, st->coder_type, st->core_brate #ifdef ADD_IVAS_TBE_CODE , @@ -511,7 +534,7 @@ void decoder_acelp_fx( *---------------------------------------------------------*/ E_UTIL_enhancer( st->voice_fac, stab_fac, st->past_gcode, gain_inov, &( st->gc_threshold_fx ), code, &exc2[i_subfr], gain_pit, &st->dm_fx.prev_gain_code, st->dm_fx.prev_gain_pit, &st->dm_fx.prev_state, st->coder_type, - acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR], L_SUBFR, st->L_frame, st->Q_exc ); + acelp_cfg.fixed_cdk_index[idx], L_SUBFR, st->L_frame, st->Q_exc ); } /* !RF_NELP frame partial copy */ /*----------------------------------------------------------* @@ -525,16 +548,16 @@ void decoder_acelp_fx( * update lp_filtered gains for the case of frame erasure *-----------------------------------------------------------------*/ - st->Mode2_lp_gainp = L_add( st->Mode2_lp_gainp, L_mult0( st->past_gpit, weights[i_subfr / L_SUBFR] ) ); /* 2Q29=1Q14*Q15 */ + st->Mode2_lp_gainp = L_add( st->Mode2_lp_gainp, L_mult0( st->past_gpit, weights[idx] ) ); /* 2Q29=1Q14*Q15 */ move32(); - st->Mode2_lp_gainc = L_add( st->Mode2_lp_gainc, Mpy_32_16_1( st->past_gcode, weights[i_subfr / L_SUBFR] ) ); /* 15Q16=15Q16*Q15 */ + st->Mode2_lp_gainc = L_add( st->Mode2_lp_gainc, Mpy_32_16_1( st->past_gcode, weights[idx] ) ); /* 15Q16=15Q16*Q15 */ move32(); /*----------------------------------------------------------* * - update pitch lag for guided ACELP * *----------------------------------------------------------*/ test(); - if ( st->enableGplc && EQ_16( shr( i_subfr, 6 ), sub( st->nb_subfr, 1 ) ) ) + IF( st->enableGplc && EQ_16( shr( i_subfr, 6 ), sub( st->nb_subfr, 1 ) ) ) { st->T0_4th = T0; move16(); @@ -547,6 +570,7 @@ void decoder_acelp_fx( /* copy current gain for next subframe use, in case there is no explicit encoding */ prev_gain_pit = gain_pit; + move16(); } /* end of subframe loop */ IF( st->BER_detect ) @@ -560,7 +584,7 @@ void decoder_acelp_fx( int_lsp_fx( st->L_frame, st->old_lsp_q_cng, st->lsp_q_cng, st->Aq_cng, M, interpol_frac_fx, 0 ); p_A = st->Aq_cng; - IF( st->last_good < UNVOICED_TRANSITION ) + IF( LT_16( st->last_good, UNVOICED_TRANSITION ) ) { Copy( st->mem_syn2_fx, mem_syn, M ); } @@ -601,6 +625,7 @@ void decoder_acelp_fx( FOR( k = 0; k < st->nb_subfr; k++ ) { pit16[k] = shl( extract_h( pitch_buf[k] ), 6 ); /*Q6*/ + move16(); } FEC_clas_estim_fx( st, /*Opt_AMR_WB*/ 0, st->L_frame, &( st->clas_dec ), st->core_ext_mode, pit16, syn, @@ -617,10 +642,16 @@ void decoder_acelp_fx( { Word16 pBuf_scaleSyn[NB_SUBFR16k]; + Word16 L_frame_fr = 0; + IF( st->L_frame != 0 ) + { + L_frame_fr = idiv1616( st->L_frame, L_SUBFR ); + } - FOR( i = 0; i < ( st->L_frame / L_SUBFR ); i++ ) + FOR( i = 0; i < L_frame_fr; i++ ) { pBuf_scaleSyn[i] = round_fx( pitch_buf[i] ); + move16(); } Scale_sig( mem_back, M, sub( st->Q_syn, Q_mem_back ) ); @@ -649,9 +680,9 @@ void decoder_acelp_fx( move16(); E_UTIL_deemph2( st->Q_syn, syn, st->preemph_fac, st->L_frame, &tmp_deemph ); /* tmp_deemph and syn in Q0 starting from here*/ - bufferCopyFx( syn + st->L_frame - st->L_frame / 2, hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), 0 /*Qf_syn*/, -1 /*Qf_old_xnq*/, 0, 0 /*Q_old_xnq*/ ); + bufferCopyFx( syn + shr( st->L_frame, 1 ), hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), 0 /*Qf_syn*/, -1 /*Qf_old_xnq*/, 0, 0 /*Q_old_xnq*/ ); - Copy( syn + st->L_frame - M - 1, st->syn, 1 + M ); /*Q0*/ + Copy( syn + sub( st->L_frame, M + 1 ), st->syn, 1 + M ); /*Q0*/ Copy( syn, synth, st->L_frame ); IF( st->hBWE_TD != NULL ) @@ -666,19 +697,26 @@ void decoder_acelp_fx( /* Output pitch parameters for bass post-filter */ FOR( i_subfr = 0; i_subfr < st->L_frame; i_subfr += L_SUBFR ) { - *pT++ = round_fx( pitch_buf[i_subfr / L_SUBFR] ); + Word16 idx = 0; + IF( i_subfr != 0 ) + { + idx = idiv1616( i_subfr, L_SUBFR ); + } + *pT++ = round_fx( pitch_buf[idx] ); } hTcxDec->tcxltp_last_gain_unmodified = 0; + move16(); /*Update MODE1*/ Copy( p_A - ( M + 1 ), st->old_Aq_12_8_fx, M + 1 ); st->old_Es_pred_fx = Es_pred; + move16(); hTcxDec->tcxltp_third_last_pitch = hTcxDec->tcxltp_second_last_pitch; hTcxDec->tcxltp_second_last_pitch = st->old_fpitch; - st->old_fpitch = pitch_buf[shr( st->L_frame, 6 ) - 1]; + st->old_fpitch = pitch_buf[sub( shr( st->L_frame, 6 ), 1 )]; move32(); diff --git a/lib_dec/dec_acelp_fx.c b/lib_dec/dec_acelp_fx.c index d2bcffb6c..b560f7bea 100644 --- a/lib_dec/dec_acelp_fx.c +++ b/lib_dec/dec_acelp_fx.c @@ -38,7 +38,7 @@ void D_ACELP_indexing_fx( UWord32 idxs32[4], index_n[NB_TRACK_FCB_4T]; Word16 restpulses, wordcnt, wordcnt32; - assert( num_tracks == NB_TRACK_FCB_4T ); + assert( EQ_16( num_tracks, NB_TRACK_FCB_4T ) ); wordcnt = shr( add( config.bits, 15 ), 4 ); /* ceil(bits/16) */ @@ -210,21 +210,21 @@ static void D_ACELP_decode_arithtrack_fx( Word16 v[], Word32 s, Word16 p, Word16 FOR( ; p; p-- ) /* one pulse placed, so one less left */ { - IF( LT_32( s, pulsestostates[k][p - 1] ) ) + IF( LT_32( s, pulsestostates[k][sub( p, 1 )] ) ) { BREAK; } - s = L_sub( s, pulsestostates[k][p - 1] ); + s = L_sub( s, pulsestostates[k][sub( p, 1 )] ); IF( v[idx] != 0 ) /* there is a pulse here already = sign is known */ { - if ( v[idx] > 0 ) + IF( v[idx] > 0 ) { v[idx] = add( v[idx], _1_CODE ); /* place one more pulse here */ move16(); } - if ( v[idx] <= 0 ) + IF( v[idx] <= 0 ) { v[idx] = sub( v[idx], _1_CODE ); /* place one more pulse here */ move16(); @@ -234,7 +234,7 @@ static void D_ACELP_decode_arithtrack_fx( Word16 v[], Word32 s, Word16 p, Word16 { v[idx] = +_1_CODE; /* place a negative pulse here */ move16(); - if ( L_and( s, 0x1 ) != 0 ) + IF( L_and( s, 0x1 ) != 0 ) { v[idx] = -_1_CODE; /* place a negative pulse here */ move16(); @@ -272,7 +272,7 @@ void fcb_pulse_track_joint_decode_fx( UWord16 *idxs, Word16 wordcnt, UWord32 *in hi_to_low[4] = 1; move16(); - if ( GE_16( indx_flag, track_num ) ) + IF( GE_16( indx_flag, track_num ) ) { hi_to_low[4] = 9; move16(); @@ -280,7 +280,7 @@ void fcb_pulse_track_joint_decode_fx( UWord16 *idxs, Word16 wordcnt, UWord32 *in hi_to_low[7] = 1; move16(); - if ( GE_16( indx_flag_2, 1 ) ) + IF( GE_16( indx_flag_2, 1 ) ) { hi_to_low[7] = 9; move16(); @@ -308,7 +308,7 @@ void fcb_pulse_track_joint_decode_fx( UWord16 *idxs, Word16 wordcnt, UWord32 *in } ELSE { - FOR( track = ( wordcnt - 1 ); track >= track_num; track-- ) + FOR( track = sub( wordcnt, 1 ); track >= track_num; track-- ) { index = L_add( L_lshl( index, 16 ), (UWord32) idxs[track] ); } @@ -322,7 +322,7 @@ void fcb_pulse_track_joint_decode_fx( UWord16 *idxs, Word16 wordcnt, UWord32 *in ELSE { index = L_deposit_l( 0 ); - FOR( track = ( wordcnt - 1 ); track >= 2; track-- ) + FOR( track = sub( wordcnt, 1 ); track >= 2; track-- ) { index = L_add( L_lshl( index, 16 ), (UWord32) idxs[track] ); } @@ -362,7 +362,7 @@ void fcb_pulse_track_joint_decode_fx( UWord16 *idxs, Word16 wordcnt, UWord32 *in ELSE { index = L_deposit_l( 0 ); - FOR( track = ( wordcnt - 1 ); track >= 0; track-- ) + FOR( track = sub( wordcnt, 1 ); track >= 0; track-- ) { index = L_add( L_lshl( index, 16 ), (UWord32) idxs[track] ); } diff --git a/lib_dec/dec_acelp_tcx_main_fx.c b/lib_dec/dec_acelp_tcx_main_fx.c index 7976b2763..93eb4605f 100644 --- a/lib_dec/dec_acelp_tcx_main_fx.c +++ b/lib_dec/dec_acelp_tcx_main_fx.c @@ -30,7 +30,7 @@ static void decode_frame_type_fx( Decoder_State *st frame_size_index = 0; move16(); total_brate = st->total_brate; - move16(); + move32(); Mpy_32_16_ss( st->total_brate, 5243, &L_tmp, &lsb ); /* 5243 is 1/50 in Q18. (0+18-15=3) */ num_bits = extract_l( L_shr( L_tmp, 3 ) ); /* Q0 */ @@ -69,9 +69,10 @@ static void decode_frame_type_fx( Decoder_State *st ELSE IF( EQ_32( st->total_brate, SID_2k40 ) ) { st->cng_type = get_next_indice( st, 1 ); - if ( NE_16( st->cng_type, FD_CNG ) ) + IF( NE_16( st->cng_type, FD_CNG ) ) { st->BER_detect = 1; + move16(); } st->m_frame_type = SID_FRAME; move16(); @@ -83,7 +84,7 @@ static void decode_frame_type_fx( Decoder_State *st frame_len_indicator = get_next_indice( st, 1 ); IF( EQ_16( st->bwidth, NB ) ) { - if ( frame_len_indicator ) + IF( frame_len_indicator ) { st->BER_detect = 1; move16(); @@ -94,18 +95,24 @@ static void decode_frame_type_fx( Decoder_State *st IF( frame_len_indicator == 0 ) { st->L_frame = L_FRAME; + move16(); st->total_brate = ACELP_9k60; + move32(); } ELSE { st->L_frame = L_FRAME16k; + move16(); + test(); IF( st->last_total_brate == ACELP_16k40 || st->last_total_brate == ACELP_24k40 ) { st->total_brate = st->last_total_brate; + move32(); } ELSE { st->total_brate = ACELP_16k40; + move32(); } } @@ -151,7 +158,7 @@ static void decode_frame_type_fx( Decoder_State *st } ELSE { - st->bwidth += FrameSizeConfig[frame_size_index].bandwidth_min; + st->bwidth = add( st->bwidth, FrameSizeConfig[frame_size_index].bandwidth_min ); } IF( GT_16( st->bwidth, FB ) ) @@ -172,12 +179,13 @@ static void decode_frame_type_fx( Decoder_State *st } /* Get reserved bits */ + test(); IF( FrameSizeConfig[frame_size_index].reserved_bits && st->rf_flag == 0 ) { Word16 dummyBit; dummyBit = (Word8) get_next_indice( st, 1 ); move16(); - if ( dummyBit != 0 ) + IF( dummyBit != 0 ) { st->BER_detect = 1; move16(); @@ -190,7 +198,8 @@ static void decode_frame_type_fx( Decoder_State *st st->rate_switching_init = 0; move16(); - if ( st->last_codec_mode != MODE2 || !st->BER_detect ) + test(); + IF( NE_16( st->last_codec_mode, MODE2 ) || !st->BER_detect ) { /* Mode or Rate Change */ test(); @@ -225,13 +234,14 @@ static void decode_frame_type_fx( Decoder_State *st ELSE { st->cldfbSyn->bandsToZero = 0; + move16(); } /* Reconf FD-CNG */ L_tmp = st->total_brate; move32(); test(); - if ( EQ_16( st->rf_flag, 1 ) && EQ_32( st->total_brate, ACELP_13k20 ) ) + IF( EQ_16( st->rf_flag, 1 ) && EQ_32( st->total_brate, ACELP_13k20 ) ) { L_tmp = ACELP_9k60; move32(); @@ -251,16 +261,18 @@ static void decode_frame_type_fx( Decoder_State *st #endif IF( EQ_16( st->L_frame, L_FRAME ) ) { - FOR( n = 0; n < st->L_frame * 2; n++ ) + FOR( n = 0; n < shl( st->L_frame, 1 ); n++ ) { st->hFdCngDec->hFdCngCom->olapBufferSynth[n] = mult_r( st->hFdCngDec->hFdCngCom->olapBufferSynth[n], 20480 ); + move16(); } } ELSE { - FOR( n = 0; n < st->L_frame * 2; n++ ) + FOR( n = 0; n < shl( st->L_frame, 1 ); n++ ) { st->hFdCngDec->hFdCngCom->olapBufferSynth[n] = mult_r( shl( st->hFdCngDec->hFdCngCom->olapBufferSynth[n], 1 ), 26214 ); + move16(); } } } @@ -268,7 +280,9 @@ static void decode_frame_type_fx( Decoder_State *st IF( NE_16( st->bwidth, st->last_bwidth ) ) { st->hFdCngDec->hFdCngCom->msFrCnt_init_counter = 0; + move16(); st->hFdCngDec->hFdCngCom->init_old = 32767; + move16(); } /* Reconf BPF */ @@ -281,6 +295,7 @@ static void decode_frame_type_fx( Decoder_State *st } st->total_brate = total_brate; + move32(); } @@ -323,7 +338,7 @@ Word16 dec_acelp_tcx_frame_fx( start_bit_pos = st->next_bit_pos; move16(); - if ( EQ_16( st->rf_flag, 1 ) ) + IF( EQ_16( st->rf_flag, 1 ) ) { start_bit_pos = sub( start_bit_pos, 2 ); } @@ -351,6 +366,7 @@ Word16 dec_acelp_tcx_frame_fx( ); st->force_lpd_reset = 0; + move16(); test(); test(); @@ -368,7 +384,7 @@ Word16 dec_acelp_tcx_frame_fx( move16(); st->L_frame = L_frame; move16(); - if ( st->ini_frame != 0 ) + IF( st->ini_frame != 0 ) { st->total_brate = total_brate; move32(); @@ -393,6 +409,7 @@ Word16 dec_acelp_tcx_frame_fx( move32(); st->bfi = 1; move16(); + test(); IF( st->ini_frame == 0 && st->hTcxCfg != NULL ) { st->hTcxCfg->tcx_coded_lines = getNumTcxCodedLines( SWB ); @@ -413,10 +430,10 @@ Word16 dec_acelp_tcx_frame_fx( FOR( i = 0; i < 8 * 2; i++ ) { st->bit_stream[i] = 0; + move16(); } } - IF( s_and( (Word16) NE_16( st->m_frame_type, SID_FRAME ), (Word16) NE_16( st->m_frame_type, ZERO_FRAME ) ) ) /* test */ { @@ -457,15 +474,16 @@ Word16 dec_acelp_tcx_frame_fx( decoder_LPD_fx( pcmBuf, pcmbufFB, NULL, st, bpf_noise_buf, 1, &bitsRead, NULL, pitch_buf, voice_factors, ptr_bwe_exc ); } - test(); - test(); - test(); - test(); - if ( st->hBWE_TD != NULL ) + IF( st->hBWE_TD != NULL ) { + test(); + test(); + test(); + test(); IF( ( st->bfi == 0 && ( EQ_16( st->prev_bfi, 1 ) || EQ_16( st->prev_use_partial_copy, 1 ) ) ) || ( ( EQ_16( st->last_vbr_hw_BWE_disable_dec, 1 ) ) && ( st->vbr_hw_BWE_disable_dec == 0 ) ) ) { hBWE_TD->bwe_non_lin_prev_scale_fx = 0; + move32(); set16_fx( hBWE_TD->old_bwe_exc_extended_fx, 0, NL_BUFF_OFFSET ); } @@ -495,20 +513,20 @@ Word16 dec_acelp_tcx_frame_fx( -1 as flag-bit not considered in rf_target_bits */ IF( EQ_16( st->rf_flag, 1 ) ) { - get_next_indice_tmp_fx( st, start_bit_pos + num_bits - st->rf_target_bits - 3 - get_tbe_bits_fx( st->total_brate, st->bwidth, st->rf_flag ) - st->next_bit_pos ); + get_next_indice_tmp_fx( st, sub( sub( sub( sub( add( start_bit_pos, num_bits ), st->rf_target_bits ), 3 ), get_tbe_bits_fx( st->total_brate, st->bwidth, st->rf_flag ) ), st->next_bit_pos ) ); } ELSE { - get_next_indice_tmp_fx( st, start_bit_pos + num_bits - st->rf_target_bits - get_tbe_bits_fx( st->total_brate, st->bwidth, st->rf_flag ) - st->next_bit_pos ); + get_next_indice_tmp_fx( st, sub( sub( sub( add( start_bit_pos, num_bits ), st->rf_target_bits ), get_tbe_bits_fx( st->total_brate, st->bwidth, st->rf_flag ) ), st->next_bit_pos ) ); } tbe_read_bitstream_fx( st ); } /* updates */ st->last_voice_factor_fx = voice_factors[st->nb_subfr - 1]; - ; move16(); st->last_coder_type = st->coder_type; + move16(); } ELSE { diff --git a/lib_dec/dec_amr_wb_fx.c b/lib_dec/dec_amr_wb_fx.c index 6c0a668d2..9682b152b 100644 --- a/lib_dec/dec_amr_wb_fx.c +++ b/lib_dec/dec_amr_wb_fx.c @@ -140,14 +140,21 @@ void decod_amr_wb_fx( L_tmp = L_mac( L_tmp, VF_1st_PARAM_FX, voice_fac_fx ); voice_fac_fx = mac_r( L_tmp, VF_0th_PARAM_FX, 32767 ); + Word16 idx = 0; + IF( i_subfr != 0 ) + { + idx = idiv1616( i_subfr, L_SUBFR ); + } + /*voice_factors[i_subfr/L_SUBFR] = min( max(0.0f, voice_fac), 1.0f);*/ - voice_factors_fx[i_subfr / L_SUBFR] = s_min( s_max( 0, voice_fac_fx ), 32767 ); + voice_factors_fx[idx] = s_min( s_max( 0, voice_fac_fx ), 32767 ); move16(); p_Aq_fx += ( M + 1 ); pt_pitch_fx++; L_Voice_fac_ave = L_mac( L_Voice_fac_ave, 8192, voice_fac_fx ); - gain_buf[i_subfr / L_SUBFR] = gain_pit_fx; + gain_buf[idx] = gain_pit_fx; + move16(); } hAmrwb_IO->lt_voice_fac_fx = round_fx( L_Voice_fac_ave ); diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index 8f75dea7f..1fd514e1c 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -282,8 +282,14 @@ ivas_error decod_gen_voic_fx( * Prepare TBE excitation *-----------------------------------------------------------------*/ + Word16 idx = 0; + IF( i_subfr_fx != 0 ) + { + idx = idiv1616( i_subfr_fx, L_SUBFR ); + } + prep_tbe_exc_fx( L_frame, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx, - &voice_factors_fx[i_subfr_fx / L_SUBFR], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, + &voice_factors_fx[idx], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, st_fx->Q_exc, T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate ); @@ -305,7 +311,7 @@ ivas_error decod_gen_voic_fx( p_Aq_fx += ( M + 1 ); move16(); pt_pitch_fx++; - gain_buf[i_subfr_fx / L_SUBFR] = gain_pit_fx; + gain_buf[idx] = gain_pit_fx; move16(); } @@ -379,7 +385,7 @@ ivas_error decod_gen_voic_fx( #else fracb = round_fx( L_shl( curr_res_nrg, expb ) ); #endif - expb = sub( 30, expb + ( 2 * st_fx->Q_exc ) ); + expb = sub( 30, add( expb, shl( st_fx->Q_exc, 1 ) ) ); scale = shr( sub( fraca, fracb ), 15 ); fracb = shl( fracb, scale ); @@ -387,12 +393,14 @@ ivas_error decod_gen_voic_fx( enratio = div_s( fracb, fraca ); exp1 = sub( expb, expa ); - Qenratio = 15 - exp1; + Qenratio = sub( 15, exp1 ); } ELSE { enratio = 0; + move16(); Qenratio = 0; + move16(); } /* sp_enratio = curr_spch_nrg/prev_spch_nrg */ @@ -400,7 +408,7 @@ ivas_error decod_gen_voic_fx( { expa = norm_l( prev_spch_nrg ); fraca = extract_h( L_shl( prev_spch_nrg, expa ) ); - expa = sub( 30, expa + ( 2 * st_fx->prev_Q_syn_fr ) ); + expa = sub( 30, add( expa, shl( st_fx->prev_Q_syn_fr, 1 ) ) ); expb = norm_l( curr_spch_nrg ); #ifdef BASOP_NOGLOB @@ -408,7 +416,7 @@ ivas_error decod_gen_voic_fx( #else fracb = round_fx( L_shl( curr_spch_nrg, expb ) ); #endif - expb = sub( 30, expb + ( 2 * st_fx->Q_syn ) ); + expb = sub( 30, add( expb, shl( st_fx->Q_syn, 1 ) ) ); scale = shr( sub( fraca, fracb ), 15 ); fracb = shl( fracb, scale ); @@ -416,12 +424,14 @@ ivas_error decod_gen_voic_fx( sp_enratio = div_s( fracb, fraca ); exp1 = sub( expb, expa ); - Qsp_enratio = 15 - exp1; + Qsp_enratio = sub( 15, exp1 ); } ELSE { sp_enratio = 0; + move16(); Qsp_enratio = 0; + move16(); } test(); @@ -429,11 +439,11 @@ ivas_error decod_gen_voic_fx( test(); test(); #ifdef BASOP_NOGLOB - IF( GT_16( shl_ro( enratio, 15 - Qenratio, &Overflow ), 8192 ) && /*compare with 0.25 in Q15*/ - LT_16( shl_ro( enratio, 10 - Qenratio, &Overflow ), 15360 ) && /*compare with 15.0 in Q10*/ - GT_16( shl_ro( sp_enratio, 15 - Qsp_enratio, &Overflow ), 4915 ) && /*compare with 0.15 in Q15*/ - st_fx->bfi_pitch_fx < 9600 && /*Q6*/ - pitch_buf_fx[sub( NB_SUBFR16k, 1 )] < 9600 ) /*Q6*/ + IF( GT_16( shl_ro( enratio, sub( 15, Qenratio ), &Overflow ), 8192 ) && /*compare with 0.25 in Q15*/ + LT_16( shl_ro( enratio, sub( 10, Qenratio ), &Overflow ), 15360 ) && /*compare with 15.0 in Q10*/ + GT_16( shl_ro( sp_enratio, sub( 15, Qsp_enratio ), &Overflow ), 4915 ) && /*compare with 0.15 in Q15*/ + LT_16( st_fx->bfi_pitch_fx, 9600 ) && /*Q6*/ + LT_16( pitch_buf_fx[sub( NB_SUBFR16k, 1 )], 9600 ) ) /*Q6*/ #else IF( GT_16( shl_r( enratio, 15 - Qenratio ), 8192 ) && /*compare with 0.25 in Q15*/ LT_16( shl_r( enratio, 10 - Qenratio ), 15360 ) && /*compare with 15.0 in Q10*/ @@ -474,7 +484,7 @@ ivas_error decod_gen_voic_fx( /* update bwe_exc for SWB-TBE */ FOR( i_subfr_fx = 0; i_subfr_fx < L_frame; i_subfr_fx += L_SUBFR ) { - interp_code_4over2_fx( exc_fx + i_subfr_fx, bwe_exc_fx + ( i_subfr_fx * 2 ), L_SUBFR ); + interp_code_4over2_fx( exc_fx + i_subfr_fx, bwe_exc_fx + shl( i_subfr_fx, 1 ), L_SUBFR ); } count_free( PREVP ); @@ -725,11 +735,11 @@ ivas_error decod_gen_voic_ivas_fx( IF( gain_preQ_fx != 0 ) { - if ( st_fx->element_mode == EVS_MONO ) + IF( st_fx->element_mode == EVS_MONO ) { tmp1_fx = add( 15 - Q_AVQ_OUT_DEC - 2, st_fx->Q_exc ); } - else + ELSE { tmp1_fx = add( 15 - Q_AVQ_OUT - 2, st_fx->Q_exc ); } @@ -782,8 +792,15 @@ ivas_error decod_gen_voic_ivas_fx( /*prep_tbe_exc_fx(L_frame, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx, &voice_factors_fx[i_subfr_fx / L_SUBFR], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, st_fx->Q_exc, T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate);*/ + + Word16 idx = 0; + IF( i_subfr_fx != 0 ) + { + idx = idiv1616( i_subfr_fx, L_SUBFR ); + } + prep_tbe_exc_ivas_fx( L_frame, L_SUBFR, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx, - &voice_factors_fx[i_subfr_fx / L_SUBFR], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, + &voice_factors_fx[idx], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, st_fx->Q_exc, T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate, st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag ); @@ -806,7 +823,7 @@ ivas_error decod_gen_voic_ivas_fx( p_Aq_fx += ( M + 1 ); move16(); pt_pitch_fx++; - gain_buf[i_subfr_fx / L_SUBFR] = gain_pit_fx; + gain_buf[idx] = gain_pit_fx; move16(); } @@ -867,11 +884,11 @@ ivas_error decod_gen_voic_ivas_fx( { expa = norm_l( prev_res_nrg ); fraca = extract_h( L_shl( prev_res_nrg, expa ) ); - expa = sub( 30, expa + ( 2 * st_fx->prev_Q_exc_fr ) ); + expa = sub( 30, add( expa, shl( st_fx->prev_Q_exc_fr, 1 ) ) ); expb = norm_l( curr_res_nrg ); fracb = round_fx( L_shl( curr_res_nrg, expb ) ); - expb = sub( 30, expb + ( 2 * st_fx->Q_exc ) ); + expb = sub( 30, add( expb, shl( st_fx->Q_exc, 1 ) ) ); scale = shr( sub( fraca, fracb ), 15 ); fracb = shl( fracb, scale ); @@ -879,12 +896,14 @@ ivas_error decod_gen_voic_ivas_fx( enratio = div_s( fracb, fraca ); exp1 = sub( expb, expa ); - Qenratio = 15 - exp1; + Qenratio = sub( 15, exp1 ); } ELSE { enratio = 0; + move16(); Qenratio = 0; + move16(); } /* sp_enratio = curr_spch_nrg/prev_spch_nrg */ @@ -892,11 +911,11 @@ ivas_error decod_gen_voic_ivas_fx( { expa = norm_l( prev_spch_nrg ); fraca = extract_h( L_shl( prev_spch_nrg, expa ) ); - expa = sub( 30, expa + ( 2 * st_fx->prev_Q_syn_fr ) ); + expa = sub( 30, add( expa, shl( st_fx->prev_Q_syn_fr, 1 ) ) ); expb = norm_l( curr_spch_nrg ); fracb = round_fx( L_shl( curr_spch_nrg, expb ) ); - expb = sub( 30, expb + ( 2 * st_fx->Q_syn ) ); + expb = sub( 30, add( expb, shl( st_fx->Q_syn, 1 ) ) ); scale = shr( sub( fraca, fracb ), 15 ); fracb = shl( fracb, scale ); @@ -904,12 +923,14 @@ ivas_error decod_gen_voic_ivas_fx( sp_enratio = div_s( fracb, fraca ); exp1 = sub( expb, expa ); - Qsp_enratio = 15 - exp1; + Qsp_enratio = sub( 15, exp1 ); } ELSE { sp_enratio = 0; + move16(); Qsp_enratio = 0; + move16(); } test(); @@ -917,11 +938,11 @@ ivas_error decod_gen_voic_ivas_fx( test(); test(); #ifdef BASOP_NOGLOB - IF( GT_16( shl_ro( enratio, 15 - Qenratio, &Overflow ), 8192 ) && /*compare with 0.25 in Q15*/ - LT_16( shl_ro( enratio, 10 - Qenratio, &Overflow ), 15360 ) && /*compare with 15.0 in Q10*/ - GT_16( shl_ro( sp_enratio, 15 - Qsp_enratio, &Overflow ), 4915 ) && /*compare with 0.15 in Q15*/ - st_fx->bfi_pitch_fx < 9600 && /*Q6*/ - pitch_buf_fx[sub( NB_SUBFR16k, 1 )] < 9600 ) /*Q6*/ + IF( GT_16( shl_ro( enratio, sub( 15, Qenratio ), &Overflow ), 8192 ) && /*compare with 0.25 in Q15*/ + LT_16( shl_ro( enratio, sub( 10, Qenratio ), &Overflow ), 15360 ) && /*compare with 15.0 in Q10*/ + GT_16( shl_ro( sp_enratio, sub( 15, Qsp_enratio ), &Overflow ), 4915 ) && /*compare with 0.15 in Q15*/ + LT_16( st_fx->bfi_pitch_fx, 9600 ) && /*Q6*/ + LT_16( pitch_buf_fx[sub( NB_SUBFR16k, 1 )], 9600 ) ) /*Q6*/ #else IF( GT_16( shl_r( enratio, 15 - Qenratio ), 8192 ) && /*compare with 0.25 in Q15*/ LT_16( shl_r( enratio, 10 - Qenratio ), 15360 ) && /*compare with 15.0 in Q10*/ @@ -950,7 +971,7 @@ ivas_error decod_gen_voic_ivas_fx( ph_offset_fx = 0; move16(); - if ( ( error = WIsyn_fx( *PREVP, CURRP, dummy2, &( ph_offset_fx ), out_fx, (Word16) st_fx->L_frame, 1, S_fx, C_fx, pf_temp1, pf_temp2, pf_temp, pf_n2 ) ) != IVAS_ERR_OK ) + IF( ( error = WIsyn_fx( *PREVP, CURRP, dummy2, &( ph_offset_fx ), out_fx, (Word16) st_fx->L_frame, 1, S_fx, C_fx, pf_temp1, pf_temp2, pf_temp, pf_n2 ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/decision_matrix_dec_fx.c b/lib_dec/decision_matrix_dec_fx.c index a2b1108a8..8c9a12b69 100644 --- a/lib_dec/decision_matrix_dec_fx.c +++ b/lib_dec/decision_matrix_dec_fx.c @@ -47,7 +47,7 @@ void decision_matrix_dec_fx( st->igf = 0; move16(); - if ( GT_32( st->total_brate, ACELP_8k00 ) ) + IF( GT_32( st->total_brate, ACELP_8k00 ) ) { st->vbr_hw_BWE_disable_dec = 0; move16(); @@ -78,7 +78,7 @@ void decision_matrix_dec_fx( move16(); tmp16 = get_next_indice( st, 1 ); - if ( EQ_16( tmp16, 1 ) ) + IF( EQ_16( tmp16, 1 ) ) { st->L_frame = L_FRAME16k; move16(); @@ -93,7 +93,7 @@ void decision_matrix_dec_fx( st->L_frame = L_FRAME16k; move16(); - if ( tmp16 == 0 ) + IF( tmp16 == 0 ) { st->L_frame = L_FRAME; move16(); @@ -102,7 +102,7 @@ void decision_matrix_dec_fx( } test(); - if ( GE_32( st->output_Fs, 32000 ) && GE_16( st->bwidth, SWB ) ) + IF( GE_32( st->output_Fs, 32000 ) && GE_16( st->bwidth, SWB ) ) { st->extl = SWB_CNG; move16(); @@ -111,7 +111,7 @@ void decision_matrix_dec_fx( test(); test(); test(); - if ( EQ_32( st->total_brate, FRAME_NO_DATA ) && st->prev_bfi && !st->bfi && GT_16( st->L_frame, L_FRAME16k ) ) + IF( EQ_32( st->total_brate, FRAME_NO_DATA ) && st->prev_bfi && !st->bfi && GT_16( st->L_frame, L_FRAME16k ) ) { st->L_frame = st->last_CNG_L_frame; move16(); @@ -206,7 +206,7 @@ void decision_matrix_dec_fx( st->core = HQ_CORE; move16(); - if ( temp_core == 0 ) + IF( temp_core == 0 ) { st->core = ACELP_CORE; move16(); @@ -244,10 +244,10 @@ void decision_matrix_dec_fx( start_idx = add( start_idx, 1 ); start_idx = add( start_idx, get_next_indice( st, nBits ) ); - IF( start_idx >= MAX_ACELP_SIG ) + IF( GE_16( start_idx, MAX_ACELP_SIG ) ) { ind = 0; - move16(); + move32(); st->BER_detect = 1; move16(); } @@ -255,6 +255,7 @@ void decision_matrix_dec_fx( { /* retrieve the signaling indice */ ind = acelp_sig_tbl[start_idx]; + move32(); /* convert signaling indice into signaling information */ st->coder_type = extract_l( L_and( ind, 0x7L ) ); @@ -262,7 +263,7 @@ void decision_matrix_dec_fx( { st->core = HQ_CORE; move16(); - st->bwidth = extract_l( L_shr( ind, 3 ) & 0x7L ); + st->bwidth = extract_l( L_and( L_shr( ind, 3 ), 0x7L ) ); } ELSE { @@ -412,7 +413,7 @@ void decision_matrix_dec_fx( test(); IF( EQ_16( st->core, ACELP_CORE ) && EQ_16( st->bwidth, WB ) && LT_32( st->total_brate, ACELP_9k60 ) ) { - if ( st->vbr_hw_BWE_disable_dec == 0 ) + IF( st->vbr_hw_BWE_disable_dec == 0 ) { st->extl = WB_BWE; move16(); @@ -443,7 +444,7 @@ void decision_matrix_dec_fx( { st->extl = SWB_BWE_HIGHRATE; move16(); - if ( EQ_16( st->bwidth, FB ) ) + IF( EQ_16( st->bwidth, FB ) ) { st->extl = FB_BWE_HIGHRATE; move16(); @@ -470,7 +471,7 @@ void decision_matrix_dec_fx( move16(); st->extl_brate = SWB_TBE_1k6; move32(); - if ( GE_32( st->total_brate, ACELP_24k40 ) ) + IF( GE_32( st->total_brate, ACELP_24k40 ) ) { st->extl_brate = SWB_TBE_2k8; move32(); @@ -530,7 +531,7 @@ void decision_matrix_dec_fx( st->last_L_frame = L_FRAME16k; move16(); tmp16 = get_next_indice( st, 1 ); - if ( tmp16 == 0 ) + IF( tmp16 == 0 ) { st->last_L_frame = L_FRAME; move16(); @@ -669,7 +670,7 @@ void decision_matrix_dec_fx( st->nb_subfr = NB_SUBFR; move16(); - if ( EQ_16( st->L_frame, L_FRAME16k ) ) + IF( EQ_16( st->L_frame, L_FRAME16k ) ) { st->nb_subfr = NB_SUBFR16k; move16(); diff --git a/lib_dec/er_dec_acelp_fx.c b/lib_dec/er_dec_acelp_fx.c index e3fceb149..100a6b207 100644 --- a/lib_dec/er_dec_acelp_fx.c +++ b/lib_dec/er_dec_acelp_fx.c @@ -92,23 +92,22 @@ void con_acelp_fx( const Word16 scale_h1 = 5; HQ_DEC_HANDLE hHQ_core; TCX_DEC_HANDLE hTcxDec; + move16(); hHQ_core = st->hHQ_core; hTcxDec = st->hTcxDec; /*Inits*/ - move16(); l_fir_fer = L_FIR_FER; + move16(); fUseExtrapolatedPitch = 0; move16(); extrapolationFailed = 1; move16(); - move16(); - move16(); - move16(); alpha = 0; + move16(); /*st->Mode2_lp_gainc = L_shl(st->Mode2_lp_gainc,7);*/ /*rudiment, could be changed in the whole file but should work also*/ pc = L_deposit_l( 0 ); @@ -130,7 +129,7 @@ void con_acelp_fx( * PLC: [ACELP:Extrapolate Pitch Lag] *------------------------------------------------------------------------*/ - if ( EQ_16( st->flagGuidedAcelp, 1 ) ) + IF( EQ_16( st->flagGuidedAcelp, 1 ) ) { T0 = st->guidedT0; move16(); @@ -143,13 +142,13 @@ void con_acelp_fx( st->plc_use_future_lag, &extrapolationFailed, st->nb_subfr ); T0 = round_fx( predPitchLag ); - IF( extrapolationFailed != 0 ) + IF( NE_16( extrapolationFailed, 0 ) ) { /*------------------------------------------------------------------------* * - Construct adaptive codebook from side information * *------------------------------------------------------------------------*/ - IF( st->flagGuidedAcelp == 0 ) + IF( EQ_16( st->flagGuidedAcelp, 0 ) ) { nSubframes = 0; move16(); @@ -174,8 +173,8 @@ void con_acelp_fx( } tmp_tc = st->old_fpitch; - move16(); /* take the previous frame last pitch*/ - if ( nSubframes > 0 ) + move32(); /* take the previous frame last pitch*/ + IF( GT_16( nSubframes, 0 ) ) { tmp_tc = L_deposit_h( st->guidedT0 ); /* take the transmit pitch*/ } @@ -184,9 +183,10 @@ void con_acelp_fx( * PLC: calculate damping factor */ alpha = Damping_fact_fx( coder_type, st->nbLostCmpt, st->last_good, stab_fac, &( st->Mode2_lp_gainp ), 0 ); /*Q14*/ st->cummulative_damping = shl( mult( st->cummulative_damping, alpha ), 1 ); /*shl(Q15*Q14,1)=shl(Q14,1) = Q15*/ - if ( EQ_16( st->nbLostCmpt, 1 ) ) + IF( EQ_16( st->nbLostCmpt, 1 ) ) { st->cummulative_damping = 32767 /*1.f Q15*/; /*Q15*/ + move16(); } /*-----------------------------------------------------------------* @@ -212,20 +212,20 @@ void con_acelp_fx( test(); test(); test(); - if ( ( T0 > 0 ) && ( NE_16( T0, Tc ) ) && ( tmp < 0 ) && extrapolationFailed == 0 ) + IF( GT_16( T0, 0 ) && ( NE_16( T0, Tc ) ) && LT_16( tmp, 0 ) && EQ_16( extrapolationFailed, 0 ) ) { fUseExtrapolatedPitch = 1; move16(); } pt_exc = exc; - if ( st->enableGplc != 0 ) + IF( NE_16( st->enableGplc, 0 ) ) { - pt_exc = &exc[nSubframes * L_SUBFR]; + pt_exc = &exc[imult1616( nSubframes, L_SUBFR )]; } pt1_exc = pt_exc - Tc; - IF( fUseExtrapolatedPitch != 0 ) + IF( NE_16( fUseExtrapolatedPitch, 0 ) ) { /* Required because later pt1_exc[1] used in filtering points to exc[0]. To make it safe also for GPL pt_exc is used instead of exc */ pt_exc[0] = 0; @@ -252,8 +252,8 @@ void con_acelp_fx( tmp_32 = L_mult( lpFiltAdapt[0], pt1_exc[-1] ); tmp_32 = L_mac( tmp_32, lpFiltAdapt[1], pt1_exc[0] ); tmp_16 = mac_r( tmp_32, lpFiltAdapt[2], pt1_exc[1] ); - move16(); *pt_exc = tmp_16; + move16(); pt_exc++; pt1_exc++; } @@ -263,12 +263,12 @@ void con_acelp_fx( /* copy the first pitch cycle without low-pass filtering */ FOR( i = 0; i < Tc; i++ ) { - move16(); *pt_exc++ = *pt1_exc++; + move16(); } } - if ( fUseExtrapolatedPitch != 0 ) + IF( NE_16( fUseExtrapolatedPitch, 0 ) ) { pt1_exc = harmonic_exc_buf; } @@ -276,8 +276,8 @@ void con_acelp_fx( l = add( st->L_frame, sub( imult1616( L_SUBFR, sub( 1, nSubframes ) ), Tc ) ); FOR( i = 0; i < l; i++ ) { - move16(); *pt_exc++ = *pt1_exc++; + move16(); } /*-------------------------------------------------------* @@ -285,29 +285,29 @@ void con_acelp_fx( * PLC: Resync pulse positions. *-------------------------------------------------------*/ - IF( nSubframes > 0 ) + IF( GT_16( nSubframes, 0 ) ) { - move16(); - move16(); pitch_buf[0] = L_deposit_h( st->guidedT0 ); + move32(); pitch_buf[1] = L_deposit_h( st->guidedT0 ); + move32(); } - IF( nSubframes > 0 ) + IF( GT_16( nSubframes, 0 ) ) { - move16(); - move16(); pitch_buf[3] = pitch_buf[2] = pitch_buf[1]; /* do not resync on second half of frame */ - if ( EQ_16( st->nb_subfr, 5 ) ) + move32(); + move32(); + IF( EQ_16( st->nb_subfr, 5 ) ) { /* for guided acelp cases and nSubframes=2, set pitch_buf[4] to avoid memory_access issues in post_decoder() */ pitch_buf[4] = pitch_buf[3]; - move16(); + move32(); } } ELSE { - IF( fUseExtrapolatedPitch != 0 ) + IF( NE_16( fUseExtrapolatedPitch, 0 ) ) { get_subframe_pitch( st->nb_subfr, st->old_fpitch, predPitchLag, pitch_buf ); @@ -325,7 +325,7 @@ void con_acelp_fx( *------------------------------------------------------------*/ pt_exc = exc + st->L_frame; pt1_exc = pt_exc - T0; - if ( T0 == 0 ) + IF( EQ_16( T0, 0 ) ) { pt1_exc = pt_exc - Tc; } @@ -341,11 +341,11 @@ void con_acelp_fx( * PLC: update the floating point pitch for consecutive loss *-------------------------------------------------------*/ - IF( fUseExtrapolatedPitch != 0 ) + IF( NE_16( fUseExtrapolatedPitch, 0 ) ) { - move32(); st->old_fpitch = predPitchLag; - if ( EQ_16( st->flagGuidedAcelp, 1 ) ) + move32(); + IF( EQ_16( st->flagGuidedAcelp, 1 ) ) { st->old_fpitch = L_deposit_h( T0 ); } @@ -384,12 +384,14 @@ void con_acelp_fx( } ELSE { - gain = 0x4000 /*1 (1Q14)*/; /* start-of-the-frame gain */ + gain = 0x4000 /*1 (1Q14)*/; /* start-of-the-frame gain */ + move16(); st->Mode2_lp_gainp = L_shl( L_deposit_l( alpha ), 15 ); /*1Q14->2Q29*/ } tmp_16 = extract_l( L_shl( L_mac( -28000, st->L_frame, 95 ), 1 - 15 ) ); tmp_16 = T_DIV_L_Frame[tmp_16]; + move16(); tmp_32 = L_mult0( tmp_16, sub( gain, alpha ) ); /* 0Q15 * 2^-7 * 1Q14 -> 2Q29 * 2^-7*/ tmp_32 = L_shr( tmp_32, 6 ); /*-> 1Q30*/ step = round_fx( tmp_32 ); /*->1Q14*/ @@ -415,7 +417,6 @@ void con_acelp_fx( l = add( l, L_SUBFR ); FOR( ; i < l; i++ ) { - move16(); BASOP_SATURATE_WARNING_OFF_EVS #ifdef BASOP_NOGLOB exc[i] = mult_r( exc[i], shl_sat( gain, 1 ) ); /*overflow is first iteration because gain may be 1 after shift*/ @@ -423,6 +424,7 @@ void con_acelp_fx( exc[i] = mult_r( exc[i], shl( gain, 1 ) ); /*overflow is first iteration because gain may be 1 after shift*/ #endif BASOP_SATURATE_WARNING_ON_EVS + move16(); gain = sub( gain, step ); } } @@ -430,7 +432,6 @@ void con_acelp_fx( l = add( st->L_frame, shr( st->L_frame, 1 ) ); FOR( ; i < l; i++ ) { - move16(); BASOP_SATURATE_WARNING_OFF_EVS #ifdef BASOP_NOGLOB exc[i] = mult_r( exc[i], shl_sat( gain, 1 ) ); /*overflow is first iteration because gain may become 1 due to shift*/ @@ -438,13 +439,16 @@ void con_acelp_fx( exc[i] = mult_r( exc[i], shl( gain, 1 ) ); /*overflow is first iteration because gain may become 1 due to shift*/ #endif BASOP_SATURATE_WARNING_ON_EVS + move16(); gain = sub( gain, step ); } FOR( i = 0; i < st->nb_subfr; i++ ) { pT[i] = round_fx( pitch_buf[i] ); /*Q0*/ + move16(); pitch_buffer[i] = round_fx( pitch_buf[i] ); + move16(); } /* update old exc without random part*/ @@ -459,6 +463,7 @@ void con_acelp_fx( FOR( i = 0; i < st->nb_subfr; i++ ) { pitch_buf[i] = L_deposit_h( st->pit_max ); /*15Q16*/ + move32(); pgainT[i] = 0; move16(); pT[i] = L_SUBFR; @@ -480,7 +485,6 @@ void con_acelp_fx( * search for "Scale from randomized buffer to excitation buffer" *-----------------------------------------------------------------*/ noise_buf = buf; - move16(); tmpSeed = st->seed_acelp; move16(); l = add( st->L_frame, sub( l_fir_fer, 1 ) ); @@ -514,6 +518,7 @@ void con_acelp_fx( tmp = 32767 /*1.0f Q15*/; + move16(); gainSynthDeemph = getLevelSynDeemph_fx( &( tmp ), A, M, @@ -526,14 +531,14 @@ void con_acelp_fx( /*gainCNG=st->cngTDLevel/gainSynthDeemph;*/ BASOP_Util_Divide_MantExp( st->cngTDLevel, st->cngTDLevel_e, gainSynthDeemph, gainSynthDeemph_e, &gainCNG, &gainCNG_e ); gainCNG_e = sub( gainCNG_e, 15 - 5 ); /*Q15->Q5*/ - if ( gainCNG == 0 ) + IF( EQ_16( gainCNG, 0 ) ) { gainCNG_e = 0; move16(); } gain_32 = st->Mode2_lp_gainc; /*15Q16 */ /* start-of-the-frame gain */ - move16(); + move32(); #ifdef BASOP_NOGLOB ftmp = round_fx_sat( L_shl_sat( gain_32, 1 ) ); /*Q0*/ @@ -549,20 +554,22 @@ void con_acelp_fx( /*in case of overflow:*/ test(); #ifdef BASOP_NOGLOB - if ( ( EQ_16( shl_sat( ftmp, sub( gainCNG_e, 1 ) ), MAXVAL_WORD16 ) ) && ( gainCNG == MAXVAL_WORD16 ) ) + IF( ( EQ_16( shl_sat( ftmp, sub( gainCNG_e, 1 ) ), MAXVAL_WORD16 ) ) && EQ_16( gainCNG, MAXVAL_WORD16 ) ) #else - if ( ( EQ_16( shl( ftmp, sub( gainCNG_e, 1 ) ), MAXVAL_WORD16 ) ) && ( gainCNG == MAXVAL_WORD16 ) ) + IF( ( EQ_16( shl( ftmp, sub( gainCNG_e, 1 ) ), MAXVAL_WORD16 ) ) && EQ_16( gainCNG, MAXVAL_WORD16 ) ) #endif { - move16(); tmp_16 = 1; + move16(); } BASOP_SATURATE_WARNING_ON_EVS - IF( tmp_16 > 0 ) + IF( GT_16( tmp_16, 0 ) ) { gainCNG = ftmp /*Q0*/; + move16(); gainCNG_e = 5; /*-> Q5*/ + move16(); s_16 = norm_s( gainCNG ); gainCNG = shl( gainCNG, s_16 ); gainCNG_e = sub( gainCNG_e, s_16 ); @@ -595,7 +602,7 @@ void con_acelp_fx( highPassFiltering_fx( st->last_good, add( st->L_frame, shr( l_fir_fer, 1 ) ), noise_buf, hp_filt, l_fir_fer ); - pt_exc = noise_buf + l_fir_fer / 2; + pt_exc = noise_buf + shr( l_fir_fer, 1 ); /*** Find energy normalization factor ***/ /*gain_inov = 1.0f / (float)sqrt( dot_product( pt_exc, pt_exc, st->L_frame ) / st->L_frame );*/ /* normalize energy */ /*<--- FLC*/ @@ -607,20 +614,24 @@ void con_acelp_fx( /*scalingfactor is twice the headroom (at noise insertion onto the buffer), -1 (because of mult) +31 (Result is Q31) +s_32 (output scalingfactor of dot_product)*/ tmp_16 = T_DIV_L_Frame[L_shl( L_mac( -28000, st->L_frame, 95 ), 1 - 15 )]; + move16(); tmp_32 = Mpy_32_16_1( tmp_32, tmp_16 ); /* Q31 * 2^s_32 * 0Q15 * 2^-7 */ s_32 = sub( s_32, 7 ); /*tmp_32 is Q31 * 2^s_32 */ /*assure doing Isqrt not for 0*/ - IF( tmp_32 != 0 ) + IF( NE_32( tmp_32, 0 ) ) { s_gain_inov = s_32; + move16(); tmp_32 = ISqrt32( tmp_32, &s_gain_inov ); } ELSE { s_gain_inov = 0; + move16(); tmp_32 = 0; + move16(); } @@ -635,7 +646,7 @@ void con_acelp_fx( step_32 = L_shr( step_32, 7 ); /* 15Q16 */ test(); - if ( ( EQ_16( st->last_good, UNVOICED_CLAS ) ) && ( NE_16( coder_type, UNVOICED ) ) ) /* Attenuate somewhat on unstable unvoiced */ + IF( ( EQ_16( st->last_good, UNVOICED_CLAS ) ) && ( NE_16( coder_type, UNVOICED ) ) ) /* Attenuate somewhat on unstable unvoiced */ { gain_inov = mult_r( gain_inov, 26214 /*0.8f Q15*/ ); /*Q15 * 2^s_gain_inov*/ } @@ -698,7 +709,7 @@ void con_acelp_fx( gain_16 = round_fx( gain_32 ); } - l = add( shr( st->L_frame, 1 ), l_fir_fer / 2 ); + l = add( shr( st->L_frame, 1 ), shr( l_fir_fer, 1 ) ); FOR( i = 0; i < l; i++ ) { /* *pt_exc++ *= (gain_inov * gain); <=> *pt_exc++ *= gain_16; */ /*<-- FLC*/ @@ -710,23 +721,23 @@ void con_acelp_fx( /*store st->past_gcode*/ /* at this point gain is equal to st->Mode2_lp_gainc, so we don't need to calculate gain at all */ st->past_gcode = st->Mode2_lp_gainc; /*15Q16 */ - move16(); + move32(); /*-----------------------------------------------------------------* * PLC: [ACELP: general] * PLC: Construct the total excitation *-----------------------------------------------------------------*/ - IF( st->last_good < UNVOICED_TRANSITION ) + IF( LT_16( st->last_good, UNVOICED_TRANSITION ) ) { - bufferCopyFx( noise_buf + l_fir_fer / 2, exc, add( st->L_frame, shr( st->L_frame, 1 ) ), 0, *Qf_exc, negate( g_e ), 0 ); /*copy between different formats*/ + bufferCopyFx( noise_buf + shr( l_fir_fer, 1 ), exc, add( st->L_frame, shr( st->L_frame, 1 ) ), 0, *Qf_exc, negate( g_e ), 0 ); /*copy between different formats*/ Copy( harmonic_exc_buf + st->L_frame, st->old_exc_fx, L_EXC_MEM_DEC ); Copy( exc, exc_unv, add( st->L_frame, shr( st->L_frame, 1 ) ) ); /* Update exc_unv */ } ELSE { /* Update exc_unv */ - bufferCopyFx( noise_buf + l_fir_fer / 2, exc_unv, add( st->L_frame, shr( st->L_frame, 1 ) ), 0, *Qf_exc, negate( g_e ), 0 ); /*copy between different formats*/ + bufferCopyFx( noise_buf + shr( l_fir_fer, 1 ), exc_unv, add( st->L_frame, shr( st->L_frame, 1 ) ), 0, *Qf_exc, negate( g_e ), 0 ); /*copy between different formats*/ } /* Compute total excitation in noisebuffer to save memories */ @@ -761,7 +772,7 @@ void con_acelp_fx( IF( EQ_16( st->nbLostCmpt, 1 ) ) { - IF( st->last_good < UNVOICED_TRANSITION ) + IF( LT_16( st->last_good, UNVOICED_TRANSITION ) ) { Copy( st->mem_syn2_fx, mem_syn_unv, M ); } @@ -776,7 +787,7 @@ void con_acelp_fx( } /* voiced synth */ - IF( st->last_good >= UNVOICED_TRANSITION ) + IF( GE_16( st->last_good, UNVOICED_TRANSITION ) ) { p_A = A; FOR( i_subfr = 0; i_subfr < st->L_frame; i_subfr += L_SUBFR ) @@ -791,12 +802,15 @@ void con_acelp_fx( deemph_fx( h1, st->preemph_fac, L_SUBFR, &tmp ); /* impulse response of deemph */ /* impulse response level = gain introduced by synthesis+deemphasis */ + /* i_subfr / L_SUBFR */ + tmp_16 = shr( i_subfr, Q6 ); /* gain_lpc[i_subfr/L_SUBFR] = 1.f/(float)sqrt(dotp( h1, h1, L_SUBFR)); */ - tmp_32 = Dot_productSq16HQ( 0, h1, L_SUBFR, &gain_lpc_e[i_subfr / L_SUBFR] ); + tmp_32 = Dot_productSq16HQ( 0, h1, L_SUBFR, &gain_lpc_e[tmp_16] ); tmp_32 = L_max( tmp_32, 1 ); - gain_lpc_e[i_subfr / L_SUBFR] = add( gain_lpc_e[i_subfr / L_SUBFR], 2 * scale_h1 ); + gain_lpc_e[tmp_16] = add( gain_lpc_e[tmp_16], shl( scale_h1, 1 ) ); + move16(); + gain_lpc[tmp_16] = round_fx( ISqrt32( tmp_32, &gain_lpc_e[tmp_16] ) ); move16(); - gain_lpc[i_subfr / L_SUBFR] = round_fx( ISqrt32( tmp_32, &gain_lpc_e[i_subfr / L_SUBFR] ) ); p_A += ( M + 1 ); /* Pointer move */ } @@ -805,20 +819,21 @@ void con_acelp_fx( move16(); FOR( i_subfr = 0; i_subfr < st->L_frame; i_subfr += L_SUBFR ) { - - g = mult_r( st->last_gain_syn_deemph, gain_lpc[i_subfr / L_SUBFR] ); + /* i_subfr / L_SUBFR */ + tmp_16 = shr( i_subfr, Q6 ); + g = mult_r( st->last_gain_syn_deemph, gain_lpc[tmp_16] ); #ifdef BASOP_NOGLOB - g_e = add_sat( st->last_gain_syn_deemph_e, gain_lpc_e[i_subfr / L_SUBFR] ); + g_e = add_sat( st->last_gain_syn_deemph_e, gain_lpc_e[tmp_16] ); g = shl_sat( g, g_e ); #else - g_e = add( st->last_gain_syn_deemph_e, gain_lpc_e[i_subfr / L_SUBFR] ); + g_e = add( st->last_gain_syn_deemph_e, gain_lpc_e[tmp_16] ); g = shl( g, g_e ); #endif FOR( i = 0; i < L_SUBFR; i++ ) { /* exc[i_subfr + i] *= st->last_gain_syn_deemph*gain_lpc[j]; */ - exc[i_subfr + i] = mult_r( exc[i_subfr + i], g ); + exc[i_subfr + i] = mult_r( exc[add( i_subfr, i )], g ); move16(); } } @@ -843,18 +858,16 @@ void con_acelp_fx( memsynPrecission_fx( st->nbLostCmpt, mem_syn, exc, st->L_frame, &s_16 ); FOR( i_subfr = 0; i_subfr < st->L_frame; i_subfr += L_SUBFR ) { - - E_UTIL_synthesis( synthScaling, p_A, &exc[i_subfr], &syn[i_subfr], L_SUBFR, mem_syn, 1, M ); - p_A += ( M + 1 ); + p_A = p_A + add( M, 1 ); } Copy( mem_syn, mem_syn2, M ); /* synthesize ola*/ - E_UTIL_synthesis( synthScaling, p_A - ( M + 1 ), &exc[i_subfr], &syn[i_subfr], ( st->L_frame / 2 ), mem_syn2, 0, M ); + E_UTIL_synthesis( synthScaling, p_A - add( M, 1 ), &exc[i_subfr], &syn[i_subfr], shr( st->L_frame, 1 ), mem_syn2, 0, M ); } test(); - IF( GT_16( st->nbLostCmpt, 5 ) && ( s_16 > 0 ) ) + IF( GT_16( st->nbLostCmpt, 5 ) && GT_16( s_16, 0 ) ) { /*scale back mem_syn, exc and synthesis*/ Scale_sig( mem_syn, M, negate( s_16 ) ); @@ -879,12 +892,15 @@ void con_acelp_fx( deemph_fx( h1, st->preemph_fac, L_SUBFR, &tmp ); /* impulse response of deemph */ /* impulse response level = gain introduced by synthesis+deemphasis */ + /* i_subfr / L_SUBFR */ + tmp_16 = shr( i_subfr, Q6 ); /* gain_lpc[i_subfr/L_SUBFR] = 1.f/(float)sqrt(dotp( h1, h1, L_SUBFR)); */ - tmp_32 = Dot_productSq16HQ( 0, h1, L_SUBFR, &gain_lpc_e[i_subfr / L_SUBFR] ); + tmp_32 = Dot_productSq16HQ( 0, h1, L_SUBFR, &gain_lpc_e[tmp_16] ); tmp_32 = L_max( tmp_32, 1 ); - gain_lpc_e[i_subfr / L_SUBFR] = add( gain_lpc_e[i_subfr / L_SUBFR], 2 * scale_h1 ); + gain_lpc_e[tmp_16] = add( gain_lpc_e[tmp_16], shl( scale_h1, 1 ) ); + move16(); + gain_lpc[tmp_16] = round_fx( ISqrt32( tmp_32, &gain_lpc_e[tmp_16] ) ); move16(); - gain_lpc[i_subfr / L_SUBFR] = round_fx( ISqrt32( tmp_32, &gain_lpc_e[i_subfr / L_SUBFR] ) ); p_A += ( M + 1 ); /* Pointer move */ } @@ -893,8 +909,10 @@ void con_acelp_fx( move16(); FOR( i_subfr = 0; i_subfr < st->L_frame; i_subfr += L_SUBFR ) { - g = mult_r( st->last_gain_syn_deemph, gain_lpc[i_subfr / L_SUBFR] ); - g_e = add( st->last_gain_syn_deemph_e, gain_lpc_e[i_subfr / L_SUBFR] ); + /* i_subfr / L_SUBFR */ + tmp_16 = shr( i_subfr, Q6 ); + g = mult_r( st->last_gain_syn_deemph, gain_lpc[tmp_16] ); + g_e = add( st->last_gain_syn_deemph_e, gain_lpc_e[tmp_16] ); #ifdef BASOP_NOGLOB g = shl_sat( g, g_e ); #else @@ -903,7 +921,7 @@ void con_acelp_fx( FOR( i = 0; i < L_SUBFR; i++ ) { /* exc[i_subfr + i] *= st->last_gain_syn_deemph*gain_lpc[j]; */ - exc_unv[i_subfr + i] = mult_r( exc_unv[i_subfr + i], g ); + exc_unv[add( i_subfr, i )] = mult_r( exc_unv[add( i_subfr, i )], g ); move16(); } } @@ -922,6 +940,7 @@ void con_acelp_fx( rescale_mem( Qf_exc, &Qf_syn_new, &Qf_syn, mem_syn_unv, NULL, M, st->L_frame ); synthScaling = sub( *Qf_exc, Qf_syn ); *Qf_mem_syn = Qf_syn; + move16(); p_A = st->Aq_cng; @@ -931,7 +950,7 @@ void con_acelp_fx( FOR( i_subfr = 0; i_subfr < st->L_frame; i_subfr += L_SUBFR ) { E_UTIL_synthesis( synthScaling, p_A, &exc_unv[i_subfr], &syn_unv[i_subfr], L_SUBFR, mem_syn_unv, 1, M ); - p_A += ( M + 1 ); + p_A = p_A + add( M, 1 ); } Copy( mem_syn_unv, st->mem_syn_unv_back, M ); @@ -939,11 +958,11 @@ void con_acelp_fx( { Copy( mem_syn_unv, mem_syn, M ); /* unvoiced for ola */ - E_UTIL_synthesis( synthScaling, p_A - ( M + 1 ), &exc_unv[i_subfr], &syn_unv[i_subfr], shr( st->L_frame, 1 ), mem_syn_unv, 0, M ); + E_UTIL_synthesis( synthScaling, p_A - add( M, 1 ), &exc_unv[i_subfr], &syn_unv[i_subfr], shr( st->L_frame, 1 ), mem_syn_unv, 0, M ); } test(); - IF( GT_16( st->nbLostCmpt, 5 ) && ( s_16 > 0 ) ) + IF( GT_16( st->nbLostCmpt, 5 ) && GT_16( s_16, 0 ) ) { /*scale back mem_syn_unv, exc_unv and synthesis*/ Scale_sig( mem_syn_unv, M, negate( s_16 ) ); @@ -988,6 +1007,7 @@ void con_acelp_fx( FOR( k = 0; k < st->nb_subfr; k++ ) { pit16[k] = shl( extract_h( pitch_buf[k] ), 6 ); /*Q6*/ + move16(); } FEC_clas_estim_fx( @@ -1037,19 +1057,20 @@ void con_acelp_fx( /*Q_mem_syn_new = Q_mem_syn;*/ /*NOT "+synthScaling", cause mem_syn format is not changed*/ /* Deemphasis and output synth */ tmp_deemph = st->syn[M]; + move16(); E_UTIL_deemph2( *Qf_mem_syn, syn, st->preemph_fac, add( st->L_frame, shr( st->L_frame, 1 ) ), &tmp_deemph ); Copy( syn, synth, st->L_frame ); - bufferCopyFx( syn + st->L_frame - st->L_frame / 2, hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), 0 /*Qf_syn*/, -1 /*Qf_old_xnq*/, 0, 0 /*Q_old_xnq*/ ); + bufferCopyFx( syn + sub( st->L_frame, shr( st->L_frame, 1 ) ), hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), 0 /*Qf_syn*/, -1 /*Qf_old_xnq*/, 0, 0 /*Q_old_xnq*/ ); /* save last half frame if next frame is TCX */ bufferCopyFx( syn + st->L_frame, hTcxDec->syn_Overl_TDAC, shr( st->L_frame, 1 ), 0 /*Qf_syn*/, -1 /*Qf_old_xnq*/, 0, 0 /*Q_old_xnq*/ ); - Copy( syn + st->L_frame - M - 1, st->syn, add( 1, M ) ); + Copy( syn + sub( st->L_frame, sub( M, 1 ) ), st->syn, add( 1, M ) ); /* update old_Aq */ - Copy( p_A - ( M + 1 ), st->old_Aq_12_8_fx, add( M, 1 ) ); + Copy( p_A - add( M, 1 ), st->old_Aq_12_8_fx, add( M, 1 ) ); Copy( syn + st->L_frame, hTcxDec->syn_Overl, shr( st->L_frame, 1 ) ); @@ -1064,59 +1085,62 @@ void con_acelp_fx( n = extract_h( L_mult( st->L_frame, 9216 /*(float)N_ZERO_MDCT_NS/(float)FRAME_SIZE_NS Q15*/ ) ); - hHQ_core->Q_old_wtda_LB = getScaleFactor16( syn + st->L_frame - n, + hHQ_core->Q_old_wtda_LB = getScaleFactor16( syn + sub( st->L_frame, n ), sub( st->L_frame, n ) ); move16(); - bufferCopyFx( syn + st->L_frame - n, hHQ_core->old_out_LB_fx, sub( st->L_frame, n ), 0, 0, hHQ_core->Q_old_wtda_LB, 0 ); + bufferCopyFx( syn + sub( st->L_frame, n ), hHQ_core->old_out_LB_fx, sub( st->L_frame, n ), 0, 0, hHQ_core->Q_old_wtda_LB, 0 ); FOR( i = 0; i < W2; i++ ) { - hHQ_core->old_out_LB_fx[i + n] = round_fx( Mpy_32_16_1( L_mult( w[i].v.re, w[i].v.re ), hHQ_core->old_out_LB_fx[i + n] ) ); + hHQ_core->old_out_LB_fx[add( i, n )] = round_fx( Mpy_32_16_1( L_mult( w[i].v.re, w[i].v.re ), hHQ_core->old_out_LB_fx[add( i, n )] ) ); + move16(); } FOR( ; i < W1; i++ ) { - hHQ_core->old_out_LB_fx[i + n] = round_fx( Mpy_32_16_1( L_mult( w[W2 - 1 - ( i - W2 )].v.im, w[W2 - 1 - ( i - W2 )].v.im ), hHQ_core->old_out_LB_fx[i + n] ) ); + hHQ_core->old_out_LB_fx[add( i, n )] = round_fx( Mpy_32_16_1( L_mult( w[sub( W2, sub( 1, sub( i, W2 ) ) )].v.im, w[sub( W2, sub( 1, sub( i, W2 ) ) )].v.im ), hHQ_core->old_out_LB_fx[add( i, n )] ) ); + move16(); } - set16_fx( &hHQ_core->old_out_LB_fx[W1 + n], 0, n ); + set16_fx( &hHQ_core->old_out_LB_fx[add( W1, n )], 0, n ); hHQ_core->Q_old_wtda = hHQ_core->Q_old_wtda_LB; + move16(); FOR( i = 0; i < W2; i++ ) { - move16(); buf[i] = mult_r( hTcxDec->syn_Overl_TDAC[i], w[i].v.re ); + move16(); } FOR( ; i < W1; i++ ) { + buf[i] = mult_r( hTcxDec->syn_Overl_TDAC[i], w[sub( sub( W1, 1 ), i )].v.im ); move16(); - buf[i] = mult_r( hTcxDec->syn_Overl_TDAC[i], w[W1 - 1 - i].v.im ); } FOR( i = 0; i < W2; i++ ) { + hTcxDec->syn_Overl_TDAC[i] = add( buf[i], buf[sub( sub( W1, 1 ), i )] ); /* A-D */ move16(); - hTcxDec->syn_Overl_TDAC[i] = add( buf[i], buf[W1 - 1 - i] ); /* A-D */ } /*-2*/ FOR( i = 0; i < W2; i++ ) { + hTcxDec->syn_Overl_TDAC[add( W2, i )] = add( buf[add( W2, i )], buf[sub( sub( sub( W1, 1 ), W2 ), i )] ); /* B-C */ move16(); - hTcxDec->syn_Overl_TDAC[W2 + i] = add( buf[W2 + i], buf[W1 - 1 - W2 - i] ); /* B-C */ } FOR( i = 0; i < W2; i++ ) { - move16(); hTcxDec->syn_Overl_TDAC[i] = mult_r( hTcxDec->syn_Overl_TDAC[i], w[i].v.re ); + move16(); } FOR( ; i < W1; i++ ) { + hTcxDec->syn_Overl_TDAC[i] = mult_r( hTcxDec->syn_Overl_TDAC[i], w[sub( sub( W1, 1 ), i )].v.im ); move16(); - hTcxDec->syn_Overl_TDAC[i] = mult_r( hTcxDec->syn_Overl_TDAC[i], w[W1 - 1 - i].v.im ); } /* update memory for full band */ @@ -1130,8 +1154,7 @@ void con_acelp_fx( lerp( exc, st->hWIDec->old_exc2_fx, L_EXC_MEM, st->L_frame ); lerp( syn, st->hWIDec->old_syn2_fx, L_EXC_MEM, st->L_frame ); } - st->bfi_pitch_fx = shl( round_fx( pitch_buf[st->nb_subfr - 1] ), 6 ); - move16(); + st->bfi_pitch_fx = shl( round_fx( pitch_buf[sub( st->nb_subfr, 1 )] ), 6 ); st->bfi_pitch_frame = st->L_frame; move16(); @@ -1163,7 +1186,7 @@ static void memsynPrecission_fx( Word16 nbLostCmpt, Word16 *mem_syn, Word16 *exc BASOP_SATURATE_WARNING_ON_EVS } /*if there is energy in scale_syn, then increase precision*/ - IF( abs_s( tmp ) > 0 ) + IF( GT_16( abs_s( tmp ), 0 ) ) { sf_mem_syn = getScaleFactor16( mem_syn, M ); /*sf_exc = getScaleFactor16(exc, add(shr(len,1),len));*/ /*this returns 0 if signal is 0*/ @@ -1173,12 +1196,11 @@ static void memsynPrecission_fx( Word16 nbLostCmpt, Word16 *mem_syn, Word16 *exc max = s_max( max, abs_s( exc[k] ) ); } sf_exc = norm_s( max ); - if ( max == 0 ) + IF( EQ_16( max, 0 ) ) { sf_exc = 16; move16(); } - move16(); *s_16 = s_max( sub( s_min( sf_exc, sf_mem_syn ), 5 ), 0 ) /*5 bits of headroom, scaling not smaller than 0*/; Scale_sig( mem_syn, M, *s_16 ); Scale_sig( exc, add( shr( len, 1 ), len ), *s_16 ); diff --git a/lib_dec/er_dec_tcx_fx.c b/lib_dec/er_dec_tcx_fx.c index 312049e70..e51721c82 100644 --- a/lib_dec/er_dec_tcx_fx.c +++ b/lib_dec/er_dec_tcx_fx.c @@ -29,7 +29,9 @@ static void calcGainc_fx( Word16 *exc, Word16 Q_exc, Word32 old_fpitch, Word16 L L_acc = L_deposit_l( 0 ); L_c = L_deposit_l( 0 ); Overflow = 0; + move16(); Carry = 0; + move16(); tmp16 = round_fx( old_fpitch ); /*Q0*/ tmp_loop = shl( L_subfr, 1 ); @@ -46,29 +48,31 @@ static void calcGainc_fx( Word16 *exc, Word16 Q_exc, Word32 old_fpitch, Word16 L /*st->lp_gainc += ( exc[i-2*L_subfr] - st->Mode2_lp_gainp * exc[i-2*L_subfr-(int)(st->old_fpitch+0.5f)] ) * ( exc[i-2*L_subfr] - st->Mode2_lp_gainp * exc[i-2*L_subfr-(int)(st->old_fpitch+0.5f)] );*/ #ifdef BASOP_NOGLOB - tmp16_3 = sub_o( exc[i - 2 * L_subfr] /*Q1*/, mult_r( tmp16_2 /*Q15*/, exc[i - 2 * L_subfr - tmp16] /*Q1*/ ) /*Q1*/, &Overflow ); + tmp16_3 = sub_o( exc[sub( i, shl( L_subfr, 1 ) )] /*Q1*/, mult_r( tmp16_2 /*Q15*/, exc[sub( sub( i, shl( L_subfr, 1 ) ), tmp16 )] /*Q1*/ ) /*Q1*/, &Overflow ); #else - tmp16_3 = sub( exc[i - 2 * L_subfr] /*Q1*/, mult_r( tmp16_2 /*Q15*/, exc[i - 2 * L_subfr - tmp16] /*Q1*/ ) /*Q1*/ ); + tmp16_3 = sub( exc[sub( i, shl( L_subfr, 1 ) )] /*Q1*/, mult_r( tmp16_2 /*Q15*/, exc[sub( sub( i, shl( L_subfr, 1 ) ), tmp16 )] /*Q1*/ ) /*Q1*/ ); #endif #ifdef BASOP_NOGLOB L_acc = L_macNs_co( L_acc, tmp16_3, tmp16_3, &Carry, &Overflow ); /*Q3*/ #else - L_acc = L_macNs( L_acc, tmp16_3, tmp16_3 ); /*Q3*/ + L_acc = L_macNs( L_acc, tmp16_3, tmp16_3 ); /*Q3*/ #endif Overflow = 0; + move16(); #ifdef BASOP_NOGLOB L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); /*Accumulate Carrys*/ #else - L_c = L_macNs( L_c, 0, 0 ); /*Accumulate Carrys*/ + L_c = L_macNs( L_c, 0, 0 ); /*Accumulate Carrys*/ #endif Carry = 0; + move16(); } L_tmp = norm_llQ31( L_c, L_acc, &tmp_e ); /*Q3,norm,tmp_e*/ tmp_e = add( tmp_e, 31 - ( add( shl( Q_exc, 1 ), 1 ) ) ); /*L_tmp is Q31, now*/ tmp16 = BASOP_Util_Divide3216_Scale( L_tmp /*Q31,norm,tmp_e*/, shl( L_subfr, 1 ) /*Q15,15*/, &tmp2_e ) /*Q15,tmp2_e+tmp_e-15*/; tmp_e = sub( add( tmp2_e, tmp_e ), 15 ); - IF( tmp16 != 0 ) + IF( NE_16( tmp16, 0 ) ) { tmp16 = Sqrt16( tmp16, &tmp_e ); /*Q15,norm,tmp_e*/ } @@ -83,10 +87,14 @@ static void calcGainc2_fx( Word16 *exc, Word16 Q_exc, Word16 L_subfr, Word32 *lp Flag Overflow = 0; Flag Carry = 0; #endif + move16(); + move16(); Carry = 0; + move16(); Overflow = 0; + move16(); L_c = L_deposit_l( 0 ); L_acc = L_deposit_l( 0 ); @@ -96,22 +104,24 @@ static void calcGainc2_fx( Word16 *exc, Word16 Q_exc, Word16 L_subfr, Word32 *lp FOR( i = 0; i < cnt; i++ ) { /* *gainc += ( exc[i-2*L_subfr] ) * ( exc[i-2*L_subfr]); */ -#ifdef BASOP_NOGLOB /* Critical Carry/Overflow */ - L_acc = L_macNs_co( L_acc, exc[i - 2 * L_subfr] /*Q1*/, exc[i - 2 * L_subfr] /*Q1*/, &Carry, &Overflow ); /*Q3*/ +#ifdef BASOP_NOGLOB /* Critical Carry/Overflow */ + L_acc = L_macNs_co( L_acc, exc[sub( i, shl( L_subfr, 1 ) )] /*Q1*/, exc[sub( i, shl( L_subfr, 1 ) )] /*Q1*/, &Carry, &Overflow ); /*Q3*/ #else - L_acc = L_macNs( L_acc, exc[i - 2 * L_subfr] /*Q1*/, exc[i - 2 * L_subfr] /*Q1*/ ); /*Q3*/ + L_acc = L_macNs( L_acc, exc[sub( i, shl( L_subfr, 1 ) )] /*Q1*/, exc[sub( i, shl( L_subfr, 1 ) )] /*Q1*/ ); /*Q3*/ #endif Overflow = 0; + move16(); #ifdef BASOP_NOGLOB /* Critical Carry/Overflow */ L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); /* Accumulate Carrys */ #else - L_c = L_macNs( L_c, 0, 0 ); /* Accumulate Carrys */ + L_c = L_macNs( L_c, 0, 0 ); /* Accumulate Carrys */ #endif Carry = 0; + move16(); } - L_tmp = norm_llQ31( L_c, L_acc, &tmp_e ); /*Q3,norm,tmp_e*/ - tmp_e = add( tmp_e, 31 - ( add( shl( Q_exc, 1 ), 1 ) ) ); /*L_tmp is Q31, now*/ + L_tmp = norm_llQ31( L_c, L_acc, &tmp_e ); /*Q3,norm,tmp_e*/ + tmp_e = add( tmp_e, sub( 31, ( add( shl( Q_exc, 1 ), 1 ) ) ) ); /*L_tmp is Q31, now*/ tmp16 = BASOP_Util_Divide3216_Scale( L_tmp /*Q31,norm,tmp_e*/, shl( L_subfr, 1 ) /*Q15,15*/, &tmp2_e ) /*Q15,tmp2_e+tmp_e-15*/; tmp_e = sub( add( tmp2_e, tmp_e ), 15 ); @@ -223,7 +233,7 @@ void con_tcx_fx( st->L_frame, &s ); - FOR( i = 0; i < ( 2 * NB_SUBFR16k + 2 ); i++ ) + FOR( i = 0; i < 2 * NB_SUBFR16k + 2; i++ ) { old_pitch_buf[i] = L_shl( Mpy_32_16_1( st->old_pitch_buf_fx[i], c ), s ); move32(); @@ -240,12 +250,12 @@ void con_tcx_fx( IF( ( EQ_16( st->nbLostCmpt, 1 ) ) || hTcxDec->tcxConceal_recalc_exc ) { /* apply pre-emphasis to the signal */ - mem = synth[-( ( shr( L_frame, 1 ) ) + hTcxDec->pit_max_TCX + M + M ) - 1]; - Q_exc = E_UTIL_f_preemph3( &( synth[-( ( shr( L_frame, 1 ) ) + hTcxDec->pit_max_TCX + 2 * M )] ), st->preemph_fac, add( add( shr( L_frame, 1 ), hTcxDec->pit_max_TCX ), shl( M, 1 ) ), &mem, 1 ); + mem = synth[sub( -( add( add( shr( L_frame, 1 ), hTcxDec->pit_max_TCX ), M + M ) ), 1 )]; + move16(); + Q_exc = E_UTIL_f_preemph3( &( synth[-add( add( shr( L_frame, 1 ), hTcxDec->pit_max_TCX ), 2 * M )] ), st->preemph_fac, add( add( shr( L_frame, 1 ), hTcxDec->pit_max_TCX ), shl( M, 1 ) ), &mem, 1 ); st->Mode2_lp_gainc = L_deposit_l( 0 ); - st->Mode2_lp_gainp = get_gain2( synth - 2 * L_subfr, synth - 2 * L_subfr - Tc, shl( L_subfr, 1 ) ); - move32(); + st->Mode2_lp_gainp = get_gain2( synth - shl( L_subfr, 1 ), synth - add( shl( L_subfr, 1 ), Tc ), shl( L_subfr, 1 ) ); st->Mode2_lp_gainp = L_max( st->Mode2_lp_gainp, 0 ); st->Mode2_lp_gainp = L_min( st->Mode2_lp_gainp, 65536l /*1.0f Q16*/ ); @@ -255,7 +265,7 @@ void con_tcx_fx( ham_cos_window( ana_window, mult( L_frame, 24576 /*0.75f Q15*/ ), shr( L_frame, 2 ) ); /* Autocorrelation */ - autocorr_fx( &( synth[-L_frame - 1] ), M, r_h, r_l, &Q_r, L_frame, ana_window, 0, 0 ); + autocorr_fx( &( synth[sub( -L_frame, 1 )] ), M, r_h, r_l, &Q_r, L_frame, ana_window, 0, 0 ); /* Lag windowing */ lag_wind( r_h, r_l, M, st->output_Fs, LAGW_STRONG ); @@ -272,8 +282,8 @@ void con_tcx_fx( BASOP_SATURATE_WARNING_OFF_EVS /*saturation possible in case of spiky synthesis*/ Residu3_fx( A_local, - &( synth[-( 2 * L_subfr + Tc + 1 + M )] ), /*Qx = Q0*/ - &( exc[-( 2 * L_subfr + Tc + 1 + M )] ), /*Qx+1 = Q1*/ + &( synth[-add( add( add( shl( L_subfr, 1 ), Tc ), 1 ), M )] ), /*Qx = Q0*/ + &( exc[-add( add( add( shl( L_subfr, 1 ), Tc ), 1 ), M )] ), /*Qx+1 = Q1*/ add( add( add( shl( L_subfr, 1 ), Tc ), 1 ), M ), 1 ); BASOP_SATURATE_WARNING_ON_EVS @@ -281,19 +291,20 @@ void con_tcx_fx( ELSE { /* apply pre-emphasis to the signal */ - mem = synth[-L_frame - 1]; + mem = synth[sub( -L_frame, 1 )]; + move16(); Q_exc = E_UTIL_f_preemph3( &( synth[-L_frame] ), st->preemph_fac, L_frame, &mem, 1 ); - Copy( st->old_Aq_12_8_fx, A_local, M + 1 ); + Copy( st->old_Aq_12_8_fx, A_local, add( M, 1 ) ); offset = shr( L_frame, 1 ); IF( GE_16( st->last_good, UNVOICED_TRANSITION ) ) { tmp16 = s_max( Tc - shr( L_frame, 1 ), 0 ); - Copy_Scale_sig( hTcxDec->old_excFB_fx, &( exc[-tmp16] ), offset + tmp16, Q_exc - st->Q_exc ); + Copy_Scale_sig( hTcxDec->old_excFB_fx, &( exc[-tmp16] ), add( offset, tmp16 ), sub( Q_exc, st->Q_exc ) ); } ELSE { - Copy_Scale_sig( hTcxDec->old_excFB_fx, &( exc[-2 * L_subfr] ), 2 * L_subfr + offset, Q_exc - st->Q_exc ); + Copy_Scale_sig( hTcxDec->old_excFB_fx, &( exc[-shl( L_subfr, 1 )] ), add( shl( L_subfr, 1 ), offset ), sub( Q_exc, st->Q_exc ) ); } } @@ -305,7 +316,7 @@ void con_tcx_fx( test(); IF( GT_16( st->last_good, UNVOICED_CLAS ) && !( EQ_16( st->last_good, UNVOICED_TRANSITION ) && EQ_16( st->core_ext_mode, GENERIC ) ) ) { - + test(); IF( EQ_16( st->nbLostCmpt, 1 ) || hTcxDec->tcxConceal_recalc_exc ) { calcGainc_fx( exc, Q_exc, st->old_fpitchFB, L_subfr, st->Mode2_lp_gainp, &( st->Mode2_lp_gainc ) ); @@ -313,7 +324,7 @@ void con_tcx_fx( tmp16 = 0; move16(); - if ( GT_32( st->output_Fs, 25600 ) ) + IF( GT_32( st->output_Fs, 25600 ) ) { tmp16 = 1; move16(); @@ -334,8 +345,7 @@ void con_tcx_fx( test(); test(); - test(); - if ( ( T0 > 0 ) && ( NE_16( T0, Tc ) ) && ( LT_32( L_deposit_h( abs_s( sub( T0, Tc ) ) ) /*Q16*/, L_mult( 4915 /*.15f Q15*/ /*Q15*/, Tc /*Q0*/ ) /*Q16*/ ) ) ) + IF( GT_16( T0, 0 ) && NE_16( T0, Tc ) && LT_32( L_deposit_h( abs_s( sub( T0, Tc ) ) ) /*Q16*/, L_mult( 4915 /*.15f Q15*/ /*Q15*/, Tc /*Q0*/ ) /*Q16*/ ) ) { fUseExtrapolatedPitch = 1; move16(); @@ -343,7 +353,6 @@ void con_tcx_fx( } ELSE { - pitch_pred_linear_fit( st->nbLostCmpt, st->last_good, @@ -362,7 +371,7 @@ void con_tcx_fx( test(); test(); test(); - if ( ( T0 > 0 ) && ( NE_16( T0, Tc ) ) && ( LT_32( L_deposit_h( abs_s( sub( T0, Tc ) ) ) /*Q16*/, L_mult( 4915 /*.15f Q15*/ /*Q15*/, Tc /*Q0*/ ) /*Q16*/ ) ) && ( extrapolationFailed == 0 ) ) + IF( GT_16( T0, 0 ) && NE_16( T0, Tc ) && LT_32( L_deposit_h( abs_s( sub( T0, Tc ) ) ) /*Q16*/, L_mult( 4915 /*.15f Q15*/ /*Q15*/, Tc /*Q0*/ ) /*Q16*/ ) && EQ_16( extrapolationFailed, 0 ) ) { fUseExtrapolatedPitch = 1; move16(); @@ -375,7 +384,7 @@ void con_tcx_fx( pt_exc = exc + offset; pt1_exc = pt_exc - Tc; - if ( fUseExtrapolatedPitch != 0 ) + IF( NE_16( fUseExtrapolatedPitch, 0 ) ) { pt_exc = buf; } @@ -388,7 +397,6 @@ void con_tcx_fx( { 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] ), @@ -416,6 +424,7 @@ void con_tcx_fx( 0 /* 0.0000f Q15*/, pt1_exc[4] ), 174 /* 0.0053f Q15*/, pt1_exc[5] ); #endif + move16(); pt1_exc++; } } @@ -423,7 +432,6 @@ void con_tcx_fx( { 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] ), @@ -451,6 +459,7 @@ void con_tcx_fx( -121 /*-0.0037f Q15*/, pt1_exc[4] ), -174 /*-0.0053f Q15*/, pt1_exc[5] ); #endif + move16(); pt1_exc++; } } @@ -470,7 +479,7 @@ void con_tcx_fx( move16(); } - if ( fUseExtrapolatedPitch != 0 ) + IF( NE_16( fUseExtrapolatedPitch, 0 ) ) { pt1_exc = buf; } @@ -481,7 +490,7 @@ void con_tcx_fx( move16(); } - IF( fUseExtrapolatedPitch != 0 ) + IF( NE_16( fUseExtrapolatedPitch, 0 ) ) { get_subframe_pitch( st->nb_subfr, st->old_fpitch, @@ -504,7 +513,7 @@ void con_tcx_fx( IF( EQ_16( st->nbLostCmpt, 1 ) ) { pt_exc = exc + L_frame; - IF( T0 == 0 ) + IF( EQ_16( T0, 0 ) ) { pt1_exc = pt_exc - Tc; } @@ -521,10 +530,10 @@ void con_tcx_fx( } } - if ( fUseExtrapolatedPitch != 0 ) + IF( NE_16( fUseExtrapolatedPitch, 0 ) ) { st->old_fpitchFB = predPitchLag; - move16(); + move32(); } st->bpf_gain_param = 0; move16(); @@ -560,10 +569,13 @@ void con_tcx_fx( gain32 = L_add( 2147483647l /*1.f Q31*/, 0 ); /*Q31*/ gain = 32767 /*1.f Q15*/; /*Q15*/ move16(); - if ( EQ_16( st->rf_frame_type, RF_TCXTD1 ) && EQ_16( st->use_partial_copy, 1 ) ) + test(); + IF( EQ_16( st->rf_frame_type, RF_TCXTD1 ) && EQ_16( st->use_partial_copy, 1 ) ) { gain32 = 1073741824l /*0.5f Q31*/; + move32(); gain = 16384 /*0.5f Q15*/; + move16(); } /*step = (1.0f/(L_frame+(L_frame/2))) * (gain - alpha);*/ @@ -590,8 +602,8 @@ void con_tcx_fx( } /* update old exc without random part */ - offset = s_max( round_fx( st->old_fpitchFB ) - shr( L_frame, 1 ), 0 ); - Copy( exc + L_frame - offset, hTcxDec->old_excFB_fx, shr( L_frame, 1 ) + offset ); + offset = s_max( sub( round_fx( st->old_fpitchFB ), shr( L_frame, 1 ) ), 0 ); + Copy( exc + sub( L_frame, offset ), hTcxDec->old_excFB_fx, add( shr( L_frame, 1 ), offset ) ); /* copy old_exc as 16kHz for acelp decoding */ IF( EQ_16( st->nbLostCmpt, 1 ) ) { @@ -603,6 +615,7 @@ void con_tcx_fx( lerp( exc, st->old_exc_fx + L_FRAME16k / 2, L_FRAME16k, L_frame ); } st->Q_exc = Q_exc; + move16(); } ELSE { @@ -699,7 +712,7 @@ void con_tcx_fx( { tmp16 = 19661 /*0.6f Q15*/; move16(); - if ( LE_32( st->output_Fs, 16000 ) ) + IF( LE_32( st->output_Fs, 16000 ) ) { tmp16 = 6554 /*0.2f Q15*/; move16(); @@ -707,7 +720,7 @@ void con_tcx_fx( mem = noise[0]; move16(); - preemph_copy_fx( &noise[1], &noise[1], tmp16, L_frame + ( L_frame / 2 ) + L_FIR_FER2, &mem ); + preemph_copy_fx( &noise[1], &noise[1], tmp16, add( add( L_frame, shr( L_frame, 1 ) ), L_FIR_FER2 ), &mem ); } /* high rate filter tuning */ IF( LE_32( st->output_Fs, 16000 ) ) @@ -741,12 +754,13 @@ void con_tcx_fx( Word16 j; L_tmp2 = 0; move32(); - for ( j = 11; j > 0; j-- ) + FOR( j = 11; j > 0; j-- ) { - L_tmp2 = L_mac( L_tmp2, noise[i + L_FIR_FER2 - j], hp_filt[L_FIR_FER2 - j] ); + L_tmp2 = L_mac( L_tmp2, noise[add( i, sub( L_FIR_FER2, j ) )], hp_filt[sub( L_FIR_FER2, j )] ); } L_tmp2 = Mpy_32_16_1( L_tmp2, st->cummulative_damping /*Q15*/ ); /*Q0, noise_e*/ noise[i] = mac_r( L_tmp2, gain_tmp, noise[i] ); /*Q15, noise_e*/ + move16(); } } } @@ -766,7 +780,7 @@ void con_tcx_fx( move16(); gainSynthDeemph = getLevelSynDeemph_fx( &( tmp16 ), A_local, M, shr( L_frame, 2 ), st->preemph_fac, 1, &gainSynthDeemph_e ); #endif - IF( 0 != st->tcxonly ) + IF( NE_16( st->tcxonly, 0 ) ) { /* gainCNG = st->conCngLevelBackgroundTrace/gainSynthDeemph; */ BASOP_Util_Divide_MantExp( hTcxDec->conCngLevelBackgroundTrace, @@ -797,7 +811,8 @@ void con_tcx_fx( } gain32 = L_add( st->Mode2_lp_gainc, 0 ); /* start-of-the-frame gain - Q16*/ - if ( EQ_16( st->rf_frame_type, RF_TCXTD1 ) && EQ_16( st->use_partial_copy, 1 ) ) + test(); + IF( EQ_16( st->rf_frame_type, RF_TCXTD1 ) && EQ_16( st->use_partial_copy, 1 ) ) { gain32 = Mpy_32_16_1( gain32, 22938 /*0.7f Q15*/ ); } @@ -818,9 +833,7 @@ void con_tcx_fx( L_tmp = Mpy_32_16_1( st->Mode2_lp_gainc, alpha ) /*Q15*/; L_tmp2 = L_mult( sub( 16384 /*1.f Q14*/, alpha ) /*Q14*/, gainCNG /*Q15,gainCNG_e*/ ); /*Q30,gainCNG_e*/ st->Mode2_lp_gainc = BASOP_Util_Add_Mant32Exp( L_tmp, 31 - 15, L_tmp2, add( gainCNG_e, 31 - 30 ), &tmp_e ); /*Q31*/ - move32(); st->Mode2_lp_gainc = L_shl( st->Mode2_lp_gainc, sub( tmp_e, 31 - 16 ) ); - move32(); /* PLC: [TCX: Fade-out] Linearly attenuate the gain through the frame */ /*step = (1.0f/L_frame) * (gain - (st->Mode2_lp_gainc));*/ @@ -828,7 +841,7 @@ void con_tcx_fx( tmp_e = norm_l( L_tmp ); L_tmp = L_shl( L_tmp, tmp_e ); /*Q16,-tmp_e*/ step32 = Mpy_32_16_1( L_tmp /*Q16,-tmp_e*/, getInvFrameLen( L_frame ) /*W16Q21*/ ); /*Q22,-tmp_e*/ - step32 = L_shl( step32, sub( ( 25 - 22 ), tmp_e ) ); /*Q25*/ + step32 = L_shl( step32, sub( 25 - 22, tmp_e ) ); /*Q25*/ pt_exc = noise + L_FIR_FER2 / 2; @@ -855,7 +868,7 @@ void con_tcx_fx( #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*/ + gain_inov = round_fx( L_tmp ); /*Q15,gain_inov_e*/ #endif } @@ -876,8 +889,8 @@ void con_tcx_fx( pt_exc++; } tmp16 = add( L_frame, L_FIR_FER2 / 2 ); - step32_tmp = L_shl( step32 /*Q25*/, sub( tmp_e, ( 25 - 16 ) ) ); /*Q16,-tmp_e*/ - FOR( i = 0; i < tmp16; i++ ) /* Actual filtered random part of excitation */ + step32_tmp = L_shl( step32 /*Q25*/, sub( tmp_e, 25 - 16 ) ); /*Q16,-tmp_e*/ + FOR( i = 0; i < tmp16; i++ ) /* Actual filtered random part of excitation */ { *pt_exc = mult_r( *pt_exc, gain_tmp ); move16(); @@ -905,10 +918,10 @@ void con_tcx_fx( FOR( i = 0; i < tmp16; i++ ) { #ifdef BASOP_NOGLOB - exc[i] = add_sat( exc[i], shl_sat( noise[i + ( L_FIR_FER2 / 2 )], Q_exc + noise_e ) ); /*Q1*/ + exc[i] = add_sat( exc[i], shl_sat( noise[add( i, L_FIR_FER2 / 2 )], add( Q_exc, noise_e ) ) ); /*Q1*/ move16(); #else - exc[i] = add( exc[i], shl( noise[i + ( L_FIR_FER2 / 2 )], Q_exc + noise_e ) ); /*Q1*/ + exc[i] = add( exc[i], shl( noise[add( i, L_FIR_FER2 / 2 )], add( Q_exc, noise_e ) ) ); /*Q1*/ move16(); #endif } @@ -916,7 +929,7 @@ void con_tcx_fx( ELSE { bufferCopyFx( noise + L_FIR_FER2 / 2, exc, add( L_frame, shr( L_frame, 1 ) ), 0 /*Q_noise*/, noise_e, Q_exc, 0 /*exc_e*/ ); - Copy( exc + L_frame - 2 * L_subfr, hTcxDec->old_excFB_fx, 2 * L_subfr + shr( L_frame, 1 ) ); + Copy( exc + sub( L_frame, shl( L_subfr, 1 ) ), hTcxDec->old_excFB_fx, add( shl( L_subfr, 1 ), shr( L_frame, 1 ) ) ); /* copy old_exc as 16kHz for acelp decoding */ IF( EQ_16( st->nbLostCmpt, 1 ) ) { @@ -928,6 +941,7 @@ void con_tcx_fx( lerp( exc, st->old_exc_fx + L_FRAME16k / 2, L_FRAME16k, L_frame ); } st->Q_exc = Q_exc; + move16(); } /*buf[0;L_FIR_FER2 + L_Frame + L_Frame/2] Q0, noise_e*/ /*buf[OLD_EXC_SIZE_DEC;3/2 L_frame] Q1*/ @@ -950,7 +964,7 @@ void con_tcx_fx( st->prev_Q_syn = new_Q; move16(); - exp_scale = sub( tmp16, Q_exc - 1 ); + exp_scale = sub( tmp16, sub( Q_exc, 1 ) ); Q_syn = tmp16; move16(); @@ -962,6 +976,7 @@ void con_tcx_fx( tmp_deemph = shl( tmp_deemph, Q_syn ); #endif st->Q_syn = Q_syn; + move16(); /*buf[OLD_EXC_SIZE_DEC;3/2 L_frame] Q1: exc*/ /*buf[0;M] Q0: mem_syn*/ @@ -1014,28 +1029,30 @@ void con_tcx_fx( /* copy mem_syn as 16kHz */ mem_syn_r_size_new = shr( L_FRAME16k, 4 ); /* replace 1.25/20.0 by shr(4) */ - Copy( syn + L_frame - L_SYN_MEM, st->mem_syn_r, L_SYN_MEM ); - lerp( st->mem_syn_r + L_SYN_MEM - mem_syn_r_size_old, st->mem_syn_r + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old ); + Copy( syn + sub( L_frame, L_SYN_MEM ), st->mem_syn_r, L_SYN_MEM ); + lerp( st->mem_syn_r + sub( L_SYN_MEM, mem_syn_r_size_old ), st->mem_syn_r + sub( L_SYN_MEM, mem_syn_r_size_new ), mem_syn_r_size_new, mem_syn_r_size_old ); Copy( st->mem_syn_r + L_SYN_MEM - M, st->mem_syn2_fx, M ); /* Deemphasis and output synth and ZIR */ deemph_fx( syn, st->preemph_fac, add( L_frame, shr( L_frame, 1 ) ), &tmp_deemph ); - bufferCopyFx( syn + L_frame - M - 1, st->syn, 1 + M, Q_syn, 0, 0, 0 ); + bufferCopyFx( syn + sub( L_frame, M + 1 ), st->syn, 1 + M, Q_syn, 0, 0, 0 ); - lerp( syn + L_frame - shr( L_frame, 1 ), hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), shr( L_frame, 1 ) ); - Copy( syn + L_frame - n, hHQ_core->old_out_fx, sub( L_frame, n ) ); + lerp( syn + sub( L_frame, shr( L_frame, 1 ) ), hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), shr( L_frame, 1 ) ); + Copy( syn + sub( L_frame, n ), hHQ_core->old_out_fx, sub( L_frame, n ) ); FOR( i = 0; i < W12; i++ ) { - hHQ_core->old_out_fx[i + n] = round_fx( Mpy_32_16_1( L_mult( w[i].v.re, w[i].v.re ), hHQ_core->old_out_fx[i + n] ) ); + hHQ_core->old_out_fx[add( i, n )] = round_fx( Mpy_32_16_1( L_mult( w[i].v.re, w[i].v.re ), hHQ_core->old_out_fx[add( i, n )] ) ); + move16(); } FOR( ; i < W1; i++ ) { - hHQ_core->old_out_fx[i + n] = round_fx( Mpy_32_16_1( L_mult( w[W12 - 1 - ( i - W12 )].v.im, w[W12 - 1 - ( i - W12 )].v.im ), hHQ_core->old_out_fx[i + n] ) ); + hHQ_core->old_out_fx[add( i, n )] = round_fx( Mpy_32_16_1( L_mult( w[sub( sub( W12, 1 ), sub( i, W12 ) )].v.im, w[sub( sub( W12, 1 ), sub( i, W12 ) )].v.im ), hHQ_core->old_out_fx[add( i, n )] ) ); + move16(); } - set16_fx( &hHQ_core->old_out_fx[W1 + n], 0, n ); + set16_fx( &hHQ_core->old_out_fx[add( W1, n )], 0, n ); hHQ_core->Q_old_wtda = Q_syn; move16(); @@ -1056,11 +1073,10 @@ void con_tcx_fx( } #ifdef BASOP_NOGLOB - st->bfi_pitch_fx /*Q6*/ = round_fx_sat( L_shl_sat( pitch_buf[st->nb_subfr - 1] /*15Q16*/, 6 /*Q6*/ ) ); + st->bfi_pitch_fx /*Q6*/ = round_fx_sat( L_shl_sat( pitch_buf[sub( st->nb_subfr, 1 )] /*15Q16*/, 6 /*Q6*/ ) ); #else - st->bfi_pitch_fx /*Q6*/ = round_fx( L_shl( pitch_buf[st->nb_subfr - 1] /*15Q16*/, 6 /*Q6*/ ) ); + st->bfi_pitch_fx /*Q6*/ = round_fx( L_shl( pitch_buf[sub( st->nb_subfr, 1 )] /*15Q16*/, 6 /*Q6*/ ) ); #endif - move16(); st->bfi_pitch_frame = st->L_frame; move16(); @@ -1074,7 +1090,7 @@ void con_tcx_fx( } FOR( ; i < W1; i++ ) { - buf[i] = mult_r( hTcxDec->syn_Overl_TDACFB[i], w[W12 - 1 - ( i - W12 )].v.im ); + buf[i] = mult_r( hTcxDec->syn_Overl_TDACFB[i], w[sub( sub( W12, 1 ), sub( i, W12 ) )].v.im ); move16(); } @@ -1082,9 +1098,9 @@ void con_tcx_fx( FOR( i = 0; i < W2; i++ ) { #ifdef BASOP_NOGLOB - hTcxDec->syn_Overl_TDACFB[i] = add_sat( buf[i], buf[W1 - 1 - i] ); + hTcxDec->syn_Overl_TDACFB[i] = add_sat( buf[i], buf[sub( sub( W1, 1 ), i )] ); #else - hTcxDec->syn_Overl_TDACFB[i] = add( buf[i], buf[W1 - 1 - i] ); + hTcxDec->syn_Overl_TDACFB[i] = add( buf[i], buf[sub( sub( W1, 1 ), i )] ); #endif move16(); } @@ -1092,9 +1108,9 @@ void con_tcx_fx( FOR( i = 0; i < W2; i++ ) { #ifdef BASOP_NOGLOB - hTcxDec->syn_Overl_TDACFB[W2 + i] = add_sat( buf[W2 + i], buf[W1 - 1 - W2 - i] ); + hTcxDec->syn_Overl_TDACFB[add( W2, i )] = add_sat( buf[add( W2, i )], buf[sub( sub( sub( W1, 1 ), W2 ), i )] ); #else - hTcxDec->syn_Overl_TDACFB[W2 + i] = add( buf[W2 + i], buf[W1 - 1 - W2 - i] ); + hTcxDec->syn_Overl_TDACFB[add( W2, i )] = add( buf[add( W2, i )], buf[sub( sub( sub( W1, 1 ), W2 ), i )] ); #endif move16(); } @@ -1106,11 +1122,12 @@ void con_tcx_fx( } FOR( ; i < W1; i++ ) { - hTcxDec->syn_Overl_TDACFB[i] = mult_r( hTcxDec->syn_Overl_TDACFB[i], w[W12 - 1 - ( i - W12 )].v.im ); + hTcxDec->syn_Overl_TDACFB[i] = mult_r( hTcxDec->syn_Overl_TDACFB[i], w[sub( sub( W12, 1 ), sub( i, W12 ) )].v.im ); move16(); } st->hTcxCfg->tcx_curr_overlap_mode = FULL_OVERLAP; + move16(); synth[-1] = pre_emph_buf; move16(); @@ -1194,7 +1211,6 @@ void con_tcx_ivas_fx( /* L_subfr = st->L_frameTCX/st->nb_subfr */ L_subfr = mult_r( hTcxDec->L_frameTCX, div_s( 1, st->nb_subfr ) ); assert( L_subfr == hTcxDec->L_frameTCX / st->nb_subfr ); - move32(); w = st->hTcxCfg->tcx_mdct_windowFB; /*pointer - no need to instrument*/ W1 = st->hTcxCfg->tcx_mdct_window_lengthFB; move16(); @@ -1213,7 +1229,7 @@ void con_tcx_ivas_fx( st->L_frame, &s ); - FOR( i = 0; i < ( 2 * NB_SUBFR16k + 2 ); i++ ) + FOR( i = 0; i < 2 * NB_SUBFR16k + 2; i++ ) { old_pitch_buf[i] = L_shl( Mpy_32_16_1( st->old_pitch_buf_fx[i], c ), s ); move32(); @@ -1230,12 +1246,12 @@ void con_tcx_ivas_fx( IF( ( EQ_16( st->nbLostCmpt, 1 ) ) || hTcxDec->tcxConceal_recalc_exc ) { /* apply pre-emphasis to the signal */ - mem = synth[-( ( shr( L_frame, 1 ) ) + hTcxDec->pit_max_TCX + M + M ) - 1]; - Q_exc = E_UTIL_f_preemph3( &( synth[-( ( shr( L_frame, 1 ) ) + hTcxDec->pit_max_TCX + 2 * M )] ), st->preemph_fac, add( add( shr( L_frame, 1 ), hTcxDec->pit_max_TCX ), shl( M, 1 ) ), &mem, 1 ); + mem = synth[sub( -add( add( shr( L_frame, 1 ), hTcxDec->pit_max_TCX ), M + M ), 1 )]; + move16(); + Q_exc = E_UTIL_f_preemph3( &( synth[-add( add( shr( L_frame, 1 ), hTcxDec->pit_max_TCX ), 2 * M )] ), st->preemph_fac, add( add( shr( L_frame, 1 ), hTcxDec->pit_max_TCX ), shl( M, 1 ) ), &mem, 1 ); st->Mode2_lp_gainc = L_deposit_l( 0 ); - st->Mode2_lp_gainp = get_gain2( synth - 2 * L_subfr, synth - 2 * L_subfr - Tc, shl( L_subfr, 1 ) ); - move32(); + st->Mode2_lp_gainp = get_gain2( synth - shl( L_subfr, 1 ), synth - add( shl( L_subfr, 1 ), Tc ), shl( L_subfr, 1 ) ); st->Mode2_lp_gainp = L_max( st->Mode2_lp_gainp, 0 ); st->Mode2_lp_gainp = L_min( st->Mode2_lp_gainp, 65536l /*1.0f Q16*/ ); @@ -1245,7 +1261,7 @@ void con_tcx_ivas_fx( ham_cos_window( ana_window, mult( L_frame, 24576 /*0.75f Q15*/ ), shr( L_frame, 2 ) ); /* Autocorrelation */ - autocorr_fx( &( synth[-L_frame - 1] ), M, r_h, r_l, &Q_r, L_frame, ana_window, 0, 0 ); + autocorr_fx( &( synth[sub( -L_frame, 1 )] ), M, r_h, r_l, &Q_r, L_frame, ana_window, 0, 0 ); /* Lag windowing */ lag_wind( r_h, r_l, M, st->output_Fs, LAGW_STRONG ); @@ -1262,8 +1278,8 @@ void con_tcx_ivas_fx( BASOP_SATURATE_WARNING_OFF_EVS /*saturation possible in case of spiky synthesis*/ Residu3_fx( A_local, - &( synth[-( 2 * L_subfr + Tc + 1 + M )] ), /*Qx = Q0*/ - &( exc[-( 2 * L_subfr + Tc + 1 + M )] ), /*Qx+1 = Q1*/ + &( synth[-add( add( add( shl( L_subfr, 1 ), Tc ), 1 ), M )] ), /*Qx = Q0*/ + &( exc[-add( add( add( shl( L_subfr, 1 ), Tc ), 1 ), M )] ), /*Qx+1 = Q1*/ add( add( add( shl( L_subfr, 1 ), Tc ), 1 ), M ), 1 ); BASOP_SATURATE_WARNING_ON_EVS @@ -1271,19 +1287,20 @@ void con_tcx_ivas_fx( ELSE { /* apply pre-emphasis to the signal */ - mem = synth[-L_frame - 1]; + mem = synth[sub( -L_frame, 1 )]; + move16(); Q_exc = E_UTIL_f_preemph3( &( synth[-L_frame] ), st->preemph_fac, L_frame, &mem, 1 ); - Copy( st->old_Aq_12_8_fx, A_local, M + 1 ); + Copy( st->old_Aq_12_8_fx, A_local, add( M, 1 ) ); offset = shr( L_frame, 1 ); IF( GE_16( st->last_good, UNVOICED_TRANSITION ) ) { tmp16 = s_max( Tc - shr( L_frame, 1 ), 0 ); - Copy_Scale_sig( hTcxDec->old_excFB_fx, &( exc[-tmp16] ), offset + tmp16, Q_exc - st->Q_exc ); + Copy_Scale_sig( hTcxDec->old_excFB_fx, &( exc[-tmp16] ), add( offset, tmp16 ), sub( Q_exc, st->Q_exc ) ); } ELSE { - Copy_Scale_sig( hTcxDec->old_excFB_fx, &( exc[-2 * L_subfr] ), 2 * L_subfr + offset, Q_exc - st->Q_exc ); + Copy_Scale_sig( hTcxDec->old_excFB_fx, &( exc[-shl( L_subfr, 1 )] ), add( shl( L_subfr, 1 ), offset ), sub( Q_exc, st->Q_exc ) ); } } @@ -1295,7 +1312,7 @@ void con_tcx_ivas_fx( test(); IF( GT_16( st->last_good, UNVOICED_CLAS ) && !( EQ_16( st->last_good, UNVOICED_TRANSITION ) && EQ_16( st->core_ext_mode, GENERIC ) ) ) { - + test(); IF( EQ_16( st->nbLostCmpt, 1 ) || hTcxDec->tcxConceal_recalc_exc ) { calcGainc_fx( exc, Q_exc, st->old_fpitchFB, L_subfr, st->Mode2_lp_gainp, &( st->Mode2_lp_gainc ) ); @@ -1303,7 +1320,7 @@ void con_tcx_ivas_fx( tmp16 = 0; move16(); - if ( GT_32( st->output_Fs, 25600 ) ) + IF( GT_32( st->output_Fs, 25600 ) ) { tmp16 = 1; move16(); @@ -1324,8 +1341,7 @@ void con_tcx_ivas_fx( test(); test(); - test(); - if ( ( T0 > 0 ) && ( NE_16( T0, Tc ) ) && ( LT_32( L_deposit_h( abs_s( sub( T0, Tc ) ) ) /*Q16*/, L_mult( 4915 /*.15f Q15*/ /*Q15*/, Tc /*Q0*/ ) /*Q16*/ ) ) ) + IF( GT_16( T0, 0 ) && NE_16( T0, Tc ) && LT_32( L_deposit_h( abs_s( sub( T0, Tc ) ) ) /*Q16*/, L_mult( 4915 /*.15f Q15*/ /*Q15*/, Tc /*Q0*/ ) /*Q16*/ ) ) { fUseExtrapolatedPitch = 1; move16(); @@ -1352,7 +1368,7 @@ void con_tcx_ivas_fx( test(); test(); test(); - if ( ( T0 > 0 ) && ( NE_16( T0, Tc ) ) && ( LT_32( L_deposit_h( abs_s( sub( T0, Tc ) ) ) /*Q16*/, L_mult( 4915 /*.15f Q15*/ /*Q15*/, Tc /*Q0*/ ) /*Q16*/ ) ) && ( extrapolationFailed == 0 ) ) + IF( GT_16( T0, 0 ) && NE_16( T0, Tc ) && LT_32( L_deposit_h( abs_s( sub( T0, Tc ) ) ) /*Q16*/, L_mult( 4915 /*.15f Q15*/ /*Q15*/, Tc /*Q0*/ ) /*Q16*/ ) && EQ_16( extrapolationFailed, 0 ) ) { fUseExtrapolatedPitch = 1; move16(); @@ -1365,7 +1381,7 @@ void con_tcx_ivas_fx( pt_exc = exc + offset; pt1_exc = pt_exc - Tc; - if ( fUseExtrapolatedPitch != 0 ) + IF( NE_16( fUseExtrapolatedPitch, 0 ) ) { pt_exc = buf; } @@ -1378,7 +1394,6 @@ void con_tcx_ivas_fx( { FOR( i = 0; i < Tc; i++ ) { - move16(); *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] ), @@ -1391,6 +1406,7 @@ void con_tcx_ivas_fx( -1442 /*-0.0440f Q15*/, pt1_exc[3] ), 0 /* 0.0000f Q15*/, pt1_exc[4] ), 174 /* 0.0053f Q15*/, pt1_exc[5] ); + move16(); pt1_exc++; } } @@ -1398,7 +1414,6 @@ void con_tcx_ivas_fx( { FOR( i = 0; i < Tc; i++ ) { - move16(); *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] ), @@ -1411,6 +1426,7 @@ void con_tcx_ivas_fx( -459 /*-0.0140f Q15*/, pt1_exc[3] ), -121 /*-0.0037f Q15*/, pt1_exc[4] ), -174 /*-0.0053f Q15*/, pt1_exc[5] ); + move16(); pt1_exc++; } } @@ -1430,7 +1446,7 @@ void con_tcx_ivas_fx( move16(); } - if ( fUseExtrapolatedPitch != 0 ) + IF( NE_16( fUseExtrapolatedPitch, 0 ) ) { pt1_exc = buf; } @@ -1441,7 +1457,7 @@ void con_tcx_ivas_fx( move16(); } - IF( fUseExtrapolatedPitch != 0 ) + IF( NE_16( fUseExtrapolatedPitch, 0 ) ) { get_subframe_pitch( st->nb_subfr, st->old_fpitch, @@ -1464,7 +1480,7 @@ void con_tcx_ivas_fx( IF( EQ_16( st->nbLostCmpt, 1 ) ) { pt_exc = exc + L_frame; - IF( T0 == 0 ) + IF( EQ_16( T0, 0 ) ) { pt1_exc = pt_exc - Tc; } @@ -1481,10 +1497,10 @@ void con_tcx_ivas_fx( } } - if ( fUseExtrapolatedPitch != 0 ) + IF( NE_16( fUseExtrapolatedPitch, 0 ) ) { st->old_fpitchFB = predPitchLag; - move16(); + move32(); } st->bpf_gain_param = 0; move16(); @@ -1520,10 +1536,13 @@ void con_tcx_ivas_fx( gain32 = L_add( 2147483647l /*1.f Q31*/, 0 ); /*Q31*/ gain = 32767 /*1.f Q15*/; /*Q15*/ move16(); - if ( EQ_16( st->rf_frame_type, RF_TCXTD1 ) && EQ_16( st->use_partial_copy, 1 ) ) + test(); + IF( EQ_16( st->rf_frame_type, RF_TCXTD1 ) && EQ_16( st->use_partial_copy, 1 ) ) { gain32 = 1073741824l /*0.5f Q31*/; + move32(); gain = 16384 /*0.5f Q15*/; + move16(); } /*step = (1.0f/(L_frame+(L_frame/2))) * (gain - alpha);*/ @@ -1550,8 +1569,8 @@ void con_tcx_ivas_fx( } /* update old exc without random part */ - offset = s_max( round_fx( st->old_fpitchFB ) - shr( L_frame, 1 ), 0 ); - Copy( exc + L_frame - offset, hTcxDec->old_excFB_fx, shr( L_frame, 1 ) + offset ); + offset = s_max( sub( round_fx( st->old_fpitchFB ), shr( L_frame, 1 ) ), 0 ); + Copy( exc + sub( L_frame, offset ), hTcxDec->old_excFB_fx, add( shr( L_frame, 1 ), offset ) ); /* copy old_exc as 16kHz for acelp decoding */ IF( EQ_16( st->nbLostCmpt, 1 ) ) { @@ -1563,6 +1582,7 @@ void con_tcx_ivas_fx( lerp( exc, st->old_exc_fx + L_FRAME16k / 2, L_FRAME16k, L_frame ); } st->Q_exc = Q_exc; + move16(); } ELSE { @@ -1593,44 +1613,52 @@ void con_tcx_ivas_fx( * Construct the random part of excitation *-----------------------------------------------------------------*/ #ifndef IVAS_CODE_CON_TCX - IF( coh != -16384 ) + IF( NE_16( coh, -16384 ) ) { Word16 tmpSeed1; Word16 alpha_coh; Word16 random1, random2; + Word16 e; tmpSeed1 = *noise_seed; noise = buf; noise_e = 1; - Word16 e = 0; + move16(); + e = 0; + move16(); alpha_coh = 0; + move16(); IF( NE_16( coh, 16384 ) ) { - alpha_coh = Sqrt16( div_s( ( 16384 - coh ), ( 16384 + coh ) ), &e ); + alpha_coh = Sqrt16( div_s( sub( 16384, coh ), add( 16384, coh ) ), &e ); } - IF( st->idchan == 1 ) + IF( EQ_16( st->idchan, 1 ) ) { alpha_coh = negate( alpha_coh ); } - FOR( i = 0; i < L_frame + L_FIR_FER2 - 1; i++ ) + FOR( i = 0; i < add( L_frame, L_FIR_FER2 - 1 ); i++ ) { random1 = own_random2_fx( tmpSeed1 ); random2 = own_random2_fx( tmpSeed1 ); noise[i] = add( shr( random1, noise_e ), shr( mult( alpha_coh, random2 ), noise_e ) ); + move16(); } - IF( st->idchan == 1 || only_left ) + test(); + IF( EQ_16( st->idchan, 1 ) || only_left ) { *noise_seed = tmpSeed1; + move16(); } - FOR( ; i < L_frame + ( L_frame / 2 ) + 2 * L_FIR_FER2; i++ ) + FOR( ; i < add( add( L_frame, shr( L_frame, 1 ) ), 2 * L_FIR_FER2 ); i++ ) { random1 = own_random2_fx( tmpSeed1 ); random2 = own_random2_fx( tmpSeed1 ); noise[i] = add( shr( random1, noise_e ), shr( mult( alpha_coh, random2 ), noise_e ) ); + move16(); } } ELSE @@ -1665,7 +1693,7 @@ void con_tcx_ivas_fx( { tmp16 = 19661 /*0.6f Q15*/; move16(); - if ( LE_32( st->output_Fs, 16000 ) ) + IF( LE_32( st->output_Fs, 16000 ) ) { tmp16 = 6554 /*0.2f Q15*/; move16(); @@ -1673,7 +1701,7 @@ void con_tcx_ivas_fx( mem = noise[0]; move16(); - preemph_copy_fx( &noise[1], &noise[1], tmp16, L_frame + ( L_frame / 2 ) + L_FIR_FER2, &mem ); + preemph_copy_fx( &noise[1], &noise[1], tmp16, add( add( L_frame, shr( L_frame, 1 ) ), L_FIR_FER2 ), &mem ); } /* high rate filter tuning */ IF( LE_32( st->output_Fs, 16000 ) ) @@ -1707,9 +1735,9 @@ void con_tcx_ivas_fx( Word16 j; L_tmp2 = 0; move32(); - for ( j = 11; j > 0; j-- ) + FOR( j = 11; j > 0; j-- ) { - L_tmp2 = L_mac( L_tmp2, noise[i + L_FIR_FER2 - j], hp_filt[L_FIR_FER2 - j] ); + L_tmp2 = L_mac( L_tmp2, noise[add( i, sub( L_FIR_FER2, j ) )], hp_filt[sub( L_FIR_FER2, j )] ); } L_tmp2 = Mpy_32_16_1( L_tmp2, st->cummulative_damping /*Q15*/ ); /*Q0, noise_e*/ noise[i] = mac_r( L_tmp2, gain_tmp, noise[i] ); /*Q15, noise_e*/ @@ -1720,6 +1748,7 @@ void con_tcx_ivas_fx( /* PLC: [TCX: Fade-out] retrieve background level */ #ifndef IVAS_CODE_CNG_FIX185_PLC_FADEOUT tmp16 = 32767; + move16(); IF( A_cng != NULL ) { gainSynthDeemph = shr( getLevelSynDeemph_fx( &( tmp16 ), A_cng, M, shr( L_frame, 2 ), st->preemph_fac, 1, &gainSynthDeemph_e ), 2 ); @@ -1733,7 +1762,7 @@ void con_tcx_ivas_fx( move16(); gainSynthDeemph = getLevelSynDeemph_fx( &( tmp16 ), A_local, M, shr( L_frame, 2 ), st->preemph_fac, 1, &gainSynthDeemph_e ); #endif - IF( 0 != st->tcxonly ) + IF( NE_16( st->tcxonly, 0 ) ) { /* gainCNG = st->conCngLevelBackgroundTrace/gainSynthDeemph; */ BASOP_Util_Divide_MantExp( hTcxDec->conCngLevelBackgroundTrace, @@ -1741,11 +1770,13 @@ void con_tcx_ivas_fx( gainSynthDeemph, gainSynthDeemph_e, &gainCNG, &gainCNG_e ); #ifndef IVAS_CODE_CNG_FIX185_PLC_FADEOUT - IF( st->element_mode == IVAS_CPE_MDCT && A_cng != NULL ) + test(); + IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && A_cng != NULL ) { IF( GT_16( st->nbLostCmpt, add( MDCT_ST_PLC_FADEOUT_MAX_CONC_FRAME, MDCT_ST_PLC_FADEOUT_TO_ZERO_LEN ) ) ) { gainCNG = 0; + move16(); } ELSE IF( GT_16( st->nbLostCmpt, MDCT_ST_PLC_FADEOUT_MAX_CONC_FRAME ) ) { @@ -1786,9 +1817,7 @@ void con_tcx_ivas_fx( L_tmp = Mpy_32_16_1( st->Mode2_lp_gainc, alpha ) /*Q15*/; L_tmp2 = L_mult( sub( 16384 /*1.f Q14*/, alpha ) /*Q14*/, gainCNG /*Q15,gainCNG_e*/ ); /*Q30,gainCNG_e*/ st->Mode2_lp_gainc = BASOP_Util_Add_Mant32Exp( L_tmp, 31 - 15, L_tmp2, add( gainCNG_e, 31 - 30 ), &tmp_e ); /*Q31*/ - move32(); st->Mode2_lp_gainc = L_shl( st->Mode2_lp_gainc, sub( tmp_e, 31 - 16 ) ); - move32(); /* PLC: [TCX: Fade-out] Linearly attenuate the gain through the frame */ /*step = (1.0f/L_frame) * (gain - (st->Mode2_lp_gainc));*/ @@ -1796,17 +1825,17 @@ void con_tcx_ivas_fx( tmp_e = norm_l( L_tmp ); L_tmp = L_shl( L_tmp, tmp_e ); /*Q16,-tmp_e*/ step32 = Mpy_32_16_1( L_tmp /*Q16,-tmp_e*/, getInvFrameLen( L_frame ) /*W16Q21*/ ); /*Q22,-tmp_e*/ - step32 = L_shl( step32, sub( ( 25 - 22 ), tmp_e ) ); /*Q25*/ + step32 = L_shl( step32, sub( 25 - 22, tmp_e ) ); /*Q25*/ - pt_exc = noise + L_FIR_FER2 / 2; + pt_exc = noise + shr( L_FIR_FER2, 1 ); /*gain_inov = 1.0f / (float)sqrt( dot_product( pt_exc, pt_exc, L_frame ) / L_frame + 0.01f );*/ /* normalize energy */ L_tmp = Dot_productSq16HQ( 0, pt_exc /*Q0,15+1*/, L_frame, &tmp_e ) /*Q31,tmp_e+16+16*/; L_tmp = Mpy_32_16_1( L_tmp, getInvFrameLen( L_frame ) /*W16Q21*/ ) /*W32Q37,tmp_e+16+16*/ /*Q5,tmp_e*/; tmp_e = add( tmp_e, 31 - 5 ); /*-->Q31*/ gain_inov = 0; - gain_inov_e = 0; move16(); + gain_inov_e = 0; move16(); IF( NE_32( L_tmp, 0 ) ) { @@ -1847,8 +1876,8 @@ void con_tcx_ivas_fx( pt_exc++; } tmp16 = add( L_frame, L_FIR_FER2 / 2 ); - step32_tmp = L_shl( step32 /*Q25*/, sub( tmp_e, ( 25 - 16 ) ) ); /*Q16,-tmp_e*/ - FOR( i = 0; i < tmp16; i++ ) /* Actual filtered random part of excitation */ + step32_tmp = L_shl( step32 /*Q25*/, sub( tmp_e, 25 - 16 ) ); /*Q16,-tmp_e*/ + FOR( i = 0; i < tmp16; i++ ) /* Actual filtered random part of excitation */ { *pt_exc = mult_r( *pt_exc, gain_tmp ); move16(); @@ -1876,10 +1905,10 @@ void con_tcx_ivas_fx( FOR( i = 0; i < tmp16; i++ ) { #ifdef BASOP_NOGLOB - exc[i] = add_sat( exc[i], shl_sat( noise[i + ( L_FIR_FER2 / 2 )], Q_exc + noise_e ) ); /*Q1*/ + exc[i] = add_sat( exc[i], shl_sat( noise[add( i, L_FIR_FER2 / 2 )], add( Q_exc, noise_e ) ) ); /*Q1*/ move16(); #else - exc[i] = add( exc[i], shl( noise[i + ( L_FIR_FER2 / 2 )], Q_exc + noise_e ) ); /*Q1*/ + exc[i] = add( exc[i], shl( noise[add( i, L_FIR_FER2 / 2 )], add( Q_exc, noise_e ) ) ); /*Q1*/ move16(); #endif } @@ -1887,7 +1916,7 @@ void con_tcx_ivas_fx( ELSE { bufferCopyFx( noise + L_FIR_FER2 / 2, exc, add( L_frame, shr( L_frame, 1 ) ), 0 /*Q_noise*/, noise_e, Q_exc, 0 /*exc_e*/ ); - Copy( exc + L_frame - 2 * L_subfr, hTcxDec->old_excFB_fx, 2 * L_subfr + shr( L_frame, 1 ) ); + Copy( exc + sub( L_frame, shl( L_subfr, 1 ) ), hTcxDec->old_excFB_fx, add( shl( L_subfr, 1 ), shr( L_frame, 1 ) ) ); /* copy old_exc as 16kHz for acelp decoding */ IF( EQ_16( st->nbLostCmpt, 1 ) ) { @@ -1899,6 +1928,7 @@ void con_tcx_ivas_fx( lerp( exc, st->old_exc_fx + L_FRAME16k / 2, L_FRAME16k, L_frame ); } st->Q_exc = Q_exc; + move16(); } /*buf[0;L_FIR_FER2 + L_Frame + L_Frame/2] Q0, noise_e*/ /*buf[OLD_EXC_SIZE_DEC;3/2 L_frame] Q1*/ @@ -1921,7 +1951,7 @@ void con_tcx_ivas_fx( st->prev_Q_syn = new_Q; move16(); - exp_scale = sub( tmp16, Q_exc - 1 ); + exp_scale = sub( tmp16, sub( Q_exc, 1 ) ); Q_syn = tmp16; move16(); @@ -1933,21 +1963,24 @@ void con_tcx_ivas_fx( tmp_deemph = shl( tmp_deemph, Q_syn ); #endif st->Q_syn = Q_syn; + move16(); /*buf[OLD_EXC_SIZE_DEC;3/2 L_frame] Q1: exc*/ /*buf[0;M] Q0: mem_syn*/ #ifndef IVAS_CODE_CNG_FIX185_PLC_FADEOUT - if ( A_cng != NULL ) + IF( A_cng != NULL ) { Word16 alpha_delayed; alpha_delayed = 16384; - IF( st->nbLostCmpt > MDCT_ST_PLC_FADEOUT_DELAY_4_LSP_FADE ) + move16(); + IF( GT_16( st->nbLostCmpt, MDCT_ST_PLC_FADEOUT_DELAY_4_LSP_FADE ) ) { alpha_delayed = Damping_fact_fx( st->core_ext_mode, st->nbLostCmpt - MDCT_ST_PLC_FADEOUT_DELAY_4_LSP_FADE, st->last_good, st->stab_fac_fx, &( st->Mode2_lp_gainp ), ACELP_CORE ); } - IF( st->plcBackgroundNoiseUpdated && alpha_delayed != 16384 ) + test(); + IF( st->plcBackgroundNoiseUpdated && NE_16( alpha_delayed, 16384 ) ) { Word16 lsp_local[M], lsp_fade[M], alpha_inv; @@ -1958,6 +1991,7 @@ void con_tcx_ivas_fx( FOR( i = 0; i < M; i++ ) { lsp_fade[i] = add( mult_r( alpha_delayed, lsp_local[i] ), mult_r( alpha_inv, st->lspold_cng[i] ) ); + move16(); } E_LPC_f_lsp_a_conversion( lsp_fade, A_local, M ); @@ -1985,28 +2019,30 @@ void con_tcx_ivas_fx( /* copy mem_syn as 16kHz */ mem_syn_r_size_new = shr( L_FRAME16k, 4 ); /* replace 1.25/20.0 by shr(4) */ - Copy( syn + L_frame - L_SYN_MEM, st->mem_syn_r, L_SYN_MEM ); - lerp( st->mem_syn_r + L_SYN_MEM - mem_syn_r_size_old, st->mem_syn_r + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old ); + Copy( syn + sub( L_frame, L_SYN_MEM ), st->mem_syn_r, L_SYN_MEM ); + lerp( st->mem_syn_r + sub( L_SYN_MEM, mem_syn_r_size_old ), st->mem_syn_r + sub( L_SYN_MEM, mem_syn_r_size_new ), mem_syn_r_size_new, mem_syn_r_size_old ); Copy( st->mem_syn_r + L_SYN_MEM - M, st->mem_syn2_fx, M ); /* Deemphasis and output synth and ZIR */ deemph_fx( syn, st->preemph_fac, add( L_frame, shr( L_frame, 1 ) ), &tmp_deemph ); - bufferCopyFx( syn + L_frame - M - 1, st->syn, 1 + M, Q_syn, 0, 0, 0 ); + bufferCopyFx( syn + sub( L_frame, M + 1 ), st->syn, 1 + M, Q_syn, 0, 0, 0 ); - lerp( syn + L_frame - shr( L_frame, 1 ), hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), shr( L_frame, 1 ) ); - Copy( syn + L_frame - n, hHQ_core->old_out_fx, sub( L_frame, n ) ); + lerp( syn + sub( L_frame, shr( L_frame, 1 ) ), hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), shr( L_frame, 1 ) ); + Copy( syn + sub( L_frame, n ), hHQ_core->old_out_fx, sub( L_frame, n ) ); FOR( i = 0; i < W12; i++ ) { - hHQ_core->old_out_fx[i + n] = round_fx( Mpy_32_16_1( L_mult( w[i].v.re, w[i].v.re ), hHQ_core->old_out_fx[i + n] ) ); + hHQ_core->old_out_fx[add( i, n )] = round_fx( Mpy_32_16_1( L_mult( w[i].v.re, w[i].v.re ), hHQ_core->old_out_fx[add( i, n )] ) ); + move16(); } FOR( ; i < W1; i++ ) { - hHQ_core->old_out_fx[i + n] = round_fx( Mpy_32_16_1( L_mult( w[W12 - 1 - ( i - W12 )].v.im, w[W12 - 1 - ( i - W12 )].v.im ), hHQ_core->old_out_fx[i + n] ) ); + hHQ_core->old_out_fx[add( i, n )] = round_fx( Mpy_32_16_1( L_mult( w[sub( sub( W12, 1 ), sub( i, W12 ) )].v.im, w[sub( sub( W12, 1 ), sub( i, W12 ) )].v.im ), hHQ_core->old_out_fx[add( i, n )] ) ); + move16(); } - set16_fx( &hHQ_core->old_out_fx[W1 + n], 0, n ); + set16_fx( &hHQ_core->old_out_fx[add( W1, n )], 0, n ); hHQ_core->Q_old_wtda = Q_syn; move16(); @@ -2027,11 +2063,10 @@ void con_tcx_ivas_fx( } #ifdef BASOP_NOGLOB - st->bfi_pitch_fx /*Q6*/ = round_fx_sat( L_shl_sat( pitch_buf[st->nb_subfr - 1] /*15Q16*/, 6 /*Q6*/ ) ); + st->bfi_pitch_fx /*Q6*/ = round_fx_sat( L_shl_sat( pitch_buf[sub( st->nb_subfr, 1 )] /*15Q16*/, 6 /*Q6*/ ) ); #else - st->bfi_pitch_fx /*Q6*/ = round_fx( L_shl( pitch_buf[st->nb_subfr - 1] /*15Q16*/, 6 /*Q6*/ ) ); + st->bfi_pitch_fx /*Q6*/ = round_fx( L_shl( pitch_buf[sub( st->nb_subfr, 1 )] /*15Q16*/, 6 /*Q6*/ ) ); #endif - move16(); st->bfi_pitch_frame = st->L_frame; move16(); @@ -2045,20 +2080,20 @@ void con_tcx_ivas_fx( } FOR( ; i < W1; i++ ) { - buf[i] = mult_r( hTcxDec->syn_Overl_TDACFB[i], w[W12 - 1 - ( i - W12 )].v.im ); + buf[i] = mult_r( hTcxDec->syn_Overl_TDACFB[i], w[sub( sub( W12, 1 ), sub( i, W12 ) )].v.im ); move16(); } FOR( i = 0; i < W2; i++ ) { - hTcxDec->syn_Overl_TDACFB[i] = add_sat( buf[i], buf[W1 - 1 - i] ); + hTcxDec->syn_Overl_TDACFB[i] = add_sat( buf[i], buf[sub( sub( W1, 1 ), i )] ); move16(); } FOR( i = 0; i < W2; i++ ) { - hTcxDec->syn_Overl_TDACFB[W2 + i] = add_sat( buf[W2 + i], buf[W1 - 1 - W2 - i] ); + hTcxDec->syn_Overl_TDACFB[add( W2, i )] = add_sat( buf[add( W2, i )], buf[sub( sub( sub( W1, 1 ), W2 ), i )] ); move16(); } @@ -2069,11 +2104,12 @@ void con_tcx_ivas_fx( } FOR( ; i < W1; i++ ) { - hTcxDec->syn_Overl_TDACFB[i] = mult_r( hTcxDec->syn_Overl_TDACFB[i], w[W12 - 1 - ( i - W12 )].v.im ); + hTcxDec->syn_Overl_TDACFB[i] = mult_r( hTcxDec->syn_Overl_TDACFB[i], w[sub( sub( W12, 1 ), sub( i, W12 ) )].v.im ); move16(); } st->hTcxCfg->tcx_curr_overlap_mode = FULL_OVERLAP; + move16(); synth[-1] = pre_emph_buf; move16(); diff --git a/lib_dec/er_scale_syn_fx.c b/lib_dec/er_scale_syn_fx.c index d9d80c6ed..a8c76aa85 100644 --- a/lib_dec/er_scale_syn_fx.c +++ b/lib_dec/er_scale_syn_fx.c @@ -37,17 +37,18 @@ Word16 Damping_fact_fx( /* o : damping factor Word32 gain32; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move16(); #endif - IF( core == ACELP_CORE ) + IF( EQ_16( core, ACELP_CORE ) ) { alpha = mult_r( _ALPHA_VT_FX, 16384 ); /* rapid convergence to 0 */ /*Q14*/ test(); test(); - test(); /*ELSEIF*/ test(); - test(); /*ELSEIF*/ + test(); + test(); IF( ( EQ_16( coder_type, UNVOICED ) ) && ( LE_16( nbLostCmpt, 3 ) ) ) /* Clear unvoiced last good frame */ { alpha = mult_r( _ALPHA_UU_FX, 16384 ); /*Q14*/ @@ -78,15 +79,15 @@ Word16 Damping_fact_fx( /* o : damping factor { alpha = 13107 /*0.8f Q14*/; /*Q14*/ } - ELSE if ( ( ( EQ_16( last_good, VOICED_CLAS ) ) || ( EQ_16( last_good, ONSET ) ) ) && ( LE_16( nbLostCmpt, 3 ) ) ) + ELSE IF( ( ( EQ_16( last_good, VOICED_CLAS ) ) || ( EQ_16( last_good, ONSET ) ) ) && ( LE_16( nbLostCmpt, 3 ) ) ) { alpha = mult_r( _ALPHA_V_FX, 16384 ); /* constant for the first 3 erased frames */ } IF( GE_16( last_good, VOICED_CLAS ) ) { - move16(); lp_tmp = *lp_gainp; + move32(); IF( EQ_16( nbLostCmpt, 1 ) ) /* if first erased frame in a block, reset harmonic gain */ { @@ -95,7 +96,6 @@ Word16 Damping_fact_fx( /* o : damping factor /*gain = (float)sqrt( *lp_gainp );*/ /* move pitch gain towards 1 for voiced to remove energy fluctuations */ /*BASOP_Util_Sqrt_MantExp(lp_gainp,&lp_gainp_E);*/ s_gainp = 31 - 29; - move16(); gain32 = Sqrt32( lp_tmp, &s_gainp ); #ifdef BASOP_NOGLOB @@ -114,22 +114,22 @@ Word16 Damping_fact_fx( /* o : damping factor } ELSE { - /*0.7 + 0.2*stab_fac*/ move16(); + /*0.7 + 0.2*stab_fac*/ lp_tmp = Mpy_32_16_1( lp_tmp, mac_r( 1503238528l /*0.7f Q31*/, 6554 /*0.2f Q15*/, stab_fac ) ); /*2Q29*/ alpha = round_fx( L_shl( lp_tmp, 1 ) ); /*1Q14*/ } - move16(); *lp_gainp = lp_tmp; /*store*/ + move32(); } } ELSE { alpha = mac_r( 375809632l /*0.35f Q30*/, 6554 /*0.4f Q14*/, stab_fac ); /*Q14*/ - if ( LT_16( nbLostCmpt, 2 ) ) + IF( LT_16( nbLostCmpt, 2 ) ) { alpha = mac_r( 751619264l /*0.70f Q30*/, 4915 /*0.3f Q14*/, stab_fac ); /*Q14*/ } - if ( EQ_16( nbLostCmpt, 2 ) ) + IF( EQ_16( nbLostCmpt, 2 ) ) { alpha = mac_r( 483183808l /*0.45f Q30*/, 6554 /*0.4f Q14*/, stab_fac ); /*Q14*/ } diff --git a/lib_dec/er_sync_exc.c b/lib_dec/er_sync_exc.c index ea14a7f4b..68cc16665 100644 --- a/lib_dec/er_sync_exc.c +++ b/lib_dec/er_sync_exc.c @@ -42,6 +42,7 @@ #include "cnst.h" #include "wmc_auto.h" +#ifndef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * Local constants *--------------------------------------------------------------------*/ @@ -56,7 +57,6 @@ *--------------------------------------------------------------------*/ /*! r: Index of the position of the minimum energy, that is the position i where filter(x[i-filterLength/2],...,x[i+(filterLength-filterLength/2)-1]) is at maximum. */ -#ifndef IVAS_FLOAT_FIXED static int16_t GetMinimumPosition( const float *x, /* i : input signal */ const int16_t length, /* i : length of the filter length used for the energy calculation */ diff --git a/lib_dec/er_sync_exc_fx.c b/lib_dec/er_sync_exc_fx.c index 44c6230d2..f01c98655 100644 --- a/lib_dec/er_sync_exc_fx.c +++ b/lib_dec/er_sync_exc_fx.c @@ -34,6 +34,7 @@ static Word16 GetMinimumPosition_fx( Word32 energy, energy_old, tmptest; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move16(); #endif filterLength = s_min( filterLength, length ); @@ -41,7 +42,7 @@ static Word16 GetMinimumPosition_fx( iMinEnergyPos = center; move16(); - IF( filterLength > 0 ) + IF( GT_16( filterLength, 0 ) ) { center = add( center, 1 ); energy = L_deposit_l( 0 ); @@ -59,7 +60,7 @@ static Word16 GetMinimumPosition_fx( #else energy = L_msu( energy_old, tmp16, tmp16 ); #endif - tmp16 = shr( x[i + filterLength], tmp_e ); + tmp16 = shr( x[add( i, filterLength )], tmp_e ); BASOP_SATURATE_WARNING_OFF_EVS /*Saturation will be handled*/ #ifdef BASOP_NOGLOB energy = L_mac_sat( energy, tmp16, tmp16 ); @@ -76,17 +77,17 @@ static Word16 GetMinimumPosition_fx( tmptest = L_sub( energy, MAXVAL_WORD32 ); #endif BASOP_SATURATE_WARNING_ON_EVS - IF( tmptest == 0 ) + IF( EQ_32( tmptest, 0 ) ) { tmp_e = add( tmp_e, 1 ); energy = L_shr( energy_old, 2 ); tmp16 = shr( x[i], tmp_e ); energy = L_msu( energy, tmp16, tmp16 ); - tmp16 = shr( x[i + filterLength], tmp_e ); + tmp16 = shr( x[add( i, filterLength )], tmp_e ); energy = L_mac( energy, tmp16, tmp16 ); } - IF( energy < 0 ) + IF( LT_32( energy, 0 ) ) { iMinEnergyPos = add( i, center ); tmp_e = 0; @@ -118,10 +119,10 @@ static Word16 FindMaxPeak_fx( move16(); FOR( i = 1; i < length; i++ ) { - if ( GT_16( abs_s( x[i] ), abs_s( x[iMax] ) ) ) + IF( GT_16( abs_s( x[i] ), abs_s( x[iMax] ) ) ) { - move16(); iMax = i; + move16(); } } @@ -144,16 +145,14 @@ static void AddSamples_fx( Word16 ftmp; pt_dest = new_exc; - move16(); pt_src = old_exc; - move16(); last_min_pos = 0; move16(); FOR( i = 0; i < nb_min; i++ ) { /* Copy section */ - FOR( j = min_pos[i] - last_min_pos; j > 0; j-- ) + FOR( j = sub( min_pos[i], last_min_pos ); j > 0; j-- ) { *pt_dest++ = *pt_src++; move16(); @@ -253,7 +252,7 @@ void PulseResynchronization_fx( test(); test(); test(); - IF( ( LT_32( L_deposit_h( nFrameLength ), pitchStart ) ) || ( pitchStart <= 0 ) || ( pitchEnd <= 0 ) || ( LT_16( nSubframes, 1 ) ) || ( GT_16( nSubframes, 5 ) ) || ( LE_32( Mpy_32_16_1( pitchEnd, add( nSubframes, 1 ) ), Mpy_32_16_1( pitchStart, sub( nSubframes, 1 ) ) ) ) || ( src_exc - dst_exc >= 0 ) ) + IF( ( LT_32( L_deposit_h( nFrameLength ), pitchStart ) ) || LE_32( pitchStart, 0 ) || LE_32( pitchEnd, 0 ) || ( LT_16( nSubframes, 1 ) ) || ( GT_16( nSubframes, 5 ) ) || ( LE_32( Mpy_32_16_1( pitchEnd, add( nSubframes, 1 ) ), Mpy_32_16_1( pitchStart, sub( nSubframes, 1 ) ) ) ) || ( src_exc - dst_exc >= 0 ) ) { /* This is error handling and recovery that should never occur. */ test(); @@ -275,7 +274,7 @@ void PulseResynchronization_fx( /*samplesDelta = 0.5f*pitchDelta*nFrameLength*(nSubframes+1)*freqStart;*/ /* pitchDelta*freqStart = ((pitchEnd - pitchStart)/roundedPitchStart)/nSubframes */ tmp16 = shl( roundedPitchStart, 2 ); /*Q0*/ - if ( EQ_16( nSubframes, 5 ) ) + IF( EQ_16( nSubframes, 5 ) ) { tmp16 = add( tmp16, roundedPitchStart ); /*Q0*/ /*tmp16=roundedPitchStart*nSubframes*/ } @@ -307,6 +306,7 @@ void PulseResynchronization_fx( tmp2_e = add( tmp2_e, 31 - 16 ); /* tmp32_a is now regarded as Q31 with scaling tmp2_e */ tmp3_e = tmp2_e; + move16(); tmp32_a = L_negate( tmp32_a ); #ifdef BASOP_NOGLOB tmp32_a = L_add( L_shl_o( 1, sub( 31, tmp3_e ), &Overflow ), tmp32_a ); /*Q31,tmp3_e*/ /*tmp32_a= 1.0f-pitchStart*freqStart*/ @@ -332,7 +332,7 @@ void PulseResynchronization_fx( tmp32 = L_add( tmp32, 65536l /*1.f Q16*/ ); k = extract_h( tmp32 ); test(); - IF( ( k >= 0 ) && LE_16( add( k, 1 ), NB_PULSES_MAX ) ) + IF( GE_16( k, 0 ) && LE_16( add( k, 1 ), NB_PULSES_MAX ) ) { absPitchDiff = L_abs( L_sub( L_deposit_h( roundedPitchStart ), pitchEnd ) ); /*Q16*/ @@ -361,7 +361,7 @@ void PulseResynchronization_fx( /* Calculate the integer number of samples to be added/removed in each pitch cycle */ /*cycleDelta = max(0, (absPitchDiff-(k+1)*perCycleDeltaDelta)*T0*freqStart); */ - tmp_e = norm_s( k + 1 ); + tmp_e = norm_s( add( k, 1 ) ); tmp32 = L_mult( perCycleDeltaDelta /*Q15,perCycleDeltaDelta_e*/, shl( add( k, 1 ), tmp_e ) /*Q0, tmp_e*/ ) /*Q0+16, perCycleDeltaDelta_e-tmp_e*/; tmp32 = BASOP_Util_Add_Mant32Exp( absPitchDiff /*Q16*/, 31 - 16, L_negate( tmp32 ), add( sub( perCycleDeltaDelta_e, tmp_e ), 31 - 16 ), &tmp_e ); /*Q31,tmp_e*/ tmp32 = Mpy_32_16_1( tmp32, T0 /*Q0*/ ); /*Q16,tmp_e*/ @@ -370,7 +370,7 @@ void PulseResynchronization_fx( cycleDelta_e = add( tmp_e, freqStart_e ); tmp32_a = L_shl( tmp32, cycleDelta_e ); roundedCycleDelta = extract_h( L_abs( tmp32_a ) ); - if ( tmp32 < 0 ) + IF( LT_32( tmp32, 0 ) ) { roundedCycleDelta = negate( roundedCycleDelta ); } @@ -383,19 +383,19 @@ void PulseResynchronization_fx( #else cycleDelta = round_fx( tmp32 ); /*Q15, cycleDelta_e*/ #endif - if ( cycleDelta == 0 ) + IF( EQ_16( cycleDelta, 0 ) ) { - move16(); cycleDelta_e = 0; + move16(); } /*roundedCycleDelta = (int)(cycleDelta); */ /*done above*/ + iDeltaSamples[0] = roundedCycleDelta; /*Q0*/ move16(); - iDeltaSamples[0] = roundedCycleDelta; /*Q0*/ /*fractionalLeft = cycleDelta-roundedCycleDelta;*/ /*done above*/ nSamplesDeltaRemain = sub( nSamplesDeltaRemain, roundedCycleDelta ); /*Q0*/ - tmp_e = ( s_max( 2, k ) ); + tmp_e = s_max( 2, k ); tmp_e = norm_s( tmp_e ); /*maximum norming factor for following loop*/ @@ -415,7 +415,7 @@ void PulseResynchronization_fx( iDeltaSamples[i] = roundedCycleDelta; move16(); roundedCycleDelta = extract_h( cycleDelta32 ); /* cycleDelta32 should never be < 0 here */ - iDeltaSamples[i - 1] = roundedCycleDelta; + iDeltaSamples[sub( i, 1 )] = roundedCycleDelta; move16(); } ELSE @@ -428,9 +428,9 @@ void PulseResynchronization_fx( fractionalLeft = lshr( extract_l( cycleDelta32 ), 1 ); /*Q15*/ /* cycleDelta32 should never be < 0 here */ nSamplesDeltaRemain = sub( nSamplesDeltaRemain, roundedCycleDelta ); } - iDeltaSamples[k + 1] = s_max( 0, nSamplesDeltaRemain ); + iDeltaSamples[add( k, 1 )] = s_max( 0, nSamplesDeltaRemain ); move16(); - maxDeltaSamples = s_max( iDeltaSamples[k], iDeltaSamples[k + 1] ); /*Q0*/ + maxDeltaSamples = s_max( iDeltaSamples[k], iDeltaSamples[add( k, 1 )] ); /*Q0*/ /* Find the location of the minimum energy between the first two pulses */ @@ -449,7 +449,7 @@ void PulseResynchronization_fx( iMinPos1 = add( iMinPos1, T0 ); - IF( nSamplesDelta < 0 ) + IF( LT_16( nSamplesDelta, 0 ) ) { /* Find the location of the minimum energy before the first pulse */ @@ -460,43 +460,45 @@ void PulseResynchronization_fx( } ELSE { - move16(); iMinPos[0] = sub( GetMinimumPosition_fx( src_exc, T0, iDeltaSamples[0] ), shr( iDeltaSamples[0], 1 ) ); + move16(); } /* Find the location of the minimum energy between the pulses */ FOR( i = 1; i <= k; i++ ) { - move16(); iMinPos[i] = add( iMinPos1, sub( imult1616( sub( i, 1 ), roundedPitchStart ), shr( iDeltaSamples[i], 1 ) ) ); + move16(); } /* Find the location of the minimum energy after the last pulse */ - IF( LT_16( add( iMinPos1, add( imult1616( k, roundedPitchStart ), sub( iDeltaSamples[k + 1], shr( iDeltaSamples[k + 1], 1 ) ) ) ), sub( nFrameLength, nSamplesDelta ) ) ) + IF( LT_16( add( iMinPos1, add( imult1616( k, roundedPitchStart ), sub( iDeltaSamples[add( k, 1 )], shr( iDeltaSamples[add( k, 1 )], 1 ) ) ) ), sub( nFrameLength, nSamplesDelta ) ) ) { + iMinPos[add( k, 1 )] = add( iMinPos1, sub( imult1616( k, roundedPitchStart ), shr( iDeltaSamples[add( k, 1 )], 1 ) ) ); move16(); - iMinPos[k + 1] = add( iMinPos1, sub( imult1616( k, roundedPitchStart ), shr( iDeltaSamples[k + 1], 1 ) ) ); } ELSE { /*iMinPos[k+1] = T0+k*roundedPitchStart + GetMinimumPosition_fx(src_exc+T0+k*roundedPitchStart, nFrameLength-nSamplesDelta-(T0+k*roundedPitchStart), iDeltaSamples[k+1]) - iDeltaSamples[k+1]/2; */ - tmp16 = GetMinimumPosition_fx( src_exc + T0 + k * roundedPitchStart, sub( nFrameLength, add( nSamplesDelta, add( T0, imult1616( k, roundedPitchStart ) ) ) ), iDeltaSamples[k + 1] ); + tmp16 = GetMinimumPosition_fx( src_exc + add( T0, imult1616( k, roundedPitchStart ) ), sub( nFrameLength, add( nSamplesDelta, add( T0, imult1616( k, roundedPitchStart ) ) ) ), iDeltaSamples[add( k, 1 )] ); tmp16 = add( add( T0, imult1616( k, roundedPitchStart ) ), tmp16 ); - tmp16 = sub( tmp16, shr( iDeltaSamples[k + 1], 1 ) ); - iMinPos[k + 1] = tmp16; + tmp16 = sub( tmp16, shr( iDeltaSamples[add( k, 1 )], 1 ) ); + iMinPos[add( k, 1 )] = tmp16; move16(); } - IF( GT_16( add( iMinPos[k + 1], iDeltaSamples[k + 1] ), sub( nFrameLength, nSamplesDelta ) ) ) + IF( GT_16( add( iMinPos[add( k, 1 )], iDeltaSamples[add( k, 1 )] ), sub( nFrameLength, nSamplesDelta ) ) ) { - iDeltaSamples[k] += add( iMinPos[k + 1], sub( iDeltaSamples[k + 1], sub( nFrameLength, nSamplesDelta ) ) ); - iDeltaSamples[k + 1] = sub( nFrameLength, add( nSamplesDelta, iMinPos[k + 1] ) ); + iDeltaSamples[k] = add( iDeltaSamples[k], add( iMinPos[add( k, 1 )], sub( iDeltaSamples[add( k, 1 )], sub( nFrameLength, nSamplesDelta ) ) ) ); + move16(); + iDeltaSamples[add( k, 1 )] = sub( nFrameLength, add( nSamplesDelta, iMinPos[add( k, 1 )] ) ); + move16(); } /* Remove samples at the given positions */ - RemoveSamples_fx( src_exc, dst_exc, nFrameLength, nSamplesDelta, iMinPos, iDeltaSamples, k + 2 ); + RemoveSamples_fx( src_exc, dst_exc, nFrameLength, nSamplesDelta, iMinPos, iDeltaSamples, add( k, 2 ) ); } ELSE { @@ -523,27 +525,27 @@ void PulseResynchronization_fx( /* Find the location of the minimum energy after the last pulse */ IF( LT_16( iMinPos1, sub( nFrameLength, nSamplesDelta ) ) ) { - iMinPos[k + 1] = iMinPos1; + iMinPos[add( k, 1 )] = iMinPos1; move16(); } ELSE { - tmp16 = GetMinimumPosition_fx( src_exc + T0 + k * roundedPitchStart, sub( nFrameLength, add( nSamplesDelta, add( T0, imult1616( k, roundedPitchStart ) ) ) ), iDeltaSamples[k + 1] ); + tmp16 = GetMinimumPosition_fx( src_exc + add( T0, imult1616( k, roundedPitchStart ) ), sub( nFrameLength, add( nSamplesDelta, add( T0, imult1616( k, roundedPitchStart ) ) ) ), iDeltaSamples[add( k, 1 )] ); tmp16 = add( add( tmp16, T0 ), imult1616( k, roundedPitchStart ) ); - iMinPos[k + 1] = tmp16; + iMinPos[add( k, 1 )] = tmp16; move16(); } - IF( GT_16( add( iMinPos[k + 1], iDeltaSamples[k + 1] ), sub( nFrameLength, nSamplesDelta ) ) ) + IF( GT_16( add( iMinPos[add( k, 1 )], iDeltaSamples[add( k, 1 )] ), sub( nFrameLength, nSamplesDelta ) ) ) { + iDeltaSamples[k] = add( iDeltaSamples[k], add( iMinPos[add( k, 1 )], sub( iDeltaSamples[add( k, 1 )], sub( nFrameLength, nSamplesDelta ) ) ) ); move16(); + iDeltaSamples[add( k, 1 )] = sub( sub( nFrameLength, nSamplesDelta ), iMinPos[add( k, 1 )] ); move16(); - iDeltaSamples[k] = add( iDeltaSamples[k], add( iMinPos[k + 1], sub( iDeltaSamples[k + 1], sub( nFrameLength, nSamplesDelta ) ) ) ); - iDeltaSamples[k + 1] = sub( sub( nFrameLength, nSamplesDelta ), iMinPos[k + 1] ); } /* Add samples at the given positions */ - AddSamples_fx( src_exc, dst_exc, nFrameLength, nSamplesDelta, iMinPos, iDeltaSamples, k + 2 ); + AddSamples_fx( src_exc, dst_exc, nFrameLength, nSamplesDelta, iMinPos, iDeltaSamples, add( k, 2 ) ); } } } diff --git a/lib_dec/er_util_fx.c b/lib_dec/er_util_fx.c index f526a6103..09a7842d1 100644 --- a/lib_dec/er_util_fx.c +++ b/lib_dec/er_util_fx.c @@ -48,9 +48,10 @@ void minimumStatistics_fx( Word32 tmp32; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; -#endif move16(); +#endif aOpt_e = 0; + move16(); BASOP_SATURATE_WARNING_OFF_EVS @@ -63,14 +64,14 @@ void minimumStatistics_fx( BASOP_SATURATE_WARNING_ON_EVS currentFrameLevel = PLC_MIN_CNG_LEV; move16(); - move16(); currentFrameLevel_e = 0; + move16(); } BASOP_SATURATE_WARNING_ON_EVS /* compute optimal factor aOpt for recursive smoothing of frame minima */ tmp2 = BASOP_Util_Add_MantExp( *lastFrameLevel, *lastFrameLevel_e, negate( *noiseEstimate ), noiseEstimate_e, &tmp ); - IF( tmp >= 0 ) + IF( GE_16( tmp, 0 ) ) { /* aOpt = *noiseEstimate / *lastFrameLevel; */ aOpt = BASOP_Util_Divide1616_Scale( *noiseEstimate, *lastFrameLevel, &aOpt_e ); @@ -84,22 +85,22 @@ void minimumStatistics_fx( } aOpt = mult_r( aOpt, aOpt ); /* Q15 */ aOpt_e = shl( aOpt_e, 1 ); - if ( aOpt == 0 ) + IF( EQ_16( aOpt, 0 ) ) { - move16(); aOpt_e = 0; + move16(); } *lastFrameLevel = currentFrameLevel; move16(); - move16(); *lastFrameLevel_e = currentFrameLevel_e; + move16(); /* recursively compute smoothed frame minima using optimal factor aOpt */ tmp = *currLevelIndex; move16(); move16(); - if ( tmp == 0 ) + IF( EQ_16( tmp, 0 ) ) { tmp = PLC_MIN_STAT_BUFF_SIZE; move16(); @@ -108,9 +109,9 @@ void minimumStatistics_fx( /*f = (aOpt * noiseLevelMemory[tmp-1]) - (currentFrameLevel * (aOpt-1))*/ /*tmp32*/ /*tmp*/ - tmp32 = L_mult( aOpt, noiseLevelMemory[tmp - 1] ); /*Q_tmp32 = aOpt_e + noiseLevelMemory_e[tmp - 1]*/ - move16(); + tmp32 = L_mult( aOpt, noiseLevelMemory[sub( tmp, 1 )] ); /*Q_tmp32 = aOpt_e + noiseLevelMemory_e[tmp - 1]*/ tmp_e = tmp; + move16(); tmp2 = BASOP_Util_Add_MantExp( aOpt, aOpt_e, negate( 32768 / 2 ), 1, &tmp ); @@ -123,7 +124,7 @@ void minimumStatistics_fx( move16(); } - *new_noiseEstimate_e = BASOP_Util_Add_MantExp( round_fx( tmp32 ), add( aOpt_e, noiseLevelMemory_e[tmp_e - 1] ), negate( s_max( tmp, -32767 ) /*to avoid negate(-32768)*/ ), tmp2, &f ); + *new_noiseEstimate_e = BASOP_Util_Add_MantExp( round_fx( tmp32 ), add( aOpt_e, noiseLevelMemory_e[sub( tmp_e, 1 )] ), negate( s_max( tmp, -32767 ) /*to avoid negate(-32768)*/ ), tmp2, &f ); assert( f >= 0 ); @@ -131,7 +132,7 @@ void minimumStatistics_fx( p = *noiseLevelIndex; move16(); tmp2 = BASOP_Util_Add_MantExp( noiseLevelMemory[p], noiseLevelMemory_e[p], negate( f ), *new_noiseEstimate_e, &tmp ); - IF( tmp >= 0 ) + IF( GE_16( tmp, 0 ) ) { /*rescale noiseLevelMemory*/ @@ -142,8 +143,6 @@ void minimumStatistics_fx( } ELSE { - move16(); - setnoiseLevelMemory_fx( f, new_noiseEstimate_e, noiseLevelMemory_e, noiseLevelMemory, currLevelIndex ); /* current min is not a new min, so check if min must be re-searched */ @@ -152,6 +151,7 @@ void minimumStatistics_fx( f = noiseLevelMemory[p]; /* min is still in memory, so return it */ move16(); *new_noiseEstimate_e = noiseLevelMemory_e[p]; + move16(); } ELSE { @@ -159,7 +159,7 @@ void minimumStatistics_fx( FOR( i = 0; i < PLC_MIN_STAT_BUFF_SIZE; i++ ) { tmp2 = BASOP_Util_Add_MantExp( noiseLevelMemory[p], noiseLevelMemory_e[p], negate( noiseLevelMemory[i] ), noiseLevelMemory_e[i], &tmp ); - if ( tmp > 0 ) + IF( GT_16( tmp, 0 ) ) { p = i; move16(); @@ -168,6 +168,7 @@ void minimumStatistics_fx( f = noiseLevelMemory[p]; move16(); *new_noiseEstimate_e = noiseLevelMemory_e[p]; + move16(); } } @@ -177,7 +178,7 @@ void minimumStatistics_fx( p = add( *currLevelIndex, 1 ); *currLevelIndex = add( *currLevelIndex, 1 ); move16(); - if ( EQ_16( *currLevelIndex, PLC_MIN_STAT_BUFF_SIZE ) ) + IF( EQ_16( *currLevelIndex, PLC_MIN_STAT_BUFF_SIZE ) ) { *currLevelIndex = 0; move16(); @@ -221,6 +222,7 @@ Word16 getLevelSynDeemph_fx( /*10Q5*/ levelSynDeemphSub = L_deposit_l( 0 ); levelSynDeemph = L_deposit_l( 0 ); tmp = 0; + move16(); Q_h1 = 9; /*synthesis scaling for */ move16(); @@ -259,7 +261,7 @@ Word16 getLevelSynDeemph_fx( /*10Q5*/ tmp16 = 32767 /*1.0f Q15*/; move16(); - if ( GT_16( numLoops, 1 ) ) + IF( GT_16( numLoops, 1 ) ) { tmp16 = div_s( 1, numLoops ); } @@ -268,8 +270,8 @@ Word16 getLevelSynDeemph_fx( /*10Q5*/ } s16 = norm_l( levelSynDeemph ); levelSynDeemph = L_shl( levelSynDeemph, s16 ); - move16(); *Exp = sub( 10, s16 ); /*Set exponent in order to transform returnvalue to Q15*/ + move16(); #ifdef BASOP_NOGLOB return round_fx_sat( levelSynDeemph ); /*Q15*/ @@ -293,14 +295,14 @@ void genPlcFiltBWAdap_fx( IF( EQ_32( sr_core, INT_FS_16k ) ) { - IF( type == 0 ) + IF( EQ_16( type, 0 ) ) { - move16(); - move16(); - move16(); *lpFiltAdapt++ = 7282 /* 0.4000f/(2.f*0.4000f+1.f) Q15*/; + move16(); *lpFiltAdapt++ = 18204 /* 1.f/(2.f*0.4000f+1.f) Q15*/; + move16(); *lpFiltAdapt = 7282 /* 0.4000f/(2.f*0.4000f+1.f) Q15*/; + move16(); } ELSE { @@ -310,24 +312,24 @@ void genPlcFiltBWAdap_fx( b = Inv16( add( a, 16384 /*0.5f Q15*/ ), &exp ); b = shr( b, sub( 1, exp ) ); a = negate( mult_r( a, b ) ); - move16(); - move16(); - move16(); *lpFiltAdapt++ = a; + move16(); *lpFiltAdapt++ = b; + move16(); *lpFiltAdapt = a; + move16(); } } ELSE /*sr_core = INT_FS_12k8 */ { - IF( type == 0 ) + IF( EQ_16( type, 0 ) ) { - move16(); - move16(); - move16(); *lpFiltAdapt++ = 5899 /* 0.2813f/(2.f*0.2813f+1.f) Q15*/; + move16(); *lpFiltAdapt++ = 20970 /* 1.f/(2.f*0.2813f+1.f) Q15*/; + move16(); *lpFiltAdapt = 5899 /* 0.2813f/(2.f*0.2813f+1.f) Q15*/; + move16(); } ELSE { @@ -337,12 +339,12 @@ void genPlcFiltBWAdap_fx( b = Inv16( add( a, 16384 /*0.5f Q15*/ ), &exp ); b = shr( b, sub( 1, exp ) ); a = negate( mult_r( a, b ) ); - move16(); - move16(); - move16(); *lpFiltAdapt++ = a; + move16(); *lpFiltAdapt++ = b; + move16(); *lpFiltAdapt = a; + move16(); } } } @@ -365,10 +367,10 @@ void highPassFiltering_fx( IF( GT_16( last_good, UNVOICED_TRANSITION ) ) { - FOR( i = 0; i < L_buffer; i++ ) { exc2[i] = round_fx( L_sub( Dot_product( &exc2[i], hp_filt, l_fir_fer ), 1 ) ); + move16(); } } } @@ -388,18 +390,21 @@ Word16 GetPLCModeDecision_ivas_fx( hTcxDec = st->hTcxDec; - IF( EQ_16( st->flagGuidedAcelp, 1 ) ) { - st->old_pitch_buf_fx[2 * st->nb_subfr] = L_deposit_h( st->guidedT0 ); - st->old_pitch_buf_fx[2 * st->nb_subfr + 1] = L_deposit_h( st->guidedT0 ); + st->old_pitch_buf_fx[shl( st->nb_subfr, 1 )] = L_deposit_h( st->guidedT0 ); + move32(); + st->old_pitch_buf_fx[add( shl( st->nb_subfr, 1 ), 1 )] = L_deposit_h( st->guidedT0 ); + move32(); st->mem_pitch_gain[0] = st->mem_pitch_gain[1] = 16384 /*1.f Q14*/; /*Q14*/ + move16(); + move16(); } st->plc_use_future_lag = 0; move16(); test(); test(); - if ( ( st->last_core > ACELP_CORE && hTcxDec->tcxltp_last_gain_unmodified != 0 ) || ( EQ_16( st->flagGuidedAcelp, 1 ) ) ) + IF( ( GT_16( st->last_core, ACELP_CORE ) && NE_16( hTcxDec->tcxltp_last_gain_unmodified, 0 ) ) || ( EQ_16( st->flagGuidedAcelp, 1 ) ) ) { /* no updates needed here, because already updated in last good frame */ st->plc_use_future_lag = 1; @@ -412,7 +417,7 @@ Word16 GetPLCModeDecision_ivas_fx( move16(); st->last_core = ACELP_CORE; move16(); - if ( st->Opt_AMR_WB ) + IF( st->Opt_AMR_WB ) { core = ACELP_CORE; move16(); @@ -424,7 +429,7 @@ Word16 GetPLCModeDecision_ivas_fx( { core = ACELP_CORE; move16(); - if ( GT_16( st->nbLostCmpt, 1 ) ) + IF( GT_16( st->nbLostCmpt, 1 ) ) { core = st->last_core_bfi; move16(); @@ -444,6 +449,7 @@ Word16 GetPLCModeDecision_ivas_fx( test(); test(); test(); + test(); // PMT("handle to tonalMDCTconceal is missing") //#ifdef ADD_IVAS_HTONALMDCTCONC IF( ( st->hTonalMDCTConc != NULL && EQ_16( st->last_core, TCX_20_CORE ) ) && ( EQ_16( st->second_last_core, TCX_20_CORE ) ) && ( ( LE_32( st->old_fpitch, L_deposit_h( shr( st->L_frame, 1 ) ) ) ) || ( LE_16( hTcxDec->tcxltp_last_gain_unmodified, 13107 /*0.4f Q15*/ ) ) ) @@ -454,9 +460,8 @@ Word16 GetPLCModeDecision_ivas_fx( { Word32 pitch; - pitch = L_deposit_h( 0 ); - if ( hTcxDec->tcxltp_last_gain_unmodified > 0 ) + IF( GT_16( hTcxDec->tcxltp_last_gain_unmodified, 0 ) ) { pitch = L_add( st->old_fpitch, 0 ); } @@ -464,7 +469,7 @@ Word16 GetPLCModeDecision_ivas_fx( // , (st->element_mode == IVAS_CPE_MDCT ? &(st->hTcxCfg->psychParamsTCX20) : st->hTcxCfg->psychParamsCurrent) //); - TonalMDCTConceal_Detect_ivas_fx( st->hTonalMDCTConc, pitch, &numIndices, ( st->element_mode == IVAS_CPE_MDCT ? &( st->hTcxCfg->psychParamsTCX20 ) : st->hTcxCfg->psychParamsCurrent ), + TonalMDCTConceal_Detect_ivas_fx( st->hTonalMDCTConc, pitch, &numIndices, ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ? &( st->hTcxCfg->psychParamsTCX20 ) : st->hTcxCfg->psychParamsCurrent ), st->element_mode ); test(); @@ -473,7 +478,8 @@ Word16 GetPLCModeDecision_ivas_fx( test(); test(); test(); - IF( ( GT_16( numIndices, 10 ) ) || ( ( GT_16( numIndices, 5 ) ) && ( LT_32( L_abs( L_sub( hTcxDec->tcxltp_third_last_pitch, hTcxDec->tcxltp_second_last_pitch ) ), 32768l /*0.5f Q16*/ ) ) ) || ( ( numIndices > 0 ) && ( ( LE_16( st->last_good, UNVOICED_TRANSITION ) ) || ( LE_16( hTcxDec->tcxltp_last_gain_unmodified, 13107 /*0.4f Q15*/ ) ) ) && ( LT_32( L_abs( L_sub( hTcxDec->tcxltp_third_last_pitch, hTcxDec->tcxltp_second_last_pitch ) ), 32768l /*0.5f Q16*/ ) ) ) ) + test(); + IF( ( GT_16( numIndices, 10 ) ) || ( ( GT_16( numIndices, 5 ) ) && ( LT_32( L_abs( L_sub( hTcxDec->tcxltp_third_last_pitch, hTcxDec->tcxltp_second_last_pitch ) ), 32768l /*0.5f Q16*/ ) ) ) || ( GT_16( numIndices, 0 ) && ( ( LE_16( st->last_good, UNVOICED_TRANSITION ) ) || ( LE_16( hTcxDec->tcxltp_last_gain_unmodified, 13107 /*0.4f Q15*/ ) ) ) && ( LT_32( L_abs( L_sub( hTcxDec->tcxltp_third_last_pitch, hTcxDec->tcxltp_second_last_pitch ) ), 32768l /*0.5f Q16*/ ) ) ) ) { core = TCX_20_CORE; move16(); @@ -486,10 +492,10 @@ Word16 GetPLCModeDecision_ivas_fx( move16(); } } - ELSE IF( st->last_core != ACELP_CORE ) + ELSE IF( NE_16( st->last_core, ACELP_CORE ) ) { test(); - if ( LE_16( st->last_good, UNVOICED_TRANSITION ) || LE_16( hTcxDec->tcxltp_last_gain_unmodified, 13107 /*0.4f Q15*/ ) ) + IF( LE_16( st->last_good, UNVOICED_TRANSITION ) || LE_16( hTcxDec->tcxltp_last_gain_unmodified, 13107 /*0.4f Q15*/ ) ) { core = st->last_core; move16(); @@ -515,15 +521,19 @@ Word16 GetPLCModeDecision_fx( IF( EQ_16( st->flagGuidedAcelp, 1 ) ) { - st->old_pitch_buf_fx[2 * st->nb_subfr] = L_deposit_h( st->guidedT0 ); - st->old_pitch_buf_fx[2 * st->nb_subfr + 1] = L_deposit_h( st->guidedT0 ); + st->old_pitch_buf_fx[shl( st->nb_subfr, 1 )] = L_deposit_h( st->guidedT0 ); + move32(); + st->old_pitch_buf_fx[add( shl( st->nb_subfr, 1 ), 1 )] = L_deposit_h( st->guidedT0 ); + move32(); st->mem_pitch_gain[0] = st->mem_pitch_gain[1] = 16384 /*1.f Q14*/; /*Q14*/ + move16(); + move16(); } st->plc_use_future_lag = 0; move16(); test(); test(); - if ( ( st->last_core > ACELP_CORE && hTcxDec->tcxltp_last_gain_unmodified != 0 ) || ( EQ_16( st->flagGuidedAcelp, 1 ) ) ) + IF( ( GT_16( st->last_core, ACELP_CORE ) && NE_16( hTcxDec->tcxltp_last_gain_unmodified, 0 ) ) || ( EQ_16( st->flagGuidedAcelp, 1 ) ) ) { /* no updates needed here, because already updated in last good frame */ st->plc_use_future_lag = 1; @@ -536,7 +546,7 @@ Word16 GetPLCModeDecision_fx( move16(); st->last_core = ACELP_CORE; move16(); - if ( st->Opt_AMR_WB ) + IF( st->Opt_AMR_WB ) { core = ACELP_CORE; move16(); @@ -548,7 +558,7 @@ Word16 GetPLCModeDecision_fx( { core = ACELP_CORE; move16(); - if ( GT_16( st->nbLostCmpt, 1 ) ) + IF( GT_16( st->nbLostCmpt, 1 ) ) { core = st->last_core_bfi; move16(); @@ -580,11 +590,11 @@ Word16 GetPLCModeDecision_fx( pitch = L_deposit_h( 0 ); - if ( hTcxDec->tcxltp_last_gain_unmodified > 0 ) + IF( GT_16( hTcxDec->tcxltp_last_gain_unmodified, 0 ) ) { pitch = L_add( st->old_fpitch, 0 ); } - if ( st->element_mode == EVS_MONO ) + IF( EQ_16( st->element_mode, EVS_MONO ) ) { TonalMDCTConceal_Detect( &st->tonalMDCTconceal, pitch, &numIndices, st->element_mode #ifdef ADD_IVAS_HTONALMDCTCONC @@ -593,7 +603,7 @@ Word16 GetPLCModeDecision_fx( #endif ); } - else + ELSE { TonalMDCTConceal_Detect( st->hTonalMDCTConc, pitch, &numIndices, st->element_mode #ifdef ADD_IVAS_HTONALMDCTCONC @@ -609,7 +619,8 @@ Word16 GetPLCModeDecision_fx( test(); test(); test(); - IF( ( GT_16( numIndices, 10 ) ) || ( ( GT_16( numIndices, 5 ) ) && ( LT_32( L_abs( L_sub( hTcxDec->tcxltp_third_last_pitch, hTcxDec->tcxltp_second_last_pitch ) ), 32768l /*0.5f Q16*/ ) ) ) || ( ( numIndices > 0 ) && ( ( LE_16( st->last_good, UNVOICED_TRANSITION ) ) || ( LE_16( hTcxDec->tcxltp_last_gain_unmodified, 13107 /*0.4f Q15*/ ) ) ) && ( LT_32( L_abs( L_sub( hTcxDec->tcxltp_third_last_pitch, hTcxDec->tcxltp_second_last_pitch ) ), 32768l /*0.5f Q16*/ ) ) ) ) + test(); + IF( ( GT_16( numIndices, 10 ) ) || ( ( GT_16( numIndices, 5 ) ) && ( LT_32( L_abs( L_sub( hTcxDec->tcxltp_third_last_pitch, hTcxDec->tcxltp_second_last_pitch ) ), 32768l /*0.5f Q16*/ ) ) ) || ( GT_16( numIndices, 0 ) && ( ( LE_16( st->last_good, UNVOICED_TRANSITION ) ) || ( LE_16( hTcxDec->tcxltp_last_gain_unmodified, 13107 /*0.4f Q15*/ ) ) ) && ( LT_32( L_abs( L_sub( hTcxDec->tcxltp_third_last_pitch, hTcxDec->tcxltp_second_last_pitch ) ), 32768l /*0.5f Q16*/ ) ) ) ) { core = TCX_20_CORE; move16(); @@ -622,10 +633,10 @@ Word16 GetPLCModeDecision_fx( move16(); } } - ELSE IF( st->last_core != ACELP_CORE ) + ELSE IF( NE_16( st->last_core, ACELP_CORE ) ) { test(); - if ( LE_16( st->last_good, UNVOICED_TRANSITION ) || LE_16( hTcxDec->tcxltp_last_gain_unmodified, 13107 /*0.4f Q15*/ ) ) + IF( LE_16( st->last_good, UNVOICED_TRANSITION ) || LE_16( hTcxDec->tcxltp_last_gain_unmodified, 13107 /*0.4f Q15*/ ) ) { core = st->last_core; move16(); diff --git a/lib_dec/hq_core_dec_fx.c b/lib_dec/hq_core_dec_fx.c index ee61b4b43..81cfae830 100644 --- a/lib_dec/hq_core_dec_fx.c +++ b/lib_dec/hq_core_dec_fx.c @@ -131,7 +131,7 @@ void hq_core_dec_fx( { hHQ_core->HqVoicing = 0; move16(); - if ( GT_32( st_fx->core_brate, MINIMUM_RATE_TO_ENCODE_VOICING_FLAG ) ) + IF ( GT_32( st_fx->core_brate, MINIMUM_RATE_TO_ENCODE_VOICING_FLAG ) ) { hHQ_core->HqVoicing = 1; move16(); diff --git a/lib_dec/hq_env_dec_fx.c b/lib_dec/hq_env_dec_fx.c index d89c24fc1..14037b5f6 100644 --- a/lib_dec/hq_env_dec_fx.c +++ b/lib_dec/hq_env_dec_fx.c @@ -66,11 +66,12 @@ Word16 decode_envelope_indices_fx( /* o : Number of b ELSE { hcode_l = 0; - IF( LCmode == 0 ) + move16(); + IF( EQ_16( LCmode, 0 ) ) { hdecnrm_context_fx( st_fx, num_sfm, &difidx[start_norm], &hcode_l ); } - ELSE IF( LCmode == 1 ) + ELSE IF( EQ_16( LCmode, 1 ) ) { startNormPlus1 = add( start_norm, 1 ); hdecnrm_resize_fx( st_fx, num_sfm, &difidx[startNormPlus1] ); @@ -106,7 +107,7 @@ Word16 decode_envelope_indices_fx( /* o : Number of b } } } - ELSE IF( LCmode == 2 ) + ELSE IF( EQ_16( LCmode, 2 ) ) { startNormPlus1 = add( start_norm, 1 ); hdecnrm_fx( st_fx, num_sfm, &difidx[start_norm + 1] ); diff --git a/lib_dec/hq_lr_dec_fx.c b/lib_dec/hq_lr_dec_fx.c index 0a615b317..3ed9d6f0a 100644 --- a/lib_dec/hq_lr_dec_fx.c +++ b/lib_dec/hq_lr_dec_fx.c @@ -240,7 +240,7 @@ void hq_lr_dec_fx( { num_bits = sub( num_bits, get_usebit_npswb_fx( hqswb_clas_fx ) ); } - if ( EQ_16( hqswb_clas_fx, HQ_NORMAL ) ) + IF ( EQ_16( hqswb_clas_fx, HQ_NORMAL ) ) { flag_spt_fx = 1; move16(); @@ -435,7 +435,7 @@ void hq_lr_dec_fx( #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 ) ) + IF ( GT_32( Ep_tmp_fx[i], Ep_peak_fx ) ) { Ep_peak_fx = L_add( Ep_tmp_fx[i], 0 ); /*Q15 */ } @@ -564,7 +564,7 @@ void hq_lr_dec_fx( ELSE { Ep_avrgL_fx = L_add( Ep_avrgL_fx, L_shr( Ep_tmp_fx[i], 1 ) ); /*Q12 */ - if ( GT_32( Ep_tmp_fx[i], Ep_peak_fx ) ) + IF ( GT_32( Ep_tmp_fx[i], Ep_peak_fx ) ) { Ep_peak_fx = L_add( Ep_tmp_fx[i], 0 ); /*Q13 */ } @@ -798,7 +798,7 @@ void hq_lr_dec_fx( #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 ) ) + IF ( GT_32( Ep_tmp_fx[i], Ep_peak_fx ) ) { Ep_peak_fx = L_add( Ep_tmp_fx[i], 0 ); /*Q15 */ } @@ -1043,7 +1043,7 @@ static Word16 decode_huff_8s_fx( { Word16 bit; - WHILE( *hufftab > 0 ) + WHILE( GT_16( *hufftab, 0 ) ) { *rbits = add( *rbits, s_and( *hufftab, 0xf ) ); bit = get_next_indice( st_fx, s_and( *hufftab, 0xf ) ); @@ -1069,13 +1069,13 @@ static Word16 large_symbol_dec_fx( /* o : bits move16(); ns2mode = get_next_indice( st_fx, BITS_DE_8SMODE ); - IF( ns2mode == 0 ) + IF( EQ_16( ns2mode, 0 ) ) { ns2mode0 = get_next_indice( st_fx, BITS_DE_8SMODE_N0 ); ns2mode1 = get_next_indice( st_fx, BITS_DE_8SMODE_N1 ); cntbits = add( cntbits, BITS_DE_8SMODE_N0 + BITS_DE_8SMODE_N1 ); - IF( ns2mode0 == 0 ) + IF( EQ_16( ns2mode0, 0 ) ) { IF( EQ_16( ns2mode1, 1 ) ) { @@ -1210,7 +1210,7 @@ static Word16 band_energy_dequant_fx( /* parsing energy difference coding mode */ deng_cmode = get_next_indice( st_fx, BITS_DE_CMODE ); - IF( deng_cmode == 0 ) + IF( EQ_16( deng_cmode, 0 ) ) { deng_bits = large_symbol_dec_fx( st_fx, bq2_fx, bands_fx ); diff --git a/lib_dec/igf_dec_fx.c b/lib_dec/igf_dec_fx.c index cddeec0de..4ae2c9ebd 100644 --- a/lib_dec/igf_dec_fx.c +++ b/lib_dec/igf_dec_fx.c @@ -48,17 +48,17 @@ static Word16 IGF_getScaleFactor32Cond( /**< ou { tmp32 = L_add( x[i], 0 ); /*L_and(x[i], cond[i]);*/ - if ( cond[i] == 0 ) + IF( EQ_16( cond[i], 0 ) ) { tmp32 = L_deposit_h( 0 ); } - if ( tmp32 >= 0 ) + IF( GE_32( tmp32, 0 ) ) { x_max = L_max( x_max, tmp32 ); } - if ( tmp32 < 0 ) + IF( LT_32( tmp32, 0 ) ) { x_min = L_min( x_min, tmp32 ); } @@ -69,11 +69,11 @@ static Word16 IGF_getScaleFactor32Cond( /**< ou i_min = 0x20; move16(); - if ( x_max != 0 ) + IF( NE_32( x_max, 0 ) ) { i_max = norm_l( x_max ); } - if ( x_min != 0 ) + IF( NE_32( x_min, 0 ) ) { i_min = norm_l( x_min ); } @@ -111,15 +111,15 @@ static Word16 IGF_replaceTCXNoise_1( /**< ou FOR( sb = start; sb < stop; sb++ ) { - if ( TCXNoise[sb] ) + IF ( TCXNoise[sb] ) { tmp16 = extract_h( L_shl( in[sb], s_l ) ); } - if ( TCXNoise[sb] ) + IF ( TCXNoise[sb] ) { nE = L_mac( nE, tmp16, tmp16 ); } - if ( TCXNoise[sb] ) + IF ( TCXNoise[sb] ) { noise = add( noise, 1 ); } @@ -157,19 +157,19 @@ static void IGF_replaceTCXNoise_2( Word32 *in, /**< in FOR( sb = start; sb < stop; sb++ ) { - if ( TCXNoise[sb] ) + IF ( TCXNoise[sb] ) { val = Random( nfSeed ); } - if ( TCXNoise[sb] ) + IF( TCXNoise[sb] ) { in[sb] = L_deposit_l( val ); } - if ( TCXNoise[sb] ) + IF( TCXNoise[sb] ) { val = shr( val, 5 ); } - if ( TCXNoise[sb] ) + IF( TCXNoise[sb] ) { rE = L_mac( rE, val, val ); } @@ -179,20 +179,20 @@ static void IGF_replaceTCXNoise_2( Word32 *in, /**< in /* make sure that rE is never 0 */ - if ( rE == 0 ) + IF( EQ_32( rE, 0 ) ) { rE = L_add( totalNoiseNrg, 0 ); /* save move32() -> use L_add(x, 0) = x; */ } /* if totalNoiseNrg == 0, then rE must be at least 0x00010000, otherwise division by 0 will occur */ - if ( totalNoiseNrg == 0 ) + IF( EQ_32( totalNoiseNrg, 0 ) ) { rE = L_max( rE, 0x00010000 ); } /* make sure that rE is never smaller than totalNoiseNrg */ L_tmp = L_sub( rE, totalNoiseNrg ); - if ( L_tmp < 0 ) + IF( LT_32( L_tmp, 0 ) ) { rE = totalNoiseNrg; /* save move32() -> use L_add(x, 0) = x; */ move32(); @@ -204,7 +204,7 @@ static void IGF_replaceTCXNoise_2( Word32 *in, /**< in FOR( sb = start; sb < stop; sb++ ) { - if ( TCXNoise[sb] ) + IF ( TCXNoise[sb] ) { in[sb] = L_shr( L_mult( extract_l( in[sb] ), g ), s_l ); move32(); @@ -256,18 +256,18 @@ static void IGF_replaceTCXNoise_2_new_ivas( Word32 *in, /**< in } - IF( n_noise_bands_tile != 0 ) + IF( NE_16( n_noise_bands_tile, 0 ) ) { noise_band_ratio = div_s( n_noise_bands_tile, n_noise_bands ); // Q15 /* make sure that rE is never 0 */ - if ( rE == 0 ) + IF ( EQ_32(rE, 0) ) { rE = L_add( totalNoiseNrg, 0 ); /* save move32() -> use L_add(x, 0) = x; */ } /* if totalNoiseNrg == 0, then rE must be at least 0x00010000, otherwise division by 0 will occur */ - if ( totalNoiseNrg == 0 ) + IF ( EQ_32(totalNoiseNrg, 0) ) { rE = L_max( rE, 0x00010000 ); } @@ -338,18 +338,18 @@ static void IGF_replaceTCXNoise_2_new_ivas_with_var_shift( Word32 *in, } - IF( n_noise_bands_tile != 0 ) + IF( NE_16( n_noise_bands_tile, 0 ) ) { noise_band_ratio = div_s( n_noise_bands_tile, n_noise_bands ); // Q15 /* make sure that rE is never 0 */ - IF( rE == 0 ) + IF( EQ_32(rE, 0) ) { rE = L_add( totalNoiseNrg, 0 ); /* save move32() -> use L_add(x, 0) = x; */ } /* if totalNoiseNrg == 0, then rE must be at least 0x00010000, otherwise division by 0 will occur */ - IF( totalNoiseNrg == 0 ) + IF( EQ_32(totalNoiseNrg, 0) ) { rE = L_max( rE, 0x00010000 ); } @@ -391,7 +391,7 @@ static void IGF_decode_whitening_level( Decoder_State *st, tmp = get_next_indice( st, 1 ); - IF( tmp == 0 ) + IF( EQ_16(tmp, 0) ) { hPrivateData->currWhiteningLevel[p] = IGF_WHITENING_MID; move16(); @@ -403,7 +403,7 @@ static void IGF_decode_whitening_level( Decoder_State *st, hPrivateData->currWhiteningLevel[p] = IGF_WHITENING_STRONG; move16(); - if ( tmp == 0 ) + IF ( EQ_16(tmp, 0) ) { hPrivateData->currWhiteningLevel[p] = IGF_WHITENING_OFF; move16(); @@ -436,7 +436,7 @@ static void IGF_setLinesToZero( const Word16 startLine, /**< in if there is content in the original MDCT spectrum */ FOR( i = startLine; i < stopLine; i++ ) { - if ( pSpectralData[i] != 0 ) + IF ( NE_32(pSpectralData[i], 0) ) { pPowerSpecIGF[i] = L_deposit_l( 0 ); } @@ -547,7 +547,7 @@ static void IGF_prep( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in tb = hGrid->swb_offset[hGrid->sfbWrap[tile_idx]]; move16(); - IF( abs_sum != 0 ) + IF( NE_32(abs_sum, 0) ) { FOR( i = strt_cpy; i < startLine; i++ ) { @@ -572,7 +572,7 @@ static void IGF_prep( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in /* medium whitening detected */ IF( EQ_16( IGF_WHITENING_MID, hPrivateData->currWhiteningLevel[tile_idx] ) ) { - IF( n_noise_bands != 0 ) + IF( NE_16(n_noise_bands, 0) ) { IGF_replaceTCXNoise_2( igf_spec, TCXNoise, @@ -595,7 +595,7 @@ static void IGF_prep( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in /* off whitening detectded */ ELSE { - IF( n_noise_bands_off != 0 ) + IF( NE_16(n_noise_bands_off, 0) ) { IGF_replaceTCXNoise_2( hPrivateData->pSpecFlat, TCXNoise, @@ -692,7 +692,7 @@ static void IGF_prep_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in IF( GT_16( element_mode, EVS_MONO ) ) { - tile_width = hGrid->swb_offset[hGrid->sfbWrap[tile_idx + 1]] - hGrid->swb_offset[hGrid->sfbWrap[tile_idx]]; + tile_width = sub(hGrid->swb_offset[hGrid->sfbWrap[tile_idx + 1]], hGrid->swb_offset[hGrid->sfbWrap[tile_idx]]); stop = add( strt_cpy, tile_width ); } ELSE @@ -717,7 +717,7 @@ static void IGF_prep_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in tb = hGrid->swb_offset[hGrid->sfbWrap[tile_idx]]; move16(); - IF( abs_sum != 0 ) + IF( NE_32(abs_sum, 0) ) { FOR( i = strt_cpy; i < stop; i++ ) { @@ -744,7 +744,7 @@ static void IGF_prep_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in { IF( GT_16( element_mode, EVS_MONO ) ) { - IF( n_noise_bands != 0 ) + IF( NE_16(n_noise_bands, 0) ) { IGF_replaceTCXNoise_2_new_ivas( igf_spec, specMed_e, @@ -759,7 +759,7 @@ static void IGF_prep_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in } ELSE { - IF( n_noise_bands != 0 ) + IF( NE_16(n_noise_bands, 0) ) { IGF_replaceTCXNoise_2( igf_spec, TCXNoise, @@ -785,7 +785,7 @@ static void IGF_prep_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in IF( GT_16( element_mode, EVS_MONO ) ) { - IF( n_noise_bands_off != 0 ) + IF( NE_16(n_noise_bands_off, 0) ) { IGF_replaceTCXNoise_2_new_ivas( src_spec, src_spec_e, @@ -800,7 +800,7 @@ static void IGF_prep_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in } ELSE { - IF( n_noise_bands_off != 0 ) + IF( NE_16(n_noise_bands_off, 0) ) { IGF_replaceTCXNoise_2( src_spec, TCXNoise, @@ -1533,19 +1533,19 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in /* select correct hopsize for envelope refinement */ hopsize = 2; move16(); - if ( EQ_16( hPrivateData->currWhiteningLevel[0], IGF_WHITENING_OFF ) ) + IF ( EQ_16( hPrivateData->currWhiteningLevel[0], IGF_WHITENING_OFF ) ) { hopsize = 4; move16(); } - if ( EQ_16( hPrivateData->currWhiteningLevel[0], IGF_WHITENING_STRONG ) ) + IF ( EQ_16( hPrivateData->currWhiteningLevel[0], IGF_WHITENING_STRONG ) ) { hopsize = 1; move16(); } hopsize = s_min( hopsize, hPrivateData->igfInfo.maxHopsize ); - IF( hopsize > 1 ) + IF( GT_16(hopsize, 1) ) { FOR( sfb = start_sfb; sfb < stop_sfb; sfb += hopsize ) { @@ -1571,7 +1571,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in } /* IGF_rescale_SCF */ - IF( hGrid->infoIsRefined != 0 ) + IF( NE_16(hGrid->infoIsRefined, 0) ) { FOR( sfb = start_sfb; sfb < stop_sfb; sfb += 2 ) { @@ -1628,7 +1628,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in #endif BASOP_SATURATE_WARNING_ON_EVS - IF( L_tmp2 < 0 ) + IF( LT_32(L_tmp2, 0) ) { L_tmp = Mpy_32_16_1( sNlocal, 33 /*0.001f Q15*/ ); L_tmp_e = sNlocal_e; @@ -1706,7 +1706,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in #endif BASOP_SATURATE_WARNING_ON_EVS - IF( L_tmp2 < 0 ) + IF( LT_32(L_tmp2, 0) ) { L_tmp = Mpy_32_16_1( sNlocal, 33 /*0.001f Q15*/ ); L_tmp_e = sNlocal_e; @@ -1731,7 +1731,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in negate( dN[start_sfb] ), dN_e[start_sfb], &tmp ); /* float: tmp = dE - dN[start_sfb] */ - IF( tmp < 0 ) + IF( LT_16(tmp, 0) ) { /* float: dS[start_sfb] = dN[start_sfb] + fFactor * (dE-dN[start_sfb]); basop: */ L_tmp = L_mult( fFactor, tmp ); @@ -1752,7 +1752,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in sfb_p1 = add( start_sfb, 1 ); sfb_m1 = sub( stop_sfb, 1 ); test(); - IF( hGrid->infoIsRefined != 0 && EQ_16( hopsize, 1 ) ) + IF( NE_16(hGrid->infoIsRefined, 0) && EQ_16( hopsize, 1 ) ) { /* apply filter to absolute energy values: */ FOR( sfb = sfb_p1; sfb < sfb_m1; sfb++ ) @@ -1882,7 +1882,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in /* gain calculation */ gain[sfb] = 0; move16(); - IF( pN[sfb] != 0 ) + IF( NE_32(pN[sfb], 0) ) { tmp = BASOP_Util_Divide3232_Scale( dNlocal, pN[sfb], &s ); s = sub( add( s, dNlocal_e ), pN_e[sfb] ); @@ -1907,7 +1907,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in /*--- check gains /spectrum exponents for possible overflows --- */ /* get tile index */ - if ( LE_16( hGrid->sfbWrap[tileIdx + 1], sfb ) ) + IF ( LE_16( hGrid->sfbWrap[tileIdx + 1], sfb ) ) { tileIdx = add( tileIdx, 1 ); } @@ -1917,7 +1917,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in /*check whether overflow would occur and calculate Headroom, needed*/ shift = sub( L_tmp_e, *spectrum_e ); tmp = sub( shift, sub( norm_l( L_tmp ), TCX_IMDCT_HEADROOM ) ); - if ( tmp > 0 ) + IF ( GT_16(tmp, 0) ) { Hr = s_max( Hr, tmp ); } @@ -1925,7 +1925,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in /* disable rescaling if gain is smaler than 1 */ /* gain < 1, if norm_s(gain[sfb]) >= gain_e[sfb] */ tmp = sub( norm_s( gain[sfb] ), gain_e[sfb] ); - if ( tmp >= 0 ) + IF ( GE_16(tmp, 0) ) { Hr = 0; move16(); @@ -1935,7 +1935,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in /* Rescale spectrum if overflow may occur */ tileIdx = -1; move16(); - IF( Hr > 0 ) + IF( GT_16(Hr, 0) ) { /* rescale virtual Spec, cheap and easy: reset scalingfactor */ *virtualSpec_e = add( *virtualSpec_e, Hr ); @@ -1957,7 +1957,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in FOR( sfb = start_sfb; sfb < stop_sfb; sfb++ ) { /* get tile index */ - if ( EQ_16( hGrid->sfbWrap[tileIdx + 1], sfb ) ) + IF ( EQ_16( hGrid->sfbWrap[tileIdx + 1], sfb ) ) { tileIdx = add( tileIdx, 1 ); } @@ -2035,7 +2035,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in { shift = sub( L_tmp_e, *spectrum_e ); tmp = norm_l( L_tmp ) - shift - 32; - if ( tmp < 0 ) + IF ( LT_16(tmp, 0) ) { L_tmp2 = L_shl( L_tmp, shift ); } @@ -2048,7 +2048,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in { shift = sub( L_tmp_e, *virtualSpec_e ); tmp = norm_l( L_tmp ) - shift - 32; - if ( tmp < 0 ) + IF ( LT_16(tmp, 0) ) { L_tmp2 = L_shl( L_tmp, shift ); } @@ -2236,12 +2236,12 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in /* select correct hopsize for envelope refinement */ hopsize = 2; move16(); - if ( EQ_16( hPrivateData->currWhiteningLevel[0], IGF_WHITENING_OFF ) ) + IF ( EQ_16( hPrivateData->currWhiteningLevel[0], IGF_WHITENING_OFF ) ) { hopsize = 4; move16(); } - if ( EQ_16( hPrivateData->currWhiteningLevel[0], IGF_WHITENING_STRONG ) ) + IF ( EQ_16( hPrivateData->currWhiteningLevel[0], IGF_WHITENING_STRONG ) ) { hopsize = 1; move16(); @@ -2252,7 +2252,7 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in hopsize = s_min( hopsize, 2 ); } - IF( hopsize > 1 ) + IF( GT_16(hopsize, 1) ) { FOR( sfb = start_sfb; sfb < stop_sfb; sfb += hopsize ) { @@ -2278,7 +2278,7 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in } /* IGF_rescale_SCF */ - IF( hGrid->infoIsRefined != 0 ) + IF( NE_16(hGrid->infoIsRefined, 0) ) { FOR( sfb = start_sfb; sfb < stop_sfb; sfb += 2 ) { @@ -2335,7 +2335,7 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in #endif BASOP_SATURATE_WARNING_ON_EVS - IF( L_tmp2 < 0 ) + IF( LT_32(L_tmp2, 0) ) { L_tmp = Mpy_32_16_1( sNlocal, 33 /*0.001f Q15*/ ); L_tmp_e = sNlocal_e; @@ -2402,7 +2402,7 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in 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 ) ); - IF( L_tmp2 < 0 ) + IF( LT_32(L_tmp2, 0) ) { L_tmp = Mpy_32_16_1( sNlocal, 33 /*0.001f Q15*/ ); L_tmp_e = sNlocal_e; @@ -2427,7 +2427,7 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in negate( dN[start_sfb] ), dN_e[start_sfb], &tmp ); /* float: tmp = dE - dN[start_sfb] */ - IF( tmp < 0 ) + IF( LT_16(tmp, 0) ) { /* float: dS[start_sfb] = dN[start_sfb] + fFactor * (dE-dN[start_sfb]); basop: */ L_tmp = L_mult( fFactor, tmp ); @@ -2448,7 +2448,7 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in sfb_p1 = add( start_sfb, 1 ); sfb_m1 = sub( stop_sfb, 1 ); test(); - IF( hGrid->infoIsRefined != 0 && EQ_16( hopsize, 1 ) ) + IF( NE_16(hGrid->infoIsRefined, 0) && EQ_16( hopsize, 1 ) ) { /* apply filter to absolute energy values: */ FOR( sfb = sfb_p1; sfb < sfb_m1; sfb++ ) @@ -2606,7 +2606,7 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in FOR( sfb = start_sfb; sfb < stop_sfb; sfb++ ) { /* get tile index */ - if ( EQ_16( hGrid->sfbWrap[tileIdx + 1], sfb ) ) + IF ( EQ_16( hGrid->sfbWrap[tileIdx + 1], sfb ) ) { tileIdx = add( tileIdx, 1 ); } @@ -2770,7 +2770,7 @@ static void IGF_getWhiteSpectralData( const Word32 *in, /**< in ak_norm = Mpy_32_16_r( ak, 2185 ); tmp_16 = sub( 31, norm_l( ak_norm ) ); - if ( ak == 0 ) + IF ( EQ_32(ak, 0) ) { tmp_16 = 0; move16(); @@ -2793,7 +2793,7 @@ static void IGF_getWhiteSpectralData( const Word32 *in, /**< in ak_norm = Mpy_32_16_r( ak, nrm_tab[nrm_i++] ); tmp_16 = sub( 31, norm_l( ak_norm ) ); - if ( ak == 0 ) + IF ( EQ_32(ak, 0) ) { tmp_16 = 0; move16(); @@ -2802,7 +2802,7 @@ static void IGF_getWhiteSpectralData( const Word32 *in, /**< in tmp_16 = s_min( 14, sub( 15, shr( tmp_16, 1 ) ) ); div = shl( 1, tmp_16 ); - if ( LT_32( ak, 16 ) ) + IF ( LT_32( ak, 16 ) ) { div = 1; move16(); @@ -3050,12 +3050,12 @@ void IGFDecReadData_ivas_fx( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in move16(); } - IF( isIndepFrame == 0 ) + IF( EQ_16(isIndepFrame, 0) ) { tmp = get_next_indice( st, 1 ); } - IF( tmp == 1 ) + IF( EQ_16(tmp, 1) ) { FOR( p = 0; p < nT; p++ ) { @@ -3066,16 +3066,18 @@ void IGFDecReadData_ivas_fx( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in ELSE { IGF_decode_whitening_level( st, hPrivateData, 0 ); + test(); IF( hPrivateData->igfInfo.bitRateIndex == IGF_BITRATE_SWB_48000_CPE || hPrivateData->igfInfo.bitRateIndex == IGF_BITRATE_FB_48000_CPE ) { tmp = 0; + move16(); } ELSE { tmp = get_next_indice( st, 1 ); } - IF( tmp == 1 ) + IF( EQ_16(tmp, 1) ) { FOR( p = 1; p < nT; p++ ) { @@ -3133,12 +3135,12 @@ void IGFDecReadData( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | ins move16(); } - IF( isIndepFrame == 0 ) + IF( EQ_16(isIndepFrame, 0) ) { tmp = get_next_indice( st, 1 ); } - IF( tmp == 1 ) + IF( EQ_16(tmp, 1) ) { FOR( p = 0; p < nT; p++ ) { @@ -3150,7 +3152,7 @@ void IGFDecReadData( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | ins { IGF_decode_whitening_level( st, hPrivateData, 0 ); tmp = get_next_indice( st, 1 ); - IF( tmp == 1 ) + IF( EQ_16(tmp, 1) ) { FOR( p = 1; p < nT; p++ ) { @@ -3205,7 +3207,7 @@ void IGFDecReadLevel( /**< ou move16(); IGFAllZero = get_next_indice( st, 1 ); - IF( IGFAllZero == 0 ) + IF( EQ_16(IGFAllZero, 0) ) { Copy( hPrivateData->igf_curr, hPrivateData->igf_prev, hGrid->stopSfb ); IGFSCFDecoderDecode( &hPrivateData->hArithSCFdec, st, &hPrivateData->igf_curr[m_igfSfbStart], /* 0Q15, hPrivateData->igf_curr = [0, 91] */ igfGridIdx, isIndepFrame ); @@ -3266,17 +3268,18 @@ void IGFDecApplyMono( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in set16_fx( igf_spec_e, 0, IGF_MAX_TILES ); /* concealment counter */ - IF( bfi != 0 ) + IF( NE_16(bfi, 0) ) { hPrivateData->frameLossCounter = add( hPrivateData->frameLossCounter, 1 ); } ELSE { hPrivateData->frameLossCounter = 0; + move16(); } /* skip IGF processing if all IGF levels are zero */ - IF( hInstance->infoIGFAllZero == 0 ) + IF( EQ_16(hInstance->infoIGFAllZero, 0) ) { @@ -3433,7 +3436,7 @@ void IGFDecApplyMono_ivas( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in set16_fx( igf_spec_e, 0, IGF_MAX_TILES ); /* concealment counter */ - IF( bfi != 0 ) + IF( NE_16(bfi, 0) ) { hPrivateData->frameLossCounter = add( hPrivateData->frameLossCounter, 1 ); } @@ -3444,7 +3447,7 @@ void IGFDecApplyMono_ivas( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in } /* skip IGF processing if all IGF levels are zero */ - IF( hInstance->infoIGFAllZero == 0 ) + IF( EQ_16(hInstance->infoIGFAllZero, 0) ) { FOR( i = 0; i < hGrid->nTiles; i++ ) { @@ -4048,16 +4051,21 @@ void IGFDecUpdateInfo_ivas_fx( { hGrid = &hPrivateData->igfInfo.grid[igfGridIdx]; hIGFDec->infoIGFStartFreq = hGrid->startFrequency; + move16(); hIGFDec->infoIGFStopFreq = hGrid->stopFrequency; + move16(); hIGFDec->infoIGFStartLine = hGrid->startLine; + move16(); hIGFDec->infoIGFStopLine = hGrid->stopLine; + move16(); } /* TODO: this was added to keep the EVS 16-bit noise info in sync. */ - FOR( int l = 0; l < IGF_START_MX; l++ ) + FOR( Word16 l = 0; l < IGF_START_MX; l++ ) { // u8bit to 16bit hIGFDec->infoTCXNoise_evs[l] = (Word16) hIGFDec->infoTCXNoise[l]; + move16(); } return; @@ -4265,9 +4273,9 @@ Word16 get_igf_startline( { Word16 igf_startline; - IF( st->igf == 0 ) + IF( EQ_16(st->igf, 0) ) { - IF( st->narrowBand == 0 ) + IF( EQ_16(st->narrowBand, 0) ) { /* minimum needed for output with sampling rates lower then the nominal sampling rate */ diff --git a/lib_dec/igf_scf_dec_fx.c b/lib_dec/igf_scf_dec_fx.c index ec6d6276a..a622058d7 100644 --- a/lib_dec/igf_scf_dec_fx.c +++ b/lib_dec/igf_scf_dec_fx.c @@ -27,9 +27,9 @@ void IGFSCFDecoderOpen( { - hPublicData->scfCountLongBlock[0] = hIgfInfo->grid[0].swb_offset_len - 1; - hPublicData->scfCountLongBlock[1] = hIgfInfo->grid[1].swb_offset_len - 1; - hPublicData->scfCountLongBlock[2] = hIgfInfo->grid[2].swb_offset_len - 1; + hPublicData->scfCountLongBlock[0] = sub(hIgfInfo->grid[0].swb_offset_len, 1); + hPublicData->scfCountLongBlock[1] = sub(hIgfInfo->grid[1].swb_offset_len, 1); + hPublicData->scfCountLongBlock[2] = sub(hIgfInfo->grid[2].swb_offset_len, 1); move16(); move16(); move16(); @@ -54,7 +54,7 @@ static Word16 quant_ctx_fx( result = s_min( abs_s( ctx ), IGF_CTX_OFFSET ); /* limit the absolute value to IGF_CTX_OFFSET */ - if ( ctx < 0 ) /* add the sign back, if needed */ + IF( LT_16( ctx, 0 ) ) /* add the sign back, if needed */ { result = negate( result ); } @@ -80,7 +80,7 @@ static Word16 arith_decode_bits_fx( x = lshl( x, 1 ); /* decode one bit using the new raw AC function */ bit = ari_decode_14bits_bit_ext_fx( st, &hPrivateData->acState ); - if ( bit != 0 ) + IF( NE_16( bit, 0 ) ) { x = s_or( x, 1 ); } @@ -107,7 +107,7 @@ static Word16 arith_decode_residual_fx( /* meaning of the values of val: */ /* esc_{0} IGF_MIN_ENC_SEPARATE ... IGF_MAX_ENC_SEPARATE esc_{IGF_SYMBOLS_IN_TABLE - 1} */ test(); - IF( ( val != 0 ) && ( NE_16( val, IGF_SYMBOLS_IN_TABLE - 1 ) ) ) + IF( ( NE_16( val, 0 ) ) && ( NE_16( val, IGF_SYMBOLS_IN_TABLE - 1 ) ) ) { x = add( val, -1 + IGF_MIN_ENC_SEPARATE ); /* (val - 1) + IGF_MIN_ENC_SEPARATE */ @@ -133,12 +133,12 @@ static Word16 arith_decode_residual_fx( extra = add( 15, extra ); } - if ( val == 0 ) + IF( EQ_16( val, 0 ) ) { /* escape code 0 to indicate x <= IGF_MIN_ENC_SEPARATE - 1 */ x = sub( IGF_MIN_ENC_SEPARATE - 1, extra ); } - if ( EQ_16( val, IGF_SYMBOLS_IN_TABLE - 1 ) ) + IF( EQ_16( val, IGF_SYMBOLS_IN_TABLE - 1 ) ) { /* escape code (IGF_SYMBOLS_IN_TABLE - 1) to indicate x >= IGF_MAX_ENC_SEPARATE + 1 */ x = add( IGF_MAX_ENC_SEPARATE + 1, extra ); @@ -186,9 +186,9 @@ static void decode_sfe_vector_fx( FOR( f = 0; f < length; ++f ) { - IF( t == 0 ) + IF( EQ_16( t, 0 ) ) { - IF( f == 0 ) + IF( EQ_16( f, 0 ) ) { /* (t == 0) && (f == 0) */ /* decode one of the IGF_SYMBOLS_IN_TABLE == 27 alphabet symbols using the new raw AC function */ @@ -228,7 +228,7 @@ static void decode_sfe_vector_fx( ELSE { /* t == 1 */ - IF( f == 0 ) + IF( EQ_16( f, 0 ) ) { /* (t == 1) && (f == 0) */ res = arith_decode_residual_fx( hPrivateData, @@ -264,7 +264,7 @@ static void decode_sfe_vector_fx( } } - IF( x[f] < 0 ) + IF( LT_16(x[f], 0) ) { x[f] = 0; move16(); @@ -293,6 +293,7 @@ void IGFSCFDecoderReset( /* reset of coder */ hPublicData->t = 0; /* indicate that an independent block follows */ + move16(); /* we do not need to fill hPublicData->prev with zeros, because when t = 0 no previous information is used */ } @@ -314,7 +315,7 @@ void IGFSCFDecoderDecode( ari_start_decoding_14bits_fx( st, &hPublicData->acState ); /* start AC decoding */ /* check if coder needs a reset and do it if necessary */ - IF( indepFlag != 0 ) + IF( NE_16( indepFlag, 0 ) ) { /* reset of coder */ IGFSCFDecoderReset( hPublicData ); diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index 3f94cea06..b327a6c0b 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -129,7 +129,8 @@ ivas_error init_decoder_fx( * SWB BWE parameters *-----------------------------------------------------------------*/ - IF( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) + test(); + IF( EQ_16(idchan, 0) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) { IF( ( st_fx->hBWE_FD = (FD_BWE_DEC_HANDLE) count_malloc( sizeof( FD_BWE_DEC_DATA ) ) ) == NULL ) { @@ -147,7 +148,8 @@ ivas_error init_decoder_fx( * IGF *-----------------------------------------------------------------*/ - IF( ( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) + test(); + IF( ( EQ_16(idchan, 0) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) { IF( ( st_fx->hIGFDec = (IGF_DEC_INSTANCE_HANDLE) count_malloc( sizeof( IGFDEC_INSTANCE ) ) ) == NULL ) { @@ -205,7 +207,9 @@ ivas_error init_decoder_fx( set16_fx( st_fx->prev_lpc_wb_fx, 0, LPC_SHB_ORDER_WB ); - IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) + test(); + test(); + IF( ( EQ_16(idchan, 0) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) { IF( ( st_fx->hGSCDec = (GSC_DEC_HANDLE) count_malloc( sizeof( GSC_DEC_DATA ) ) ) == NULL ) { @@ -223,7 +227,6 @@ ivas_error init_decoder_fx( * parameters for fast recovery (WI) *-----------------------------------------------------------------*/ test(); - test(); IF( EQ_32( st_fx->output_Fs, 16000 ) && EQ_16( st_fx->element_mode, EVS_MONO ) ) { IF( ( st_fx->hWIDec = (WI_DEC_HANDLE) count_malloc( sizeof( WI_DEC_DATA ) ) ) == NULL ) @@ -234,7 +237,7 @@ ivas_error init_decoder_fx( set16_fx( st_fx->hWIDec->old_exc2_fx, 0, L_EXC_MEM ); set16_fx( st_fx->hWIDec->old_syn2_fx, 0, L_EXC_MEM ); } - else + ELSE { st_fx->hWIDec = NULL; } @@ -243,6 +246,8 @@ ivas_error init_decoder_fx( /*-----------------------------------------------------------------* * NB/formant post-filter *-----------------------------------------------------------------*/ + test(); + test(); IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) { IF( ( st_fx->hPFstat = (PFSTAT_HANDLE) count_malloc( sizeof( PFSTAT ) ) ) == NULL ) @@ -324,10 +329,13 @@ ivas_error init_decoder_fx( move16(); #ifdef MSAN_FIX st_fx->Q_stat_noise = 31; + move16(); #endif // MSAN_FIX /*-----------------------------------------------------------------* * LD music post-filter *-----------------------------------------------------------------*/ + test(); + test(); IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) { IF( ( st_fx->hMusicPF = (MUSIC_POSTFILT_HANDLE) count_malloc( sizeof( MUSIC_POSTFILT_DATA ) ) ) == NULL ) @@ -346,9 +354,9 @@ ivas_error init_decoder_fx( test(); test(); test(); - IF( idchan == 0 && ( EQ_16( st_fx->element_mode, EVS_MONO ) || EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) ) + IF( EQ_16(idchan, 0) && ( EQ_16( st_fx->element_mode, EVS_MONO ) || EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) ) { - if ( ( st_fx->hTdCngDec = (TD_CNG_DEC_HANDLE) count_malloc( sizeof( TD_CNG_DEC_DATA ) ) ) == NULL ) + IF ( ( st_fx->hTdCngDec = (TD_CNG_DEC_HANDLE) count_malloc( sizeof( TD_CNG_DEC_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX/TD CNG\n" ) ); } @@ -420,7 +428,7 @@ ivas_error init_decoder_fx( test(); test(); test(); - IF( ( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || EQ_16( st_fx->element_mode, IVAS_SCE ) || EQ_16( st_fx->element_mode, EVS_MONO ) ) ) + IF( ( EQ_16(idchan, 0) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || EQ_16( st_fx->element_mode, IVAS_SCE ) || EQ_16( st_fx->element_mode, EVS_MONO ) ) ) { IF( ( st_fx->hHQ_core = (HQ_DEC_HANDLE) count_malloc( sizeof( HQ_DEC_DATA ) ) ) == NULL ) { @@ -453,8 +461,11 @@ ivas_error init_decoder_fx( move16(); } st_fx->Qprev_synth_buffer_fx = 15; + move16(); st_fx->old_bfi_cnt = 0; + move16(); st_fx->prev_old_bfi = 0; + move16(); set16_fx( st_fx->delay_buf_out_fx, 0, HQ_DELTA_MAX * HQ_DELAY_COMP ); set16_fx( st_fx->previoussynth_fx, 0, L_FRAME48k ); IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) @@ -466,7 +477,7 @@ ivas_error init_decoder_fx( *-----------------------------------------------------------------*/ /* TCX-LTP */ - IF( ( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) + IF( ( EQ_16(idchan,0) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) { IF( ( st_fx->hTcxLtpDec = (TCX_LTP_DEC_HANDLE) count_malloc( sizeof( TCX_LTP_DEC_DATA ) ) ) == NULL ) { @@ -480,7 +491,7 @@ ivas_error init_decoder_fx( /* TCX core */ // VE: reduction possible for MCT_CHAN_MODE_LFE channel - see I1-172 - IF( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) + IF( EQ_16(idchan, 0) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) { IF( ( st_fx->hTcxDec = (TCX_DEC_HANDLE) count_malloc( sizeof( TCX_DEC_DATA ) ) ) == NULL ) { @@ -497,7 +508,7 @@ ivas_error init_decoder_fx( st_fx->hTcxDec = NULL; } /* TCX config. data structure */ - IF( ( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) + IF( ( EQ_16(idchan, 0) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) { IF( ( st_fx->hTcxCfg = (TCX_CONFIG_HANDLE) count_malloc( sizeof( TCX_config ) ) ) == NULL ) { @@ -524,10 +535,10 @@ ivas_error init_decoder_fx( * TBE parameters *-----------------------------------------------------------------*/ - - IF( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) + test(); + IF( EQ_16(idchan, 0) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) { - if ( ( st_fx->hBWE_TD = (TD_BWE_DEC_HANDLE) count_malloc( sizeof( TD_BWE_DEC_DATA ) ) ) == NULL ) + IF ( ( st_fx->hBWE_TD = (TD_BWE_DEC_HANDLE) count_malloc( sizeof( TD_BWE_DEC_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD BWE\n" ) ); } @@ -540,6 +551,7 @@ ivas_error init_decoder_fx( #ifdef MSAN_FIX st_fx->hBWE_TD->prev_hb_synth_fx_exp = 31; + move16(); #endif } ELSE @@ -548,7 +560,9 @@ ivas_error init_decoder_fx( } st_fx->tilt_swb_fx = 0; + move16(); st_fx->tilt_wb_fx = 0; + move16(); st_fx->prev_ener_shb_fx = 0; move16(); @@ -608,6 +622,7 @@ ivas_error init_decoder_fx( /*----------------------------------------------------------------------------------* * AMR-WB IO mode parameters *----------------------------------------------------------------------------------*/ + test(); IF( st_fx->Opt_AMR_WB || EQ_16( st_fx->element_mode, EVS_MONO ) ) { IF( ( st_fx->hAmrwb_IO = (AMRWB_IO_DEC_HANDLE) count_malloc( sizeof( AMRWB_IO_DEC_DATA ) ) ) == NULL ) @@ -628,8 +643,9 @@ ivas_error init_decoder_fx( /*-----------------------------------------------------------------* * HF (6-7kHz) (zero) BWE parameters *-----------------------------------------------------------------*/ - - IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) + test(); + test(); + IF( ( EQ_16(idchan, 0) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) { IF( ( st_fx->hBWE_zero = (ZERO_BWE_DEC_HANDLE) count_malloc( sizeof( ZERO_BWE_DEC_DATA ) ) ) == NULL ) { @@ -650,13 +666,13 @@ ivas_error init_decoder_fx( st_fx->bpf_off = 0; + move16(); /*-----------------------------------------------------------------* * Bass post-filter parameters *-----------------------------------------------------------------*/ test(); test(); - test(); - IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) + IF( ( EQ_16(idchan, 0) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) { IF( ( st_fx->hBPF = (BPF_DEC_HANDLE) count_malloc( sizeof( BPF_DEC_DATA ) ) ) == NULL ) { @@ -673,18 +689,18 @@ ivas_error init_decoder_fx( * FD BPF & resampling tools parameters *-----------------------------------------------------------------*/ /* open analysis for max. SR 48kHz */ - if ( ( error = openCldfb( &st_fx->cldfbAna, CLDFB_ANALYSIS, CLDFB_getNumChannels( 48000 ), 320 ) ) != IVAS_ERR_OK ) + IF ( ( error = openCldfb( &st_fx->cldfbAna, CLDFB_ANALYSIS, CLDFB_getNumChannels( 48000 ), 320 ) ) != IVAS_ERR_OK ) { return error; } /* open analysis BPF for max. SR 16kHz */ - if ( ( error = openCldfb( &st_fx->cldfbBPF, CLDFB_ANALYSIS, CLDFB_getNumChannels( 16000 ), 320 ) ) != IVAS_ERR_OK ) + IF ( ( error = openCldfb( &st_fx->cldfbBPF, CLDFB_ANALYSIS, CLDFB_getNumChannels( 16000 ), 320 ) ) != IVAS_ERR_OK ) { return error; } /* open synthesis for output SR */ - if ( ( error = openCldfb( &st_fx->cldfbSyn, CLDFB_SYNTHESIS, CLDFB_getNumChannels( st_fx->output_Fs ), st_fx->output_frame_fx ) ) != IVAS_ERR_OK ) + IF ( ( error = openCldfb( &st_fx->cldfbSyn, CLDFB_SYNTHESIS, CLDFB_getNumChannels( st_fx->output_Fs ), st_fx->output_frame_fx ) ) != IVAS_ERR_OK ) { return error; } @@ -767,15 +783,17 @@ ivas_error init_decoder_fx( resampleCldfb( st_fx->cldfbAna, newCldfbBands, st_fx->L_frame, 1 ); resampleCldfb( st_fx->cldfbBPF, newCldfbBands, st_fx->L_frame, 1 ); + + test(); #ifdef IVAS_CODE IF( ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || idchan == 0 ) && NE_16( mc_mode, MC_MODE_MCT ) && NE_16( mc_mode, MC_MODE_PARAMUPMIX ) ) // TBV Fixed point missing #else - IF( ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || idchan == 0 ) /*&& mc_mode != MC_MODE_MCT && mc_mode != MC_MODE_PARAMUPMIX*/ ) + IF( ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || EQ_16(idchan, 0) ) /*&& mc_mode != MC_MODE_MCT && mc_mode != MC_MODE_PARAMUPMIX*/ ) #endif { /* Create FD_CNG instance */ - if ( ( error = createFdCngDec_fx( &st_fx->hFdCngDec ) ) != IVAS_ERR_OK ) + IF ( ( error = createFdCngDec_fx( &st_fx->hFdCngDec ) ) != IVAS_ERR_OK ) { return error; } @@ -789,6 +807,7 @@ ivas_error init_decoder_fx( } st_fx->lp_noise = -167772160l /*-20.f Q23*/; + move32(); st_fx->force_lpd_reset = 0; move16(); @@ -822,13 +841,21 @@ ivas_error init_decoder_fx( *----------------------------------------------------------------------------------*/ #if 1 // IVAS_CODE -> To be verified st_fx->tdm_LRTD_flag = 0; /* LRTD stereo mode flag */ + move16(); st_fx->cna_dirac_flag = 0; /* CNA in DirAC flag */ + move16(); st_fx->cng_sba_flag = 0; /* CNG in SBA flag */ + move16(); st_fx->element_mode = EVS_MONO; /* element mode */ + move16(); st_fx->last_element_mode = st_fx->element_mode; /* element mode */ + move16(); st_fx->element_brate = -1; /* element bitrate */ + move16(); st_fx->low_rate_mode = 0; /* low-rate mode flag */ + move16(); st_fx->last_low_rate_mode = 0; /* low-rate mode flag */ + move16(); // st_fx->cng_ism_flag = 0; // st_fx->coder_type = GENERIC; /* low-rate mode flag */ @@ -837,7 +864,9 @@ ivas_error init_decoder_fx( st_fx->id_element = -1; /* element ID */ #endif st_fx->extl_orig = -1; /* extension layer */ + move16(); st_fx->extl_brate_orig = 0; /* extension layer bitrate */ + move16(); return error; } @@ -1078,6 +1107,8 @@ ivas_error init_decoder_ivas_fx( st_fx->Last_GSC_noisy_speech_flag = 0; move16(); + test(); + test(); IF( ( EQ_16( idchan, 0 ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) { IF( ( st_fx->hGSCDec = (GSC_DEC_HANDLE) count_malloc( sizeof( GSC_DEC_DATA ) ) ) == NULL ) @@ -1095,7 +1126,8 @@ ivas_error init_decoder_ivas_fx( /*-----------------------------------------------------------------* * parameters for fast recovery (WI) *-----------------------------------------------------------------*/ - + + test(); IF( EQ_32( st_fx->output_Fs, 16000 ) && EQ_16( st_fx->element_mode, EVS_MONO ) ) { IF( ( st_fx->hWIDec = (WI_DEC_HANDLE) count_malloc( sizeof( WI_DEC_DATA ) ) ) == NULL ) @@ -1114,6 +1146,8 @@ ivas_error init_decoder_ivas_fx( /*-----------------------------------------------------------------* * NB/formant post-filter *-----------------------------------------------------------------*/ + test(); + test(); IF( ( EQ_16( idchan, 0 ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) { IF( ( st_fx->hPFstat = (PFSTAT_HANDLE) count_malloc( sizeof( PFSTAT ) ) ) == NULL ) @@ -1133,7 +1167,9 @@ ivas_error init_decoder_ivas_fx( /*-----------------------------------------------------------------* * HF (6-7kHz) (zero) BWE parameters *-----------------------------------------------------------------*/ - + + test(); + test(); IF( ( EQ_16( idchan, 0 ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) { IF( ( st_fx->hBWE_zero = (ZERO_BWE_DEC_HANDLE) malloc( sizeof( ZERO_BWE_DEC_DATA ) ) ) == NULL ) @@ -1154,7 +1190,8 @@ ivas_error init_decoder_ivas_fx( /*-----------------------------------------------------------------* * LD music post-filter *-----------------------------------------------------------------*/ - + test(); + test(); IF( ( EQ_16( idchan, 0 ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) { IF( ( st_fx->hMusicPF = (MUSIC_POSTFILT_HANDLE) count_malloc( sizeof( MUSIC_POSTFILT_DATA ) ) ) == NULL ) @@ -1186,9 +1223,12 @@ ivas_error init_decoder_ivas_fx( st_fx->active_cnt = 20; move16(); + test(); + test(); + test(); IF( EQ_16( idchan, 0 ) && ( EQ_16( st_fx->element_mode, EVS_MONO ) || EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) ) { - if ( ( st_fx->hTdCngDec = (TD_CNG_DEC_HANDLE) count_malloc( sizeof( TD_CNG_DEC_DATA ) ) ) == NULL ) + IF ( ( st_fx->hTdCngDec = (TD_CNG_DEC_HANDLE) count_malloc( sizeof( TD_CNG_DEC_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX/TD CNG\n" ) ); } @@ -1223,6 +1263,9 @@ ivas_error init_decoder_ivas_fx( set16_fx( st_fx->old_synth_sw_fx, 0, NS2SA( 48000, FRAME_SIZE_NS - ACELP_LOOK_NS - DELAY_BWE_TOTAL_NS ) ); } + test(); + test(); + test(); IF( ( EQ_16( idchan, 0 ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || EQ_16( st_fx->element_mode, IVAS_SCE ) || EQ_16( st_fx->element_mode, EVS_MONO ) ) ) { IF( ( st_fx->hHQ_core = (HQ_DEC_HANDLE) malloc( sizeof( HQ_DEC_DATA ) ) ) == NULL ) @@ -1258,9 +1301,10 @@ ivas_error init_decoder_ivas_fx( * TBE parameters *-----------------------------------------------------------------*/ + test(); IF( EQ_16( idchan, 0 ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) { - if ( ( st_fx->hBWE_TD = (TD_BWE_DEC_HANDLE) malloc( sizeof( TD_BWE_DEC_DATA ) ) ) == NULL ) + IF ( ( st_fx->hBWE_TD = (TD_BWE_DEC_HANDLE) malloc( sizeof( TD_BWE_DEC_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD BWE\n" ) ); } @@ -1283,7 +1327,7 @@ ivas_error init_decoder_ivas_fx( /*-----------------------------------------------------------------* * SWB BWE parameters *-----------------------------------------------------------------*/ - + test(); IF( EQ_16( idchan, 0 ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) { IF( ( st_fx->hBWE_FD = (FD_BWE_DEC_HANDLE) malloc( sizeof( FD_BWE_DEC_DATA ) ) ) == NULL ) @@ -1346,7 +1390,7 @@ ivas_error init_decoder_ivas_fx( /*----------------------------------------------------------------------------------* * AMR-WB IO mode parameters *----------------------------------------------------------------------------------*/ - + test(); IF( st_fx->Opt_AMR_WB || EQ_16( st_fx->element_mode, EVS_MONO ) ) { IF( ( st_fx->hAmrwb_IO = (AMRWB_IO_DEC_HANDLE) count_malloc( sizeof( AMRWB_IO_DEC_DATA ) ) ) == NULL ) @@ -1402,6 +1446,8 @@ ivas_error init_decoder_ivas_fx( st_fx->bpf_off = 0; move16(); + test(); + test(); IF( ( EQ_16( idchan, 0 ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) { IF( ( st_fx->hBPF = (BPF_DEC_HANDLE) malloc( sizeof( BPF_DEC_DATA ) ) ) == NULL ) @@ -1419,7 +1465,8 @@ ivas_error init_decoder_ivas_fx( /*-----------------------------------------------------------------* * FD BPF & resampling tools parameters *-----------------------------------------------------------------*/ - + test(); + test(); IF( ( EQ_16( idchan, 0 ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) { /* open analysis for max. SR 48kHz */ @@ -1518,6 +1565,7 @@ ivas_error init_decoder_ivas_fx( *-----------------------------------------------------------------*/ /* TCX-LTP */ + test(); IF( ( EQ_16( idchan, 0 ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) { IF( ( st_fx->hTcxLtpDec = (TCX_LTP_DEC_HANDLE) count_malloc( sizeof( TCX_LTP_DEC_DATA ) ) ) == NULL ) @@ -1531,6 +1579,7 @@ ivas_error init_decoder_ivas_fx( } /* TCX core */ + test(); IF( EQ_16( idchan, 0 ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) { IF( ( st_fx->hTcxDec = (TCX_DEC_HANDLE) malloc( sizeof( TCX_DEC_DATA ) ) ) == NULL ) @@ -1549,6 +1598,7 @@ ivas_error init_decoder_ivas_fx( } /* TCX config. data structure */ + test(); IF( ( EQ_16( idchan, 0 ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) { IF( ( st_fx->hTcxCfg = (TCX_CONFIG_HANDLE) count_malloc( sizeof( TCX_config ) ) ) == NULL ) @@ -1562,6 +1612,7 @@ ivas_error init_decoder_ivas_fx( } /* Tonal MDCT concealment data structure */ + test(); IF( ( EQ_16( idchan, 0 ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) { IF( ( st_fx->hTonalMDCTConc = (TonalMDCTConcealPtr) malloc( sizeof( TonalMDCTConceal_INSTANCE ) ) ) == NULL ) @@ -1577,7 +1628,8 @@ ivas_error init_decoder_ivas_fx( /*-----------------------------------------------------------------* * IGF *-----------------------------------------------------------------*/ - + + test(); IF( ( EQ_16( idchan, 0 ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) { IF( ( st_fx->hIGFDec = (IGF_DEC_INSTANCE_HANDLE) malloc( sizeof( IGFDEC_INSTANCE ) ) ) == NULL ) @@ -1644,6 +1696,7 @@ ivas_error init_decoder_ivas_fx( st_fx->m_old_frame_type = ACTIVE_FRAME; move16(); + test(); IF( ( EQ_16( idchan, 0 ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) { resampleCldfb_ivas_fx( st_fx->cldfbAna, L_mult0( st_fx->L_frame, FRAMES_PER_SEC ) ); @@ -1654,6 +1707,9 @@ ivas_error init_decoder_ivas_fx( * FD-CNG decoder *-----------------------------------------------------------------*/ + test(); + test(); + test(); IF( ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || EQ_16( idchan, 0 ) ) && NE_16( mc_mode, MC_MODE_MCT ) && NE_16( mc_mode, MC_MODE_PARAMUPMIX ) ) { /* Create FD_CNG instance */ diff --git a/lib_dec/inov_dec_fx.c b/lib_dec/inov_dec_fx.c index cedf36a6e..0024e7464 100644 --- a/lib_dec/inov_dec_fx.c +++ b/lib_dec/inov_dec_fx.c @@ -60,61 +60,71 @@ void inov_decode_fx( IF( EQ_16( L_frame, L_FRAME ) ) { g1 = FORMANT_SHARPENING_G1; + move16(); g2 = FORMANT_SHARPENING_G2; + move16(); } ELSE { g1 = FORMANT_SHARPENING_G1_16k; + move16(); g2 = FORMANT_SHARPENING_G2_16k; + move16(); } IF( !Opt_AMR_WB ) { - if ( st_fx->acelp_cfg.fcb_mode ) + IF ( st_fx->acelp_cfg.fcb_mode ) { - int16_t i; - int16_t indexing_indices[8], wordcnt, bitcnt; + Word16 i; + Word16 indexing_indices[8], wordcnt, bitcnt; PulseConfig config; - if ( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_subfr] >= 0 ) + test(); + test(); + test(); + IF( GE_16( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_subfr], 0 ) ) { - if ( L_subfr == 2 * L_SUBFR ) + IF( EQ_16( L_subfr, 2 * L_SUBFR ) ) { nBits = st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_subfr]; + move16(); - if ( nBits == 8 ) + IF( EQ_16( nBits, 8 ) ) { // dec_acelp_1t64(st_fx, code, L_subfr); dec_acelp_1t64_fx( st_fx, code, L_subfr ); } - else + ELSE { // dec_acelp_fast(st_fx, nBits, code, L_subfr); dec_acelp_fast_fx( st_fx, nBits, code, L_subfr ); } } - else if ( ( st_fx->idchan == 1 && st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] <= 7 ) || ( st_fx->idchan == 0 && st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] <= 3 ) ) + ELSE IF( ( EQ_16( st_fx->idchan, 1 ) && LE_16( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR], 7 ) ) || ( EQ_16( st_fx->idchan, 0 ) && LE_16( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR], 3 ) ) ) { - if ( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] == 0 ) + IF( EQ_16( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR], 0 ) ) { // dec_acelp_1t64(st_fx, code, L_SUBFR); dec_acelp_1t64_fx( st_fx, code, L_SUBFR ); } - else + ELSE { // dec_acelp_fast(st_fx, st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR], code, L_SUBFR); dec_acelp_fast_fx( st_fx, st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR], code, L_SUBFR ); } } - else + ELSE { wordcnt = ACELP_FIXED_CDK_BITS( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] ) >> 4; + move16(); bitcnt = ACELP_FIXED_CDK_BITS( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] ) & 15; + move16(); // PMT("CONDITION above is missing -> idchan") - for ( i = 0; i < wordcnt; i++ ) + FOR ( i = 0; i < wordcnt; i++ ) { indexing_indices[i] = get_next_indice( st_fx, 16 ); } - if ( bitcnt ) + IF( bitcnt ) { indexing_indices[i] = get_next_indice( st_fx, bitcnt ); } @@ -122,14 +132,15 @@ void inov_decode_fx( D_ACELP_indexing_fx( code, config, NB_TRACK_FCB_4T, indexing_indices, &st_fx->BER_detect ); } } - else + ELSE { set16_fx( code, 0, L_SUBFR ); } } - else + ELSE { nBits = st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR]; + move16(); IF( EQ_16( nBits, 7 ) ) { @@ -237,12 +248,16 @@ void inov_decode_ivas_fx( IF( EQ_16( L_frame, L_FRAME ) ) { g1 = FORMANT_SHARPENING_G1; + move16(); g2 = FORMANT_SHARPENING_G2; + move16(); } ELSE { g1 = FORMANT_SHARPENING_G1_16k; + move16(); g2 = FORMANT_SHARPENING_G2_16k; + move16(); } IF( !Opt_AMR_WB ) @@ -253,6 +268,9 @@ void inov_decode_ivas_fx( Word16 i; Word16 indexing_indices[8], wordcnt, bitcnt; PulseConfig config; + test(); + test(); + test(); IF( GE_16( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_subfr], 0 ) ) { IF( EQ_16( L_subfr, 2 * L_SUBFR ) ) @@ -270,7 +288,7 @@ void inov_decode_ivas_fx( dec_acelp_fast_fx( st_fx, nBits, code, L_subfr ); } } - ELSE IF( ( EQ_16( st_fx->idchan, 1 ) && LE_16( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR], 7 ) ) || ( st_fx->idchan == 0 && st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] <= 3 ) ) + ELSE IF( ( EQ_16( st_fx->idchan, 1 ) && LE_16( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR], 7 ) ) || ( EQ_16( st_fx->idchan, 0 ) && LE_16( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR], 3 ) ) ) { IF( EQ_16( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR], 0 ) ) { @@ -286,7 +304,9 @@ void inov_decode_ivas_fx( ELSE { wordcnt = shr( ACELP_FIXED_CDK_BITS( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] ), 4 ); + move16(); bitcnt = ACELP_FIXED_CDK_BITS( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] ) & 15; + move16(); // PMT("CONDITION above is missing -> idchan") FOR( i = 0; i < wordcnt; i++ ) { @@ -309,6 +329,7 @@ void inov_decode_ivas_fx( #endif { nBits = st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR]; + move16(); IF( EQ_16( nBits, 7 ) ) { diff --git a/lib_dec/ivas_dirac_output_synthesis_cov.c b/lib_dec/ivas_dirac_output_synthesis_cov.c index 6c09458ba..70a8a0e2e 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov.c @@ -1091,13 +1091,11 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx( /* apply residual mixing */ - matrix_product_fx( mixing_matrix_res_smooth_fx, nY, nY, 0, diff_f_real_fx, nY, 1, 0, output_f_real_fx ); - output_f_real_e = add( mixing_matrix_res_smooth_e, 25 ); + matrix_product_mant_exp_fx( mixing_matrix_res_smooth_fx, mixing_matrix_res_smooth_e, nY, nY, 0, diff_f_real_fx, 25, nY, 1, 0, output_f_real_fx, &output_f_real_e ); scale_sig32( output_f_real_fx, nY, 6 - ( 31 - output_f_real_e ) ); - matrix_product_fx( mixing_matrix_res_smooth_fx, nY, nY, 0, diff_f_imag_fx, nY, 1, 0, output_f_imag_fx ); - output_f_imag_e = mixing_matrix_res_smooth_e + 25; + matrix_product_mant_exp_fx( mixing_matrix_res_smooth_fx, mixing_matrix_res_smooth_e, nY, nY, 0, diff_f_imag_fx, 25, nY, 1, 0, output_f_imag_fx, &output_f_imag_e ); scale_sig32( output_f_imag_fx, nY, 6 - ( 31 - output_f_imag_e ) ); FOR( ch_idx = 0; ch_idx < nY; ch_idx++ ) @@ -1131,13 +1129,11 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx( /* apply mixing matrix */ - matrix_product_fx( mixing_matrix_smooth_fx, nY, nX, 0, input_f_real_fx, nX, 1, 0, output_f_real_fx ); - output_f_real_e = add( mixing_matrix_smooth_e, 25 ); + matrix_product_mant_exp_fx( mixing_matrix_smooth_fx, mixing_matrix_smooth_e, nY, nX, 0, input_f_real_fx, 25, nX, 1, 0, output_f_real_fx, &output_f_real_e ); scale_sig32( output_f_real_fx, MAX_CICP_CHANNELS, sub( 6, sub( 31, output_f_real_e ) ) ); - matrix_product_fx( mixing_matrix_smooth_fx, nY, nX, 0, input_f_imag_fx, nX, 1, 0, output_f_imag_fx ); - output_f_imag_e = add( mixing_matrix_smooth_e, 25 ); + matrix_product_mant_exp_fx( mixing_matrix_smooth_fx, mixing_matrix_smooth_e, nY, nX, 0, input_f_imag_fx, 25, nX, 1, 0, output_f_imag_fx, &output_f_imag_e ); scale_sig32( output_f_imag_fx, MAX_CICP_CHANNELS, sub( 6, sub( 31, output_f_imag_e ) ) ); /* collect output */ @@ -1701,9 +1697,7 @@ Word16 computeMixingMatrices_fx( /* Computing Q*Cx*Q' */ - matrix_product_fx( Q_fx, lengthCy, lengthCx, 0, Cx_fx, lengthCx, lengthCx, 0, Q_Cx_fx ); - Q_Cx_e = Q_e + Cx_fx_e; - + matrix_product_mant_exp_fx( Q_fx, Q_e, lengthCy, lengthCx, 0, Cx_fx, Cx_fx_e, lengthCx, lengthCx, 0, Q_Cx_fx, &Q_Cx_e ); Word16 guard_bits = find_guarded_bits_fx( lengthCx + 1 ); @@ -1790,15 +1784,11 @@ Word16 computeMixingMatrices_fx( /* Computing the input matrix Kx'*Q'*G_hat'*Ky */ - matrix_product_fx( Kx_fx, lengthCx, lengthCx, 1, Q_fx, lengthCy, lengthCx, 1, mat_mult_buffer1_fx ); - mat_mult_buffer1_e = Kx_fx_e[0] + Q_e; - + matrix_product_mant_exp_fx( Kx_fx, Kx_fx_e[0], lengthCx, lengthCx, 1, Q_fx, Q_e, lengthCy, lengthCx, 1, mat_mult_buffer1_fx, &mat_mult_buffer1_e ); matrix_diag_product_fx( mat_mult_buffer1_fx, mat_mult_buffer1_e, lengthCx, lengthCy, 0, G_hat_fx, G_hat_e, lengthCy, mat_mult_buffer2_fx, &mat_mult_buffer2_e ); - matrix_product_fx( mat_mult_buffer2_fx, lengthCx, lengthCy, 0, Ky_fx, lengthCy, lengthCy, 0, mat_mult_buffer1_fx ); - mat_mult_buffer1_e = mat_mult_buffer2_e + Ky_fx_e[0]; - + matrix_product_mant_exp_fx( mat_mult_buffer2_fx, mat_mult_buffer2_e, lengthCx, lengthCy, 0, Ky_fx, Ky_fx_e[0], lengthCy, lengthCy, 0, mat_mult_buffer1_fx, &mat_mult_buffer1_e ); IF( lengthCx < lengthCy ) { @@ -1843,42 +1833,15 @@ Word16 computeMixingMatrices_fx( mat_mult_buffer1_e = 0; mat_mult_buffer2_e = 0; - guard_bits = find_guarded_bits_fx( lengthCx + 1 ); - FOR( i = 0; i < lengthCx * lengthCy; ++i ) - { - IF( mat_mult_buffer1_e > mat_mult_buffer1_e ) - { - mat_mult_buffer1_fx[i] = L_shr( mat_mult_buffer1_fx[i], guard_bits ); - } - ELSE - { - mat_mult_buffer2_fx[i] = L_shr( mat_mult_buffer2_fx[i], guard_bits ); - } - } - - IF( mat_mult_buffer1_e > mat_mult_buffer2_e ) - { - mat_mult_buffer2_e += guard_bits; - } - ELSE - { - mat_mult_buffer1_e += guard_bits; - } - - matrix_product_fx( mat_mult_buffer1_fx, lengthCy, lengthCx, 0, - mat_mult_buffer2_fx, lengthCx, lengthCx, 1, - mat_mult_buffer3_fx ); - mat_mult_buffer3_e = mat_mult_buffer1_e + mat_mult_buffer2_e; + matrix_product_mant_exp_fx( mat_mult_buffer1_fx, mat_mult_buffer1_e, lengthCy, lengthCx, 0, + mat_mult_buffer2_fx, mat_mult_buffer2_e, lengthCx, lengthCx, 1, + mat_mult_buffer3_fx, &mat_mult_buffer3_e ); /************************ Formulate M **********************/ - matrix_product_fx( Ky_fx, lengthCy, lengthCy, 0, mat_mult_buffer3_fx, lengthCy, lengthCx, 0, mat_mult_buffer1_fx ); - mat_mult_buffer1_e = Ky_fx_e[0] + mat_mult_buffer3_e; - - - matrix_product_fx( mat_mult_buffer1_fx, lengthCy, lengthCx, 0, Kx_reg_inv_fx, lengthCx, lengthCx, 0, mixing_matrix_fx ); - mixing_matrix_e = Kx_reg_inv_e[0] + mat_mult_buffer1_e; + matrix_product_mant_exp_fx( Ky_fx, Ky_fx_e[0], lengthCy, lengthCy, 0, mat_mult_buffer3_fx, mat_mult_buffer3_e, lengthCy, lengthCx, 0, mat_mult_buffer1_fx, &mat_mult_buffer1_e ); + matrix_product_mant_exp_fx( mat_mult_buffer1_fx, mat_mult_buffer1_e, lengthCy, lengthCx, 0, Kx_reg_inv_fx, Kx_reg_inv_e[0], lengthCx, lengthCx, 0, mixing_matrix_fx, &mixing_matrix_e ); /*-----------------------------------------------------------------* * Formulate Cr @@ -1887,11 +1850,9 @@ Word16 computeMixingMatrices_fx( /* Compute Cy_tilde = M*Cx*M' */ - matrix_product_fx( mixing_matrix_fx, lengthCy, lengthCx, 0, Cx_fx, lengthCx, lengthCx, 0, mat_mult_buffer1_fx ); - mat_mult_buffer1_e = mixing_matrix_e + Cx_fx_e; + matrix_product_mant_exp_fx( mixing_matrix_fx, mixing_matrix_e, lengthCy, lengthCx, 0, Cx_fx, Cx_fx_e, lengthCx, lengthCx, 0, mat_mult_buffer1_fx, &mat_mult_buffer1_e); - matrix_product_fx( mat_mult_buffer1_fx, lengthCy, lengthCx, 0, mixing_matrix_fx, lengthCy, lengthCx, 1, mat_mult_buffer2_fx ); - mat_mult_buffer2_e = mat_mult_buffer1_e + mixing_matrix_e; + matrix_product_mant_exp_fx( mat_mult_buffer1_fx, mat_mult_buffer1_e, lengthCy, lengthCx, 0, mixing_matrix_fx, mixing_matrix_e, lengthCy, lengthCx, 1, mat_mult_buffer2_fx, &mat_mult_buffer2_e); Cr_p_fx = Cr_fx; Cy_p_fx = Cy_fx; @@ -2490,44 +2451,20 @@ Word16 computeMixingMatricesResidual_fx( svdMat2mat_fx( svd_v_buffer_fx, mat_mult_buffer1_fx, lengthCy, lengthCx ); svdMat2mat_fx( svd_u_buffer_fx, mat_mult_buffer2_fx, lengthCx, lengthCx ); - mat_mult_buffer2_e = 0; - move16(); mat_mult_buffer1_e = 0; move16(); + mat_mult_buffer2_e = 0; + move16(); - Word16 guard_bits = find_guarded_bits_fx( lengthCx + 1 ); - - FOR( i = 0; i < lengthCy * lengthCx; ++i ) - { - IF( mat_mult_buffer1_e > mat_mult_buffer2_e ) - { - mat_mult_buffer2_fx[i] = L_shr( mat_mult_buffer2_fx[i], guard_bits ); - } - ELSE - { - mat_mult_buffer1_fx[i] = L_shr( mat_mult_buffer1_fx[i], guard_bits ); - } - } - - IF( mat_mult_buffer1_e > mat_mult_buffer2_e ) - { - mat_mult_buffer2_e += guard_bits; - } - ELSE - { - mat_mult_buffer1_e += guard_bits; - } - matrix_product_fx( mat_mult_buffer1_fx, lengthCy, lengthCx, 0, - mat_mult_buffer2_fx, lengthCx, lengthCx, 1, - mat_mult_buffer3_fx ); - mat_mult_buffer3_e = 0; + matrix_product_mant_exp_fx( mat_mult_buffer1_fx, mat_mult_buffer1_e, lengthCy, lengthCx, 0, + mat_mult_buffer2_fx, mat_mult_buffer2_e, lengthCx, lengthCx, 1, + mat_mult_buffer3_fx, &mat_mult_buffer3_e); /*-----------------------------------------------------------------* * Formulate M *-----------------------------------------------------------------*/ - matrix_product_fx( Ky_fx, lengthCy, lengthCy, 0, mat_mult_buffer3_fx, lengthCy, lengthCx, 0, mat_mult_buffer1_fx ); - mat_mult_buffer1_e = Ky_fx_e[0] + mat_mult_buffer3_e; + matrix_product_mant_exp_fx( Ky_fx, Ky_fx_e[0], lengthCy, lengthCy, 0, mat_mult_buffer3_fx, mat_mult_buffer3_e, lengthCy, lengthCx, 0, mat_mult_buffer1_fx, &mat_mult_buffer1_e); FOR( i = 0; i < num_outputs; i++ ) { @@ -2549,7 +2486,7 @@ Word16 computeMixingMatricesResidual_fx( matrix_diag_product_fx( mixing_matrix_fx, mixing_matrix_e, lengthCy, lengthCx, 0, Cx_fx, Cx_e, lengthCx, mat_mult_buffer1_fx, &mat_mult_buffer1_e ); - guard_bits = find_guarded_bits_fx( lengthCx + 1 ); + Word16 guard_bits = find_guarded_bits_fx( lengthCx + 1 ); FOR( i = 0; i < lengthCy * lengthCx; ++i ) { diff --git a/lib_dec/updt_dec_fx.c b/lib_dec/updt_dec_fx.c index fb846b91a..8b817242f 100644 --- a/lib_dec/updt_dec_fx.c +++ b/lib_dec/updt_dec_fx.c @@ -984,9 +984,11 @@ void ivas_updt_dec_common_fx( } #endif #ifdef NON_BE_1055_RESET_LP_MEMORIES - IF( ( LE_32( st_fx->core_brate, SID_2k40 ) && EQ_16( st_fx->cng_type, FD_CNG ) ) || ( st_fx->tcxonly && ( EQ_16( st_fx->codec_mode, MODE2 ) || GT_16( st_fx->element_mode, EVS_MONO ) ) ) ) + IF( (LE_32(st_fx->core_brate , SID_2k40) && EQ_16(st_fx->cng_type , FD_CNG) ) || (st_fx->tcxonly && (EQ_16(st_fx->codec_mode , MODE2) || GT_16(st_fx->element_mode , EVS_MONO)) ) ) #else - IF( ( ( LE_32( st_fx->core_brate, SID_2k40 ) ) && EQ_16( st_fx->cng_type, FD_CNG ) ) || ( st_fx->tcxonly && EQ_16( st_fx->codec_mode, MODE2 ) ) ) + IF( ((LE_32(st_fx->core_brate,SID_2k40))&&EQ_16(st_fx->cng_type,FD_CNG)) + || (st_fx->tcxonly && EQ_16(st_fx->codec_mode,MODE2)) + ) #endif { -- GitLab From 37f9b19490d5d86828f38a0911ce1a90ac5be286 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 12 Jun 2024 11:51:11 +0530 Subject: [PATCH 2/3] clang formatting changes --- lib_dec/dec4t64_fx.c | 6 +- lib_dec/hq_core_dec_fx.c | 2 +- lib_dec/hq_lr_dec_fx.c | 8 +- lib_dec/igf_dec_fx.c | 150 +++++++++++----------- lib_dec/igf_scf_dec_fx.c | 8 +- lib_dec/init_dec_fx.c | 66 +++++----- lib_dec/inov_dec_fx.c | 4 +- lib_dec/ivas_dirac_output_synthesis_cov.c | 14 +- lib_dec/updt_dec_fx.c | 6 +- 9 files changed, 130 insertions(+), 134 deletions(-) diff --git a/lib_dec/dec4t64_fx.c b/lib_dec/dec4t64_fx.c index 882dd67f9..10e9b5b13 100644 --- a/lib_dec/dec4t64_fx.c +++ b/lib_dec/dec4t64_fx.c @@ -299,7 +299,7 @@ void dec_1p_N1_fx( /* i = ((index >> N) & 1); */ i = L_shr( index, N ) & 1L; - IF ( i != 0 ) + IF( i != 0 ) { pos1 = add( pos1, NB_POS_FCB_4T ); } @@ -697,7 +697,7 @@ static void fcb_decode_position_fx( FOR( ; PI_select_table[L_sub( 16, l )][temp] >= k; l += 2 ); - IF ( GT_32( k, PI_select_table[L_sub( 17, l )][temp] ) ) + IF( GT_32( k, PI_select_table[L_sub( 17, l )][temp] ) ) { l = L_sub( l, 1 ); } @@ -779,7 +779,7 @@ void D_ACELP_decode_43bit_fx( UWord16 idxs[], Word16 code[], Word16 *pulsestrack move32(); joint_index = L_shr( L_add( L_shl( (Word32) idxs[2], 16 ), (Word32) idxs[1] ), 2 ); - IF ( GE_32( joint_index, joint_offset ) ) + IF( GE_32( joint_index, joint_offset ) ) { joint_index = L_sub( joint_index, joint_offset ); } diff --git a/lib_dec/hq_core_dec_fx.c b/lib_dec/hq_core_dec_fx.c index 81cfae830..e13071294 100644 --- a/lib_dec/hq_core_dec_fx.c +++ b/lib_dec/hq_core_dec_fx.c @@ -131,7 +131,7 @@ void hq_core_dec_fx( { hHQ_core->HqVoicing = 0; move16(); - IF ( GT_32( st_fx->core_brate, MINIMUM_RATE_TO_ENCODE_VOICING_FLAG ) ) + IF( GT_32( st_fx->core_brate, MINIMUM_RATE_TO_ENCODE_VOICING_FLAG ) ) { hHQ_core->HqVoicing = 1; move16(); diff --git a/lib_dec/hq_lr_dec_fx.c b/lib_dec/hq_lr_dec_fx.c index 3ed9d6f0a..8a014d817 100644 --- a/lib_dec/hq_lr_dec_fx.c +++ b/lib_dec/hq_lr_dec_fx.c @@ -240,7 +240,7 @@ void hq_lr_dec_fx( { num_bits = sub( num_bits, get_usebit_npswb_fx( hqswb_clas_fx ) ); } - IF ( EQ_16( hqswb_clas_fx, HQ_NORMAL ) ) + IF( EQ_16( hqswb_clas_fx, HQ_NORMAL ) ) { flag_spt_fx = 1; move16(); @@ -435,7 +435,7 @@ void hq_lr_dec_fx( #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 ) ) + IF( GT_32( Ep_tmp_fx[i], Ep_peak_fx ) ) { Ep_peak_fx = L_add( Ep_tmp_fx[i], 0 ); /*Q15 */ } @@ -564,7 +564,7 @@ void hq_lr_dec_fx( ELSE { Ep_avrgL_fx = L_add( Ep_avrgL_fx, L_shr( Ep_tmp_fx[i], 1 ) ); /*Q12 */ - IF ( GT_32( Ep_tmp_fx[i], Ep_peak_fx ) ) + IF( GT_32( Ep_tmp_fx[i], Ep_peak_fx ) ) { Ep_peak_fx = L_add( Ep_tmp_fx[i], 0 ); /*Q13 */ } @@ -798,7 +798,7 @@ void hq_lr_dec_fx( #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 ) ) + IF( GT_32( Ep_tmp_fx[i], Ep_peak_fx ) ) { Ep_peak_fx = L_add( Ep_tmp_fx[i], 0 ); /*Q15 */ } diff --git a/lib_dec/igf_dec_fx.c b/lib_dec/igf_dec_fx.c index 4ae2c9ebd..deace01a0 100644 --- a/lib_dec/igf_dec_fx.c +++ b/lib_dec/igf_dec_fx.c @@ -109,26 +109,24 @@ static Word16 IGF_replaceTCXNoise_1( /**< ou nE = 0; move32(); - FOR( sb = start; sb < stop; sb++ ) - { - IF ( TCXNoise[sb] ) - { + FOR( sb = start; sb < stop; sb++ ){ + IF( TCXNoise[sb] ){ tmp16 = extract_h( L_shl( in[sb], s_l ) ); - } - IF ( TCXNoise[sb] ) - { - nE = L_mac( nE, tmp16, tmp16 ); - } - IF ( TCXNoise[sb] ) - { - noise = add( noise, 1 ); - } - } +} +IF( TCXNoise[sb] ) +{ + nE = L_mac( nE, tmp16, tmp16 ); +} +IF( TCXNoise[sb] ) +{ + noise = add( noise, 1 ); +} +} - *totalNoiseNrg = nE; - move32(); +*totalNoiseNrg = nE; +move32(); - return noise; +return noise; } /**********************************************************************/ /* @@ -157,7 +155,7 @@ static void IGF_replaceTCXNoise_2( Word32 *in, /**< in FOR( sb = start; sb < stop; sb++ ) { - IF ( TCXNoise[sb] ) + IF( TCXNoise[sb] ) { val = Random( nfSeed ); } @@ -204,7 +202,7 @@ static void IGF_replaceTCXNoise_2( Word32 *in, /**< in FOR( sb = start; sb < stop; sb++ ) { - IF ( TCXNoise[sb] ) + IF( TCXNoise[sb] ) { in[sb] = L_shr( L_mult( extract_l( in[sb] ), g ), s_l ); move32(); @@ -261,13 +259,13 @@ static void IGF_replaceTCXNoise_2_new_ivas( Word32 *in, /**< in noise_band_ratio = div_s( n_noise_bands_tile, n_noise_bands ); // Q15 /* make sure that rE is never 0 */ - IF ( EQ_32(rE, 0) ) + IF( EQ_32( rE, 0 ) ) { rE = L_add( totalNoiseNrg, 0 ); /* save move32() -> use L_add(x, 0) = x; */ } /* if totalNoiseNrg == 0, then rE must be at least 0x00010000, otherwise division by 0 will occur */ - IF ( EQ_32(totalNoiseNrg, 0) ) + IF( EQ_32( totalNoiseNrg, 0 ) ) { rE = L_max( rE, 0x00010000 ); } @@ -343,13 +341,13 @@ static void IGF_replaceTCXNoise_2_new_ivas_with_var_shift( Word32 *in, noise_band_ratio = div_s( n_noise_bands_tile, n_noise_bands ); // Q15 /* make sure that rE is never 0 */ - IF( EQ_32(rE, 0) ) + IF( EQ_32( rE, 0 ) ) { rE = L_add( totalNoiseNrg, 0 ); /* save move32() -> use L_add(x, 0) = x; */ } /* if totalNoiseNrg == 0, then rE must be at least 0x00010000, otherwise division by 0 will occur */ - IF( EQ_32(totalNoiseNrg, 0) ) + IF( EQ_32( totalNoiseNrg, 0 ) ) { rE = L_max( rE, 0x00010000 ); } @@ -391,7 +389,7 @@ static void IGF_decode_whitening_level( Decoder_State *st, tmp = get_next_indice( st, 1 ); - IF( EQ_16(tmp, 0) ) + IF( EQ_16( tmp, 0 ) ) { hPrivateData->currWhiteningLevel[p] = IGF_WHITENING_MID; move16(); @@ -403,7 +401,7 @@ static void IGF_decode_whitening_level( Decoder_State *st, hPrivateData->currWhiteningLevel[p] = IGF_WHITENING_STRONG; move16(); - IF ( EQ_16(tmp, 0) ) + IF( EQ_16( tmp, 0 ) ) { hPrivateData->currWhiteningLevel[p] = IGF_WHITENING_OFF; move16(); @@ -436,7 +434,7 @@ static void IGF_setLinesToZero( const Word16 startLine, /**< in if there is content in the original MDCT spectrum */ FOR( i = startLine; i < stopLine; i++ ) { - IF ( NE_32(pSpectralData[i], 0) ) + IF( NE_32( pSpectralData[i], 0 ) ) { pPowerSpecIGF[i] = L_deposit_l( 0 ); } @@ -547,7 +545,7 @@ static void IGF_prep( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in tb = hGrid->swb_offset[hGrid->sfbWrap[tile_idx]]; move16(); - IF( NE_32(abs_sum, 0) ) + IF( NE_32( abs_sum, 0 ) ) { FOR( i = strt_cpy; i < startLine; i++ ) { @@ -572,7 +570,7 @@ static void IGF_prep( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in /* medium whitening detected */ IF( EQ_16( IGF_WHITENING_MID, hPrivateData->currWhiteningLevel[tile_idx] ) ) { - IF( NE_16(n_noise_bands, 0) ) + IF( NE_16( n_noise_bands, 0 ) ) { IGF_replaceTCXNoise_2( igf_spec, TCXNoise, @@ -595,7 +593,7 @@ static void IGF_prep( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in /* off whitening detectded */ ELSE { - IF( NE_16(n_noise_bands_off, 0) ) + IF( NE_16( n_noise_bands_off, 0 ) ) { IGF_replaceTCXNoise_2( hPrivateData->pSpecFlat, TCXNoise, @@ -692,7 +690,7 @@ static void IGF_prep_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in IF( GT_16( element_mode, EVS_MONO ) ) { - tile_width = sub(hGrid->swb_offset[hGrid->sfbWrap[tile_idx + 1]], hGrid->swb_offset[hGrid->sfbWrap[tile_idx]]); + tile_width = sub( hGrid->swb_offset[hGrid->sfbWrap[tile_idx + 1]], hGrid->swb_offset[hGrid->sfbWrap[tile_idx]] ); stop = add( strt_cpy, tile_width ); } ELSE @@ -717,7 +715,7 @@ static void IGF_prep_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in tb = hGrid->swb_offset[hGrid->sfbWrap[tile_idx]]; move16(); - IF( NE_32(abs_sum, 0) ) + IF( NE_32( abs_sum, 0 ) ) { FOR( i = strt_cpy; i < stop; i++ ) { @@ -744,7 +742,7 @@ static void IGF_prep_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in { IF( GT_16( element_mode, EVS_MONO ) ) { - IF( NE_16(n_noise_bands, 0) ) + IF( NE_16( n_noise_bands, 0 ) ) { IGF_replaceTCXNoise_2_new_ivas( igf_spec, specMed_e, @@ -759,7 +757,7 @@ static void IGF_prep_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in } ELSE { - IF( NE_16(n_noise_bands, 0) ) + IF( NE_16( n_noise_bands, 0 ) ) { IGF_replaceTCXNoise_2( igf_spec, TCXNoise, @@ -785,7 +783,7 @@ static void IGF_prep_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in IF( GT_16( element_mode, EVS_MONO ) ) { - IF( NE_16(n_noise_bands_off, 0) ) + IF( NE_16( n_noise_bands_off, 0 ) ) { IGF_replaceTCXNoise_2_new_ivas( src_spec, src_spec_e, @@ -800,7 +798,7 @@ static void IGF_prep_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in } ELSE { - IF( NE_16(n_noise_bands_off, 0) ) + IF( NE_16( n_noise_bands_off, 0 ) ) { IGF_replaceTCXNoise_2( src_spec, TCXNoise, @@ -1533,19 +1531,19 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in /* select correct hopsize for envelope refinement */ hopsize = 2; move16(); - IF ( EQ_16( hPrivateData->currWhiteningLevel[0], IGF_WHITENING_OFF ) ) + IF( EQ_16( hPrivateData->currWhiteningLevel[0], IGF_WHITENING_OFF ) ) { hopsize = 4; move16(); } - IF ( EQ_16( hPrivateData->currWhiteningLevel[0], IGF_WHITENING_STRONG ) ) + IF( EQ_16( hPrivateData->currWhiteningLevel[0], IGF_WHITENING_STRONG ) ) { hopsize = 1; move16(); } hopsize = s_min( hopsize, hPrivateData->igfInfo.maxHopsize ); - IF( GT_16(hopsize, 1) ) + IF( GT_16( hopsize, 1 ) ) { FOR( sfb = start_sfb; sfb < stop_sfb; sfb += hopsize ) { @@ -1571,7 +1569,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in } /* IGF_rescale_SCF */ - IF( NE_16(hGrid->infoIsRefined, 0) ) + IF( NE_16( hGrid->infoIsRefined, 0 ) ) { FOR( sfb = start_sfb; sfb < stop_sfb; sfb += 2 ) { @@ -1628,7 +1626,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in #endif BASOP_SATURATE_WARNING_ON_EVS - IF( LT_32(L_tmp2, 0) ) + IF( LT_32( L_tmp2, 0 ) ) { L_tmp = Mpy_32_16_1( sNlocal, 33 /*0.001f Q15*/ ); L_tmp_e = sNlocal_e; @@ -1706,7 +1704,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in #endif BASOP_SATURATE_WARNING_ON_EVS - IF( LT_32(L_tmp2, 0) ) + IF( LT_32( L_tmp2, 0 ) ) { L_tmp = Mpy_32_16_1( sNlocal, 33 /*0.001f Q15*/ ); L_tmp_e = sNlocal_e; @@ -1731,7 +1729,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in negate( dN[start_sfb] ), dN_e[start_sfb], &tmp ); /* float: tmp = dE - dN[start_sfb] */ - IF( LT_16(tmp, 0) ) + IF( LT_16( tmp, 0 ) ) { /* float: dS[start_sfb] = dN[start_sfb] + fFactor * (dE-dN[start_sfb]); basop: */ L_tmp = L_mult( fFactor, tmp ); @@ -1752,7 +1750,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in sfb_p1 = add( start_sfb, 1 ); sfb_m1 = sub( stop_sfb, 1 ); test(); - IF( NE_16(hGrid->infoIsRefined, 0) && EQ_16( hopsize, 1 ) ) + IF( NE_16( hGrid->infoIsRefined, 0 ) && EQ_16( hopsize, 1 ) ) { /* apply filter to absolute energy values: */ FOR( sfb = sfb_p1; sfb < sfb_m1; sfb++ ) @@ -1882,7 +1880,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in /* gain calculation */ gain[sfb] = 0; move16(); - IF( NE_32(pN[sfb], 0) ) + IF( NE_32( pN[sfb], 0 ) ) { tmp = BASOP_Util_Divide3232_Scale( dNlocal, pN[sfb], &s ); s = sub( add( s, dNlocal_e ), pN_e[sfb] ); @@ -1907,7 +1905,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in /*--- check gains /spectrum exponents for possible overflows --- */ /* get tile index */ - IF ( LE_16( hGrid->sfbWrap[tileIdx + 1], sfb ) ) + IF( LE_16( hGrid->sfbWrap[tileIdx + 1], sfb ) ) { tileIdx = add( tileIdx, 1 ); } @@ -1917,7 +1915,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in /*check whether overflow would occur and calculate Headroom, needed*/ shift = sub( L_tmp_e, *spectrum_e ); tmp = sub( shift, sub( norm_l( L_tmp ), TCX_IMDCT_HEADROOM ) ); - IF ( GT_16(tmp, 0) ) + IF( GT_16( tmp, 0 ) ) { Hr = s_max( Hr, tmp ); } @@ -1925,7 +1923,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in /* disable rescaling if gain is smaler than 1 */ /* gain < 1, if norm_s(gain[sfb]) >= gain_e[sfb] */ tmp = sub( norm_s( gain[sfb] ), gain_e[sfb] ); - IF ( GE_16(tmp, 0) ) + IF( GE_16( tmp, 0 ) ) { Hr = 0; move16(); @@ -1935,7 +1933,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in /* Rescale spectrum if overflow may occur */ tileIdx = -1; move16(); - IF( GT_16(Hr, 0) ) + IF( GT_16( Hr, 0 ) ) { /* rescale virtual Spec, cheap and easy: reset scalingfactor */ *virtualSpec_e = add( *virtualSpec_e, Hr ); @@ -1957,7 +1955,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in FOR( sfb = start_sfb; sfb < stop_sfb; sfb++ ) { /* get tile index */ - IF ( EQ_16( hGrid->sfbWrap[tileIdx + 1], sfb ) ) + IF( EQ_16( hGrid->sfbWrap[tileIdx + 1], sfb ) ) { tileIdx = add( tileIdx, 1 ); } @@ -2035,7 +2033,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in { shift = sub( L_tmp_e, *spectrum_e ); tmp = norm_l( L_tmp ) - shift - 32; - IF ( LT_16(tmp, 0) ) + IF( LT_16( tmp, 0 ) ) { L_tmp2 = L_shl( L_tmp, shift ); } @@ -2048,7 +2046,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in { shift = sub( L_tmp_e, *virtualSpec_e ); tmp = norm_l( L_tmp ) - shift - 32; - IF ( LT_16(tmp, 0) ) + IF( LT_16( tmp, 0 ) ) { L_tmp2 = L_shl( L_tmp, shift ); } @@ -2236,12 +2234,12 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in /* select correct hopsize for envelope refinement */ hopsize = 2; move16(); - IF ( EQ_16( hPrivateData->currWhiteningLevel[0], IGF_WHITENING_OFF ) ) + IF( EQ_16( hPrivateData->currWhiteningLevel[0], IGF_WHITENING_OFF ) ) { hopsize = 4; move16(); } - IF ( EQ_16( hPrivateData->currWhiteningLevel[0], IGF_WHITENING_STRONG ) ) + IF( EQ_16( hPrivateData->currWhiteningLevel[0], IGF_WHITENING_STRONG ) ) { hopsize = 1; move16(); @@ -2252,7 +2250,7 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in hopsize = s_min( hopsize, 2 ); } - IF( GT_16(hopsize, 1) ) + IF( GT_16( hopsize, 1 ) ) { FOR( sfb = start_sfb; sfb < stop_sfb; sfb += hopsize ) { @@ -2278,7 +2276,7 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in } /* IGF_rescale_SCF */ - IF( NE_16(hGrid->infoIsRefined, 0) ) + IF( NE_16( hGrid->infoIsRefined, 0 ) ) { FOR( sfb = start_sfb; sfb < stop_sfb; sfb += 2 ) { @@ -2335,7 +2333,7 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in #endif BASOP_SATURATE_WARNING_ON_EVS - IF( LT_32(L_tmp2, 0) ) + IF( LT_32( L_tmp2, 0 ) ) { L_tmp = Mpy_32_16_1( sNlocal, 33 /*0.001f Q15*/ ); L_tmp_e = sNlocal_e; @@ -2402,7 +2400,7 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in 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 ) ); - IF( LT_32(L_tmp2, 0) ) + IF( LT_32( L_tmp2, 0 ) ) { L_tmp = Mpy_32_16_1( sNlocal, 33 /*0.001f Q15*/ ); L_tmp_e = sNlocal_e; @@ -2427,7 +2425,7 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in negate( dN[start_sfb] ), dN_e[start_sfb], &tmp ); /* float: tmp = dE - dN[start_sfb] */ - IF( LT_16(tmp, 0) ) + IF( LT_16( tmp, 0 ) ) { /* float: dS[start_sfb] = dN[start_sfb] + fFactor * (dE-dN[start_sfb]); basop: */ L_tmp = L_mult( fFactor, tmp ); @@ -2448,7 +2446,7 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in sfb_p1 = add( start_sfb, 1 ); sfb_m1 = sub( stop_sfb, 1 ); test(); - IF( NE_16(hGrid->infoIsRefined, 0) && EQ_16( hopsize, 1 ) ) + IF( NE_16( hGrid->infoIsRefined, 0 ) && EQ_16( hopsize, 1 ) ) { /* apply filter to absolute energy values: */ FOR( sfb = sfb_p1; sfb < sfb_m1; sfb++ ) @@ -2606,7 +2604,7 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in FOR( sfb = start_sfb; sfb < stop_sfb; sfb++ ) { /* get tile index */ - IF ( EQ_16( hGrid->sfbWrap[tileIdx + 1], sfb ) ) + IF( EQ_16( hGrid->sfbWrap[tileIdx + 1], sfb ) ) { tileIdx = add( tileIdx, 1 ); } @@ -2770,7 +2768,7 @@ static void IGF_getWhiteSpectralData( const Word32 *in, /**< in ak_norm = Mpy_32_16_r( ak, 2185 ); tmp_16 = sub( 31, norm_l( ak_norm ) ); - IF ( EQ_32(ak, 0) ) + IF( EQ_32( ak, 0 ) ) { tmp_16 = 0; move16(); @@ -2793,7 +2791,7 @@ static void IGF_getWhiteSpectralData( const Word32 *in, /**< in ak_norm = Mpy_32_16_r( ak, nrm_tab[nrm_i++] ); tmp_16 = sub( 31, norm_l( ak_norm ) ); - IF ( EQ_32(ak, 0) ) + IF( EQ_32( ak, 0 ) ) { tmp_16 = 0; move16(); @@ -2802,7 +2800,7 @@ static void IGF_getWhiteSpectralData( const Word32 *in, /**< in tmp_16 = s_min( 14, sub( 15, shr( tmp_16, 1 ) ) ); div = shl( 1, tmp_16 ); - IF ( LT_32( ak, 16 ) ) + IF( LT_32( ak, 16 ) ) { div = 1; move16(); @@ -3050,12 +3048,12 @@ void IGFDecReadData_ivas_fx( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in move16(); } - IF( EQ_16(isIndepFrame, 0) ) + IF( EQ_16( isIndepFrame, 0 ) ) { tmp = get_next_indice( st, 1 ); } - IF( EQ_16(tmp, 1) ) + IF( EQ_16( tmp, 1 ) ) { FOR( p = 0; p < nT; p++ ) { @@ -3077,7 +3075,7 @@ void IGFDecReadData_ivas_fx( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in tmp = get_next_indice( st, 1 ); } - IF( EQ_16(tmp, 1) ) + IF( EQ_16( tmp, 1 ) ) { FOR( p = 1; p < nT; p++ ) { @@ -3135,12 +3133,12 @@ void IGFDecReadData( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | ins move16(); } - IF( EQ_16(isIndepFrame, 0) ) + IF( EQ_16( isIndepFrame, 0 ) ) { tmp = get_next_indice( st, 1 ); } - IF( EQ_16(tmp, 1) ) + IF( EQ_16( tmp, 1 ) ) { FOR( p = 0; p < nT; p++ ) { @@ -3152,7 +3150,7 @@ void IGFDecReadData( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | ins { IGF_decode_whitening_level( st, hPrivateData, 0 ); tmp = get_next_indice( st, 1 ); - IF( EQ_16(tmp, 1) ) + IF( EQ_16( tmp, 1 ) ) { FOR( p = 1; p < nT; p++ ) { @@ -3207,7 +3205,7 @@ void IGFDecReadLevel( /**< ou move16(); IGFAllZero = get_next_indice( st, 1 ); - IF( EQ_16(IGFAllZero, 0) ) + IF( EQ_16( IGFAllZero, 0 ) ) { Copy( hPrivateData->igf_curr, hPrivateData->igf_prev, hGrid->stopSfb ); IGFSCFDecoderDecode( &hPrivateData->hArithSCFdec, st, &hPrivateData->igf_curr[m_igfSfbStart], /* 0Q15, hPrivateData->igf_curr = [0, 91] */ igfGridIdx, isIndepFrame ); @@ -3268,7 +3266,7 @@ void IGFDecApplyMono( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in set16_fx( igf_spec_e, 0, IGF_MAX_TILES ); /* concealment counter */ - IF( NE_16(bfi, 0) ) + IF( NE_16( bfi, 0 ) ) { hPrivateData->frameLossCounter = add( hPrivateData->frameLossCounter, 1 ); } @@ -3279,7 +3277,7 @@ void IGFDecApplyMono( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in } /* skip IGF processing if all IGF levels are zero */ - IF( EQ_16(hInstance->infoIGFAllZero, 0) ) + IF( EQ_16( hInstance->infoIGFAllZero, 0 ) ) { @@ -3436,7 +3434,7 @@ void IGFDecApplyMono_ivas( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in set16_fx( igf_spec_e, 0, IGF_MAX_TILES ); /* concealment counter */ - IF( NE_16(bfi, 0) ) + IF( NE_16( bfi, 0 ) ) { hPrivateData->frameLossCounter = add( hPrivateData->frameLossCounter, 1 ); } @@ -3447,7 +3445,7 @@ void IGFDecApplyMono_ivas( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in } /* skip IGF processing if all IGF levels are zero */ - IF( EQ_16(hInstance->infoIGFAllZero, 0) ) + IF( EQ_16( hInstance->infoIGFAllZero, 0 ) ) { FOR( i = 0; i < hGrid->nTiles; i++ ) { @@ -4273,9 +4271,9 @@ Word16 get_igf_startline( { Word16 igf_startline; - IF( EQ_16(st->igf, 0) ) + IF( EQ_16( st->igf, 0 ) ) { - IF( EQ_16(st->narrowBand, 0) ) + IF( EQ_16( st->narrowBand, 0 ) ) { /* minimum needed for output with sampling rates lower then the nominal sampling rate */ diff --git a/lib_dec/igf_scf_dec_fx.c b/lib_dec/igf_scf_dec_fx.c index a622058d7..cda1bb3b8 100644 --- a/lib_dec/igf_scf_dec_fx.c +++ b/lib_dec/igf_scf_dec_fx.c @@ -27,9 +27,9 @@ void IGFSCFDecoderOpen( { - hPublicData->scfCountLongBlock[0] = sub(hIgfInfo->grid[0].swb_offset_len, 1); - hPublicData->scfCountLongBlock[1] = sub(hIgfInfo->grid[1].swb_offset_len, 1); - hPublicData->scfCountLongBlock[2] = sub(hIgfInfo->grid[2].swb_offset_len, 1); + hPublicData->scfCountLongBlock[0] = sub( hIgfInfo->grid[0].swb_offset_len, 1 ); + hPublicData->scfCountLongBlock[1] = sub( hIgfInfo->grid[1].swb_offset_len, 1 ); + hPublicData->scfCountLongBlock[2] = sub( hIgfInfo->grid[2].swb_offset_len, 1 ); move16(); move16(); move16(); @@ -264,7 +264,7 @@ static void decode_sfe_vector_fx( } } - IF( LT_16(x[f], 0) ) + IF( LT_16( x[f], 0 ) ) { x[f] = 0; move16(); diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index b327a6c0b..ad5c524c1 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -130,7 +130,7 @@ ivas_error init_decoder_fx( *-----------------------------------------------------------------*/ test(); - IF( EQ_16(idchan, 0) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) + IF( EQ_16( idchan, 0 ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) { IF( ( st_fx->hBWE_FD = (FD_BWE_DEC_HANDLE) count_malloc( sizeof( FD_BWE_DEC_DATA ) ) ) == NULL ) { @@ -149,7 +149,7 @@ ivas_error init_decoder_fx( *-----------------------------------------------------------------*/ test(); - IF( ( EQ_16(idchan, 0) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) + IF( ( EQ_16( idchan, 0 ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) { IF( ( st_fx->hIGFDec = (IGF_DEC_INSTANCE_HANDLE) count_malloc( sizeof( IGFDEC_INSTANCE ) ) ) == NULL ) { @@ -209,7 +209,7 @@ ivas_error init_decoder_fx( test(); test(); - IF( ( EQ_16(idchan, 0) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) + IF( ( EQ_16( idchan, 0 ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) { IF( ( st_fx->hGSCDec = (GSC_DEC_HANDLE) count_malloc( sizeof( GSC_DEC_DATA ) ) ) == NULL ) { @@ -354,9 +354,9 @@ ivas_error init_decoder_fx( test(); test(); test(); - IF( EQ_16(idchan, 0) && ( EQ_16( st_fx->element_mode, EVS_MONO ) || EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) ) + IF( EQ_16( idchan, 0 ) && ( EQ_16( st_fx->element_mode, EVS_MONO ) || EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) ) { - IF ( ( st_fx->hTdCngDec = (TD_CNG_DEC_HANDLE) count_malloc( sizeof( TD_CNG_DEC_DATA ) ) ) == NULL ) + IF( ( st_fx->hTdCngDec = (TD_CNG_DEC_HANDLE) count_malloc( sizeof( TD_CNG_DEC_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX/TD CNG\n" ) ); } @@ -428,7 +428,7 @@ ivas_error init_decoder_fx( test(); test(); test(); - IF( ( EQ_16(idchan, 0) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || EQ_16( st_fx->element_mode, IVAS_SCE ) || EQ_16( st_fx->element_mode, EVS_MONO ) ) ) + IF( ( EQ_16( idchan, 0 ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || EQ_16( st_fx->element_mode, IVAS_SCE ) || EQ_16( st_fx->element_mode, EVS_MONO ) ) ) { IF( ( st_fx->hHQ_core = (HQ_DEC_HANDLE) count_malloc( sizeof( HQ_DEC_DATA ) ) ) == NULL ) { @@ -477,7 +477,7 @@ ivas_error init_decoder_fx( *-----------------------------------------------------------------*/ /* TCX-LTP */ - IF( ( EQ_16(idchan,0) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) + IF( ( EQ_16( idchan, 0 ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) { IF( ( st_fx->hTcxLtpDec = (TCX_LTP_DEC_HANDLE) count_malloc( sizeof( TCX_LTP_DEC_DATA ) ) ) == NULL ) { @@ -491,7 +491,7 @@ ivas_error init_decoder_fx( /* TCX core */ // VE: reduction possible for MCT_CHAN_MODE_LFE channel - see I1-172 - IF( EQ_16(idchan, 0) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) + IF( EQ_16( idchan, 0 ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) { IF( ( st_fx->hTcxDec = (TCX_DEC_HANDLE) count_malloc( sizeof( TCX_DEC_DATA ) ) ) == NULL ) { @@ -508,7 +508,7 @@ ivas_error init_decoder_fx( st_fx->hTcxDec = NULL; } /* TCX config. data structure */ - IF( ( EQ_16(idchan, 0) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) + IF( ( EQ_16( idchan, 0 ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) { IF( ( st_fx->hTcxCfg = (TCX_CONFIG_HANDLE) count_malloc( sizeof( TCX_config ) ) ) == NULL ) { @@ -536,9 +536,9 @@ ivas_error init_decoder_fx( *-----------------------------------------------------------------*/ test(); - IF( EQ_16(idchan, 0) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) + IF( EQ_16( idchan, 0 ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) { - IF ( ( st_fx->hBWE_TD = (TD_BWE_DEC_HANDLE) count_malloc( sizeof( TD_BWE_DEC_DATA ) ) ) == NULL ) + IF( ( st_fx->hBWE_TD = (TD_BWE_DEC_HANDLE) count_malloc( sizeof( TD_BWE_DEC_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD BWE\n" ) ); } @@ -645,7 +645,7 @@ ivas_error init_decoder_fx( *-----------------------------------------------------------------*/ test(); test(); - IF( ( EQ_16(idchan, 0) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) + IF( ( EQ_16( idchan, 0 ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) { IF( ( st_fx->hBWE_zero = (ZERO_BWE_DEC_HANDLE) count_malloc( sizeof( ZERO_BWE_DEC_DATA ) ) ) == NULL ) { @@ -672,7 +672,7 @@ ivas_error init_decoder_fx( *-----------------------------------------------------------------*/ test(); test(); - IF( ( EQ_16(idchan, 0) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) + IF( ( EQ_16( idchan, 0 ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) { IF( ( st_fx->hBPF = (BPF_DEC_HANDLE) count_malloc( sizeof( BPF_DEC_DATA ) ) ) == NULL ) { @@ -689,18 +689,18 @@ ivas_error init_decoder_fx( * FD BPF & resampling tools parameters *-----------------------------------------------------------------*/ /* open analysis for max. SR 48kHz */ - IF ( ( error = openCldfb( &st_fx->cldfbAna, CLDFB_ANALYSIS, CLDFB_getNumChannels( 48000 ), 320 ) ) != IVAS_ERR_OK ) + IF( ( error = openCldfb( &st_fx->cldfbAna, CLDFB_ANALYSIS, CLDFB_getNumChannels( 48000 ), 320 ) ) != IVAS_ERR_OK ) { return error; } /* open analysis BPF for max. SR 16kHz */ - IF ( ( error = openCldfb( &st_fx->cldfbBPF, CLDFB_ANALYSIS, CLDFB_getNumChannels( 16000 ), 320 ) ) != IVAS_ERR_OK ) + IF( ( error = openCldfb( &st_fx->cldfbBPF, CLDFB_ANALYSIS, CLDFB_getNumChannels( 16000 ), 320 ) ) != IVAS_ERR_OK ) { return error; } /* open synthesis for output SR */ - IF ( ( error = openCldfb( &st_fx->cldfbSyn, CLDFB_SYNTHESIS, CLDFB_getNumChannels( st_fx->output_Fs ), st_fx->output_frame_fx ) ) != IVAS_ERR_OK ) + IF( ( error = openCldfb( &st_fx->cldfbSyn, CLDFB_SYNTHESIS, CLDFB_getNumChannels( st_fx->output_Fs ), st_fx->output_frame_fx ) ) != IVAS_ERR_OK ) { return error; } @@ -788,12 +788,12 @@ ivas_error init_decoder_fx( #ifdef IVAS_CODE IF( ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || idchan == 0 ) && NE_16( mc_mode, MC_MODE_MCT ) && NE_16( mc_mode, MC_MODE_PARAMUPMIX ) ) // TBV Fixed point missing #else - IF( ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || EQ_16(idchan, 0) ) /*&& mc_mode != MC_MODE_MCT && mc_mode != MC_MODE_PARAMUPMIX*/ ) + IF( ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || EQ_16( idchan, 0 ) ) /*&& mc_mode != MC_MODE_MCT && mc_mode != MC_MODE_PARAMUPMIX*/ ) #endif { /* Create FD_CNG instance */ - IF ( ( error = createFdCngDec_fx( &st_fx->hFdCngDec ) ) != IVAS_ERR_OK ) + IF( ( error = createFdCngDec_fx( &st_fx->hFdCngDec ) ) != IVAS_ERR_OK ) { return error; } @@ -839,22 +839,22 @@ ivas_error init_decoder_fx( /*----------------------------------------------------------------------------------* * Stereo/IVAS parameters *----------------------------------------------------------------------------------*/ -#if 1 // IVAS_CODE -> To be verified - st_fx->tdm_LRTD_flag = 0; /* LRTD stereo mode flag */ +#if 1 // IVAS_CODE -> To be verified + st_fx->tdm_LRTD_flag = 0; /* LRTD stereo mode flag */ move16(); - st_fx->cna_dirac_flag = 0; /* CNA in DirAC flag */ + st_fx->cna_dirac_flag = 0; /* CNA in DirAC flag */ move16(); - st_fx->cng_sba_flag = 0; /* CNG in SBA flag */ + st_fx->cng_sba_flag = 0; /* CNG in SBA flag */ move16(); - st_fx->element_mode = EVS_MONO; /* element mode */ + st_fx->element_mode = EVS_MONO; /* element mode */ move16(); st_fx->last_element_mode = st_fx->element_mode; /* element mode */ move16(); - st_fx->element_brate = -1; /* element bitrate */ + st_fx->element_brate = -1; /* element bitrate */ move16(); - st_fx->low_rate_mode = 0; /* low-rate mode flag */ + st_fx->low_rate_mode = 0; /* low-rate mode flag */ move16(); - st_fx->last_low_rate_mode = 0; /* low-rate mode flag */ + st_fx->last_low_rate_mode = 0; /* low-rate mode flag */ move16(); // st_fx->cng_ism_flag = 0; // st_fx->coder_type = GENERIC; /* low-rate mode flag */ @@ -863,7 +863,7 @@ ivas_error init_decoder_fx( #ifdef DEBUGGING st_fx->id_element = -1; /* element ID */ #endif - st_fx->extl_orig = -1; /* extension layer */ + st_fx->extl_orig = -1; /* extension layer */ move16(); st_fx->extl_brate_orig = 0; /* extension layer bitrate */ move16(); @@ -1126,7 +1126,7 @@ ivas_error init_decoder_ivas_fx( /*-----------------------------------------------------------------* * parameters for fast recovery (WI) *-----------------------------------------------------------------*/ - + test(); IF( EQ_32( st_fx->output_Fs, 16000 ) && EQ_16( st_fx->element_mode, EVS_MONO ) ) { @@ -1167,7 +1167,7 @@ ivas_error init_decoder_ivas_fx( /*-----------------------------------------------------------------* * HF (6-7kHz) (zero) BWE parameters *-----------------------------------------------------------------*/ - + test(); test(); IF( ( EQ_16( idchan, 0 ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) @@ -1228,7 +1228,7 @@ ivas_error init_decoder_ivas_fx( test(); IF( EQ_16( idchan, 0 ) && ( EQ_16( st_fx->element_mode, EVS_MONO ) || EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) ) { - IF ( ( st_fx->hTdCngDec = (TD_CNG_DEC_HANDLE) count_malloc( sizeof( TD_CNG_DEC_DATA ) ) ) == NULL ) + IF( ( st_fx->hTdCngDec = (TD_CNG_DEC_HANDLE) count_malloc( sizeof( TD_CNG_DEC_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX/TD CNG\n" ) ); } @@ -1304,7 +1304,7 @@ ivas_error init_decoder_ivas_fx( test(); IF( EQ_16( idchan, 0 ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) { - IF ( ( st_fx->hBWE_TD = (TD_BWE_DEC_HANDLE) malloc( sizeof( TD_BWE_DEC_DATA ) ) ) == NULL ) + IF( ( st_fx->hBWE_TD = (TD_BWE_DEC_HANDLE) malloc( sizeof( TD_BWE_DEC_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD BWE\n" ) ); } @@ -1446,7 +1446,7 @@ ivas_error init_decoder_ivas_fx( st_fx->bpf_off = 0; move16(); - test(); + test(); test(); IF( ( EQ_16( idchan, 0 ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) { @@ -1628,7 +1628,7 @@ ivas_error init_decoder_ivas_fx( /*-----------------------------------------------------------------* * IGF *-----------------------------------------------------------------*/ - + test(); IF( ( EQ_16( idchan, 0 ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) { diff --git a/lib_dec/inov_dec_fx.c b/lib_dec/inov_dec_fx.c index 0024e7464..9531a05be 100644 --- a/lib_dec/inov_dec_fx.c +++ b/lib_dec/inov_dec_fx.c @@ -74,7 +74,7 @@ void inov_decode_fx( IF( !Opt_AMR_WB ) { - IF ( st_fx->acelp_cfg.fcb_mode ) + IF( st_fx->acelp_cfg.fcb_mode ) { Word16 i; Word16 indexing_indices[8], wordcnt, bitcnt; @@ -120,7 +120,7 @@ void inov_decode_fx( bitcnt = ACELP_FIXED_CDK_BITS( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] ) & 15; move16(); // PMT("CONDITION above is missing -> idchan") - FOR ( i = 0; i < wordcnt; i++ ) + FOR( i = 0; i < wordcnt; i++ ) { indexing_indices[i] = get_next_indice( st_fx, 16 ); } diff --git a/lib_dec/ivas_dirac_output_synthesis_cov.c b/lib_dec/ivas_dirac_output_synthesis_cov.c index 70a8a0e2e..11535dded 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov.c @@ -1834,8 +1834,8 @@ Word16 computeMixingMatrices_fx( mat_mult_buffer2_e = 0; matrix_product_mant_exp_fx( mat_mult_buffer1_fx, mat_mult_buffer1_e, lengthCy, lengthCx, 0, - mat_mult_buffer2_fx, mat_mult_buffer2_e, lengthCx, lengthCx, 1, - mat_mult_buffer3_fx, &mat_mult_buffer3_e ); + mat_mult_buffer2_fx, mat_mult_buffer2_e, lengthCx, lengthCx, 1, + mat_mult_buffer3_fx, &mat_mult_buffer3_e ); /************************ Formulate M **********************/ @@ -1850,9 +1850,9 @@ Word16 computeMixingMatrices_fx( /* Compute Cy_tilde = M*Cx*M' */ - matrix_product_mant_exp_fx( mixing_matrix_fx, mixing_matrix_e, lengthCy, lengthCx, 0, Cx_fx, Cx_fx_e, lengthCx, lengthCx, 0, mat_mult_buffer1_fx, &mat_mult_buffer1_e); + matrix_product_mant_exp_fx( mixing_matrix_fx, mixing_matrix_e, lengthCy, lengthCx, 0, Cx_fx, Cx_fx_e, lengthCx, lengthCx, 0, mat_mult_buffer1_fx, &mat_mult_buffer1_e ); - matrix_product_mant_exp_fx( mat_mult_buffer1_fx, mat_mult_buffer1_e, lengthCy, lengthCx, 0, mixing_matrix_fx, mixing_matrix_e, lengthCy, lengthCx, 1, mat_mult_buffer2_fx, &mat_mult_buffer2_e); + matrix_product_mant_exp_fx( mat_mult_buffer1_fx, mat_mult_buffer1_e, lengthCy, lengthCx, 0, mixing_matrix_fx, mixing_matrix_e, lengthCy, lengthCx, 1, mat_mult_buffer2_fx, &mat_mult_buffer2_e ); Cr_p_fx = Cr_fx; Cy_p_fx = Cy_fx; @@ -2457,14 +2457,14 @@ Word16 computeMixingMatricesResidual_fx( move16(); matrix_product_mant_exp_fx( mat_mult_buffer1_fx, mat_mult_buffer1_e, lengthCy, lengthCx, 0, - mat_mult_buffer2_fx, mat_mult_buffer2_e, lengthCx, lengthCx, 1, - mat_mult_buffer3_fx, &mat_mult_buffer3_e); + mat_mult_buffer2_fx, mat_mult_buffer2_e, lengthCx, lengthCx, 1, + mat_mult_buffer3_fx, &mat_mult_buffer3_e ); /*-----------------------------------------------------------------* * Formulate M *-----------------------------------------------------------------*/ - matrix_product_mant_exp_fx( Ky_fx, Ky_fx_e[0], lengthCy, lengthCy, 0, mat_mult_buffer3_fx, mat_mult_buffer3_e, lengthCy, lengthCx, 0, mat_mult_buffer1_fx, &mat_mult_buffer1_e); + matrix_product_mant_exp_fx( Ky_fx, Ky_fx_e[0], lengthCy, lengthCy, 0, mat_mult_buffer3_fx, mat_mult_buffer3_e, lengthCy, lengthCx, 0, mat_mult_buffer1_fx, &mat_mult_buffer1_e ); FOR( i = 0; i < num_outputs; i++ ) { diff --git a/lib_dec/updt_dec_fx.c b/lib_dec/updt_dec_fx.c index 8b817242f..fb846b91a 100644 --- a/lib_dec/updt_dec_fx.c +++ b/lib_dec/updt_dec_fx.c @@ -984,11 +984,9 @@ void ivas_updt_dec_common_fx( } #endif #ifdef NON_BE_1055_RESET_LP_MEMORIES - IF( (LE_32(st_fx->core_brate , SID_2k40) && EQ_16(st_fx->cng_type , FD_CNG) ) || (st_fx->tcxonly && (EQ_16(st_fx->codec_mode , MODE2) || GT_16(st_fx->element_mode , EVS_MONO)) ) ) + IF( ( LE_32( st_fx->core_brate, SID_2k40 ) && EQ_16( st_fx->cng_type, FD_CNG ) ) || ( st_fx->tcxonly && ( EQ_16( st_fx->codec_mode, MODE2 ) || GT_16( st_fx->element_mode, EVS_MONO ) ) ) ) #else - IF( ((LE_32(st_fx->core_brate,SID_2k40))&&EQ_16(st_fx->cng_type,FD_CNG)) - || (st_fx->tcxonly && EQ_16(st_fx->codec_mode,MODE2)) - ) + IF( ( ( LE_32( st_fx->core_brate, SID_2k40 ) ) && EQ_16( st_fx->cng_type, FD_CNG ) ) || ( st_fx->tcxonly && EQ_16( st_fx->codec_mode, MODE2 ) ) ) #endif { -- GitLab From 4f3fdb501323add4b99d1aa03776329323cdecb0 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 12 Jun 2024 13:37:02 +0530 Subject: [PATCH 3/3] EVS BE issue fixed --- lib_dec/er_dec_acelp_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/er_dec_acelp_fx.c b/lib_dec/er_dec_acelp_fx.c index 100a6b207..11ada1141 100644 --- a/lib_dec/er_dec_acelp_fx.c +++ b/lib_dec/er_dec_acelp_fx.c @@ -1067,7 +1067,7 @@ void con_acelp_fx( /* save last half frame if next frame is TCX */ bufferCopyFx( syn + st->L_frame, hTcxDec->syn_Overl_TDAC, shr( st->L_frame, 1 ), 0 /*Qf_syn*/, -1 /*Qf_old_xnq*/, 0, 0 /*Q_old_xnq*/ ); - Copy( syn + sub( st->L_frame, sub( M, 1 ) ), st->syn, add( 1, M ) ); + Copy( syn + sub( st->L_frame, add( M, 1 ) ), st->syn, add( 1, M ) ); /* update old_Aq */ Copy( p_A - add( M, 1 ), st->old_Aq_12_8_fx, add( M, 1 ) ); @@ -1097,7 +1097,7 @@ void con_acelp_fx( } FOR( ; i < W1; i++ ) { - hHQ_core->old_out_LB_fx[add( i, n )] = round_fx( Mpy_32_16_1( L_mult( w[sub( W2, sub( 1, sub( i, W2 ) ) )].v.im, w[sub( W2, sub( 1, sub( i, W2 ) ) )].v.im ), hHQ_core->old_out_LB_fx[add( i, n )] ) ); + hHQ_core->old_out_LB_fx[i + n] = round_fx( Mpy_32_16_1( L_mult( w[sub( W2, add( 1, sub( i, W2 ) ) )].v.im, w[sub( W2, add( 1, sub( i, W2 ) ) )].v.im ), hHQ_core->old_out_LB_fx[add( i, n )] ) ); move16(); } set16_fx( &hHQ_core->old_out_LB_fx[add( W1, n )], 0, n ); -- GitLab