diff --git a/lib_dec/FEC_HQ_core_fx.c b/lib_dec/FEC_HQ_core_fx.c index 49dab93588a863200675b1a0fcf3522397273592..f2209944953031b27796dfe8798b715ad9731a8c 100644 --- a/lib_dec/FEC_HQ_core_fx.c +++ b/lib_dec/FEC_HQ_core_fx.c @@ -397,8 +397,8 @@ void HQ_FEC_processing_fx( k = add( k, 1 ); #else hHQ_nbfec->Norm_gain_fx[k++] = shl( tmp_fx, 1 ); -#endif move16(); +#endif } } ELSE @@ -641,7 +641,6 @@ void ivas_HQ_FEC_Mem_update_fx( FOR( i = k; i < num_Sb; i++ ) { en_high_fx[i] = L_deposit_l( 0 ); - move32(); FOR( j = 0; j < 2; j++ ) { /*en_high[i] += 0.5f*st->ynrm_values[i][j+1];*/ @@ -787,7 +786,7 @@ void HQ_FEC_Mem_update_fx( } } #ifndef ADD_IVAS_HQ_CODE_FEC - if ( EQ_16( output_frame, L_FRAME8k ) ) + IF( EQ_16( output_frame, L_FRAME8k ) ) { #endif /* if LR MDCT core is used, recalculate norms from decoded MDCT spectrum (using code from hq_hr_enc_fx()) */ @@ -1161,7 +1160,6 @@ static Word16 Search_Max_Corr_fx( /*in = mu_o + 2*L -lin; */ in_fx = mu_o_fx + sub( shl( L, 1 ), lin ); - move16(); /* generate correlation */ delta = 2; @@ -1171,7 +1169,7 @@ static Word16 Search_Max_Corr_fx( pos = find_best_delay_fx( mu_o_fx, in_fx, mind1, maxd1, lin, delta, &false_flag ); - IF( false_flag ) + if ( false_flag ) { return 0; } @@ -1199,7 +1197,6 @@ static Word16 Search_Max_Corr_fx( mind1 = mult_r( L, 14746 ); /* min value of delay d1 to search for */ maxd1 = mult_r( L, 22938 ); /* max value of delay d1 to search for */ in_fx = mu_o_fx + sub( shl( L, 1 ), lin ); - move16(); /* generate correlation */ delta = 2; @@ -1209,7 +1206,7 @@ static Word16 Search_Max_Corr_fx( pos = find_best_delay_fx( mu_o_fx, in_fx, mind1, maxd1, lin, delta, &false_flag ); - IF( false_flag ) + if ( false_flag ) { return 0; } @@ -1276,7 +1273,7 @@ static Word16 FEC_phase_matching_fx( pos = Search_Max_Corr_fx( st_fx->old_auOut_2fr_fx, st_fx->old_Min_ind, L ); - IF( pos == 0 ) + if ( pos == 0 ) { return 1; } @@ -1659,7 +1656,7 @@ static Word16 Repetition_smoothing_fx( } - IF( GT_32( pow22_fx, L_add( pow1_fx, L_shl( pow1_fx, 1 ) ) ) ) + if ( GT_32( pow22_fx, L_add( pow1_fx, L_shl( pow1_fx, 1 ) ) ) ) { return 1; } diff --git a/lib_dec/FEC_adapt_codebook_fx.c b/lib_dec/FEC_adapt_codebook_fx.c index d6aec88404e2ecee34b8437376f9d46bb259e021..03e01f2bac8c2783f56b59e6328eeb756a26629e 100644 --- a/lib_dec/FEC_adapt_codebook_fx.c +++ b/lib_dec/FEC_adapt_codebook_fx.c @@ -333,7 +333,7 @@ Word16 FEC_synchro_exc_fx( /* o : do_WI flag IF( add( start_search, pos ) < 0 ) { start_search = negate( pos ); - IF( LT_16( abs_s( start_search ), shr( Old_pitch, 3 ) ) ) + if ( LT_16( abs_s( start_search ), shr( Old_pitch, 3 ) ) ) { /* it's not safe to remove/add point inside 1/8 of the pulse position */ return 0; @@ -423,6 +423,7 @@ Word16 FEC_synchro_exc_fx( /* o : do_WI flag { /* points_by_pos[i-1] = (Word16)(fact*(sqi[i-2]) - total_point+0.5) */ points_by_pos[i - 1] = sub( shr( extract_l( L_mac0( 64L, fact, sqi[i - 2] ) ), 7 ), total_point ); + move16(); total_point = add( total_point, points_by_pos[i - 1] ); /* ensure a constant increase */ @@ -515,9 +516,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(); /* Remove points */ FOR( j = 0; j < points_by_pos[i]; j++ ) { diff --git a/lib_dec/FEC_clas_estim_fx.c b/lib_dec/FEC_clas_estim_fx.c index 0c668df55ed762c801f29b4473adc0b24dde0e97..61b21cc11c5916866533a925748fda988d8734bd 100644 --- a/lib_dec/FEC_clas_estim_fx.c +++ b/lib_dec/FEC_clas_estim_fx.c @@ -101,6 +101,9 @@ void FEC_clas_estim_fx( Word16 pos_limit; Word16 codec_mode, narrowBand, tcxonly, preemph_fac; Word16 memmax; + move16(); + move16(); + move16(); nb_subfr = shr( L_frame, 6 ); memmax = 0; @@ -181,6 +184,7 @@ void FEC_clas_estim_fx( Scale_sig( mem_syn_clas_estim, L_SYN_MEM_CLAS_ESTIM, tmp_scale_mem ); *Q_mem_syn = add( *Q_mem_syn, tmp_scale_mem ); + move16(); } } @@ -192,6 +196,7 @@ void FEC_clas_estim_fx( /*Tell MODE2 decoder the scaling of the buffer*/ *Q_mem_syn = add( add( Q_syn, tmp_scale_syn ), tmp_scale ); + move16(); /**Q_mem_syn = *Q_syn; move16();*/ @@ -340,7 +345,7 @@ void FEC_clas_estim_fx( pc = shr( abs_s( sub( add( pitch[3], sub( pitch[2], pitch[1] ) ), pitch[0] ) ), 6 ); #endif - if ( EQ_16( L_frame, L_FRAME16k ) ) + IF( EQ_16( L_frame, L_FRAME16k ) ) { pc = mult_r( pc, 26214 ); /* Renormalization for 12.8kHz core*/ } @@ -453,13 +458,14 @@ void FEC_clas_estim_fx( #endif BASOP_SATURATE_WARNING_ON_EVS test(); - if ( EQ_16( codec_mode, MODE2 ) && narrowBand != 0 ) + IF( EQ_16( codec_mode, MODE2 ) && narrowBand != 0 ) { fmerit1 = mult_r( fmerit1, 29491 /*0.9f Q15*/ ); /* 0.90 */ } IF( EQ_16( codec_mode, MODE1 ) ) { *class_para = round_fx( L_shl( Ltmp, 14 - 8 ) ); /*Q14 - cannot be saturated, degrades HF synthesis */ + move16(); } /*------------------------------------------------------------------------* @@ -467,7 +473,7 @@ void FEC_clas_estim_fx( *------------------------------------------------------------------------*/ test(); test(); - if ( ( NE_16( coder_type, VOICED ) && LT_32( bitrate, ACELP_11k60 ) ) || Opt_AMR_WB ) + IF( ( NE_16( coder_type, VOICED ) && LT_32( bitrate, ACELP_11k60 ) ) || Opt_AMR_WB ) { Word16 result = UNVOICED_CLAS; move16(); @@ -539,7 +545,7 @@ void FEC_clas_estim_fx( move16(); } - if ( EQ_16( coder_type, INACTIVE ) ) + IF( EQ_16( coder_type, INACTIVE ) ) { *decision_hyst = sub( *decision_hyst, 10 ); move16(); @@ -669,6 +675,7 @@ void FEC_clas_estim_fx( Ltmp = L_mac( Ltmp, 29491 /*0.9f*/, *LT_UV_cnt ); /* Q22*/ /* Store */ *LT_UV_cnt = round_fx( Ltmp ); + move16(); } /*-----------------------------------------------------------------------------* @@ -862,7 +869,7 @@ Word16 FEC_pos_dec_fx( test(); test(); test(); - IF( EQ_16( st_fx->coder_type, GENERIC ) && EQ_16( st_fx->clas_dec, VOICED_CLAS ) && ( LE_16( st_fx->last_good, UNVOICED_CLAS ) || EQ_16( st_fx->last_good, INACTIVE_CLAS ) ) ) + if ( EQ_16( st_fx->coder_type, GENERIC ) && EQ_16( st_fx->clas_dec, VOICED_CLAS ) && ( LE_16( st_fx->last_good, UNVOICED_CLAS ) || EQ_16( st_fx->last_good, INACTIVE_CLAS ) ) ) { st_fx->clas_dec = SIN_ONSET; move16(); @@ -876,7 +883,7 @@ Word16 FEC_pos_dec_fx( 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 ) ) + 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 */ bit_pos_pitch_index = add( bit_pos_pitch_index, 1 ); @@ -900,7 +907,7 @@ Word16 FEC_pos_dec_fx( *last_pulse_pos = negate( s_and( *last_pulse_pos, 0x7F ) ); move16(); } - if ( GE_16( T0, 128 ) ) + IF( GE_16( T0, 128 ) ) { *last_pulse_pos = add( *last_pulse_pos, *last_pulse_pos ); move16(); diff --git a/lib_dec/FEC_fx.c b/lib_dec/FEC_fx.c index 7353f8f83b03b8a852ab8800343b0a060b26ec17..a7d1527ef065bd0ccd97a117fbbcaf1f2c3a1443 100644 --- a/lib_dec/FEC_fx.c +++ b/lib_dec/FEC_fx.c @@ -204,6 +204,7 @@ void FEC_exc_estim_fx( { /* take the pitch value of last subframe of the previous frame */ *tmp_tc = round_fx( L_shl( st_fx->old_pitch_buf_fx[2 * NB_SUBFR - 1], 6 ) ); + move16(); } } ELSE /* L_frame == L_FRAME16k */ @@ -222,6 +223,7 @@ void FEC_exc_estim_fx( { /* take the pitch value of last subframe of the previous frame */ *tmp_tc = round_fx( L_shl( st_fx->old_pitch_buf_fx[2 * NB_SUBFR16k - 1], 6 ) ); + move16(); } } @@ -357,6 +359,7 @@ void FEC_exc_estim_fx( /* move pitch gain towards 1 for voiced to remove energy fluctuations */ /*gain = (float)sqrt( st_fx->lp_gainp );*/ st_fx->lp_gainp_fx = s_max( st_fx->lp_gainp_fx, 1 ); + move16(); exp = norm_s( st_fx->lp_gainp_fx ); tmp = shl( st_fx->lp_gainp_fx, exp ); tmp = div_s( 16384, tmp ); @@ -394,9 +397,7 @@ void FEC_exc_estim_fx( { pt_exc = exc; - move16(); pt1_exc = pt_exc - Tc; - move16(); IF( EQ_16( st_fx->nbLostCmpt, 1 ) ) { @@ -488,6 +489,7 @@ void FEC_exc_estim_fx( { /* exc[i] *= gain */ exc[i] = round_fx( L_shl( L_mult( exc[i], gain ), 1 ) ); /* in Q_exc */ + move16(); /* gain -= step */ gain = sub( gain, step ); } @@ -543,6 +545,7 @@ void FEC_exc_estim_fx( 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*/ + move16(); /* Transform back to time domain */ edct_16fx( exc_dct_in, exc, st_fx->L_frame, 5, st_fx->element_mode ); } @@ -574,6 +577,7 @@ void FEC_exc_estim_fx( L_tmp = L_mult( alpha, st_fx->lp_gainc_fx ); st_fx->lp_gainc_fx = msu_r( L_tmp, add( alpha, -32768 ), gainCNG ); + move16(); } ELSE { /* Here alpha is in Q14, but lp_gainc still in Q3 */ @@ -581,6 +585,7 @@ void FEC_exc_estim_fx( L_tmp = L_mult( alpha, st_fx->lp_gainc_fx ); /* Q14*Q3->Q18 */ st_fx->lp_gainc_fx = round_fx( L_shl( L_msu( L_tmp, add( alpha, -16384 ), gainCNG ), 1 ) ); /* (Q14*Q3<<1)>>16 ->Q3 */ + move16(); } test(); @@ -596,7 +601,7 @@ void FEC_exc_estim_fx( /* step = (1.0f/L_FRAME) * (gain - *lp_gainc); */ step = sub( gain, st_fx->lp_gainc_fx ); /* divide by L_FRAME done later */ test(); - if ( EQ_16( L_frame, L_FRAME16k ) ) + IF( EQ_16( L_frame, L_FRAME16k ) ) { step = mult_r( step, 26214 ); /* L_frame16k-> L_frame and division by L_frame done later*/ } @@ -622,7 +627,7 @@ void FEC_exc_estim_fx( L_tmp = L_add( L_tmp, L_shr( L_tmp2, 1 ) ); /* Q-7 */ } test(); - if ( EQ_16( L_frame, L_FRAME16k ) ) + IF( EQ_16( L_frame, L_FRAME16k ) ) { L_tmp = Mult_32_16( L_tmp, 26214 ); /* x0.8 to normalize to 256 samples */ } @@ -636,7 +641,7 @@ void FEC_exc_estim_fx( /* attenuate somewhat on unstable unvoiced */ test(); test(); - if ( ( EQ_16( st_fx->last_good, UNVOICED_CLAS ) || EQ_16( st_fx->last_good, INACTIVE_CLAS ) ) && NE_16( st_fx->last_coder_type, UNVOICED ) ) + IF( ( EQ_16( st_fx->last_good, UNVOICED_CLAS ) || EQ_16( st_fx->last_good, INACTIVE_CLAS ) ) && NE_16( st_fx->last_coder_type, UNVOICED ) ) { gain_inov = mult_r( gain_inov, 26214 ); } @@ -798,6 +803,7 @@ static void pulseRes_preCalc( Word16 *cond1, Word16 *cond2, Word32 *cond3, Word1 Word32 tmp_pit2; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif tmp_pit = BASOP_Util_Divide1616_Scale( new_pit /*Q0*/, Tc /*Q0*/, &tmp_pit_e ) /*Q15*/; @@ -814,8 +820,10 @@ static void pulseRes_preCalc( Word16 *cond1, Word16 *cond2, Word32 *cond3, Word1 #endif BASOP_SATURATE_WARNING_ON_EVS *cond1 = sub( tmp_pit, negate( tmp_frame ) ); + move16(); *cond2 = sub( Tc, new_pit ); + move16(); tmp_pit_e = BASOP_Util_Add_MantExp( new_pit, 15 - 0, negate( Tc ), 15 - 0, &tmp_pit ); /*Q15*/ tmp_pit = abs_s( tmp_pit ); @@ -829,6 +837,7 @@ static void pulseRes_preCalc( Word16 *cond1, Word16 *cond2, Word32 *cond3, Word1 #endif BASOP_SATURATE_WARNING_ON_EVS *cond3 = L_sub( L_mult0( -1, tmp_pit ), tmp_pit2 ); + move32(); } /*-------------------------------------------------------------------* diff --git a/lib_dec/FEC_scale_syn_fx.c b/lib_dec/FEC_scale_syn_fx.c index 8448695c1fc517838e124cb175bcefee213d3d2e..7aa2056a21d49f6bba43882295e221e66ec410b0 100644 --- a/lib_dec/FEC_scale_syn_fx.c +++ b/lib_dec/FEC_scale_syn_fx.c @@ -172,7 +172,6 @@ void FEC_scale_syn_fx( * Find the energy/gain at the end of the frame *-----------------------------------------------------------------*/ - /*fer_energy( L_frame, clas, synth, pitch[(L_frame>>6)-1], &enr2, L_frame );*/ frame_ener_fx( L_frame, clas, synth, pitch[sub( shr( L_frame, 6 ), 1 )], &L_enr2 /*Q0*/, 1, Q_syn, 3, 0 ); test(); diff --git a/lib_dec/ari_dec_fx.c b/lib_dec/ari_dec_fx.c index 385a50d41830af911c122a4f8ef3f89f03d20b7b..c1fe8880968b7742f0093b781f0e1eb1c551b8e7 100644 --- a/lib_dec/ari_dec_fx.c +++ b/lib_dec/ari_dec_fx.c @@ -15,7 +15,7 @@ Word32 ari_decode_overflow_fx( Tastat *s ) { - return LE_32( L_sub( L_sub( s->high, 1 ), s->low ), 0 ); + return ( L_sub( L_sub( s->high, 1 ), s->low ) <= 0 ); } /** @@ -157,12 +157,12 @@ static Word16 ari_lookup_s27_fx( move16(); /* (il + ih) >> 1 */ tmp = L_multi31x16_X2( range_h, range_l, cum_freq[im] ); tmp = L_sub( tmp, cum ); - IF( GT_32( tmp, 0 ) ) + if ( ( tmp > 0 ) ) { il = im; move16(); } - IF( LE_32( tmp, 0 ) ) + if ( ( tmp <= 0 ) ) { ih = im; move16(); @@ -171,12 +171,12 @@ static Word16 ari_lookup_s27_fx( im = shr( add( il, ih ), 1 ); tmp = L_multi31x16_X2( range_h, range_l, cum_freq[im] ); tmp = L_sub( tmp, cum ); - IF( GT_32( tmp, 0 ) ) + if ( tmp > 0 ) { il = im; move16(); } - IF( LE_32( tmp, 0 ) ) + if ( tmp <= 0 ) { ih = im; move16(); @@ -185,12 +185,12 @@ static Word16 ari_lookup_s27_fx( im = shr( add( il, ih ), 1 ); tmp = L_multi31x16_X2( range_h, range_l, cum_freq[im] ); tmp = L_sub( tmp, cum ); - IF( GT_32( tmp, 0 ) ) + if ( tmp > 0 ) { il = im; move16(); } - IF( LE_32( tmp, 0 ) ) + if ( tmp <= 0 ) { ih = im; move16(); @@ -199,12 +199,12 @@ static Word16 ari_lookup_s27_fx( im = shr( add( il, ih ), 1 ); tmp = L_multi31x16_X2( range_h, range_l, cum_freq[im] ); tmp = L_sub( tmp, cum ); - IF( GT_32( tmp, 0 ) ) + if ( tmp > 0 ) { il = im; move16(); } - IF( LE_32( tmp, 0 ) ) + if ( tmp <= 0 ) { ih = im; move16(); @@ -216,7 +216,7 @@ static Word16 ari_lookup_s27_fx( im = add( il, 1 ); /* (il + ih) >> 1 */ tmp = L_multi31x16_X2( range_h, range_l, cum_freq[im] ); tmp = L_sub( tmp, cum ); - IF( GT_32( tmp, 0 ) ) + if ( tmp > 0 ) { il = im; move16(); @@ -232,18 +232,19 @@ static Word16 ari_lookup_bit_fx( UWord16 const *cum_freq ) { Word16 symbol = 0; /* initialize just to avoid compiler warning */ + move16(); (void) cum_freq; range = L_shl( range, 13 ); /* L_multi31x16_X2(range_h, range_l, 8192) */ cum = L_sub( range, cum ); - IF( GT_32( cum, 0 ) ) + if ( cum > 0 ) { symbol = 1; move16(); } - IF( LE_32( cum, 0 ) ) + if ( cum <= 0 ) { symbol = 0; move16(); @@ -276,7 +277,7 @@ static Word16 ari_decode_14bits_ext_fx( range = L_sub( high, low ); cum = L_add( L_shl( L_sub( value, low ), stat_bitsnew ), sub( shl( 1, stat_bitsnew ), 1 ) ); - IF( LT_32( cum, 0 ) ) + if ( cum < 0 ) { cum = 0x7fffffff; move32(); @@ -342,6 +343,9 @@ Word16 ari_decode_14bits_s27_ext_fx( Decoder_State *st, Tastat *s, UWord16 const Word16 ari_decode_14bits_bit_ext_fx( Decoder_State *st, Tastat *s ) { static const UWord16 cum_freq[3] = { 16384, 8192, 0 }; + move16(); + move16(); + move16(); return ari_decode_14bits_ext_fx( st, s, cum_freq, ari_lookup_bit_fx ); } @@ -382,7 +386,7 @@ static Word16 ari_lookup_pow_fx( Tastat *s, Word16 base ) move16(); testval = mult_r( pows[k], base ); - IF( LE_32( L_multi31x16_X2( range_h, range_l, testval >> 1 ), cum ) ) /* found! big range is [lowlim,testval], (now narrow it down) */ + IF( LE_32( L_multi31x16_X2( range_h, range_l, shr( testval, 1 ) ), cum ) ) /* found! big range is [lowlim,testval], (now narrow it down) */ { lowlim = testval; move16(); @@ -398,7 +402,7 @@ static Word16 ari_lookup_pow_fx( Tastat *s, Word16 base ) { testval = mult_r( highlim, pows[k + 1] ); - IF( LE_32( L_multi31x16_X2( range_h, range_l, testval >> 1 ), cum ) ) + IF( LE_32( L_multi31x16_X2( range_h, range_l, shr( testval, 1 ) ), cum ) ) { lowlim = testval; move16(); diff --git a/lib_dec/ari_hm_dec.c b/lib_dec/ari_hm_dec.c index fbd863d6fc2d4592f125665a97613d1890bb9053..1611f0b9194747c35bb608beb581d6ddce4b5782 100644 --- a/lib_dec/ari_hm_dec.c +++ b/lib_dec/ari_hm_dec.c @@ -92,9 +92,10 @@ DecodeIndex_fx( hTcxDec = st->hTcxDec; test(); - IF( GT_16( hTcxDec->tcx_hm_LtpPitchLag, 0 ) && GT_16( hTcxLtpDec->tcxltp_gain, kLtpHmGainThr ) ) + IF( hTcxDec->tcx_hm_LtpPitchLag > 0 && GT_16( hTcxLtpDec->tcxltp_gain, kLtpHmGainThr ) ) { - Word16 LtpPitchIndex = sub( mult_r( hTcxDec->tcx_hm_LtpPitchLag, shl( 1, sub( 15, kLtpHmFractionalResolution ) ) ), 2 ); + Word16 LtpPitchIndex; + LtpPitchIndex = sub( mult_r( hTcxDec->tcx_hm_LtpPitchLag, shl( 1, sub( 15, kLtpHmFractionalResolution ) ) ), 2 ); *PeriodicityIndex = kLtpHmFlag; move16(); @@ -278,11 +279,10 @@ void tcx_hm_decode( move16(); /* Convert the index to lag */ + test(); UnmapIndex_fx( prm_hm[1], ( L_frame_m_256 >= 0 ), LtpPitchLag, ( ( LE_16( NumTargetBits, kSmallerLagsTargetBitsThreshold ) ) || ( L_frame_m_256 < 0 ) ), &fract_res, &lag ); - test(); - test(); /* Render the harmonic model */ IF( tcx_hm_render_fx( lag, fract_res, p ) ) diff --git a/lib_dec/d_gain2p_fx.c b/lib_dec/d_gain2p_fx.c index 63eff5413795ce52a79bc6208eaf96deb046e82f..b93accc7289bda1537e2155faddf442b0f9d5c48 100644 --- a/lib_dec/d_gain2p_fx.c +++ b/lib_dec/d_gain2p_fx.c @@ -26,11 +26,13 @@ static Word32 calc_gcode0_fx( L_tmp = L_mult( *gcode0, 5443 /*0.166096f Q15*/ ); *exp_gcode0 = add( 1, extract_l( L_shr( L_tmp, 24 ) ) ); + move16(); L_tmp = L_lshl( L_tmp, 7 ); L_tmp = L_and( 0x7FFFFFFF, L_tmp ); L_tmp = Pow2( 30, round_fx( L_tmp ) ); *gcode0 = round_fx( L_tmp ); + move16(); return L_tmp; } @@ -85,6 +87,7 @@ static void Mode2_gain_dec_mless_fx( #else *gain_inov = round_fx( L_shl( L_tmp, 15 - 3 ) ); /* gain_inov in Q12 */ #endif + move16(); /*-----------------------------------------------------------------* * Select the gains quantization table *-----------------------------------------------------------------*/ @@ -129,7 +132,8 @@ static void Mode2_gain_dec_mless_fx( * decode normalized codebook gain *-----------------------------------------------------------------*/ /* *gain_code = t_qua_gain[index*2+1] * gcode0;*/ - Word16 tmp_idx = add( shl( index, 1 ), 1 ); + Word16 tmp_idx; + tmp_idx = add( shl( index, 1 ), 1 ); L_tmp = calc_gain_code_fx( t_qua_gain[tmp_idx], gcode0, exp_gcode0 ); *gain_code = L_tmp; @@ -140,6 +144,7 @@ static void Mode2_gain_dec_mless_fx( /* Q16/Q12 => Q5 */ L_tmp1 = L_deposit_h( BASOP_Util_Divide3216_Scale( L_tmp, *gain_inov, &exp_L_tmp1 ) ); *past_gcode = L_shl( L_tmp1, sub( exp_L_tmp1, 15 - 12 ) ); + move32(); return; @@ -251,6 +256,7 @@ static void gain_dec_gacelp_uv_fx( /* gain_inov = 1.0f / sqrt((dot_product(code, code, L_SUBFR) + 0.01) / L_SUBFR) */ L_tmp = calc_gain_inov( code, lcode, NULL, NULL ); *gain_inov = round_fx( L_shl( L_tmp, 15 - 3 ) ); /* gain_inov in Q12 */ + move16(); /* gcode = pred_nrg_frame * (*gain_inov); */ L_tmp = Mpy_32_16_1( pred_nrg_frame, *gain_inov ); /* 18Q13 */ @@ -325,6 +331,7 @@ static void gain_dec_gacelp_uv_fx( L_tmp1 = L_add( L_tmp1, L_tmp ); } *gain_code2 = L_tmp1; + move32(); return; diff --git a/lib_dec/dec_LPD_fx.c b/lib_dec/dec_LPD_fx.c index c870b04a03b7973ab10ad57106a8d3891f6d1091..8e50850c41b2d5079d89b684cebee551d325d7bc 100644 --- a/lib_dec/dec_LPD_fx.c +++ b/lib_dec/dec_LPD_fx.c @@ -96,7 +96,7 @@ void decoder_LPD_fx( } /*Adjust bit per frame*/ - if ( bfi == 0 ) + IF( bfi == 0 ) { st->bits_frame_core = sub( st->bits_frame, bitsRead[0] ); move16(); @@ -132,7 +132,7 @@ void decoder_LPD_fx( /* PLC: [Common: Memory update] * PLC: Update the number of lost frames */ - if ( bfi != 0 ) + IF( bfi != 0 ) { move16(); st->nbLostCmpt = add( st->nbLostCmpt, 1 ); @@ -197,7 +197,7 @@ void decoder_LPD_fx( /* PLC: [Common: mode decision] * PLC: Decide which Concealment to use. Update pitch lags if needed */ - if ( bfi != 0 ) + IF( bfi != 0 ) { st->core = GetPLCModeDecision_fx( st ); move16(); @@ -233,6 +233,7 @@ void decoder_LPD_fx( test(); test(); test(); + test(); IF( EQ_16( st->use_partial_copy, 1 ) && ( LT_16( st->rf_frame_type, RF_TCXFD ) || GT_16( st->rf_frame_type, RF_TCXTD2 ) ) ) { IF( EQ_16( (Word16) hTcxDec->envWeighted, 1 ) ) @@ -255,6 +256,7 @@ void decoder_LPD_fx( Word16 tmp = lsf_q_diff_cb_8b_rf[i + M * param_lpc[1]]; /*tmp = unquantized lsf difference (2nd VQ) in Q6*/ tmp = shr( mult_r( tmp, 20972 ), 4 ); /* bring tmp to Qx2.56 for addition */ lsf_q_rf[i] = add( lsf_q_1st_rf[i], tmp ); + move16(); } v_sort( lsf_q_rf, 0, M - 1 ); @@ -399,7 +401,6 @@ void decoder_LPD_fx( Copy( st->lsf_old_fx, st->old_lsf_q_cng, M ); Copy( st->lsp_old_fx, st->old_lsp_q_cng, M ); } - move16(); xsfBase = PlcGetLsfBase( st->lpcQuantization, (Word16) st->narrowBand, st->sr_core ); dlpc_bfi( st->L_frame, xsfnew_uw, st->lsfold_uw, st->last_good, st->nbLostCmpt, st->mem_MA_fx, st->mem_AR_fx, @@ -536,7 +537,7 @@ void decoder_LPD_fx( test(); test(); test(); - IF( EQ_16( st->clas_dec, UNVOICED_CLAS ) || EQ_16( st->clas_dec, SIN_ONSET ) || EQ_16( st->clas_dec, INACTIVE_CLAS ) || EQ_16( st->coder_type, GENERIC ) || EQ_16( st->coder_type, TRANSITION ) ) + if ( EQ_16( st->clas_dec, UNVOICED_CLAS ) || EQ_16( st->clas_dec, SIN_ONSET ) || EQ_16( st->clas_dec, INACTIVE_CLAS ) || EQ_16( st->coder_type, GENERIC ) || EQ_16( st->coder_type, TRANSITION ) ) { st->relax_prev_lsf_interp = 1; move16(); @@ -548,7 +549,7 @@ void decoder_LPD_fx( test(); test(); test(); - IF( st->stab_fac_fx == 0 && st->old_bfi_cnt > 0 && NE_16( st->clas_dec, VOICED_CLAS ) && NE_16( st->clas_dec, ONSET ) && st->relax_prev_lsf_interp == 0 ) + if ( st->stab_fac_fx == 0 && st->old_bfi_cnt > 0 && NE_16( st->clas_dec, VOICED_CLAS ) && NE_16( st->clas_dec, ONSET ) && st->relax_prev_lsf_interp == 0 ) { st->relax_prev_lsf_interp = 2; move16(); @@ -854,7 +855,7 @@ void decoder_LPD_fx( *--------------------------------------------------------------------------------*/ test(); - IF( bfi && NE_16( st->last_core_bfi, ACELP_CORE ) ) + IF( bfi && st->last_core_bfi != ACELP_CORE ) { /* Update FEC_scale_syn parameters */ IF( hTcxLtpDec->tcxltp_gain == 0 ) @@ -921,7 +922,7 @@ void decoder_LPD_fx( /* update CNG parameters in active frames */ test(); test(); - IF( EQ_16( st->bwidth, NB ) && hTcxDec->enableTcxLpc != 0 && NE_16( st->core, ACELP_CORE ) ) + IF( EQ_16( st->bwidth, NB ) && hTcxDec->enableTcxLpc != 0 && st->core != ACELP_CORE ) { Word16 buf[L_LP], res[L_FRAME], A[M + 1], Qexc, r_l[M + 1], r_h[M + 1], lsptmp[M], Q_r, tmp; @@ -950,7 +951,7 @@ void decoder_LPD_fx( /* Set 16k LSP flag for CNG buffer */ st->hTdCngDec->ho_16k_lsp[st->hTdCngDec->ho_circ_ptr] = 1; move16(); - if ( EQ_16( st->L_frame, L_FRAME ) ) + IF( EQ_16( st->L_frame, L_FRAME ) ) { st->hTdCngDec->ho_16k_lsp[st->hTdCngDec->ho_circ_ptr] = 0; move16(); diff --git a/lib_dec/dec_higher_acelp_fx.c b/lib_dec/dec_higher_acelp_fx.c index 042a69b3abefdda66e966b73870bff26c296bca0..51a7ab962e2c727c049d1fec85e9571e235c4288 100644 --- a/lib_dec/dec_higher_acelp_fx.c +++ b/lib_dec/dec_higher_acelp_fx.c @@ -39,7 +39,8 @@ void transf_cdbk_dec_fx( #ifdef IVAS_CODE Word16 avq_bit_sFlag; Word16 trgtSvPos; - Word16 Nsv = 8; + Word16 Nsv; + Nsv = 8; move16(); avq_bit_sFlag = 0; @@ -89,6 +90,7 @@ void transf_cdbk_dec_fx( L_tmp = L_shl( L_tmp, 5 ); /* Q13 -> Q18*/ *gain_preQ = round_fx( L_tmp ); /* Q2*/ #endif + move16(); } ELSE { @@ -113,6 +115,7 @@ void transf_cdbk_dec_fx( } L_tmp = L_shl( L_tmp, add( exp16, 9 ) ); /* Q18*/ *gain_preQ = round_fx( L_tmp ); /* Q2*/ + move16(); } #ifdef IVAS_CODE trgtSvPos = sub( Nsv, 1 ); @@ -184,7 +187,7 @@ void transf_cdbk_dec_fx( *--------------------------------------------------------------*/ /* in extreme cases at subframe boundaries, lower the preemphasis memory to avoid a saturation */ test(); - if ( ( nq[7] != 0 ) && ( GT_16( sub( st_fx->last_nq_preQ, nq[0] ), 7 ) ) ) + IF( ( nq[7] != 0 ) && ( GT_16( sub( st_fx->last_nq_preQ, nq[0] ), 7 ) ) ) { /* *mem_preemp /= 16; */ st_fx->mem_preemp_preQ_fx = shr( st_fx->mem_preemp_preQ_fx, 4 ); @@ -200,7 +203,7 @@ void transf_cdbk_dec_fx( test(); test(); test(); - IF( GT_16( st_fx->element_mode, EVS_MONO ) && NE_16( st_fx->coder_type, INACTIVE ) && GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && LE_32( st_fx->core_brate, MAX_BRATE_AVQ_EXC_TD ) && !harm_flag_acelp && code_preQ[0] != 0 ) + IF( st_fx->element_mode > EVS_MONO && NE_16( st_fx->coder_type, INACTIVE ) && GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && LE_32( st_fx->core_brate, MAX_BRATE_AVQ_EXC_TD ) && !harm_flag_acelp && code_preQ[0] != 0 ) { // PMT("Fixed point taking accound of the scaling needs to be done here ") IF( GT_16( abs_s( st_fx->last_code_preq ), shl_sat( abs_s( code_preQ[0] ), 4 ) ) ) @@ -338,6 +341,7 @@ Word16 gain_dequant_fx( /* o: decoded gain */ /* output of Pow2() will be: */ /* 16384 < Pow2() <= 32767 */ *expg = sub( *expg, 14 ); + move16(); return ( gain ); } diff --git a/lib_dec/dec_pit_exc_fx.c b/lib_dec/dec_pit_exc_fx.c index 37e1d2730ba7a5e36cacf6e2734b6985c94abc77..d65183d81d7e1eb902fdbc94e8fe83226b3ee44e 100644 --- a/lib_dec/dec_pit_exc_fx.c +++ b/lib_dec/dec_pit_exc_fx.c @@ -50,12 +50,11 @@ void dec_pit_exc_fx( ) { Word16 T0_fx, T0_frac_fx, T0_min_fx, T0_max_fx; /* integer pitch variables */ - Word16 gain_pit_fx = 0; /* pitch gain Q14 */ - move16(); - Word32 gain_code_fx; /* gain/normalized gain of the algebraic excitation Q16 */ - Word32 norm_gain_code_fx; /* normalized gain of the algebraic excitation Q16 */ - Word16 gain_inov_fx; /* Innovation gain Q12 */ - Word16 voice_fac_fx; /* voicing factor Q15 */ + Word16 gain_pit_fx; /* pitch gain Q14 */ + Word32 gain_code_fx; /* gain/normalized gain of the algebraic excitation Q16 */ + Word32 norm_gain_code_fx; /* normalized gain of the algebraic excitation Q16 */ + Word16 gain_inov_fx; /* Innovation gain Q12 */ + Word16 voice_fac_fx; /* voicing factor Q15 */ Word16 L_subfr_fx, pit_idx_fx; const Word16 *p_Aq_fx; /* Pointer to frame LP coefficient Q12 */ Word16 *pt_pitch_fx; /* pointer to floating pitch Q6 */ @@ -69,6 +68,8 @@ void dec_pit_exc_fx( Word32 L_tmp; Word16 nbits; GSC_DEC_HANDLE hGSCDec; + gain_pit_fx = 0; + move16(); hGSCDec = st_fx->hGSCDec; MUSIC_POSTFILT_HANDLE hMusicPF; @@ -149,6 +150,9 @@ void dec_pit_exc_fx( test(); test(); test(); + test(); + test(); + test(); IF( ( ( GE_32( st_fx->core_brate, MIN_RATE_FCB ) || ( EQ_16( st_fx->GSC_noisy_speech, 1 ) && ( ( EQ_16( st_fx->L_frame, L_FRAME ) && GE_32( st_fx->core_brate, ACELP_13k20 ) ) || ( EQ_16( st_fx->L_frame, L_FRAME16k ) && GE_32( st_fx->core_brate, GSC_H_RATE_STG ) ) || st_fx->GSC_IVAS_mode == 0 ) ) ) && EQ_16( L_subfr_fx, L_SUBFR ) ) ) { use_fcb = 1; @@ -209,6 +213,7 @@ void dec_pit_exc_fx( L_subfr_fx #endif ); + move16(); } ELSE IF( EQ_16( use_fcb, 2 ) ) /* IVAS only */ { @@ -226,6 +231,7 @@ void dec_pit_exc_fx( L_subfr_fx #endif ); + move16(); } ELSE { @@ -285,6 +291,7 @@ void dec_pit_exc_fx( L_tmp = L_shl( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1 ); /*Q16+Q_exc*/ exc_fx[i + i_subfr_fx] = round_fx( L_tmp ); /*Q_exc*/ #endif + move16(); } } ELSE @@ -299,6 +306,7 @@ void dec_pit_exc_fx( #else exc_fx[i + i_subfr_fx] = round_fx( L_tmp ); /*Q_exc*/ #endif + move16(); } } } @@ -324,7 +332,6 @@ void dec_pit_exc_fx( move16(); move16(); move16(); - move16(); p_Aq_fx += 5 * ( M + 1 ); } ELSE IF( EQ_16( L_subfr_fx, L_FRAME16k / 2 ) ) @@ -336,14 +343,12 @@ void dec_pit_exc_fx( pt_pitch_fx++; p_Aq_fx += 2 * ( M + 1 ); move16(); - move16(); - move16(); - move16(); /* update gains for FEC - equivalent to lp_gain_updt() */ st_fx->lp_gainp_fx = extract_h( L_mult( 6554, gain_pit_fx ) ); /*Q14 (3/15 in Q15 9830)*/ st_fx->lp_gainc_fx = 0; - move32(); + move16(); + move16(); } ELSE { @@ -355,19 +360,17 @@ void dec_pit_exc_fx( p_Aq_fx += 3 * ( M + 1 ); move16(); move16(); - move16(); - move16(); /* update gains for FEC - equivalent to lp_gain_updt() */ st_fx->lp_gainp_fx = extract_h( L_mult( 26214, gain_pit_fx ) ); /*Q14 (12/15 in Q15 9830)*/ st_fx->lp_gainc_fx = 0; - move32(); + move16(); + move16(); } } ELSE IF( EQ_16( L_subfr_fx, 128 ) ) /*2*L_SUBFR*/ { p_Aq_fx += 2 * ( M + 1 ); - move16(); pt_pitch_fx++; *pt_pitch_fx = *( pt_pitch_fx - 1 ); move16(); @@ -384,6 +387,7 @@ void dec_pit_exc_fx( st_fx->lp_gainp_fx = extract_h( L_mult( 9830, gain_pit_fx ) ); /*Q14 (3/10 in Q15 9830)*/ st_fx->lp_gainc_fx = 0; move16(); + move16(); } ELSE { @@ -391,6 +395,7 @@ void dec_pit_exc_fx( st_fx->lp_gainp_fx = extract_h( L_mult( 22938, gain_pit_fx ) ); /*Q14 (7/10 in Q15 22938)*/ st_fx->lp_gainc_fx = 0; move16(); + move16(); } } ELSE IF( EQ_16( L_subfr_fx, 256 ) ) /*4*L_SUBFR*/ @@ -418,7 +423,6 @@ void dec_pit_exc_fx( move16(); pt_gain++; p_Aq_fx += 4 * ( M + 1 ); - move16(); /* update gains for FEC - equivalent to lp_gain_updt() */ st_fx->lp_gainp_fx = gain_pit_fx; @@ -485,12 +489,11 @@ void dec_pit_exc_ivas_fx( ) { Word16 T0_fx, T0_frac_fx, T0_min_fx, T0_max_fx; /* integer pitch variables */ - Word16 gain_pit_fx = 0; /* pitch gain Q14 */ - move16(); - Word32 gain_code_fx; /* gain/normalized gain of the algebraic excitation Q16 */ - Word32 norm_gain_code_fx; /* normalized gain of the algebraic excitation Q16 */ - Word16 gain_inov_fx; /* Innovation gain Q12 */ - Word16 voice_fac_fx; /* voicing factor Q15 */ + Word16 gain_pit_fx; /* pitch gain Q14 */ + Word32 gain_code_fx; /* gain/normalized gain of the algebraic excitation Q16 */ + Word32 norm_gain_code_fx; /* normalized gain of the algebraic excitation Q16 */ + Word16 gain_inov_fx; /* Innovation gain Q12 */ + Word16 voice_fac_fx; /* voicing factor Q15 */ Word16 L_subfr_fx, pit_idx_fx; const Word16 *p_Aq_fx; /* Pointer to frame LP coefficient Q12 */ Word16 *pt_pitch_fx; /* pointer to Word16 pitch Q6 */ @@ -504,6 +507,8 @@ void dec_pit_exc_ivas_fx( Word32 L_tmp; Word16 nbits; GSC_DEC_HANDLE hGSCDec; + gain_pit_fx = 0; + move16(); hGSCDec = st_fx->hGSCDec; MUSIC_POSTFILT_HANDLE hMusicPF; @@ -514,13 +519,13 @@ void dec_pit_exc_ivas_fx( Word16 gp_mem[NB_SUBFR - 1]; /* gain_pitch from previous subframes */ #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif use_fcb = 0; move16(); test(); test(); - test(); IF( ( st_fx->GSC_IVAS_mode > 0 ) && ( EQ_16( st_fx->GSC_noisy_speech, 1 ) || GT_32( st_fx->core_brate, GSC_H_RATE_STG ) ) ) { Local_BR_fx = ACELP_8k00; @@ -550,7 +555,7 @@ void dec_pit_exc_ivas_fx( move16(); Pitch_BR_fx = ACELP_7k20; move32(); - IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) + if ( EQ_16( st_fx->L_frame, L_FRAME16k ) ) { Pitch_BR_fx = st_fx->core_brate; move32(); @@ -645,6 +650,7 @@ void dec_pit_exc_ivas_fx( L_subfr_fx, 0 #endif ); + move16(); } ELSE IF( EQ_16( use_fcb, 2 ) ) /* IVAS only */ { @@ -663,6 +669,7 @@ void dec_pit_exc_ivas_fx( L_subfr_fx, 0 #endif ); + move16(); } ELSE { @@ -681,8 +688,7 @@ void dec_pit_exc_ivas_fx( pit_idx_fx = (Word16) get_next_indice_fx( st_fx, nbits ); move16(); - gain_pit_fx = add( 9590, dic_gp_fx[pit_idx_fx] ); - move16(); /*Q14 0.5853 in Q14 9590*/ + gain_pit_fx = add( 9590, dic_gp_fx[pit_idx_fx] ); /*Q14 0.5853 in Q14 9590*/ if ( st_fx->BER_detect ) /* Bitstream is corrupted, use the past pitch gain */ { @@ -716,6 +722,7 @@ void dec_pit_exc_ivas_fx( { L_tmp = L_shl( L_mult( gain_pit_fx, exc_fx[add( i, i_subfr_fx )] ), 1 ); /*Q16+Q_exc*/ exc_fx[add( i, i_subfr_fx )] = round_fx( L_tmp ); /*Q_exc*/ + move16(); } } ELSE @@ -726,6 +733,7 @@ void dec_pit_exc_ivas_fx( { L_tmp = L_mult( gain_pitx2, exc_fx[add( i, i_subfr_fx )] ); /*Q16+Q_exc*/ exc_fx[add( i, i_subfr_fx )] = round_fx( L_tmp ); /*Q_exc*/ + move16(); } } } @@ -751,7 +759,6 @@ void dec_pit_exc_ivas_fx( move16(); move16(); move16(); - move16(); p_Aq_fx += 5 * ( M + 1 ); } ELSE IF( EQ_16( L_subfr_fx, L_FRAME16k / 2 ) ) @@ -763,14 +770,12 @@ void dec_pit_exc_ivas_fx( pt_pitch_fx++; p_Aq_fx += 2 * ( M + 1 ); move16(); - move16(); - move16(); - move16(); /* update gains for FEC - equivalent to lp_gain_updt() */ st_fx->lp_gainp_fx = extract_h( L_mult( 6554, gain_pit_fx ) ); /*Q14 (3/15 in Q15 9830)*/ st_fx->lp_gainc_fx = 0; - move32(); + move16(); + move16(); } ELSE { @@ -782,13 +787,12 @@ void dec_pit_exc_ivas_fx( p_Aq_fx += 3 * ( M + 1 ); move16(); move16(); - move16(); - move16(); /* update gains for FEC - equivalent to lp_gain_updt() */ st_fx->lp_gainp_fx = extract_h( L_mult( 26214, gain_pit_fx ) ); /*Q14 (12/15 in Q15 9830)*/ st_fx->lp_gainc_fx = 0; - move32(); + move16(); + move16(); } } ELSE IF( EQ_16( L_subfr_fx, 128 ) ) /*2*L_SUBFR*/ @@ -811,6 +815,7 @@ void dec_pit_exc_ivas_fx( st_fx->lp_gainp_fx = extract_h( L_mult( 9830, gain_pit_fx ) ); /*Q14 (3/10 in Q15 9830)*/ st_fx->lp_gainc_fx = 0; move16(); + move16(); } ELSE { @@ -818,6 +823,7 @@ void dec_pit_exc_ivas_fx( st_fx->lp_gainp_fx = extract_h( L_mult( 22938, gain_pit_fx ) ); /*Q14 (7/10 in Q15 22938)*/ st_fx->lp_gainc_fx = 0; move16(); + move16(); } } ELSE IF( EQ_16( L_subfr_fx, 256 ) ) /*4*L_SUBFR*/ @@ -845,7 +851,6 @@ void dec_pit_exc_ivas_fx( move16(); pt_gain++; p_Aq_fx += 4 * ( M + 1 ); - move16(); /* update gains for FEC - equivalent to lp_gain_updt() */ st_fx->lp_gainp_fx = gain_pit_fx; @@ -856,9 +861,7 @@ void dec_pit_exc_ivas_fx( ELSE { p_Aq_fx += ( M + 1 ); - move16(); pt_pitch_fx++; - move16(); *pt_gain = gain_pit_fx; move16(); pt_gain++; diff --git a/lib_dec/dec_prm_fx.c b/lib_dec/dec_prm_fx.c index feef8f2be017b8da3317805e1d7ff309753523e4..de346a5016bbef6270c63369e73aab334b09d054 100644 --- a/lib_dec/dec_prm_fx.c +++ b/lib_dec/dec_prm_fx.c @@ -510,6 +510,7 @@ void getTCXparam_fx( { prms[add( ix, nbits_tcx )] = 1; } + move16(); j = add( j, nbits_tcx ); } ELSE @@ -602,6 +603,7 @@ void dec_prm_fx( if ( EQ_16( FrameSizeConfig[n].frame_bits, num_bits ) ) { st->bits_frame_core = add( st->bits_frame_core, FrameSizeConfig[n].bandwidth_bits ); + move16(); BREAK; } } @@ -741,6 +743,7 @@ void dec_prm_fx( st->core = TCX_20_CORE; move16(); *coder_type = sub( *coder_type, ACELP_MODE_MAX ); + move16(); st->hTcxCfg->coder_type = *coder_type; move16(); } @@ -1288,6 +1291,7 @@ void dec_prm_fx( Word32 tmp32 = L_shl( L_mult0( st->L_frame, st->pit_res_max ), 1 + kLtpHmFractionalResolution + 1 ); Word16 tmp1 = add( imult1616( hTcxLtpDec->tcxltp_pitch_int, st->pit_res_max ), hTcxLtpDec->tcxltp_pitch_fr ); hTcxDec->tcx_hm_LtpPitchLag = div_l( tmp32, tmp1 ); + move16(); } } @@ -1574,16 +1578,17 @@ void dec_prm_fx( move16(); } - st->BER_detect = st->BER_detect | - tcx_ltp_decode_params( &prm[j], - &( hTcxLtpDec->tcxltp_pitch_int ), - &( hTcxLtpDec->tcxltp_pitch_fr ), - &( hTcxLtpDec->tcxltp_gain ), - st->pit_min, - st->pit_fr1, - st->pit_fr2, - st->pit_max, - st->pit_res_max ); + st->BER_detect = s_or( st->BER_detect, + tcx_ltp_decode_params( &prm[j], + &( hTcxLtpDec->tcxltp_pitch_int ), + &( hTcxLtpDec->tcxltp_pitch_fr ), + &( hTcxLtpDec->tcxltp_gain ), + st->pit_min, + st->pit_fr1, + st->pit_fr2, + st->pit_max, + st->pit_res_max ) ); + move16(); hTcxDec->tcxltp_last_gain_unmodified = hTcxLtpDec->tcxltp_gain; move16(); @@ -1631,7 +1636,7 @@ void dec_prm_fx( IF( st->hTcxCfg->fIsTNSAllowed ) { test(); - IF( EQ_16( st->last_core_from_bs, ACELP_CORE ) && ( k == 0 ) ) + IF( st->last_core_from_bs == ACELP_CORE && ( k == 0 ) ) { st->BER_detect = 1; move16(); diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 6f1e2907521554873223826dc03d8ca36478849e..9440774a7ce3536f9993de872c56d1e44edf4f62 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -72,8 +72,7 @@ void decoder_tcx_fx( Word16 gainCompensate, gainCompensate_e; Word16 h1[L_FRAME_MAX / 4 + 1]; Word16 mem[M]; - Word16 temp_concealment_method = 0; - move16(); + Word16 temp_concealment_method; Word16 arith_bits, signaling_bits; Word16 *prm_ltp, *prm_tns, *prm_hm, *prm_sqQ, *prm_target; Word16 *pInfoTCXNoise; @@ -86,7 +85,11 @@ void decoder_tcx_fx( #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; Flag Carry = 0; + move32(); + move32(); #endif + temp_concealment_method = 0; + move16(); hTcxLtpDec = st->hTcxLtpDec; hTcxDec = st->hTcxDec; @@ -168,7 +171,7 @@ void decoder_tcx_fx( ELSE { test(); - IF( frame_cnt == 0 && EQ_16( st->last_core, ACELP_CORE ) ) + IF( frame_cnt == 0 && st->last_core == ACELP_CORE ) { if ( st->prev_bfi == 0 ) { @@ -242,7 +245,6 @@ void decoder_tcx_fx( /* minimum needed for output with sampling rates lower then the nominal sampling rate */ infoIGFStartLine = s_min( L_frameTCX, L_frame ); - move16(); } ELSE { @@ -253,7 +255,6 @@ void decoder_tcx_fx( ELSE { infoIGFStartLine = s_min( st->hIGFDec->infoIGFStartLine, L_frameTCX ); - move16(); } noiseFillingSize = L_spec; @@ -266,9 +267,7 @@ void decoder_tcx_fx( prm_ltp = &prm[1 + NOISE_FILL_RANGES]; - move16(); prm_tns = prm_ltp + LTPSIZE; - move16(); /*-----------------------------------------------------------* * Read TCX parameters * @@ -314,9 +313,7 @@ void decoder_tcx_fx( } prm_hm = prm_tns + tnsSize; - move16(); prm_sqQ = prm_hm + NPRM_CTX_HM; - move16(); /*-----------------------------------------------------------* * Spectrum data * @@ -330,7 +327,7 @@ void decoder_tcx_fx( *-----------------------------------------------------------*/ test(); test(); - IF( hTcxCfg->ctx_hm != 0 && ( ( NE_16( st->last_core_from_bs, ACELP_CORE ) ) || ( frame_cnt > 0 ) ) ) + IF( hTcxCfg->ctx_hm != 0 && ( ( st->last_core_from_bs != ACELP_CORE ) || ( frame_cnt > 0 ) ) ) { st->last_ctx_hm_enabled = prm_hm[0]; move16(); @@ -444,7 +441,7 @@ void decoder_tcx_fx( #endif s = 15 - 5 - 7; move16(); - if ( L_spec >= 1024 ) /*reduce precision for avoiding overflow*/ + IF( GE_16( L_spec, 1024 ) ) /*reduce precision for avoiding overflow*/ { tmp1 = mult_r( shl( L_spec, 4 ), 26214 /*128.f/NORM_MDCT_FACTOR Q15*/ ); s = 15 - 4 - 7; @@ -504,6 +501,7 @@ void decoder_tcx_fx( ELSE { hTcxDec->damping = Damping_fact_fx( coder_type, st->nbLostCmpt, st->last_good, stab_fac, &( st->Mode2_lp_gainp ), st->last_core ); + move16(); gain_tcx = hTcxDec->old_gaintcx_bfi; move16(); gain_tcx_e = hTcxDec->old_gaintcx_bfi_e; @@ -511,6 +509,7 @@ void decoder_tcx_fx( } hTcxDec->cummulative_damping_tcx = shl( mult( hTcxDec->cummulative_damping_tcx, hTcxDec->damping ), 1 ); /*shl(Q15*Q14,1)=shl(Q14,1) = Q15*/ + move16(); } { IF( bfi ) @@ -547,18 +546,19 @@ void decoder_tcx_fx( E_UTIL_synthesis( 0, Ap, h1, h1, L_SUBFR, mem, 0, M ); deemph_fx( h1, st->preemph_fac, L_SUBFR, &tmp2 ); /* impulse response level = gain introduced by synthesis+deemphasis */ - test(); IF( bfi == 0 ) { /* st->last_gain_syn_deemph = (float)sqrt(dot_product( h1, h1, L_SUBFR)); */ tmp32 = Dot_productSq16HQ( 0, h1, L_SUBFR, &st->last_gain_syn_deemph_e ) /*Q15, st->last_gain_syn_deemph_e*/; st->last_gain_syn_deemph_e = add( st->last_gain_syn_deemph_e, 10 /*scaling of h1[0] and E_UTIL_synthesis * 2*/ ); + move16(); tmp32 = Sqrt32( tmp32, &st->last_gain_syn_deemph_e ); #ifdef BASOP_NOGLOB st->last_gain_syn_deemph = round_fx_o( tmp32, &Overflow ); #else st->last_gain_syn_deemph = round_fx( tmp32 ); #endif + move16(); /*for avoiding compiler warnings*/ hTcxDec->gainHelper = 32768 / 2; move16(); @@ -598,6 +598,7 @@ void decoder_tcx_fx( negate( mult( gainCompensate, tmp1 ) ), add( -7, gainCompensate_e ), &hTcxDec->stepCompensate ); + move16(); hTcxDec->gainHelper = 32768 / 2; move16(); @@ -617,6 +618,7 @@ void decoder_tcx_fx( move16(); hTcxDec->gainHelper = st->last_concealed_gain_syn_deemph; hTcxDec->gainHelper_e = st->last_concealed_gain_syn_deemph_e; + move16(); } move16(); move16(); @@ -638,8 +640,9 @@ void decoder_tcx_fx( Word16 *prm_resq; - prm_resq = prm_sqQ + *prm_target /* = targetBits */ - - hTcxDec->resQBits[frame_cnt]; + prm_resq = prm_sqQ + sub( *prm_target /* = targetBits */ + , + hTcxDec->resQBits[frame_cnt] ); i = tcx_ari_res_invQ_spec( x, x_e, L_spec, prm_resq, @@ -677,6 +680,7 @@ void decoder_tcx_fx( IF( bfi == 0 && st->tcxonly == 0 ) { /* Replication of ACELP formant enhancement for low rates */ + test(); IF( LT_32( st->total_brate, ACELP_13k20 ) || st->rf_flag != 0 ) { tcxFormantEnhancement( xn_buf, gainlpc2, gainlpc2_e, x, &x_e, L_frame, L_frameTCX ); @@ -687,7 +691,7 @@ void decoder_tcx_fx( * Add gain to the lpc gains * *-----------------------------------------------------------*/ - if ( st->VAD == 0 ) + IF( st->VAD == 0 ) { gain_tcx = mult_r( gain_tcx, hTcxCfg->na_scale ); } @@ -727,7 +731,7 @@ void decoder_tcx_fx( move16(); test(); test(); - if ( ( hTcxCfg->ctx_hm != 0 ) && ( NE_16( st->last_core, ACELP_CORE ) ) && ( st->last_ctx_hm_enabled != 0 ) ) + if ( ( hTcxCfg->ctx_hm != 0 ) && ( st->last_core != ACELP_CORE ) && ( st->last_ctx_hm_enabled != 0 ) ) { tmp1 = 10240 /*0.3125f Q15*/; move16(); @@ -768,7 +772,6 @@ void decoder_tcx_fx( #endif pInfoTCXNoise = st->hIGFDec->infoTCXNoise_evs; - move16(); } tcx_noise_filling( x, x_e, tmp1 /* seed */, firstLine, noiseFillingSize, noiseTransWidth, L_frame, noiseTiltFactor, fac_ns, pInfoTCXNoise, st->element_mode ); @@ -827,7 +830,7 @@ void decoder_tcx_fx( } } /* get the starting location of the subframe in the frame */ - if ( EQ_16( st->core, TCX_10_CORE ) ) + IF( EQ_16( st->core, TCX_10_CORE ) ) { st->plcInfo.subframe_fx = extract_l( L_mult0( frame_cnt, L_frameTCX_glob ) ); move16(); @@ -882,8 +885,6 @@ void decoder_tcx_fx( #else tmp1 = shl( tmp1, tmp2 ); #endif - test(); - test(); /* replace higher energy TCX5 frame by lower one to avoid energy fluctuation */ IF( GT_16( tmp1, 16384 /*2 in Q13*/ ) ) { @@ -909,7 +910,7 @@ void decoder_tcx_fx( tmp = 0; move16(); test(); - IF( GE_16( st->bits_frame, 256 ) && st->rf_flag == 0 ) + if ( GE_16( st->bits_frame, 256 ) && st->rf_flag == 0 ) { tmp = 1; move16(); @@ -945,6 +946,7 @@ void decoder_tcx_fx( test(); test(); test(); + test(); IF( bfi && ( !st->enablePlcWaveadjust || EQ_16( temp_concealment_method, TCX_TONAL ) ) && st->igf && ( frame_cnt == 0 ) && ( EQ_16( L_frameTCX, shr( hTcxDec->L_frameTCX, 1 ) ) ) && ( st->tcxonly ) && ( !st->tonal_mdct_plc_active ) && ( EQ_16( st->nbLostCmpt, 1 ) ) && ( NE_16( hTcxCfg->tcx_last_overlap_mode, FULL_OVERLAP ) ) && ( NE_16( hTcxCfg->tcx_curr_overlap_mode, FULL_OVERLAP ) ) ) { IGFDecCopyLPCFlatSpectrum( st->hIGFDec, x, x_e, IGF_GRID_LB_SHORT ); @@ -964,7 +966,7 @@ void decoder_tcx_fx( } ELSE { - IF( EQ_16( st->last_core, ACELP_CORE ) ) + IF( st->last_core == ACELP_CORE ) { IGFDecCopyLPCFlatSpectrum( st->hIGFDec, x, x_e, IGF_GRID_LB_TRAN ); } @@ -1050,7 +1052,6 @@ void decoder_tcx_fx( { Word16 igfGridIdx; - test(); test(); IF( ( EQ_16( st->last_core, ACELP_CORE ) ) || ( left_rect && bfi ) ) { @@ -1065,6 +1066,7 @@ void decoder_tcx_fx( } *st->hIGFDec->igfData.igfInfo.nfSeed = extract_l( L_mac0( 13849L, nf_seed, 31821 ) ); + move16(); IGFDecApplyMono( st->hIGFDec, x, &x_e, igfGridIdx, bfi ); } test(); @@ -1072,6 +1074,7 @@ void decoder_tcx_fx( IF( st->igf && ( ( EQ_16( L_frame, shr( st->L_frame, 1 ) ) ) && ( st->tcxonly ) ) ) { *st->hIGFDec->igfData.igfInfo.nfSeed = extract_l( L_mac0( 13849L, nf_seed, 31821 ) ); + move16(); IGFDecApplyMono( st->hIGFDec, x, &x_e, IGF_GRID_LB_SHORT, bfi ); } @@ -1089,9 +1092,10 @@ void decoder_tcx_fx( test(); IF( st->hIGFDec->flatteningTrigger != 0 && fUseTns == 0 ) { - Word16 startLine = st->hIGFDec->infoIGFStartLine; + Word16 startLine, endLine; + startLine = st->hIGFDec->infoIGFStartLine; move16(); - Word16 endLine = st->hIGFDec->infoIGFStopLine; + endLine = st->hIGFDec->infoIGFStopLine; move16(); Word32 x_itf[N_MAX_TCX - IGF_START_MN]; Word16 j; @@ -1101,11 +1105,13 @@ void decoder_tcx_fx( const Word16 maxOrder = 8; move16(); - Word16 curr_order = 0; /* not counted */ + Word16 curr_order; /* not counted */ + curr_order = 0; move16(); Word16 A_itf[ITF_MAX_FILTER_ORDER + 1]; Word16 Q_A_itf; - Word16 predictionGain = 0; /* not counted */ + Word16 predictionGain; /* not counted */ + predictionGain = 0; move16(); FOR( j = startLine; j < endLine; j++ ) @@ -1137,7 +1143,7 @@ void decoder_tcx_fx( FOR( j = startLine; j < endLine; j++ ) { - if ( EQ_16( chk_sparse[j - IGF_START_MN], 2 ) ) + IF( EQ_16( chk_sparse[j - IGF_START_MN], 2 ) ) { x[j] = x_itf[j - IGF_START_MN]; move32(); @@ -1149,7 +1155,8 @@ void decoder_tcx_fx( test(); IF( ( EQ_16( L_frame, shr( st->L_frame, 1 ) ) ) && ( st->tcxonly != 0 ) ) { - Word16 L = L_frameTCX; + Word16 L; + L = L_frameTCX; move16(); test(); @@ -1183,7 +1190,6 @@ void decoder_tcx_fx( { /* Apply TNS to get the reconstructed signal */ test(); - test(); SetTnsConfig( hTcxCfg, L_frame_glob == st->L_frame, ( st->last_core == ACELP_CORE ) && ( frame_cnt == 0 ) ); ApplyTnsFilter( hTcxCfg->pCurrentTnsConfig, &tnsData, x, 0 ); @@ -1199,14 +1205,14 @@ void decoder_tcx_fx( { tmp1 = shr( hTcxCfg->tnsConfig[0][0].iFilterBorders[0], 1 ); /* undo rearrangement of LF sub-window lines for TNS synthesis filtering */ - IF( s_max( L_frameTCX, L_spec ) > hTcxCfg->tnsConfig[0][0].iFilterBorders[0] ) + IF( GT_16( s_max( L_frameTCX, L_spec ), hTcxCfg->tnsConfig[0][0].iFilterBorders[0] ) ) { tmp2 = shr( s_max( L_frameTCX, L_spec ), 1 ); - Copy32( x + tmp1 + 8, x + tmp2 + 8, sub( tmp1, 8 ) ); + Copy32( x + add( tmp1, 8 ), x + add( tmp2, 8 ), sub( tmp1, 8 ) ); Copy32( x + 8, x + tmp2, 8 ); Copy32( x + 16, x + 8, sub( tmp1, 8 ) ); set32_fx( x + tmp1, 0, sub( tmp2, tmp1 ) ); - set32_fx( x + tmp2 + tmp1, 0, sub( tmp2, tmp1 ) ); + set32_fx( x + add( tmp2, tmp1 ), 0, sub( tmp2, tmp1 ) ); } ELSE { @@ -1281,8 +1287,8 @@ void decoder_tcx_fx( } /* Output */ - Copy( xn_buf + shr( overlap, 1 ) - tcx_offset, synth, L_frame_glob ); - Copy( xn_bufFB + shr( overlapFB, 1 ) - tcx_offsetFB, synthFB, L_frameTCX_glob ); + Copy( xn_buf + sub( shr( overlap, 1 ), tcx_offset ), synth, L_frame_glob ); + Copy( xn_bufFB + sub( shr( overlapFB, 1 ), tcx_offsetFB ), synthFB, L_frameTCX_glob ); } @@ -1304,6 +1310,7 @@ void decoder_tcx_post_fx( Decoder_State *st_fx, TCX_DEC_HANDLE hTcxDec; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif hTcxDec = st_fx->hTcxDec; @@ -1314,11 +1321,12 @@ void decoder_tcx_post_fx( Decoder_State *st_fx, /* first TCX frame after ACELP; overwrite ltp initialization done during acelp PLC */ test(); test(); - if ( !st_fx->bfi && st_fx->prev_bfi && EQ_16( st_fx->last_core, ACELP_CORE ) ) + if ( !st_fx->bfi && st_fx->prev_bfi && st_fx->last_core == ACELP_CORE ) { hTcxDec->tcxltp_last_gain_unmodified = 0; move16(); } + test(); IF( bfi != 0 && st_fx->use_partial_copy == 0 ) { test(); @@ -1367,7 +1375,8 @@ void decoder_tcx_post_fx( Decoder_State *st_fx, /* level_syn = (float)sqrt(( dot_product(synthFB, synthFB, L_frame)) / L_frame ); */ s = sub( getScaleFactor16( synthFB, hTcxDec->L_frameTCX ), 4 ); { - Word64 tmp64 = 0; + Word64 tmp64; + tmp64 = 0; move64(); FOR( i = 0; i < hTcxDec->L_frameTCX; i++ ) { @@ -1540,10 +1549,12 @@ void decoder_tcx_post_fx( Decoder_State *st_fx, st_fx->last_concealed_gain_syn_deemph ), st_fx->last_concealed_gain_syn_deemph_e ) ); /*Q30->Q14*/ #endif + move16(); } ELSE { st_fx->plcInfo.recovery_gain = extract_h( conceal_eof_gainFB ); /*Q14*/ + move16(); } st_fx->plcInfo.step_concealgain_fx = #ifdef BASOP_NOGLOB @@ -1554,6 +1565,7 @@ void decoder_tcx_post_fx( Decoder_State *st_fx, round_fx( L_shl( L_mult0( st_fx->L_frame, getInvFrameLen( hTcxDec->L_frameTCX ) ), 8 ) ) ), 3 ) ); /*Q15*/ #endif + move16(); } /*-----------------------------------------------------------* @@ -1581,6 +1593,7 @@ void decoder_tcx_post_fx( Decoder_State *st_fx, #else st_fx->bfi_pitch_fx = shl( round_fx( st_fx->old_fpitch ), 6 ); #endif + move16(); st_fx->bfi_pitch_frame = st_fx->L_frame; move16(); @@ -1618,6 +1631,7 @@ void decoder_tcx_post_ivas_fx( Decoder_State *st_fx, TCX_DEC_HANDLE hTcxDec; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif hTcxDec = st_fx->hTcxDec; @@ -1636,7 +1650,7 @@ void decoder_tcx_post_ivas_fx( Decoder_State *st_fx, test(); test(); test(); - IF( st_fx->hTcxLtpDec != NULL && GT_16( st_fx->element_mode, EVS_MONO ) && ( EQ_16( st_fx->clas_dec, UNVOICED_CLAS ) || EQ_16( st_fx->clas_dec, INACTIVE_CLAS ) ) ) + IF( st_fx->hTcxLtpDec != NULL && st_fx->element_mode > EVS_MONO && ( EQ_16( st_fx->clas_dec, UNVOICED_CLAS ) || EQ_16( st_fx->clas_dec, INACTIVE_CLAS ) ) ) { /* deactivate TCX LTP for non-voiced frames */ st_fx->hTcxLtpDec->tcxltp = 0; @@ -1720,6 +1734,7 @@ void decoder_tcx_post_ivas_fx( Decoder_State *st_fx, * PLC: estimate and update CNG energy */ level_syn_e = s; // add(s, 15); + move16(); test(); test(); test(); @@ -1877,6 +1892,7 @@ void decoder_tcx_post_ivas_fx( Decoder_State *st_fx, st_fx->last_concealed_gain_syn_deemph ), st_fx->last_concealed_gain_syn_deemph_e ) ); /*Q30->Q14*/ #endif + move16(); } ELSE { @@ -1892,6 +1908,7 @@ void decoder_tcx_post_ivas_fx( Decoder_State *st_fx, round_fx( L_shl( L_mult0( st_fx->L_frame, getInvFrameLen( hTcxDec->L_frameTCX ) ), 8 ) ) ), 3 ) ); /*Q15*/ #endif + move16(); } /*-----------------------------------------------------------* @@ -1948,20 +1965,21 @@ static Word32 CalculateAbsEnergy_fx( /* o : normalized resul Word32 L_sum, L_c; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; - Flag Carry = 0; + Flag Carry; + move32(); #endif /* Clear carry flag and init sum */ Carry = 0; - move16(); + move32(); L_c = 0; move32(); #ifdef BASOP_NOGLOB /* Critical Overflow/Carry */ L_sum = L_macNs_co( L_off, 0, 0, &Carry, &Overflow ); - if ( L_sum > 0 ) + IF( L_sum > 0 ) { L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); } - if ( L_sum < 0 ) + IF( L_sum < 0 ) { L_c = L_msuNs_co( L_c, 0, 0, &Carry, &Overflow ); } @@ -1975,6 +1993,7 @@ static Word32 CalculateAbsEnergy_fx( /* o : normalized resul FOR( i = 0; i < lg; i += 2 ) { Carry = 0; + move32(); BASOP_SATURATE_WARNING_OFF_EVS /*multiplication of -32768 * -32768 throws an overflow, but is not critical*/ #ifdef BASOP_NOGLOB /* Critical Overflow/Carry */ L_sum = L_macNs_co( L_sum, x[i], x[i], &Carry, &Overflow ); @@ -1983,7 +2002,8 @@ static Word32 CalculateAbsEnergy_fx( /* o : normalized resul #endif BASOP_SATURATE_WARNING_ON_EVS Overflow = 0; /* to avoid useless warning in L_macNs calling L_mult */ -#ifdef BASOP_NOGLOB /* Critical Overflow/Carry */ + move32(); +#ifdef BASOP_NOGLOB /* Critical Overflow/Carry */ L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); #else L_c = L_macNs( L_c, 0, 0 ); @@ -2003,9 +2023,10 @@ void IMDCT_fx( Word32 *x, Word16 x_e, Word16 *old_syn_overl, Word16 *syn_Overl_T Word8 tmp8; Word16 i; Word16 nz; - Word16 aldo = 0; - move16(); + Word16 aldo; TCX_DEC_HANDLE hTcxDec; + aldo = 0; + move16(); hTcxDec = st->hTcxDec; @@ -2417,7 +2438,7 @@ void IMDCT_fx( Word32 *x, Word16 x_e, Word16 *old_syn_overl, Word16 *syn_Overl_T test(); test(); if ( ( bfi == 0 ) && ( frame_cnt > 0 ) && ( index == 0 ) && - ( EQ_16( tcx_cfg->tcx_curr_overlap_mode, FULL_OVERLAP ) ) && ( NE_16( st->last_core, ACELP_CORE ) ) ) + ( EQ_16( tcx_cfg->tcx_curr_overlap_mode, FULL_OVERLAP ) ) && ( st->last_core != ACELP_CORE ) ) { index = MIN_OVERLAP; /* use minimum overlap between the two TCX-10 windows */ move16(); @@ -2685,7 +2706,7 @@ void IMDCT_fx( Word32 *x, Word16 x_e, Word16 *old_syn_overl, Word16 *syn_Overl_T test(); test(); test(); - IF( left_rect && ( frame_cnt == 0 ) && ( EQ_16( st->last_core_bfi, ACELP_CORE ) ) && st->prev_bfi ) + IF( left_rect && ( frame_cnt == 0 ) && ( st->last_core_bfi == ACELP_CORE ) && st->prev_bfi ) { IF( fullbandScale ) @@ -2702,6 +2723,7 @@ void IMDCT_fx( Word32 *x, Word16 x_e, Word16 *old_syn_overl, Word16 *syn_Overl_T xn_buf[i + tmp1] = add( xn_buf[i + tmp1], mult_r( hTcxDec->syn_OverlFB[i], mult_r( tcx_mdct_window_half[i].v.re, tcx_mdct_window_half[i].v.re ) ) ); #endif move16(); + move16(); } FOR( ; i < tcx_mdct_window_half_length; i++ ) { @@ -2713,6 +2735,7 @@ void IMDCT_fx( Word32 *x, Word16 x_e, Word16 *old_syn_overl, Word16 *syn_Overl_T xn_buf[i + tmp1] = add( xn_buf[i + tmp1], mult_r( hTcxDec->syn_OverlFB[i], mult_r( tcx_mdct_window_half[tcx_mdct_window_half_length - 1 - i].v.im, tcx_mdct_window_half[tcx_mdct_window_half_length - 1 - i].v.im ) ) ); #endif move16(); + move16(); } } ELSE @@ -2729,6 +2752,7 @@ void IMDCT_fx( Word32 *x, Word16 x_e, Word16 *old_syn_overl, Word16 *syn_Overl_T xn_buf[i + tmp1] = add( xn_buf[i + tmp1], mult_r( hTcxDec->syn_Overl[i], mult_r( tcx_mdct_window_half[i].v.re, tcx_mdct_window_half[i].v.re ) ) ); #endif move16(); + move16(); } FOR( ; i < tcx_mdct_window_half_length; i++ ) { @@ -2740,6 +2764,7 @@ void IMDCT_fx( Word32 *x, Word16 x_e, Word16 *old_syn_overl, Word16 *syn_Overl_T xn_buf[i + tmp1] = add( xn_buf[i + tmp1], mult_r( hTcxDec->syn_Overl[i], mult_r( tcx_mdct_window_half[tcx_mdct_window_half_length - 1 - i].v.im, tcx_mdct_window_half[tcx_mdct_window_half_length - 1 - i].v.im ) ) ); #endif move16(); + move16(); } } } @@ -2783,13 +2808,15 @@ void IMDCT_ivas_fx( TCX_DEC_HANDLE hTcxDec = st->hTcxDec; TCX_CONFIG_HANDLE hTcxCfg = st->hTcxCfg; Word16 x_e_hdrm; + Word32 c; + Word16 exp; x_e_hdrm = add( q_win, sub( Q16, q_x ) ); aldo = 0; move16(); - Word32 c = L_mult0( NS2SA( st->output_Fs, N_ZERO_MDCT_NS ), L_frame ); - Word16 exp = 0; + c = L_mult0( NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), L_frame ); + exp = 0; move16(); nz = BASOP_Util_Divide3216_Scale( c, L_frameTCX, &exp ); exp = exp + ( 31 - 15 ); @@ -2801,13 +2828,14 @@ void IMDCT_ivas_fx( test(); test(); test(); - test(); - IF( NE_16( st->element_mode, EVS_MONO ) && ( frame_cnt == 0 ) && ( bfi == 0 ) && ( st->prev_bfi != 0 ) && ( EQ_16( st->last_core_bfi, TCX_20_CORE ) || EQ_16( st->last_core_bfi, TCX_10_CORE ) ) && ( hTcxCfg->last_aldo == 0 ) ) + IF( st->element_mode != EVS_MONO && ( frame_cnt == 0 ) && ( bfi == 0 ) && ( st->prev_bfi != 0 ) && ( EQ_16( st->last_core_bfi, TCX_20_CORE ) || EQ_16( st->last_core_bfi, TCX_10_CORE ) ) && ( hTcxCfg->last_aldo == 0 ) ) { - Word16 fac = shl( mult_r( hTcxDec->conceal_eof_gain, st->last_concealed_gain_syn_deemph ), 1 ); + Word16 fac; + fac = shl( mult_r( hTcxDec->conceal_eof_gain, st->last_concealed_gain_syn_deemph ), 1 ); FOR( Word16 ind = 0; ind < overlap; ind++ ) { old_syn_overl_fx[ind] = mult_r( old_syn_overl_fx[ind], fac ); + move16(); } } @@ -2877,7 +2905,8 @@ void IMDCT_ivas_fx( IF( w > 0 ) { - Word16 tmp = add( sub( tcx_offset, shr( L_ola, 1 ) ), imult1616( w, L_win ) ); + Word16 tmp; + tmp = add( sub( tcx_offset, shr( L_ola, 1 ) ), imult1616( w, L_win ) ); tcx_windowing_synthesis_past_frame( xn_buf_fx + tmp, tcx_aldo_window_1_trunc_fx, tcx_mdct_window_half_fx, tcx_mdct_window_minimum_fx, L_ola, tcx_mdct_window_half_length, tcx_mdct_window_min_length, MIN_OVERLAP ); } @@ -2994,11 +3023,13 @@ void IMDCT_ivas_fx( IF( NE_16( hTcxCfg->tcx_last_overlap_mode, TRANSITION_OVERLAP ) ) { - Word16 q_tmp_fx_32 = 15, q_xn_buf_fx_32 = q_x; + Word16 q_tmp_fx_32, q_xn_buf_fx_32; + q_tmp_fx_32 = 15; + q_xn_buf_fx_32 = q_x; move16(); move16(); - Word32 xn_buf_fx_32[2000] = { 0 }, tmp_fx_32[1200], old_out_fx_32[1200]; - + Word32 xn_buf_fx_32[2000], tmp_fx_32[1200], old_out_fx_32[1200]; + set32_fx( xn_buf_fx_32, 0, 2000 ); IF( NE_16( kernel_type, MDCT_IV ) ) /* inverse transform */ { Word16 tmp_a = add( shr( overlap, 1 ), nz ); @@ -3011,7 +3042,8 @@ void IMDCT_ivas_fx( edxt_fx( x_fx, xn_buf_fx_32 + tmp_a, L_frame, kernel_type, TRUE ); } - Word16 res_m, res_e = 0; + Word16 res_m, res_e; + res_e = 0; move16(); res_m = BASOP_Util_Divide1616_Scale( L_frame, NORM_MDCT_FACTOR, &res_e ); res_m = Sqrt16( res_m, &res_e ); @@ -3019,6 +3051,7 @@ void IMDCT_ivas_fx( FOR( Word16 ind = 0; ind < L_frame; ind++ ) { tmp_fx_32[ind] = L_shl( Mpy_32_16_1( xn_buf_fx_32[shr( overlap, 1 ) + nz + ind], res_m ), res_e ); + move32(); } q_tmp_fx_32 = q_xn_buf_fx_32; move16(); @@ -3026,6 +3059,7 @@ void IMDCT_ivas_fx( FOR( Word16 ind = 0; ind < L_frame; ind++ ) { old_out_fx_32[ind] = L_shl( old_out_fx[ind], sub( q_tmp_fx_32, q_win ) ); + move32(); } window_ola_ext_fx( tmp_fx_32, xn_buf_fx_32, old_out_fx_32, L_frame, hTcxCfg->tcx_last_overlap_mode, hTcxCfg->tcx_curr_overlap_mode, kernel_type ); @@ -3043,7 +3077,8 @@ void IMDCT_ivas_fx( Word16 q_old_out = q_win; move16(); edct_fx( x_fx, xn_buf_fx_32 + add( shr( overlap, 1 ), nz ), L_frame, &q_xn_buf_fx_32 ); - Word16 res_m, res_e = 0; + Word16 res_m, res_e; + res_e = 0; move16(); res_m = BASOP_Util_Divide1616_Scale( L_frame, NORM_MDCT_FACTOR, &res_e ); res_m = Sqrt16( res_m, &res_e ); @@ -3109,7 +3144,7 @@ void IMDCT_ivas_fx( test(); test(); test(); - IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && ( LE_32( st->last_core_brate, SID_2k40 ) || EQ_16( st->last_core, ACELP_CORE ) ) && ( fullbandScale == 0 ) ) + IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && ( LE_32( st->last_core_brate, SID_2k40 ) || st->last_core == ACELP_CORE ) && ( fullbandScale == 0 ) ) { /* get LPC from that signal part to use for acelp zir smoothing */ const Word16 analysis_len = shr( L_frame_glob, 2 ); @@ -3123,8 +3158,6 @@ void IMDCT_ivas_fx( q_buf = q_win; move16(); - // q_old_Aq_12_8 = 28; - move16(); ham_cos_window_ivas( &window_buf_fx[0], shr( analysis_len, 1 ), shr( analysis_len, 1 ) ); autocorr_fx_32( &buf_fx[0], M, &r_fx[0], &q_r, analysis_len, &window_buf_fx[0], 0, 0 ); @@ -3133,6 +3166,7 @@ void IMDCT_ivas_fx( FOR( Word16 ind = 0; ind <= M; ind++ ) { st->old_Aq_12_8_fx[ind] = (Word16) L_shr( st->old_Aq_12_8_fx_32[ind], 16 ); + move16(); } } @@ -3291,7 +3325,6 @@ void IMDCT_ivas_fx( /* If current overlap mode = FULL_OVERLAP -> ALDO_WINDOW */ IF( EQ_16( hTcxCfg->tcx_curr_overlap_mode, FULL_OVERLAP ) ) { - // tested IF( s_and( kernel_type, 1 ) ) { FOR( i = 0; i < nz; i++ ) @@ -3323,7 +3356,7 @@ void IMDCT_ivas_fx( test(); test(); test(); - IF( ( left_rect != 0 ) && ( frame_cnt == 0 ) && EQ_16( st->last_core_bfi, ACELP_CORE ) && ( st->prev_bfi != 0 ) ) + IF( ( left_rect != 0 ) && ( frame_cnt == 0 ) && st->last_core_bfi == ACELP_CORE && ( st->prev_bfi != 0 ) ) { IF( FB_flag != 0 ) { @@ -3393,6 +3426,8 @@ void init_tcx_info_fx( /* Init lengths */ *tcx_offset = hTcxCfg->tcx_offset; *tcx_offsetFB = hTcxCfg->tcx_offsetFB; + move16(); + move16(); IF( bfi ) { @@ -3420,7 +3455,7 @@ void init_tcx_info_fx( ELSE { test(); - IF( frame_cnt == 0 && EQ_16( st->last_core, ACELP_CORE ) ) + IF( frame_cnt == 0 && st->last_core == ACELP_CORE ) { if ( !st->prev_bfi ) { @@ -3431,11 +3466,14 @@ void init_tcx_info_fx( /* if past frame is ACELP */ *L_frame = add( L_frame_glob, *tcx_offset ); *L_frameTCX = add( L_frameTCX_glob, *tcx_offsetFB ); - if ( EQ_16( st->last_core, st->last_core_from_bs ) ) + move16(); + move16(); + IF( EQ_16( st->last_core, st->last_core_from_bs ) ) { /* case: last frame was lost and concealed as CNG */ /* using the longer transition spec length causes reading of uninitialized data */ *L_spec = add( *L_spec, shr( st->hTcxCfg->tcx_coded_lines, 2 ) ); + move16(); } assert( hTcxCfg->lfacNext <= 0 ); @@ -3443,6 +3481,8 @@ void init_tcx_info_fx( *L_frameTCX = sub( *L_frameTCX, hTcxCfg->lfacNextFB ); *tcx_offset = hTcxCfg->lfacNext; move16(); + move16(); + move16(); *tcx_offsetFB = hTcxCfg->lfacNextFB; move16(); @@ -3469,9 +3509,9 @@ void init_tcx_info_fx( move16(); } - test(); IF( st->igf ) { + test(); IF( EQ_16( *L_frame, shr( st->L_frame, 1 ) ) && ( st->tcxonly ) ) { IGFDecUpdateInfo_ivas_fx( st->hIGFDec, frame_cnt, IGF_GRID_LB_SHORT ); @@ -3511,6 +3551,7 @@ void decoder_tcx_IGF_mono_fx( } ELSE { + test(); IF( ( EQ_16( st->last_core, ACELP_CORE ) || left_rect ) ) { igfGridIdx = IGF_GRID_LB_TRAN; @@ -3660,7 +3701,6 @@ void decoder_tcx_IGF_stereo_fx( test(); IF( NE_16( L_frame, shr( sts[0]->L_frame, 1 ) ) && ( sts[0]->tcxonly ) ) { - test(); test(); IF( EQ_16( sts[0]->last_core, ACELP_CORE ) || ( left_rect && bfi ) ) { @@ -3676,7 +3716,7 @@ void decoder_tcx_IGF_stereo_fx( restrict_hopsize = 0; move16(); - IF( EQ_16( hStereoMdct->IGFStereoMode[k], SMDCT_BW_MS ) ) + if ( EQ_16( hStereoMdct->IGFStereoMode[k], SMDCT_BW_MS ) ) { restrict_hopsize = 1; move16(); @@ -3707,13 +3747,10 @@ void decoder_tcx_ivas_fx( const Word16 sba_dirac_stereo_flag ) { Word32 x_fx[N_MAX]; - Word16 x_e = 30; - move16(); + Word16 x_e; Word16 gainlpc2_fx[FDNS_NPTS]; Word16 gainlpc2_e[FDNS_NPTS]; - Word16 gain_tcx_e = 0, gain_tcx_fx = 0; - move16(); - move16(); + Word16 gain_tcx_e, gain_tcx_fx; Word16 fUseTns, L_frame_glob, L_frameTCX_glob; STnsData tnsData; Word16 tcx_offset, tcx_offsetFB, L_frame, L_frameTCX; @@ -3722,9 +3759,15 @@ void decoder_tcx_ivas_fx( Word16 xn_buf_fx[L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX]; /* Q14 */ Word16 shift; Word16 x_len; - Word16 q_x = Q11; + Word16 q_x; + q_x = Q11; + move16(); + x_e = 30; + move16(); + gain_tcx_e = 0; + gain_tcx_fx = 0; + move16(); move16(); - set32_fx( x_fx, 0, N_MAX ); set16_fx( gainlpc2_fx, 0, FDNS_NPTS ); set16_fx( gainlpc2_e, 0, FDNS_NPTS ); @@ -3756,27 +3799,22 @@ void decoder_tcx_ivas_fx( decoder_tcx_invQ_fx( st, prm, A_fx, Aind, L_spec, L_frame, L_frameTCX, x_fx, &x_e, gainlpc2_fx, gainlpc2_e, &xn_buf_fx[0], &fUseTns, &tnsData, &gain_tcx_fx, &gain_tcx_e, &prm_sqQ, &nf_seed, bfi, frame_cnt ); shift = Find_Max_Norm32( x_fx, N_MAX ); - move16(); Scale_sig32( x_fx, N_MAX, shift ); x_e = sub( x_e, shift ); - move16(); decoder_tcx_noisefilling_fx( st, NULL, 0, A_fx, L_frameTCX_glob, L_spec, L_frame, L_frameTCX, x_fx, &x_e, gainlpc2_fx, gainlpc2_e, &tmp_concealment_method, gain_tcx_fx, gain_tcx_e, prm_sqQ, nf_seed, bfi, 0, frame_cnt ); decoder_tcx_noiseshaping_igf_fx( st, L_spec, L_frame, L_frameTCX, left_rect, x_fx, &x_e, &x_len, gainlpc2_fx, gainlpc2_e, &tmp_concealment_method, bfi ); shift = sub( Find_Max_Norm32( x_fx, N_MAX ), 6 ); // 6 -> guardbits// - move16(); Scale_sig32( x_fx, N_MAX, shift ); x_e = sub( x_e, shift ); - move16(); decoder_tcx_tns_fx( st, L_frame_glob, L_spec, L_frame, L_frameTCX, x_fx, fUseTns, &tnsData, bfi, frame_cnt, 0, NULL ); Scale_sig32( x_fx, N_MAX, sub( x_e, 20 ) ); // Scaling x_fx to Q11 Scale_sig( xn_buf_fx, L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX, sub( st->Q_syn, 14 ) ); // Scaling xn_buf_fx to Q_syn x_e = sub( 31, 11 ); - move16(); IF( st->igf != 0 ) { @@ -3844,9 +3882,7 @@ void decoder_tcx_invQ_fx( Word16 gamma1; /* Q15 */ Word16 gamma; /* Q15 */ Word16 mem[M]; - Word16 gainCompensate = 0, gainCompensate_e = 0; - move16(); - move16(); + Word16 gainCompensate, gainCompensate_e; Word16 h1[L_SUBFR + 1]; Word16 tmp1, tmp2; Word32 tmp32; @@ -3858,8 +3894,14 @@ void decoder_tcx_invQ_fx( TCX_DEC_HANDLE hTcxDec = st->hTcxDec; TCX_CONFIG_HANDLE hTcxCfg = st->hTcxCfg; + gainCompensate = 0; + gainCompensate_e = 0; + move16(); + move16(); + #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif tnsSize = 0; @@ -3889,9 +3931,7 @@ void decoder_tcx_invQ_fx( } prm_ltp = &prm[1 + NOISE_FILL_RANGES]; - move16(); prm_tns = prm_ltp + LTPSIZE; - move16(); gainCompensate = ONE_IN_Q14; move16(); @@ -3929,11 +3969,8 @@ void decoder_tcx_invQ_fx( } prm_hm = prm_tns + tnsSize; - move16(); prm_sqQ = prm_hm + NPRM_CTX_HM; - move16(); *prm_sqQ1 = prm_sqQ; - move16(); /*-----------------------------------------------------------* * Spectrum data * @@ -3983,6 +4020,7 @@ void decoder_tcx_invQ_fx( #else *nf_seed = add( *nf_seed, (Word16) abs( tmp32 ) * i * 2 ); #endif + move16(); } } ELSE /* TCX-only: context based arithmetic coder */ @@ -4004,18 +4042,19 @@ void decoder_tcx_invQ_fx( // start_zeroing = ( st->last_core != st->last_core_from_bs ) ? min( L_spec, L_frame ) : L_spec; IF( NE_16( st->last_core, st->last_core_from_bs ) ) { - start_zeroing = min( L_spec, L_frame ); + start_zeroing = s_min( L_spec, L_frame ); } ELSE { start_zeroing = L_spec; + move16(); } - move16(); test(); test(); IF( frame_cnt == 0 && EQ_16( st->last_core, ACELP_CORE ) && NE_16( st->last_core_from_bs, ACELP_CORE ) ) { - Word16 L_spec_con = L_spec + ( shr( st->hTcxCfg->tcx_coded_lines, 2 ) ); + Word16 L_spec_con; + L_spec_con = add( L_spec, shr( st->hTcxCfg->tcx_coded_lines, 2 ) ); FOR( i = start_zeroing; i < L_spec_con; i++ ) { @@ -4072,6 +4111,8 @@ void decoder_tcx_invQ_fx( tmp32 = L_shl( L_mult0( index, 0x797D ), 7 ); /* 6Q25; 0x797D -> log2(10)/28 (Q18) */ *gain_tcx_e = add( extract_l( L_shr( tmp32, 25 ) ), 1 ); /* get exponent */ *gain_tcx = round_fx( BASOP_Util_InvLog2( L_or( tmp32, (Word32) 0xFE000000 ) ) ); + move16(); + move16(); #ifdef BASOP_NOGLOB tmp1 = mult_r( shl_sat( L_spec, 5 ), 26214 /*128.f/NORM_MDCT_FACTOR Q15*/ ); @@ -4090,6 +4131,8 @@ void decoder_tcx_invQ_fx( *gain_tcx = mult( *gain_tcx, tmp1 ); *gain_tcx_e = add( *gain_tcx_e, s ); + move16(); + move16(); hTcxDec->old_gaintcx_bfi = *gain_tcx; move16(); @@ -4110,6 +4153,8 @@ void decoder_tcx_invQ_fx( tmp32 = L_shl( L_mult0( hTcxDec->old_gaintcx_bfi, 0x797D ), 7 ); /* 6Q25; 0x797D -> log2(10)/28 (Q18) */ *gain_tcx_e = add( extract_l( L_shr( tmp32, 25 ) ), 1 ); /* get exponent */ *gain_tcx = round_fx( BASOP_Util_InvLog2( L_or( tmp32, 0xFE000000 ) ) ); + move16(); + move16(); tmp1 = mult_r( shl( L_spec, 5 ), 26214 /*128.f/NORM_MDCT_FACTOR Q15*/ ); s = 15 - 5 - 7; @@ -4118,6 +4163,8 @@ void decoder_tcx_invQ_fx( *gain_tcx = mult( *gain_tcx, tmp1 ); *gain_tcx_e = add( *gain_tcx_e, s ); + move16(); + move16(); hTcxDec->old_gaintcx_bfi = *gain_tcx; move16(); @@ -4146,9 +4193,11 @@ void decoder_tcx_invQ_fx( st->stab_fac_fx, &st->Mode2_lp_gainp, st->last_core ); + move16(); } hTcxDec->cummulative_damping_tcx = shl( mult( hTcxDec->cummulative_damping_tcx, hTcxDec->damping ), 1 ); /*shl(Q15*Q14,1)=shl(Q14,1) = Q15*/ + move16(); } IF( bfi ) @@ -4183,7 +4232,7 @@ void decoder_tcx_invQ_fx( } } - IF( st->element_mode != IVAS_CPE_MDCT ) + IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { set16_fx( h1, 0, L_SUBFR + 1 ); set16_fx( mem, 0, M ); @@ -4211,12 +4260,14 @@ void decoder_tcx_invQ_fx( { tmp32 = Dot_productSq16HQ( 0, h1, L_SUBFR, &st->last_gain_syn_deemph_e ) /*Q15, st->last_gain_syn_deemph_e*/; st->last_gain_syn_deemph_e = add( st->last_gain_syn_deemph_e, 10 /*scaling of h1[0] and E_UTIL_synthesis * 2*/ ); + move16(); tmp32 = Sqrt32( tmp32, &st->last_gain_syn_deemph_e ); #ifdef BASOP_NOGLOB st->last_gain_syn_deemph = round_fx_o( tmp32, &Overflow ); #else last_gain_syn_deemph_fx = round_fx( tmp32 ); #endif + move16(); } /*for avoiding compiler warnings*/ @@ -4298,7 +4349,7 @@ void decoder_tcx_invQ_fx( { /* envelope based arithmetic coder */ const Word16 *prm_resq; - prm_resq = prm_sqQ + *prm_target /* = targetBits */ - hTcxDec->resQBits[frame_cnt]; + prm_resq = prm_sqQ + sub( *prm_target /* = targetBits */, hTcxDec->resQBits[frame_cnt] ); i = tcx_ari_res_invQ_spec( x, *x_e, L_spec, prm_resq, @@ -4358,6 +4409,7 @@ void decoder_tcx_invQ_fx( IF( st->VAD == 0 ) { *gain_tcx = mult_r( *gain_tcx, hTcxCfg->na_scale ); + move16(); } IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) ) @@ -4365,6 +4417,8 @@ void decoder_tcx_invQ_fx( i = norm_s( *gain_tcx ); *gain_tcx = shl( *gain_tcx, i ); *gain_tcx_e = sub( *gain_tcx_e, i ); + move16(); + move16(); FOR( i = 0; i < FDNS_NPTS; i++ ) { gainlpc2[i] = mult( gainlpc2[i], *gain_tcx ); @@ -4420,16 +4474,17 @@ void decoder_tcx_noisefilling_fx( TCX_LTP_DEC_HANDLE hTcxLtpDec = st->hTcxLtpDec; TCX_DEC_HANDLE hTcxDec = st->hTcxDec; TCX_CONFIG_HANDLE hTcxCfg = st->hTcxCfg; - Word32 total_brate = ( (Word16) EQ_16( st->element_mode, IVAS_CPE_MDCT ) ? st->element_brate : st->total_brate ); + Word32 total_brate; Word32 tmp32; Word16 *pInfoTCXNoise; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; - move16(); + move32(); Flag Carry = 0; - move16(); + move32(); #endif - + total_brate = ( (Word16) EQ_16( st->element_mode, IVAS_CPE_MDCT ) ? st->element_brate : st->total_brate ); + move32(); /*-----------------------------------------------------------------* * Initializations *-----------------------------------------------------------------*/ @@ -4470,7 +4525,7 @@ void decoder_tcx_noisefilling_fx( move16(); test(); test(); - if ( ( hTcxCfg->ctx_hm != 0 ) && ( NE_16( st->last_core, ACELP_CORE ) ) && ( st->last_ctx_hm_enabled != 0 ) ) + if ( ( hTcxCfg->ctx_hm != 0 ) && ( st->last_core != ACELP_CORE ) && ( st->last_ctx_hm_enabled != 0 ) ) { tmp1 = 10240 /*0.3125f Q15*/; move16(); @@ -4491,7 +4546,7 @@ void decoder_tcx_noisefilling_fx( noiseTransWidth = HOLE_SIZE_FROM_LTP( s_max( hTcxLtpDec->tcxltp_gain, tmp1 ) ); } - IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) ) + if ( EQ_16( L_frame, shr( st->L_frame, 1 ) ) ) { noiseTransWidth = 3; /* minimum transition fading for noise filling in TCX-10 */ move16(); @@ -4528,7 +4583,6 @@ void decoder_tcx_noisefilling_fx( if ( st->igf ) { pInfoTCXNoise = st->hIGFDec->infoTCXNoise_ptr; - move16(); } #endif tcx_noise_filling_with_shift( x, x_e, nf_seed, firstLine, noiseFillingSize, noiseTransWidth, L_frame, noiseTiltFactor, fac_ns, pInfoTCXNoise, st->element_mode ); @@ -4606,6 +4660,7 @@ void decoder_tcx_noisefilling_fx( if ( EQ_16( st->core, TCX_10_CORE ) ) { st->hPlcInfo->subframe = extract_l( L_mult0( frame_cnt, L_frameTCX_glob ) ); + move16(); } } @@ -4618,7 +4673,6 @@ void decoder_tcx_noisefilling_fx( IF( bfi == 0 && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { TonalMDCTConceal_SaveFreqSignal_ivas_fx( st->hTonalMDCTConc, x, *x_e, L_frameTCX, L_frame, gainlpc2, gainlpc2_e, gain_tcx_e, infoIGFStartLine ); - // st->hTonalMDCTConc->last_block_nrg_flt = me2f( st->hTonalMDCTConc->last_block_nrg, st->hTonalMDCTConc->last_block_nrg_exp ); } ELSE IF( bfi ) { @@ -4652,7 +4706,7 @@ void decoder_tcx_noisefilling_fx( Word32 E_2ndlast, E_last; Word16 tmp_len; - IF( GT_16( st->element_mode, EVS_MONO ) ) + IF( st->element_mode > EVS_MONO ) { tmp_len = L_frame; move16(); @@ -4675,7 +4729,7 @@ void decoder_tcx_noisefilling_fx( tmp1 = shl( tmp1, tmp2 ); #endif /* replace higher energy TCX5 frame by lower one to avoid energy fluctuation */ - IF( GT_16( st->element_mode, EVS_MONO ) ) + IF( st->element_mode > EVS_MONO ) { tmp_len = L_frame; move16(); @@ -4717,8 +4771,10 @@ void decoder_tcx_noisefilling_fx( tcxGetNoiseFillingTilt( A, M, L_frame, tmp, &noiseTiltFactor ); - Word32 CngLevelBackgroundTrace_bfi_fx = L_deposit_l( hTcxDec->conCngLevelBackgroundTrace ); - Word16 CngLevelBackgroundTrace_bfi_exp = hTcxDec->conCngLevelBackgroundTrace_e + 16; + Word32 CngLevelBackgroundTrace_bfi_fx; + CngLevelBackgroundTrace_bfi_fx = L_deposit_l( hTcxDec->conCngLevelBackgroundTrace ); + Word16 CngLevelBackgroundTrace_bfi_exp; + CngLevelBackgroundTrace_bfi_exp = add( hTcxDec->conCngLevelBackgroundTrace_e, 16 ); test(); IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && MCT_flag == 0 ) { @@ -4743,6 +4799,7 @@ void decoder_tcx_noisefilling_fx( move16(); } *x_e = add( *x_e, gain_tcx_e ); + move16(); } } @@ -4782,7 +4839,7 @@ void decoder_tcx_noisefilling_fx( IGFDecReplicateTCX10State_fx( st->hIGFDec ); } - IF( NE_16( st->element_mode, EVS_MONO ) ) + IF( st->element_mode != EVS_MONO ) { IF( bfi ) { @@ -4799,6 +4856,7 @@ void decoder_tcx_noisefilling_fx( if ( st->igf ) { *st->hIGFDec->igfData.igfInfo.nfSeed = extract_l( L_add( L_mult0( nf_seed, 31821 ), 13849 ) ); + move16(); } return; @@ -4825,7 +4883,7 @@ void decoder_tcx_noiseshaping_igf_fx( const Word16 bfi /* i : Bad frame indicator */ ) { - TCX_DEC_HANDLE hTcxDec = st->hTcxDec; + TCX_DEC_HANDLE hTcxDec; Word16 i; Word32 tmp32; Word8 tmp8; @@ -4833,6 +4891,7 @@ void decoder_tcx_noiseshaping_igf_fx( /*-----------------------------------------------------------* * Noise shaping in frequency domain (1/Wz) * *-----------------------------------------------------------*/ + hTcxDec = st->hTcxDec; test(); test(); @@ -4846,7 +4905,7 @@ void decoder_tcx_noiseshaping_igf_fx( } ELSE { - IF( EQ_16( st->last_core, ACELP_CORE ) ) + IF( st->last_core == ACELP_CORE ) { IGFDecCopyLPCFlatSpectrum_fx( st->hIGFDec, x_fx, *x_e, IGF_GRID_LB_TRAN ); } @@ -4907,6 +4966,7 @@ void decoder_tcx_noiseshaping_igf_fx( } } *x_e = s_max( spec_side_x_e, frame_side_x_e ); + move16(); set32_fx( x_fx + L_spec, 0, sub( L_frameTCX, L_spec ) ); } @@ -4982,6 +5042,7 @@ void decoder_tcx_noiseshaping_igf_fx( concealment_update_x( bfi, st->core, st->tonality_flag, x_fx, x_e, &st->hPlcInfo ); *x_len = s_max( *x_len, st->hPlcInfo->L_frameTCX ); + move16(); } /*-----------------------------------------------------------* @@ -4996,7 +5057,6 @@ void decoder_tcx_noiseshaping_igf_fx( { Word16 igfGridIdx; - test(); test(); IF( ( EQ_16( st->last_core, ACELP_CORE ) ) || ( left_rect && bfi ) ) { @@ -5013,6 +5073,7 @@ void decoder_tcx_noiseshaping_igf_fx( IGFDecApplyMono_ivas( st->hIGFDec, x_fx, x_e, igfGridIdx, bfi, st->element_mode ); *x_len = s_max( *x_len, st->hIGFDec->igfData.igfInfo.grid[igfGridIdx].stopLine ); + move16(); } } test(); @@ -5024,6 +5085,7 @@ void decoder_tcx_noiseshaping_igf_fx( IGFDecApplyMono_ivas( st->hIGFDec, x_fx, x_e, IGF_GRID_LB_SHORT, bfi, st->element_mode ); *x_len = s_max( *x_len, st->hIGFDec->igfData.igfInfo.grid[IGF_GRID_LB_SHORT].stopLine ); + move16(); } } diff --git a/lib_dec/dec_tran_fx.c b/lib_dec/dec_tran_fx.c index 4d8767e475e737c6a2eb2e4fd98c2667483d9683..f92ef8904f274e14e1bc40b323df516c32c8f5cc 100644 --- a/lib_dec/dec_tran_fx.c +++ b/lib_dec/dec_tran_fx.c @@ -57,24 +57,19 @@ void decod_tran_fx( ) { Word16 T0, T0_frac, T0_min, T0_max; /* integer pitch variables */ - Word32 gain_code_fx = 0; /* Quantized algebraic codeebook gain */ - move16(); - Word32 norm_gain_code_fx = 0; /* normalized algebraic codeebook gain */ - move16(); - Word16 gain_pit_fx = 0; /* Quantized pitch gain */ - move16(); - Word16 voice_fac_fx; /* Voicing factor */ - Word16 gain_inov_fx = 0; /* inovation gain */ - move16(); - Word16 code_fx[L_SUBFR]; /* algebraic codevector */ - const Word16 *p_Aq_fx; /* pointer to lp filter coefficient */ - Word16 *pt_pitch_fx; /* pointer to floating pitch */ - Word16 i_subfr, i; /* tmp variables */ - Word16 position; /* TC related flag */ - Word16 gain_preQ_fx = 0; /* Gain of prequantizer excitation */ - move16(); - Word16 code_preQ_fx[L_SUBFR]; /* Prequantizer excitation */ - Word16 Jopt_flag; /* flag indicating zero adaptive contribtuion */ + Word32 gain_code_fx; /* Quantized algebraic codeebook gain */ + Word32 norm_gain_code_fx; /* normalized algebraic codeebook gain */ + Word16 gain_pit_fx; /* Quantized pitch gain */ + Word16 voice_fac_fx; /* Voicing factor */ + Word16 gain_inov_fx; /* inovation gain */ + Word16 code_fx[L_SUBFR]; /* algebraic codevector */ + const Word16 *p_Aq_fx; /* pointer to lp filter coefficient */ + Word16 *pt_pitch_fx; /* pointer to floating pitch */ + Word16 i_subfr, i; /* tmp variables */ + Word16 position; /* TC related flag */ + Word16 gain_preQ_fx; /* Gain of prequantizer excitation */ + Word16 code_preQ_fx[L_SUBFR]; /* Prequantizer excitation */ + Word16 Jopt_flag; /* flag indicating zero adaptive contribtuion */ Word32 norm_gain_preQ_fx; Word16 gain_code16; Word32 L_tmp; @@ -84,6 +79,18 @@ void decod_tran_fx( MUSIC_POSTFILT_HANDLE hMusicPF; hMusicPF = st_fx->hMusicPF; + + gain_code_fx = 0; /* Quantized algebraic codeebook gain */ + move32(); + norm_gain_code_fx = 0; /* normalized algebraic codeebook gain */ + move32(); + gain_pit_fx = 0; /* Quantized pitch gain */ + move16(); + gain_inov_fx = 0; /* inovation gain */ + move16(); + gain_preQ_fx = 0; /* Gain of prequantizer excitation */ + move16(); + gain_preQ_fx = 0; move16(); set16_fx( code_preQ_fx, 0, L_SUBFR ); @@ -92,9 +99,7 @@ void decod_tran_fx( *----------------------------------------------------------------*/ p_Aq_fx = Aq_fx; - move16(); pt_pitch_fx = pitch_buf_fx; - move16(); Jopt_flag = 0; move16(); norm_gain_preQ_fx = 0; @@ -144,7 +149,7 @@ void decod_tran_fx( IF( Jopt_flag == 0 ) { /* 2/3-bit decoding */ - IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) + IF( st_fx->element_mode == EVS_MONO ) { gain_dec_tc_fx( st_fx, code_fx, i_subfr, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx ); } @@ -189,7 +194,7 @@ void decod_tran_fx( test(); test(); test(); - IF( GT_16( st_fx->element_mode, EVS_MONO ) && ( GE_16( add( i_subfr, L_SUBFR ), tc_subfr_fx ) && LT_16( i_subfr, tc_subfr_fx ) && GT_16( st_fx->Q_subfr[0], 4 ) ) ) + IF( st_fx->element_mode > EVS_MONO && ( GE_16( add( i_subfr, L_SUBFR ), tc_subfr_fx ) && LT_16( i_subfr, tc_subfr_fx ) && GT_16( st_fx->Q_subfr[0], 4 ) ) ) { test(); test(); @@ -257,7 +262,9 @@ void decod_tran_fx( /*-----------------------------------------------------------------* * Prepare TBE excitation *-----------------------------------------------------------------*/ - Word16 tmp_idx_2 = 0; + Word16 tmp_idx_2; + tmp_idx_2 = 0; + move16(); if ( i_subfr != 0 ) { tmp_idx_2 = idiv1616( i_subfr, L_SUBFR ); @@ -280,14 +287,14 @@ void decod_tran_fx( norm_gain_code_fx, gain_inov_fx, &st_fx->gc_threshold_fx, code_fx, exc2_fx, gain_pit_fx, &( st_fx->dm_fx ), st_fx->Q_exc ); } - Word16 tmp_idx = 0; + Word16 tmp_idx; + tmp_idx = 0; move16(); if ( i_subfr != 0 ) { tmp_idx = idiv1616( i_subfr, L_SUBFR ); } p_Aq_fx += ( M + 1 ); - move16(); pt_pitch_fx++; st_fx->tilt_code_dec_fx[tmp_idx] = st_fx->tilt_code_fx; move16(); diff --git a/lib_dec/dec_uv_fx.c b/lib_dec/dec_uv_fx.c index ceb4d26507435ec099a533980f7278d4dc2ab8b3..2cb4aa9347200da967176ddda0772d449f35ea0c 100644 --- a/lib_dec/dec_uv_fx.c +++ b/lib_dec/dec_uv_fx.c @@ -38,8 +38,7 @@ void decod_unvoiced_fx( Word16 *bwe_exc_fx, /* Q_X i/o: excitation for SWB TBE */ Word16 *gain_buf ) { - Word16 gain_pit_fx = 0; /* Quantized pitch gain */ - move16(); + Word16 gain_pit_fx; /* Quantized pitch gain */ Word32 gain_code_fx; /* Quantized algebraic codeebook gain */ Word16 gain_inov_fx; /* inovation gain */ Word32 norm_gain_code_fx; /* normalized algebraic codeebook gain */ @@ -49,6 +48,9 @@ void decod_unvoiced_fx( const Word16 *p_Aq_fx; Word16 *pt_pitch_fx; + gain_pit_fx = 0; + move16(); + test(); IF( EQ_16( st_fx->last_ppp_mode_dec, 1 ) || EQ_16( st_fx->last_nelp_mode_dec, 1 ) ) { @@ -71,6 +73,7 @@ void decod_unvoiced_fx( &voice_fac_fx, &gain_pit_fx, pt_pitch_fx, exc_fx, &gain_code_fx, exc2_fx, bwe_exc_fx, &( st_fx->Q_exc ), st_fx->Q_subfr ); *tmp_noise_fx = extract_h( norm_gain_code_fx ); /*Q16*/ + move16(); /*----------------------------------------------------------------* * Excitation enhancements (update of total excitation signal) @@ -91,7 +94,6 @@ void decod_unvoiced_fx( interp_code_5over2_fx( &exc_fx[i_subfr_fx], &bwe_exc_fx[shr( imult1616( i_subfr_fx, 2 * HIBND_ACB_L_FAC ), 1 )], L_SUBFR ); p_Aq_fx += ( M + 1 ); - move16(); pt_pitch_fx++; st_fx->tilt_code_dec_fx[tmp_idx] = st_fx->tilt_code_fx; move16(); @@ -126,8 +128,7 @@ void decod_unvoiced_ivas_fx( Word16 *bwe_exc_fx, /* Q_X i/o: excitation for SWB TBE */ Word16 *gain_buf ) { - Word16 gain_pit_fx = 0; /* Quantized pitch gain */ - move16(); + Word16 gain_pit_fx; /* Quantized pitch gain */ Word32 gain_code_fx; /* Quantized algebraic codeebook gain */ Word32 gain_code2_fx; Word16 gain_inov_fx; /* inovation gain */ @@ -139,6 +140,9 @@ void decod_unvoiced_ivas_fx( Word16 *pt_pitch_fx; Word16 code2_fx[L_SUBFR]; + gain_pit_fx = 0; /* Quantized pitch gain */ + move16(); + test(); IF( EQ_16( st_fx->last_ppp_mode_dec, 1 ) || EQ_16( st_fx->last_nelp_mode_dec, 1 ) ) { @@ -146,10 +150,8 @@ void decod_unvoiced_ivas_fx( CNG_reset_dec_fx( st_fx, pitch_buf_fx, voice_factors_fx ); } - p_Aq_fx = Aq_fx; - move16(); /*Q12*/ /* pointer to interpolated LPC parameters */ - pt_pitch_fx = pitch_buf_fx; - move16(); /* pointer to the pitch buffer */ + p_Aq_fx = Aq_fx; /*Q12*/ /* pointer to interpolated LPC parameters */ + pt_pitch_fx = pitch_buf_fx; /* pointer to the pitch buffer */ FOR( i_subfr_fx = 0; i_subfr_fx < L_FRAME; i_subfr_fx += L_SUBFR ) { @@ -171,6 +173,7 @@ void decod_unvoiced_ivas_fx( set16_fx( exc_fx + i_subfr_fx, 0, L_SUBFR ); *pt_pitch_fx = shl( L_SUBFR, Q6 ); + move16(); /*--------------------------------------------------------------* * Innovation decoding @@ -189,21 +192,22 @@ void decod_unvoiced_ivas_fx( /*-----------------------------------------------------------------* * Gain encoding *-----------------------------------------------------------------*/ - Word16 tmp_idx_1 = 0; + Word16 tmp_idx_1; + tmp_idx_1 = 0; move16(); if ( i_subfr_fx != 0 ) { tmp_idx_1 = idiv1616( i_subfr_fx, L_SUBFR ); } - Word16 index = get_next_indice_fx( st_fx, st_fx->acelp_cfg.gains_mode[tmp_idx_1] ); - // gain_dec_gacelp_uv(index, code, code2, Es_pred, L_SUBFR, &gain_pit, &gain_code, &gain_code2, &(st->past_gpit_float), &norm_gain_code, &gain_inov); + Word16 index; + index = get_next_indice_fx( st_fx, st_fx->acelp_cfg.gains_mode[tmp_idx_1] ); + gain_dec_gacelp_uv_fx( index, code_fx, code2_fx, Es_pred_fx, L_SUBFR, &gain_pit_fx, &gain_code_fx, &gain_code2_fx, &( st_fx->past_gpit ), &norm_gain_code_fx, &gain_inov_fx ); - // st->tilt_code = est_tilt(exc + i_subfr, gain_pit, code, gain_code, &voice_fac, L_SUBFR, 0); st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR, 0 ); + move16(); /* update LP filtered gains for the case of frame erasures */ - // lp_gain_updt(i_subfr, gain_pit, norm_gain_code, &st->lp_gainp, &st->lp_gainc, L_FRAME); lp_gain_updt_ivas_fx( i_subfr_fx, gain_pit_fx, norm_gain_code_fx, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_FRAME ); /*-------------------------------------------------------* @@ -231,10 +235,14 @@ void decod_unvoiced_ivas_fx( exc2_fx[i + i_subfr_fx] = shl( mult_r( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 2 ); // Q_exc exc2_fx[i + i_subfr_fx] = add( exc2_fx[i + i_subfr_fx], extract_l( L_shr( Mpy_32_16_1( gain_code2_fx, code2_fx[i] ), sub( Q10, st_fx->Q_exc ) ) ) ); // Q_exc exc_fx[i + i_subfr_fx] = add( exc2_fx[i + i_subfr_fx], extract_l( L_shr( Mpy_32_16_1( gain_code_fx, code_fx[i] ), sub( Q10, st_fx->Q_exc ) ) ) ); // Q_exc + move16(); + move16(); + move16(); } // Scale_sig(code_fx, L_SUBFR, 3); //Q12 } *tmp_noise_fx = extract_h( norm_gain_code_fx ); /*Q16*/ + move16(); /*----------------------------------------------------------------* * Excitation enhancements (update of total excitation signal) @@ -245,7 +253,9 @@ void decod_unvoiced_ivas_fx( enhancer_ivas_fx( MODE1, st_fx->core_brate, uc_two_stage_flag, 0, coder_type, i_subfr_fx, L_FRAME, voice_fac_fx, st_fx->stab_fac_fx, norm_gain_code_fx, gain_inov_fx, &st_fx->gc_threshold_fx, code_fx /*Q9/Q12?*/, exc2_fx, gain_pit_fx, &( st_fx->dm_fx ), st_fx->Q_exc ); - Word16 tmp_idx = 0; + Word16 tmp_idx; + tmp_idx = 0; + move16(); if ( i_subfr_fx != 0 ) { idiv1616( i_subfr_fx, L_SUBFR ); @@ -255,7 +265,6 @@ void decod_unvoiced_ivas_fx( interp_code_5over2_fx( &exc_fx[i_subfr_fx], &bwe_exc_fx[shr( imult1616( i_subfr_fx, 2 * HIBND_ACB_L_FAC ), 1 )], L_SUBFR ); p_Aq_fx += ( M + 1 ); - move16(); pt_pitch_fx++; st_fx->tilt_code_dec_fx[tmp_idx] = st_fx->tilt_code_fx; move16(); @@ -310,6 +319,7 @@ static void gain_dec_gacelp_uv_fx( /* gain_inov = 1.0f / sqrt((dot_product(code, code, L_SUBFR) + 0.01) / L_SUBFR) */ L_tmp = calc_gain_inov( code, lcode, NULL, NULL ); *gain_inov = round_fx( L_shl( L_tmp, 15 - 3 ) ); /* gain_inov in Q12 */ + move16(); /* gcode = pred_nrg_frame * (*gain_inov); */ L_tmp = Mpy_32_16_1( pred_nrg_frame, *gain_inov ); /* 18Q13 */ i = sub( norm_l( L_tmp ), 1 ); // gaurd-bits diff --git a/lib_dec/er_dec_acelp_fx.c b/lib_dec/er_dec_acelp_fx.c index 3a8a3de62bc5e9a0cb93a9569798e54f1035b696..e0174c71eb5771036dc499068be26492f43073a8 100644 --- a/lib_dec/er_dec_acelp_fx.c +++ b/lib_dec/er_dec_acelp_fx.c @@ -182,6 +182,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*/ + move16(); if ( EQ_16( st->nbLostCmpt, 1 ) ) { st->cummulative_damping = 32767 /*1.f Q15*/; /*Q15*/ @@ -297,7 +298,7 @@ void con_acelp_fx( pitch_buf[3] = pitch_buf[2] = pitch_buf[1]; /* do not resync on second half of frame */ move32(); move32(); - IF( EQ_16( st->nb_subfr, 5 ) ) + if ( EQ_16( st->nb_subfr, 5 ) ) { /* for guided acelp cases and nSubframes=2, set pitch_buf[4] to avoid memory_access issues in post_decoder() */ pitch_buf[4] = pitch_buf[3]; @@ -347,6 +348,7 @@ void con_acelp_fx( if ( EQ_16( st->flagGuidedAcelp, 1 ) ) { st->old_fpitch = L_deposit_h( T0 ); + move32(); } } @@ -386,6 +388,7 @@ void con_acelp_fx( gain = 0x4000 /*1 (1Q14)*/; /* start-of-the-frame gain */ move16(); st->Mode2_lp_gainp = L_shl( L_deposit_l( alpha ), 15 ); /*1Q14->2Q29*/ + move32(); } tmp_16 = extract_l( L_shl( L_mac( -28000, st->L_frame, 95 ), 1 - 15 ) ); @@ -592,11 +595,14 @@ void con_acelp_fx( s_16 = BASOP_Util_Add_MantExp( tmp_16, s_16, tmp2, s2, &tmp_16 ); st->Mode2_lp_gainc = L_shl( L_deposit_l( tmp_16 ), add( s_16, 1 ) ); + move32(); test(); IF( ( EQ_16( st->last_good, UNVOICED_TRANSITION ) ) && ( EQ_16( coder_type, GENERIC ) ) ) { st->Mode2_lp_gainc = L_deposit_h( gainCNG ); /*Q21*/ st->Mode2_lp_gainc = L_shr( st->Mode2_lp_gainc, sub( 5, gainCNG_e ) ); /*15Q16, no scaling*/ + move32(); + move32(); } highPassFiltering_fx( st->last_good, add( st->L_frame, shr( l_fir_fer, 1 ) ), noise_buf, hp_filt, l_fir_fer ); @@ -1049,6 +1055,7 @@ void con_acelp_fx( #else st->enr_old_fx = L_shl( st->enr_old_fx, shl( negate( Qf_syn ), 1 ) ); #endif + move32(); /* update ACELP synthesis memory */ Copy( mem_syn, st->mem_syn2_fx, M ); Copy( syn + st->L_frame - L_SYN_MEM, st->mem_syn_r, L_SYN_MEM ); @@ -1156,6 +1163,7 @@ void con_acelp_fx( st->bfi_pitch_fx = shl( round_fx( pitch_buf[sub( st->nb_subfr, 1 )] ), 6 ); st->bfi_pitch_frame = st->L_frame; move16(); + move16(); return; } @@ -1201,6 +1209,7 @@ static void memsynPrecission_fx( Word16 nbLostCmpt, Word16 *mem_syn, Word16 *exc move16(); } *s_16 = s_max( sub( s_min( sf_exc, sf_mem_syn ), 5 ), 0 ) /*5 bits of headroom, scaling not smaller than 0*/; + move16(); Scale_sig( mem_syn, M, *s_16 ); Scale_sig( exc, add( shr( len, 1 ), len ), *s_16 ); } diff --git a/lib_dec/er_dec_tcx_fx.c b/lib_dec/er_dec_tcx_fx.c index 3ffd7811a89e0ca6f8efe2a854d908a8608a2c25..04545e3fcfe6fd503447238ffd0f78a24538b2fa 100644 --- a/lib_dec/er_dec_tcx_fx.c +++ b/lib_dec/er_dec_tcx_fx.c @@ -22,6 +22,8 @@ static void calcGainc_fx( Word16 *exc, Word16 Q_exc, Word32 old_fpitch, Word16 L #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; Flag Carry = 0; + move32(); + move32(); #endif @@ -76,6 +78,7 @@ static void calcGainc_fx( Word16 *exc, Word16 Q_exc, Word32 old_fpitch, Word16 L tmp16 = Sqrt16( tmp16, &tmp_e ); /*Q15,norm,tmp_e*/ } *lp_gainc = L_shl( L_deposit_l( tmp16 ), add( tmp_e, 1 ) ); /*15Q16*/ + move32(); } static void calcGainc2_fx( Word16 *exc, Word16 Q_exc, Word16 L_subfr, Word32 *lp_gainc ) @@ -298,7 +301,7 @@ void con_tcx_fx( offset = shr( L_frame, 1 ); IF( GE_16( st->last_good, UNVOICED_TRANSITION ) ) { - tmp16 = s_max( Tc - shr( L_frame, 1 ), 0 ); + tmp16 = s_max( sub( Tc, shr( L_frame, 1 ) ), 0 ); Copy_Scale_sig( hTcxDec->old_excFB_fx, &( exc[-tmp16] ), add( offset, tmp16 ), sub( Q_exc, st->Q_exc ) ); } ELSE @@ -335,9 +338,12 @@ void con_tcx_fx( test(); IF( ( ( EQ_16( st->nbLostCmpt, 1 ) ) || hTcxDec->tcxConceal_recalc_exc ) && GE_16( st->rf_frame_type, RF_TCXFD ) && LE_16( st->rf_frame_type, RF_TCXTD2 ) && st->use_partial_copy ) { - Word32 tcxltp_pitch_tmp = L_add( L_deposit_h( hTcxLtpDec->tcxltp_pitch_int ), L_shl( L_deposit_l( div_s( hTcxLtpDec->tcxltp_pitch_fr, st->pit_res_max ) ), 1 ) ); /*15Q16*/ - Word16 scale_tmp = mult_r( hTcxDec->L_frameTCX, getInvFrameLen( st->L_frame ) ); /*getInvFrameLen()->9Q6*/ - Word16 tmp_shift = norm_s( scale_tmp ); + Word32 tcxltp_pitch_tmp; /*15Q16*/ + Word16 scale_tmp; /*getInvFrameLen()->9Q6*/ + Word16 tmp_shift; + tcxltp_pitch_tmp = L_add( L_deposit_h( hTcxLtpDec->tcxltp_pitch_int ), L_shl( L_deposit_l( div_s( hTcxLtpDec->tcxltp_pitch_fr, st->pit_res_max ) ), 1 ) ); /*15Q16*/ + scale_tmp = mult_r( hTcxDec->L_frameTCX, getInvFrameLen( st->L_frame ) ); /*getInvFrameLen()->9Q6*/ + tmp_shift = norm_s( scale_tmp ); predPitchLag = L_shl( Mpy_32_16_1( tcxltp_pitch_tmp, shl( scale_tmp, tmp_shift ) ), sub( 9, tmp_shift ) ); T0 = round_fx( predPitchLag ); @@ -563,6 +569,7 @@ void con_tcx_fx( #else st->cummulative_damping = shl( mult_r( st->cummulative_damping /*Q15*/, alpha /*Q14*/ ), 1 ) /*Q15*/; #endif + move16(); } gain32 = L_add( 2147483647l /*1.f Q31*/, 0 ); /*Q31*/ @@ -833,6 +840,8 @@ void con_tcx_fx( L_tmp2 = L_mult( sub( 16384 /*1.f Q14*/, alpha ) /*Q14*/, gainCNG /*Q15,gainCNG_e*/ ); /*Q30,gainCNG_e*/ st->Mode2_lp_gainc = BASOP_Util_Add_Mant32Exp( L_tmp, 31 - 15, L_tmp2, add( gainCNG_e, 31 - 30 ), &tmp_e ); /*Q31*/ st->Mode2_lp_gainc = L_shl( st->Mode2_lp_gainc, sub( tmp_e, 31 - 16 ) ); + move32(); + move32(); /* PLC: [TCX: Fade-out] Linearly attenuate the gain through the frame */ /*step = (1.0f/L_frame) * (gain - (st->Mode2_lp_gainc));*/ @@ -872,7 +881,8 @@ void con_tcx_fx( } st->Mode2_lp_gainp = L_shr( L_deposit_h( alpha /*Q14*/ ) /*Q14+16*/, 1 ); /*Q29*/ - pt_exc = noise; /* non-causal ringing of the FIR filter */ + move32(); + pt_exc = noise; /* non-causal ringing of the FIR filter */ tmp_e = norm_l( gain32 ); tmp_e = sub( tmp_e, 5 ); /*5 Bit additional Headroom for the gain - should be enough*/ @@ -1076,6 +1086,7 @@ void con_tcx_fx( #else st->bfi_pitch_fx /*Q6*/ = round_fx( L_shl( pitch_buf[sub( st->nb_subfr, 1 )] /*15Q16*/, 6 /*Q6*/ ) ); #endif + move16(); st->bfi_pitch_frame = st->L_frame; move16(); @@ -1138,6 +1149,7 @@ void con_tcx_fx( lerp( st->hHQ_core->old_out_fx, st->hHQ_core->old_out_LB_fx, st->L_frame, L_frame ); st->old_enr_LP = Enr_1_Az_fx( A_local, L_SUBFR ); /*Q3*/ + move16(); return; } @@ -1251,10 +1263,14 @@ void con_tcx_ivas_fx( st->Mode2_lp_gainc = L_deposit_l( 0 ); st->Mode2_lp_gainp = get_gain2( synth - shl( L_subfr, 1 ), synth - add( shl( L_subfr, 1 ), Tc ), shl( L_subfr, 1 ) ); + move32(); st->Mode2_lp_gainp = L_max( st->Mode2_lp_gainp, 0 ); st->Mode2_lp_gainp = L_min( st->Mode2_lp_gainp, 65536l /*1.0f Q16*/ ); st->Mode2_lp_gainp = L_shl( st->Mode2_lp_gainp, 13 ); + move32(); + move32(); + move32(); ana_window = buf; ham_cos_window( ana_window, mult( L_frame, 24576 /*0.75f Q15*/ ), shr( L_frame, 2 ) ); @@ -1331,9 +1347,13 @@ void con_tcx_ivas_fx( test(); IF( ( ( EQ_16( st->nbLostCmpt, 1 ) ) || hTcxDec->tcxConceal_recalc_exc ) && GE_16( st->rf_frame_type, RF_TCXFD ) && LE_16( st->rf_frame_type, RF_TCXTD2 ) && st->use_partial_copy ) { - Word32 tcxltp_pitch_tmp = L_add( L_deposit_h( hTcxLtpDec->tcxltp_pitch_int ), L_shl( L_deposit_l( div_s( hTcxLtpDec->tcxltp_pitch_fr, st->pit_res_max ) ), 1 ) ); /*15Q16*/ - Word16 scale_tmp = mult_r( hTcxDec->L_frameTCX, getInvFrameLen( st->L_frame ) ); /*getInvFrameLen()->9Q6*/ - Word16 tmp_shift = norm_s( scale_tmp ); + Word32 tcxltp_pitch_tmp; /*15Q16*/ + Word16 scale_tmp; /*getInvFrameLen()->9Q6*/ + Word16 tmp_shift; + tcxltp_pitch_tmp = L_add( L_deposit_h( hTcxLtpDec->tcxltp_pitch_int ), L_shl( L_deposit_l( div_s( hTcxLtpDec->tcxltp_pitch_fr, st->pit_res_max ) ), 1 ) ); /*15Q16*/ + scale_tmp = mult_r( hTcxDec->L_frameTCX, getInvFrameLen( st->L_frame ) ); /*getInvFrameLen()->9Q6*/ + tmp_shift = norm_s( scale_tmp ); + predPitchLag = L_shl( Mpy_32_16_1( tcxltp_pitch_tmp, shl( scale_tmp, tmp_shift ) ), sub( 9, tmp_shift ) ); T0 = round_fx( predPitchLag ); @@ -1530,6 +1550,7 @@ void con_tcx_ivas_fx( #else st->cummulative_damping = shl( mult_r( st->cummulative_damping /*Q15*/, alpha /*Q14*/ ), 1 ) /*Q15*/; #endif + move16(); } gain32 = L_add( 2147483647l /*1.f Q31*/, 0 ); /*Q31*/ @@ -1632,7 +1653,7 @@ void con_tcx_ivas_fx( { alpha_coh = Sqrt16( div_s( sub( 16384, coh ), add( 16384, coh ) ), &e ); } - IF( EQ_16( st->idchan, 1 ) ) + if ( EQ_16( st->idchan, 1 ) ) { alpha_coh = negate( alpha_coh ); } @@ -1646,7 +1667,7 @@ void con_tcx_ivas_fx( } test(); - IF( EQ_16( st->idchan, 1 ) || only_left ) + if ( EQ_16( st->idchan, 1 ) || only_left ) { *noise_seed = tmpSeed1; move16(); @@ -1740,6 +1761,7 @@ void con_tcx_ivas_fx( } L_tmp2 = Mpy_32_16_1( L_tmp2, st->cummulative_damping /*Q15*/ ); /*Q0, noise_e*/ noise[i] = mac_r( L_tmp2, gain_tmp, noise[i] ); /*Q15, noise_e*/ + move16(); } } } @@ -1815,6 +1837,8 @@ void con_tcx_ivas_fx( L_tmp2 = L_mult( sub( 16384 /*1.f Q14*/, alpha ) /*Q14*/, gainCNG /*Q15,gainCNG_e*/ ); /*Q30,gainCNG_e*/ st->Mode2_lp_gainc = BASOP_Util_Add_Mant32Exp( L_tmp, 31 - 15, L_tmp2, add( gainCNG_e, 31 - 30 ), &tmp_e ); /*Q31*/ st->Mode2_lp_gainc = L_shl( st->Mode2_lp_gainc, sub( tmp_e, 31 - 16 ) ); + move32(); + move32(); /* PLC: [TCX: Fade-out] Linearly attenuate the gain through the frame */ /*step = (1.0f/L_frame) * (gain - (st->Mode2_lp_gainc));*/ @@ -1857,7 +1881,9 @@ void con_tcx_ivas_fx( } st->Mode2_lp_gainp = L_shr( L_deposit_h( alpha /*Q14*/ ) /*Q14+16*/, 1 ); /*Q29*/ - pt_exc = noise; /* non-causal ringing of the FIR filter */ + move32(); + + pt_exc = noise; /* non-causal ringing of the FIR filter */ tmp_e = norm_l( gain32 ); tmp_e = sub( tmp_e, 5 ); /*5 Bit additional Headroom for the gain - should be enough*/ @@ -2067,6 +2093,7 @@ void con_tcx_ivas_fx( #else st->bfi_pitch_fx /*Q6*/ = round_fx( L_shl( pitch_buf[sub( st->nb_subfr, 1 )] /*15Q16*/, 6 /*Q6*/ ) ); #endif + move16(); st->bfi_pitch_frame = st->L_frame; move16(); @@ -2121,6 +2148,7 @@ void con_tcx_ivas_fx( lerp( st->hHQ_core->old_out_fx, st->hHQ_core->old_out_LB_fx, st->L_frame, L_frame ); st->old_enr_LP = Enr_1_Az_fx( A_local, L_SUBFR ); /*Q3*/ + move16(); return; } diff --git a/lib_dec/er_scale_syn_fx.c b/lib_dec/er_scale_syn_fx.c index 652041e6717b2572ef49833799c2ba03ccb0c3ac..2e5746ccfd530b7eaf6c65008bb1e9f32acd8a4a 100644 --- a/lib_dec/er_scale_syn_fx.c +++ b/lib_dec/er_scale_syn_fx.c @@ -125,11 +125,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 48f811e71d26c990432a3e27605e4d9582d6d445..6d8b2e8a2f474fc36a891055a5d346d7c4ca8f93 100644 --- a/lib_dec/er_sync_exc_fx.c +++ b/lib_dec/er_sync_exc_fx.c @@ -242,6 +242,7 @@ void PulseResynchronization_fx( Word32 /* pitchDelta, */ tmp32, tmp32_a, tmp32_b, samplesDelta, absPitchDiff, cycleDelta32; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif diff --git a/lib_dec/er_util_fx.c b/lib_dec/er_util_fx.c index 93ccaed26d8be53dd3e2740f13cd14c6fcfe8c5a..cc6a53cd2a541dc620458b710db8f5ed6b4b278a 100644 --- a/lib_dec/er_util_fx.c +++ b/lib_dec/er_util_fx.c @@ -98,7 +98,6 @@ void minimumStatistics_fx( /* recursively compute smoothed frame minima using optimal factor aOpt */ tmp = *currLevelIndex; move16(); - move16(); if ( tmp == 0 ) { tmp = PLC_MIN_STAT_BUFF_SIZE; @@ -124,6 +123,7 @@ void minimumStatistics_fx( } *new_noiseEstimate_e = BASOP_Util_Add_MantExp( round_fx( tmp32 ), add( aOpt_e, noiseLevelMemory_e[sub( tmp_e, 1 )] ), negate( s_max( tmp, -32767 ) /*to avoid negate(-32768)*/ ), tmp2, &f ); + move16(); assert( f >= 0 ); @@ -512,9 +512,12 @@ Word16 GetPLCModeDecision_fx( ) { Word16 /*int*/ core; - Word16 numIndices = 0; + Word16 numIndices; TCX_DEC_HANDLE hTcxDec; + numIndices = 0; + move16(); + hTcxDec = st->hTcxDec; diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c index 25f7a88f82543a312546841ec4e0b4f6e7186c6a..e1e630941dd0158dbe79614236377b74d80ef157 100644 --- a/lib_dec/fd_cng_dec.c +++ b/lib_dec/fd_cng_dec.c @@ -373,7 +373,7 @@ void configureFdCngDec_ivas_fx( hsCom->CngBandwidth = bwidth; move16(); - IF( EQ_16( hsCom->CngBandwidth, FB ) ) + if ( EQ_16( hsCom->CngBandwidth, FB ) ) { hsCom->CngBandwidth = SWB; move16(); @@ -387,7 +387,7 @@ void configureFdCngDec_ivas_fx( ELSE IF( EQ_32( hsCom->CngBitrate, -1 ) ) { /* set minimum active CBR bitrate IF CngBitrate is uninitialized */ - IF( GT_16( element_mode, EVS_MONO ) ) + IF( element_mode > EVS_MONO ) { hsCom->CngBitrate = IVAS_13k2; move32(); @@ -401,7 +401,7 @@ void configureFdCngDec_ivas_fx( /* 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(); @@ -486,7 +486,7 @@ void configureFdCngDec_ivas_fx( hsCom->regularStopBand = 40; move16(); test(); - IF( EQ_16( last_L_frame, L_FRAME ) && EQ_16( element_mode, IVAS_CPE_DFT ) ) + if ( EQ_16( last_L_frame, L_FRAME ) && EQ_16( element_mode, IVAS_CPE_DFT ) ) { hsCom->regularStopBand = 35; move16(); @@ -523,6 +523,7 @@ void configureFdCngDec_ivas_fx( move16(); } hsCom->nCLDFBpart = sub( hsCom->npart, hsCom->nFFTpart ); + move16(); FOR( j = 0; j < hsCom->nCLDFBpart; j++ ) { hsCom->CLDFBpart[j] = sub( hsCom->part[add( j, hsCom->nFFTpart )], sub( hsCom->stopFFTbin, hsCom->startBand ) ); @@ -533,7 +534,7 @@ void configureFdCngDec_ivas_fx( stopBandFR = 40; //(Word16)floor(1000.f /*Hz*/ / 25.f /*Hz/Bin*/); move16(); - IF( GT_16( stopBandFR, hsCom->stopFFTbin ) ) + if ( GT_16( stopBandFR, hsCom->stopFFTbin ) ) { stopBandFR = hsCom->stopFFTbin; move16(); @@ -1315,6 +1316,7 @@ void FdCng_decodeSID_ivas_fx( gain = 0; move32(); hFdCngCom->sid_frame_counter = add( hFdCngCom->sid_frame_counter, 1 ); + move16(); /* Read bitstream */ FOR( i = 0; i < FD_CNG_stages_37bits; i++ ) @@ -1348,10 +1350,9 @@ void FdCng_decodeSID_ivas_fx( 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] ); move32(); - IF( LT_16( max_res_exp, res_exp[i] ) ) + if ( LT_16( max_res_exp, res_exp[i] ) ) { max_res_exp = res_exp[i]; move16(); @@ -1934,14 +1935,16 @@ void generate_masking_noise_ivas_fx( Word32 maskingNoise_fx[L_FRAME16k]; Word32 *ptr_r_fx; Word32 *ptr_i_fx; - Word16 startBand = hFdCngCom->startBand; - move16(); + Word16 startBand; Word16 *seed = &( hFdCngCom->seed ); - Word32 scale_fx = 0x40000000; // 1.0 in Q30 + Word32 scale_fx; + Word16 shift; + scale_fx = 0x40000000; // 1.0 in Q30 move32(); - - Word16 shift = getScaleFactor32( hFdCngCom->cngNoiseLevel, FFTCLDFBLEN ); - IF( LT_16( sub( hFdCngCom->cngNoiseLevelExp, shift ), 4 ) ) + startBand = hFdCngCom->startBand; + move16(); + shift = getScaleFactor32( hFdCngCom->cngNoiseLevel, FFTCLDFBLEN ); + if ( LT_16( sub( hFdCngCom->cngNoiseLevelExp, shift ), 4 ) ) { shift = sub( hFdCngCom->cngNoiseLevelExp, 4 ); } @@ -1961,9 +1964,9 @@ void generate_masking_noise_ivas_fx( { test(); test(); - IF( EQ_16( hFdCngCom->CngBandwidth, scaleTable_cn_only[i].bwmode ) && - GE_32( hFdCngCom->CngBitrate, scaleTable_cn_only[i].bitrateFrom ) && - LT_32( hFdCngCom->CngBitrate, scaleTable_cn_only[i].bitrateTo ) ) + if ( EQ_16( hFdCngCom->CngBandwidth, scaleTable_cn_only[i].bwmode ) && + GE_32( hFdCngCom->CngBitrate, scaleTable_cn_only[i].bitrateFrom ) && + LT_32( hFdCngCom->CngBitrate, scaleTable_cn_only[i].bitrateTo ) ) { BREAK; } @@ -1976,7 +1979,7 @@ void generate_masking_noise_ivas_fx( /* Compute additional CN level */ FOR( i = 0; i < SIZE_SCALE_TABLE_CN_AMRWB; i++ ) { - IF( GE_32( hFdCngCom->CngBitrate, scaleTable_cn_only_amrwbio[i][0] ) ) + if ( GE_32( hFdCngCom->CngBitrate, scaleTable_cn_only_amrwbio[i][0] ) ) { BREAK; } @@ -2002,8 +2005,10 @@ void generate_masking_noise_ivas_fx( { rand_gauss_fx( &fftBuffer_fx[0], seed, *exp_out ); // Q15 ptr_r_fx = fftBuffer_fx + 2; - Word16 exp1 = add( hFdCngCom->cngNoiseLevelExp, 1 ); - Word32 mpy1 = Sqrt32( Mpy_32_32( scale_fx, *ptr_level_fx ), &exp1 ); // Q = noise_exp-1 + Word16 exp1; + exp1 = sub( 32, hFdCngCom->cngNoiseLevelExp ); + Word32 mpy1; + 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 ptr_level_fx++; @@ -2020,9 +2025,12 @@ void generate_masking_noise_ivas_fx( { /* Real part in FFT bins */ rand_gauss_fx( ptr_r_fx, seed, *exp_out ); // Q15 - Word16 exp2 = add( hFdCngCom->cngNoiseLevelExp, 1 ); - 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 + Word16 exp2; + exp2 = sub( 32, hFdCngCom->cngNoiseLevelExp ); + Word32 mpy2; + 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 + move32(); ptr_r_fx += 2; /* Imaginary part in FFT bins */ @@ -2373,20 +2381,27 @@ void generate_stereo_masking_noise_fx( move32(); IF( LT_32( gamma_fx, 966367642 /* 0.9 in Q30 */ ) ) { - Word16 exp_gamma = 0; + Word16 exp_gamma; + 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; + Word16 divisor1; + 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, exp_gamma2, exp_gamma3; + exp_gamma1 = Q1; + exp_gamma2 = Q1; + exp_gamma3 = Q1; move16(); move16(); move16(); gamma_fx = Sqrt32( L_add( gamma_fx, ONE_IN_Q30 ), &exp_gamma1 ); - Word32 temp = Sqrt32( gamma_fx, &exp_gamma2 ); // Q31-exp_gamma1 - 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 ), add( Q15, exp_gamma3 ) ); // Q30 + Word32 temp; + temp = Sqrt32( gamma_fx, &exp_gamma2 ); // Q31-exp_gamma1 + 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; + 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 ), add( Q15, exp_gamma3 ) ); // Q30 } ELSE { @@ -2399,7 +2414,8 @@ void generate_stereo_masking_noise_fx( 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 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 + Word32 add2; + 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 ); @@ -2421,7 +2437,7 @@ void generate_stereo_masking_noise_fx( } /* Below code to be converted */ 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++ ) + FOR( i = 0; i < shr( hFdCngCom->frameSize, 1 ); i++ ) { hFdCngCom->olapBufferSynth2[i] = (Word16) L_shr( Mpy_32_32( scale_fx_tmp, L_add( L_shr( hFdCngCom->olapBufferSynth2[add( i, i_mult( 5, shr( hFdCngCom->frameSize, 2 ) ) )], Q15 ), @@ -2437,7 +2453,7 @@ void generate_stereo_masking_noise_fx( } ELSE { - FOR( i = 0; i < hFdCngCom->frameSize / 2; i++ ) + FOR( i = 0; i < shr( hFdCngCom->frameSize, 1 ); i++ ) { Np_fx[i] = L_add( Np_fx[i], N1_fx[i] ); // Q6 move32(); @@ -2478,14 +2494,17 @@ void generate_stereo_masking_noise_fx( } 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 */ + Word16 SP_ratio_fx; + SP_ratio_fx = extract_h( hStereoTD->SP_ratio_LT_fx ); /* Use long-term SP ratio based on L/R synthesis */ + Word16 prevSP_ratio_fx; + 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 < shr( *hStereoCng->frameSize, 2 ); i++ ) { 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 + Word16 scale_fx_tmp; + 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] = add( syn[i], mult( scale_fx_tmp, shr( hStereoCng->maskingNoiseS_fx[i], sub( Q6, Q_syn ) ) ) ); move16(); @@ -2651,8 +2670,10 @@ void generate_masking_noise_lb_dirac_fx( /* Init */ scale = 0; + move32(); n_samples_out = i_mult( shr( hFdCngCom->frameSize, 4 ), nCldfbTs ); n_samples_start = 0; + move16(); Word16 exp_out = Q15; move16(); /*LB CLDFB - CNA from STFT*/ @@ -2666,9 +2687,9 @@ void generate_masking_noise_lb_dirac_fx( { test(); test(); - IF( ( EQ_16( hFdCngCom->CngBandwidth, scaleTable_cn_dirac[i].bwmode ) ) && - GE_32( hFdCngCom->CngBitrate, scaleTable_cn_dirac[i].bitrateFrom ) && - LT_32( hFdCngCom->CngBitrate, scaleTable_cn_dirac[i].bitrateTo ) ) + if ( ( EQ_16( hFdCngCom->CngBandwidth, scaleTable_cn_dirac[i].bwmode ) ) && + GE_32( hFdCngCom->CngBitrate, scaleTable_cn_dirac[i].bitrateFrom ) && + LT_32( hFdCngCom->CngBitrate, scaleTable_cn_dirac[i].bitrateTo ) ) { BREAK; } @@ -2683,10 +2704,10 @@ void generate_masking_noise_lb_dirac_fx( test(); IF( cna_flag && tdBuffer != NULL ) { - WHILE( GT_16( n_samples_out, 0 ) ) + WHILE( n_samples_out > 0 ) { n_samples_out_loop = s_min( hFdCngCom->frameSize, n_samples_out ); - IF( NE_32( scale, 0 ) ) + IF( scale != 0 ) { /*Generate LF comfort noise only at first slot, for the whole frame*/ ptr_level = cngNoiseLevel; @@ -2720,11 +2741,13 @@ void generate_masking_noise_lb_dirac_fx( Word16 exp2 = sub( 31, hFdCngCom->cngNoiseLevelExp ); Word32 mpy2 = Sqrt32( Mpy_32_32( scale, *ptr_level ), &exp2 ); ( *ptr_r ) = L_shl( Mpy_32_32( *ptr_r, mpy2 ), exp2 ); // hFdCngCom->fftBuffer_exp + exp2 - 31 + move32(); ptr_r += 2; /* Imaginary part in FFT bins */ rand_gauss_fx( ptr_i, seed, exp_out ); ( *ptr_i ) = L_shl( Mpy_32_32( *ptr_i, mpy2 ), exp2 ); + move32(); ptr_i += 2; } /* Remaining FFT bins are set to zero */ @@ -2747,6 +2770,7 @@ void generate_masking_noise_lb_dirac_fx( SynthesisSTFT_dirac_fx( fftBuffer, tdBuffer + n_samples_start, hFdCngCom->olapBufferSynth2_fx, hFdCngCom->olapWinSyn_fx, n_samples_out_loop, hFdCngCom ); } hFdCngCom->fftBuffer_exp = 31 - 15; + move16(); n_samples_out = sub( n_samples_out, hFdCngCom->frameSize ); n_samples_start = add( n_samples_start, hFdCngCom->frameSize ); } @@ -2893,17 +2917,19 @@ void generate_masking_noise_dirac_ivas_fx( set32_fx( Cldfb_ImagBuffer_fx, 0, CLDFB_NO_CHANNELS_MAX ); /*LB CLDFB - CNA from STFT*/ - IF( NE_16( cna_flag, 0 ) ) + IF( cna_flag != 0 ) { /* skip noise generating if level is very low, to avoid problems with possibly running into denormals */ - IF( GT_16( hFdCngCom->likelihood_noisy_speech, 0 ) ) + IF( hFdCngCom->likelihood_noisy_speech > 0 ) { /* Compute additional CN level */ FOR( i = 0; i < 15; i++ ) { - IF( ( EQ_16( hFdCngCom->CngBandwidth, scaleTable_cn_dirac[i].bwmode ) ) && - ( GE_32( hFdCngCom->CngBitrate, scaleTable_cn_dirac[i].bitrateFrom ) ) && - ( LT_32( hFdCngCom->CngBitrate, scaleTable_cn_dirac[i].bitrateTo ) ) ) + test(); + test(); + if ( ( EQ_16( hFdCngCom->CngBandwidth, scaleTable_cn_dirac[i].bwmode ) ) && + ( GE_32( hFdCngCom->CngBitrate, scaleTable_cn_dirac[i].bitrateFrom ) ) && + ( LT_32( hFdCngCom->CngBitrate, scaleTable_cn_dirac[i].bitrateTo ) ) ) { BREAK; } @@ -2931,10 +2957,9 @@ void generate_masking_noise_dirac_ivas_fx( } /*HF CLDFB - CNA and/or FD-CNG*/ - IF( fd_cng_flag ) + if ( fd_cng_flag ) { scale_fx = L_add( scale_fx, 2048 ); // 1 in Q11 - move16(); } IF( scale_fx != 0 ) { @@ -2947,7 +2972,6 @@ void generate_masking_noise_dirac_ivas_fx( q_scale = sub( add( q_scale, 2 * Q8 ), 31 ); 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++ ) { @@ -3012,7 +3036,7 @@ void FdCngDecodeMDCTStereoSID_fx( is_out_ms = 0; move16(); - IF( hCPE->hCoreCoder[0]->cng_sba_flag ) + if ( hCPE->hCoreCoder[0]->cng_sba_flag ) { is_out_ms = 1; move16(); @@ -3035,7 +3059,8 @@ void FdCngDecodeMDCTStereoSID_fx( hFdCngCom = ( sts[ch]->hFdCngDec )->hFdCngCom; N = hFdCngCom->npart; move16(); - hFdCngCom->sid_frame_counter++; + hFdCngCom->sid_frame_counter = add( hFdCngCom->sid_frame_counter, 1 ); + move16(); IF( ch ) { @@ -3088,7 +3113,7 @@ void FdCngDecodeMDCTStereoSID_fx( tmp32 = L_add( ms_ptr_fx[ch][p], gain_fx[ch] ); // Q20 tmp32_arr[p] = BASOP_util_Pow2( Mpy_32_32( tmp32, LOG_10_BASE_2_BY_10_Q31 ), Q11, &exp_arr[p] ); move32(); - IF( LT_16( exp_arr[max_exp_idx], exp_arr[p] ) ) + if ( LT_16( exp_arr[max_exp_idx], exp_arr[p] ) ) { max_exp_idx = p; move16(); @@ -3118,6 +3143,7 @@ void FdCngDecodeMDCTStereoSID_fx( { /* create proper M noise shape in channel zero after gains have been applied */ exp_diff = sub( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEstExp, sts[1]->hFdCngDec->hFdCngCom->sidNoiseEstExp ); + move16(); FOR( p = 0; p < N; p++ ) { IF( GT_16( exp_diff, 0 ) ) @@ -3316,7 +3342,7 @@ void FdCngDecodeDiracMDCTStereoSID_fx( tmp32 = L_add( ms_ptr_fx[ch][p], gain_fx[ch] ); // Q20 tmp32_arr[p] = BASOP_util_Pow2( Mpy_32_32( tmp32, LOG_10_BASE_2_BY_10_Q31 ), Q11, &exp_arr[p] ); move32(); - IF( LT_16( exp_arr[max_exp_idx], exp_arr[p] ) ) + if ( LT_16( exp_arr[max_exp_idx], exp_arr[p] ) ) { max_exp_idx = p; move16(); @@ -3378,6 +3404,7 @@ void FdCngDecodeDiracMDCTStereoSID_fx( IF( 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 7886c704036884266db0b63f39c7fa49cb61a133..134e47c01f5e7e1e119daa6f0eb0c877ae8ec7c7 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -330,7 +330,7 @@ void configureFdCngDec_fx( hsCom->CngBandwidth = bwidth; move16(); - IF( EQ_16( hsCom->CngBandwidth, FB ) ) + if ( EQ_16( hsCom->CngBandwidth, FB ) ) { hsCom->CngBandwidth = SWB; move16(); @@ -443,7 +443,7 @@ void configureFdCngDec_fx( hsCom->regularStopBand = 40; move16(); test(); - IF( EQ_16( Last_L_frame, L_FRAME ) && EQ_16( element_mode, IVAS_CPE_DFT ) ) + if ( EQ_16( Last_L_frame, L_FRAME ) && EQ_16( element_mode, IVAS_CPE_DFT ) ) { hsCom->regularStopBand = 35; move16(); @@ -460,6 +460,7 @@ void configureFdCngDec_fx( hsCom->startBand = 2; move16(); hsCom->stopBand = add( hsCom->FdCngSetup.sidPartitions[sub( hsCom->FdCngSetup.numPartitions, 1 )], 1 ); + move16(); 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 ); @@ -477,6 +478,7 @@ void configureFdCngDec_fx( } hsCom->nCLDFBpart = sub( hsCom->npart, hsCom->nFFTpart ); + move16(); FOR( j = 0; j < hsCom->nCLDFBpart; j++ ) { hsCom->CLDFBpart[j] = sub( hsCom->part[add( j, hsCom->nFFTpart )], sub( hsCom->stopFFTbin, hsCom->startBand ) ); @@ -486,6 +488,7 @@ void configureFdCngDec_fx( } stopBandFR = 1000 / 25; + move16(); if ( GT_16( stopBandFR, hsCom->stopFFTbin ) ) { stopBandFR = hsCom->stopFFTbin; @@ -519,6 +522,7 @@ void configureFdCngDec_fx( BASOP_getTables( &hsCom->olapWinAna, NULL, NULL, shr( hsCom->fftlen, 1 ) ); BASOP_getTables( &hsCom->olapWinSyn, NULL, NULL, shr( hsCom->fftlen, 2 ) ); hsCom->frameSize = shr( hsCom->fftlen, 1 ); + move16(); } @@ -629,6 +633,7 @@ Word16 ApplyFdCng_fx( move16(); } cngNoiseLevel = hFdCngCom->cngNoiseLevel; + move32(); cngNoiseLevel_exp = &hFdCngCom->cngNoiseLevelExp; move16(); nBins = sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ); @@ -649,6 +654,7 @@ Word16 ApplyFdCng_fx( /* set noise estimation inactive during concealment, as no update with noise generated by concealment should be performed. */ /* set noise estimation inactive during concealment, no update with noise generated by concealment should be performed. */ +#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT test(); test(); test(); @@ -659,7 +665,6 @@ Word16 ApplyFdCng_fx( test(); test(); test(); -#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT if ( concealWholeFrame == 0 && ( timeDomainInput == NULL || ( *timeDomainInput( -FLT_MAX ) && @@ -830,11 +835,11 @@ Word16 ApplyFdCng_fx( 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 ); @@ -993,11 +998,11 @@ Word16 ApplyFdCng_fx( 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 ); } @@ -1026,6 +1031,7 @@ Word16 ApplyFdCng_fx( #ifdef BASOP_NOGLOB /* Critical Carry/Overflow */ st->cngTDLevel = round_fx_o( Sqrt32( L_tmp, &L_tmp_exp ), &Overflow ); + move16(); #else st->cngTDLevel = round_fx( Sqrt32( L_tmp, &L_tmp_exp ) ); #endif @@ -1054,12 +1060,12 @@ Word16 ApplyFdCng_fx( hFdCngCom->psize_inv, hFdCngDec->partNoiseShape, &hFdCngDec->partNoiseShape_exp ); - if ( EQ_16( st->element_mode, IVAS_CPE_DFT ) ) - { #ifdef IVAS_CODE_CNG + IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) ) + { Copy( hFdCngDec->hFdCngCom->sidNoiseEst, hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART ); -#endif } +#endif } IF( EQ_16( st->m_frame_type, SID_FRAME ) ) @@ -1078,8 +1084,8 @@ Word16 ApplyFdCng_fx( { #ifdef IVAS_CODE_CNG sidNoiseEst = hFdCngCom->sidNoiseEstLp; -#endif move16(); +#endif } /* Interpolate the CLDFB band levels from the SID (partition) levels */ IF( GT_16( hFdCngCom->regularStopBand, hFdCngCom->numCoreBands ) ) @@ -1225,17 +1231,15 @@ Word16 ApplyFdCng_ivas_fx( move16(); #endif Word16 L_frame, last_L_frame; - // Word32 *sidNoiseEst; hFdCngDec = st->hFdCngDec; hFdCngCom = hFdCngDec->hFdCngCom; - // sidNoiseEst = hFdCngCom->sidNoiseEst; /* limit L_frame and core fs values for MDCT-Stereo modes which can have higher core sampling than 16kHz, but use a downsampled buffer */ L_frame = s_min( st->L_frame, L_FRAME16k ); last_L_frame = s_min( st->last_L_frame, L_FRAME16k ); - IF( EQ_16( hFdCngCom->frame_type_previous, ACTIVE_FRAME ) ) + if ( EQ_16( hFdCngCom->frame_type_previous, ACTIVE_FRAME ) ) { hFdCngCom->inactive_frame_counter = 0; move16(); @@ -1246,6 +1250,7 @@ Word16 ApplyFdCng_ivas_fx( move16(); } cngNoiseLevel = hFdCngCom->cngNoiseLevel; + move32(); cngNoiseLevel_exp = &hFdCngCom->cngNoiseLevelExp; move16(); nBins = sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ); @@ -1382,6 +1387,7 @@ Word16 ApplyFdCng_ivas_fx( { s = sub( *cngNoiseLevel_exp, add( hFdCngDec->bandNoiseShape_exp, s2 ) ); Word16 e_shift = 0; + move16(); IF( s > 0 ) { Word16 q_norm = L_norm_arr( &cngNoiseLevel[j], sub( FFTCLDFBLEN, j ) ); @@ -1420,7 +1426,6 @@ Word16 ApplyFdCng_ivas_fx( IF( ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && timeDomainInput == NULL ) ) { - // st->hTcxDec->CngLevelBackgroundTrace_bfi = sqrtf(sum_f(cngNoiseLevel, hFdCngCom->stopFFTbin - hFdCngCom->startBand) / NORM_MDCT_FACTOR); tmp_loop = sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ); L_tmp = L_deposit_h( 0 ); @@ -1438,11 +1443,11 @@ Word16 ApplyFdCng_ivas_fx( 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 ); @@ -1461,20 +1466,17 @@ Word16 ApplyFdCng_ivas_fx( L_tmp_exp = add( L_tmp_exp, 31 - 16 ); /*->Q31, L_tmp_exp*/ #ifdef BASOP_NOGLOB - // st->hTcxDec->CngLevelBackgroundTrace_bfi_fx = ( Sqrt32( L_tmp, &L_tmp_exp ) ); st->hTcxDec->conCngLevelBackgroundTrace = round_fx_sat( Sqrt32( L_tmp, &L_tmp_exp ) ); #else st->hTcxDec->conCngLevelBackgroundTrace = round_fx( Sqrt32( L_tmp, &L_tmp_exp ) ); - // st->hTcxDec->CngLevelBackgroundTrace_bfi_fx = ( Sqrt32( L_tmp, &L_tmp_exp ) ); #endif + move16(); L_tmp_exp = add( L_tmp_exp, 1 ); - // st->hTcxDec->CngLevelBackgroundTrace_bfi_exp = L_tmp_exp; st->hTcxDec->conCngLevelBackgroundTrace_e = L_tmp_exp; move16(); } ELSE { - // st->hTcxDec->CngLevelBackgroundTrace_bfi = (float)sqrt((sum_f(cngNoiseLevel, hFdCngCom->stopFFTbin - hFdCngCom->startBand) / 2 * hFdCngCom->fftlen) / L_frame); tmp_loop = sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ); L_tmp = L_deposit_h( 0 ); @@ -1492,11 +1494,11 @@ Word16 ApplyFdCng_ivas_fx( 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 ); @@ -1515,18 +1517,16 @@ Word16 ApplyFdCng_ivas_fx( L_tmp_exp = add( L_tmp_exp, 31 - 16 ); /*->Q31, L_tmp_exp*/ #ifdef BASOP_NOGLOB - // st->hTcxDec->CngLevelBackgroundTrace_bfi_fx = ( Sqrt32( L_tmp, &L_tmp_exp ) ); st->hTcxDec->conCngLevelBackgroundTrace = round_fx_sat( Sqrt32( L_tmp, &L_tmp_exp ) ); + move16(); #else st->hTcxDec->conCngLevelBackgroundTrace = round_fx( Sqrt32( L_tmp, &L_tmp_exp ) ); st->hTcxDec->CngLevelBackgroundTrace_bfi_fx = ( Sqrt32( L_tmp, &L_tmp_exp ) ); #endif - // st->hTcxDec->CngLevelBackgroundTrace_bfi_exp = L_tmp_exp; st->hTcxDec->conCngLevelBackgroundTrace_e = L_tmp_exp; move16(); } - /*st->cngTDLevel = (float)sqrt( (sumFLOAT(cngNoiseLevel, hFdCngCom->stopFFTbin - hFdCngCom->startBand) / 2 * hFdCngCom->fftlen) / st->Mode2_L_frame);*/ tmp_loop = sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ); L_tmp = L_deposit_h( 0 ); L_c = L_deposit_h( 0 ); @@ -1543,11 +1543,11 @@ Word16 ApplyFdCng_ivas_fx( 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 ); @@ -1570,6 +1570,7 @@ Word16 ApplyFdCng_ivas_fx( #else st->cngTDLevel = round_fx( Sqrt32( L_tmp, &L_tmp_exp ) ); #endif + move16(); st->cngTDLevel_e = L_tmp_exp; move16(); } @@ -1670,11 +1671,11 @@ Word16 ApplyFdCng_ivas_fx( 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 ); } @@ -1706,11 +1707,13 @@ Word16 ApplyFdCng_ivas_fx( #else st->cngTDLevel = round_fx( Sqrt32( L_tmp, &L_tmp_exp ) ); #endif + move16(); st->cngTDLevel_e = L_tmp_exp; move16(); BREAK; } hFdCngCom->inactive_frame_counter = add( hFdCngCom->inactive_frame_counter, 1 ); + move16(); /************************************* * SID_FRAME or ZERO_FRAME at DECODER * @@ -1747,11 +1750,6 @@ Word16 ApplyFdCng_ivas_fx( } ELSE { - // IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) ) - //{ - // sidNoiseEst = hFdCngCom->sidNoiseEstLp; - // move16(); - // } /* Interpolate the CLDFB band levels from the SID (partition) levels */ IF( GT_16( hFdCngCom->regularStopBand, hFdCngCom->numCoreBands ) ) { @@ -1804,7 +1802,7 @@ Word16 ApplyFdCng_ivas_fx( } s2 = s_max( s2, facTabExp[k] ); } - IF( EQ_16( s2, -31 ) ) + if ( EQ_16( s2, -31 ) ) { s2 = 0; move16(); @@ -1837,7 +1835,6 @@ Word16 ApplyFdCng_ivas_fx( { IF( !( LT_16( hFdCngCom->msFrCnt_init_counter, hFdCngCom->msFrCnt_init_thresh ) ) ) { - // sidNoiseEst = hFdCngCom->sidNoiseEstLp; s2 = negate( sub( WORD32_BITS, 1 ) ); /* Shape the SID noise levels in each FFT bin */ @@ -1873,9 +1870,9 @@ Word16 ApplyFdCng_ivas_fx( move16(); } /* Set unique exponent, IF mantissa is equal to zero */ - IF( EQ_16( facTab[k], 0 ) ) + if ( facTab[k] == 0 ) { - facTabExp[k] = negate( sub( WORD32_BITS, 1 ) ); + facTabExp[k] = -( WORD32_BITS - 1 ); move16(); } s2 = s_max( s2, facTabExp[k] ); @@ -2310,6 +2307,7 @@ void perform_noise_estimation_dec_fx( } hFdCngDec->hFdCngCom->periodog_exp = shl( sub( fftBuffer_exp, s ), 1 ); + move16(); /* Rescale */ assert( ( hFdCngDec->hFdCngCom->fftlen == 640 ) || ( hFdCngDec->hFdCngCom->fftlen == 512 ) || ( hFdCngDec->hFdCngCom->fftlen == 320 ) ); @@ -2345,6 +2343,7 @@ void perform_noise_estimation_dec_fx( move32(); } hFdCngDec->hFdCngCom->periodog_exp = add( hFdCngDec->hFdCngCom->periodog_exp, sub( 2, s ) ); + move16(); #endif /* Adjust to the desired frequency resolution by averaging over spectral partitions for SID transmission */ @@ -2484,12 +2483,13 @@ void perform_noise_estimation_dec_ivas_fx( assert( 0 ); } /* Calculate periodogram (squared magnitude in each FFT bin) */ - IF( EQ_16( startBand, 0 ) ) + IF( startBand == 0 ) { 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 ) ) ); + move32(); ptr_per++; ptr_r = fftBuffer + 2; } @@ -2500,25 +2500,35 @@ void perform_noise_estimation_dec_ivas_fx( ptr_i = ptr_r + 1; - FOR( ; ptr_per < periodog + stopFFTbin - startBand; ptr_per++ ) + FOR( ; ptr_per < periodog + sub( stopFFTbin, startBand ); ptr_per++ ) { W_tmp = W_add( W_mult0_32_32( ( *ptr_r ), ( *ptr_r ) ), W_mult0_32_32( ( *ptr_i ), ( *ptr_i ) ) ); tmp_s = W_norm( W_tmp ); tmp_q = sub( add( i_mult( sub( 31, fftBuffer_exp ), 2 ), tmp_s ), 32 ); - IF( LT_16( tmp_q, 0 ) ) + IF( tmp_q < 0 ) { W_tmp = W_shr( W_tmp, negate( tmp_q ) ); } IF( LT_16( tmp_q, min_q ) ) { reIter = ptr_per; - Word16 diff = ( LE_16( tmp_q, 0 ) ) ? min_q : sub( min_q, tmp_q ); + Word16 diff; + IF( tmp_q <= 0 ) + { + diff = min_q; + move16(); + } + ELSE + { + diff = sub( min_q, tmp_q ); + } WHILE( reIter > periodog ) { reIter--; *reIter = L_shr( *reIter, diff ); + move32(); } IF( GE_16( tmp_q, 0 ) ) { @@ -2528,14 +2538,19 @@ void perform_noise_estimation_dec_ivas_fx( { min_q = 0; } + move16(); } ( *ptr_per ) = W_extract_l( W_shr( W_tmp, sub( shl( sub( 31, fftBuffer_exp ), 1 ), min_q ) ) ); // Qmin_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; @@ -2545,12 +2560,14 @@ void perform_noise_estimation_dec_ivas_fx( hFdCngDec->hFdCngCom->periodog_exp = sub( 31, min_q ); hFdCngDec->hFdCngCom->fftBuffer_exp = fftBuffer_exp; move16(); + move16(); tmp_s = getScaleFactor32( periodog, sub( stopFFTbin, startBand ) ); IF( GT_16( tmp_s, 7 ) ) { tmp_s = sub( tmp_s, 7 ); hFdCngDec->hFdCngCom->periodog_exp = sub( hFdCngDec->hFdCngCom->periodog_exp, tmp_s ); + move16(); FOR( p = 0; p < stopFFTbin - startBand; p++ ) { periodog[p] = L_shl( periodog[p], tmp_s ); @@ -2560,11 +2577,13 @@ void perform_noise_estimation_dec_ivas_fx( /* Combine bins of power spectrum into partitions */ i = 0; + move16(); FOR( p = 0; p < npart; p++ ) { /* calculate mean over all bins in power partition */ temp = 0; + move16(); FOR( ; i <= part[p]; i++ ) { temp = L_add( temp, periodog[i] ); @@ -2609,13 +2628,12 @@ void perform_noise_estimation_dec_ivas_fx( ftemp = rand_gauss( &hFdCngDec->cna_seed ); L_tmp = Mpy_32_32( temp, ftemp ); - // L_tmp = L_shr( L_tmp, ( 31 - e_temp ) + 29 - 31 - ( 31 - hFdCngDec->hFdCngCom->periodog_exp ) ); 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 ) ) + if ( LT_32( msPeriodog[p], 0 ) ) { msPeriodog[p] = 0; move32(); @@ -2633,6 +2651,7 @@ void perform_noise_estimation_dec_ivas_fx( move32(); } hFdCngDec->msPeriodog_exp = add( hFdCngDec->msPeriodog_exp, sub( 5, tmp_s ) ); + move16(); } enr_tot = 1; move32(); @@ -2747,7 +2766,7 @@ void perform_noise_estimation_dec_ivas_fx( Word16 e = 15; move16(); /* background noise update with moving average */ - IF( NE_16( hFdCngDec->first_cna_noise_update_cnt, 0 ) ) + IF( hFdCngDec->first_cna_noise_update_cnt != 0 ) { alpha = Inv16( add( hFdCngDec->first_cna_noise_update_cnt, 1 ), &e ); alpha = shl_sat( alpha, e ); // Q15 @@ -2779,18 +2798,20 @@ void perform_noise_estimation_dec_ivas_fx( Copy32( msPeriodog, msNoiseEst, npart ); scale_sig32( &msNoiseEst[npart], sub( NPART_SHAPING, npart ), sub( hFdCngDec->msNoiseEst_exp, hFdCngDec->msPeriodog_exp ) ); hFdCngDec->msNoiseEst_exp = hFdCngDec->msPeriodog_exp; + move16(); } /* check, if we reached the required number of first CNA noise update frames */ IF( LT_16( hFdCngDec->first_cna_noise_update_cnt, FIRST_CNA_NOISE_UPD_FRAMES - 1 ) ) { - hFdCngDec->first_cna_noise_update_cnt++; + hFdCngDec->first_cna_noise_update_cnt = add( hFdCngDec->first_cna_noise_update_cnt, 1 ); + move16(); } ELSE { hFdCngDec->first_cna_noise_updated = 1; move16(); - IF( EQ_16( hFdCngDec->hFdCngCom->msFrCnt_init_counter, 0 ) ) + if ( EQ_16( hFdCngDec->hFdCngCom->msFrCnt_init_counter, 0 ) ) { hFdCngDec->hFdCngCom->msFrCnt_init_counter = 1; move16(); @@ -2812,7 +2833,7 @@ void perform_noise_estimation_dec_ivas_fx( Word16 scale; /* no updates during active frames except for significant energy drops */ enr_ratio = BASOP_Util_Divide3232_Scale( enr_tot, enr_tot0, &scale ); - IF( LE_16( scale, 0 ) ) + IF( scale <= 0 ) { enr_ratio = shl( enr_ratio, scale ); scale = 15; @@ -2879,7 +2900,7 @@ void perform_noise_estimation_dec_ivas_fx( ELSE { test(); - IF( GE_16( bwidth, WB ) && EQ_16( hFdCngDec->ms_last_inactive_bwidth, NB ) ) + if ( GE_16( bwidth, WB ) && hFdCngDec->ms_last_inactive_bwidth == NB ) { /* bandwidth increased -> set counter for fast initilization */ hFdCngDec->ms_cnt_bw_up = FIRST_CNA_NOISE_UPD_FRAMES; @@ -2904,7 +2925,7 @@ void perform_noise_estimation_dec_ivas_fx( IF( GT_16( hFdCngDec->ms_cnt_bw_up, 0 ) && GT_16( p, 55 ) ) { alpha = Inv16( add( hFdCngDec->ms_cnt_bw_up, 1 ), &i_e ); - IF( LT_16( i_e, 0 ) ) + IF( i_e <= 0 ) { alpha = shr( alpha, negate( i_e ) ); // Q15 } @@ -2940,7 +2961,7 @@ void perform_noise_estimation_dec_ivas_fx( { *ptr_per = Mpy_32_16_1( ( *ptr_per ), alpha ); move32(); - IF( *ptr_per == 0 ) + if ( *ptr_per == 0 ) { *ptr_per = 1; move32(); @@ -2952,16 +2973,16 @@ void perform_noise_estimation_dec_ivas_fx( move32(); } #ifdef IVAS_ENH32_CADENCE_CHANGES - if ( enr ) + IF( enr ) { q_shift = sub( enr_e, hFdCngDec->msNoiseEst_exp ); norm_shift = norm_l( enr ); - if ( LE_16( q_shift, norm_shift ) ) + IF( LE_16( q_shift, norm_shift ) ) { enr = L_shl( enr, q_shift ); move32(); } - else + ELSE { enr_e = sub( enr_e, norm_shift ); enr = L_shl( enr, norm_shift ); @@ -2971,20 +2992,22 @@ void perform_noise_estimation_dec_ivas_fx( } } *ptr_per = Madd_32_16( ( *ptr_per ), enr, sub( MAX_16, alpha ) ); + move32(); #else *ptr_per = L_add( ( *ptr_per ), Mpy_32_16_1( enr, sub( MAX_16, alpha ) ) ); #endif ptr_per++; } - IF( GT_16( hFdCngDec->ms_cnt_bw_up, 0 ) ) + IF( hFdCngDec->ms_cnt_bw_up > 0 ) { - hFdCngDec->ms_cnt_bw_up--; + hFdCngDec->ms_cnt_bw_up = sub( hFdCngDec->ms_cnt_bw_up, 1 ); + move16(); } } } maximum_32_fx( msNoiseEst, NPART_SHAPING, &max_l ); - if ( max_l ) + IF( max_l ) { q_shift = sub( norm_l( max_l ), 2 ); scale_sig32( msNoiseEst, NPART_SHAPING, q_shift ); @@ -3002,6 +3025,7 @@ void perform_noise_estimation_dec_ivas_fx( move16(); Copy32( hFdCngDec->bandNoiseShape, &hFdCngDec->smoothed_psd_fx[startBand], sub( stopFFTbin, startBand ) ); hFdCngDec->q_smoothed_psd = sub( Q31, hFdCngDec->bandNoiseShape_exp ); + move16(); set32_fx( &hFdCngDec->smoothed_psd_fx[stopFFTbin], 0, sub( L_FRAME16k, stopFFTbin ) ); } ELSE @@ -3016,12 +3040,13 @@ void perform_noise_estimation_dec_ivas_fx( ELSE { /* Compute the squared magnitude in each FFT bin */ - IF( EQ_16( startBand, 0 ) ) + IF( startBand == 0 ) { 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 ) ) ); + move32(); ptr_per++; ptr_r = fftBuffer + 2; } @@ -3056,26 +3081,34 @@ void perform_noise_estimation_dec_ivas_fx( tmp_s = W_norm( W_tmp ); tmp_q = sub( add( i_mult( sub( 31, fftBuffer_exp ), 2 ), tmp_s ), 32 ); - IF( LT_16( tmp_q, 0 ) ) + IF( tmp_q < 0 ) { W_tmp = W_shr( W_tmp, negate( tmp_q ) ); } IF( LT_16( tmp_q, min_q ) ) { reIter = ptr_per; - Word16 diff = ( tmp_q <= 0 ) ? min_q : sub( min_q, tmp_q ); + Word16 diff; + IF( ( tmp_q <= 0 ) ) + { + diff = min_q; + } + ELSE + { + diff = sub( min_q, tmp_q ); + } WHILE( reIter > periodog ) { reIter--; *reIter = L_shr( *reIter, diff ); move32(); } - IF( GE_16( tmp_q, 0 ) ) + IF( tmp_q >= 0 ) { min_q = tmp_q; move16(); } - ELSE IF( LT_16( tmp_q, 0 ) ) + ELSE IF( tmp_q < 0 ) { min_q = 0; move16(); @@ -3087,7 +3120,7 @@ void perform_noise_estimation_dec_ivas_fx( /* 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 ) ) + IF( tmp_q <= 0 ) { ( *ptr_per ) = L_shl( ( *ptr_per ), negate( tmp_q ) ); move32(); @@ -3098,6 +3131,7 @@ void perform_noise_estimation_dec_ivas_fx( } hFdCngDec->hFdCngCom->periodog_exp = sub( 31, min_q ); + move16(); hFdCngDec->hFdCngCom->fftBuffer_exp = fftBuffer_exp; move16(); @@ -3106,6 +3140,7 @@ void perform_noise_estimation_dec_ivas_fx( { tmp_s = sub( tmp_s, 3 ); hFdCngDec->hFdCngCom->periodog_exp = sub( hFdCngDec->hFdCngCom->periodog_exp, tmp_s ); + move16(); FOR( p = 0; p < stopFFTbin - startBand; p++ ) { periodog[p] = L_shl( periodog[p], tmp_s ); @@ -3160,6 +3195,7 @@ void perform_noise_estimation_dec_ivas_fx( move32(); } hFdCngDec->msPsd_exp_fft = 6 + WORD16_BITS; + move16(); /* Expand MS outputs */ expand_range( hFdCngDec->msLogNoiseEst, hFdCngDec->msNoiseEst, &hFdCngDec->msNoiseEst_exp, npart ); @@ -3369,6 +3405,7 @@ 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 { @@ -3415,11 +3452,12 @@ 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(); @@ -3427,7 +3465,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(); @@ -3622,6 +3660,7 @@ void generate_comfort_noise_dec_fx( exp = sub( 25, exp ); Lener = L_shr( Lener, exp ); /*Q6*/ st->lp_ener_fx = L_add( Mult_32_16( st->lp_ener_fx, 26214 /*0.8f Q15*/ ), Lener ); /*Q6*/ + move32(); } /* @@ -3873,6 +3912,7 @@ void generate_comfort_noise_dec_ivas_fx( HANDLE_FD_CNG_COM hFdCngCom = hFdCngDec->hFdCngCom; Word32 *cngNoiseLevel = hFdCngCom->cngNoiseLevel; Word16 cngNoiseLevel_exp = hFdCngCom->cngNoiseLevelExp; + move16(); Word32 *ptr_level = cngNoiseLevel; Word16 *seed = &( hFdCngCom->seed ); @@ -3918,6 +3958,7 @@ void generate_comfort_noise_dec_ivas_fx( move16(); seed2 = &( hFdCngCom->seed2 ); + test(); if ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && EQ_16( st->idchan, 1 ) ) { seed2 = &( hFdCngCom->seed3 ); @@ -3937,6 +3978,7 @@ void generate_comfort_noise_dec_ivas_fx( fftBuffer[0] = L_add( Mpy_32_16_1( tmp1, c1 ), Mpy_32_16_1( tmp2, c2 ) ); move32(); fftBuffer_temp_exp[0] = Q16 + Q15; + move16(); } ELSE { @@ -4035,7 +4077,7 @@ void generate_comfort_noise_dec_ivas_fx( move16(); FOR( i = 0; i < FFTLEN; i++ ) { - if ( fftBuffer[i] != 0 ) + IF( fftBuffer[i] != 0 ) { fftBuffer_exp = s_min( fftBuffer_exp, add( sub( 31, fftBuffer_temp_exp[i] ), norm_l( fftBuffer[i] ) ) ); } @@ -4119,6 +4161,7 @@ void generate_comfort_noise_dec_ivas_fx( exp = sub( 25, exp ); Lener = L_shr( Lener, exp ); /*Q6*/ st->lp_ener_fx = L_add( Mult_32_16( st->lp_ener_fx, 26214 /*0.8f Q15*/ ), Lener ); /*Q6*/ + move32(); } /* Generate Gaussian random noise in real and imaginary parts of the CLDFB bands @@ -4395,6 +4438,7 @@ void generate_comfort_noise_dec_ivas_fx( 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(); + move16(); } } } @@ -4534,7 +4578,7 @@ void generate_comfort_noise_dec_hf_ivas_fx( move16(); } - randGaussExp = add( CNG_RAND_GAUSS_SHIFT, 1 ); + randGaussExp = CNG_RAND_GAUSS_SHIFT + 1; move16(); /* @@ -4588,6 +4632,7 @@ void generate_comfort_noise_dec_hf_ivas_fx( ptr_level = ptr_level + 1; } *bufferScale = sub( sc, 15 ); + move16(); } return; diff --git a/lib_dec/gain_dec_fx.c b/lib_dec/gain_dec_fx.c index d9639bbcc716a624e62b32ec011a9ffc4dc278d0..e56c3294e1c8cd52eaabf6332d1f4f6edd44f7e9 100644 --- a/lib_dec/gain_dec_fx.c +++ b/lib_dec/gain_dec_fx.c @@ -455,6 +455,7 @@ void gain_dec_mless_fx( /* decode normalized codebook gain */ /*index = (short)get_indice( st_fx, "gain_code", i_subfr_fx, ACELP_CORE );move16();*/ index = (Word16) get_next_indice_fx( st_fx, shr( add( nBits, 1 ), 1 ) ); + move16(); /**gain_code = gain_dequant( index, G_CODE_MIN_TC192, G_CODE_MAX_TC192, (nBits+1)>>1 );*/ gain_code16 = gain_dequant_fx( index, G_CODE_MIN_TC192_Q15, G_CODE_MAX_TC192_Q0, shr( add( nBits, 1 ), 1 ), &expg ); @@ -506,6 +507,7 @@ void gain_dec_mless_fx( } index = (Word16) get_next_indice_fx( st_fx, nBits ); + move16(); *gain_pit_fx = qua_table_fx[index * 2]; move16(); @@ -723,6 +725,7 @@ void gain_dec_lbr_fx( /* retrieve the codebook index and calculate both gains */ /*index = (Word16)get_indice( st_fx,"gain", i_subfr, ACELP_CORE);move16();*/ index = (Word16) get_next_indice_fx( st_fx, nBits ); + move16(); *gain_pit_fx = cdbk_fx[index * 2]; move16(); @@ -796,6 +799,7 @@ void gain_dec_lbr_fx( /* retrieve the codebook index and calculate both gains */ index = (Word16) get_next_indice_fx( st_fx, nBits ); + move16(); *gain_pit_fx = cdbk_fx[index * 2]; move16(); @@ -873,6 +877,7 @@ void gain_dec_lbr_fx( /* retrieve the codebook index and calculate both gains */ index = (Word16) get_next_indice_fx( st_fx, nBits ); + move16(); *gain_pit_fx = cdbk_fx[shl( index, 1 )]; move16(); @@ -883,6 +888,7 @@ void gain_dec_lbr_fx( #else *gain_code_fx = L_shl( L_tmp, add( exp_gcode0, 6 ) ); /* Q10 -> Q16*/ #endif + move32(); gc_mem[2] = *gain_code_fx; move32(); gp_mem[2] = *gain_pit_fx; @@ -1351,6 +1357,7 @@ void gain_dec_SQ_fx( *-----------------------------------------------------------------*/ index = (Word16) get_next_indice_fx( st_fx, shr( nBits, 1 ) ); + move16(); /*Ei = (G_PITCH_MAX - G_PITCH_MIN) / ((1 << (nBits>>1)) - 1); set quantization step */ tmp16 = div_s( 1, sub( shl( 1, shr( nBits, 1 ) ), 1 ) ); /* Q15*/ @@ -1401,6 +1408,7 @@ void gain_dec_SQ_fx( *-----------------------------------------------------------------*/ index = (Word16) get_next_indice_fx( st_fx, shr( add( nBits, 1 ), 1 ) ); + move16(); tmp16 = gain_dequant_fx( index, G_CODE_MIN_TC_Q15, G_CODE_MAX_TC_Q0, shr( add( nBits, 1 ), 1 ), &expg ); @@ -1517,6 +1525,7 @@ void gain_dec_amr_wb_fx( *-----------------------------------------------------------------*/ index = (Word16) get_next_indice_fx( st_fx, nbits ); + move16(); index2 = shl( index, 1 ); *gain_pit = t_qua_gain[index2]; move16(); @@ -1529,8 +1538,7 @@ void gain_dec_amr_wb_fx( /* *gain_code = t_qua_gain[indice*2+1] * gcode0; */ L_tmp = L_mult( qua_en, gcode0 ); /* Q11*Q0 -> Q12 */ - tmp = round_fx( L_tmp ); - move16(); /* Q-4 */ + tmp = round_fx( L_tmp ); /* Q-4 */ *gain_code = L_shl( L_tmp, add( exp_gcode0, 4 ) ); move32(); /* Q12 -> Q16 */ diff --git a/lib_dec/gaus_dec_fx.c b/lib_dec/gaus_dec_fx.c index 7b70d7281d7727278eaf889b793dd831bad203ce..a7806e274b81e466b06aebc029f9c57a15aa41a6 100644 --- a/lib_dec/gaus_dec_fx.c +++ b/lib_dec/gaus_dec_fx.c @@ -71,6 +71,7 @@ void gaus_dec_fx( nb_bits = st_fx->acelp_cfg.gains_mode[shr( i_subfr, 6 )]; move16(); idx = (Word16) get_next_indice_fx( st_fx, nb_bits ); + move16(); /* safety check in case of bit errors */ test(); @@ -167,6 +168,8 @@ void gaus_dec2v_fx( idx = (Word16) get_next_indice_fx( st_fx, add( shl( nb_bits, 1 ), 1 ) ); index_delta = (Word16) get_next_indice_fx( st_fx, 3 ); + move16(); + move16(); dec_2pos_fx( idx, &ind1, &ind2, &sign1, &sign2, nb_bits ); diff --git a/lib_dec/gs_dec_fx.c b/lib_dec/gs_dec_fx.c index be2975db026b77e99c75974092008c1674c790e6..78f798e557d7a29b64db7551ebe02d97d1a79eaf 100644 --- a/lib_dec/gs_dec_fx.c +++ b/lib_dec/gs_dec_fx.c @@ -72,6 +72,7 @@ void decod_audio_fx( /* decode GSC attack flag (used to reduce possible pre-echo) */ gsc_attack_flag = (Word16) get_next_indice_fx( st_fx, 1 ); + move16(); /* decode GSC SWB speech flag */ test(); @@ -180,8 +181,9 @@ void decod_audio_fx( } #endif nb_frame_flg = (Word16) get_next_indice_fx( st_fx, nbits ); + move16(); - if ( s_and( nb_frame_flg, 0x1 ) == 0 ) + IF( s_and( nb_frame_flg, 0x1 ) == 0 ) { nb_subfr = 2 * SWNB_SUBFR; move16(); @@ -217,7 +219,7 @@ void decod_audio_fx( nbits = 3; move16(); test(); - IF( LT_32( st_fx->core_brate, ACELP_9k60 ) && st_fx->coder_type == INACTIVE ) + if ( LT_32( st_fx->core_brate, ACELP_9k60 ) && st_fx->coder_type == INACTIVE ) { nbits = 1; move16(); @@ -237,9 +239,10 @@ void decod_audio_fx( ELSE { pit_band_idx = (Word16) get_next_indice_fx( st_fx, nbits ); + move16(); } - if ( pit_band_idx != 0 ) + IF( pit_band_idx != 0 ) { IF( LT_32( st_fx->core_brate, ACELP_9k60 ) ) { @@ -252,7 +255,7 @@ void decod_audio_fx( } /* detect bit errors in the bitstream */ - if ( GT_16( pit_band_idx, 13 ) ) /* The maximum decodable index is 10 + BAND1k2 (3) = 13 */ + IF( GT_16( pit_band_idx, 13 ) ) /* The maximum decodable index is 10 + BAND1k2 (3) = 13 */ { pit_band_idx = 13; move16(); @@ -577,6 +580,7 @@ void decod_audio_ivas_fx( /* decode GSC attack flag (used to reduce possible pre-echo) */ gsc_attack_flag = (Word16) get_next_indice_fx( st_fx, 1 ); + move16(); /* decode GSC SWB speech flag */ test(); @@ -702,6 +706,7 @@ void decod_audio_ivas_fx( } #endif nb_frame_flg = (Word16) get_next_indice_fx( st_fx, nbits ); + move16(); test(); IF( s_and( nb_frame_flg, 0x1 ) == 0 ) @@ -763,6 +768,7 @@ void decod_audio_ivas_fx( ELSE { pit_band_idx = (Word16) get_next_indice_fx( st_fx, nbits ); + move16(); } IF( pit_band_idx != 0 ) @@ -998,7 +1004,6 @@ void decod_audio_ivas_fx( } } #endif - // gsc_dec_fx(st_fx, dct_epit, pit_band_idx, Diff_len, tmp_nb_bits_tot, nb_subfr, st_fx->coder_type, &last_bin, lsf_new, exc_wo_nf, st_fx->Q_exc ); gsc_dec_ivas_fx( st_fx, dct_epit, pit_band_idx, Diff_len, tmp_nb_bits_tot, nb_subfr, st_fx->coder_type, &last_bin, lsf_new, exc_wo_nf, st_fx->Q_exc ); /*--------------------------------------------------------------------------------------* * iDCT transform @@ -1489,7 +1494,7 @@ void gsc_dec_ivas_fx( move16(); WHILE( LT_16( i, SIZE_BRATE_INTERMED_TBL ) ) { - IF( LE_32( st_fx->core_brate, brate_intermed_tbl[i] ) ) + if ( LE_32( st_fx->core_brate, brate_intermed_tbl[i] ) ) { break; } @@ -1499,8 +1504,8 @@ void gsc_dec_ivas_fx( test(); test(); test(); - IF( st_fx->element_mode > EVS_MONO && EQ_16( coder_type, AUDIO ) && - LE_32( st_fx->core_brate, STEREO_GSC_BIT_RATE_ALLOC ) && EQ_32( brate_intermed_tbl[i], ACELP_9k60 ) ) /* Bit allocation is mapped to 8 kb/s instead of 9.6 kb/s in this case */ + if ( st_fx->element_mode > EVS_MONO && EQ_16( coder_type, AUDIO ) && + LE_32( st_fx->core_brate, STEREO_GSC_BIT_RATE_ALLOC ) && EQ_32( brate_intermed_tbl[i], ACELP_9k60 ) ) /* Bit allocation is mapped to 8 kb/s instead of 9.6 kb/s in this case */ { i = sub( i, 1 ); } @@ -1576,7 +1581,6 @@ void gsc_dec_ivas_fx( #endif { pvq_core_dec_fx( st_fx, gsc_sfm_start, gsc_sfm_end, gsc_sfm_size, concat_out, &Q_tmp, bit, nb_subbands, bits_per_bands, NULL, inpulses_fx, imaxpulse_fx, ACELP_CORE ); - // ivas_pvq_core_dec_fx(st_fx, gsc_sfm_start, gsc_sfm_end, gsc_sfm_size, concat_out, &Q_tmp, bit, nb_subbands, bits_per_bands, NULL, inpulses_fx, imaxpulse_fx, ACELP_CORE); Scale_sig( concat_out, gsc_sfm_end[nb_subbands - 1], sub( Q_PVQ_OUT, Q_tmp ) ); } seed_init = 0; @@ -1596,7 +1600,7 @@ void gsc_dec_ivas_fx( j = maximum_fx( concat_out, imult1616( nb_subbands, 16 ), &max_eq ); // max_eq = max_eq_val / (abs_s(concat_out[j]) + 328 /*0.01f*/ ); Word16 temp_max_eq = add( abs_s( concat_out[j] ), 10 ) /*0.01f in Q10*/; - IF( LE_16( temp_max_eq, ONE_IN_Q10 ) ) + if ( LE_16( temp_max_eq, ONE_IN_Q10 ) ) { max_eq = max_eq_val; move16(); @@ -1613,7 +1617,7 @@ void gsc_dec_ivas_fx( /* Reorder Q bands */ FOR( j = 0; j < nb_subbands; j++ ) { - Copy( concat_out + j * 16, exc_diffQ + max_ener_band[j] * 16, 16 ); + Copy( concat_out + imult1616( j, 16 ), exc_diffQ + imult1616( max_ener_band[j], 16 ), 16 ); *last_bin = s_max( *last_bin, max_ener_band[j] ); move16(); diff --git a/lib_dec/hf_synth_fx.c b/lib_dec/hf_synth_fx.c index cee42b0ca04ff1a1117570370a21b384a6eefc1d..626796be2bff5f3fa5780d945b94c5a9294f0394 100644 --- a/lib_dec/hf_synth_fx.c +++ b/lib_dec/hf_synth_fx.c @@ -200,6 +200,7 @@ static void hf_synthesis_fx( Word16 Ap[M16k + 1]; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif (void) extl; (void) CNG_mode; @@ -345,7 +346,7 @@ static void hf_synthesis_fx( *-----------------------------------------------------------------*/ /* delay by 5 samples @16kHz to compensate CLDFB resampling delay (20samples) and HP filtering delay (roughly 15 samples) */ - delay = NS2SA( 16000, DELAY_CLDFB_NS ) - 15; + delay = NS2SA_FX2( 16000, DELAY_CLDFB_NS ) - 15; Copy( HF_syn + sub( L_SUBFR16k, delay ), temp_buffer, delay ); Copy( HF_syn, HF_syn + delay, sub( L_SUBFR16k, delay ) ); Copy( delay_syn_hf, HF_syn, delay ); @@ -2020,27 +2021,31 @@ void AdaptiveStartBand_fx( tmp2 = extract_l( L_tmp ); /*Q26 */ W_fx = mult_r( tmp1, tmp2 ); /*Q25 */ - if ( EQ_16( clas, AUDIO_CLAS ) ) + IF( EQ_16( clas, AUDIO_CLAS ) ) { W_fx = mult_r( W_fx, 24576 ); /*Q25 */ } pos = 2; move16(); - M2 = sub( M, 2 ); + M2 = M - 2; + move16(); IF( EQ_16( *voicing_flag, 1 ) ) { IF( LE_32( core_rate, ACELP_8k85 ) ) { - M2 = sub( M, 8 ); + M2 = M - 8; + move16(); } ELSE IF( LE_32( core_rate, ACELP_12k65 ) ) { - M2 = sub( M, 6 ); + M2 = M - 6; + move16(); } ELSE IF( LE_32( core_rate, ACELP_15k85 ) ) { - M2 = sub( M, 4 ); + M2 = M - 4; + move16(); } } @@ -2104,14 +2109,14 @@ void AdaptiveStartBand_fx( move16(); } - if ( EQ_16( clas, AUDIO_CLAS ) ) + IF( EQ_16( clas, AUDIO_CLAS ) ) { *start_band = s_min( *start_band, 120 ); move16(); } flag = sub( s_and( *start_band, 0x0001 ), 1 ); - if ( flag == 0 ) + IF( flag == 0 ) { *start_band = sub( *start_band, 1 ); move16(); diff --git a/lib_dec/hq_core_dec_fx.c b/lib_dec/hq_core_dec_fx.c index bde72c4a35cb7a62306ae1f50574d49e22d1d5d8..f0a31655fbd31f5043178bf0bb1ebdafd0114fe5 100644 --- a/lib_dec/hq_core_dec_fx.c +++ b/lib_dec/hq_core_dec_fx.c @@ -124,6 +124,7 @@ void hq_core_dec_fx( IF( !( core_switching_flag ) && GT_32( st_fx->core_brate, MINIMUM_RATE_TO_ENCODE_VOICING_FLAG ) ) { hHQ_core->HqVoicing = get_next_indice( st_fx, 1 ); + move16(); num_bits = sub( num_bits, 1 ); } ELSE @@ -499,6 +500,7 @@ void hq_core_dec_fx( { #ifdef BASOP_NOGLOB st_fx->plcInfo.recovery_gain = shl_sat( st_fx->plcInfo.recovery_gain, *Q_synth ); + move16(); #else st_fx->plcInfo.recovery_gain = shl( st_fx->plcInfo.recovery_gain, *Q_synth ); move16(); @@ -656,7 +658,7 @@ void ivas_hq_core_dec_fx( st_fx->hTcxCfg->tcx_last_overlap_mode = st_fx->hTcxCfg->tcx_curr_overlap_mode; move16(); - IF( EQ_16( st_fx->hTcxCfg->tcx_curr_overlap_mode, FULL_OVERLAP ) ) + if ( EQ_16( st_fx->hTcxCfg->tcx_curr_overlap_mode, FULL_OVERLAP ) ) { st_fx->hTcxCfg->tcx_last_overlap_mode = ALDO_WINDOW; move16(); @@ -685,13 +687,14 @@ void ivas_hq_core_dec_fx( IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { L_spec = l_spec_ext_tbl[st_fx->bwidth]; + move16(); } ELSE { core_switching_hq_prepare_dec_fx( st_fx, &num_bits, output_frame ); /* During ACELP->HQ core switching, limit the HQ core bitrate to 48kbps */ - IF( GT_16( num_bits, HQ_48k / 50 ) ) + if ( GT_16( num_bits, HQ_48k / 50 ) ) { num_bits = (Word16) ( HQ_48k / 50 ); move16(); @@ -713,13 +716,14 @@ void ivas_hq_core_dec_fx( IF( !( core_switching_flag ) && GT_32( st_fx->core_brate, MINIMUM_RATE_TO_ENCODE_VOICING_FLAG ) ) { hHQ_core->HqVoicing = get_next_indice_fx( st_fx, 1 ); + move16(); num_bits = sub( num_bits, 1 ); } ELSE { hHQ_core->HqVoicing = 0; move16(); - IF( GT_32( st_fx->core_brate, MINIMUM_RATE_TO_ENCODE_VOICING_FLAG ) ) + if ( GT_32( st_fx->core_brate, MINIMUM_RATE_TO_ENCODE_VOICING_FLAG ) ) { hHQ_core->HqVoicing = 1; move16(); @@ -740,7 +744,7 @@ void ivas_hq_core_dec_fx( { hHQ_core->ph_ecu_HqVoicing = 0; move16(); - IF( GE_16( output_frame, L_FRAME16k ) ) + if ( GE_16( output_frame, L_FRAME16k ) ) { hHQ_core->ph_ecu_HqVoicing = hHQ_core->HqVoicing; move16(); @@ -787,8 +791,9 @@ void ivas_hq_core_dec_fx( Copy( st_fx->delay_buf_out_fx, st_fx->previoussynth_fx + output_frame - delay_comp, delay_comp ); flag_uv = 1; - move16(); /* disable costly pitch out synthesis in bfi frame */ - hHQ_core->HqVoicing = sub( 1, flag_uv ); /* safety setting for HQ->ACELP switch logic */ + move16(); /* disable costly pitch out synthesis in bfi frame */ + hHQ_core->HqVoicing = sub( 1, flag_uv ); /* safety setting for HQ->ACELP switch logic */ + move16(); set16_fx( hHQ_core->fer_samples_fx, 0, L_FRAME48k ); /* safety, create a known signal state for HQ->ACELP switch logic */ } } @@ -826,7 +831,7 @@ void ivas_hq_core_dec_fx( test(); test(); test(); - IF( EQ_16( st_fx->element_mode, EVS_MONO ) || ( !core_switching_flag && !hq_recovery_flag ) ) + IF( st_fx->element_mode == EVS_MONO || ( !core_switching_flag && !hq_recovery_flag ) ) { /* scaling (coefficients are in nominal level) */ IF( NE_16( output_frame, NORM_MDCT_FACTOR ) ) @@ -834,12 +839,13 @@ void ivas_hq_core_dec_fx( IF( EQ_16( output_frame, L_FRAME32k ) ) { Q_audio = sub( Q_audio, 1 ); /* Multiply by 2 */ - Q_G_audio = Q_G_audio - 1; + Q_G_audio = sub( Q_G_audio, 1 ); } ELSE { tmp = mult_r( output_frame, 410 / 2 ); /* 1/8000 in Q15 */ ener_match = hq_nominal_scaling_inv[tmp]; + move16(); FOR( i = 0; i < inner_frame; i++ ) { /*t_audio_q[i] *= ener_match;*/ @@ -914,7 +920,9 @@ void ivas_hq_core_dec_fx( * Overlap-add * Pre-echo reduction *--------------------------------------------------------------------------*/ - IF( GT_16( st_fx->element_mode, EVS_MONO ) && ( core_switching_flag || hq_recovery_flag ) ) + test(); + test(); + IF( st_fx->element_mode > EVS_MONO && ( core_switching_flag || hq_recovery_flag ) ) { /* Initializations for TCX MDCT framework, to be used for switching frame */ tcx_cfg = st_fx->hTcxCfg; @@ -929,7 +937,9 @@ void ivas_hq_core_dec_fx( // encoderLookahead = ( L_LOOK_12k8 * st_fx->fscale ) / FSCALE_DENOM; // encoderLookaheadFB = ( L_LOOK_12k8 * fscaleFB ) / FSCALE_DENOM; mdctWindowLength = getMdctWindowLength( st_fx->fscale ); - mdctWindowLengthFB = (int16_t) ( mdctWindowLength * st_fx->output_Fs / st_fx->sr_core ); + Word16 temp, temp_e; + temp = BASOP_Util_Divide3232_Scale( st_fx->output_Fs, st_fx->sr_core, &temp_e ); + mdctWindowLengthFB = extract_l( L_shr( L_mult0( temp, mdctWindowLength ), sub( 15, temp_e ) ) ); IF( core_switching_flag ) { tcx_cfg->tcx_last_overlap_mode = TRANSITION_OVERLAP; @@ -963,24 +973,24 @@ void ivas_hq_core_dec_fx( #endif /* LB synthesis */ - E_audio = 31 - Q_audio; - move16(); + E_audio = sub( 31, Q_audio ); IMDCT_fx( t_audio_q, E_audio, hTcxDec->syn_Overl, hTcxDec->syn_Overl_TDAC, wtda_audio_16, tcx_cfg->tcx_aldo_window_1, tcx_cfg->tcx_aldo_window_1_trunc, tcx_cfg->tcx_aldo_window_2, tcx_cfg->tcx_mdct_window_half, tcx_cfg->tcx_mdct_window_minimum, tcx_cfg->tcx_mdct_window_trans, tcx_cfg->tcx_mdct_window_half_length, tcx_cfg->tcx_mdct_window_min_length, index, - left_rect, tcx_offset, overlap, L_frame, L_frameTCX, max( L_frameTCX, L_spec ) >> 1, L_frame_glob, 0, st_fx->bfi, hHQ_core->old_out_LB_fx, &hHQ_core->Q_old_wtda_LB, st_fx, 0, acelp_zir ); + left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frame_glob, 0, st_fx->bfi, hHQ_core->old_out_LB_fx, &hHQ_core->Q_old_wtda_LB, st_fx, 0, acelp_zir ); // values till L_frame same Scale_sig( wtda_audio_16 + L_frame, overlap, Q1 ); - Copy( wtda_audio_16 + ( overlap >> 1 ) - tcx_offset, output, L_frame_glob ); + Copy( wtda_audio_16 + sub( shr( overlap, 1 ), tcx_offset ), output, L_frame_glob ); /* FB synthesis */ - + temp = BASOP_Util_Divide3232_Scale( L_mult0( FSCALE_DENOM, L_frameTCX_glob ), L_frame_glob, &temp_e ); + temp = shr( temp, sub( 15, temp_e ) ); IMDCT_fx( t_audio_q, E_audio, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, wtda_audio_16, tcx_cfg->tcx_aldo_window_1_FB, tcx_cfg->tcx_aldo_window_1_FB_trunc, tcx_cfg->tcx_aldo_window_2_FB, tcx_cfg->tcx_mdct_window_halfFB, tcx_cfg->tcx_mdct_window_minimumFB, tcx_cfg->tcx_mdct_window_transFB, tcx_cfg->tcx_mdct_window_half_lengthFB, tcx_cfg->tcx_mdct_window_min_lengthFB, index, - left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, max( L_frameTCX, L_spec ) >> 1, L_frameTCX_glob, 0, st_fx->bfi, hHQ_core->old_out_fx, &hHQ_core->Q_old_wtda, st_fx, FSCALE_DENOM * L_frameTCX_glob / L_frame_glob, acelp_zir ); + left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, 0, st_fx->bfi, hHQ_core->old_out_fx, &hHQ_core->Q_old_wtda, st_fx, temp, acelp_zir ); Scale_sig( wtda_audio_16 + L_frameTCX, overlapFB, Q1 ); - Copy( wtda_audio_16 + ( overlapFB >> 1 ) - tcx_offsetFB, synth, L_frameTCX_glob ); + Copy( wtda_audio_16 + sub( shr( overlapFB, 1 ), tcx_offsetFB ), synth, L_frameTCX_glob ); Copy_Scale_sig_16_32( wtda_audio_16, wtda_audio, 2 * L_FRAME48k, 12 ); IF( !core_switching_flag ) @@ -992,7 +1002,7 @@ void ivas_hq_core_dec_fx( ELSE { test(); - IF( EQ_16( output_frame, L_FRAME8k ) || EQ_16( st_fx->bfi, 0 ) ) + IF( EQ_16( output_frame, L_FRAME8k ) || st_fx->bfi == 0 ) { test(); Q_audio = Q_G_audio; @@ -1009,7 +1019,7 @@ void ivas_hq_core_dec_fx( move16(); } - IF( GT_16( st_fx->element_mode, EVS_MONO ) ) + IF( st_fx->element_mode > EVS_MONO ) { IF( st_fx->bfi ) { @@ -1022,12 +1032,13 @@ void ivas_hq_core_dec_fx( /* LB synthesis for potential switch to ACELP */ tmp = BASOP_Util_Divide1616_Scale( st_fx->L_frame, output_frame, &tmp_e ); tmp = Sqrt16( tmp, &tmp_e ); - ener_match = shr( tmp, 2 - tmp_e ); // Q13 + ener_match = shr( tmp, sub( 2, tmp_e ) ); // Q13 v_multc_fixed_16( t_audio_q, ener_match, t_audio_q, inner_frame ); // Q Scale_sig32( t_audio_q, inner_frame, Q2 ); Q_audio = Q_G_audio; + move16(); Inverse_Transform( t_audio_q, &Q_audio, wtda_audio_LB, is_transient, st_fx->L_frame, inner_frame, st_fx->element_mode ); } *Q_output = Q_audio; @@ -1037,7 +1048,7 @@ void ivas_hq_core_dec_fx( IF( EQ_16( output_frame, L_FRAME8k ) ) { test(); - IF( EQ_16( st_fx->bfi, 0 ) && EQ_16( st_fx->prev_bfi, 0 ) ) + IF( EQ_16( st_fx->bfi, 0 ) && st_fx->prev_bfi == 0 ) { Copy_Scale_sig( hHQ_core->old_out_fx + N_ZERO_NB, hHQ_nbfec->prev_oldauOut_fx, output_frame - N_ZERO_NB, negate( hHQ_core->Q_old_wtda ) ); } @@ -1096,7 +1107,7 @@ void ivas_hq_core_dec_fx( } test(); test(); - IF( ( EQ_16( st_fx->bfi, 0 ) && EQ_16( st_fx->prev_bfi, 0 ) ) || !( GE_16( output_frame, L_FRAME16k ) ) ) + IF( ( st_fx->bfi == 0 && st_fx->prev_bfi == 0 ) || !( GE_16( output_frame, L_FRAME16k ) ) ) { preecho_sb_fx( st_fx->core_brate, wtda_audio, Q_audio, synth, *Q_synth, output_frame, &hHQ_core->memfilt_lb_fx, &hHQ_core->mean_prev_hb_fx, &hHQ_core->smoothmem_fx, &hHQ_core->mean_prev_fx, &hHQ_core->mean_prev_nc_fx, @@ -1120,6 +1131,7 @@ void ivas_hq_core_dec_fx( #else st_fx->plcInfo.recovery_gain = shl( st_fx->plcInfo.recovery_gain, *Q_synth ); #endif + move16(); waveform_adj2_fix( st_fx->tonalMDCTconceal.secondLastPcmOut, synth, st_fx->plcInfo.data_noise, @@ -1155,7 +1167,7 @@ void ivas_hq_core_dec_fx( move16(); } - IF( EQ_16( st_fx->nbLostCmpt, FRAMECTTOSTART_MDCT ) ) + if ( EQ_16( st_fx->nbLostCmpt, FRAMECTTOSTART_MDCT ) ) { hHQ_core->HqVoicing = 0; move16(); @@ -1174,7 +1186,7 @@ void ivas_hq_core_dec_fx( Word16 nbsubfr; /*nbsubfr = extract_l(L_mult0(st_fx->L_frame,FL2WORD16(1/L_SUBFR)));*/ nbsubfr = 4; - IF( EQ_16( st_fx->L_frame, 320 ) ) + if ( EQ_16( st_fx->L_frame, 320 ) ) { nbsubfr = 5; move16(); @@ -1192,10 +1204,10 @@ void ivas_hq_core_dec_fx( set16_fx( &st_fx->mem_pitch_gain[2], 0, nbsubfr ); } /* Move LB excitation to old_exc memory in case of switch HQ->ACELP */ - IF( GT_16( st_fx->element_mode, EVS_MONO ) ) + IF( st_fx->element_mode > EVS_MONO ) { Copy_Scale_sig( output, tmp_out, st_fx->L_frame, -( *Q_output ) ); - Copy( tmp_out, st_fx->old_exc_fx + L_EXC_MEM_DEC - st_fx->L_frame, st_fx->L_frame ); + Copy( tmp_out, st_fx->old_exc_fx + sub( L_EXC_MEM_DEC, st_fx->L_frame ), st_fx->L_frame ); } return; } @@ -1220,11 +1232,18 @@ void HQ_core_dec_init_fx( hHQ_core->Q_old_wtda_LB = 0; hHQ_core->Q_old_out = 0; hHQ_core->Q_old_outLB = 0; + move16(); + move16(); + move16(); + move16(); + move16(); hHQ_core->last_hq_core_type = -1; + move16(); set16_fx( hHQ_core->old_is_transient, 0, 3 ); hHQ_core->mem_norm[0] = 31; + move16(); set16_fx( hHQ_core->mem_norm + 1, 39, SFM_N_ENV_STAB - 1 ); hHQ_core->mem_env_delta = 0; hHQ_core->no_att_hangover = 0; @@ -1238,10 +1257,12 @@ void HQ_core_dec_init_fx( hHQ_core->prev_hqswb_clas = HQ_NORMAL; hHQ_core->prev_R = 0; move16(); + move16(); set32_fx( hHQ_core->prev_coeff_out_fx, 0, L_HQ_WB_BWE ); set16_fx( hHQ_core->prev_SWB_peak_pos_fx, 0, SPT_SHORTEN_SBNUM ); hHQ_core->HqVoicing = 0; + move16(); set16_fx( hHQ_core->fer_samples_fx, 0, L_FRAME48k ); set32_fx( hHQ_core->prev_env_fx, 0, SFM_N_WB ); set32_fx( hHQ_core->prev_normq_fx, 0, SFM_N_WB ); @@ -1252,6 +1273,7 @@ void HQ_core_dec_init_fx( hHQ_core->last_max_pos_pulse = 0; move16(); hHQ_core->Q_fer_samples = 0; + move16(); reset_preecho_dec_fx( hHQ_core ); @@ -1268,20 +1290,25 @@ void HQ_core_dec_init_fx( * HQ FEC *----------------------------------------------------------------------------------*/ hHQ_core->time_offs = 0; + move16(); set16_fx( hHQ_core->X_sav_fx, 0, PH_ECU_SPEC_SIZE ); hHQ_core->Q_X_sav = 0; hHQ_core->num_p = 0; + move16(); + move16(); - // set16_fx(hHQ_core->plocs, 0, MAX_PLOCS); - // set32_fx(hHQ_core->plocsi_fx, 0, MAX_PLOCS); hHQ_core->env_stab_fx = 0x6000; /*0.75 Q15*/ hHQ_core->mem_norm_hqfec[0] = 31; move16(); + move16(); set16_fx( hHQ_core->mem_norm_hqfec + 1, 39, SFM_N_ENV_STAB - 1 ); hHQ_core->mem_env_delta_hqfec = 0; hHQ_core->env_stab_plc_fx = 0; + move16(); + move16(); set16_fx( hHQ_core->env_stab_state_p_fx, INV_NUM_ENV_STAB_PLC_STATES, NUM_ENV_STAB_PLC_STATES ); hHQ_core->envstabplc_hocnt = 0; + move16(); set16_fx( hHQ_core->mag_chg_1st_fx, 32767, LGW_MAX ); set16_fx( hHQ_core->Xavg_fx, 0, LGW_MAX ); hHQ_core->beta_mute_fx = BETA_MUTE_FAC_INI; @@ -1297,6 +1324,8 @@ void HQ_core_dec_init_fx( move16(); move16(); move16(); + move16(); + move16(); return; @@ -1312,7 +1341,7 @@ void HQ_nbfec_init_fx( HQ_NBFEC_HANDLE hHQ_nbfec /* i/o: HQ NB FEC data handle */ ) { - int16_t i, j; + Word16 i, j; hHQ_nbfec->prev_last_core = -1; hHQ_nbfec->diff_energy_fx = 0; @@ -1320,13 +1349,14 @@ void HQ_nbfec_init_fx( hHQ_nbfec->stat_mode_old = 0; move16(); move16(); + move16(); + move16(); hHQ_nbfec->phase_mat_flag = 0; hHQ_nbfec->phase_mat_next = 0; hHQ_nbfec->old_Min_ind = 0; move16(); move16(); move16(); - move16(); set16_fx( hHQ_nbfec->old_auOut_2fr_fx, 0, L_FRAME8k * 2 ); set16_fx( hHQ_nbfec->old_out_pha_fx[0], 0, N_LEAD_NB ); set16_fx( hHQ_nbfec->old_out_pha_fx[1], 0, N_LEAD_NB ); @@ -1347,6 +1377,7 @@ void HQ_nbfec_init_fx( set16_fx( hHQ_nbfec->Norm_gain_fx, 1, SFM_N_NB ); hHQ_nbfec->HQ_FEC_seed = RANDOM_INITSEED; + move16(); set16_fx( hHQ_nbfec->energy_MA_Curr_fx, 100, 2 ); set16_fx( hHQ_nbfec->prev_sign_switch, 0, HQ_FEC_SIGN_SFM ); diff --git a/lib_dec/hq_hr_dec_fx.c b/lib_dec/hq_hr_dec_fx.c index a4c5ebf13cf9457ed55d6a94d4da784b06e0e9b1..93b94a5c862c5c25cab3c07590bc22b12af336d4 100644 --- a/lib_dec/hq_hr_dec_fx.c +++ b/lib_dec/hq_hr_dec_fx.c @@ -44,6 +44,8 @@ void ivas_hq_pred_hb_bws_fx( L_tmp = L_min( 8191, L_shr( L_tmp, 13 ) ); st_fx->prev_ener_shb_fx = extract_l( L_tmp ); /*Q1*/ st_fx->prev_ener_shb_fx = mult( st_fx->prev_ener_shb_fx, 5461 ); /*Q1*/ + move16(); + move16(); } ELSE { @@ -100,6 +102,8 @@ void hq_pred_hb_bws_fx( L_tmp = L_min( 8191, L_shr( L_tmp, 13 ) ); st_fx->prev_ener_shb_fx = extract_l( L_tmp ); /*Q1*/ st_fx->prev_ener_shb_fx = mult( st_fx->prev_ener_shb_fx, 5461 ); /*Q1*/ + move16(); + move16(); } ELSE { @@ -113,6 +117,7 @@ void hq_pred_hb_bws_fx( } L_tmp = Mpy_32_16_1( L_tmp, 2979 ); // Q1 st_fx->prev_ener_shb_fx = extract_l( L_tmp ); /*Q1*/ + move16(); #else st_fx->prev_ener_shb_fx = 0; move16(); @@ -182,9 +187,11 @@ void ivas_hq_hr_dec_fx( HQ_DEC_HANDLE hHQ_core = st_fx->hHQ_core; + move16(); move16(); Q_audio = 0; /* to avoid compilation warnings */ + move16(); /*------------------------------------------------------------------* * Initializations @@ -285,9 +292,11 @@ void ivas_hq_hr_dec_fx( ELSE { hHQ_core->env_stab_fx = env_stability_fx( ynrm, SFM_N_ENV_STAB_WB, hHQ_core->mem_norm_hqfec, &hHQ_core->mem_env_delta_hqfec, csw_flag1 ); + move16(); } } hHQ_core->env_stab_plc_fx = env_stab_smo_fx( s_min( hHQ_core->env_stab_fx, sub( 32767, stab_trans_fx[L_STAB_TBL - 1] ) ), hHQ_core->env_stab_state_p_fx, &hHQ_core->envstabplc_hocnt ); + move16(); /*------------------------------------------------------------------* * Bit allocation @@ -298,7 +307,7 @@ void ivas_hq_hr_dec_fx( test(); test(); - IF( EQ_16( *hqswb_clas, HQ_GEN_SWB ) && GT_16( st_fx->bws_cnt1, 0 ) && LT_32( st_fx->core_brate, HQ_32k ) ) + IF( EQ_16( *hqswb_clas, HQ_GEN_SWB ) && st_fx->bws_cnt1 > 0 && LT_32( st_fx->core_brate, HQ_32k ) ) { tmp = i_mult( st_fx->bws_cnt1, 1638 ); move16(); @@ -353,6 +362,7 @@ void ivas_hq_hr_dec_fx( FOR( i = 0; i < 300; i++ ) { t_audio_q[i] = L_shl( L_deposit_l( t_audio_q_norm[i] ), Q_shift ); /* Q12 */ + move32(); } } @@ -443,6 +453,8 @@ void hq_hr_dec_fx( Word16 Q_shift; Word16 bits_left; Word16 csw_flag1, csw_flag2; + move16(); + move16(); HQ_DEC_HANDLE hHQ_core = st_fx->hHQ_core; @@ -514,7 +526,7 @@ void hq_hr_dec_fx( env_stab = 0; move16(); - csw_flag1 = s_and( core_switching_flag, (Word16) NE_16( st_fx->element_mode, EVS_MONO ) ); + csw_flag1 = s_and( core_switching_flag, (Word16) ( st_fx->element_mode != EVS_MONO ) ); csw_flag2 = s_and( csw_flag1, (Word16) EQ_16( length, L_SPEC32k_EXT ) ); test(); IF( EQ_16( *hqswb_clas, HQ_HVQ ) ) @@ -541,6 +553,7 @@ void hq_hr_dec_fx( } ELSE { + test(); IF( EQ_16( length, L_FRAME32k ) || csw_flag2 ) { move16(); /* calculated stability */ @@ -549,6 +562,7 @@ void hq_hr_dec_fx( ELSE { hHQ_core->env_stab_fx = env_stability_fx( ynrm, SFM_N_ENV_STAB_WB, hHQ_core->mem_norm_hqfec, &hHQ_core->mem_env_delta_hqfec, csw_flag1 ); + move16(); } } hHQ_core->env_stab_plc_fx = env_stab_smo_fx( s_min( hHQ_core->env_stab_fx, sub( 32767, stab_trans_fx[L_STAB_TBL - 1] ) ), hHQ_core->env_stab_state_p_fx, &hHQ_core->envstabplc_hocnt ); @@ -617,6 +631,7 @@ void hq_hr_dec_fx( FOR( i = 0; i < 300; i++ ) { t_audio_q[i] = L_shl( L_deposit_l( t_audio_q_norm[i] ), Q_shift ); /* Q12 */ + move32(); } } @@ -626,9 +641,9 @@ void hq_hr_dec_fx( move16(); } +#if 0 test(); test(); -#if 0 IF ( NE_16(*hqswb_clas, HQ_HARMONIC)||NE_16(*hqswb_clas,HQ_HVQ)||flag_dis==0) // TV2VE -> always reset in floating point code, is it OK #endif { diff --git a/lib_dec/hq_lr_dec_fx.c b/lib_dec/hq_lr_dec_fx.c index f6bedf43ba4906ebb8f50ab9d9b46aa23d3560d3..887f37d5c93780f7bd18fbdcfd165ffdc5d33160 100644 --- a/lib_dec/hq_lr_dec_fx.c +++ b/lib_dec/hq_lr_dec_fx.c @@ -76,6 +76,7 @@ static void spt_shorten_domain_set_dec_fx( { spt_shorten_flag[j] = get_next_indice_fx( st_fx, 1 ); *bit_budget = sub( *bit_budget, 1 ); + move16(); IF( EQ_16( spt_shorten_flag[j], 1 ) ) { band_start[k] = new_band_start[j]; @@ -178,6 +179,7 @@ void hq_lr_dec_fx( HQ_DEC_HANDLE hHQ_core = st_fx->hHQ_core; tmp2 = 0; /* to avoid compilation flags */ + move16(); set16_fx( last_bitalloc_max_band, 0, 2 ); set32_fx( L_y2, 0x0L, L_FRAME48k ); @@ -216,6 +218,7 @@ void hq_lr_dec_fx( { /* decode transient flag */ *is_transient_fx = get_next_indice_fx( st_fx, 1 ); + move16(); num_bits = sub( num_bits, 1 ); } @@ -351,11 +354,13 @@ void hq_lr_dec_fx( FOR( i = 0; i < bands_fx; i++ ) { L_tmp2 = Ep_fx[i]; + move32(); L_tmp = L_max( 1, L_tmp2 ); exp = norm_l( L_tmp ); tmp = extract_h( L_shl( L_tmp, exp ) ); L_tmp3 = (Word32) band_width[i]; + move16(); exp2 = norm_l( L_tmp3 ); tmp2 = extract_h( L_shl( L_tmp3, exp2 ) ); @@ -387,6 +392,7 @@ void hq_lr_dec_fx( { /* decode the last p2a_bands-1 subbands bit-allocation index of the previous frame */ j = 0; + move16(); FOR( i = 0; i < 2; i++ ) { last_bitalloc_max_band[i] = get_next_indice_fx( st_fx, 1 ); @@ -777,6 +783,7 @@ void hq_lr_dec_fx( } L_tmp = Mult_32_16( L_band_energy_tmp[i], alpha_fx ); /*Q(Q_band_energy+14-15=Q_band_energy-1) */ L_band_energy_tmp[i] = L_shl( L_tmp, 1 ); /*Q Q_band_energy */ + move32(); } lowband = 6; move16(); @@ -944,6 +951,7 @@ void hq_lr_dec_fx( L_tmp = L_add( L_tmp, Mult_32_16( Ep_tmp_fx[i], tmp ) ); /*Q15 */ } st_fx->prev_ener_shb_fx = extract_l( L_shr( L_tmp, 14 ) ); + move16(); } test(); IF( GE_16( st_fx->last_inner_frame, L_FRAME32k ) && st_fx->hBWE_FD != NULL ) @@ -1048,6 +1056,7 @@ static Word16 decode_huff_8s_fx( WHILE( *hufftab > 0 ) { *rbits = add( *rbits, s_and( *hufftab, 0xf ) ); + move16(); bit = get_next_indice_fx( st_fx, s_and( *hufftab, 0xf ) ); move16(); hufftab += add( shr( *hufftab, 4 ), bit ); @@ -1352,6 +1361,7 @@ static void mdct_spectrum_fine_gain_dec_fx( temp_lo_fx = L_Extract_lc( L_temp, &temp_hi_fx ); Qgt = sub( 14, temp_hi_fx ); gain_table_fx[i] = extract_l( Pow2( 14, temp_lo_fx ) ); /* Qgt */ + move16(); /*q += delta; */ L_q = L_add( L_q, L_delta ); @@ -1378,6 +1388,7 @@ static void mdct_spectrum_fine_gain_dec_fx( ELSE { L_y2[i] = L_negate( L_shl( Mpy_32_16_1( L_abs( L_y2[i] ), gamma_fx ), 1 ) ); + move32(); } } } diff --git a/lib_dec/igf_dec_fx.c b/lib_dec/igf_dec_fx.c index eca6ee3aa23a43faf94cff91c2e6a4ce215c7fd2..95c0454b5496c286caa692fe96ea3338e54c3ecf 100644 --- a/lib_dec/igf_dec_fx.c +++ b/lib_dec/igf_dec_fx.c @@ -109,11 +109,11 @@ static Word16 IGF_replaceTCXNoise_1( /**< ou FOR( sb = start; sb < stop; sb++ ) { - if ( TCXNoise[sb] ) + IF( TCXNoise[sb] ) { tmp16 = extract_h( L_shl( in[sb], s_l ) ); } - if ( TCXNoise[sb] ) + IF( TCXNoise[sb] ) { nE = L_mac( nE, tmp16, tmp16 ); } @@ -162,6 +162,7 @@ static void IGF_replaceTCXNoise_2( Word32 *in, /**< in IF( TCXNoise[sb] ) { in[sb] = L_deposit_l( val ); + move32(); } IF( TCXNoise[sb] ) { @@ -177,7 +178,7 @@ static void IGF_replaceTCXNoise_2( Word32 *in, /**< in /* make sure that rE is never 0 */ - IF( rE == 0 ) + if ( rE == 0 ) { rE = L_add( totalNoiseNrg, 0 ); /* save move32() -> use L_add(x, 0) = x; */ } @@ -332,6 +333,7 @@ static void IGF_replaceTCXNoise_2_new_ivas_with_var_shift( Word32 *in, in[sb] = L_deposit_l( val ); move32(); in_e_arr[sb] = 31; + move16(); val = shr( val, 5 ); rE = L_mac( rE, val, val ); n_noise_bands_tile = add( n_noise_bands_tile, 1 ); @@ -344,13 +346,13 @@ static void IGF_replaceTCXNoise_2_new_ivas_with_var_shift( Word32 *in, noise_band_ratio = div_s( n_noise_bands_tile, n_noise_bands ); // Q15 /* make sure that rE is never 0 */ - IF( rE == 0 ) + if ( rE == 0 ) { rE = L_add( totalNoiseNrg, 0 ); /* save move32() -> use L_add(x, 0) = x; */ } /* if totalNoiseNrg == 0, then rE must be at least 0x00010000, otherwise division by 0 will occur */ - IF( totalNoiseNrg == 0 ) + if ( totalNoiseNrg == 0 ) { rE = L_max( rE, 0x00010000 ); } @@ -392,7 +394,7 @@ static void IGF_decode_whitening_level( Decoder_State *st, tmp = get_next_indice_fx( st, 1 ); - IF( tmp == 0 ) + if ( tmp == 0 ) { hPrivateData->currWhiteningLevel[p] = IGF_WHITENING_MID; move16(); @@ -419,6 +421,7 @@ static void IGF_decode_temp_flattening_trigger( Decoder_State *st, ) { hInstance->flatteningTrigger = get_next_indice_fx( st, 1 ); + move16(); } /**********************************************************************/ /* @@ -440,7 +443,6 @@ static void IGF_setLinesToZero( const Word16 startLine, /**< in if ( pSpectralData[i] != 0 ) { pPowerSpecIGF[i] = L_deposit_l( 0 ); - move32(); } } } @@ -554,6 +556,7 @@ static void IGF_prep( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in FOR( i = strt_cpy; i < startLine; i++ ) { igf_spec[tb++] = L_deposit_l( Random( hInfo->nfSeed ) ); /* 31Q0, fill LSBs */ + move32(); } } ELSE @@ -1435,6 +1438,8 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; Flag Carry = 0; + move16(); + move16(); #endif @@ -1520,6 +1525,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in #ifdef BASOP_NOGLOB /* Critical Carry/Overflow*/ L_tmp = L_add_co( L_tmp, energyTmp[tb], &Carry, &Overflow ); Overflow = 0; + move16(); L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); #else L_tmp = L_add_c( L_tmp, energyTmp[tb] ); @@ -1570,9 +1576,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in &pN_e[sfb] ); move32(); sN[tb] = L_deposit_l( 0 ); - move32(); pN[tb] = L_deposit_l( 0 ); - move32(); } } } @@ -1592,7 +1596,8 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in gn = hPrivateData->igf_curr[shr( sfb, 1 )]; move16(); move16(); - gn_e = 13; /* set exponent of igf_curr to 13 = 15 - 2; -> igf_curr = igf_curr * 0.25, virtual division by 4 */ + gn_e = 13; /* set exponent of igf_curr to 13 = 15 - 2; -> igf_curr = igf_curr * 0.25, virtual division by 4 */ + move16(); gn = sub( gn, 16 ); /* 13Q2 | 4 = 16 * 2^(-15 + 13); ("4" has same exponent as igf_curr now) */ /* float: tmp = pow(2.f, gn); basop: */ @@ -1719,6 +1724,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in { L_tmp = Mpy_32_16_1( sNlocal, 33 /*0.001f Q15*/ ); L_tmp_e = sNlocal_e; + move16(); } /* calc square root of L_tmp and store result in dN */ @@ -1772,6 +1778,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in dS[sfb] = round_fx( L_tmp ); move16(); dS_e[sfb] = dN_e[sfb - 1]; /* w0 is Q15, so no need to add an exponent */ + move16(); L_tmp = L_mult( w1, dN[sfb] ); dS_e[sfb] = BASOP_Util_Add_MantExp( dS[sfb], dS_e[sfb], @@ -1824,6 +1831,8 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in tmp = dS[s_min( add( sfb, tb ), sub( stop_sfb, 1 ) )]; tmp_e = dS_e[s_min( add( sfb, tb ), sub( stop_sfb, 1 ) )]; + move16(); + move16(); /* square tmp */ L_tmp = L_mult( tmp, tmp ); @@ -1863,6 +1872,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in dS[sfb] = round_fx( L_tmp ); dS_e[sfb] = L_tmp_e; move16(); + move16(); /* calculate the new dN */ dN[sfb] = mult_r( gFactor, dS[sfb] ); @@ -2529,6 +2539,8 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in tmp = dS[s_min( add( sfb, tb ), sub( stop_sfb, 1 ) )]; tmp_e = dS_e[s_min( add( sfb, tb ), sub( stop_sfb, 1 ) )]; + move16(); + move16(); /* square tmp */ L_tmp = L_mult( tmp, tmp ); @@ -2776,6 +2788,14 @@ static void IGF_getWhiteSpectralData( const Word32 *in, /**< in Word16 div; Word16 nrm_i; Word16 nrm_tab[] = { 2341 /* 1/14 */, 2521 /* 1/13 */, 2731 /* 1/12 */, 2979 /* 1/11 */, 3277 /* 1/10 */, 3641 /* 1/9 */, 4096 /* 1/8 */, 4681 /* 1/7 */ }; + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); /* inits */ div = 0; @@ -2908,6 +2928,8 @@ static void IGF_getWhiteSpectralData_ivas( { ak = 0; ak_e = 0; + move32(); + move16(); FOR( j = i - level; j < stop; j++ ) { @@ -2978,6 +3000,7 @@ static void IGF_RefineGrid( H_IGF_GRID hGrid /**< in } } hGrid->stopSfb = shl( hGrid->stopSfb, 1 ); + move16(); FOR( sfb = 0; sfb <= hGrid->stopSfb; sfb++ ) { hGrid->swb_offset[sfb] = a[sfb]; @@ -3028,7 +3051,6 @@ static void IGF_RefineGrid_ivas_fx( H_IGF_GRID hGrid /**< in/out: | IGF grid han a[tmp] = add( a[tmp], 1 ); move16(); } - move16(); IF( s_and( a[tmp], 1 ) != 0 ) { a[tmp] = sub( a[tmp], 1 ); @@ -3036,6 +3058,7 @@ static void IGF_RefineGrid_ivas_fx( H_IGF_GRID hGrid /**< in/out: | IGF grid han } } hGrid->stopSfb = shl( hGrid->stopSfb, 1 ); + move16(); FOR( sfb = 0; sfb <= hGrid->stopSfb; sfb++ ) { hGrid->swb_offset[sfb] = a[sfb]; @@ -3302,6 +3325,7 @@ void IGFDecApplyMono( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in IF( bfi != 0 ) { hPrivateData->frameLossCounter = add( hPrivateData->frameLossCounter, 1 ); + move16(); } ELSE { @@ -3340,6 +3364,8 @@ void IGFDecApplyMono( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in hGrid->minSrcSubband, hGrid->startLine, &hPrivateData->totalNoiseNrg ); + move16(); + move16(); BREAK; } @@ -3359,6 +3385,9 @@ void IGFDecApplyMono( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in hGrid->minSrcSubband, hGrid->startLine, &hPrivateData->totalNoiseNrg_off ); + move16(); + move16(); + BREAK; } } @@ -3470,6 +3499,7 @@ void IGFDecApplyMono_ivas( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in IF( bfi != 0 ) { hPrivateData->frameLossCounter = add( hPrivateData->frameLossCounter, 1 ); + move16(); } ELSE { @@ -3513,14 +3543,17 @@ void IGFDecApplyMono_ivas( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in hInstance->infoTCXNoise_ptr, igf_spec + hGrid->minSrcSubband, sub( hGrid->startLine, hGrid->minSrcSubband ) ); + move16(); hPrivateData->n_noise_bands = IGF_replaceTCXNoise_1( igf_spec, hPrivateData->headroom_TCX_noise_white, hInstance->infoTCXNoise_ptr, hGrid->minSrcSubband, hGrid->startLine, &hPrivateData->totalNoiseNrg ); + move16(); hPrivateData->totalNoiseNrg_exp = shl( sub( igf_spec_e[i], sub( hPrivateData->headroom_TCX_noise_white, 5 ) ), 1 ); + move16(); BREAK; } @@ -3535,6 +3568,7 @@ void IGFDecApplyMono_ivas( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in hInstance->infoTCXNoise_ptr, hPrivateData->pSpecFlat + hGrid->minSrcSubband, sub( hGrid->startLine, hGrid->minSrcSubband ) ); + move16(); hPrivateData->n_noise_bands_off = IGF_replaceTCXNoise_1( hPrivateData->pSpecFlat, hPrivateData->headroom_TCX_noise, @@ -3542,7 +3576,9 @@ void IGFDecApplyMono_ivas( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in hGrid->minSrcSubband, hGrid->startLine, &hPrivateData->totalNoiseNrg_off ); + move16(); hPrivateData->totalNoiseNrg_off_exp = shl( sub( hPrivateData->pSpecFlat_exp, sub( hPrivateData->headroom_TCX_noise, 5 ) ), 1 ); + move16(); BREAK; } } @@ -3687,6 +3723,8 @@ void IGFDecApplyStereo( { hPrivateDataL->frameLossCounter = add( hPrivateDataL->frameLossCounter, 1 ); hPrivateDataR->frameLossCounter = add( hPrivateDataR->frameLossCounter, 1 ); + move16(); + move16(); } ELSE { @@ -3707,7 +3745,7 @@ void IGFDecApplyStereo( { IF( !bfi ) { - s_l = getScaleFactor32( hPrivateDataL->pSpecFlat + hGrid->minSrcSubband - whiteningLevel, + s_l = getScaleFactor32( hPrivateDataL->pSpecFlat + sub( hGrid->minSrcSubband, whiteningLevel ), add( sub( hGrid->startLine, hGrid->minSrcSubband ), whiteningLevel ) ); IGF_getWhiteSpectralData_ivas( hPrivateDataL->pSpecFlat, hPrivateDataL->pSpecFlat_exp, @@ -3728,14 +3766,17 @@ void IGFDecApplyStereo( hPrivateDataL->headroom_TCX_noise_white = IGF_getScaleFactor32Cond( hIGFDecL->infoTCXNoise_ptr + hGrid->minSrcSubband, igf_specL_fx + hGrid->minSrcSubband, sub( hGrid->startLine, hGrid->minSrcSubband ) ); + move16(); hPrivateDataL->n_noise_bands = IGF_replaceTCXNoise_1( igf_specL_fx, hPrivateDataL->headroom_TCX_noise_white, hIGFDecL->infoTCXNoise_ptr, hGrid->minSrcSubband, hGrid->startLine, &hPrivateDataL->totalNoiseNrg ); + move16(); hPrivateDataL->totalNoiseNrg_exp = shl( sub( specMedL_e, sub( hPrivateDataL->headroom_TCX_noise_white, 5 ) ), 1 ); + move16(); IF( !bfi ) { @@ -3760,13 +3801,16 @@ void IGFDecApplyStereo( hPrivateDataR->headroom_TCX_noise_white = IGF_getScaleFactor32Cond( hIGFDecR->infoTCXNoise_ptr, igf_specR_fx + hGrid->minSrcSubband, sub( hGrid->startLine, hGrid->minSrcSubband ) ); + move16(); hPrivateDataR->n_noise_bands = IGF_replaceTCXNoise_1( igf_specR_fx, hPrivateDataR->headroom_TCX_noise_white, hIGFDecR->infoTCXNoise_ptr, hGrid->minSrcSubband, hGrid->startLine, &hPrivateDataR->totalNoiseNrg ); + move16(); hPrivateDataR->totalNoiseNrg_exp = shl( sub( specMedR_e, sub( hPrivateDataR->headroom_TCX_noise_white, 5 ) ), 1 ); + move16(); BREAK; } @@ -3787,6 +3831,9 @@ void IGFDecApplyStereo( hGrid->startLine, &hPrivateDataL->totalNoiseNrg_off ); hPrivateDataL->totalNoiseNrg_off_exp = shl( sub( hPrivateDataL->pSpecFlat_exp, sub( hPrivateDataL->headroom_TCX_noise_white, 5 ) ), 1 ); + move16(); + move16(); + move16(); hPrivateDataR->headroom_TCX_noise_white = IGF_getScaleFactor32Cond( hIGFDecR->infoTCXNoise_ptr, hPrivateDataR->pSpecFlat + hGrid->minSrcSubband, @@ -3798,6 +3845,9 @@ void IGFDecApplyStereo( hGrid->startLine, &hPrivateDataR->totalNoiseNrg_off ); hPrivateDataR->totalNoiseNrg_off_exp = shl( sub( hPrivateDataR->pSpecFlat_exp, sub( hPrivateDataR->headroom_TCX_noise_white, 5 ) ), 1 ); + move16(); + move16(); + move16(); BREAK; @@ -4218,6 +4268,7 @@ void IGFDecRestoreTCX10SubFrameData_fx( /* restore flattening trigger for current subframe */ hIGFDec->flatteningTrigger = hPrivateData->igf_flatteningTrigger_subframe[subFrameIdx]; + move16(); hIGFDec->flag_sparse = &hIGFDec->flag_sparseBuf[subFrameIdx * ( N_MAX_TCX - IGF_START_MN ) / 2]; hIGFDec->infoTCXNoise_ptr = &hIGFDec->infoTCXNoise_evs[subFrameIdx * ( IGF_START_MX ) / 2]; @@ -4241,12 +4292,15 @@ void init_igf_dec( set16_fx( (Word16 *) hIGFDec, 0, ( sizeof( IGFDEC_INSTANCE ) ) / sizeof( Word16 ) ); hIGFDec->igfData.igfInfo.nfSeedBuf[0] = 9733; hIGFDec->igfData.igfInfo.nfSeedBuf[1] = 9733; + move16(); + move16(); hIGFDec->igfData.igfInfo.nfSeed = &hIGFDec->igfData.igfInfo.nfSeedBuf[0]; set16_fx( hIGFDec->infoTCXNoise_evs, 0, IGF_START_MX ); set16_fx( hIGFDec->flag_sparseBuf, 0, N_MAX_TCX - IGF_START_MN ); set32_fx( hIGFDec->virtualSpec, 0, N_MAX_TCX - IGF_START_MN ); hIGFDec->virtualSpec_e = 0; + move16(); hIGFDec->infoIGFStopFreq = -1; move16(); hIGFDec->infoIGFStartFreq = -1; diff --git a/lib_dec/igf_scf_dec_fx.c b/lib_dec/igf_scf_dec_fx.c index 221b9b7a4981e17944331cf6875eafc25a4bd080..e7e4fecb381272626d355c04e309b44794c40e9f 100644 --- a/lib_dec/igf_scf_dec_fx.c +++ b/lib_dec/igf_scf_dec_fx.c @@ -32,7 +32,6 @@ void IGFSCFDecoderOpen( move16(); move16(); move16(); - move16(); hPublicData->t = 0; move16(); /* protect against the invalid request of starting decoding with a dependent block */ @@ -98,7 +97,7 @@ static Word16 arith_decode_residual_fx( Word16 val; Word16 x = 0; /* to avoid a compiler warning (potentially uninitialized local variable used) */ Word16 extra; - + move16(); /* decode one of the IGF_SYMBOLS_IN_TABLE == 27 alphabet symbols using the new raw AC function */ val = ari_decode_14bits_s27_ext_fx( st, &hPrivateData->acState, cumulativeFrequencyTable ); @@ -328,7 +327,9 @@ void IGFSCFDecoderDecode( /* advance history */ Copy( sfe, hPublicData->prev, hPublicData->scfCountLongBlock[igfGridIdx] ); hPublicData->t = add( hPublicData->t, 1 ); + move16(); hPublicData->bitsRead = sub( st->next_bit_pos, hPublicData->bitsRead ); + move16(); } #endif diff --git a/lib_dec/ivas_agc_dec_fx.c b/lib_dec/ivas_agc_dec_fx.c index bd01d2f04d08f102b7ad32bbebbb52d9c8e41e07..f4a7c7e9c5dafbde0a975c6610b2c13f9c7f878a 100644 --- a/lib_dec/ivas_agc_dec_fx.c +++ b/lib_dec/ivas_agc_dec_fx.c @@ -147,7 +147,7 @@ void ivas_spar_agc_dec_close_fx( ivas_agc_dec_state_t *hAgc; test(); - IF( hAgcDec == NULL || *hAgcDec == NULL ) + if ( hAgcDec == NULL || *hAgcDec == NULL ) { return; } @@ -195,6 +195,7 @@ void ivas_agc_dec_process_fx( FOR( i = 0; i < n_channels; i++ ) { pState->gain_state[i].gainExpVal = sub( pState->gain_data[i].absGainExp, pState->gain_data[i].absGainExpCurr ); + move16(); test(); IF( GT_16( pState->gain_state[i].gainExpVal, ( pState->agc_com.maxAttExp + 1 ) ) || LT_16( pState->gain_state[i].gainExpVal, -1 ) ) @@ -278,6 +279,7 @@ void ivas_agc_dec_process_fx( } pcm_out[i][idx] = Mpy_32_16_1( pcm_in[i][idx], gain ); // Q_pcm_out = Q_pcm_in - 3 + move32(); } // pState->gain_state[i].lastGain *= powf( pState->agc_com.winFunc[offset - 1], (float) pState->gain_state[i].gainExpVal ); @@ -304,6 +306,7 @@ void ivas_agc_dec_process_fx( tmp_2 = shr( tmp_2, 1 ); // Q14 } pState->gain_state[i].lastGain_fx = mult( pState->gain_state[i].lastGain_fx, tmp_2 ); + move16(); } ELSE { @@ -311,6 +314,7 @@ void ivas_agc_dec_process_fx( FOR( idx = 0; idx < output_frame; idx++ ) { pcm_out[i][idx] = Mpy_32_16_1( pcm_in[i][idx], gain ); // Q_pcm_out = Q_pcm_in - 3 + move32(); } } pState->gain_data[i].absGainExp = pState->gain_data[i].absGainExpCurr; diff --git a/lib_dec/ivas_cpe_dec_fx.c b/lib_dec/ivas_cpe_dec_fx.c index 5705d5dd52fb68eaa17c6857fc13d0a17b17ac5d..1cf15b1d2a83b9a9fad2d97a005025a8de093a0f 100644 --- a/lib_dec/ivas_cpe_dec_fx.c +++ b/lib_dec/ivas_cpe_dec_fx.c @@ -108,6 +108,8 @@ ivas_error ivas_cpe_dec_fx( sts[0]->BER_detect = s_or( sts[0]->BER_detect, st_ivas->BER_detect ); sts[1]->BER_detect = s_or( sts[1]->BER_detect, st_ivas->BER_detect ); + move16(); + move16(); element_brate_ref = hCPE->element_brate; move32(); @@ -268,6 +270,8 @@ ivas_error ivas_cpe_dec_fx( iDiv_and_mod_32( L_shr( hCPE->element_brate, 1 ), FRAMES_PER_SEC, &quo, &rem, 0 ); sts[0]->bits_frame_nominal = extract_l( quo ); sts[1]->bits_frame_nominal = extract_l( quo ); + move16(); + move16(); } ELSE { @@ -334,7 +338,8 @@ ivas_error ivas_cpe_dec_fx( nb_bits = sub( nb_bits, SID_FORMAT_NBITS ); sts[1]->bit_stream = sts[1]->bit_stream - SID_FORMAT_NBITS; /* set total bitrate of Stereo CNG parameters for BER detection */ - sts[1]->total_brate = L_sub( IVAS_SID_5k2, SID_2k40 ); + sts[1]->total_brate = IVAS_SID_5k2 - SID_2k40; + move32(); } test(); @@ -365,6 +370,7 @@ ivas_error ivas_cpe_dec_fx( /* subtract metadata bitbudget */ sts[0]->total_brate = L_sub( sts[0]->total_brate, L_mult0( nb_bits_metadata, FRAMES_PER_SEC ) ); + move32(); /* subtract bit-rate for combined format coding */ test(); @@ -373,6 +379,7 @@ ivas_error ivas_cpe_dec_fx( IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && ( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) || EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) || EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) ) { sts[0]->total_brate = L_add( sts[0]->total_brate, hCPE->brate_surplus ); + move32(); } } ELSE @@ -388,6 +395,7 @@ ivas_error ivas_cpe_dec_fx( move16(); iDiv_and_mod_32( hCPE->element_brate, FRAMES_PER_SEC, &quo, &rem, 0 ); sts[1]->bits_frame_channel = extract_l( quo ); + move16(); IF( hCPE->brate_surplus < 0 ) { iDiv_and_mod_32( L_abs( hCPE->brate_surplus ), FRAMES_PER_SEC, &quo, &rem, 0 ); @@ -398,9 +406,11 @@ ivas_error ivas_cpe_dec_fx( iDiv_and_mod_32( hCPE->brate_surplus, FRAMES_PER_SEC, &quo, &rem, 0 ); } sts[1]->bits_frame_channel = add( sts[1]->bits_frame_channel, extract_l( quo ) ); + move16(); IF( st_ivas->hQMetaData != NULL ) { sts[1]->bits_frame_channel = sub( sts[1]->bits_frame_channel, st_ivas->hQMetaData->metadata_max_bits ); + move16(); } } ELSE IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) ) @@ -455,6 +465,8 @@ ivas_error ivas_cpe_dec_fx( sts[n]->bits_frame_nominal = extract_l( quo ); iDiv_and_mod_32( hCPE->element_brate, FRAMES_PER_SEC, &quo, &rem, 0 ); sts[n]->bits_frame_channel = extract_l( L_shr( quo, sub( n_channels, 1 ) ) ); + move16(); + move16(); /* subtract bit-rate for combined format coding */ test(); @@ -472,6 +484,8 @@ ivas_error ivas_cpe_dec_fx( } sts[n]->bits_frame_channel = add( sts[n]->bits_frame_channel, extract_l( quo ) ); sts[n]->total_brate = L_add( sts[n]->total_brate, brate_surplus[n] ); + move16(); + move32(); } } @@ -483,12 +497,14 @@ ivas_error ivas_cpe_dec_fx( FOR( n = 0; n < n_channels; n++ ) { sts[n]->bits_frame_channel = sub( sts[n]->bits_frame_channel, shr( nb_bits_metadata, sub( n_channels, 1 ) ) ); + move16(); } } ELSE { /* subtract metadata bitbudget */ sts[0]->bits_frame_channel = sub( sts[0]->bits_frame_channel, nb_bits_metadata ); + move16(); } } } @@ -508,6 +524,7 @@ ivas_error ivas_cpe_dec_fx( { sts[n]->flag_ACELP16k = set_ACELP_flag_IVAS( hCPE->element_mode, hCPE->element_brate, sts[n]->total_brate, n, 0, sts[n]->bwidth, sts[n]->cng_type ); } + move16(); } FOR( n = 0; n < n_channels; n++ ) @@ -519,7 +536,7 @@ ivas_error ivas_cpe_dec_fx( move16(); sts[n]->active_cnt = 0; move16(); - IF( sts[1] != NULL ) + if ( sts[1] != NULL ) { sts[1]->active_cnt = 0; move16(); @@ -531,6 +548,8 @@ ivas_error ivas_cpe_dec_fx( move16(); sts[n]->active_cnt = add( sts[n]->active_cnt, 1 ); sts[n]->active_cnt = s_min( sts[n]->active_cnt, 100 ); + move16(); + move16(); } /* set CNA flag */ @@ -684,8 +703,6 @@ ivas_error ivas_cpe_dec_fx( q_dft = hCPE->hStereoDft->q_dft; move16(); - // TODO : To check this - stereo_dtf_cng_fx( hCPE, ivas_total_brate, DFT_fx, output_frame, q_dft ); } @@ -849,7 +866,7 @@ ivas_error ivas_cpe_dec_fx( hCPE->last_element_mode = hCPE->element_mode; move32(); - IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) + if ( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) { hCPE->element_brate = element_brate_ref; move32(); @@ -863,6 +880,8 @@ ivas_error ivas_cpe_dec_fx( st_ivas->BER_detect = s_or( st_ivas->BER_detect, sts[0]->BER_detect ); st_ivas->BER_detect = s_or( st_ivas->BER_detect, sts[1]->BER_detect ); + move16(); + move16(); pop_wmops(); @@ -930,7 +949,6 @@ ivas_error create_cpe_dec( move16(); hCPE->NbFrameMod = 7; move16(); - // hCPE->lt_es_em = 0.0f; hCPE->lt_es_em_fx = 0; move32(); @@ -946,6 +964,7 @@ ivas_error create_cpe_dec( ELSE { hCPE->nchan_out = s_min( CPE_CHANNELS, st_ivas->hDecoderConfig->nchan_out ); + move16(); } test(); @@ -966,9 +985,9 @@ ivas_error create_cpe_dec( test(); test(); test(); - IF( ( ( EQ_16( (Word16) st_ivas->ivas_format, MASA_FORMAT ) && LT_32( st_ivas->hDecoderConfig->ivas_total_brate, MASA_STEREO_MIN_BITRATE ) ) || - ( EQ_16( (Word16) st_ivas->ivas_format, MASA_ISM_FORMAT ) && LT_32( cpe_brate, MASA_STEREO_MIN_BITRATE ) ) ) && - GT_32( st_ivas->hDecoderConfig->ivas_total_brate, IVAS_SID_5k2 ) ) + if ( ( ( EQ_16( (Word16) st_ivas->ivas_format, MASA_FORMAT ) && LT_32( st_ivas->hDecoderConfig->ivas_total_brate, MASA_STEREO_MIN_BITRATE ) ) || + ( EQ_16( (Word16) st_ivas->ivas_format, MASA_ISM_FORMAT ) && LT_32( cpe_brate, MASA_STEREO_MIN_BITRATE ) ) ) && + GT_32( st_ivas->hDecoderConfig->ivas_total_brate, IVAS_SID_5k2 ) ) { hCPE->nchan_out = 1; move16(); @@ -1043,7 +1062,7 @@ ivas_error create_cpe_dec( { hCPE->input_mem_fx[i] = NULL; hCPE->input_mem_LB_fx[i] = NULL; - IF( i == 0 ) + if ( i == 0 ) { hCPE->input_mem_BPF_fx[0] = NULL; } @@ -1060,7 +1079,7 @@ ivas_error create_cpe_dec( FOR( n = 0; n < CPE_CHANNELS; n++ ) { - IF( st_ivas->sba_dirac_stereo_flag && EQ_16( st_ivas->nchan_transport, 1 ) ) + if ( st_ivas->sba_dirac_stereo_flag && EQ_16( st_ivas->nchan_transport, 1 ) ) { /* for SBA DirAC stereo output CPE element is only used for upmix, core coder is found in SCE element used for core decoding */ BREAK; @@ -1075,6 +1094,7 @@ ivas_error create_cpe_dec( // st->total_brate = hCPE->element_brate / ( CPE_CHANNELS ); st->total_brate = L_shr( hCPE->element_brate, 1 ); /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ + move32(); st->mct_chan_mode = MCT_CHAN_MODE_REGULAR; move32(); st->is_ism_format = 0; @@ -1082,7 +1102,7 @@ ivas_error create_cpe_dec( st->ivas_format = st_ivas->ivas_format; move32(); - IF( NE_32( ( error = init_decoder_ivas_fx( st, n, st_ivas->mc_mode ) ), IVAS_ERR_OK ) ) + if ( NE_32( ( error = init_decoder_ivas_fx( st, n, st_ivas->mc_mode ) ), IVAS_ERR_OK ) ) { return error; } @@ -1341,7 +1361,7 @@ static void read_stereo_mode_and_bwidth_fx( *-----------------------------------------------------------------*/ test(); - IF( st_ivas->bfi || LT_32( st_ivas->hDecoderConfig->ivas_total_brate, IVAS_SID_5k2 ) ) + if ( st_ivas->bfi || LT_32( st_ivas->hDecoderConfig->ivas_total_brate, IVAS_SID_5k2 ) ) { hCPE->element_mode = hCPE->last_element_mode; move16(); @@ -1363,6 +1383,9 @@ static void read_stereo_mode_and_bwidth_fx( /* Read BW information in SID */ hCPE->hCoreCoder[0]->bwidth = get_next_indice_fx( hCPE->hCoreCoder[0], 2 ); + move16(); + move16(); + BREAK; case SID_MDCT_STEREO: /* 2TC SBA DTX also uses MDCT-Stereo DTX */ @@ -1379,7 +1402,7 @@ static void read_stereo_mode_and_bwidth_fx( BREAK; case SID_MASA_2TC: /* 2TC MASA DTX uses MDCT or DFT based core */ - IF( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) ) + if ( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) ) { hCPE->element_mode = IVAS_CPE_DFT; move16(); @@ -1391,6 +1414,8 @@ static void read_stereo_mode_and_bwidth_fx( /* Read BW information in SID */ hCPE->hCoreCoder[0]->bwidth = get_next_indice_fx( hCPE->hCoreCoder[0], 2 ); + move16(); + move16(); } BREAK; default: @@ -1423,6 +1448,7 @@ static void read_stereo_mode_and_bwidth_fx( IF( LT_32( hCPE->element_brate, MIN_BRATE_MDCT_STEREO ) && st_ivas->hMCT == NULL ) { hCPE->element_mode = add( get_next_indice_fx( sts[0], NBITS_ELEMENT_MODE ), IVAS_CPE_DFT ); + move16(); } ELSE { @@ -1435,6 +1461,7 @@ static void read_stereo_mode_and_bwidth_fx( { /* WB and SWB are supported */ sts[0]->bwidth = add( get_next_indice_fx( sts[0], 1 ), WB ); + move16(); sts[1]->bwidth = sts[0]->bwidth; move16(); } @@ -1442,6 +1469,7 @@ static void read_stereo_mode_and_bwidth_fx( { /* WB, SWB and FB are supported */ sts[0]->bwidth = get_next_indice_fx( sts[0], NBITS_BWIDTH ); + move16(); sts[1]->bwidth = sts[0]->bwidth; move16(); } @@ -1498,6 +1526,7 @@ static void stereo_mode_combined_format_dec_fx( hCPE->element_brate = IVAS_64k; move32(); hCPE->brate_surplus = L_sub( hCPE->brate_surplus, L_sub( hCPE->element_brate, element_brate_ref ) ); + move32(); } } } diff --git a/lib_dec/ivas_decision_matrix_dec.c b/lib_dec/ivas_decision_matrix_dec.c index 75bfecc1593707bdec966361bf35ce48babfccd0..0a4e950f60b131f3a16800874e264e9c5f3f3f69 100644 --- a/lib_dec/ivas_decision_matrix_dec.c +++ b/lib_dec/ivas_decision_matrix_dec.c @@ -531,10 +531,12 @@ void ivas_decision_matrix_dec_fx( IF( NE_16( st->element_mode, IVAS_CPE_DFT ) ) { st->cng_type = get_next_indice_fx( st, 1 ); + move16(); IF( EQ_16( st->cng_type, FD_CNG ) ) { st->bwidth = get_next_indice_fx( st, 2 ); + move16(); } } IF( get_next_indice_fx( st, 1 ) ) @@ -559,6 +561,7 @@ void ivas_decision_matrix_dec_fx( /* read flag for no side noise shape */ st->hFdCngDec->hFdCngCom->no_side_flag = get_next_indice_fx( st, 1 ); + move16(); } test(); @@ -566,7 +569,7 @@ void ivas_decision_matrix_dec_fx( test(); test(); test(); - IF( ( GE_32( st->output_Fs, 32000 ) && GE_16( st->bwidth, SWB ) ) || ( EQ_16( st->element_mode, IVAS_CPE_DFT ) && GE_16( st->bwidth, SWB ) && EQ_16( nchan_out, 2 ) && LT_16( st->L_frame, L_FRAME16k ) ) ) + if ( ( GE_32( st->output_Fs, 32000 ) && GE_16( st->bwidth, SWB ) ) || ( EQ_16( st->element_mode, IVAS_CPE_DFT ) && GE_16( st->bwidth, SWB ) && EQ_16( nchan_out, 2 ) && LT_16( st->L_frame, L_FRAME16k ) ) ) { st->extl = SWB_CNG; move16(); @@ -575,7 +578,7 @@ void ivas_decision_matrix_dec_fx( test(); test(); test(); - IF( EQ_32( st->total_brate, FRAME_NO_DATA ) && st->prev_bfi && !st->bfi && GT_16( st->L_frame, L_FRAME16k ) ) + if ( EQ_32( st->total_brate, FRAME_NO_DATA ) && st->prev_bfi && !st->bfi && GT_16( st->L_frame, L_FRAME16k ) ) { st->L_frame = st->last_CNG_L_frame; move16(); @@ -651,7 +654,7 @@ void ivas_decision_matrix_dec_fx( { *sharpFlag = 0; move16(); - IF( EQ_16( st->coder_type, GENERIC ) || EQ_16( st->coder_type, VOICED ) ) + if ( EQ_16( st->coder_type, GENERIC ) || EQ_16( st->coder_type, VOICED ) ) { *sharpFlag = 1; move16(); @@ -664,7 +667,7 @@ void ivas_decision_matrix_dec_fx( test(); test(); - IF( EQ_16( st->idchan, 1 ) && ( st->tdm_LRTD_flag == 0 || LT_16( st->bits_frame_channel, IVAS_16k4 / FRAMES_PER_SEC ) ) ) + if ( EQ_16( st->idchan, 1 ) && ( st->tdm_LRTD_flag == 0 || LT_16( st->bits_frame_channel, IVAS_16k4 / FRAMES_PER_SEC ) ) ) { st->bwidth = WB; /* only WB in the secondary channel */ move16(); @@ -681,7 +684,7 @@ void ivas_decision_matrix_dec_fx( test(); test(); test(); - IF( LT_32( element_brate, IVAS_24k4 ) && ( EQ_16( st->coder_type, VOICED ) || EQ_16( st->coder_type, GENERIC ) || EQ_16( st->coder_type, TRANSITION ) ) ) + if ( LT_32( element_brate, IVAS_24k4 ) && ( EQ_16( st->coder_type, VOICED ) || EQ_16( st->coder_type, GENERIC ) || EQ_16( st->coder_type, TRANSITION ) ) ) { *sharpFlag = 1; move16(); @@ -839,7 +842,7 @@ void ivas_decision_matrix_dec_fx( move32(); test(); test(); - IF( GE_32( st->total_brate, MIN_BRATE_SWB_TBE_2k80 ) && st->flag_ACELP16k && EQ_16( st->element_mode, IVAS_SCE ) ) + if ( GE_32( st->total_brate, MIN_BRATE_SWB_TBE_2k80 ) && st->flag_ACELP16k && EQ_16( st->element_mode, IVAS_SCE ) ) { st->extl_brate = FB_TBE_3k0; move32(); @@ -875,7 +878,7 @@ void ivas_decision_matrix_dec_fx( test(); test(); test(); - IF( GE_16( st->element_mode, IVAS_CPE_DFT ) && EQ_16( st->core, ACELP_CORE ) && ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && !( EQ_16( st->element_mode, IVAS_CPE_TD ) && st->tdm_LRTD_flag ) ) + if ( GE_16( st->element_mode, IVAS_CPE_DFT ) && EQ_16( st->core, ACELP_CORE ) && ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && !( EQ_16( st->element_mode, IVAS_CPE_TD ) && st->tdm_LRTD_flag ) ) { icbwe_brate = L_add( icbwe_brate, STEREO_ICBWE_MSFLAG_BITS * FRAMES_PER_SEC ); } @@ -884,6 +887,7 @@ void ivas_decision_matrix_dec_fx( /* set core bitrate */ st->core_brate = L_sub( L_sub( st->total_brate, st->extl_brate ), icbwe_brate ); + move32(); /*-----------------------------------------------------------------* * Read transform core (TCX vs. HQ) signaling bit from the bitstream @@ -926,6 +930,7 @@ void ivas_decision_matrix_dec_fx( { /* read ACELP->HQ core switching flag */ *core_switching_flag = get_next_indice_fx( st, 1 ); + move16(); } ELSE { @@ -938,7 +943,7 @@ void ivas_decision_matrix_dec_fx( st->last_core_from_bs = ACELP_CORE; move16(); - IF( EQ_16( st->core, st->last_core ) ) + if ( EQ_16( st->core, st->last_core ) ) { /* A mismatch between the core_switching_flag and the st->core/st->last_core indicates a frame was lost. if prev_bfi is not set the frame loss diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 53891fc5121dc887006e13e960a9e87dae35c587..1e67761fd4b38fe701435f6b54cc71df74de7433 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -490,17 +490,16 @@ ivas_error ivas_dec_setup( /* read ism_mode */ st_ivas->ism_mode = ISM_MODE_DISC; move32(); - if ( GT_16( nchan_ism, 2 ) ) + IF( GT_16( nchan_ism, 2 ) ) { - k -= nchan_ism; /* SID metadata flags */ - move16(); + k = sub( k, nchan_ism ); /* SID metadata flags */ idx = st_ivas->bit_stream[k]; move16(); st_ivas->ism_mode = (ISM_MODE) add( idx, 1 ); move32(); } - IF( st_ivas->ini_frame == 0 ) + if ( st_ivas->ini_frame == 0 ) { last_ism_mode = st_ivas->ism_mode; move32(); @@ -2480,7 +2479,7 @@ ivas_error ivas_init_decoder_fx( st_ivas->nSCE = 0; move16(); - st_ivas->nCPE = shr( MC_PARAMUPMIX_MAX_TRANSPORT_CHANS, 1 ); + st_ivas->nCPE = MC_PARAMUPMIX_MAX_TRANSPORT_CHANS >> 1; move16(); st_ivas->nchan_transport = MC_PARAMUPMIX_MAX_TRANSPORT_CHANS; move16(); @@ -2745,7 +2744,7 @@ ivas_error ivas_init_decoder_fx( FOR( Word16 nS = 0; nS < nchan_rend; nS++ ) { TDREND_SRC_t *Src_p = st_ivas->hBinRendererTd->Sources[SrcInd[nS]]; - IF( Src_p->SrcSpatial_p != NULL ) + if ( Src_p->SrcSpatial_p != NULL ) { Src_p->SrcSpatial_p->q_Pos_p = Q31; move16(); @@ -2813,7 +2812,7 @@ ivas_error ivas_init_decoder_fx( test(); IF( ( EQ_32( st_ivas->ivas_format, MC_FORMAT ) ) && ( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) ) ) { - granularity = NS2SA( output_Fs, CLDFB_SLOT_NS ); + granularity = NS2SA_FX2( output_Fs, CLDFB_SLOT_NS ); move16(); n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ); @@ -2825,7 +2824,7 @@ ivas_error ivas_init_decoder_fx( } ELSE { - granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); + granularity = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); move16(); n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ); @@ -2851,7 +2850,7 @@ ivas_error ivas_init_decoder_fx( Word16 nchan_rend = num_src; move16(); test(); - IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && NE_32( st_ivas->transport_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) + if ( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && NE_32( st_ivas->transport_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) { nchan_rend = sub( nchan_rend, 1 ); /* Skip LFE channel -- added to the others */ move16(); @@ -2859,7 +2858,7 @@ ivas_error ivas_init_decoder_fx( FOR( Word16 nS = 0; nS < nchan_rend; nS++ ) { TDREND_SRC_t *Src_p = st_ivas->hBinRendererTd->Sources[SrcInd[nS]]; - IF( Src_p->SrcSpatial_p != NULL ) + if ( Src_p->SrcSpatial_p != NULL ) { Src_p->SrcSpatial_p->q_Pos_p = Q31; move16(); @@ -2936,7 +2935,7 @@ ivas_error ivas_init_decoder_fx( move16(); test(); - IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && NE_32( st_ivas->transport_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) + if ( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && NE_32( st_ivas->transport_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) { nchan_rend = sub( nchan_rend, 1 ); /* Skip LFE channel -- added to the others */ } diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index 1d56a3412e86b03a52294fba3dd6e16c2df54a39..745c5c65d33efbcb08b17ed5edb814296353f8bb 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -49,7 +49,6 @@ void ivas_init_dec_get_num_cldfb_instances_ivas_fx( IF( EQ_32( ivas_format, MASA_ISM_FORMAT ) ) { - test(); test(); IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) { @@ -70,7 +69,6 @@ void ivas_init_dec_get_num_cldfb_instances_ivas_fx( BREAK; case RENDERER_NON_DIEGETIC_DOWNMIX: case RENDERER_MONO_DOWNMIX: - test(); test(); test(); IF( EQ_32( ivas_format, ISM_FORMAT ) || EQ_32( ivas_format, MASA_ISM_FORMAT ) || EQ_32( ivas_format, SBA_ISM_FORMAT ) ) diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 9f1f1bf1c7644173591688e9a23734c1b1b8e491..e18d369f46df393119862027b01d9649946e1b9c 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -72,6 +72,7 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( RENDERER_TYPE renderer_type_old; error = IVAS_ERR_OK; + move32(); nCPE_old = st_ivas->nCPE; move16(); nSCE_old = st_ivas->nSCE; @@ -118,6 +119,7 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( tc_granularity_new = 1; move16(); renderer_type_old = st_ivas->renderer_type; + move32(); /*-----------------------------------------------------------------* * Initialize the needed renderer struct and destroy the unnecessary renderer struct @@ -128,6 +130,7 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->intern_config ); + test(); IF( ( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) && ( EQ_32( st_ivas->ism_mode, ISM_MODE_DISC ) ) ) { ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->hDecoderConfig->output_config ); @@ -330,7 +333,7 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( hTcBuffer = st_ivas->hTcBuffer; tc_buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode( st_ivas ); - tc_nchan_tc_new = ivas_jbm_dec_get_num_tc_channels( st_ivas ); + tc_nchan_tc_new = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ); tc_nchan_allocate_new = tc_nchan_tc_new; move16(); tc_nchan_full_new = tc_nchan_tc_new; @@ -350,7 +353,7 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( test(); test(); test(); - IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) && ( NE_32( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) && NE_32( st_ivas->renderer_type, RENDERER_DISABLE ) && NE_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && NE_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) ) + if ( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) && ( NE_32( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) && NE_32( st_ivas->renderer_type, RENDERER_DISABLE ) && NE_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && NE_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) ) { tc_nchan_full_new = 0; move16(); @@ -710,6 +713,7 @@ ivas_error ivas_ism_dec_config_fx( Word16 nchan_transport_old; error = IVAS_ERR_OK; + move32(); ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; move32(); /* Assumes that num of input objects are constant */ @@ -722,6 +726,8 @@ ivas_error ivas_ism_dec_config_fx( move16(); } + test(); + test(); test(); IF( !st_ivas->bfi && NE_32( ivas_total_brate, IVAS_SID_5k2 ) && NE_32( ivas_total_brate, FRAME_NO_DATA ) ) { @@ -731,7 +737,7 @@ ivas_error ivas_ism_dec_config_fx( st_ivas->nchan_transport = st_ivas->nchan_ism; move16(); - if ( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) ) + IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) ) { st_ivas->nchan_transport = MAX_PARAM_ISM_WAVE; move16(); @@ -742,7 +748,7 @@ ivas_error ivas_ism_dec_config_fx( } } - if ( st_ivas->ini_active_frame != 0 ) + IF( st_ivas->ini_active_frame != 0 ) { /* ISM bit-rate switching */ { diff --git a/lib_dec/ivas_ism_metadata_dec.c b/lib_dec/ivas_ism_metadata_dec.c index 529a4033dc6b0cee89ea9fa57abbb772bdbeff62..37c0f6d7baf5cc35971f772d99e6c81ad4ef7376 100644 --- a/lib_dec/ivas_ism_metadata_dec.c +++ b/lib_dec/ivas_ism_metadata_dec.c @@ -1022,6 +1022,7 @@ ivas_error ivas_ism_metadata_dec_fx( { /* read non-diegetic flag for each object */ hIsmMetaData->non_diegetic_flag = get_next_indice_fx( st0, ISM_METADATA_IS_NDP_BITS ); + move16(); } ELSE { @@ -1041,6 +1042,7 @@ ivas_error ivas_ism_metadata_dec_fx( hIsmMetaData->azimuth_fx = ism_dequant_meta_fx( idx_angle1, ism_azimuth_borders_fx, ISM_Q_STEP_FX, ISM_Q_STEP_BORDER_FX, shl( 1, ISM_AZIMUTH_NBITS ) ); hIsmMetaData->elevation_fx = 0; move32(); + move32(); /* save for smoothing metadata evolution */ hIsmMetaData->last_true_azimuth_fx = hIsmMetaData->azimuth_fx; @@ -1068,6 +1070,8 @@ ivas_error ivas_ism_metadata_dec_fx( { hIsmMetaData->azimuth_fx = ism_dequant_meta_fx( idx_angle1, ism_azimuth_borders_fx, ISM_Q_STEP_FX, ISM_Q_STEP_BORDER_FX, shl( 1, ISM_AZIMUTH_NBITS ) ); hIsmMetaData->elevation_fx = ism_dequant_meta_fx( idx_angle2, ism_elevation_borders_fx, ISM_Q_STEP_FX, ISM_Q_STEP_BORDER_FX, shl( 1, ISM_ELEVATION_NBITS ) ); + move32(); + move32(); /* radius/raw/pitch dequantization */ IF( ism_extmeta_bitstream ) diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 5586d72b1264493f9fcb578fe957a4160c606fda..16b818327819f04df311caeb9280800284c5d20f 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -499,18 +499,22 @@ static void ivas_param_ism_compute_mixing_matrix_fx( { case 2: direct_power_fx[w] = L_shr_r( ref_power_fx[bin_idx], 1 ); + move32(); BREAK; case 3: direct_power_fx[w] = Mpy_32_16_1( ref_power_fx[bin_idx], 24576 ); + move32(); BREAK; case 4: direct_power_fx[w] = L_shr_r( ref_power_fx[bin_idx], 2 ); + move32(); BREAK; } } ELSE { direct_power_fx[w] = Mpy_32_16_1( ref_power_fx[bin_idx], hParamIsmDec->power_ratios_fx[band_idx][0][w] ); + move32(); } direct_power_e = ref_power_e; move16(); @@ -519,11 +523,13 @@ static void ivas_param_ism_compute_mixing_matrix_fx( FOR( i = 0; i < nchan_out_woLFE; i++ ) { cy_diag_fx[i] = BASOP_Util_Add_Mant32Exp( cy_diag_fx[i], cy_diag_e_arr[i], Mpy_32_32( direct_power_fx[w], cy_diag_tmp_fx[w][i] ), add( direct_power_e, cy_diag_tmp_e[w] ), &cy_diag_e_arr[i] ); + move32(); } } temp_e[w] = direct_power_e; move16(); direct_power_fx[w] = Sqrt32( direct_power_fx[w], &temp_e[w] ); + move32(); } cy_diag_e = cy_diag_e_arr[0]; move16(); @@ -534,6 +540,7 @@ static void ivas_param_ism_compute_mixing_matrix_fx( FOR( i = 0; i < nchan_out_woLFE; i++ ) { cy_diag_fx[i] = L_shr_r( cy_diag_fx[i], sub( cy_diag_e, cy_diag_e_arr[i] ) ); + move32(); } direct_power_e = temp_e[0]; @@ -545,6 +552,7 @@ static void ivas_param_ism_compute_mixing_matrix_fx( FOR( w = 0; w < num_wave; w++ ) { direct_power_fx[w] = L_shr_r( direct_power_fx[w], sub( direct_power_e, temp_e[w] ) ); + move32(); } /* Compute mixing matrix */ @@ -1051,6 +1059,7 @@ ivas_error ivas_param_ism_dec_open_fx( set16_fx( hSpatParamRendCom->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS ); set16_fx( hSpatParamRendCom->subframe_nbslots, JBM_CLDFB_SLOTS_IN_SUBFRAME, DEFAULT_JBM_SUBFRAMES_5MS ); hSpatParamRendCom->nb_subframes = DEFAULT_JBM_SUBFRAMES_5MS; + move16(); hSpatParamRendCom->subframes_rendered = 0; move16(); hSpatParamRendCom->slots_rendered = 0; @@ -1207,7 +1216,7 @@ ivas_error ivas_param_ism_dec_open_fx( IF( st_ivas->hTcBuffer == NULL ) { move16(); // NS2SA - IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, nchan_full, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, nchan_full, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ), IVAS_ERR_OK ) ) { return error; @@ -1221,9 +1230,8 @@ ivas_error ivas_param_ism_dec_open_fx( IF( st_ivas->hTcBuffer == NULL ) { Word16 nchan_to_allocate = st_ivas->hDecoderConfig->nchan_out; - move16(); move16(); // NS2SA - IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_BUFFER, nchan_to_allocate, nchan_to_allocate, nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_BUFFER, nchan_to_allocate, nchan_to_allocate, nchan_to_allocate, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ), IVAS_ERR_OK ) ) { return error; } @@ -2088,12 +2096,13 @@ void ivas_param_ism_dec_digest_tc_fx( Word32 ivas_total_brate; Word16 output_frame; /* Direct Response/EFAP Gains */ - Word32 direct_response_fx[MAX_NUM_OBJECTS][PARAM_ISM_MAX_CHAN] = { 0 }; + Word32 direct_response_fx[MAX_NUM_OBJECTS][PARAM_ISM_MAX_CHAN]; PARAM_ISM_DEC_HANDLE hParamIsmDec; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; Word16 fade_len; /* Initialization */ + set32_fx( &direct_response_fx[0][0], 0, MAX_NUM_OBJECTS * PARAM_ISM_MAX_CHAN ); hParamIsmDec = st_ivas->hParamIsmDec; assert( hParamIsmDec ); hSpatParamRendCom = st_ivas->hSpatParamRendCom; @@ -2752,7 +2761,7 @@ static void ivas_ism_param_dec_render_sf_fx( { set32_fx( output_f_fx[ch], 0, i_mult( hSpatParamRendCom->subframe_nbslots[subframe_idx], hSpatParamRendCom->num_freq_bands ) ); - IF( LT_16( idx_lfe, sub( hSetup.num_lfe, 1 ) ) ) + if ( LT_16( idx_lfe, sub( hSetup.num_lfe, 1 ) ) ) { idx_lfe = add( idx_lfe, 1 ); } @@ -2770,8 +2779,8 @@ static void ivas_ism_param_dec_render_sf_fx( { RealBuffer_fx[i] = Cldfb_RealBuffer_fx[idx_in][i]; ImagBuffer_fx[i] = Cldfb_ImagBuffer_fx[idx_in][i]; - Q_real = min( Q_real, sub( 31, imag_exp[i] ) ); - Q_real = min( Q_real, sub( 31, real_exp[i] ) ); + Q_real = s_min( Q_real, sub( 31, imag_exp[i] ) ); + Q_real = s_min( Q_real, sub( 31, real_exp[i] ) ); } Q_real = sub( Q_real, 3 ); // guarded bits @@ -2952,12 +2961,12 @@ void ivas_param_ism_dec_render_fx( } ELSE { - nchan_out = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; + nchan_out = add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe ); move16(); nchan_out_woLFE = st_ivas->hIntSetup.nchan_out_woLFE; move16(); } - slot_size = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + slot_size = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); move16(); /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ Word32 res_dec, res_frac; diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index 6ab1ad3b526dab8170082c1beb983c0283d46fd0..d50c3196c98300f9c893a0a1c4ce5ae6cdf5f414 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -218,7 +218,7 @@ void ivas_ism_renderer_close( ) { test(); - IF( hIsmRendererData == NULL || *hIsmRendererData == NULL ) + if ( hIsmRendererData == NULL || *hIsmRendererData == NULL ) { return; } @@ -391,7 +391,7 @@ void ivas_ism_render_sf_fx( num_objects = st_ivas->nchan_transport; move16(); - IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) + if ( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) { num_objects = st_ivas->nchan_ism; move16(); @@ -1093,6 +1093,7 @@ void ivas_omasa_separate_object_render_jbm_fx( FOR( k = 0; k < n_samples_sf; k++ ) { hRendererData->interpolator_fx[k] = div_s( k, n_samples_sf ); + move16(); } hRendererData->interpolator_len = n_samples_sf; move16(); @@ -1154,6 +1155,7 @@ void ivas_omasa_separate_object_render_jbm_fx( g2_fx = sub( 32767, g1_fx ); output_fx_local[j2][k + offsetSamples] = L_add( output_fx_local[j2][add( k, offsetSamples )], L_add( L_shl( Mpy_32_32( Mpy_32_16_1( input_fx[obj][k + offsetSamples], g1_fx ), gains_fx[j] ), 2 ), L_shl( Mpy_32_32( Mpy_32_16_1( input_fx[obj][add( k, offsetSamples )], g2_fx ), hRendererData->prev_gains_fx[obj][j] ), 2 ) ) ); + move32(); } } hRendererData->prev_gains_fx[obj][j] = gains_fx[j]; diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 0772e46f8e395738cd0f0f7f3d96a7970d4ddeb1..274f8cbdf81268da903e118ead891f70ce3e183f 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -80,9 +80,9 @@ static Word16 ceil_fx16( Word16 inp, Word16 Q ); static Word16 ceil_fx16( Word16 inp, Word16 Q ) { Word16 ret = shr( inp, Q ); - IF( ( inp & ( ( 1 << Q ) - 1 ) ) > 0 ) + IF( ( s_and( inp, sub( shl( 1, Q ), 1 ) ) ) > 0 ) { - ret = ret + 1; + ret = add( ret, 1 ); } return ret; } @@ -127,7 +127,7 @@ ivas_error ivas_jbm_dec_tc_fx( ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; move32(); - output_frame = (Word16) ( output_Fs / FRAMES_PER_SEC ); + output_frame = extract_l( Mult_32_16( output_Fs, INV_FRAME_PER_SEC_Q15 ) ) /* output_Fs / FRAMES_PER_SEC */; FOR( n = 0; n < MAX_TRANSPORT_CHANNELS; n++ ) { @@ -147,6 +147,7 @@ ivas_error ivas_jbm_dec_tc_fx( } #ifdef MSAN_FIX st_ivas->hTcBuffer->no_channels = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); + move16(); #endif } @@ -197,9 +198,11 @@ ivas_error ivas_jbm_dec_tc_fx( hp20_fix32( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); } + test(); IF( EQ_32( st_ivas->renderer_type, RENDERER_MC ) && EQ_16( st_ivas->hDecoderConfig->nchan_out, 1 ) ) { s = Q16 - Q11; + move16(); s = sub( s, find_guarded_bits_fx( st_ivas->nchan_transport ) ); FOR( i = 0; i < s_max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) { @@ -222,7 +225,7 @@ ivas_error ivas_jbm_dec_tc_fx( set32_fx( p_output_fx[st_ivas->hISMDTX.sce_id_dtx], 0, L_FRAME48k ); - IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, st_ivas->hISMDTX.sce_id_dtx, &p_output_fx[st_ivas->hISMDTX.sce_id_dtx], output_frame, nb_bits_metadata[st_ivas->hISMDTX.sce_id_dtx] ) ), IVAS_ERR_OK ) ) + IF( ( error = ivas_sce_dec_fx( st_ivas, st_ivas->hISMDTX.sce_id_dtx, &p_output_fx[st_ivas->hISMDTX.sce_id_dtx], output_frame, nb_bits_metadata[st_ivas->hISMDTX.sce_id_dtx] ) ) != IVAS_ERR_OK ) { return error; } @@ -232,7 +235,7 @@ ivas_error ivas_jbm_dec_tc_fx( IF( st_ivas->hSCE[ch] != NULL ) { Word16 shift = getScaleFactor32( st_ivas->hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN ); - IF( LT_16( sub( st_ivas->hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ), 4 ) ) + if ( LT_16( sub( st_ivas->hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ), 4 ) ) { shift = sub( st_ivas->hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, 4 ); } @@ -319,7 +322,7 @@ ivas_error ivas_jbm_dec_tc_fx( st = st_ivas->hCPE[0]->hCoreCoder[0]; } - IF( NE_32( ( error = ivas_masa_decode_fx( st_ivas, st, &nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) + IF( ( error = ivas_masa_decode_fx( st_ivas, st, &nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { return error; } @@ -331,7 +334,7 @@ ivas_error ivas_jbm_dec_tc_fx( } ELSE IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) ) { - IF( NE_32( ( error = ivas_spar_dec_fx( st_ivas, nb_bits_metadata ) ), IVAS_ERR_OK ) ) + IF( ( error = ivas_spar_dec_fx( st_ivas, nb_bits_metadata ) ) != IVAS_ERR_OK ) { return error; } @@ -439,6 +442,7 @@ ivas_error ivas_jbm_dec_tc_fx( Scale_sig32( p_output_fx[i], L_FRAME48k, s ); } hCPE->hStereoDft->q_dft = add( Q11, s ); + move16(); IF( EQ_16( hCPE->hStereoDft->first_frame, 1 ) ) { hCPE->hStereoDft->q_smoothed_nrg = Q6; // hCPE->hStereoDft->q_dft; @@ -482,15 +486,15 @@ ivas_error ivas_jbm_dec_tc_fx( test(); test(); test(); - IF( ( ( st->last_core != ACELP_CORE || ( st->prev_bfi == 1 && st->last_core == ACELP_CORE && st->last_con_tcx == 1 ) ) && st->last_core != AMR_WB_CORE ) || ( st_ivas->sba_dirac_stereo_flag && st->cng_type == FD_CNG ) ) /* TCX / HQ-CORE -> TCX / HQ-CORE */ + IF( ( ( st->last_core != ACELP_CORE || ( EQ_16( st->prev_bfi, 1 ) && st->last_core == ACELP_CORE && EQ_16( st->last_con_tcx, 1 ) ) ) && NE_16( st->last_core, AMR_WB_CORE ) ) || ( st_ivas->sba_dirac_stereo_flag && EQ_16( st->cng_type, FD_CNG ) ) ) /* TCX / HQ-CORE -> TCX / HQ-CORE */ { - scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( hCPE->hCoreCoder[0]->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); + scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( hCPE->hCoreCoder[0]->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); } - ELSE IF( st->core == TCX_20_CORE || st->core == TCX_10_CORE || st->core == HQ_CORE ) /* ACELP -> TCX/HQ */ + ELSE IF( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) || EQ_16( st->core, HQ_CORE ) ) /* ACELP -> TCX/HQ */ { IF( !st->tcxonly ) { - scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( hCPE->hCoreCoder[0]->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); + scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( hCPE->hCoreCoder[0]->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); } } } @@ -506,7 +510,7 @@ ivas_error ivas_jbm_dec_tc_fx( test(); IF( ( LE_16( st->last_L_frame, L_FRAME16k ) && LE_16( st->L_frame, L_FRAME16k ) ) || ( st_ivas->sba_dirac_stereo_flag && EQ_32( st->core_brate, SID_2k40 ) && EQ_16( st->cng_type, FD_CNG ) ) ) { - scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( hCPE->hCoreCoder[0]->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); + scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( hCPE->hCoreCoder[0]->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); } } } @@ -514,17 +518,19 @@ ivas_error ivas_jbm_dec_tc_fx( #else scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); #endif - scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA( 16000, DELAY_BWE_TOTAL_NS ), sub( hCPE->hStereoDft->q_dft, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); + scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA_FX2( 16000, DELAY_BWE_TOTAL_NS ), sub( hCPE->hStereoDft->q_dft, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); hCPE->hStereoDft->q_ap_fade_mem_fx = hCPE->hStereoDft->q_dft; move16(); } IF( hSCE != NULL ) { - Scale_sig32( &hSCE->save_hb_synth_fx[0], (Word16) ( hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC ), hCPE->hStereoDft->q_dft - hSCE->q_save_hb_synth_fx ); + Scale_sig32( &hSCE->save_hb_synth_fx[0], extract_l( Mult_32_16( hCPE->hCoreCoder[0]->output_Fs, INV_FRAME_PER_SEC_Q15 ) ), sub( hCPE->hStereoDft->q_dft, hSCE->q_save_hb_synth_fx ) ); hSCE->q_save_hb_synth_fx = hCPE->hStereoDft->q_dft; - Scale_sig32( &hSCE->save_synth_fx[0], (Word16) ( hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC ), hCPE->hStereoDft->q_dft - hSCE->q_save_synth_fx ); + move16(); + Scale_sig32( &hSCE->save_synth_fx[0], extract_l( Mult_32_16( hCPE->hCoreCoder[0]->output_Fs, INV_FRAME_PER_SEC_Q15 ) ), sub( hCPE->hStereoDft->q_dft, hSCE->q_save_synth_fx ) ); hSCE->q_save_synth_fx = hCPE->hStereoDft->q_dft; + move16(); } st_ivas->hSpar->hMdDec->Q_mixer_mat = 30; move16(); @@ -532,11 +538,12 @@ ivas_error ivas_jbm_dec_tc_fx( { scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); hCPE->q_output_mem_fx[ii] = hCPE->hStereoDft->q_dft; + move16(); } #ifdef MSAN_FIX FOR( Word16 ii = 0; ii < CPE_CHANNELS; ii++ ) { - Scale_sig32( &hCPE->prev_synth_fx[ii][0], NS2SA( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), hCPE->q_prev_synth_fx - 11 ); + Scale_sig32( &hCPE->prev_synth_fx[ii][0], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), hCPE->q_prev_synth_fx - 11 ); } #else Scale_sig32( &hCPE->prev_synth_fx[0][0], sizeof( hCPE->prev_synth_fx ) / sizeof( hCPE->prev_synth_fx[0][0] ), hCPE->q_prev_synth_fx - 11 ); @@ -551,7 +558,7 @@ ivas_error ivas_jbm_dec_tc_fx( #ifdef MSAN_FIX FOR( int ii = 0; ii < CPE_CHANNELS; ii++ ) { - Scale_sig32( &hCPE->prev_synth_fx[ii][0], NS2SA( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), 11 - hCPE->q_prev_synth_fx ); + Scale_sig32( &hCPE->prev_synth_fx[ii][0], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), 11 - hCPE->q_prev_synth_fx ); } #else Scale_sig32( &hCPE->prev_synth_fx[0][0], sizeof( hCPE->prev_synth_fx ) / sizeof( hCPE->prev_synth_fx[0][0] ), 11 - hCPE->q_prev_synth_fx ); @@ -561,7 +568,7 @@ ivas_error ivas_jbm_dec_tc_fx( FOR( i = 0; i < CPE_CHANNELS; ++i ) { scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); - scale_sig32( hCPE->input_mem_fx[i], NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); + scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); } IF( hCPE->hCoreCoder[0] != NULL ) @@ -580,7 +587,7 @@ ivas_error ivas_jbm_dec_tc_fx( test(); test(); test(); - IF( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) || EQ_16( st->core, HQ_CORE ) || ( EQ_16( st->bfi, 1 ) && EQ_16( st->core, ACELP_CORE ) && EQ_16( st->con_tcx, 1 ) ) ) + IF( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) || EQ_16( st->core, HQ_CORE ) || ( EQ_16( st->bfi, 1 ) && st->core == ACELP_CORE && EQ_16( st->con_tcx, 1 ) ) ) { test(); test(); @@ -589,15 +596,16 @@ ivas_error ivas_jbm_dec_tc_fx( test(); test(); test(); - IF( ( ( st->last_core != ACELP_CORE || ( st->prev_bfi == 1 && st->last_core == ACELP_CORE && st->last_con_tcx == 1 ) ) && st->last_core != AMR_WB_CORE ) || ( st_ivas->sba_dirac_stereo_flag && st->cng_type == FD_CNG ) ) /* TCX / HQ-CORE -> TCX / HQ-CORE */ + test(); + IF( ( ( st->last_core != ACELP_CORE || ( EQ_16( st->prev_bfi, 1 ) && st->last_core == ACELP_CORE && EQ_16( st->last_con_tcx, 1 ) ) ) && NE_16( st->last_core, AMR_WB_CORE ) ) || ( st_ivas->sba_dirac_stereo_flag && EQ_16( st->cng_type, FD_CNG ) ) ) /* TCX / HQ-CORE -> TCX / HQ-CORE */ { - scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( hCPE->hCoreCoder[0]->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); + scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( hCPE->hCoreCoder[0]->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); } - ELSE IF( st->core == TCX_20_CORE || st->core == TCX_10_CORE || st->core == HQ_CORE ) /* ACELP -> TCX/HQ */ + ELSE IF( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) || EQ_16( st->core, HQ_CORE ) ) /* ACELP -> TCX/HQ */ { IF( !st->tcxonly ) { - scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( hCPE->hCoreCoder[0]->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); + scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( hCPE->hCoreCoder[0]->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); } } } @@ -605,13 +613,15 @@ ivas_error ivas_jbm_dec_tc_fx( { test(); test(); - IF( st->last_core == TCX_20_CORE || st->last_core == TCX_10_CORE || st->last_core == HQ_CORE ) /* TCX/HQ -> ACELP */ + IF( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) || EQ_16( st->last_core, HQ_CORE ) ) /* TCX/HQ -> ACELP */ { test(); test(); - IF( ( st->last_L_frame <= L_FRAME16k && st->L_frame <= L_FRAME16k ) || ( st_ivas->sba_dirac_stereo_flag && st->core_brate == SID_2k40 && st->cng_type == FD_CNG ) ) + test(); + test(); + IF( ( LE_16( st->last_L_frame, L_FRAME16k ) && LE_16( st->L_frame, L_FRAME16k ) ) || ( st_ivas->sba_dirac_stereo_flag && EQ_32( st->core_brate, SID_2k40 ) && EQ_16( st->cng_type, FD_CNG ) ) ) { - scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( hCPE->hCoreCoder[0]->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); + scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( hCPE->hCoreCoder[0]->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); } } } @@ -619,7 +629,7 @@ ivas_error ivas_jbm_dec_tc_fx( #else scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); #endif - scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA( 16000, DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); + scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA_FX2( 16000, DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); hCPE->hStereoDft->q_ap_fade_mem_fx = Q11; test(); } @@ -629,12 +639,14 @@ ivas_error ivas_jbm_dec_tc_fx( { scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); hCPE->q_output_mem_fx[ii] = Q11; + move16(); } } } ELSE IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) && LT_32( ivas_total_brate, MASA_STEREO_MIN_BITRATE ) && ( GT_32( ivas_total_brate, IVAS_SID_5k2 ) || ( LE_32( ivas_total_brate, IVAS_SID_5k2 ) && st_ivas->nCPE > 0 && EQ_16( st_ivas->hCPE[0]->nchan_out, 1 ) ) ) ) { nchan_remapped = 1; /* Only one channel transported */ + move16(); test(); } @@ -668,7 +680,7 @@ ivas_error ivas_jbm_dec_tc_fx( Q_p_output = s_min( Q_p_output, temp_min ); } Q_p_output = sub( Q_p_output, 2 ); - IF( GT_16( Q_p_output, 20 ) ) + if ( GT_16( Q_p_output, 20 ) ) { Q_p_output = 20; move16(); @@ -691,8 +703,8 @@ ivas_error ivas_jbm_dec_tc_fx( { Word16 size = st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport; move16(); - IF( EQ_16( st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, 3 ) ) - size = add( size, 1 ); + if ( EQ_16( st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, 3 ) ) + size = add( size, 1 ); FOR( i = 0; i < size; i++ ) { @@ -708,13 +720,14 @@ ivas_error ivas_jbm_dec_tc_fx( IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) ) { Word16 q_shift = 0; + move16(); ivas_masa_prerender_fx( st_ivas, p_output_fx, &q_shift, output_frame, nchan_remapped ); FOR( i = 0; i < 2; i++ ) { Scale_sig32( p_output_fx[i], output_frame, negate( q_shift ) ); } } - ELSE IF( st_ivas->ivas_format == SBA_FORMAT && ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) + ELSE IF( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) && ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) ) { /* loudness correction */ ivas_dirac_dec_binaural_sba_gain_fx( p_output_fx, nchan_remapped, output_frame ); @@ -740,7 +753,7 @@ ivas_error ivas_jbm_dec_tc_fx( st_ivas->hSpatParamRendCom->numIsmDirections = 0; move16(); test(); - IF( NE_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && NE_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) + if ( NE_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && NE_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) { st_ivas->hSpatParamRendCom->numIsmDirections = st_ivas->nchan_ism; move16(); @@ -778,7 +791,7 @@ ivas_error ivas_jbm_dec_tc_fx( } /* MASA metadata decoding */ - IF( NE_32( ( error = ivas_masa_decode_fx( st_ivas, st_ivas->hCPE[0]->hCoreCoder[0], &nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) + IF( ( error = ivas_masa_decode_fx( st_ivas, st_ivas->hCPE[0]->hCoreCoder[0], &nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { return error; } @@ -788,7 +801,7 @@ ivas_error ivas_jbm_dec_tc_fx( st_ivas->hCPE[0]->hCoreCoder[0]->bit_stream = &( st_ivas->bit_stream[( ism_total_brate / FRAMES_PER_SEC )] ); - IF( NE_32( ( error = ivas_omasa_ism_metadata_dec_fx( st_ivas, ism_total_brate, &nchan_ism, &nchan_transport_ism, dirac_bs_md_write_idx, &nb_bits_metadata[1] ) ), IVAS_ERR_OK ) ) + IF( ( error = ivas_omasa_ism_metadata_dec_fx( st_ivas, ism_total_brate, &nchan_ism, &nchan_transport_ism, dirac_bs_md_write_idx, &nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) { return error; } @@ -868,6 +881,7 @@ ivas_error ivas_jbm_dec_tc_fx( set16_fx( nb_bits_metadata, 0, MAX_SCE + 1 ); nchan_ism = st_ivas->nchan_ism; + move16(); IF( EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) { /* set ISM parameters and decode ISM metadata in OSBA format */ @@ -882,6 +896,8 @@ ivas_error ivas_jbm_dec_tc_fx( { nb_bits_metadata[1] = add( nb_bits_metadata[1], NO_BITS_MASA_ISM_NO_OBJ ); sba_ch_idx = 0; + move16(); + move16(); } /* SBA metadata decoding */ @@ -905,7 +921,7 @@ ivas_error ivas_jbm_dec_tc_fx( { set32_fx( p_output_fx[0], 0, L_FRAME48k ); - IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ), IVAS_ERR_OK ) ) + IF( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) { return error; } @@ -930,7 +946,7 @@ ivas_error ivas_jbm_dec_tc_fx( } ELSE IF( GT_16( st_ivas->nCPE, 1 ) ) { - IF( NE_32( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ), IVAS_ERR_OK ) ) + IF( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) { return error; } @@ -972,6 +988,7 @@ ivas_error ivas_jbm_dec_tc_fx( Scale_sig32( p_output_fx[sba_ch_idx + i], L_FRAME48k, s ); } hCPE->hStereoDft->q_dft = add( Q11, s ); + move16(); IF( EQ_16( hCPE->hStereoDft->first_frame, 1 ) ) { hCPE->hStereoDft->q_smoothed_nrg = Q6; // hCPE->hStereoDft->q_dft; @@ -993,12 +1010,14 @@ ivas_error ivas_jbm_dec_tc_fx( Copy_Scale_sig_16_32( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx, L_FRAME32k, sub( q, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ) ); Copy_Scale_sig_16_32( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx, L_FRAME48k, sub( q, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ) ); hCPE->hCoreCoder[0]->hHQ_core->q_old_outLB_fx = q; + move16(); } IF( hCPE->hStereoDft != NULL ) { scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA( 16000, DELAY_BWE_TOTAL_NS ), sub( hCPE->hStereoDft->q_dft, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); hCPE->hStereoDft->q_ap_fade_mem_fx = hCPE->hStereoDft->q_dft; + move16(); } st_ivas->hSpar->hMdDec->Q_mixer_mat = Q30; move32(); @@ -1105,8 +1124,8 @@ ivas_error ivas_jbm_dec_tc_fx( } ELSE IF( NE_32( st_ivas->renderer_type, RENDERER_DISABLE ) && st_ivas->sba_dirac_stereo_flag == 0 ) { - Word16 size = st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport + sba_ch_idx; - IF( EQ_16( size, 3 ) ) + Word16 size = add( st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, sba_ch_idx ); + if ( EQ_16( size, 3 ) ) { size = add( size, 1 ); } @@ -1163,7 +1182,7 @@ ivas_error ivas_jbm_dec_tc_fx( ivas_lfe_dec_fx( st_ivas->hLFE, st, output_frame, st_ivas->bfi, p_output_fx[LFE_CHANNEL] ); Scale_sig32( p_output_fx[LFE_CHANNEL], L_FRAME48k, Q11 - Q9 ); - IF( NE_32( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, 0 ) ), IVAS_ERR_OK ) ) + IF( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, 0 ) ) != IVAS_ERR_OK ) { return error; } @@ -1194,6 +1213,7 @@ ivas_error ivas_jbm_dec_tc_fx( IF( EQ_32( st_ivas->renderer_type, RENDERER_MC ) ) { s = Q16 - Q11; + move16(); s = sub( s, find_guarded_bits_fx( st_ivas->nchan_transport ) ); FOR( i = 0; i < s_max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) { @@ -1356,12 +1376,13 @@ ivas_error ivas_jbm_dec_tc_fx( /* Identify the index of the separated channel, always LFE_CHANNEL-1 here */ n = LFE_CHANNEL - 1; + move16(); /* Decode the separated channel to output[n] to be combined with the synthesized channels */ set32_fx( p_output_fx[n], 0, L_FRAME48k ); - IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[n], output_frame, 0 ) ), IVAS_ERR_OK ) ) + IF( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[n], output_frame, 0 ) ) != IVAS_ERR_OK ) { return error; } @@ -1433,6 +1454,7 @@ ivas_error ivas_jbm_dec_tc_fx( Scale_sig32( p_output_fx[i], L_FRAME48k, s ); } hCPE->hStereoDft->q_dft = add( Q11, s ); + move16(); IF( EQ_16( hCPE->hStereoDft->first_frame, 1 ) ) { hCPE->hStereoDft->q_smoothed_nrg = Q6; // hCPE->hStereoDft->q_dft; @@ -1509,18 +1531,18 @@ ivas_error ivas_jbm_dec_tc_fx( FOR( i = 0; i < CPE_CHANNELS; ++i ) { scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); - scale_sig32( hCPE->input_mem_fx[i], NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); + scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); } IF( hCPE->hCoreCoder[0] != NULL ) { - Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, L_FRAME32k, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB - q ); - Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, L_FRAME48k, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda - q ); + Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB, q ) ); + Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, L_FRAME48k, sub( hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda, q ) ); } IF( hCPE->hStereoDft != NULL ) { - scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); - scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA( 16000, DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); + scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( 16000, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); + scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA_FX2( 16000, DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); hCPE->hStereoDft->q_ap_fade_mem_fx = Q11; move16(); } @@ -1573,13 +1595,16 @@ ivas_error ivas_jbm_dec_tc_fx( { st_ivas->hDecoderConfig->last_ivas_total_brate = ivas_total_brate; move32(); - st_ivas->last_active_ivas_total_brate = ( ivas_total_brate <= IVAS_SID_5k2 ) ? st_ivas->last_active_ivas_total_brate : ivas_total_brate; + IF( LE_32( ivas_total_brate, IVAS_SID_5k2 ) ) + st_ivas->last_active_ivas_total_brate = st_ivas->last_active_ivas_total_brate; + ELSE + st_ivas->last_active_ivas_total_brate = ivas_total_brate; move32(); } test(); test(); - IF( LT_16( st_ivas->ini_frame, MAX_FRAME_COUNTER ) && !( st_ivas->bfi && st_ivas->ini_frame == 0 ) ) /* keep "st_ivas->ini_frame = 0" until first good received frame */ + if ( LT_16( st_ivas->ini_frame, MAX_FRAME_COUNTER ) && !( st_ivas->bfi && st_ivas->ini_frame == 0 ) ) /* keep "st_ivas->ini_frame = 0" until first good received frame */ { st_ivas->ini_frame = add( st_ivas->ini_frame, 1 ); move16(); @@ -1587,7 +1612,7 @@ ivas_error ivas_jbm_dec_tc_fx( test(); test(); - IF( LT_16( st_ivas->ini_active_frame, MAX_FRAME_COUNTER ) && !( st_ivas->bfi && st_ivas->ini_frame == 0 ) && GT_32( ivas_total_brate, IVAS_SID_5k2 ) ) /* needed in MASA decoder in case the first active frame is BFI, and there were SID-frames decoded before */ + if ( LT_16( st_ivas->ini_active_frame, MAX_FRAME_COUNTER ) && !( st_ivas->bfi && st_ivas->ini_frame == 0 ) && GT_32( ivas_total_brate, IVAS_SID_5k2 ) ) /* needed in MASA decoder in case the first active frame is BFI, and there were SID-frames decoded before */ { st_ivas->ini_active_frame = add( st_ivas->ini_active_frame, 1 ); move16(); @@ -2277,14 +2302,21 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( { Word32 data_f_fx[MAX_CLDFB_DIGEST_CHANNELS][MAX_JBM_L_FRAME48k] = { 0 }; /* Word32 buffer for transport channels that will be directly converted with the CLDFB */ Word32 *p_data_f_fx[MAX_CLDFB_DIGEST_CHANNELS]; + Word16 i; - IF( st_ivas->hTcBuffer ) + FOR( i = 0; i < MAX_CLDFB_DIGEST_CHANNELS; i++ ) + { + set_zero_fx( data_f_fx[i], MAX_JBM_L_FRAME48k ); + } + if ( st_ivas->hTcBuffer ) { st_ivas->hTcBuffer->q_tc_fx = 11; + move16(); } - IF( st_ivas->hSpar ) + if ( st_ivas->hSpar ) { st_ivas->hSpar->hMdDec->Q_mixer_mat = 31; + move16(); } Word16 n, n_render_timeslots; @@ -2305,6 +2337,7 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( } n_render_timeslots = idiv1616( st_ivas->hTcBuffer->n_samples_available, st_ivas->hTcBuffer->n_samples_granularity ); + test(); IF( EQ_16( st_ivas->hTcBuffer->tc_buffer_mode, TC_BUFFER_MODE_BUFFER ) ) { ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); @@ -2325,6 +2358,7 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( /* Rendering */ IF( EQ_16( st_ivas->ism_mode, ISM_MODE_PARAM ) ) { + test(); test(); 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 ) ) @@ -2349,7 +2383,7 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( IF( st_ivas->hSCE[0] ) { Word16 shift = getScaleFactor32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN ); - IF( LT_16( sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ), 4 ) ) + if ( LT_16( sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ), 4 ) ) { shift = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, 4 ); } @@ -2387,13 +2421,15 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( { IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ) { - n_render_timeslots *= ( st_ivas->hTcBuffer->n_samples_granularity / st_ivas->hSpatParamRendCom->slot_size ); + Word16 temp, temp_e; + temp = BASOP_Util_Divide1616_Scale( st_ivas->hTcBuffer->n_samples_granularity, st_ivas->hSpatParamRendCom->slot_size, &temp_e ); + n_render_timeslots = extract_l( L_shr( L_mult0( n_render_timeslots, temp ), sub( 15, temp_e ) ) ); } IF( st_ivas->hSCE[0] ) { Word16 shift = getScaleFactor32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN ); - IF( LT_16( sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ), 4 ) ) + if ( LT_16( sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ), 4 ) ) { shift = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, 4 ); } @@ -2410,7 +2446,7 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( IF( st_ivas->hSCE[0] ) { Word16 shift = getScaleFactor32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN ); - IF( LT_16( sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ), 4 ) ) + if ( LT_16( sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ), 4 ) ) { shift = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, 4 ); } @@ -2422,6 +2458,7 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( } ELSE IF( EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) { + test(); IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) { n_render_timeslots = i_mult( n_render_timeslots, idiv1616( st_ivas->hTcBuffer->n_samples_granularity, st_ivas->hSpatParamRendCom->slot_size ) ); @@ -2430,12 +2467,13 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( IF( st_ivas->hSCE[0] ) { Word16 shift = getScaleFactor32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN ); - IF( LT_16( sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ), 4 ) ) + if ( LT_16( sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ), 4 ) ) { shift = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, 4 ); } scale_sig32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, shift ); st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ); + move16(); } ivas_sba_dec_digest_tc_fx( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); @@ -2458,27 +2496,33 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( { Word16 nchan_transport = st_ivas->nchan_transport; + move16(); Word16 nchan_out_transport = add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ); Word16 nchan_out_cov; - IF( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) + test(); + test(); + IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { nchan_out_cov = add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ); } - ELSE IF( st_ivas->hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_CLDFB ) + ELSE IF( EQ_16( st_ivas->hParamMC->synthesis_conf, PARAM_MC_SYNTH_LS_CONV_CLDFB ) ) { nchan_out_cov = nchan_out_transport; + move16(); } - ELSE IF( st_ivas->hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || st_ivas->hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) + ELSE IF( EQ_16( st_ivas->hParamMC->synthesis_conf, PARAM_MC_SYNTH_LS_CONV_COV ) || EQ_16( st_ivas->hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) { - nchan_out_cov = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; + nchan_out_cov = add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ); } ELSE { nchan_out_cov = nchan_out_transport; + move16(); } scale_sig32( st_ivas->hParamMC->proto_matrix_int_fx, st_ivas->hParamMC->proto_matrix_int_len, -1 ); st_ivas->hParamMC->proto_matrix_int_e = 1; + move16(); ivas_param_mc_dec_digest_tc_fx( st_ivas, (UWord8) n_render_timeslots, (Word32 **) p_data_f_fx, Q11 ); @@ -2490,10 +2534,12 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( shift = getScaleFactor32( st_ivas->hParamMC->h_output_synthesis_cov_state.cx_old_fx[param_band_idx], s_min( st_ivas->hParamMC->h_output_synthesis_cov_state.cx_old_len, nchan_transport * nchan_transport ) ); scale_sig32( st_ivas->hParamMC->h_output_synthesis_cov_state.cx_old_fx[param_band_idx], s_min( st_ivas->hParamMC->h_output_synthesis_cov_state.cx_old_len, nchan_transport * nchan_transport ), shift ); st_ivas->hParamMC->h_output_synthesis_cov_state.cx_old_e[param_band_idx] = sub( st_ivas->hParamMC->h_output_synthesis_cov_state.cx_old_e[param_band_idx], shift ); + move16(); shift = getScaleFactor32( st_ivas->hParamMC->h_output_synthesis_cov_state.cy_old_fx[param_band_idx], nchan_out_cov * nchan_out_cov ); scale_sig32( st_ivas->hParamMC->h_output_synthesis_cov_state.cy_old_fx[param_band_idx], nchan_out_cov * nchan_out_cov, shift ); st_ivas->hParamMC->h_output_synthesis_cov_state.cy_old_e[param_band_idx] = sub( st_ivas->hParamMC->h_output_synthesis_cov_state.cy_old_e[param_band_idx], shift ); + move16(); } } ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) ) @@ -2501,12 +2547,13 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( IF( st_ivas->hSCE[0] ) { Word16 shift = getScaleFactor32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN ); - IF( LT_16( sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ), 4 ) ) + if ( LT_16( sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ), 4 ) ) { shift = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, 4 ); } scale_sig32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, shift ); st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ); + move16(); } ivas_sba_dec_digest_tc_fx( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); } @@ -2701,7 +2748,7 @@ ivas_error ivas_jbm_dec_render_fx( move16(); output_config = st_ivas->hDecoderConfig->output_config; move32(); - nSamplesAskedLocal = nSamplesAsked + st_ivas->hTcBuffer->n_samples_discard; + nSamplesAskedLocal = add( (Word16) nSamplesAsked, st_ivas->hTcBuffer->n_samples_discard ); move16(); FOR( n = 0; n < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; n++ ) @@ -2740,6 +2787,7 @@ ivas_error ivas_jbm_dec_render_fx( { /* take the discard samples into account here to make sure head rotation stays on the correct 5ms grid */ st_ivas->hCombinedOrientationData->cur_subframe_samples_rendered_start = sub( st_ivas->hCombinedOrientationData->cur_subframe_samples_rendered_start, st_ivas->hTcBuffer->n_samples_discard ); + move16(); ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData ); } @@ -2791,6 +2839,7 @@ ivas_error ivas_jbm_dec_render_fx( ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_NON_DIEGETIC_DOWNMIX ) ) { *nSamplesRendered = s_min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); + move16(); ivas_apply_non_diegetic_panning_fx( p_output_fx, st_ivas->hDecoderConfig->non_diegetic_pan_gain_fx, *nSamplesRendered ); } ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_PARAM_ISM ) || EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) @@ -2807,6 +2856,7 @@ ivas_error ivas_jbm_dec_render_fx( ELSE /* ISM_MODE_DISC */ { *nSamplesRendered = s_min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); + move16(); test(); test(); @@ -2928,6 +2978,7 @@ ivas_error ivas_jbm_dec_render_fx( IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_DEC ) ) { *nSamplesRendered = s_min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); + move16(); FOR( n = 0; n < nchan_remapped; n++ ) { Copy32( st_ivas->hTcBuffer->tc_fx[n] + st_ivas->hTcBuffer->n_samples_rendered, p_output_fx[n], *nSamplesRendered ); @@ -2947,6 +2998,7 @@ ivas_error ivas_jbm_dec_render_fx( SPAR_DEC_HANDLE hSpar; hSpar = st_ivas->hSpar; hSpar->hMdDec->Q_mixer_mat = 30; + move16(); IF( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx, 960 ) ) != IVAS_ERR_OK ) { @@ -2994,6 +3046,7 @@ ivas_error ivas_jbm_dec_render_fx( SPAR_DEC_HANDLE hSpar; hSpar = st_ivas->hSpar; hSpar->hMdDec->Q_mixer_mat = 30; + move16(); IF( ( error = ivas_osba_dirac_td_binaural_jbm_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx, 960 ) ) != IVAS_ERR_OK ) { @@ -3003,6 +3056,7 @@ ivas_error ivas_jbm_dec_render_fx( ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_OSBA_STEREO ) ) { *nSamplesRendered = s_min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); + move16(); test(); /* shift SBA channels to avoid overwrite by ISM upmix in 1 object case and non-TSM unified channel memory*/ @@ -3035,6 +3089,7 @@ ivas_error ivas_jbm_dec_render_fx( SPAR_DEC_HANDLE hSpar; hSpar = st_ivas->hSpar; hSpar->hMdDec->Q_mixer_mat = 30; + move16(); IF( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, &p_output_fx[st_ivas->nchan_ism], 960 ) ) != IVAS_ERR_OK ) { @@ -3071,7 +3126,7 @@ ivas_error ivas_jbm_dec_render_fx( IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) { - FOR( n = st_ivas->hIntSetup.nchan_out_woLFE - 1; n >= 0; n-- ) + FOR( n = sub( st_ivas->hIntSetup.nchan_out_woLFE, 1 ); n >= 0; n-- ) { Copy32( p_output_fx[n], p_output_fx[n + st_ivas->nchan_ism], *nSamplesRendered ); } @@ -3164,6 +3219,7 @@ ivas_error ivas_jbm_dec_render_fx( ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_MC ) ) { *nSamplesRendered = s_min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); + move16(); ivas_ls_setup_conversion_fx( st_ivas, st_ivas->nchan_transport, *nSamplesRendered, p_tc_fx, p_output_fx ); } @@ -3219,7 +3275,9 @@ ivas_error ivas_jbm_dec_render_fx( set16_fx( channel_active_fx, 0, MAX_CICP_CHANNELS ); Word16 nchan_transport_tmp = st_ivas->nchan_transport; + move16(); output_Fs = st_ivas->hDecoderConfig->output_Fs; + move32(); Word16 nchan_out_transport = add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ); test(); test(); @@ -3251,15 +3309,13 @@ ivas_error ivas_jbm_dec_render_fx( move16(); set16_fx( channel_active_fx, 1, nchan_out_cov ); } - // ftf for ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx - // ftf changes IF( st_ivas->hParamMC->max_band_decorr > 0 ) { - // ftf for ivas_dirac_dec_decorr_process_fx Word16 tmp; tmp = L_norm_arr( st_ivas->hParamMC->h_freq_domain_decorr_ap_state->decorr_buffer_fx, st_ivas->hParamMC->h_freq_domain_decorr_ap_state->decorr_buffer_len ); scale_sig32( st_ivas->hParamMC->h_freq_domain_decorr_ap_state->decorr_buffer_fx, st_ivas->hParamMC->h_freq_domain_decorr_ap_state->decorr_buffer_len, tmp ); st_ivas->hParamMC->h_freq_domain_decorr_ap_state->q_decorr_buffer = add( st_ivas->hParamMC->h_freq_domain_decorr_ap_state->q_decorr_buffer, tmp ); + move16(); } /* CLDFB synthesis */ FOR( Word16 ch = 0; ch < nchan_out_cldfb; ch++ ) @@ -3275,15 +3331,15 @@ ivas_error ivas_jbm_dec_render_fx( Word16 tempp; FOR( Word16 param_band_idx = 0; param_band_idx < st_ivas->hParamMC->num_param_bands_synth; param_band_idx++ ) { - tempp = getScaleFactor32( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx[param_band_idx], nchan_transport * nchan_out_cov ); - scale_sig32( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx[param_band_idx], nchan_transport * nchan_out_cov, tempp ); + tempp = getScaleFactor32( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx[param_band_idx], imult1616( nchan_transport, nchan_out_cov ) ); + scale_sig32( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx[param_band_idx], imult1616( nchan_transport, nchan_out_cov ), tempp ); st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp[param_band_idx] = sub( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp[param_band_idx], tempp ); move16(); - IF( st_ivas->hParamMC->band_grouping[param_band_idx] < st_ivas->hParamMC->h_output_synthesis_params.max_band_decorr ) + IF( LT_16( st_ivas->hParamMC->band_grouping[param_band_idx], st_ivas->hParamMC->h_output_synthesis_params.max_band_decorr ) ) { - tempp = getScaleFactor32( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx[param_band_idx], nchan_transport * nchan_out_cov ); - scale_sig32( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx[param_band_idx], nchan_transport * nchan_out_cov, tempp ); + tempp = getScaleFactor32( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx[param_band_idx], imult1616( nchan_transport, nchan_out_cov ) ); + scale_sig32( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx[param_band_idx], imult1616( nchan_transport, nchan_out_cov ), tempp ); st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp[param_band_idx] = sub( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp[param_band_idx], tempp ); move16(); } @@ -3304,11 +3360,11 @@ ivas_error ivas_jbm_dec_render_fx( { IF( LT_16( st_ivas->hParamMC->band_grouping[param_band_idx], st_ivas->hParamMC->h_output_synthesis_params.max_band_decorr ) ) { - Copy32( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old_fx[param_band_idx], nchan_transport_tmp * nchan_out_cov ); + Copy32( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old_fx[param_band_idx], imult1616( nchan_transport_tmp, nchan_out_cov ) ); st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old_exp[param_band_idx] = st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp[param_band_idx]; move16(); } - Copy32( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_old_fx[param_band_idx], nchan_transport_tmp * nchan_out_cov ); + Copy32( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_old_fx[param_band_idx], imult1616( nchan_transport_tmp, nchan_out_cov ) ); st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_old_exp[param_band_idx] = st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp[param_band_idx]; move16(); } @@ -3370,7 +3426,7 @@ ivas_error ivas_jbm_dec_render_fx( Copy32( st_ivas->hTcBuffer->tc_fx[LFE_CHANNEL] + offset, p_output_fx[LFE_CHANNEL], *nSamplesRendered ); Copy32( st_ivas->hTcBuffer->tc_fx[LFE_CHANNEL - 1] + offset, p_output_fx[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); } - ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && EQ_16( st_ivas->hOutSetup.num_lfe, 0 ) ) + ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && st_ivas->hOutSetup.num_lfe == 0 ) { /* Delay the separated channel to sync with the DirAC rendering */ Copy32( st_ivas->hTcBuffer->tc_fx[LFE_CHANNEL - 1] + offset, p_output_fx[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); @@ -3978,6 +4034,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( move16(); move16(); move16(); + move16(); FOR( ch_idx = 0; ch_idx < MAX_CICP_CHANNELS; ch_idx++ ) { @@ -4425,9 +4482,13 @@ ivas_error ivas_jbm_dec_set_discard_samples( #ifdef IVAS_FLOAT_FIXED { Word16 nMaxSlotsPerSubframe, nSlotsInFirstSubframe; - + Word16 temp, temp_e; /* render first frame with front zero padding and discarding those samples */ - nMaxSlotsPerSubframe = (Word16) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / st_ivas->hTcBuffer->n_samples_granularity; + // nMaxSlotsPerSubframe = (Word16)(st_ivas->hDecoderConfig->output_Fs / (FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES)) / st_ivas->hTcBuffer->n_samples_granularity; + temp = BASOP_Util_Divide3232_Scale( st_ivas->hDecoderConfig->output_Fs, ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ), &temp_e ); + temp = shr( temp, sub( 15, temp_e ) ); + nMaxSlotsPerSubframe = BASOP_Util_Divide1616_Scale( temp, st_ivas->hTcBuffer->n_samples_granularity, &temp_e ); + nMaxSlotsPerSubframe = shr( nMaxSlotsPerSubframe, sub( 15, temp_e ) ); nSlotsInFirstSubframe = sub( nMaxSlotsPerSubframe, st_ivas->hTcBuffer->subframe_nbslots[sub( st_ivas->hTcBuffer->nb_subframes, 1 )] ); IF( nSlotsInFirstSubframe > 0 ) { @@ -4508,9 +4569,10 @@ void ivas_jbm_dec_get_adapted_linear_interpolator_fx( { Word16 jbm_segment_len, idx; Word16 dec_fx; + Word16 dec_e; jbm_segment_len = shr( default_interp_length, 1 ); - dec_fx = 32767 / default_interp_length; + dec_fx = divide1616( 1, default_interp_length ); /*32767 / default_interp_length*/ move16(); interpolator_fx[interp_length - 1] = 32767; @@ -4521,11 +4583,13 @@ void ivas_jbm_dec_get_adapted_linear_interpolator_fx( IF( GT_16( interpolator_fx[idx + 1], 0 ) ) { - dec_fx = interpolator_fx[idx + 1] / ( jbm_segment_len + 1 ); + dec_fx = BASOP_Util_Divide1616_Scale( interpolator_fx[idx + 1], add( jbm_segment_len, 1 ), &dec_e ); + dec_fx = shr( dec_fx, sub( 15, dec_e ) ); move16(); FOR( ; idx >= 0; idx-- ) { interpolator_fx[idx] = sub( interpolator_fx[idx + 1], dec_fx ); + move16(); } } ELSE @@ -4552,7 +4616,8 @@ void ivas_jbm_dec_get_adapted_subframes( { UWord16 nSlotsInLastSubframe, nSlotsInFirstSubframe; UWord16 nCldfbSlotsLocal = nCldfbTs; - + move16(); + Word16 temp, temp_e; /* get last subframe size from previous frame, determine how many slots have to be processed in the first subframe (i.e. potential leftover of a 5ms subframe) */ nSlotsInFirstSubframe = ( sub( PARAM_MC_MAX_NSLOTS_IN_SUBFRAME, subframe_nbslots[*nb_subframes - 1] ) ); @@ -4565,9 +4630,11 @@ void ivas_jbm_dec_get_adapted_subframes( nCldfbSlotsLocal = sub( nCldfbSlotsLocal, nSlotsInFirstSubframe ); } - *nb_subframes = add( *nb_subframes, ( nCldfbSlotsLocal + PARAM_MC_MAX_NSLOTS_IN_SUBFRAME - 1 ) / PARAM_MC_MAX_NSLOTS_IN_SUBFRAME ); + temp = BASOP_Util_Divide3232_Scale( L_add( nCldfbSlotsLocal, PARAM_MC_MAX_NSLOTS_IN_SUBFRAME - 1 ), PARAM_MC_MAX_NSLOTS_IN_SUBFRAME, &temp_e ); + *nb_subframes = add( *nb_subframes, shr( temp, sub( 15, temp_e ) ) ); move16(); nSlotsInLastSubframe = nCldfbSlotsLocal % PARAM_MC_MAX_NSLOTS_IN_SUBFRAME; + move16(); set16_fx( subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS ); set16_fx( subframe_nbslots, PARAM_MC_MAX_NSLOTS_IN_SUBFRAME, *nb_subframes ); @@ -4643,32 +4710,38 @@ void ivas_jbm_dec_get_md_map( { Word16 jbm_segment_len, map_idx, src_idx, src_idx_map; Word32 dec_fx, src_idx_fx; - + Word16 temp_e; + Word16 temp; jbm_segment_len = shr( default_len, 1 ); - // dec = 1.0f / default_len; - FOR( ( map_idx = len - 1, src_idx = default_len - 1 ); map_idx >= jbm_segment_len; ( map_idx--, src_idx-- ) ) + FOR( ( map_idx = sub( len, 1 ), src_idx = sub( default_len, 1 ) ); map_idx >= jbm_segment_len; ( map_idx--, src_idx-- ) ) { - src_idx_map = s_max( 0, src_idx / subframe_len ); - map[map_idx] = ( offset + src_idx_map ) % buf_len; + temp = BASOP_Util_Divide1616_Scale( src_idx, subframe_len, &temp_e ); + temp = shr( temp, sub( 15, temp_e ) ); + src_idx_map = s_max( 0, temp ); + map[map_idx] = add( offset, src_idx_map ) % buf_len; + move16(); } /* changed part (first segment), interpolate index to parameters (we do not want to interpolate and smooth acutal direction/diffuseness values even more) */ IF( src_idx >= 0 ) { - dec_fx = L_shl( src_idx + 1, 16 ) / jbm_segment_len; - src_idx_fx = L_shl( src_idx + 1, 16 ) - dec_fx; + dec_fx = BASOP_Util_Divide3232_Scale( L_shl( add( src_idx, 1 ), 16 ), jbm_segment_len, &temp_e ); + dec_fx = L_shr( dec_fx, sub( 15, temp_e ) ); + src_idx_fx = L_sub( L_shl( add( src_idx, 1 ), 16 ), dec_fx ); FOR( ; map_idx >= 0; map_idx-- ) { - src_idx = s_max( 0, round_fx( src_idx_fx ) / subframe_len ); - map[map_idx] = ( offset + src_idx ) % buf_len; + temp = BASOP_Util_Divide1616_Scale( round_fx( src_idx_fx ), subframe_len, &temp_e ); + temp = shr( temp, sub( 15, temp_e ) ); + src_idx = s_max( 0, temp ); + map[map_idx] = add( offset, src_idx ) % buf_len; src_idx_fx -= dec_fx; } } ELSE { - set16_fx( map, offset, map_idx + 1 ); + set16_fx( map, offset, add( map_idx, 1 ) ); } return; @@ -4737,28 +4810,37 @@ void ivas_jbm_dec_get_md_map_even_spacing( Word16 subframe_map_length[MAX_PARAM_SPATIAL_SUBFRAMES]; /* subframe map length */ - sf_length = len / subframe_len; + sf_length = idiv1616( len, subframe_len ); IF( len % subframe_len == 0 ) { /* even subframes */ FOR( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) { subframe_map_length[sf_idx] = sf_length; + move16(); } } ELSE { /* uneven subframes */ - decimal_fx = L_sub( ( L_shl( len, 16 ) / subframe_len ), L_shl( sf_length, 16 ) ); + Word32 temp; + Word16 temp_e; + temp = BASOP_Util_Divide3232_Scale( L_shl( len, 16 ), subframe_len, &temp_e ); + temp = L_shr( temp, sub( 15, temp_e ) ); + decimal_fx = L_sub( temp, L_shl( sf_length, 16 ) ); decimal_sum_fx = decimal_fx; + eps_fx = 65; + move32(); + move32(); FOR( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) { - increment = (Word16) L_shr( decimal_sum_fx + eps_fx, 16 ); - subframe_map_length[sf_idx] = sf_length + increment; + increment = extract_l( L_shr( L_add( decimal_sum_fx, eps_fx ), 16 ) ); + subframe_map_length[sf_idx] = add( sf_length, increment ); + move16(); IF( increment > 0 ) { - decimal_sum_fx = L_sub( decimal_sum_fx, ( 1 << 16 ) ); + decimal_sum_fx = L_sub( decimal_sum_fx, ONE_IN_Q16 ); } decimal_sum_fx = L_add( decimal_sum_fx, decimal_fx ); } @@ -4771,11 +4853,12 @@ void ivas_jbm_dec_get_md_map_even_spacing( move16(); FOR( map_idx = 0; map_idx < len; map_idx++ ) { - map[map_idx] = ( offset + sf_idx ) % buf_len; - IF( map_idx - subframes_written >= subframe_map_length[sf_idx] - 1 ) + map[map_idx] = add( offset, sf_idx ) % buf_len; + move16(); + IF( GE_16( sub( map_idx, subframes_written ), sub( subframe_map_length[sf_idx], 1 ) ) ) { - subframes_written += subframe_map_length[sf_idx]; - ++sf_idx; + subframes_written = add( subframes_written, subframe_map_length[sf_idx] ); + sf_idx = add( sf_idx, 1 ); } } @@ -4844,7 +4927,7 @@ void ivas_jbm_dec_get_md_map_even_spacing( * * Get the number of transport channels provided by the JBM transport channel decode function *--------------------------------------------------------------------------*/ - +#ifndef IVAS_FLOAT_FIXED int16_t ivas_jbm_dec_get_num_tc_channels( Decoder_Struct *st_ivas /* i : IVAS decoder handle */ ) @@ -4985,6 +5068,7 @@ int16_t ivas_jbm_dec_get_num_tc_channels( return num_tc; } +#endif // !IVAS_FLOAT_FIXED #ifdef IVAS_FLOAT_FIXED @@ -5028,7 +5112,7 @@ Word16 ivas_jbm_dec_get_num_tc_channels_fx( } ELSE IF( EQ_16( st_ivas->ivas_format, ISM_FORMAT ) ) { - IF( EQ_16( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) ) + if ( EQ_16( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) ) { num_tc = 1; move16(); @@ -5064,7 +5148,7 @@ Word16 ivas_jbm_dec_get_num_tc_channels_fx( } IF( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) ) { - IF( EQ_16( num_tc, 3 ) ) + if ( EQ_16( num_tc, 3 ) ) { num_tc = add( num_tc, 1 ); } @@ -5089,17 +5173,18 @@ Word16 ivas_jbm_dec_get_num_tc_channels_fx( { test(); test(); - IF( st_ivas->sba_dirac_stereo_flag ) + if ( st_ivas->sba_dirac_stereo_flag ) { num_tc = CPE_CHANNELS; move16(); } test(); - IF( ( st_ivas->sba_planar && GE_16( num_tc, 3 ) ) || EQ_16( num_tc, 3 ) ) + test(); + if ( ( st_ivas->sba_planar && GE_16( num_tc, 3 ) ) || EQ_16( num_tc, 3 ) ) { num_tc = add( num_tc, 1 ); } - IF( EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) + if ( EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) { num_tc = add( num_tc, st_ivas->nchan_ism ); } @@ -5126,7 +5211,7 @@ Word16 ivas_jbm_dec_get_num_tc_channels_fx( test(); IF( NE_16( st_ivas->transport_config, st_ivas->intern_config ) && ( EQ_16( st_ivas->intern_config, IVAS_AUDIO_CONFIG_FOA ) || EQ_16( st_ivas->intern_config, IVAS_AUDIO_CONFIG_HOA2 ) || EQ_16( st_ivas->intern_config, IVAS_AUDIO_CONFIG_HOA3 ) ) ) { - IF( GE_16( add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ), add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe ) ) ) + if ( GE_16( add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ), add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe ) ) ) { num_tc = add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe ); } @@ -5143,7 +5228,7 @@ Word16 ivas_jbm_dec_get_num_tc_channels_fx( } ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) ) { - IF( st_ivas->hOutSetup.separateChannelEnabled ) + if ( st_ivas->hOutSetup.separateChannelEnabled ) { num_tc = add( num_tc, 1 ); } @@ -5153,6 +5238,7 @@ Word16 ivas_jbm_dec_get_num_tc_channels_fx( test(); test(); test(); + test(); IF( st_ivas->hOutSetup.separateChannelEnabled && ( EQ_16( output_config, IVAS_AUDIO_CONFIG_5_1 ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_7_1 ) || 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_5_1_2 ) || ( EQ_16( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && st_ivas->hOutSetup.num_lfe > 0 ) ) ) @@ -5199,6 +5285,8 @@ static void ivas_jbm_dec_copy_tc( hTcBuffer->n_samples_available = i_mult( hTcBuffer->n_samples_granularity, idiv1616( hTcBuffer->n_samples_buffered, hTcBuffer->n_samples_granularity ) ); *nSamplesResidual = sub( hTcBuffer->n_samples_buffered, hTcBuffer->n_samples_available ); move16(); + move16(); + move16(); n_ch_full_copy = s_min( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); n_ch_res_copy = sub( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); @@ -5209,6 +5297,7 @@ static void ivas_jbm_dec_copy_tc( FOR( m = 0; m < nSamplesForRendering; m++ ) { hTcBuffer->tc_fx[ch][n_samples_still_available + hTcBuffer->n_samples_discard + m] = data[m * st_ivas->hTcBuffer->nchan_transport_jbm + ch]; + move32(); } } @@ -5220,6 +5309,7 @@ static void ivas_jbm_dec_copy_tc( FOR( m = 0; m < nSamplesForRendering; m++ ) { tc_digest_f[ch][add( n_samples_still_available, m )] = data[add( imult1616( m, st_ivas->hTcBuffer->nchan_transport_jbm ), ch )]; + move32(); } Copy32( tc_digest_f[ch] + hTcBuffer->n_samples_available, hTcBuffer->tc_fx[ch], *nSamplesResidual ); } @@ -5293,6 +5383,7 @@ static void ivas_jbm_dec_copy_tc( *--------------------------------------------------------------------------*/ /*! r: render granularity */ +#ifndef IVAS_FLOAT_FIXED int16_t ivas_jbm_dec_get_render_granularity_flt( const RENDERER_TYPE rendererType, /* i : renderer type */ const IVAS_FORMAT ivas_format, /* i : ivas format */ @@ -5320,6 +5411,8 @@ int16_t ivas_jbm_dec_get_render_granularity_flt( return render_granularity; } +#endif // !IVAS_FLOAT_FIXED + #ifdef IVAS_FLOAT_FIXED Word16 ivas_jbm_dec_get_render_granularity( @@ -5338,18 +5431,17 @@ Word16 ivas_jbm_dec_get_render_granularity( test(); IF( ( EQ_32( ivas_format, MC_FORMAT ) ) && ( EQ_32( mc_mode, MC_MODE_PARAMUPMIX ) ) ) { - render_granularity = NS2SA( output_Fs, CLDFB_SLOT_NS ); + render_granularity = NS2SA_FX2( output_Fs, CLDFB_SLOT_NS ); } ELSE { - render_granularity = NS2SA( output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); + render_granularity = NS2SA_FX2( output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); } } ELSE { - render_granularity = NS2SA( output_Fs, CLDFB_SLOT_NS ); + render_granularity = NS2SA_FX2( output_Fs, CLDFB_SLOT_NS ); } - move16(); return render_granularity; } @@ -5511,6 +5603,7 @@ ivas_error ivas_jbm_dec_tc_buffer_open_fx( } hTcBuffer->tc_buffer_mode = tc_buffer_mode; + move16(); hTcBuffer->nchan_transport_jbm = nchan_transport_jbm; move16(); hTcBuffer->nchan_transport_internal = nchan_transport_internal; @@ -5544,6 +5637,7 @@ ivas_error ivas_jbm_dec_tc_buffer_open_fx( nMaxSlotsPerSubframe = shr( tmp, sub( 15, tmp_e ) ); // Q0 hTcBuffer->num_slots = mult0( nMaxSlotsPerSubframe, MAX_PARAM_SPATIAL_SUBFRAMES ); + move16(); set16_fx( hTcBuffer->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS ); set16_fx( hTcBuffer->subframe_nbslots, nMaxSlotsPerSubframe, MAX_PARAM_SPATIAL_SUBFRAMES ); @@ -5563,7 +5657,7 @@ ivas_error ivas_jbm_dec_tc_buffer_open_fx( Word32 offset; IF( st_ivas->hDecoderConfig->Opt_tsm ) { - n_samp_full = ( NS2SA( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS ) + hTcBuffer->n_samples_granularity - 1 ); + n_samp_full = add( NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS ), sub( hTcBuffer->n_samples_granularity, 1 ) ); n_samp_residual = sub( hTcBuffer->n_samples_granularity, 1 ); } ELSE @@ -5762,12 +5856,12 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx( { Word16 nMaxSlotsPerSubframeNew; - nMaxSlotsPerSubframeNew = (Word16) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / n_samples_granularity; + nMaxSlotsPerSubframeNew = idiv1616( divide3216( st_ivas->hDecoderConfig->output_Fs, ( ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) >> 1 ) ), n_samples_granularity ); /* if samples were flushed, take that into account here */ test(); - IF( LT_16( n_samples_granularity, hTcBuffer->n_samples_granularity ) && GT_16( hTcBuffer->n_samples_flushed, 0 ) ) + IF( LT_16( n_samples_granularity, hTcBuffer->n_samples_granularity ) && hTcBuffer->n_samples_flushed > 0 ) { - hTcBuffer->subframe_nbslots[hTcBuffer->subframes_rendered - 1] = hTcBuffer->n_samples_flushed / n_samples_granularity; + hTcBuffer->subframe_nbslots[hTcBuffer->subframes_rendered - 1] = idiv1616( hTcBuffer->n_samples_flushed, n_samples_granularity ); hTcBuffer->n_samples_flushed = 0; move16(); move16(); @@ -5800,17 +5894,17 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx( IF( st_ivas->hDecoderConfig->Opt_tsm ) { - n_samp_full = ( add( NS2SA( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS ), sub( hTcBuffer->n_samples_granularity, 1 ) ) ); + n_samp_full = ( add( NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS ), sub( hTcBuffer->n_samples_granularity, 1 ) ) ); n_samp_residual = sub( hTcBuffer->n_samples_granularity, 1 ); } ELSE { - n_samp_full = (Word16) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); + n_samp_full = extract_l( Mult_32_16( st_ivas->hDecoderConfig->output_Fs, INV_FRAME_PER_SEC_Q15 ) ); n_samp_residual = 0; move16(); } - nsamp_to_allocate = hTcBuffer->nchan_buffer_full * n_samp_full; - nsamp_to_allocate = add( nsamp_to_allocate, nchan_residual * n_samp_residual ); + nsamp_to_allocate = imult1616( hTcBuffer->nchan_buffer_full, n_samp_full ); + nsamp_to_allocate = add( nsamp_to_allocate, imult1616( nchan_residual, n_samp_residual ) ); IF( nsamp_to_allocate == 0 ) { @@ -5849,18 +5943,16 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx( } hTcBuffer->tc_buff_len = nsamp_to_allocate; - // set_zero( hTcBuffer->tc_buffer, nsamp_to_allocate ); + move16(); offset = 0; move16(); FOR( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) { - // hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; offset = add( offset, n_samp_full ); } FOR( ; ch_idx < hTcBuffer->nchan_transport_internal; ch_idx++ ) { - // hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; offset = add( offset, n_samp_residual ); } } @@ -6066,18 +6158,20 @@ void ivas_jbm_dec_td_renderers_adapt_subframes( tmp = div_s( tmp1, tmp2 ); st_ivas->hTcBuffer->nb_subframes = add( st_ivas->hTcBuffer->nb_subframes, ceil_fx16( tmp, sub( 15, sub( s2, s1 ) ) ) ); + move16(); nSlotsInLastSubframe = nSlotsAvailable % nMaxSlotsPerSubframe; + move16(); set16_fx( st_ivas->hTcBuffer->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS ); set16_fx( st_ivas->hTcBuffer->subframe_nbslots, nMaxSlotsPerSubframe, st_ivas->hTcBuffer->nb_subframes ); - IF( nSlotsInFirstSubframe > 0 ) + if ( nSlotsInFirstSubframe > 0 ) { st_ivas->hTcBuffer->subframe_nbslots[0] = nSlotsInFirstSubframe; move16(); } - IF( nSlotsInLastSubframe > 0 ) + if ( nSlotsInLastSubframe > 0 ) { st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1] = nSlotsInLastSubframe; move16(); @@ -6198,7 +6292,7 @@ TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( } BREAK; case RENDERER_MC: - IF( NE_16( ivas_jbm_dec_get_num_tc_channels( st_ivas ), st_ivas->hDecoderConfig->nchan_out ) ) + if ( NE_16( ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ), st_ivas->hDecoderConfig->nchan_out ) ) { buffer_mode = TC_BUFFER_MODE_RENDERER; move16(); @@ -6436,7 +6530,6 @@ void ivas_jbm_dec_copy_tc_no_tsm_fx( { Word32 *cldfb_real_buffer_fx; Word32 *cldfb_imag_buffer_fx; - // Word16 cldfb_real_e, cldfb_imag_e; Word16 cldfb_ch, slot_idx, num_freq_bands; cldfb_real_buffer_fx = NULL; @@ -6447,10 +6540,9 @@ void ivas_jbm_dec_copy_tc_no_tsm_fx( IF( EQ_16( (Word16) st_ivas->ivas_format, (Word16) ISM_FORMAT ) ) { cldfb_real_buffer_fx = st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx; - // cldfb_real_e = st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_exp; cldfb_imag_buffer_fx = st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx; - // cldfb_imag_e = st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_exp; num_freq_bands = st_ivas->hSpatParamRendCom->num_freq_bands; + move16(); ivas_ism_param_dec_tc_gain_ajust_fx( st_ivas, output_frame, output_frame / 2, tc_fx, &Q_tc ); Scale_sig32( tc_fx[0], output_frame, sub( Q11, Q_tc ) ); /*keepeing tc_fx at Q11*/ @@ -6459,10 +6551,9 @@ void ivas_jbm_dec_copy_tc_no_tsm_fx( ELSE IF( EQ_16( (Word16) st_ivas->ivas_format, (Word16) MC_FORMAT ) ) { cldfb_real_buffer_fx = st_ivas->hParamMC->Cldfb_RealBuffer_tc_fx; - // cldfb_real_e = st_ivas->hParamMC->Cldfb_RealBuffer_tc_e; cldfb_imag_buffer_fx = st_ivas->hParamMC->Cldfb_ImagBuffer_tc_fx; - // cldfb_imag_e = st_ivas->hParamMC->Cldfb_ImagBuffer_tc_e; num_freq_bands = st_ivas->hParamMC->num_freq_bands; + move16(); } /* CLDFB Analysis*/ diff --git a/lib_dec/ivas_lfe_dec_fx.c b/lib_dec/ivas_lfe_dec_fx.c index 0b38566e1a8a697d32cd54b8e65981d9298a2353..a3453ac537f656c6de7c7654daaffc59faf9123b 100644 --- a/lib_dec/ivas_lfe_dec_fx.c +++ b/lib_dec/ivas_lfe_dec_fx.c @@ -476,16 +476,37 @@ ivas_error ivas_create_lfe_dec_fx( hLFE->bfi_count = 0; move16(); - output_fs_fx = NE_32( output_Fs, 48000 ) ? ( NE_32( output_Fs, 32000 ) ? FS_16K_IN_NS_Q31 : FS_32K_IN_NS_Q31 ) : FS_48K_IN_NS_Q31; + IF( NE_32( output_Fs, 48000 ) ) + { + IF( NE_32( output_Fs, 32000 ) ) + { + output_fs_fx = FS_16K_IN_NS_Q31; + } + ELSE + { + output_fs_fx = FS_32K_IN_NS_Q31; + } + } + ELSE + { + output_fs_fx = FS_48K_IN_NS_Q31; + } move32(); 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 ); + hLFE->lfe_addl_delay = add( (Word16) L_shr( imult3216( output_Fs, lfe_addl_delay_s ), 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 ) ) ); + IF( add_delay_sa == 0 ) + { + hLFE->lfe_block_delay_s_fx = add( hLFE->lfe_block_delay_s_fx, lfe_addl_delay_s ); + } + ELSE + { + hLFE->lfe_block_delay_s_fx = add( hLFE->lfe_block_delay_s_fx, add( lfe_addl_delay_s, idiv1616( add_delay_sa, extract_l( output_Fs ) ) ) ); + } move16(); IF( hLFE->lfe_addl_delay > 0 ) diff --git a/lib_dec/ivas_lfe_plc_fx.c b/lib_dec/ivas_lfe_plc_fx.c index 9737868308a38be0ebb7ba9e8b13e6872fa5ee55..007a099caea00ba131806f37e038c84955ba28e7 100644 --- a/lib_dec/ivas_lfe_plc_fx.c +++ b/lib_dec/ivas_lfe_plc_fx.c @@ -53,22 +53,11 @@ #else #define LFE_PLC_LPCORD ( MAX_LP_FILTER_ORDER ) #endif -#define LFE_PLC_MAXITER ( 10 ) -#ifndef IVAS_FLOAT_FIXED -#define POW_THR ( 1.0e-8f ) -#endif +#define LFE_PLC_MAXITER ( 10 ) #define LFE_PLC_RECLEN_48K ( ( IVAS_LFE_NUM_COEFFS_IN_SUBGRP + 1 ) * L_FRAME48k / IVAS_LFE_NUM_COEFFS_IN_SUBGRP + LFE_PLC_FDEL ) #define LFE_PLC_RECLEN ( ( LFE_PLC_RECLEN_48K / LFE_PLC_DSF ) ) #define LFE_PLC_MUTE_THR ( 10 ) -#ifdef NONE_BE_FIX_816_LFE_PLC_FLOAT -#define LFE_PLC_BURST_ATT ( powf( powf( 10.0f, -3.0f / 20.0f ), 1.0f / ( LFE_PLC_FS * 20 / 1000 ) ) ) /* attenuate 3dB per frame starting with 10th consecutive loss */ -#define EPS_STOP 1e-5f -#define MAX_LEN_LP 960 -#else -#define MAX_LEN_LP 960 -#define LFE_PLC_BURST_ATT ( pow( pow( 10.0, -3.0 / 20.0 ), 1.0 / ( LFE_PLC_FS * 0.02 ) ) ) /* attenuate 3dB per frame starting with 10th consecutive loss */ -#define EPS_STOP 1e-5 -#endif +#define MAX_LEN_LP 960 #ifdef IVAS_FLOAT_FIXED #define POW_THR_Q50 ( 11258999 ) #define EPS_STOP_Q31 ( 21475 ) @@ -480,6 +469,8 @@ static Word16 lfeplc_lev_dur_fx( s = r_fx[1]; s_q_fx = r_q_fx[1]; + move32(); + move16(); a_fx[1] = rc_fx[0]; move32(); @@ -495,7 +486,7 @@ static Word16 lfeplc_lev_dur_fx( move16(); WHILE( LT_16( i, m ) ) { - FOR( j = 1; j <= i / 2; j++ ) + FOR( j = 1; j <= shr( i, 1 ); j++ ) { l = sub( i, j ); exp1 = sub( norm_l( rc_fx[i - 1] ), 1 ); @@ -517,9 +508,10 @@ static Word16 lfeplc_lev_dur_fx( temp2 = Mpy_32_32( rc_fx[i - 1], a_fx[l] ); temp_q2 = sub( add( rc_q_fx[i - 1], a_q_fx[l] ), 31 ); - IF( temp2 == 0 ) + if ( temp2 == 0 ) { temp_q2 = 31; + move16(); } IF( LT_16( temp_q2, a_q_fx[j] ) ) @@ -537,9 +529,10 @@ static Word16 lfeplc_lev_dur_fx( temp2 = Mpy_32_32( rc_fx[i - 1], a_fx[j] ); temp_q2 = sub( add( rc_q_fx[sub( i, 1 )], a_q_fx[j] ), 31 ); - IF( temp2 == 0 ) + if ( temp2 == 0 ) { temp_q2 = 31; + move16(); } IF( LT_16( temp_q2, a_q_fx[l] ) ) @@ -569,9 +562,10 @@ static Word16 lfeplc_lev_dur_fx( exp2 = norm_l( s ); temp1 = Mpy_32_32( L_shl( rc_fx[sub( i, 1 )], exp1 ), L_shl( s, exp2 ) ); temp_q1 = sub( add( add( rc_q_fx[sub( i, 1 )], exp1 ), add( s_q_fx, exp2 ) ), 31 ); - IF( temp1 == 0 ) + if ( temp1 == 0 ) { temp_q1 = 31; + move16(); } IF( LT_16( temp_q1, err_q_fx ) ) @@ -599,12 +593,13 @@ static Word16 lfeplc_lev_dur_fx( exp2 = norm_l( a_fx[j] ); temp1 = Mpy_32_32( L_shl( r_fx[i - j], exp1 ), L_shl( a_fx[j], exp2 ) ); temp_q1 = sub( add( add( r_q_fx[i - j], exp1 ), add( a_q_fx[j], exp2 ) ), 31 ); - IF( temp1 == 0 ) + if ( temp1 == 0 ) { temp_q1 = 31; + move16(); } - IF( EQ_16( j, 0 ) ) + IF( j == 0 ) { s_fx = W_deposit32_l( temp1 ); s_q_fx = temp_q1; @@ -647,6 +642,8 @@ static Word16 lfeplc_lev_dur_fx( { a_out_fx[j] = a_fx[j]; a_out_q_fx[j] = a_q_fx[j]; + move32(); + move32(); } } } @@ -662,6 +659,8 @@ static Word16 lfeplc_lev_dur_fx( { a_out_fx[j] = a_fx[j]; a_out_q_fx[j] = a_q_fx[j]; + move32(); + move32(); } } } @@ -740,9 +739,10 @@ static Word16 d_a2rc_fx( exp2 = sub( norm_l( temp2 ), 1 ); temp = Mpy_32_32( L_shl( km_fx, exp1 ), L_shl( temp2, exp2 ) ); temp_q = sub( add( add( km_q_fx, exp1 ), add( temp_q2, exp2 ) ), 31 ); - IF( temp == 0 ) + if ( temp == 0 ) { temp_q = 31; + move16(); } IF( LT_16( temp_q, temp_q1 ) ) { @@ -763,9 +763,10 @@ static Word16 d_a2rc_fx( exp2 = sub( norm_l( temp1 ), 1 ); temp = Mpy_32_32( L_shl( km_fx, exp1 ), L_shl( temp1, exp2 ) ); temp_q = sub( add( add( km_q_fx, exp1 ), add( temp_q1, exp2 ) ), 31 ); - IF( temp == 0 ) + if ( temp == 0 ) { temp_q = 31; + move16(); } IF( LT_16( temp_q, temp_q2 ) ) { @@ -944,17 +945,19 @@ static Word16 check_stab_fx( move32(); amod_q_fx[i] = sub( add( add( a_q_fx[i], exp1 ), add( fac_q_fx, exp2 ) ), 31 ); move16(); - IF( amod_fx[i] == 0 ) + if ( amod_fx[i] == 0 ) { amod_q_fx[i] = 31; + move16(); } exp1 = norm_l( fac_fx ); exp2 = norm_l( fac1_fx ); fac_fx = Mpy_32_32( L_shl( fac_fx, exp1 ), L_shl( fac1_fx, exp2 ) ); fac_q_fx = sub( add( add( fac_q_fx, exp1 ), add( fac1_q_fx, exp2 ) ), 31 ); - IF( fac_fx == 0 ) + if ( fac_fx == 0 ) { fac_q_fx = 0; + move16(); } } stable = d_a2rc_fx( amod_fx, amod_q_fx, refl_fx, LFE_PLC_LPCORD ); @@ -1027,6 +1030,8 @@ static Word32 find_max_delta_fx( *delta_q_fx = sub( norm_l( eps_fx ), 1 ); delta_fx = L_shl( eps_fx, *delta_q_fx ); *delta_q_fx = add( eps_q_fx, *delta_q_fx ); + move16(); + move16(); exp1 = norm_l( eps_fx ); exp2 = norm_l( fac_fx ); @@ -1065,7 +1070,7 @@ static Word32 find_max_delta_fx( ELSE { temp = abs( eps_fx ); - IF( LT_32( L_shr( temp, sub( eps_q_fx, 31 ) ), EPS_STOP_Q31 ) ) + if ( LT_32( L_shr( temp, sub( eps_q_fx, 31 ) ), EPS_STOP_Q31 ) ) { BREAK; } @@ -1234,9 +1239,10 @@ static void recover_samples_fx( move32(); d_a_q_fx[i] = sub( add( d_a_q_fx[i], fac_q_fx ), 31 ); move16(); - IF( d_a_fx[i] == 0 ) + if ( d_a_fx[i] == 0 ) { d_a_q_fx[i] = 31; + move16(); } IF( LT_16( delta_q_fx, Q30 ) ) { @@ -1343,7 +1349,7 @@ void ivas_lfe_tdplc_fx( FOR( i = 0; i < 2; i++ ) { ivas_dct_windowing_fx( fade_len, full_len, dct_len, zero_pad_len, pWindow_coeffs_fx, output_frame, input_tda_fx, rec_frame_us_fx + plc_fdel, rec_frame_us_fx + add( add( plc_fdel, fade_len ), i_mult( i, dct_len ) ) ); - ivas_tda_fx( input_tda_fx, ytda + i * dct_len, dct_len ); + ivas_tda_fx( input_tda_fx, ytda + imult1616( i, dct_len ), dct_len ); } return; diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index ded33dcec8a7984a67ce4e0ed3e3736384c36fa4..b882eda3d4d85368e7645edce9d42d53586b5265 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -97,7 +97,7 @@ static ivas_error init_lfe_synth_data_fx( Decoder_Struct *st_ivas, MASA_DECODER_ static void compute_foa_cov_matrix_fx( Word32 foaCov_fx[FOA_CHANNELS][FOA_CHANNELS], Word32 inCov_fx[FOA_CHANNELS][FOA_CHANNELS], Word32 mixMtx_fx[FOA_CHANNELS][FOA_CHANNELS] ); -static Word16 decode_lfe_to_total_energy_ratio_fx( MCMASA_LFE_SYNTH_DATA_HANDLE hMasaLfeSynth, uint16_t *bitstream, int16_t *index, const int32_t ivas_total_brate ); +static Word16 decode_lfe_to_total_energy_ratio_fx( MCMASA_LFE_SYNTH_DATA_HANDLE hMasaLfeSynth, UWord16 *bitstream, Word16 *index, const Word32 ivas_total_brate ); static ivas_error ivas_masa_dec_config_fx( Decoder_Struct *st_ivas ); @@ -661,13 +661,14 @@ ivas_error ivas_masa_decode_fx( { st->next_bit_pos = sub( tmp, 1 ); } + move16(); test(); test(); test(); test(); test(); - IF( EQ_16( st->bfi, 0 ) && GT_32( ivas_total_brate, IVAS_SID_5k2 ) ) + IF( st->bfi == 0 && GT_32( ivas_total_brate, IVAS_SID_5k2 ) ) { test(); IF( NE_32( ivas_format, MC_FORMAT ) || NE_16( st_ivas->mc_mode, MC_MODE_MCMASA ) ) @@ -678,6 +679,7 @@ ivas_error ivas_masa_decode_fx( /* the number of MASA transport channels was read in ivas_dec_setup() */ st->next_bit_pos = sub( st->next_bit_pos, MASA_TRANSP_BITS ); *nb_bits_read = add( *nb_bits_read, MASA_TRANSP_BITS ); + move16(); } test(); @@ -686,6 +688,8 @@ ivas_error ivas_masa_decode_fx( /* the number of objects was read */ st->next_bit_pos = sub( st->next_bit_pos, NO_BITS_MASA_ISM_NO_OBJ ); *nb_bits_read = add( *nb_bits_read, NO_BITS_MASA_ISM_NO_OBJ ); + move16(); + move16(); IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) { @@ -694,8 +698,11 @@ ivas_error ivas_masa_decode_fx( byteBuffer = st->bit_stream[( st->next_bit_pos )--]; move16(); *nb_bits_read = add( *nb_bits_read, 1 ); + move16(); st_ivas->hMasaIsmData->idx_separated_ism = extract_l( L_add( L_shl( byteBuffer, 1 ), st->bit_stream[( st->next_bit_pos )--] ) ); + move16(); *nb_bits_read = add( *nb_bits_read, 1 ); + move16(); } ELSE { @@ -714,6 +721,7 @@ ivas_error ivas_masa_decode_fx( byteBuffer = st->bit_stream[( st->next_bit_pos )--]; move16(); *nb_bits_read = add( *nb_bits_read, 1 ); + move16(); ism_imp = add( shl( ism_imp, 1 ), (Word16) byteBuffer ); } st_ivas->hIsmMetaData[0]->ism_imp = ism_imp; @@ -729,7 +737,9 @@ ivas_error ivas_masa_decode_fx( byteBuffer = st->bit_stream[( st->next_bit_pos )--]; move16(); *nb_bits_read = add( *nb_bits_read, 1 ); + move16(); ism_imp = add( shl( ism_imp, 1 ), (Word16) byteBuffer ); + move16(); } st_ivas->hIsmMetaData[0]->ism_imp = ism_imp; move16(); @@ -745,9 +755,11 @@ ivas_error ivas_masa_decode_fx( st_ivas->hIsmMetaData[0]->ism_md_null_flag = st->bit_stream[( st->next_bit_pos )--]; move16(); *nb_bits_read = add( *nb_bits_read, ISM_METADATA_MD_FLAG_BITS ); + move16(); st_ivas->hIsmMetaData[0]->ism_md_lowrate_flag = st->bit_stream[( st->next_bit_pos )--]; move16(); *nb_bits_read = add( *nb_bits_read, ISM_METADATA_INACTIVE_FLAG_BITS ); + move16(); } } ELSE IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) @@ -761,6 +773,7 @@ ivas_error ivas_masa_decode_fx( byteBuffer = st->bit_stream[( st->next_bit_pos )--]; move16(); *nb_bits_read = add( *nb_bits_read, 1 ); + move16(); ism_imp = add( shl( ism_imp, 1 ), (Word16) byteBuffer ); } st_ivas->hIsmMetaData[ch]->ism_imp = ism_imp; @@ -777,9 +790,11 @@ ivas_error ivas_masa_decode_fx( st_ivas->hIsmMetaData[ch]->ism_md_null_flag = st->bit_stream[( st->next_bit_pos )--]; move16(); *nb_bits_read = add( *nb_bits_read, ISM_METADATA_MD_FLAG_BITS ); + move16(); st_ivas->hIsmMetaData[ch]->ism_md_lowrate_flag = st->bit_stream[( st->next_bit_pos )--]; move16(); *nb_bits_read = add( *nb_bits_read, ISM_METADATA_INACTIVE_FLAG_BITS ); + move16(); } } st_ivas->flag_omasa_brate = 0; @@ -790,6 +805,7 @@ ivas_error ivas_masa_decode_fx( st_ivas->flag_omasa_brate = st->bit_stream[( st->next_bit_pos )--]; move16(); *nb_bits_read = add( *nb_bits_read, 1 ); + move16(); } } } @@ -816,11 +832,14 @@ ivas_error ivas_masa_decode_fx( byteBuffer = st->bit_stream[( st->next_bit_pos )--]; move16(); *nb_bits_read = add( *nb_bits_read, 1 ); - hMasa->config.numberOfDirections = (uint8_t) ( byteBuffer + 1 ); + move16(); + hMasa->config.numberOfDirections = (UWord8) L_add( byteBuffer, 1 ); + move16(); } ELSE { hMasa->config.numberOfDirections = 1; + move16(); } test(); @@ -830,16 +849,20 @@ ivas_error ivas_masa_decode_fx( byteBuffer = st->bit_stream[( st->next_bit_pos )--]; move16(); *nb_bits_read = add( *nb_bits_read, 1 ); - hMasa->config.joinedSubframes = (uint8_t) byteBuffer; + move16(); + hMasa->config.joinedSubframes = (UWord8) byteBuffer; + move16(); } ELSE { hMasa->config.joinedSubframes = FALSE; + move16(); } IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) ) { *nb_bits_read = add( *nb_bits_read, decode_lfe_to_total_energy_ratio_fx( hMasa->hMasaLfeSynth, st->bit_stream, &st->next_bit_pos, ivas_total_brate ) ); + move16(); } /* Once we know incoming configuration, we can config decoder further based on bitrate etc. */ @@ -941,6 +964,7 @@ ivas_error ivas_masa_decode_fx( { *nb_bits_read = add( *nb_bits_read, ivas_qmetadata_dec_decode( hQMetaData, st->bit_stream, &st->next_bit_pos, 0 ) ); + move16(); } test(); @@ -976,7 +1000,7 @@ ivas_error ivas_masa_decode_fx( replicate_subframes_fx( hQMetaData ); } } - ELSE IF( EQ_16( st->bfi, 0 ) && EQ_32( ivas_format, MASA_FORMAT ) && EQ_32( ivas_total_brate, IVAS_SID_5k2 ) ) + ELSE IF( st->bfi == 0 && EQ_32( ivas_format, MASA_FORMAT ) && EQ_32( ivas_total_brate, IVAS_SID_5k2 ) ) { IF( hQMetaData->q_direction == NULL ) { @@ -1023,6 +1047,7 @@ ivas_error ivas_masa_decode_fx( *nb_bits_read = add( *nb_bits_read, ivas_qmetadata_dec_sid_decode( hQMetaData, st->bit_stream, &( st->next_bit_pos ), st_ivas->nchan_transport, &tmp_elem_mode, ivas_format ) ); + move16(); IF( EQ_16( st_ivas->nchan_transport, 2 ) ) { @@ -1031,6 +1056,7 @@ ivas_error ivas_masa_decode_fx( move16(); } *nb_bits_read = add( *nb_bits_read, SID_FORMAT_NBITS ); + move16(); } ELSE IF( st->bfi == 0 && EQ_32( ivas_format, MASA_FORMAT ) && EQ_32( ivas_total_brate, FRAME_NO_DATA ) ) { @@ -1301,6 +1327,7 @@ ivas_error ivas_masa_dec_open_fx( Word32 ism_total_brate; error = IVAS_ERR_OK; + move16(); IF( ( hMasa = (MASA_DECODER_HANDLE) malloc( sizeof( MASA_DECODER ) ) ) == NULL ) { @@ -1748,6 +1775,7 @@ static ivas_error ivas_masa_dec_config_fx( 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 ); + move32(); } ELSE { @@ -1764,9 +1792,9 @@ static ivas_error ivas_masa_dec_config_fx( move16(); WHILE( LE_16( maxBand, MASA_FREQUENCY_BANDS ) && LE_16( MASA_band_grouping_24[maxBand], maxBin ) ) { - maxBand++; + maxBand = (UWord8) add( maxBand, 1 ); } - maxBand--; + maxBand = (UWord8) sub( maxBand, 1 ); IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) { @@ -1971,14 +1999,14 @@ static void replicate_subframes_fx( hQMetaData->q_direction[dir].band_data[band].energy_ratio_fx[sf] = hQMetaData->q_direction[dir].band_data[band].energy_ratio_fx[0]; move32(); - IF( hQMetaData->q_direction[dir].coherence_band_data != NULL ) + 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 ) + if ( hQMetaData->surcoh_band_data != NULL ) { hQMetaData->surcoh_band_data[band].surround_coherence[sf] = hQMetaData->surcoh_band_data[band].surround_coherence[0]; move16(); @@ -2076,12 +2104,12 @@ static void restore_lowbitrate_masa_fx( hQMetaData->q_direction[0].band_data[band].energy_ratio_fx[sf] = hQMetaData->q_direction[0].band_data[band].energy_ratio_fx[0]; move32(); - IF( hQMetaData->q_direction[0].coherence_band_data != NULL ) + 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 ) + if ( hQMetaData->surcoh_band_data != NULL ) { hQMetaData->surcoh_band_data[band].surround_coherence[sf] = hQMetaData->surcoh_band_data[band].surround_coherence[0]; move16(); @@ -2108,12 +2136,12 @@ static void restore_lowbitrate_masa_fx( hQMetaData->q_direction[0].band_data[band].energy_ratio_fx[sf] = hQMetaData->q_direction[0].band_data[0].energy_ratio_fx[sf]; move32(); - IF( hQMetaData->q_direction[0].coherence_band_data != NULL ) + 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 ) + if ( hQMetaData->surcoh_band_data != NULL ) { hQMetaData->surcoh_band_data[band].surround_coherence[sf] = hQMetaData->surcoh_band_data[0].surround_coherence[sf]; move16(); @@ -2322,6 +2350,7 @@ static ivas_error init_lfe_synth_data_fx( hMasa->hMasaLfeSynth->ringBufferLoPointer = 0; move16(); hMasa->hMasaLfeSynth->ringBufferHiPointer = shr( bufferSize, 1 ); + move16(); hMasa->hMasaLfeSynth->lowpassSum_fx = 0; move16(); hMasa->hMasaLfeSynth->ringBufferSize = bufferSize; @@ -2355,7 +2384,7 @@ static ivas_error init_lfe_synth_data_fx( move16(); /* Delay buffer for syncing with DirAC rendering */ - bufferSize = sub( sub( NS2SA( output_Fs, IVAS_FB_DEC_DELAY_NS ), shr( hMasa->hMasaLfeSynth->ringBufferSize, 1 ) ), shr( hMasa->hMasaLfeSynth->ringBufferSize2, 1 ) ); + bufferSize = sub( sub( NS2SA_FX2( output_Fs, IVAS_FB_DEC_DELAY_NS ), shr( hMasa->hMasaLfeSynth->ringBufferSize, 1 ) ), shr( hMasa->hMasaLfeSynth->ringBufferSize2, 1 ) ); IF( ( hMasa->hMasaLfeSynth->delayBuffer_syncDirAC_fx = (Word32 *) malloc( bufferSize * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MASA decoder\n" ) ); @@ -2376,6 +2405,7 @@ static ivas_error init_lfe_synth_data_fx( FOR( i = 0; i < slot_size; i++ ) { hMasa->hMasaLfeSynth->interpolator_fx[i] = div_s( add( i, 1 ), slot_size ); + move16(); } } ELSE IF( st_ivas->hOutSetup.separateChannelEnabled && EQ_16( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && EQ_16( st_ivas->hOutSetup.num_lfe, 0 ) ) @@ -2383,7 +2413,7 @@ static ivas_error init_lfe_synth_data_fx( Word16 bufferSize; /* Delay buffer for syncing with DirAC rendering */ - bufferSize = NS2SA( output_Fs, IVAS_FB_DEC_DELAY_NS ); + bufferSize = NS2SA_FX2( output_Fs, IVAS_FB_DEC_DELAY_NS ); IF( ( hMasa->hMasaLfeSynth->delayBuffer_syncDirAC_fx = (Word32 *) malloc( bufferSize * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MASA decoder\n" ) ); @@ -2570,7 +2600,7 @@ static Word16 decode_lfe_to_total_energy_ratio_fx( { lfeToTotalEnergyRatioTemp_fx = mult( lfeToTotalEnergyRatioTemp_fx, MCMASA_LFE_ALPHA_Q15 ); // Q14 } - IF( GT_16( lfeToTotalEnergyRatioTemp_fx, ONE_IN_Q14 ) ) + if ( GT_16( lfeToTotalEnergyRatioTemp_fx, ONE_IN_Q14 ) ) { lfeToTotalEnergyRatioTemp_fx = ONE_IN_Q14; move16(); @@ -2598,6 +2628,9 @@ static Word16 decode_lfe_to_total_energy_ratio_fx( byteBuffer = (UWord16) L_shl( bitstream[( *index )--], 2 ); byteBuffer = (UWord16) L_add( byteBuffer, L_shl( bitstream[( *index )--], 1 ) ); byteBuffer = (UWord16) L_add( byteBuffer, bitstream[( *index )--] ); + move16(); + move16(); + move16(); lfeBitsRead = add( lfeBitsRead, 3 ); lfeToTotalEnergyRatioIndices[1] = byteBuffer; /* Scalar index */ move16(); @@ -2635,6 +2668,7 @@ static Word16 decode_lfe_to_total_energy_ratio_fx( FOR( i = 0; i < VQBits; i++ ) { byteBuffer = (UWord16) L_add( byteBuffer, L_shl( bitstream[( *index )--], sub( sub( VQBits, 1 ), i ) ) ); + move16(); lfeBitsRead = add( lfeBitsRead, 1 ); } lfeToTotalEnergyRatioIndices[2] = byteBuffer; /* VQ index */ @@ -2983,7 +3017,7 @@ ivas_error ivas_masa_dec_reconfigure_fx( ( ( 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 ( NE_32( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_OPEN ) ), IVAS_ERR_OK ) ) + if ( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) { return error; } @@ -3028,6 +3062,8 @@ ivas_error ivas_masa_dec_reconfigure_fx( // st_ivas->hSCE[sce_id]->element_brate = ivas_total_brate / st_ivas->nchan_transport; st_ivas->hSCE[sce_id]->element_brate = L_deposit_h( BASOP_Util_Divide3216_Scale( ivas_total_brate, st_ivas->nchan_transport, &tmp_e ) ); st_ivas->hSCE[sce_id]->element_brate = L_shr( st_ivas->hSCE[sce_id]->element_brate, sub( 15, tmp_e ) ); + move32(); + move32(); st_ivas->hSCE[sce_id]->hCoreCoder[0]->total_brate = st_ivas->hSCE[sce_id]->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ move32(); @@ -3057,6 +3093,7 @@ ivas_error ivas_masa_dec_reconfigure_fx( tmp32 = L_deposit_h( BASOP_Util_Divide3216_Scale( ivas_total_brate, st_ivas->nchan_transport, &tmp_e ) ); tmp32 = L_shr( tmp32, sub( 15, tmp_e ) ); st_ivas->hCPE[cpe_id]->element_brate = imult3216( tmp32, CPE_CHANNELS ); + move32(); /* prepare bitstream buffers */ FOR( n = 0; n < CPE_CHANNELS; n++ ) @@ -3117,7 +3154,7 @@ ivas_error ivas_masa_dec_reconfigure_fx( test(); 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 ( NE_32( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_RECONFIGURE ) ), IVAS_ERR_OK ) ) + if ( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK ) { return error; } @@ -3154,6 +3191,7 @@ ivas_error ivas_masa_dec_reconfigure_fx( Word16 Q_tmp = getScaleFactor16( st_ivas->hSpar->hFbMixer->cldfb_cross_fade_fx, 16 ); Scale_sig( st_ivas->hSpar->hFbMixer->cldfb_cross_fade_fx, 16, Q_tmp - st_ivas->hSpar->hFbMixer->cldfb_cross_fade_q ); st_ivas->hSpar->hFbMixer->cldfb_cross_fade_q = Q_tmp; + move16(); } if ( NE_32( ( error = ivas_cldfb_dec_reconfig_fx( st_ivas, st_ivas->nchan_transport, numCldfbAnalyses_old, numCldfbSyntheses_old ) ), IVAS_ERR_OK ) ) { @@ -3311,14 +3349,14 @@ void ivas_spar_param_to_masa_param_mapping_fx( Word32 mixer_mat_sf_bins_real_fx[CLDFB_NO_CHANNELS_MAX][FOA_CHANNELS][FOA_CHANNELS]; Word16 *band_grouping; Word16 band_start, band_end; - Word32 transportSignalEnergies_32[2][CLDFB_NO_CHANNELS_MAX] = { 0 }; - Word64 transportSignalEnergies_64[2][CLDFB_NO_CHANNELS_MAX] = { 0 }; - Word32 transportSignalCrossCorrelation_32[CLDFB_NO_CHANNELS_MAX] = { 0 }; - Word64 transportSignalCrossCorrelation_64[CLDFB_NO_CHANNELS_MAX] = { 0 }; + Word32 transportSignalEnergies_32[2][CLDFB_NO_CHANNELS_MAX]; + Word64 transportSignalEnergies_64[2][CLDFB_NO_CHANNELS_MAX]; + Word32 transportSignalCrossCorrelation_32[CLDFB_NO_CHANNELS_MAX]; + Word64 transportSignalCrossCorrelation_64[CLDFB_NO_CHANNELS_MAX]; Word64 instEne_fx; - Word32 inCovarianceMtx_fx[FOA_CHANNELS][FOA_CHANNELS] = { 0 }; + Word32 inCovarianceMtx_fx[FOA_CHANNELS][FOA_CHANNELS]; Word16 q_inCovarianceMtx = 31; - Word32 foaCovarianceMtx_fx[FOA_CHANNELS][FOA_CHANNELS] = { 0 }; + Word32 foaCovarianceMtx_fx[FOA_CHANNELS][FOA_CHANNELS]; Word32 Iy_fx, Iz_fx, Ix_fx, E_fx, azi_fx, ele_fx, I_fx, ratio_float_fx; Word32 diffuseGainX_fx, diffuseGainY_fx, diffuseGainZ_fx, diffuseGainSum_fx; Word16 slot_idx, slot_idx_start, sf; @@ -3336,6 +3374,30 @@ void ivas_spar_param_to_masa_param_mapping_fx( Word16 headroom_left_max_common = 63; // 0 value Word16 q_max_common = 31; Word32 ratio_fx; /* Q30 */ + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move64(); + move64(); + move64(); + + FOR( i = 0; i < 2; i++ ) + { + set64_fx( transportSignalEnergies_64[i], 0, CLDFB_NO_CHANNELS_MAX ); + set32_fx( transportSignalEnergies_32[i], 0, CLDFB_NO_CHANNELS_MAX ); + } + set32_fx( transportSignalCrossCorrelation_32, 0, CLDFB_NO_CHANNELS_MAX ); + set64_fx( transportSignalCrossCorrelation_64, 0, CLDFB_NO_CHANNELS_MAX ); + FOR( i = 0; i < FOA_CHANNELS; i++ ) + { + set32_fx( inCovarianceMtx_fx[i], 0, FOA_CHANNELS ); + set32_fx( foaCovarianceMtx_fx[i], 0, FOA_CHANNELS ); + } + FOR( Word16 ind = 0; ind < 6; ind++ ) { FOR( Word16 ind2 = 0; ind2 < 4; ind2++ ) @@ -3379,7 +3441,15 @@ void ivas_spar_param_to_masa_param_mapping_fx( } FOR( slot_idx = 0; slot_idx < hSpar->subframe_nbslots[subframe]; slot_idx++ ) { - sf = hSpar->render_to_md_map[slot_idx + slot_idx_start] / JBM_CLDFB_SLOTS_IN_SUBFRAME; + IF( hSpar->render_to_md_map[slot_idx + slot_idx_start] == 0 ) + { + sf = 0; + move16(); + } + ELSE + { + sf = idiv1616( hSpar->render_to_md_map[slot_idx + slot_idx_start], JBM_CLDFB_SLOTS_IN_SUBFRAME ); + } IF( LT_16( sf, SPAR_META_DELAY_SUBFRAMES ) ) { @@ -3451,9 +3521,13 @@ void ivas_spar_param_to_masa_param_mapping_fx( instEne_fx = (Word64) L_shr_sat( inRe_fx[ch][slot][bin], sub( q_cldfb[ch][slot], common_q ) ) * L_shr_sat( inRe_fx[ch][slot][bin], sub( q_cldfb[ch][slot], common_q ) ); instEne_fx = W_add( instEne_fx, (Word64) L_shr_sat( inIm_fx[ch][slot][bin], sub( q_cldfb[ch][slot], common_q ) ) * L_shr_sat( inIm_fx[ch][slot][bin], sub( q_cldfb[ch][slot], common_q ) ) ); transportSignalEnergies_64[ch][bin] = W_add( transportSignalEnergies_64[ch][bin], instEne_fx ); + move64(); + move64(); } - transportSignalCrossCorrelation_64[bin] = W_add( transportSignalCrossCorrelation_64[bin], (Word64) L_shr_sat( inRe_fx[0][slot][bin], sub( q_cldfb[0][slot], common_q ) ) * L_shr_sat( inRe_fx[1][slot][bin], sub( q_cldfb[0][slot], common_q ) ) ); - transportSignalCrossCorrelation_64[bin] = W_add( transportSignalCrossCorrelation_64[bin], (Word64) L_shr_sat( inIm_fx[0][slot][bin], sub( q_cldfb[0][slot], common_q ) ) * L_shr_sat( inIm_fx[1][slot][bin], sub( q_cldfb[0][slot], common_q ) ) ); + transportSignalCrossCorrelation_64[bin] = W_add( transportSignalCrossCorrelation_64[bin], W_mult0_32_32( L_shr_sat( inRe_fx[0][slot][bin], sub( q_cldfb[0][slot], common_q ) ), L_shr_sat( inRe_fx[1][slot][bin], sub( q_cldfb[0][slot], common_q ) ) ) ); + transportSignalCrossCorrelation_64[bin] = W_add( transportSignalCrossCorrelation_64[bin], W_mult0_32_32( L_shr_sat( inIm_fx[0][slot][bin], sub( q_cldfb[0][slot], common_q ) ), L_shr_sat( inIm_fx[1][slot][bin], sub( q_cldfb[0][slot], common_q ) ) ) ); + move64(); + move64(); } } @@ -3575,9 +3649,9 @@ void ivas_spar_param_to_masa_param_mapping_fx( Ix_fx = foaCovarianceMtx_fx[0][3]; /* Intensity in X direction */ move32(); - Word64 I1 = (Word64) Ix_fx * Ix_fx; - Word64 I2 = (Word64) Iy_fx * Iy_fx; - Word64 I3 = (Word64) Iz_fx * Iz_fx; + Word64 I1 = W_mult0_32_32( Ix_fx, Ix_fx ); + Word64 I2 = W_mult0_32_32( Iy_fx, Iy_fx ); + Word64 I3 = W_mult0_32_32( Iz_fx, Iz_fx ); Word64 I_res = W_add( W_add( I1, I2 ), I3 ); Word64 E_fx_64 = W_add( W_add( W_add( foaCovarianceMtx_fx[0][0], foaCovarianceMtx_fx[1][1] ), foaCovarianceMtx_fx[2][2] ), foaCovarianceMtx_fx[3][3] ); @@ -3606,8 +3680,8 @@ void ivas_spar_param_to_masa_param_mapping_fx( move16(); azi_fx = BASOP_util_atan2( Iy_fx, Ix_fx, azi_q ); /* Azimuth */ - Word64 I_ele_x = (Word64) Ix_fx * Ix_fx; - Word64 I_ele_y = (Word64) Iy_fx * Iy_fx; + Word64 I_ele_x = W_mult0_32_32( Ix_fx, Ix_fx ); + Word64 I_ele_y = W_mult0_32_32( Iy_fx, Iy_fx ); Word64 I_ele = W_add( I_ele_x, I_ele_y ); Word16 headroom_left_I_ele = W_norm( I_ele ); IF( LT_16( headroom_left_I_ele, 32 ) ) @@ -3619,42 +3693,50 @@ 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 ); + I_ele = Sqrt32( W_extract_l( I_ele ), &ele_q ); IF( ele_q < 0 ) { - I_ele = W_shr( I_ele, -1 * ele_q ); + I_ele = W_shr( I_ele, negate( ele_q ) ); ele_q = 0; move16(); } - ele_fx = BASOP_util_atan2( Iz_fx, (Word32) I_ele, sub( sub( 31, q_inCovarianceMtx ), ele_q ) ); + ele_fx = BASOP_util_atan2( Iz_fx, W_extract_l( I_ele ), sub( sub( 31, q_inCovarianceMtx ), ele_q ) ); num_q = sub( 31, q_I_res ); denom_q = q_inCovarianceMtx; move16(); res_q = 0; move16(); - E_fx = GT_32( E_fx, 0 ) ? E_fx : 1; + IF( E_fx > 0 ) + { + E_fx = E_fx; + } + ELSE + { + E_fx = 1; + } + move32(); ratio_float_fx = BASOP_Util_Divide3232_Scale( I_fx, E_fx, &res_q ); res_q = sub( res_q, sub( num_q, denom_q ) ); - ratio_fx = L_shl_sat( ratio_float_fx, Q15 + res_q ); + ratio_fx = L_shl_sat( ratio_float_fx, add( Q15, res_q ) ); ratio_fx = L_max( 0, L_min( ratio_fx, ONE_IN_Q30 ) ); - azi_val = (Word64) azi_fx * ONE_BY_PI_OVER_180_Q25; + azi_val = W_mult0_32_32( azi_fx, ONE_BY_PI_OVER_180_Q25 ); IF( azi_val < 0 ) { - azi_val = W_shr( -1 * azi_val, 13 + 25 ); - azi_val = -1 * azi_val; + azi_val = W_shr( W_neg( azi_val ), 13 + 25 ); + azi_val = W_neg( azi_val ); } ELSE { azi_val = W_shr( azi_val, 13 + 25 ); } - ele_val = (Word64) ele_fx * ONE_BY_PI_OVER_180_Q25; + ele_val = W_mult0_32_32( ele_fx, ONE_BY_PI_OVER_180_Q25 ); IF( ele_val < 0 ) { - ele_val = W_shr( -1 * ele_val, 13 + 25 ); - ele_val = -1 * ele_val; + ele_val = W_shr( W_neg( ele_val ), 13 + 25 ); + ele_val = W_neg( ele_val ); } ELSE { @@ -4211,6 +4293,14 @@ static void create_masa_ext_out_meta_fx( UWord8 numCodingBands; UWord8 numDirections; MASA_DECODER_EXT_OUT_META *extOutMeta; + move16(); /*ivasmasaFormatDescriptor*/ + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); numDirections = hMasa->config.numberOfDirections; move16(); @@ -4227,7 +4317,7 @@ static void create_masa_ext_out_meta_fx( descMeta->formatDescriptor[i] = ivasmasaFormatDescriptor[i]; move16(); } - descMeta->numberOfDirections = numDirections - 1; + descMeta->numberOfDirections = (UWord8) sub( numDirections, 1 ); descMeta->numberOfChannels = (UWord8) ( sub( nchan_transport, 1 ) ); /* Following correspond to "unknown" values until transmission is implemented */ descMeta->sourceFormat = 0x0u; @@ -4782,7 +4872,7 @@ static void read_ism_ratio_index_fx( IF( GT_16( idx_sep_obj, -1 ) ) { test(); - IF( EQ_16( idx_sep_obj, sub( nchan_ism, 1 ) ) && GT_16( nchan_ism, 2 ) ) + if ( EQ_16( idx_sep_obj, sub( nchan_ism, 1 ) ) && GT_16( nchan_ism, 2 ) ) { idx_sep_obj_local = 0; move16(); @@ -4792,10 +4882,10 @@ static void read_ism_ratio_index_fx( b_signif = 0; move16(); no_levels_ratio_ism = sub( shl( 1, PARAM_ISM_POW_RATIO_NBITS ), 1 ); - move16(); WHILE( ( LT_16( b_signif, numCodingBands ) ) && ( GE_32( masa_to_total_energy_ratio_fx[b_signif], MASA2TOTAL_THR_Q30 ) ) ) { + test(); /* distribute evenly the objects */ distribute_evenly_ism_fx( ratio_ism_idx[b_signif], no_levels_ratio_ism, nchan_ism ); b_signif = add( b_signif, 1 ); @@ -4958,7 +5048,7 @@ static void read_ism_ratio_index_fx( { IF( LT_32( masa_to_total_energy_ratio_fx[b], MASA2TOTAL_THR_Q30 ) ) { - FOR( i = 0; i < nchan_ism - 1 - shift_one; i++ ) + FOR( i = 0; i < sub( nchan_ism, add( 1, shift_one ) ); i++ ) { buf = ivas_qmetadata_DecodeExtendedGR( bit_stream, next_bit_pos, 100, GR_order ); IF( ( buf % 2 ) == 0 ) @@ -5001,7 +5091,7 @@ static void read_ism_ratio_index_fx( move16(); test(); - IF( ( 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(); @@ -5029,7 +5119,7 @@ static void read_ism_ratio_index_fx( move16(); test(); - IF( ( 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(); @@ -5053,7 +5143,7 @@ static void read_ism_ratio_index_fx( move16(); test(); - IF( NE_16( shift_one, 0 ) && EQ_16( i, idx_sep_obj_local ) ) + if ( NE_16( shift_one, 0 ) && EQ_16( i, idx_sep_obj_local ) ) { ratio_ism_idx[b][i] = 0; move16(); @@ -5478,7 +5568,7 @@ static Word16 ivas_decode_masaism_metadata_fx( } ELSE { - IF( GT_32( L_sub( hMasaIsmData->q_azimuth_old_fx[obj], azimuth ), delta_phi ) ) + if ( GT_32( L_sub( hMasaIsmData->q_azimuth_old_fx[obj], azimuth ), delta_phi ) ) { azimuth = L_add( azimuth, delta_phi ); } @@ -5582,7 +5672,7 @@ static Word16 rint_fx( /* returns in Q0 */ test(); test(); - IF( GT_32( frac_part, ONE_IN_Q15 ) || ( EQ_32( frac_part, ONE_IN_Q15 ) && EQ_16( s_and( int_part, 1 ), 1 ) ) ) + if ( GT_32( frac_part, ONE_IN_Q15 ) || ( EQ_32( frac_part, ONE_IN_Q15 ) && EQ_16( s_and( int_part, 1 ), 1 ) ) ) { res = add( res, 1 ); } diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 68054e048a34bf6437f4ac3e06c0a9c065693ce1..10077e345eedc9427dbb6b9fa93272e948c03f9f 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -64,11 +64,13 @@ typedef struct parameter_band_mapping_struct { +#ifndef IVAS_FLOAT_FIXED int16_t n_source_bands[20]; int16_t source_band_idx[20][4]; -#ifndef IVAS_FLOAT_FIXED float source_band_factor[20][4]; #else + Word16 n_source_bands[20]; + Word16 source_band_idx[20][4]; Word16 source_band_factor_fx[20][4]; /*Q15*/ #endif // IVAS_FLOAT_FIXED diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index 8d71571129fa5af0836d7627d9b0defe9f35844e..7cbac3f8130a0958e69e1681ae06b3c106a9e945 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -59,7 +59,14 @@ /* boxes = { 0 1 2 3 [4 6] [5 7] [8 10] [9 11] }; */ const Word16 MC_PARAMUPMIX_CHIDX1[MC_PARAMUPMIX_COMBINATIONS] = { 0, 1, 4, 5 }; const Word16 MC_PARAMUPMIX_CHIDX2[MC_PARAMUPMIX_COMBINATIONS] = { 2, 3, 6, 7 }; - +const Word16 qmf_to_par_band[] = { + 0, 1, 2, 3, 4, 5, 5, 6, 6, 7, + 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, + 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11 +}; /*-----------------------------------------------------------------------* * Local function prototypes @@ -133,6 +140,7 @@ void ivas_mc_paramupmix_dec_read_BS( FOR( i = 0; i < s_min( MAX_BITS_METADATA, last_bit_pos ); i++ ) { bstr_meta[i] = st_ivas->bit_stream[sub( last_bit_pos, i )]; + move16(); } st0->bit_stream = bstr_meta; st0->next_bit_pos = 0; @@ -344,6 +352,7 @@ ivas_error ivas_mc_paramupmix_dec_open( *-----------------------------------------------------------------*/ hMCParamUpmix->num_freq_bands = (Word16) Mpy_32_32_r( output_Fs, INV_CLDFB_BANDWIDTH_Q31 ); + move16(); FOR( i = 0; i < MC_PARAMUPMIX_COMBINATIONS; i++ ) { @@ -390,9 +399,10 @@ ivas_error ivas_mc_paramupmix_dec_open( TC_BUFFER_MODE buffer_mode; buffer_mode = TC_BUFFER_MODE_RENDERER; - nchan_tc = ivas_jbm_dec_get_num_tc_channels( st_ivas ); + nchan_tc = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ); nchan_to_allocate = MC_PARAMUPMIX_MAX_INPUT_CHANS; move16(); + move16(); test(); test(); @@ -624,14 +634,7 @@ static void ps_pred_process_sf( Word16 ifac_fx; Word32 alpha_start_fx[IVAS_MAX_NUM_BANDS], beta_start_fx[IVAS_MAX_NUM_BANDS]; Word32 res_a, res_b; - const Word16 qmf_to_par_band[] = { - 0, 1, 2, 3, 4, 5, 5, 6, 6, 7, - 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, - 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 11, 11, 11 - }; + Copy32( alpha_sf_fx, alpha_start_fx, IVAS_MAX_NUM_BANDS ); Copy32( beta_sf_fx, beta_start_fx, IVAS_MAX_NUM_BANDS ); @@ -645,6 +648,7 @@ static void ps_pred_process_sf( move16(); ismp = 0; + move16(); alpha2_fx = hMCParamUpmix->alphas_fx[ch]; beta2_fx = hMCParamUpmix->betas_fx[ch]; alpha_smp_fx = alpha_start_fx[ipar]; @@ -681,10 +685,12 @@ static void ps_pred_process_sf( res_a = L_shl_sat( Mpy_32_32( alpha_smp_fx, vmre_fx ), Q31 - Q28 ); res_b = L_shl_sat( Mpy_32_32( beta_smp_fx, vsre_fx ), Q31 - Q28 ); qmf_side_re_fx[ismp][iqmf] = L_add_sat( res_a, res_b ); + move32(); res_a = L_shl_sat( Mpy_32_32( alpha_smp_fx, vmim_fx ), Q31 - Q28 ); res_b = L_shl_sat( Mpy_32_32( beta_smp_fx, vsim_fx ), Q31 - Q28 ); qmf_side_im_fx[ismp][iqmf] = L_add_sat( res_a, res_b ); + move32(); ismp = add( ismp, 1 ); } @@ -782,6 +788,7 @@ static void ivas_mc_paramupmix_dec_sf( } } + test(); IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { Word16 temp_e; @@ -917,7 +924,7 @@ static void ivas_mc_paramupmix_dec_sf( Scale_sig32( output_fx[ch], imult1616( hMCParamUpmix->num_freq_bands, st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->subframes_rendered] ), 6 ); } /* adjust delay of other channels */ - noparamupmix_delay = NS2SA( st_ivas->hDecoderConfig->output_Fs, IVAS_FB_DEC_DELAY_NS ); + noparamupmix_delay = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_FB_DEC_DELAY_NS ); n_samples_rendered = imult1616( st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->subframes_rendered], hMCParamUpmix->num_freq_bands ); IF( n_samples_rendered > noparamupmix_delay ) { @@ -945,6 +952,8 @@ static void ivas_mc_paramupmix_dec_sf( st_ivas->hTcBuffer->slots_rendered = add( st_ivas->hTcBuffer->slots_rendered, st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->subframes_rendered] ); st_ivas->hTcBuffer->subframes_rendered = add( st_ivas->hTcBuffer->subframes_rendered, 1 ); + move16(); + move16(); pop_wmops(); return; @@ -957,6 +966,8 @@ static Word16 huff_read( { Word16 node = 0; UWord16 next_bit = 0; + move16(); + move16(); DO { @@ -1013,6 +1024,7 @@ static void huffman_decode( assert( 0 ); } vq[0] = huff_read( st, huff_node_table ); + move32(); SWITCH( parType ) { diff --git a/lib_dec/ivas_mcmasa_dec.c b/lib_dec/ivas_mcmasa_dec.c index b0d4f5c7168f892ee575837624221d30cee6a2f5..d89f5e9d0491393b3218b5bb5ca382abb5799010 100644 --- a/lib_dec/ivas_mcmasa_dec.c +++ b/lib_dec/ivas_mcmasa_dec.c @@ -76,6 +76,7 @@ ivas_error ivas_mcmasa_dec_reconfig( } st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); + move16(); test(); IF( NE_16( st_ivas->renderer_type, RENDERER_DISABLE ) && NE_16( st_ivas->renderer_type, RENDERER_MCMASA_MONO_STEREO ) ) diff --git a/lib_dec/ivas_mct_core_dec.c b/lib_dec/ivas_mct_core_dec.c index cc014dd76ebd112cfa75b0eb5c741ffe1e460f99..3e95cbc5353a2100683feb7c9862c997df330088 100644 --- a/lib_dec/ivas_mct_core_dec.c +++ b/lib_dec/ivas_mct_core_dec.c @@ -225,9 +225,10 @@ void ivas_mct_side_bits_fx( st->bits_frame_channel = 0; move16(); move16(); - continue; + CONTINUE; } chBitRatios[ch] = get_next_indice_fx( sts[0], NBBITS_MCT_RATIO ); + move16(); IF( EQ_16( st->core, TCX_10_CORE ) ) { nSubframes = NB_DIV; @@ -248,7 +249,7 @@ void ivas_mct_side_bits_fx( 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( sub( tmp, sts[0]->next_bit_pos ), nf_side_bits ) ); availableBits = sub( availableBits, nb_bits_metadata ); splitAvailableBitsMCT( (void **) sts, availableBits, chBitRatios, DEC, nChannels ); diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 66ced94fb9a552c996fe3f950af806092f9350ba..c67e7c95af2c74dab5ccee843f6a76507805eba4 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -318,7 +318,7 @@ ivas_error ivas_mct_dec_fx( set16_fx( x_len[1], 0, NB_DIV ); Decoder_State **sts; Word16 synth_fx[CPE_CHANNELS][L_FRAME_PLUS]; - int32_t ivas_total_brate; + Word32 ivas_total_brate; ivas_error error; Word16 e_sig[CPE_CHANNELS] = { 15, 15 }; move16(); @@ -327,6 +327,7 @@ ivas_error ivas_mct_dec_fx( push_wmops( "ivas_mct_dec" ); error = IVAS_ERR_OK; + move32(); nCPE = st_ivas->nCPE; move16(); hMCT = st_ivas->hMCT; @@ -399,18 +400,20 @@ ivas_error ivas_mct_dec_fx( FOR( cpe_id = 0; cpe_id < nCPE; cpe_id++ ) { st_ivas->hCPE[cpe_id]->hCoreCoder[0]->BER_detect = s_or( st_ivas->hCPE[cpe_id]->hCoreCoder[0]->BER_detect, st_ivas->BER_detect ); - test(); + move16(); st_ivas->hCPE[cpe_id]->hCoreCoder[1]->BER_detect = s_or( st_ivas->hCPE[cpe_id]->hCoreCoder[1]->BER_detect, st_ivas->BER_detect ); - test(); + move16(); FOR( n = 0; n < CPE_CHANNELS; n++ ) { x_fx[n][0] = output_fx[add( n, shl( cpe_id, 1 /* * CPE_CHANNELS*/ ) )]; x_e[n][0] = 20; move16(); + move16(); x_fx[n][1] = output_fx[add( n, shl( cpe_id, 1 /* * CPE_CHANNELS*/ ) )] + ( L_FRAME48k / 2 ); x_e[n][1] = 20; move16(); + move16(); set32_fx( x_fx[n][0], 0, L_FRAME48k / 2 ); set32_fx( x_fx[n][1], 0, L_FRAME48k / 2 ); @@ -439,10 +442,8 @@ ivas_error ivas_mct_dec_fx( st_ivas->BER_detect = s_or( st_ivas->BER_detect, st_ivas->hCPE[cpe_id]->hCoreCoder[0]->BER_detect ); move16(); - test(); st_ivas->BER_detect = s_or( st_ivas->BER_detect, st_ivas->hCPE[cpe_id]->hCoreCoder[1]->BER_detect ); move16(); - test(); } @@ -471,6 +472,7 @@ ivas_error ivas_mct_dec_fx( FOR( n = 0; n < CPE_CHANNELS; n++ ) { st_ivas->hCPE[cpe_id]->hCoreCoder[n]->mct_chan_mode = MCT_CHAN_MODE_IGNORE; + move16(); } } } @@ -488,6 +490,8 @@ ivas_error ivas_mct_dec_fx( x_fx[n][1] = output_fx[add( n, shl( cpe_id, 1 /* * CPE_CHANNELS*/ ) )] + ( L_FRAME48k / 2 ); x_e[n][0] = 20; move16(); + move16(); + move16(); x_e[n][1] = 20; move16(); } @@ -597,6 +601,7 @@ ivas_error ivas_mct_dec_fx( { hCPE->hCoreCoder[n]->hBPF->pst_mem_deemp_err_fx = extract_l( L_shr( hCPE->hCoreCoder[n]->mem_error, sub( Q16, sub( hCPE->hCoreCoder[n]->Q_syn2, 1 ) ) ) ); Scale_sig( hCPE->hCoreCoder[n]->hBPF->pst_old_syn_fx, NBPSF_PIT_MAX, sub( hCPE->hCoreCoder[n]->Q_syn2, 1 ) ); + move16(); } } @@ -750,7 +755,7 @@ ivas_error create_mct_dec_fx( { hMCT->nchan_out_woLFE = st_ivas->nchan_transport; move16(); - IF( EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) + if ( EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) { hMCT->nchan_out_woLFE = add( hMCT->nchan_out_woLFE, st_ivas->nchan_ism ); move16(); @@ -789,7 +794,7 @@ ivas_error create_mct_dec_fx( } /* in case we have an uneven number of transport channels, indicate last channel ID as inactive */ - IF( hMCT->nchan_out_woLFE % 2 ) + if ( hMCT->nchan_out_woLFE % 2 ) { st_ivas->hCPE[sub( st_ivas->nCPE, 1 )]->hCoreCoder[1]->mct_chan_mode = MCT_CHAN_MODE_IGNORE; move32(); @@ -1154,6 +1159,7 @@ ivas_error mct_dec_reconfigure_fx( tmp = extract_l( L_shr( log_tmp, Q25 ) ); tmp = add( tmp, 1 ); hMCT->bitsChannelPairIndex = s_max( 1, tmp ); + move16(); set16_fx( hMCT->chBitRatios, 0, MCT_MAX_CHANNELS ); set16_fx( hMCT->lowE_ch, 0, MCT_MAX_CHANNELS ); @@ -1411,6 +1417,7 @@ ivas_error ivas_mc_dec_config_fx( /* store last frame MC mode */ last_mc_mode = st_ivas->mc_mode; + move16(); IF( st_ivas->bfi == 0 ) { @@ -1716,13 +1723,13 @@ static ivas_error ivas_mc_dec_reconfig_fx( test(); IF( ( EQ_16( st_ivas->renderer_type, RENDERER_MC ) ) && st_ivas->hLsSetUpConversion == NULL ) { - IF( NE_32( ( error = ivas_ls_setup_conversion_open_fx( st_ivas ) ), IVAS_ERR_OK ) ) + IF( ( error = ivas_ls_setup_conversion_open_fx( st_ivas ) ) != IVAS_ERR_OK ) { return error; } } - IF( NE_32( ( error = ivas_mc_paramupmix_dec_open( st_ivas ) ), IVAS_ERR_OK ) ) + IF( ( error = ivas_mc_paramupmix_dec_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } @@ -2097,13 +2104,13 @@ static ivas_error ivas_mc_dec_reconfig_fx( } ELSE IF( st_ivas->hBinRendererTd == NULL && EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) ) { - IF( NE_32( ( error = ivas_td_binaural_open_fx( st_ivas, &st_ivas->SrcInd[0], &st_ivas->num_src ) ), IVAS_ERR_OK ) ) + IF( ( error = ivas_td_binaural_open_fx( st_ivas, &st_ivas->SrcInd[0], &st_ivas->num_src ) ) != IVAS_ERR_OK ) { return error; } IF( EQ_16( st_ivas->hIntSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { - IF( NE_32( ( error = ivas_rend_initCrendWrapper( &st_ivas->hCrendWrapper ) ), IVAS_ERR_OK ) ) + IF( ( error = ivas_rend_initCrendWrapper( &st_ivas->hCrendWrapper ) ) != IVAS_ERR_OK ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend Wrapper\n" ); } @@ -2118,7 +2125,7 @@ static ivas_error ivas_mc_dec_reconfig_fx( } ELSE IF( st_ivas->hCrendWrapper == NULL && ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) ) { - IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) ) + IF( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) { return error; } @@ -2126,15 +2133,6 @@ static ivas_error ivas_mc_dec_reconfig_fx( move32(); } } -/* mono/stereo */ -ELSE IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) -{ - /* nothing should happen here... */ -} -/* LS */ -ELSE IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_5_1 ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_5_1_2 ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_5_1_4 ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_7_1 ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_7_1_4 ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) -{ -} } /*-----------------------------------------------------------------* * CLDFB instances @@ -2184,6 +2182,7 @@ IF( NE_32( ( error = ivas_cldfb_dec_reconfig_fx( st_ivas, nchan_transport_old, n move16(); tc_buffer_mode_new = TC_BUFFER_MODE_RENDERER; move32(); + test(); IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) ) { tc_buffer_mode_new = TC_BUFFER_MODE_BUFFER; diff --git a/lib_dec/ivas_mct_dec_mct_fx.c b/lib_dec/ivas_mct_dec_mct_fx.c index 29685d898c85cf9c9c892823571a64189ed0b5af..d6e5b686582b0a9899e0b6faf964b0be72470225 100644 --- a/lib_dec/ivas_mct_dec_mct_fx.c +++ b/lib_dec/ivas_mct_dec_mct_fx.c @@ -72,7 +72,7 @@ static void indexToChannelPair_fx( } ELSE { - tmpIdx++; + tmpIdx = add( tmpIdx, 1 ); } } } @@ -239,7 +239,7 @@ void apply_MCT_dec_fx( Word16 pair; MCT_DEC_BLOCK_DATA_HANDLE hBlock; - FOR( pair = hMCT->currBlockDataCnt - 1; pair >= 0; pair-- ) + FOR( pair = sub( hMCT->currBlockDataCnt, 1 ); pair >= 0; pair-- ) { hBlock = hMCT->hBlockData[pair]; @@ -353,12 +353,13 @@ void mctStereoIGF_dec_fx( st = sts[ch]; test(); - IF( bfi && ( st->core == ACELP_CORE ) ) /*no igf processing needed*/ + if ( bfi && ( st->core == ACELP_CORE ) ) /*no igf processing needed*/ { CONTINUE; } tmp = BASOP_Util_Divide1616_Scale( st->hTcxCfg->tcx_coded_lines, nSubframes, &tmp_e ); L_spec[ch] = shr( tmp, add( 15, negate( tmp_e ) ) ); + move32(); tmp = BASOP_Util_Divide1616_Scale( st->L_frame, nSubframes, &tmp_e ); L_frame_nSubframe = shr( tmp, add( 15, negate( tmp_e ) ) ); @@ -394,11 +395,11 @@ void mctStereoIGF_dec_fx( { st = stm[ch]; test(); - IF( bfi && ( st->core == ACELP_CORE ) ) /*no igf processing needed*/ + if ( bfi && ( st->core == ACELP_CORE ) ) /*no igf processing needed*/ { CONTINUE; } - IF( EQ_16( st->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) + if ( EQ_16( st->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) { CONTINUE; } @@ -419,6 +420,7 @@ void mctStereoIGF_dec_fx( tmp = BASOP_Util_Divide1616_Scale( st->hTcxCfg->tcx_coded_lines, nSubframes, &tmp_e ); L_spec[0] = shr( tmp, add( 15, negate( tmp_e ) ) ); + move32(); tmp = BASOP_Util_Divide1616_Scale( st->L_frame, nSubframes, &tmp_e ); L_frame_nSubframe = shr( tmp, add( 15, negate( tmp_e ) ) ); @@ -438,6 +440,7 @@ void mctStereoIGF_dec_fx( { // Converting from variable exponent to Fixed q-factor (Q12) x[ch][k][i] = L_shr( x[ch][k][i], sub( 31 - Q12, x_e ) ); + move32(); } } } diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal.c index 02b6cc099117f0ab3b1cbb7f189d49d6618f3200..7379ca1d6cedc65bfd0919f6151b1457b9fcd669 100644 --- a/lib_dec/ivas_sba_rendering_internal.c +++ b/lib_dec/ivas_sba_rendering_internal.c @@ -762,6 +762,7 @@ ivas_error ivas_sba_linear_renderer_fx( ivas_error error; error = IVAS_ERR_OK; + move32(); /* Number of channels of HOA depends of transport format which is mixed order xH1V*/ nchan_hoa = nchan_in; @@ -881,7 +882,6 @@ void ivas_sba_mix_matrix_determiner_fx( Word16 i, ch; Word16 num_bands_out, nchan_transport, nchan_out; Word16 Q_p_output = add( 11, Q_output ); - move16(); Word32 temp_fx; /* Convert numeric range */ FOR( ch = 0; ch < nchan_remapped; ch++ ) diff --git a/lib_dec/ivas_sce_dec_fx.c b/lib_dec/ivas_sce_dec_fx.c index 491a89f285c1d1e6db2fbb4ab22a77c18d0abfd3..f38068570436aa6a0b928c8675e9288c1d1f6247 100644 --- a/lib_dec/ivas_sce_dec_fx.c +++ b/lib_dec/ivas_sce_dec_fx.c @@ -65,6 +65,7 @@ ivas_error ivas_sce_dec_fx( ivas_error error; error = IVAS_ERR_OK; + move32(); push_wmops( "ivas_sce_dec" ); diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 755c9b52d8eabeaab4425fe539a527d55a795078..4c1c9d00849bfd92ce9bd1807caa7215b32e7f5c 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -331,14 +331,14 @@ ivas_error ivas_spar_dec_open_fx( } ELSE { - IF( NE_32( ( error = ivas_td_decorr_dec_open_fx( &hSpar->hTdDecorr, output_Fs, add( num_decor_chs, 1 ), 1 ) ), IVAS_ERR_OK ) ) + IF( ( error = ivas_td_decorr_dec_open_fx( &hSpar->hTdDecorr, output_Fs, add( num_decor_chs, 1 ), 1 ) ) != IVAS_ERR_OK ) { return error; } } /* MD handle */ - IF( NE_32( ( error = ivas_spar_md_dec_open( &hSpar->hMdDec, st_ivas->hDecoderConfig, num_channels_internal, sba_order_internal, st_ivas->sid_format, st_ivas->last_active_ivas_total_brate ) ), IVAS_ERR_OK ) ) + IF( ( error = ivas_spar_md_dec_open( &hSpar->hMdDec, st_ivas->hDecoderConfig, num_channels_internal, sba_order_internal, st_ivas->sid_format, st_ivas->last_active_ivas_total_brate ) ) != IVAS_ERR_OK ) { return error; } @@ -466,7 +466,7 @@ ivas_error ivas_spar_dec_open_fx( buffer_mode = TC_BUFFER_MODE_RENDERER; move32(); - nchan_tc = ivas_jbm_dec_get_num_tc_channels( st_ivas ); + nchan_tc = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ); nchan_to_allocate = num_channels_internal; move16(); @@ -517,7 +517,6 @@ ivas_error ivas_spar_dec_open_fx( Word32 quo, rem; iDiv_and_mod_32( st_ivas->hDecoderConfig->output_Fs, FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES, &quo, &rem, 0 ); granularity = extract_l( quo ); - move16(); } IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, granularity ) ), IVAS_ERR_OK ) ) @@ -1207,7 +1206,7 @@ void ivas_spar_get_cldfb_gains_fx( test(); test(); test(); - IF( GT_16( num_cf_slots, 3 ) || GT_16( pt_len, 10 * CLDFB_NO_CHANNELS_MAX ) || GT_16( stride, CLDFB_NO_CHANNELS_MAX ) || EQ_16( split_band, IVAS_MAX_NUM_BANDS ) ) + if ( GT_16( num_cf_slots, 3 ) || GT_16( pt_len, 10 * CLDFB_NO_CHANNELS_MAX ) || GT_16( stride, CLDFB_NO_CHANNELS_MAX ) || EQ_16( split_band, IVAS_MAX_NUM_BANDS ) ) { return; } @@ -1347,7 +1346,7 @@ Word16 ivas_is_res_channel( { 0, 1, 1, 1 } }; - IF( GE_16( ch, FOA_CHANNELS ) ) + if ( GE_16( ch, FOA_CHANNELS ) ) { /* never transmitted */ return 0; @@ -2268,7 +2267,7 @@ static void ivas_spar_calc_smooth_facs_fx( { test(); test(); - IF( GE_16( bin, CLDFB_NO_CHANNELS_MAX ) || ( ( b > 0 ) && LT_16( bin2band->p_cldfb_map_to_spar_band[bin], bin2band->p_cldfb_map_to_spar_band[bin - 1] ) ) ) + if ( GE_16( bin, CLDFB_NO_CHANNELS_MAX ) || ( ( b > 0 ) && LT_16( bin2band->p_cldfb_map_to_spar_band[bin], bin2band->p_cldfb_map_to_spar_band[bin - 1] ) ) ) { BREAK; } @@ -3081,7 +3080,7 @@ void ivas_spar_dec_upmixer_sf_fx( numch_out = hSpar->hFbMixer->fb_cfg->num_out_chans; move16(); num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); - slot_size = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + slot_size = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); move16(); slot_idx_start = hSpar->slots_rendered; move16(); diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c index 8e89e6b06381abe083f3767737cc468daa926242..3db0ce5290f180297240197ad38e522f9b23e758 100644 --- a/lib_dec/ivas_spar_md_dec.c +++ b/lib_dec/ivas_spar_md_dec.c @@ -42,11 +42,7 @@ #ifdef IVAS_FLOAT_FIXED #include "prot_fx.h" #include "ivas_prot_fx.h" -#endif // IVAS_FLOAT_FIXED -#ifdef IVAS_FLOAT_FIXED #include "ivas_rom_com_fx.h" -#endif -#ifdef IVAS_FLOAT_FIXED /*------------------------------------------------------------------------------------------* * Local constants @@ -66,74 +62,28 @@ static const int16_t ivas_spar_dec_plc_spatial_target[IVAS_SPAR_MAX_CH] = { 1, 0 * Static functions declaration *------------------------------------------------------------------------------------------*/ -#ifdef IVAS_FLOAT_FIXED static void ivas_get_spar_matrices_fx( ivas_spar_md_dec_state_t *hMdDec, const Word16 num_bands_out, const Word16 n_ts, const Word16 bw, const Word16 dtx_vad, const Word16 nB, const Word16 numch_out, const Word16 active_w_vlbr, const Word16 dyn_active_w_flag ); static void ivas_decode_arith_bs( ivas_spar_md_dec_state_t *hMdDec, Decoder_State *st, const UWord16 qsi, const Word16 nB, const Word16 bands_bw, Word16 *pDo_diff, const Word16 strat, const Word32 ivas_total_brate ); static void ivas_decode_huffman_bs( ivas_spar_md_dec_state_t *hMdDec, Decoder_State *st, const UWord16 qsi, const Word16 nB, const Word16 bands_bw ); static void ivas_fill_band_coeffs_idx( ivas_band_coeffs_ind_t *pBands_idx, const Word16 nB, Word16 *pSymbol_re, ivas_cell_dim_t *pCell_dims, ivas_coeffs_type_t coeff_type ); -#else -static void ivas_get_spar_matrices( ivas_spar_md_dec_state_t *hMdDec, const int16_t num_bands_out, const int16_t n_ts, const int16_t bw, const int16_t dtx_vad, const int16_t nB, const int16_t numch_out, const int16_t active_w_vlbr, const int16_t dyn_active_w_flag ); -static void ivas_decode_arith_bs( ivas_spar_md_dec_state_t *hMdDec, Decoder_State *st, const uint16_t qsi, const int16_t nB, const int16_t bands_bw, int16_t *pDo_diff, const int16_t strat, const int32_t ivas_total_brate ); - -static void ivas_decode_huffman_bs( ivas_spar_md_dec_state_t *hMdDec, Decoder_State *st, const uint16_t qsi, const int16_t nB, const int16_t bands_bw ); - -static void ivas_fill_band_coeffs_idx( ivas_band_coeffs_ind_t *pBands_idx, const int16_t nB, int16_t *pSymbol_re, ivas_cell_dim_t *pCell_dims, ivas_coeffs_type_t coeff_type ); -#endif - -#ifndef IVAS_FLOAT_FIXED -static void ivas_mat_col_rearrange( float in_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], const int16_t order[IVAS_SPAR_MAX_CH], const int16_t i_ts, float ***mixer_mat, const int16_t bands, const int16_t num_ch ); -#else static void ivas_mat_col_rearrange_fx( Word32 in_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], const Word16 order[IVAS_SPAR_MAX_CH], const Word16 i_ts, Word32 ***mixer_mat, const Word16 bands, const Word16 num_ch ); -#endif - -#ifndef IVAS_FLOAT_FIXED -static void ivas_spar_dec_compute_ramp_down_post_matrix( ivas_spar_md_dec_state_t *hMdDec, const int16_t num_bands, const int16_t bfi, const int16_t num_md_sub_frames ); -#endif -#ifdef IVAS_FLOAT_FIXED static void ivas_spar_dec_compute_ramp_down_post_matrix_fx( ivas_spar_md_dec_state_t *hMdDec, const Word16 num_bands, const Word16 bfi, const Word16 num_md_sub_frames ); -#endif // IVAS_FLOAT_FIXED -#ifdef IVAS_FLOAT_FIXED static void ivas_spar_md_fill_invalid_bands_fx( ivas_spar_dec_matrices_t *pSpar_coeffs, ivas_spar_dec_matrices_t *pSpar_coeffs_prev, const Word16 *valid_bands, Word16 *base_band_age, const Word16 num_bands, const Word16 num_channels, const Word16 num_md_sub_frames ); -#endif -#ifndef IVAS_FLOAT_FIXED -static void ivas_spar_md_fill_invalid_bands( ivas_spar_dec_matrices_t *pSpar_coeffs, ivas_spar_dec_matrices_t *pSpar_coeffs_prev, const int16_t *valid_bands, int16_t *base_band_age, const int16_t num_bands, const int16_t numch_out, const int16_t num_md_sub_frames ); -#endif -#ifdef IVAS_FLOAT_FIXED static void ivas_spar_md_fill_invalid_bandcoeffs( ivas_band_coeffs_t *pBand_coeffs, ivas_band_coeffs_t *pBand_coeffs_prev, const Word16 *valid_bands, Word16 *base_band_age, Word16 *first_valid_frame, const Word16 num_bands ); -#else -static void ivas_spar_md_fill_invalid_bandcoeffs( ivas_band_coeffs_t *pBand_coeffs, ivas_band_coeffs_t *pBand_coeffs_prev, const int16_t *valid_bands, int16_t *base_band_age, int16_t *first_valid_frame, const int16_t num_bands ); -#endif -#ifdef IVAS_FLOAT_FIXED static ivas_error ivas_spar_set_dec_config( ivas_spar_md_dec_state_t *hMdDec, const Word16 nchan_transport, Word32 *pFC ); -#else -static ivas_error ivas_spar_set_dec_config( ivas_spar_md_dec_state_t *hMdDec, const int16_t nchan_transport, float *pFC ); -#endif -#ifdef IVAS_FLOAT_FIXED static void ivas_parse_parameter_bitstream_dtx( ivas_spar_md_t *pSpar_md, Decoder_State *st, const Word16 bw, const Word16 num_bands, Word16 *num_dmx_per_band, Word16 *num_dec_per_band ); -#else -static void ivas_parse_parameter_bitstream_dtx( ivas_spar_md_t *pSpar_md, Decoder_State *st, const int16_t bw, const int16_t num_bands, int16_t *num_dmx_per_band, int16_t *num_dec_per_band ); -#endif -#ifndef IVAS_FLOAT_FIXED -static ivas_error ivas_deindex_real_index( const int16_t *index, const int16_t q_levels, const float min_value, const float max_value, float *quant, const int16_t num_ch_dim2 ); -#endif -#ifdef IVAS_FLOAT_FIXED static ivas_error ivas_deindex_real_index_fx( const Word16 *index, const Word16 q_levels, const Word32 min_value, const Word32 max_value, Word32 *quant, const Word16 num_ch_dim2 ); -#endif -#ifdef IVAS_FLOAT_FIXED static void ivas_spar_dec_parse_md_bs_fx( ivas_spar_md_dec_state_t *hMdDec, Decoder_State *st, Word16 *nB, Word16 *bands_bw, Word16 *dtx_vad, const Word32 ivas_total_brate, const Word16 sba_inactive_mode ); -#else -static void ivas_spar_dec_parse_md_bs( ivas_spar_md_dec_state_t *hMdDec, Decoder_State *st, int16_t *nB, int16_t *bands_bw, int16_t *dtx_vad, const int32_t ivas_total_brate, const int16_t sba_inactive_mode ); -#endif #ifndef IVAS_FLOAT_FIXED @@ -401,7 +351,6 @@ ivas_error ivas_spar_md_dec_matrix_open_fx( } } - // Fix Memory IF( ( hMdDec->spar_coeffs_prev.P_re_fx = (Word32 ***) malloc( i_mult( num_channels, sizeof( Word32 ** ) ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD matrix" ); @@ -420,7 +369,6 @@ ivas_error ivas_spar_md_dec_matrix_open_fx( } } } - // Fix Memory IF( ( hMdDec->spar_coeffs_tar.C_re_fx = (Word32 ***) malloc( i_mult( num_channels, sizeof( Word32 ** ) ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD matrix" ); @@ -439,7 +387,6 @@ ivas_error ivas_spar_md_dec_matrix_open_fx( } } } - // Fix Memory IF( ( hMdDec->spar_coeffs_tar.P_re_fx = (Word32 ***) malloc( i_mult( num_channels, sizeof( Word32 ** ) ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD matrix" ); @@ -2619,7 +2566,7 @@ static void ivas_get_spar_matrices_fx( } hMdDec->spar_coeffs.C_re_fx[0][0][add( i_mult( b, bw ), i_mult( i_ts, IVAS_MAX_NUM_BANDS ) )] = - max( 0, hMdDec->spar_coeffs.C_re_fx[0][0][add( i_mult( b, bw ), i_mult( i_ts, IVAS_MAX_NUM_BANDS ) )] ); + L_max( 0, hMdDec->spar_coeffs.C_re_fx[0][0][add( i_mult( b, bw ), i_mult( i_ts, IVAS_MAX_NUM_BANDS ) )] ); move32(); } } @@ -3251,22 +3198,6 @@ static void ivas_spar_dec_parse_md_bs_fx( } qs = hMdDec->spar_md_cfg.quant_strat[qsi]; - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); strat = get_next_indice_fx( st0, 3 ); @@ -3470,6 +3401,11 @@ static void ivas_decode_arith_bs( ndec = hMdDec->spar_md_cfg.num_decorr_per_band[bands_bw * i]; move16(); move16(); + test(); + test(); + test(); + test(); + test(); IF( LT_32( ivas_total_brate, IVAS_24k4 ) && GT_16( strat, 3 ) && ( ( EQ_16( i % 2, 1 ) && ( strat % 2 == 0 ) ) || ( ( i % 2 == 0 ) && EQ_16( strat % 2, 1 ) ) ) ) { pred_cell_dims[i].dim1 = 0; @@ -3488,16 +3424,17 @@ static void ivas_decode_arith_bs( move16(); move16(); move16(); - move16(); } ELSE { pred_cell_dims[i].dim1 = add( ndm, sub( ndec, 1 ) ); + move16(); IF( hMdDec->spar_hoa_md_flag && hMdDec->spar_hoa_dirac2spar_md_flag ) { IF( GE_16( i, SPAR_DIRAC_SPLIT_START_BAND ) ) { pred_cell_dims[i].dim1 = sub( pred_cell_dims[i].dim1, ( FOA_CHANNELS - 1 ) ); + move16(); } } pred_cell_dims[i].dim2 = 1; @@ -4223,7 +4160,7 @@ static void ivas_spar_dec_compute_ramp_down_post_matrix_fx( } ELSE { - IF( hMdDec->td_decorr_flag == 0 ) + if ( hMdDec->td_decorr_flag == 0 ) { assert( 0 ); } @@ -5058,6 +4995,7 @@ void ivas_spar_to_dirac_fx( hSpatParamRendCom = st_ivas->hSpatParamRendCom; dirac_to_spar_md_bands = st_ivas->hSpar->dirac_to_spar_md_bands; + move16(); IF( st_ivas->hSpar->enc_param_start_band > 0 ) { @@ -5203,9 +5141,9 @@ void ivas_spar_to_dirac_fx( ele_res = extract_l( L_shr( ele_intermediate, 22 ) ); } - azi[band] = max( -180, min( 180, azi_res ) ); + azi[band] = s_max( -180, s_min( 180, azi_res ) ); move16(); - ele[band] = max( -90, min( 180, ele_res ) ); + ele[band] = s_max( -90, s_min( 180, ele_res ) ); move16(); } diff --git a/lib_dec/ivas_stereo_adapt_GR_dec.c b/lib_dec/ivas_stereo_adapt_GR_dec.c index 3eed99635d62285fd9f829559778b26509de909c..b47aa68ae69833768431522edfc2411a82c39de0 100644 --- a/lib_dec/ivas_stereo_adapt_GR_dec.c +++ b/lib_dec/ivas_stereo_adapt_GR_dec.c @@ -82,15 +82,18 @@ static Word16 read_GR2( ELSE { temp = (UWord16) ( L_add( temp, 1 ) ); + move16(); } } WHILE( ready == 0 ); b = *p++; move16(); b = (UWord16) L_add( L_shl( b, 1 ), *p++ ); + move16(); ind[i] = extract_l( L_add( L_shl( temp, 2 ), b ) ); move16(); nb = (UWord16) L_add( nb, L_add( temp, 3 ) ); + move16(); } return nb; @@ -136,6 +139,7 @@ static Word16 read_GR1( ELSE { temp = (UWord16) ( L_add( temp, 1 ) ); + move16(); } } WHILE( ready == 0 ); @@ -145,6 +149,7 @@ static Word16 read_GR1( ind[i] = extract_l( L_add( L_shl( temp, 1 ), b ) ); move16(); nb = (UWord16) L_add( nb, L_add( temp, 2 ) ); + move16(); } return nb; @@ -190,12 +195,14 @@ Word16 read_GR0( ELSE { temp = (UWord16) L_add( temp, 1 ); + move16(); } } WHILE( ready == 0 ); ind[i] = temp; move16(); nb = (UWord16) L_add( nb, L_add( temp, 1 ) ); + move16(); } return nb; @@ -290,6 +297,8 @@ Word16 get_value( { val = (UWord16) L_add( val, L_shl( bit_stream[i], mask ) ); mask = (UWord16) L_add( mask, 1 ); + move16(); + move16(); } return val; @@ -420,8 +429,8 @@ Word16 read_itd( Word16 huff_flag, sign_flag, I, i, nb = 0, ready; move16(); - huff_flag = (Word16) get_next_indice_fx( st, 1 ); - sign_flag = (Word16) get_next_indice_fx( st, 1 ); + huff_flag = extract_l( get_next_indice_fx( st, 1 ) ); + sign_flag = extract_l( get_next_indice_fx( st, 1 ) ); nb = add( nb, 2 ); IF( EQ_16( huff_flag, 1 ) ) @@ -434,7 +443,7 @@ Word16 read_itd( WHILE( ( ready == 0 ) && ( LT_16( nb, 10 ) ) ) { test(); - I = add( shl( I, 1 ), (Word16) get_next_indice_fx( st, 1 ) ); + I = add( shl( I, 1 ), extract_l( get_next_indice_fx( st, 1 ) ) ); nb = add( nb, 1 ); FOR( i = 0; i < 20; i++ ) @@ -457,7 +466,7 @@ Word16 read_itd( } ELSE { - I = (Word16) get_next_indice_fx( st, STEREO_DFT_ITD_NBITS - 1 ); + I = extract_l( get_next_indice_fx( st, STEREO_DFT_ITD_NBITS - 1 ) ); nb = add( nb, STEREO_DFT_ITD_NBITS - 1 ); } diff --git a/lib_dec/ivas_stereo_cng_dec.c b/lib_dec/ivas_stereo_cng_dec.c index 8ef692402e587e93291d12f0df28794d6d1a11ec..e9669f4b00c928a7fd5040c3d8ea19e187ae767a 100644 --- a/lib_dec/ivas_stereo_cng_dec.c +++ b/lib_dec/ivas_stereo_cng_dec.c @@ -720,8 +720,6 @@ static void stereo_dft_generate_comfort_noise_fx( Word16 trigo_dec[STEREO_DFT32MS_N_16k / 2 + 1]; const Word16 *pTrigo; Word16 trigo_step; - // Word16 addl_guard_bits; - // Word16 max_diff; Word32 tmp32_1, tmp32_2; Word16 q_div, q_sqrt1, q_sqrt2, q_sqrt, sqrt_res; Word16 q_shift; @@ -1859,6 +1857,7 @@ static void stereo_cng_compute_LRcorr_fx( Word16 denom_1_q, denom_2_q, denom_3_q, denom_q; Word32 beta_sqr, one_minus_beta_sqr; beta_fx = tdm_ratio_tabl_fx[tdm_ratio_idx]; + move32(); enrL_fx = 0; move64(); diff --git a/lib_dec/ivas_stereo_dft_dec_dmx.c b/lib_dec/ivas_stereo_dft_dec_dmx.c index 849a0bbe9812ab46ea38b0dd3316ffdd7fdfc698..f1b7055e4a536de275a31390c4f7db84f1c7e428 100644 --- a/lib_dec/ivas_stereo_dft_dec_dmx.c +++ b/lib_dec/ivas_stereo_dft_dec_dmx.c @@ -141,6 +141,7 @@ void stereo_dft_unify_dmx_fx( IF( LT_16( output_frame, inner_frame_tbl[st0->bwidth] ) ) { hStereoDft->nbands = stereo_dft_band_config_fx( hStereoDft->band_limits, hStereoDft->band_res[k_offset], hStereoDft->NFFT, DEC ); + move16(); } IF( prev_bfi ) { @@ -158,6 +159,7 @@ void stereo_dft_unify_dmx_fx( test(); hStereoDft->trans = (Word16) ( ( EQ_16( st0->clas_dec, ONSET ) || EQ_16( st0->clas_dec, SIN_ONSET ) || EQ_16( st0->clas_dec, UNVOICED_CLAS ) || EQ_16( st0->clas_dec, UNVOICED_TRANSITION ) ) || LE_16( st0->stab_fac_fx, (Word16) 0x2000 ) ) || ( ( EQ_16( st0->core, TCX_20_CORE ) && ( EQ_16( st0->hTcxCfg->tcx_last_overlap_mode, MIN_OVERLAP ) || EQ_16( st0->hTcxCfg->tcx_last_overlap_mode, HALF_OVERLAP ) ) ) || EQ_16( st0->core, TCX_10_CORE ) ); + move16(); /* Smoothing for the current frame */ stereo_dft_dec_smooth_parameters_fx( hStereoDft, prev_sid_nodata, st0->hFdCngDec->hFdCngCom->active_frame_counter, st0->element_brate ); @@ -370,6 +372,7 @@ void stereo_dft_unify_dmx_fx( move16(); Copy32( pDFT_DMX, hStereoDft->DFT_past_DMX_fx[hStereoDft->past_DMX_pos], s_min( hStereoDft->NFFT, STEREO_DFT32MS_N_32k ) ); hStereoDft->q_DFT_past_DMX_fx[hStereoDft->past_DMX_pos] = hStereoDft->q_dft; + move16(); test(); IF( st0->bfi && !prev_bfi ) { @@ -385,6 +388,7 @@ void stereo_dft_unify_dmx_fx( /*dmx energy memory*/ hStereoDft->past_dmx_nrg_fx = stereo_dft_dmx_swb_nrg_fx( hStereoDft->DFT_past_DMX_fx[idx_k0], hStereoDft->DFT_past_DMX_fx[idx_k1], s_min( hStereoDft->NFFT, STEREO_DFT32MS_N_32k ), q_shift0, q_shift1 ); + move32(); } } @@ -668,17 +672,18 @@ void add_HB_to_mono_dmx_fx( const int16_t output_frame /* i : frame length */ ) { - int16_t i, j, decoderDelay, icbweOLASize, dftOvlLen, memOffset; + Word16 i, j, decoderDelay, icbweOLASize, dftOvlLen, memOffset; Word32 temp_fx[L_FRAME48k + NS2SA( 48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS )]; Word32 winSlope_fx = 0; move32(); Word32 alpha_fx; const Word16 *win_dft_fx; - int32_t output_Fs; + Word32 output_Fs; Word32 *memOutHB_fx, *memTransitionHB_fx; output_Fs = hCPE->hCoreCoder[0]->output_Fs; + move32(); memOutHB_fx = hCPE->hStereoDftDmx->memOutHB_fx; memTransitionHB_fx = hCPE->hStereoDftDmx->memTransitionHB_fx; @@ -686,7 +691,7 @@ void add_HB_to_mono_dmx_fx( move16(); test(); - IF( hCPE->hCoreCoder[0]->core == ACELP_CORE && GT_32( hCPE->hCoreCoder[0]->extl_brate, 0 ) ) + IF( hCPE->hCoreCoder[0]->core == ACELP_CORE && hCPE->hCoreCoder[0]->extl_brate > 0 ) { /* Resampled LB and HB offset */ Copy32( outputHB, temp_fx + memOffset, sub( output_frame, memOffset ) ); diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index a7bcb6285958acfc52dc71044ccf75c510ad0e01..3944dc926cc69d8f582dc4c58a5670950f137f68 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -2806,7 +2806,7 @@ void stereo_dft_generate_res_pred_fx( pred_gain_avg = Madd_32_16( Mpy_32_16_1( hStereoDft->past_res_pred_gain_fx[d_short_ind][b], g_short ), hStereoDft->past_res_pred_gain_fx[d_long_ind][b], g_long ); - g2 = s_min( Mpy_32_16_1( pred_gain_avg, STEREO_DFT_STEFFI_GAIN_AMP_FX ), + g2 = L_min( Mpy_32_16_1( pred_gain_avg, STEREO_DFT_STEFFI_GAIN_AMP_FX ), Madd_32_16( Mpy_32_16_1( pred_gain_avg, sub( MAX_16, STEREO_DFT_STEFFI_GAIN_REST_AMT_FX ) ), g2, STEREO_DFT_STEFFI_GAIN_REST_AMT_FX ) ); q_sqrt = 0; diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 89c3fcc667bff416580b53a24979dfa73ebe276b..9d1f6720cf405dbfc6323527345cc10c9c135ad7 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -589,7 +589,7 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx( n_samples_granularity = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); /* Use the same granularity as tdrend */ } - IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, ivas_jbm_dec_get_num_tc_channels( st_ivas ), nchan_to_allocate, nchan_to_allocate, n_samples_granularity ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ), nchan_to_allocate, nchan_to_allocate, n_samples_granularity ) ), IVAS_ERR_OK ) ) { return error; }