diff --git a/lib_com/enh64.c b/lib_com/enh64.c index b59a9ef6ca2d6ac4a37969948fee25fe5ebd8eda..dda2d451b6e0e13ce1689fdda506acdbd7044e53 100644 --- a/lib_com/enh64.c +++ b/lib_com/enh64.c @@ -1062,6 +1062,7 @@ Word64 W_msu_16_16( Word64 L64_var1, Word16 var2, Word16 var3 ) return L64_var_out; } +/* Below BASOP is not part of STL 2023 library, might be proposed in next update */ /*________________________________________________________________________________________________ | | | Function Name : W_mac_32_32 | diff --git a/lib_com/enh64.h b/lib_com/enh64.h index efc58e83e6894bf892b1dc700e573ce733728083..8aed870a67e0688ab7e3398caa7f7aa040f186b0 100644 --- a/lib_com/enh64.h +++ b/lib_com/enh64.h @@ -36,6 +36,7 @@ Word64 W_msu0_16_16( Word64 L64_acc, Word16 var1, Word16 var2 ); Word64 W_mult_16_16( Word16 var1, Word16 var2 ); Word64 W_mac_16_16( Word64 L64_acc, Word16 var1, Word16 var2 ); Word64 W_msu_16_16( Word64 L64_acc, Word16 var1, Word16 var2 ); +/* BASOP W_mac_32_32 is not part of STL 2023 library, might be proposed in next update */ Word64 W_mac_32_32( Word64 L64_acc, Word32 var1, Word32 var2 ); Word64 W_deposit32_l( Word32 L_var1 ); diff --git a/lib_com/fd_cng_com_fx.c b/lib_com/fd_cng_com_fx.c index f439bbe28c86a3761de3e62f58aa92ae8779e305..a42a85a1590b0c46fb30baff9661cb77e7d41ce8 100644 --- a/lib_com/fd_cng_com_fx.c +++ b/lib_com/fd_cng_com_fx.c @@ -1360,8 +1360,12 @@ void minimum_statistics_fx( scalar16 = shl( scalar16, s3 ); scalar16 = s_max( scalar16, MSALPHACORMAX ); +#ifdef IVAS_ENH32_CADENCE_CHANGES + hFdCngCom->msAlphaCor[cnt] = Madd_32_16( L_mult( scalar16, msAlphaCorAlpha2 ), hFdCngCom->msAlphaCor[cnt], msAlphaCorAlpha ); +#else hFdCngCom->msAlphaCor[cnt] = L_add( Mpy_32_16_1( hFdCngCom->msAlphaCor[cnt], msAlphaCorAlpha ), L_mult( scalar16, msAlphaCorAlpha2 ) ); +#endif move32(); } @@ -1447,8 +1451,12 @@ void minimum_statistics_fx( } /* Compute the PSD (smoothed periodogram) in each band */ +#ifdef IVAS_ENH32_CADENCE_CHANGES + msPsd[j] = round_fx( Madd_32_16( Mpy_32_16_1( msAlpha[j], msPsd[j] ), L_sub( 2147483647l /*1.0 Q31*/, msAlpha[j] ), msPeriodog[j] ) ); +#else msPsd[j] = round_fx( L_add( Mpy_32_16_1( msAlpha[j], msPsd[j] ), Mpy_32_16_1( L_sub( 2147483647l /*1.0 Q31*/, msAlpha[j] ), msPeriodog[j] ) ) ); +#endif move16(); } msPsdSum[cnt] = dotp_s_fx( msPsd + start, psize + start, current_len, CNG_HS ); @@ -1527,13 +1535,21 @@ void minimum_statistics_fx( /* Compute bias correction Bmin */ tmp0 = Mpy_32_16_1( scalar, QeqInv ); +#ifdef IVAS_ENH32_CADENCE_CHANGES + tmp1 = L_msu( 1073741824l /*0.5 Q31*/, msM_win, QeqInv ); +#else tmp1 = L_sub( 1073741824l /*0.5 Q31*/, L_mult( msM_win, QeqInv ) ); +#endif tmp16 = BASOP_Util_Divide3232_uu_1616_Scale( tmp0, tmp1, &s ); msBminWin[j] = L_add( 134217728l /*1.0 Q27*/, L_shl( L_deposit_h( tmp16 ), add( s, 7 - 4 ) ) ); move32(); tmp0 = Mpy_32_16_1( scalar2, QeqInv ); +#ifdef IVAS_ENH32_CADENCE_CHANGES + tmp1 = L_msu( 1073741824l /*0.5 Q31*/, msM_subwin, QeqInv ); +#else tmp1 = L_sub( 1073741824l /*0.5 Q31*/, L_mult( msM_subwin, QeqInv ) ); +#endif tmp16 = BASOP_Util_Divide3232_uu_1616_Scale( tmp0, tmp1, &s ); msBminSubWin[j] = L_add( 134217728l /*1.0 Q27*/, L_shl( L_deposit_h( tmp16 ), s ) ); move32(); diff --git a/lib_com/modif_fs.c b/lib_com/modif_fs.c index 67593def40fda55788f296974738c043ecc238a2..73a08dd3280bf71fd4cd0750fb29bf41fae64032 100644 --- a/lib_com/modif_fs.c +++ b/lib_com/modif_fs.c @@ -537,6 +537,53 @@ void Interpolate_allpass_steep_32( int16_t n, k; Word32 temp_fx[ALLPASSSECTIONS_STEEP - 1]; +#ifdef IVAS_ENH32_CADENCE_CHANGES + /* upper allpass filter chain */ + FOR( k = 0; k < N; k++ ) + { + temp_fx[0] = Madd_32_16( mem_fx[0], in_fx[k], AP2_STEEP_FX[0] ); + move32(); + mem_fx[0] = Msub_32_16( in_fx[k], temp_fx[0], AP2_STEEP_FX[0] ); + move32(); + + /* for better performance, unroll this loop */ + FOR( n = 1; n < ALLPASSSECTIONS_STEEP - 1; n++ ) + { + temp_fx[n] = Madd_32_16( mem_fx[n], temp_fx[n - 1], AP2_STEEP_FX[n] ); + move32(); + mem_fx[n] = Msub_32_16( temp_fx[n - 1], temp_fx[n], AP2_STEEP_FX[n] ); + move32(); + } + + out_fx[2 * k + 1] = Madd_32_16( mem_fx[ALLPASSSECTIONS_STEEP - 1], temp_fx[ALLPASSSECTIONS_STEEP - 2], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); + move32(); + mem_fx[ALLPASSSECTIONS_STEEP - 1] = Msub_32_16( temp_fx[ALLPASSSECTIONS_STEEP - 2], out_fx[2 * k + 1], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); + move32(); + } + + /* lower allpass filter chain */ + FOR( k = 0; k < N; k++ ) + { + temp_fx[0] = Madd_32_16( mem_fx[ALLPASSSECTIONS_STEEP], in_fx[k], AP1_STEEP_FX[0] ); + move32(); + mem_fx[ALLPASSSECTIONS_STEEP] = Msub_32_16( in_fx[k], temp_fx[0], AP1_STEEP_FX[0] ); + move32(); + + /* for better performance, unroll this loop */ + FOR( n = 1; n < ALLPASSSECTIONS_STEEP - 1; n++ ) + { + temp_fx[n] = Madd_32_16( mem_fx[ALLPASSSECTIONS_STEEP + n], temp_fx[n - 1], AP1_STEEP_FX[n] ); + move32(); + mem_fx[ALLPASSSECTIONS_STEEP + n] = Msub_32_16( temp_fx[n - 1], temp_fx[n], AP1_STEEP_FX[n] ); + move32(); + } + + out_fx[2 * k] = Madd_32_16( mem_fx[2 * ALLPASSSECTIONS_STEEP - 1], temp_fx[ALLPASSSECTIONS_STEEP - 2], AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); + move32(); + mem_fx[2 * ALLPASSSECTIONS_STEEP - 1] = Msub_32_16( temp_fx[ALLPASSSECTIONS_STEEP - 2], out_fx[2 * k], AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); + move32(); + } +#else /* upper allpass filter chain */ FOR( k = 0; k < N; k++ ) { @@ -582,6 +629,7 @@ void Interpolate_allpass_steep_32( mem_fx[2 * ALLPASSSECTIONS_STEEP - 1] = L_sub( temp_fx[ALLPASSSECTIONS_STEEP - 2], Mpy_32_16_1( out_fx[2 * k], AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) ); move32(); } +#endif return; } diff --git a/lib_com/options.h b/lib_com/options.h index b9d043c2cf0021eacbf79d0204b815869d555363..be93e6a440487527d69c6633b817f10dc1260f3e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -95,6 +95,7 @@ #define FIX_785_REMOVE_DEAD_CODE /* VA: issue 785: remove dead code */ #define FIX_852_FIX_HANDLE_DEREF /* VA: issue 852: Fix missing handle dereferencing of hIsmMetadaData in ivas_ism_metadata_close() */ #define FIX_901_PARAMMC_DEAD_CODE /* FhG: issue 901: remove dead ParamMC code */ +#define IVAS_ENH32_CADENCE_CHANGES /* #################### End BE switches ################################## */ diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c index 77c92e20210491566362de6877683a402a48ff04..270b9a5bc1f83497177ee107478658d6a2fb8daa 100644 --- a/lib_dec/acelp_core_dec_ivas_fx.c +++ b/lib_dec/acelp_core_dec_ivas_fx.c @@ -176,13 +176,21 @@ ivas_error acelp_core_dec_ivas_fx( FdCng_decodeSID_ivas_fx( st ); rescale_fdCngDec( st->hFdCngDec, sub( old_NoiseEstExp, st->hFdCngDec->hFdCngCom->sidNoiseEstExp ) ); } +#ifdef IVAS_ENH32_CADENCE_CHANGES + FOR( i = 0; i < NPART; i++ ) + { + st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] = Madd_32_32( Mpy_32_32( STEREO_DFT_FD_FILT_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] ), + STEREO_DFT_FD_FILT_COMP_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEst[i] ); + move32(); + } +#else FOR( i = 0; i < NPART; i++ ) { st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] = L_add( Mpy_32_32( STEREO_DFT_FD_FILT_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] ), Mpy_32_32( STEREO_DFT_FD_FILT_COMP_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEst[i] ) ); move32(); } - +#endif ApplyFdCng_ivas_fx( NULL, 0, NULL, 0, NULL, NULL, NULL, st, 0, 0 ); IF( st->hFdCngDec->hFdCngCom->cngNoiseLevelExp < 0 ) @@ -673,12 +681,21 @@ ivas_error acelp_core_dec_ivas_fx( { assert( nchan_out == 1 ); +#ifdef IVAS_ENH32_CADENCE_CHANGES + FOR( i = 0; i < NPART; i++ ) + { + st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] = Madd_32_32( Mpy_32_32( STEREO_DFT_FD_FILT_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] ), + STEREO_DFT_FD_FILT_COMP_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEst[i] ); + move32(); + } +#else FOR( i = 0; i < NPART; i++ ) { st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] = L_add( Mpy_32_32( STEREO_DFT_FD_FILT_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] ), Mpy_32_32( STEREO_DFT_FD_FILT_COMP_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEst[i] ) ); move32(); } +#endif Word16 new_sidNoiseEstExp = 31 - Q4; move16(); Scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART, sub( st->hFdCngDec->hFdCngCom->sidNoiseEstExp, new_sidNoiseEstExp ) ); diff --git a/lib_dec/bass_psfilter.c b/lib_dec/bass_psfilter.c index c33edf96c6f4aee536b678176959b4ff41a32f70..63e304417487c1c270e297c350d122e1cc935c32 100644 --- a/lib_dec/bass_psfilter.c +++ b/lib_dec/bass_psfilter.c @@ -571,6 +571,20 @@ void addBassPostFilter_ivas_fx( cldfbAnalysis_ivas_fx( harm_timeIn_fx, tmp_R_fx, tmp_I_fx, samplesToProcess, cldfb ); +#ifdef IVAS_ENH32_CADENCE_CHANGES + /* now do the subtraction */ + FOR( i = 0; i < nColToProcess; i++ ) + { + /* loop over low frequency bands */ + FOR( b = 0; b < maxBand; b++ ) + { + rAnalysis_fx[i][b] = Msub_32_32( rAnalysis_fx[i][b], tmp_R_fx[i][b], weights_fx[b] ); // Qx - 6 + move32(); + iAnalysis_fx[i][b] = Msub_32_32( iAnalysis_fx[i][b], tmp_I_fx[i][b], weights_fx[b] ); // Qx - 6 + move32(); + } + } +#else /* now do the subtraction */ FOR( i = 0; i < nColToProcess; i++ ) { @@ -583,6 +597,7 @@ void addBassPostFilter_ivas_fx( move32(); } } +#endif return; } diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index df0da51374392777a1a74645351a7d1cd88a824b..4e93acdfb048f572512c8b253ecab32f59850c0f 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -2679,8 +2679,11 @@ void perform_noise_estimation_dec_ivas_fx( { temp = L_shr( temp, sub( hFdCngDec->msPeriodog_ST_exp, hFdCngDec->hFdCngCom->periodog_exp ) ); } - +#ifdef IVAS_ENH32_CADENCE_CHANGES + hFdCngDec->msPeriodog_ST_fx[p] = Madd_32_16( Mpy_32_16_1( hFdCngDec->msPeriodog_ST_fx[p], ST_PERIODOG_FACT_Q15 ), temp, sub( MAX_16, ST_PERIODOG_FACT_Q15 ) ); +#else hFdCngDec->msPeriodog_ST_fx[p] = L_add( Mpy_32_16_1( hFdCngDec->msPeriodog_ST_fx[p], ST_PERIODOG_FACT_Q15 ), Mpy_32_16_1( temp, sub( MAX_16, ST_PERIODOG_FACT_Q15 ) ) ); +#endif move32(); } } @@ -2761,7 +2764,11 @@ void perform_noise_estimation_dec_ivas_fx( temp = msPeriodog[p]; move32(); temp = L_shr( temp, sub( hFdCngDec->msNoiseEst_exp, hFdCngDec->msPeriodog_exp ) ); +#ifdef IVAS_ENH32_CADENCE_CHANGES + msNoiseEst[p] = Madd_32_16( Mpy_32_16_1( msNoiseEst[p], sub( shl_sat( 1, sub( 15, e ) ), alpha ) ), temp, alpha ); +#else msNoiseEst[p] = L_add( Mpy_32_16_1( msNoiseEst[p], sub( shl_sat( 1, sub( 15, e ) ), alpha ) ), Mpy_32_16_1( temp, alpha ) ); +#endif move32(); } } @@ -2832,7 +2839,11 @@ void perform_noise_estimation_dec_ivas_fx( L_tmp = L_shr( msPeriodog[p], sub( sub( 31, hFdCngDec->hFdCngCom->periodog_exp ), 4 ) ); IF( LT_32( L_tmp, msNoiseEst[p] ) ) { +#ifdef IVAS_ENH32_CADENCE_CHANGES + msNoiseEst[p] = Madd_32_16( Mpy_32_16_1( msNoiseEst[p], wght ), L_tmp, (Word16) L_sub( shr( MAX_16, sub( 15, scale ) ), wght ) ); +#else msNoiseEst[p] = L_add( Mpy_32_16_1( msNoiseEst[p], wght ), Mpy_32_16_1( L_tmp, (Word16) L_sub( shr( MAX_16, sub( 15, scale ) ), wght ) ) ); +#endif move32(); temp_q_msNoiseEst[p] = sub( add( hFdCngDec->msNoiseEst_exp, scale ), 15 ); move16(); @@ -2855,7 +2866,11 @@ void perform_noise_estimation_dec_ivas_fx( L_tmp = L_shr( hFdCngDec->msPeriodog_ST_fx[p], sub( hFdCngDec->msNoiseEst_exp, hFdCngDec->msPeriodog_ST_exp ) ); IF( LT_32( L_tmp, msNoiseEst[p] ) ) { +#ifdef IVAS_ENH32_CADENCE_CHANGES + msNoiseEst[p] = Madd_32_16( Mpy_32_16_1( msNoiseEst[p], CNA_ACT_DN_FACT_Q15 ), L_tmp, ONE_IN_Q15 - CNA_ACT_DN_FACT_Q15 ); +#else msNoiseEst[p] = L_add( Mpy_32_16_1( msNoiseEst[p], CNA_ACT_DN_FACT_Q15 ), Mpy_32_16_1( L_tmp, ONE_IN_Q15 - CNA_ACT_DN_FACT_Q15 ) ); +#endif move32(); } } @@ -2922,7 +2937,11 @@ void perform_noise_estimation_dec_ivas_fx( *ptr_per = 0; move32(); } +#ifdef IVAS_ENH32_CADENCE_CHANGES + *ptr_per = Madd_32_16( ( *ptr_per ), temp, sub( MAX_16, alpha ) ); +#else *ptr_per = L_add( ( *ptr_per ), Mpy_32_16_1( temp, sub( MAX_16, alpha ) ) ); +#endif ptr_per++; } diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal.c index 5a2ee5c77466665375c43b5d612f2b87b8d6ad0c..b30b8533c1b86b6b2e14bd89a0aeaa404481b2fe 100644 --- a/lib_dec/ivas_sba_rendering_internal.c +++ b/lib_dec/ivas_sba_rendering_internal.c @@ -655,6 +655,17 @@ void ivas_ism2sba_sf_fx( move32(); prev_gain_fx = hIsmRendererData->prev_gains_fx[i][j]; move32(); +#ifdef IVAS_ENH32_CADENCE_CHANGES + FOR( k = 0; k < n_samples_to_render; k++ ) + { + g1_fx = sub( 32767, *g2_fx ); + *( out_fx ) = Madd_32_32( *( out_fx ), Madd_32_16( Mult_32_16( gain_fx, ( *( g2_fx ) ) ), prev_gain_fx, g1_fx ), ( *( tc_fx ) ) ); /*Q_buffer_in + 29 - 31*/ + move32(); + g2_fx++; + tc_fx++; + out_fx++; + } +#else FOR( k = 0; k < n_samples_to_render; k++ ) { g1_fx = sub( 32767, *g2_fx ); @@ -664,6 +675,7 @@ void ivas_ism2sba_sf_fx( tc_fx++; out_fx++; } +#endif } } FOR( j = 0; j < sba_num_chans; j++ ) diff --git a/lib_enc/ivas_mct_core_enc.c b/lib_enc/ivas_mct_core_enc.c index 5c7b481e53a23161e7f22be5e30f32bf8d48beee..ba72415325d6461cbb10c0083e3cb2f499fd0543 100644 --- a/lib_enc/ivas_mct_core_enc.c +++ b/lib_enc/ivas_mct_core_enc.c @@ -40,6 +40,7 @@ #include "wmc_auto.h" #ifdef IVAS_FLOAT_FIXED #include "prot_fx.h" +#include "prot_fx_enc.h" #include "ivas_prot_fx.h" #include "prot_fx.h" #endif @@ -597,12 +598,12 @@ void ivas_mct_core_enc( float *inv_mdst_spectrum[MCT_MAX_CHANNELS][2]; float *inv_spectrum[MCT_MAX_CHANNELS][2]; float *mdst_spectrum[MCT_MAX_CHANNELS][2] = { NULL }; - float inv_spectrum_long[MCT_MAX_CHANNELS][L_FRAME48k]; /* quantized MDCT spectrum, inv ms mask mdst spectrum, scratch for MS spectra in the MS decision */ + float inv_spectrum_long[MCT_MAX_CHANNELS][L_FRAME48k]; /* quantized MDCT spectrum, inv ms mask mdst spectrum, scratch for MS spectra in the MS decision */ #if 0 Word32 *orig_spectrum_fx[MCT_MAX_CHANNELS][2]; /* Pointers to MDCT output for a short block (L/R) */ +#endif Word32 powerSpec_fx[MCT_MAX_CHANNELS][L_FRAME48k]; Word32 mdst_fx; -#endif Word32 powerSpecMsInv_long_fx[MCT_MAX_CHANNELS][L_FRAME48k]; /* MS inv power spectrum, also inverse MDST spectrum */ Word32 *powerSpecMsInv_fx[MCT_MAX_CHANNELS][2]; Word32 *inv_mdst_spectrum_fx[MCT_MAX_CHANNELS][2]; @@ -611,12 +612,13 @@ void ivas_mct_core_enc( Word32 inv_spectrum_long_fx[MCT_MAX_CHANNELS][L_FRAME48k]; /* quantized MDCT spectrum, inv ms mask mdst spectrum, scratch for MS spectra in the MS decision */ Word16 total_side_bits; Word16 chBitRatios[MCT_MAX_CHANNELS]; + Word16 q_powSpec[MCT_MAX_CHANNELS], q_spec, tmp_s; + Word16 tmp_q_powSpec[L_FRAME48k], tmp_q_powSpecInv[L_FRAME48k], *tmp_q_psi[2]; + Word64 W_tmp; Encoder_State *sts[MCT_MAX_CHANNELS]; Encoder_State *st; Word16 sp_aud_decision0[MCT_MAX_CHANNELS]; BSTR_ENC_HANDLE hBstr; - float mdst; - push_wmops( "mct_encoding" ); @@ -644,12 +646,22 @@ void ivas_mct_core_enc( inv_spectrum[ch][1] = inv_spectrum_long[ch] + N_TCX10_MAX; #endif + set32_fx( inv_spectrum_long_fx[ch], 0, L_FRAME48k ); + set32_fx( powerSpec_fx[ch], 0, L_FRAME48k ); + set32_fx( powerSpecMsInv_long_fx[ch], 0, L_FRAME48k ); + inv_mdst_spectrum_fx[ch][0] = powerSpecMsInv_fx[ch][0] = powerSpecMsInv_long_fx[ch]; inv_mdst_spectrum_fx[ch][1] = powerSpecMsInv_fx[ch][1] = powerSpecMsInv_long_fx[ch] + N_TCX10_MAX; inv_spectrum_fx[ch][0] = inv_spectrum_long_fx[ch]; inv_spectrum_fx[ch][1] = inv_spectrum_long_fx[ch] + N_TCX10_MAX; } + set16_fx( tmp_q_powSpecInv, 63, L_FRAME48k ); + set16_fx( tmp_q_powSpec, 63, L_FRAME48k ); + + tmp_q_psi[0] = tmp_q_powSpecInv; + tmp_q_psi[1] = &tmp_q_powSpecInv[N_TCX10_MAX]; + FOR( ( cpe_id = 0, i = 0 ); cpe_id < nCPE; cpe_id++ ) { FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) @@ -752,156 +764,195 @@ void ivas_mct_core_enc( * MCT algorithm *---------------------------------------------------------------*/ -#if 1 // Float to Fixed, to be removed - Word16 q_spec = Q31; - Word16 length; - - FOR( ch = 0; ch < nChannels; ch++ ) - { - length = sts[ch]->hTcxEnc->L_frameTCX / ( ( sts[ch]->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV ); - IF( sts[ch]->last_core == ACELP_CORE ) - { - length += length / 4; - } - FOR( Word16 k = 0; k <= ( ( sts[ch]->core == TCX_20_CORE ) ? 1 : NB_DIV ) - 1; k++ ) - { - if ( sts[ch]->hTcxEnc->spectrum[0] ) - { - q_spec = s_min( q_spec, Q_factor_arrL( sts[ch]->hTcxEnc->spectrum[k], length ) - 1 ); - } - IF( mdst_spectrum[ch][0] ) - { - q_spec = s_min( q_spec, Q_factor_arrL( mdst_spectrum[ch][k], length ) - 1 ); - } - } - } - - FOR( ch = 0; ch < nChannels; ch++ ) - { - length = sts[ch]->hTcxEnc->L_frameTCX / ( ( sts[ch]->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV ); - IF( sts[ch]->last_core == ACELP_CORE ) - { - length += length / 4; - } - FOR( Word16 k = 0; k <= ( ( sts[ch]->core == TCX_20_CORE ) ? 1 : NB_DIV ) - 1; k++ ) - { - if ( sts[ch]->hTcxEnc->spectrum[0] ) - { - floatToFixed_arrL32( sts[ch]->hTcxEnc->spectrum[k], sts[ch]->hTcxEnc->spectrum_fx[k], q_spec, length ); - sts[ch]->hTcxEnc->spectrum_e[k] = sub( Q31, q_spec ); - } - if ( mdst_spectrum[ch][0] ) - { - floatToFixed_arrL32( mdst_spectrum[ch][k], mdst_spectrum_fx[ch][k], q_spec, length ); - } - } - } -#endif // 1 - apply_MCT_enc_fx( hMCT, sts, mdst_spectrum_fx, inv_spectrum_fx, inv_mdst_spectrum_fx, nChannels ); -#if 1 // Fixed to Float, to be removed + /*--------------------------------------------------------------* + * Power spectrum calculation for Noise Estimation + *---------------------------------------------------------------*/ FOR( ch = 0; ch < nChannels; ch++ ) { - if ( sts[ch]->hTcxEnc->spectrum[0] ) + IF( EQ_32( sts[ch]->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) { - q_spec = 31 - sts[ch]->hTcxEnc->spectrum_e[0]; + CONTINUE; } - length = sts[ch]->hTcxEnc->L_frameTCX / ( ( sts[ch]->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV ); - IF( sts[ch]->last_core == ACELP_CORE ) + IF( EQ_16( sts[ch]->hTcxEnc->tcxMode, TCX_20 ) ) { - length += length / 4; + nSubframes = 1; + L_subframeTCX = sts[ch]->hTcxEnc->L_frameTCX; + move16(); + move16(); } - FOR( Word16 k = 0; k <= ( ( sts[ch]->core == TCX_20_CORE ) ? 1 : NB_DIV ) - 1; k++ ) + ELSE { - if ( sts[ch]->hTcxEnc->spectrum[0] ) - { - fixedToFloat_arrL32( sts[ch]->hTcxEnc->spectrum_fx[k], sts[ch]->hTcxEnc->spectrum[k], q_spec, length ); - fixedToFloat_arrL32( inv_spectrum_fx[ch][k], inv_spectrum[ch][k], q_spec, length ); - } - if ( mdst_spectrum[ch][0] ) - { - fixedToFloat_arrL32( inv_mdst_spectrum_fx[ch][k], inv_mdst_spectrum[ch][k], q_spec, length ); - fixedToFloat_arrL32( mdst_spectrum_fx[ch][k], mdst_spectrum[ch][k], q_spec, length ); - } + nSubframes = NB_DIV; + move16(); + L_subframeTCX = shr( sts[ch]->hTcxEnc->L_frameTCX, 1 ); } - } -#endif // 1 - - /*--------------------------------------------------------------* - * Power spectrum calculation for Noise Estimation - *---------------------------------------------------------------*/ - for ( ch = 0; ch < nChannels; ch++ ) - { - if ( sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) - { - continue; - } - nSubframes = ( sts[ch]->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV; - L_subframeTCX = sts[ch]->hTcxEnc->L_frameTCX / nSubframes; /* in MCT only relevant for bitrate switching from non-MCT bitrates */ - if ( sts[ch]->last_core == ACELP_CORE ) + IF( EQ_16( sts[ch]->last_core, ACELP_CORE ) ) { - L_subframeTCX += L_subframeTCX / 4; + L_subframeTCX = add( L_subframeTCX, shr( L_subframeTCX, 2 ) ); } - for ( n = 0; n < nSubframes; n++ ) + FOR( n = 0; n < nSubframes; n++ ) { - if ( sts[ch]->hTcxEnc->tns_ms_flag[n] ) + q_spec = sub( 31, sts[ch]->hTcxEnc->spectrum_e[0] ); + + IF( sts[ch]->hTcxEnc->tns_ms_flag[n] ) { /* power spectrum: MDCT^2 + MDST^2 */ - for ( i = 0; i < L_subframeTCX; i++ ) + FOR( i = 0; i < L_subframeTCX; i++ ) { - powerSpec[ch][i + n * L_subframeTCX] = mdst_spectrum[ch][n][i] * mdst_spectrum[ch][n][i] + sts[ch]->hTcxEnc->spectrum[n][i] * sts[ch]->hTcxEnc->spectrum[n][i]; - powerSpecMsInv[ch][n][i] = inv_mdst_spectrum[ch][n][i] * inv_mdst_spectrum[ch][n][i] + inv_spectrum[ch][n][i] * inv_spectrum[ch][n][i]; + W_tmp = W_mac_32_32( W_mult_32_32( mdst_spectrum_fx[ch][n][i], mdst_spectrum_fx[ch][n][i] ), sts[ch]->hTcxEnc->spectrum_fx[n][i], sts[ch]->hTcxEnc->spectrum_fx[n][i] ); + tmp_s = sub( W_norm( W_tmp ), 1 ); + W_tmp = W_shl( W_tmp, tmp_s ); + powerSpec_fx[ch][add( i, imult1616( n, L_subframeTCX ) )] = W_extract_h( W_tmp ); + tmp_q_powSpec[add( i, imult1616( n, L_subframeTCX ) )] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32 + move32(); + move16(); + + W_tmp = W_mac_32_32( W_mult_32_32( inv_mdst_spectrum_fx[ch][n][i], inv_mdst_spectrum_fx[ch][n][i] ), inv_spectrum_fx[ch][n][i], inv_spectrum_fx[ch][n][i] ); + tmp_s = sub( W_norm( W_tmp ), 1 ); + W_tmp = W_shl( W_tmp, tmp_s ); + powerSpecMsInv_fx[ch][n][i] = W_extract_h( W_tmp ); + tmp_q_psi[n][i] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32 + move32(); + move16(); } } - else + ELSE { - if ( hMCT->currBlockDataCnt > 0 ) + IF( hMCT->currBlockDataCnt > 0 ) { /* power spectrum: MDCT^2 + MDST^2 */ - powerSpecMsInv[ch][n][0] = inv_spectrum[ch][n][0] * inv_spectrum[ch][n][0]; - - for ( i = 1; i < L_subframeTCX - 1; i++ ) + W_tmp = W_mult_32_32( inv_spectrum_fx[ch][n][0], inv_spectrum_fx[ch][n][0] ); + tmp_s = sub( W_norm( W_tmp ), 1 ); + W_tmp = W_shl( W_tmp, tmp_s ); + powerSpecMsInv_fx[ch][n][0] = W_extract_h( W_tmp ); + tmp_q_psi[n][0] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32 + move32(); + move16(); + + FOR( i = 1; i < L_subframeTCX - 1; i++ ) { - mdst = ( inv_spectrum[ch][n][i + 1] - inv_spectrum[ch][n][i - 1] ); /* An MDST estimate */ - powerSpecMsInv[ch][n][i] = mdst * mdst + inv_spectrum[ch][n][i] * inv_spectrum[ch][n][i]; + mdst_fx = L_sub( inv_spectrum_fx[ch][n][i + 1], inv_spectrum_fx[ch][n][i - 1] ); /* An MDST estimate */ + + W_tmp = W_mac_32_32( W_mult_32_32( mdst_fx, mdst_fx ), inv_spectrum_fx[ch][n][i], inv_spectrum_fx[ch][n][i] ); + tmp_s = sub( W_norm( W_tmp ), 1 ); + W_tmp = W_shl( W_tmp, tmp_s ); + powerSpecMsInv_fx[ch][n][i] = W_extract_h( W_tmp ); + tmp_q_psi[n][i] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32 + move32(); + move16(); } - powerSpecMsInv[ch][n][L_subframeTCX - 1] = inv_spectrum[ch][n][L_subframeTCX - 1] * inv_spectrum[ch][n][L_subframeTCX - 1]; + W_tmp = W_mult_32_32( inv_spectrum_fx[ch][n][L_subframeTCX - 1], inv_spectrum_fx[ch][n][L_subframeTCX - 1] ); + tmp_s = sub( W_norm( W_tmp ), 1 ); + W_tmp = W_shl( W_tmp, tmp_s ); + powerSpecMsInv_fx[ch][n][L_subframeTCX - 1] = W_extract_h( W_tmp ); + tmp_q_psi[n][L_subframeTCX - 1] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32 + move32(); + move16(); } /* power spectrum: MDCT^2 + MDST^2 */ - powerSpec[ch][n * L_subframeTCX] = sts[ch]->hTcxEnc->spectrum[n][0] * sts[ch]->hTcxEnc->spectrum[n][0]; + W_tmp = W_mult_32_32( sts[ch]->hTcxEnc->spectrum_fx[n][0], sts[ch]->hTcxEnc->spectrum_fx[n][0] ); + tmp_s = sub( W_norm( W_tmp ), 1 ); + W_tmp = W_shl( W_tmp, tmp_s ); + powerSpec_fx[ch][n * L_subframeTCX] = W_extract_h( W_tmp ); + tmp_q_powSpec[n * L_subframeTCX] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32 + move32(); + move16(); + + FOR( i = 1; i < L_subframeTCX - 1; i++ ) + { + mdst_fx = L_sub( sts[ch]->hTcxEnc->spectrum_fx[n][i + 1], sts[ch]->hTcxEnc->spectrum_fx[n][i - 1] ); /* An MDST estimate */ + + W_tmp = W_mac_32_32( W_mult_32_32( mdst_fx, mdst_fx ), sts[ch]->hTcxEnc->spectrum_fx[n][i], sts[ch]->hTcxEnc->spectrum_fx[n][i] ); + tmp_s = sub( W_norm( W_tmp ), 1 ); + W_tmp = W_shl( W_tmp, tmp_s ); + powerSpec_fx[ch][add( i, imult1616( n, L_subframeTCX ) )] = W_extract_h( W_tmp ); + tmp_q_powSpec[add( i, imult1616( n, L_subframeTCX ) )] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32 + move32(); + move16(); + } - for ( i = 1; i < L_subframeTCX - 1; i++ ) + W_tmp = W_mult_32_32( sts[ch]->hTcxEnc->spectrum_fx[n][L_subframeTCX - 1], sts[ch]->hTcxEnc->spectrum_fx[n][L_subframeTCX - 1] ); + tmp_s = sub( W_norm( W_tmp ), 1 ); + W_tmp = W_shl( W_tmp, tmp_s ); + powerSpec_fx[ch][add( sub( L_subframeTCX, 1 ), imult1616( n, L_subframeTCX ) )] = W_extract_h( W_tmp ); + tmp_q_powSpec[add( sub( L_subframeTCX, 1 ), imult1616( n, L_subframeTCX ) )] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32 + move32(); + move16(); + } + } + + /* Aligning the Q-factors */ + { + /* NOTE: This logic has been added because using a constant headroom while computing `powSpec` and `powSpecMsInv` leads to significant precision loss, which results in poor quality. */ + FOR( i = 0; i < L_FRAME48k; i++ ) + { + if ( powerSpec_fx[ch][i] == 0 ) { - mdst = ( sts[ch]->hTcxEnc->spectrum[n][i + 1] - sts[ch]->hTcxEnc->spectrum[n][i - 1] ); /* An MDST estimate */ - powerSpec[ch][i + n * L_subframeTCX] = mdst * mdst + sts[ch]->hTcxEnc->spectrum[n][i] * sts[ch]->hTcxEnc->spectrum[n][i]; + tmp_q_powSpec[i] = 63; + move16(); + } + if ( powerSpecMsInv_fx[ch][0][i] == 0 ) + { + tmp_q_powSpecInv[i] = 63; + move16(); + } + } + minimum_s( tmp_q_powSpec, L_FRAME48k, &q_powSpec[ch] ); + minimum_s( tmp_q_powSpecInv, L_FRAME48k, &tmp_s ); + q_powSpec[ch] = s_min( q_powSpec[ch], tmp_s ); + move16(); + + FOR( n = 0; n < nSubframes; n++ ) + { + FOR( i = 0; i < L_subframeTCX; i++ ) + { + powerSpecMsInv_fx[ch][n][i] = L_shr( powerSpecMsInv_fx[ch][n][i], sub( tmp_q_psi[n][i], q_powSpec[ch] ) ); + powerSpec_fx[ch][add( i, imult1616( n, L_subframeTCX ) )] = L_shr( powerSpec_fx[ch][add( i, imult1616( n, L_subframeTCX ) )], sub( tmp_q_powSpec[i], q_powSpec[ch] ) ); + move32(); + move32(); } - powerSpec[ch][L_subframeTCX - 1 + n * L_subframeTCX] = sts[ch]->hTcxEnc->spectrum[n][L_subframeTCX - 1] * sts[ch]->hTcxEnc->spectrum[n][L_subframeTCX - 1]; } } } - for ( ch = 0; ch < nChannels; ch++ ) + FOR( ch = 0; ch < nChannels; ch++ ) { st = sts[ch]; - if ( sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) + IF( EQ_32( sts[ch]->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) { - continue; + CONTINUE; } - nSubframes = ( st->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV; - L_subframeTCX = st->hTcxEnc->L_frameTCX / nSubframes; + + IF( EQ_16( st->hTcxEnc->tcxMode, TCX_20 ) ) + { + nSubframes = 1; + move16(); + L_subframeTCX = st->hTcxEnc->L_frameTCX; + move16(); + } + ELSE + { + nSubframes = NB_DIV; + move16(); + L_subframeTCX = shr( st->hTcxEnc->L_frameTCX, 1 ); + } + /* in MCT only relevant for bitrate switching from non-MCT bitrates */ - if ( st->last_core == ACELP_CORE ) + IF( st->last_core == ACELP_CORE ) { - L_subframeTCX += L_subframeTCX / 4; + L_subframeTCX = add( L_subframeTCX, shr( L_subframeTCX, 2 ) ); } - if ( ( st->hTcxEnc->tcxMode == TCX_20 ) && ( st->total_brate < HQ_96k || st->igf ) ) + test(); + test(); + IF( EQ_16( st->hTcxEnc->tcxMode, TCX_20 ) && ( LT_32( st->total_brate, HQ_96k ) || st->igf ) ) { /*-----------------------------------------------------------* * Compute noise-measure flags for spectrum filling * @@ -909,12 +960,50 @@ void ivas_mct_core_enc( * Detect low pass if present. * *-----------------------------------------------------------*/ - ComputeSpectrumNoiseMeasure( powerSpec[ch], st->hTcxEnc->L_frameTCX, st->hTcxEnc->nmStartLine, ( st->L_frame * st->last_sr_core != st->L_frame_past * st->sr_core ) || ( st->last_core != TCX_20_CORE ), st->hTcxEnc->memQuantZeros, st->hTcxEnc->L_frameTCX ); + test(); + ComputeSpectrumNoiseMeasure_fx( powerSpec_fx[ch], st->hTcxEnc->L_frameTCX, st->hTcxEnc->nmStartLine, NE_32( imult3216( st->last_sr_core, st->L_frame ), imult3216( st->sr_core, st->L_frame_past ) ) || NE_16( st->last_core, TCX_20_CORE ), st->hTcxEnc->memQuantZeros, st->hTcxEnc->L_frameTCX ); } - st->hTcxEnc->measuredBwRatio_flt = 1.f; /* No bandwidth limit for the noise filling */ +#if 1 // Float initialization to be removed + st->hTcxEnc->measuredBwRatio_flt = 1.f; /* No bandwidth limit for the noise filling */ +#endif + st->hTcxEnc->measuredBwRatio = ONE_IN_Q14; /* No bandwidth limit for the noise filling, Q14 */ } +#if 1 // Fixed to float conversions, to be removed + Word16 length; + q_spec = 31; + move16(); + for ( ch = 0; ch < nChannels; ch++ ) + { + if ( sts[ch]->hTcxEnc->spectrum[0] ) + { + q_spec = 31 - sts[ch]->hTcxEnc->spectrum_e[0]; + } + length = sts[ch]->hTcxEnc->L_frameTCX / ( ( sts[ch]->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV ); + if ( sts[ch]->last_core == ACELP_CORE ) + { + length += length / 4; + } + for ( Word16 k = 0; k <= ( ( sts[ch]->core == TCX_20_CORE ) ? 1 : NB_DIV ) - 1; k++ ) + { + if ( sts[ch]->hTcxEnc->spectrum[0] ) + { + fixedToFloat_arrL32( sts[ch]->hTcxEnc->spectrum_fx[k], sts[ch]->hTcxEnc->spectrum[k], q_spec, length ); + fixedToFloat_arrL32( inv_spectrum_fx[ch][k], inv_spectrum[ch][k], q_spec, length ); + } + if ( mdst_spectrum[ch][0] ) + { + fixedToFloat_arrL32( inv_mdst_spectrum_fx[ch][k], inv_mdst_spectrum[ch][k], q_spec, length ); + fixedToFloat_arrL32( mdst_spectrum_fx[ch][k], mdst_spectrum[ch][k], q_spec, length ); + } + } + + fixedToFloat_arrL( powerSpecMsInv_fx[ch][0], powerSpecMsInv[ch][0], q_powSpec[ch], L_FRAME48k ); + fixedToFloat_arrL( powerSpec_fx[ch], powerSpec[ch], q_powSpec[ch], sts[ch]->hTcxEnc->L_frameTCX ); + } +#endif // 1 + if ( sts[0]->igf ) { if ( hMCT->currBlockDataCnt > 0 ) diff --git a/lib_enc/ivas_mct_enc.c b/lib_enc/ivas_mct_enc.c index 89515091fd61420b5d3b3b22e41b5fcb10e7d72f..0fac502c14803c5a9660fef328973a53b77c5eef 100644 --- a/lib_enc/ivas_mct_enc.c +++ b/lib_enc/ivas_mct_enc.c @@ -399,6 +399,67 @@ ivas_error ivas_mct_enc( } } +#if 1 // Float to Fixed, to be removed + Word16 q_spec = Q31; + Word16 length, ch, nCPE; + nCPE = ( hMCT->nchan_out_woLFE % 2 ) == 0 ? ( hMCT->nchan_out_woLFE / 2 ) : ( hMCT->nchan_out_woLFE / 2 ) + 1; + + for ( cpe_id = 0; cpe_id < nCPE; cpe_id++ ) + { + for ( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + if ( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) + { + continue; + } + length = st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->L_frameTCX / ( ( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV ); + if ( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->last_core == ACELP_CORE ) + { + length += length / 4; + } + for ( Word16 k = 0; k <= ( ( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->core == TCX_20_CORE ) ? 1 : NB_DIV ) - 1; k++ ) + { + if ( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum[0] ) + { + q_spec = s_min( q_spec, Q_factor_arrL( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum[k], length ) - 1 ); + } + if ( hMCT->p_mdst_spectrum_long[cpe_id][ch] ) + { + q_spec = s_min( q_spec, Q_factor_arrL( &hMCT->p_mdst_spectrum_long[cpe_id][ch][k * N_TCX10_MAX], length ) - 1 ); + } + } + } + } + + for ( cpe_id = 0; cpe_id < nCPE; cpe_id++ ) + { + for ( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + // if ( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) + //{ + // continue; + // } + length = st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->L_frameTCX / ( ( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV ); + if ( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->last_core == ACELP_CORE ) + { + length += length / 4; + } + for ( Word16 k = 0; k <= ( ( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->core == TCX_20_CORE ) ? 1 : NB_DIV ) - 1; k++ ) + { + if ( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum[0] ) + { + floatToFixed_arrL32( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum[k], st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_fx[k], q_spec, length ); + st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_e[k] = sub( Q31, q_spec ); + } + if ( hMCT->p_mdst_spectrum_long[cpe_id][ch] ) + { + floatToFixed_arrL32( &hMCT->p_mdst_spectrum_long[cpe_id][ch][k * N_TCX10_MAX], &hMCT->p_mdst_spectrum_long_fx[cpe_id][ch][k * N_TCX10_MAX], q_spec, length ); + } + } + } + } +#endif // 1 + /* joint MCT encoding */ ivas_mct_core_enc( ivas_format, hMCT, st_ivas->hCPE, hMCT->nchan_out_woLFE, ivas_total_brate, switch_bw, ( ivas_format == MC_FORMAT && ( st_ivas->mc_mode == MC_MODE_MCT || st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) ) ? (int16_t) st_ivas->hLFE->lfe_bits : 0, st_ivas->hEncoderConfig->sba_order ); diff --git a/lib_enc/ivas_mct_enc_mct.c b/lib_enc/ivas_mct_enc_mct.c index 0a4659182d2d801abe86d1d6c985dd5b4e3b3677..066f7a55770a385abc22d20b05252302d81a7cd7 100644 --- a/lib_enc/ivas_mct_enc_mct.c +++ b/lib_enc/ivas_mct_enc_mct.c @@ -379,8 +379,7 @@ static void getCorrelationMatrix_fx( FOR( n = 0; n < nSubframes; n++ ) { res_q = sub( 31, sts[0]->hTcxEnc->spectrum_e[0] ); - L_tmp = dotp_fixed_32( sts[ch1]->hTcxEnc->spectrum_fx[n], sts[ch2]->hTcxEnc->spectrum_fx[n], L_subframe, 1 /*find_guarded_bits_fx( L_subframe )*/, &res_q ); - + L_tmp = dotp_fixed_32( sts[ch1]->hTcxEnc->spectrum_fx[n], sts[ch2]->hTcxEnc->spectrum_fx[n], L_subframe, 1, &res_q ); xCorrMatrix[ch1][ch2] = BASOP_Util_Add_Mant32Exp( xCorrMatrix[ch1][ch2], xCorrMatrix_exp[ch1][ch2], L_tmp, sub( 31, res_q ), &xCorrMatrix_exp[ch1][ch2] ); move32(); } diff --git a/lib_enc/ivas_stereo_classifier.c b/lib_enc/ivas_stereo_classifier.c index 22d07cf28cd8e2d2479d7299b1381b6e31f953a4..89525e8ef7817b96e1179d7e8661f2eeda55c764 100644 --- a/lib_enc/ivas_stereo_classifier.c +++ b/lib_enc/ivas_stereo_classifier.c @@ -969,6 +969,7 @@ void xtalk_classifier_dft( /* raw score */ hStereoClassif->xtalk_score = score; + printf( "%f ", hStereoClassif->xtalk_score ); if ( !hStereoClassif->vad_flag_glob ) { diff --git a/lib_enc/ivas_stereo_dft_enc_itd.c b/lib_enc/ivas_stereo_dft_enc_itd.c index e01e9b5ba383c9dd6933f956335de55aee8ff25f..0f4c863a8449614b3f648e986415fac8f774c6e2 100644 --- a/lib_enc/ivas_stereo_dft_enc_itd.c +++ b/lib_enc/ivas_stereo_dft_enc_itd.c @@ -1201,6 +1201,7 @@ void stereo_dft_enc_compute_itd( hItd->itd_cnt = 0; hItd->lp_phat_peak = 0.0f; } + printf( "\n%d %f ", itd, hItd->itd_thres ); { /* stereo Xtalk classifier */ diff --git a/lib_enc/ivas_stereo_td_analysis.c b/lib_enc/ivas_stereo_td_analysis.c index be64a017503d1de37ccb9ecaedf327bdf6517fd5..73b03eb183aa3bc3dd031fd570d50bf29c007289 100644 --- a/lib_enc/ivas_stereo_td_analysis.c +++ b/lib_enc/ivas_stereo_td_analysis.c @@ -579,6 +579,12 @@ int16_t stereo_tdm_ener_analysis( hStereoTD->tdm_last_diff_lt_corr_SM = 0; hStereoTD->tdm_last_ener_lt_R_SM = 0; hStereoTD->tdm_last_ener_lt_L_SM = 0; +#ifdef IVAS_FLOAT_FIXED + hStereoTD->tdm_lt_corr_RM_SM_fx = 167772 /*0.01f Q24*/; + hStereoTD->tdm_lt_corr_LM_SM_fx = 167772 /*0.01f Q24*/; + hStereoTD->tdm_last_ener_lt_R_SM_fx = 0; + hStereoTD->tdm_last_ener_lt_L_SM_fx = 0; +#endif hStereoTD->tdm_noop_mov_flag = 0; hStereoTD->tdm_noop_cnt = 0; @@ -595,7 +601,8 @@ int16_t stereo_tdm_ener_analysis( hStereoTD->tdm_LT_es_em_SM_fx = floatToFixed_32( hStereoTD->tdm_LT_es_em_SM, Q21 ); sts[0]->hNoiseEst->Etot_last_fx = float_to_fix16( sts[0]->hNoiseEst->Etot_last, Q8 ); sts[1]->hNoiseEst->Etot_last_fx = float_to_fix16( sts[1]->hNoiseEst->Etot_last, Q8 ); - + sts[0]->old_corr_fx = float_to_fix16( sts[0]->old_corr, Q15 ); + sts[1]->old_corr_fx = float_to_fix16( sts[1]->old_corr, Q15 ); hStereoTD->q_tdm_last_diff_lt_corr_SM = Q31; hStereoTD->tdm_last_diff_lt_corr_SM_fx = floatToFixed_32( hStereoTD->tdm_last_diff_lt_corr_SM, hStereoTD->q_tdm_last_diff_lt_corr_SM ); #endif