From 7e422aff46947a650b57e4f9b4ff74329c482590 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Sun, 17 Aug 2025 21:11:13 +0200 Subject: [PATCH 01/16] [cleanup] accept OPT_MCT_ENC_V3_BE --- lib_com/ivas_tools_fx.c | 13 ------------- lib_com/options.h | 1 - lib_enc/analy_sp_fx.c | 20 -------------------- lib_enc/igf_enc.c | 4 ---- lib_enc/tcx_utils_enc_fx.c | 30 ------------------------------ 5 files changed, 68 deletions(-) diff --git a/lib_com/ivas_tools_fx.c b/lib_com/ivas_tools_fx.c index fad7c0549..9001276bf 100644 --- a/lib_com/ivas_tools_fx.c +++ b/lib_com/ivas_tools_fx.c @@ -606,9 +606,6 @@ Word64 dot_product_cholesky_fixed( { Word16 i, j; Word64 suma, tmp_sum; -#ifndef OPT_MCT_ENC_V3_BE - Word32 mul; -#endif Word32 tmp; const Word32 *pt_x, *pt_A; pt_A = A; @@ -623,20 +620,10 @@ Word64 dot_product_cholesky_fixed( FOR( j = 0; j <= i; j++ ) { -#ifdef OPT_MCT_ENC_V3_BE tmp_sum = W_add( tmp_sum, Mpy_32_32( *pt_x++, *pt_A++ ) ); -#else - mul = Mpy_32_32( *pt_x++, *pt_A++ ); - tmp_sum = W_add( tmp_sum, W_deposit32_l( mul ) ); -#endif } -#ifdef OPT_MCT_ENC_V3_BE tmp = W_shl_sat_l( tmp_sum, -4 ); // to make sure that the tmp_sum will not overflow -#else - tmp_sum = W_shr( tmp_sum, 4 ); // to make sure that the tmp_sum will not overflow - tmp = W_extract_l( tmp_sum ); -#endif suma = W_mac_32_32( suma, tmp, tmp ); } diff --git a/lib_com/options.h b/lib_com/options.h index c739875d4..16b2ec918 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -72,7 +72,6 @@ #endif /* Note: each compile switch (FIX_1101_...) is independent from the other ones */ -#define OPT_MCT_ENC_V3_BE #define OPT_BIN_REND_V2_NBE #define FIX_1348_BIT_PRECISION_IMPROVEMENT diff --git a/lib_enc/analy_sp_fx.c b/lib_enc/analy_sp_fx.c index 8618c8fd7..ef51e01d7 100644 --- a/lib_enc/analy_sp_fx.c +++ b/lib_enc/analy_sp_fx.c @@ -719,9 +719,7 @@ static void ivas_find_enr( Word32 min_ener; Word16 shift = 0; move16(); -#ifdef OPT_MCT_ENC_V3_BE Word16 tmp_shift; -#endif ptR = &data[1]; /* first real */ ptI = &data[L_FFT - 1]; /* first imaginary */ @@ -751,20 +749,14 @@ static void ivas_find_enr( freq = BIN_FREQ_FX; move16(); -#ifdef OPT_MCT_ENC_V3_BE tmp_shift = sub( -Q16, shift ); // 16 - shift - 32 -#endif FOR( i = 0; i < voic_band; i++ ) /* up to maximum allowed voiced critical band */ { band_ener = 0; move64(); start_freq = freq; move16(); -#ifdef OPT_MCT_ENC_V3_BE FOR( ; LE_32( freq, crit_bands_fx[i] ); ) -#else - WHILE( LE_32( freq, crit_bands_fx[i] ) ) -#endif { /* *ptE = *ptR * *ptR + *ptI * *ptI; @@ -797,11 +789,7 @@ static void ivas_find_enr( freq = add( freq, BIN_FREQ_FX ); } -#ifdef OPT_MCT_ENC_V3_BE band[i] = W_shl_sat_l( band_ener, tmp_shift ); // *q_band -#else - band[i] = W_extract_h( W_shl( band_ener, sub( Q16, shift ) ) ); // *q_band -#endif move32(); band_energies[i] = band[i]; /* per band energy without E_MIN */ // *q_band @@ -826,11 +814,7 @@ static void ivas_find_enr( move64(); start_freq = freq; move16(); -#ifdef OPT_MCT_ENC_V3_BE FOR( ; LE_32( freq, crit_bands_fx[i] ); ) -#else - WHILE( LE_32( freq, crit_bands_fx[i] ) ) -#endif { /* *Bin_E = *ptR * *ptR + *ptI * *ptI; @@ -861,11 +845,7 @@ static void ivas_find_enr( freq = add( freq, BIN_FREQ_FX ); } -#ifdef OPT_MCT_ENC_V3_BE band[i] = W_shl_sat_l( band_ener, tmp_shift ); // *q_band -#else - band[i] = W_extract_h( W_shl_nosat( band_ener, sub( Q16, shift ) ) ); // *q_band -#endif move32(); band_energies[i] = band[i]; /* per band energy without E_MIN */ // *q_band diff --git a/lib_enc/igf_enc.c b/lib_enc/igf_enc.c index ee4f43996..a639317be 100644 --- a/lib_enc/igf_enc.c +++ b/lib_enc/igf_enc.c @@ -135,11 +135,7 @@ static Word16 IGF_getCrest_new_fx( { x = logSpec[i]; move16(); -#ifdef OPT_MCT_ENC_V3_BE x_eff = L_mac0( x_eff, x, x ); -#else - x_eff = L_add( x_eff, L_mult0( x, x ) ); -#endif if ( GT_16( x, x_max ) ) { diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index bdf473aab..0face2cf4 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -3588,10 +3588,8 @@ Word16 tcx_res_Q_spec_ivas_fx( Word16 s, s2, lf_deemph_factor; Word16 c; Word32 thres; -#ifdef OPT_MCT_ENC_V3_BE Word16 cmp_1, cmp_2; Word32 tmp32_1, tmp32_2; -#endif /* Limit the number of residual bits */ sqTargetBits = s_min( sqTargetBits, NPRM_RESQ ); @@ -3607,28 +3605,18 @@ Word16 tcx_res_Q_spec_ivas_fx( move16(); s2 = sub( x_Q_e, 1 ); -#ifdef OPT_MCT_ENC_V3_BE cmp_1 = sub( sqTargetBits, kMaxEstimatorUndershoot ); cmp_2 = s_min( NPRM_RESQ, add( sqTargetBits, kMaxEstimatorOvershoot ) ); -#endif FOR( i = 0; i < L_frame; i++ ) { -#ifdef OPT_MCT_ENC_V3_BE IF( GE_16( bits, cmp_1 ) ) -#else - IF( GE_16( bits, sub( sqTargetBits, kMaxEstimatorUndershoot ) ) ) -#endif { fac_m = 0; move16(); fac_p = 0; move16(); -#ifdef OPT_MCT_ENC_V3_BE IF( GE_16( bits, cmp_2 ) ) -#else - IF( GE_16( bits, s_min( NPRM_RESQ, add( sqTargetBits, kMaxEstimatorOvershoot ) ) ) ) -#endif { BREAK; } @@ -3695,17 +3683,8 @@ Word16 tcx_res_Q_spec_ivas_fx( /*Quantize zeroed-line of the spectrum*/ c = sub( 21627 /*0.66f Q15*/, mult_r( sq_round, 21627 /*0.66f Q15*/ ) ); -#ifdef OPT_MCT_ENC_V3_BE FOR( i = 0; ( i < L_frame ) && ( bits < ( sqTargetBits - 2 ) ); i++ ) { -#else - FOR( i = 0; i < L_frame; i++ ) - { - IF( GE_16( bits, sub( sqTargetBits, 2 ) ) ) - { - BREAK; - } -#endif test(); test(); @@ -3722,15 +3701,10 @@ Word16 tcx_res_Q_spec_ivas_fx( tmp1 = Mpy_32_16_1( thres, sqGain ); -#ifdef OPT_MCT_ENC_V3_BE tmp32_1 = L_shl( x_orig[i], sub( x_orig_e, shift_tmp ) ); tmp32_2 = L_shl( tmp1, sub( sqGain_e, shift_tmp ) ); IF( GT_32( tmp32_1, tmp32_2 ) ) { -#else - IF( GT_32( L_shl( x_orig[i], sub( x_orig_e, shift_tmp ) ), L_shl( tmp1, sub( sqGain_e, shift_tmp ) ) ) ) - { -#endif prm[bits] = 1; move16(); bits = add( bits, 1 ); @@ -3742,11 +3716,7 @@ Word16 tcx_res_Q_spec_ivas_fx( x_Q[i] = L_shl( thres, sub( 1, x_Q_e ) ); move32(); } -#ifdef OPT_MCT_ENC_V3_BE ELSE IF( L_add( tmp32_1, tmp32_2 ) < 0 ) -#else - ELSE IF( L_add( L_shl( x_orig[i], sub( x_orig_e, shift_tmp ) ), L_shl( tmp1, sub( sqGain_e, shift_tmp ) ) ) < 0 ) -#endif { prm[bits] = 1; move16(); -- GitLab From aa67056b610f8169fbae7cbb57dd4da0667bb4ab Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Sun, 17 Aug 2025 21:12:09 +0200 Subject: [PATCH 02/16] [cleanup] accept OPT_BIN_REND_V2_NBE --- lib_com/options.h | 1 - lib_dec/ivas_binRenderer_internal_fx.c | 77 -------------------------- 2 files changed, 78 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 16b2ec918..36746adc2 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -72,7 +72,6 @@ #endif /* Note: each compile switch (FIX_1101_...) is independent from the other ones */ -#define OPT_BIN_REND_V2_NBE #define FIX_1348_BIT_PRECISION_IMPROVEMENT #define FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index 53f1c271a..db2b89c5b 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -88,31 +88,11 @@ static void ivas_binRenderer_filterModule_fx( Q_filterStates = hBinRenderer->hBinRenConvModule->Q_filterStates[pos_idx]; move16(); -#ifdef OPT_BIN_REND_V2_NBE shift_q = add( sub( Q_filterStates, Q_curr ), 1 ); hBinRenderer->hBinRenConvModule->Q_filterStates[pos_idx] = Q_curr; -#else /* OPT_BIN_REND_V2_NBE */ - Word64 Cldfb_RealBuffer_64fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES]; - Word64 Cldfb_ImagBuffer_64fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES]; -#endif /* OPT_BIN_REND_V2_NBE */ FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { -#ifndef OPT_BIN_REND_V2_NBE - set64_fx( &Cldfb_RealBuffer_64fx[0][0], 0, BINAURAL_CHANNELS * MAX_PARAM_SPATIAL_SUBFRAMES ); - set64_fx( &Cldfb_ImagBuffer_64fx[0][0], 0, BINAURAL_CHANNELS * MAX_PARAM_SPATIAL_SUBFRAMES ); - - FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) - { - filterStatesLeftRealPtr_fx = (Word32 *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx][0] ); - filterStatesLeftImagPtr_fx = (Word32 *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx][0] ); - - filterTapsLeftRealPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx]; // Q29 - filterTapsLeftImagPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx]; // Q29 - filterTapsRightRealPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx]; // Q29 - filterTapsRightImagPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx]; // Q29 - -#endif /* OPT_BIN_REND_V2_NBE */ FOR( k = 0; k < numTimeSlots; k++ ) { Word64 outRealLeft_fx = 0, outRealRight_fx = 0, outImagLeft_fx = 0, outImagRight_fx = 0; @@ -120,7 +100,6 @@ static void ivas_binRenderer_filterModule_fx( move64(); move64(); move64(); -#ifdef OPT_BIN_REND_V2_NBE Word64 outRealLeft = 0, outRealRight = 0, outImagLeft = 0, outImagRight = 0; move64(); move64(); @@ -136,7 +115,6 @@ static void ivas_binRenderer_filterModule_fx( filterTapsLeftImagPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx]; // Q29 filterTapsRightRealPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx]; // Q29 filterTapsRightImagPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx]; // Q29 -#endif /* OPT_BIN_REND_V2_NBE */ FOR( tapIdx = hBinRenderer->hBinRenConvModule->numTapsArray[bandIdx] - 1; tapIdx > 0; tapIdx-- ) { @@ -160,25 +138,11 @@ static void ivas_binRenderer_filterModule_fx( outImagRight_fx = W_mac_32_32( outImagRight_fx, filterStatesLeftImagPtr_fx[tapIdx], filterTapsRightRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates } -#ifndef OPT_BIN_REND_V2_NBE - shift_q = add( sub( Q_filterStates, Q_curr ), 1 ); - - IF( shift_q != 0 ) - { - outRealLeft_fx = W_shr( outRealLeft_fx, shift_q ); // Q_curr + Q29 - outImagLeft_fx = W_shr( outImagLeft_fx, shift_q ); // Q_curr + Q29 - outRealRight_fx = W_shr( outRealRight_fx, shift_q ); // Q_curr + Q29 - outImagRight_fx = W_shr( outImagRight_fx, shift_q ); // Q_curr + Q29 - hBinRenderer->hBinRenConvModule->Q_filterStates[pos_idx] = Q_curr; - move16(); - } -#endif /* OPT_BIN_REND_V2_NBE */ filterStatesLeftRealPtr_fx[0] = CLDFB_real[chIdx][k][bandIdx]; move32(); filterStatesLeftImagPtr_fx[0] = CLDFB_imag[chIdx][k][bandIdx]; move32(); -#ifdef OPT_BIN_REND_V2_NBE /* Left Real and Imag */ Word32 neg_temp2 = L_negate( filterStatesLeftImagPtr_fx[0] ); // Q_curr @@ -198,47 +162,6 @@ static void ivas_binRenderer_filterModule_fx( move32(); move32(); } -#else /* OPT_BIN_REND_V2_NBE */ - /* Left Real and Imag */ - - Word32 temp1 = L_shr( filterStatesLeftRealPtr_fx[0], 1 ); // Q_curr -1 - Word32 temp2 = L_shr( filterStatesLeftImagPtr_fx[0], 1 ); // Q_curr -1 - Word32 neg_temp2 = L_negate( temp2 ); // Q_curr -1 - - - outRealLeft_fx = W_mac_32_32( outRealLeft_fx, temp1, filterTapsLeftRealPtr_fx[0] ); - outRealLeft_fx = W_mac_32_32( outRealLeft_fx, neg_temp2, filterTapsLeftImagPtr_fx[0] ); - Cldfb_RealBuffer_64fx[0][k] = W_add( Cldfb_RealBuffer_64fx[0][k], outRealLeft_fx ); // Q29 + Q_curr - move64(); - - outImagLeft_fx = W_mac_32_32( outImagLeft_fx, temp1, filterTapsLeftImagPtr_fx[0] ); - outImagLeft_fx = W_mac_32_32( outImagLeft_fx, temp2, filterTapsLeftRealPtr_fx[0] ); - Cldfb_ImagBuffer_64fx[0][k] = W_add( Cldfb_ImagBuffer_64fx[0][k], outImagLeft_fx ); // Q29 + Q_curr - move64(); - - /* Right Real and Imag */ - outRealRight_fx = W_mac_32_32( outRealRight_fx, temp1, filterTapsRightRealPtr_fx[0] ); - outRealRight_fx = W_mac_32_32( outRealRight_fx, neg_temp2, filterTapsRightImagPtr_fx[0] ); - Cldfb_RealBuffer_64fx[1][k] = W_add( Cldfb_RealBuffer_64fx[1][k], outRealRight_fx ); // Q29 + Q_curr - move64(); - - outImagRight_fx = W_mac_32_32( outImagRight_fx, temp1, filterTapsRightImagPtr_fx[0] ); - outImagRight_fx = W_mac_32_32( outImagRight_fx, temp2, filterTapsRightRealPtr_fx[0] ); - Cldfb_ImagBuffer_64fx[1][k] = W_add( Cldfb_ImagBuffer_64fx[1][k], outImagRight_fx ); // Q29 + Q_curr - move64(); - } - } - FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) - { - FOR( k = 0; k < MAX_PARAM_SPATIAL_SUBFRAMES; k++ ) - { - out_Conv_CLDFB_real[chIdx][k][bandIdx] = W_shl_sat_l( Cldfb_RealBuffer_64fx[chIdx][k], shift_q6 ); // Q6 - move32(); - out_Conv_CLDFB_imag[chIdx][k][bandIdx] = W_shl_sat_l( Cldfb_ImagBuffer_64fx[chIdx][k], shift_q6 ); // Q6 - move32(); - } - } -#endif /* OPT_BIN_REND_V2_NBE */ } -- GitLab From 078ce2338dce651316587069758ab56ace2c9eb3 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Sun, 17 Aug 2025 21:15:21 +0200 Subject: [PATCH 03/16] [cleanup] accept FIX_1348_BIT_PRECISION_IMPROVEMENT, FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN, FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD --- lib_com/ivas_prot_fx.h | 4 - lib_com/options.h | 3 - lib_com/prot_fx.h | 13 -- lib_dec/core_dec_init_fx.c | 10 - lib_dec/dec_ace_fx.c | 2 - lib_dec/dec_tcx_fx.c | 267 ------------------------- lib_dec/er_dec_acelp_fx.c | 6 - lib_dec/er_dec_tcx_fx.c | 28 --- lib_dec/hq_core_dec_fx.c | 2 - lib_dec/ivas_core_dec_fx.c | 27 --- lib_dec/ivas_cpe_dec_fx.c | 4 - lib_dec/ivas_jbm_dec_fx.c | 12 -- lib_dec/ivas_mdct_core_dec_fx.c | 109 ---------- lib_dec/ivas_post_proc_fx.c | 6 - lib_dec/ivas_stereo_switching_dec_fx.c | 6 - lib_dec/stat_dec.h | 4 - lib_dec/updt_dec_fx.c | 2 - 17 files changed, 505 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 337fb72a9..7adb4d806 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1612,12 +1612,8 @@ void decoder_tcx_imdct_fx( Word32 x_fx[N_MAX], Word16 q_x, Word16 xn_buf_fx[], -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN Word16 *q_win, Word16 *q_winFB, -#else - Word16 q_win, -#endif const UWord16 kernelType, /* i : TCX transform kernel type */ const Word16 fUseTns, /* i : flag that is set if TNS data is present */ Word16 synth_fx[], /* i/o: synth[-M..L_frame] */ diff --git a/lib_com/options.h b/lib_com/options.h index 36746adc2..7b4838bef 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -73,9 +73,6 @@ /* Note: each compile switch (FIX_1101_...) is independent from the other ones */ -#define FIX_1348_BIT_PRECISION_IMPROVEMENT -#define FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN -#define FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD #define NONBE_FIX_864_JBM_RENDER_FRAMESIZE /* FhG: issue #864: fix different behaviour of JBM TSM with different render frame sizes */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index e98200766..2b3e200f2 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -9376,19 +9376,12 @@ void IMDCT_fx( Word32 *x, Word16 x_e, Word16 *old_syn_overl, Word16 *syn_Overl_T void IMDCT_ivas_fx( Word32 *x_fx, Word16 q_x, -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN Word16 *old_syn_overl_fx, Word16 *Q_old_syn_overl_fx, Word16 *syn_Overl_TDAC_fx, Word16 *Q_syn_Overl_TDAC_fx, -#else - Word16 *old_syn_overl_fx, - Word16 *syn_Overl_TDAC_fx, -#endif Word16 *xn_buf_fx, -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN Word16 q_xn_buf_fx, -#endif const Word16 *tcx_aldo_window_1_fx, const PWord16 *tcx_aldo_window_1_trunc_fx, const PWord16 *tcx_aldo_window_2_fx, @@ -9409,19 +9402,13 @@ void IMDCT_ivas_fx( const Word16 frame_cnt, const Word16 bfi, Word16 *old_out_fx, -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD Word16 *q_old_out_fx, -#endif const Word16 FB_flag, Decoder_State *st, const Word16 fullbandScale, Word16 *acelp_zir_fx, -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN Word16 *q_acelp_zir_fx, Word16 *pq_win ); -#else - Word16 q_win ); -#endif void v_mult16_fixed( const Word16 x1[], /* i : Input vector 1 */ diff --git a/lib_dec/core_dec_init_fx.c b/lib_dec/core_dec_init_fx.c index 9430f2ac5..2722d4303 100644 --- a/lib_dec/core_dec_init_fx.c +++ b/lib_dec/core_dec_init_fx.c @@ -396,15 +396,11 @@ void open_decoder_LPD_fx( move16(); Copy( hHQ_core->fer_samples_fx + delay_comp, hTcxDec->syn_OverlFB, shr( hTcxDec->L_frameTCX, 1 ) ); /* hHQ_core->Q_fer_samples*/ -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT hTcxDec->Q_syn_OverlFB = hHQ_core->Q_fer_samples; move16(); -#endif lerp( hHQ_core->fer_samples_fx + delay_comp, hTcxDec->syn_Overl, shr( st->L_frame, 1 ), shr( hTcxDec->L_frameTCX, 1 ) ); /*Q0: ACELP(bfi)->TCX(rect)*/ -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT hTcxDec->Q_syn_Overl = hHQ_core->Q_fer_samples; move16(); -#endif /*old_out needed for MODE1 routine and syn_Overl_TDAC for MODE2 routine*/ hHQ_core->Q_old_wtda = -1; @@ -1077,15 +1073,11 @@ void acelp_plc_mdct_transition_fx( move16(); /*CLDFB delay*/ Copy( st->hHQ_core->fer_samples_fx + delay_comp, st->hTcxDec->syn_OverlFB, shr( st->hTcxDec->L_frameTCX, 1 ) ); /* Q_fer_samples */ -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT st->hTcxDec->Q_syn_OverlFB = st->hHQ_core->Q_fer_samples; move16(); -#endif lerp( st->hHQ_core->fer_samples_fx + delay_comp, st->hTcxDec->syn_Overl, shr( st->L_frame, 1 ), shr( st->hTcxDec->L_frameTCX, 1 ) ); /*ACELP(bfi)->TCX(rect)*/ -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT st->hTcxDec->Q_syn_Overl = st->hHQ_core->Q_fer_samples; move16(); -#endif /*old_out needed for MODE1 routine and syn_Overl_TDAC for MODE2 routine*/ st->hHQ_core->Q_old_wtda = -1; move16(); @@ -2105,11 +2097,9 @@ void reset_tcx_overl_buf_fx( set16_fx( hTcxDec->syn_Overl, 0, L_FRAME32k / 2 ); /*HQ-CORE(bfi)->TCX don't need it*/ hTcxDec->Q_syn_Overl = 0; move16(); -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT set16_fx( hTcxDec->syn_OverlFB, 0, L_FRAME48k / 2 ); /*HQ-CORE(bfi)->TCX don't need it*/ hTcxDec->Q_syn_OverlFB = 0; move16(); -#endif set16_fx( hTcxDec->syn_Overl_TDACFB, 0, L_FRAME_MAX / 2 ); /*HQ-CORE(bfi)->TCX don't need it*/ hTcxDec->Q_syn_Overl_TDACFB = 0; move16(); diff --git a/lib_dec/dec_ace_fx.c b/lib_dec/dec_ace_fx.c index edc429459..d7f8f7ab0 100644 --- a/lib_dec/dec_ace_fx.c +++ b/lib_dec/dec_ace_fx.c @@ -690,10 +690,8 @@ void decoder_acelp_fx( E_UTIL_deemph2( st->Q_syn, syn, st->preemph_fac, st->L_frame, &tmp_deemph ); /* tmp_deemph and syn in Q0 starting from here*/ bufferCopyFx( syn + shr( st->L_frame, 1 ), hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), 0 /*Qf_syn*/, -1 /*Qf_old_xnq*/, 0, 0 /*Q_old_xnq*/ ); -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT st->hTcxDec->Q_old_syn_Overl = sub( st->Q_syn, 1 ); move16(); -#endif Copy( syn + sub( st->L_frame, M + 1 ), st->syn, 1 + M ); /*Q0*/ diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 664b22e93..d87c09135 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -2635,7 +2635,6 @@ void IMDCT_fx( Word32 *x, Word16 x_e, Word16 *old_syn_overl, Word16 *syn_Overl_T } } -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN static Word16 IMDCT_ivas_fx_calc_qwin( Decoder_State *st, @@ -3005,24 +3004,16 @@ static void TCX_MDXT_Inverse_qwin_fx( return; } -#endif void IMDCT_ivas_fx( Word32 *x_fx, // Q(q_x) Word16 q_x, -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN Word16 *old_syn_overl_fx, // *Q_old_syn_overl_fx Word16 *Q_old_syn_overl_fx, Word16 *syn_Overl_TDAC_fx, // *Q_syn_Overl_TDAC_fx Word16 *Q_syn_Overl_TDAC_fx, -#else - Word16 *old_syn_overl_fx, // Q(-2) - Word16 *syn_Overl_TDAC_fx, // Q(-2) -#endif Word16 *xn_buf_fx, // Q(-2) -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN Word16 q_xn_buf_fx, -#endif const Word16 *tcx_aldo_window_1_fx, // Q(15) const PWord16 *tcx_aldo_window_1_trunc_fx, // Q(15) const PWord16 *tcx_aldo_window_2_fx, // Q(15) @@ -3043,19 +3034,13 @@ void IMDCT_ivas_fx( const Word16 frame_cnt, const Word16 bfi, Word16 *old_out_fx, // Q(-2) -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD Word16 *q_old_out_fx, -#endif const Word16 FB_flag, Decoder_State *st, const Word16 fullbandScale, Word16 *acelp_zir_fx, -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN Word16 *q_acelp_zir_fx, Word16 *pq_win ) -#else - Word16 q_win ) // Q(-2) -#endif { Word16 i, nz, aldo, w, L_win, L_ola; Word16 win_fx[( L_FRAME_PLUS + L_MDCT_OVLP_MAX ) / 2]; @@ -3064,7 +3049,6 @@ void IMDCT_ivas_fx( Word16 x_e_hdrm; Word32 c; Word16 exp; -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN Word16 q_win = *pq_win; Word16 allow_qwin_change = 1; move16(); @@ -3082,9 +3066,6 @@ void IMDCT_ivas_fx( q_win = IMDCT_ivas_fx_calc_qwin( st, syn_Overl_TDAC_fx, *Q_syn_Overl_TDAC_fx, old_syn_overl_fx, *Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, hTcxDec->Q_old_syn_Overl, old_out_fx, *q_old_out_fx, q_win, FB_flag ); } -#else - x_e_hdrm = add( q_win, sub( Q16, q_x ) ); -#endif aldo = 0; move16(); @@ -3159,7 +3140,6 @@ void IMDCT_ivas_fx( Word16 L_spec_TCX5_tmp = 0; move16(); -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN IF( allow_qwin_change ) { /* Use fixed q_win to avoid the need to adapt scaling of two TCX5 blocks (less effort with maybe not ideal scaling) */ @@ -3168,14 +3148,12 @@ void IMDCT_ivas_fx( allow_qwin_change = 0; move16(); } -#endif FOR( w = 0; w < 2; w++ ) { test(); test(); L_spec_TCX5_tmp = imult1616( w, L_spec_TCX5 ); -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN // Assume that xn_buf_fx has no headroom. q_win = s_min( q_xn_buf_fx, q_win ); @@ -3193,20 +3171,6 @@ void IMDCT_ivas_fx( } IMDCT_ivas_fx_rescale( xn_buf_fx, &q_xn_buf_fx, syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); -#else - IF( EQ_16( kernel_type, MDST_IV ) || s_and( kernel_type, w ) ) - { - TCX_MDST_Inverse_fx( x_fx + L_spec_TCX5_tmp, x_e_hdrm, win_fx, L_ola, sub( L_win, L_ola ), L_ola ); - } - ELSE IF( ( kernel_type != 0 ) && ( w == 0 ) ) /* type 1 or 2 */ - { - TCX_MDXT_Inverse_fx( x_fx + L_spec_TCX5_tmp, x_e_hdrm, win_fx, L_ola, sub( L_win, L_ola ), L_ola, kernel_type ); - } - ELSE - { - TCX_MDCT_Inverse( x_fx + L_spec_TCX5_tmp, x_e_hdrm, win_fx, L_ola, sub( L_win, L_ola ), L_ola, st->element_mode ); - } -#endif tcx_windowing_synthesis_current_frame( win_fx, tcx_aldo_window_2_fx, tcx_mdct_window_half_fx, tcx_mdct_window_minimum_fx, L_ola, tcx_mdct_window_half_length, tcx_mdct_window_min_length, ( w > 0 ) ? 0 : left_rect, ( w > 0 ) || ( w == 0 && index == 2 ) ? MIN_OVERLAP : hTcxCfg->tcx_last_overlap_mode, acelp_zir_fx, hTcxDec->old_syn_Overl, syn_Overl_TDAC_fx, st->old_Aq_12_8_fx, tcx_mdct_window_trans_fx, L_win, tcx_offset < 0 ? -tcx_offset : 0, ( w > 0 ) || ( frame_cnt > 0 ) ? 1 : st->last_core, ( w > 0 ) || ( frame_cnt > 0 ) ? 0 : (Word8) st->last_is_cng, fullbandScale ); @@ -3245,14 +3209,12 @@ void IMDCT_ivas_fx( set16_fx( win_fx, 0, shr( add( L_FRAME_PLUS, L_MDCT_OVLP_MAX ), 1 ) ); /* 1st TCX-5 window, special MDCT with minimum overlap on right side */ -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN Word16 q_win_prev; #if 0 // Assume that xn_buf_fx has no headroom. q_win = s_min( q_xn_buf_fx, q_win ); #endif -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN IF( allow_qwin_change ) { /* Use fixed q_win to avoid the need to adapt scaling of two TCX5 blocks (less effort with maybe not ideal scaling) */ @@ -3261,7 +3223,6 @@ void IMDCT_ivas_fx( allow_qwin_change = 0; move16(); } -#endif IF( EQ_16( kernel_type, MDST_IV ) ) { @@ -3276,27 +3237,12 @@ void IMDCT_ivas_fx( TCX_MDCT_Inverse_qwin_fx( x_fx, x_e_hdrm, win_fx + L_win, 0, sub( L_win, shr( L_ola, 1 ) ), L_ola, st->element_mode, &q_win, allow_qwin_change ); } q_win_prev = q_win; -#else - IF( EQ_16( kernel_type, MDST_IV ) ) - { - TCX_MDST_Inverse_fx( x_fx, x_e_hdrm, win_fx + L_win, 0, sub( L_win, shr( L_ola, 1 ) ), L_ola ); - } - ELSE IF( NE_16( kernel_type, MDCT_IV ) ) /* type 1 or 2 */ - { - TCX_MDXT_Inverse_fx( x_fx, x_e_hdrm, win_fx + L_win, 0, sub( L_win, shr( L_ola, 1 ) ), L_ola, kernel_type ); - } - ELSE - { - TCX_MDCT_Inverse( x_fx, x_e_hdrm, win_fx + L_win, 0, sub( L_win, shr( L_ola, 1 ) ), L_ola, st->element_mode ); - } -#endif set16_fx( xn_buf_fx, 0, shr( overlap, 1 ) ); /* copy new sub-window region not overlapping with previous window */ Copy( win_fx + L_win, xn_buf_fx + shr( overlap, 1 ), add( L_win, shr( L_ola, 1 ) ) ); -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN q_xn_buf_fx = q_win; move16(); @@ -3313,17 +3259,6 @@ void IMDCT_ivas_fx( assert( q_win_prev == q_win ); IMDCT_ivas_fx_rescale( xn_buf_fx, &q_xn_buf_fx, syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); -#else - /* 2nd TCX-5 window, regular MDCT with minimum overlap on both sides */ - IF( s_and( kernel_type, 1 ) ) - { - TCX_MDST_Inverse_fx( x_fx + L_spec_TCX5, x_e_hdrm, win_fx, L_ola, sub( L_win, L_ola ), L_ola ); - } - ELSE - { - TCX_MDCT_Inverse( x_fx + L_spec_TCX5, x_e_hdrm, win_fx, L_ola, sub( L_win, L_ola ), L_ola, st->element_mode ); - } -#endif tcx_windowing_synthesis_current_frame( win_fx, tcx_aldo_window_2_fx, tcx_mdct_window_half_fx, tcx_mdct_window_minimum_fx, L_ola, tcx_mdct_window_half_length, tcx_mdct_window_min_length, 0, /* left_rect */ MIN_OVERLAP, /* left_mode */ acelp_zir_fx, hTcxDec->old_syn_Overl, syn_Overl_TDAC_fx, st->old_Aq_12_8_fx, tcx_mdct_window_trans_fx, L_win, ( tcx_offset < 0 ) ? -tcx_offset : 0, 1, /* st->last_mode_bfi */ 0, /* st->last_is_cng */ fullbandScale ); @@ -3358,7 +3293,6 @@ void IMDCT_ivas_fx( ELSE { /* default, i.e. maximum overlap, single transform, no grouping */ -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN IF( allow_qwin_change && fullbandScale ) { q_win = s_min( q_win, norm_arr( acelp_zir_fx, shr( L_frame_glob, 1 ) ) + *q_acelp_zir_fx ); @@ -3381,22 +3315,7 @@ void IMDCT_ivas_fx( move16(); IMDCT_ivas_fx_rescale( xn_buf_fx, &q_xn_buf_fx, syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); -#else - IF( EQ_16( kernel_type, MDST_IV ) ) - { - TCX_MDST_Inverse_fx( x_fx, x_e_hdrm, xn_buf_fx, overlap, sub( L_frame, overlap ), overlap ); - } - ELSE IF( NE_16( kernel_type, MDCT_IV ) ) /* type 1 or 2 */ - { - TCX_MDXT_Inverse_fx( x_fx, x_e_hdrm, xn_buf_fx, overlap, sub( L_frame, overlap ), overlap, kernel_type ); - } - ELSE - { - TCX_MDCT_Inverse( x_fx, x_e_hdrm, xn_buf_fx, overlap, sub( L_frame, overlap ), overlap, st->element_mode ); - } -#endif -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN IF( !fullbandScale ) { *q_acelp_zir_fx = q_xn_buf_fx; @@ -3405,7 +3324,6 @@ void IMDCT_ivas_fx( { scale_sig( acelp_zir_fx, shr( L_frame_glob, 1 ), sub( q_xn_buf_fx, *q_acelp_zir_fx ) ); } -#endif tcx_windowing_synthesis_current_frame( xn_buf_fx, tcx_aldo_window_2_fx, tcx_mdct_window_half_fx, tcx_mdct_window_minimum_fx, overlap, tcx_mdct_window_half_length, tcx_mdct_window_min_length, left_rect, !bfi && ( frame_cnt > 0 ) && ( index == 0 ) && NE_16( st->last_core, ACELP_CORE ) ? MIN_OVERLAP : index, acelp_zir_fx, hTcxDec->old_syn_Overl, syn_Overl_TDAC_fx, st->old_Aq_12_8_fx, tcx_mdct_window_trans_fx, shr( L_frame_glob, 1 ), ( tcx_offset < 0 ) ? -tcx_offset : 0, ( frame_cnt > 0 /*|| (st->last_con_tcx )*/ ) ? 1 : st->last_core_bfi, ( frame_cnt > 0 ) ? 0 : (Word8) st->last_is_cng, fullbandScale ); } /* tcx_last_overlap_mode != FULL_OVERLAP */ @@ -3450,14 +3368,11 @@ void IMDCT_ivas_fx( q_tmp_fx_32 = q_xn_buf_fx_32; move16(); -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN // q_win < norm + q_tmp_fx_32 - 16 q_win = s_min( q_win, L_norm_arr( tmp_fx_32, L_frame ) + q_tmp_fx_32 - 16 ); IMDCT_ivas_fx_rescale( NULL, NULL, syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); -#endif Word16 diff = sub( q_tmp_fx_32, q_win ); -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD Word16 q_old_out_diff = sub( q_tmp_fx_32, *q_old_out_fx ); IF( q_old_out_diff < 0 ) { @@ -3465,15 +3380,10 @@ void IMDCT_ivas_fx( *q_old_out_fx = add( *q_old_out_fx, q_old_out_diff ); q_old_out_diff = 0; } -#endif FOR( Word16 ind = 0; ind < L_frame; ind++ ) { -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD assert( L_shr( L_shl( old_out_fx[ind], q_old_out_diff ), q_old_out_diff ) == old_out_fx[ind] ); old_out_fx_32[ind] = L_shl( L_deposit_l( old_out_fx[ind] ), q_old_out_diff ); -#else - old_out_fx_32[ind] = L_shl( old_out_fx[ind], diff ); -#endif move32(); } @@ -3481,13 +3391,8 @@ void IMDCT_ivas_fx( FOR( Word16 ind = 0; ind < L_frame; ind++ ) { -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD assert( extract_h( L_shr( old_out_fx_32[ind], q_old_out_diff ) ) == 0 || extract_h( L_shr( old_out_fx_32[ind], q_old_out_diff ) ) == -1 ); old_out_fx[ind] = extract_l( L_shr( old_out_fx_32[ind], q_old_out_diff ) ); -#else - assert( extract_h( L_shr( old_out_fx_32[ind], diff ) ) == 0 || extract_h( L_shr( old_out_fx_32[ind], diff ) ) == -1 ); - old_out_fx[ind] = extract_l( L_shr( old_out_fx_32[ind], diff ) ); -#endif assert( extract_h( L_shr( xn_buf_fx_32[ind], diff ) ) == 0 || extract_h( L_shr( xn_buf_fx_32[ind], diff ) ) == -1 ); xn_buf_fx[ind] = extract_l( L_shr( xn_buf_fx_32[ind], diff ) ); move16(); @@ -3496,10 +3401,6 @@ void IMDCT_ivas_fx( } ELSE { -#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD - Word16 q_old_out = q_win; - move16(); -#endif edct_ivas_fx( x_fx, xn_buf_fx_32 + add( shr( overlap, 1 ), nz ), L_frame, &q_xn_buf_fx_32 ); Word16 res_m, res_e; res_e = 0; @@ -3515,7 +3416,6 @@ void IMDCT_ivas_fx( q_tmp_fx_32 = sub( q_xn_buf_fx_32, res_e ); // v_multc_fixed( xn_buf_fx_32 + overlap / 2 + nz, (float) sqrt( (float) L_frame / NORM_MDCT_FACTOR ), tmp_fx_32, L_frame ); -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN if ( allow_qwin_change ) { // sub( q_xn_buf_fx_32, q_win ) == 16 - L_norm_arr( xn_buf_fx_32, L_frame ) @@ -3524,7 +3424,6 @@ void IMDCT_ivas_fx( q_win = s_min( q_win, add( sub( q_xn_buf_fx_32, 16 ), sub( L_norm_arr( xn_buf_fx_32 + ( overlap / 2 ) + nz, L_frame ), 2 ) ) ); } IMDCT_ivas_fx_rescale( xn_buf_fx, &q_xn_buf_fx, syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); -#endif Word16 q_diff = sub( q_xn_buf_fx_32, q_win ); FOR( Word16 ind = 0; ind < L_frame; ind++ ) @@ -3534,14 +3433,7 @@ void IMDCT_ivas_fx( move16(); } -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD window_ola_fx( tmp_fx_32, xn_buf_fx, &q_tmp_fx_32, old_out_fx, q_old_out_fx, L_frame, hTcxCfg->tcx_last_overlap_mode, hTcxCfg->tcx_curr_overlap_mode, 0, 0, NULL ); -#else - window_ola_fx( tmp_fx_32, xn_buf_fx, &q_tmp_fx_32, old_out_fx, &q_old_out, L_frame, hTcxCfg->tcx_last_overlap_mode, hTcxCfg->tcx_curr_overlap_mode, 0, 0, NULL ); - - q_diff = sub( q_old_out, q_win ); -#endif -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN if ( allow_qwin_change ) { // sub( q_tmp_fx_32, q_win ) == -norm_arr( xn_buf_fx, L_frame ) @@ -3549,15 +3441,9 @@ void IMDCT_ivas_fx( // q_win == q_tmp_fx_32 + norm_arr( xn_buf_fx, L_frame ) q_win = s_min( q_win, add( q_tmp_fx_32, norm_arr( xn_buf_fx, L_frame ) ) ); } -#endif Word16 diff = sub( q_tmp_fx_32, q_win ); FOR( Word16 ind = 0; ind < L_frame; ind++ ) { -#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD - - old_out_fx[ind] = shr_sat( old_out_fx[ind], q_diff ); - move16(); -#endif xn_buf_fx[ind] = shr_sat( xn_buf_fx[ind], diff ); move16(); } @@ -3580,7 +3466,6 @@ void IMDCT_ivas_fx( move16(); } -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN IF( allow_qwin_change && fullbandScale ) { q_win = s_min( q_win, norm_arr( acelp_zir_fx, shr( L_frame_glob, 1 ) ) + *q_acelp_zir_fx ); @@ -3613,20 +3498,6 @@ void IMDCT_ivas_fx( move16(); IMDCT_ivas_fx_rescale( xn_buf_fx, &q_xn_buf_fx, syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); -#else - IF( EQ_16( kernel_type, MDST_IV ) ) - { - TCX_MDST_Inverse_fx( x_fx, x_e_hdrm, xn_buf_fx, overlap, L_frame - overlap, overlap ); - } - ELSE IF( NE_16( kernel_type, MDCT_IV ) ) /* type 1 or 2 */ - { - TCX_MDXT_Inverse_fx( x_fx, x_e_hdrm, xn_buf_fx, overlap, L_frame - overlap, overlap, kernel_type ); - } - ELSE - { - TCX_MDCT_Inverse( x_fx, x_e_hdrm, xn_buf_fx, overlap, L_frame - overlap, overlap, st->element_mode ); - } -#endif /*-----------------------------------------------------------* * Windowing, overlap and add * *-----------------------------------------------------------*/ @@ -3658,7 +3529,6 @@ void IMDCT_ivas_fx( move16(); } } -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN IF( !fullbandScale ) { *q_acelp_zir_fx = q_xn_buf_fx; @@ -3667,7 +3537,6 @@ void IMDCT_ivas_fx( { scale_sig( acelp_zir_fx, shr( L_frame_glob, 1 ), sub( q_xn_buf_fx, *q_acelp_zir_fx ) ); } -#endif /* Window current frame */ tcx_windowing_synthesis_current_frame( xn_buf_fx, tcx_aldo_window_2_fx, tcx_mdct_window_half_fx, tcx_mdct_window_minimum_fx, overlap, tcx_mdct_window_half_length, tcx_mdct_window_min_length, left_rect, hTcxCfg->tcx_last_overlap_mode, acelp_zir_fx, hTcxDec->old_syn_Overl, syn_Overl_TDAC_fx, st->old_Aq_12_8_fx, tcx_mdct_window_trans_fx, shr( L_frame_glob, 1 ), acelp_mem_len, st->last_core_bfi, (Word8) st->last_is_cng, fullbandScale ); } @@ -3692,18 +3561,9 @@ void IMDCT_ivas_fx( IF( hTcxCfg->last_aldo != 0 ) { -#if defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD ) && !defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN ) - Word16 tmp_old_out; - Word16 q_diff = sub( *q_old_out_fx, q_win ); -#endif FOR( i = 0; i < sub( overlap, tcx_mdct_window_min_length ); i++ ) { -#if defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD ) && !defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN ) - tmp_old_out = shr_sat( old_out_fx[( i + nz )], q_diff ); - xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )] = add_sat( xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )], tmp_old_out ); // q_win -#else xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )] = add_sat( xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )], old_out_fx[( i + nz )] ); // Q(-2) -#endif move16(); } @@ -3716,32 +3576,17 @@ void IMDCT_ivas_fx( // tested FOR( ; i < overlap; i++ ) /* perfectly reconstructing ALDO shortening */ { -#if defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD ) && !defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN ) - tmp_old_out = shr_sat( old_out_fx[( i + nz )], q_diff ); - xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], tmp_old_out ); // q_win -#else xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], old_out_fx[( i + nz )] ); // q_win -#endif move16(); } FOR( i = 0; i < ( tcx_mdct_window_min_length / 2 ); i++ ) { -#if defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD ) && !defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN ) - tmp_old_out = shr_sat( old_out_fx[( ( i + nz ) + overlap )], q_diff ); - xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )] = add_sat( xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )], mult_r( tmp_old_out, tcx_mdct_window_minimum_fx[i].v.re ) ); // q_win -#else xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )] = add_sat( xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )], mult_r( old_out_fx[( ( i + nz ) + overlap )], tcx_mdct_window_minimum_fx[i].v.re ) ); // q_win -#endif move16(); } FOR( ; i < tcx_mdct_window_min_length; i++ ) { -#if defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD ) && !defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN ) - tmp_old_out = shr_sat( old_out_fx[( ( i + nz ) + overlap )], q_diff ); - xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )] = add_sat( xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )], mult_r( tmp_old_out, tcx_mdct_window_minimum_fx[( tcx_mdct_window_min_length - ( 1 + i ) )].v.im ) ); // q_win -#else xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )] = add_sat( xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )], mult_r( old_out_fx[( ( i + nz ) + overlap )], tcx_mdct_window_minimum_fx[( tcx_mdct_window_min_length - ( 1 + i ) )].v.im ) ); // q_win -#endif move16(); } } @@ -3749,22 +3594,12 @@ void IMDCT_ivas_fx( { FOR( ; i < ( overlap - ( tcx_mdct_window_min_length / 2 ) ); i++ ) { -#if defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD ) && !defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN ) - tmp_old_out = shr_sat( old_out_fx[( i + nz )], q_diff ); - xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( tmp_old_out, tcx_mdct_window_minimum_fx[( ( tcx_mdct_window_min_length - overlap ) + i )].v.re ) ); // Q(-2) -#else xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( old_out_fx[( i + nz )], tcx_mdct_window_minimum_fx[( ( tcx_mdct_window_min_length - overlap ) + i )].v.re ) ); // Q(-2) -#endif move16(); } FOR( ; i < overlap; i++ ) { -#if defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD ) && !defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN ) - tmp_old_out = shr_sat( old_out_fx[( i + nz )], q_diff ); - xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( tmp_old_out, tcx_mdct_window_minimum_fx[( overlap - ( 1 + i ) )].v.im ) ); // Q(-2) -#else xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( old_out_fx[( i + nz )], tcx_mdct_window_minimum_fx[( overlap - ( 1 + i ) )].v.im ) ); // Q(-2) -#endif move16(); } } @@ -3813,9 +3648,7 @@ void IMDCT_ivas_fx( /* Compute windowed synthesis in case of switching to ALDO windows in next frame */ Copy( xn_buf_fx + sub( L_frame, nz ), old_out_fx, add( nz, overlap ) ); set16_fx( old_out_fx + add( nz, overlap ), 0, nz ); -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD *q_old_out_fx = q_win; -#endif tcx_windowing_synthesis_past_frame( old_out_fx + nz, tcx_aldo_window_1_trunc_fx, tcx_mdct_window_half_fx, tcx_mdct_window_minimum_fx, overlap, tcx_mdct_window_half_length, tcx_mdct_window_min_length, hTcxCfg->tcx_curr_overlap_mode ); /* If current overlap mode = FULL_OVERLAP -> ALDO_WINDOW */ @@ -3889,10 +3722,8 @@ void IMDCT_ivas_fx( } } } -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN *pq_win = q_win; move16(); -#endif return; } @@ -4312,7 +4143,6 @@ void decoder_tcx_ivas_fx( decoder_tcx_tns_fx( st, L_frame_glob, L_spec, L_frame, L_frameTCX, x_fx, fUseTns, &tnsData, bfi, frame_cnt, 0, NULL ); -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN 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 ); @@ -4349,57 +4179,6 @@ void decoder_tcx_ivas_fx( Scale_sig( st->hTcxDec->old_syn_Overl, 320, ( -2 - st->hTcxDec->Q_old_syn_Overl ) ); // Scaling to Q-2 st->hTcxDec->Q_old_syn_Overl = -2; -#else - 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 ); - - IF( st->igf != 0 ) - { - Scale_sig32( st->hIGFDec->virtualSpec, ( N_MAX_TCX - IGF_START_MN ), ( sub( st->hIGFDec->virtualSpec_e, x_e ) ) ); - st->hIGFDec->virtualSpec_e = x_e; - move16(); - } - - /* Scaling down buffers for decoder_tcx_imdct_fx*/ - Scale_sig( st->hTcxDec->syn_Overl_TDACFB, L_FRAME_MAX / 2, sub( st->Q_syn, st->hTcxDec->Q_syn_Overl_TDACFB ) ); // Scaling to Q_syn - st->hTcxDec->Q_syn_Overl_TDACFB = st->Q_syn; - move16(); - Scale_sig( st->hTcxDec->syn_Overl_TDAC, L_FRAME32k / 2, sub( st->Q_syn, st->hTcxDec->Q_syn_Overl_TDAC ) ); // Scaling to Q_syn - st->hTcxDec->Q_syn_Overl_TDAC = st->Q_syn; - move16(); -#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD - Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, negate( st->hHQ_core->Q_old_wtda ) ); // Scaling to Q0 - Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, negate( st->hHQ_core->Q_old_wtda_LB ) ); // Scaling to Q0 - st->hHQ_core->Q_old_wtda = 0; - move16(); - st->hHQ_core->Q_old_wtda_LB = 0; - move16(); -#endif - - Scale_sig( st->hTcxDec->old_syn_Overl, 320, st->Q_syn - st->hTcxDec->Q_old_syn_Overl ); // Scaling to Q_syn - st->hTcxDec->Q_old_syn_Overl = st->Q_syn; - Copy_Scale_sig_16_32_no_sat( st->old_Aq_12_8_fx, st->old_Aq_12_8_fx_32, M + 1, ( sub( 28, ( sub( 15, norm_s( sub( st->old_Aq_12_8_fx[0], 1 ) ) ) ) ) ) ); - - Scale_sig( synth_fx, L_frame_glob, st->Q_syn ); // Scaling to Q_syn - Scale_sig( synthFB_fx, L_frameTCX_glob, st->Q_syn ); // Scaling to Q_syn - - decoder_tcx_imdct_fx( st, L_frame_glob, L_frameTCX_glob, L_spec, tcx_offset, tcx_offsetFB, L_frame, L_frameTCX, left_rect, &x_fx[0], q_x, xn_buf_fx, st->Q_syn, MDCT_IV, - fUseTns, &synth_fx[0], &synthFB_fx[0], bfi, frame_cnt, sba_dirac_stereo_flag ); - - /* Scaling up again */ - Scale_sig( synth_fx, L_frame_glob, negate( st->Q_syn ) ); - Scale_sig( synthFB_fx, L_frameTCX_glob, negate( st->Q_syn ) ); - // Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, 1 ); -#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD - st->hHQ_core->Q_old_wtda = st->Q_syn; - // Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, ( sub( st->hHQ_core->Q_old_wtda, st->Q_syn ) ) ); - st->hHQ_core->Q_old_wtda_LB = st->Q_syn; - // Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, ( sub( st->hHQ_core->Q_old_wtda, st->Q_syn ) ) ); -#endif - Scale_sig( st->hTcxDec->old_syn_Overl, 320, ( -2 - st->hTcxDec->Q_old_syn_Overl ) ); // Scaling to Q-2 - st->hTcxDec->Q_old_syn_Overl = -2; -#endif } /*-------------------------------------------------------------------* @@ -5793,12 +5572,8 @@ void decoder_tcx_imdct_fx( Word32 x_fx[N_MAX], // Q(11) Word16 q_x, Word16 xn_buf_fx[], // Q(-2) -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN Word16 *q_win, Word16 *q_winFB, -#else - Word16 q_win, -#endif const UWord16 kernelType, /* i : TCX transform kernel type */ const Word16 fUseTns, /* i : flag that is set if TNS data is present */ Word16 synth_fx[], // Q(-2) /* i/o: synth[-M..L_frame] */ @@ -5824,12 +5599,8 @@ void decoder_tcx_imdct_fx( Word16 q_a_itf = 15; Word16 x_e = sub( 31, q_x ); move16(); -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN Word16 q_acelp_zir_fx = 0; set16_fx( acelp_zir_fx, 0, L_FRAME_MAX / 2 ); -#else - Word16 shift_q = sub( q_x, q_win ); -#endif /*-----------------------------------------------------------------* * Initializations @@ -5982,17 +5753,9 @@ void decoder_tcx_imdct_fx( IF( NE_16( st->element_mode, IVAS_CPE_DFT ) && !sba_dirac_stereo_flag ) { -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN IMDCT_ivas_fx( xn_bufFB_fx, q_x, hTcxDec->syn_Overl, &hTcxDec->Q_syn_Overl, hTcxDec->syn_Overl_TDAC, &hTcxDec->Q_syn_Overl_TDAC, xn_buf_fx, *q_win, hTcxCfg->tcx_aldo_window_1, hTcxCfg->tcx_aldo_window_1_trunc, hTcxCfg->tcx_aldo_window_2, -#else - IMDCT_ivas_fx( xn_bufFB_fx, q_x, hTcxDec->syn_Overl, hTcxDec->syn_Overl_TDAC, xn_buf_fx, hTcxCfg->tcx_aldo_window_1, hTcxCfg->tcx_aldo_window_1_trunc, hTcxCfg->tcx_aldo_window_2, -#endif hTcxCfg->tcx_mdct_window_half, hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_half_length, hTcxCfg->tcx_mdct_window_min_length, index, -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, &st->hHQ_core->Q_old_wtda_LB, 0, st, 0, acelp_zir_fx, &q_acelp_zir_fx, q_win ); -#else - kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, 0, st, 0, acelp_zir_fx, q_win ); -#endif } /* Generate additional comfort noise to mask potential coding artefacts */ @@ -6012,31 +5775,19 @@ void decoder_tcx_imdct_fx( IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || ( sba_dirac_stereo_flag != 0 ) ) { Copy32( x_fx, xn_bufFB_fx, s_max( L_spec, s_max( L_frame, L_frameTCX ) ) ); // q_x -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN IMDCT_ivas_fx( xn_bufFB_fx, q_x, hTcxDec->syn_Overl, &hTcxDec->Q_syn_Overl, hTcxDec->syn_Overl_TDAC, &hTcxDec->Q_syn_Overl_TDAC, xn_buf_fx, *q_win, hTcxCfg->tcx_aldo_window_1, hTcxCfg->tcx_aldo_window_1_trunc, hTcxCfg->tcx_aldo_window_2, hTcxCfg->tcx_mdct_window_half, hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_half_length, hTcxCfg->tcx_mdct_window_min_length, index, -#else - IMDCT_ivas_fx( xn_bufFB_fx, q_x, hTcxDec->syn_Overl, hTcxDec->syn_Overl_TDAC, xn_buf_fx, hTcxCfg->tcx_aldo_window_1, hTcxCfg->tcx_aldo_window_1_trunc, hTcxCfg->tcx_aldo_window_2, hTcxCfg->tcx_mdct_window_half, hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_half_length, hTcxCfg->tcx_mdct_window_min_length, index, -#endif -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, &st->hHQ_core->Q_old_wtda_LB, 0, st, 0, acelp_zir_fx, &q_acelp_zir_fx, q_win ); -#else - kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, 0, st, 0, acelp_zir_fx, q_win ); -#endif } -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN Word16 shift_q, q_x16; shift_q = L_norm_arr( xn_bufFB_fx, L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX ); shift_q = sub( 16, shift_q ); q_x16 = sub( q_x, shift_q ); -#endif FOR( Word16 ind = 0; ind < L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX; ind++ ) { -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN assert( extract_h( L_shr( xn_bufFB_fx[ind], shift_q ) ) == 0 || extract_h( L_shr( xn_bufFB_fx[ind], shift_q ) ) == -1 ); -#endif xn_bufFB_fx_16[ind] = extract_l( L_shr( xn_bufFB_fx[ind], shift_q ) ); // q_x16 move16(); } @@ -6047,36 +5798,18 @@ void decoder_tcx_imdct_fx( IF( st->element_mode != EVS_MONO ) { -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN IMDCT_ivas_fx( x_tmp_fx, q_x, hTcxDec->syn_OverlFB, &hTcxDec->Q_syn_OverlFB, hTcxDec->syn_Overl_TDACFB, &hTcxDec->Q_syn_Overl_TDACFB, xn_bufFB_fx_16, q_x16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, -#else - IMDCT_ivas_fx( x_tmp_fx, q_x, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, xn_bufFB_fx_16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, -#endif hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index, -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, &st->hHQ_core->Q_old_wtda, 1, st, ratio, acelp_zir_fx, &q_acelp_zir_fx, q_winFB ); -#else - kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, ratio, acelp_zir_fx, q_win ); -#endif } ELSE { -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN IMDCT_ivas_fx( x_fx, q_x, hTcxDec->syn_OverlFB, &hTcxDec->Q_syn_OverlFB, hTcxDec->syn_Overl_TDACFB, &hTcxDec->Q_syn_Overl_TDACFB, xn_bufFB_fx_16, q_x16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index, -#else - IMDCT_ivas_fx( x_fx, q_x, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, xn_bufFB_fx_16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index, -#endif -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, &st->hHQ_core->Q_old_wtda, 1, st, ratio, acelp_zir_fx, &q_acelp_zir_fx, q_winFB ); -#else - kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, ratio, acelp_zir_fx, q_win ); -#endif } -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN shift_q = 16; move16(); -#endif FOR( Word16 ind = 0; ind < L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX; ind++ ) { diff --git a/lib_dec/er_dec_acelp_fx.c b/lib_dec/er_dec_acelp_fx.c index 470053c6a..20408c23c 100644 --- a/lib_dec/er_dec_acelp_fx.c +++ b/lib_dec/er_dec_acelp_fx.c @@ -1018,10 +1018,8 @@ void con_acelp_fx( Copy( syn, synth, st->L_frame ); bufferCopyFx( syn + sub( st->L_frame, shr( st->L_frame, 1 ) ), hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), 0 /*Qf_syn*/, -1 /*Qf_old_xnq*/, 0, 0 /*Q_old_xnq*/ ); -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT st->hTcxDec->Q_old_syn_Overl = sub( Qf_syn, 1 ); move16(); -#endif /* save last half frame if next frame is TCX */ bufferCopyFx( syn + st->L_frame, hTcxDec->syn_Overl_TDAC, shr( st->L_frame, 1 ), 0 /*Qf_syn*/, -1 /*Qf_old_xnq*/, 0, 0 /*Q_old_xnq*/ ); @@ -1106,15 +1104,11 @@ void con_acelp_fx( st->hTcxDec->Q_syn_Overl_TDACFB = st->hTcxDec->Q_syn_Overl_TDAC; move16(); lerp( hTcxDec->syn_Overl, hTcxDec->syn_OverlFB, shr( hTcxDec->L_frameTCX, 1 ), shr( st->L_frame, 1 ) ); -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT hTcxDec->Q_syn_OverlFB = hTcxDec->Q_syn_Overl; move16(); -#endif lerp( hHQ_core->old_out_LB_fx, hHQ_core->old_out_fx, hTcxDec->L_frameTCX, st->L_frame ); -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT hHQ_core->Q_old_wtda = hHQ_core->Q_old_wtda_LB; move16(); -#endif /* copy total excitation exc2 as 16kHz for acelp mode1 decoding */ IF( st->hWIDec != NULL ) diff --git a/lib_dec/er_dec_tcx_fx.c b/lib_dec/er_dec_tcx_fx.c index 9d0a3cc44..bf35bb852 100644 --- a/lib_dec/er_dec_tcx_fx.c +++ b/lib_dec/er_dec_tcx_fx.c @@ -851,10 +851,8 @@ void con_tcx_fx( lerp( syn + sub( L_frame, shr( L_frame, 1 ) ), hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), shr( L_frame, 1 ) ); -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT st->hTcxDec->Q_old_syn_Overl = Q_syn; move16(); -#endif Copy( syn + sub( L_frame, n ), hHQ_core->old_out_fx, sub( L_frame, n ) ); /*Q_syn*/ FOR( i = 0; i < W12; i++ ) @@ -879,13 +877,9 @@ void con_tcx_fx( bufferCopyFx( syn, synth, L_frame, Q_syn, 0, 0, 0 ); /*Q_syn*/ BASOP_SATURATE_WARNING_ON_EVS -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT Copy_Scale_sig( syn + L_frame, hTcxDec->syn_OverlFB, shr( L_frame, 1 ), sub( 0, Q_syn ) ); /*Q0*/ hTcxDec->Q_syn_OverlFB = 0; move16(); -#else - Copy_Scale_sig( syn + L_frame, hTcxDec->syn_OverlFB, shr( L_frame, 1 ), negate( Q_syn ) ); /*Q0*/ -#endif /* copy total excitation exc2 as 16kHz for acelp mode1 decoding */ IF( st->hWIDec != NULL ) @@ -947,15 +941,11 @@ void con_tcx_fx( /* update memory for low band */ Scale_sig( hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), sub( -1, Q_syn ) ); /*Q_syn*/ -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT hTcxDec->Q_old_syn_Overl = -1; move16(); -#endif lerp( hTcxDec->syn_OverlFB, hTcxDec->syn_Overl, shr( st->L_frame, 1 ), shr( L_frame, 1 ) ); -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT hTcxDec->Q_syn_Overl = hTcxDec->Q_syn_OverlFB; move16(); -#endif lerp( hTcxDec->syn_Overl_TDACFB, hTcxDec->syn_Overl_TDAC, shr( st->L_frame, 1 ), shr( L_frame, 1 ) ); hTcxDec->Q_syn_Overl_TDAC = hTcxDec->Q_syn_Overl_TDACFB; move16(); @@ -1819,10 +1809,8 @@ void con_tcx_ivas_fx( lerp( syn + sub( L_frame, shr( L_frame, 1 ) ), hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), shr( L_frame, 1 ) ); -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT hTcxDec->Q_old_syn_Overl = Q_syn; move16(); -#endif Copy( syn + sub( L_frame, n ), hHQ_core->old_out_fx, sub( L_frame, n ) ); /*Q_syn*/ FOR( i = 0; i < W12; i++ ) @@ -1847,13 +1835,9 @@ void con_tcx_ivas_fx( bufferCopyFx( syn, synth, L_frame, Q_syn, 0, 0, 0 ); /*Q_syn*/ BASOP_SATURATE_WARNING_ON_EVS -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT Copy_Scale_sig( syn + L_frame, hTcxDec->syn_OverlFB, shr( L_frame, 1 ), sub( 0, Q_syn ) ); /*Q0*/ hTcxDec->Q_syn_OverlFB = 0; move16(); -#else - Copy_Scale_sig( syn + L_frame, hTcxDec->syn_OverlFB, shr( L_frame, 1 ), negate( Q_syn ) ); /*Q0*/ -#endif /* copy total excitation exc2 as 16kHz for acelp mode1 decoding */ IF( st->hWIDec != NULL ) @@ -1868,14 +1852,8 @@ void con_tcx_ivas_fx( move16(); /* create aliasing and windowing need for transition to TCX10/5 */ -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT Copy( syn + L_frame, hTcxDec->syn_Overl_TDACFB, shr( L_frame, 1 ) ); hTcxDec->Q_syn_Overl_TDACFB = Q_syn; -#else - // bufferCopyFx( syn + L_frame, hTcxDec->syn_Overl_TDACFB, shr( L_frame, 1 ), Q_syn, 0, -1, 0 ); - Copy_Scale_sig( syn + L_frame, hTcxDec->syn_Overl_TDACFB, shr( L_frame, 1 ), sub( Q_syn, 1 ) ); - hTcxDec->Q_syn_Overl_TDACFB = sub( Q_syn, 1 ); -#endif move16(); FOR( i = 0; i < W12; i++ ) @@ -1922,15 +1900,9 @@ void con_tcx_ivas_fx( /* update memory for low band */ st->Q_syn = Q_syn; move16(); -#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT - Scale_sig( hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), sub( -1, Q_syn ) ); /*Q_syn*/ - st->hTcxDec->Q_old_syn_Overl = -1; -#endif lerp( hTcxDec->syn_OverlFB, hTcxDec->syn_Overl, shr( st->L_frame, 1 ), shr( L_frame, 1 ) ); -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT hTcxDec->Q_syn_Overl = hTcxDec->Q_syn_OverlFB; move16(); -#endif lerp( hTcxDec->syn_Overl_TDACFB, hTcxDec->syn_Overl_TDAC, shr( st->L_frame, 1 ), shr( L_frame, 1 ) ); hTcxDec->Q_syn_Overl_TDAC = hTcxDec->Q_syn_Overl_TDACFB; move16(); diff --git a/lib_dec/hq_core_dec_fx.c b/lib_dec/hq_core_dec_fx.c index 3e7660332..5153215db 100644 --- a/lib_dec/hq_core_dec_fx.c +++ b/lib_dec/hq_core_dec_fx.c @@ -1094,10 +1094,8 @@ void HQ_core_dec_init_fx( move16(); move16(); move16(); -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT hHQ_core->Q_old_out_fx32 = Q11; move16(); -#endif hHQ_core->last_hq_core_type = -1; /* Q0 */ move16(); diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index cfdb13801..b7dd1872d 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -343,10 +343,8 @@ ivas_error ivas_core_dec_fx( Copy_Scale_sig_16_32_no_sat( sts[0]->hHQ_core->old_out_LB_fx, sts[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, sub( Q11, sts[0]->hHQ_core->Q_old_wtda_LB ) ); // Q11 L_lerp_fx_q11( sts[0]->hHQ_core->old_out_LB_fx32, sts[0]->hHQ_core->old_out_LB_fx32, sts[0]->L_frame, sts[0]->last_L_frame ); Copy_Scale_sig_32_16( sts[0]->hHQ_core->old_out_LB_fx32, sts[0]->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( sts[0]->hHQ_core->Q_old_wtda_LB, Q11 ) ); // Q_old_wtda_LB -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT sts[0]->hHQ_core->Q_old_out_fx32 = Q11; move16(); -#endif } IF( NE_16( sts[0]->L_frame, L_FRAME16k ) ) { @@ -592,14 +590,6 @@ ivas_error ivas_core_dec_fx( /* TCX decoder */ Scale_sig( st->hPFstat->mem_stp, L_SUBFR, -Qsyn_temp ); // Q0 Scale_sig( st->hPFstat->mem_pf_in, L_SUBFR, -Qsyn_temp ); // Q0 -#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT - Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, -st->hHQ_core->Q_old_wtda_LB ); // Q0 - Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, -st->hHQ_core->Q_old_wtda ); // Q0 - st->hHQ_core->Q_old_wtda_LB = 0; - move16(); - st->hHQ_core->Q_old_wtda = 0; - move16(); -#endif IF( st_ivas == NULL ) { @@ -614,10 +604,6 @@ ivas_error ivas_core_dec_fx( stereo_tcx_core_dec_fx( st, frameMode[n], output_16_fx[n], synth_16_fx[n], pitch_buf_fx[n], sba_dirac_stereo_flag, hStereoTD, last_element_mode, flag_sec_CNA, hStereoCng, nchan_out, ivas_format ); -#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN - st->hHQ_core->Q_old_wtda_LB = st->hHQ_core->Q_old_wtda; - move16(); -#endif Copy_Scale_sig_16_32_DEPREC( output_16_fx[n], output_32_fx[n], output_frame, Q11 ); // Q11 IF( st->hTcxDec ) @@ -723,17 +709,6 @@ ivas_error ivas_core_dec_fx( st->hHQ_core->Q_fer_samples = 0; move16(); } -#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT - IF( NE_16( st->core, st->last_core ) ) - { - IF( st->hTcxDec ) - { - Scale_sig( st->hTcxDec->syn_OverlFB, L_FRAME_MAX / 2, negate( st->Q_syn ) ); // Q0 - } - st->Q_syn = 0; - move16(); - } -#endif st->prev_Q_syn = st->Q_syn; move16(); @@ -1428,10 +1403,8 @@ ivas_error ivas_core_dec_fx( { Copy_Scale_sig_16_32_no_sat( st->hHQ_core->old_out_LB_fx, st->hHQ_core->old_out_LB_fx32, L_FRAME32k, sub( Q11, st->hHQ_core->Q_old_wtda_LB ) ); // Q11 Copy_Scale_sig_16_32_no_sat( st->hHQ_core->old_out_fx, st->hHQ_core->old_out_fx32, L_FRAME48k, sub( Q11, st->hHQ_core->Q_old_wtda ) ); // Q11 -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT st->hHQ_core->Q_old_out_fx32 = Q11; move16(); -#endif } IF( NE_16( st->element_mode, IVAS_CPE_DFT ) ) diff --git a/lib_dec/ivas_cpe_dec_fx.c b/lib_dec/ivas_cpe_dec_fx.c index 18d3cdb06..f8d229540 100644 --- a/lib_dec/ivas_cpe_dec_fx.c +++ b/lib_dec/ivas_cpe_dec_fx.c @@ -132,11 +132,7 @@ ivas_error ivas_cpe_dec_fx( IF( hCPE->hCoreCoder[ind1]->hHQ_core ) { Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[ind1]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[ind1]->hHQ_core->old_out_LB_fx32, L_FRAME32k, sub( Q11, hCPE->hCoreCoder[ind1]->hHQ_core->Q_old_wtda_LB ) ); // Q11 -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT hCPE->hCoreCoder[ind1]->hHQ_core->Q_old_out_fx32 = Q11; -#else - hCPE->hCoreCoder[ind1]->hHQ_core->q_old_outLB_fx = Q11; -#endif move16(); } } diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 54d7f5f17..a502d1b1c 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -418,11 +418,7 @@ ivas_error ivas_jbm_dec_tc_fx( { Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ); // q Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, L_FRAME48k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ); // q -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT hCPE->hCoreCoder[0]->hHQ_core->Q_old_out_fx32 = q; -#else - hCPE->hCoreCoder[0]->hHQ_core->q_old_outLB_fx = q; -#endif move16(); } IF( hCPE->hStereoDft != NULL ) @@ -968,11 +964,7 @@ ivas_error ivas_jbm_dec_tc_fx( { Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, sub( q, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ) ); // q Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, L_FRAME48k, sub( q, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ) ); // q -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT hCPE->hCoreCoder[0]->hHQ_core->Q_old_out_fx32 = q; -#else - hCPE->hCoreCoder[0]->hHQ_core->q_old_outLB_fx = q; -#endif move16(); } IF( hCPE->hStereoDft != NULL ) @@ -1424,11 +1416,7 @@ ivas_error ivas_jbm_dec_tc_fx( { Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ); // q Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, L_FRAME48k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ); // q -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT hCPE->hCoreCoder[0]->hHQ_core->Q_old_out_fx32 = q; -#else - hCPE->hCoreCoder[0]->hHQ_core->q_old_outLB_fx = q; -#endif move16(); } IF( hCPE->hStereoDft != NULL ) diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index e63f910c5..d02bb025f 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1107,17 +1107,8 @@ void ivas_mdct_core_reconstruct_fx( Word16 *synthFB_fx; Word16 q_syn = 0; move16(); -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN Word16 q_win = 0; Word16 q_winFB = 0; -#else -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT - Word16 q_win = -1; -#else - Word16 q_win = -2; -#endif - move16(); -#endif /* TCX */ Word16 xn_buf_fx[L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX]; // Q(-2) Word16 tcx_offset[CPE_CHANNELS]; @@ -1178,52 +1169,22 @@ void ivas_mdct_core_reconstruct_fx( st->hTcxDec->q_old_synth = 0; move16(); } -#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN - Copy( st->hTcxDec->old_synth, synth_buf_fx, st->hTcxDec->old_synth_len ); // Q = st->hTcxDec->q_old_synth - Copy_Scale_sig( st->hTcxDec->old_synthFB_fx, synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, sub( st->hTcxDec->q_old_synth, st->Q_syn ) ); // Q = st->hTcxDec->q_old_synth -#endif q_syn = st->hTcxDec->q_old_synth; move16(); set16_fx( synth_fx, 0, L_FRAME_PLUS + M ); set16_fx( synthFB_fx, 0, L_FRAME_PLUS + M ); IF( st->core != ACELP_CORE ) { -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN Word16 q_win0 = Q15; move16(); Word16 q_winFB0 = Q15; move16(); -#else - Scale_sig( st->hTcxDec->syn_Overl_TDACFB, L_FRAME_MAX / 2, sub( q_win, st->hTcxDec->Q_syn_Overl_TDACFB ) ); // st->hTcxDec->Q_syn_Overl_TDACFB -> q_win - st->hTcxDec->Q_syn_Overl_TDACFB = q_win; - move16(); - Scale_sig( st->hTcxDec->syn_Overl_TDAC, L_FRAME32k / 2, sub( q_win, st->hTcxDec->Q_syn_Overl_TDAC ) ); // st->hTcxDec->Q_syn_Overl_TDAC -> q_win - st->hTcxDec->Q_syn_Overl_TDAC = q_win; - move16(); - Scale_sig( st->hTcxDec->old_syn_Overl, L_FRAME32k / 2, sub( q_win, st->hTcxDec->Q_old_syn_Overl ) ); // Q(-1 - st->Q_syn) -> q_win - st->hTcxDec->Q_old_syn_Overl = q_win; - move16(); - Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, sub( q_win, st->Q_syn ) ); // Q(st->Q_syn) -> q_win - Scale_sig( st->hTcxDec->syn_OverlFB, L_FRAME_MAX / 2, sub( q_win, st->Q_syn ) ); // Q(st->Q_syn) -> q_win - Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( q_win, st->hHQ_core->Q_old_wtda_LB ) ); // Q(st->hHQ_core->Q_old_wtda_LB) -> q_win - Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, sub( q_win, st->hHQ_core->Q_old_wtda ) ); // Q(st->hHQ_core->Q_old_wtda) -> q_win -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD - st->hHQ_core->Q_old_wtda = q_win; - move16(); - st->hHQ_core->Q_old_wtda_LB = q_win; - move16(); -#endif - Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ), sub( q_win, q_syn ) ); // q_syn -> q_win - Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), sub( q_win, q_syn ) ); // q_syn -> q_win - Scale_sig( st->syn, M + 1, sub( q_win, st->Q_syn ) ); // st->Q_syn -> q_win -#endif FOR( k = 0; k < nSubframes[ch]; k++ ) { init_tcx_info_fx( st, L_frame_global[ch], L_frame_globalTCX[ch], k, bfi, &tcx_offset[ch], &tcx_offsetFB[ch], &L_frame[ch], &L_frameTCX[ch], &left_rect[ch], &L_spec[ch] ); -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN assert( nSubframes[ch] <= 2 ); q_win0 = q_win; move16(); @@ -1233,11 +1194,9 @@ void ivas_mdct_core_reconstruct_fx( move16(); q_winFB = -2; move16(); -#endif IF( !skip_decoding ) { -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN test(); test(); IF( ( EQ_16( hCPE->nchan_out, 1 ) && EQ_16( st->hTcxDec->kernel_type[k], MDST_IV ) ) || EQ_16( st->hTcxCfg->tcx_last_overlap_mode, TRANSITION_OVERLAP ) ) @@ -1250,45 +1209,26 @@ void ivas_mdct_core_reconstruct_fx( decoder_tcx_imdct_fx( st, L_frame_global[ch], L_frame_globalTCX[ch], L_spec[ch], tcx_offset[ch], tcx_offsetFB[ch], L_frame[ch], L_frameTCX[ch], left_rect[ch], x_fx[ch][k], q_x, xn_buf_fx, &q_win, &q_winFB, st->hTcxDec->kernel_type[k], fUseTns[ch][k], &synth_fx[k * L_frame[ch]], &synthFB_fx[k * L_frameTCX[ch]], bfi, k, 0 ); } -#else - test(); - test(); - IF( ( EQ_16( hCPE->nchan_out, 1 ) && EQ_16( st->hTcxDec->kernel_type[k], MDST_IV ) ) || EQ_16( st->hTcxCfg->tcx_last_overlap_mode, TRANSITION_OVERLAP ) ) - { - decoder_tcx_imdct_fx( st, L_frame_global[ch], L_frame_globalTCX[ch], L_spec[ch], tcx_offset[ch], tcx_offsetFB[ch], L_frame[ch], L_frameTCX[ch], left_rect[ch], x_fx[ch][k], q_x, xn_buf_fx, q_win, - MDCT_IV, fUseTns[ch][k], &synth_fx[k * L_frame[ch]], &synthFB_fx[k * L_frameTCX[ch]], bfi, k, 0 ); - } - ELSE - { - decoder_tcx_imdct_fx( st, L_frame_global[ch], L_frame_globalTCX[ch], L_spec[ch], tcx_offset[ch], tcx_offsetFB[ch], L_frame[ch], L_frameTCX[ch], left_rect[ch], x_fx[ch][k], q_x, xn_buf_fx, q_win, - st->hTcxDec->kernel_type[k], fUseTns[ch][k], &synth_fx[k * L_frame[ch]], &synthFB_fx[k * L_frameTCX[ch]], bfi, k, 0 ); - } -#endif } ELSE { -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN q_win = Q15; move16(); q_winFB = Q15; move16(); -#endif set16_fx( &synth_fx[k * L_frame[ch]], 0, L_frame[ch] ); set16_fx( &synthFB_fx[k * L_frame[ch]], 0, L_frameTCX[ch] ); /* Note: these buffers are not subframe-based, hence no indexing with k */ set16_fx( &st->hHQ_core->old_out_LB_fx[0], 0, L_frame[ch] ); set16_fx( &st->hHQ_core->old_out_fx[0], 0, L_frameTCX[ch] ); -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD st->hHQ_core->Q_old_wtda = Q15; st->hHQ_core->Q_old_wtda_LB = Q15; -#endif set16_fx( &st->hTcxDec->syn_Overl[0], 0, shr( L_frame[ch], 1 ) ); set16_fx( &st->hTcxDec->syn_OverlFB[0], 0, shr( L_frameTCX[ch], 1 ) ); set16_fx( &st->hTcxDec->syn_Overl_TDAC[0], 0, shr( L_frame[ch], 1 ) ); set16_fx( &st->hTcxDec->syn_Overl_TDACFB[0], 0, shr( L_frameTCX[ch], 1 ) ); } } -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN IF( nSubframes[ch] > 1 ) { @@ -1342,58 +1282,12 @@ void ivas_mdct_core_reconstruct_fx( { Scale_sig( st->mem_syn2_fx, M, sub( st->Q_syn, add( q_win, 2 ) ) ); // q_win+2 -> st->Q_syn: in this case, E_UTIL_f_preemph2 shifts st->mem_syn2_fx by 2 bits } -#else - test(); - IF( ( bfi == 0 ) && st->hTonalMDCTConc != NULL ) - { - TonalMDCTConceal_SaveTimeSignal_ivas_fx( st->hTonalMDCTConc, synthFB_fx, q_win, L_frameTCX[ch] ); - } - decoder_tcx_post_ivas_fx( st, synth_fx, synthFB_fx, q_win, NULL, bfi, MCT_flag ); - - sf = s_min( getScaleFactor16( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ) ), getScaleFactor16( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ) ) ); - IF( LT_16( sf, 2 ) ) - { - q_syn = sub( sf, 2 ); - st->Q_syn = q_syn; - move16(); - } - sf = s_min( getScaleFactor16( st->hHQ_core->old_out_fx, L_FRAME48k ), getScaleFactor16( st->hHQ_core->old_out_LB_fx, L_FRAME32k ) ); - IF( LT_16( sf, sub( st->Q_syn, q_win ) ) ) - { - st->Q_syn = add( q_win, sf ); - } - - Scale_sig( st->hTcxDec->syn_Overl_TDACFB, L_FRAME_MAX / 2, sub( sub( -1, st->Q_syn ), q_win ) ); // q_win -> Q(-1 - st->Q_syn) - st->hTcxDec->Q_syn_Overl_TDACFB = sub( -1, st->Q_syn ); - move16(); - Scale_sig( st->hTcxDec->syn_Overl_TDAC, L_FRAME32k / 2, sub( sub( -1, st->Q_syn ), q_win ) ); // q_win -> Q(-1 - st->Q_syn) - st->hTcxDec->Q_syn_Overl_TDAC = sub( -1, st->Q_syn ); - move16(); - Scale_sig( st->hTcxDec->old_syn_Overl, L_FRAME32k / 2, sub( sub( -1, st->Q_syn ), st->hTcxDec->Q_old_syn_Overl ) ); // q_win -> Q(-1 - st->Q_syn) - st->hTcxDec->Q_old_syn_Overl = sub( -1, st->Q_syn ); - Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ), sub( q_syn, q_win ) ); // q_win -> q_syn - Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), sub( q_syn, q_win ) ); // q_win -> q_syn - Scale_sig( st->syn, M + 1, add( st->Q_syn, 2 ) ); - Scale_sig( st->hTcxDec->syn_OverlFB, L_FRAME_MAX / 2, sub( st->Q_syn, q_win ) ); // q_win -> st->Q_syn - st->hTcxDec->Q_syn_OverlFB = st->Q_syn; - Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, sub( st->Q_syn, q_win ) ); // q_win -> st->Q_syn - st->hTcxDec->Q_syn_Overl = st->Q_syn; -#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD - Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( st->Q_syn, q_win ) ); // q_win -> st->Q_syn - Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, sub( st->Q_syn, q_win ) ); // q_win -> st->Q_syn - st->hHQ_core->Q_old_wtda = st->Q_syn; - move16(); - st->hHQ_core->Q_old_wtda_LB = st->Q_syn; - move16(); -#endif -#endif #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD_NO Scale_sig( st->mem_syn2_fx, M, sub( st->Q_syn, q_win ) ); // q_win -> Q_syn #endif } ELSE /*ACELP core for ACELP-PLC */ { -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN Copy( st->hTcxDec->old_synth, synth_buf_fx, st->hTcxDec->old_synth_len ); // Q = st->hTcxDec->q_old_synth Copy_Scale_sig( st->hTcxDec->old_synthFB_fx, synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, sub( st->hTcxDec->q_old_synth, st->Q_syn ) ); // Q = st->hTcxDec->q_old_synth @@ -1401,7 +1295,6 @@ void ivas_mdct_core_reconstruct_fx( // Scale_sig( synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, -2 ); // Scale_sig( synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, +2 ); /////////////////////////////////////////////////////////////////////////////////// -#endif assert( EQ_16( st->bfi, 1 ) ); /* PLC: [TCX: TD PLC] */ IF( MCT_flag != 0 ) @@ -1431,12 +1324,10 @@ void ivas_mdct_core_reconstruct_fx( move16(); st->hTcxDec->Q_old_syn_Overl = add( st->hTcxDec->Q_old_syn_Overl, q_syn ); move16(); -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN st->hTcxDec->Q_syn_OverlFB = add( st->hTcxDec->Q_syn_OverlFB, q_syn ); move16(); // st->hTcxDec->Q_syn_Overl = add( st->hTcxDec->Q_syn_Overl, q_syn ); // It is disabled because it increased the number of regressions. // move16(); -#endif IF( ( EQ_16( st->nbLostCmpt, 1 ) ) || ( st->hTcxDec->tcxConceal_recalc_exc != 0 ) ) { diff --git a/lib_dec/ivas_post_proc_fx.c b/lib_dec/ivas_post_proc_fx.c index 1b02b2b17..f3254c4a5 100644 --- a/lib_dec/ivas_post_proc_fx.c +++ b/lib_dec/ivas_post_proc_fx.c @@ -112,9 +112,7 @@ void ivas_post_proc_fx( { Word16 numZeros = (Word16) ( NS2SA_FX2( output_Fs, N_ZERO_MDCT_NS ) ); /*Q0*/ move16(); -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT assert( sts[n]->hHQ_core->Q_old_out_fx32 == Q11 ); -#endif Copy32( sts[n]->hHQ_core->old_out_fx32 + numZeros, sts[n]->hTcxDec->FBTCXdelayBuf_32, delay_comp ); /*Q11*/ } @@ -591,11 +589,7 @@ void stereo_dft_dec_core_switching_fx( Word32 tmp_fade_fx[max( STEREO_DFT_ALLPASS_FADELEN_12k8, STEREO_DFT_ALLPASS_FADELEN_16k )]; Copy32( st->hHQ_core->old_out_LB_fx32 + numZeros, hCPE->hStereoDft->ap_fade_mem_fx, ap_fade_len ); /*st->hHQ_core->q_old_outLB_fx*/ -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT hCPE->hStereoDft->q_ap_fade_mem_fx = st->hHQ_core->Q_old_out_fx32; -#else - hCPE->hStereoDft->q_ap_fade_mem_fx = st->hHQ_core->q_old_outLB_fx; -#endif move16(); test(); diff --git a/lib_dec/ivas_stereo_switching_dec_fx.c b/lib_dec/ivas_stereo_switching_dec_fx.c index fe99711e2..182c1e16c 100644 --- a/lib_dec/ivas_stereo_switching_dec_fx.c +++ b/lib_dec/ivas_stereo_switching_dec_fx.c @@ -68,10 +68,8 @@ static ivas_error allocate_CoreCoder_TCX_fx( reset_tcx_overl_buf_fx( st->hTcxDec ); // st->hTcxDec->CngLevelBackgroundTrace_bfi = 0; //initializing to avoid garbage overflow; set16_fx( st->hTcxDec->syn_OverlFB, 0, L_FRAME48k / 2 ); -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT st->hTcxDec->Q_syn_OverlFB = 0; move16(); -#endif set16_fx( st->hTcxDec->old_synth, 0, OLD_SYNTH_INTERNAL_DEC ); st->hTcxDec->q_old_synth = 0; move16(); @@ -422,9 +420,7 @@ ivas_error stereo_memory_dec_fx( test(); IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_MDCT ) && EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) ) { -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT assert( hCPE->hCoreCoder[0]->hHQ_core->Q_old_out_fx32 == hCPE->hCoreCoder[1]->hHQ_core->Q_old_out_fx32 ); -#endif v_add_32( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, hCPE->hCoreCoder[1]->hHQ_core->old_out_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, extract_l( Mpy_32_16_1( output_Fs, INV_FRAME_PER_SEC_Q15 ) ) ); /* exp(exp_old_out) */ v_multc_fixed_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, 16384 /* 0.5 in Q15 */, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, extract_l( Mpy_32_16_1( output_Fs, INV_FRAME_PER_SEC_Q15 ) ) ); /* exp(exp_old_out) */ @@ -2161,9 +2157,7 @@ void stereo_td2dft_update_fx( move16(); /* update buffers used for fading when switching to DFT Stereo */ -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT assert( sts[0]->hHQ_core->Q_old_out_fx32 == sts[1]->hHQ_core->Q_old_out_fx32 ); -#endif v_add_fx( sts[0]->hHQ_core->old_out_LB_fx32 + nsLB, sts[1]->hHQ_core->old_out_LB_fx32 + nsLB, hCPE->old_outLB_mdct_fx, old_outLB_len ); L_lerp_fx_q11( hCPE->old_outLB_mdct_fx, hCPE->old_outLB_mdct_fx, STEREO_MDCT2DFT_FADE_LEN_48k, old_outLB_len ); diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index 3015b85e4..f7be0dda0 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -704,11 +704,7 @@ typedef struct hq_dec_structure Word16 exp_old_out; Word16 old_out_LB_fx[L_FRAME32k]; /* HQ core - previous synthesis for OLA for Low Band. Q_old_wtda_LB */ Word32 old_out_LB_fx32[L_FRAME32k]; -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT Word16 Q_old_out_fx32; /* Q for both old_out_fx32 and old_out_LB_fx32 */ -#else - Word16 q_old_outLB_fx; -#endif Word16 Q_old_wtda_LB; Word16 Q_old_wtda; Word16 Q_old_postdec; /*scaling of the output of core_switching_post_dec_fx() */ diff --git a/lib_dec/updt_dec_fx.c b/lib_dec/updt_dec_fx.c index d1fe01b42..8704c2e07 100644 --- a/lib_dec/updt_dec_fx.c +++ b/lib_dec/updt_dec_fx.c @@ -1207,10 +1207,8 @@ void update_decoder_LPD_cng( Copy( hTcxDec->old_synth + st->L_frame, hTcxDec->old_synth, sub( hTcxDec->old_synth_len, st->L_frame ) ); Copy( synth, hTcxDec->old_synth + sub( hTcxDec->old_synth_len, st->L_frame ), st->L_frame ); bufferCopyFx( synth + sub( st->L_frame, ( st->L_frame / 2 ) ), hTcxDec->old_syn_Overl, st->L_frame / 2, 0 /*Qf_syn*/, -1 /*Qf_old_xnq*/, 0, 0 /*Q_old_xnq*/ ); -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT st->hTcxDec->Q_old_syn_Overl = sub( st->Q_syn, 1 ); move16(); -#endif hTcxDec->tcxltp_last_gain_unmodified = 0; move16(); -- GitLab From eb90fd07e4d69e12a68e4b2e7def48d53536a18d Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Sun, 17 Aug 2025 21:19:03 +0200 Subject: [PATCH 04/16] [cleanup] remove inactive code in FIX_1348_BIT_PRECISION_IMPROVEMENT_NO, FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD_NO --- lib_dec/er_dec_tcx_fx.c | 4 ---- lib_dec/ivas_mdct_core_dec_fx.c | 3 --- 2 files changed, 7 deletions(-) diff --git a/lib_dec/er_dec_tcx_fx.c b/lib_dec/er_dec_tcx_fx.c index bf35bb852..fd77497b8 100644 --- a/lib_dec/er_dec_tcx_fx.c +++ b/lib_dec/er_dec_tcx_fx.c @@ -950,10 +950,6 @@ void con_tcx_fx( hTcxDec->Q_syn_Overl_TDAC = hTcxDec->Q_syn_Overl_TDACFB; move16(); lerp( st->hHQ_core->old_out_fx, st->hHQ_core->old_out_LB_fx, st->L_frame, L_frame ); -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_NO - hHQ_core->Q_old_wtda_LB = hHQ_core->Q_old_wtda; - move16(); -#endif st->old_enr_LP = Enr_1_Az_fx( A_local, L_SUBFR ); /*Q3*/ move16(); diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index d02bb025f..4e080bb2f 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1282,9 +1282,6 @@ void ivas_mdct_core_reconstruct_fx( { Scale_sig( st->mem_syn2_fx, M, sub( st->Q_syn, add( q_win, 2 ) ) ); // q_win+2 -> st->Q_syn: in this case, E_UTIL_f_preemph2 shifts st->mem_syn2_fx by 2 bits } -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD_NO - Scale_sig( st->mem_syn2_fx, M, sub( st->Q_syn, q_win ) ); // q_win -> Q_syn -#endif } ELSE /*ACELP core for ACELP-PLC */ { -- GitLab From 8c9cd16e1c9e58d60b4c333ffe3e4d5963962e63 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Sun, 17 Aug 2025 21:19:59 +0200 Subject: [PATCH 05/16] [cleanup] accept NONBE_FIX_864_JBM_RENDER_FRAMESIZE --- apps/decoder.c | 6 ------ lib_com/options.h | 1 - lib_dec/lib_dec_fx.c | 48 -------------------------------------------- 3 files changed, 55 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index fe6a27dcd..b75a280e5 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -3070,14 +3070,10 @@ static ivas_error decodeVoIP( } vec_pos_update = ( vec_pos_update + 1 ) % vec_pos_len; frame++; -#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE if ( vec_pos_update == 0 ) { systemTime_ms += vec_pos_len * systemTimeInc_ms; } -#else - systemTime_ms += systemTimeInc_ms; -#endif #ifdef WMOPS update_mem(); @@ -3086,7 +3082,6 @@ static ivas_error decodeVoIP( } -#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE int16_t nSamplesFlushed = 0; /* decode and get samples */ @@ -3166,7 +3161,6 @@ static ivas_error decodeVoIP( } } } -#endif /*------------------------------------------------------------------------------------------* diff --git a/lib_com/options.h b/lib_com/options.h index 7b4838bef..9c53dfbfa 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -74,7 +74,6 @@ /* Note: each compile switch (FIX_1101_...) is independent from the other ones */ -#define NONBE_FIX_864_JBM_RENDER_FRAMESIZE /* FhG: issue #864: fix different behaviour of JBM TSM with different render frame sizes */ #define FIX_1762_COMPILER_ISSUE_NEW /* FhG: fix compiler issues with W_mac_32_32() + ONE_IN_Q30 */ #define ISSUE_1796_replace_shl_o /* FhG: replace shl_ro by overflow-free alternatives - BE*/ diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index ccd24ad4c..1e190083d 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -60,9 +60,7 @@ struct IVAS_DEC_VOIP UWord16 lastDecodedWasActive; JB4_DATAUNIT_HANDLE hCurrentDataUnit; /* Points to the currently processed data unit */ UWord16 *bs_conversion_buf; /* Buffer for bitstream conversion from packed to serial */ -#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE Word16 nSamplesRendered20ms; /* how many samples have been rendered since the last 20ms render border*/ -#endif #ifdef SUPPORT_JBM_TRACEFILE IVAS_JBM_TRACE_DATA JbmTraceData; #endif @@ -84,9 +82,7 @@ struct IVAS_DEC bool Opt_VOIP; /* flag indicating VOIP mode with JBM */ Word16 tsm_scale; /* scale for TSM operation */ Word16 tsm_max_scaling; -#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE Word16 timeScalingDone; /* have we done already one TSM in a 20ms frame? */ -#endif Word16 tsm_quality; /*Q14*/ Word32 *apaExecBuffer_fx; /* Buffer for APA scaling */ PCMDSP_APA_HANDLE hTimeScaler; @@ -120,9 +116,7 @@ static ivas_error IVAS_DEC_RendererFeedTcSamples( IVAS_DEC_HANDLE hIvasDec, cons static ivas_error IVAS_DEC_GetRenderedSamples( IVAS_DEC_HANDLE hIvasDec, const UWord16 nSamplesForRendering, UWord16 *nSamplesRendered, UWord16 *nSamplesAvailableNext, Word16 *pcmBuf ); static ivas_error IVAS_DEC_GetBufferedNumberOfSamples( IVAS_DEC_HANDLE hIvasDec, Word16 *nSamplesBuffered ); static Word16 get_render_frame_size_ms( IVAS_RENDER_FRAMESIZE render_framesize ); -#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE static void update_voip_rendered20ms( IVAS_DEC_HANDLE hIvasDec, const Word16 nSamplesRendered ); -#endif static ivas_error isar_set_split_rend_setup( ISAR_DEC_SPLIT_REND_WRAPPER *hSplitBinRend, const ISAR_SPLIT_REND_CONFIG_DATA *hSplitBinConfig, const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, ISAR_SPLIT_REND_BITS_DATA *splitRendBits ); static ivas_error ivas_dec_reconfig_split_rend( Decoder_Struct *st_ivas ); static ivas_error ivas_dec_init_split_rend( Decoder_Struct *st_ivas ); @@ -165,9 +159,7 @@ ivas_error IVAS_DEC_Open( hIvasDec->tsm_scale = 100; hIvasDec->tsm_max_scaling = 0; hIvasDec->tsm_quality = ONE_IN_Q14; /*1.f Q14*/ -#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE hIvasDec->timeScalingDone = 0; -#endif hIvasDec->needNewFrame = false; hIvasDec->nTransportChannelsOld = 0; hIvasDec->nSamplesAvailableNext = 0; @@ -190,9 +182,7 @@ ivas_error IVAS_DEC_Open( move16(); move16(); move16(); -#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE move16(); -#endif hIvasDec->mode = mode; move16(); @@ -920,10 +910,8 @@ ivas_error IVAS_DEC_EnableVoIP( hIvasDec->hVoIP->hCurrentDataUnit = NULL; hIvasDec->hVoIP->nSamplesFrame = (UWord16) Mpy_32_16_1( hDecoderConfig->output_Fs, INV_FRAME_PER_SEC_Q15 ); move16(); -#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE hIvasDec->hVoIP->nSamplesRendered20ms = 0; move16(); -#endif #define WMC_TOOL_SKIP /* Bitstream conversion is not counted towards complexity and memory usage */ @@ -1239,10 +1227,8 @@ ivas_error IVAS_DEC_GetSamples( } assert( LE_32( (Word32) nTimeScalerOutSamples, APA_BUF ) ); nSamplesTcsScaled = idiv1616U( extract_l( nTimeScalerOutSamples ), nTransportChannels ); -#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE hIvasDec->timeScalingDone = 1; move16(); -#endif } ELSE { @@ -1983,9 +1969,7 @@ static ivas_error IVAS_DEC_GetBufferedNumberOfSamples( if ( hIvasDec->st_ivas->hTcBuffer != NULL ) { *nSamplesBuffered = sub( hIvasDec->st_ivas->hTcBuffer->n_samples_buffered, hIvasDec->st_ivas->hTcBuffer->n_samples_rendered ); -#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE *nSamplesBuffered = add( *nSamplesBuffered, hIvasDec->hVoIP->nSamplesRendered20ms ); -#endif move16(); } @@ -3285,9 +3269,6 @@ ivas_error IVAS_DEC_VoIP_GetSamples( UWord32 extBufferedTime_ms, scale, maxScaling; JB4_DATAUNIT_HANDLE dataUnit; UWord16 extBufferedSamples; -#ifndef NONBE_FIX_864_JBM_RENDER_FRAMESIZE - Word16 timeScalingDone; -#endif Word16 result; ivas_error error; Word16 nSamplesRendered; @@ -3296,9 +3277,6 @@ ivas_error IVAS_DEC_VoIP_GetSamples( st_ivas = hIvasDec->st_ivas; hDecoderConfig = st_ivas->hDecoderConfig; hVoIP = hIvasDec->hVoIP; -#ifndef NONBE_FIX_864_JBM_RENDER_FRAMESIZE - timeScalingDone = 0; -#endif nOutChannels = (UWord8) st_ivas->hDecoderConfig->nchan_out; nSamplesRendered = 0; move16(); @@ -3326,12 +3304,8 @@ ivas_error IVAS_DEC_VoIP_GetSamples( } } -#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE extBufferedSamples = nSamplesBuffered; move16(); -#else - extBufferedSamples = add( nSamplesRendered, nSamplesBuffered ); -#endif Word16 exp; extBufferedTime_ms = BASOP_Util_Divide3232_Scale( imult3216( extBufferedSamples, 1000 ), hDecoderConfig->output_Fs, &exp ); extBufferedTime_ms = (UWord32) W_shr( extBufferedTime_ms, sub( 15, exp ) ); // Q0 @@ -3363,24 +3337,12 @@ ivas_error IVAS_DEC_VoIP_GetSamples( /* avoid time scaling multiple times in one sound card slot */ IF( NE_64( scale, 100U ) ) -#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE { IF( hIvasDec->timeScalingDone ) -#else - { - IF( timeScalingDone ) -#endif { scale = 100; move32(); } -#ifndef NONBE_FIX_864_JBM_RENDER_FRAMESIZE - ELSE - { - timeScalingDone = 1; - move16(); - } -#endif } /* limit scale to range supported by time scaler */ @@ -3473,9 +3435,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( hIvasDec->nSamplesAvailableNext = sub( hIvasDec->nSamplesAvailableNext, nSamplesToZero ); move16(); move16(); -#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE update_voip_rendered20ms( hIvasDec, nSamplesToZero ); -#endif } ELSE { @@ -3490,16 +3450,13 @@ ivas_error IVAS_DEC_VoIP_GetSamples( } nSamplesRendered = add( nSamplesRendered, nSamplesRendered_loop ); -#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE update_voip_rendered20ms( hIvasDec, nSamplesRendered_loop ); -#endif } } return IVAS_ERR_OK; } -#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE /*---------------------------------------------------------------------* * update_voip_rendered20ms( ) * @@ -3528,7 +3485,6 @@ static void update_voip_rendered20ms( } } -#endif /*---------------------------------------------------------------------* * IVAS_DEC_VoIP_Flush( ) @@ -3554,22 +3510,18 @@ ivas_error IVAS_DEC_Flush( move16(); /* render IVAS frames */ -#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE error = IVAS_ERR_OK; test(); IF( GT_16( nSamplesToRender, 0 ) && NE_16( (Word16) hIvasDec->st_ivas->ivas_format, (Word16) MONO_FORMAT ) ) { -#endif error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesFlushedLocal, &hIvasDec->nSamplesAvailableNext, pcmBuf ); -#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE } ELSE { *nSamplesFlushed = 0; move16(); } -#endif return error; } -- GitLab From 6d1e5d5384d8e381caa64b3090d0e1502343afca Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Sun, 17 Aug 2025 21:20:45 +0200 Subject: [PATCH 06/16] [cleanup] accept FIX_1762_COMPILER_ISSUE_NEW --- lib_com/options.h | 1 - lib_enc/find_tilt_fx.c | 4 ---- 2 files changed, 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 9c53dfbfa..eb58691fa 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -75,7 +75,6 @@ -#define FIX_1762_COMPILER_ISSUE_NEW /* FhG: fix compiler issues with W_mac_32_32() + ONE_IN_Q30 */ #define ISSUE_1796_replace_shl_o /* FhG: replace shl_ro by overflow-free alternatives - BE*/ #define ISSUE_1799_replace_L_shr_o /* FhG: replace by non-overflow-alternative - BE */ #define ISSUE_1836_replace_overflow_libcom /* FhG: replace overflow operators by non-overflow-alternatives - BE */ diff --git a/lib_enc/find_tilt_fx.c b/lib_enc/find_tilt_fx.c index d2e946098..2f7e724ab 100644 --- a/lib_enc/find_tilt_fx.c +++ b/lib_enc/find_tilt_fx.c @@ -370,11 +370,7 @@ void find_tilt_ivas_fx( FOR( i = 0; i < 2; i++ ) { /*hp_E[i] = 0.5f * (hf_bands[max_band-1] + hf_bands[max_band]) - hp_bckr; */ /* averaged E in last 2 critical bands */ -#ifndef FIX_1762_COMPILER_ISSUE_NEW - Ltmp = W_extract_h( W_mac_32_32( W_mult_32_32( hf_bands[max_band - 1], ONE_IN_Q30 ), hf_bands[max_band], ONE_IN_Q30 ) ); // q_fr_bands -#else Ltmp = W_extract_h( W_shl( W_add( W_deposit32_l( hf_bands[max_band - 1] ), W_deposit32_l( hf_bands[max_band] ) ), 31 ) ); // q_fr_bands -#endif Ltmp = L_sub( Ltmp, hp_bckr ); // q_fr_bands Ltmp2 = L_max( Ltmp, L_shl_sat( 1, q_fr_bands ) ); // q_fr_bands, saturation is added because q_fr_bands is limited to 31 -- GitLab From 75dde82c4a69c6a6b7dae04af7b51005d9914225 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Sun, 17 Aug 2025 21:21:29 +0200 Subject: [PATCH 07/16] [cleanup] accept ISSUE_1799_replace_L_shr_o --- lib_com/options.h | 1 - lib_com/swb_bwe_com_fx.c | 4 ---- lib_com/tools_fx.c | 4 ---- lib_enc/bw_detect_fx.c | 4 ---- lib_enc/energy_fx.c | 9 --------- lib_enc/find_tilt_fx.c | 12 ------------ lib_enc/find_uv_fx.c | 8 -------- lib_enc/hvq_enc_fx.c | 16 ---------------- lib_enc/nois_est_fx.c | 20 -------------------- lib_enc/pitch_ol2_fx.c | 16 ---------------- lib_enc/pitch_ol_fx.c | 8 -------- lib_enc/pvq_encode_fx.c | 8 -------- lib_enc/speech_music_classif_fx.c | 16 ---------------- lib_enc/swb_bwe_enc_hr_fx.c | 4 ---- lib_enc/swb_tbe_enc_fx.c | 4 ---- lib_enc/vad_fx.c | 12 ------------ 16 files changed, 146 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index eb58691fa..0827f1374 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -76,7 +76,6 @@ #define ISSUE_1796_replace_shl_o /* FhG: replace shl_ro by overflow-free alternatives - BE*/ -#define ISSUE_1799_replace_L_shr_o /* FhG: replace by non-overflow-alternative - BE */ #define ISSUE_1836_replace_overflow_libcom /* FhG: replace overflow operators by non-overflow-alternatives - BE */ #define ISSUE_1866_replace_overflow_libdec /* FhG: BE - Replace BASOPoverflow operators all over the lib_dec module if Overflow result is not used */ diff --git a/lib_com/swb_bwe_com_fx.c b/lib_com/swb_bwe_com_fx.c index 138fbd705..0e618f7d9 100644 --- a/lib_com/swb_bwe_com_fx.c +++ b/lib_com/swb_bwe_com_fx.c @@ -595,12 +595,8 @@ Word32 calc_tilt_bwe_fx( /* o : Tilt in Q24 tmp1 = mult_ro( *ptr++, 8192 /*0.25 in Q15 */, &Overflow ); /* Divide by 4 */ L_ener = L_mac0_o( L_ener, tmp1, tmp1, &Overflow ); } -#ifdef ISSUE_1799_replace_L_shr_o /*Overflow will never happen because exp2 is always positive*/ L_ener = L_shr( L_ener, exp2 ); -#else - L_ener = L_shr_o( L_ener, exp2, &Overflow ); -#endif L_temp = L_add_o( L_ener_tot, L_ener, &Overflow ); IF( Overflow != 0 ) { diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c index cae17e24d..19d0ed64c 100644 --- a/lib_com/tools_fx.c +++ b/lib_com/tools_fx.c @@ -3452,12 +3452,8 @@ Word32 Calc_Energy_Autoscaled( /* o: Result (Energy) #endif L_temp = L_mac0_o( L_temp, temp, temp, &Overflow ); } -#ifdef ISSUE_1799_replace_L_shr_o /*Overfloe will never happen because temp2 is always positive*/ L_temp = L_shr( L_temp, temp2 ); -#else - L_temp = L_shr_o( L_temp, temp2, &Overflow ); -#endif /* Here we try the addition just to check if we can sum the energy of the small (8 Iterations) loop with the total energy calculated so far without an overflow. diff --git a/lib_enc/bw_detect_fx.c b/lib_enc/bw_detect_fx.c index eeaf56969..7aeb3f77f 100644 --- a/lib_enc/bw_detect_fx.c +++ b/lib_enc/bw_detect_fx.c @@ -297,11 +297,7 @@ void bw_detect_fx( FOR( i = 0; i < BWD_TOTAL_WIDTH; i++ ) { -#ifdef ISSUE_1799_replace_L_shr_o spect[i] = round_fx_o( L_shr_sat( spect32[i], Q_dct ), &Overflow ); -#else - spect[i] = round_fx_o( L_shr_o( spect32[i], Q_dct, &Overflow ), &Overflow ); -#endif move16(); } Q_dct = -2; diff --git a/lib_enc/energy_fx.c b/lib_enc/energy_fx.c index cc0001d4a..308c7cc5d 100644 --- a/lib_enc/energy_fx.c +++ b/lib_enc/energy_fx.c @@ -42,11 +42,6 @@ void est_energy_fx( const Word16 *Nregion_index; Word32 *sb_power = enerBuffer; Word32 Ltmp32 = 0; -#ifndef ISSUE_1799_replace_L_shr_o -#ifdef BASOP_NOGLOB_DECLARE_LOCAL - Flag Overflow = 0; -#endif -#endif move32(); SNR_sb_num = SNR_SUB_BAND_NUM[bandwidth - CLDFBVAD_NB_ID]; move16(); @@ -127,11 +122,7 @@ void est_energy_fx( tmpspec_amp = L_shl( sb_power[j], s16MaxCoefNorm ); /* sb_power_Q + s16MaxCoefNorm */ s32CopyPower = L_add( s32CopyPower, tmpspec_amp ); } -#ifdef ISSUE_1799_replace_L_shr_o frame_sb_energy[i] = L_shr_sat( s32CopyPower, s16MaxCoefNorm ); /* sb_power_Q */ -#else - frame_sb_energy[i] = L_shr_o( s32CopyPower, s16MaxCoefNorm, &Overflow ); /* sb_power_Q */ -#endif move32(); } diff --git a/lib_enc/find_tilt_fx.c b/lib_enc/find_tilt_fx.c index 2f7e724ab..7d47349ad 100644 --- a/lib_enc/find_tilt_fx.c +++ b/lib_enc/find_tilt_fx.c @@ -175,11 +175,7 @@ void find_tilt_fx( m_tmp = div_s( m_tmp, m_cnt ); /* exp(e_tmp + e_cnt) */ e_tmp = sub( e_tmp, e_cnt ); -#ifdef ISSUE_1799_replace_L_shr_o lp_E = L_sub_o( L_shr_sat( m_tmp, sub( e_tmp, 1 ) ), lp_bckr, &Overflow ); /* Q_new + QSCALE */ -#else - lp_E = L_sub_o( L_shr_o( m_tmp, sub( e_tmp, 1 ), &Overflow ), lp_bckr, &Overflow ); /* Q_new + QSCALE */ -#endif pt_E = tmp_E + VOIC_BINS; /* Update for next half-frame */ } @@ -207,11 +203,7 @@ void find_tilt_fx( m_tmp = div_s( m_tmp, m_hpE ); /* exp(e_tmp + e_hpE) */ e_tmp = sub( e_tmp, e_hpE ); -#ifdef ISSUE_1799_replace_L_shr_o ee[i] = L_shr_sat( m_tmp, add( e_tmp, 15 - 6 ) ); /* ee in Q6 */ -#else - ee[i] = L_shr_o( m_tmp, add( e_tmp, 15 - 6 ), &Overflow ); /* ee in Q6 */ -#endif } ELSE IF( lp_E == 0 ) { @@ -470,11 +462,7 @@ void find_tilt_ivas_fx( m_hpE = extract_h( L_shl( hp_E[i], e_hpE ) ); // e_hpE+q_bckr-16 m_tmp = div_s( m_tmp, m_hpE ); // Q15+(e_tmp+q_lp_E)-(e_hpE+q_bckr) e_tmp = sub( add( e_tmp, q_lp_E ), add( e_hpE, q_bckr ) ); -#ifdef ISSUE_1799_replace_L_shr_o ee[i] = L_shr_sat( m_tmp, add( e_tmp, 15 - 6 ) ); /* ee in Q6 */ -#else - ee[i] = L_shr_o( m_tmp, add( e_tmp, 15 - 6 ), &Overflow ); /* ee in Q6 */ -#endif move32(); } diff --git a/lib_enc/find_uv_fx.c b/lib_enc/find_uv_fx.c index 792ddf265..89db87ef2 100644 --- a/lib_enc/find_uv_fx.c +++ b/lib_enc/find_uv_fx.c @@ -178,11 +178,7 @@ Word16 find_uv_fx( /* o : coding type */ exp1 = sub( norm_l( *pt_enr_ssf1 ), 1 ); wtmp1 = extract_h( L_shl( *pt_enr_ssf1, exp1 ) ); fac = div_s( wtmp1, wtmp0 ); -#ifdef ISSUE_1799_replace_L_shr_o fac_32 = L_shr_sat( L_deposit_l( fac ), add( sub( exp1, exp0 ), 15 - 13 ) ); /* fac32 in Q13*/ -#else - fac_32 = L_shr_o( L_deposit_l( fac ), add( sub( exp1, exp0 ), 15 - 13 ), &Overflow ); /* fac32 in Q13*/ -#endif if ( GT_32( fac_32, dE1 ) ) { @@ -674,11 +670,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ exp1 = sub( norm_l( *pt_enr_ssf1 ), 1 ); wtmp1 = extract_h( L_shl( *pt_enr_ssf1, exp1 ) ); fac = div_s( wtmp1, wtmp0 ); -#ifdef ISSUE_1799_replace_L_shr_o fac_32 = L_shr_sat( L_deposit_l( fac ), add( sub( exp1, exp0 ), 15 - 13 ) ); /* fac32 in Q13*/ -#else - fac_32 = L_shr_o( L_deposit_l( fac ), add( sub( exp1, exp0 ), 15 - 13 ), &Overflow ); /* fac32 in Q13*/ -#endif if ( GT_32( fac_32, dE1 ) ) { diff --git a/lib_enc/hvq_enc_fx.c b/lib_enc/hvq_enc_fx.c index f6c45dab2..993c9e4a2 100644 --- a/lib_enc/hvq_enc_fx.c +++ b/lib_enc/hvq_enc_fx.c @@ -146,11 +146,7 @@ Word16 hvq_enc_ivas_fx( /*o : Consumed bits expNfpe3 = extract_l( L_mult0( expNfpe, 3 ) ); /* Cube operation */ /* Number of bits required to adjust to Q15 */ adjust = add( 19 - ( 15 + 16 ), expNfpe3 ); /* +16 is due to the following extract_h(). */ -#ifdef ISSUE_1799_replace_L_shr_o noise_level[i] = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ -#else - noise_level[i] = extract_h( L_shr_o( acc, adjust, &Overflow ) ); /* noise_level[] in Q15 */ -#endif move16(); q_noise_level_idx[i] = quant_lc_fx( noise_level[i], &q_noise_level[i] ); move16(); @@ -181,11 +177,7 @@ Word16 hvq_enc_ivas_fx( /*o : Consumed bits expo3 = extract_l( L_mult0( expo, 3 ) ); /* Cube operation. */ /* Number of bits required to adjust to Q15 */ adjust = add( 22 - ( 15 + 16 ), expo3 ); /* +16 is due to the following extract_h(). */ -#ifdef ISSUE_1799_replace_L_shr_o lb_nfpe = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ -#else - lb_nfpe = extract_h( L_shr_o( acc, adjust, &Overflow ) ); /* noise_level[] in Q15 */ -#endif IF( GT_16( lb_nfpe, 16384 ) ) /* in Q15 */ { lb_nfpe = 16384; @@ -335,11 +327,7 @@ Word16 hvq_enc_fx( /*o : Consumed bits expNfpe3 = extract_l( L_mult0( expNfpe, 3 ) ); /* Cube operation */ /* Number of bits required to adjust to Q15 */ adjust = add( 19 - ( 15 + 16 ), expNfpe3 ); /* +16 is due to the following extract_h(). */ -#ifdef ISSUE_1799_replace_L_shr_o noise_level[i] = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ -#else - noise_level[i] = extract_h( L_shr_o( acc, adjust, &Overflow ) ); /* noise_level[] in Q15 */ -#endif move16(); q_noise_level_idx[i] = quant_lc_fx( noise_level[i], &q_noise_level[i] ); move16(); @@ -370,11 +358,7 @@ Word16 hvq_enc_fx( /*o : Consumed bits expo3 = extract_l( L_mult0( expo, 3 ) ); /* Cube operation. */ /* Number of bits required to adjust to Q15 */ adjust = add( 22 - ( 15 + 16 ), expo3 ); /* +16 is due to the following extract_h(). */ -#ifdef ISSUE_1799_replace_L_shr_o lb_nfpe = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ -#else - lb_nfpe = extract_h( L_shr_o( acc, adjust, &Overflow ) ); /* noise_level[] in Q15 */ -#endif IF( lb_nfpe > 16384 ) /* in Q15 */ { lb_nfpe = 16384; diff --git a/lib_enc/nois_est_fx.c b/lib_enc/nois_est_fx.c index 224e4dddb..d37275b2d 100644 --- a/lib_enc/nois_est_fx.c +++ b/lib_enc/nois_est_fx.c @@ -1232,11 +1232,7 @@ void noise_est_fx( ExpDen = norm_l( Ltmp ); den = extract_h( L_shl( Ltmp, ExpDen ) ); num = div_s( num, den ); -#ifdef ISSUE_1799_replace_L_shr_o noise_chartmp = extract_h( L_shr_sat( num, add( sub( ExpNum, ExpDen ), 4 - 16 ) ) ); /* Q11 */ -#else - noise_chartmp = extract_h( L_shr_o( num, add( sub( ExpNum, ExpDen ), 4 - 16 ), &Overflow ) ); /* Q11 */ -#endif } noise_chartmp = s_min( noise_chartmp, (Word16) 10 << 11 ); /* Q11 */ @@ -1335,11 +1331,7 @@ void noise_est_fx( den = extract_h( L_shl( Lden, ExpDen ) ); num = div_s( num, den ); Ltmp = Mult_32_16( non_sta, num ); -#ifdef ISSUE_1799_replace_L_shr_o non_sta = L_shr_sat( Ltmp, sub( ExpNum, ExpDen ) ); /* Q10 */ -#else - non_sta = L_shr_o( Ltmp, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */ -#endif } /* st->ave_enr[i] = alpha * st->ave_enr[i] + (1-alpha) * enr[i];*/ /* update long-term average */ @@ -1374,11 +1366,7 @@ void noise_est_fx( den = extract_h( L_shl( Lden, ExpDen ) ); num = div_s( num, den ); Ltmp1 = Mult_32_16( Lnon_sta2, num ); -#ifdef ISSUE_1799_replace_L_shr_o Lnon_sta2 = L_shr_sat( Ltmp1, sub( ExpNum, ExpDen ) ); /* Q10 */ -#else - Lnon_sta2 = L_shr_o( Ltmp1, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */ -#endif } /* st_ave_enr2[i] = (float)alpha2 * st_ave_enr2[i] @@ -2699,11 +2687,7 @@ void noise_est_ivas_fx( num = div_s( num, den ); // 15+ExpNum-ExpDen Ltmp1 = Mult_32_16( non_sta, num ); // 15+ExpNum-ExpDen+10-15 -#ifdef ISSUE_1799_replace_L_shr_o non_sta = L_shr_sat( Ltmp1, sub( ExpNum, ExpDen ) ); /* Q10 */ -#else - non_sta = L_shr_o( Ltmp1, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */ -#endif } /* st->ave_enr[i] = alpha * st->ave_enr[i] + (1-alpha) * enr[i];*/ /* update long-term average */ @@ -2742,11 +2726,7 @@ void noise_est_ivas_fx( num = div_s( num, den ); // 15+ExpNum-ExpDen Ltmp1 = Mult_32_16( Lnon_sta2, num ); // 15+ExpNum-ExpDen+10-15 -#ifdef ISSUE_1799_replace_L_shr_o Lnon_sta2 = L_shr_sat( Ltmp1, sub( ExpNum, ExpDen ) ); /* Q10 */ -#else - Lnon_sta2 = L_shr_o( Ltmp1, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */ -#endif } /* st_ave_enr2[i] = (float)alpha2 * st_ave_enr2[i] + (1.0f - alpha2) * (enr[i]) */ diff --git a/lib_enc/pitch_ol2_fx.c b/lib_enc/pitch_ol2_fx.c index de47d85af..c0c17ec63 100644 --- a/lib_enc/pitch_ol2_fx.c +++ b/lib_enc/pitch_ol2_fx.c @@ -294,11 +294,7 @@ void StableHighPitchDetect_fx( tmp = abs_s( tmp ); tmp = div_s( 16384, tmp ); /*Q(15+exp)*/ BASOP_SATURATE_WARNING_OFF_EVS -#ifdef ISSUE_1799_replace_L_shr_o diff = L_negate( L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ) ); -#else - diff = L_negate( L_shr_o( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ), &Overflow ) ); -#endif BASOP_SATURATE_WARNING_ON_EVS diff16 = round_fx_o( diff, &Overflow ); } @@ -306,11 +302,7 @@ void StableHighPitchDetect_fx( { tmp = div_s( 16384, tmp ); /*Q(15+exp)*/ BASOP_SATURATE_WARNING_OFF_EVS -#ifdef ISSUE_1799_replace_L_shr_o diff = L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ); -#else - diff = L_shr_o( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ), &Overflow ); -#endif BASOP_SATURATE_WARNING_ON_EVS diff16 = round_fx_o( diff, &Overflow ); } @@ -517,11 +509,7 @@ void StableHighPitchDetect_ivas_fx( tmp = abs_s( tmp ); tmp = div_s( 16384, tmp ); /*Q(15+exp)*/ BASOP_SATURATE_WARNING_OFF_EVS -#ifdef ISSUE_1799_replace_L_shr_o diff = L_negate( L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ) ); -#else - diff = L_negate( L_shr_o( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ), &Overflow ) ); -#endif BASOP_SATURATE_WARNING_ON_EVS diff16 = round_fx_o( diff, &Overflow ); } @@ -529,11 +517,7 @@ void StableHighPitchDetect_ivas_fx( { tmp = div_s( 16384, tmp ); /*Q(15+exp)*/ BASOP_SATURATE_WARNING_OFF_EVS -#ifdef ISSUE_1799_replace_L_shr_o diff = L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ); -#else - diff = L_shr_o( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ), &Overflow ); -#endif BASOP_SATURATE_WARNING_ON_EVS diff16 = round_fx_o( diff, &Overflow ); } diff --git a/lib_enc/pitch_ol_fx.c b/lib_enc/pitch_ol_fx.c index d4e3284da..56647f7b1 100644 --- a/lib_enc/pitch_ol_fx.c +++ b/lib_enc/pitch_ol_fx.c @@ -751,11 +751,7 @@ void pitch_ol_fx( Ltmp = L_mult0( cor_buf[ind], enr1 ); qCorX = add( sub( 15, enr1_exp ), sub( 14, pt_exp1[ind] ) ); -#ifdef ISSUE_1799_replace_L_shr_o corX[i][j] = extract_h( L_shr_sat( Ltmp, sub( qCorX, 31 ) ) ); -#else - corX[i][j] = extract_h( L_shr_o( Ltmp, sub( qCorX, 31 ), &Overflow ) ); -#endif qCorX = 31; move16(); @@ -792,11 +788,7 @@ void pitch_ol_fx( Ltmp = L_mult0( cor_buf[ind1 + len_x], enr1 ); qCorX = add( sub( 15, enr1_exp ), sub( 14, pt_exp3[ind1] ) ); -#ifdef ISSUE_1799_replace_L_shr_o corX[i][j + NSECT] = extract_h( L_shr_sat( Ltmp, qCorX - 31 ) ); -#else - corX[i][j + NSECT] = extract_h( L_shr_o( Ltmp, qCorX - 31, &Overflow ) ); -#endif qCorX = 31; move16(); diff --git a/lib_enc/pvq_encode_fx.c b/lib_enc/pvq_encode_fx.c index d08b8a902..4ea362588 100644 --- a/lib_enc/pvq_encode_fx.c +++ b/lib_enc/pvq_encode_fx.c @@ -359,11 +359,7 @@ void pvq_encode_ivas_fx( } Mpy_32_16_ss( L_isqrt, tmp, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) +1 */ Mpy_32_16_ss( L_tmp, neg_gain_norm, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) *Q15 +1 */ -#ifdef ISSUE_1799_replace_L_shr_o L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ -#else - L_tmp = L_shr_o( L_tmp, shift_tot, &Overflow ); /* Q31+x */ -#endif xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15, array move */ move16(); L_xq[i] = L_tmp; /* Q31 currently unused */ @@ -571,11 +567,7 @@ void pvq_encode_fx( } Mpy_32_16_ss( L_isqrt, tmp, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) +1 */ Mpy_32_16_ss( L_tmp, neg_gain_norm, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) *Q15 +1 */ -#ifdef ISSUE_1799_replace_L_shr_o L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ -#else - L_tmp = L_shr_o( L_tmp, shift_tot, &Overflow ); /* Q31+x */ -#endif xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15, array move */ move16(); L_xq[i] = L_tmp; /* Q31 currently unused */ diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index 0c4a4ec23..65f3fb1b8 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -1500,19 +1500,11 @@ static Word16 attack_det_fx( /* o : attack flag exp1 = norm_s( att_3lsub_pos ); tmp = div_s( shl( 1, sub( 14, exp1 ) ), att_3lsub_pos ); /*Q(29-exp1) */ -#ifdef ISSUE_1799_replace_L_shr_o L_tmp = L_shr_sat( finc[0], Qx ); /*Qx */ -#else - L_tmp = L_shr_o( finc[0], Qx, &Overflow ); /*Qx */ -#endif FOR( i = 1; i < att_3lsub_pos; i++ ) { -#ifdef ISSUE_1799_replace_L_shr_o L_tmp = L_add_o( L_tmp, L_shr_sat( finc[i], Qx ), &Overflow ); /*Qx */ -#else - L_tmp = L_add_o( L_tmp, L_shr_o( finc[i], Qx, &Overflow ), &Overflow ); /*Qx */ -#endif } L_tmp = Mult_32_16( L_tmp, tmp ); /*Q(14-exp1+Qx) */ etmp = L_shl( L_tmp, sub( exp1, 14 ) ); /*Qx */ @@ -1521,18 +1513,10 @@ static Word16 attack_det_fx( /* o : attack flag exp1 = norm_s( tmp1 ); tmp = div_s( shl( 1, sub( 14, exp1 ) ), tmp1 ); /*Q(29-exp1) */ -#ifdef ISSUE_1799_replace_L_shr_o L_tmp = L_shr_sat( finc[attack], Qx ); /*Qx */ -#else - L_tmp = L_shr_o( finc[attack], Qx, &Overflow ); /*Qx */ -#endif FOR( i = 1; i < tmp1; i++ ) { -#ifdef ISSUE_1799_replace_L_shr_o L_tmp = L_add_o( L_tmp, L_shr_sat( finc[i + attack], Qx ), &Overflow ); /*Qx */ -#else - L_tmp = L_add_o( L_tmp, L_shr_o( finc[i + attack], Qx, &Overflow ), &Overflow ); /*Qx */ -#endif } L_tmp = Mult_32_16( L_tmp, tmp ); /*Q(14-exp1+Qx) */ etmp2 = L_shl( L_tmp, sub( exp1, 14 ) ); /*Qx */ diff --git a/lib_enc/swb_bwe_enc_hr_fx.c b/lib_enc/swb_bwe_enc_hr_fx.c index f510a1cb6..dc962d1bc 100644 --- a/lib_enc/swb_bwe_enc_hr_fx.c +++ b/lib_enc/swb_bwe_enc_hr_fx.c @@ -767,11 +767,7 @@ void swb_bwe_enc_hr_fx( FOR( i = 0; i < Nsv2 * WIDTH_BAND; i++ ) { L_tmp = L_mult( temp, t_audio_fx[i] ); -#ifdef ISSUE_1799_replace_L_shr_o L_tmp = L_shr_sat( L_tmp, temp2 ); -#else - L_tmp = L_shr_o( L_tmp, temp2, &Overflow ); -#endif t_audio_fx[i] = round_fx_o( L_tmp, &Overflow ); move16(); } diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 986aa26a6..9aa30cd5a 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -7471,11 +7471,7 @@ void fb_tbe_enc_fx( tmp = div_s( tmp2, tmp ); L_tmp = L_deposit_h( tmp ); L_tmp = Isqrt_lc( L_tmp, &exp ); /*Q(31-exp)*/ -#ifdef ISSUE_1799_replace_L_shr_o L_tmp = L_max( L_shr_sat( L_tmp, sub( 31, exp ) ), 0x1 ); /* Q0 */ -#else - L_tmp = L_max( L_shr_o( L_tmp, sub( 31, exp ), &Overflow ), 0x1 ); /* Q0 */ -#endif } ELSE { diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index 9819285f0..12e482b0f 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -975,11 +975,7 @@ Word16 wb_vad_fx( m_num = shr( m_num, 1 ); shift_snr = add( sub( e_num, e_noise ), 15 - 4 ); snr_tmp = div_s( m_num, m_noise_local ); -#ifdef ISSUE_1799_replace_L_shr_o L_snr = L_shr_sat( snr_tmp, shift_snr ); /* L_snr in Q4 */ -#else - L_snr = L_shr_o( snr_tmp, shift_snr, &Overflow ); /* L_snr in Q4 */ -#endif } ELSE { @@ -1012,11 +1008,7 @@ Word16 wb_vad_fx( shift_snr = add( sub( e_num, e_noise ), 15 - 4 ); snr_tmp = div_s( m_num, m_noise_local ); -#ifdef ISSUE_1799_replace_L_shr_o L_snr = L_shr_sat( snr_tmp, shift_snr ); /* L_snr in Q4 */ -#else - L_snr = L_shr_o( snr_tmp, shift_snr, &Overflow ); /* L_snr in Q4 */ -#endif } ELSE { @@ -1121,11 +1113,7 @@ Word16 wb_vad_fx( shift_snr = add( sub( e_num, e_noise ), 15 - 4 ); snr_tmp = div_s( m_num, m_noise_local ); -#ifdef ISSUE_1799_replace_L_shr_o L_snr = L_shr_sat( snr_tmp, shift_snr ); /* L_snr in Q4 */ -#else - L_snr = L_shr_o( snr_tmp, shift_snr, &Overflow ); /* L_snr in Q4 */ -#endif } ELSE { -- GitLab From 816d0a4f7bab44ccf2839ec4bc5f1b23c1de9332 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Sun, 17 Aug 2025 21:22:08 +0200 Subject: [PATCH 08/16] [cleanup] accept NONBE_FIX_TCX5_INTERLEAVING_FOR_FS_IN_UNEQUAL_FS_OUT --- lib_com/options.h | 1 - lib_dec/dec_tcx_fx.c | 8 -------- 2 files changed, 9 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 0827f1374..d183ff423 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -79,7 +79,6 @@ #define ISSUE_1836_replace_overflow_libcom /* FhG: replace overflow operators by non-overflow-alternatives - BE */ #define ISSUE_1866_replace_overflow_libdec /* FhG: BE - Replace BASOPoverflow operators all over the lib_dec module if Overflow result is not used */ -#define NONBE_FIX_TCX5_INTERLEAVING_FOR_FS_IN_UNEQUAL_FS_OUT /* FhG: apply correct TCX5 grouping/interleaving when input_fs != output_fs */ #define FIX_1917_DIRAC_RENDER_PTR_INCR /* FhG: fix wrong pointer increment in ivas_dirac_dec_render_sf_fx() for object rendering */ #define FIX_CDLFB_BUFFER_SCALING /* FhG: fix wrong buffer scaling in ivas_dirac_dec_render_sf_fx() for object rendering */ diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index d87c09135..e5f601fb5 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -5455,12 +5455,8 @@ void decoder_tcx_tns_fx( test(); test(); test(); -#ifdef NONBE_FIX_TCX5_INTERLEAVING_FOR_FS_IN_UNEQUAL_FS_OUT test(); IF( ( NE_16( hTcxCfg->fIsTNSAllowed, 0 ) && NE_16( fUseTns, 0 ) && NE_16( bfi, 1 ) && whitenedDomain ) || GT_16( L_spec, L_frameTCX ) ) -#else - IF( ( NE_16( hTcxCfg->fIsTNSAllowed, 0 ) && NE_16( fUseTns, 0 ) && NE_16( bfi, 1 ) ) || GT_16( L_spec, L_frameTCX ) ) -#endif { L = L_spec; move16(); @@ -5514,12 +5510,8 @@ void decoder_tcx_tns_fx( IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && st->tcxonly != 0 && isTCX5 != 0 ) { test(); -#ifdef NONBE_FIX_TCX5_INTERLEAVING_FOR_FS_IN_UNEQUAL_FS_OUT test(); IF( st->element_mode == EVS_MONO || ( LT_16( L_spec, L_frameTCX ) && !whitenedDomain ) ) /* todo: this is temporary to maintain EVS BE, this is a bug and should be fixed also for EVS (see issue 13) */ -#else - IF( st->element_mode == EVS_MONO || LT_16( L_spec, L_frameTCX ) ) /* todo: this is temporary to maintain EVS BE, this is a bug and should be fixed also for EVS (see issue 13) */ -#endif { tcx5TnsUngrouping_fx( shr( L_frameTCX, 1 ), shr( hTcxCfg->tnsConfig[0][0].iFilterBorders[0], 1 ), x_fx, DEC ); tmp = L_frameTCX; -- GitLab From 0353fa7be3c9f789ac71e6456513888e20c32896 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Sun, 17 Aug 2025 21:22:47 +0200 Subject: [PATCH 09/16] [cleanup] accept FIX_1824 --- lib_com/options.h | 1 - lib_dec/jbm_pcmdsp_similarityestimation_fx.c | 6 ------ 2 files changed, 7 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index d183ff423..448c07e39 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -82,7 +82,6 @@ #define FIX_1917_DIRAC_RENDER_PTR_INCR /* FhG: fix wrong pointer increment in ivas_dirac_dec_render_sf_fx() for object rendering */ #define FIX_CDLFB_BUFFER_SCALING /* FhG: fix wrong buffer scaling in ivas_dirac_dec_render_sf_fx() for object rendering */ -#define FIX_1824 #define FIX_1822 #define FIX_ISSUE_1764 /* NTT: update renorm and use abs */ diff --git a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c index 1166cb1f7..2d757a38a 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c @@ -113,15 +113,9 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal, sumXX = L_shl( sumXX, normX ); normY = norm_l( sumYY ); sumYY = L_shl( sumYY, normY ); -#ifdef FIX_1824 product = L_shr( L_mult0( extract_h( sumXX ), extract_h( sumYY ) ), 1 ); normXY = add( normX, normY ); normXY = sub( normXY, 32 + 1 ); -#else - product = L_mult0( extract_h( sumXX ), extract_h( sumYY ) ); - normXY = add( normX, normY ); - normXY = sub( normXY, 32 ); -#endif /* change norm to factor of 2 */ IF( s_and( normXY, 0x1 ) != 0 ) -- GitLab From 83ea94769eeb1c3da32586db9d2e95b480459765 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Sun, 17 Aug 2025 21:23:29 +0200 Subject: [PATCH 10/16] [cleanup] accept FIX_1822 --- lib_com/options.h | 1 - lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 6 ------ 2 files changed, 7 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 448c07e39..b4c31e232 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -82,7 +82,6 @@ #define FIX_1917_DIRAC_RENDER_PTR_INCR /* FhG: fix wrong pointer increment in ivas_dirac_dec_render_sf_fx() for object rendering */ #define FIX_CDLFB_BUFFER_SCALING /* FhG: fix wrong buffer scaling in ivas_dirac_dec_render_sf_fx() for object rendering */ -#define FIX_1822 #define FIX_ISSUE_1764 /* NTT: update renorm and use abs */ #define FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW /* FhG: bit-exact, replace carry and overflow operations by 64-bit operations, MR 1931 */ diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index 7a12f4192..541e4d5a8 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -1002,17 +1002,11 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( move16(); } } -#ifdef FIX_1822 diff = L_sub( h_dirac_output_synthesis_params->diffuse_compensation_factor_fx, ONE_IN_Q27 /*1 Q27*/ ); diff = L_shl( diff, 2 ); // Q29 -#endif FOR( ; k < num_freq_bands; k++ ) { -#ifdef FIX_1822 sqr_inp = Madd_32_32( One_in_qdiff, diffuseness[k], diff ); // Q = q_diffuseness - 1 -#else - sqr_inp = Madd_32_32( One_in_qdiff, diffuseness[k], L_sub( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr_fx, ONE_IN_Q29 /*1 Q29*/ ) ); // Q = q_diffuseness - 1 -#endif sqr_exp = sq_e; move16(); sqr = Sqrt32( sqr_inp, &sqr_exp ); /*Q(31-sqr_exp)*/ -- GitLab From 285e1351b5f41dc956c848c7f7b7956ab40cfc56 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Sun, 17 Aug 2025 21:24:17 +0200 Subject: [PATCH 11/16] [cleanup] accept FIX_ISSUE_1764 --- lib_com/options.h | 1 - lib_enc/ivas_stereo_dmx_evs_fx.c | 112 ------------------------------- 2 files changed, 113 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index b4c31e232..157593c99 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -83,7 +83,6 @@ #define FIX_CDLFB_BUFFER_SCALING /* FhG: fix wrong buffer scaling in ivas_dirac_dec_render_sf_fx() for object rendering */ -#define FIX_ISSUE_1764 /* NTT: update renorm and use abs */ #define FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW /* FhG: bit-exact, replace carry and overflow operations by 64-bit operations, MR 1931 */ #define FIX_1844_MISSING_FREE /* FhG: add missing free in ivas_binRenderer_convModuleClose_fx() */ diff --git a/lib_enc/ivas_stereo_dmx_evs_fx.c b/lib_enc/ivas_stereo_dmx_evs_fx.c index 59f00bd90..e3e49193a 100644 --- a/lib_enc/ivas_stereo_dmx_evs_fx.c +++ b/lib_enc/ivas_stereo_dmx_evs_fx.c @@ -98,13 +98,8 @@ #define STEREO_DMX_EVS_TRNS_EGY_FORGETTING_Q15 24576 -#ifdef FIX_ISSUE_1764 #define STEREO_DMX_EVS_POC_RENORM_TH 1048576 // 65536 * 16 #define STEREO_DMX_EVS_POC_RENORM_SHIFT 10 -#else -#define STEREO_DMX_EVS_POC_RENORM_TH 33554432 // 65536 << 9 -#define STEREO_DMX_EVS_POC_RENORM_SHIFT 3 -#endif #define STEREO_DMX_EVS_FAD_R 3 #define STEREO_DMX_EVS_FAD_IR 10923 /* 1/3 in Q15 */ @@ -232,12 +227,10 @@ static Word32 spectral_flatness_fx( const Word16 *sig_fx_e, /* i : input signal (exponent) - can be NULL */ const Word16 sig_length /* i : input signal length */ ); -#ifdef FIX_ISSUE_1764 static void renorm_poc_fx( Word32 *real, /* i/o real-part*/ Word32 *imag /* i/o imaginary-part */ ); -#endif /*-------------------------------------------------------------------* * estimate_itd_wnd_fft() * @@ -420,11 +413,7 @@ static void calc_poc_fx( mult_angle = 2; /*****/ move16(); } -#ifdef FIX_ISSUE_1764 ELSE IF( EQ_16( input_frame, L_FRAME32k ) ) -#else - if ( EQ_16( input_frame, L_FRAME32k ) ) -#endif { mult_angle = 2; move16(); @@ -452,21 +441,8 @@ static void calc_poc_fx( Rr = L_add( L_add( specRr[i], Mpy_32_32_r( specLr[i], eps_cos ) ), Mpy_32_32_r( specLi[i], eps_sin ) ); Ri = L_add( L_sub( specRi[i], Mpy_32_32_r( specLr[i], eps_sin ) ), Mpy_32_32_r( specLi[i], eps_cos ) ); -#ifdef FIX_ISSUE_1764 renorm_poc_fx( &Lr, &Li ); renorm_poc_fx( &Rr, &Ri ); -#else - IF( ( LT_32( L_abs( Lr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && - ( LT_32( L_abs( Li ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && - ( LT_32( L_abs( Rr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && - ( LT_32( L_abs( Ri ), STEREO_DMX_EVS_POC_RENORM_TH ) ) ) - { - Lr = L_shl( Lr, STEREO_DMX_EVS_POC_RENORM_SHIFT ); - Li = L_shl( Li, STEREO_DMX_EVS_POC_RENORM_SHIFT ); - Rr = L_shl( Rr, STEREO_DMX_EVS_POC_RENORM_SHIFT ); - Ri = L_shl( Ri, STEREO_DMX_EVS_POC_RENORM_SHIFT ); - } -#endif specPOr[i] = L_add( Mpy_32_32_r( Lr, Rr ), Mpy_32_32_r( Li, Ri ) ); // 2*spec_e move32(); @@ -480,21 +456,8 @@ static void calc_poc_fx( Rr = L_add( L_sub( specRr[j], Mpy_32_32_r( specLr[j], eps_cos ) ), Mpy_32_32_r( specLi[j], eps_sin ) ); Ri = L_sub( L_sub( specRi[j], Mpy_32_32_r( specLr[j], eps_sin ) ), Mpy_32_32_r( specLi[j], eps_cos ) ); -#ifdef FIX_ISSUE_1764 renorm_poc_fx( &Lr, &Li ); renorm_poc_fx( &Rr, &Ri ); -#else - IF( ( LT_32( L_abs( Lr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && - ( LT_32( L_abs( Li ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && - ( LT_32( L_abs( Rr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && - ( LT_32( L_abs( Ri ), STEREO_DMX_EVS_POC_RENORM_TH ) ) ) - { - Lr = L_shl( Lr, STEREO_DMX_EVS_POC_RENORM_SHIFT ); - Li = L_shl( Li, STEREO_DMX_EVS_POC_RENORM_SHIFT ); - Rr = L_shl( Rr, STEREO_DMX_EVS_POC_RENORM_SHIFT ); - Ri = L_shl( Ri, STEREO_DMX_EVS_POC_RENORM_SHIFT ); - } -#endif specPOr[j] = L_add( Mpy_32_32_r( Lr, Rr ), Mpy_32_32_r( Li, Ri ) ); // 2*spec_e move32(); @@ -517,21 +480,8 @@ static void calc_poc_fx( Rr = L_add( L_add( specRr[i], Mpy_32_32_r( specLr[i], eps_cos ) ), Mpy_32_32_r( specLi[i], eps_sin ) ); Ri = L_add( L_sub( specRi[i], Mpy_32_32_r( specLr[i], eps_sin ) ), Mpy_32_32_r( specLi[i], eps_cos ) ); -#ifdef FIX_ISSUE_1764 renorm_poc_fx( &Lr, &Li ); renorm_poc_fx( &Rr, &Ri ); -#else - IF( ( LT_32( L_abs( Lr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && - ( LT_32( L_abs( Li ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && - ( LT_32( L_abs( Rr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && - ( LT_32( L_abs( Ri ), STEREO_DMX_EVS_POC_RENORM_TH ) ) ) - { - Lr = L_shl( Lr, STEREO_DMX_EVS_POC_RENORM_SHIFT ); - Li = L_shl( Li, STEREO_DMX_EVS_POC_RENORM_SHIFT ); - Rr = L_shl( Rr, STEREO_DMX_EVS_POC_RENORM_SHIFT ); - Ri = L_shl( Ri, STEREO_DMX_EVS_POC_RENORM_SHIFT ); - } -#endif specPOr[i] = L_add( Mpy_32_32_r( Lr, Rr ), Mpy_32_32_r( Li, Ri ) ); // 2*spec_e move32(); @@ -544,21 +494,8 @@ static void calc_poc_fx( Rr = L_add( L_sub( specRr[j], Mpy_32_32_r( specLr[j], eps_cos ) ), Mpy_32_32_r( specLi[j], eps_sin ) ); Ri = L_sub( L_sub( specRi[j], Mpy_32_32_r( specLr[j], eps_sin ) ), Mpy_32_32_r( specLi[j], eps_cos ) ); -#ifdef FIX_ISSUE_1764 renorm_poc_fx( &Lr, &Li ); renorm_poc_fx( &Rr, &Ri ); -#else - IF( ( LT_32( L_abs( Lr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && - ( LT_32( L_abs( Li ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && - ( LT_32( L_abs( Rr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && - ( LT_32( L_abs( Ri ), STEREO_DMX_EVS_POC_RENORM_TH ) ) ) - { - Lr = L_shl( Lr, STEREO_DMX_EVS_POC_RENORM_SHIFT ); - Li = L_shl( Li, STEREO_DMX_EVS_POC_RENORM_SHIFT ); - Rr = L_shl( Rr, STEREO_DMX_EVS_POC_RENORM_SHIFT ); - Ri = L_shl( Ri, STEREO_DMX_EVS_POC_RENORM_SHIFT ); - } -#endif specPOr[j] = L_add( Mpy_32_32_r( Lr, Rr ), Mpy_32_32_r( Li, Ri ) ); // 2*spec_e move32(); @@ -573,10 +510,8 @@ static void calc_poc_fx( Rr = L_add( specRr[i], Mpy_32_32_r( specLi[i], EPS ) ); Ri = L_sub( specRi[i], Mpy_32_32_r( specLr[i], EPS ) ); -#ifdef FIX_ISSUE_1764 renorm_poc_fx( &Lr, &Li ); renorm_poc_fx( &Rr, &Ri ); -#endif specPOr[i] = L_add( Mpy_32_32_r( Lr, Rr ), Mpy_32_32_r( Li, Ri ) ); move32(); @@ -609,11 +544,7 @@ static void calc_poc_fx( { tmp1 = Mpy_32_32_r( wnd[i * step + bias], gamma ); // Q31 -#ifdef FIX_ISSUE_1764 IF( GT_32( L_abs( specPOr[i] ), L_abs( specPOi[i] ) ) ) -#else - IF( W_mult0_32_32( L_sub( specPOr[i], specPOi[i] ), L_add( specPOr[i], specPOi[i] ) ) > 0 ) -#endif { specPOr[i] = Mpy_32_16_1( tmp1, imult1616( sign_fx( specPOr[i] ), /*0.923880f*/ s[120 * mult_angle] ) ); /* cos(PI/8) Q31*/ move32(); @@ -632,17 +563,9 @@ static void calc_poc_fx( FOR( ; i < end; i++ ) /* binary search from 16 angles */ { tmp1 = Mpy_32_32_r( wnd[i * step + bias], gamma ); // Q31 -#ifdef FIX_ISSUE_1764 IF( GT_32( L_abs( specPOr[i] ), L_abs( specPOi[i] ) ) ) -#else - IF( W_mult0_32_32( L_sub( specPOr[i], specPOi[i] ), L_add( specPOr[i], specPOi[i] ) ) > 0 ) -#endif { -#ifdef FIX_ISSUE_1764 IF( GT_32( L_abs( Mpy_32_16_1( specPOr[i], 13573 /*0.414213f*/ ) ), L_abs( specPOi[i] ) ) ) /*tan(PI/8)*/ -#else - IF( W_mult0_32_32( L_sub( Mpy_32_16_1( specPOr[i], 13573 /*0.414213f*/ ), specPOi[i] ), L_add( Mpy_32_16_1( specPOr[i], 13573 /*0.414213f*/ ), specPOi[i] ) ) > 0 ) /*tan(PI/8)*/ -#endif { specPOr[i] = Mpy_32_16_1( tmp1 /*0.980785f */, imult1616( sign_fx( specPOr[i] ), s[140 * mult_angle] ) ); /* cos(PI/16) Q31*/ move32(); @@ -659,11 +582,7 @@ static void calc_poc_fx( } ELSE { -#ifdef FIX_ISSUE_1764 IF( GT_32( L_abs( specPOr[i] ), L_abs( Mpy_32_16_1( specPOi[i], 13573 /*0.414213f*/ ) ) ) ) /*tan(PI/8)*/ -#else - IF( W_mult0_32_32( L_sub( specPOr[i], Mpy_32_16_1( specPOi[i], 13573 /*0.414213f*/ ) ), L_add( specPOr[i], Mpy_32_16_1( specPOi[i], 13573 /*0.414213f*/ ) ) ) > 0 ) /*tan(PI/8)*/ -#endif { specPOr[i] = Mpy_32_16_1( tmp1 /** 0.555570f*/, imult1616( sign_fx( specPOr[i] ), s[60 * mult_angle] ) ); /*cos(PI*5/16) Q31*/ move32(); @@ -758,11 +677,7 @@ static void calc_poc_fx( hPHA->pha_hys_cnt = 0; move16(); } -#ifdef FIX_ISSUE_1764 IF( GE_32( hPHA->pha_hys_cnt, STEREO_DMX_EVS_SWTCH_HYS_THRES ) ) -#else - if ( GE_32( hPHA->pha_hys_cnt, STEREO_DMX_EVS_SWTCH_HYS_THRES ) ) -#endif { hPHA->curr_pha = STEREO_DMX_EVS_PHA_IPD; move32(); @@ -786,11 +701,7 @@ static void calc_poc_fx( hPHA->pha_hys_cnt = 0; move16(); } -#ifdef FIX_ISSUE_1764 IF( GE_16( hPHA->pha_hys_cnt, STEREO_DMX_EVS_SWTCH_HYS_THRES ) ) -#else - if ( GE_16( hPHA->pha_hys_cnt, STEREO_DMX_EVS_SWTCH_HYS_THRES ) ) -#endif { hPHA->curr_pha = STEREO_DMX_EVS_PHA_IPD2; move32(); @@ -1685,11 +1596,6 @@ static Word32 find_poc_peak_fx( { Q_fx[i] = L_shr( Q_fx[i], negate( Q_e[i] ) ); // Q31 move32(); -#ifndef FIX_ISSUE_1764 - } - FOR( i = 0; i < CPE_CHANNELS; i++ ) - { -#endif peakQ_fx[i] = L_shr( peakQ_fx[i], sub( 15, peakQ_e[i] ) ); // Q16 move32(); } @@ -1889,7 +1795,6 @@ static Word32 spectral_flatness_fx( return L_shl_sat( L_deposit_h( sf ), L_tmp_e ); } -#ifdef FIX_ISSUE_1764 /*-------------------------------------------------------------------* * renorm_poc_fx() * @@ -1913,7 +1818,6 @@ static void renorm_poc_fx( } } } -#endif /*-------------------------------------------------------------------* * calc_energy() @@ -2435,11 +2339,7 @@ void stereo_dmx_evs_enc_fx( FOR( ( fx_tmp = 0, m = 0 ); m < pha_len; m++ ) { // ftmp += p_data_mem[n - m] * p_prev_taps[m]; -#ifdef FIX_ISSUE_1764 fx_tmp = L_add( fx_tmp, Mpy_32_32( p_data_mem[n - m], p_prev_taps[m] ) ); // Q25 -#else - fx_tmp = L_add( fx_tmp, Mpy_32_32( p_data_mem[sub( n, m )], p_prev_taps[m] ) ); // Q25 -#endif } fx_tmp = L_shl( fx_tmp, 1 ); // Q26 mem_prev[n] = L_add( mem_prev[n], Mpy_32_32( fx_tmp, INV_SQRT_2_Q31 ) ); @@ -2464,11 +2364,7 @@ void stereo_dmx_evs_enc_fx( FOR( ( fx_tmp = 0, m = 0 ); m < pha_len; m++ ) { // ftmp += p_data_mem[n - m] * p_curr_taps[m]; -#ifdef FIX_ISSUE_1764 fx_tmp = L_add( fx_tmp, Mpy_32_32( p_data_mem[n - m], p_curr_taps[m] ) ); // Q25 -#else - fx_tmp = L_add( fx_tmp, Mpy_32_32( p_data_mem[sub( n, m )], p_curr_taps[m] ) ); // Q25 -#endif } fx_tmp = L_shl( fx_tmp, 1 ); // Q26 // dmx_pha_data[n] += ftmp * INV_SQRT_2; @@ -2514,11 +2410,7 @@ void stereo_dmx_evs_enc_fx( hPHA->prc_hys_cnt = 0; move16(); } -#ifdef FIX_ISSUE_1764 IF( GE_16( hPHA->prc_hys_cnt, STEREO_DMX_EVS_SWTCH_PRC_HYS_THRES ) ) -#else - if ( GE_16( hPHA->prc_hys_cnt, STEREO_DMX_EVS_SWTCH_PRC_HYS_THRES ) ) -#endif { hPHA->curr_prc = STEREO_DMX_EVS_PRC_POC; move32(); @@ -2542,11 +2434,7 @@ void stereo_dmx_evs_enc_fx( move16(); } -#ifdef FIX_ISSUE_1764 IF( GE_16( hPHA->prc_hys_cnt, STEREO_DMX_EVS_SWTCH_PRC_HYS_THRES ) ) -#else - if ( GE_16( hPHA->prc_hys_cnt, STEREO_DMX_EVS_SWTCH_PRC_HYS_THRES ) ) -#endif { hPHA->curr_prc = STEREO_DMX_EVS_PRC_PHA; move32(); -- GitLab From 8643daf34e43c73170be0f4976ca0cc19e45ef15 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Sun, 17 Aug 2025 21:24:57 +0200 Subject: [PATCH 12/16] [cleanup] accept FIX_1844_MISSING_FREE --- lib_com/options.h | 1 - lib_dec/ivas_binRenderer_internal_fx.c | 2 -- 2 files changed, 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 157593c99..868472f70 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -84,7 +84,6 @@ #define FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW /* FhG: bit-exact, replace carry and overflow operations by 64-bit operations, MR 1931 */ -#define FIX_1844_MISSING_FREE /* FhG: add missing free in ivas_binRenderer_convModuleClose_fx() */ #define NONBE_SVD_OPTIMIZATION /* FhG: reduce WMOPS of HouseHolderReduction() in ivas_svd_dec.c() by removing redundant mathematics and using 64 bit additions.*/ /* #################### Start BASOP porting switches ############################ */ diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index db2b89c5b..c8f1aac4e 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -1496,10 +1496,8 @@ static void ivas_binRenderer_convModuleClose_fx( free( hBinRenConvModule->filterStatesLeftImag_fx ); hBinRenConvModule->filterStatesLeftImag_fx = NULL; -#ifdef FIX_1844_MISSING_FREE free( hBinRenConvModule->Q_filterStates ); hBinRenConvModule->Q_filterStates = NULL; -#endif free( ( *hBinRenderer )->hBinRenConvModule ); ( *hBinRenderer )->hBinRenConvModule = NULL; -- GitLab From bffc4d37bd73bd5f137d39c652c6c3e9e337897c Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Sun, 17 Aug 2025 21:26:45 +0200 Subject: [PATCH 13/16] [cleanup] accept FIX_1741_REVERB_TIMES_Q_FORMAT --- lib_com/options.h | 1 - .../ivas_dirac_dec_binaural_functions_fx.c | 4 -- lib_rend/ivas_prot_rend_fx.h | 2 - lib_rend/ivas_reverb_filter_design_fx.c | 2 - lib_rend/ivas_reverb_fx.c | 22 ---------- lib_rend/ivas_reverb_utils_fx.c | 40 ------------------- lib_rend/ivas_rom_binauralRenderer.h | 8 ---- lib_rend/ivas_rom_binauralRenderer_fx.c | 20 ---------- lib_rend/ivas_stat_rend.h | 12 ------ lib_util/hrtf_file_reader.c | 8 ---- 10 files changed, 119 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 868472f70..eec773022 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -102,7 +102,6 @@ #define NONBE_FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT /* fix 1070 USAN: nullptr-with-offset and Segfaults in 7_1_4 to BINAURAL and BINAURAL_ROOM_REVERB decoding with bitrate switching and head rotation*/ -#define FIX_1741_REVERB_TIMES_Q_FORMAT /* Philips: reverberation times in Q26 format instead of Q31 */ #define FIX_1831_REVERB_REGRESSION /* Philips: fixes reverb regression issues */ #define FIX_1835_REVERB_ACTIVATION /* FhG: Modified reverberation activation logic and corrected factEQ calculation */ #define LC3PLUS_LEA_COMPAT_BITRATES_48_6 /* FhG: treat split-rendering 256kbps lc3plus 10ms 0dof bitrate as sentinel value for LEA compatible 48_6 bitrate (124 kbps per channel) */ diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 65d159579..327160b3c 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -515,11 +515,7 @@ ivas_error ivas_dirac_dec_binaural_copy_hrtfs_fx( Copy( hrtfShCoeffsIm_fx[i][j], hrtfParambin->hrtfShCoeffsIm_fx[i][j], HRTF_NUM_BINS ); /*Q14*/ } } -#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT Copy32( parametricReverberationTimes_fx, hrtfParambin->parametricReverberationTimes_fx, CLDFB_NO_CHANNELS_MAX ); /*Q26*/ -#else - Copy32( parametricReverberationTimes_fx, hrtfParambin->parametricReverberationTimes_fx, CLDFB_NO_CHANNELS_MAX ); /*Q31*/ -#endif Copy32( parametricReverberationEneCorrections_fx, hrtfParambin->parametricReverberationEneCorrections_fx, CLDFB_NO_CHANNELS_MAX ); /*Q31*/ Copy32( parametricEarlyPartEneCorrection_fx, hrtfParambin->parametricEarlyPartEneCorrection_fx, CLDFB_NO_CHANNELS_MAX ); /*Q28*/ *hHrtfParambin = hrtfParambin; diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index 566914f2f..04d45c726 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -1117,7 +1117,6 @@ void ivas_reverb_interpolate_acoustic_data_fx( Word16 *pOutput_t60_e, //output e Word16 *pOutput_dsr_e //output e ); -#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT void ivas_reverb_interpolate_energies_fx( const Word16 input_table_size, const Word32 *pInput_fc, //input in Q16 @@ -1130,7 +1129,6 @@ void ivas_reverb_interpolate_energies_fx( Word16 *pOutput_ene_l_e, //output e Word16 *pOutput_ene_r_e //output e ); -#endif /*---------------------------------------------------------------------------------* * Shoebox Prototypes *-----------------------------------------------------------------------------------*/ diff --git a/lib_rend/ivas_reverb_filter_design_fx.c b/lib_rend/ivas_reverb_filter_design_fx.c index a40fcfac8..900a90dca 100644 --- a/lib_rend/ivas_reverb_filter_design_fx.c +++ b/lib_rend/ivas_reverb_filter_design_fx.c @@ -920,7 +920,6 @@ void ivas_reverb_interpolate_acoustic_data_fx( return; } -#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT /*-------------------------------------------------------------------* * ivas_reverb_interpolate_energies_fx() * @@ -1001,4 +1000,3 @@ void ivas_reverb_interpolate_energies_fx( return; } -#endif diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index 8ff779f51..ae1d08dae 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -221,11 +221,7 @@ static void ivas_binaural_reverb_setPreDelay_fx( static void ivas_binaural_reverb_setReverbTimes_fx( REVERB_STRUCT_HANDLE hReverb, /* i/o: binaural reverb handle */ const Word32 output_Fs, /* i : sampling_rate */ -#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT const Word32 *revTimes_fx, /*Q26 i : reverberation times T60 for each CLDFB bin in seconds */ -#else - const Word32 *revTimes_fx, /*Q31 i : reverberation times T60 for each CLDFB bin in seconds */ -#endif const Word32 *revEnes_fx /*Q31 i : spectrum for reverberated sound at each CLDFB bin */ ) { @@ -330,11 +326,7 @@ static void ivas_binaural_reverb_setReverbTimes_fx( /* Determine attenuation factor that generates the appropriate energy decay according to reverberation time */ L_tmp = Mpy_32_32( 1677721600, revTimes_fx[bin] ); // e10 --> 800 * 2^21, + e0 tmp = BASOP_Util_Divide3232_Scale( 1073741824, L_tmp, &scale ); -#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT scale = add( scale, sub( 1, 15 ) ); // revTimes_fx in Q26 -#else - scale = add( scale, sub( 1, 10 ) ); -#endif L_tmp = Mpy_32_16_1( -1610612736, tmp ); // * -3 scale = add( 2, scale ); L_tmp = Mpy_32_32( 1783446563, L_tmp ); // scale + 2 @@ -2389,11 +2381,7 @@ static ivas_error ivas_binaural_reverb_open_fx( const Word16 numBins, /* i : Q0 number of CLDFB bins */ const Word16 numCldfbSlotsPerFrame, /* i : Q0 number of CLDFB slots per frame */ const Word32 sampling_rate, /* i : Q0 sampling rate */ -#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT const Word32 *revTimes_fx, /* i : Q26 reverberation times T60 for each CLDFB bin in seconds */ -#else - const Word32 *revTimes_fx, /* i : Q31 reverberation times T60 for each CLDFB bin in seconds */ -#endif const Word32 *revEnes_fx, /* i : Q31 spectrum for reverberated sound at each CLDFB bin */ const Word16 preDelay /* i : Q0 reverb pre-delay in CLDFB slots */ ) @@ -2453,15 +2441,9 @@ static ivas_error ivas_binaural_reverb_open_fx( * but not excessively long loops to generate reverberation. */ /* Note: the resulted length is very sensitive to the precision of the constants below (e.g. 1.45 vs. 1.45f) */ // hReverb->loopBufLength[bin] = (int16_t) ( 1.45 * (int16_t) ( revTimes[bin] * 150.0 ) + 1 ); -#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT Word32 L_tmp_BufLength = L_shl( L_shr( Mpy_32_32( revTimes_fx[bin], 1258291200 /*150.0 in Q23*/ ), 18 ), 18 ); L_tmp_BufLength = L_add( Mpy_32_32( 1556925645 /*1.45 in Q30*/, L_tmp_BufLength ), ONE_IN_Q17 ); hReverb->loopBufLength[bin] = (Word16) L_shr( L_tmp_BufLength, 17 ); /*Q0*/ -#else - Word32 L_tmp_BufLength = L_shl( L_shr( Mpy_32_32( revTimes_fx[bin], 1258291200 /*150.0 in Q23*/ ), 23 ), 23 ); - L_tmp_BufLength = L_add( Mpy_32_32( 1556925645 /*1.45 in Q30*/, L_tmp_BufLength ), ONE_IN_Q22 ); - hReverb->loopBufLength[bin] = (Word16) L_shr( L_tmp_BufLength, 22 ); /*Q0*/ -#endif move16(); hReverb->loopBufLength[bin] = s_min( hReverb->loopBufLength[bin], hReverb->loopBufLengthMax[bin] ); @@ -2561,11 +2543,7 @@ ivas_error ivas_binaural_reverb_init( #else preDelay = (int16_t) roundf( 48000.0f * roomAcoustics->acousticPreDelay / CLDFB_NO_CHANNELS_MAX ); #endif -#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT floatToFixed_arrL( t60_temp, t60, Q26, CLDFB_NO_CHANNELS_MAX ); -#else - floatToFixed_arrL( t60_temp, t60, Q31, CLDFB_NO_CHANNELS_MAX ); -#endif floatToFixed_arrL( ene_temp, ene, Q31, CLDFB_NO_CHANNELS_MAX ); } else diff --git a/lib_rend/ivas_reverb_utils_fx.c b/lib_rend/ivas_reverb_utils_fx.c index b914df8f3..b8f923b46 100644 --- a/lib_rend/ivas_reverb_utils_fx.c +++ b/lib_rend/ivas_reverb_utils_fx.c @@ -147,7 +147,6 @@ static void ivas_reverb_set_energies( { int16_t freq_idx; float input_fc[FFT_SPECTRUM_SIZE]; -#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT Word32 input_fc_fx[FFT_SPECTRUM_SIZE]; Word32 output_fc_fx[CLDFB_NO_CHANNELS_MAX]; Word32 avg_pwr_left_fx[CLDFB_NO_CHANNELS_MAX]; @@ -155,7 +154,6 @@ static void ivas_reverb_set_energies( Word32 avg_pwr_right_fx[CLDFB_NO_CHANNELS_MAX]; Word16 avg_pwr_right_e[CLDFB_NO_CHANNELS_MAX]; const Word16 cldfb_freq_halfstep = MAX_SAMPLING_RATE / ( 4 * CLDFB_NO_CHANNELS_MAX ); -#endif const int16_t avg_pwr_len = sampling_rate == 16000 ? LR_IAC_LENGTH_NR_FC_16KHZ : LR_IAC_LENGTH_NR_FC; @@ -163,48 +161,18 @@ static void ivas_reverb_set_energies( for ( freq_idx = 0; freq_idx < avg_pwr_len; freq_idx++ ) { input_fc[freq_idx] = freq_idx * ( 0.5f * sampling_rate / (float) ( avg_pwr_len - 1 ) ); -#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT input_fc_fx[freq_idx] = (Word16) ( input_fc[freq_idx] * ONE_IN_Q16 + 0.5f ); -#endif } -#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT for ( freq_idx = 0; freq_idx < CLDFB_NO_CHANNELS_MAX; freq_idx++ ) { output_fc_fx[freq_idx] = ( ( freq_idx << 1 ) + 1 ) * cldfb_freq_halfstep * ONE_IN_Q16; } -#endif -#ifndef FIX_1741_REVERB_TIMES_Q_FORMAT - Word32 *input_fc_fx = (Word32 *) malloc( 60 * sizeof( Word32 ) ); - Word32 *output_fc_fx = (Word32 *) malloc( avg_pwr_len * sizeof( Word32 ) ); - Word16 *avg_pwr_left_e = (Word16 *) malloc( avg_pwr_len * sizeof( Word16 ) ); - Word16 *avg_pwr_right_e = (Word16 *) malloc( avg_pwr_len * sizeof( Word16 ) ); - Word32 *avg_pwr_left_fx = (Word32 *) malloc( avg_pwr_len * sizeof( Word32 ) ); - Word32 *avg_pwr_right_fx = (Word32 *) malloc( avg_pwr_len * sizeof( Word32 ) ); -#endif - -#ifndef FIX_1741_REVERB_TIMES_Q_FORMAT - for ( int i = 0; i < 60; i++ ) - { - input_fc_fx[i] = (Word32) input_fc[i] * ( 1 << 16 ); - } - - for ( int i = 0; i < 257; i++ ) - { - output_fc_fx[i] = (Word32) input_fc[i] * ONE_IN_Q16; - } -#endif - -#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT ivas_reverb_interpolate_energies_fx( avg_pwr_len, input_fc_fx, avg_pwr_l, avg_pwr_r, CLDFB_NO_CHANNELS_MAX, output_fc_fx, avg_pwr_left_fx, avg_pwr_right_fx, avg_pwr_left_e, avg_pwr_right_e ); -#else - ivas_reverb_interpolate_acoustic_data_fx( FFT_SPECTRUM_SIZE, input_fc_fx, avg_pwr_l, avg_pwr_r, - CLDFB_NO_CHANNELS_MAX, output_fc_fx, avg_pwr_left_fx, avg_pwr_right_fx, avg_pwr_left_e, avg_pwr_right_e ); -#endif for ( int i = 0; i < 60; i++ ) { @@ -212,12 +180,4 @@ static void ivas_reverb_set_energies( avg_pwr_right[i] = (float) fabs( me2f( avg_pwr_right_fx[i], avg_pwr_right_e[i] ) ); } -#ifndef FIX_1741_REVERB_TIMES_Q_FORMAT - free( input_fc_fx ); - free( output_fc_fx ); - free( avg_pwr_left_e ); - free( avg_pwr_right_e ); - free( avg_pwr_left_fx ); - free( avg_pwr_right_fx ); -#endif } diff --git a/lib_rend/ivas_rom_binauralRenderer.h b/lib_rend/ivas_rom_binauralRenderer.h index 1027c482b..aee54e983 100644 --- a/lib_rend/ivas_rom_binauralRenderer.h +++ b/lib_rend/ivas_rom_binauralRenderer.h @@ -72,20 +72,12 @@ extern Word32 rightBRIRReal_fx[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NT extern Word32 rightBRIRImag_fx[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NTAPS_MAX]; /* Q29 */ /* Reverberation parameters based on BRIRs for fastconv */ -#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT extern Word32 fastconvReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q26 */ -#else -extern Word32 fastconvReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ -#endif extern Word32 fastconvReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ /* Binaural rendering data set based on BRIRs, to be used in a combined manner * with the above binaural rendering data set based on HRIRs for parametric * renderer */ -#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT extern const Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q26 */ -#else -extern const Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ -#endif extern const Word32 parametricReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ extern const Word32 parametricEarlyPartEneCorrection_fx[CLDFB_NO_CHANNELS_MAX]; /* Q28 */ diff --git a/lib_rend/ivas_rom_binauralRenderer_fx.c b/lib_rend/ivas_rom_binauralRenderer_fx.c index 7333868b0..b0b5120e5 100644 --- a/lib_rend/ivas_rom_binauralRenderer_fx.c +++ b/lib_rend/ivas_rom_binauralRenderer_fx.c @@ -47156,7 +47156,6 @@ const Word32 rightBRIRImag_fx[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NTA }; -#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT const Word32 fastconvReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX] /* Q26 */ = { 28803192, 13764699, 13578673, 13984346, 14472966, 15874266, 15475170, 15327665, @@ -47167,12 +47166,6 @@ const Word32 fastconvReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX] /* Q26 */ = 14959707, 15463023, 15698642, 15679785, 15860039, 15933523, 16215448, 16181155, 16028751, 16266115, 16528376, 16505291, 16515491, 16468247, 16371274, 16382817 }; -#else -const Word32 fastconvReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX] /* Q31 */= -{ - 921702144, 440470368, 434517536, 447499072, 463134912, 507976512, 495205440, 490485280, 488481664, 470204416, 485509536, 473953952, 475669760, 479900320, 480402816, 487614080, 489409376, 479041312, 472446400, 469403424, 473341888, 468688320, 457950880, 451686688, 445424608, 426812384, 421443680, 418581056, 408736992, 396210720, 387262176, 378315744, 379030848, 381356576, 394241504, 420728544, 436476064, 447572096, 460993888, 472446400, 478710624, 494816736, 502356544, 501753120, 507521248, 509872736, 518894336, 517796960, 512920032, 520515680, 528908032, 528169312, 528495712, 526983904, 523880768, 524250144, 513828416, 518561472, 504280704, 543399232 -}; -#endif const Word32 fastconvReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX] /* Q31 */= @@ -47181,7 +47174,6 @@ const Word32 fastconvReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX] /* Q }; -#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT const Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX] /* Q26 */ = { 23185710, 21438196, 22344634, 24221132, 25118780, 24882424, 24066916, 23360796, @@ -47193,18 +47185,6 @@ const Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX] /* Q26 */ = 10172093, 10063847, 9945802, 9827825, 9709847, 9591870, 9473893, 9355915, 9237871, 9119893, 9001916, 8883939 }; -#else -const Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX] /* Q31 */= -{ - 741942720,686022272,715028288,775076224,803800960,796237568,770141312,747545472,736820992, - 711570880,679682880,654928832,633196288,617506752,601123648,580415424,567025856,550623424, - 536654016,519776928,504817568,493163168,480456512,469858688,456552864,446008736,433967776, - 425403616,416412096,399234400,392295872,390756128,386091776,384573504,379121056,370071552, - 367440896,360672032,360721408,363373568,359359904,356323360,351253152,346943168,340172160, - 336405472,333613728,329810528,325506976,322043104,318265664,314490400,310715104,306939840, - 303164576,299389280,295611872,291836576,288061312,284286048 -}; -#endif const Word32 parametricReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX] /* Q31 */= diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 8fd13cdd4..46841487f 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -599,11 +599,7 @@ typedef struct ivas_hrtfs_parambin_struct Word16 hrtfShCoeffsRe_fx[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS]; /* Q14 */ Word16 hrtfShCoeffsIm_fx[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS]; /* Q14 */ -#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q26 */ -#else - Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ -#endif Word32 parametricReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ Word32 parametricEarlyPartEneCorrection_fx[CLDFB_NO_CHANNELS_MAX]; /* Q28 */ @@ -1450,11 +1446,7 @@ typedef struct ivas_hrtfs_fastconv_struct Word16 allocate_init_flag; /*Memory allocation flag 0: if the hrtf pointers are allocated at application level , 1: of allocated at ivas_binaural_hrtf_open() */ -#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT Word32 fastconvReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q26 */ -#else - Word32 fastconvReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ -#endif Word32 fastconvReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ } HRTFS_FASTCONV, *HRTFS_FASTCONV_HANDLE; @@ -1465,11 +1457,7 @@ typedef struct ivas_hrtfs_parambin_struct Word16 hrtfShCoeffsRe_fx[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS]; /* Q14 */ Word16 hrtfShCoeffsIm_fx[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS]; /* Q14 */ -#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q26 */ -#else - Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ -#endif Word32 parametricReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ Word32 parametricEarlyPartEneCorrection_fx[CLDFB_NO_CHANNELS_MAX]; /* Q28 */ diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 9a89badaf..6c755957e 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -1660,11 +1660,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata( memcpy( f_tmp_brir_reverb, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( float ); -#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT floatToFixed_arrL( f_tmp_brir_reverb, ( *hHRTF )->fastconvReverberationTimes_fx, Q26, CLDFB_NO_CHANNELS_MAX ); -#else - floatToFixed_arrL( f_tmp_brir_reverb, ( *hHRTF )->fastconvReverberationTimes_fx, Q31, CLDFB_NO_CHANNELS_MAX ); -#endif memcpy( f_tmp_brir_reverb, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); floatToFixed_arrL( f_tmp_brir_reverb, ( *hHRTF )->fastconvReverberationEneCorrections_fx, Q31, CLDFB_NO_CHANNELS_MAX ); @@ -1828,11 +1824,7 @@ static ivas_error create_parambin_HRTF_from_rawdata( memcpy( f_tmp_reverb, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( float ); /*adding conversion as file reading is done in float*/ -#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT floatToFixed_arrL( f_tmp_reverb, ( *hHRTF )->parametricReverberationTimes_fx, Q26, CLDFB_NO_CHANNELS_MAX ); -#else - floatToFixed_arrL( f_tmp_reverb, ( *hHRTF )->parametricReverberationTimes_fx, Q31, CLDFB_NO_CHANNELS_MAX ); -#endif memcpy( f_tmp_reverb, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( float ); -- GitLab From 16150f6dfd3391f599d1379329f226a1bedae179 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Sun, 17 Aug 2025 21:27:37 +0200 Subject: [PATCH 14/16] [cleanup] accept FIX_1831_REVERB_REGRESSION --- lib_com/options.h | 1 - lib_rend/ivas_reverb_fx.c | 6 ------ 2 files changed, 7 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index eec773022..0eeff26c6 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -102,7 +102,6 @@ #define NONBE_FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT /* fix 1070 USAN: nullptr-with-offset and Segfaults in 7_1_4 to BINAURAL and BINAURAL_ROOM_REVERB decoding with bitrate switching and head rotation*/ -#define FIX_1831_REVERB_REGRESSION /* Philips: fixes reverb regression issues */ #define FIX_1835_REVERB_ACTIVATION /* FhG: Modified reverberation activation logic and corrected factEQ calculation */ #define LC3PLUS_LEA_COMPAT_BITRATES_48_6 /* FhG: treat split-rendering 256kbps lc3plus 10ms 0dof bitrate as sentinel value for LEA compatible 48_6 bitrate (124 kbps per channel) */ #define NONBE_FIX_ISM_XOVER_BR /* FhG: issue 1072: select OSBA coding method depending on number of object and bitrate */ diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index ae1d08dae..6b742ec45 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -2518,9 +2518,7 @@ ivas_error ivas_binaural_reverb_init( Word32 t60[CLDFB_NO_CHANNELS_MAX]; Word32 ene[CLDFB_NO_CHANNELS_MAX]; Word16 preDelay; -#ifdef FIX_1831_REVERB_REGRESSION Word32 temp32; -#endif error = IVAS_ERR_OK; @@ -2537,12 +2535,8 @@ ivas_error ivas_binaural_reverb_init( return error; } -#ifdef FIX_1831_REVERB_REGRESSION temp32 = Mult_32_16( roomAcoustics->acousticPreDelay_fx, ( ( IVAS_48k / CLDFB_NO_CHANNELS_MAX ) >> 1 ) ); // Q11 preDelay = extract_l( L_shr( L_add( temp32, L_shl( 1, 10 ) ), 11 ) ); // Q0 -#else - preDelay = (int16_t) roundf( 48000.0f * roomAcoustics->acousticPreDelay / CLDFB_NO_CHANNELS_MAX ); -#endif floatToFixed_arrL( t60_temp, t60, Q26, CLDFB_NO_CHANNELS_MAX ); floatToFixed_arrL( ene_temp, ene, Q31, CLDFB_NO_CHANNELS_MAX ); } -- GitLab From 472752df266b8e62cfd31dadbaa2ce2d0c5fa759 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Sun, 17 Aug 2025 21:28:39 +0200 Subject: [PATCH 15/16] [cleanup] accept FIX_1835_REVERB_ACTIVATION --- lib_com/options.h | 1 - lib_dec/ivas_binRenderer_internal_fx.c | 8 -------- lib_rend/ivas_rotation_fx.c | 2 -- 3 files changed, 11 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 0eeff26c6..f9bedbf44 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -102,7 +102,6 @@ #define NONBE_FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT /* fix 1070 USAN: nullptr-with-offset and Segfaults in 7_1_4 to BINAURAL and BINAURAL_ROOM_REVERB decoding with bitrate switching and head rotation*/ -#define FIX_1835_REVERB_ACTIVATION /* FhG: Modified reverberation activation logic and corrected factEQ calculation */ #define LC3PLUS_LEA_COMPAT_BITRATES_48_6 /* FhG: treat split-rendering 256kbps lc3plus 10ms 0dof bitrate as sentinel value for LEA compatible 48_6 bitrate (124 kbps per channel) */ #define NONBE_FIX_ISM_XOVER_BR /* FhG: issue 1072: select OSBA coding method depending on number of object and bitrate */ #define FIX_1053_REVERB_RECONFIGURATION /* Philips: issue 1053: fix for dynamic switching of acoustic environment */ diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index c8f1aac4e..57fe6dc5f 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -981,11 +981,7 @@ static void ivas_binaural_obtain_DMX_fx( ELSE { Word16 div = divide3232( P_in_fx[bandIdx], P_out_fx ); -#ifdef FIX_1835_REVERB_ACTIVATION Word16 exp = 0; // divide3232 returns Q15 + following Q16 shift -#else - Word16 exp = norm_l( div ); -#endif factEQ_fx = Sqrt32( L_shl( div, Q16 ), &exp ); factEQ_fx = L_shl( factEQ_fx, sub( exp, 1 ) ); // Q30 } @@ -1354,11 +1350,7 @@ ivas_error ivas_binRenderer_open_fx( /* Allocate memories needed for reverb module */ test(); -#ifdef FIX_1835_REVERB_ACTIVATION IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) && EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) ) -#else - IF( ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ) && EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) -#endif { IF( NE_32( ( error = ivas_binaural_reverb_init( &( hBinRenderer->hReverb ), st_ivas->hHrtfStatistics, hBinRenderer->conv_band, hBinRenderer->timeSlots, &( st_ivas->hRenderConfig->roomAcoustics ), st_ivas->hDecoderConfig->output_Fs, st_ivas->hHrtfFastConv->fastconvReverberationTimes_fx, st_ivas->hHrtfFastConv->fastconvReverberationEneCorrections_fx ) ), IVAS_ERR_OK ) ){ return error; diff --git a/lib_rend/ivas_rotation_fx.c b/lib_rend/ivas_rotation_fx.c index 2db143ab4..21b443a04 100644 --- a/lib_rend/ivas_rotation_fx.c +++ b/lib_rend/ivas_rotation_fx.c @@ -1165,9 +1165,7 @@ void rotateFrame_sd_cldfb_fixed( IF( hEFAPdata != NULL && ( NE_16( extract_l( L_shr( hOutputSetup->ls_azimuth_fx[n], Q22 ) ), azimuth ) || NE_16( extract_l( L_shr( hOutputSetup->ls_elevation_fx[n], Q22 ) ), elevation ) ) ) { efap_determine_gains_fx( hEFAPdata, gains_fx[n], L_shl( azimuth, Q22 ), L_shl( elevation, Q22 ), EFAP_MODE_EFAP ); -#ifdef FIX_1835_REVERB_ACTIVATION scale_sig32( gains_fx[n], hEFAPdata->numSpk, Q1 ); // gains_fx: Q31 -#endif } ELSE { -- GitLab From 35745e2b33d61b5d10615f023c4c0c77f2552812 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Sun, 17 Aug 2025 21:32:40 +0200 Subject: [PATCH 16/16] formatting --- lib_com/options.h | 19 +- lib_dec/dec_tcx_fx.c | 84 +- lib_dec/ivas_binRenderer_internal_fx.c | 725 +++++++++--------- lib_dec/lib_dec_fx.c | 4 +- lib_enc/analy_sp_fx.c | 2 +- lib_enc/find_tilt_fx.c | 4 +- lib_enc/hvq_enc_fx.c | 12 +- lib_enc/nois_est_fx.c | 10 +- lib_enc/pvq_encode_fx.c | 8 +- lib_enc/swb_tbe_enc_fx.c | 2 +- lib_enc/vad_fx.c | 2 +- .../ivas_dirac_dec_binaural_functions_fx.c | 2 +- lib_rend/ivas_reverb_fx.c | 12 +- lib_rend/ivas_reverb_utils_fx.c | 2 - lib_rend/ivas_rom_binauralRenderer.h | 4 +- lib_rend/ivas_stat_rend.h | 14 +- 16 files changed, 444 insertions(+), 462 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index f9bedbf44..49f6e68e9 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -73,35 +73,28 @@ /* Note: each compile switch (FIX_1101_...) is independent from the other ones */ - - #define ISSUE_1796_replace_shl_o /* FhG: replace shl_ro by overflow-free alternatives - BE*/ #define ISSUE_1836_replace_overflow_libcom /* FhG: replace overflow operators by non-overflow-alternatives - BE */ -#define ISSUE_1866_replace_overflow_libdec /* FhG: BE - Replace BASOPoverflow operators all over the lib_dec module if Overflow result is not used */ +#define ISSUE_1866_replace_overflow_libdec /* FhG: BE - Replace BASOPoverflow operators all over the lib_dec module if Overflow result is not used */ #define FIX_1917_DIRAC_RENDER_PTR_INCR /* FhG: fix wrong pointer increment in ivas_dirac_dec_render_sf_fx() for object rendering */ #define FIX_CDLFB_BUFFER_SCALING /* FhG: fix wrong buffer scaling in ivas_dirac_dec_render_sf_fx() for object rendering */ +#define FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW /* FhG: bit-exact, replace carry and overflow operations by 64-bit operations, MR 1931 */ +#define NONBE_SVD_OPTIMIZATION /* FhG: reduce WMOPS of HouseHolderReduction() in ivas_svd_dec.c() by removing redundant mathematics and using 64 bit additions */ +#define FIX_1766_TCX2ACELP_BWE_ISSUE /* VA : Fix rare BWE issue when switching from TCX to ACELP */ - -#define FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW /* FhG: bit-exact, replace carry and overflow operations by 64-bit operations, MR 1931 */ - -#define NONBE_SVD_OPTIMIZATION /* FhG: reduce WMOPS of HouseHolderReduction() in ivas_svd_dec.c() by removing redundant mathematics and using 64 bit additions.*/ /* #################### Start BASOP porting switches ############################ */ #define FIX_1372_ISAR_POST_REND #define NONBE_FIX_984_OMASA_EXT_OUTPUT /* Nokia: issue #984: complete the OMASA EXT output implementation */ #define USE_NEW_HRTF_BINARY_FILE_FORMAT /* Orange: to activate when decided to change the hrtf binary file format */ #define FIX_WARNING_RENDER_CONFIG /* Orange: fix warning on windows build */ - #define FIX_1052_EXT_OUTPUT /* VA: issue 1052: define EXT decoder output configuration for stereo and MC formats */ #define NONBE_1215_FIX_JBM_MAX_SCALING /* FhG: issue 1215: Fix assert hit in a specific VoIP decoder config. Caused by integer overflow in max scaling calculation. */ - #define NONBE_FIX_991_PARAMBIN_BINARY_HRTF /* Nokia: issue #991: fix using of binary file HRTF in ParamBin (to activate when USE_NEW_HRTF_BINARY_FILE_FORMAT and FIX_777_COMBI_RENDER_CONFIG_FILE are on ) */ #define FIX_1050_EFAP_ALLOC /* FhG: issue 1050: reduction of memory allocated to EFAP handle */ #define NONBE_FIX_1091_PMC_LOW_SIGNAL_BURSTS /* FhG: fix for #1091, fix limit calculation for the regularized inverse of Kx to avoid bursts in very low signals */ - #define NONBE_FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT /* fix 1070 USAN: nullptr-with-offset and Segfaults in 7_1_4 to BINAURAL and BINAURAL_ROOM_REVERB decoding with bitrate switching and head rotation*/ - #define LC3PLUS_LEA_COMPAT_BITRATES_48_6 /* FhG: treat split-rendering 256kbps lc3plus 10ms 0dof bitrate as sentinel value for LEA compatible 48_6 bitrate (124 kbps per channel) */ #define NONBE_FIX_ISM_XOVER_BR /* FhG: issue 1072: select OSBA coding method depending on number of object and bitrate */ #define FIX_1053_REVERB_RECONFIGURATION /* Philips: issue 1053: fix for dynamic switching of acoustic environment */ @@ -124,16 +117,12 @@ #define NONBE_FIX_1174_MCMASA_LBR_LOOP_ERROR /* Nokia: Fix issue 1174 by removing the unnecessary inner loop causing problems. */ #define NONBE_FIX_1052_SBA_EXT_FIX /* VA: SBA external output support fix - do not overwrite "output_config" parameter */ #define NONBE_FIX_1110_STEREO_DTX_BRATE_SWITCHING /* VA: issue 1110: fix encoder crash in the stereo DTX bitrate switching condition */ - #define NONBE_1894_OSBA_SCALING /* FhG: do not scale OSBA inputs by 0.5 any more */ #define NONBE_FIX_1141_OSBA_ROOM_RENDERING /* FhG: Fix for issue 1141: render objects in OSBA decoder with room effect */ #define NONBE_1360_LFE_DELAY /* Dlb: LFE delay alignment when rendering in CLDFB domain*/ - #define NONBE_1229_FIX_ISM1_DPID /* Eri: issue 1229: fix bug causing ISM 1 to use default -dpid instead of the specified one */ #define NONBE_SVD_OPTIMIZATION /* #################### End BASOP porting switches ############################ */ -#define FIX_1766_TCX2ACELP_BWE_ISSUE /* VA : Fix rare BWE issue when switching from TCX to ACELP */ - #endif diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index e5f601fb5..e56a3d54c 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -3563,7 +3563,7 @@ void IMDCT_ivas_fx( { FOR( i = 0; i < sub( overlap, tcx_mdct_window_min_length ); i++ ) { - xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )] = add_sat( xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )], old_out_fx[( i + nz )] ); // Q(-2) + xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )] = add_sat( xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )], old_out_fx[( i + nz )] ); // Q(-2) move16(); } @@ -3576,12 +3576,12 @@ void IMDCT_ivas_fx( // tested FOR( ; i < overlap; i++ ) /* perfectly reconstructing ALDO shortening */ { - xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], old_out_fx[( i + nz )] ); // q_win + xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], old_out_fx[( i + nz )] ); // q_win move16(); } FOR( i = 0; i < ( tcx_mdct_window_min_length / 2 ); i++ ) { - xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )] = add_sat( xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )], mult_r( old_out_fx[( ( i + nz ) + overlap )], tcx_mdct_window_minimum_fx[i].v.re ) ); // q_win + xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )] = add_sat( xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )], mult_r( old_out_fx[( ( i + nz ) + overlap )], tcx_mdct_window_minimum_fx[i].v.re ) ); // q_win move16(); } FOR( ; i < tcx_mdct_window_min_length; i++ ) @@ -3594,12 +3594,12 @@ void IMDCT_ivas_fx( { FOR( ; i < ( overlap - ( tcx_mdct_window_min_length / 2 ) ); i++ ) { - xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( old_out_fx[( i + nz )], tcx_mdct_window_minimum_fx[( ( tcx_mdct_window_min_length - overlap ) + i )].v.re ) ); // Q(-2) + xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( old_out_fx[( i + nz )], tcx_mdct_window_minimum_fx[( ( tcx_mdct_window_min_length - overlap ) + i )].v.re ) ); // Q(-2) move16(); } FOR( ; i < overlap; i++ ) { - xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( old_out_fx[( i + nz )], tcx_mdct_window_minimum_fx[( overlap - ( 1 + i ) )].v.im ) ); // Q(-2) + xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( old_out_fx[( i + nz )], tcx_mdct_window_minimum_fx[( overlap - ( 1 + i ) )].v.im ) ); // Q(-2) move16(); } } @@ -3685,47 +3685,44 @@ void IMDCT_ivas_fx( test(); test(); test(); - IF( ( left_rect != 0 ) && ( frame_cnt == 0 ) && 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 ){ + FOR( i = 0; i < ( tcx_mdct_window_half_length / 2 ); i++ ){ + xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = mult_r( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], tcx_mdct_window_half_fx[i].v.im ); // Q(-2) + xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( mult_r( hTcxDec->syn_OverlFB[i], tcx_mdct_window_half_fx[i].v.re ), tcx_mdct_window_half_fx[i].v.re ) ); // Q(-2) + move16(); + move16(); +} +FOR( ; i < tcx_mdct_window_half_length; i++ ) +{ + xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = mult_r( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], tcx_mdct_window_half_fx[( tcx_mdct_window_half_length - ( 1 + i ) )].v.re ); // Q(-2) + xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( mult_r( hTcxDec->syn_OverlFB[i], tcx_mdct_window_half_fx[( tcx_mdct_window_half_length - ( 1 + i ) )].v.im ), tcx_mdct_window_half_fx[( tcx_mdct_window_half_length - ( 1 + i ) )].v.im ) ); // Q(-2) + move16(); + move16(); +} +} +ELSE +{ + FOR( i = 0; i < ( tcx_mdct_window_half_length / 2 ); i++ ) { - IF( FB_flag != 0 ) - { - FOR( i = 0; i < ( tcx_mdct_window_half_length / 2 ); i++ ) - { - xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = mult_r( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], tcx_mdct_window_half_fx[i].v.im ); // Q(-2) - xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( mult_r( hTcxDec->syn_OverlFB[i], tcx_mdct_window_half_fx[i].v.re ), tcx_mdct_window_half_fx[i].v.re ) ); // Q(-2) - move16(); - move16(); - } - FOR( ; i < tcx_mdct_window_half_length; i++ ) - { - xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = mult_r( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], tcx_mdct_window_half_fx[( tcx_mdct_window_half_length - ( 1 + i ) )].v.re ); // Q(-2) - xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( mult_r( hTcxDec->syn_OverlFB[i], tcx_mdct_window_half_fx[( tcx_mdct_window_half_length - ( 1 + i ) )].v.im ), tcx_mdct_window_half_fx[( tcx_mdct_window_half_length - ( 1 + i ) )].v.im ) ); // Q(-2) - move16(); - move16(); - } - } - ELSE - { - FOR( i = 0; i < ( tcx_mdct_window_half_length / 2 ); i++ ) - { - xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = mult_r( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], tcx_mdct_window_half_fx[i].v.im ); - xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( mult_r( hTcxDec->syn_Overl[i], tcx_mdct_window_half_fx[i].v.re ), tcx_mdct_window_half_fx[i].v.re ) ); // Q(-2) - move16(); - move16(); - } - FOR( ; i < tcx_mdct_window_half_length; i++ ) - { - xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = mult_r( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], tcx_mdct_window_half_fx[( tcx_mdct_window_half_length - ( 1 + i ) )].v.re ); - xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( mult_r( hTcxDec->syn_Overl[i], tcx_mdct_window_half_fx[( tcx_mdct_window_half_length - ( 1 + i ) )].v.im ), tcx_mdct_window_half_fx[( tcx_mdct_window_half_length - ( 1 + i ) )].v.im ) ); // Q(-2) - move16(); - move16(); - } - } + xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = mult_r( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], tcx_mdct_window_half_fx[i].v.im ); + xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( mult_r( hTcxDec->syn_Overl[i], tcx_mdct_window_half_fx[i].v.re ), tcx_mdct_window_half_fx[i].v.re ) ); // Q(-2) + move16(); + move16(); } - *pq_win = q_win; - move16(); + FOR( ; i < tcx_mdct_window_half_length; i++ ) + { + xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = mult_r( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], tcx_mdct_window_half_fx[( tcx_mdct_window_half_length - ( 1 + i ) )].v.re ); + xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( mult_r( hTcxDec->syn_Overl[i], tcx_mdct_window_half_fx[( tcx_mdct_window_half_length - ( 1 + i ) )].v.im ), tcx_mdct_window_half_fx[( tcx_mdct_window_half_length - ( 1 + i ) )].v.im ) ); // Q(-2) + move16(); + move16(); + } +} +} +*pq_win = q_win; +move16(); - return; +return; } void init_tcx_info_fx( @@ -4178,7 +4175,6 @@ void decoder_tcx_ivas_fx( Scale_sig( st->hTcxDec->old_syn_Overl, 320, ( -2 - st->hTcxDec->Q_old_syn_Overl ) ); // Scaling to Q-2 st->hTcxDec->Q_old_syn_Overl = -2; - } /*-------------------------------------------------------------------* diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index 57fe6dc5f..981eac806 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -93,505 +93,505 @@ static void ivas_binRenderer_filterModule_fx( FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { - FOR( k = 0; k < numTimeSlots; k++ ) - { - Word64 outRealLeft_fx = 0, outRealRight_fx = 0, outImagLeft_fx = 0, outImagRight_fx = 0; - move64(); - move64(); - move64(); - move64(); - Word64 outRealLeft = 0, outRealRight = 0, outImagLeft = 0, outImagRight = 0; - move64(); - move64(); - move64(); - move64(); + FOR( k = 0; k < numTimeSlots; k++ ) + { + Word64 outRealLeft_fx = 0, outRealRight_fx = 0, outImagLeft_fx = 0, outImagRight_fx = 0; + move64(); + move64(); + move64(); + move64(); + Word64 outRealLeft = 0, outRealRight = 0, outImagLeft = 0, outImagRight = 0; + move64(); + move64(); + move64(); + move64(); - FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) - { - filterStatesLeftRealPtr_fx = (Word32 *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx][0] ); - filterStatesLeftImagPtr_fx = (Word32 *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx][0] ); + FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) + { + filterStatesLeftRealPtr_fx = (Word32 *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx][0] ); + filterStatesLeftImagPtr_fx = (Word32 *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx][0] ); - filterTapsLeftRealPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx]; // Q29 - filterTapsLeftImagPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx]; // Q29 - filterTapsRightRealPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx]; // Q29 - filterTapsRightImagPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx]; // Q29 + filterTapsLeftRealPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx]; // Q29 + filterTapsLeftImagPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx]; // Q29 + filterTapsRightRealPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx]; // Q29 + filterTapsRightImagPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx]; // Q29 - FOR( tapIdx = hBinRenderer->hBinRenConvModule->numTapsArray[bandIdx] - 1; tapIdx > 0; tapIdx-- ) - { - filterStatesLeftRealPtr_fx[tapIdx] = filterStatesLeftRealPtr_fx[tapIdx - 1]; - move32(); - filterStatesLeftImagPtr_fx[tapIdx] = filterStatesLeftImagPtr_fx[tapIdx - 1]; - move32(); - Word32 neg_filterStatesLeftImagPtr_fx = L_negate( filterStatesLeftImagPtr_fx[tapIdx] ); + FOR( tapIdx = hBinRenderer->hBinRenConvModule->numTapsArray[bandIdx] - 1; tapIdx > 0; tapIdx-- ) + { + filterStatesLeftRealPtr_fx[tapIdx] = filterStatesLeftRealPtr_fx[tapIdx - 1]; + move32(); + filterStatesLeftImagPtr_fx[tapIdx] = filterStatesLeftImagPtr_fx[tapIdx - 1]; + move32(); + Word32 neg_filterStatesLeftImagPtr_fx = L_negate( filterStatesLeftImagPtr_fx[tapIdx] ); - outRealLeft_fx = W_mac_32_32( outRealLeft_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsLeftRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates - outRealLeft_fx = W_mac_32_32( outRealLeft_fx, neg_filterStatesLeftImagPtr_fx, filterTapsLeftImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates + outRealLeft_fx = W_mac_32_32( outRealLeft_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsLeftRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates + outRealLeft_fx = W_mac_32_32( outRealLeft_fx, neg_filterStatesLeftImagPtr_fx, filterTapsLeftImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates - outImagLeft_fx = W_mac_32_32( outImagLeft_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsLeftImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates - outImagLeft_fx = W_mac_32_32( outImagLeft_fx, filterStatesLeftImagPtr_fx[tapIdx], filterTapsLeftRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates + outImagLeft_fx = W_mac_32_32( outImagLeft_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsLeftImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates + outImagLeft_fx = W_mac_32_32( outImagLeft_fx, filterStatesLeftImagPtr_fx[tapIdx], filterTapsLeftRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates - outRealRight_fx = W_mac_32_32( outRealRight_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsRightRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates - outRealRight_fx = W_mac_32_32( outRealRight_fx, neg_filterStatesLeftImagPtr_fx, filterTapsRightImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates + outRealRight_fx = W_mac_32_32( outRealRight_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsRightRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates + outRealRight_fx = W_mac_32_32( outRealRight_fx, neg_filterStatesLeftImagPtr_fx, filterTapsRightImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates - outImagRight_fx = W_mac_32_32( outImagRight_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsRightImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates - outImagRight_fx = W_mac_32_32( outImagRight_fx, filterStatesLeftImagPtr_fx[tapIdx], filterTapsRightRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates - } + outImagRight_fx = W_mac_32_32( outImagRight_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsRightImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates + outImagRight_fx = W_mac_32_32( outImagRight_fx, filterStatesLeftImagPtr_fx[tapIdx], filterTapsRightRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates + } - filterStatesLeftRealPtr_fx[0] = CLDFB_real[chIdx][k][bandIdx]; - move32(); - filterStatesLeftImagPtr_fx[0] = CLDFB_imag[chIdx][k][bandIdx]; - move32(); + filterStatesLeftRealPtr_fx[0] = CLDFB_real[chIdx][k][bandIdx]; + move32(); + filterStatesLeftImagPtr_fx[0] = CLDFB_imag[chIdx][k][bandIdx]; + move32(); - /* Left Real and Imag */ - Word32 neg_temp2 = L_negate( filterStatesLeftImagPtr_fx[0] ); // Q_curr + /* Left Real and Imag */ + Word32 neg_temp2 = L_negate( filterStatesLeftImagPtr_fx[0] ); // Q_curr - outRealLeft = W_mac_32_32( W_mac_32_32( outRealLeft, filterStatesLeftRealPtr_fx[0], filterTapsLeftRealPtr_fx[0] ), neg_temp2, filterTapsLeftImagPtr_fx[0] ); - outImagLeft = W_mac_32_32( W_mac_32_32( outImagLeft, filterStatesLeftImagPtr_fx[0], filterTapsLeftRealPtr_fx[0] ), filterStatesLeftRealPtr_fx[0], filterTapsLeftImagPtr_fx[0] ); + outRealLeft = W_mac_32_32( W_mac_32_32( outRealLeft, filterStatesLeftRealPtr_fx[0], filterTapsLeftRealPtr_fx[0] ), neg_temp2, filterTapsLeftImagPtr_fx[0] ); + outImagLeft = W_mac_32_32( W_mac_32_32( outImagLeft, filterStatesLeftImagPtr_fx[0], filterTapsLeftRealPtr_fx[0] ), filterStatesLeftRealPtr_fx[0], filterTapsLeftImagPtr_fx[0] ); - /* Right Real and Imag */ - outRealRight = W_mac_32_32( W_mac_32_32( outRealRight, neg_temp2, filterTapsRightImagPtr_fx[0] ), filterStatesLeftRealPtr_fx[0], filterTapsRightRealPtr_fx[0] ); - outImagRight = W_mac_32_32( W_mac_32_32( outImagRight, filterStatesLeftImagPtr_fx[0], filterTapsRightRealPtr_fx[0] ), filterStatesLeftRealPtr_fx[0], filterTapsRightImagPtr_fx[0] ); - } - out_Conv_CLDFB_real[0][k][bandIdx] = W_shl_sat_l( W_add( W_shr( outRealLeft_fx, shift_q ), W_shr( outRealLeft, 1 ) ), shift_q6 ); - out_Conv_CLDFB_real[1][k][bandIdx] = W_shl_sat_l( W_add( W_shr( outRealRight_fx, shift_q ), W_shr( outRealRight, 1 ) ), shift_q6 ); - out_Conv_CLDFB_imag[0][k][bandIdx] = W_shl_sat_l( W_add( W_shr( outImagLeft_fx, shift_q ), W_shr( outImagLeft, 1 ) ), shift_q6 ); - out_Conv_CLDFB_imag[1][k][bandIdx] = W_shl_sat_l( W_add( W_shr( outImagRight_fx, shift_q ), W_shr( outImagRight, 1 ) ), shift_q6 ); - move32(); - move32(); - move32(); - move32(); + /* Right Real and Imag */ + outRealRight = W_mac_32_32( W_mac_32_32( outRealRight, neg_temp2, filterTapsRightImagPtr_fx[0] ), filterStatesLeftRealPtr_fx[0], filterTapsRightRealPtr_fx[0] ); + outImagRight = W_mac_32_32( W_mac_32_32( outImagRight, filterStatesLeftImagPtr_fx[0], filterTapsRightRealPtr_fx[0] ), filterStatesLeftRealPtr_fx[0], filterTapsRightImagPtr_fx[0] ); } + out_Conv_CLDFB_real[0][k][bandIdx] = W_shl_sat_l( W_add( W_shr( outRealLeft_fx, shift_q ), W_shr( outRealLeft, 1 ) ), shift_q6 ); + out_Conv_CLDFB_real[1][k][bandIdx] = W_shl_sat_l( W_add( W_shr( outRealRight_fx, shift_q ), W_shr( outRealRight, 1 ) ), shift_q6 ); + out_Conv_CLDFB_imag[0][k][bandIdx] = W_shl_sat_l( W_add( W_shr( outImagLeft_fx, shift_q ), W_shr( outImagLeft, 1 ) ), shift_q6 ); + out_Conv_CLDFB_imag[1][k][bandIdx] = W_shl_sat_l( W_add( W_shr( outImagRight_fx, shift_q ), W_shr( outImagRight, 1 ) ), shift_q6 ); + move32(); + move32(); + move32(); + move32(); } + } - return; - } + return; +} + +/*------------------------------------------------------------------------- + * ivas_binRenderer_convModuleOpen() + * + * Open convolution module handle of fastconv binaural renderer + *-------------------------------------------------------------------------*/ +static ivas_error ivas_binRenderer_convModuleOpen( + BINAURAL_RENDERER_HANDLE hBinRenderer, + const Word16 renderer_type, + const Word16 isLoudspeaker, + const AUDIO_CONFIG input_config, + const HRTFS_FASTCONV_HANDLE hHrtf, + const Word16 num_poses ) +{ + Word16 bandIdx, chIdx; + Word16 pos_idx; + + BINRENDERER_CONV_MODULE_HANDLE_FX hBinRenConvModule; + + /*-----------------------------------------------------------------* + * prepare library opening + *-----------------------------------------------------------------*/ - /*------------------------------------------------------------------------- - * ivas_binRenderer_convModuleOpen() - * - * Open convolution module handle of fastconv binaural renderer - *-------------------------------------------------------------------------*/ - static ivas_error ivas_binRenderer_convModuleOpen( - BINAURAL_RENDERER_HANDLE hBinRenderer, - const Word16 renderer_type, - const Word16 isLoudspeaker, - const AUDIO_CONFIG input_config, - const HRTFS_FASTCONV_HANDLE hHrtf, - const Word16 num_poses ) + IF( ( hBinRenConvModule = (BINRENDERER_CONV_MODULE_HANDLE_FX) malloc( sizeof( BINRENDERER_CONV_MODULE_FX ) ) ) == NULL ) { - Word16 bandIdx, chIdx; - Word16 pos_idx; + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } - BINRENDERER_CONV_MODULE_HANDLE_FX hBinRenConvModule; + IF( !isLoudspeaker ) + { + hBinRenderer->nInChannels = audioCfg2channels( input_config ); + move16(); + } + ELSE + { + /* Note: needs to be revisited if multiple LFE support is required */ + hBinRenderer->nInChannels = sub( audioCfg2channels( input_config ), isLoudspeaker ); + move16(); + } - /*-----------------------------------------------------------------* - * prepare library opening - *-----------------------------------------------------------------*/ + IF( EQ_16( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) + { + hBinRenConvModule->numTaps = BINAURAL_NTAPS_MAX; + move16(); - IF( ( hBinRenConvModule = (BINRENDERER_CONV_MODULE_HANDLE_FX) malloc( sizeof( BINRENDERER_CONV_MODULE_FX ) ) ) == NULL ) + /* Use variable order filtering */ + bandIdx = 0; + move16(); + FOR( ; bandIdx < 5; bandIdx++ ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + hBinRenConvModule->numTapsArray[bandIdx] = hBinRenConvModule->numTaps; + move16(); } - - IF( !isLoudspeaker ) + FOR( ; bandIdx < 10; bandIdx++ ) { - hBinRenderer->nInChannels = audioCfg2channels( input_config ); + hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_6; move16(); } - ELSE + FOR( ; bandIdx < 20; bandIdx++ ) { - /* Note: needs to be revisited if multiple LFE support is required */ - hBinRenderer->nInChannels = sub( audioCfg2channels( input_config ), isLoudspeaker ); + hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_5; move16(); } - - IF( EQ_16( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) + FOR( ; bandIdx < 30; bandIdx++ ) { - hBinRenConvModule->numTaps = BINAURAL_NTAPS_MAX; + hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_4; move16(); - - /* Use variable order filtering */ - bandIdx = 0; + } + FOR( ; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_3; + move16(); + } + } + ELSE + { + IF( EQ_16( hBinRenderer->ivas_format, SBA_FORMAT ) ) + { + hBinRenConvModule->numTaps = BINAURAL_NTAPS_SBA; move16(); - FOR( ; bandIdx < 5; bandIdx++ ) - { - hBinRenConvModule->numTapsArray[bandIdx] = hBinRenConvModule->numTaps; - move16(); - } - FOR( ; bandIdx < 10; bandIdx++ ) - { - hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_6; - move16(); - } - FOR( ; bandIdx < 20; bandIdx++ ) - { - hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_5; - move16(); - } - FOR( ; bandIdx < 30; bandIdx++ ) - { - hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_4; - move16(); - } - FOR( ; bandIdx < hBinRenderer->conv_band; bandIdx++ ) - { - hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_3; - move16(); - } } ELSE { - IF( EQ_16( hBinRenderer->ivas_format, SBA_FORMAT ) ) - { - hBinRenConvModule->numTaps = BINAURAL_NTAPS_SBA; - move16(); - } - ELSE - { - hBinRenConvModule->numTaps = BINAURAL_NTAPS; - move16(); - } - - /* Use fixed order filtering */ - bandIdx = 0; + hBinRenConvModule->numTaps = BINAURAL_NTAPS; move16(); - FOR( ; bandIdx < hBinRenderer->conv_band; bandIdx++ ) - { - hBinRenConvModule->numTapsArray[bandIdx] = hBinRenConvModule->numTaps; - move16(); - } } - /* allocate memory for filter states */ - IF( ( hBinRenConvModule->filterTapsLeftReal_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) + /* Use fixed order filtering */ + bandIdx = 0; + move16(); + FOR( ; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + hBinRenConvModule->numTapsArray[bandIdx] = hBinRenConvModule->numTaps; + move16(); } + } + + /* allocate memory for filter states */ + IF( ( hBinRenConvModule->filterTapsLeftReal_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } - IF( ( hBinRenConvModule->filterTapsLeftImag_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) + IF( ( hBinRenConvModule->filterTapsLeftImag_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } + + IF( ( hBinRenConvModule->filterTapsRightReal_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } + + IF( ( hBinRenConvModule->filterTapsRightImag_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } + + FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + IF( ( hBinRenConvModule->filterTapsLeftReal_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - IF( ( hBinRenConvModule->filterTapsRightReal_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) + IF( ( hBinRenConvModule->filterTapsLeftImag_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - IF( ( hBinRenConvModule->filterTapsRightImag_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) + IF( ( hBinRenConvModule->filterTapsRightReal_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + IF( ( hBinRenConvModule->filterTapsRightImag_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) { - IF( ( hBinRenConvModule->filterTapsLeftReal_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } + } - IF( ( hBinRenConvModule->filterTapsLeftImag_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } + IF( ( hBinRenConvModule->filterStatesLeftReal_fx = (Word32 ****) malloc( num_poses * sizeof( Word32 *** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } - IF( ( hBinRenConvModule->filterTapsRightReal_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } + IF( ( hBinRenConvModule->filterStatesLeftImag_fx = (Word32 ****) malloc( num_poses * sizeof( Word32 *** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } - IF( ( hBinRenConvModule->filterTapsRightImag_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } - } + IF( ( hBinRenConvModule->Q_filterStates = (Word16 *) malloc( num_poses * sizeof( Word16 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } - IF( ( hBinRenConvModule->filterStatesLeftReal_fx = (Word32 ****) malloc( num_poses * sizeof( Word32 *** ) ) ) == NULL ) + FOR( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) + { + IF( ( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx] = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - IF( ( hBinRenConvModule->filterStatesLeftImag_fx = (Word32 ****) malloc( num_poses * sizeof( Word32 *** ) ) ) == NULL ) + IF( ( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx] = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - IF( ( hBinRenConvModule->Q_filterStates = (Word16 *) malloc( num_poses * sizeof( Word16 ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } - FOR( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) + FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { - IF( ( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx] = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) + IF( ( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - IF( ( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx] = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) + IF( ( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) { - IF( ( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + IF( ( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx] = (Word32 *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - IF( ( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + IF( ( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx] = (Word32 *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } + } + } + } + /* set memories */ + FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) + { + Word16 tmp = 0; + move16(); - FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) + IF( isLoudspeaker ) + { + IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_5_1 ) ) { - IF( ( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx] = (Word32 *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( Word32 ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } - - IF( ( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx] = (Word32 *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( Word32 ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } + tmp = channelIndex_CICP6[chIdx]; + move16(); + } + ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_7_1 ) ) + { + tmp = channelIndex_CICP12[chIdx]; + move16(); + } + ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_5_1_2 ) ) + { + tmp = channelIndex_CICP14[chIdx]; + move16(); + } + ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_5_1_4 ) ) + { + tmp = channelIndex_CICP16[chIdx]; + move16(); + } + ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_7_1_4 ) ) + { + tmp = channelIndex_CICP19[chIdx]; + move16(); } } - } - /* set memories */ - FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) - { - FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) + IF( EQ_16( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { - Word16 tmp = 0; - move16(); - + /* set the memories to zero */ IF( isLoudspeaker ) { - IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_5_1 ) ) - { - tmp = channelIndex_CICP6[chIdx]; - move16(); - } - ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_7_1 ) ) - { - tmp = channelIndex_CICP12[chIdx]; - move16(); - } - ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_5_1_2 ) ) - { - tmp = channelIndex_CICP14[chIdx]; - move16(); - } - ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_5_1_4 ) ) - { - tmp = channelIndex_CICP16[chIdx]; - move16(); - } - ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_7_1_4 ) ) - { - tmp = channelIndex_CICP19[chIdx]; - move16(); - } + hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftBRIRReal_fx[bandIdx][tmp]; + hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftBRIRImag_fx[bandIdx][tmp]; + hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightBRIRReal_fx[bandIdx][tmp]; + hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightBRIRImag_fx[bandIdx][tmp]; } - - IF( EQ_16( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) + } + ELSE + { + /* set the memories to zero */ + IF( isLoudspeaker ) { - /* set the memories to zero */ - IF( isLoudspeaker ) - { - hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftBRIRReal_fx[bandIdx][tmp]; - hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftBRIRImag_fx[bandIdx][tmp]; - hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightBRIRReal_fx[bandIdx][tmp]; - hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightBRIRImag_fx[bandIdx][tmp]; - } + hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_fx[bandIdx][tmp]; + hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_fx[bandIdx][tmp]; + hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_fx[bandIdx][tmp]; + hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_fx[bandIdx][tmp]; } ELSE { - /* set the memories to zero */ - IF( isLoudspeaker ) + IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_HOA3 ) ) + { + /* HOA3 filter coefficients */ + hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_HOA3_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_HOA3_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_HOA3_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_HOA3_fx[bandIdx][chIdx]; + } + ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_HOA2 ) ) { - hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_fx[bandIdx][tmp]; - hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_fx[bandIdx][tmp]; - hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_fx[bandIdx][tmp]; - hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_fx[bandIdx][tmp]; + /* HOA2 filter coefficients */ + hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_HOA2_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_HOA2_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_HOA2_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_HOA2_fx[bandIdx][chIdx]; + } + ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_FOA ) ) + { + /* FOA filter coefficients */ + hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_FOA_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_FOA_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_FOA_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_FOA_fx[bandIdx][chIdx]; } ELSE { - IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_HOA3 ) ) - { - /* HOA3 filter coefficients */ - hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_HOA3_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_HOA3_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_HOA3_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_HOA3_fx[bandIdx][chIdx]; - } - ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_HOA2 ) ) - { - /* HOA2 filter coefficients */ - hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_HOA2_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_HOA2_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_HOA2_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_HOA2_fx[bandIdx][chIdx]; - } - ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_FOA ) ) - { - /* FOA filter coefficients */ - hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_FOA_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_FOA_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_FOA_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_FOA_fx[bandIdx][chIdx]; - } - ELSE - { - return IVAS_ERR_INVALID_INPUT_FORMAT; - } + return IVAS_ERR_INVALID_INPUT_FORMAT; } } } } + } - IF( EQ_16( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) + IF( EQ_16( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) + { + FOR( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) { - FOR( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) + hBinRenConvModule->Q_filterStates[pos_idx] = 31; + move16(); + FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { - hBinRenConvModule->Q_filterStates[pos_idx] = 31; - move16(); - FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) { - FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) - { - /* set the memories to zero */ - set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); - set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); - } + /* set the memories to zero */ + set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); + set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); } } } - ELSE + } + ELSE + { + FOR( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) { - FOR( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) + hBinRenConvModule->Q_filterStates[pos_idx] = 31; + move16(); + FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { - hBinRenConvModule->Q_filterStates[pos_idx] = 31; - move16(); - FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) { - FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) - { - /* set the memories to zero */ - set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); - set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); - } + /* set the memories to zero */ + set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); + set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); } } } - - hBinRenderer->hBinRenConvModule = hBinRenConvModule; - - return IVAS_ERR_OK; } - /*-------------------------------------------------------------------------* - * ivas_init_binaural_hrtf() - * - * initialize memory for HrtfFastConv structure elements - *-------------------------------------------------------------------------*/ - void ivas_init_binaural_hrtf_fx( - HRTFS_FASTCONV * HrtfFastConv /* i/o: FASTCONV HRTF structure */ - ) - { - Word16 i; + hBinRenderer->hBinRenConvModule = hBinRenConvModule; - HrtfFastConv->leftHRIRReal_HOA3_fx = NULL; - HrtfFastConv->leftHRIRImag_HOA3_fx = NULL; - HrtfFastConv->rightHRIRReal_HOA3_fx = NULL; - HrtfFastConv->rightHRIRImag_HOA3_fx = NULL; - HrtfFastConv->FASTCONV_HOA3_latency_s_fx = 0; - move32(); + return IVAS_ERR_OK; +} - HrtfFastConv->leftHRIRReal_fx = NULL; - HrtfFastConv->leftHRIRImag_fx = NULL; - HrtfFastConv->rightHRIRReal_fx = NULL; - HrtfFastConv->rightHRIRImag_fx = NULL; - HrtfFastConv->FASTCONV_HRIR_latency_s_fx = 0; - move32(); +/*-------------------------------------------------------------------------* + * ivas_init_binaural_hrtf() + * + * initialize memory for HrtfFastConv structure elements + *-------------------------------------------------------------------------*/ +void ivas_init_binaural_hrtf_fx( + HRTFS_FASTCONV *HrtfFastConv /* i/o: FASTCONV HRTF structure */ +) +{ + Word16 i; - HrtfFastConv->leftBRIRReal_fx = NULL; - HrtfFastConv->leftBRIRImag_fx = NULL; - HrtfFastConv->rightBRIRReal_fx = NULL; - HrtfFastConv->rightBRIRImag_fx = NULL; - HrtfFastConv->FASTCONV_BRIR_latency_s_fx = 0; - move32(); + HrtfFastConv->leftHRIRReal_HOA3_fx = NULL; + HrtfFastConv->leftHRIRImag_HOA3_fx = NULL; + HrtfFastConv->rightHRIRReal_HOA3_fx = NULL; + HrtfFastConv->rightHRIRImag_HOA3_fx = NULL; + HrtfFastConv->FASTCONV_HOA3_latency_s_fx = 0; + move32(); - HrtfFastConv->leftHRIRReal_HOA2_fx = NULL; - HrtfFastConv->leftHRIRImag_HOA2_fx = NULL; - HrtfFastConv->rightHRIRReal_HOA2_fx = NULL; - HrtfFastConv->rightHRIRImag_HOA2_fx = NULL; - HrtfFastConv->FASTCONV_HOA2_latency_s_fx = 0; - move32(); + HrtfFastConv->leftHRIRReal_fx = NULL; + HrtfFastConv->leftHRIRImag_fx = NULL; + HrtfFastConv->rightHRIRReal_fx = NULL; + HrtfFastConv->rightHRIRImag_fx = NULL; + HrtfFastConv->FASTCONV_HRIR_latency_s_fx = 0; + move32(); - HrtfFastConv->leftHRIRReal_FOA_fx = NULL; - HrtfFastConv->leftHRIRImag_FOA_fx = NULL; - HrtfFastConv->rightHRIRReal_FOA_fx = NULL; - HrtfFastConv->rightHRIRImag_FOA_fx = NULL; - HrtfFastConv->FASTCONV_FOA_latency_s_fx = 0; - move32(); + HrtfFastConv->leftBRIRReal_fx = NULL; + HrtfFastConv->leftBRIRImag_fx = NULL; + HrtfFastConv->rightBRIRReal_fx = NULL; + HrtfFastConv->rightBRIRImag_fx = NULL; + HrtfFastConv->FASTCONV_BRIR_latency_s_fx = 0; + move32(); - HrtfFastConv->allocate_init_flag = 0; - move16(); + HrtfFastConv->leftHRIRReal_HOA2_fx = NULL; + HrtfFastConv->leftHRIRImag_HOA2_fx = NULL; + HrtfFastConv->rightHRIRReal_HOA2_fx = NULL; + HrtfFastConv->rightHRIRImag_HOA2_fx = NULL; + HrtfFastConv->FASTCONV_HOA2_latency_s_fx = 0; + move32(); - FOR( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) - { - HrtfFastConv->fastconvReverberationTimes_fx[i] = 0; - move32(); - HrtfFastConv->fastconvReverberationEneCorrections_fx[i] = 0; - move32(); - } + HrtfFastConv->leftHRIRReal_FOA_fx = NULL; + HrtfFastConv->leftHRIRImag_FOA_fx = NULL; + HrtfFastConv->rightHRIRReal_FOA_fx = NULL; + HrtfFastConv->rightHRIRImag_FOA_fx = NULL; + HrtfFastConv->FASTCONV_FOA_latency_s_fx = 0; + move32(); - return; - } + HrtfFastConv->allocate_init_flag = 0; + move16(); - /*-------------------------------------------------------------------------* - * ivas_alloc_pppMem() - * - * Allocate memory for tripple pointer elements - *-------------------------------------------------------------------------*/ - static ivas_error ivas_alloc_pppMem_fx( - Word32 * ***pppMem, /*Qx*/ - const Word16 dim1, - const Word16 dim2, - const Word16 dim3, - const Word16 allocate_init_flag ) + FOR( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) { - Word16 i, j; - Word32 ***localMem = NULL; + HrtfFastConv->fastconvReverberationTimes_fx[i] = 0; + move32(); + HrtfFastConv->fastconvReverberationEneCorrections_fx[i] = 0; + move32(); + } - IF( ( localMem = (Word32 ***) malloc( dim1 * sizeof( Word32 ** ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF memory" ); - } + return; +} - FOR( i = 0; i < dim1; i++ ){ - IF( ( localMem[i] = (Word32 **) malloc( dim2 * sizeof( Word32 * ) ) ) == NULL ){ - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF memory" ); +/*-------------------------------------------------------------------------* + * ivas_alloc_pppMem() + * + * Allocate memory for tripple pointer elements + *-------------------------------------------------------------------------*/ +static ivas_error ivas_alloc_pppMem_fx( + Word32 ****pppMem, /*Qx*/ + const Word16 dim1, + const Word16 dim2, + const Word16 dim3, + const Word16 allocate_init_flag ) +{ + Word16 i, j; + Word32 ***localMem = NULL; + + IF( ( localMem = (Word32 ***) malloc( dim1 * sizeof( Word32 ** ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF memory" ); } - IF( allocate_init_flag == 0 ) + + FOR( i = 0; i < dim1; i++ ){ + IF( ( localMem[i] = (Word32 **) malloc( dim2 * sizeof( Word32 * ) ) ) == NULL ){ + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF memory" ); +} +IF( allocate_init_flag == 0 ) +{ + FOR( j = 0; j < dim2; j++ ) { - FOR( j = 0; j < dim2; j++ ) + IF( ( localMem[i][j] = (Word32 *) malloc( dim3 * sizeof( Word32 ) ) ) == NULL ) { - IF( ( localMem[i][j] = (Word32 *) malloc( dim3 * sizeof( Word32 ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF memory" ); - } + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF memory" ); } } } +} *pppMem = localMem; @@ -1350,10 +1350,9 @@ ivas_error ivas_binRenderer_open_fx( /* Allocate memories needed for reverb module */ test(); - IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) && EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) ) - { - IF( NE_32( ( error = ivas_binaural_reverb_init( &( hBinRenderer->hReverb ), st_ivas->hHrtfStatistics, hBinRenderer->conv_band, hBinRenderer->timeSlots, &( st_ivas->hRenderConfig->roomAcoustics ), st_ivas->hDecoderConfig->output_Fs, st_ivas->hHrtfFastConv->fastconvReverberationTimes_fx, st_ivas->hHrtfFastConv->fastconvReverberationEneCorrections_fx ) ), IVAS_ERR_OK ) ){ - return error; + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) && EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) ){ + IF( NE_32( ( error = ivas_binaural_reverb_init( &( hBinRenderer->hReverb ), st_ivas->hHrtfStatistics, hBinRenderer->conv_band, hBinRenderer->timeSlots, &( st_ivas->hRenderConfig->roomAcoustics ), st_ivas->hDecoderConfig->output_Fs, st_ivas->hHrtfFastConv->fastconvReverberationTimes_fx, st_ivas->hHrtfFastConv->fastconvReverberationEneCorrections_fx ) ), IVAS_ERR_OK ) ){ + return error; } /* initialize the dmx matrix */ diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 1e190083d..c75cba971 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -60,7 +60,7 @@ struct IVAS_DEC_VOIP UWord16 lastDecodedWasActive; JB4_DATAUNIT_HANDLE hCurrentDataUnit; /* Points to the currently processed data unit */ UWord16 *bs_conversion_buf; /* Buffer for bitstream conversion from packed to serial */ - Word16 nSamplesRendered20ms; /* how many samples have been rendered since the last 20ms render border*/ + Word16 nSamplesRendered20ms; /* how many samples have been rendered since the last 20ms render border*/ #ifdef SUPPORT_JBM_TRACEFILE IVAS_JBM_TRACE_DATA JbmTraceData; #endif @@ -82,7 +82,7 @@ struct IVAS_DEC bool Opt_VOIP; /* flag indicating VOIP mode with JBM */ Word16 tsm_scale; /* scale for TSM operation */ Word16 tsm_max_scaling; - Word16 timeScalingDone; /* have we done already one TSM in a 20ms frame? */ + Word16 timeScalingDone; /* have we done already one TSM in a 20ms frame? */ Word16 tsm_quality; /*Q14*/ Word32 *apaExecBuffer_fx; /* Buffer for APA scaling */ PCMDSP_APA_HANDLE hTimeScaler; diff --git a/lib_enc/analy_sp_fx.c b/lib_enc/analy_sp_fx.c index ef51e01d7..5f8137368 100644 --- a/lib_enc/analy_sp_fx.c +++ b/lib_enc/analy_sp_fx.c @@ -749,7 +749,7 @@ static void ivas_find_enr( freq = BIN_FREQ_FX; move16(); - tmp_shift = sub( -Q16, shift ); // 16 - shift - 32 + tmp_shift = sub( -Q16, shift ); // 16 - shift - 32 FOR( i = 0; i < voic_band; i++ ) /* up to maximum allowed voiced critical band */ { band_ener = 0; diff --git a/lib_enc/find_tilt_fx.c b/lib_enc/find_tilt_fx.c index 7d47349ad..c5fb6d2e1 100644 --- a/lib_enc/find_tilt_fx.c +++ b/lib_enc/find_tilt_fx.c @@ -361,9 +361,9 @@ void find_tilt_ivas_fx( FOR( i = 0; i < 2; i++ ) { - /*hp_E[i] = 0.5f * (hf_bands[max_band-1] + hf_bands[max_band]) - hp_bckr; */ /* averaged E in last 2 critical bands */ + /*hp_E[i] = 0.5f * (hf_bands[max_band-1] + hf_bands[max_band]) - hp_bckr; */ /* averaged E in last 2 critical bands */ Ltmp = W_extract_h( W_shl( W_add( W_deposit32_l( hf_bands[max_band - 1] ), W_deposit32_l( hf_bands[max_band] ) ), 31 ) ); // q_fr_bands - Ltmp = L_sub( Ltmp, hp_bckr ); // q_fr_bands + Ltmp = L_sub( Ltmp, hp_bckr ); // q_fr_bands Ltmp2 = L_max( Ltmp, L_shl_sat( 1, q_fr_bands ) ); // q_fr_bands, saturation is added because q_fr_bands is limited to 31 if ( Opt_vbr_mode == 0 ) diff --git a/lib_enc/hvq_enc_fx.c b/lib_enc/hvq_enc_fx.c index 993c9e4a2..55dbe0bf4 100644 --- a/lib_enc/hvq_enc_fx.c +++ b/lib_enc/hvq_enc_fx.c @@ -145,7 +145,7 @@ Word16 hvq_enc_ivas_fx( /*o : Consumed bits acc = L_mult( tmp16, HVQ_NFPE_FACTOR_CUBE_FX ); /* in Q(12+6+1) = Q19 */ expNfpe3 = extract_l( L_mult0( expNfpe, 3 ) ); /* Cube operation */ /* Number of bits required to adjust to Q15 */ - adjust = add( 19 - ( 15 + 16 ), expNfpe3 ); /* +16 is due to the following extract_h(). */ + adjust = add( 19 - ( 15 + 16 ), expNfpe3 ); /* +16 is due to the following extract_h(). */ noise_level[i] = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ move16(); q_noise_level_idx[i] = quant_lc_fx( noise_level[i], &q_noise_level[i] ); @@ -176,9 +176,9 @@ Word16 hvq_enc_ivas_fx( /*o : Consumed bits acc = L_mult( tmp16, HVQ_LB_NFPE_FACTOR_CUBE_FX ); /* in Q(12+9+1) = Q22 */ expo3 = extract_l( L_mult0( expo, 3 ) ); /* Cube operation. */ /* Number of bits required to adjust to Q15 */ - adjust = add( 22 - ( 15 + 16 ), expo3 ); /* +16 is due to the following extract_h(). */ + adjust = add( 22 - ( 15 + 16 ), expo3 ); /* +16 is due to the following extract_h(). */ lb_nfpe = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ - IF( GT_16( lb_nfpe, 16384 ) ) /* in Q15 */ + IF( GT_16( lb_nfpe, 16384 ) ) /* in Q15 */ { lb_nfpe = 16384; move16(); @@ -326,7 +326,7 @@ Word16 hvq_enc_fx( /*o : Consumed bits acc = L_mult( tmp16, HVQ_NFPE_FACTOR_CUBE_FX ); /* in Q(12+6+1) = Q19 */ expNfpe3 = extract_l( L_mult0( expNfpe, 3 ) ); /* Cube operation */ /* Number of bits required to adjust to Q15 */ - adjust = add( 19 - ( 15 + 16 ), expNfpe3 ); /* +16 is due to the following extract_h(). */ + adjust = add( 19 - ( 15 + 16 ), expNfpe3 ); /* +16 is due to the following extract_h(). */ noise_level[i] = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ move16(); q_noise_level_idx[i] = quant_lc_fx( noise_level[i], &q_noise_level[i] ); @@ -357,9 +357,9 @@ Word16 hvq_enc_fx( /*o : Consumed bits acc = L_mult( tmp16, HVQ_LB_NFPE_FACTOR_CUBE_FX ); /* in Q(12+9+1) = Q22 */ expo3 = extract_l( L_mult0( expo, 3 ) ); /* Cube operation. */ /* Number of bits required to adjust to Q15 */ - adjust = add( 22 - ( 15 + 16 ), expo3 ); /* +16 is due to the following extract_h(). */ + adjust = add( 22 - ( 15 + 16 ), expo3 ); /* +16 is due to the following extract_h(). */ lb_nfpe = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ - IF( lb_nfpe > 16384 ) /* in Q15 */ + IF( lb_nfpe > 16384 ) /* in Q15 */ { lb_nfpe = 16384; move16(); diff --git a/lib_enc/nois_est_fx.c b/lib_enc/nois_est_fx.c index d37275b2d..99bd4d86b 100644 --- a/lib_enc/nois_est_fx.c +++ b/lib_enc/nois_est_fx.c @@ -2556,7 +2556,7 @@ void noise_est_ivas_fx( #ifdef ISSUE_1796_replace_shl_o noise_chartmp = shl_sat( num, sub( sub( exp, exp2 ), 4 ) ); // 15+exp2-exp1 -> Q11 #else - noise_chartmp = shl_o( num, sub( sub( exp, exp2 ), 4 ), &Overflow ); // 15+exp2-exp1 -> Q11 + noise_chartmp = shl_o( num, sub( sub( exp, exp2 ), 4 ), &Overflow ); // 15+exp2-exp1 -> Q11 #endif } @@ -2685,8 +2685,8 @@ void noise_est_ivas_fx( ExpDen = norm_l( Lden ); den = extract_h( L_shl( Lden, ExpDen ) ); // q_enr+ExpDen-16 - num = div_s( num, den ); // 15+ExpNum-ExpDen - Ltmp1 = Mult_32_16( non_sta, num ); // 15+ExpNum-ExpDen+10-15 + num = div_s( num, den ); // 15+ExpNum-ExpDen + Ltmp1 = Mult_32_16( non_sta, num ); // 15+ExpNum-ExpDen+10-15 non_sta = L_shr_sat( Ltmp1, sub( ExpNum, ExpDen ) ); /* Q10 */ } @@ -2724,8 +2724,8 @@ void noise_est_ivas_fx( ExpDen = norm_l( Lden ); den = extract_h( L_shl( Lden, ExpDen ) ); // q_enr+ExpDen-16 - num = div_s( num, den ); // 15+ExpNum-ExpDen - Ltmp1 = Mult_32_16( Lnon_sta2, num ); // 15+ExpNum-ExpDen+10-15 + num = div_s( num, den ); // 15+ExpNum-ExpDen + Ltmp1 = Mult_32_16( Lnon_sta2, num ); // 15+ExpNum-ExpDen+10-15 Lnon_sta2 = L_shr_sat( Ltmp1, sub( ExpNum, ExpDen ) ); /* Q10 */ } diff --git a/lib_enc/pvq_encode_fx.c b/lib_enc/pvq_encode_fx.c index 4ea362588..e98906704 100644 --- a/lib_enc/pvq_encode_fx.c +++ b/lib_enc/pvq_encode_fx.c @@ -359,8 +359,8 @@ void pvq_encode_ivas_fx( } Mpy_32_16_ss( L_isqrt, tmp, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) +1 */ Mpy_32_16_ss( L_tmp, neg_gain_norm, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) *Q15 +1 */ - L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ - xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15, array move */ + L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ + xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15, array move */ move16(); L_xq[i] = L_tmp; /* Q31 currently unused */ move32(); @@ -567,8 +567,8 @@ void pvq_encode_fx( } Mpy_32_16_ss( L_isqrt, tmp, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) +1 */ Mpy_32_16_ss( L_tmp, neg_gain_norm, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) *Q15 +1 */ - L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ - xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15, array move */ + L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ + xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15, array move */ move16(); L_xq[i] = L_tmp; /* Q31 currently unused */ move32(); diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 9aa30cd5a..f243cd27c 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -7470,7 +7470,7 @@ void fb_tbe_enc_fx( { tmp = div_s( tmp2, tmp ); L_tmp = L_deposit_h( tmp ); - L_tmp = Isqrt_lc( L_tmp, &exp ); /*Q(31-exp)*/ + L_tmp = Isqrt_lc( L_tmp, &exp ); /*Q(31-exp)*/ L_tmp = L_max( L_shr_sat( L_tmp, sub( 31, exp ) ), 0x1 ); /* Q0 */ } ELSE diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index 12e482b0f..c70865a81 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -1043,7 +1043,7 @@ Word16 wb_vad_fx( #ifdef ISSUE_1796_replace_shl_o tmp = shl_sat( snr, 5 ); /* Q8 -> Q13 */ #else - tmp = shl_o( snr, 5, &Overflow ); /* Q8 -> Q13 */ + tmp = shl_o( snr, 5, &Overflow ); /* Q8 -> Q13 */ #endif IF( LT_16( i, 2 ) ) { diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 327160b3c..90cf37e88 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -515,7 +515,7 @@ ivas_error ivas_dirac_dec_binaural_copy_hrtfs_fx( Copy( hrtfShCoeffsIm_fx[i][j], hrtfParambin->hrtfShCoeffsIm_fx[i][j], HRTF_NUM_BINS ); /*Q14*/ } } - Copy32( parametricReverberationTimes_fx, hrtfParambin->parametricReverberationTimes_fx, CLDFB_NO_CHANNELS_MAX ); /*Q26*/ + Copy32( parametricReverberationTimes_fx, hrtfParambin->parametricReverberationTimes_fx, CLDFB_NO_CHANNELS_MAX ); /*Q26*/ Copy32( parametricReverberationEneCorrections_fx, hrtfParambin->parametricReverberationEneCorrections_fx, CLDFB_NO_CHANNELS_MAX ); /*Q31*/ Copy32( parametricEarlyPartEneCorrection_fx, hrtfParambin->parametricEarlyPartEneCorrection_fx, CLDFB_NO_CHANNELS_MAX ); /*Q28*/ *hHrtfParambin = hrtfParambin; diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index 6b742ec45..31141a1ef 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -221,8 +221,8 @@ static void ivas_binaural_reverb_setPreDelay_fx( static void ivas_binaural_reverb_setReverbTimes_fx( REVERB_STRUCT_HANDLE hReverb, /* i/o: binaural reverb handle */ const Word32 output_Fs, /* i : sampling_rate */ - const Word32 *revTimes_fx, /*Q26 i : reverberation times T60 for each CLDFB bin in seconds */ - const Word32 *revEnes_fx /*Q31 i : spectrum for reverberated sound at each CLDFB bin */ + const Word32 *revTimes_fx, /*Q26 i : reverberation times T60 for each CLDFB bin in seconds */ + const Word32 *revEnes_fx /*Q31 i : spectrum for reverberated sound at each CLDFB bin */ ) { Word16 bin, ch, tap, sample; @@ -326,7 +326,7 @@ static void ivas_binaural_reverb_setReverbTimes_fx( /* Determine attenuation factor that generates the appropriate energy decay according to reverberation time */ L_tmp = Mpy_32_32( 1677721600, revTimes_fx[bin] ); // e10 --> 800 * 2^21, + e0 tmp = BASOP_Util_Divide3232_Scale( 1073741824, L_tmp, &scale ); - scale = add( scale, sub( 1, 15 ) ); // revTimes_fx in Q26 + scale = add( scale, sub( 1, 15 ) ); // revTimes_fx in Q26 L_tmp = Mpy_32_16_1( -1610612736, tmp ); // * -3 scale = add( 2, scale ); L_tmp = Mpy_32_32( 1783446563, L_tmp ); // scale + 2 @@ -2381,9 +2381,9 @@ static ivas_error ivas_binaural_reverb_open_fx( const Word16 numBins, /* i : Q0 number of CLDFB bins */ const Word16 numCldfbSlotsPerFrame, /* i : Q0 number of CLDFB slots per frame */ const Word32 sampling_rate, /* i : Q0 sampling rate */ - const Word32 *revTimes_fx, /* i : Q26 reverberation times T60 for each CLDFB bin in seconds */ - const Word32 *revEnes_fx, /* i : Q31 spectrum for reverberated sound at each CLDFB bin */ - const Word16 preDelay /* i : Q0 reverb pre-delay in CLDFB slots */ + const Word32 *revTimes_fx, /* i : Q26 reverberation times T60 for each CLDFB bin in seconds */ + const Word32 *revEnes_fx, /* i : Q31 spectrum for reverberated sound at each CLDFB bin */ + const Word16 preDelay /* i : Q0 reverb pre-delay in CLDFB slots */ ) { Word16 bin, chIdx, k, len, scale, tmp; diff --git a/lib_rend/ivas_reverb_utils_fx.c b/lib_rend/ivas_reverb_utils_fx.c index b8f923b46..c20e0b670 100644 --- a/lib_rend/ivas_reverb_utils_fx.c +++ b/lib_rend/ivas_reverb_utils_fx.c @@ -170,7 +170,6 @@ static void ivas_reverb_set_energies( } - ivas_reverb_interpolate_energies_fx( avg_pwr_len, input_fc_fx, avg_pwr_l, avg_pwr_r, CLDFB_NO_CHANNELS_MAX, output_fc_fx, avg_pwr_left_fx, avg_pwr_right_fx, avg_pwr_left_e, avg_pwr_right_e ); @@ -179,5 +178,4 @@ static void ivas_reverb_set_energies( avg_pwr_left[i] = (float) fabs( me2f( avg_pwr_left_fx[i], avg_pwr_left_e[i] ) ); avg_pwr_right[i] = (float) fabs( me2f( avg_pwr_right_fx[i], avg_pwr_right_e[i] ) ); } - } diff --git a/lib_rend/ivas_rom_binauralRenderer.h b/lib_rend/ivas_rom_binauralRenderer.h index aee54e983..b9c4054ae 100644 --- a/lib_rend/ivas_rom_binauralRenderer.h +++ b/lib_rend/ivas_rom_binauralRenderer.h @@ -72,12 +72,12 @@ extern Word32 rightBRIRReal_fx[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NT extern Word32 rightBRIRImag_fx[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NTAPS_MAX]; /* Q29 */ /* Reverberation parameters based on BRIRs for fastconv */ -extern Word32 fastconvReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q26 */ +extern Word32 fastconvReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q26 */ extern Word32 fastconvReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ /* Binaural rendering data set based on BRIRs, to be used in a combined manner * with the above binaural rendering data set based on HRIRs for parametric * renderer */ -extern const Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q26 */ +extern const Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q26 */ extern const Word32 parametricReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ extern const Word32 parametricEarlyPartEneCorrection_fx[CLDFB_NO_CHANNELS_MAX]; /* Q28 */ diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 46841487f..e55ccdb6a 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -599,7 +599,7 @@ typedef struct ivas_hrtfs_parambin_struct Word16 hrtfShCoeffsRe_fx[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS]; /* Q14 */ Word16 hrtfShCoeffsIm_fx[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS]; /* Q14 */ - Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q26 */ + Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q26 */ Word32 parametricReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ Word32 parametricEarlyPartEneCorrection_fx[CLDFB_NO_CHANNELS_MAX]; /* Q28 */ @@ -709,7 +709,7 @@ typedef struct EFAP_VERTEX #ifdef FIX_1050_EFAP_ALLOC bool isNaN; /* used to indicate if the vertex is a virtual speaker */ #else - Word16 isNaN; /* used to indicate if the vertex is a virtual speaker */ + Word16 isNaN; /* used to indicate if the vertex is a virtual speaker */ #endif EFAP_VTX_DMX_TYPE dmxType; /* virtual speaker downmix type */ @@ -728,7 +728,7 @@ typedef struct EFAP_POLYSET #ifdef FIX_1050_EFAP_ALLOC bool isNaN[EFAP_MAX_CHAN_NUM]; /* Indicates if one of the vertices isNaN */ #else - Word16 isNaN[EFAP_MAX_CHAN_NUM]; /* Indicates if one of the vertices isNaN */ + Word16 isNaN[EFAP_MAX_CHAN_NUM]; /* Indicates if one of the vertices isNaN */ #endif Word16 numChan; /* An integer between 0 and EFAP_MAX_CHAN_NUM corresponding to the number of vertices of the polygon */ Word32 polyAzi[EFAP_MAX_CHAN_NUM]; /* An array (same length as "chan"), with the azimuth of the channels */ /* Q22 */ @@ -746,13 +746,13 @@ typedef struct EFAP_POLYSET_DATA #ifdef FIX_1050_EFAP_ALLOC EFAP_POLYSET *polysetArray; /* Array of polygons */ #else - EFAP_POLYSET polysetArray[EFAP_MAX_POLY_SET]; /* Array of polygons */ + EFAP_POLYSET polysetArray[EFAP_MAX_POLY_SET]; /* Array of polygons */ #endif Word16 numPoly; /* Number of polygons */ #ifdef FIX_1050_EFAP_ALLOC EFAP_LS_TRIANGLE *triArray; /* Array of triangles */ #else - EFAP_LS_TRIANGLE triArray[EFAP_MAX_POLY_SET]; /* Array of triangles */ + EFAP_LS_TRIANGLE triArray[EFAP_MAX_POLY_SET]; /* Array of triangles */ #endif Word16 numTri; /* Number of triangles */ @@ -1446,7 +1446,7 @@ typedef struct ivas_hrtfs_fastconv_struct Word16 allocate_init_flag; /*Memory allocation flag 0: if the hrtf pointers are allocated at application level , 1: of allocated at ivas_binaural_hrtf_open() */ - Word32 fastconvReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q26 */ + Word32 fastconvReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q26 */ Word32 fastconvReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ } HRTFS_FASTCONV, *HRTFS_FASTCONV_HANDLE; @@ -1457,7 +1457,7 @@ typedef struct ivas_hrtfs_parambin_struct Word16 hrtfShCoeffsRe_fx[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS]; /* Q14 */ Word16 hrtfShCoeffsIm_fx[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS]; /* Q14 */ - Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q26 */ + Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q26 */ Word32 parametricReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ Word32 parametricEarlyPartEneCorrection_fx[CLDFB_NO_CHANNELS_MAX]; /* Q28 */ -- GitLab