From e09be01426a6194851007a13a4d610e6a7968f6c Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 21 Jun 2024 13:52:53 +0530 Subject: [PATCH 1/3] BASOP additions and instrumention code additions --- lib_com/cnst.h | 2 + lib_dec/FEC_adapt_codebook_fx.c | 31 +-- lib_dec/FEC_clas_estim_fx.c | 33 ++-- lib_dec/FEC_fx.c | 39 ++-- lib_dec/er_dec_acelp_fx.c | 64 +++--- lib_dec/er_dec_tcx_fx.c | 62 +++--- lib_dec/er_scale_syn_fx.c | 7 +- lib_dec/er_sync_exc_fx.c | 24 +-- lib_dec/er_util_fx.c | 50 ++--- lib_dec/evs_dec_fx.c | 128 +++++++----- lib_dec/fd_cng_dec.c | 336 +++++++++++++++----------------- lib_dec/fd_cng_dec_fx.c | 290 +++++++++++++++++++-------- lib_dec/ivas_lfe_dec_fx.c | 41 ++-- lib_dec/ivas_lfe_plc_fx.c | 17 +- lib_dec/ivas_ls_custom_dec.c | 14 +- lib_dec/ivas_masa_dec.c | 258 ++++++++++++++---------- lib_dec/ivas_mcmasa_dec.c | 8 +- lib_dec/ivas_mct_core_dec.c | 109 ++++++++--- 18 files changed, 907 insertions(+), 606 deletions(-) diff --git a/lib_com/cnst.h b/lib_com/cnst.h index 7dde79cee..a77a8d8e0 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -1818,7 +1818,9 @@ typedef enum _DCTTYPE #define CNA_INIT_NBANDS 6 #define GAIN_Q_OFFSET_EVS 60.f +#define GAIN_Q_OFFSET_EVS_FX_Q0 60 #define GAIN_Q_OFFSET_IVAS 45.f +#define GAIN_Q_OFFSET_IVAS_FX_Q0 45 /*----------------------------------------------------------------------------------* * Bass post-filter constants diff --git a/lib_dec/FEC_adapt_codebook_fx.c b/lib_dec/FEC_adapt_codebook_fx.c index 6a8a23518..63c5559c0 100644 --- a/lib_dec/FEC_adapt_codebook_fx.c +++ b/lib_dec/FEC_adapt_codebook_fx.c @@ -64,7 +64,7 @@ Word16 FEC_SinOnset_fx( P0 = PIT_MAX; move16(); /* Should never be the case, however... */ } - ELSE if ( GT_16( P0, PIT16k_MAX ) && EQ_16( L_frame, L_FRAME16k ) ) + ELSE IF( GT_16( P0, PIT16k_MAX ) && EQ_16( L_frame, L_FRAME16k ) ) { P0 = PIT16k_MAX; move16(); /* Should never be the case, however... */ @@ -134,13 +134,11 @@ Word16 FEC_SinOnset_fx( { L_tmp = L_mult( gain, H_low[i] ); /* Q_exc*Q15 -> Q_exc */ H_low_s[i] = round_fx( L_shl( L_tmp, exp2 ) ); + move16(); } /*------------------------------------------------------------------------------------------* * Construct the harmonic part as a train of low-pass filtered pulses *------------------------------------------------------------------------------------------*/ - move16(); - move16(); - move16(); pt_exc = exc_tmp + sub( L_frame, add( add( 1, MODE1_L_FIR_FER / 2 ), P0 ) ); /* beginning of the 1st pulse */ pt_end = exc_tmp + onset_len; len = (Word16) ( pt_exc - pt_end ); @@ -165,7 +163,7 @@ Word16 FEC_SinOnset_fx( move16(); } } - Copy( &exc_tmp[L_frame - L_EXC_MEM], exc, L_EXC_MEM ); + Copy( &exc_tmp[sub( L_frame, L_EXC_MEM )], exc, L_EXC_MEM ); return Q_exc; } @@ -191,7 +189,7 @@ Word16 FEC_enhACB_fx( Copy( exc_io, exc + L_FRAME16k - L_EXC_MEM, L_EXC_MEM ); Tc = shr( bfi_pitch, 6 ); - Copy( exc + L_FRAME16k - Tc, exc + L_FRAME16k, L_SUBFR ); + Copy( exc + sub( L_FRAME16k, Tc ), exc + L_FRAME16k, L_SUBFR ); /*------------------------------------------------------------ * Decode phase information transmitted in the bitstream @@ -229,6 +227,7 @@ Word16 FEC_enhACB_fx( move16(); Tlist[0] = findpulse_fx( L_frame, exc + sub( L_frame, pit_search ), pit_search, DEC, &sign ); + move16(); /*Terr = (short) abs(pit_search-Tlist[0]-P0);*/ Terr = abs_s( sub( pit_search, add( Tlist[0], P0 ) ) ); @@ -236,6 +235,7 @@ Word16 FEC_enhACB_fx( dist_Plast = sub( Tc, Tlist[0] ); Tlist[1] = findpulse_fx( L_frame, exc + sub( L_frame, pit_search ), add( pit_search, L_SUBFR ), DEC, &sign ); + move16(); /*if(Terr > abs(Tlist[1]-Tc + P0))*/ @@ -256,7 +256,6 @@ Word16 FEC_enhACB_fx( { /* performe excitation resynchronization here */ Do_WI = FEC_synchro_exc_fx( L_frame, exc, P0, dist_Plast, Tc ); - move16(); Copy( exc + L_FRAME16k - L_EXC_MEM, exc_io, L_EXC_MEM ); } ELSE @@ -350,15 +349,16 @@ Word16 FEC_synchro_exc_fx( /* o : do_WI flag * --------------------------------------------------------------------*/ L_min_energy = L_add( MAX_32, 0 ); L_tmp = L_mult( pt_exc[start_search], pt_exc[start_search] ); - L_tmp = L_mac( L_tmp, pt_exc[start_search + 1], pt_exc[start_search + 1] ); - L_tmp = L_mac( L_tmp, pt_exc[start_search + 2], pt_exc[start_search + 2] ); - L_tmp = L_mac( L_tmp, pt_exc[start_search + 3], pt_exc[start_search + 3] ); - L_tmp = L_mac( L_tmp, pt_exc[start_search + 4], pt_exc[start_search + 4] ); + L_tmp = L_mac( L_tmp, pt_exc[add( start_search, 1 )], pt_exc[add( start_search, 1 )] ); + L_tmp = L_mac( L_tmp, pt_exc[add( start_search, 2 )], pt_exc[add( start_search, 2 )] ); + L_tmp = L_mac( L_tmp, pt_exc[add( start_search, 3 )], pt_exc[add( start_search, 3 )] ); + L_tmp = L_mac( L_tmp, pt_exc[add( start_search, 4 )], pt_exc[add( start_search, 4 )] ); IF( LT_32( L_tmp, L_min_energy ) ) { L_min_energy = L_add( L_tmp, 0 ); min_pos[0] = add( add( pos, start_search ), 2 ); + move16(); } FOR( i = start_search; i < -5; i++ ) @@ -371,6 +371,7 @@ Word16 FEC_synchro_exc_fx( /* o : do_WI flag L_min_energy = L_tmp; /* sets to 'L_tmp' in 1 clock */ move32(); min_pos[0] = add( add( pos, i ), 2 ); + move16(); } } @@ -407,13 +408,15 @@ Word16 FEC_synchro_exc_fx( /* o : do_WI flag nb_min = 1; move16(); points_by_pos[0] = abs_s( point_to_remove ); + move16(); } ELSE { /* First position */ /* fact = (float)fabs(point_to_remove) / sqi[nb_min-2]; (nb_min*nb_min) */ - fact = mult_r( shl( abs_s( point_to_remove ), 7 ), inv_sqi[nb_min - 2] ); /*Q7 */ - points_by_pos[0] = mult_r( fact, 256 ); /*Q7 */ + fact = mult_r( shl( abs_s( point_to_remove ), 7 ), inv_sqi[sub( nb_min, 2 )] ); /*Q7 */ + points_by_pos[0] = mult_r( fact, 256 ); /*Q7 */ + move16(); total_point = points_by_pos[0]; move16(); @@ -475,9 +478,7 @@ Word16 FEC_synchro_exc_fx( /* o : do_WI flag Copy( pt_exc1, pt_exc, tmp_len ); remaining_len = sub( remaining_len, tmp_len ); pt_exc1 += tmp_len; - move16(); pt_exc += tmp_len; - move16(); /* Find point to add and Add points */ tmp16 = mult_r( *pt_exc1, -1638 ); diff --git a/lib_dec/FEC_clas_estim_fx.c b/lib_dec/FEC_clas_estim_fx.c index aef047af1..9591807b7 100644 --- a/lib_dec/FEC_clas_estim_fx.c +++ b/lib_dec/FEC_clas_estim_fx.c @@ -110,9 +110,13 @@ void FEC_clas_estim_fx( move16(); codec_mode = st_fx->codec_mode; - tcxonly = st_fx->tcxonly; /* i : tcxonly flag */ /*B*/ - narrowBand = st_fx->narrowBand; /* i : narrowband flag */ /*B*/ + move16(); + tcxonly = st_fx->tcxonly; /* i : tcxonly flag */ /*B*/ + move16(); + narrowBand = st_fx->narrowBand; /* i : narrowband flag */ /*B*/ + move16(); preemph_fac = st_fx->preemph_fac; /* i : preemphasis factor */ /*B*/ + move16(); /*------------------------------------------------------------------------* * Copy synthesized into local buffer *------------------------------------------------------------------------*/ @@ -129,13 +133,14 @@ void FEC_clas_estim_fx( test(); test(); test(); + test(); IF( ( EQ_32( last_core_brate, SID_1k75 ) || EQ_32( last_core_brate, ACELP_6k60 ) || EQ_32( last_core_brate, ACELP_8k85 ) || EQ_32( last_core_brate, ACELP_12k65 ) || EQ_32( last_core_brate, ACELP_14k25 ) || EQ_32( last_core_brate, ACELP_15k85 ) || EQ_32( last_core_brate, ACELP_18k25 ) || EQ_32( last_core_brate, ACELP_19k85 ) || EQ_32( last_core_brate, ACELP_23k05 ) || EQ_32( last_core_brate, ACELP_23k85 ) ) && !Opt_AMR_WB && EQ_16( codec_mode, MODE2 ) && GT_16( L_frame, L_FRAME ) ) { Word16 oldLenClasBuff, newLenClasBuff; oldLenClasBuff = extract_l( L_shr( Mpy_32_16_1( L_mult0( st_fx->last_L_frame, getInvFrameLen( st_fx->L_frame ) /*Q21*/ ) /*Q21*/, L_SYN_MEM_CLAS_ESTIM /*Q0*/ ) /*Q6*/, 6 ) /*Q0*/ ); newLenClasBuff = L_SYN_MEM_CLAS_ESTIM; move16(); - lerp( &mem_syn_clas_estim[L_SYN_MEM_CLAS_ESTIM - oldLenClasBuff], &mem_syn_clas_estim[L_SYN_MEM_CLAS_ESTIM - newLenClasBuff], newLenClasBuff, oldLenClasBuff ); + lerp( &mem_syn_clas_estim[sub( L_SYN_MEM_CLAS_ESTIM, oldLenClasBuff )], &mem_syn_clas_estim[sub( L_SYN_MEM_CLAS_ESTIM, newLenClasBuff )], newLenClasBuff, oldLenClasBuff ); } synth = old_synth + L_SYN_MEM_CLAS_ESTIM; @@ -280,7 +285,7 @@ void FEC_clas_estim_fx( pos = sub( L_frame, T0 ); /* T0 [34 231] */ - Corre( &pt1[pos], &pt1[pos - T0], T0, &cor_max[0] ); + Corre( &pt1[pos], &pt1[sub( pos, T0 )], T0, &cor_max[0] ); #ifdef BASOP_NOGLOB T0 = mult_r_sat( add_sat( pitch[2], pitch[3] ), 256 ); #else @@ -294,14 +299,14 @@ void FEC_clas_estim_fx( j = 16384; move16(); pos = sub( pos, T0 ); /* T0 [34 231] */ - Corre( &pt1[pos], &pt1[pos - T0], T0, &cor_max[1] ); + Corre( &pt1[pos], &pt1[sub( pos, T0 )], T0, &cor_max[1] ); Ltmp = L_add( Ltmp, cor_max[1] ); IF( GT_16( pos, pos_limit ) ) { j = 10923; move16(); pos = sub( pos, T0 ); /* T0 [34 231] */ - Corre( &pt1[pos], &pt1[pos - T0], T0, &cor_max[2] ); + Corre( &pt1[pos], &pt1[sub( pos, T0 )], T0, &cor_max[2] ); Ltmp = L_add( Ltmp, cor_max[2] ); } IF( GT_16( pos, pos_limit ) ) @@ -309,7 +314,7 @@ void FEC_clas_estim_fx( j = 8192; move16(); pos = sub( pos, T0 ); /* T0 [34 231] */ - Corre( &pt1[pos], &pt1[pos - T0], T0, &cor_max[3] ); + Corre( &pt1[pos], &pt1[sub( pos, T0 )], T0, &cor_max[3] ); Ltmp = L_add( Ltmp, cor_max[3] ); } } @@ -473,6 +478,8 @@ void FEC_clas_estim_fx( case ONSET: case SIN_ONSET: case VOICED_TRANSITION: + test(); + test(); IF( LT_16( fmerit1, 12780 /*0.39f Q15*/ ) ) { result = UNVOICED_CLAS; @@ -543,7 +550,7 @@ void FEC_clas_estim_fx( *decision_hyst = 200; move16(); } - ELSE if ( *decision_hyst < 0 ) + ELSE IF( *decision_hyst < 0 ) { *decision_hyst = 0; move16(); @@ -783,7 +790,7 @@ static Word16 FEC_dec_class_fx( IF( NE_16( st_fx->coder_type, VOICED ) ) { /* decode the class */ - tmpS = (Word16) get_next_indice( st_fx, FEC_BITS_CLS ); + tmpS = (Word16) get_next_indice_fx( st_fx, FEC_BITS_CLS ); IF( tmpS == 0 ) { @@ -820,7 +827,7 @@ static Word16 FEC_dec_class_fx( test(); IF( GT_16( st_fx->acelp_cfg.FEC_mode, 1 ) ) { - tmpS = (Word16) get_next_indice( st_fx, FEC_BITS_ENR ); + tmpS = (Word16) get_next_indice_fx( st_fx, FEC_BITS_ENR ); /* convert from logarithmic to linear domain (the range is 0 : 3.0 : 96 dB) */ tmpS = mult_r( shl( tmpS, 10 ), 24576 ); /* Q10*Q13->Q8 */ L_tmp = L_mult( tmpS, 10885 ); /* 0.332192 in Q15 */ @@ -867,7 +874,9 @@ Word16 FEC_pos_dec_fx( IF( EQ_16( st_fx->coder_type, GENERIC ) && GT_16( st_fx->acelp_cfg.FEC_mode, 2 ) ) { nBits = st_fx->acelp_cfg.pitch_bits[0]; /* The first pitch index is located right after the actual position + the last pulse position index + predicted innovation energy index */ - bit_pos_pitch_index = st_fx->next_bit_pos + FEC_BITS_POS + nBits_es_Pred; + bit_pos_pitch_index = add( add( st_fx->next_bit_pos, FEC_BITS_POS ), nBits_es_Pred ); + test(); + test(); IF( GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && LE_32( st_fx->core_brate, MAX_BRATE_AVQ_EXC_TD ) && EQ_16( st_fx->coder_type, GENERIC ) ) { /* Harmonic flag is present */ @@ -884,7 +893,7 @@ Word16 FEC_pos_dec_fx( pit16k_Q_dec_fx( pitch_index, 10, 1, &T0, &T0_frac, &T0_min, &T0_max, &st_fx->BER_detect ); /* decode last pulse position */ - *last_pulse_pos = (Word16) get_next_indice( st_fx, FEC_BITS_POS ); + *last_pulse_pos = (Word16) get_next_indice_fx( st_fx, FEC_BITS_POS ); /* respect the sign */ IF( GE_16( *last_pulse_pos, 128 ) ) diff --git a/lib_dec/FEC_fx.c b/lib_dec/FEC_fx.c index 225e2c638..a029f1dfd 100644 --- a/lib_dec/FEC_fx.c +++ b/lib_dec/FEC_fx.c @@ -99,6 +99,7 @@ void FEC_exc_estim_fx( GSC_DEC_HANDLE hGSCDec; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move16(); #endif hGSCDec = st_fx->hGSCDec; @@ -107,6 +108,7 @@ void FEC_exc_estim_fx( /* nb_subfr = L_frame/L_SUBFR */ nb_subfr = shr( L_frame, 6 ); Diff_len = 0; /* to avoid compilation flags */ + move16(); set16_fx( exc_dct_in, 0, L_FRAME16k ); extrapolationFailed = 1; @@ -148,7 +150,9 @@ void FEC_exc_estim_fx( tmp_old_pitch = &st_fx->old_pitch_buf_fx[2 * NB_SUBFR16k - 1]; tmp_pitmin = PIT16k_MIN_EXTEND; + move16(); tmp_pitmax = PIT16k_MAX; + move16(); IF( EQ_16( L_frame, L_FRAME ) ) { tmp_old_pitch = &st_fx->old_pitch_buf_fx[2 * NB_SUBFR - 1]; @@ -278,7 +282,7 @@ void FEC_exc_estim_fx( test(); test(); test(); - IF( st_fx->last_coder_type == UNVOICED && LE_16( st_fx->nbLostCmpt, 3 ) ) + IF( EQ_16( st_fx->last_coder_type, UNVOICED ) && LE_16( st_fx->nbLostCmpt, 3 ) ) { /* last good frame was clearly unvoiced */ alpha = _ALPHA_UU_FX; @@ -412,7 +416,7 @@ void FEC_exc_estim_fx( /* last pitch cycle of the previous frame is repeatedly copied up to an extra subframe */ - tmp = (Word16) ( ( exc + L_frame + L_SUBFR ) - pt_exc ); + tmp = extract_l( ( exc + add( L_frame, L_SUBFR ) ) - pt_exc ); FOR( i = 0; i < tmp; i++ ) { *pt_exc++ = *pt1_exc++; @@ -430,8 +434,8 @@ void FEC_exc_estim_fx( test(); IF( ( cond1 < 0 ) && ( new_pit > 0 ) && ( cond2 != 0 ) && ( cond3 > 0 ) && extrapolationFailed == 0 ) { - Copy( exc, exc - L_frame - L_SUBFR, L_frame + L_SUBFR ); - PulseResynchronization_fx( exc - L_frame - L_SUBFR, exc, L_frame, nb_subfr, L_deposit_h( Tc /*Q0*/ ) /*15Q16*/, L_deposit_h( new_pit /*Q0*/ ) /*15Q16*/ ); + Copy( exc, exc - add( L_frame, L_SUBFR ), add( L_frame, L_SUBFR ) ); + PulseResynchronization_fx( exc - add( L_frame, L_SUBFR ), exc, L_frame, nb_subfr, L_deposit_h( Tc /*Q0*/ ) /*15Q16*/, L_deposit_h( new_pit /*Q0*/ ) /*15Q16*/ ); } } test(); @@ -457,7 +461,8 @@ void FEC_exc_estim_fx( /* end of the frame gain */ test(); - + test(); + test(); IF( !( GE_16( st_fx->last_good, VOICED_CLAS ) && LT_16( st_fx->last_good, INACTIVE_CLAS ) && NE_16( st_fx->last_coder_type, AUDIO ) && GT_16( st_fx->nbLostCmpt, 1 ) ) ) { st_fx->lp_gainp_fx = shr( alpha, 1 ); /* alpha in Q15 */ @@ -504,13 +509,13 @@ void FEC_exc_estim_fx( move16(); /*ptr init*/ FOR( i = 0; i < Len; i++ ) { - exc_dct_in[i + Diff_len] = mult_r( exc_dct_in[i + Diff_len], sm_table_fx[i] ); + exc_dct_in[add( i, Diff_len )] = mult_r( exc_dct_in[add( i, Diff_len )], sm_table_fx[i] ); move16(); } FOR( ; i < max_len; i++ ) { - exc_dct_in[i + Diff_len] = 0; + exc_dct_in[add( i, Diff_len )] = 0; move16(); } Diff_len = add( Diff_len, 1 ); @@ -527,14 +532,16 @@ void FEC_exc_estim_fx( { st_fx->GSC_noisy_speech = st_fx->Last_GSC_noisy_speech_flag; move16(); + /* st_fx->L_frame / L_SUBFR */ + tmp = shr( st_fx->L_frame, 6 ); /* Replication of the last spectrum, with a slight downscaling of its dynamic */ - if ( st_fx->element_mode == EVS_MONO ) + IF( st_fx->element_mode == EVS_MONO ) { - gsc_dec_fx( st_fx, exc_dct_in, hGSCDec->Last_GSC_pit_band_idx, Diff_len, 0, st_fx->L_frame / L_SUBFR, st_fx->last_coder_type, &last_bin_fx, lsf_new, NULL, st_fx->Q_exc ); + gsc_dec_fx( st_fx, exc_dct_in, hGSCDec->Last_GSC_pit_band_idx, Diff_len, 0, tmp, st_fx->last_coder_type, &last_bin_fx, lsf_new, NULL, st_fx->Q_exc ); } - else + ELSE { - gsc_dec_ivas_fx( st_fx, exc_dct_in, hGSCDec->Last_GSC_pit_band_idx, Diff_len, 0, st_fx->L_frame / L_SUBFR, st_fx->last_coder_type, &last_bin_fx, lsf_new, NULL, st_fx->Q_exc ); + gsc_dec_ivas_fx( st_fx, exc_dct_in, hGSCDec->Last_GSC_pit_band_idx, Diff_len, 0, tmp, st_fx->last_coder_type, &last_bin_fx, lsf_new, NULL, st_fx->Q_exc ); } *tmp_noise = shr_r( st_fx->lp_gainc_fx, 3 ); /*Q0*/ /* Transform back to time domain */ @@ -653,6 +660,7 @@ void FEC_exc_estim_fx( #else *pt_exc++ = round_fx( L_shl( L_tmp, exp ) ); #endif + move16(); } FOR( i = 0; i < L_frame; i++ ) @@ -665,6 +673,7 @@ void FEC_exc_estim_fx( #else *pt_exc++ = round_fx( L_shl( L_tmp, exp ) ); #endif + move16(); /* gain -= step; */ L_tmp2 = L_sub( L_tmp2, L_step ); tmp = round_fx( L_tmp2 ); @@ -679,6 +688,7 @@ void FEC_exc_estim_fx( #else *pt_exc++ = round_fx( L_shl( L_tmp, exp ) ); #endif + move16(); } } @@ -699,7 +709,6 @@ void FEC_exc_estim_fx( /* For voiced and generic signals - prepare a HP filter for the random part of excitation */ /* tmp = -(1-tilt_code) to correctly represent 1.0000 */ tmp = add( st_fx->tilt_code_fx, -32768 ); - move16(); FOR( i = 0; i < MODE1_L_FIR_FER; i++ ) { hp_filt[i] = msu_r( 0, tmp, h_high_fx[i] ); @@ -708,7 +717,6 @@ void FEC_exc_estim_fx( /* HP filter the random part of the excitation and add the adaptive part */ pt_exc = exc2_buf; - move16(); FOR( i = 0; i < L_frame; i++ ) { /* exc2[i] = exc[i] + dotp( &exc2_buf[i], hp_filt, MODE1_L_FIR_FER );*/ @@ -740,7 +748,6 @@ void FEC_exc_estim_fx( { IF( EQ_16( L_frame, L_FRAME ) ) { - interp_code_5over2_fx( exc, bwe_exc, L_frame ); } ELSE @@ -775,7 +782,9 @@ void FEC_exc_estim_fx( { gain_dec_bfi_fx( hAmrwb_IO->past_qua_en_fx ); } - st_fx->bfi_pitch_fx = pitch_buf[( L_frame / L_SUBFR ) - 1]; + /* L_frame / L_SUBFR */ + tmp = shr( L_frame, 6 ); + st_fx->bfi_pitch_fx = pitch_buf[sub( tmp, 1 )]; move16(); st_fx->bfi_pitch_frame = st_fx->L_frame; move16(); diff --git a/lib_dec/er_dec_acelp_fx.c b/lib_dec/er_dec_acelp_fx.c index eec1d3be8..debb8aad3 100644 --- a/lib_dec/er_dec_acelp_fx.c +++ b/lib_dec/er_dec_acelp_fx.c @@ -129,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(); @@ -142,13 +142,13 @@ void con_acelp_fx( st->plc_use_future_lag, &extrapolationFailed, st->nb_subfr ); T0 = round_fx( predPitchLag ); - IF( NE_16( extrapolationFailed, 0 ) ) + IF( extrapolationFailed != 0 ) { /*------------------------------------------------------------------------* * - Construct adaptive codebook from side information * *------------------------------------------------------------------------*/ - IF( EQ_16( st->flagGuidedAcelp, 0 ) ) + IF( st->flagGuidedAcelp == 0 ) { nSubframes = 0; move16(); @@ -174,7 +174,7 @@ void con_acelp_fx( tmp_tc = st->old_fpitch; move32(); /* take the previous frame last pitch*/ - IF( GT_16( nSubframes, 0 ) ) + if ( nSubframes > 0 ) { tmp_tc = L_deposit_h( st->guidedT0 ); /* take the transmit pitch*/ } @@ -183,7 +183,7 @@ 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( GT_16( T0, 0 ) && ( NE_16( T0, Tc ) ) && LT_16( tmp, 0 ) && EQ_16( extrapolationFailed, 0 ) ) + if ( ( T0 > 0 ) && ( NE_16( T0, Tc ) ) && ( tmp < 0 ) && extrapolationFailed == 0 ) { fUseExtrapolatedPitch = 1; move16(); } pt_exc = exc; - IF( NE_16( st->enableGplc, 0 ) ) + if ( st->enableGplc != 0 ) { pt_exc = &exc[imult1616( nSubframes, L_SUBFR )]; } pt1_exc = pt_exc - Tc; - IF( NE_16( fUseExtrapolatedPitch, 0 ) ) + IF( 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; @@ -268,7 +268,7 @@ void con_acelp_fx( } } - IF( NE_16( fUseExtrapolatedPitch, 0 ) ) + if ( fUseExtrapolatedPitch != 0 ) { pt1_exc = harmonic_exc_buf; } @@ -285,7 +285,7 @@ void con_acelp_fx( * PLC: Resync pulse positions. *-------------------------------------------------------*/ - IF( GT_16( nSubframes, 0 ) ) + IF( nSubframes > 0 ) { pitch_buf[0] = L_deposit_h( st->guidedT0 ); move32(); @@ -293,7 +293,7 @@ void con_acelp_fx( move32(); } - IF( GT_16( nSubframes, 0 ) ) + IF( nSubframes > 0 ) { pitch_buf[3] = pitch_buf[2] = pitch_buf[1]; /* do not resync on second half of frame */ move32(); @@ -307,7 +307,7 @@ void con_acelp_fx( } ELSE { - IF( NE_16( fUseExtrapolatedPitch, 0 ) ) + IF( 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( EQ_16( T0, 0 ) ) + if ( 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( NE_16( fUseExtrapolatedPitch, 0 ) ) + IF( fUseExtrapolatedPitch != 0 ) { st->old_fpitch = predPitchLag; move32(); - IF( EQ_16( st->flagGuidedAcelp, 1 ) ) + if ( EQ_16( st->flagGuidedAcelp, 1 ) ) { st->old_fpitch = L_deposit_h( T0 ); } @@ -531,7 +531,7 @@ 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( EQ_16( gainCNG, 0 ) ) + if ( gainCNG == 0 ) { gainCNG_e = 0; move16(); @@ -554,9 +554,9 @@ void con_acelp_fx( /*in case of overflow:*/ test(); #ifdef BASOP_NOGLOB - IF( ( EQ_16( shl_sat( ftmp, sub( gainCNG_e, 1 ) ), MAXVAL_WORD16 ) ) && EQ_16( 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 ) ) && EQ_16( gainCNG, MAXVAL_WORD16 ) ) + if ( ( EQ_16( shl( ftmp, sub( gainCNG_e, 1 ) ), MAXVAL_WORD16 ) ) && EQ_16( gainCNG, MAXVAL_WORD16 ) ) #endif { tmp_16 = 1; @@ -564,7 +564,7 @@ void con_acelp_fx( } BASOP_SATURATE_WARNING_ON_EVS - IF( GT_16( tmp_16, 0 ) ) + IF( tmp_16 > 0 ) { gainCNG = ftmp /*Q0*/; move16(); @@ -620,7 +620,7 @@ void con_acelp_fx( s_32 = sub( s_32, 7 ); /*tmp_32 is Q31 * 2^s_32 */ /*assure doing Isqrt not for 0*/ - IF( NE_32( tmp_32, 0 ) ) + IF( tmp_32 != 0 ) { s_gain_inov = s_32; move16(); @@ -646,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*/ } @@ -859,15 +859,15 @@ void con_acelp_fx( 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 = p_A + add( M, 1 ); + p_A += ( M + 1 ); } Copy( mem_syn, mem_syn2, M ); /* synthesize ola*/ - E_UTIL_synthesis( synthScaling, p_A - add( M, 1 ), &exc[i_subfr], &syn[i_subfr], shr( st->L_frame, 1 ), mem_syn2, 0, M ); + E_UTIL_synthesis( synthScaling, p_A - ( M + 1 ), &exc[i_subfr], &syn[i_subfr], shr( st->L_frame, 1 ), mem_syn2, 0, M ); } test(); - IF( GT_16( st->nbLostCmpt, 5 ) && GT_16( s_16, 0 ) ) + IF( GT_16( st->nbLostCmpt, 5 ) && ( s_16 > 0 ) ) { /*scale back mem_syn, exc and synthesis*/ Scale_sig( mem_syn, M, negate( s_16 ) ); @@ -950,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 = p_A + add( M, 1 ); + p_A += ( M + 1 ); } Copy( mem_syn_unv, st->mem_syn_unv_back, M ); @@ -958,11 +958,11 @@ void con_acelp_fx( { Copy( mem_syn_unv, mem_syn, M ); /* unvoiced for ola */ - 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 ); + 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 ); } test(); - IF( GT_16( st->nbLostCmpt, 5 ) && GT_16( s_16, 0 ) ) + IF( GT_16( st->nbLostCmpt, 5 ) && ( s_16 > 0 ) ) { /*scale back mem_syn_unv, exc_unv and synthesis*/ Scale_sig( mem_syn_unv, M, negate( s_16 ) ); @@ -1067,10 +1067,10 @@ 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, add( M, 1 ) ), st->syn, add( 1, M ) ); + Copy( syn + sub(st->L_frame, M + 1), st->syn, 1 + M ); /* update old_Aq */ - Copy( p_A - add( M, 1 ), st->old_Aq_12_8_fx, add( M, 1 ) ); + Copy( p_A - ( M + 1 ), st->old_Aq_12_8_fx, M + 1 ); Copy( syn + st->L_frame, hTcxDec->syn_Overl, shr( st->L_frame, 1 ) ); @@ -1097,7 +1097,7 @@ void con_acelp_fx( } FOR( ; i < W1; i++ ) { - 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 )] ) ); + 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 ); @@ -1186,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( GT_16( abs_s( tmp ), 0 ) ) + IF( 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*/ @@ -1196,7 +1196,7 @@ 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( EQ_16( max, 0 ) ) + if ( max == 0 ) { sf_exc = 16; move16(); diff --git a/lib_dec/er_dec_tcx_fx.c b/lib_dec/er_dec_tcx_fx.c index fa30326ca..8849f7b63 100644 --- a/lib_dec/er_dec_tcx_fx.c +++ b/lib_dec/er_dec_tcx_fx.c @@ -72,7 +72,7 @@ static void calcGainc_fx( Word16 *exc, Word16 Q_exc, Word32 old_fpitch, Word16 L 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( NE_16( tmp16, 0 ) ) + IF( tmp16 != 0 ) { tmp16 = Sqrt16( tmp16, &tmp_e ); /*Q15,norm,tmp_e*/ } @@ -294,7 +294,7 @@ void con_tcx_fx( 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, add( M, 1 ) ); + Copy( st->old_Aq_12_8_fx, A_local, M + 1 ); offset = shr( L_frame, 1 ); IF( GE_16( st->last_good, UNVOICED_TRANSITION ) ) @@ -324,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(); @@ -345,7 +345,7 @@ void con_tcx_fx( test(); test(); - 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*/ ) ) + 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*/ ) ) ) { fUseExtrapolatedPitch = 1; move16(); @@ -371,7 +371,7 @@ void con_tcx_fx( test(); test(); test(); - 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 ) ) + 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 ) ) { fUseExtrapolatedPitch = 1; move16(); @@ -384,7 +384,7 @@ void con_tcx_fx( pt_exc = exc + offset; pt1_exc = pt_exc - Tc; - IF( NE_16( fUseExtrapolatedPitch, 0 ) ) + if ( fUseExtrapolatedPitch != 0 ) { pt_exc = buf; } @@ -479,7 +479,7 @@ void con_tcx_fx( move16(); } - IF( NE_16( fUseExtrapolatedPitch, 0 ) ) + if ( fUseExtrapolatedPitch != 0 ) { pt1_exc = buf; } @@ -490,7 +490,7 @@ void con_tcx_fx( move16(); } - IF( NE_16( fUseExtrapolatedPitch, 0 ) ) + if ( fUseExtrapolatedPitch != 0 ) { get_subframe_pitch( st->nb_subfr, st->old_fpitch, @@ -513,7 +513,7 @@ void con_tcx_fx( IF( EQ_16( st->nbLostCmpt, 1 ) ) { pt_exc = exc + L_frame; - IF( EQ_16( T0, 0 ) ) + IF( T0 == 0 ) { pt1_exc = pt_exc - Tc; } @@ -530,7 +530,7 @@ void con_tcx_fx( } } - IF( NE_16( fUseExtrapolatedPitch, 0 ) ) + if ( fUseExtrapolatedPitch != 0 ) { st->old_fpitchFB = predPitchLag; move32(); @@ -712,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(); @@ -780,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( NE_16( st->tcxonly, 0 ) ) + IF( st->tcxonly != 0 ) { /* gainCNG = st->conCngLevelBackgroundTrace/gainSynthDeemph; */ BASOP_Util_Divide_MantExp( hTcxDec->conCngLevelBackgroundTrace, @@ -812,7 +812,7 @@ void con_tcx_fx( gain32 = L_add( st->Mode2_lp_gainc, 0 ); /* start-of-the-frame gain - Q16*/ test(); - IF( EQ_16( st->rf_frame_type, RF_TCXTD1 ) && EQ_16( st->use_partial_copy, 1 ) ) + 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*/ ); } @@ -868,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 } @@ -918,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[add( i, L_FIR_FER2 / 2 )], add( Q_exc, noise_e ) ) ); /*Q1*/ + exc[i] = add_sat( exc[i], shl_sat( noise[i + ( L_FIR_FER2 / 2 )], add( Q_exc, noise_e ) ) ); /*Q1*/ move16(); #else - exc[i] = add( exc[i], shl( noise[add( i, L_FIR_FER2 / 2 )], add( Q_exc, noise_e ) ) ); /*Q1*/ + exc[i] = add( exc[i], shl( noise[i + ( L_FIR_FER2 / 2 )], add( Q_exc, noise_e ) ) ); /*Q1*/ move16(); #endif } @@ -1290,7 +1290,7 @@ void con_tcx_ivas_fx( 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, add( M, 1 ) ); + Copy( st->old_Aq_12_8_fx, A_local, M + 1 ); offset = shr( L_frame, 1 ); IF( GE_16( st->last_good, UNVOICED_TRANSITION ) ) @@ -1320,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(); @@ -1341,7 +1341,7 @@ void con_tcx_ivas_fx( test(); test(); - 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*/ ) ) + 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*/ ) ) ) { fUseExtrapolatedPitch = 1; move16(); @@ -1368,7 +1368,7 @@ void con_tcx_ivas_fx( test(); test(); test(); - 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 ) ) + 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 ) ) { fUseExtrapolatedPitch = 1; move16(); @@ -1381,7 +1381,7 @@ void con_tcx_ivas_fx( pt_exc = exc + offset; pt1_exc = pt_exc - Tc; - IF( NE_16( fUseExtrapolatedPitch, 0 ) ) + if ( fUseExtrapolatedPitch != 0 ) { pt_exc = buf; } @@ -1446,7 +1446,7 @@ void con_tcx_ivas_fx( move16(); } - IF( NE_16( fUseExtrapolatedPitch, 0 ) ) + if ( fUseExtrapolatedPitch != 0 ) { pt1_exc = buf; } @@ -1457,7 +1457,7 @@ void con_tcx_ivas_fx( move16(); } - IF( NE_16( fUseExtrapolatedPitch, 0 ) ) + IF( fUseExtrapolatedPitch != 0 ) { get_subframe_pitch( st->nb_subfr, st->old_fpitch, @@ -1480,7 +1480,7 @@ void con_tcx_ivas_fx( IF( EQ_16( st->nbLostCmpt, 1 ) ) { pt_exc = exc + L_frame; - IF( EQ_16( T0, 0 ) ) + IF( T0 == 0 ) { pt1_exc = pt_exc - Tc; } @@ -1497,7 +1497,7 @@ void con_tcx_ivas_fx( } } - IF( NE_16( fUseExtrapolatedPitch, 0 ) ) + if ( fUseExtrapolatedPitch != 0 ) { st->old_fpitchFB = predPitchLag; move32(); @@ -1638,7 +1638,7 @@ void con_tcx_ivas_fx( alpha_coh = negate( alpha_coh ); } - FOR( i = 0; i < add( L_frame, L_FIR_FER2 - 1 ); i++ ) + FOR( i = 0; i < L_frame + L_FIR_FER2 - 1; i++ ) { random1 = Random( &tmpSeed1 ); random2 = Random( &tmpSeed1 ); @@ -1653,7 +1653,7 @@ void con_tcx_ivas_fx( move16(); } - FOR( ; i < add( add( L_frame, shr( L_frame, 1 ) ), 2 * L_FIR_FER2 ); i++ ) + FOR( ; i < L_frame + ( L_frame / 2 ) + 2 * L_FIR_FER2; i++ ) { random1 = Random( &tmpSeed1 ); random2 = Random( &tmpSeed1 ); @@ -1693,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(); @@ -1762,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( NE_16( st->tcxonly, 0 ) ) + IF( st->tcxonly != 0 ) { /* gainCNG = st->conCngLevelBackgroundTrace/gainSynthDeemph; */ BASOP_Util_Divide_MantExp( hTcxDec->conCngLevelBackgroundTrace, @@ -1905,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[add( i, L_FIR_FER2 / 2 )], add( Q_exc, noise_e ) ) ); /*Q1*/ + exc[i] = add_sat( exc[i], shl_sat( noise[i + ( L_FIR_FER2 / 2 )], add( Q_exc, noise_e ) ) ); /*Q1*/ move16(); #else - exc[i] = add( exc[i], shl( noise[add( i, L_FIR_FER2 / 2 )], add( Q_exc, noise_e ) ) ); /*Q1*/ + exc[i] = add( exc[i], shl( noise[i + ( L_FIR_FER2 / 2 )], add( Q_exc, noise_e ) ) ); /*Q1*/ move16(); #endif } diff --git a/lib_dec/er_scale_syn_fx.c b/lib_dec/er_scale_syn_fx.c index a8c76aa85..ed78d8842 100644 --- a/lib_dec/er_scale_syn_fx.c +++ b/lib_dec/er_scale_syn_fx.c @@ -41,7 +41,7 @@ Word16 Damping_fact_fx( /* o : damping factor #endif - IF( EQ_16( core, ACELP_CORE ) ) + IF( core == ACELP_CORE ) { alpha = mult_r( _ALPHA_VT_FX, 16384 ); /* rapid convergence to 0 */ /*Q14*/ test(); @@ -96,6 +96,7 @@ 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 @@ -125,11 +126,11 @@ Word16 Damping_fact_fx( /* o : damping factor 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_fx.c b/lib_dec/er_sync_exc_fx.c index f01c98655..f4535152f 100644 --- a/lib_dec/er_sync_exc_fx.c +++ b/lib_dec/er_sync_exc_fx.c @@ -42,7 +42,7 @@ static Word16 GetMinimumPosition_fx( iMinEnergyPos = center; move16(); - IF( GT_16( filterLength, 0 ) ) + IF( filterLength > 0 ) { center = add( center, 1 ); energy = L_deposit_l( 0 ); @@ -77,7 +77,7 @@ static Word16 GetMinimumPosition_fx( tmptest = L_sub( energy, MAXVAL_WORD32 ); #endif BASOP_SATURATE_WARNING_ON_EVS - IF( EQ_32( tmptest, 0 ) ) + IF( tmptest == 0 ) { tmp_e = add( tmp_e, 1 ); energy = L_shr( energy_old, 2 ); @@ -87,7 +87,7 @@ static Word16 GetMinimumPosition_fx( energy = L_mac( energy, tmp16, tmp16 ); } - IF( LT_32( energy, 0 ) ) + IF( energy < 0 ) { iMinEnergyPos = add( i, center ); tmp_e = 0; @@ -119,7 +119,7 @@ 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] ) ) ) { iMax = i; move16(); @@ -152,7 +152,7 @@ static void AddSamples_fx( FOR( i = 0; i < nb_min; i++ ) { /* Copy section */ - FOR( j = sub( min_pos[i], last_min_pos ); j > 0; j-- ) + FOR( j = min_pos[i] - last_min_pos; j > 0; j-- ) { *pt_dest++ = *pt_src++; move16(); @@ -252,7 +252,7 @@ void PulseResynchronization_fx( test(); test(); test(); - 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 ) ) + 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 ) ) { /* This is error handling and recovery that should never occur. */ test(); @@ -274,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*/ } @@ -332,7 +332,7 @@ void PulseResynchronization_fx( tmp32 = L_add( tmp32, 65536l /*1.f Q16*/ ); k = extract_h( tmp32 ); test(); - IF( GE_16( k, 0 ) && LE_16( add( k, 1 ), NB_PULSES_MAX ) ) + IF( ( k >= 0 ) && LE_16( add( k, 1 ), NB_PULSES_MAX ) ) { absPitchDiff = L_abs( L_sub( L_deposit_h( roundedPitchStart ), pitchEnd ) ); /*Q16*/ @@ -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( LT_32( tmp32, 0 ) ) + if ( tmp32 < 0 ) { roundedCycleDelta = negate( roundedCycleDelta ); } @@ -383,7 +383,7 @@ void PulseResynchronization_fx( #else cycleDelta = round_fx( tmp32 ); /*Q15, cycleDelta_e*/ #endif - IF( EQ_16( cycleDelta, 0 ) ) + if ( cycleDelta == 0 ) { cycleDelta_e = 0; move16(); @@ -415,7 +415,7 @@ void PulseResynchronization_fx( iDeltaSamples[i] = roundedCycleDelta; move16(); roundedCycleDelta = extract_h( cycleDelta32 ); /* cycleDelta32 should never be < 0 here */ - iDeltaSamples[sub( i, 1 )] = roundedCycleDelta; + iDeltaSamples[i - 1] = roundedCycleDelta; move16(); } ELSE @@ -449,7 +449,7 @@ void PulseResynchronization_fx( iMinPos1 = add( iMinPos1, T0 ); - IF( LT_16( nSamplesDelta, 0 ) ) + IF( nSamplesDelta < 0 ) { /* Find the location of the minimum energy before the first pulse */ diff --git a/lib_dec/er_util_fx.c b/lib_dec/er_util_fx.c index 09a7842d1..ee0c52b8e 100644 --- a/lib_dec/er_util_fx.c +++ b/lib_dec/er_util_fx.c @@ -71,7 +71,7 @@ void minimumStatistics_fx( /* compute optimal factor aOpt for recursive smoothing of frame minima */ tmp2 = BASOP_Util_Add_MantExp( *lastFrameLevel, *lastFrameLevel_e, negate( *noiseEstimate ), noiseEstimate_e, &tmp ); - IF( GE_16( tmp, 0 ) ) + IF( tmp >= 0 ) { /* aOpt = *noiseEstimate / *lastFrameLevel; */ aOpt = BASOP_Util_Divide1616_Scale( *noiseEstimate, *lastFrameLevel, &aOpt_e ); @@ -85,7 +85,7 @@ void minimumStatistics_fx( } aOpt = mult_r( aOpt, aOpt ); /* Q15 */ aOpt_e = shl( aOpt_e, 1 ); - IF( EQ_16( aOpt, 0 ) ) + if ( aOpt == 0 ) { aOpt_e = 0; move16(); @@ -100,7 +100,7 @@ void minimumStatistics_fx( tmp = *currLevelIndex; move16(); move16(); - IF( EQ_16( tmp, 0 ) ) + if ( tmp == 0 ) { tmp = PLC_MIN_STAT_BUFF_SIZE; move16(); @@ -118,7 +118,7 @@ void minimumStatistics_fx( tmp = mult_r( tmp, currentFrameLevel ); /*Q_tmp = tmp2 + currentFrameLevel_e*/ tmp2 = add( tmp2, currentFrameLevel_e ); - IF( EQ_16( tmp, 0 ) ) + if ( tmp == 0 ) { tmp2 = 0; move16(); @@ -132,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( GE_16( tmp, 0 ) ) + IF( tmp >= 0 ) { /*rescale noiseLevelMemory*/ @@ -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( GT_16( tmp, 0 ) ) + if ( tmp > 0 ) { p = i; move16(); @@ -178,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(); @@ -261,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 ); } @@ -295,7 +295,7 @@ void genPlcFiltBWAdap_fx( IF( EQ_32( sr_core, INT_FS_16k ) ) { - IF( EQ_16( type, 0 ) ) + IF( type == 0 ) { *lpFiltAdapt++ = 7282 /* 0.4000f/(2.f*0.4000f+1.f) Q15*/; move16(); @@ -322,7 +322,7 @@ void genPlcFiltBWAdap_fx( } ELSE /*sr_core = INT_FS_12k8 */ { - IF( EQ_16( type, 0 ) ) + IF( type == 0 ) { *lpFiltAdapt++ = 5899 /* 0.2813f/(2.f*0.2813f+1.f) Q15*/; move16(); @@ -404,7 +404,7 @@ Word16 GetPLCModeDecision_ivas_fx( move16(); test(); test(); - IF( ( GT_16( st->last_core, ACELP_CORE ) && NE_16( hTcxDec->tcxltp_last_gain_unmodified, 0 ) ) || ( EQ_16( st->flagGuidedAcelp, 1 ) ) ) + if ( ( st->last_core > ACELP_CORE && 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; @@ -417,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(); @@ -429,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(); @@ -461,7 +461,7 @@ Word16 GetPLCModeDecision_ivas_fx( Word32 pitch; pitch = L_deposit_h( 0 ); - IF( GT_16( hTcxDec->tcxltp_last_gain_unmodified, 0 ) ) + if ( hTcxDec->tcxltp_last_gain_unmodified > 0 ) { pitch = L_add( st->old_fpitch, 0 ); } @@ -479,7 +479,7 @@ 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*/ ) ) ) || ( 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*/ ) ) ) ) + 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*/ ) ) ) ) { core = TCX_20_CORE; move16(); @@ -492,10 +492,10 @@ Word16 GetPLCModeDecision_ivas_fx( move16(); } } - ELSE IF( NE_16( st->last_core, ACELP_CORE ) ) + ELSE IF( 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(); @@ -533,7 +533,7 @@ Word16 GetPLCModeDecision_fx( move16(); test(); test(); - IF( ( GT_16( st->last_core, ACELP_CORE ) && NE_16( hTcxDec->tcxltp_last_gain_unmodified, 0 ) ) || ( EQ_16( st->flagGuidedAcelp, 1 ) ) ) + if ( ( st->last_core > ACELP_CORE && 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; @@ -546,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(); @@ -558,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(); @@ -590,11 +590,11 @@ Word16 GetPLCModeDecision_fx( pitch = L_deposit_h( 0 ); - IF( GT_16( hTcxDec->tcxltp_last_gain_unmodified, 0 ) ) + if ( hTcxDec->tcxltp_last_gain_unmodified > 0 ) { pitch = L_add( st->old_fpitch, 0 ); } - IF( EQ_16( st->element_mode, EVS_MONO ) ) + IF( st->element_mode == EVS_MONO ) { TonalMDCTConceal_Detect( &st->tonalMDCTconceal, pitch, &numIndices, st->element_mode #ifdef ADD_IVAS_HTONALMDCTCONC @@ -620,7 +620,7 @@ 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*/ ) ) ) || ( 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*/ ) ) ) ) + 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*/ ) ) ) ) { core = TCX_20_CORE; move16(); @@ -633,10 +633,10 @@ Word16 GetPLCModeDecision_fx( move16(); } } - ELSE IF( NE_16( st->last_core, ACELP_CORE ) ) + ELSE IF( 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/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index 33515f491..e258c68e9 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -70,17 +70,22 @@ ivas_error evs_dec_fx( ivas_error error; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move16(); #endif hBWE_TD = st_fx->hBWE_TD; hHQ_core = st_fx->hHQ_core; hTcxLtpDec = st_fx->hTcxLtpDec; hTcxDec = st_fx->hTcxDec; error = IVAS_ERR_OK; + move16(); + move16(); + move16(); timeIn_e = 0; move16(); delay_tdbwe = 0; /* for compiler warning*/ + move16(); Qpostd = 0; move16(); /* default and used for MODE2 */ concealWholeFrame = -1; @@ -91,7 +96,9 @@ ivas_error evs_dec_fx( *-----------------------------------------------------------------*/ st_fx->idchan = 0; + move16(); st_fx->element_brate = st_fx->total_brate; + move32(); st_fx->flag_ACELP16k = set_ACELP_flag( EVS_MONO, -1, st_fx->total_brate, 0, 0, -1, -1 ); FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) @@ -99,7 +106,9 @@ ivas_error evs_dec_fx( set32_fx( realBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX ); set32_fx( imagBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX ); realBuffer[i] = realBufferTmp[i]; + move32(); imagBuffer[i] = imagBufferTmp[i]; + move32(); } if ( st_fx->bfi == 0 ) { @@ -158,6 +167,7 @@ ivas_error evs_dec_fx( #else hHQ_core->old_out_fx[i] = shl( mult_r( hHQ_core->old_out_fx[i], st_fx->plcInfo.recovery_gain ), 1 ); #endif + move16(); } FOR( i = 0; i < st_fx->L_frame; i++ ) { @@ -166,10 +176,11 @@ ivas_error evs_dec_fx( #else hHQ_core->old_out_LB_fx[i] = shl( mult_r( hHQ_core->old_out_LB_fx[i], st_fx->plcInfo.recovery_gain ), 1 ); #endif + move16(); } /* attenuate PLC buffers, if no aldo window is used and if no sid or zero frame is received */ - IF( 0 == st_fx->hTcxCfg->last_aldo ) + IF( st_fx->hTcxCfg->last_aldo == 0 ) { Word32 f; Word16 s; @@ -180,7 +191,6 @@ ivas_error evs_dec_fx( tmp1 = extract_l( L_shr_r( f, s ) ); FOR( i = 0; i < st_fx->hTcxCfg->tcx_mdct_window_lengthFB; i++ ) { - #ifdef BASOP_NOGLOB hTcxDec->syn_OverlFB[i] = shl_sat( mult_sat( tmp1, hTcxDec->syn_OverlFB[i] ), add( s, 1 ) ); #else @@ -214,6 +224,7 @@ ivas_error evs_dec_fx( if ( !st_fx->bfi ) { st_fx->flagGuidedAcelp = 0; + move16(); } /*----------------------------------------------------------------* @@ -229,6 +240,7 @@ ivas_error evs_dec_fx( { getPartialCopyInfo( st_fx, &st_fx->coder_type, &sharpFlag ); frameMode = st_fx->bfi; + move16(); } test(); @@ -265,6 +277,10 @@ ivas_error evs_dec_fx( } /* if previous frame was HQ Core or TCX10, drop partial copy info and continue HQ Core/TCX10 concealment */ + test(); + test(); + test(); + test(); IF( st_fx->use_partial_copy && ( ( sub( st_fx->last_core, HQ_CORE ) == 0 ) || ( sub( st_fx->last_core, TCX_10_CORE ) == 0 ) || ( ( sub( st_fx->last_core, TCX_20_CORE ) == 0 ) && getTcxonly( /*EVS_MONO, */ st_fx->last_total_brate /*, 0, 0*/ ) ) ) ) { st_fx->bfi = 1; @@ -295,6 +311,7 @@ ivas_error evs_dec_fx( { st_fx->sr_core = i_mult( st_fx->L_frame, FRAMES_PER_SEC ); st_fx->fscale_old = st_fx->fscale; + move16(); st_fx->fscale = sr2fscale_fx( st_fx->sr_core ); } ELSE @@ -332,7 +349,7 @@ ivas_error evs_dec_fx( * Preprocessing (preparing) for ACELP/HQ core switching *---------------------------------------------------------------------*/ // PMT("core_switching_pre_dec_fx missign args") - if ( ( error = core_switching_pre_dec_fx( st_fx, output_frame ) ) != IVAS_ERR_OK ) + IF( ( error = core_switching_pre_dec_fx( st_fx, output_frame ) ) != IVAS_ERR_OK ) { return error; } @@ -345,7 +362,7 @@ ivas_error evs_dec_fx( { /* ACELP core decoder */ - if ( ( error = acelp_core_dec_fx( st_fx, NULL, synth_fx, NULL, bwe_exc_extended_fx, voice_factors_fx, old_syn_12k8_16k_fx, sharpFlag, pitch_buf_fx, &unbits, &sid_bw, NULL, NULL, NULL, 0, EVS_MONO, 0, 0, 1, NULL, 1 ) ) != IVAS_ERR_OK ) + IF( ( error = acelp_core_dec_fx( st_fx, NULL, synth_fx, NULL, bwe_exc_extended_fx, voice_factors_fx, old_syn_12k8_16k_fx, sharpFlag, pitch_buf_fx, &unbits, &sid_bw, NULL, NULL, NULL, 0, EVS_MONO, 0, 0, 1, NULL, 1 ) ) != IVAS_ERR_OK ) { return error; } @@ -423,6 +440,15 @@ ivas_error evs_dec_fx( test(); test(); test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); IF( EQ_16( st_fx->extl, SWB_TBE ) || EQ_16( st_fx->extl, FB_TBE ) || ( NE_16( st_fx->coder_type, AUDIO ) && NE_16( st_fx->coder_type, INACTIVE ) && GT_32( st_fx->core_brate, SID_2k40 ) && EQ_16( st_fx->core, ACELP_CORE ) && GE_32( st_fx->output_Fs, 32000 ) && GT_16( st_fx->bwidth, NB ) && st_fx->bws_cnt > 0 && !st_fx->ppp_mode_dec && !( EQ_16( st_fx->nelp_mode_dec, 1 ) && EQ_16( st_fx->bfi, 1 ) ) ) ) { swb_tbe_dec_fx( st_fx, st_fx->coder_type, bwe_exc_extended_fx, st_fx->Q_exc, voice_factors_fx, @@ -539,10 +565,10 @@ ivas_error evs_dec_fx( test(); test(); test(); - test(); - IF( EQ_16( st_fx->core, ACELP_CORE ) && !st_fx->bfi && st_fx->prev_bfi && GE_32( st_fx->last_total_brate, HQ_48k ) && EQ_16( st_fx->last_codec_mode, MODE2 ) && ( EQ_16( st_fx->last_core_bfi, TCX_20_CORE ) || EQ_16( st_fx->last_core_bfi, TCX_10_CORE ) ) && st_fx->plcInfo.concealment_method == TCX_NONTONAL && LT_32( st_fx->plcInfo.nbLostCmpt, 4 ) ) + IF( EQ_16( st_fx->core, ACELP_CORE ) && !st_fx->bfi && st_fx->prev_bfi && GE_32( st_fx->last_total_brate, HQ_48k ) && EQ_16( st_fx->last_codec_mode, MODE2 ) && ( EQ_16( st_fx->last_core_bfi, TCX_20_CORE ) || EQ_16( st_fx->last_core_bfi, TCX_10_CORE ) ) && EQ_16( st_fx->plcInfo.concealment_method, TCX_NONTONAL ) && LT_32( st_fx->plcInfo.nbLostCmpt, 4 ) ) { tmps = 0; + move16(); IF( GE_16( output_frame, L_FRAME16k ) ) { tmps = NS2SA_fx2( st_fx->output_Fs, DELAY_BWE_TOTAL_NS ); @@ -562,6 +588,7 @@ ivas_error evs_dec_fx( add( extract_l( st_fx->plcInfo.nbLostCmpt ), 1 ), st_fx->bfi ); st_fx->plcInfo.Pitch_fx = 0; + move16(); } /*----------------------------------------------------------------* @@ -621,8 +648,9 @@ ivas_error evs_dec_fx( move16(); FOR( i = 0; i < tmps; i++ ) { - tmp_buffer_fx[i] = round_fx( L_mac( L_mult( st_fx->hb_prev_synth_buffer_fx[i], sin_table256_fx[255 - tmp16] ), - st_fx->hb_prev_synth_buffer_fx[st_fx->old_bwe_delay - 1 - i], sin_table256_fx[tmp16] ) ); + tmp_buffer_fx[i] = round_fx( L_mac( L_mult( st_fx->hb_prev_synth_buffer_fx[i], sin_table256_fx[sub( 255, tmp16 )] ), + st_fx->hb_prev_synth_buffer_fx[sub( sub( st_fx->old_bwe_delay, 1 ), i )], sin_table256_fx[tmp16] ) ); + move16(); tmp16 = add( tmp16, incr ); } Copy( tmp_buffer_fx, st_fx->hb_prev_synth_buffer_fx, tmps ); @@ -636,7 +664,7 @@ ivas_error evs_dec_fx( move16(); FOR( i = 0; i < st_fx->old_bwe_delay; i++ ) { - tmp_buffer_fx[i] = mult_r( st_fx->hb_prev_synth_buffer_fx[i], sin_table256_fx[255 - tmp16] ); + tmp_buffer_fx[i] = mult_r( st_fx->hb_prev_synth_buffer_fx[i], sin_table256_fx[sub( 255, tmp16 )] ); move16(); tmp16 = add( tmp16, incr ); } @@ -649,7 +677,8 @@ ivas_error evs_dec_fx( FOR( i = 0; i < st_fx->old_bwe_delay; i++ ) { /*tmp_buffer[tmps - 1 - i] += st->hb_prev_synth_buffer[st->old_bwe_delay - 1 - i] * sin_table256[i * incr];*/ - tmp_buffer_fx[tmps - 1 - i] = round_fx( L_mac( L_mult( tmp_buffer_fx[tmps - 1 - i], 32767 ), st_fx->hb_prev_synth_buffer_fx[st_fx->old_bwe_delay - 1 - i], sin_table256_fx[tmp16 /*i * incr*/] ) ); + tmp_buffer_fx[sub( sub( tmps, 1 ), i )] = round_fx( L_mac( L_mult( tmp_buffer_fx[sub( sub( tmps, 1 ), i )], 32767 ), st_fx->hb_prev_synth_buffer_fx[sub( sub( st_fx->old_bwe_delay, 1 ), i )], sin_table256_fx[tmp16 /*i * incr*/] ) ); + move16(); tmp16 = add( tmp16, incr ); } @@ -663,8 +692,8 @@ ivas_error evs_dec_fx( } Copy( hb_synth_fx, tmp_buffer_fx, output_frame ); Copy( st_fx->hb_prev_synth_buffer_fx, hb_synth_fx, tmps ); - Copy( tmp_buffer_fx, hb_synth_fx + tmps, output_frame - tmps ); - Copy( tmp_buffer_fx + output_frame - tmps, st_fx->hb_prev_synth_buffer_fx, tmps ); + Copy( tmp_buffer_fx, hb_synth_fx + tmps, sub( output_frame, tmps ) ); + Copy( tmp_buffer_fx + sub( output_frame, tmps ), st_fx->hb_prev_synth_buffer_fx, tmps ); st_fx->old_bwe_delay = tmps; move16(); @@ -674,9 +703,7 @@ ivas_error evs_dec_fx( test(); test(); test(); - test(); - IF( ( st_fx->ppp_mode_dec || ( EQ_16( st_fx->nelp_mode_dec, 1 ) && EQ_16( st_fx->bfi, 1 ) ) ) && EQ_16( st_fx->L_frame, st_fx->last_L_frame ) && ( st_fx->bws_cnt > 1 || st_fx->last_extl != -1 ) ) - + IF( ( st_fx->ppp_mode_dec || ( EQ_16( st_fx->nelp_mode_dec, 1 ) && EQ_16( st_fx->bfi, 1 ) ) ) && EQ_16( st_fx->L_frame, st_fx->last_L_frame ) && ( GT_16( st_fx->bws_cnt, 1 ) || NE_16( st_fx->last_extl, -1 ) ) ) { Copy( hBWE_TD->old_hb_synth_fx, hb_synth_fx, output_frame ); IF( LT_16( hBWE_TD->prev_hb_synth_fx_exp, 14 ) ) @@ -686,6 +713,7 @@ ivas_error evs_dec_fx( ELSE { hb_synth_fx_exp = 14; + move16(); } } ELSE @@ -703,15 +731,19 @@ ivas_error evs_dec_fx( { case L_FRAME8k: tmp16 = 205; + move16(); BREAK; /*Q15*/ case L_FRAME16k: tmp16 = 102; + move16(); BREAK; /*Q15*/ case L_FRAME32k: tmp16 = 51; + move16(); BREAK; /*Q15*/ case L_FRAME48k: tmp16 = 34; + move16(); BREAK; /*Q15*/ } @@ -754,25 +786,25 @@ ivas_error evs_dec_fx( concealWholeFrame = 0; move16(); - if ( EQ_16( frameMode, FRAMEMODE_NORMAL ) ) + if ( EQ_32( frameMode, FRAMEMODE_NORMAL ) ) { st_fx->m_decodeMode = DEC_NO_FRAM_LOSS; - move16(); + move32(); } - IF( EQ_16( frameMode, FRAMEMODE_MISSING ) ) + IF( EQ_32( frameMode, FRAMEMODE_MISSING ) ) { test(); test(); IF( st_fx->use_partial_copy && GE_16( st_fx->rf_frame_type, RF_TCXFD ) && LE_16( st_fx->rf_frame_type, RF_TCXTD2 ) ) { st_fx->m_decodeMode = DEC_NO_FRAM_LOSS; - move16(); + move32(); } ELSE { st_fx->m_decodeMode = DEC_CONCEALMENT_EXT; - move16(); + move32(); } } @@ -799,7 +831,7 @@ ivas_error evs_dec_fx( if ( st_fx->bfi ) { frameMode = FRAMEMODE_MISSING; - move16(); + move32(); } IF( st_fx->igf ) { @@ -918,7 +950,7 @@ ivas_error evs_dec_fx( hb_synth_fx_exp = st_fx->prev_Q_bwe_syn2; move16(); } - ELSE IF( st_fx->bwidth == WB && st_fx->last_extl == WB_TBE ) + ELSE IF( EQ_16( st_fx->bwidth, WB ) && EQ_16( st_fx->last_extl, WB_TBE ) ) { GenTransition_WB_fx( hBWE_TD->syn_overlap_fx, hBWE_TD->old_tbe_synth_fx, st_fx->prev_Qx, 2 * NS2SA( st_fx->output_Fs, DELAY_BWE_TOTAL_NS ), hb_synth_fx, hBWE_TD->state_lsyn_filt_shb_fx, hBWE_TD->state_lsyn_filt_dwn_shb_fx, st_fx->output_Fs, hBWE_TD->mem_resamp_HB_fx ); @@ -937,6 +969,7 @@ ivas_error evs_dec_fx( { set16_fx( hBWE_TD->fb_state_lpc_syn_fx, 0, LPC_SHB_ORDER ); hBWE_TD->fb_tbe_demph_fx = 0; + move16(); fb_tbe_reset_synth_fx( hBWE_TD->fbbwe_hpf_mem_fx, hBWE_TD->fbbwe_hpf_mem_fx_Q, &hBWE_TD->prev_fbbwe_ratio_fx ); } swb_tbe_reset_synth_fx( hBWE_TD->genSHBsynth_Hilbert_Mem_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx ); @@ -959,7 +992,6 @@ ivas_error evs_dec_fx( { nab = s_min( st_fx->cldfbAna->no_channels, st_fx->cldfbSyn->no_channels ); st_fx->cldfbSyn->lsb = s_min( st_fx->cldfbAna->no_channels, st_fx->cldfbSyn->no_channels ); - move16(); st_fx->cldfbSyn->usb = st_fx->cldfbSyn->no_channels; move16(); st_fx->cldfbAna->lsb = st_fx->cldfbAna->no_channels; @@ -979,14 +1011,12 @@ ivas_error evs_dec_fx( - do CNG during inactive frames ****************************************/ HANDLE_FD_CNG_DEC hFdCngDec = st_fx->hFdCngDec; - move16(); - noisy_speech_detection_fx( st_fx->hFdCngDec, st_fx->VAD && st_fx->m_frame_type == ACTIVE_FRAME, output_sp, 0 ); + noisy_speech_detection_fx( st_fx->hFdCngDec, st_fx->VAD && EQ_16( st_fx->m_frame_type, ACTIVE_FRAME ), output_sp, 0 ); hFdCngDec->hFdCngCom->likelihood_noisy_speech = mult_r( hFdCngDec->hFdCngCom->likelihood_noisy_speech, 32440 /*0.99 Q15*/ ); - IF( hFdCngDec->hFdCngCom->flag_noisy_speech != 0 ) + if ( hFdCngDec->hFdCngCom->flag_noisy_speech != 0 ) { hFdCngDec->hFdCngCom->likelihood_noisy_speech = add( hFdCngDec->hFdCngCom->likelihood_noisy_speech, 328 /*0.01 Q15*/ ); - move16(); } st_fx->lp_noise = hFdCngDec->lp_noise; move32(); @@ -1045,6 +1075,11 @@ ivas_error evs_dec_fx( update_decoder_LPD_cng( st_fx, st_fx->coder_type, timeDomainBuffer, A, st_fx->p_bpf_noise_buf ); /* Generate additional comfort noise to mask potential coding artefacts */ + test(); + test(); + test(); + test(); + test(); IF( st_fx->flag_cna ) { generate_masking_noise_fx( timeDomainBuffer, 0, st_fx->hFdCngDec->hFdCngCom, st_fx->hFdCngDec->hFdCngCom->frameSize, 0 ); @@ -1053,12 +1088,12 @@ ivas_error evs_dec_fx( { FOR( i = 0; i < st_fx->L_frame / 2; i++ ) { - timeDomainBuffer[i] = add( timeDomainBuffer[i], st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2[i + 5 * st_fx->L_frame / 4] ); + timeDomainBuffer[i] = add( timeDomainBuffer[i], st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2[add( i, i_mult( 5, shr( st_fx->L_frame, 2 ) ) )] ); move16(); } } /* check if the CLDFB works on the right sample rate */ - IF( NE_16( ( st_fx->cldfbAna->no_channels * st_fx->cldfbAna->no_col ), st_fx->L_frame ) ) + IF( NE_16( i_mult( st_fx->cldfbAna->no_channels, st_fx->cldfbAna->no_col ), st_fx->L_frame ) ) { Word16 newCldfbBands = CLDFB_getNumChannels( L_mult0( st_fx->L_frame, 50 ) ); @@ -1073,9 +1108,9 @@ ivas_error evs_dec_fx( { st_fx->cldfbSyn->bandsToZero = sub( st_fx->cldfbSyn->no_channels, 10 ); } - ELSE IF( st_fx->hFdCngDec->hFdCngCom->regularStopBand < st_fx->cldfbSyn->no_channels ) + ELSE IF( LT_16( st_fx->hFdCngDec->hFdCngCom->regularStopBand, st_fx->cldfbSyn->no_channels ) ) { - st_fx->cldfbSyn->bandsToZero = st_fx->cldfbSyn->no_channels - st_fx->hFdCngDec->hFdCngCom->regularStopBand; + st_fx->cldfbSyn->bandsToZero = sub( st_fx->cldfbSyn->no_channels, st_fx->hFdCngDec->hFdCngCom->regularStopBand ); } timeIn_e = 2; @@ -1090,7 +1125,7 @@ ivas_error evs_dec_fx( cldfbAnalysisFiltering( st_fx->cldfbAna, realBuffer, imagBuffer, &st_fx->scaleFactor, timeDomainBuffer, timeIn_e, CLDFB_NO_COL_MAX, workBuffer ); } - if ( st_fx->flag_cna == 0 ) + IF( st_fx->flag_cna == 0 ) { set16_fx( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, st_fx->hFdCngDec->hFdCngCom->fftlen ); } @@ -1214,7 +1249,7 @@ ivas_error evs_dec_fx( } ELSE { - Copy( hTcxDec->old_synthFB_fx + hTcxDec->old_synth_lenFB - delay_comp, st_fx->delay_buf_out_fx, delay_comp ); + Copy( hTcxDec->old_synthFB_fx + sub( hTcxDec->old_synth_lenFB, delay_comp ), st_fx->delay_buf_out_fx, delay_comp ); IF( EQ_32( st_fx->output_Fs, 8000 ) ) { Copy( hTcxDec->FBTCXdelayBuf, st_fx->previoussynth_fx, delay_comp ); @@ -1232,8 +1267,8 @@ ivas_error evs_dec_fx( { Copy( output_sp, tmp_buffer_fx, output_frame ); Copy_Scale_sig( st_fx->prev_synth_buffer_fx, output_sp, delay_tdbwe, negate( timeIn_e ) ); - Copy( tmp_buffer_fx, output_sp + delay_tdbwe, output_frame - delay_tdbwe ); - Copy_Scale_sig( tmp_buffer_fx + output_frame - delay_tdbwe, st_fx->prev_synth_buffer_fx, delay_tdbwe, timeIn_e ); + Copy( tmp_buffer_fx, output_sp + delay_tdbwe, sub( output_frame, delay_tdbwe ) ); + Copy_Scale_sig( tmp_buffer_fx + sub( output_frame, delay_tdbwe ), st_fx->prev_synth_buffer_fx, delay_tdbwe, timeIn_e ); } test(); @@ -1320,7 +1355,7 @@ ivas_error evs_dec_fx( Copy_Scale_sig( pcmbufFB + tmps, output_sp + shl( tmps, 1 ), sub( hTcxDec->L_frameTCX, shl( tmps, 1 ) ), negate( timeIn_e ) ); } - Copy( pcmbufFB + hTcxDec->L_frameTCX - tmps, hTcxDec->FBTCXdelayBuf, tmps ); + Copy( pcmbufFB + sub( hTcxDec->L_frameTCX, tmps ), hTcxDec->FBTCXdelayBuf, tmps ); test(); IF( st_fx->bfi && GT_16( st_fx->last_core, ACELP_CORE ) ) @@ -1367,7 +1402,6 @@ ivas_error evs_dec_fx( Scale_sig( hTcxLtpDec->tcxltp_mem_in, delta, sub( Qpostd, Qpostd_prev ) ); Scale_sig( hTcxLtpDec->tcxltp_mem_out, output_frame, sub( Qpostd, Qpostd_prev ) ); - test(); Scale_sig( output_sp, output_frame, timeIn_e ); @@ -1386,30 +1420,28 @@ ivas_error evs_dec_fx( IF( EQ_16( st_fx->codec_mode, MODE1 ) ) { - Copy( hTcxDec->synth_history_fx + output_frame, hTcxDec->synth_history_fx, output_frame - post_hq_delay + NS2SA_fx2( st_fx->output_Fs, PH_ECU_MEM_NS ) ); - Copy_Scale_sig( synth_fx, hTcxDec->old_synthFB_fx + output_frame - post_hq_delay, output_frame, negate( Qpostd ) ); /* output_sp not initialized yet */ + Copy( hTcxDec->synth_history_fx + output_frame, hTcxDec->synth_history_fx, add( sub( output_frame, post_hq_delay ), NS2SA_fx2( st_fx->output_Fs, PH_ECU_MEM_NS ) ) ); + Copy_Scale_sig( synth_fx, hTcxDec->old_synthFB_fx + sub( output_frame, post_hq_delay ), output_frame, negate( Qpostd ) ); /* output_sp not initialized yet */ /* reset the remaining buffer, which is read in TCX concealment the necessary samples to fill this buffer are not available for all cases, the impact on the output is limited */ - set16_fx( hTcxDec->old_synthFB_fx + 2 * output_frame - post_hq_delay, 0, post_hq_delay ); + set16_fx( hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), post_hq_delay ), 0, post_hq_delay ); IF( GE_16( output_frame, L_FRAME16k ) ) { - - Copy_Scale_sig( st_fx->prev_synth_buffer_fx, hTcxDec->old_synthFB_fx + 2 * output_frame - NS2SA_fx2( st_fx->output_Fs, DELAY_BWE_TOTAL_NS ), NS2SA_fx2( st_fx->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), negate( st_fx->Qprev_synth_buffer_fx ) ); + Copy_Scale_sig( st_fx->prev_synth_buffer_fx, hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_fx2( st_fx->output_Fs, DELAY_BWE_TOTAL_NS ) ), NS2SA_fx2( st_fx->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), negate( st_fx->Qprev_synth_buffer_fx ) ); } IF( NE_16( st_fx->core, ACELP_CORE ) ) { IF( GE_16( output_frame, L_FRAME16k ) ) { - - Copy_Scale_sig( synth_fx + output_frame, hTcxDec->old_synthFB_fx + 2 * output_frame - NS2SA_fx2( st_fx->output_Fs, DELAY_CLDFB_NS ), NS2SA_fx2( st_fx->output_Fs, DELAY_CLDFB_NS ), negate( Qpostd ) ); - Copy_Scale_sig( hHQ_core->old_out_fx + NS2SA_fx2( st_fx->output_Fs, N_ZERO_MDCT_NS ), hTcxDec->old_synthFB_fx + 2 * output_frame, NS2SA_fx2( st_fx->output_Fs, PH_ECU_LOOKAHEAD_NS ), negate( hHQ_core->Q_old_wtda ) ); + Copy_Scale_sig( synth_fx + output_frame, hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_fx2( st_fx->output_Fs, DELAY_CLDFB_NS ) ), NS2SA_fx2( st_fx->output_Fs, DELAY_CLDFB_NS ), negate( Qpostd ) ); + Copy_Scale_sig( hHQ_core->old_out_fx + NS2SA_fx2( st_fx->output_Fs, N_ZERO_MDCT_NS ), hTcxDec->old_synthFB_fx + shl( output_frame, 1 ), NS2SA_fx2( st_fx->output_Fs, PH_ECU_LOOKAHEAD_NS ), negate( hHQ_core->Q_old_wtda ) ); } ELSE { - Copy_Scale_sig( synth_fx + output_frame, hTcxDec->old_synthFB_fx + 2 * output_frame - NS2SA_fx2( st_fx->output_Fs, DELAY_BWE_TOTAL_NS ), NS2SA_fx2( st_fx->output_Fs, DELAY_CLDFB_NS ), negate( Qpostd ) ); - Copy_Scale_sig( hHQ_core->old_out_fx + NS2SA_fx2( st_fx->output_Fs, N_ZERO_MDCT_NS ), hTcxDec->old_synthFB_fx + 2 * output_frame - NS2SA_fx2( st_fx->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), NS2SA_fx2( st_fx->output_Fs, PH_ECU_LOOKAHEAD_NS ), negate( hHQ_core->Q_old_wtda ) ); + Copy_Scale_sig( synth_fx + output_frame, hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_fx2( st_fx->output_Fs, DELAY_BWE_TOTAL_NS ) ), NS2SA_fx2( st_fx->output_Fs, DELAY_CLDFB_NS ), negate( Qpostd ) ); + Copy_Scale_sig( hHQ_core->old_out_fx + NS2SA_fx2( st_fx->output_Fs, N_ZERO_MDCT_NS ), hTcxDec->old_synthFB_fx + shl( output_frame, 1 ) - NS2SA_fx2( st_fx->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), NS2SA_fx2( st_fx->output_Fs, PH_ECU_LOOKAHEAD_NS ), negate( hHQ_core->Q_old_wtda ) ); } } } @@ -1445,6 +1477,8 @@ ivas_error evs_dec_fx( { st_fx->bfi = 0; move16(); + test(); + test(); IF( st_fx->use_partial_copy && GE_16( st_fx->rf_frame_type, RF_TCXFD ) && LE_16( st_fx->rf_frame_type, RF_TCXTD2 ) ) { if ( EQ_16( frameMode, FRAMEMODE_MISSING ) ) diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c index 5ee55a3a7..063a91269 100644 --- a/lib_dec/fd_cng_dec.c +++ b/lib_dec/fd_cng_dec.c @@ -131,76 +131,37 @@ void initFdCngDec( /* Set some counters and flags */ hFdCngDec->flag_dtx_mode = 0; -#ifndef IVAS_FLOAT_FIXED - hFdCngDec->lp_noise_float = -20.f; - hFdCngDec->lp_speech_float = 25.f; + move16(); - /* Initialize noise estimation algorithm */ - set_f( hFdCngDec->bandNoiseShape_float, 0.0f, FFTLEN2 ); - set_f( hFdCngDec->partNoiseShape_float, 0.0f, NPART ); - set_f( hFdCngDec->msPeriodog_float, 0.0f, NPART_SHAPING ); - set_f( hFdCngDec->msAlpha_float, 0.0f, NPART_SHAPING ); - set_f( hFdCngDec->msBminWin_float, 0.0f, NPART_SHAPING ); - set_f( hFdCngDec->msBminSubWin_float, 0.0f, NPART_SHAPING ); - set_f( hFdCngDec->msPsd_float, 0.0f, NPART_SHAPING ); - set_f( hFdCngDec->msNoiseFloor_float, 0.0f, NPART_SHAPING ); - set_f( hFdCngDec->msNoiseEst_float, 0.0f, NPART_SHAPING ); - set_f( hFdCngDec->msMinBuf_float, FLT_MAX, MSNUMSUBFR * NPART_SHAPING ); - set_f( hFdCngDec->msCurrentMin_float, FLT_MAX, NPART_SHAPING ); - set_f( hFdCngDec->msCurrentMinOut_float, FLT_MAX, NPART_SHAPING ); - set_f( hFdCngDec->msCurrentMinSubWindow_float, FLT_MAX, NPART_SHAPING ); -#endif - set_s( hFdCngDec->msLocalMinFlag, 0, NPART_SHAPING ); - set_s( hFdCngDec->msNewMinFlag, 0, NPART_SHAPING ); -#ifndef IVAS_FLOAT_FIXED - set_f( hFdCngDec->msPsdFirstMoment_float, 0.0f, NPART_SHAPING ); - set_f( hFdCngDec->msPsdSecondMoment_float, 0.0f, NPART_SHAPING ); -#endif + set16_fx( hFdCngDec->msLocalMinFlag, 0, NPART_SHAPING ); + set16_fx( hFdCngDec->msNewMinFlag, 0, NPART_SHAPING ); hFdCngDec->msPeriodogBufPtr = 0; -#ifndef IVAS_FLOAT_FIXED - set_f( hFdCngDec->msPeriodogBuf_float, 0.0f, MSBUFLEN * NPART_SHAPING ); - set_f( hFdCngDec->msLogPeriodog_float, 0.0f, NPART_SHAPING ); - set_f( hFdCngDec->msLogNoiseEst_float, 0.0f, NPART_SHAPING ); - set_f( hFdCngDec->psize_shaping_float, 0.0f, NPART_SHAPING ); -#endif + move16(); hFdCngDec->nFFTpart_shaping = 0; - -#ifndef IVAS_FLOAT_FIXED - set_f( hFdCngDec->hFdCngCom->sidNoiseEstLp_flt, 0.0f, NPART ); - set_f( hFdCngDec->smoothed_psd, 0.0f, L_FRAME16k ); - set_f( hFdCngDec->msPeriodog_ST, 0.0f, NPART_SHAPING ); -#endif + move16(); hFdCngDec->ms_last_inactive_bwidth = NB; + move16(); hFdCngDec->ms_cnt_bw_up = 0; -#ifndef IVAS_FLOAT_FIXED - hFdCngDec->cna_LR_LT = 0.5f; - hFdCngDec->cna_ILD_LT = 0.0f; -#endif + move16(); hFdCngDec->first_cna_noise_updated = 0; + move16(); hFdCngDec->first_cna_noise_update_cnt = 0; + move16(); hFdCngDec->cna_nbands = CNA_INIT_NBANDS; - mvs2s( cna_init_bands, hFdCngDec->cna_band_limits, CNA_INIT_NBANDS + 1 ); - + move16(); + Copy( cna_init_bands, hFdCngDec->cna_band_limits, CNA_INIT_NBANDS + 1 ); -#ifndef IVAS_FLOAT_FIXED - hFdCngDec->cna_act_fact = 1.0f; - hFdCngDec->cna_rescale_fact = 0.0f; -#else hFdCngDec->cna_act_fact_fx = MAX_WORD16; + move16(); hFdCngDec->cna_rescale_fact_fx = 0; -#endif + move16(); hFdCngDec->cna_seed = 5687; -#ifndef IVAS_FLOAT_FIXED - set_zero( hFdCngDec->cna_cm, STEREO_DFT_BAND_MAX ); - set_zero( hFdCngDec->cna_g_state, STEREO_DFT_BAND_MAX ); -#endif + move16(); st->CNG_mode = -1; -#ifndef IVAS_FLOAT_FIXED - mvr2r( st->lsp_old, st->lspCNG, M ); -#endif // #ifndef IVAS_FLOAT_FIXED + move16(); return; } @@ -590,7 +551,7 @@ void configureFdCngDec_ivas_fx( hsCom->startBand = 2; move16(); - hsCom->stopBand = add( hsCom->FdCngSetup.sidPartitions[hsCom->FdCngSetup.numPartitions - 1], 1 ); + hsCom->stopBand = add( hsCom->FdCngSetup.sidPartitions[sub( hsCom->FdCngSetup.numPartitions, 1 )], 1 ); #ifndef IVAS_FLOAT_FIXED /* remove floating point dependency */ initPartitions_flt( hsCom->FdCngSetup.sidPartitions, hsCom->FdCngSetup.numPartitions, hsCom->startBand, hsCom->stopBand, hsCom->part, &hsCom->npart, hsCom->midband, hsCom->psize_flt, hsCom->psize_inv_flt, 0 ); @@ -616,11 +577,12 @@ void configureFdCngDec_ivas_fx( hsCom->nCLDFBpart = sub( hsCom->npart, hsCom->nFFTpart ); FOR( j = 0; j < hsCom->nCLDFBpart; j++ ) { - hsCom->CLDFBpart[j] = sub( hsCom->part[j + hsCom->nFFTpart], sub( hsCom->stopFFTbin, hsCom->startBand ) ); + hsCom->CLDFBpart[j] = sub( hsCom->part[add( j, hsCom->nFFTpart )], sub( hsCom->stopFFTbin, hsCom->startBand ) ); #ifndef IVAS_FLOAT_FIXED hsCom->CLDFBpsize_inv_flt[j] = hsCom->psize_inv_flt[j + hsCom->nFFTpart]; // TODO remove floating point dependency #endif - hsCom->CLDFBpsize_inv[j] = hsCom->psize_inv[j + hsCom->nFFTpart]; + move16(); + hsCom->CLDFBpsize_inv[j] = hsCom->psize_inv[add( j, hsCom->nFFTpart )]; move16(); } @@ -651,12 +613,6 @@ void configureFdCngDec_ivas_fx( hsCom->olapWinAna_fx = olapWinAna512_fx; hsCom->fftSineTab_fx = NULL; hsCom->olapWinSyn_fx = olapWinSyn256_fx; -#ifndef IVAS_FLOAT_FIXED - /* TODO: remove floating point dependency */ - hsCom->fftSineTab_flt = NULL; - hsCom->olapWinAna_flt = olapWinAna512; - hsCom->olapWinSyn_flt = olapWinSyn256; -#endif hsCom->fftlenShift = 8; move16(); hsCom->fftlenFac = 32767 /*1.0 Q15*/; @@ -666,12 +622,6 @@ void configureFdCngDec_ivas_fx( hsCom->olapWinAna_fx = olapWinAna640_fx; hsCom->fftSineTab_fx = fftSineTab640_fx; hsCom->olapWinSyn_fx = olapWinSyn320_fx; -#ifndef IVAS_FLOAT_FIXED - /* remove floating point dependency */ - hsCom->fftSineTab_flt = fftSineTab640; - hsCom->olapWinAna_flt = olapWinAna640; - hsCom->olapWinSyn_flt = olapWinSyn320; -#endif hsCom->fftlenShift = 9; move16(); hsCom->fftlenFac = 20480 /*0.625 Q15*/; @@ -1397,8 +1347,21 @@ void FdCng_decodeSID_ivas_fx( HANDLE_FD_CNG_COM hFdCngCom; Word32 *invTrfMatrix_fx; Word32 tmpRAM_fx[FDCNG_VQ_MAX_LEN][FDCNG_VQ_DCT_MAXTRUNC]; + Word16 tmp16; + + IF( st->element_mode == EVS_MONO ) + { + tmp16 = GAIN_Q_OFFSET_EVS_FX_Q0; + move16(); + } + ELSE + { + tmp16 = GAIN_Q_OFFSET_IVAS_FX_Q0; + move16(); + } - const Word16 gain_q_offset = (Word16) ( ( st->element_mode == EVS_MONO ) ? GAIN_Q_OFFSET_EVS : GAIN_Q_OFFSET_IVAS ); // Q0 + const Word16 gain_q_offset = tmp16; /* Q0 */ + move16(); invTrfMatrix_fx = (Word32 *) tmpRAM_fx; @@ -1408,24 +1371,26 @@ void FdCng_decodeSID_ivas_fx( N = hFdCngCom->npart; gain = 0; - hFdCngCom->sid_frame_counter++; + move32(); + hFdCngCom->sid_frame_counter = add( hFdCngCom->sid_frame_counter, 1 ); /* Read bitstream */ - for ( i = 0; i < FD_CNG_stages_37bits; i++ ) + FOR( i = 0; i < FD_CNG_stages_37bits; i++ ) { - indices[i] = get_next_indice( st, bits_37bits[i] ); + indices[i] = get_next_indice_fx( st, bits_37bits[i] ); + move16(); } - index = get_next_indice( st, 7 ); + index = get_next_indice_fx( st, 7 ); /* MSVQ decoder */ - if ( st->element_mode != EVS_MONO ) + IF( st->element_mode != EVS_MONO ) { - create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, sizeof( tmpRAM_fx ) / ( sizeof( Word32 ) ) ); + create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, FDCNG_VQ_MAX_LEN * FDCNG_VQ_DCT_MAXTRUNC ); msvq_dec_fx( ivas_cdk_37bits_fx, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 1, invTrfMatrix_fx, v, NULL, 7 ); } - else + ELSE { /* Legacy EVS_MONO MSVQ tables */ msvq_dec_fx( cdk_37bits, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 0, NULL, v, NULL, 7 ); } @@ -1433,42 +1398,51 @@ void FdCng_decodeSID_ivas_fx( /* Decode gain */ // gain = ((float)index - gain_q_offset) / 1.5f; - gain = L_mult0( ( index - gain_q_offset ), 21845 ); // Q15 + gain = L_mult0( sub( index, gain_q_offset ), 21845 ); // Q15 /* Apply gain and undo log */ Word16 res_exp[NPART]; Word16 max_res_exp = 0; - for ( i = 0; i < N; i++ ) + move16(); + FOR( i = 0; i < N; i++ ) { // sidNoiseEst_flt[i] = (float)pow(10.f, (v[i] + gain) / 10.f); sidNoiseEst[i] = BASOP_util_Pow2( Mpy_32_32( L_add( v[i], gain ), LOG_10_BASE_2_BY_10_Q31 ), Q16, &res_exp[i] ); - if ( max_res_exp < res_exp[i] ) + move32(); + IF( LT_16( max_res_exp, res_exp[i] ) ) { max_res_exp = res_exp[i]; + move16(); } } - for ( i = 0; i < N; i++ ) + FOR( i = 0; i < N; i++ ) { - sidNoiseEst[i] = L_shr( sidNoiseEst[i], max_res_exp - res_exp[i] ); + sidNoiseEst[i] = L_shr( sidNoiseEst[i], sub( max_res_exp, res_exp[i] ) ); + move32(); } hFdCngCom->sidNoiseEstExp = max_res_exp; + move16(); /* NB last band energy compensation */ - if ( hFdCngCom->CngBandwidth == NB ) + IF( hFdCngCom->CngBandwidth == NB ) { - sidNoiseEst[N - 1] = Mpy_32_16_1( sidNoiseEst[N - 1], NB_LAST_BAND_SCALE ); + sidNoiseEst[sub( N, 1 )] = Mpy_32_16_1( sidNoiseEst[sub( N, 1 )], NB_LAST_BAND_SCALE ); + move32(); } - if ( hFdCngCom->CngBandwidth == SWB && hFdCngCom->CngBitrate <= ACELP_13k20 ) + test(); + IF( EQ_16( hFdCngCom->CngBandwidth, SWB ) && LE_32( hFdCngCom->CngBitrate, ACELP_13k20 ) ) { - sidNoiseEst[N - 1] = Mpy_32_16_1( sidNoiseEst[N - 1], SWB_13k2_LAST_BAND_SCALE ); + sidNoiseEst[sub( N, 1 )] = Mpy_32_16_1( sidNoiseEst[sub( N, 1 )], SWB_13k2_LAST_BAND_SCALE ); + move32(); } - scalebands( sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, hFdCngCom->stopBand - hFdCngCom->startBand, hFdCngCom->cngNoiseLevel, 1 ); + scalebands( sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), hFdCngCom->cngNoiseLevel, 1 ); hFdCngCom->cngNoiseLevelExp = hFdCngCom->sidNoiseEstExp; + move16(); lpc_from_spectrum( hFdCngCom, hFdCngCom->startBand, hFdCngCom->stopFFTbin, st->preemph_fac ); @@ -2064,7 +2038,7 @@ void generate_masking_noise_ivas_fx( } } - IF( i < SIZE_SCALE_TABLE_CN_AMRWB ) + IF( LT_16( i, SIZE_SCALE_TABLE_CN_AMRWB ) ) { scale_fx = L_deposit_h( scaleTable_cn_only_amrwbio[i][1] ); /* Q30 */ } @@ -2084,7 +2058,7 @@ void generate_masking_noise_ivas_fx( { rand_gauss_fx( &fftBuffer_fx[0], seed, *exp_out ); // Q15 ptr_r_fx = fftBuffer_fx + 2; - Word16 exp1 = 32 - hFdCngCom->cngNoiseLevelExp; + Word16 exp1 = sub( 32, hFdCngCom->cngNoiseLevelExp ); Word32 mpy1 = Sqrt32( Mpy_32_32( scale_fx, *ptr_level_fx ), &exp1 ); // Q = noise_exp-1 mpy1 = L_shl( mpy1, exp1 ); // Q31 fftBuffer_fx[0] = Mpy_32_32( fftBuffer_fx[0], mpy1 ); /* DC component in FFT */ // Q = Q15 @@ -2094,15 +2068,15 @@ void generate_masking_noise_ivas_fx( { fftBuffer_fx[0] = 0; move32(); - set_l( fftBuffer_fx + 2, 0, 2 * ( startBand - 1 ) ); - ptr_r_fx = fftBuffer_fx + 2 * startBand; + set32_fx( fftBuffer_fx + 2, 0, shl( sub( startBand, 1 ), 1 ) ); + ptr_r_fx = fftBuffer_fx + shl( startBand, 1 ); } ptr_i_fx = ptr_r_fx + 1; FOR( ; ptr_level_fx < cngNoiseLevel_fx + hFdCngCom->stopFFTbin - startBand; ptr_level_fx++ ) { /* Real part in FFT bins */ rand_gauss_fx( ptr_r_fx, seed, *exp_out ); // Q15 - Word16 exp2 = 32 - hFdCngCom->cngNoiseLevelExp; + Word16 exp2 = sub( 32, hFdCngCom->cngNoiseLevelExp ); Word32 mpy2 = Sqrt32( L_shr( Mpy_32_32( scale_fx, *ptr_level_fx ), 1 ), &exp2 ); // Q = noise_exp-1 ( *ptr_r_fx ) = L_shl( Mpy_32_32( *ptr_r_fx, mpy2 ), exp2 ); // Q = Q15 ptr_r_fx += 2; @@ -2114,7 +2088,7 @@ void generate_masking_noise_ivas_fx( } /* Remaining FFT bins are set to zero */ - set_l( fftBuffer_fx + 2 * hFdCngCom->stopFFTbin, 0, hFdCngCom->fftlen - 2 * hFdCngCom->stopFFTbin ); + set32_fx( fftBuffer_fx + shl( hFdCngCom->stopFFTbin, 1 ), 0, sub( hFdCngCom->fftlen, shl( hFdCngCom->stopFFTbin, 1 ) ) ); /* Nyquist frequency is discarded */ fftBuffer_fx[1] = 0; move32(); @@ -2124,7 +2098,7 @@ void generate_masking_noise_ivas_fx( /* very low level case - update random seeds and reset FFT buffer; don't fully skip SynthesisSTFT_flt(), because of the buffer updates done there... */ generate_masking_noise_update_seed_fx( hFdCngCom ); - set_l( fftBuffer_fx, 0, hFdCngCom->fftlen ); + set32_fx( fftBuffer_fx, 0, hFdCngCom->fftlen ); } /* Perform STFT synthesis */ @@ -2141,11 +2115,11 @@ void generate_masking_noise_ivas_fx( /* Add some comfort noise on top of decoded signal */ IF( return_noise ) { - mvl2l( maskingNoise_fx, timeDomainBuffer, min( hFdCngCom->frameSize, length ) ); + Copy32( maskingNoise_fx, timeDomainBuffer, s_min( hFdCngCom->frameSize, length ) ); } ELSE { - v_add_fixed( maskingNoise_fx, timeDomainBuffer, timeDomainBuffer, min( hFdCngCom->frameSize, length ), 0 ); + v_add_fixed( maskingNoise_fx, timeDomainBuffer, timeDomainBuffer, s_min( hFdCngCom->frameSize, length ), 0 ); } return; @@ -2434,156 +2408,152 @@ void generate_stereo_masking_noise_fx( IF( st->idchan == 0 ) { hFdCngCom = st->hFdCngDec->hFdCngCom; - Copy_Scale_sig_16_32( hStereoCng->olapBufferSynth22_fx, Ns_fx, hFdCngCom->frameSize / 2, Q6 - st->Q_syn ); - Copy32( hFdCngCom->olapBufferSynth2_fx, Np_fx, hFdCngCom->frameSize / 2 ); + Copy_Scale_sig_16_32( hStereoCng->olapBufferSynth22_fx, Ns_fx, shr( hFdCngCom->frameSize, 1 ), sub( Q6, st->Q_syn ) ); + Copy32( hFdCngCom->olapBufferSynth2_fx, Np_fx, shr( hFdCngCom->frameSize, 1 ) ); - set_l( &Np_fx[hFdCngCom->frameSize / 2], 0, hFdCngCom->frameSize / 2 ); - set_l( &Ns_fx[hFdCngCom->frameSize / 2], 0, hFdCngCom->frameSize / 2 ); + set32_fx( &Np_fx[shr( hFdCngCom->frameSize, 1 )], 0, shr( hFdCngCom->frameSize, 1 ) ); + set32_fx( &Ns_fx[shr( hFdCngCom->frameSize, 1 )], 0, shr( hFdCngCom->frameSize, 1 ) ); IF( !fadeOut ) { - // generate_masking_noise(N1, hFdCngCom, hFdCngCom->frameSize, 0, 1, 0, st->element_mode, hStereoCng, nchan_out); - Copy_Scale_sig_16_32( hStereoCng->olapBufferSynth22_fx, hStereoCng->olapBufferSynth22_32fx, hFdCngCom->fftlen, -( st->Q_syn - 15 ) ); + Copy_Scale_sig_16_32( hStereoCng->olapBufferSynth22_fx, hStereoCng->olapBufferSynth22_32fx, hFdCngCom->fftlen, sub( Q15, st->Q_syn ) ); generate_masking_noise_ivas_fx( N1_fx, &N1_fx_exp, hFdCngCom, hFdCngCom->frameSize, 0, 1, 0, st->element_mode, hStereoCng, nchan_out ); // N1_fx Q6 /* Generate masking noise for secondary channel */ IF( flag_sec_CNA ) { - // generate_masking_noise(N2, hFdCngCom, hFdCngCom->frameSize, 0, 1, 1, st->element_mode, hStereoCng, nchan_out); generate_masking_noise_ivas_fx( N2_fx, &N2_fx_exp, hFdCngCom, hFdCngCom->frameSize, 0, 1, 1, st->element_mode, hStereoCng, nchan_out ); // N2_fx Q6 - // gamma = hStereoCng->c_PS_LT * hStereoCng->c_PS_LT; gamma_fx = L_shr( Mpy_32_32( hStereoCng->c_PS_LT_fx, hStereoCng->c_PS_LT_fx ), 1 ); - // scale = 1.0f; scale_fx = ONE_IN_Q30; - // if (gamma < 0.9f) - IF( gamma_fx < 966367642 ) + move32(); + IF( LT_32( gamma_fx, 966367642 /* 0.9 in Q30 */ ) ) { - // gamma = gamma / (1 - gamma); - // gamma = (float)sqrt(gamma + 1) - (float)sqrt(gamma); - // scale = 1.0f / (float)sqrt(1 + gamma * gamma); Word16 exp_gamma = 0; + move16(); Word16 divisor1 = Inv16( (Word16) L_shr( L_sub( ONE_IN_Q30, gamma_fx ), Q15 ), &exp_gamma ); // Q15-exp_gamma gamma_fx = L_shl( Mpy_32_16_1( gamma_fx, divisor1 ), exp_gamma ); // Q30 Word16 exp_gamma1 = Q1, exp_gamma2 = Q1, exp_gamma3 = Q1; + move16(); + move16(); + move16(); gamma_fx = Sqrt32( L_add( gamma_fx, ONE_IN_Q30 ), &exp_gamma1 ); - // gamma_fx = L_shl( gamma_fx, exp_gamma1 ); Word32 temp = Sqrt32( gamma_fx, &exp_gamma2 ); // Q31-exp_gamma1 - gamma_fx = L_sub( gamma_fx, L_shl( temp, exp_gamma2 - exp_gamma1 ) ); // Q31-exp_gamma1 - gamma_fx = L_shl( gamma_fx, exp_gamma1 - Q1 ); // Q30 + gamma_fx = L_sub( gamma_fx, L_shl( temp, sub( exp_gamma2, exp_gamma1 ) ) ); // Q31-exp_gamma1 + gamma_fx = L_shl( gamma_fx, sub( exp_gamma1, Q1 ) ); // Q30 Word32 divisor2 = Sqrt32( L_add( ONE_IN_Q30, L_shl( Mpy_32_32( gamma_fx, gamma_fx ), Q1 ) ), &exp_gamma3 ); // Q31 - exp_gamma3 - scale_fx = L_shl( divide3232( ONE_IN_Q30, divisor2 ), Q15 + exp_gamma3 ); // Q30 + scale_fx = L_shl( divide3232( ONE_IN_Q30, divisor2 ), add( Q15, exp_gamma3 ) ); // Q30 } ELSE { gamma_fx = 0; + move16(); } FOR( i = 0; i < 2 * hFdCngCom->frameSize / 4; i++ ) { - // Np[i] += scale * (N1[i] + gamma * N2[i]); - // Ns[i] += scale * sign(hStereoCng->c_PS_LT) * (N1[i] - gamma * N2[i]); Np_fx[i] = L_add( Np_fx[i], Mpy_32_32( scale_fx, L_shl( L_add( N1_fx[i], Mpy_32_32( gamma_fx, L_shl( N2_fx[i], Q1 ) ) ), Q1 ) ) ); // Q6 - Word32 add2 = Mpy_32_32( scale_fx, L_shl( L_sub( N1_fx[i], Mpy_32_32( gamma_fx, L_shl( N2_fx[i], Q1 ) ) ), Q1 ) ); // Q6 + move32(); + Word32 add2 = Mpy_32_32( scale_fx, L_shl( L_sub( N1_fx[i], Mpy_32_32( gamma_fx, L_shl( N2_fx[i], Q1 ) ) ), Q1 ) ); // Q6 if ( hStereoCng->c_PS_LT_fx < 0 ) { add2 = L_negate( add2 ); } Ns_fx[i] = L_add( Ns_fx[i], add2 ); + move32(); } FOR( ; i < hFdCngCom->frameSize; i++ ) { - // Np[i] = scale * (N1[i] + gamma * N2[i]); - // Ns[i] = scale * sign(hStereoCng->c_PS_LT) * (N1[i] - gamma * N2[i]); Np_fx[i] = Mpy_32_32( scale_fx, L_shl( L_add( N1_fx[i], Mpy_32_32( gamma_fx, L_shl( N2_fx[i], Q1 ) ) ), Q1 ) ); // Q6 + move32(); Ns_fx[i] = Mpy_32_32( scale_fx, L_shl( L_sub( N1_fx[i], Mpy_32_32( gamma_fx, L_shl( N2_fx[i], Q1 ) ) ), Q1 ) ); // Q6 + move32(); IF( hStereoCng->c_PS_LT_fx < 0 ) { Ns_fx[i] = L_negate( Ns_fx[i] ); + move32(); } } /* Below code to be converted */ - Word32 scale_fx_tmp = Mpy_32_32( scale_fx, L_shl( hFdCngCom->fftlen / 2, Q22 ) ); // Q21 - // scale_fx = L_shr(scale_fx, Q1) * hFdCngCom->fftlen; - for ( i = 0; i < hFdCngCom->frameSize / 2; i++ ) + Word32 scale_fx_tmp = Mpy_32_32( scale_fx, L_shl( shr( hFdCngCom->fftlen, 1 ), Q22 ) ); // Q21 + FOR( i = 0; i < hFdCngCom->frameSize / 2; i++ ) { - // hFdCngCom->olapBufferSynth2_flt[i] = scale * (hFdCngCom->olapBufferSynth2_flt[i + 5 * hFdCngCom->frameSize / 4] + gamma * hStereoCng->olapBufferSynth22[i + 5 * hFdCngCom->frameSize / 4]); - // hStereoCng->olapBufferSynth22[i] = sign(hStereoCng->c_PS_LT) * scale * (hFdCngCom->olapBufferSynth2_flt[i + 5 * hFdCngCom->frameSize / 4] - gamma * hStereoCng->olapBufferSynth22[i + 5 * hFdCngCom->frameSize / 4]); hFdCngCom->olapBufferSynth2[i] = (Word16) L_shr( Mpy_32_32( scale_fx_tmp, - L_add( L_shr( hFdCngCom->olapBufferSynth2[i + 5 * hFdCngCom->frameSize / 4], Q15 ), - Mpy_32_16_1( gamma_fx, hStereoCng->olapBufferSynth22_fx[i + 5 * hFdCngCom->frameSize / 4] ) ) ), + L_add( L_shr( hFdCngCom->olapBufferSynth2[add( i, i_mult( 5, shr( hFdCngCom->frameSize, 2 ) ) )], Q15 ), + Mpy_32_16_1( gamma_fx, hStereoCng->olapBufferSynth22_fx[add( i, i_mult( 5, shr( hFdCngCom->frameSize, 2 ) ) )] ) ) ), Q14 ); // Q_olap + move16(); hStereoCng->olapBufferSynth22_fx[i] = (Word16) L_shr( Mpy_32_32( scale_fx_tmp, - L_sub( L_shr( hFdCngCom->olapBufferSynth2[i + 5 * hFdCngCom->frameSize / 4], Q15 ), - Mpy_32_16_1( gamma_fx, hStereoCng->olapBufferSynth22_fx[i + 5 * hFdCngCom->frameSize / 4] ) ) ), + L_sub( L_shr( hFdCngCom->olapBufferSynth2[add( i, i_mult( 5, shr( hFdCngCom->frameSize, 2 ) ) )], Q15 ), + Mpy_32_16_1( gamma_fx, hStereoCng->olapBufferSynth22_fx[add( i, i_mult( 5, shr( hFdCngCom->frameSize, 2 ) ) )] ) ) ), Q14 ); // Q_olap + move16(); } } - else + ELSE { FOR( i = 0; i < hFdCngCom->frameSize / 2; i++ ) { - // Np[i] += N1[i]; Np_fx[i] = L_add( Np_fx[i], N1_fx[i] ); // Q6 + move32(); } - // mvr2r(&N1[hFdCngCom->frameSize / 2], &Np[hFdCngCom->frameSize / 2], hFdCngCom->frameSize / 2); - mvl2l( &N1_fx[hFdCngCom->frameSize / 2], &Np_fx[hFdCngCom->frameSize / 2], hFdCngCom->frameSize / 2 ); - // float scale = (float)(hFdCngCom->fftlen / 2); - scale_fx = L_shl( hFdCngCom->fftlen / 2, Q22 ); // Q21 - for ( i = 0; i < hFdCngCom->frameSize; i++ ) + Copy32( &N1_fx[shr( hFdCngCom->frameSize, 1 )], &Np_fx[shr( hFdCngCom->frameSize, 1 )], shr( hFdCngCom->frameSize, 1 ) ); + scale_fx = L_shl( shr( hFdCngCom->fftlen, 1 ), Q22 ); // Q21 + FOR( i = 0; i < hFdCngCom->frameSize; i++ ) { - // hFdCngCom->olapBufferSynth2_flt[i] = scale * hFdCngCom->olapBufferSynth2_flt[i + 5 * hFdCngCom->frameSize / 4]; - hFdCngCom->olapBufferSynth2[i] = (Word16) L_shr( Mpy_32_16_1( scale_fx, hFdCngCom->olapBufferSynth2[i + 5 * hFdCngCom->frameSize / 4] ), Q6 ); // Q_olap + hFdCngCom->olapBufferSynth2[i] = (Word16) L_shr( Mpy_32_16_1( scale_fx, hFdCngCom->olapBufferSynth2[add( i, i_mult( 5, shr( hFdCngCom->frameSize, 2 ) ) )] ), Q6 ); // Q_olap + move16(); } } - Copy_Scale_sig_32_16( hStereoCng->olapBufferSynth22_32fx, hStereoCng->olapBufferSynth22_fx, hFdCngCom->fftlen, ( st->Q_syn - 15 ) ); + Copy_Scale_sig_32_16( hStereoCng->olapBufferSynth22_32fx, hStereoCng->olapBufferSynth22_fx, hFdCngCom->fftlen, sub( st->Q_syn, 15 ) ); } - else + ELSE { - set_s( hFdCngCom->olapBufferSynth2, 0, hFdCngCom->frameSize / 2 ); - set_s( hStereoCng->olapBufferSynth22_fx, 0, hFdCngCom->frameSize / 2 ); + set16_fx( hFdCngCom->olapBufferSynth2, 0, shr( hFdCngCom->frameSize, 1 ) ); + set16_fx( hStereoCng->olapBufferSynth22_fx, 0, shr( hFdCngCom->frameSize, 1 ) ); } - if ( flag_sec_CNA ) + IF( flag_sec_CNA ) { Copy_Scale_sig_32_16( Ns_fx, hStereoCng->maskingNoiseS_fx, hFdCngCom->frameSize, 0 ); // Q6 hStereoCng->enableSecCNA = 1; + move16(); } - else + ELSE { - set_s( hStereoCng->olapBufferSynth22_fx, 0, hFdCngCom->frameSize ); + set16_fx( hStereoCng->olapBufferSynth22_fx, 0, hFdCngCom->frameSize ); } /* add masking noise */ - // v_add(Np, syn, syn, hFdCngCom->frameSize); - for ( i = 0; i < hFdCngCom->frameSize; i++ ) + FOR( i = 0; i < hFdCngCom->frameSize; i++ ) { - syn[i] = syn[i] + (Word16) L_shr( Np_fx[i], Q16 + Q6 - Q_syn ); // Q_syn + syn[i] = add( syn[i], (Word16) L_shr( Np_fx[i], sub( Q16 + Q6, Q_syn ) ) ); // Q_syn + move16(); } } - else if ( hStereoCng->enableSecCNA ) + ELSE IF( hStereoCng->enableSecCNA ) { Word16 SP_ratio_fx = extract_h( hStereoTD->SP_ratio_LT_fx ); /* Use long-term SP ratio based on L/R synthesis */ Word16 prevSP_ratio_fx = hStereoTD->prevSP_ratio_fx; /* Use long-term SP ratio based on L/R synthesis */ + move16(); /* scale and add masking noise */ - for ( i = 0; i < *hStereoCng->frameSize / 4; i++ ) + FOR( i = 0; i < *hStereoCng->frameSize / 4; i++ ) { - // Word16 scale_fx_tmp = idiv1616( add( imult1616( prevSP_ratio_fx, sub( shr( *hStereoCng->frameSize, 2 ), i ) ), imult1616( SP_ratio_fx, i ) ), shr( *hStereoCng->frameSize, 2 ) ); // Q15 Word16 s; Word16 scale_fx_tmp = BASOP_Util_Divide3216_Scale( L_add( L_mult0( prevSP_ratio_fx, sub( shr( *hStereoCng->frameSize, 2 ), i ) ), L_mult0( SP_ratio_fx, i ) ), shr( *hStereoCng->frameSize, 2 ), &s ); // Q15 scale_fx_tmp = shl( scale_fx_tmp, s ); - // syn[i] += scale * hStereoCng->maskingNoiseS[i]; - syn[i] = add( syn[i], mult( scale_fx_tmp, shr( hStereoCng->maskingNoiseS_fx[i], Q6 - Q_syn ) ) ); + syn[i] = add( syn[i], mult( scale_fx_tmp, shr( hStereoCng->maskingNoiseS_fx[i], sub( Q6, Q_syn ) ) ) ); + move16(); } - for ( ; i < *hStereoCng->frameSize / 2; i++ ) + FOR( ; i < *hStereoCng->frameSize / 2; i++ ) { - // syn[i] += SP_ratio * hStereoCng->maskingNoiseS[i]; - syn[i] = add( syn[i], mult( SP_ratio_fx, shr( hStereoCng->maskingNoiseS_fx[i], Q6 - Q_syn ) ) ); + syn[i] = add( syn[i], mult( SP_ratio_fx, shr( hStereoCng->maskingNoiseS_fx[i], sub( Q6, Q_syn ) ) ) ); + move16(); } - for ( ; i < *hStereoCng->frameSize; i++ ) + FOR( ; i < *hStereoCng->frameSize; i++ ) { - // syn[i] += SP_ratio * hStereoCng->maskingNoiseS[i]; - syn[i] = add( syn[i], mult( SP_ratio_fx, shr( hStereoCng->maskingNoiseS_fx[i], Q6 - Q_syn ) ) ); + syn[i] = add( syn[i], mult( SP_ratio_fx, shr( hStereoCng->maskingNoiseS_fx[i], sub( Q6, Q_syn ) ) ) ); + move16(); } hStereoTD->prevSP_ratio_fx = extract_h( hStereoTD->SP_ratio_LT_fx ); } @@ -2753,7 +2723,7 @@ void generate_masking_noise_lb_dirac_fx( GE_32( hFdCngCom->CngBitrate, scaleTable_cn_dirac[i].bitrateFrom ) && LT_32( hFdCngCom->CngBitrate, scaleTable_cn_dirac[i].bitrateTo ) ) { - break; + BREAK; } } @@ -2761,8 +2731,8 @@ void generate_masking_noise_lb_dirac_fx( Word16 div1 = BASOP_Util_Divide1616_Scale( negate( scaleTable_cn_dirac[i].scale_ivas ), shl( 10, Q11 ), &exp ); exp = add( exp, sub( sub( 15, 13 ), sub( 15, 11 ) ) ); Word32 scale_temp = BASOP_util_Pow2( Mpy_32_16_1( LOG_10_BASE_2, div1 ), add( exp, 2 ), &exp ); - scale_temp = L_sub( scale_temp, L_shl( 1, Q31 - exp ) ); - scale = L_shl( scale_temp, exp - Q1 ); // Q30 + scale_temp = L_sub( scale_temp, L_shl( 1, sub( Q31, exp ) ) ); + scale = L_shl( scale_temp, sub( exp, Q1 ) ); // Q30 scale = Mpy_32_32( scale, hFdCngCom->likelihood_noisy_speech_32fx ); // Q30 } @@ -2770,7 +2740,6 @@ void generate_masking_noise_lb_dirac_fx( /* LB CLDFB - CNA from STFT: CNA applied only in channel 0*/ test(); - test(); IF( cna_flag && tdBuffer != NULL ) { WHILE( GT_16( n_samples_out, 0 ) ) @@ -2788,21 +2757,23 @@ void generate_masking_noise_lb_dirac_fx( rand_gauss_fx( &fftBuffer[0], seed, exp_out ); ptr_r = fftBuffer + 2; - Word16 exp2 = 31 - hFdCngCom->cngNoiseLevelExp; + Word16 exp2 = sub( 31, hFdCngCom->cngNoiseLevelExp ); Word32 sqr = Sqrt32( L_shr( Mpy_32_32( scale, *ptr_level ), 1 ), &exp2 ); /* DC component in FFT */ sqr = L_shl( sqr, exp2 ); fftBuffer[0] = Mpy_32_32( fftBuffer[0], sqr ); /* DC component in FFT */ + move32(); ptr_level++; } ELSE { fftBuffer[0] = 0; + move32(); set32_fx( fftBuffer + 2, 0, shl( sub( hFdCngCom->startBand, 1 ), 1 ) ); ptr_r = fftBuffer + shl( hFdCngCom->startBand, 1 ); } ptr_i = ptr_r + 1; - FOR( ; ptr_level < cngNoiseLevel + hFdCngCom->stopFFTbin - hFdCngCom->startBand; ptr_level++ ) + FOR( ; ptr_level < cngNoiseLevel + sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ); ptr_level++ ) { rand_gauss_fx( ptr_r, seed, exp_out ); Word16 exp2 = sub( 31, hFdCngCom->cngNoiseLevelExp ); @@ -2819,6 +2790,7 @@ void generate_masking_noise_lb_dirac_fx( set32_fx( fftBuffer + shl( hFdCngCom->stopFFTbin, 1 ), 0, sub( hFdCngCom->fftlen, shl( hFdCngCom->stopFFTbin, 1 ) ) ); /* Nyquist frequency is discarded */ fftBuffer[1] = 0; + move32(); /* Perform STFT synthesis */ SynthesisSTFT_dirac_fx( fftBuffer, tdBuffer + n_samples_start, hFdCngCom->olapBufferSynth2_fx, hFdCngCom->olapWinSyn_fx, n_samples_out_loop, hFdCngCom ); @@ -3004,22 +2976,23 @@ void generate_masking_noise_dirac_ivas_fx( IF( cna_flag && tdBuffer_fx != NULL ) { *q_cldfb = q_input; + move16(); IF( scale_fx != 0 ) { /* LF CLDFB*/ - cldfbAnalysis_ts_fx_fixed_q( &( tdBuffer_fx[hFdCngCom->numCoreBands * slot_index] ), Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, hFdCngCom->numCoreBands, h_cldfb, q_cldfb ); + cldfbAnalysis_ts_fx_fixed_q( &( tdBuffer_fx[L_mult0( hFdCngCom->numCoreBands, slot_index )] ), Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, hFdCngCom->numCoreBands, h_cldfb, q_cldfb ); } ELSE { /* LB ana CLDFB*/ - cldfbAnalysis_ts_fx_fixed_q( &( tdBuffer_fx[hFdCngCom->numCoreBands * slot_index] ), Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, hFdCngCom->numCoreBands, h_cldfb, q_cldfb ); + cldfbAnalysis_ts_fx_fixed_q( &( tdBuffer_fx[L_mult0( hFdCngCom->numCoreBands, slot_index )] ), Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, hFdCngCom->numCoreBands, h_cldfb, q_cldfb ); } } /*HF CLDFB - CNA and/or FD-CNG*/ IF( fd_cng_flag ) { - scale_fx += 2048; // 1 in Q11 + scale_fx = L_add( scale_fx, 2048 ); // 1 in Q11 move16(); } IF( scale_fx != 0 ) @@ -3029,10 +3002,10 @@ void generate_masking_noise_dirac_ivas_fx( q_shift = norm_l( scale_fx ); scale_fx = L_shl( scale_fx, q_shift ); q_scale = add( q_scale, q_shift ); - scale_fx = Mpy_32_32( scale_fx, Mpy_32_16_1( L_mult( h_cldfb->scale, h_cldfb->scale ), CLDFB_SCALING ) ); // Q = q_scale + 2 * Q8 -34 + scale_fx = Mpy_32_32( scale_fx, Mpy_32_16_1( L_mult( h_cldfb->scale, h_cldfb->scale ), CLDFB_SCALING ) ); // Q = q_scale + 2 * Q8 - 34 q_scale = sub( add( q_scale, 2 * Q8 ), 31 ); - ptr_level_fx = hFdCngCom->cngNoiseLevel + hFdCngCom->stopFFTbin - hFdCngCom->startBand; - q_ptr_level = 31 - hFdCngCom->cngNoiseLevelExp; + ptr_level_fx = hFdCngCom->cngNoiseLevel + sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ); + q_ptr_level = sub( 31, hFdCngCom->cngNoiseLevelExp ); move16(); FOR( i = hFdCngCom->numCoreBands; i < hFdCngCom->regularStopBand; i++ ) @@ -3049,9 +3022,11 @@ void generate_masking_noise_dirac_ivas_fx( /* Real part in CLDFB band */ rand_gauss_fx( &Cldfb_RealBuffer_fx[i], seed, *q_cldfb ); Cldfb_RealBuffer_fx[i] = L_shl( Mpy_32_32( Cldfb_RealBuffer_fx[i], num ), exp ); + move32(); /* Imaginary part in CLDFB band */ rand_gauss_fx( &Cldfb_ImagBuffer_fx[i], seed, *q_cldfb ); Cldfb_ImagBuffer_fx[i] = L_shl( Mpy_32_32( Cldfb_ImagBuffer_fx[i], num ), exp ); + move32(); ptr_level_fx++; } @@ -3092,7 +3067,7 @@ void FdCngDecodeMDCTStereoSID_fx( Word32 tmp32, tmp32_arr[NPART]; invTrfMatrix_fx = (Word32 *) tmpRAM_fx; - create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, sizeof( tmpRAM_fx ) / ( sizeof( Word32 ) ) ); // Q31 + create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, FDCNG_VQ_MAX_LEN * FDCNG_VQ_DCT_MAXTRUNC ); // Q31 is_out_ms = 0; move16(); @@ -3182,14 +3157,14 @@ void FdCngDecodeMDCTStereoSID_fx( // Bringing in same exponent FOR( p = 0; p < N; p++ ) { - lr_ptr_fx[ch][p] = L_shl( tmp32_arr[p], ( exp_arr[p] - exp_arr[max_exp_idx] ) ); + lr_ptr_fx[ch][p] = L_shl( tmp32_arr[p], sub( exp_arr[p], exp_arr[max_exp_idx] ) ); move32(); } hFdCngCom->sidNoiseEstExp = exp_arr[max_exp_idx]; move16(); - scalebands( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, hFdCngCom->stopBand - hFdCngCom->startBand, hFdCngCom->cngNoiseLevel, 1 ); + scalebands( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), hFdCngCom->cngNoiseLevel, 1 ); hFdCngCom->cngNoiseLevelExp = hFdCngCom->sidNoiseEstExp; move16(); @@ -3353,8 +3328,8 @@ void FdCngDecodeDiracMDCTStereoSID_fx( Word16 exp_arr[NPART]; Word32 tmp32, tmp32_arr[NPART]; - invTrfMatrix_fx = (Word32 *) tmpRAM_fx; /* dynamically filled */ - create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, sizeof( tmpRAM_fx ) / ( sizeof( Word32 ) ) ); // Q31 + invTrfMatrix_fx = (Word32 *) tmpRAM_fx; /* dynamically filled */ + create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, FDCNG_VQ_MAX_LEN * FDCNG_VQ_DCT_MAXTRUNC ); // Q31 FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { @@ -3410,7 +3385,7 @@ void FdCngDecodeDiracMDCTStereoSID_fx( // Bringing in same exponent FOR( p = 0; p < N; p++ ) { - lr_ptr_fx[ch][p] = L_shl( tmp32_arr[p], ( exp_arr[p] - exp_arr[max_exp_idx] ) ); + lr_ptr_fx[ch][p] = L_shl( tmp32_arr[p], sub( exp_arr[p], exp_arr[max_exp_idx] ) ); move32(); } @@ -3419,18 +3394,18 @@ void FdCngDecodeDiracMDCTStereoSID_fx( /* NB last band energy compensation */ test(); - IF( EQ_16( hFdCngCom->CngBandwidth, NB ) ) + IF( hFdCngCom->CngBandwidth == NB ) { - lr_ptr_fx[ch][N - 1] = Mpy_32_32( lr_ptr_fx[ch][N - 1], NB_LAST_BAND_SCALE_Q31 ); + lr_ptr_fx[ch][sub( N, 1 )] = Mpy_32_32( lr_ptr_fx[ch][sub( N, 1 )], NB_LAST_BAND_SCALE_Q31 ); move32(); } ELSE IF( EQ_16( hFdCngCom->CngBandwidth, SWB ) && LE_32( hFdCngCom->CngBitrate, ACELP_13k20 ) ) { - lr_ptr_fx[ch][N - 1] = Mpy_32_32( lr_ptr_fx[ch][N - 1], SWB_13k2_LAST_BAND_SCALE_Q31 ); + lr_ptr_fx[ch][sub( N, 1 )] = Mpy_32_32( lr_ptr_fx[ch][sub( N, 1 )], SWB_13k2_LAST_BAND_SCALE_Q31 ); move32(); } - scalebands( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, hFdCngCom->stopBand - hFdCngCom->startBand, hFdCngCom->cngNoiseLevel, 1 ); + scalebands( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), hFdCngCom->cngNoiseLevel, 1 ); hFdCngCom->cngNoiseLevelExp = hFdCngCom->sidNoiseEstExp; move16(); @@ -3462,7 +3437,6 @@ void FdCngDecodeDiracMDCTStereoSID_fx( IF( LT_16( exp_diff, 0 ) ) { sts[0]->hFdCngDec->hFdCngCom->sidNoiseEstExp = add( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEstExp, negate( exp_diff ) ); - move16(); } } diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 91022457e..cdbf98f55 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -54,11 +54,11 @@ ivas_error createFdCngDec_fx( HANDLE_FD_CNG_DEC *hFdCngDec ) /* Allocate memory */ hs = (HANDLE_FD_CNG_DEC) count_malloc( sizeof( FD_CNG_DEC ) ); - if ( hs == NULL ) + IF( hs == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for FD CNG DEC structure" ); } - if ( ( error = createFdCngCom( &( hs->hFdCngCom ) ) ) != IVAS_ERR_OK ) + IF( ( error = createFdCngCom( &( hs->hFdCngCom ) ) ) != IVAS_ERR_OK ) { return error; } @@ -81,10 +81,8 @@ void initFdCngDec_ivas_fx( ivas_initFdCngCom_fx( hFdCngDec->hFdCngCom, scale ); set16_fx( hFdCngDec->olapBufferAna, 0, FFTLEN ); hFdCngDec->hFdCngCom->olapBufferAna = hFdCngDec->olapBufferAna; - move16(); set16_fx( hFdCngDec->olapBufferSynth2, 0, FFTLEN ); hFdCngDec->hFdCngCom->olapBufferSynth2 = hFdCngDec->olapBufferSynth2; - move16(); /* Set some counters and flags */ @@ -208,7 +206,9 @@ void initFdCngDec_fx( hFdCngDec->flag_dtx_mode = 0; move16(); hFdCngDec->lp_noise = -167772160l /*-20.f Q23*/; /* format: Q8.24 */ + move32(); hFdCngDec->lp_speech = 209715200l /* 25.f Q23*/; /* format: Q8.24 */ + move32(); /* Initialization of the noise estimation algorithm */ @@ -257,15 +257,19 @@ void initFdCngDec_fx( set16_fx( hFdCngDec->msLogNoiseEst, 0, NPART_SHAPING ); set16_fx( hFdCngDec->psize_shaping, 0, NPART_SHAPING ); - move16(); hFdCngDec->nFFTpart_shaping = 0; + move16(); set32_fx( hFdCngDec->msPeriodog_ST_fx, 0, NPART_SHAPING ); hFdCngDec->msPeriodog_ST_exp = 0; + move16(); hFdCngDec->hFdCngCom->fftBuffer_exp = 0; + move16(); hFdCngDec->hFdCngCom->periodog_exp = 0; + move16(); set32_fx( hFdCngDec->smoothed_psd_fx, 0, L_FRAME16k ); #ifdef IVAS_FLOAT_FIXED hFdCngDec->q_smoothed_psd = Q4; + move16(); #endif #ifdef IVAS_CODE_CNG @@ -325,12 +329,14 @@ void configureFdCngDec_fx( hsCom->CngBandwidth = bwidth; + move16(); IF( EQ_16( hsCom->CngBandwidth, FB ) ) { hsCom->CngBandwidth = SWB; + move16(); } test(); - if ( total_brate != FRAME_NO_DATA && NE_32( total_brate, SID_2k40 ) ) + IF( total_brate != FRAME_NO_DATA && NE_32( total_brate, SID_2k40 ) ) { hsCom->CngBitrate = total_brate; move32(); @@ -339,17 +345,17 @@ void configureFdCngDec_fx( { /* set minimum active CBR bitrate if CngBitrate is uninitialized */ hsCom->CngBitrate = ACELP_7k20; - IF( GT_16( element_mode, EVS_MONO ) ) + move32(); + if ( element_mode > EVS_MONO ) { hsCom->CngBitrate = IVAS_13k2; move32(); } - move32(); } /* FD-CNG config for MDCT-Stereo is always the same (since for > 48 kbps only) */ /* This may need adjustment in the future if 2TC DTX for some mode uses MDCT-Stereo DTX for lower bitrates too */ - IF( EQ_16( element_mode, IVAS_CPE_MDCT ) ) + if ( EQ_16( element_mode, IVAS_CPE_MDCT ) ) { hsCom->CngBitrate = IVAS_48k; move32(); @@ -453,7 +459,7 @@ void configureFdCngDec_fx( hsCom->startBand = 2; move16(); - hsCom->stopBand = add( hsCom->FdCngSetup.sidPartitions[hsCom->FdCngSetup.numPartitions - 1], 1 ); + hsCom->stopBand = add( hsCom->FdCngSetup.sidPartitions[sub( hsCom->FdCngSetup.numPartitions, 1 )], 1 ); initPartitions( hsCom->FdCngSetup.sidPartitions, hsCom->FdCngSetup.numPartitions, hsCom->startBand, hsCom->stopBand, hsCom->part, &hsCom->npart, hsCom->midband, hsCom->psize, hsCom->psize_norm, &hsCom->psize_norm_exp, hsCom->psize_inv, 0 ); @@ -473,9 +479,9 @@ void configureFdCngDec_fx( hsCom->nCLDFBpart = sub( hsCom->npart, hsCom->nFFTpart ); FOR( j = 0; j < hsCom->nCLDFBpart; j++ ) { - hsCom->CLDFBpart[j] = sub( hsCom->part[j + hsCom->nFFTpart], ( hsCom->stopFFTbin - hsCom->startBand ) ); + hsCom->CLDFBpart[j] = sub( hsCom->part[add( j, hsCom->nFFTpart )], sub( hsCom->stopFFTbin, hsCom->startBand ) ); move16(); - hsCom->CLDFBpsize_inv[j] = hsCom->psize_inv[j + hsCom->nFFTpart]; + hsCom->CLDFBpsize_inv[j] = hsCom->psize_inv[add( j, hsCom->nFFTpart )]; move16(); } @@ -593,6 +599,8 @@ Word16 ApplyFdCng_fx( #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; Flag Carry = 0; + move16(); + move16(); #endif #ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT int16_t L_frame, last_L_frame; @@ -623,7 +631,6 @@ Word16 ApplyFdCng_fx( cngNoiseLevel = hFdCngCom->cngNoiseLevel; cngNoiseLevel_exp = &hFdCngCom->cngNoiseLevelExp; move16(); - move16(); nBins = sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ); SWITCH( st->m_frame_type ) @@ -663,9 +670,20 @@ Word16 ApplyFdCng_fx( ( st->element_mode == IVAS_CPE_TD ) ) && ( !st->BER_detect ) ) #else + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); IF( ( concealWholeFrame == 0 ) && - ( *timeDomainInput < MAXVAL_WORD16 ) && ( *timeDomainInput > MINVAL_WORD16 ) && ( *( timeDomainInput + hFdCngCom->frameSize - 1 ) < MAXVAL_WORD16 ) && ( *( timeDomainInput + hFdCngCom->frameSize - 1 ) > MINVAL_WORD16 ) && ( ( ( hFdCngDec->flag_dtx_mode == 0 ) && ( st->VAD != 0 ) ) == 0 ) && ( ( ( st->cng_type == LP_CNG ) && ( hFdCngDec->flag_dtx_mode != 0 ) ) == 0 ) && ( is_music == 0 ) && ( st->BER_detect == 0 ) ) + ( LT_16( *timeDomainInput, MAXVAL_WORD16 ) ) && GT_16( *timeDomainInput, MINVAL_WORD16 ) && ( LT_16( *( timeDomainInput + sub( hFdCngCom->frameSize, 1 ) ), MAXVAL_WORD16 ) ) && GT_16( *( timeDomainInput + sub( hFdCngCom->frameSize, 1 ) ), MINVAL_WORD16 ) && ( ( ( hFdCngDec->flag_dtx_mode == 0 ) && ( st->VAD != 0 ) ) == 0 ) && ( ( ( st->cng_type == LP_CNG ) && ( hFdCngDec->flag_dtx_mode != 0 ) ) == 0 ) && ( is_music == 0 ) && ( st->BER_detect == 0 ) ) #endif { /* Perform noise estimation at the decoder */ @@ -687,7 +705,7 @@ Word16 ApplyFdCng_fx( /* Update CNG levels */ test(); - IF( hFdCngDec->flag_dtx_mode != 0 && st->cng_type == FD_CNG ) + IF( hFdCngDec->flag_dtx_mode != 0 && EQ_16( st->cng_type, FD_CNG ) ) { /* This needs to be done only once per inactive phase */ bandcombinepow( @@ -803,12 +821,14 @@ Word16 ApplyFdCng_fx( { Carry = 0; + move16(); #ifdef BASOP_NOGLOB L_tmp = L_add_co( L_tmp, *( cngNoiseLevel + j ), &Carry, &Overflow ); #else L_tmp = L_add_c( L_tmp, *( cngNoiseLevel + j ) ); #endif Overflow = 0; + move16(); if ( *( cngNoiseLevel + j ) < 0 ) { @@ -860,8 +880,10 @@ Word16 ApplyFdCng_fx( L_tmp = L_add( L_tmp, L_shr( cngNoiseLevel[j], 16 ) ); } L_tmp_exp = add( *cngNoiseLevel_exp, 16 ); + test(); + test(); #ifdef BASOP_NOGLOB - IF( EQ_16( concealWholeFrame, 1 ) && EQ_16( st->nbLostCmpt, 1 ) && ( L_shl_o( L_tmp, L_tmp_exp, &Overflow ) > 21474836 /*0.01f Q31*/ ) ) + IF( EQ_16( concealWholeFrame, 1 ) && EQ_16( st->nbLostCmpt, 1 ) && ( GT_32( L_shl_o( L_tmp, L_tmp_exp, &Overflow ), 21474836 ) /*0.01f Q31*/ ) ) #else IF( EQ_16( concealWholeFrame, 1 ) && EQ_16( st->nbLostCmpt, 1 ) && ( L_shl( L_tmp, L_tmp_exp ) > 21474836 /*0.01f Q31*/ ) ) #endif @@ -943,14 +965,15 @@ Word16 ApplyFdCng_fx( #endif /* Update the shaping parameters */ + test(); IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) ) { - scalebands( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, hFdCngCom->stopFFTbin - hFdCngCom->startBand, hFdCngDec->bandNoiseShape, 1 ); + scalebands( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), hFdCngDec->bandNoiseShape, 1 ); } hFdCngDec->bandNoiseShape_exp = hFdCngDec->msNoiseEst_exp; move16(); /* This sets the new CNG levels until a SID update overwrites it */ - Copy32( hFdCngDec->bandNoiseShape, cngNoiseLevel, hFdCngCom->stopFFTbin - hFdCngCom->startBand ); /* This sets the new CNG levels until a SID update overwrites it */ + Copy32( hFdCngDec->bandNoiseShape, cngNoiseLevel, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ) ); /* This sets the new CNG levels until a SID update overwrites it */ *cngNoiseLevel_exp = hFdCngDec->bandNoiseShape_exp; move16(); #ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT @@ -964,9 +987,11 @@ Word16 ApplyFdCng_fx( { Carry = 0; + move16(); #ifdef BASOP_NOGLOB /* Critical Carry/Overflow */ L_tmp = L_add_co( L_tmp, *( cngNoiseLevel + j ), &Carry, &Overflow ); Overflow = 0; + move16(); if ( *( cngNoiseLevel + j ) < 0 ) { @@ -1029,7 +1054,7 @@ Word16 ApplyFdCng_fx( hFdCngCom->psize_inv, hFdCngDec->partNoiseShape, &hFdCngDec->partNoiseShape_exp ); - IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) ) + if ( EQ_16( st->element_mode, IVAS_CPE_DFT ) ) { #ifdef IVAS_CODE_CNG Copy( hFdCngDec->hFdCngCom->sidNoiseEst, hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART ); @@ -1196,6 +1221,8 @@ Word16 ApplyFdCng_ivas_fx( #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; Flag Carry = 0; + move16(); + move16(); #endif Word16 L_frame, last_L_frame; // Word32 *sidNoiseEst; @@ -1216,13 +1243,11 @@ Word16 ApplyFdCng_ivas_fx( IF( EQ_16( st->element_mode, IVAS_CPE_TD ) ) { hFdCngDec->flag_dtx_mode = hFdCngDec->flag_dtx_mode || st->first_CNG; - test(); move16(); } cngNoiseLevel = hFdCngCom->cngNoiseLevel; cngNoiseLevel_exp = &hFdCngCom->cngNoiseLevelExp; move16(); - move16(); nBins = sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ); SWITCH( st->m_frame_type ) @@ -1251,13 +1276,20 @@ Word16 ApplyFdCng_ivas_fx( test(); test(); test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); IF( EQ_16( concealWholeFrame, 0 ) && ( timeDomainInput == NULL || - ( *timeDomainInput( MINVAL_WORD16 ) && - *( timeDomainInput + hFdCngCom->frameSize - 1 ) < MAXVAL_WORD16 && - *( timeDomainInput + hFdCngCom->frameSize - 1 ) > ( MINVAL_WORD16 ) ) ) && + ( LT_16( *timeDomainInput, MAXVAL_WORD16 ) && GT_16( *timeDomainInput, MINVAL_WORD16 ) && + LT_16( *( timeDomainInput + sub( hFdCngCom->frameSize, 1 ) ), MAXVAL_WORD16 ) && + GT_16( *( timeDomainInput + sub( hFdCngCom->frameSize, 1 ) ), MINVAL_WORD16 ) ) ) && ( ( ( ( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) && hFdCngDec->flag_dtx_mode ) || !st->VAD || ( LT_16( st->ini_frame, 100 ) && st->is_ism_format ) ) && - !( EQ_16( st->cng_type, LP_CNG ) && hFdCngDec->flag_dtx_mode ) && ( EQ_16( is_music, 0 ) ) ) || + !( st->cng_type == LP_CNG && hFdCngDec->flag_dtx_mode ) && ( is_music == 0 ) ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && ( !st->BER_detect ) ) { @@ -1276,7 +1308,7 @@ Word16 ApplyFdCng_ivas_fx( /* Update CNG levels */ test(); - IF( hFdCngDec->flag_dtx_mode != 0 && st->cng_type == FD_CNG ) + IF( hFdCngDec->flag_dtx_mode != 0 && EQ_16( st->cng_type, FD_CNG ) ) { /* This needs to be done only once per inactive phase */ bandcombinepow( @@ -1387,18 +1419,20 @@ Word16 ApplyFdCng_ivas_fx( { Carry = 0; + move16(); #ifdef BASOP_NOGLOB L_tmp = L_add_co( L_tmp, *( cngNoiseLevel + j ), &Carry, &Overflow ); #else L_tmp = L_add_c( L_tmp, *( cngNoiseLevel + j ) ); #endif Overflow = 0; + move16(); - IF( *( cngNoiseLevel + j ) < 0 ) + if ( *( cngNoiseLevel + j ) < 0 ) { L_c = L_msuNs( L_c, 0, 0 ); } - IF( *( cngNoiseLevel + j ) >= 0 ) + if ( *( cngNoiseLevel + j ) >= 0 ) { #ifdef BASOP_NOGLOB L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); @@ -1439,18 +1473,20 @@ Word16 ApplyFdCng_ivas_fx( { Carry = 0; + move16(); #ifdef BASOP_NOGLOB L_tmp = L_add_co( L_tmp, *( cngNoiseLevel + j ), &Carry, &Overflow ); #else L_tmp = L_add_c( L_tmp, *( cngNoiseLevel + j ) ); #endif Overflow = 0; + move16(); - IF( *( cngNoiseLevel + j ) < 0 ) + if ( *( cngNoiseLevel + j ) < 0 ) { L_c = L_msuNs( L_c, 0, 0 ); } - IF( *( cngNoiseLevel + j ) >= 0 ) + if ( *( cngNoiseLevel + j ) >= 0 ) { #ifdef BASOP_NOGLOB L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); @@ -1488,18 +1524,20 @@ Word16 ApplyFdCng_ivas_fx( { Carry = 0; + move16(); #ifdef BASOP_NOGLOB L_tmp = L_add_co( L_tmp, *( cngNoiseLevel + j ), &Carry, &Overflow ); #else L_tmp = L_add_c( L_tmp, *( cngNoiseLevel + j ) ); #endif Overflow = 0; + move16(); - IF( *( cngNoiseLevel + j ) < 0 ) + if ( *( cngNoiseLevel + j ) < 0 ) { L_c = L_msuNs( L_c, 0, 0 ); } - IF( *( cngNoiseLevel + j ) >= 0 ) + if ( *( cngNoiseLevel + j ) >= 0 ) { #ifdef BASOP_NOGLOB L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); @@ -1533,12 +1571,12 @@ Word16 ApplyFdCng_ivas_fx( perform_noise_estimation_dec_ivas_fx( timeDomainInput, Q, powerSpectrum, Q_power_spectrum, hFdCngDec, st->element_mode, st->bwidth, L_frame, last_L_frame, st->last_core_brate, st->VAD ); } } - test(); - test(); + test(); IF( EQ_16( concealWholeFrame, 1 ) && EQ_16( st->nbLostCmpt, 1 ) ) { /* always set psychParameters for MDCT-Stereo ... */ + test(); IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->hTonalMDCTConc != NULL ) { st->hTonalMDCTConc->psychParams = EQ_16( st->core, TCX_20_CORE ) ? &st->hTonalMDCTConc->psychParamsTCX20 : &st->hTonalMDCTConc->psychParamsTCX10; @@ -1549,16 +1587,18 @@ Word16 ApplyFdCng_ivas_fx( move32(); FOR( j = hFdCngCom->startBand; j < hFdCngCom->stopFFTbin; j++ ) { - L_tmp = L_add_sat( L_tmp, L_shl_sat( cngNoiseLevel[j], 31 - *cngNoiseLevel_exp ) ); + L_tmp = L_add_sat( L_tmp, L_shl_sat( cngNoiseLevel[j], sub( 31, *cngNoiseLevel_exp ) ) ); } L_tmp_exp = 0; move16(); #ifdef BASOP_NOGLOB - IF( L_shl_o( L_tmp, L_tmp_exp, &Overflow ) > 21474836 /*0.01f Q31*/ ) + IF( GT_32( L_shl_o( L_tmp, L_tmp_exp, &Overflow ), 21474836 ) /*0.01f Q31*/ ) #else IF( L_shl( L_tmp, L_tmp_exp ) > 21474836 /*0.01f Q31*/ ) #endif { + test(); + test(); IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && NE_16( st->core, ACELP_CORE ) ) { TonalMdctConceal_whiten_noise_shape_ivas_fx( st, L_frame, ON_FIRST_LOST_FRAME ); @@ -1594,14 +1634,15 @@ Word16 ApplyFdCng_ivas_fx( /* Update the shaping parameters */ + test(); IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) ) { - scalebands_fx( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, hFdCngCom->stopFFTbin - hFdCngCom->startBand, hFdCngDec->bandNoiseShape, 1 ); + scalebands_fx( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), hFdCngDec->bandNoiseShape, 1 ); } hFdCngDec->bandNoiseShape_exp = hFdCngDec->msNoiseEst_exp; move16(); /* This sets the new CNG levels until a SID update overwrites it */ - Copy32( hFdCngDec->bandNoiseShape, cngNoiseLevel, hFdCngCom->stopFFTbin - hFdCngCom->startBand ); /* This sets the new CNG levels until a SID update overwrites it */ + Copy32( hFdCngDec->bandNoiseShape, cngNoiseLevel, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ) ); /* This sets the new CNG levels until a SID update overwrites it */ *cngNoiseLevel_exp = hFdCngDec->bandNoiseShape_exp; move16(); @@ -1613,15 +1654,17 @@ Word16 ApplyFdCng_ivas_fx( { Carry = 0; + move16(); #ifdef BASOP_NOGLOB /* Critical Carry/Overflow */ L_tmp = L_add_co( L_tmp, *( cngNoiseLevel + j ), &Carry, &Overflow ); Overflow = 0; + move16(); - IF( *( cngNoiseLevel + j ) < 0 ) + if ( *( cngNoiseLevel + j ) < 0 ) { L_c = L_msuNs_co( L_c, 0, 0, &Carry, &Overflow ); } - IF( *( cngNoiseLevel + j ) >= 0 ) + if ( *( cngNoiseLevel + j ) >= 0 ) { L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); } @@ -1629,11 +1672,11 @@ Word16 ApplyFdCng_ivas_fx( L_tmp = L_add_c( L_tmp, *( cngNoiseLevel + j ) ); Overflow = 0; - IF( *( cngNoiseLevel + j ) < 0 ) + if ( *( cngNoiseLevel + j ) < 0 ) { L_c = L_msuNs( L_c, 0, 0 ); } - IF( *( cngNoiseLevel + j ) >= 0 ) + if ( *( cngNoiseLevel + j ) >= 0 ) { L_c = L_macNs( L_c, 0, 0 ); } @@ -1658,7 +1701,6 @@ Word16 ApplyFdCng_ivas_fx( BREAK; } hFdCngCom->inactive_frame_counter = add( hFdCngCom->inactive_frame_counter, 1 ); - move16(); /************************************* * SID_FRAME or ZERO_FRAME at DECODER * @@ -1783,12 +1825,11 @@ Word16 ApplyFdCng_ivas_fx( } ELSE IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) ) { - IF( !( hFdCngCom->msFrCnt_init_counter < hFdCngCom->msFrCnt_init_thresh ) ) + IF( !( LT_16( hFdCngCom->msFrCnt_init_counter, hFdCngCom->msFrCnt_init_thresh ) ) ) { // sidNoiseEst = hFdCngCom->sidNoiseEstLp; s2 = negate( sub( WORD32_BITS, 1 ) ); - move16(); /* Shape the SID noise levels in each FFT bin */ j = 0; move16(); @@ -2221,7 +2262,7 @@ void perform_noise_estimation_dec_fx( len = sub( stopFFTbin, startBand ); - s = getScaleFactor32( &fftBuffer[2 * startBand], 2 * len ); + s = getScaleFactor32( &fftBuffer[shl( startBand, 1 )], shl( len, 1 ) ); s = sub( s, 1 ); ptr_per = periodog; @@ -2232,6 +2273,7 @@ void perform_noise_estimation_dec_fx( tmp = L_mult( tmp_r, tmp_r ); *ptr_per = tmp; + move32(); ptr_per++; ptr_r = fftBuffer + 2; @@ -2250,6 +2292,7 @@ void perform_noise_estimation_dec_fx( tmp = L_mac( L_mult( tmp_r, tmp_r ), tmp_i, tmp_i ); *ptr_per = tmp; + move32(); ptr_r += 2; ptr_i += 2; @@ -2289,6 +2332,7 @@ void perform_noise_estimation_dec_fx( FOR( i = 0; i < len; i++ ) { hFdCngDec->hFdCngCom->periodog[i] = Mpy_32_16_1( hFdCngDec->hFdCngCom->periodog[i], fac ); + move32(); } hFdCngDec->hFdCngCom->periodog_exp = add( hFdCngDec->hFdCngCom->periodog_exp, sub( 2, s ) ); #endif @@ -2400,24 +2444,29 @@ void perform_noise_estimation_dec_ivas_fx( move16(); /* Perform STFT analysis */ + test(); IF( !( EQ_16( element_mode, IVAS_CPE_MDCT ) && power_spectrum != NULL ) ) { /* Perform STFT analysis */ AnalysisSTFT_fx( timeDomainInput, Q, fftBuffer, &fftBuffer_exp, hFdCngDec->hFdCngCom ); } + test(); IF( EQ_16( element_mode, IVAS_CPE_TD ) || EQ_16( element_mode, IVAS_CPE_DFT ) ) { SWITCH( hFdCngDec->hFdCngCom->fftlen ) { case 640: rescale_fac = 20972; // 4/(640 * 640) in Q31 + move32(); BREAK; case 512: rescale_fac = 32768; // 4/(512 * 512) in Q31 + move32(); BREAK; case 320: rescale_fac = 83886; // 4/(320 * 320) in Q31 + move32(); BREAK; default: assert( 0 ); @@ -2427,6 +2476,7 @@ void perform_noise_estimation_dec_ivas_fx( { W_tmp = W_mult0_32_32( fftBuffer[0], fftBuffer[0] ); min_q = 2; + move16(); ( *ptr_per ) = W_extract_l( W_shr( W_tmp, sub( i_mult( sub( 31, fftBuffer_exp ), 2 ), min_q ) ) ); ptr_per++; ptr_r = fftBuffer + 2; @@ -2467,7 +2517,7 @@ void perform_noise_estimation_dec_ivas_fx( min_q = 0; } } - ( *ptr_per ) = W_extract_l( W_shr( W_tmp, ( 31 - fftBuffer_exp ) * 2 - min_q ) ); // Qmin_q + ( *ptr_per ) = W_extract_l( W_shr( W_tmp, sub( shl( sub( 31, fftBuffer_exp ), 1 ), min_q ) ) ); // Qmin_q /* Rescale to get energy/sample: it should be 2*(1/N)*(2/N), parseval relation with 1/N,*2 for nrg computed till Nyquist only, 2/N as windowed samples correspond to half a frame*/ ( *ptr_per ) = Mpy_32_32_r( ( *ptr_per ), rescale_fac ); // Q = min_q @@ -2482,8 +2532,9 @@ void perform_noise_estimation_dec_ivas_fx( hFdCngDec->hFdCngCom->periodog_exp = sub( 31, min_q ); hFdCngDec->hFdCngCom->fftBuffer_exp = fftBuffer_exp; + move16(); - tmp_s = getScaleFactor32( periodog, stopFFTbin - startBand ); + tmp_s = getScaleFactor32( periodog, sub( stopFFTbin, startBand ) ); IF( GT_16( tmp_s, 7 ) ) { tmp_s = sub( tmp_s, 7 ); @@ -2491,6 +2542,7 @@ void perform_noise_estimation_dec_ivas_fx( FOR( p = 0; p < stopFFTbin - startBand; p++ ) { periodog[p] = L_shl( periodog[p], tmp_s ); + move32(); } } @@ -2506,19 +2558,24 @@ void perform_noise_estimation_dec_ivas_fx( temp = L_add( temp, periodog[i] ); } msPeriodog[p] = Mpy_32_16_1( temp, psize_inv[p] ); // Qtemp = Qperiodog + move32(); } hFdCngDec->msPeriodog_exp = hFdCngDec->hFdCngCom->periodog_exp; + move16(); /* compensate for the loss of variance - don't do when first noise update is not completed yet due to risk of msPeriodog[p] < 0 */ IF( hFdCngDec->first_cna_noise_updated ) { i = 0; + move16(); FOR( p = 0; p < npart; p++ ) { /* calculate variance over all bins in power partition */ temp = 0; + move32(); W_tmp = 0; + move64(); FOR( ; i <= part[p]; i++ ) { delta = L_sub( periodog[i], msPeriodog[p] ); @@ -2544,10 +2601,12 @@ void perform_noise_estimation_dec_ivas_fx( L_tmp = L_shr( L_tmp, sub( sub( hFdCngDec->hFdCngCom->periodog_exp, e_temp ), 2 ) ); msPeriodog[p] = L_add( msPeriodog[p], L_tmp ); + move32(); IF( LT_32( msPeriodog[p], 0 ) ) { msPeriodog[p] = 0; + move32(); } } } @@ -2559,11 +2618,14 @@ void perform_noise_estimation_dec_ivas_fx( FOR( p = 0; p < npart; p++ ) { msPeriodog[p] = L_shr( msPeriodog[p], sub( 5, tmp_s ) ); + move32(); } hFdCngDec->msPeriodog_exp = add( hFdCngDec->msPeriodog_exp, sub( 5, tmp_s ) ); } enr_tot = 1; + move32(); enr_tot0 = 1; + move32(); IF( GE_16( hFdCngDec->msNoiseEst_exp, hFdCngDec->msPeriodog_exp ) ) { enr_tot = L_add_sat( L_shr( sum32_fx( msPeriodog, npart ), sub( hFdCngDec->msNoiseEst_exp, hFdCngDec->msPeriodog_exp ) ), 1 ); @@ -2575,33 +2637,41 @@ void perform_noise_estimation_dec_ivas_fx( enr_tot0 = L_add_sat( L_shr( sum32_fx( msNoiseEst, npart ), sub( hFdCngDec->msPeriodog_exp, hFdCngDec->msNoiseEst_exp ) ), 1 ); } + test(); IF( !( NE_16( L_frame, last_L_frame ) || LE_32( last_core_brate, SID_2k40 ) ) ) { IF( GT_16( hFdCngDec->hFdCngCom->periodog_exp, hFdCngDec->msPeriodog_ST_exp ) ) { exp_flag = 1; + move16(); } ELSE { exp_flag = 0; + move16(); } } /* update short-term periodogram on larger partitions */ FOR( p = CNA_ACT_DN_LARGE_PARTITION; p < npart; p++ ) { + test(); IF( NE_16( L_frame, last_L_frame ) || LE_32( last_core_brate, SID_2k40 ) ) { /* core Fs has changed or last frame was SID/NO_DATA -> re-initialize short-term periodogram */ hFdCngDec->msPeriodog_ST_fx[p] = msPeriodog[p]; + move32(); hFdCngDec->msPeriodog_ST_exp = hFdCngDec->hFdCngCom->periodog_exp; + move16(); } ELSE { temp = msPeriodog[p]; + move32(); IF( exp_flag ) { hFdCngDec->msPeriodog_ST_fx[p] = L_shr( hFdCngDec->msPeriodog_ST_fx[p], sub( hFdCngDec->hFdCngCom->periodog_exp, hFdCngDec->msPeriodog_ST_exp ) ); + move32(); } ELSE { @@ -2609,13 +2679,16 @@ void perform_noise_estimation_dec_ivas_fx( } hFdCngDec->msPeriodog_ST_fx[p] = L_add( Mpy_32_16_1( hFdCngDec->msPeriodog_ST_fx[p], ST_PERIODOG_FACT_Q15 ), Mpy_32_16_1( temp, sub( MAX_16, ST_PERIODOG_FACT_Q15 ) ) ); + move32(); } } + test(); IF( !( NE_16( L_frame, last_L_frame ) || LE_32( last_core_brate, SID_2k40 ) ) ) { IF( exp_flag ) { hFdCngDec->msPeriodog_ST_exp = hFdCngDec->hFdCngCom->periodog_exp; + move16(); } } @@ -2630,25 +2703,40 @@ void perform_noise_estimation_dec_ivas_fx( /* [60] 317 230 */ /* [61] 253 */ + test(); + test(); IF( EQ_16( last_L_frame, L_FRAME16k ) && EQ_16( L_frame, L_FRAME ) ) { msNoiseEst[61] = msNoiseEst[58]; + move32(); msNoiseEst[60] = L_min( msNoiseEst[58], msNoiseEst[57] ); + move32(); msNoiseEst[59] = msNoiseEst[57]; + move32(); msNoiseEst[58] = msNoiseEst[56]; + move32(); msNoiseEst[57] = msNoiseEst[56]; + move32(); msNoiseEst[56] = L_min( msNoiseEst[56], msNoiseEst[55] ); + move32(); } ELSE IF( EQ_16( last_L_frame, L_FRAME ) && EQ_16( L_frame, L_FRAME16k ) ) { msNoiseEst[56] = L_min( msNoiseEst[56], msNoiseEst[57] ); + move32(); msNoiseEst[57] = L_min( msNoiseEst[58], msNoiseEst[59] ); + move32(); msNoiseEst[58] = L_min( msNoiseEst[60], msNoiseEst[61] ); + move32(); msNoiseEst[59] = 0; + move32(); msNoiseEst[60] = 0; + move32(); msNoiseEst[61] = 0; + move32(); hFdCngDec->ms_cnt_bw_up = FIRST_CNA_NOISE_UPD_FRAMES; + move16(); } /* Smooth with IIR filter */ @@ -2657,10 +2745,11 @@ void perform_noise_estimation_dec_ivas_fx( IF( !VAD ) { Word16 e = 15; + move16(); /* background noise update with moving average */ IF( NE_16( hFdCngDec->first_cna_noise_update_cnt, 0 ) ) { - alpha = Inv16( hFdCngDec->first_cna_noise_update_cnt + 1, &e ); + alpha = Inv16( add( hFdCngDec->first_cna_noise_update_cnt, 1 ), &e ); IF( LT_16( e, 0 ) ) { alpha = shr( alpha, negate( e ) ); // Q15 @@ -2668,8 +2757,10 @@ void perform_noise_estimation_dec_ivas_fx( FOR( p = 0; p < npart; p++ ) { temp = msPeriodog[p]; + move32(); temp = L_shr( temp, sub( hFdCngDec->msNoiseEst_exp, hFdCngDec->msPeriodog_exp ) ); msNoiseEst[p] = L_add( Mpy_32_16_1( msNoiseEst[p], sub( shl_sat( 1, sub( 15, e ) ), alpha ) ), Mpy_32_16_1( temp, alpha ) ); + move32(); } } ELSE @@ -2677,31 +2768,36 @@ void perform_noise_estimation_dec_ivas_fx( FOR( p = 0; p < npart; p++ ) { msNoiseEst[p] = L_shr( msPeriodog[p], sub( hFdCngDec->msNoiseEst_exp, hFdCngDec->msPeriodog_exp ) ); + move32(); } } /* check, if we reached the required number of first CNA noise update frames */ - IF( hFdCngDec->first_cna_noise_update_cnt < FIRST_CNA_NOISE_UPD_FRAMES - 1 ) + IF( LT_16( hFdCngDec->first_cna_noise_update_cnt, FIRST_CNA_NOISE_UPD_FRAMES - 1 ) ) { hFdCngDec->first_cna_noise_update_cnt++; } ELSE { hFdCngDec->first_cna_noise_updated = 1; + move16(); IF( EQ_16( hFdCngDec->hFdCngCom->msFrCnt_init_counter, 0 ) ) { hFdCngDec->hFdCngCom->msFrCnt_init_counter = 1; + move16(); } } } ELSE { hFdCngDec->first_cna_noise_update_cnt = 0; + move16(); } } ELSE { hFdCngDec->hFdCngCom->msFrCnt_init_counter = 1; + move16(); IF( VAD ) { Word16 scale; @@ -2723,6 +2819,7 @@ void perform_noise_estimation_dec_ivas_fx( wght = lin_interp_fx( enr_ratio, 0, shr( 26214, sub( 15, scale ) ) /*0.8f in Q15*/, shr( 16384, sub( 15, scale ) ) /*0.5f in Q15*/, shr( 31130, sub( 15, scale ) ) /*0.95f in Q15*/, shr( 32767, sub( 15, scale ) ) /*1 in Q15*/ ); Word16 temp_q_msNoiseEst[NPART_SHAPING]; Word16 min_q_msNoiseEst = MAX_16; + move16(); FOR( p = 0; p < NPART_SHAPING; p++ ) { temp_q_msNoiseEst[p] = hFdCngDec->msNoiseEst_exp; @@ -2734,13 +2831,16 @@ void perform_noise_estimation_dec_ivas_fx( IF( LT_32( L_tmp, msNoiseEst[p] ) ) { msNoiseEst[p] = L_add( Mpy_32_16_1( msNoiseEst[p], wght ), Mpy_32_16_1( L_tmp, (Word16) L_sub( shr( MAX_16, sub( 15, scale ) ), wght ) ) ); + move32(); temp_q_msNoiseEst[p] = sub( add( hFdCngDec->msNoiseEst_exp, scale ), 15 ); + move16(); } min_q_msNoiseEst = s_min( temp_q_msNoiseEst[p], min_q_msNoiseEst ); } FOR( p = 0; p < NPART_SHAPING; p++ ) { msNoiseEst[p] = L_shl( msNoiseEst[p], sub( min_q_msNoiseEst, temp_q_msNoiseEst[p] ) ); + move32(); } hFdCngDec->msNoiseEst_exp = min_q_msNoiseEst; move16(); @@ -2754,28 +2854,35 @@ void perform_noise_estimation_dec_ivas_fx( IF( LT_32( hFdCngDec->msPeriodog_ST_fx[p], msNoiseEst[p] ) ) { msNoiseEst[p] = L_add( Mpy_32_16_1( msNoiseEst[p], CNA_ACT_DN_FACT_Q15 ), Mpy_32_16_1( L_tmp, (Word16) L_sub( ONE_IN_Q15, CNA_ACT_DN_FACT_Q15 ) ) ); + move32(); } } } } ELSE { - + test(); IF( GE_16( bwidth, WB ) && EQ_16( hFdCngDec->ms_last_inactive_bwidth, NB ) ) { /* bandwidth increased -> set counter for fast initilization */ hFdCngDec->ms_cnt_bw_up = FIRST_CNA_NOISE_UPD_FRAMES; + move16(); } hFdCngDec->ms_last_inactive_bwidth = bwidth; + move16(); /* update background noise during inactive frames */ ptr_per = msNoiseEst; FOR( p = 0; p < npart; p++ ) { Word16 i_e = 15; + move16(); enr = msPeriodog[p]; + move32(); temp = L_shr( enr, sub( hFdCngDec->msNoiseEst_exp, hFdCngDec->msPeriodog_exp ) ); alpha = 31130; // 0.95f in Q15 + move16(); /* bandwidth increased -> do fast re-initilization */ + test(); IF( GT_16( hFdCngDec->ms_cnt_bw_up, 0 ) && GT_16( p, 55 ) ) { alpha = Inv16( add( hFdCngDec->ms_cnt_bw_up, 1 ), &i_e ); @@ -2788,6 +2895,7 @@ void perform_noise_estimation_dec_ivas_fx( { /* faster downward update for single-bin partitions */ alpha = 26214; // 0.8f in Q15 + move16(); } ELSE IF( GT_32( temp, L_shl( ( *ptr_per ), 1 ) ) ) { @@ -2810,21 +2918,24 @@ void perform_noise_estimation_dec_ivas_fx( Copy32( msNoiseEst, hFdCngDec->msPsd_fx, npart ); hFdCngDec->msPsd_exp_fft = hFdCngDec->msNoiseEst_exp; + move16(); /* Expand partitions into bins of power spectrum */ scalebands_fx( msNoiseEst, part, nFFTpart, hFdCngDec->midband_shaping, nFFTpart, sub( stopFFTbin, startBand ), hFdCngDec->bandNoiseShape, 1 ); hFdCngDec->bandNoiseShape_exp = hFdCngDec->msNoiseEst_exp; + move16(); Copy32( hFdCngDec->bandNoiseShape, &hFdCngDec->smoothed_psd_fx[startBand], sub( stopFFTbin, startBand ) ); hFdCngDec->q_smoothed_psd = sub( Q31, hFdCngDec->bandNoiseShape_exp ); set32_fx( &hFdCngDec->smoothed_psd_fx[stopFFTbin], 0, sub( L_FRAME16k, stopFFTbin ) ); } ELSE { + test(); IF( EQ_16( element_mode, IVAS_CPE_MDCT ) && power_spectrum != NULL ) { /* use power spectrum calculated in the MDCT-domain instead of calculating new power spectrum */ periodog = power_spectrum; - periodog_exp = 31 - Q_power_spectrum; + periodog_exp = sub( 31, Q_power_spectrum ); } ELSE { @@ -2833,6 +2944,7 @@ void perform_noise_estimation_dec_ivas_fx( { W_tmp = W_mult0_32_32( fftBuffer[0], fftBuffer[0] ); /* DC component */ min_q = 2; + move16(); ( *ptr_per ) = W_extract_l( W_shr( W_tmp, sub( i_mult( sub( 31, fftBuffer_exp ), 2 ), min_q ) ) ); ptr_per++; ptr_r = fftBuffer + 2; @@ -2848,12 +2960,15 @@ void perform_noise_estimation_dec_ivas_fx( { case 640: rescale_fac = 20972; // 4/(640 * 640) in Q31 + move32(); BREAK; case 512: rescale_fac = 32768; // 4/(512 * 512) in Q31 + move32(); BREAK; case 320: rescale_fac = 83886; // 4/(320 * 320) in Q31 + move32(); BREAK; default: assert( 0 ); @@ -2877,23 +2992,29 @@ void perform_noise_estimation_dec_ivas_fx( { reIter--; *reIter = L_shr( *reIter, diff ); + move32(); } IF( GE_16( tmp_q, 0 ) ) { min_q = tmp_q; + move16(); } ELSE IF( LT_16( tmp_q, 0 ) ) { min_q = 0; + move16(); } } ( *ptr_per ) = W_extract_l( W_shr( W_tmp, sub( i_mult( sub( 31, fftBuffer_exp ), 2 ), min_q ) ) ); // Q = min_q + move32(); /* Rescale to get energy/sample: it should be 2*(1/N)*(2/N), parseval relation with 1/N,*2 for nrg computed till Nyquist only, 2/N as windowed samples correspond to half a frame*/ ( *ptr_per ) = Mpy_32_32_r( ( *ptr_per ), rescale_fac ); // Q = min_q + move32(); IF( LT_16( tmp_q, 0 ) ) { ( *ptr_per ) = L_shl( ( *ptr_per ), negate( tmp_q ) ); + move32(); } ptr_r += 2; @@ -2902,6 +3023,7 @@ void perform_noise_estimation_dec_ivas_fx( hFdCngDec->hFdCngCom->periodog_exp = sub( 31, min_q ); hFdCngDec->hFdCngCom->fftBuffer_exp = fftBuffer_exp; + move16(); tmp_s = getScaleFactor32( periodog, L_frame ); IF( GT_16( tmp_s, 3 ) ) @@ -2911,9 +3033,11 @@ void perform_noise_estimation_dec_ivas_fx( FOR( p = 0; p < stopFFTbin - startBand; p++ ) { periodog[p] = L_shl( periodog[p], tmp_s ); + move32(); } } periodog_exp = hFdCngDec->hFdCngCom->periodog_exp; + move16(); } /* Adjust to the desired frequency resolution by averaging over spectral partitions for SID transmission */ @@ -2957,6 +3081,7 @@ void perform_noise_estimation_dec_ivas_fx( FOR( i = 0; i < hFdCngDec->npart_shaping; i++ ) { hFdCngDec->msPsd_fx[i] = (Word32) hFdCngDec->msPsd[i]; + move32(); } hFdCngDec->msPsd_exp_fft = 6 + WORD16_BITS; @@ -3024,12 +3149,12 @@ void FdCng_decodeSID_fx( HANDLE_FD_CNG_COM st, Decoder_State *corest ) /* MSVQ decoder */ #ifdef IVAS_FLOAT_FIXED - if ( corest->element_mode != EVS_MONO ) + IF( corest->element_mode != EVS_MONO ) { - create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, sizeof( tmpRAM_fx ) / ( sizeof( Word32 ) ) ); + create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, FDCNG_VQ_MAX_LEN * FDCNG_VQ_DCT_MAXTRUNC ); msvq_dec_fx( ivas_cdk_37bits_fx, NULL, NULL, stages_37bits, N, maxN_37bits, indices, 1, invTrfMatrix_fx, v, NULL, 7 ); } - else + ELSE #endif { msvq_decoder( @@ -3043,6 +3168,7 @@ void FdCng_decodeSID_fx( HANDLE_FD_CNG_COM st, Decoder_State *corest ) FOR( i = 0; i < N; i++ ) { v[i] = L_deposit_h( v16[i] ); + move32(); } } @@ -3089,18 +3215,19 @@ void FdCng_decodeSID_fx( HANDLE_FD_CNG_COM st, Decoder_State *corest ) /* NB last band energy compensation */ IF( st->CngBandwidth == NB ) { - st->sidNoiseEst[N - 1] = Mpy_32_16_1( st->sidNoiseEst[N - 1], NB_LAST_BAND_SCALE ); + st->sidNoiseEst[sub( N, 1 )] = Mpy_32_16_1( st->sidNoiseEst[sub( N, 1 )], NB_LAST_BAND_SCALE ); move32(); } test(); - if ( st->CngBandwidth == SWB && st->CngBitrate <= ACELP_13k20 ) + IF( EQ_16( st->CngBandwidth, SWB ) && LE_32( st->CngBitrate, ACELP_13k20 ) ) { - st->sidNoiseEst[N - 1] = Mpy_32_16_1( st->sidNoiseEst[N - 1], SWB_13k2_LAST_BAND_SCALE ); + st->sidNoiseEst[sub( N, 1 )] = Mpy_32_16_1( st->sidNoiseEst[sub( N, 1 )], SWB_13k2_LAST_BAND_SCALE ); + move32(); } - scalebands( sidNoiseEst, st->part, st->npart, st->midband, st->nFFTpart, st->stopBand - st->startBand, st->cngNoiseLevel, 1 ); + scalebands( sidNoiseEst, st->part, st->npart, st->midband, st->nFFTpart, sub( st->stopBand, st->startBand ), st->cngNoiseLevel, 1 ); st->cngNoiseLevelExp = st->sidNoiseEstExp; move16(); @@ -3170,16 +3297,17 @@ void noisy_speech_detection_fx( } hFdCngDec->lp_noise = L_add( Mpy_32_16_1( hFdCngDec->lp_noise, 32604 /*0.995 Q15*/ ), L_shr( Mpy_32_16_1( logTotalNoise, 20972 /*0.64 Q15*/ ), 7 ) ); - move32(); } ELSE { Etot = 0; + move32(); Etot_exp = 31; + move16(); FOR( i = 0; i < hFdCngDec->hFdCngCom->frameSize; i++ ) { tmp = L_shr_r( L_mult0( syn[i], syn[i] ), sub( Etot_exp, 31 ) ); - IF( L_sub( maxWord32, tmp ) < Etot ) + IF( LT_32( L_sub( maxWord32, tmp ), Etot ) ) { Etot_exp = add( Etot_exp, 1 ); Etot = L_shr_r( Etot, 1 ); @@ -3215,12 +3343,11 @@ void noisy_speech_detection_fx( } hFdCngDec->lp_speech = L_add( Mpy_32_16_1( hFdCngDec->lp_speech, 32604 /*0.995 Q15*/ ), L_shr( Mpy_32_16_1( logEtot, 20972 /*0.64 Q15*/ ), 7 ) ); - move32(); } tmp = L_sub( hFdCngDec->lp_speech, 377487360l /*45.0 Q23*/ ); - if ( LT_32( hFdCngDec->lp_noise, tmp ) ) + IF( LT_32( hFdCngDec->lp_noise, tmp ) ) { hFdCngDec->lp_noise = tmp; move32(); @@ -3228,7 +3355,7 @@ void noisy_speech_detection_fx( hFdCngDec->hFdCngCom->flag_noisy_speech = 0; move16(); - if ( LT_32( L_sub( hFdCngDec->lp_speech, hFdCngDec->lp_noise ), 234881024l /*28.0 Q23*/ ) ) + IF( LT_32( L_sub( hFdCngDec->lp_speech, hFdCngDec->lp_noise ), 234881024l /*28.0 Q23*/ ) ) { hFdCngDec->hFdCngCom->flag_noisy_speech = 1; move16(); @@ -3270,11 +3397,13 @@ void generate_comfort_noise_dec_fx( HANDLE_FD_CNG_DEC hFdCngDec = st->hFdCngDec; HANDLE_FD_CNG_COM hFdCngCom = hFdCngDec->hFdCngCom; TCX_DEC_HANDLE hTcxDec; + move16(); hTcxDec = st->hTcxDec; /* Warning fix */ s = 0; + move16(); // PMTE(); /*IVAS CODE need to be added */ /* pointer initialization */ @@ -3358,12 +3487,12 @@ void generate_comfort_noise_dec_fx( fftBufferExp = add( shr( cngNoiseLevelExp, 1 ), randGaussExp ); /* If previous frame is active, reset the overlap-add buffer */ - IF( hFdCngCom->frame_type_previous == ACTIVE_FRAME ) + IF( EQ_16( hFdCngCom->frame_type_previous, ACTIVE_FRAME ) ) { set16_fx( hFdCngCom->olapBufferSynth, 0, hFdCngCom->fftlen ); test(); test(); - if ( ( st->last_core_bfi > ACELP_CORE && st->codec_mode == MODE2 ) || st->codec_mode == MODE1 ) + if ( ( st->last_core_bfi > ACELP_CORE && EQ_16( st->codec_mode, MODE2 ) ) || EQ_16( st->codec_mode, MODE1 ) ) { tcx_transition = 1; move16(); @@ -3388,12 +3517,12 @@ void generate_comfort_noise_dec_fx( /*(float)log10( enr + 0.1f ) / (float)log10( 2.0f );*/ Lener = BASOP_Util_Log2( Lener ); Lener = L_add( Lener, L_shl( L_deposit_l( exp ), WORD32_BITS - 1 - LD_DATA_SCALE ) ); /*Q25*/ - if ( st->L_frame == L_FRAME16k ) + if ( EQ_16( st->L_frame, L_FRAME16k ) ) { Lener = L_sub( Lener, 10802114l /*0.3219280949f Q25*/ ); /*log2(320) = 8.3219280949f*/ } /* decrease the energy in case of WB input */ - IF( NE_16( st->bwidth, NB ) ) + IF( st->bwidth != NB ) { IF( EQ_16( st->bwidth, WB ) ) { @@ -3463,7 +3592,7 @@ void generate_comfort_noise_dec_fx( /* Overlap-add when previous frame is active */ test(); - IF( hFdCngCom->frame_type_previous == ACTIVE_FRAME && st->codec_mode == MODE2 ) + IF( EQ_16( hFdCngCom->frame_type_previous, ACTIVE_FRAME ) && EQ_16( st->codec_mode, MODE2 ) ) { Word32 old_exc_ener, gain, noise32; Word16 seed_loc, lpcorder, old_syn, tmp, gain16, N, N2, N4, N8; @@ -3494,13 +3623,14 @@ void generate_comfort_noise_dec_fx( move16(); } tcx_windowing_synthesis_current_frame( timeDomainOutput, st->hTcxCfg->tcx_mdct_window, st->hTcxCfg->tcx_mdct_window_half, st->hTcxCfg->tcx_mdct_window_minimum, st->hTcxCfg->tcx_mdct_window_length, st->hTcxCfg->tcx_mdct_window_half_length, - st->hTcxCfg->tcx_mdct_window_min_length, 0, left_overlap_mode, NULL, NULL, NULL, NULL, NULL, N / 2, shr( sub( abs_s( st->hTcxCfg->tcx_offset ), st->hTcxCfg->tcx_offset ), 1 ), 1, 0, 0 ); + st->hTcxCfg->tcx_mdct_window_min_length, 0, left_overlap_mode, NULL, NULL, NULL, NULL, NULL, shr( N, 1 ), shr( sub( abs_s( st->hTcxCfg->tcx_offset ), st->hTcxCfg->tcx_offset ), 1 ), 1, 0, 0 ); IF( st->hTcxCfg->last_aldo != 0 ) { FOR( i = 0; i < sub( hFdCngCom->frameSize, NS2SA( st->sr_core, N_ZERO_MDCT_NS ) ); i++ ) { timeDomainOutput[i] = add( timeDomainOutput[i], shr_r( st->hHQ_core->old_out_LB_fx[i + NS2SA( st->sr_core, N_ZERO_MDCT_NS )], st->hHQ_core->Q_old_wtda_LB ) ); + move16(); } } ELSE @@ -3510,7 +3640,8 @@ void generate_comfort_noise_dec_fx( FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_length; i++ ) { - timeDomainOutput[i] += shl( hTcxDec->syn_Overl[i], TCX_IMDCT_HEADROOM ); + timeDomainOutput[i] = add( timeDomainOutput[i], shl( hTcxDec->syn_Overl[i], TCX_IMDCT_HEADROOM ) ); + move16(); } } } @@ -3580,6 +3711,7 @@ void generate_comfort_noise_dec_fx( { noise32 = rand_gauss( &seed_loc ); noise[i] = extract_h( noise32 ); + move16(); gain = L_add( gain, L_shr( L_mult( noise[i], noise[i] ), normShiftP2 ) ); } gain = L_shl( Mpy_32_16_1( gain, shl( normFacG, normShiftGM1 ) ), 1 ); @@ -3645,8 +3777,8 @@ void generate_comfort_noise_dec_fx( tmp = mult( noise[i], hFdCngCom->olapWinSyn[i].v.re ); timeDomainOutput[i] = add( timeDomainOutput[i], tmp ); move16(); - tmp = mult( noise[i + N4], hFdCngCom->olapWinSyn[N4 - 1 - i].v.im ); - timeDomainOutput[i + N4] = add( timeDomainOutput[i + N4], tmp ); + tmp = mult( noise[add( i, N4 )], hFdCngCom->olapWinSyn[sub( sub( N4, 1 ), i )].v.im ); + timeDomainOutput[add( i, N4 )] = add( timeDomainOutput[add( i, N4 )], tmp ); move16(); } } @@ -3670,8 +3802,9 @@ void generate_comfort_noise_dec_hf_fx( Word32 *ptr_level; HANDLE_FD_CNG_COM hFdCngCom = st->hFdCngDec->hFdCngCom; - cngNoiseLevel = hFdCngCom->cngNoiseLevel + hFdCngCom->stopFFTbin - hFdCngCom->startBand; + cngNoiseLevel = hFdCngCom->cngNoiseLevel + sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ); cngNoiseLevelExp = hFdCngCom->cngNoiseLevelExp; + move16(); ptr_level = cngNoiseLevel; seed = &( hFdCngCom->seed ); @@ -3684,7 +3817,6 @@ void generate_comfort_noise_dec_hf_fx( { sn = add( sn, 1 ); cngNoiseLevelExp = add( cngNoiseLevelExp, sn ); - move16(); } randGaussExp = CNG_RAND_GAUSS_SHIFT; @@ -3743,7 +3875,7 @@ void generate_comfort_noise_dec_hf_ivas_fx( Word32 *cngNoiseLevel; Word32 tmp1, tmp2; - cngNoiseLevel = hFdCngCom->cngNoiseLevel + hFdCngCom->stopFFTbin - hFdCngCom->startBand; + cngNoiseLevel = hFdCngCom->cngNoiseLevel + sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ); cngNoiseLevelExp = hFdCngCom->cngNoiseLevelExp; move16(); ptr_level = cngNoiseLevel; @@ -3812,9 +3944,7 @@ void generate_comfort_noise_dec_hf_ivas_fx( IF( cng_coh_flag ) { tmp1 = rand_gauss( seed ); - move16(); tmp2 = rand_gauss( seed2 ); - move16(); bufferReal[i][j] = L_add( Mpy_32_16_1( tmp1, c1 ), Mpy_32_16_1( tmp2, c2 ) ); move32(); @@ -3822,9 +3952,7 @@ void generate_comfort_noise_dec_hf_ivas_fx( move32(); tmp1 = rand_gauss( seed ); - move16(); tmp2 = rand_gauss( seed2 ); - move16(); bufferImag[i][j] = L_add( Mpy_32_16_1( tmp1, c1 ), Mpy_32_16_1( tmp2, c2 ) ); move32(); @@ -3897,7 +4025,7 @@ void generate_masking_noise_fx( cngNoiseLevelExp = hFdCngCom->cngNoiseLevelExp; move16(); - IF( core != AMR_WB_CORE ) + IF( NE_16( core, AMR_WB_CORE ) ) { scaleTableSize = 18; move16(); diff --git a/lib_dec/ivas_lfe_dec_fx.c b/lib_dec/ivas_lfe_dec_fx.c index 18bb18224..4d5dd9591 100644 --- a/lib_dec/ivas_lfe_dec_fx.c +++ b/lib_dec/ivas_lfe_dec_fx.c @@ -70,7 +70,14 @@ static void ivas_lfe_dec_delay_adjust_fx( Word32 tmp_buffer[L_FRAME48k]; diff = sub( hLFE->lfe_prior_buf_len, hLFE->pWindow_state->fade_len ); - loop_counter = LT_16( diff, 0 ) ? 0 : diff; + IF( diff < 0 ) + { + loop_counter = 0; + } + ELSE + { + loop_counter = diff; + } move16(); fade_len = hLFE->pWindow_state->fade_len; move16(); @@ -233,7 +240,7 @@ static Word16 ivas_lfe_dec_dequant_fx( move16(); FOR( i = 0; i < 4; i++ ) { - abs_values[iii * 4 + i] = get_next_indice_fx( st0, base2_bit_size ); + abs_values[add( iii * 4 , i )] = get_next_indice_fx( st0, base2_bit_size ); move16(); } } @@ -248,7 +255,7 @@ static Word16 ivas_lfe_dec_dequant_fx( FOR( i = 0; i < 4; i++ ) { - abs_values[iii * 4 + i] = ivas_ari_decode_14bits_bit_ext_1_lfe( st0, &as, hLFE->cum_freq_models[quant_strategy][iii], &extra_bits_read ); + abs_values[add( iii * 4, i )] = ivas_ari_decode_14bits_bit_ext_1_lfe( st0, &as, hLFE->cum_freq_models[quant_strategy][iii], &extra_bits_read ); move16(); } ivas_ari_done_decoding_14bits_ext_1_lfe( st0, extra_bits_read ); @@ -259,7 +266,7 @@ static Word16 ivas_lfe_dec_dequant_fx( { values[i] = shl( abs_values[i], 9 ); // Q9 move16(); - IF( GT_16( sign_bits[i], 0 ) ) + IF( sign_bits[i] > 0 ) { values[i] = shl( sub( negate( abs_values[i] ), 1 ), 9 ); // Q9 move16(); @@ -273,12 +280,12 @@ static Word16 ivas_lfe_dec_dequant_fx( { pOut_buf[2 * i] = Mpy_32_16_1( two_pow_shift_by_4, values[4 * i] ); // Q30 + Q9 >> 15 = Q24 move32(); - pOut_buf[2 * i + 1] = Mpy_32_16_1( two_pow_shift_by_4, values[4 * i + 1] ); // Q30 + Q9 >> 15 = Q24 + pOut_buf[add( 2 * i, 1 )] = Mpy_32_16_1( two_pow_shift_by_4, values[add( 2 * i, 1 )] ); // Q30 + Q9 >> 15 = Q24 move32(); - pOut_buf[2 * i + *num_dct_pass_bins] = Mpy_32_16_1( two_pow_shift_by_4, values[4 * i + 2] ); // Q30 + Q9 >> 15 = Q24 + pOut_buf[add( 2 * i, *num_dct_pass_bins )] = Mpy_32_16_1( two_pow_shift_by_4, values[add( 4 * i, 2 )] ); // Q30 + Q9 >> 15 = Q24 move32(); - pOut_buf[2 * i + *num_dct_pass_bins + 1] = Mpy_32_16_1( two_pow_shift_by_4, values[4 * i + 3] ); // Q30 + Q9 >> 15 = Q24 + pOut_buf[add( add( 2 * i, *num_dct_pass_bins ), 1 )] = Mpy_32_16_1( two_pow_shift_by_4, values[add( 4 * i, 3 )] ); // Q30 + Q9 >> 15 = Q24 move32(); } } @@ -305,6 +312,7 @@ void ivas_lfe_dec_fx( { Word16 num_dct_pass_bins; Word16 i, j, dct_len, q_out = 0; + move16(); Word32 out[L_FRAME48k]; Word32 t_audio[L_FRAME48k]; Word32 lfe_dct[IVAS_LFE_MAX_NUM_DCT_COEFFS]; @@ -314,7 +322,7 @@ void ivas_lfe_dec_fx( num_dct_pass_bins = IVAS_LFE_MAX_NUM_DCT_PASS_BINS; move16(); - IF( EQ_16( bfi, 0 ) ) + IF( bfi == 0 ) { ivas_lfe_dec_dequant_fx( hLFE, st0, lfe_dct, &num_dct_pass_bins ); // Q24 @@ -340,7 +348,7 @@ void ivas_lfe_dec_fx( move16(); FOR( i = 0; i < L_FRAME_1k6; i++ ) { - hLFE->prevsynth_buf_fx[i + LFE_PLC_BUFLEN - L_FRAME_1k6] = output_lfe_ch[j]; + hLFE->prevsynth_buf_fx[sub( add( i, LFE_PLC_BUFLEN ), L_FRAME_1k6 )] = output_lfe_ch[j]; move32(); j = add( j, shr( output_frame, 5 ) ); } @@ -351,8 +359,8 @@ void ivas_lfe_dec_fx( ELSE { /* note: in BFI branch, buffer 't_audio' is in time-domain ('wtda' signal) */ - hLFE->bfi_count++; - + hLFE->bfi_count = add( hLFE->bfi_count, 1 ); + move16(); ivas_lfe_tdplc_fx( hLFE, hLFE->prevsynth_buf_fx, t_audio, output_frame ); ivas_itda_fx( t_audio, out, dct_len ); @@ -375,7 +383,7 @@ void ivas_lfe_dec_fx( } } - IF( GT_16( hLFE->filter_state.order, 0 ) ) + IF( hLFE->filter_state.order > 0 ) { /* NOTE: this block is not getting hit by any stream present in pytest test suite */ /* Low Pass Filter */ @@ -383,7 +391,7 @@ void ivas_lfe_dec_fx( } /* add delay to make overall max(block_offset, 11.5) */ - IF( GT_16( hLFE->lfe_addl_delay, 0 ) ) + IF( hLFE->lfe_addl_delay > 0 ) { delay_signal_fx( output_lfe_ch, output_frame, hLFE->lfe_delay_buf_fx, hLFE->lfe_addl_delay ); } @@ -451,6 +459,7 @@ ivas_error ivas_create_lfe_dec_fx( /* delay calculation */ hLFE->lfe_block_delay_s_fx = add( IVAS_LFE_FADE_S_Q15, ivas_lfe_lpf_delay_Q15[IVAS_FILTER_ORDER_4 - 3] ); + move16(); block_offset_s = BLOCK_OFFSET_S_Q15; move16(); @@ -461,6 +470,7 @@ ivas_error ivas_create_lfe_dec_fx( hLFE->filter_state.order = filt_order; move16(); hLFE->lfe_block_delay_s_fx = add( hLFE->lfe_block_delay_s_fx, low_pass_delay_dec_out ); + move16(); hLFE->lfe_prior_buf_len = NS2SA_fx2( output_Fs, IVAS_LFE_FADE_NS ); move16(); @@ -473,10 +483,13 @@ ivas_error ivas_create_lfe_dec_fx( lfe_addl_delay_s = sub( block_offset_s, hLFE->lfe_block_delay_s_fx ); lfe_addl_delay_s = s_max( 0, lfe_addl_delay_s ); add_delay_sa = (Word16) W_round64_L( W_mult0_32_32( L_shl( binauralization_delay_ns, 1 ), output_fs_fx ) ); + move16(); hLFE->lfe_addl_delay = add( (Word16) L_shr( ( (Word32) lfe_addl_delay_s * (Word32) output_Fs ), 15 ), add_delay_sa ); + move16(); hLFE->lfe_block_delay_s_fx = add( hLFE->lfe_block_delay_s_fx, add( lfe_addl_delay_s, (Word16) ( add_delay_sa / output_Fs ) ) ); + move16(); - IF( GT_16( hLFE->lfe_addl_delay, 0 ) ) + IF( hLFE->lfe_addl_delay > 0 ) { IF( ( hLFE->lfe_delay_buf_fx = (Word32 *) malloc( hLFE->lfe_addl_delay * sizeof( Word32 ) ) ) == NULL ) { diff --git a/lib_dec/ivas_lfe_plc_fx.c b/lib_dec/ivas_lfe_plc_fx.c index 325fc962e..7c1d59d5d 100644 --- a/lib_dec/ivas_lfe_plc_fx.c +++ b/lib_dec/ivas_lfe_plc_fx.c @@ -208,6 +208,7 @@ static Word16 d_lev_dur_fx( { Word16 i, j, l; Word16 flag = 0; + move16(); Word32 buf_fx[TCXLTP_LTP_ORDER]; Word16 rc_q_fx[TCXLTP_LTP_ORDER]; Word32 *rc_fx; /* reflection coefficients 0,...,m-1 */ @@ -305,7 +306,7 @@ static Word16 d_lev_dur_fx( IF( LT_16( rc_q_fx[i - 1], 31 ) ) { - IF( GT_32( abs( rc_fx[i - 1] ), L_shr( 2146302532, sub( 31, rc_q_fx[i - 1] ) ) ) ) // 2146302532 = 0.99945f in Q31 + if ( GT_32( abs( rc_fx[i - 1] ), L_shr( 2146302532, sub( 31, rc_q_fx[i - 1] ) ) ) ) // 2146302532 = 0.99945f in Q31 { flag = 1; /* Test for unstable filter. If unstable keep old A(z) */ move16(); @@ -313,7 +314,7 @@ static Word16 d_lev_dur_fx( } ELSE { - IF( GT_32( abs( L_shr( rc_fx[i - 1], sub( rc_q_fx[i - 1], 31 ) ) ), 2146302532 ) ) // 2146302532 = 0.00045f in Q31 + if ( GT_32( abs( L_shr( rc_fx[i - 1], sub( rc_q_fx[i - 1], 31 ) ) ), 2146302532 ) ) // 2146302532 = 0.00045f in Q31 { flag = 1; /* Test for unstable filter. If unstable keep old A(z) */ move16(); @@ -397,7 +398,7 @@ static Word16 d_lev_dur_fx( err_fx = L_add( err_fx, L_shr( temp1, sub( temp_q1, err_q_fx ) ) ); } - IF( LE_32( err_fx, 0 ) ) + IF( err_fx <= 0 ) { err_fx = 21474836; // 0.01 in Q31 move32(); @@ -437,7 +438,7 @@ static Word16 d_a2rc_fx( FOR( m = 0; m < lpcorder; m++ ) { - ff_fx[m] = -a_fx[m]; + ff_fx[m] = L_negate( a_fx[m] ); move32(); ff_q_fx[m] = a_q_fx[m]; move32(); @@ -460,7 +461,7 @@ static Word16 d_a2rc_fx( return 0; } - refl_fx[m] = -km_fx; + refl_fx[m] = L_negate( km_fx ); move32(); exp1 = norm_l( km_fx ); @@ -470,7 +471,7 @@ static Word16 d_a2rc_fx( denom_fx = L_deposit_l( BASOP_Util_Divide3232_Scale( ONE_IN_Q30, temp1, &temp_q1 ) ); denom_q_fx = sub( 15, temp_q1 ); - FOR( j = 0; j < m / 2; j++ ) + FOR( j = 0; j < shr( m, 1 ); j++ ) { n = sub( sub( m, 1 ), j ); @@ -524,7 +525,7 @@ static Word16 d_a2rc_fx( } } - IF( m & 1 ) + IF( s_and( m, 1 ) ) { exp1 = norm_l( denom_fx ); exp2 = sub( norm_l( ff_fx[j] ), 1 ); @@ -793,7 +794,7 @@ static Word32 find_max_delta_fx( } ELSE { - eps_fx = -abs( eps_fx ); + eps_fx = L_negate( abs( eps_fx ) ); } } ELSE diff --git a/lib_dec/ivas_ls_custom_dec.c b/lib_dec/ivas_ls_custom_dec.c index cfdce74bd..86414d84a 100644 --- a/lib_dec/ivas_ls_custom_dec.c +++ b/lib_dec/ivas_ls_custom_dec.c @@ -82,15 +82,19 @@ ivas_error ivas_ls_custom_open_fx( } ( *hLsSetupCustom )->num_spk = -1; + move16(); ( *hLsSetupCustom )->is_planar_setup = -1; + move16(); set32_fx( ( *hLsSetupCustom )->ls_azimuth_fx, 0, MAX_OUTPUT_CHANNELS ); set32_fx( ( *hLsSetupCustom )->ls_elevation_fx, 0, MAX_OUTPUT_CHANNELS ); ( *hLsSetupCustom )->num_lfe = -1; + move16(); set_s( ( *hLsSetupCustom )->lfe_idx, -1, MAX_OUTPUT_CHANNELS ); ( *hLsSetupCustom )->separate_ch_found = -1; + move16(); set16_fx( ( *hLsSetupCustom )->separate_ch_gains_fx, 0, MAX_OUTPUT_CHANNELS ); return IVAS_ERR_OK; @@ -135,17 +139,25 @@ void ivas_ls_custom_setup_fx( ) { hOutSetup->output_config = IVAS_AUDIO_CONFIG_LS_CUSTOM; + move32(); hOutSetup->nchan_out_woLFE = hLsSetupCustom->num_spk; + move16(); hOutSetup->ls_azimuth_fx = hLsSetupCustom->ls_azimuth_fx; + move32(); hOutSetup->ls_elevation_fx = hLsSetupCustom->ls_elevation_fx; + move32(); hOutSetup->num_lfe = hLsSetupCustom->num_lfe; + move16(); hOutSetup->index_lfe[0] = hLsSetupCustom->lfe_idx[0]; /* IVAS_OUTPUT_SETUP only supports 1 LFE */ + move16(); hOutSetup->is_loudspeaker_setup = TRUE; - hOutSetup->is_planar_setup = (int8_t) hLsSetupCustom->is_planar_setup; + move16(); + hOutSetup->is_planar_setup = (Word8) hLsSetupCustom->is_planar_setup; + move16(); return; } diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 2673ec268..8b187d57a 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -645,6 +645,7 @@ ivas_error ivas_masa_decode_fx( move16(); hQMetaData->is_masa_ivas_format = 1; + move16(); *nb_bits_read = 0; move16(); @@ -654,7 +655,7 @@ ivas_error ivas_masa_decode_fx( Word16 tmp, tmp_e; tmp = BASOP_Util_Divide3232_Scale( masa_brate, FRAMES_PER_SEC, &tmp_e ); - tmp = shr( tmp, 15 - tmp_e ); + tmp = shr( tmp, sub( 15, tmp_e ) ); assert( masa_brate / FRAMES_PER_SEC == tmp ); IF( EQ_32( masa_brate, IVAS_SID_5k2 ) ) @@ -674,9 +675,9 @@ ivas_error ivas_masa_decode_fx( IF( EQ_16( st->bfi, 0 ) && GT_32( ivas_total_brate, IVAS_SID_5k2 ) ) { test(); - IF( NE_16( ivas_format, MC_FORMAT ) || NE_16( st_ivas->mc_mode, MC_MODE_MCMASA ) ) + IF( NE_32( ivas_format, MC_FORMAT ) || NE_16( st_ivas->mc_mode, MC_MODE_MCMASA ) ) { - IF( NE_16( ivas_format, MASA_ISM_FORMAT ) ) + IF( NE_32( ivas_format, MASA_ISM_FORMAT ) ) { /* number of transport channels is always 2 for MASA_ISM format */ /* the number of MASA transport channels was read in ivas_dec_setup() */ @@ -685,7 +686,7 @@ ivas_error ivas_masa_decode_fx( } test(); - IF( EQ_16( ivas_format, MASA_ISM_FORMAT ) && NE_16( st_ivas->ism_mode, ISM_MODE_NONE ) ) + IF( EQ_32( ivas_format, MASA_ISM_FORMAT ) && NE_32( st_ivas->ism_mode, ISM_MODE_NONE ) ) { /* the number of objects was read */ st->next_bit_pos = sub( st->next_bit_pos, NO_BITS_MASA_ISM_NO_OBJ ); @@ -828,7 +829,7 @@ ivas_error ivas_masa_decode_fx( } test(); - IF( NE_16( ivas_format, MC_FORMAT ) || NE_16( st_ivas->mc_mode, MC_MODE_MCMASA ) ) + IF( NE_32( ivas_format, MC_FORMAT ) || NE_32( st_ivas->mc_mode, MC_MODE_MCMASA ) ) { /* read subframe mode */ byteBuffer = st->bit_stream[( st->next_bit_pos )--]; @@ -847,7 +848,7 @@ ivas_error ivas_masa_decode_fx( } /* Once we know incoming configuration, we can config decoder further based on bitrate etc. */ - IF( ( error = ivas_masa_dec_config_fx( st_ivas ) ) != IVAS_ERR_OK ) + if ( NE_32( ( error = ivas_masa_dec_config_fx( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } @@ -857,9 +858,12 @@ ivas_error ivas_masa_decode_fx( IF( LT_32( hMasa->config.max_metadata_bits, MINIMUM_BIT_BUDGET_NORMAL_META ) && EQ_16( hMasa->config.joinedSubframes, FALSE ) ) { /* read low bitrate mode */ - byteBuffer = st->bit_stream[( st->next_bit_pos )--]; + byteBuffer = st->bit_stream[st->next_bit_pos]; + move16(); + st->next_bit_pos = sub( st->next_bit_pos, 1 ); move16(); *nb_bits_read = add( *nb_bits_read, 1 ); + move16(); low_bitrate_mode = byteBuffer; move16(); @@ -877,15 +881,17 @@ ivas_error ivas_masa_decode_fx( /* Remove already read bits from the bit budget */ hQMetaData->metadata_max_bits = sub( hQMetaData->metadata_max_bits, *nb_bits_read ); + move16(); - IF( EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) + IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) { - IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) + IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) { IF( st_ivas->hDirAC != NULL ) { *nb_bits_read = add( *nb_bits_read, ivas_decode_masaism_metadata_fx( hQMetaData, st_ivas->hMasa, st_ivas->hMasaIsmData, st_ivas->nchan_ism, st->bit_stream, &st->next_bit_pos, st_ivas->hMasaIsmData->idx_separated_ism, ism_imp, st_ivas->hSpatParamRendCom->dirac_bs_md_write_idx, st_ivas->hSpatParamRendCom->dirac_md_buffer_length ) ); + move16(); FOR( obj = 0; obj <= st_ivas->nchan_ism; obj++ ) { IF( EQ_16( st_ivas->hMasaIsmData->idx_separated_ism, obj ) ) @@ -908,6 +914,7 @@ ivas_error ivas_masa_decode_fx( { *nb_bits_read = add( *nb_bits_read, ivas_decode_masaism_metadata_fx( hQMetaData, st_ivas->hMasa, st_ivas->hMasaIsmData, st_ivas->nchan_ism, st->bit_stream, &st->next_bit_pos, st_ivas->hMasaIsmData->idx_separated_ism, ism_imp, 0, MAX_PARAM_SPATIAL_SUBFRAMES ) ); + move16(); } } } @@ -915,10 +922,9 @@ ivas_error ivas_masa_decode_fx( masa_total_brate = ivas_total_brate; move32(); test(); - IF( EQ_16( ivas_format, MASA_ISM_FORMAT ) && EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) + IF( EQ_32( ivas_format, MASA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) { masa_total_brate = calculate_cpe_brate_MASA_ISM_fx( st_ivas->ism_mode, ivas_total_brate, st_ivas->nchan_ism ); - move32(); } IF( GE_32( masa_total_brate, IVAS_384k ) ) @@ -927,11 +933,13 @@ ivas_error ivas_masa_decode_fx( { *nb_bits_read = add( *nb_bits_read, ivas_qmetadata_dec_decode_hr_384_512( hQMetaData, st->bit_stream, &st->next_bit_pos, hMasa->data.sph_grid16, 16, 4, hMasa->config.numCodingBands ) ); + move16(); } ELSE { *nb_bits_read = add( *nb_bits_read, ivas_qmetadata_dec_decode_hr_384_512( hQMetaData, st->bit_stream, &st->next_bit_pos, hMasa->data.sph_grid16, 11, 3, hMasa->config.numCodingBands ) ); + move16(); } } ELSE @@ -942,21 +950,23 @@ ivas_error ivas_masa_decode_fx( test(); test(); - IF( EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) && NE_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && NE_16( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) + IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && NE_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && NE_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) { /* Modify spatial metadata based on the MASA-to-total energy ratios */ ivas_omasa_modify_masa_energy_ratios_fx( hQMetaData, st_ivas->hMasaIsmData->masa_to_total_energy_ratio_fx ); } /* Get direction decoding quality. EC 1 and 2 are handled by the default value. */ - IF( EQ_16( hQMetaData->ec_flag, 2 ) ) + if ( EQ_16( hQMetaData->ec_flag, 2 ) ) { hMasa->data.dir_decode_quality_fx = hQMetaData->dir_comp_ratio_fx; /* Q15 */ + move16(); } hMasa->config.coherencePresent = !hQMetaData->all_coherence_zero; + move16(); - IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) + IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) { index_16bits_fx( hQMetaData, hMasa->data.sph_grid16 ); } @@ -966,17 +976,17 @@ ivas_error ivas_masa_decode_fx( { restore_lowbitrate_masa_fx( hQMetaData, low_bitrate_mode, hMasa->config.numCodingBands ); } - ELSE IF( hMasa->config.joinedSubframes == TRUE ) + ELSE IF( EQ_16( hMasa->config.joinedSubframes, TRUE ) ) { replicate_subframes_fx( hQMetaData ); } } - ELSE IF( EQ_16( st->bfi, 0 ) && EQ_16( ivas_format, MASA_FORMAT ) && EQ_32( ivas_total_brate, IVAS_SID_5k2 ) ) + ELSE IF( EQ_16( st->bfi, 0 ) && EQ_32( ivas_format, MASA_FORMAT ) && EQ_32( ivas_total_brate, IVAS_SID_5k2 ) ) { IF( hQMetaData->q_direction == NULL ) { /* replicate ivas_masa_dec_config() in case that first good received frame is SID frame */ - IF( ( error = ivas_masa_dec_config_fx( st_ivas ) ) != IVAS_ERR_OK ) + if ( NE_32( ( error = ivas_masa_dec_config_fx( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } @@ -986,13 +996,15 @@ ivas_error ivas_masa_decode_fx( hQMetaData->metadata_max_bits = ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC; move16(); - IF( ( error = ivas_qmetadata_allocate_memory( hQMetaData, 5, 1, 0 ) ) != IVAS_ERR_OK ) + if ( NE_32( ( error = ivas_qmetadata_allocate_memory( hQMetaData, 5, 1, 0 ) ), IVAS_ERR_OK ) ) { return error; } hQMetaData->numTwoDirBands = hMasa->config.numTwoDirBands; + move16(); hQMetaData->useLowerRes = 0; + move16(); hQMetaData->q_direction->cfg.nbands = 5; move16(); @@ -1000,7 +1012,7 @@ ivas_error ivas_masa_decode_fx( move16(); test(); - IF( EQ_16( ivas_format, MC_FORMAT ) && EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) ) + IF( EQ_32( ivas_format, MC_FORMAT ) && EQ_32( st_ivas->mc_mode, MC_MODE_MCMASA ) ) { hQMetaData->q_direction->cfg.mc_ls_setup = ivas_mc_map_output_config_to_mc_ls_setup_fx( st_ivas->transport_config ); } @@ -1019,13 +1031,13 @@ ivas_error ivas_masa_decode_fx( IF( EQ_16( st_ivas->nchan_transport, 2 ) ) { - assert( GT_16( st_ivas->nCPE, 0 ) ); + assert( st_ivas->nCPE > 0 ); st_ivas->hCPE[0]->element_mode = tmp_elem_mode; move16(); } *nb_bits_read = add( *nb_bits_read, SID_FORMAT_NBITS ); } - ELSE IF( EQ_16( st->bfi, 0 ) && EQ_16( ivas_format, MASA_FORMAT ) && EQ_32( ivas_total_brate, FRAME_NO_DATA ) ) + ELSE IF( st->bfi == 0 && EQ_32( ivas_format, MASA_FORMAT ) && EQ_32( ivas_total_brate, FRAME_NO_DATA ) ) { IF( hQMetaData->q_direction == NULL ) { @@ -1044,11 +1056,11 @@ ivas_error ivas_masa_decode_fx( ivas_qmetadata_to_dirac_fx( hQMetaData, st_ivas->hDirAC, hMasa, st_ivas->hSpatParamRendCom, ivas_total_brate, ivas_format, 0, 0 ); } - IF( EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) + IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) { IF( hQMetaData->q_direction == NULL ) { - IF( ( error = ivas_masa_dec_config_fx( st_ivas ) ) != IVAS_ERR_OK ) + if ( NE_32( ( error = ivas_masa_dec_config_fx( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } @@ -1091,7 +1103,7 @@ ivas_error ivas_masa_decode_fx( st->next_bit_pos = next_bit_pos_orig; move16(); - IF( EQ_16( ivas_format, MASA_ISM_FORMAT ) ) + IF( EQ_32( ivas_format, MASA_ISM_FORMAT ) ) { Word32 cpe_brate; cpe_brate = calculate_cpe_brate_MASA_ISM_fx( st_ivas->ism_mode, ivas_total_brate, st_ivas->nchan_ism ); @@ -1111,7 +1123,7 @@ ivas_error ivas_masa_decode_fx( move16(); } - IF( LE_32( ivas_total_brate, IVAS_SID_5k2 ) ) + if ( LE_32( ivas_total_brate, IVAS_SID_5k2 ) ) { st_ivas->hCPE[0]->hStereoDft->hConfig->force_mono_transmission = 0; move32(); @@ -1123,7 +1135,7 @@ ivas_error ivas_masa_decode_fx( test(); test(); test(); - IF( EQ_16( ivas_format, MASA_FORMAT ) && EQ_16( st_ivas->nCPE, 1 ) && st_ivas->hCPE[0]->hStereoDft != NULL && st_ivas->hCPE[0]->hStereoDft->hConfig != NULL ) + IF( EQ_32( ivas_format, MASA_FORMAT ) && EQ_16( st_ivas->nCPE, 1 ) && st_ivas->hCPE[0]->hStereoDft != NULL && st_ivas->hCPE[0]->hStereoDft->hConfig != NULL ) { IF( LT_32( ivas_total_brate, MASA_STEREO_MIN_BITRATE ) ) { @@ -1136,7 +1148,7 @@ ivas_error ivas_masa_decode_fx( move16(); } - IF( LE_32( ivas_total_brate, IVAS_SID_5k2 ) ) + if ( LE_32( ivas_total_brate, IVAS_SID_5k2 ) ) { st_ivas->hCPE[0]->hStereoDft->hConfig->force_mono_transmission = 0; move16(); @@ -1145,7 +1157,7 @@ ivas_error ivas_masa_decode_fx( } test(); - IF( EQ_16( ivas_format, MASA_FORMAT ) && EQ_16( st_ivas->nCPE, 1 ) ) + IF( EQ_32( ivas_format, MASA_FORMAT ) && EQ_16( st_ivas->nCPE, 1 ) ) { st_ivas->hCPE[0]->hCoreCoder[0]->masa_sid_format = 0; move16(); @@ -1155,7 +1167,7 @@ ivas_error ivas_masa_decode_fx( st_ivas->hCPE[0]->hCoreCoder[0]->masa_sid_format = 1; move16(); - IF( GE_32( ivas_total_brate, IVAS_SID_5k2 ) ) + if ( GE_32( ivas_total_brate, IVAS_SID_5k2 ) ) { st_ivas->hCPE[0]->element_brate = ivas_total_brate; move32(); @@ -1165,7 +1177,7 @@ ivas_error ivas_masa_decode_fx( test(); test(); - IF( ( EQ_16( st_ivas->ivas_format, MASA_FORMAT ) || EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) && EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) + IF( ( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) || EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) && EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) { create_masa_ext_out_meta_fx( hMasa, hQMetaData, st_ivas->nchan_transport ); } @@ -1307,7 +1319,7 @@ ivas_error ivas_masa_dec_open_fx( test(); test(); test(); - IF( EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) && GT_16( st_ivas->nSCE, 0 ) && ( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) || EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) || EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) ) + IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && GT_16( st_ivas->nSCE, 0 ) && ( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) || EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) || EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) ) { FOR( i = 0; i < st_ivas->nSCE; i++ ) { @@ -1320,7 +1332,9 @@ ivas_error ivas_masa_dec_open_fx( Copy( DirAC_block_grouping, hMasa->config.block_grouping, MAX_PARAM_SPATIAL_SUBFRAMES + 1 ); Copy( MASA_band_grouping_24, hMasa->config.band_grouping, MASA_FREQUENCY_BANDS + 1 ); hMasa->config.numberOfDirections = 1; + move16(); hMasa->config.joinedSubframes = FALSE; + move16(); /* Create spherical grid only for external output */ IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) @@ -1386,14 +1400,14 @@ ivas_error ivas_masa_dec_open_fx( test(); test(); - IF( EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_16( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) ) + IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_32( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) ) { nchan_transport = 1; move16(); nchan_to_allocate = 1; move16(); } - ELSE IF( EQ_16( st_ivas->nchan_transport, 1 ) && EQ_16( st_ivas->renderer_type, RENDERER_DIRAC ) ) + ELSE IF( EQ_16( st_ivas->nchan_transport, 1 ) && EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) ) { /* addtl channel for CNG */ nchan_to_allocate = add( nchan_to_allocate, 1 ); @@ -1655,6 +1669,7 @@ static ivas_error ivas_masa_dec_config_fx( Word32 ivas_total_brate; Word32 ism_total_brate; error = IVAS_ERR_OK; + move32(); hMasa = st_ivas->hMasa; ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; @@ -1666,7 +1681,7 @@ static ivas_error ivas_masa_dec_config_fx( test(); test(); test(); - IF( EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) && GT_16( st_ivas->nSCE, 0 ) && ( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) || EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) || EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) ) + IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && st_ivas->nSCE > 0 && ( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) || EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) || EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) ) { FOR( i = 0; i < st_ivas->nSCE; i++ ) { @@ -1676,20 +1691,21 @@ static ivas_error ivas_masa_dec_config_fx( ivas_masa_set_elements_fx( ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, st_ivas->hQMetaData, &st_ivas->element_mode_init, &st_ivas->nSCE, &st_ivas->nCPE, st_ivas->ivas_format, st_ivas->ism_mode, ism_total_brate ); - IF( EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) + IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) { ivas_masa_set_coding_config_fx( &( hMasa->config ), hMasa->data.band_mapping, st_ivas->hCPE[0]->element_brate, st_ivas->nchan_transport, MC_MODE_NONE ); } ELSE { - ivas_masa_set_coding_config_fx( &( hMasa->config ), hMasa->data.band_mapping, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCMASA ) ); + ivas_masa_set_coding_config_fx( &( hMasa->config ), hMasa->data.band_mapping, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, ( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && EQ_32( st_ivas->mc_mode, MC_MODE_MCMASA ) ) ); } test(); test(); - IF( ( EQ_16( st_ivas->ivas_format, MASA_FORMAT ) || EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) && EQ_32( st_ivas->hDecoderConfig->ivas_total_brate, IVAS_512k ) ) + IF( ( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) || EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) && EQ_32( st_ivas->hDecoderConfig->ivas_total_brate, IVAS_512k ) ) { hMasa->config.mergeRatiosOverSubframes = 0; + move16(); /* initialize spherical grid */ IF( hMasa->data.sph_grid16 == NULL ) @@ -1709,12 +1725,13 @@ static ivas_error ivas_masa_dec_config_fx( move16(); /* TODO: use fixed version of this function call */ - IF( ( error = ivas_qmetadata_allocate_memory( st_ivas->hQMetaData, hMasa->config.numCodingBands, hMasa->config.numberOfDirections, hMasa->config.useCoherence ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_qmetadata_allocate_memory( st_ivas->hQMetaData, hMasa->config.numCodingBands, hMasa->config.numberOfDirections, hMasa->config.useCoherence ) ), IVAS_ERR_OK ) ) { return error; } st_ivas->hQMetaData->numTwoDirBands = st_ivas->hMasa->config.numTwoDirBands; + move16(); st_ivas->hQMetaData->useLowerRes = 0; move16(); @@ -1722,11 +1739,18 @@ static ivas_error ivas_masa_dec_config_fx( { st_ivas->hQMetaData->q_direction[i].cfg.nbands = hMasa->config.numCodingBands; move16(); - st_ivas->hQMetaData->q_direction[i].cfg.nblocks = EQ_16( hMasa->config.joinedSubframes, TRUE ) ? 1 : 4; + IF( EQ_16( hMasa->config.joinedSubframes, TRUE ) ) + { + st_ivas->hQMetaData->q_direction[i].cfg.nblocks = 1; + } + ELSE + { + st_ivas->hQMetaData->q_direction[i].cfg.nblocks = 4; + } move16(); test(); - IF( EQ_16( st_ivas->ivas_format, MC_FORMAT ) && EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) ) + IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) ) { st_ivas->hQMetaData->q_direction[i].cfg.mc_ls_setup = ivas_mc_map_output_config_to_mc_ls_setup_fx( st_ivas->transport_config ); } @@ -1815,16 +1839,16 @@ void ivas_masa_prerender_fx( test(); test(); - IF( EQ_16( st_ivas->ivas_format, MASA_FORMAT ) && EQ_16( st_ivas->nchan_transport, 2 ) && EQ_16( nchan_remapped, 1 ) ) + IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) && EQ_16( st_ivas->nchan_transport, 2 ) && EQ_16( nchan_remapped, 1 ) ) { - IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) + IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) { Copy32( output_fx[0], output_fx[1], output_frame ); /* Copy mono signal to stereo output channels */ } ELSE { test(); - IF( EQ_16( st_ivas->renderer_type, RENDERER_DIRAC ) || EQ_16( st_ivas->renderer_type, RENDERER_DISABLE ) ) + IF( EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) || EQ_32( st_ivas->renderer_type, RENDERER_DISABLE ) ) { v_multc_fixed( output_fx[0], SQRT2_FIXED, output_fx[0], output_frame ); /* q + 30 - 31 = q - 1*/ /* Gain transport signal when transmitting mono with cpe in order to match loudness */ *q_shift = -1; /* Q has decreased by 1. */ @@ -1955,12 +1979,14 @@ static void replicate_subframes_fx( IF( hQMetaData->q_direction[dir].coherence_band_data != NULL ) { hQMetaData->q_direction[dir].coherence_band_data[band].spread_coherence[sf] = hQMetaData->q_direction[dir].coherence_band_data[band].spread_coherence[0]; + move16(); } } IF( hQMetaData->surcoh_band_data != NULL ) { hQMetaData->surcoh_band_data[band].surround_coherence[sf] = hQMetaData->surcoh_band_data[band].surround_coherence[0]; + move16(); } } } @@ -2058,10 +2084,12 @@ static void restore_lowbitrate_masa_fx( IF( hQMetaData->q_direction[0].coherence_band_data != NULL ) { hQMetaData->q_direction[0].coherence_band_data[band].spread_coherence[sf] = hQMetaData->q_direction[0].coherence_band_data[band].spread_coherence[0]; + move16(); } IF( hQMetaData->surcoh_band_data != NULL ) { hQMetaData->surcoh_band_data[band].surround_coherence[sf] = hQMetaData->surcoh_band_data[band].surround_coherence[0]; + move16(); } } } @@ -2088,10 +2116,12 @@ static void restore_lowbitrate_masa_fx( IF( hQMetaData->q_direction[0].coherence_band_data != NULL ) { hQMetaData->q_direction[0].coherence_band_data[band].spread_coherence[sf] = hQMetaData->q_direction[0].coherence_band_data[0].spread_coherence[sf]; + move16(); } IF( hQMetaData->surcoh_band_data != NULL ) { hQMetaData->surcoh_band_data[band].surround_coherence[sf] = hQMetaData->surcoh_band_data[0].surround_coherence[sf]; + move16(); } } } @@ -2277,7 +2307,7 @@ static ivas_error init_lfe_synth_data_fx( EQ_16( output_config, IVAS_AUDIO_CONFIG_5_1_4 ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_7_1_4 ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_FOA ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_HOA2 ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_HOA3 ) || - ( EQ_16( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && GT_16( st_ivas->hOutSetup.num_lfe, 0 ) ) ) ) + ( EQ_16( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && ( st_ivas->hOutSetup.num_lfe > 0 ) ) ) ) { Word16 bufferSize; Word16 i; @@ -2955,16 +2985,16 @@ ivas_error ivas_masa_dec_reconfigure_fx( test(); test(); test(); - IF( ( EQ_16( st_ivas->renderer_type, RENDERER_DIRAC ) && st_ivas->hDirACRend == NULL ) || - ( ( EQ_16( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) && st_ivas->hDiracDecBin == NULL ) ) + IF( ( EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) && st_ivas->hDirACRend == NULL ) || + ( ( EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) && st_ivas->hDiracDecBin == NULL ) ) { /* init a new DirAC dec */ - IF( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) + if ( NE_32( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_OPEN ) ), IVAS_ERR_OK ) ) { return error; } } - ELSE IF( EQ_16( st_ivas->renderer_type, RENDERER_DISABLE ) || EQ_16( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) ) + ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_DISABLE ) || EQ_32( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) ) { IF( st_ivas->hDirAC != NULL ) { @@ -3019,9 +3049,9 @@ ivas_error ivas_masa_dec_reconfigure_fx( test(); test(); test(); - IF( ( EQ_16( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) && st_ivas->hDiracDecBin != NULL ) + IF( ( EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) && st_ivas->hDiracDecBin != NULL ) { - IF( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK ) + if ( NE_32( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_RECONFIGURE ) ), IVAS_ERR_OK ) ) { return error; } @@ -3040,7 +3070,7 @@ ivas_error ivas_masa_dec_reconfigure_fx( { tmp = CPE_CHANNELS; move16(); - IF( GT_16( st_ivas->nCPE, 1 ) ) + if ( GT_16( st_ivas->nCPE, 1 ) ) { st_ivas->nCPE = 1; move16(); @@ -3075,9 +3105,9 @@ ivas_error ivas_masa_dec_reconfigure_fx( test(); test(); test(); - IF( ( EQ_16( st_ivas->renderer_type, RENDERER_DIRAC ) && st_ivas->hDirACRend != NULL ) || ( ( EQ_16( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) && st_ivas->hDiracDecBin != NULL ) ) + IF( ( EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) && st_ivas->hDirACRend != NULL ) || ( ( EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) && st_ivas->hDiracDecBin != NULL ) ) { - IF( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK ) + if ( NE_32( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_RECONFIGURE ) ), IVAS_ERR_OK ) ) { return error; } @@ -3093,9 +3123,9 @@ ivas_error ivas_masa_dec_reconfigure_fx( test(); test(); test(); - IF( ( EQ_16( st_ivas->renderer_type, RENDERER_DIRAC ) && st_ivas->hDirACRend != NULL ) || ( ( EQ_16( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) && st_ivas->hDiracDecBin != NULL ) ) + IF( ( EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) && st_ivas->hDirACRend != NULL ) || ( ( EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) && st_ivas->hDiracDecBin != NULL ) ) { - IF( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK ) + if ( NE_32( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_RECONFIGURE ) ), IVAS_ERR_OK ) ) { return error; } @@ -3110,14 +3140,14 @@ ivas_error ivas_masa_dec_reconfigure_fx( } test(); - IF( EQ_16( st_ivas->ivas_format, MASA_FORMAT ) && EQ_16( st_ivas->last_ivas_format, MASA_FORMAT ) ) /* note: switching within OMASA is handled in ivas_omasa_dec_config() */ + IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) && EQ_32( st_ivas->last_ivas_format, MASA_FORMAT ) ) /* note: switching within OMASA is handled in ivas_omasa_dec_config() */ { /*-----------------------------------------------------------------* * TD Decorrelator *-----------------------------------------------------------------*/ IF( st_ivas->hDiracDecBin != NULL ) { - IF( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) ) ), IVAS_ERR_OK ) ) { return error; } @@ -3140,7 +3170,7 @@ ivas_error ivas_masa_dec_reconfigure_fx( floatToFixed_arr( st_ivas->hSpar->hFbMixer->cldfb_cross_fade, st_ivas->hSpar->hFbMixer->cldfb_cross_fade_fx, st_ivas->hSpar->hFbMixer->cldfb_cross_fade_q, 16 ); } #endif - if ( ( error = ivas_cldfb_dec_reconfig_fx( st_ivas, st_ivas->nchan_transport, numCldfbAnalyses_old, numCldfbSyntheses_old ) ) != IVAS_ERR_OK ) + if ( NE_32( ( error = ivas_cldfb_dec_reconfig_fx( st_ivas, st_ivas->nchan_transport, numCldfbAnalyses_old, numCldfbSyntheses_old ) ), IVAS_ERR_OK ) ) { return error; } @@ -3158,7 +3188,7 @@ ivas_error ivas_masa_dec_reconfigure_fx( test(); test(); test(); - IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && GT_16( st_ivas->nSCE, 0 ) && ( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) || EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) || EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) ) + IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && GT_32( st_ivas->nSCE, 0 ) && ( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) || EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) || EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) ) { FOR( n = 0; n < st_ivas->nSCE; n++ ) { @@ -3168,7 +3198,7 @@ ivas_error ivas_masa_dec_reconfigure_fx( ivas_masa_set_elements_fx( ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, st_ivas->hQMetaData, &tmp, &tmp, &tmp, st_ivas->ivas_format, st_ivas->ism_mode, ism_total_brate ); - IF( EQ_16( st_ivas->ivas_format, MASA_FORMAT ) ) + IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) ) { st_ivas->nchan_ism = 0; move16(); @@ -3183,6 +3213,7 @@ ivas_error ivas_masa_dec_reconfigure_fx( Word16 n_samples_granularity; n_samples_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + move16(); buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode( st_ivas ); tc_nchan_transport = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ); @@ -3195,7 +3226,7 @@ ivas_error ivas_masa_dec_reconfigure_fx( test(); IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_16( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) { - IF( EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) + IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) { tc_nchan_to_allocate = add( shl( BINAURAL_CHANNELS, 1 ), 2 ); } @@ -3206,29 +3237,29 @@ ivas_error ivas_masa_dec_reconfigure_fx( test(); test(); test(); - IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) + IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) { n_samples_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); /* Use the same granularity as tdrend */ IF( GT_16( n_samples_granularity, st_ivas->hTcBuffer->n_samples_granularity ) ) { - IF( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK ) + if ( NE_32( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } } } - ELSE IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && NE_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) + ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && NE_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) { IF( LT_16( n_samples_granularity, st_ivas->hTcBuffer->n_samples_granularity ) ) { - IF( ( error = ivas_jbm_dec_flush_renderer_fx( st_ivas, n_samples_granularity, st_ivas->renderer_type, st_ivas->intern_config, &st_ivas->hIntSetup, MC_MODE_NONE, ISM_MASA_MODE_DISC, nSamplesRendered, data ) ) != IVAS_ERR_OK ) + if ( NE_32( ( error = ivas_jbm_dec_flush_renderer_fx( st_ivas, n_samples_granularity, st_ivas->renderer_type, st_ivas->intern_config, &st_ivas->hIntSetup, MC_MODE_NONE, ISM_MASA_MODE_DISC, nSamplesRendered, data ) ), IVAS_ERR_OK ) ) { return error; } } } } - ELSE IF( EQ_16( st_ivas->nchan_transport, 1 ) && ( EQ_16( st_ivas->renderer_type, RENDERER_DIRAC ) && EQ_16( st_ivas->hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) ) + ELSE IF( EQ_16( st_ivas->nchan_transport, 1 ) && ( EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) && EQ_32( st_ivas->hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) ) { /* addtl channel for CNG */ tc_nchan_to_allocate = add( tc_nchan_to_allocate, 1 ); @@ -3238,7 +3269,7 @@ ivas_error ivas_masa_dec_reconfigure_fx( test(); IF( NE_16( tc_nchan_transport, st_ivas->hTcBuffer->nchan_transport_jbm ) || NE_16( tc_nchan_to_allocate, st_ivas->hTcBuffer->nchan_transport_internal ) || NE_16( buffer_mode_new, st_ivas->hTcBuffer->tc_buffer_mode ) ) { - IF( ( error = ivas_jbm_dec_tc_buffer_reconfigure_fx( st_ivas, buffer_mode_new, tc_nchan_transport, tc_nchan_to_allocate, tc_nchan_to_allocate, n_samples_granularity ) ) != IVAS_ERR_OK ) + if ( NE_32( error = ivas_jbm_dec_tc_buffer_reconfigure_fx( st_ivas, buffer_mode_new, tc_nchan_transport, tc_nchan_to_allocate, tc_nchan_to_allocate, n_samples_granularity ), IVAS_ERR_OK ) ) { return error; } @@ -3256,7 +3287,7 @@ ivas_error ivas_masa_dec_reconfigure_fx( test(); test(); - IF( EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) + IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) { Word16 granularityMultiplier = idiv1616( st_ivas->hTcBuffer->n_samples_granularity, st_ivas->hSpatParamRendCom->slot_size ); FOR( n = 0; n < MAX_JBM_SUBFRAMES_5MS; n++ ) @@ -3325,7 +3356,11 @@ void ivas_spar_param_to_masa_param_mapping_fx( { FOR( Word16 ind2 = 0; ind2 < 4; ind2++ ) { - common_q = common_q < q_cldfb[ind][ind2] ? common_q : q_cldfb[ind][ind2]; + if ( GT_16( common_q, q_cldfb[ind][ind2] ) ) + { + common_q = q_cldfb[ind][ind2]; + move16(); + } } } /* Set values */ @@ -3354,7 +3389,7 @@ void ivas_spar_param_to_masa_param_mapping_fx( slot_idx_start = hSpar->slots_rendered; move16(); slot_fac_fx = BASOP_Util_Divide3232_Scale( 1, hSpar->subframe_nbslots[subframe], &q_slot_fac ); - IF( LT_16( q_slot_fac, 0 ) ) + IF( q_slot_fac < 0 ) { slot_fac_fx = shr( slot_fac_fx, -1 * q_slot_fac ); } @@ -3450,7 +3485,7 @@ void ivas_spar_param_to_masa_param_mapping_fx( max_common_val = GT_64( transportSignalEnergies_max, transportSignalCrossCorrelation_max ) ? transportSignalEnergies_max : transportSignalCrossCorrelation_max; - IF( NE_64( max_common_val, 0 ) ) + IF( max_common_val != 0 ) { headroom_left_max_common = W_norm( max_common_val ); IF( GT_16( headroom_left_max_common, 32 ) ) @@ -3577,7 +3612,7 @@ void ivas_spar_param_to_masa_param_mapping_fx( q_I_res = sub( 31, shl( q_inCovarianceMtx, 1 ) ); } I_fx = Sqrt32( (Word32) I_res, &q_I_res ); - IF( LT_16( q_I_res, 0 ) ) + IF( q_I_res < 0 ) { I_fx = L_shr( I_fx, -1 * q_I_res ); q_I_res = 0; @@ -3601,7 +3636,7 @@ void ivas_spar_param_to_masa_param_mapping_fx( ele_q = sub( 31, shl( q_inCovarianceMtx, 1 ) ); } I_ele = Sqrt32( (Word32) I_ele, &ele_q ); - IF( LT_16( ele_q, 0 ) ) + IF( ele_q < 0 ) { I_ele = W_shr( I_ele, -1 * ele_q ); ele_q = 0; @@ -3622,7 +3657,7 @@ void ivas_spar_param_to_masa_param_mapping_fx( ratio_fx = L_max( 0, L_min( ratio_fx, ONE_IN_Q30 ) ); azi_val = (Word64) azi_fx * ONE_BY_PI_OVER_180_Q25; - IF( LT_64( azi_val, 0 ) ) + IF( azi_val < 0 ) { azi_val = W_shr( -1 * azi_val, 13 + 25 ); azi_val = -1 * azi_val; @@ -3632,7 +3667,7 @@ void ivas_spar_param_to_masa_param_mapping_fx( azi_val = W_shr( azi_val, 13 + 25 ); } ele_val = (Word64) ele_fx * ONE_BY_PI_OVER_180_Q25; - IF( LT_64( ele_val, 0 ) ) + IF( ele_val < 0 ) { ele_val = W_shr( -1 * ele_val, 13 + 25 ); ele_val = -1 * ele_val; @@ -3682,7 +3717,7 @@ void ivas_spar_param_to_masa_param_mapping_fx( } diffuseGainSum_fx = L_add_sat( L_add_sat( diffuseGainY_fx, diffuseGainX_fx ), diffuseGainZ_fx ); - IF( EQ_32( diffuseGainSum_fx, 0 ) ) + IF( diffuseGainSum_fx == 0 ) { hDiffuseDist->diffuseRatioX_fx[bin] = 715827904; move32(); @@ -3694,12 +3729,13 @@ void ivas_spar_param_to_masa_param_mapping_fx( ELSE { Word16 temp_q = 0; + move16(); Word16 intermediate_results; intermediate_results = BASOP_Util_Divide3232_Scale( diffuseGainX_fx, diffuseGainSum_fx + EPSILON_FX_SMALL, &temp_q ); // saturating value to less than 1 - IF( LE_16( temp_q, 0 ) ) + IF( temp_q <= 0 ) { - intermediate_results = shr( intermediate_results, -1 * temp_q ); + intermediate_results = shr( intermediate_results, negate( temp_q ) ); } ELSE { @@ -3710,9 +3746,9 @@ void ivas_spar_param_to_masa_param_mapping_fx( intermediate_results = BASOP_Util_Divide3232_Scale( diffuseGainY_fx, diffuseGainSum_fx + EPSILON_FX_SMALL, &temp_q ); // saturating value to less than 1 - IF( LE_16( temp_q, 0 ) ) + IF( temp_q <= 0 ) { - intermediate_results = shr( intermediate_results, -1 * temp_q ); + intermediate_results = shr( intermediate_results, negate( temp_q ) ); } ELSE { @@ -3723,9 +3759,9 @@ void ivas_spar_param_to_masa_param_mapping_fx( intermediate_results = BASOP_Util_Divide3232_Scale( diffuseGainZ_fx, diffuseGainSum_fx + EPSILON_FX_SMALL, &temp_q ); // saturating value to less than 1 - IF( LE_16( temp_q, 0 ) ) + IF( temp_q <= 0 ) { - intermediate_results = shr( intermediate_results, -1 * temp_q ); + intermediate_results = shr( intermediate_results, negate( temp_q ) ); } ELSE { @@ -4193,8 +4229,11 @@ static void create_masa_ext_out_meta_fx( MASA_DECODER_EXT_OUT_META *extOutMeta; numDirections = hMasa->config.numberOfDirections; + move16(); numCodingBands = hMasa->config.numCodingBands; + move16(); bandMap = hMasa->data.band_mapping; + move16(); extOutMeta = hMasa->data.extOutMeta; descMeta = &hMasa->data.extOutMeta->descriptiveMeta; @@ -4202,6 +4241,7 @@ static void create_masa_ext_out_meta_fx( FOR( i = 0; i < 8; i++ ) { descMeta->formatDescriptor[i] = ivasmasaFormatDescriptor[i]; + move16(); } descMeta->numberOfDirections = numDirections - 1; descMeta->numberOfChannels = (UWord8) ( sub( nchan_transport, 1 ) ); @@ -4212,6 +4252,14 @@ static void create_masa_ext_out_meta_fx( descMeta->channelDistance = 0x0u; descMeta->channelLayout = 0x0u; + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + /* Construct spatial metadata from qmetadata */ FOR( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ ) { @@ -4233,7 +4281,9 @@ static void create_masa_ext_out_meta_fx( FOR( b_new = bandMap[b_old]; b_new < bandMap[b_old + 1]; b_new++ ) { UWord8 tmp = (UWord8) L_shr( hQMetaData->q_direction[dir].band_data[b_old].energy_ratio_fx[sf], Q30 - 8 ); + move16(); extOutMeta->directToTotalRatio[dir][sf][b_new] = tmp; + move16(); } } @@ -4245,6 +4295,7 @@ static void create_masa_ext_out_meta_fx( FOR( b_new = bandMap[b_old]; b_new < bandMap[b_old + 1]; b_new++ ) { extOutMeta->spreadCoherence[dir][sf][b_new] = hQMetaData->q_direction[dir].coherence_band_data[b_old].spread_coherence[sf]; + move16(); } } } @@ -4253,6 +4304,7 @@ static void create_masa_ext_out_meta_fx( FOR( i = 0; i < MASA_FREQUENCY_BANDS; i++ ) { extOutMeta->spreadCoherence[dir][sf][i] = 0; + move16(); } } } @@ -4269,11 +4321,13 @@ static void create_masa_ext_out_meta_fx( FOR( i = 0; i < MASA_FREQUENCY_BANDS; i++ ) { extOutMeta->directToTotalRatio[1][sf][i] = 0; + move16(); } FOR( i = 0; i < MASA_FREQUENCY_BANDS; i++ ) { extOutMeta->spreadCoherence[1][sf][i] = 0; + move16(); } } @@ -4284,10 +4338,13 @@ static void create_masa_ext_out_meta_fx( FOR( b_new = bandMap[b_old]; b_new < bandMap[b_old + 1]; b_new++ ) { extOutMeta->diffuseToTotalRatio[sf][b_new] = UINT8_MAX; + move16(); FOR( dir = 0; dir < numDirections; dir++ ) { UWord8 tmp = (UWord8) L_shr( hQMetaData->q_direction[dir].band_data[b_old].energy_ratio_fx[sf], Q30 - 8 ); + move16(); extOutMeta->diffuseToTotalRatio[sf][b_new] -= tmp; + move16(); } } } @@ -4300,6 +4357,7 @@ static void create_masa_ext_out_meta_fx( FOR( b_new = bandMap[b_old]; b_new < bandMap[b_old + 1]; b_new++ ) { extOutMeta->surroundCoherence[sf][b_new] = hQMetaData->surcoh_band_data[b_old].surround_coherence[sf]; + move16(); } } } @@ -4308,6 +4366,7 @@ static void create_masa_ext_out_meta_fx( FOR( i = 0; i < MASA_FREQUENCY_BANDS; i++ ) { extOutMeta->surroundCoherence[sf][i] = 0; + move16(); } } } @@ -4393,7 +4452,7 @@ static void decode_index_slice_fx( { j = 0; move16(); - WHILE( GE_16( index, 0 ) ) + WHILE( index >= 0 ) { IF( valid_ratio_index_fx( j, K, nchan_ism - 1 ) ) { @@ -4404,14 +4463,14 @@ static void decode_index_slice_fx( j = sub( j, 1 ); base[0] = 1; move16(); - FOR( i = 1; i < sub( nchan_ism, 1 ); i++ ) + FOR( i = 1; i < nchan_ism - 1; i++ ) { base[i] = i_mult( base[i - 1], 10 ); move16(); } sum = 0; move16(); - FOR( i = sub( nchan_ism, 2 ); i >= 0; i-- ) + FOR( i = nchan_ism - 2; i >= 0; i-- ) { IF( EQ_16( j, 0 ) ) { @@ -4765,7 +4824,7 @@ static void read_ism_ratio_index_fx( ELSE { - IF( EQ_16( sf, 0 ) ) + IF( sf == 0 ) { bits_index = bits_index_ism_ratio_fx( nchan_ism ); @@ -4787,7 +4846,8 @@ static void read_ism_ratio_index_fx( test(); IF( GT_16( idx_sep_obj, -1 ) && EQ_16( ratio_ism_idx[b][idx_sep_obj_local], 0 ) ) { - ( *num_zeros )++; + *num_zeros = add( *num_zeros, 1 ); + move16(); } } ELSE @@ -4808,9 +4868,10 @@ static void read_ism_ratio_index_fx( } decode_index_slice_fx( index, ratio_ism_idx[b_signif], nchan_ism, no_levels_ratio_ism ); test(); - IF( GT_16( idx_sep_obj, -1 ) && EQ_16( ratio_ism_idx[b_signif][idx_sep_obj_local], 0 ) ) + IF( GT_16( idx_sep_obj, -1 ) && ratio_ism_idx[b_signif][idx_sep_obj_local] == 0 ) { - ( *num_zeros )++; + *num_zeros = add( *num_zeros, 1 ); + move16(); } Copy( ratio_ism_idx[b_signif], ratio_ism_idx_ref, nchan_ism ); FOR( b = b_signif + 1; b < numCodingBands; b++ ) @@ -4834,14 +4895,15 @@ static void read_ism_ratio_index_fx( } ratio_ism_idx[b][i] = add( ratio_ism_idx[b][i], ratio_ism_idx_ref[i] ); move16(); - ratio_ism_idx[b][nchan_ism - 1] = sub( ratio_ism_idx[b][nchan_ism - 1], ratio_ism_idx[b][i] ); + ratio_ism_idx[b][sub( nchan_ism, 1 )] = sub( ratio_ism_idx[b][sub( nchan_ism, 1 )], ratio_ism_idx[b][i] ); move16(); } Copy( ratio_ism_idx[b], ratio_ism_idx_ref, nchan_ism ); test(); IF( GT_16( idx_sep_obj, -1 ) && EQ_16( ratio_ism_idx[b][idx_sep_obj_local], 0 ) ) { - ( *num_zeros )++; + *num_zeros = add( *num_zeros, 1 ); + move16(); } } ELSE @@ -4885,7 +4947,7 @@ static void read_ism_ratio_index_fx( { IF( LT_32( masa_to_total_energy_ratio_fx[b], MASA2TOTAL_THR_Q30 ) ) { - IF( EQ_16( idx_sep_obj_local, 0 ) ) + IF( idx_sep_obj_local == 0 ) { ratio_ism_idx[b][0] = 0; move16(); @@ -4915,7 +4977,7 @@ static void read_ism_ratio_index_fx( FOR( i = 0; i < nchan_ism - 1 - shift_one; i++ ) { buf = ivas_qmetadata_DecodeExtendedGR( bit_stream, next_bit_pos, 100, GR_order ); - IF( EQ_16( buf % 2, 0 ) ) + IF( ( buf % 2 ) == 0 ) { ratio_ism_idx[b][i] = negate( shr( buf, 1 ) ); move16(); @@ -4947,7 +5009,7 @@ static void read_ism_ratio_index_fx( { IF( LT_32( masa_to_total_energy_ratio_fx[b], MASA2TOTAL_THR_Q30 ) ) { - ratio_ism_idx[b][nchan_ism - 1] = no_levels_ratio_ism; + ratio_ism_idx[b][sub( nchan_ism, 1 )] = no_levels_ratio_ism; move16(); FOR( i = 0; i < nchan_ism - 1; i++ ) { @@ -4955,7 +5017,7 @@ static void read_ism_ratio_index_fx( move16(); test(); - IF( NE_16( shift_one, 0 ) && EQ_16( i, idx_sep_obj_local ) ) + IF( ( shift_one != 0 ) && EQ_16( i, idx_sep_obj_local ) ) { ratio_ism_idx[b][i] = 0; move16(); @@ -4983,7 +5045,7 @@ static void read_ism_ratio_index_fx( move16(); test(); - IF( NE_16( shift_one, 0 ) && EQ_16( i, idx_sep_obj_local ) ) + IF( ( shift_one != 0 ) && EQ_16( i, idx_sep_obj_local ) ) { ratio_ism_idx[b_signif][i] = 0; move16(); @@ -5421,7 +5483,7 @@ static Word16 ivas_decode_masaism_metadata_fx( test(); test(); // if ( azimuth * hMasaIsmData->q_azimuth_old[obj] > 0 ) - IF( ( GT_32( azimuth, 0 ) && GT_32( hMasaIsmData->q_azimuth_old_fx[obj], 0 ) ) || ( LT_32( azimuth, 0 ) && LT_32( hMasaIsmData->q_azimuth_old_fx[obj], 0 ) ) ) + IF( ( ( azimuth > 0 ) && ( hMasaIsmData->q_azimuth_old_fx[obj] > 0 ) ) || ( ( azimuth < 0 ) && ( hMasaIsmData->q_azimuth_old_fx[obj] < 0 ) ) ) { Word16 tmp_e; delta_phi = L_deposit_h( BASOP_Util_Divide1616_Scale( 180, no_phi_masa[bits_ism[obj] - 1][idx_el], &tmp_e ) ); @@ -5540,7 +5602,7 @@ static Word16 rint_fx( /* returns in Q0 */ { res = add( res, 1 ); } - IF( LT_32( num, 0 ) ) + if ( num < 0 ) { res = negate( res ); } diff --git a/lib_dec/ivas_mcmasa_dec.c b/lib_dec/ivas_mcmasa_dec.c index 1ccf304df..b0d4f5c71 100644 --- a/lib_dec/ivas_mcmasa_dec.c +++ b/lib_dec/ivas_mcmasa_dec.c @@ -54,6 +54,7 @@ ivas_error ivas_mcmasa_dec_reconfig( Word32 ivas_total_brate; ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; + move32(); /* close the old MASA instance */ ivas_masa_dec_close_fx( &( st_ivas->hMasa ) ); @@ -69,25 +70,26 @@ ivas_error ivas_mcmasa_dec_reconfig( ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->intern_config ); ivas_mcmasa_set_separate_channel_mode_fx( &( st_ivas->hIntSetup.separateChannelEnabled ), &( st_ivas->hIntSetup.separateChannelIndex ), ivas_total_brate ); - IF( ( error = ivas_masa_dec_open_fx( st_ivas ) ) != IVAS_ERR_OK ) + if ( NE_32( ( error = ivas_masa_dec_open_fx( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); + test(); IF( NE_16( st_ivas->renderer_type, RENDERER_DISABLE ) && NE_16( st_ivas->renderer_type, RENDERER_MCMASA_MONO_STEREO ) ) { IF( st_ivas->hDirAC == NULL ) { - IF( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) + if ( NE_32( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_OPEN ) ), IVAS_ERR_OK ) ) { return error; } } ELSE { - IF( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK ) + if ( NE_32( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_RECONFIGURE ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_dec/ivas_mct_core_dec.c b/lib_dec/ivas_mct_core_dec.c index b703aaaef..7bd948ad6 100644 --- a/lib_dec/ivas_mct_core_dec.c +++ b/lib_dec/ivas_mct_core_dec.c @@ -167,11 +167,13 @@ void ivas_mct_side_bits_fx( { Word16 ch, cpe_id, nChannels, i, k, nSubframes; Word16 nf_side_bits, availableBits, next_bit_pos, nf_bits; - Word16 chBitRatios[MCT_MAX_CHANNELS]; + Word16 chBitRatios[MCT_MAX_CHANNELS], tmp, scale; Decoder_State *st, *sts[MCT_MAX_CHANNELS]; nf_side_bits = 0; nChannels = hMCT->nchan_out_woLFE; + move16(); + move16(); /*initializations */ FOR( ( cpe_id = 0, i = 0 ); cpe_id < nCPE; cpe_id++ ) @@ -185,12 +187,13 @@ void ivas_mct_side_bits_fx( } /*first read IFG bits */ + test(); IF( !bfi && st0->igf ) { FOR( ch = 0; ch < nChannels; ch++ ) { st = sts[ch]; - IF( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) + if ( EQ_32( st->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) { continue; } @@ -200,7 +203,7 @@ void ivas_mct_side_bits_fx( } /*read MCT data and calculate frame bits per channel */ - FOR( ch = 0; ch < (Word16) ( hMCT->nchan_out_woLFE * 0.5 ); ch++ ) + FOR( ch = 0; ch < shr( hMCT->nchan_out_woLFE, 1 ); ch++ ) { initMdctStereoDecData_fx( hMCT->hBlockData[ch]->hStereoMdct, st0->igf, st0->hIGFDec->igfData.igfInfo.grid, hCPE[0]->element_brate, st0->bwidth ); } @@ -208,6 +211,7 @@ void ivas_mct_side_bits_fx( IF( !bfi ) { availableBits = 0; + move16(); ivas_mct_dec_mct_fx( hMCT, sts, nChannels ); @@ -216,37 +220,59 @@ void ivas_mct_side_bits_fx( { st = sts[ch]; - IF( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) + IF( EQ_32( st->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) { chBitRatios[ch] = 0; st->bits_frame_channel = 0; + move16(); + move16(); continue; } chBitRatios[ch] = get_next_indice_fx( sts[0], NBBITS_MCT_RATIO ); - - nSubframes = ( st->core == TCX_10_CORE ) ? NB_DIV : 1; + IF( EQ_16( st->core, TCX_10_CORE ) ) + { + nSubframes = NB_DIV; + move16(); + } + ELSE + { + nSubframes = 1; + move16(); + } FOR( k = 0; k < nSubframes; k++ ) { - nf_side_bits += ( NBITS_TCX_GAIN + NOISE_FILL_RANGES * NBITS_NOISE_FILL_LEVEL ); + nf_side_bits = add( nf_side_bits, ( NBITS_TCX_GAIN + NOISE_FILL_RANGES * NBITS_NOISE_FILL_LEVEL ) ); } } - availableBits = (Word16) ( ( ivas_total_brate / FRAMES_PER_SEC ) - sts[0]->next_bit_pos - nf_side_bits ); - availableBits -= nb_bits_metadata; + tmp = BASOP_Util_Divide3232_Scale( ivas_total_brate, FRAMES_PER_SEC, &scale ); + tmp = shr( tmp, sub( 15, scale ) ); + + availableBits = (Word16) ( sub( sub( tmp, sts[0]->next_bit_pos ), nf_side_bits ) ); + availableBits = sub( availableBits, nb_bits_metadata ); splitAvailableBitsMCT( (void **) sts, availableBits, chBitRatios, DEC, nChannels ); next_bit_pos = sts[0]->next_bit_pos; + move16(); FOR( ch = 1; ch < nChannels; ch++ ) { - nf_bits = ( sts[ch - 1]->core == TCX_20_CORE ? 1 : NB_DIV ) * ( NBITS_TCX_GAIN + NOISE_FILL_RANGES * NBITS_NOISE_FILL_LEVEL ); + nf_bits = NB_DIV; + move16(); + if ( EQ_16( sts[ch - 1]->core, TCX_20_CORE ) ) + { + nf_bits = 1; + move16(); + } + nf_bits = imult1616( nf_bits, ( NBITS_TCX_GAIN + NOISE_FILL_RANGES * NBITS_NOISE_FILL_LEVEL ) ); - IF( chBitRatios[ch - 1] == 0 ) /* indicates LFE with no content */ + if ( chBitRatios[ch - 1] == 0 ) /* indicates LFE with no content */ { nf_bits = 0; + move16(); } - next_bit_pos += sts[ch - 1]->bits_frame_channel + nf_bits; + next_bit_pos = add( next_bit_pos, add( sts[ch - 1]->bits_frame_channel, nf_bits ) ); sts[ch]->bit_stream = bitstream + next_bit_pos; } } @@ -278,7 +304,7 @@ void ivas_mct_core_dec( Word16 tcx_offset; Word16 tcx_offsetFB; Word16 left_rect; - Word16 L_spec; + Word16 L_spec, scale, tmp1, tmp2; #ifdef DEBUG_MCT float nrg[MCT_MAX_CHANNELS]; #endif @@ -291,37 +317,43 @@ void ivas_mct_core_dec( *--------------------------------------------------------------------------------*/ nChannels = hMCT->nchan_out_woLFE; + move16(); /*initializations */ i = 0; + move16(); FOR( cpe_id = 0; cpe_id < nCPE; cpe_id++ ) { FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { sts[i] = hCPE[cpe_id]->hCoreCoder[ch]; - i++; + i = add( i, 1 ); } } i = 0; + move16(); FOR( ch = 0; ch < nChannels; ch++ ) { - IF( sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) + IF( EQ_32( sts[ch]->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) { continue; } - i++; + i = add( i, 1 ); } bfi = sts[0]->bfi; + move16(); FOR( ch = 0; ch < nChannels; ch++ ) { /* Initialization or re-configuration of Stereo TCX */ sts[ch]->enablePlcWaveadjust = 0; + move16(); x_fx[ch][0] = signal_out_fx[ch]; x_fx[ch][1] = signal_out_fx[ch] + ( L_FRAME48k / 2 ); q_x[ch] = Q12; + move16(); } IF( sts[0]->igf ) @@ -332,33 +364,51 @@ void ivas_mct_core_dec( { st = sts[ch]; - IF( sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) /*indicates LFE */ + if ( EQ_32( sts[ch]->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) /*indicates LFE */ { continue; } - IF( bfi && st->core == ACELP_CORE ) /*no igf processing needed*/ + test(); + if ( bfi && EQ_16( st->core, ACELP_CORE ) ) /*no igf processing needed*/ { continue; } - nSubframes = ( st->core == TCX_10_CORE ) ? NB_DIV : 1; + + IF( EQ_16( st->core, TCX_10_CORE ) ) + { + nSubframes = NB_DIV; + } + ELSE + { + nSubframes = 1; + } + move16(); FOR( k = 0; k < nSubframes; k++ ) { - L_spec = st->hTcxCfg->tcx_coded_lines / nSubframes; + L_spec = BASOP_Util_Divide1616_Scale( st->hTcxCfg->tcx_coded_lines, nSubframes, &scale ); + L_spec = shr( L_spec, sub( 15, scale ) ); - init_tcx_info_fx( st, st->L_frame / nSubframes, st->hTcxDec->L_frameTCX / nSubframes, k, bfi, &tcx_offset, &tcx_offsetFB, &L_frame, &L_frameTCX, &left_rect, &L_spec ); + tmp1 = BASOP_Util_Divide1616_Scale( st->L_frame, nSubframes, &scale ); + tmp1 = shr( tmp1, sub( 15, scale ) ); + tmp2 = BASOP_Util_Divide1616_Scale( st->hTcxDec->L_frameTCX, nSubframes, &scale ); + tmp2 = shr( tmp1, sub( 15, scale ) ); + init_tcx_info_fx( st, tmp1, tmp2, k, bfi, &tcx_offset, &tcx_offsetFB, &L_frame, &L_frameTCX, &left_rect, &L_spec ); Word16 x_e, x_len; /* mono or dual mono IGF decoding */ - x_e = 31 - q_x[ch]; + x_e = sub( 31, q_x[ch] ); decoder_tcx_IGF_mono_fx( st, x_fx[ch][k], &x_e, &x_len, L_frame, left_rect, bfi, k ); - q_x[ch] = 31 - x_e; - for ( i = 0; i < x_len; i++ ) + q_x[ch] = sub( 31, x_e ); + move16(); + FOR( i = 0; i < x_len; i++ ) { - x_fx[ch][k][i] = L_shr( x_fx[ch][k][i], q_x[ch] - Q12 ); + x_fx[ch][k][i] = L_shr( x_fx[ch][k][i], sub( q_x[ch], Q12 ) ); + move32(); } q_x[ch] = Q12; + move16(); } } } @@ -377,12 +427,15 @@ void ivas_mct_core_dec( apply_MCT_dec_fx( hMCT, sts, x_fx, q_x ); FOR( ch = 0; ch < nChannels; ch++ ) { - for ( i = 0; i < L_FRAME48k / 2; i++ ) + FOR( i = 0; i < L_FRAME48k / 2; i++ ) { - x_fx[ch][0][i] = L_shr( x_fx[ch][0][i], q_x[ch] - Q12 ); - x_fx[ch][1][i] = L_shr( x_fx[ch][1][i], q_x[ch] - Q12 ); + x_fx[ch][0][i] = L_shr( x_fx[ch][0][i], sub( q_x[ch], Q12 ) ); + x_fx[ch][1][i] = L_shr( x_fx[ch][1][i], sub( q_x[ch], Q12 ) ); + move32(); + move32(); } q_x[ch] = Q12; + move16(); } } -- GitLab From 63f9bc6dc1d547b5fc9798a7276d17450deca8f2 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 21 Jun 2024 14:06:16 +0530 Subject: [PATCH 2/3] Clang formatting changes --- lib_dec/er_dec_acelp_fx.c | 4 ++-- lib_dec/ivas_lfe_dec_fx.c | 2 +- lib_dec/ivas_masa_dec.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_dec/er_dec_acelp_fx.c b/lib_dec/er_dec_acelp_fx.c index debb8aad3..ca23584a1 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, M + 1), st->syn, 1 + M ); + Copy( syn + sub( st->L_frame, M + 1 ), st->syn, 1 + M ); /* update old_Aq */ Copy( p_A - ( M + 1 ), st->old_Aq_12_8_fx, M + 1 ); @@ -1097,7 +1097,7 @@ void con_acelp_fx( } FOR( ; i < W1; i++ ) { - 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)] ) ); + 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 ); diff --git a/lib_dec/ivas_lfe_dec_fx.c b/lib_dec/ivas_lfe_dec_fx.c index 4d5dd9591..32519adc2 100644 --- a/lib_dec/ivas_lfe_dec_fx.c +++ b/lib_dec/ivas_lfe_dec_fx.c @@ -240,7 +240,7 @@ static Word16 ivas_lfe_dec_dequant_fx( move16(); FOR( i = 0; i < 4; i++ ) { - abs_values[add( iii * 4 , i )] = get_next_indice_fx( st0, base2_bit_size ); + abs_values[add( iii * 4, i )] = get_next_indice_fx( st0, base2_bit_size ); move16(); } } diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 8b187d57a..a6f797e0a 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -914,7 +914,7 @@ ivas_error ivas_masa_decode_fx( { *nb_bits_read = add( *nb_bits_read, ivas_decode_masaism_metadata_fx( hQMetaData, st_ivas->hMasa, st_ivas->hMasaIsmData, st_ivas->nchan_ism, st->bit_stream, &st->next_bit_pos, st_ivas->hMasaIsmData->idx_separated_ism, ism_imp, 0, MAX_PARAM_SPATIAL_SUBFRAMES ) ); - move16(); + move16(); } } } -- GitLab From e0eaee409f97c7cf26fb6039ce252ae3c0d19ce4 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 21 Jun 2024 15:35:19 +0530 Subject: [PATCH 3/3] Corrected the index in ivas_lfe_dec_dequant_fx --- lib_dec/ivas_lfe_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_lfe_dec_fx.c b/lib_dec/ivas_lfe_dec_fx.c index 32519adc2..f615bbd1e 100644 --- a/lib_dec/ivas_lfe_dec_fx.c +++ b/lib_dec/ivas_lfe_dec_fx.c @@ -280,7 +280,7 @@ static Word16 ivas_lfe_dec_dequant_fx( { pOut_buf[2 * i] = Mpy_32_16_1( two_pow_shift_by_4, values[4 * i] ); // Q30 + Q9 >> 15 = Q24 move32(); - pOut_buf[add( 2 * i, 1 )] = Mpy_32_16_1( two_pow_shift_by_4, values[add( 2 * i, 1 )] ); // Q30 + Q9 >> 15 = Q24 + pOut_buf[add( 2 * i, 1 )] = Mpy_32_16_1( two_pow_shift_by_4, values[add( 4 * i, 1 )] ); // Q30 + Q9 >> 15 = Q24 move32(); pOut_buf[add( 2 * i, *num_dct_pass_bins )] = Mpy_32_16_1( two_pow_shift_by_4, values[add( 4 * i, 2 )] ); // Q30 + Q9 >> 15 = Q24 -- GitLab