From 3728c466ad7a735742a2a950bbe8ef1afcb390b4 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 13 Apr 2026 16:41:17 +0200 Subject: [PATCH 01/22] [cleanup] accept HARM_HQ_CORE_KEEP_BE --- lib_com/low_rate_band_att_fx.c | 2 -- lib_com/options.h | 1 - lib_enc/hq_lr_enc_fx.c | 4 ---- 3 files changed, 7 deletions(-) diff --git a/lib_com/low_rate_band_att_fx.c b/lib_com/low_rate_band_att_fx.c index 4319d51ee..d31e032b9 100644 --- a/lib_com/low_rate_band_att_fx.c +++ b/lib_com/low_rate_band_att_fx.c @@ -101,12 +101,10 @@ void fine_gain_pred_fx( ELSE { tmp1 = fine_gain_pred_sqrt_bw[bw_idx]; -#ifdef HARM_HQ_CORE_KEEP_BE if ( EQ_16( bw_idx, 0 ) ) { tmp1--; /* Lookup table uses rounding while calculations use truncation */ } -#endif } } #endif diff --git a/lib_com/options.h b/lib_com/options.h index 8d06feb49..e3837923a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -90,7 +90,6 @@ #define NONBE_FIX_ISSUE_2206_TD_CHANNEL_EXTRAPOLATION /* FhG: Use different scale to avoid saturation of LPC coefficient in TD Stereo signal extrapolation. */ #define NONBE_FIX_ISSUE_2206_AVOID_OVERFLOW_SWB_fenv_fx2 /* FhG: Avoid overflow of SWB_fenv_fx in SWB_BWE_encoding_fx because of very small energies. */ #define NONBE_FIX_ISSUE_2206_AVOID_OVERFLOW_MSVQ_Interpol_Tran_fx /* FhG: Fix saturation crash in MSVQ_Interpol_Tran_fx() */ -#define HARM_HQ_CORE_KEEP_BE /* hack to keep all BE after HQ core functions harmonization; pending resolving issues #2450, #2451, #2452 */ #define FIX_2452_HQ_CORE_PEAQ_AVR_RATIO_HARM /* Eri: Basop issue 2453: Fix alignment of peak_avrg_ratio_fx */ #define FIX_2480_HARM_TONALMDCT /* FhG: basop issue 2480: Harmonize TonalMDCTConceal_Detect_fx() and TonalMDCTConceal_Detect_ivas_fx() */ #define FIX_2479_HARM_PITCH_GAIN /* FhG: basop issue 2479: Harmonize tcx_ltp_pitch_search_*(), tcx_ltp_find_gain_*fx() */ diff --git a/lib_enc/hq_lr_enc_fx.c b/lib_enc/hq_lr_enc_fx.c index e60f66bdc..5daf90dd5 100644 --- a/lib_enc/hq_lr_enc_fx.c +++ b/lib_enc/hq_lr_enc_fx.c @@ -209,11 +209,7 @@ void hq_lr_enc_fx( #ifdef FIX_2452_HQ_CORE_PEAQ_AVR_RATIO_HARM hqswb_clas_fx = peak_avrg_ratio_fx( st_fx->total_brate, L_t_audio, NUMC_N, &hHQ_core->mode_count, &hHQ_core->mode_count1, SWB_BWE_LR_Qs ); /* Q0 */ #else -#ifdef HARM_HQ_CORE_KEEP_BE hqswb_clas_fx = peak_avrg_ratio_fx( HQ_BWE_CROSSOVER_BRATE, L_t_audio, NUMC_N, &hHQ_core->mode_count, &hHQ_core->mode_count1, SWB_BWE_LR_Qs ); /* Q0 */ -#else - hqswb_clas_fx = peak_avrg_ratio_fx( st_fx->total_brate, L_t_audio, NUMC_N, &hHQ_core->mode_count, &hHQ_core->mode_count1, SWB_BWE_LR_Qs ); /* Q0 */ -#endif #endif } -- GitLab From ead75aed6d4acf9c00ee4cf346a2e53038ea225c Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 13 Apr 2026 16:42:12 +0200 Subject: [PATCH 02/22] [cleanup] accept FIX_2480_HARM_TONALMDCT --- lib_com/ivas_prot_fx.h | 10 -- lib_com/options.h | 1 - lib_com/prot_fx.h | 8 -- lib_dec/er_util_fx.c | 11 --- lib_dec/tonalMDCTconcealment_fx.c | 156 ------------------------------ 5 files changed, 186 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index f6b376af3..4588c8d41 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1695,15 +1695,6 @@ void ivas_mdct_tcx10_bit_distribution_fx( const Word16 nTnsBitsTCX10[NB_DIV] /* i : TNS bits */ ); -#ifndef FIX_2480_HARM_TONALMDCT -void TonalMDCTConceal_Detect_ivas_fx( - const TonalMDCTConcealPtr hTonalMDCTConc, - const Word32 pitchLag, - Word16 *numIndices, - const PsychoacousticParameters *psychParamsCurrent, - Word16 element_mode -); -#else void TonalMDCTConceal_Detect_fx( const TonalMDCTConcealPtr hTonalMDCTConc, const Word32 pitchLag, @@ -1711,7 +1702,6 @@ void TonalMDCTConceal_Detect_fx( const PsychoacousticParameters* psychParamsCurrent, Word16 element_mode ); -#endif // !FIX_2480_HARM_TONALMDCT ivas_error stereo_dft_dec_create_fx( STEREO_DFT_DEC_DATA_HANDLE *hStereoDft, /* i/o: decoder DFT stereo handle */ const Word32 element_brate, /* i : element bitrate */ diff --git a/lib_com/options.h b/lib_com/options.h index e3837923a..33f4fd491 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -91,7 +91,6 @@ #define NONBE_FIX_ISSUE_2206_AVOID_OVERFLOW_SWB_fenv_fx2 /* FhG: Avoid overflow of SWB_fenv_fx in SWB_BWE_encoding_fx because of very small energies. */ #define NONBE_FIX_ISSUE_2206_AVOID_OVERFLOW_MSVQ_Interpol_Tran_fx /* FhG: Fix saturation crash in MSVQ_Interpol_Tran_fx() */ #define FIX_2452_HQ_CORE_PEAQ_AVR_RATIO_HARM /* Eri: Basop issue 2453: Fix alignment of peak_avrg_ratio_fx */ -#define FIX_2480_HARM_TONALMDCT /* FhG: basop issue 2480: Harmonize TonalMDCTConceal_Detect_fx() and TonalMDCTConceal_Detect_ivas_fx() */ #define FIX_2479_HARM_PITCH_GAIN /* FhG: basop issue 2479: Harmonize tcx_ltp_pitch_search_*(), tcx_ltp_find_gain_*fx() */ #define HARMONIZE_2481_EXTEND_SHRINK /* FhG: basop issue 2481: Harmonize extend_frm_*fx() and shrink_frm_*fx() */ #define FIX_2485_HARMONIZE_perform_noise_estimation_enc /* FhG: harmonize perform_noise_estimation_enc and perform_noise_estimation_enc_ivas */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 5eb6bc7e9..12a057684 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -5769,14 +5769,6 @@ void TonalMDCTConceal_UpdateState_fx( const Word16 badBlock, const Word8 tonalConcealmentActive ); -#ifndef FIX_2480_HARM_TONALMDCT -void TonalMDCTConceal_Detect_fx( - const TonalMDCTConcealPtr self, /*IN */ - const Word32 pitchLag, /*IN */ - Word16 *umIndices, /*OUT*/ - const Word16 element_mode /* IN */ -); -#endif // !FIX_2480_HARM_TONALMDCT void TonalMDCTConceal_Apply_fx( const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ diff --git a/lib_dec/er_util_fx.c b/lib_dec/er_util_fx.c index 7adb78c12..78fb12f10 100644 --- a/lib_dec/er_util_fx.c +++ b/lib_dec/er_util_fx.c @@ -449,18 +449,7 @@ Word16 GetPLCModeDecision_fx( { pitch = L_add( st->old_fpitch, 0 ); /*Q16*/ } -#ifndef FIX_2480_HARM_TONALMDCT - IF( NE_16( st->element_mode, EVS_MONO ) ) - { - TonalMDCTConceal_Detect_ivas_fx( st->hTonalMDCTConc, pitch, &numIndices, ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ? &( st->hTcxCfg->psychParamsTCX20 ) : st->hTcxCfg->psychParamsCurrent ), st->element_mode ); - } - ELSE - { - TonalMDCTConceal_Detect_fx( st->hTonalMDCTConc, pitch, &numIndices, st->element_mode ); - } -#else TonalMDCTConceal_Detect_fx( st->hTonalMDCTConc, pitch, &numIndices, ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ? &( st->hTcxCfg->psychParamsTCX20 ) : st->hTcxCfg->psychParamsCurrent ), st->element_mode ); -#endif // !FIX_2480_HARM_TONALMDCT test(); diff --git a/lib_dec/tonalMDCTconcealment_fx.c b/lib_dec/tonalMDCTconcealment_fx.c index 210d2a2c0..e45aac27c 100644 --- a/lib_dec/tonalMDCTconcealment_fx.c +++ b/lib_dec/tonalMDCTconcealment_fx.c @@ -927,148 +927,12 @@ static void CalcMDXT( return; } -#ifndef FIX_2480_HARM_TONALMDCT void TonalMDCTConceal_Detect_fx( - const TonalMDCTConcealPtr hTonalMDCTConc, - const Word32 pitchLag, /*15Q16*/ - Word16 *numIndices, - const Word16 element_mode ) -{ - Word32 secondLastMDST[L_FRAME_MAX]; - Word32 secondLastMDCT[L_FRAME_MAX]; - Word16 secondLastMDCT_exp; - Word32 *powerSpectrum = secondLastMDST; - Word16 i, powerSpectrum_exp, secondLastMDST_exp, s; - Word16 nSamples; - - nSamples = hTonalMDCTConc->nSamples; - move16(); - secondLastMDST_exp = 16; /*time signal Q-1*/ - move16(); - secondLastMDCT_exp = 16; /*time signal Q-1*/ - move16(); - test(); - test(); - test(); - test(); - test(); - IF( hTonalMDCTConc->lastBlockData.blockIsValid && hTonalMDCTConc->secondLastBlockData.blockIsValid && ( EQ_16( hTonalMDCTConc->lastBlockData.nSamples, nSamples ) ) && ( EQ_16( hTonalMDCTConc->secondLastBlockData.nSamples, nSamples ) ) && ( !hTonalMDCTConc->secondLastBlockData.blockIsConcealed || hTonalMDCTConc->secondLastBlockData.tonalConcealmentActive || ( pitchLag != 0 ) ) ) - { - /* Safety if the second last frame was concealed and tonal concealment was inactive */ - - IF( hTonalMDCTConc->lastBlockData.blockIsConcealed == 0 ) - { - IF( hTonalMDCTConc->secondLastBlockData.tonalConcealmentActive == 0 ) - { - CalcMDXT( hTonalMDCTConc, 0, hTonalMDCTConc->secondLastPcmOut, secondLastMDST, &secondLastMDST_exp ); - CalcMDXT( hTonalMDCTConc, 1, hTonalMDCTConc->secondLastPcmOut, secondLastMDCT, &secondLastMDCT_exp ); - hTonalMDCTConc->nNonZeroSamples = 0; - move16(); - FOR( i = 0; i < hTonalMDCTConc->nSamples; i++ ) - { - if ( hTonalMDCTConc->secondLastBlockData.spectralData[i] != 0 ) - { - hTonalMDCTConc->nNonZeroSamples = i; - move16(); - } - } - - /* 23 is the maximum length of the MA filter in getEnvelope */ - hTonalMDCTConc->nNonZeroSamples = s_min( hTonalMDCTConc->nSamples, add( hTonalMDCTConc->nNonZeroSamples, 23 ) ); - move16(); - nSamples = hTonalMDCTConc->nNonZeroSamples; - move16(); - - s = getScaleFactor32( secondLastMDST, nSamples ); - - FOR( i = 0; i < nSamples; i++ ) - { - secondLastMDST[i] = L_shl( secondLastMDST[i], s ); - move32(); - } - secondLastMDST_exp = sub( secondLastMDST_exp, s ); - move16(); - s = getScaleFactor32( secondLastMDCT, nSamples ); - - FOR( i = 0; i < nSamples; i++ ) - { - secondLastMDCT[i] = L_shl( secondLastMDCT[i], s ); - move32(); - } - secondLastMDCT_exp = sub( secondLastMDCT_exp, s ); - move16(); - CalcPowerSpecAndDetectTonalComponents_fx( hTonalMDCTConc, secondLastMDST, secondLastMDST_exp, secondLastMDCT, secondLastMDCT_exp, pitchLag, NULL, element_mode ); - } - ELSE - { - /* If the second last frame was also lost, it is expected that pastTimeSignal could hold a bit different signal (e.g. including fade-out) from the one stored in TonalMDCTConceal_SaveTimeSignal. */ - /* That is why we reuse the already stored information about the concealed spectrum in the second last frame */ - { - nSamples = hTonalMDCTConc->nNonZeroSamples; - move16(); - mdct_shaping_16( hTonalMDCTConc->secondLastPowerSpectrum, hTonalMDCTConc->nSamplesCore, nSamples, - hTonalMDCTConc->secondLastBlockData.scaleFactors, hTonalMDCTConc->secondLastBlockData.scaleFactors_exp, - hTonalMDCTConc->secondLastBlockData.scaleFactors_max_e, powerSpectrum ); - } - powerSpectrum_exp = getScaleFactor32( powerSpectrum, nSamples ); - powerSpectrum_exp = sub( powerSpectrum_exp, 3 ); /*extra 3 bits of headroom for MA filter in getEnvelope*/ - - /* multFLOAT(powerSpectrum, powerSpectrum, powerSpectrum, nSamples); */ - FOR( i = 0; i < nSamples; i++ ) - { - Word32 const t = L_shl( powerSpectrum[i], powerSpectrum_exp ); // Q(31-secondLastMDST_exp+powerSpectrum_exp) - powerSpectrum[i] = Mpy_32_32( t, t ); // Q2*(31-secondLastMDST_exp+powerSpectrum_exp) -31 - move32(); - } - - RefineTonalComponents_fx( (Word16 *) hTonalMDCTConc->pTCI->indexOfTonalPeak, - (Word16 *) hTonalMDCTConc->pTCI->lowerIndex, - (Word16 *) hTonalMDCTConc->pTCI->upperIndex, - hTonalMDCTConc->pTCI->phaseDiff, - hTonalMDCTConc->pTCI->phase_currentFramePredicted, - (Word16 *) &hTonalMDCTConc->pTCI->numIndexes, - hTonalMDCTConc->lastPitchLag, - pitchLag, - hTonalMDCTConc->lastBlockData.spectralData, - add( hTonalMDCTConc->lastBlockData.spectralData_exp, hTonalMDCTConc->lastBlockData.gain_tcx_exp ), - hTonalMDCTConc->lastBlockData.scaleFactors, - hTonalMDCTConc->lastBlockData.scaleFactors_exp, - hTonalMDCTConc->lastBlockData.scaleFactors_max_e, - powerSpectrum, - -1, - nSamples, - hTonalMDCTConc->nSamplesCore, - extract_l( Mpy_32_16_1( L_mult0( hTonalMDCTConc->nSamples, hTonalMDCTConc->nSamples ), 82 ) ), element_mode, NULL ); - } - } - } - ELSE - { - hTonalMDCTConc->pTCI->numIndexes = 0; - move16(); - } - - *numIndices = hTonalMDCTConc->pTCI->numIndexes; - move16(); - - return; -} -#endif // !FIX_2480_HARM_TONALMDCT -#ifndef FIX_2480_HARM_TONALMDCT -void TonalMDCTConceal_Detect_ivas_fx( const TonalMDCTConcealPtr hTonalMDCTConc, const Word32 pitchLag, /*15Q16*/ Word16 *numIndices, const PsychoacousticParameters *psychParamsCurrent, Word16 element_mode ) -#else -void TonalMDCTConceal_Detect_fx( - const TonalMDCTConcealPtr hTonalMDCTConc, - const Word32 pitchLag, /*15Q16*/ - Word16 *numIndices, - const PsychoacousticParameters *psychParamsCurrent, - Word16 element_mode ) -#endif // !FIX_2480_HARM_TONALMDCT { Word32 secondLastMDST[L_FRAME_MAX]; set32_fx( secondLastMDST, 0, L_FRAME_MAX ); @@ -1086,12 +950,6 @@ void TonalMDCTConceal_Detect_fx( nSamples = hTonalMDCTConc->nSamples; move16(); -#ifndef FIX_2480_HARM_TONALMDCT - secondLastMDST_exp = sub( 16, hTonalMDCTConc->q_lastPcmOut ); /*time signal Q-1 - hTonalMDCTConc->q_lastPcmOut*/ - move16(); - secondLastMDCT_exp = sub( 16, hTonalMDCTConc->q_lastPcmOut ); /*time signal Q-1 - hTonalMDCTConc->q_lastPcmOut*/ - move16(); -#else IF( EQ_16( element_mode, EVS_MONO ) ) { secondLastMDST_exp = 16; /*time signal Q-1*/ @@ -1102,7 +960,6 @@ void TonalMDCTConceal_Detect_fx( secondLastMDST_exp = sub( 16, hTonalMDCTConc->q_lastPcmOut ); /*time signal Q-1 - hTonalMDCTConc->q_lastPcmOut*/ secondLastMDCT_exp = sub( 16, hTonalMDCTConc->q_lastPcmOut ); /*time signal Q-1 - hTonalMDCTConc->q_lastPcmOut*/ } -#endif // !FIX_2480_HARM_TONALMDCT move16(); move16(); test(); @@ -1136,15 +993,11 @@ void TonalMDCTConceal_Detect_fx( move16(); nSamples = hTonalMDCTConc->nNonZeroSamples; move16(); -#ifndef FIX_2480_HARM_TONALMDCT - s = sub( getScaleFactor32( secondLastMDST, nSamples ), 1 ); -#else s = getScaleFactor32( secondLastMDST, nSamples ); IF( NE_16( element_mode, EVS_MONO ) ) { s = sub( s, 1 ); } -#endif // !FIX_2480_HARM_TONALMDCT FOR( i = 0; i < nSamples; i++ ) { @@ -1153,15 +1006,11 @@ void TonalMDCTConceal_Detect_fx( } secondLastMDST_exp = sub( secondLastMDST_exp, s ); move16(); -#ifndef FIX_2480_HARM_TONALMDCT - s = sub( getScaleFactor32( secondLastMDCT, nSamples ), 1 ); -#else s = getScaleFactor32( secondLastMDCT, nSamples ); IF( NE_16( element_mode, EVS_MONO ) ) { s = sub( s, 1 ); } -#endif // !FIX_2480_HARM_TONALMDCT FOR( i = 0; i < nSamples; i++ ) { @@ -1179,16 +1028,11 @@ void TonalMDCTConceal_Detect_fx( Word16 temp_power_spectrum_q = 0; nSamples = hTonalMDCTConc->nNonZeroSamples; move16(); -#ifndef FIX_2480_HARM_TONALMDCT - Copy_Scale_sig_16_32_DEPREC( hTonalMDCTConc->secondLastPowerSpectrum, powerSpectrum, nSamples, Q15 ); - temp_power_spectrum_q = add( Q15, sub( 15, hTonalMDCTConc->secondLastPowerSpectrum_exp ) ); -#else IF( NE_16( element_mode, EVS_MONO ) ) { Copy_Scale_sig_16_32_DEPREC( hTonalMDCTConc->secondLastPowerSpectrum, powerSpectrum, nSamples, Q15 ); temp_power_spectrum_q = add( Q15, sub( 15, hTonalMDCTConc->secondLastPowerSpectrum_exp ) ); } -#endif // !FIX_2480_HARM_TONALMDCT IF( psychParamsCurrent == NULL ) { mdct_shaping_16( hTonalMDCTConc->secondLastPowerSpectrum, hTonalMDCTConc->nSamplesCore, nSamples, -- GitLab From ddca9e5fdb697086183ed43eec3bb221a6b93f86 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 13 Apr 2026 16:43:05 +0200 Subject: [PATCH 03/22] [cleanup] accept FIX_2479_HARM_PITCH_GAIN --- lib_com/options.h | 1 - lib_enc/tcx_ltp_enc_fx.c | 317 --------------------------------------- 2 files changed, 318 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 33f4fd491..32ec7dc63 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -91,7 +91,6 @@ #define NONBE_FIX_ISSUE_2206_AVOID_OVERFLOW_SWB_fenv_fx2 /* FhG: Avoid overflow of SWB_fenv_fx in SWB_BWE_encoding_fx because of very small energies. */ #define NONBE_FIX_ISSUE_2206_AVOID_OVERFLOW_MSVQ_Interpol_Tran_fx /* FhG: Fix saturation crash in MSVQ_Interpol_Tran_fx() */ #define FIX_2452_HQ_CORE_PEAQ_AVR_RATIO_HARM /* Eri: Basop issue 2453: Fix alignment of peak_avrg_ratio_fx */ -#define FIX_2479_HARM_PITCH_GAIN /* FhG: basop issue 2479: Harmonize tcx_ltp_pitch_search_*(), tcx_ltp_find_gain_*fx() */ #define HARMONIZE_2481_EXTEND_SHRINK /* FhG: basop issue 2481: Harmonize extend_frm_*fx() and shrink_frm_*fx() */ #define FIX_2485_HARMONIZE_perform_noise_estimation_enc /* FhG: harmonize perform_noise_estimation_enc and perform_noise_estimation_enc_ivas */ #define FIX_2485_HARMONIZE_minimum_statistics /* FhG: harmonize minimum_statistics and minimum_statistics_fx */ diff --git a/lib_enc/tcx_ltp_enc_fx.c b/lib_enc/tcx_ltp_enc_fx.c index 0a1b0039a..5247f3604 100644 --- a/lib_enc/tcx_ltp_enc_fx.c +++ b/lib_enc/tcx_ltp_enc_fx.c @@ -73,230 +73,6 @@ static Word32 interpolate_corr( return s; } -#ifndef FIX_2479_HARM_PITCH_GAIN -static void tcx_ltp_pitch_search( - Word16 pitch_ol, - Word16 *pitch_int, - Word16 *pitch_fr, - Word16 *index, - Word16 *norm_corr, - const Word16 len, - Word16 *wsp, - Word16 pitmin, - Word16 pitfr1, - Word16 pitfr2, - Word16 pitmax, - Word16 pitres ) -{ - Word16 i, t, t0, t1, step, fraction, t0_min, t0_max, t_min, t_max, delta, temp_m, temp_e, s, s_wsp; - Word16 cor_idx_ini, cor_idx; - Word32 cor_max, cor[256], *pt_cor, temp; - Word16 wsp2[L_FRAME_PLUS + PIT_MAX_MAX + L_INTERPOL1]; - - delta = 16; - move16(); - if ( EQ_16( pitres, 6 ) ) - { - delta = 8; - move16(); - } - - t0_min = sub( pitch_ol, shr( delta, 1 ) ); - t0_max = sub( add( t0_min, delta ), 1 ); - - IF( LT_16( t0_min, pitmin ) ) - { - t0_min = pitmin; - move16(); - t0_max = sub( add( t0_min, delta ), 1 ); - } - - IF( GT_16( t0_max, pitmax ) ) - { - t0_max = pitmax; - move16(); - t0_min = add( sub( t0_max, delta ), 1 ); - } - - t_min = sub( t0_min, L_INTERPOL1 ); - t_max = add( t0_max, L_INTERPOL1 ); - - /* normalize wsp */ - assert( len + t_max <= L_FRAME_PLUS + PIT_MAX_MAX + L_INTERPOL1 ); - s_wsp = getScaleFactor16( wsp - t_max, add( len, t_max ) ); - s_wsp = sub( s_wsp, 4 ); - FOR( t = negate( t_max ); t < len; t++ ) - { - wsp2[t + t_max] = shl( wsp[t], s_wsp ); - move16(); - } - wsp = wsp2 + t_max; - move16(); - - pt_cor = cor; - move32(); - - FOR( t = t_min; t <= t_max; t++ ) - { - *pt_cor = dot( wsp, wsp - t, len ); - move32(); - pt_cor++; - } - - pt_cor = cor + L_INTERPOL1; - cor_max = L_add( *pt_cor++, 0 ); - t1 = t0_min; - move16(); - move32(); - - FOR( t = t0_min + 1; t <= t0_max; t++ ) - { - IF( GT_32( *pt_cor, cor_max ) ) - { - cor_max = *pt_cor; - move32(); - t1 = t; - move16(); - } - pt_cor++; - } - - temp = dot( wsp, wsp, len ); - s = norm_l( temp ); - temp_m = extract_h( L_shl( temp, s ) ); - temp_e = negate( s ); - - temp = dot( wsp - t1, wsp - t1, len ); - s = norm_l( temp ); - temp_m = mult( temp_m, extract_h( L_shl( temp, s ) ) ); - temp_e = sub( temp_e, s ); - - temp_m = Sqrt16( temp_m, &temp_e ); - - if ( temp_m == 0 ) - { - temp_m = 1; - move16(); - } - s = sub( norm_l( cor_max ), 1 ); - temp_m = divide1616( extract_h( L_shl( cor_max, s ) ), temp_m ); - temp_e = sub( negate( s ), temp_e ); - - *norm_corr = shl_sat( temp_m, temp_e ); - - IF( GE_16( t1, pitfr1 ) ) - { - *pitch_int = t1; - move16(); - *pitch_fr = 0; - move16(); - - *index = add( sub( t1, pitfr1 ), extract_l( L_mac0( L_mult0( sub( pitfr2, pitmin ), pitres ), - sub( pitfr1, pitfr2 ), shr( pitres, 1 ) ) ) ); - move16(); - - return; - } - - /*------------------------------------------------------------------* - * Search fractional pitch with 1/4 subsample resolution. - * search the fractions around t0 and choose the one which maximizes - * the interpolated normalized correlation. - *-----------------------------------------------------------------*/ - - cor_idx_ini = sub( L_INTERPOL1, t0_min ); - t0 = t1; - move16(); - - step = 1; - move16(); - if ( GE_16( t0, pitfr2 ) ) - { - step = 2; - move16(); - } - fraction = step; - move16(); - - IF( EQ_16( t0, t0_min ) ) /* Limit case */ - { - cor_idx = add( cor_idx_ini, t0 ); - fraction = 0; - move16(); - cor_max = interpolate_corr( &cor[cor_idx], fraction, pitres ); - } - ELSE /* Process negative fractions */ - { - t0 = sub( t0, 1 ); - cor_idx = add( cor_idx_ini, t0 ); - cor_max = interpolate_corr( &cor[cor_idx], fraction, pitres ); - - FOR( i = fraction + step; i < pitres; i += step ) - { - temp = interpolate_corr( &cor[cor_idx], i, pitres ); - - IF( GT_32( temp, cor_max ) ) - { - cor_max = L_add( temp, 0 ); - fraction = i; - move16(); - } - } - } - - cor_idx = add( cor_idx_ini, t1 ); - FOR( i = 0; i < pitres; i += step ) /* Process positive fractions */ - { - temp = interpolate_corr( &cor[cor_idx], i, pitres ); - - IF( GT_32( temp, cor_max ) ) - { - cor_max = L_add( temp, 0 ); - fraction = i; - move16(); - t0 = t1; - move16(); - } - } - - *pitch_int = t0; - move16(); - *pitch_fr = fraction; - move16(); - - IF( GE_16( t0, pitfr2 ) ) - { - *index = add( extract_l( L_mac0( L_mult0( sub( t0, pitfr2 ), shr( pitres, 1 ) ), - sub( pitfr2, pitmin ), pitres ) ), - shr( fraction, 1 ) ); - move16(); - } - ELSE - { - *index = add( imult1616( sub( t0, pitmin ), pitres ), fraction ); - move16(); - } -} - - -#endif // !FIX_2479_HARM_PITCH_GAIN -#ifndef FIX_2479_HARM_PITCH_GAIN -static void tcx_ltp_pitch_search_ivas_fx( - const Word16 pitch_ol, - Word16 *pitch_int, - Word16 *pitch_fr, - Word16 *index, - Word16 *norm_corr, - const Word16 len, - const Word16 *wsp, // Qx - const Word16 pitmin, - const Word16 pitfr1, - const Word16 pitfr2, - const Word16 pitmax, - const Word16 pitres, - const Word16 check_border_case, - Word16 *border_case ) -#else static void tcx_ltp_pitch_search_fx( const Word16 pitch_ol, Word16 *pitch_int, @@ -312,7 +88,6 @@ static void tcx_ltp_pitch_search_fx( const Word16 pitres, const Word16 check_border_case, Word16 *border_case ) -#endif // !FIX_2479_HARM_PITCH_GAIN { Word16 i, t, t0, t1, step, fraction, t0_min, t0_max, t_min, t_max, delta, temp_m, temp_e, s, s_wsp; Word16 cor_idx_ini, cor_idx; @@ -348,9 +123,7 @@ static void tcx_ltp_pitch_search_fx( t_max = add( t0_max, L_INTERPOL1 ); /* normalize wsp */ -#ifdef FIX_2479_HARM_PITCH_GAIN assert( len + t_max <= L_FRAME_PLUS + PIT_MAX_MAX + L_INTERPOL1 ); -#endif // FIX_2479_HARM_PITCH_GAIN s_wsp = getScaleFactor16( wsp - t_max, add( len, t_max ) ); s_wsp = sub( s_wsp, 4 ); @@ -518,59 +291,7 @@ static void tcx_ltp_pitch_search_fx( } } -#ifndef FIX_2479_HARM_PITCH_GAIN -static void tcx_ltp_find_gain( Word16 *speech, Word16 *pred_speech, Word16 L_frame, Word16 *gain, Word16 *gain_index ) -{ - Word32 corr, ener; - Word16 i, g, s1, s2, tmp; - - s1 = sub( getScaleFactor16( speech, L_frame ), 4 ); - s2 = sub( getScaleFactor16( pred_speech, L_frame ), 4 ); - - /* Find gain */ - corr = L_deposit_l( 0 ); - ener = L_deposit_l( 1 ); - - FOR( i = 0; i < L_frame; i++ ) - { - tmp = shl_sat( pred_speech[i], s2 ); - corr = L_mac0_sat( corr, shl( speech[i], s1 ), tmp ); - ener = L_mac0_sat( ener, tmp, tmp ); - } - - s1 = sub( 1, add( s1, s2 ) ); - s2 = sub( 1, shl( s2, 1 ) ); - - tmp = sub( norm_l( corr ), 1 ); - corr = L_shl( corr, tmp ); - s1 = sub( s1, tmp ); - - tmp = norm_l( ener ); - ener = L_shl( ener, tmp ); - s2 = sub( s2, tmp ); - - g = divide1616( round_fx_sat( corr ), round_fx_sat( ener ) ); - BASOP_SATURATE_WARNING_OFF_EVS - g = shl_sat( g, sub( s1, s2 ) ); - BASOP_SATURATE_WARNING_ON_EVS - - /* Quantize gain */ - g = shr( sub_sat( g, 0x1000 ), 13 ); - g = s_max( g, -1 ); - - *gain_index = g; - move16(); - - /* Dequantize gain */ - *gain = imult1616( add( g, 1 ), 0x1400 ); - move16(); -} -#endif // !FIX_2479_HARM_PITCH_GAIN -#ifndef FIX_2479_HARM_PITCH_GAIN -static void tcx_ltp_find_gain_ivas_fx( Word16 *speech /*Qx*/, Word16 *pred_speech /*Qx*/, Word16 L_frame, Word16 *gain, Word16 *gain_index ) -#else static void tcx_ltp_find_gain_fx( Word16 *speech /*Qx*/, Word16 *pred_speech /*Qx*/, Word16 L_frame, Word16 *gain, Word16 *gain_index ) -#endif // !FIX_2479_HARM_PITCH_GAIN { Word32 corr, ener; Word16 i, g, s1, s2, tmp; @@ -657,9 +378,7 @@ void tcx_ltp_encode_fx( Word16 buf_zir[M + L_SUBFR], *zir; Word16 Aest[M + 1]; Word16 alpha, step; -#ifdef FIX_2479_HARM_PITCH_GAIN Word16 border_case; -#endif // FIX_2479_HARM_PITCH_GAIN norm_corr = 0; move16(); @@ -691,11 +410,7 @@ void tcx_ltp_encode_fx( } /* Find pitch lag */ -#ifndef FIX_2479_HARM_PITCH_GAIN - tcx_ltp_pitch_search( Top, pitch_int, pitch_fr, <p_param[1], &norm_corr, L_frame, wsp, pitmin, pitfr1, pitfr2, pitmax, pitres ); -#else tcx_ltp_pitch_search_fx( Top, pitch_int, pitch_fr, <p_param[1], &norm_corr, L_frame, wsp, pitmin, pitfr1, pitfr2, pitmax, pitres, 0, &border_case ); -#endif // !FIX_2479_HARM_PITCH_GAIN nPrevSubblocks = extract_h( L_mac( 0x17fff, NSUBBLOCKS, div_s( *pitch_int, L_frame ) ) ); @@ -756,11 +471,7 @@ void tcx_ltp_encode_fx( predict_signal( speech, pred_speech, *pitch_int, *pitch_fr, pitres, L_frame ); /* Find gain */ -#ifndef FIX_2479_HARM_PITCH_GAIN - tcx_ltp_find_gain( speech, pred_speech, L_frame, gain, <p_param[2] ); -#else tcx_ltp_find_gain_fx( speech, pred_speech, L_frame, gain, <p_param[2] ); -#endif // !FIX_2479_HARM_PITCH_GAIN /* Total number of bits for LTP */ IF( NE_16( ltp_param[2], -1 ) ) /* gain > 0 */ { @@ -994,11 +705,7 @@ void tcx_ltp_encode_ivas_fx( IF( LT_16( abs_s( sub( Top[0], Top[1] ) ), shr( delta, 1 ) ) ) { /* estimates are close enough and stable, take the artihmetic mean as estimate */ -#ifndef FIX_2479_HARM_PITCH_GAIN - tcx_ltp_pitch_search_ivas_fx( shr( add( Top[0], Top[1] ), 1 ), &hTcxEnc->tcxltp_pitch_int, &hTcxEnc->tcxltp_pitch_fr, <p_param[1], &norm_corr_fx, L_frame, wsp_fx, st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max, 1, &border_case ); -#else tcx_ltp_pitch_search_fx( shr( add( Top[0], Top[1] ), 1 ), &hTcxEnc->tcxltp_pitch_int, &hTcxEnc->tcxltp_pitch_fr, <p_param[1], &norm_corr_fx, L_frame, wsp_fx, st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max, 1, &border_case ); -#endif // !FIX_2479_HARM_PITCH_GAIN } ELSE { @@ -1010,11 +717,7 @@ void tcx_ltp_encode_ivas_fx( FOR( i = 0; i < 2; i++ ) { -#ifndef FIX_2479_HARM_PITCH_GAIN - tcx_ltp_pitch_search_ivas_fx( Top[i], &pitch_int_2[i], &pitch_fr_2[i], &pit_param_2[i], &norm_corr_2_fx[i], L_frame, wsp_fx, st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max, 1, &border_case ); -#else tcx_ltp_pitch_search_fx( Top[i], &pitch_int_2[i], &pitch_fr_2[i], &pit_param_2[i], &norm_corr_2_fx[i], L_frame, wsp_fx, st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max, 1, &border_case ); -#endif // !FIX_2479_HARM_PITCH_GAIN } IF( GT_16( norm_corr_2_fx[1], norm_corr_2_fx[0] ) ) @@ -1039,7 +742,6 @@ void tcx_ltp_encode_ivas_fx( } ELSE { -#ifdef FIX_2479_HARM_PITCH_GAIN Word16 check_border_case; IF( GT_16( element_mode, EVS_MONO ) ) { @@ -1049,23 +751,8 @@ void tcx_ltp_encode_ivas_fx( { check_border_case = 0; } -#else - Word16 tmp; - IF( GT_16( element_mode, EVS_MONO ) ) - { - tmp = 1; - } - ELSE - { - tmp = 0; - } -#endif move16(); -#ifndef FIX_2479_HARM_PITCH_GAIN - tcx_ltp_pitch_search_ivas_fx( Top[1], &hTcxEnc->tcxltp_pitch_int, &hTcxEnc->tcxltp_pitch_fr, <p_param[1], &norm_corr_fx, L_frame, wsp_fx, st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max, tmp, &border_case ); -#else tcx_ltp_pitch_search_fx( Top[1], &hTcxEnc->tcxltp_pitch_int, &hTcxEnc->tcxltp_pitch_fr, <p_param[1], &norm_corr_fx, L_frame, wsp_fx, st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max, check_border_case, &border_case ); -#endif // !FIX_2479_HARM_PITCH_GAIN } if ( border_case ) @@ -1181,11 +868,7 @@ void tcx_ltp_encode_ivas_fx( predict_signal( speech_fx, pred_speech_fx, hTcxEnc->tcxltp_pitch_int, hTcxEnc->tcxltp_pitch_fr, st->pit_res_max, L_frame ); /* Find gain */ -#ifndef FIX_2479_HARM_PITCH_GAIN - tcx_ltp_find_gain_ivas_fx( speech_fx, pred_speech_fx, L_frame, &hTcxEnc->tcxltp_gain, <p_param[2] ); -#else tcx_ltp_find_gain_fx( speech_fx, pred_speech_fx, L_frame, &hTcxEnc->tcxltp_gain, <p_param[2] ); -#endif // !FIX_2479_HARM_PITCH_GAIN IF( ltp_param[0] ) { /* Total number of bits for LTP */ -- GitLab From 08c7ceb503324af1811186ae3f4502b471815742 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 13 Apr 2026 16:44:12 +0200 Subject: [PATCH 04/22] [cleanup] accept HARMONIZE_2481_EXTEND_SHRINK --- lib_com/options.h | 1 - lib_dec/jbm_pcmdsp_apa_fx.c | 504 ------------------- lib_dec/jbm_pcmdsp_similarityestimation.h | 5 - lib_dec/jbm_pcmdsp_similarityestimation_fx.c | 32 -- 4 files changed, 542 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 32ec7dc63..880828b09 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -91,7 +91,6 @@ #define NONBE_FIX_ISSUE_2206_AVOID_OVERFLOW_SWB_fenv_fx2 /* FhG: Avoid overflow of SWB_fenv_fx in SWB_BWE_encoding_fx because of very small energies. */ #define NONBE_FIX_ISSUE_2206_AVOID_OVERFLOW_MSVQ_Interpol_Tran_fx /* FhG: Fix saturation crash in MSVQ_Interpol_Tran_fx() */ #define FIX_2452_HQ_CORE_PEAQ_AVR_RATIO_HARM /* Eri: Basop issue 2453: Fix alignment of peak_avrg_ratio_fx */ -#define HARMONIZE_2481_EXTEND_SHRINK /* FhG: basop issue 2481: Harmonize extend_frm_*fx() and shrink_frm_*fx() */ #define FIX_2485_HARMONIZE_perform_noise_estimation_enc /* FhG: harmonize perform_noise_estimation_enc and perform_noise_estimation_enc_ivas */ #define FIX_2485_HARMONIZE_minimum_statistics /* FhG: harmonize minimum_statistics and minimum_statistics_fx */ #define FIX_FLOAT_ISSUE_1546_DEAD_CODE /* FhG: remove dead code reported in the issue*/ diff --git a/lib_dec/jbm_pcmdsp_apa_fx.c b/lib_dec/jbm_pcmdsp_apa_fx.c index 75a1fba48..9a7a88bf1 100644 --- a/lib_dec/jbm_pcmdsp_apa_fx.c +++ b/lib_dec/jbm_pcmdsp_apa_fx.c @@ -149,23 +149,11 @@ static Word16 find_synch_fx( apa_state_t *ps, const Word16 *in, Word16 l_in, Wor static bool copy_frm_fx( apa_state_t *ps, const Word16 frm_in[], Word16 frm_out[], UWord16 *l_frm_out ); -#ifndef HARMONIZE_2481_EXTEND_SHRINK - -static bool shrink_frm_fx( apa_state_t *ps, const Word16 frm_in[], UWord16 maxScaling, Word16 frm_out[], UWord16 *l_frm_out ); - -static bool shrink_frm_ivas_fx( apa_state_t *ps, const Word16 frm_in[], UWord16 maxScaling, Word16 frm_out[], Word16 Q_frm_in, UWord16 *l_frm_out ); - -static bool extend_frm_fx( apa_state_t *ps, const Word16 frm_in[], Word16 frm_out[], UWord16 *l_frm_out ); - -static bool extend_frm_ivas_fx( apa_state_t *ps, const Word16 frm_in[], Word16 frm_out[], Word16 Q_frm_in, UWord16 *l_frm_out ); - -#else static bool shrink_frm_fx( apa_state_t *ps, const Word16 frm_in[], UWord16 maxScaling, Word16 frm_out[], Word16 Q_frm_in, UWord16 *l_frm_out, bool bIsEVS ); static bool extend_frm_fx( apa_state_t *ps, const Word16 frm_in[], Word16 frm_out[], Word16 Q_frm_in, UWord16 *l_frm_out, bool bIsEVS ); -#endif // !HARMONIZE_2481_EXTEND_SHRINK /*---------------------------------------------------------------------* * Public functions @@ -801,20 +789,12 @@ UWord8 apa_exec_fx( ELSE IF( LT_32( ps->scale, 100 ) ) { -#ifndef HARMONIZE_2481_EXTEND_SHRINK - shrink_frm_fx( ps, frm_in, maxScaling, a_out, &l_frm_out ); -#else shrink_frm_fx( ps, frm_in, maxScaling, a_out, 0, &l_frm_out, true ); -#endif // !HARMONIZE_2481_EXTEND_SHRINK } /* extend */ ELSE { -#ifndef HARMONIZE_2481_EXTEND_SHRINK - extend_frm_fx( ps, frm_in, a_out, &l_frm_out ); -#else extend_frm_fx( ps, frm_in, a_out, 0, &l_frm_out, true ); -#endif // !HARMONIZE_2481_EXTEND_SHRINK } /* control the amount/frequency of scaling */ IF( NE_32( l_frm_out, ps->l_frm ) ) @@ -1044,20 +1024,12 @@ UWord8 apa_exec_ivas_fx( /* shrink */ IF( LT_32( ps->scale, 100 ) ) { -#ifndef HARMONIZE_2481_EXTEND_SHRINK - shrink_frm_ivas_fx( ps, frm_in, maxScaling, a_tmp, Q_a_out, &l_frm_out ); -#else shrink_frm_fx( ps, frm_in, maxScaling, a_tmp, Q_a_out, &l_frm_out, false ); -#endif // !HARMONIZE_2481_EXTEND_SHRINK } /* extend */ ELSE { -#ifndef HARMONIZE_2481_EXTEND_SHRINK - extend_frm_ivas_fx( ps, frm_in, a_tmp, Q_a_out, &l_frm_out ); -#else extend_frm_fx( ps, frm_in, a_tmp, Q_a_out, &l_frm_out, false ); -#endif // !HARMONIZE_2481_EXTEND_SHRINK } /* control the amount/frequency of scaling */ IF( NE_32( l_frm_out, ps->l_frm ) ) @@ -1617,187 +1589,7 @@ static bool copy_frm_fx( * ******************************************************************************** */ -#ifndef HARMONIZE_2481_EXTEND_SHRINK - -static bool shrink_frm_fx( - apa_state_t *ps, - const Word16 frm_in_fx[], // Qx - UWord16 maxScaling, - Word16 frm_out_fx[], // Qx - UWord16 *l_frm_out ) -{ - bool findSynchResult = 0; - Word16 xtract, l_rem, s_start, s_end; - UWord16 i; - UWord16 over; - Word16 energy_fx = 0; - Word32 quality_fx = 0; - UWord16 l_frm; - UWord16 l_seg; - move16(); - move32(); - - l_frm = ps->l_frm; - move16(); - l_seg = ps->l_seg; - move16(); - - /* only 2nd input frame is used */ - frm_in_fx += l_frm; - - /* set search range */ - // s_start = ( ps->p_min / ps->num_channels ) * ps->num_channels; - Word16 tmp, tmp_e; - tmp = BASOP_Util_Divide3232_Scale( ps->p_min, ps->num_channels, &tmp_e ); - tmp = shr( tmp, sub( 15, tmp_e ) ); - s_start = i_mult( tmp, extract_l( ps->num_channels ) ); - s_end = add( s_start, extract_l( ps->l_search ) ); - IF( GE_32( L_add( s_end, l_seg ), l_frm ) ) - { - s_end = extract_l( L_sub( l_frm, l_seg ) ); - } - - /* calculate overlap position */ - IF( isSilence_fx( frm_in_fx, l_seg, 10 ) ) - { - /* maximum scaling */ - energy_fx = -65 * ( 1 << 8 ); // Q8 - move16(); - quality_fx = 5 << Q16; // Q16 - move32(); - IF( ps->evs_compat_mode == false ) - { - - xtract = maxScaling; - move16(); - /* take samples already in the renderer buf into account */ - xtract = add( xtract, extract_l( ps->l_r_buf ) ); - /* snap to renderer time slot borders */ - xtract = sub( xtract, extract_l( L_sub( ps->l_ts, ( L_add( L_sub( l_frm, xtract ), ps->l_r_buf ) ) % ps->l_ts ) ) ); - WHILE( xtract < 0 ) - { - xtract = add( xtract, extract_l( ps->l_ts ) ); - } - WHILE( GT_32( xtract, sub( s_end, extract_l( ps->num_channels ) ) ) ) - { - /* exceeded the possible shrinking, go back one renderer ts*/ - xtract = sub( xtract, extract_l( ps->l_ts ) ); - } - } - ELSE IF( maxScaling != 0U && GT_16( s_end, add( extract_l( maxScaling ), 1 ) ) ) - { - xtract = maxScaling; - move16(); - } - ELSE - { - /* set to last valid element (i.e. element[len - 1] but note for stereo last element is last pair of samples) */ - xtract = sub( s_end, extract_l( ps->num_channels ) ); - } - } - ELSE - { - /* find synch */ - scaleSignal16( frm_in_fx, ps->frmInScaled, l_frm, ps->signalScaleForCorrelation ); - findSynchResult = find_synch_fx( ps, ps->frmInScaled, l_frm, s_start, (UWord16) ( sub( s_end, s_start ) ), 0, l_seg, 0, &energy_fx, &quality_fx, &xtract ); - } - - /* assert synch_pos is cleanly divisible by number of channels */ - assert( xtract % ps->num_channels == 0 ); - - /* set frame overlappable - reset if necessary */ - over = 1; - move16(); - - /* test whether frame has sufficient quality */ - IF( LT_32( quality_fx, L_add( L_sub( ps->targetQuality_fx, - L_mult0( ps->bad_frame_count, 6554 ) ), - L_mult0( ps->good_frame_count, 13107 ) ) ) ) - { - /* not sufficient */ - over = 0; - move16(); - IF( LT_32( ps->bad_frame_count, ps->qualityred ) ) - { - ps->bad_frame_count = u_extract_l( UL_addNsD( ps->bad_frame_count, 1 ) ); - move16(); - } - IF( GT_32( ps->good_frame_count, 0 ) ) - { - ps->good_frame_count = u_extract_l( UL_subNsD( ps->good_frame_count, 1 ) ); - move16(); - } - } - ELSE - { - /* sufficient quality */ - IF( GT_32( ps->bad_frame_count, 0 ) ) - { - ps->bad_frame_count = u_extract_l( UL_subNsD( ps->bad_frame_count, 1 ) ); - move16(); - } - IF( LT_32( ps->good_frame_count, ps->qualityrise ) ) - { - ps->good_frame_count = u_extract_l( UL_addNsD( ps->good_frame_count, 1 ) ); - move16(); - } - } - /* Calculate output data */ - test(); - IF( over && xtract ) - { - IF( findSynchResult == 1 ) - { - return 1; - } - IF( ps->evs_compat_mode == true ) - { - // overlapAddEvs_fx( frm_in_fx, frm_in_fx + xtract, frm_out_fx, l_seg, ps->num_channels, ps->win_fx + ps->l_halfwin_fx, ps->win_fx ); - overlapAdd( frm_in_fx, frm_in_fx + xtract, frm_out_fx, l_seg, ps->num_channels, ps->win_fx + ps->l_halfwin, ps->win_fx, ps->win_incrementor ); - } - ELSE - { - overlapAdd( frm_in_fx, frm_in_fx + xtract, frm_out_fx, l_seg, ps->num_channels, ps->win_fx + ps->l_halfwin, ps->win_fx, ps->win_incrementor ); - } - } - ELSE - { - xtract = 0; - move16(); - FOR( i = 0; i < l_seg; i++ ) - { - frm_out_fx[i] = frm_in_fx[i]; - move16(); - } - } - - /* append remaining samples */ - l_rem = extract_l( L_sub( L_sub( l_frm, xtract ), l_seg ) ); - FOR( i = 0; i < l_rem; i++ ) - { - frm_out_fx[l_seg + i] = frm_in_fx[l_frm - l_rem + i]; - move16(); - } - - /* set output length */ - *l_frm_out = u_extract_l( UL_addNsD( l_seg, l_rem ) ); - move16(); - - return 0; -} - -#endif // !HARMONIZE_2481_EXTEND_SHRINK - -#ifndef HARMONIZE_2481_EXTEND_SHRINK -static bool shrink_frm_ivas_fx( - apa_state_t *ps, - const Word16 frm_in_fx[], // Qx - UWord16 maxScaling, - Word16 frm_out_fx[], // Qx - Word16 Q_frm_in, - UWord16 *l_frm_out ) -#else static bool shrink_frm_fx( apa_state_t *ps, const Word16 frm_in_fx[], // Qx @@ -1806,7 +1598,6 @@ static bool shrink_frm_fx( Word16 Q_frm_in, UWord16 *l_frm_out, bool bIsEVS ) -#endif // !HARMONIZE_2481_EXTEND_SHRINK { bool findSynchResult = 0; move16(); @@ -1817,9 +1608,7 @@ static bool shrink_frm_fx( Word32 quality_fx = 0; UWord16 l_frm; UWord16 l_seg; -#ifdef HARMONIZE_2481_EXTEND_SHRINK bool bIsSilence; -#endif // HARMONIZE_2481_EXTEND_SHRINK move16(); move32(); @@ -1844,9 +1633,6 @@ static bool shrink_frm_fx( } /* calculate overlap position */ -#ifndef HARMONIZE_2481_EXTEND_SHRINK - IF( isSilence_ivas_fx( frm_in_fx, Q_frm_in, l_seg, 10 ) ) -#else IF( bIsEVS ) { @@ -1857,7 +1643,6 @@ static bool shrink_frm_fx( bIsSilence = isSilence_ivas_fx( frm_in_fx, Q_frm_in, l_seg, 10 ); } IF( bIsSilence ) -#endif // !HARMONIZE_2481_EXTEND_SHRINK { /* maximum scaling */ energy_fx = -65 * ( 1 << 8 ); // Q8 @@ -1898,13 +1683,6 @@ static bool shrink_frm_fx( { /* find synch */ scaleSignal16( frm_in_fx, ps->frmInScaled, l_frm, ps->signalScaleForCorrelation ); -#ifndef HARMONIZE_2481_EXTEND_SHRINK - ps->signalScaleForCorrelation = sub( ps->signalScaleForCorrelation, Q_frm_in ); - move16(); - findSynchResult = find_synch_fx( ps, ps->frmInScaled, l_frm, s_start, (UWord16) ( sub( s_end, s_start ) ), 0, l_seg, 0, &energy_fx, &quality_fx, &xtract ); - ps->signalScaleForCorrelation = add( ps->signalScaleForCorrelation, Q_frm_in ); - move16(); -#else IF( bIsEVS ) { findSynchResult = find_synch_fx( ps, ps->frmInScaled, l_frm, s_start, (UWord16) ( sub( s_end, s_start ) ), 0, l_seg, 0, &energy_fx, &quality_fx, &xtract ); @@ -1917,7 +1695,6 @@ static bool shrink_frm_fx( ps->signalScaleForCorrelation = add( ps->signalScaleForCorrelation, Q_frm_in ); move16(); } -#endif // !HARMONIZE_2481_EXTEND_SHRINK } /* assert synch_pos is cleanly divisible by number of channels */ @@ -1949,11 +1726,7 @@ static bool shrink_frm_fx( ELSE { /* sufficient quality */ -#ifndef HARMONIZE_2481_EXTEND_SHRINK - IF( ps->bad_frame_count > 0 ) -#else IF( GT_32( ps->bad_frame_count, 0 ) ) -#endif // !HARMONIZE_2481_EXTEND_SHRINK { ps->bad_frame_count = u_extract_l( UL_subNsD( ps->bad_frame_count, 1 ) ); move16(); @@ -2029,271 +1802,7 @@ static bool shrink_frm_fx( * ******************************************************************************** */ -#ifndef HARMONIZE_2481_EXTEND_SHRINK -static bool extend_frm_fx( - apa_state_t *ps, - const Word16 frm_in_fx[], // Qx - Word16 frm_out_fx[], // Qx - UWord16 *l_frm_out ) -{ - bool findSynchResult = 0; - UWord16 l_frm_out_target; - UWord16 n, i; - Word16 N; - Word16 s[MAXN + 2], s_max, s_min; - Word16 xtract[MAXN + 2], sync_start, s_end; - UWord16 over[MAXN + 2]; - Word16 l_rem; - Word16 s_start = 0; - move16(); - Word16 energy_fx; - Word32 quality_fx = 0; - move32(); - UWord16 l_frm, l_seg; - const Word16 *fadeOut_fx, *fadeIn_fx; - Word16 *out_fx; - l_frm = ps->l_frm; - l_seg = ps->l_seg; - move16(); - move16(); - /* number of segments/iterations */ - l_frm_out_target = (UWord16) ( L_add( l_frm, L_shr( l_frm, 1 ) ) ); - //(l_frm_out_target/l_seg -1 ) - Word16 tmp, tmp_e; - tmp = BASOP_Util_Divide3232_Scale( l_frm_out_target, l_seg, &tmp_e ); - tmp = shr( tmp, sub( 15, tmp_e ) ); - N = sub( ( tmp ), 1 ); - if ( LT_16( N, 1 ) ) - { - N = 1; - move16(); - } - IF( GT_16( N, MAXN ) ) - { - return 1; - } - /* calculate equally spaced search regions */ - /* s[n] are given relative to 2nd frame and point to the start of */ - /* the search region. The first segment (n=1) will not be moved. */ - /* Hence, the iterations will start with n=2. */ - s_min = extract_l( L_negate( L_add( ps->l_search, ps->p_min ) ) ); - /* (make sure not to exceed array dimension) */ - IF( L_add( l_frm, s_min ) < 0 ) - { - s_min = extract_l( L_negate( l_frm ) ); - } - s_max = extract_l( L_sub( L_sub( l_frm, L_shl( l_seg, 1 ) ), ps->l_search ) ); - if ( s_max < s_min ) - { - N = 1; - move16(); - } - /* for just one segment start at s_min */ - if ( N == 1 ) - { - s[2] = s_min; - move16(); - } - /* else, spread linear in between s_min and s_max */ - /* (including s_min and s_max) */ - ELSE - { - FOR( n = 2; n <= ( N + 1 ); n++ ) - { - // s[n] = s_min + ( ( s_max - s_min ) * ( n - 2 ) ) / ( N - 1 ); - Word16 tmp2, tmp2_e; - tmp2 = sub( s_max, s_min ); - tmp2 = i_mult( tmp2, extract_l( L_sub( n, 2 ) ) ); - tmp2 = BASOP_Util_Divide1616_Scale( tmp2, sub( N, 1 ), &tmp2_e ); - tmp2 = shr( tmp2, sub( 15, tmp2_e ) ); - s[n] = add( s_min, tmp2 ); - move16(); - } - } - - /* - * Planning Phase - */ - - xtract[1] = extract_l( L_negate( l_seg ) ); /* make sync_start=0 in 1st iteration */ - move16(); - n = 2; - move16(); - /* define synch segment (to be correlated with search region) */ - sync_start = extract_l( L_add( xtract[n - 1], l_seg ) ); - over[n] = 1; /* will be reset if overlap is not required */ - move16(); - /* check end of search region: should be at least p_min */ - /* samples on the left of synch_start */ - IF( LT_32( L_add( s[n], ps->l_search ), L_sub( sync_start, ( ps->p_min ) ) ) ) - { - s_start = s[n]; - move16(); - s_end = extract_l( L_add( s_start, ps->l_search ) ); - } - ELSE - { - /* shrink search region to enforce minimum shift */ - s_end = extract_l( L_sub( sync_start, ( ps->p_min ) ) ); - IF( LT_16( extract_l( L_add( s[n], ps->l_search ) ), sync_start ) ) - { - s_start = s[n]; /* just do it with normal start position */ - move16(); - } - ELSE IF( EQ_32( n, L_add( N, 1 ) ) ) /* move search region left for last segment */ - { - s_start = extract_l( L_sub( s_end, L_sub( ps->l_search, ps->p_min ) ) ); - } - ELSE - { - over[n] = 0; /* don't search/overlap (just copy down) */ - move16(); - } - } - - IF( over[n] ) - { - /* calculate overlap position */ - IF( isSilence_fx( frm_in_fx, l_seg, 10 ) ) - { - /* maximum scaling */ - energy_fx = -65 * ( 1 << 8 ); // Q8 - move16(); - quality_fx = 5 << 16; // Q16 - move32(); - xtract[n] = extract_l( L_add( s_start, ps->num_channels ) ); - move16(); - IF( ps->evs_compat_mode == false ) - { - /* take renderer buffer samples into accout */ - xtract[n] = extract_l( L_add( xtract[n], ps->l_r_buf ) ); - /* snap to next renderer time slot border to resynchronize */ - // xtract[n] -= ( ( N - 1 ) * l_seg - xtract[n] + ps->l_r_buf ) % ps->l_ts; - Word16 tmp3; - tmp3 = extract_l( L_add( L_sub( W_extract_l( W_mult0_32_32( L_sub( N, 1 ), l_seg ) ), xtract[n] ), ps->l_r_buf ) ); - xtract[n] = sub( xtract[n], tmp3 % ps->l_ts ); - move16(); - move16(); - } - } - ELSE - { - Word16 *frmInScaled; - frmInScaled = ps->frmInScaled; - assert( sizeof( ps->frmInScaled ) / sizeof( ps->frmInScaled[0] ) >= 2 * (size_t) l_frm ); - scaleSignal16( frm_in_fx, frmInScaled, shl( l_frm, 1 ), ps->signalScaleForCorrelation ); - findSynchResult = find_synch_fx( ps, frmInScaled, extract_l( L_shl( l_frm, 1 ) ), s_start, sub( s_end, s_start ), sync_start, l_seg, l_frm, &energy_fx, &quality_fx, &xtract[n] ); - } - /* assert synch_pos is cleanly divisible by number of channels */ - assert( xtract[n] % ps->num_channels == 0 ); - - /* test for sufficient quality */ - IF( LT_32( quality_fx, L_add( L_sub( ps->targetQuality_fx, - L_mult0( ps->bad_frame_count, 6554 /*.1f in Q16*/ ) ), - L_mult0( ps->good_frame_count, 13107 /*.1f in Q16*/ ) ) ) ) - { - /* not sufficient */ - over[n] = 0; - move16(); - xtract[n] = sync_start; - move16(); - IF( LT_32( ps->bad_frame_count, ps->qualityred ) ) - { - ps->bad_frame_count = u_extract_l( UL_addNsD( ps->bad_frame_count, 1 ) ); - move16(); - } - IF( GT_32( ps->good_frame_count, 0 ) ) - { - ps->good_frame_count = u_extract_l( UL_subNsD( ps->good_frame_count, 1 ) ); - move16(); - } - } - ELSE - { - /* sufficient quality */ - IF( GT_32( ps->bad_frame_count, 0 ) ) - { - ps->bad_frame_count = u_extract_l( UL_subNsD( ps->bad_frame_count, 1 ) ); - move16(); - } - IF( LT_32( ps->good_frame_count, ps->qualityrise ) ) - { - ps->good_frame_count = u_extract_l( UL_addNsD( ps->good_frame_count, 1 ) ); - move16(); - } - } - IF( findSynchResult ) - { - return 1; - } - } - ELSE - { - xtract[n] = sync_start; - move16(); - } - - - /* Calculate output data */ - FOR( n = 2; n <= N; n++ ) - { - test(); - IF( over[n] && NE_16( extract_l( L_add( xtract[n - 1], l_seg ) ), xtract[n] ) ) - { - /* mix 2nd half of previous segment with 1st half of current segment */ - fadeOut_fx = frm_in_fx + l_frm + xtract[n - 1] + l_seg; - fadeIn_fx = frm_in_fx + l_frm + xtract[n]; - out_fx = frm_out_fx + ( n - 2 ) * l_seg; - IF( ps->evs_compat_mode == true ) - { - // overlapAddEvs_fx( fadeOut_fx, fadeIn_fx, out_fx, l_seg, ps->num_channels, ps->win_fx + ps->l_halfwin_fx, ps->win_fx ); - overlapAdd( fadeOut_fx, fadeIn_fx, out_fx, l_seg, ps->num_channels, ps->win_fx + ps->l_halfwin, ps->win_fx, ps->win_incrementor ); - } - ELSE - { - overlapAdd( fadeOut_fx, fadeIn_fx, out_fx, l_seg, ps->num_channels, ps->win_fx + ps->l_halfwin, ps->win_fx, ps->win_incrementor ); - } - } - ELSE - { - /* just copy down 1st half of current segment (= 2nd half of previous segment) */ - Word16 *frm_out_ptr; - const Word16 *frm_in_ptr; - frm_out_ptr = &( frm_out_fx[( n - 2 ) * l_seg] ); - frm_in_ptr = &( frm_in_fx[l_frm + xtract[n]] ); - FOR( i = 0; i < l_seg; i++ ) - { - frm_out_ptr[i] = frm_in_ptr[i]; - move16(); - } - } - } - - /* append remaining samples */ - l_rem = l_frm - ( xtract[N] + l_seg ); - FOR( i = 0; i < l_rem; i++ ) - { - frm_out_fx[( N - 1 ) * l_seg + i] = frm_in_fx[2 * l_frm - l_rem + i]; - move16(); - } - - /* set output length */ - *l_frm_out = (UWord16) ( W_mult0_32_32( L_sub( N, 1 ), L_add( l_seg, l_rem ) ) ); - move16(); - return 0; -} - -#endif // !HARMONIZE_2481_EXTEND_SHRINK - -#ifndef HARMONIZE_2481_EXTEND_SHRINK -static bool extend_frm_ivas_fx( - apa_state_t *ps, - const Word16 frm_in_fx[], // Qx - Word16 frm_out_fx[], // Qx - Word16 Q_frm_in, - UWord16 *l_frm_out ) -#else static bool extend_frm_fx( apa_state_t *ps, const Word16 frm_in_fx[], // Qx @@ -2301,7 +1810,6 @@ static bool extend_frm_fx( Word16 Q_frm_in, UWord16 *l_frm_out, bool bIsEVS ) -#endif // !HARMONIZE_2481_EXTEND_SHRINK { bool findSynchResult = 0; move16(); @@ -2318,9 +1826,7 @@ static bool extend_frm_fx( Word32 quality_fx = 0; move32(); UWord16 l_frm, l_seg; -#ifdef HARMONIZE_2481_EXTEND_SHRINK bool bIsSilence; -#endif // HARMONIZE_2481_EXTEND_SHRINK const Word16 *fadeOut_fx, *fadeIn_fx; Word16 *out_fx; @@ -2427,9 +1933,6 @@ static bool extend_frm_fx( IF( over[n] ) { /* calculate overlap position */ -#ifndef HARMONIZE_2481_EXTEND_SHRINK - IF( isSilence_ivas_fx( frm_in_fx, Q_frm_in, l_seg, 10 ) ) -#else IF( bIsEVS ) { bIsSilence = isSilence_fx( frm_in_fx, l_seg, 10 ); @@ -2439,7 +1942,6 @@ static bool extend_frm_fx( bIsSilence = isSilence_ivas_fx( frm_in_fx, Q_frm_in, l_seg, 10 ); } IF( bIsSilence ) -#endif // !HARMONIZE_2481_EXTEND_SHRINK { /* maximum scaling */ energy_fx = -65 * ( 1 << 8 ); // Q8 @@ -2467,11 +1969,6 @@ static bool extend_frm_fx( frmInScaled = ps->frmInScaled; assert( sizeof( ps->frmInScaled ) / sizeof( ps->frmInScaled[0] ) >= 2 * (size_t) l_frm ); scaleSignal16( frm_in_fx, frmInScaled, shl( l_frm, 1 ), ps->signalScaleForCorrelation ); -#ifndef HARMONIZE_2481_EXTEND_SHRINK - ps->signalScaleForCorrelation = sub( ps->signalScaleForCorrelation, Q_frm_in ); - findSynchResult = find_synch_fx( ps, frmInScaled, extract_l( L_shl( l_frm, 1 ) ), s_start, sub( s_end, s_start ), sync_start, l_seg, l_frm, &energy_fx, &quality_fx, &xtract[n] ); - ps->signalScaleForCorrelation = add( ps->signalScaleForCorrelation, Q_frm_in ); -#else IF( bIsEVS ) { findSynchResult = find_synch_fx( ps, frmInScaled, extract_l( L_shl( l_frm, 1 ) ), s_start, sub( s_end, s_start ), sync_start, l_seg, l_frm, &energy_fx, &quality_fx, &xtract[n] ); @@ -2482,7 +1979,6 @@ static bool extend_frm_fx( findSynchResult = find_synch_fx( ps, frmInScaled, extract_l( L_shl( l_frm, 1 ) ), s_start, sub( s_end, s_start ), sync_start, l_seg, l_frm, &energy_fx, &quality_fx, &xtract[n] ); ps->signalScaleForCorrelation = add( ps->signalScaleForCorrelation, Q_frm_in ); } -#endif // !HARMONIZE_2481_EXTEND_SHRINK } /* assert synch_pos is cleanly divisible by number of channels */ assert( xtract[n] % ps->num_channels == 0 ); diff --git a/lib_dec/jbm_pcmdsp_similarityestimation.h b/lib_dec/jbm_pcmdsp_similarityestimation.h index af12f22ba..7a6d9f6da 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation.h +++ b/lib_dec/jbm_pcmdsp_similarityestimation.h @@ -64,12 +64,7 @@ Word32 cross_correlation_self_fx( const Word16 *signal, Word16 y, Word16 corr_len ); -#ifdef HARMONIZE_2481_EXTEND_SHRINK bool isSilence_fx( const Word16 *signal, Word16 len, Word16 segments ); bool isSilence_ivas_fx( const Word16 *signal, Word16 q_sig, Word16 len, Word16 segments ); -#else -Word8 isSilence_fx( const Word16 *signal, Word16 len, Word16 segments ); -Word8 isSilence_ivas_fx( const Word16 *signal, Word16 q_sig, Word16 len, Word16 segments ); -#endif #endif /* JBM_PCMDSP_SIMILARITYESTIMATION_H */ diff --git a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c index e1ddd5993..e088a38a6 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c @@ -190,19 +190,11 @@ Word32 cross_correlation_self_fx( const Word16 *signal, return sum; } -#ifdef HARMONIZE_2481_EXTEND_SHRINK bool isSilence_fx( const Word16 *signal, Word16 len, Word16 segments ) -#else -Word8 isSilence_fx( const Word16 *signal, Word16 len, Word16 segments ) -#endif { Word16 i, j, samplesPerSegment; Word32 energy, maxEnergy; -#ifdef HARMONIZE_2481_EXTEND_SHRINK bool ret; -#else - Word8 ret; -#endif assert( len > 0 ); assert( segments > 0 ); @@ -213,11 +205,7 @@ Word8 isSilence_fx( const Word16 *signal, Word16 len, Word16 segments ) * 20 * log10(sum_i(abs(signal[i]))) > -65 */ -#ifdef HARMONIZE_2481_EXTEND_SHRINK ret = true; -#else - ret = 1; -#endif move16(); energy = 0; move32(); @@ -239,11 +227,7 @@ Word8 isSilence_fx( const Word16 *signal, Word16 len, Word16 segments ) * => energy > samplesPerSegment * 10 ^ (-65 / 20) * 32768 */ IF( GT_32( energy, maxEnergy ) ) { -#ifdef HARMONIZE_2481_EXTEND_SHRINK ret = false; -#else - ret = 0; -#endif move16(); BREAK; } @@ -255,22 +239,14 @@ Word8 isSilence_fx( const Word16 *signal, Word16 len, Word16 segments ) /* check last segment */ if ( GT_32( energy, maxEnergy ) ) { -#ifdef HARMONIZE_2481_EXTEND_SHRINK ret = false; -#else - ret = 0; -#endif move16(); } return ret; } -#ifdef HARMONIZE_2481_EXTEND_SHRINK bool isSilence_ivas_fx( const Word16 *signal, Word16 q_sig, Word16 len, Word16 segments ) -#else -Word8 isSilence_ivas_fx( const Word16 *signal, Word16 q_sig, Word16 len, Word16 segments ) -#endif { Word16 i, j, samplesPerSegment; Word64 energy, maxEnergy; @@ -301,11 +277,7 @@ Word8 isSilence_ivas_fx( const Word16 *signal, Word16 q_sig, Word16 len, Word16 * => energy > samplesPerSegment * 10 ^ (-65 / 10) * 32768 * 32768.0*/ IF( GT_64( energy, maxEnergy ) ) { -#ifdef HARMONIZE_2481_EXTEND_SHRINK return false; -#else - return 0; -#endif } IF( EQ_16( i, j ) ) { @@ -315,9 +287,5 @@ Word8 isSilence_ivas_fx( const Word16 *signal, Word16 q_sig, Word16 len, Word16 } } -#ifdef HARMONIZE_2481_EXTEND_SHRINK return true; -#else - return 1; -#endif } -- GitLab From 82a098e0e7fde882d0688cda36177cb8b219ce60 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 13 Apr 2026 16:45:09 +0200 Subject: [PATCH 05/22] [cleanup] accept FIX_2485_HARMONIZE_perform_noise_estimation_enc --- lib_com/options.h | 1 - lib_enc/fd_cng_enc_fx.c | 355 -------------------------- lib_enc/ivas_core_pre_proc_front_fx.c | 8 - lib_enc/pre_proc_fx.c | 4 - lib_enc/prot_fx_enc.h | 20 -- 5 files changed, 388 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 880828b09..77bb41670 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -91,7 +91,6 @@ #define NONBE_FIX_ISSUE_2206_AVOID_OVERFLOW_SWB_fenv_fx2 /* FhG: Avoid overflow of SWB_fenv_fx in SWB_BWE_encoding_fx because of very small energies. */ #define NONBE_FIX_ISSUE_2206_AVOID_OVERFLOW_MSVQ_Interpol_Tran_fx /* FhG: Fix saturation crash in MSVQ_Interpol_Tran_fx() */ #define FIX_2452_HQ_CORE_PEAQ_AVR_RATIO_HARM /* Eri: Basop issue 2453: Fix alignment of peak_avrg_ratio_fx */ -#define FIX_2485_HARMONIZE_perform_noise_estimation_enc /* FhG: harmonize perform_noise_estimation_enc and perform_noise_estimation_enc_ivas */ #define FIX_2485_HARMONIZE_minimum_statistics /* FhG: harmonize minimum_statistics and minimum_statistics_fx */ #define FIX_FLOAT_ISSUE_1546_DEAD_CODE /* FhG: remove dead code reported in the issue*/ #define FIX_FLOAT_1539_G192_FORMAT_SWITCH /* VA/Nokia: reintroduce format switching for g192 bitstreams */ diff --git a/lib_enc/fd_cng_enc_fx.c b/lib_enc/fd_cng_enc_fx.c index 7e813b699..2e0db50f0 100644 --- a/lib_enc/fd_cng_enc_fx.c +++ b/lib_enc/fd_cng_enc_fx.c @@ -405,168 +405,6 @@ void resetFdCngEnc_fx( return; } -#ifndef FIX_2485_HARMONIZE_perform_noise_estimation_enc -/* - perform_noise_estimation_enc_fx - - Parameters: - - band_energies i : energy in critical bands without minimum noise floor MODE2_E_MIN - band_energies_exp i : exponent for energy in critical bands without minimum noise floor MODE2_E_MIN - cldfbBufferReal, i : real part of the CLDFB buffer - cldfbBufferImag, i : imaginary part of the CLDFB buffer - cldfbBufferExp, i : exponent for CLDFB buffer - bitrate i : bitrate - st i/o: FD_CNG structure containing all buffers and variables - - Function: - Perform noise estimation - - Returns: - void -*/ -void perform_noise_estimation_enc_fx( - Word32 *band_energies, /* i : energy in critical bands without minimum noise floor MODE2_E_MIN band_energies_exp*/ - Word16 band_energies_exp, /* i : exponent for energy in critical bands without minimum noise floor MODE2_E_MIN */ - Word32 *enerBuffer, /* enerBuffer_exp */ - Word16 enerBuffer_exp, - HANDLE_FD_CNG_ENC st /* i/o: FD_CNG structure containing all buffers and variables */ -) -{ - Word16 i, j, s, s1, s2; - Word16 nFFTpart; - Word16 nCLDFBpart; - Word16 numBands; - Word16 numCoreBands; - Word16 regularStopBand; - Word16 numSlots; - Word32 tmp; - Word32 *periodog; - Word32 *ptr_per; - Word32 *msPeriodog; - - nFFTpart = st->hFdCngCom->nFFTpart; - move16(); - nCLDFBpart = st->hFdCngCom->nCLDFBpart; - move16(); - numCoreBands = st->hFdCngCom->numCoreBands; - move16(); - regularStopBand = st->hFdCngCom->regularStopBand; - move16(); - numSlots = st->hFdCngCom->numSlots; - move16(); - periodog = st->hFdCngCom->periodog; - move16(); - ptr_per = periodog; - move16(); - msPeriodog = st->msPeriodog_fx; - move16(); - - assert( numSlots == 16 ); - - /* preemphasis compensation and grouping of per bin energies into msPeriodog */ - FOR( i = 0; i < nFFTpart; i++ ) - { - tmp = L_add( L_shr( band_energies[i], 1 ), L_shr( band_energies[i + NB_BANDS], 1 ) ); /* exp(band_energies_exp) */ - msPeriodog[i] = Mpy_32_16_1( tmp, preemphCompensation_fx[i] ); /* exp(band_energies_exp + 4) */ - move32(); - } - - /* exponent for fft part of msPeriodog */ - st->msPeriodog_fx_exp_fft = add( band_energies_exp, PREEMPH_COMPENSATION_EXP ); - move16(); - - numBands = sub( regularStopBand, numCoreBands ); /* Q0 */ - - IF( numBands > 0 ) - { - /* Adjust to the desired time resolution by averaging the periodograms over the CLDFB time slots */ - - FOR( j = numCoreBands; j < regularStopBand; j++ ) - { - *ptr_per = Mpy_32_16_1( enerBuffer[j], st->hFdCngCom->scalingFactor ); /* exp(enerBuffer_exp) */ - move32(); - - ptr_per++; - } - - /* exponent for cldfb part of msPeriodog */ - st->hFdCngCom->exp_cldfb_periodog = add( sub( enerBuffer_exp, 4 ), CLDFBscalingFactor_EXP ); - - /* Adjust CLDFB filterbank to the desired frequency resolution by averaging over spectral partitions for SID transmission */ - bandcombinepow( - periodog, - st->hFdCngCom->exp_cldfb_periodog, - numBands, - st->hFdCngCom->CLDFBpart, - st->hFdCngCom->nCLDFBpart, - st->hFdCngCom->CLDFBpsize_inv, - &msPeriodog[nFFTpart], - &st->msPeriodog_fx_exp_cldfb ); - - /* find common exponent for fft part and cldfb part of msperiodog */ - s1 = getScaleFactor32( msPeriodog, nFFTpart ); - s2 = getScaleFactor32( &msPeriodog[nFFTpart], nCLDFBpart ); - - s = s_max( sub( st->msPeriodog_fx_exp_fft, s1 ), sub( st->msPeriodog_fx_exp_cldfb, s2 ) ); - s1 = sub( s, st->msPeriodog_fx_exp_fft ); - s2 = sub( s, st->msPeriodog_fx_exp_cldfb ); - - st->msPeriodog_fx_exp_fft = s; - move16(); - st->msPeriodog_fx_exp_cldfb = s; - move16(); - - FOR( i = 0; i < nFFTpart; i++ ) - { - msPeriodog[i] = L_shr( msPeriodog[i], s1 ); // st->msPeriodog_fx_exp_fft - move32(); - } - - FOR( i = 0; i < nCLDFBpart; i++ ) - { - msPeriodog[nFFTpart + i] = L_shr( msPeriodog[nFFTpart + i], s_min( 31, s2 ) ); // st->msPeriodog_fx_exp_fft - move32(); - } - } - - /* exponent for entire msPeriodog vector */ - st->msPeriodog_fx_exp = st->msPeriodog_fx_exp_fft; - move16(); - - /* Compress MS inputs */ - compress_range( st->msPeriodog_fx, st->msPeriodog_fx_exp, st->msLogPeriodog_fx, st->hFdCngCom->npart ); - - /* Call the minimum statistics routine for noise estimation */ - minimum_statistics( - st->hFdCngCom->npart, - st->hFdCngCom->nFFTpart, - st->hFdCngCom->psize_norm, - st->msLogPeriodog_fx, - st->msNoiseFloor_fx, - st->msLogNoiseEst_fx, - st->msAlpha_fx, - st->msPsd_fx, - st->msPsdFirstMoment_fx, - st->msPsdSecondMoment_fx, - st->msMinBuf_fx, - st->msBminWin_fx, - st->msBminSubWin_fx, - st->msCurrentMin_fx, - st->msCurrentMinOut_fx, - st->msCurrentMinSubWindow_fx, - st->msLocalMinFlag, - st->msNewMinFlag, - st->msPeriodogBuf_fx, - &( st->msPeriodogBufPtr ), - st->hFdCngCom ); - - /* Expand MS outputs */ - expand_range( st->msLogNoiseEst_fx, st->msNoiseEst_fx, &st->msNoiseEst_fx_exp, st->hFdCngCom->npart ); - - return; -} -#endif /*FIX_2485_HARMONIZE_perform_noise_estimation_enc*/ /* AdjustFirstSID_fx @@ -1745,199 +1583,7 @@ Word16 cng_energy_ivas_fx( return enr; } -#ifndef FIX_2485_HARMONIZE_perform_noise_estimation_enc -void perform_noise_estimation_enc_ivas_fx( - Word32 *band_energies, /* i : energy in critical bands without minimum noise floor MODE2_E_MIN band_energies_exp*/ - Word16 band_energies_exp, - Word32 *enerBuffer, /* enerBuffer_exp */ - Word16 enerBuffer_exp, - HANDLE_FD_CNG_ENC hFdCngEnc, /* i/o: CNG structure containing all buffers and variables */ - const Word32 input_Fs, /* i : input sampling rate Q0*/ - CPE_ENC_HANDLE hCPE /* i : CPE encoder structure */ -) -{ - Word16 i, j, s, s1, s2; - Word16 numBands; - Word16 numCoreBands = hFdCngEnc->hFdCngCom->numCoreBands; /* Q0 */ - move16(); - Word16 regularStopBand = hFdCngEnc->hFdCngCom->regularStopBand; /* Q0 */ - move16(); - Word16 numSlots = hFdCngEnc->hFdCngCom->numSlots; /* Q0 */ - move16(); - assert( numSlots == 16 ); - - Word32 numSlots_inv_fx = 1073741824; // Q34 of .0625 - move32(); - Word32 *periodog = hFdCngEnc->hFdCngCom->periodog; /* exp(peridog_exp) */ - Word32 *ptr_per_fx = periodog; - Word64 periodog_64; - Word16 periodog_exp[PERIODOGLEN]; - Word16 npart = hFdCngEnc->hFdCngCom->npart; /* Q0 */ - move16(); - Word16 nFFTpart = hFdCngEnc->hFdCngCom->nFFTpart; /* Q0 */ - move16(); - Word16 nCLDFBpart = hFdCngEnc->hFdCngCom->nCLDFBpart; /* Q0 */ - move16(); - - Word16 *psize_norm = hFdCngEnc->hFdCngCom->psize_norm; // 6Q9 - Word32 *msPeriodog_fx = hFdCngEnc->msPeriodog_fx; - Word32 *msNoiseEst_fx = hFdCngEnc->msNoiseEst_fx; /* exp(msNoiseEst_fx_exp) */ - - Word16 *msLogPeriodog_fx = hFdCngEnc->msLogPeriodog_fx; - Word32 *msLogNoiseEst_fx = hFdCngEnc->msLogNoiseEst_32fx; - - Word32 scaleEB_fx = 0; - move32(); - Word32 tmp; - - test(); - IF( hCPE != NULL && hCPE->hStereoDft != NULL ) - { - // band_res_dft = ( (float) input_Fs ) / hCPE->hStereoDft->NFFT; - // chan_width_f = 24000.f / CLDFB_NO_CHANNELS_MAX; - // chan_width_bins = chan_width_f / band_res_dft; - - ///* Scaling of Energy buffer to get energy per sample, same scaling as for band_energies, 3 is to compensate for the 1/3 scaling in calculate_energy_buffer */ - // scaleEB = 3 * 4.0f / ( hCPE->hStereoDft->NFFT * hCPE->hStereoDft->NFFT ); - - ///* Scale with number of bins in one band */ - // scaleEB = scaleEB / chan_width_bins; - - SWITCH( input_Fs ) - { - case 8000: - scaleEB_fx = 251648; // Q35 - move32(); - BREAK; - case 16000: - scaleEB_fx = 62912; // Q35 - move32(); - BREAK; - case 32000: - scaleEB_fx = 15728; // Q35 - move32(); - BREAK; - case 48000: - scaleEB_fx = 6991; // Q35 - move32(); - BREAK; - default: - assert( 0 && "invalid sample rate" ); - } - } - ELSE - { - scaleEB_fx = Mpy_32_32( numSlots_inv_fx, L_deposit_l( hFdCngEnc->hFdCngCom->scalingFactor ) ); // Q34 + Q30 - Q31 = Q33 - scaleEB_fx = L_shl( scaleEB_fx, 2 ); // Q35 - } - - /* preemphasis compensation and grouping of per bin energies into msPeriodog */ - FOR( i = 0; i < nFFTpart; i++ ) - { - tmp = L_add( L_shr( band_energies[i], 1 ), L_shr( band_energies[i + NB_BANDS], 1 ) ); - msPeriodog_fx[i] = Mpy_32_16_1( tmp, preemphCompensation_fx[i] ); - move32(); - } - - /* exponent for fft part of msPeriodog */ - hFdCngEnc->msPeriodog_fx_exp_fft = add( band_energies_exp, PREEMPH_COMPENSATION_EXP ); - move16(); - - Word16 max_exp = -31; - move16(); - i = 0; - move16(); - /* Adjust to the desired time resolution by averaging the periodograms over the time slots */ - FOR( j = numCoreBands; j < regularStopBand; j++ ) - { - periodog_64 = W_mult_32_32( enerBuffer[j], scaleEB_fx ); - Word16 scale = W_norm( periodog_64 ); - *ptr_per_fx = W_extract_h( W_shl( periodog_64, scale ) ); - move32(); - periodog_exp[i] = sub( Q31, add( add( sub( Q31, enerBuffer_exp ), 35 - 31 ), scale ) ); - move16(); - if ( *ptr_per_fx ) - { - max_exp = s_max( max_exp, periodog_exp[i] ); - } - ptr_per_fx++; - i++; - } - /* exponent for cldfb part of msPeriodog */ - // hFdCngEnc->hFdCngCom->exp_cldfb_periodog = add( sub( enerBuffer_exp, 4 ), CLDFBscalingFactor_EXP ); - // move16(); - - numBands = sub( regularStopBand, numCoreBands ); /* Q0 */ - FOR( i = 0; i < numBands; i++ ) - { - - periodog[i] = L_shr( periodog[i], sub( max_exp, periodog_exp[i] ) ); - - move16(); - } - hFdCngEnc->hFdCngCom->exp_cldfb_periodog = max_exp; - move16(); - IF( numBands > 0 ) - { - ///* Adjust CLDFB filterbank to the desired frequency resolution by averaging over spectral partitions for SID transmission */ - bandcombinepow( - periodog, - hFdCngEnc->hFdCngCom->exp_cldfb_periodog, - numBands, - hFdCngEnc->hFdCngCom->CLDFBpart, - nCLDFBpart, - hFdCngEnc->hFdCngCom->CLDFBpsize_inv, - &msPeriodog_fx[nFFTpart], - &hFdCngEnc->msPeriodog_fx_exp_cldfb ); - - ///* find common exponent for fft part and cldfb part of msperiodog */ - s1 = L_norm_arr( msPeriodog_fx, nFFTpart ); - s2 = L_norm_arr( &msPeriodog_fx[nFFTpart], nCLDFBpart ); - - s = s_max( sub( hFdCngEnc->msPeriodog_fx_exp_fft, s1 ), sub( hFdCngEnc->msPeriodog_fx_exp_cldfb, s2 ) ); - s1 = sub( s, hFdCngEnc->msPeriodog_fx_exp_fft ); - s2 = sub( s, hFdCngEnc->msPeriodog_fx_exp_cldfb ); - - hFdCngEnc->msPeriodog_fx_exp_fft = s; - move16(); - hFdCngEnc->msPeriodog_fx_exp_cldfb = s; - move16(); - - FOR( i = 0; i < nFFTpart; i++ ) - { - msPeriodog_fx[i] = L_shr( msPeriodog_fx[i], s1 ); /* hFdCngEnc->msPeriodog_fx_exp_fft */ - move32(); - } - - FOR( i = 0; i < nCLDFBpart; i++ ) - { - msPeriodog_fx[nFFTpart + i] = L_shr( msPeriodog_fx[nFFTpart + i], s2 ); /* hFdCngEnc->msPeriodog_fx_exp_fft */ - move32(); - } - } - /* exponent for entire msPeriodog vector */ - hFdCngEnc->msPeriodog_fx_exp = hFdCngEnc->msPeriodog_fx_exp_fft; - move16(); - - /* Compress MS inputs */ - // compress_range_flt( msPeriodog, msLogPeriodog, npart ); - compress_range( msPeriodog_fx, hFdCngEnc->msPeriodog_fx_exp, msLogPeriodog_fx, npart ); - - - /* Call the minimum statistics routine for noise estimation */ - - minimum_statistics_fx( npart, nFFTpart, psize_norm, msLogPeriodog_fx, hFdCngEnc->msNoiseFloor_32fx, msLogNoiseEst_fx, hFdCngEnc->msAlpha_fx, hFdCngEnc->msPsd_fx, hFdCngEnc->msPsdFirstMoment_fx, - hFdCngEnc->msPsdSecondMoment_fx, hFdCngEnc->msMinBuf_fx, hFdCngEnc->msBminWin_fx, hFdCngEnc->msBminSubWin_fx, hFdCngEnc->msCurrentMin_fx, hFdCngEnc->msCurrentMinOut_fx, hFdCngEnc->msCurrentMinSubWindow_fx, hFdCngEnc->msLocalMinFlag, hFdCngEnc->msNewMinFlag, hFdCngEnc->msPeriodogBuf_fx, &( hFdCngEnc->msPeriodogBufPtr ), hFdCngEnc->hFdCngCom, - ENC, ( hCPE == NULL ) ? 0 : hCPE->element_mode ); - - /* Expand MS outputs */ - expand_range_fx( msLogNoiseEst_fx, msNoiseEst_fx, &hFdCngEnc->msNoiseEst_fx_exp, hFdCngEnc->hFdCngCom->npart ); - - return; -} -#endif /*FIX_2485_HARMONIZE_perform_noise_estimation_enc*/ -#ifdef FIX_2485_HARMONIZE_perform_noise_estimation_enc void perform_noise_estimation_enc_fx( Word32 *band_energies, /* i : energy in critical bands without minimum noise floor MODE2_E_MIN band_energies_exp*/ Word16 band_energies_exp, @@ -2214,7 +1860,6 @@ void perform_noise_estimation_enc_fx( return; } -#endif /*FIX_2485_HARMONIZE_perform_noise_estimation_enc*/ /*-------------------------------------------------------------------* diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index 70cf534d7..80116aa5b 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -1000,11 +1000,7 @@ void pre_proc_front_ivas_fx( test(); IF( EQ_16( element_mode, IVAS_CPE_TD ) && lr_vad_enabled && band_energies_LR_fx != NULL ) { -#ifdef FIX_2485_HARMONIZE_perform_noise_estimation_enc perform_noise_estimation_enc_fx( band_energies_LR_fx, sub( Q31, band_energies_LR_fx_q ), enerBuffer_fx, *enerBuffer_fx_exp, st->hFdCngEnc, input_Fs, hCPE, st->element_mode ); -#else - perform_noise_estimation_enc_ivas_fx( band_energies_LR_fx, sub( Q31, band_energies_LR_fx_q ), enerBuffer_fx, *enerBuffer_fx_exp, st->hFdCngEnc, input_Fs, hCPE ); -#endif } ELSE { @@ -1015,11 +1011,7 @@ void pre_proc_front_ivas_fx( st->hFdCngEnc->hFdCngCom->exp_cldfb_periodog = sub( st->hFdCngEnc->hFdCngCom->exp_cldfb_periodog, norm ); move16(); } -#ifdef FIX_2485_HARMONIZE_perform_noise_estimation_enc perform_noise_estimation_enc_fx( band_energies_fx, sub( Q31, q_band_energies ), enerBuffer_fx, *enerBuffer_fx_exp, st->hFdCngEnc, input_Fs, hCPE, st->element_mode ); -#else - perform_noise_estimation_enc_ivas_fx( band_energies_fx, sub( Q31, q_band_energies ), enerBuffer_fx, *enerBuffer_fx_exp, st->hFdCngEnc, input_Fs, hCPE ); -#endif } } } diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c index 020d0e8a3..c5cc50341 100644 --- a/lib_enc/pre_proc_fx.c +++ b/lib_enc/pre_proc_fx.c @@ -323,11 +323,7 @@ void pre_proc_fx( resetFdCngEnc_fx( st ); -#ifdef FIX_2485_HARMONIZE_perform_noise_estimation_enc perform_noise_estimation_enc_fx( st->band_energies, st->band_energies_exp, enerBuffer, enerBuffer_exp, st->hFdCngEnc, 0, NULL, EVS_MONO ); -#else - perform_noise_estimation_enc_fx( st->band_energies, st->band_energies_exp, enerBuffer, enerBuffer_exp, st->hFdCngEnc ); -#endif /*-----------------------------------------------------------------* * Select SID or FRAME_NO_DATA frame if DTX enabled diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index f5f2d2dcf..cb86ecd56 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -1632,7 +1632,6 @@ void configureFdCngEnc_fx( ); /* Perform noise estimation */ -#ifdef FIX_2485_HARMONIZE_perform_noise_estimation_enc void perform_noise_estimation_enc_fx( Word32 *band_energies, /* i : energy in critical bands without minimum noise floor MODE2_E_MIN band_energies_exp*/ Word16 band_energies_exp, @@ -1643,25 +1642,6 @@ void perform_noise_estimation_enc_fx( CPE_ENC_HANDLE hCPE, /* i : CPE encoder structure */ Word16 element_mode /* i : is element EVS or IVAS */ ); -#else -void perform_noise_estimation_enc_fx( - Word32 *band_energies, /* i : energy in critical bands without minimum noise floor MODE2_E_MIN exp_band_energies*/ - Word16 exp_band_energies, - Word32 *enerBuffer, /* enerBuffer_exp */ - Word16 enerBuffer_exp, - HANDLE_FD_CNG_ENC st /* i/o: FD_CNG structure containing all buffers and variables */ -); - -void perform_noise_estimation_enc_ivas_fx( - Word32 *band_energies, /* i : energy in critical bands without minimum noise floor MODE2_E_MIN band_energies_exp*/ - Word16 band_energies_exp, - Word32 *enerBuffer, /* enerBuffer_exp */ - Word16 enerBuffer_exp, - HANDLE_FD_CNG_ENC hFdCngEnc, /* i/o: CNG structure containing all buffers and variables */ - const Word32 input_Fs, /* i : input sampling rate Q0*/ - CPE_ENC_HANDLE hCPE /* i : CPE encoder structure */ -); -#endif /* Adjust the noise estimator at the beginning of each CNG phase (encoder-side) */ Word16 AdjustFirstSID_fx( -- GitLab From c6b28724e2eca154b9aca74db618c93b2837f31c Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 13 Apr 2026 16:45:59 +0200 Subject: [PATCH 06/22] [cleanup] accept FIX_2485_HARMONIZE_minimum_statistics --- lib_com/fd_cng_com_fx.c | 1207 --------------------------------------- lib_com/options.h | 1 - lib_com/prot_fx.h | 52 -- lib_dec/fd_cng_dec_fx.c | 25 - lib_enc/fd_cng_enc_fx.c | 61 -- 5 files changed, 1346 deletions(-) diff --git a/lib_com/fd_cng_com_fx.c b/lib_com/fd_cng_com_fx.c index 75a9edce3..77b374099 100644 --- a/lib_com/fd_cng_com_fx.c +++ b/lib_com/fd_cng_com_fx.c @@ -484,1212 +484,6 @@ void expand_range_var_exp( return; } -#ifndef FIX_2485_HARMONIZE_minimum_statistics -/*------------------------------------------------------------------- - * minimum_statistics() - * - * Noise estimation using Minimum Statistics (MS) - *-------------------------------------------------------------------*/ - -void minimum_statistics( - Word16 len, /* i : Total number of partitions (CLDFB or FFT) */ - Word16 lenFFT, /* i : Number of FFT partitions */ - Word16 *psize, /* i : Partition sizes, fractional */ - Word16 *msPeriodog, /* i : Periodogram (energies) */ - Word16 *msNoiseFloor, /* i/o: Noise floors (energies) */ - Word16 *msNoiseEst, /* i/o: Noise estimates (energies) */ - Word32 *msAlpha, /* i/o: Forgetting factors */ - Word16 *msPsd, /* i/o: Power Spectral Density (smoothed periodogram => energies) */ - Word16 *msPsdFirstMoment, /* i/o: PSD statistics of 1st order (energy means) */ - Word32 *msPsdSecondMoment, /* i/o: PSD statistics of 2nd order (energy variances) */ - Word32 *msMinBuf, /* i/o: Buffer of minima (energies) */ - Word32 *msBminWin, /* o : Bias correction factors */ - Word32 *msBminSubWin, /* o : Bias correction factors */ - Word32 *msCurrentMin, /* i/o: Local minima (energies) */ - Word32 *msCurrentMinOut, /* i/o: Local minima (energies) */ - Word32 *msCurrentMinSubWindow, /* i/o: Local minima (energies) */ - Word16 *msLocalMinFlag, /* i : Binary flag */ - Word16 *msNewMinFlag, /* i : Binary flag */ - Word16 *msPeriodogBuf, /* i/o: Buffer of periodograms (energies) */ - Word16 *msPeriodogBufPtr, /* i/o: Counter */ - HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */ -) -{ - Word16 i, j, k, s, s1, s2, s3; - Word16 len2; - Word16 current_len; - Word16 start, stop, cnt; - Word16 totsize; - Word16 inv_totsize; - - Word32 tmp, tmp0, tmp1; - Word32 scalar, scalar2, scalar3; - Word32 snr; - Word32 msAlphaHatMin2; - Word32 BminCorr; - Word32 QeqInvAv; - Word32 *ptr; - Word32 *msPsdSum; - Word32 *msPeriodogSum; - - Word16 tmp16, tmp16_1; - Word16 beta; - Word16 slope; - Word16 QeqInv; - Word16 scalar16; - Word16 scalar216; - Word16 scalar316; - Word16 msM_win; - Word16 msM_subwin; - Word16 msAlphaCorAlpha; - Word16 msAlphaCorAlpha2; - Word16 msPeriodogSum16; - Word16 msNoiseFloor16; - - len2 = i_mult( MSNUMSUBFR, len ); - - msM_win = hFdCngCom->msM_win; - move16(); - msM_subwin = hFdCngCom->msM_subwin; - move16(); - - msAlphaCorAlpha = MSALPHACORALPHA; - move16(); - msAlphaCorAlpha2 = MSALPHACORALPHA2; - move16(); - - msPsdSum = hFdCngCom->msPsdSum; - msPeriodogSum = hFdCngCom->msPeriodogSum; - - /* No minimum statistics at initialization */ - IF( LT_16( hFdCngCom->msFrCnt_init_counter, hFdCngCom->msFrCnt_init_thresh ) ) - { - Copy( msPeriodog, msPsd, len ); /* 6Q9 */ - Copy( msPeriodog, msNoiseFloor, len ); /* 6Q9 */ - Copy( msPeriodog, msNoiseEst, len ); /* 6Q9 */ - Copy( msPeriodog, msPsdFirstMoment, len ); /* 6Q9 */ - - set32_fx( msPsdSecondMoment, 0l /*0.0 Q31*/, len ); - msPeriodogSum[0] = dotp_s_fx( msPeriodog, psize, lenFFT, CNG_HS ); - move32(); - msPsdSum[0] = msPeriodogSum[0]; /* 16Q15 */ - move32(); - - IF( LT_16( lenFFT, len ) ) - { - msPeriodogSum[1] = dotp_s_fx( msPeriodog + lenFFT, psize + lenFFT, sub( len, lenFFT ), CNG_HS ); - move32(); - msPsdSum[1] = msPeriodogSum[1]; /* 16Q15 */ - move32(); - } - - /* Increment frame counter at initialization */ - /* Some frames are sometimes zero at initialization => ignore them */ - IF( LT_16( msPeriodog[0], hFdCngCom->init_old ) ) - { - set32_fx( msCurrentMinOut, 2147483647l /*1.0 Q31*/, len ); /* 16Q15 */ - set32_fx( msCurrentMin, 2147483647l /*1.0 Q31*/, len ); /* 16Q15 */ - set32_fx( msMinBuf, 2147483647l /*1.0 Q31*/, len2 ); /* 16Q15 */ - set32_fx( msCurrentMinSubWindow, 2147483647l /*1.0 Q31*/, len ); /* 16Q15 */ - - hFdCngCom->msFrCnt_init_counter = add( hFdCngCom->msFrCnt_init_counter, 1 ); - move16(); - } - hFdCngCom->init_old = msPeriodog[0]; /* 6Q9 */ - move16(); - } - ELSE - { - /* Consider the FFT and CLDFB bands separately - - first iteration for FFT bins, - - second one for CLDFB bands in SWB mode */ - cnt = 0; - move16(); - start = 0; - move16(); - stop = lenFFT; - move16(); - totsize = sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ); - WHILE( GT_16( stop, start ) ) - { - current_len = sub( stop, start ); - - /* Compute smoothed correction factor for PSD smoothing */ - - /* msPeriodogSum[cnt] with format 16Q15 */ - msPeriodogSum[cnt] = dotp_s_fx( msPeriodog + start, psize + start, current_len, CNG_HS ); - move32(); - - IF( msPeriodogSum[cnt] == 0 ) - { - hFdCngCom->msAlphaCor[cnt] = Mpy_32_16_1( hFdCngCom->msAlphaCor[cnt], msAlphaCorAlpha ); - move32(); - } - ELSE - { - /* calculate scalar with normalized msPeriodogSum[cnt], exponent -2*s1 */ - s1 = norm_l( msPeriodogSum[cnt] ); - msPeriodogSum16 = round_fx_sat( L_shl_sat( msPeriodogSum[cnt], s1 ) ); - scalar = L_mult( msPeriodogSum16, msPeriodogSum16 ); - - /* calculate difference, both elements in 16Q15 format, use absolute value - to avoid -1.0 x -1.0 multiplications later */ - scalar2 = L_abs( L_sub( msPsdSum[cnt], msPeriodogSum[cnt] ) ); - - s2 = WORD32_BITS - 1; - move16(); - if ( scalar2 != 0 ) - { - /* use absolute value to avoid -1.0 x -1.0 multiplications */ - s2 = norm_l( scalar2 ); - } - scalar216 = round_fx_sat( L_shl( scalar2, s2 ) ); - scalar2 = L_mult( scalar216, scalar216 ); - - /* find common exponent */ - tmp16_1 = sub( s1, s2 ); - tmp16 = s_min( shl( abs_s( tmp16_1 ), 1 ), WORD32_BITS - 1 ); - if ( tmp16_1 < 0 ) - { - scalar2 = L_shr( scalar2, tmp16 ); - } - if ( tmp16_1 > 0 ) - { - scalar = L_shr( scalar, tmp16 ); - } - - - /* add scalar and scalar2, avoid overflows */ - scalar = L_shr( scalar, 1 ); - scalar2 = L_shr( scalar2, 1 ); - scalar3 = L_add( scalar, scalar2 ); - - /* calculate division */ - scalar16 = BASOP_Util_Divide3232_uu_1616_Scale( scalar, scalar3, &s3 ); - s3 = s_max( s3, -( WORD16_BITS - 1 ) ); - scalar16 = shl( scalar16, s3 ); - scalar16 = s_max( scalar16, MSALPHACORMAX ); - - hFdCngCom->msAlphaCor[cnt] = L_add( Mpy_32_16_1( hFdCngCom->msAlphaCor[cnt], msAlphaCorAlpha ), - L_mult( scalar16, msAlphaCorAlpha2 ) ); - move32(); - } - - /* Compute SNR */ - - /* msPeriodogSum[cnt] with format 16Q15 */ - snr = dotp_s_fx( msNoiseFloor + start, psize + start, current_len, CNG_HS ); - - IF( GT_32( L_shr( Mpy_32_16_1( msPsdSum[cnt], 18431 /*0.56246299817 Q15*/ ), 13 ), snr ) ) - { - tmp0 = BASOP_Util_Log2( msPsdSum[cnt] ); - tmp1 = BASOP_Util_Log2( snr ); - tmp1 = L_sub( tmp0, tmp1 ); - tmp1 = Mpy_32_16_1( tmp1, MSSNREXP ); - msAlphaHatMin2 = BASOP_Util_InvLog2( tmp1 ); - } - ELSE - { - msAlphaHatMin2 = MSALPHAHATMIN; - move32(); - } - scalar = Mpy_32_16_1( hFdCngCom->msAlphaCor[cnt], MSALPHAMAX ); - - FOR( j = start; j < stop; j++ ) - { - /* Compute optimal smoothing parameter for PSD estimation */ - test(); - IF( ( scalar == 0 ) || ( msNoiseFloor[j] == 0 ) ) - { - msAlpha[j] = msAlphaHatMin2; - move32(); - } - ELSE - { - /* calculate scalar2 with normalized msNoiseFloor[j], exponent -2*s1 */ - s1 = WORD16_BITS - 1; - move16(); - if ( msNoiseFloor[j] != 0 ) - { - s1 = norm_s( msNoiseFloor[j] ); - } - msNoiseFloor16 = shl( msNoiseFloor[j], s1 ); - scalar2 = L_mult( msNoiseFloor16, msNoiseFloor16 ); - - /* calculate difference, both elements in 6Q9 format, use absolute value - to avoid -1.0 x -1.0 multiplications later */ - scalar316 = abs_s( sub( msPsd[j], msNoiseFloor[j] ) ); - - s2 = WORD16_BITS - 1; - move16(); - if ( scalar316 != 0 ) - { - /* use absolute value to avoid -1.0 x -1.0 multiplications */ - s2 = norm_s( scalar316 ); - } - scalar316 = shl( scalar316, s2 ); - scalar3 = L_mult( scalar316, scalar316 ); - - /* find common exponent */ - tmp16_1 = sub( s1, s2 ); - tmp16 = s_min( shl( abs_s( tmp16_1 ), 1 ), WORD32_BITS - 1 ); - if ( tmp16_1 < 0 ) - { - scalar3 = L_shr( scalar3, tmp16 ); - } - if ( tmp16_1 > 0 ) - { - scalar2 = L_shr( scalar2, tmp16 ); - } - - /* add scalar2 and scalar3, avoid overflows */ - scalar2 = L_shr( scalar2, 1 ); - scalar3 = L_shr( scalar3, 1 ); - scalar3 = L_add( scalar2, scalar3 ); - - /* calculate division */ - tmp16 = BASOP_Util_Divide3232_uu_1616_Scale( scalar2, scalar3, &s3 ); - scalar2 = Mpy_32_16_1( scalar, tmp16 ); - s3 = s_max( s3, -( WORD32_BITS - 1 ) ); - scalar2 = L_shl( scalar2, s3 ); - msAlpha[j] = L_max( scalar2, msAlphaHatMin2 ); - move32(); - } - - /* Compute the PSD (smoothed periodogram) in each band */ - msPsd[j] = round_fx( L_add( Mpy_32_16_1( msAlpha[j], msPsd[j] ), - Mpy_32_16_1( L_sub( 2147483647l /*1.0 Q31*/, msAlpha[j] ), msPeriodog[j] ) ) ); - move16(); - } - msPsdSum[cnt] = dotp_s_fx( msPsd + start, psize + start, current_len, CNG_HS ); - move32(); - - QeqInvAv = 0l /*0.0 Q31*/; - move32(); - - /* scalar: 7Q24 format */ - tmp = 1191182336l /*(float)(MSNUMSUBFR*MSSUBFRLEN)-1.0 Q24*/; - move32(); - scalar = L_sub( tmp, L_mult( round_fx( tmp ), msM_win ) ); - - /* scalar2: 4Q27 format */ - tmp = 1476395008l /*(float)MSSUBFRLEN-1.0 Q27*/; - move32(); - scalar2 = L_sub( tmp, L_mult( round_fx( tmp ), msM_subwin ) ); - - FOR( j = start; j < stop; j++ ) - { - /* Compute variance of PSD */ - tmp = L_min( msAlpha[j], MSBETAMAX_SQRT ); - - s1 = WORD32_BITS - 1; - move16(); - if ( tmp != 0 ) - { - s1 = norm_l( tmp ); - } - s2 = shl( s1, 1 ); - - s2 = s_min( s2, WORD32_BITS - 1 ); - - /* beta: scaled by s2 */ - tmp16 = round_fx_sat( L_shl( tmp, s1 ) ); - beta = mult_r( tmp16, tmp16 ); - - /* scalar3: scaled by s3 */ - scalar3 = L_sub( L_deposit_l( msPsd[j] ), L_deposit_l( msPsdFirstMoment[j] ) ); - s3 = norm_l( scalar3 ); - scalar3 = L_shl( scalar3, s3 ); - - /* msPsdFirstMoment: 6Q9 */ - tmp = L_msu( L_mult( beta, msPsdFirstMoment[j] ), beta, msPsd[j] ); - msPsdFirstMoment[j] = add( round_fx( L_shr( tmp, s2 ) ), msPsd[j] ); - move16(); - - /* msPsdSecondMoment: 12Q19 */ - tmp0 = L_shr( Mpy_32_16_r( msPsdSecondMoment[j], beta ), s2 ); - tmp1 = Mpy_32_32( scalar3, scalar3 ); - tmp1 = L_shr( L_sub( tmp1, L_shr( Mpy_32_16_r( tmp1, beta ), s2 ) ), sub( shl( s3, 1 ), 32 ) ); - msPsdSecondMoment[j] = L_add( tmp0, tmp1 ); - move32(); - - /* Compute inverse of amount of degrees of freedom */ - QeqInv = MSQEQINVMAX; - move16(); - - IF( msNoiseFloor[j] != 0 /*0.0 Q15*/ ) - { - tmp = L_mult( msNoiseFloor[j], msNoiseFloor[j] ); - tmp16 = BASOP_Util_Divide3232_uu_1616_Scale( msPsdSecondMoment[j], tmp, &s ); - /* consider factor of 2 */ - s = s_min( s_max( sub( s, 1 ), -( WORD16_BITS - 1 ) ), ( WORD16_BITS - 1 ) ); - if ( s < 0 ) - { - QeqInv = shl( tmp16, s ); - } - QeqInv = s_min( QeqInv, MSQEQINVMAX ); - } - QeqInvAv = L_add( QeqInvAv, L_mult( QeqInv, psize[j] ) ); - - /* Compute bias correction Bmin */ - tmp0 = Mpy_32_16_1( scalar, QeqInv ); - tmp1 = L_sub( 1073741824l /*0.5 Q31*/, L_mult( msM_win, QeqInv ) ); - tmp16 = BASOP_Util_Divide3232_uu_1616_Scale( tmp0, tmp1, &s ); - msBminWin[j] = L_add( 134217728l /*1.0 Q27*/, L_shl( L_deposit_h( tmp16 ), add( s, 7 - 4 ) ) ); - move32(); - - tmp0 = Mpy_32_16_1( scalar2, QeqInv ); - tmp1 = L_sub( 1073741824l /*0.5 Q31*/, L_mult( msM_subwin, QeqInv ) ); - tmp16 = BASOP_Util_Divide3232_uu_1616_Scale( tmp0, tmp1, &s ); - msBminSubWin[j] = L_add( 134217728l /*1.0 Q27*/, L_shl( L_deposit_h( tmp16 ), s ) ); - move32(); - } - - inv_totsize = BASOP_Util_Divide3232_uu_1616_Scale( 1, totsize, &s ); - QeqInvAv = Mpy_32_16_1( QeqInvAv, inv_totsize ); - QeqInvAv = L_shl( QeqInvAv, s ); - hFdCngCom->msQeqInvAv[cnt] = QeqInvAv; - move32(); - - /* New minimum? */ - - /* exponent QeqInvAv: CNG_S, exponent MSAV: (4>>1) */ - s = CNG_S + 2 * MSAV_EXP; - move16(); - BminCorr = Mpy_32_16_1( Sqrt32( QeqInvAv, &s ), MSAV ); - BminCorr = L_shl( BminCorr, sub( s, 1 ) ); - - /* exponent BminCorr: 1 */ - BminCorr = L_add( BminCorr, 1073741824l /*0.5 Q31*/ ); - - FOR( j = start; j < stop; j++ ) - { - /* exponent scalar: CNG_S+1 */ - scalar = Mpy_32_16_1( BminCorr, msPsd[j] ); - - /* exponent scalar2: CNG_S+1+4 */ - scalar2 = Mpy_32_32( scalar, msBminWin[j] ); - - msNewMinFlag[j] = 0; - move16(); - IF( LT_32( scalar2, msCurrentMin[j] ) /*0.0 Q31*/ ) - { - msNewMinFlag[j] = 1; - move16(); - /* exponent msCurrentMin[j]: CNG_S+1+4 */ - msCurrentMin[j] = scalar2; - move32(); - /* exponent msCurrentMinSubWindow[j]: CNG_S */ - BASOP_SATURATE_WARNING_OFF_EVS; - msCurrentMinSubWindow[j] = L_shl_sat( Mpy_32_32( scalar, msBminSubWin[j] ), 5 ); - move32(); - BASOP_SATURATE_WARNING_ON_EVS; - } - } - - /* This is used later to identify local minima */ - IF( GE_16( hFdCngCom->msFrCnt, MSSUBFRLEN ) ) - { - FOR( i = 0; i < 3; i++ ) - { - IF( LT_32( hFdCngCom->msQeqInvAv[cnt], L_shr( L_deposit_h( msQeqInvAv_thresh[i] ), CNG_S ) ) /*0.0 Q31*/ ) - { - BREAK; - } - } - /* format 1Q30 */ - hFdCngCom->msSlope[cnt] = msNoiseSlopeMax[i]; - move32(); - } - - /* Consider the FFT and CLDFB bands separately */ - start = stop; - move16(); - stop = len; - move16(); - totsize = sub( hFdCngCom->stopBand, hFdCngCom->stopFFTbin ); - cnt = add( cnt, 1 ); - } /*while (stop > start)*/ - - /* Update minimum between sub windows */ - test(); - IF( GT_16( hFdCngCom->msFrCnt, 1 ) && LT_16( hFdCngCom->msFrCnt, MSSUBFRLEN ) ) - { - FOR( j = 0; j < len; j++ ) - { - if ( msNewMinFlag[j] > 0 ) - { - msLocalMinFlag[j] = 1; - move16(); - } - if ( LT_32( msCurrentMinSubWindow[j], msCurrentMinOut[j] ) /*0.0 Q31*/ ) - { - /* msCurrentMinOut[j] scaled with CNG_S */ - msCurrentMinOut[j] = msCurrentMinSubWindow[j]; - move32(); - } - } - /* Get the current noise floor */ - Copy_Scale_sig_32_16( msCurrentMinOut, msNoiseFloor, len, -16 ); - } - ELSE /* sub window complete */ - { - IF( GE_16( hFdCngCom->msFrCnt, MSSUBFRLEN ) ) - { - /* Collect buffers */ - Copy32( msCurrentMinSubWindow, msMinBuf + len * hFdCngCom->msMinBufferPtr, len ); - - /* Compute minimum among all buffers */ - Copy32( msMinBuf, msCurrentMinOut, len ); - ptr = msMinBuf + len; - FOR( i = 1; i < MSNUMSUBFR; i++ ) - { - FOR( j = 0; j < len; j++ ) - { - if ( LT_32( *ptr, msCurrentMinOut[j] ) /*0.0 Q31*/ ) - { - msCurrentMinOut[j] = *ptr; - move32(); - } - ptr++; - } - } - - /* Take over local minima */ - slope = hFdCngCom->msSlope[0]; - move16(); - FOR( j = 0; j < len; j++ ) - { - if ( EQ_16( j, lenFFT ) ) - { - slope = hFdCngCom->msSlope[1]; - move16(); - } - test(); - test(); - test(); - IF( ( msLocalMinFlag[j] != 0 ) && ( msNewMinFlag[j] == 0 ) && ( LT_32( L_shr( msCurrentMinSubWindow[j], 1 ), Mpy_32_16_1( msCurrentMinOut[j], slope ) ) /*0.0 Q31*/ ) && ( GT_32( msCurrentMinSubWindow[j], msCurrentMinOut[j] ) /*0.0 Q31*/ ) ) - { - msCurrentMinOut[j] = msCurrentMinSubWindow[j]; - move32(); - i = j; - move16(); - FOR( k = 0; k < MSNUMSUBFR; k++ ) - { - msMinBuf[i] = msCurrentMinOut[j]; - move32(); - i = add( i, len ); - } - } - } - - /* Reset */ - set16_fx( msLocalMinFlag, 0, len ); - set32_fx( msCurrentMin, 2147483647l /*1.0 Q31*/, len ); - - /* Get the current noise floor */ - Copy_Scale_sig_32_16( msCurrentMinOut, msNoiseFloor, len, -16 ); - } - } - - - /* Detect sudden offsets based on the FFT bins (core bandwidth) */ - IF( GT_32( Mpy_32_16_1( msPsdSum[0], 655 /*0.02 Q15*/ ), msPeriodogSum[0] ) /*0.0 Q31*/ ) - { - IF( hFdCngCom->offsetflag > 0 ) - { - Copy( msPeriodog, msPsd, len ); - FOR( j = 0; j < len; j++ ) - { - msCurrentMinOut[j] = L_deposit_h( msPeriodog[j] ); - move32(); - } - set32_fx( hFdCngCom->msAlphaCor, 2147483647l /*1.0 Q31*/, cnt ); - set32_fx( msAlpha, 0l /*0.0 Q31*/, len ); - Copy( msPeriodog, msPsdFirstMoment, len ); - set32_fx( msPsdSecondMoment, 0l /*0.0 Q31*/, len ); - - msPsdSum[0] = dotp_s_fx( msPeriodog, psize, lenFFT, CNG_HS ); - move32(); - IF( LT_16( lenFFT, len ) ) - { - msPsdSum[1] = dotp_s_fx( msPeriodog + lenFFT, psize + lenFFT, sub( len, lenFFT ), CNG_HS ); - move32(); - } - } - hFdCngCom->offsetflag = 1; - move16(); - } - ELSE - { - hFdCngCom->offsetflag = 0; - move16(); - } - - - /* Increment frame counter */ - IF( EQ_16( hFdCngCom->msFrCnt, MSSUBFRLEN ) ) - { - hFdCngCom->msFrCnt = 1; - move16(); - hFdCngCom->msMinBufferPtr = add( hFdCngCom->msMinBufferPtr, 1 ); - move16(); - if ( EQ_16( hFdCngCom->msMinBufferPtr, MSNUMSUBFR ) ) - { - hFdCngCom->msMinBufferPtr = 0; - move16(); - } - } - ELSE - { - hFdCngCom->msFrCnt = add( hFdCngCom->msFrCnt, 1 ); - } - - /* Smooth noise estimate during CNG phases */ - FOR( j = 0; j < len; j++ ) - { - msNoiseEst[j] = round_fx( L_mac( L_mult( 31130 /*0.95 Q15*/, msNoiseEst[j] ), 1638 /*0.05 Q15*/, msNoiseFloor[j] ) ); - move16(); - } - } - /* Collect buffers */ - Copy( msPeriodog, msPeriodogBuf + len * ( *msPeriodogBufPtr ), len ); - - *msPeriodogBufPtr = add( *msPeriodogBufPtr, 1 ); - move16(); - if ( EQ_16( *msPeriodogBufPtr, MSBUFLEN ) ) - { - ( *msPeriodogBufPtr ) = 0; - move16(); - } - - /* Upper limit the noise floors with the averaged input energy */ - FOR( j = 0; j < len; j++ ) - { - scalar = L_mult( msPeriodogBuf[j], 6554 /*1.0/MSBUFLEN Q15*/ ); - - FOR( i = j + len; i < MSBUFLEN * len; i += len ) - { - scalar = L_mac( scalar, msPeriodogBuf[i], 6554 /*1.0/MSBUFLEN Q15*/ ); - } - scalar16 = round_fx( scalar ); - if ( GT_16( msNoiseEst[j], scalar16 ) /*0.0 Q15*/ ) - { - msNoiseEst[j] = scalar16; - move16(); - } - - assert( msNoiseEst[j] >= 0 /*0.0 Q15*/ ); - } -} - -void minimum_statistics_fx( - Word16 len, /* i : Total number of partitions (CLDFB or FFT) */ - Word16 lenFFT, /* i : Number of FFT partitions */ - Word16 *psize, /* i : Partition sizes, fractional Q9*/ - Word16 *msPeriodog, /* i : Periodogram (energies) */ - Word32 *msNoiseFloor, /* i/o: Noise floors (energies) Q25*/ - Word32 *msNoiseEst, /* i/o: Noise estimates (energies) Q25*/ - Word32 *msAlpha, /* i/o: Forgetting factors */ - Word16 *msPsd, /* i/o: Power Spectral Density (smoothed periodogram => energies) */ - Word16 *msPsdFirstMoment, /* i/o: PSD statistics of 1st order (energy means) */ - Word32 *msPsdSecondMoment, /* i/o: PSD statistics of 2nd order (energy variances) */ - Word32 *msMinBuf, /* i/o: Buffer of minima (energies) */ - Word32 *msBminWin, /* o : Bias correction factors */ - Word32 *msBminSubWin, /* o : Bias correction factors */ - Word32 *msCurrentMin, /* i/o: Local minima (energies) */ - Word32 *msCurrentMinOut, /* i/o: Local minima (energies) */ - Word32 *msCurrentMinSubWindow, /* i/o: Local minima (energies) */ - Word16 *msLocalMinFlag, /* i : Binary flag */ - Word16 *msNewMinFlag, /* i : Binary flag */ - Word16 *msPeriodogBuf, /* i/o: Buffer of periodograms (energies) */ - Word16 *msPeriodogBufPtr, /* i/o: Counter */ - HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - const Word16 enc_dec, /* i : encoder/decoder indicator */ - const Word16 element_mode /* i : IVAS element mode type */ -) -{ - Word16 i, j, k, s, s1, s2, s3; - Word16 len2; - Word16 current_len; - Word16 start, stop, cnt; - Word16 totsize; - Word16 inv_totsize; - - Word32 tmp, tmp0, tmp1; - Word32 scalar, scalar2, scalar3; - Word32 snr; - Word32 msAlphaHatMin2; - Word32 BminCorr; - Word32 QeqInvAv; - Word32 *ptr; - Word32 *msPsdSum; - Word32 *msPeriodogSum; - - Word16 tmp16, tmp16_1; - Word16 beta; - Word16 slope; - Word16 QeqInv; - Word16 scalar16; - Word16 scalar216; - Word16 scalar316; - Word16 msM_win; - Word16 msM_subwin; - Word16 msAlphaCorAlpha; - Word16 msAlphaCorAlpha2; - Word16 msPeriodogSum16; - Word16 msNoiseFloor16; - - len2 = i_mult( MSNUMSUBFR, len ); - - msM_win = hFdCngCom->msM_win; - move16(); - msM_subwin = hFdCngCom->msM_subwin; - move16(); - - msAlphaCorAlpha = MSALPHACORALPHA; - move16(); - msAlphaCorAlpha2 = MSALPHACORALPHA2; - move16(); - - msPsdSum = hFdCngCom->msPsdSum; - msPeriodogSum = hFdCngCom->msPeriodogSum; - - /* No minimum statistics at initialization */ - IF( LT_16( hFdCngCom->msFrCnt_init_counter, hFdCngCom->msFrCnt_init_thresh ) ) - { - Copy( msPeriodog, msPsd, len ); /* 6Q9 */ - Copy_Scale_sig_16_32_no_sat( msPeriodog, msNoiseFloor, len, Q16 ); /* Q25 */ - Copy_Scale_sig_16_32_no_sat( msPeriodog, msNoiseEst, len, Q16 ); /* Q25 */ - Copy( msPeriodog, msPsdFirstMoment, len ); /* 6Q9 */ - - set32_fx( msPsdSecondMoment, 0l /*0.0 Q31*/, len ); - msPeriodogSum[0] = dotp_s_fx( msPeriodog, psize, lenFFT, CNG_HS ); - move32(); - msPsdSum[0] = msPeriodogSum[0]; /* 16Q15 */ - move32(); - - IF( LT_16( lenFFT, len ) ) - { - msPeriodogSum[1] = dotp_s_fx( msPeriodog + lenFFT, psize + lenFFT, sub( len, lenFFT ), CNG_HS ); - move32(); - msPsdSum[1] = msPeriodogSum[1]; /* 16Q15 */ - move32(); - } - - /* Increment frame counter at initialization */ - /* Some frames are sometimes zero at initialization => ignore them */ - IF( LT_16( msPeriodog[0], hFdCngCom->init_old ) ) - { - set32_fx( msCurrentMinOut, 2147483647l /*1.0 Q31*/, len ); /* 16Q15 */ - set32_fx( msCurrentMin, 2147483647l /*1.0 Q31*/, len ); /* 16Q15 */ - set32_fx( msMinBuf, 2147483647l /*1.0 Q31*/, len2 ); /* 16Q15 */ - set32_fx( msCurrentMinSubWindow, 2147483647l /*1.0 Q31*/, len ); /* 16Q15 */ - - hFdCngCom->msFrCnt_init_counter = add( hFdCngCom->msFrCnt_init_counter, 1 ); - move16(); - } - hFdCngCom->init_old = msPeriodog[0]; /* 6Q9 */ - move16(); - } - ELSE - { - /* Consider the FFT and CLDFB bands separately - - first iteration for FFT bins, - - second one for CLDFB bands in SWB mode */ - cnt = 0; - move16(); - start = 0; - move16(); - stop = lenFFT; - move16(); - totsize = sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ); - WHILE( GT_16( stop, start ) ) - { - current_len = sub( stop, start ); - - /* Compute smoothed correction factor for PSD smoothing */ - - /* msPeriodogSum[cnt] with format 16Q15 */ - msPeriodogSum[cnt] = dotp_s_fx( msPeriodog + start, psize + start, current_len, CNG_HS ); - move32(); - - IF( msPeriodogSum[cnt] == 0 ) - { - hFdCngCom->msAlphaCor[cnt] = Mpy_32_16_1( hFdCngCom->msAlphaCor[cnt], msAlphaCorAlpha ); - move32(); - } - ELSE - { - /* calculate scalar with normalized msPeriodogSum[cnt], exponent -2*s1 */ - s1 = norm_l( msPeriodogSum[cnt] ); - msPeriodogSum16 = round_fx_sat( L_shl( msPeriodogSum[cnt], s1 ) ); - scalar = L_mult( msPeriodogSum16, msPeriodogSum16 ); - - /* calculate difference, both elements in 16Q15 format, use absolute value - to avoid -1.0 x -1.0 multiplications later */ - scalar2 = L_abs( L_sub( msPsdSum[cnt], msPeriodogSum[cnt] ) ); - - s2 = WORD32_BITS - 1; - move16(); - if ( scalar2 != 0 ) - { - /* use absolute value to avoid -1.0 x -1.0 multiplications */ - s2 = norm_l( scalar2 ); - } - scalar216 = round_fx_sat( L_shl( scalar2, s2 ) ); - scalar2 = L_mult( scalar216, scalar216 ); - - /* find common exponent */ - tmp16_1 = sub( s1, s2 ); - tmp16 = s_min( shl( abs_s( tmp16_1 ), 1 ), WORD32_BITS - 1 ); - if ( tmp16_1 < 0 ) - { - scalar2 = L_shr( scalar2, tmp16 ); - } - if ( tmp16_1 > 0 ) - { - scalar = L_shr( scalar, tmp16 ); - } - - - /* add scalar and scalar2, avoid overflows */ - scalar = L_shr( scalar, 1 ); - scalar2 = L_shr( scalar2, 1 ); - scalar3 = L_add( scalar, scalar2 ); - - /* calculate division */ - scalar16 = BASOP_Util_Divide3232_uu_1616_Scale( scalar, scalar3, &s3 ); - s3 = s_max( s3, -( WORD16_BITS - 1 ) ); - scalar16 = shl( scalar16, s3 ); - scalar16 = s_max( scalar16, MSALPHACORMAX ); - - hFdCngCom->msAlphaCor[cnt] = Madd_32_16( L_mult( scalar16, msAlphaCorAlpha2 ), hFdCngCom->msAlphaCor[cnt], msAlphaCorAlpha ); - move32(); - } - - /* Compute SNR */ - - /* msPeriodogSum[cnt] with format 16Q15 */ - Word16 msNoiseFloor16tmp[NPART_SHAPING]; - IF( enc_dec == ENC ) - { - Copy_Scale_sig32_16( msNoiseFloor, msNoiseFloor16tmp, NPART, 0 ); - } - ELSE - { - Copy_Scale_sig32_16( msNoiseFloor, msNoiseFloor16tmp, NPART_SHAPING, 0 ); - } - snr = dotp_s_fx( &msNoiseFloor16tmp[start], psize + start, current_len, CNG_HS ); - - IF( GT_32( L_shr( Mpy_32_16_1( msPsdSum[cnt], 18431 /*0.56246299817 Q15*/ ), 13 ), snr ) ) - { - tmp0 = BASOP_Util_Log2( msPsdSum[cnt] ); - tmp1 = BASOP_Util_Log2( snr ); - tmp1 = L_sub( tmp0, tmp1 ); - tmp1 = Mpy_32_16_1( tmp1, MSSNREXP ); - msAlphaHatMin2 = BASOP_Util_InvLog2( tmp1 ); - } - ELSE - { - msAlphaHatMin2 = MSALPHAHATMIN; - move32(); - } - scalar = Mpy_32_16_1( hFdCngCom->msAlphaCor[cnt], MSALPHAMAX ); - - FOR( j = start; j < stop; j++ ) - { - /* Compute optimal smoothing parameter for PSD estimation */ - test(); - IF( ( scalar == 0 ) || ( msNoiseFloor[j] == 0 ) ) - { - msAlpha[j] = msAlphaHatMin2; - move32(); - } - ELSE - { - /* calculate scalar2 with normalized msNoiseFloor[j], exponent -2*s1 */ - s1 = WORD16_BITS - 1; - move16(); - if ( msNoiseFloor16tmp[j] != 0 ) - { - s1 = norm_s( msNoiseFloor16tmp[j] ); - } - msNoiseFloor16 = shl( msNoiseFloor16tmp[j], s1 ); - scalar2 = L_mult( msNoiseFloor16, msNoiseFloor16 ); - - /* calculate difference, both elements in 6Q9 format, use absolute value - to avoid -1.0 x -1.0 multiplications later */ - scalar316 = abs_s( sub( msPsd[j], msNoiseFloor16tmp[j] ) ); - - s2 = WORD16_BITS - 1; - move16(); - if ( scalar316 != 0 ) - { - /* use absolute value to avoid -1.0 x -1.0 multiplications */ - s2 = norm_s( scalar316 ); - } - scalar316 = shl( scalar316, s2 ); - scalar3 = L_mult( scalar316, scalar316 ); - - /* find common exponent */ - tmp16_1 = sub( s1, s2 ); - tmp16 = s_min( shl( abs_s( tmp16_1 ), 1 ), WORD32_BITS - 1 ); - if ( tmp16_1 < 0 ) - { - scalar3 = L_shr( scalar3, tmp16 ); - } - if ( tmp16_1 > 0 ) - { - scalar2 = L_shr( scalar2, tmp16 ); - } - - /* add scalar2 and scalar3, avoid overflows */ - scalar2 = L_shr( scalar2, 1 ); - scalar3 = L_shr( scalar3, 1 ); - scalar3 = L_add( scalar2, scalar3 ); - - /* calculate division */ - tmp16 = BASOP_Util_Divide3232_uu_1616_Scale( scalar2, scalar3, &s3 ); - scalar2 = Mpy_32_16_1( scalar, tmp16 ); - s3 = s_max( s3, -( WORD32_BITS - 1 ) ); - scalar2 = L_shl( scalar2, s3 ); - msAlpha[j] = L_max( scalar2, msAlphaHatMin2 ); - move32(); - } - - /* Compute the PSD (smoothed periodogram) in each band */ - msPsd[j] = round_fx( Madd_32_16( Mpy_32_16_1( msAlpha[j], msPsd[j] ), L_sub( 2147483647l /*1.0 Q31*/, msAlpha[j] ), msPeriodog[j] ) ); - move16(); - } - msPsdSum[cnt] = dotp_s_fx( msPsd + start, psize + start, current_len, CNG_HS ); - move32(); - - QeqInvAv = 0l /*0.0 Q31*/; - move32(); - - /* scalar: 7Q24 format */ - tmp = 1191182336l /*(float)(MSNUMSUBFR*MSSUBFRLEN)-1.0 Q24*/; - move32(); - scalar = L_sub( tmp, L_mult( round_fx( tmp ), msM_win ) ); - - /* scalar2: 4Q27 format */ - tmp = 1476395008l /*(float)MSSUBFRLEN-1.0 Q27*/; - move32(); - scalar2 = L_sub( tmp, L_mult( round_fx( tmp ), msM_subwin ) ); - - FOR( j = start; j < stop; j++ ) - { - /* Compute variance of PSD */ - tmp = L_min( msAlpha[j], MSBETAMAX_SQRT ); - - s1 = WORD32_BITS - 1; - move16(); - if ( tmp != 0 ) - { - s1 = norm_l( tmp ); - } - s2 = shl( s1, 1 ); - - s2 = s_min( s2, WORD32_BITS - 1 ); - - /* beta: scaled by s2 */ - tmp16 = round_fx_sat( L_shl( tmp, s1 ) ); - beta = mult_r( tmp16, tmp16 ); - - /* scalar3: scaled by s3 */ - scalar3 = L_sub( L_deposit_l( msPsd[j] ), L_deposit_l( msPsdFirstMoment[j] ) ); - s3 = norm_l( scalar3 ); - scalar3 = L_shl( scalar3, s3 ); - - /* msPsdFirstMoment: 6Q9 */ - tmp = L_msu( L_mult( beta, msPsdFirstMoment[j] ), beta, msPsd[j] ); - msPsdFirstMoment[j] = add( round_fx( L_shr( tmp, s2 ) ), msPsd[j] ); - move16(); - - /* msPsdSecondMoment: 12Q19 */ - tmp0 = L_shr( Mpy_32_16_r( msPsdSecondMoment[j], beta ), s2 ); - tmp1 = Mpy_32_32( scalar3, scalar3 ); - tmp1 = L_shr( L_sub( tmp1, L_shr( Mpy_32_16_r( tmp1, beta ), s2 ) ), sub( shl( s3, 1 ), 32 ) ); - msPsdSecondMoment[j] = L_add( tmp0, tmp1 ); - move32(); - - /* Compute inverse of amount of degrees of freedom */ - QeqInv = MSQEQINVMAX; - move16(); - - IF( msNoiseFloor[j] != 0 /*0.0 Q15*/ ) - { - tmp = Mpy_32_32( msNoiseFloor[j], msNoiseFloor[j] ); - tmp16 = BASOP_Util_Divide3232_uu_1616_Scale( msPsdSecondMoment[j], tmp, &s ); - /* consider factor of 2 */ - s = s_min( s_max( sub( s, 1 ), -( WORD16_BITS - 1 ) ), ( WORD16_BITS - 1 ) ); - if ( s < 0 ) - { - QeqInv = shl( tmp16, s ); - } - QeqInv = s_min( QeqInv, MSQEQINVMAX ); - } - QeqInvAv = L_add( QeqInvAv, L_mult( QeqInv, psize[j] ) ); - - /* Compute bias correction Bmin */ - tmp0 = Mpy_32_16_1( scalar, QeqInv ); - tmp1 = L_msu( 1073741824l /*0.5 Q31*/, msM_win, QeqInv ); - tmp16 = BASOP_Util_Divide3232_uu_1616_Scale( tmp0, tmp1, &s ); - msBminWin[j] = L_add( 134217728l /*1.0 Q27*/, L_shl( L_deposit_h( tmp16 ), add( s, 7 - 4 ) ) ); - move32(); - - tmp0 = Mpy_32_16_1( scalar2, QeqInv ); - tmp1 = L_msu( 1073741824l /*0.5 Q31*/, msM_subwin, QeqInv ); - tmp16 = BASOP_Util_Divide3232_uu_1616_Scale( tmp0, tmp1, &s ); - msBminSubWin[j] = L_add( 134217728l /*1.0 Q27*/, L_shl( L_deposit_h( tmp16 ), s ) ); - move32(); - } - - inv_totsize = BASOP_Util_Divide3232_uu_1616_Scale( 1, totsize, &s ); - QeqInvAv = Mpy_32_16_1( QeqInvAv, inv_totsize ); - QeqInvAv = L_shl( QeqInvAv, s ); - hFdCngCom->msQeqInvAv[cnt] = QeqInvAv; - move32(); - - /* New minimum? */ - - /* exponent QeqInvAv: CNG_S, exponent MSAV: (4>>1) */ - s = CNG_S + 2 * MSAV_EXP; - move16(); - BminCorr = Mpy_32_16_1( Sqrt32( QeqInvAv, &s ), MSAV ); - BminCorr = L_shl( BminCorr, sub( s, 1 ) ); - - /* exponent BminCorr: 1 */ - BminCorr = L_add( BminCorr, 1073741824l /*0.5 Q31*/ ); - - FOR( j = start; j < stop; j++ ) - { - /* exponent scalar: CNG_S+1 */ - scalar = Mpy_32_16_1( BminCorr, msPsd[j] ); - - /* exponent scalar2: CNG_S+1+4 */ - scalar2 = Mpy_32_32( scalar, msBminWin[j] ); - - msNewMinFlag[j] = 0; - move16(); - IF( LT_32( scalar2, msCurrentMin[j] ) /*0.0 Q31*/ ) - { - msNewMinFlag[j] = 1; - move16(); - /* exponent msCurrentMin[j]: CNG_S+1+4 */ - msCurrentMin[j] = scalar2; - move32(); - /* exponent msCurrentMinSubWindow[j]: CNG_S */ - BASOP_SATURATE_WARNING_OFF_EVS; - msCurrentMinSubWindow[j] = L_shl_sat( Mpy_32_32( scalar, msBminSubWin[j] ), 5 ); - move32(); - BASOP_SATURATE_WARNING_ON_EVS; - } - } - - /* This is used later to identify local minima */ - IF( GE_16( hFdCngCom->msFrCnt, MSSUBFRLEN ) ) - { - FOR( i = 0; i < 3; i++ ) - { - IF( LT_32( hFdCngCom->msQeqInvAv[cnt], L_shr( L_deposit_h( msQeqInvAv_thresh[i] ), CNG_S ) ) /*0.0 Q31*/ ) - { - BREAK; - } - } - /* format 1Q30 */ - hFdCngCom->msSlope[cnt] = msNoiseSlopeMax[i]; - move32(); - } - - /* Consider the FFT and CLDFB bands separately */ - start = stop; - move16(); - stop = len; - move16(); - totsize = sub( hFdCngCom->stopBand, hFdCngCom->stopFFTbin ); - cnt = add( cnt, 1 ); - } /*while (stop > start)*/ - - /* Update minimum between sub windows */ - test(); - IF( GT_16( hFdCngCom->msFrCnt, 1 ) && LT_16( hFdCngCom->msFrCnt, MSSUBFRLEN ) ) - { - FOR( j = 0; j < len; j++ ) - { - if ( msNewMinFlag[j] > 0 ) - { - msLocalMinFlag[j] = 1; - move16(); - } - if ( LT_32( msCurrentMinSubWindow[j], msCurrentMinOut[j] ) /*0.0 Q31*/ ) - { - /* msCurrentMinOut[j] scaled with CNG_S */ - msCurrentMinOut[j] = msCurrentMinSubWindow[j]; - move32(); - } - } - /* Get the current noise floor */ - Copy32( msCurrentMinOut, msNoiseFloor, len ); - } - ELSE /* sub window complete */ - { - IF( GE_16( hFdCngCom->msFrCnt, MSSUBFRLEN ) ) - { - /* Collect buffers */ - Copy32( msCurrentMinSubWindow, msMinBuf + len * hFdCngCom->msMinBufferPtr, len ); - - /* Compute minimum among all buffers */ - Copy32( msMinBuf, msCurrentMinOut, len ); - ptr = msMinBuf + len; - FOR( i = 1; i < MSNUMSUBFR; i++ ) - { - FOR( j = 0; j < len; j++ ) - { - if ( LT_32( *ptr, msCurrentMinOut[j] ) /*0.0 Q31*/ ) - { - msCurrentMinOut[j] = *ptr; - move32(); - } - ptr++; - } - } - - /* Take over local minima */ - slope = hFdCngCom->msSlope[0]; - move16(); - FOR( j = 0; j < len; j++ ) - { - if ( EQ_16( j, lenFFT ) ) - { - slope = hFdCngCom->msSlope[1]; - move16(); - } - test(); - test(); - test(); - IF( ( msLocalMinFlag[j] != 0 ) && ( msNewMinFlag[j] == 0 ) && ( LT_32( L_shr( msCurrentMinSubWindow[j], 1 ), Mpy_32_16_1( msCurrentMinOut[j], slope ) ) /*0.0 Q31*/ ) && ( GT_32( msCurrentMinSubWindow[j], msCurrentMinOut[j] ) /*0.0 Q31*/ ) ) - { - msCurrentMinOut[j] = msCurrentMinSubWindow[j]; - move32(); - i = j; - move16(); - FOR( k = 0; k < MSNUMSUBFR; k++ ) - { - msMinBuf[i] = msCurrentMinOut[j]; - move32(); - i = add( i, len ); - } - } - } - - /* Reset */ - set16_fx( msLocalMinFlag, 0, len ); - set32_fx( msCurrentMin, 2147483647l /*1.0 Q31*/, len ); - - /* Get the current noise floor */ - Copy32( msCurrentMinOut, msNoiseFloor, len ); - } - } - - - /* Detect sudden offsets based on the FFT bins (core bandwidth) */ - IF( GT_32( Mpy_32_16_1( msPsdSum[0], 655 /*0.02 Q15*/ ), msPeriodogSum[0] ) /*0.0 Q31*/ ) - { - IF( hFdCngCom->offsetflag > 0 ) - { - Copy( msPeriodog, msPsd, len ); - FOR( j = 0; j < len; j++ ) - { - msCurrentMinOut[j] = L_deposit_h( msPeriodog[j] ); - move32(); - } - set32_fx( hFdCngCom->msAlphaCor, 2147483647l /*1.0 Q31*/, cnt ); - set32_fx( msAlpha, 0l /*0.0 Q31*/, len ); - Copy( msPeriodog, msPsdFirstMoment, len ); - set32_fx( msPsdSecondMoment, 0l /*0.0 Q31*/, len ); - - msPsdSum[0] = dotp_s_fx( msPeriodog, psize, lenFFT, CNG_HS ); - move32(); - IF( LT_16( lenFFT, len ) ) - { - msPsdSum[1] = dotp_s_fx( msPeriodog + lenFFT, psize + lenFFT, sub( len, lenFFT ), CNG_HS ); - move32(); - } - } - hFdCngCom->offsetflag = 1; - move16(); - } - ELSE - { - hFdCngCom->offsetflag = 0; - move16(); - } - - - /* Increment frame counter */ - IF( EQ_16( hFdCngCom->msFrCnt, MSSUBFRLEN ) ) - { - hFdCngCom->msFrCnt = 1; - move16(); - hFdCngCom->msMinBufferPtr = add( hFdCngCom->msMinBufferPtr, 1 ); - move16(); - if ( EQ_16( hFdCngCom->msMinBufferPtr, MSNUMSUBFR ) ) - { - hFdCngCom->msMinBufferPtr = 0; - move16(); - } - } - ELSE - { - hFdCngCom->msFrCnt = add( hFdCngCom->msFrCnt, 1 ); - move16(); - } - Word64 tmp64; - /* Smooth noise estimate during CNG phases */ - FOR( j = 0; j < len; j++ ) - { - tmp64 = W_add( W_mult_32_16( msNoiseEst[j], 31130 /*0.95 Q15*/ ), W_mult_32_16( msNoiseFloor[j], 1638 /*0.05 Q15*/ ) ); - msNoiseEst[j] = W_extract_h( W_shl( tmp64, 16 ) ); // Q25 - move32(); - } - } - IF( EQ_16( enc_dec, DEC ) && EQ_16( element_mode, IVAS_CPE_TD ) ) - { - // v_multc(msNoiseEst, 1.4125f, msNoiseEst, NPART_SHAPING); - v_multc_att32( msNoiseEst, 23142, msNoiseEst, NPART_SHAPING ); - } - /* Collect buffers */ - Copy( msPeriodog, msPeriodogBuf + len * ( *msPeriodogBufPtr ), len ); - - *msPeriodogBufPtr = add( *msPeriodogBufPtr, 1 ); - move16(); - if ( EQ_16( *msPeriodogBufPtr, MSBUFLEN ) ) - { - ( *msPeriodogBufPtr ) = 0; - move16(); - } - - /* Upper limit the noise floors with the averaged input energy */ - FOR( j = 0; j < len; j++ ) - { - scalar = L_mult( msPeriodogBuf[j], 6554 /*1.0/MSBUFLEN Q15*/ ); - - FOR( i = j + len; i < MSBUFLEN * len; i += len ) - { - scalar = L_mac( scalar, msPeriodogBuf[i], 6554 /*1.0/MSBUFLEN Q15*/ ); - } - if ( GT_32( msNoiseEst[j], scalar ) /*0.0 Q15*/ ) - { - msNoiseEst[j] = scalar; - move32(); - } - - assert( msNoiseEst[j] >= 0 /*0.0 Q15*/ ); - } -} -#else void minimum_statistics_fx( Word16 len, /* i : Total number of partitions (CLDFB or FFT) */ @@ -2404,7 +1198,6 @@ void minimum_statistics_fx( } } -#endif /*FIX_2485_HARMONIZE_minimum_statistics*/ /*------------------------------------------------------------------- diff --git a/lib_com/options.h b/lib_com/options.h index 77bb41670..ea5b697be 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -91,7 +91,6 @@ #define NONBE_FIX_ISSUE_2206_AVOID_OVERFLOW_SWB_fenv_fx2 /* FhG: Avoid overflow of SWB_fenv_fx in SWB_BWE_encoding_fx because of very small energies. */ #define NONBE_FIX_ISSUE_2206_AVOID_OVERFLOW_MSVQ_Interpol_Tran_fx /* FhG: Fix saturation crash in MSVQ_Interpol_Tran_fx() */ #define FIX_2452_HQ_CORE_PEAQ_AVR_RATIO_HARM /* Eri: Basop issue 2453: Fix alignment of peak_avrg_ratio_fx */ -#define FIX_2485_HARMONIZE_minimum_statistics /* FhG: harmonize minimum_statistics and minimum_statistics_fx */ #define FIX_FLOAT_ISSUE_1546_DEAD_CODE /* FhG: remove dead code reported in the issue*/ #define FIX_FLOAT_1539_G192_FORMAT_SWITCH /* VA/Nokia: reintroduce format switching for g192 bitstreams */ #define OPTIMIZE_FFT_STACK /* VA: removal of intermediate FFT buffers */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 12a057684..58d19a87a 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -4620,7 +4620,6 @@ void expand_range_var_exp( Word16 *out_exp, const Word16 len ); -#ifdef FIX_2485_HARMONIZE_minimum_statistics void minimum_statistics_fx( Word16 len, /* i : Total number of partitions (CLDFB or FFT) */ Word16 lenFFT, /* i : Number of FFT partitions */ @@ -4646,57 +4645,6 @@ void minimum_statistics_fx( const Word16 enc_dec, /* i : encoder/decoder indicator */ const Word16 element_mode /* i : element mode type */ ); -#else -void minimum_statistics( - Word16 len, /* i : Total number of partitions (CLDFB or FFT) */ - Word16 lenFFT, /* i : Number of FFT partitions */ - Word16 *psize, /* i : Partition sizes, fractional */ - Word16 *msPeriodog, /* i : Periodogram (energies) */ - Word16 *msNoiseFloor, /* i/o: Noise floors (energies) */ - Word16 *msNoiseEst, /* i/o: Noise estimates (energies) */ - Word32 *msAlpha, /* i/o: Forgetting factors */ - Word16 *msPsd, /* i/o: Power Spectral Density (smoothed periodogram => energies) */ - Word16 *msPsdFirstMoment, /* i/o: PSD statistics of 1st order (energy means) */ - Word32 *msPsdSecondMoment, /* i/o: PSD statistics of 2nd order (energy variances) */ - Word32 *msMinBuf, /* i/o: Buffer of minima (energies) */ - Word32 *msBminWin, /* o : Bias correction factors */ - Word32 *msBminSubWin, /* o : Bias correction factors */ - Word32 *msCurrentMin, /* i/o: Local minima (energies) */ - Word32 *msCurrentMinOut, /* i/o: Local minima (energies) */ - Word32 *msCurrentMinSubWindow, /* i/o: Local minima (energies) */ - Word16 *msLocalMinFlag, /* i : Binary flag */ - Word16 *msNewMinFlag, /* i : Binary flag */ - Word16 *msPeriodogBuf, /* i/o: Buffer of periodograms (energies) */ - Word16 *msPeriodogBufPtr, /* i/o: Counter */ - HANDLE_FD_CNG_COM st /* i/o: FD_CNG structure containing buffers and variables */ -); - -void minimum_statistics_fx( - Word16 len, /* i : Total number of partitions (CLDFB or FFT) */ - Word16 lenFFT, /* i : Number of FFT partitions */ - Word16 *psize, /* i : Partition sizes, fractional */ - Word16 *msPeriodog, /* i : Periodogram (energies) */ - Word32 *msNoiseFloor, /* i/o: Noise floors (energies) Q25*/ - Word32 *msNoiseEst, /* i/o: Noise estimates (energies) Q25*/ - Word32 *msAlpha, /* i/o: Forgetting factors */ - Word16 *msPsd, /* i/o: Power Spectral Density (smoothed periodogram => energies) */ - Word16 *msPsdFirstMoment, /* i/o: PSD statistics of 1st order (energy means) */ - Word32 *msPsdSecondMoment, /* i/o: PSD statistics of 2nd order (energy variances) */ - Word32 *msMinBuf, /* i/o: Buffer of minima (energies) */ - Word32 *msBminWin, /* o : Bias correction factors */ - Word32 *msBminSubWin, /* o : Bias correction factors */ - Word32 *msCurrentMin, /* i/o: Local minima (energies) */ - Word32 *msCurrentMinOut, /* i/o: Local minima (energies) */ - Word32 *msCurrentMinSubWindow, /* i/o: Local minima (energies) */ - Word16 *msLocalMinFlag, /* i : Binary flag */ - Word16 *msNewMinFlag, /* i : Binary flag */ - Word16 *msPeriodogBuf, /* i/o: Buffer of periodograms (energies) */ - Word16 *msPeriodogBufPtr, /* i/o: Counter */ - HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - const Word16 enc_dec, /* i : encoder/decoder indicator */ - const Word16 element_mode /* i : IVAS element mode type */ -); -#endif /* Apply bitrate-dependant scale */ void apply_scale( diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 27772455b..aba421f95 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -1280,7 +1280,6 @@ void perform_noise_estimation_dec_fx( compress_range( hFdCngDec->msPeriodog, hFdCngDec->msPeriodog_exp, hFdCngDec->msLogPeriodog, npart ); /* Call the minimum statistics routine for noise estimation */ -#ifdef FIX_2485_HARMONIZE_minimum_statistics minimum_statistics_fx( npart, nFFTpart, @@ -1305,30 +1304,6 @@ void perform_noise_estimation_dec_fx( hFdCngDec->hFdCngCom, DEC, EVS_MONO ); -#else - minimum_statistics( - npart, - nFFTpart, - psize_norm, - hFdCngDec->msLogPeriodog, - hFdCngDec->msNoiseFloor, - hFdCngDec->msLogNoiseEst, - hFdCngDec->msAlpha, - hFdCngDec->msPsd, - hFdCngDec->msPsdFirstMoment, - hFdCngDec->msPsdSecondMoment, - hFdCngDec->msMinBuf, - hFdCngDec->msBminWin, - hFdCngDec->msBminSubWin, - hFdCngDec->msCurrentMin, - hFdCngDec->msCurrentMinOut, - hFdCngDec->msCurrentMinSubWindow, - hFdCngDec->msLocalMinFlag, - hFdCngDec->msNewMinFlag, - hFdCngDec->msPeriodogBuf, - &( hFdCngDec->msPeriodogBufPtr ), - hFdCngDec->hFdCngCom ); -#endif /* Expand MS outputs */ expand_range( hFdCngDec->msLogNoiseEst, hFdCngDec->msNoiseEst, &hFdCngDec->msNoiseEst_exp, npart ); diff --git a/lib_enc/fd_cng_enc_fx.c b/lib_enc/fd_cng_enc_fx.c index 2e0db50f0..5b7a43563 100644 --- a/lib_enc/fd_cng_enc_fx.c +++ b/lib_enc/fd_cng_enc_fx.c @@ -1761,7 +1761,6 @@ void perform_noise_estimation_enc_fx( compress_range( msPeriodog_fx, hFdCngEnc->msPeriodog_fx_exp, hFdCngEnc->msLogPeriodog_fx, hFdCngEnc->hFdCngCom->npart ); /* Call the minimum statistics routine for noise estimation */ -#ifdef FIX_2485_HARMONIZE_minimum_statistics minimum_statistics_fx( hFdCngEnc->hFdCngCom->npart, nFFTpart, @@ -1797,66 +1796,6 @@ void perform_noise_estimation_enc_fx( { expand_range( hFdCngEnc->msLogNoiseEst_fx, hFdCngEnc->msNoiseEst_fx, &hFdCngEnc->msNoiseEst_fx_exp, hFdCngEnc->hFdCngCom->npart ); } -#else - IF( element_mode > 0 ) - { - minimum_statistics_fx( - hFdCngEnc->hFdCngCom->npart, - nFFTpart, - hFdCngEnc->hFdCngCom->psize_norm, - hFdCngEnc->msLogPeriodog_fx, - hFdCngEnc->msNoiseFloor_32fx, /*32bit*/ - hFdCngEnc->msLogNoiseEst_32fx, /*32bit*/ - hFdCngEnc->msAlpha_fx, - hFdCngEnc->msPsd_fx, - hFdCngEnc->msPsdFirstMoment_fx, - hFdCngEnc->msPsdSecondMoment_fx, - hFdCngEnc->msMinBuf_fx, - hFdCngEnc->msBminWin_fx, - hFdCngEnc->msBminSubWin_fx, - hFdCngEnc->msCurrentMin_fx, - hFdCngEnc->msCurrentMinOut_fx, - hFdCngEnc->msCurrentMinSubWindow_fx, - hFdCngEnc->msLocalMinFlag, - hFdCngEnc->msNewMinFlag, - hFdCngEnc->msPeriodogBuf_fx, - &( hFdCngEnc->msPeriodogBufPtr ), - hFdCngEnc->hFdCngCom, - ENC, - ( hCPE == NULL ) ? 0 : hCPE->element_mode ); - - /* Expand MS outputs */ - expand_range_fx( hFdCngEnc->msLogNoiseEst_32fx, hFdCngEnc->msNoiseEst_fx, &hFdCngEnc->msNoiseEst_fx_exp, hFdCngEnc->hFdCngCom->npart ); - } - ELSE - { - minimum_statistics( - hFdCngEnc->hFdCngCom->npart, - nFFTpart, - hFdCngEnc->hFdCngCom->psize_norm, - hFdCngEnc->msLogPeriodog_fx, - hFdCngEnc->msNoiseFloor_fx, /*16bit*/ - hFdCngEnc->msLogNoiseEst_fx, /*16bit*/ - hFdCngEnc->msAlpha_fx, - hFdCngEnc->msPsd_fx, - hFdCngEnc->msPsdFirstMoment_fx, - hFdCngEnc->msPsdSecondMoment_fx, - hFdCngEnc->msMinBuf_fx, - hFdCngEnc->msBminWin_fx, - hFdCngEnc->msBminSubWin_fx, - hFdCngEnc->msCurrentMin_fx, - hFdCngEnc->msCurrentMinOut_fx, - hFdCngEnc->msCurrentMinSubWindow_fx, - hFdCngEnc->msLocalMinFlag, - hFdCngEnc->msNewMinFlag, - hFdCngEnc->msPeriodogBuf_fx, - &( hFdCngEnc->msPeriodogBufPtr ), - hFdCngEnc->hFdCngCom ); - - /* Expand MS outputs */ - expand_range( hFdCngEnc->msLogNoiseEst_fx, hFdCngEnc->msNoiseEst_fx, &hFdCngEnc->msNoiseEst_fx_exp, hFdCngEnc->hFdCngCom->npart ); - } -#endif /*FIX_2485_HARMONIZE_minimum_statistics*/ return; } -- GitLab From 4d927001ebf528be4867471da86e71fdda73d5a7 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 13 Apr 2026 16:46:40 +0200 Subject: [PATCH 07/22] [cleanup] accept FIX_FLOAT_ISSUE_1546_DEAD_CODE --- lib_com/options.h | 1 - lib_enc/swb_bwe_enc_fx.c | 9 --------- 2 files changed, 10 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index ea5b697be..32cdefd6a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -91,7 +91,6 @@ #define NONBE_FIX_ISSUE_2206_AVOID_OVERFLOW_SWB_fenv_fx2 /* FhG: Avoid overflow of SWB_fenv_fx in SWB_BWE_encoding_fx because of very small energies. */ #define NONBE_FIX_ISSUE_2206_AVOID_OVERFLOW_MSVQ_Interpol_Tran_fx /* FhG: Fix saturation crash in MSVQ_Interpol_Tran_fx() */ #define FIX_2452_HQ_CORE_PEAQ_AVR_RATIO_HARM /* Eri: Basop issue 2453: Fix alignment of peak_avrg_ratio_fx */ -#define FIX_FLOAT_ISSUE_1546_DEAD_CODE /* FhG: remove dead code reported in the issue*/ #define FIX_FLOAT_1539_G192_FORMAT_SWITCH /* VA/Nokia: reintroduce format switching for g192 bitstreams */ #define OPTIMIZE_FFT_STACK /* VA: removal of intermediate FFT buffers */ #define HARMONIZE_DCT /* VA: removal of duplicated DCT functions */ diff --git a/lib_enc/swb_bwe_enc_fx.c b/lib_enc/swb_bwe_enc_fx.c index 6ad951c5a..31bcd1e89 100644 --- a/lib_enc/swb_bwe_enc_fx.c +++ b/lib_enc/swb_bwe_enc_fx.c @@ -243,9 +243,6 @@ void swb_bwe_enc_fx( Word16 Qenc_synth_hf, Qenc_synth; FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; -#ifndef FIX_FLOAT_ISSUE_1546_DEAD_CODE - TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; -#endif IF( st_fx->element_mode == EVS_MONO ) { @@ -307,9 +304,6 @@ void swb_bwe_enc_fx( IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) ) { Copy( old_input_12k8_fx + L_INP_MEM - Sample_Delay_LP, hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); -#ifndef FIX_FLOAT_ISSUE_1546_DEAD_CODE - Copy( hBWE_TD->old_speech_shb_fx + L_LOOK_16k + L_SUBFR16k - Sample_Delay_HP, new_input_hp_fx, Sample_Delay_HP ); -#endif } Copy( hBWE_FD->old_input_lp_fx, old_input_lp_fx, Sample_Delay_LP ); Copy( old_input_12k8_fx + L_INP_MEM, &old_input_lp_fx[Sample_Delay_LP], L_FRAME - Sample_Delay_LP ); @@ -337,9 +331,6 @@ void swb_bwe_enc_fx( IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) ) { Copy( old_input_16k_fx + L_INP_MEM - Sample_Delay_LP, hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); -#ifndef FIX_FLOAT_ISSUE_1546_DEAD_CODE - Copy( hBWE_TD->old_speech_shb_fx + L_LOOK_16k + L_SUBFR16k - Sample_Delay_HP, new_input_hp_fx, Sample_Delay_HP ); -#endif } Copy( hBWE_FD->old_input_lp_fx, old_input_lp_fx, Sample_Delay_LP ); -- GitLab From 7045019f2f00cf76a52faf1550439a4c3812c24b Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 13 Apr 2026 16:47:57 +0200 Subject: [PATCH 08/22] [cleanup] accept OPTIMIZE_FFT_STACK --- lib_com/basop_util.c | 2 - lib_com/basop_util.h | 2 - lib_com/edct_fx.c | 265 ----------------- lib_com/fft_fx_evs.c | 10 - lib_com/options.h | 1 - lib_com/prot_fx.h | 6 - lib_com/rom_com.h | 6 - lib_com/rom_com_fx.c | 513 -------------------------------- lib_com/scale_mem_fx.c | 2 - lib_com/tools_fx.c | 2 - lib_dec/FEC_HQ_phase_ecu_fx.c | 4 - lib_enc/ivas_mdct_core_enc_fx.c | 34 --- 12 files changed, 847 deletions(-) diff --git a/lib_com/basop_util.c b/lib_com/basop_util.c index b67332ab9..335f61c1e 100644 --- a/lib_com/basop_util.c +++ b/lib_com/basop_util.c @@ -714,7 +714,6 @@ Word16 getScaleFactor16( /* o: measured headroom in range [ return i; } -#ifdef OPTIMIZE_FFT_STACK /* o: measured headroom in range [0..31], 0 if all x[i] == 0 */ Word16 getScaleFactor32_cmplx( cmplx *x, /* i: array containing 32-bit data */ @@ -772,7 +771,6 @@ Word16 getScaleFactor32_cmplx( return s_min( i_re, i_im ); } -#endif /********************************************************************/ diff --git a/lib_com/basop_util.h b/lib_com/basop_util.h index 47c795913..d52830430 100644 --- a/lib_com/basop_util.h +++ b/lib_com/basop_util.h @@ -221,13 +221,11 @@ Word16 getScaleFactor16( const Word16 *x, /* i: array containing 16-bit data */ const Word16 len_x ); /* i: length of the array to scan */ -#ifdef OPTIMIZE_FFT_STACK /* o: measured headroom in range [0..31], 0 if all x[i] == 0 */ Word16 getScaleFactor32_cmplx( cmplx *x, /* i: array containing 32-bit data */ const Word16 len_x /* i: length of the array to scan */ ); -#endif /********************************************************************/ /*! diff --git a/lib_com/edct_fx.c b/lib_com/edct_fx.c index 84793d4fd..d63117cb0 100644 --- a/lib_com/edct_fx.c +++ b/lib_com/edct_fx.c @@ -55,12 +55,7 @@ static Word16 get_edxt_factor( } ELSE IF( EQ_16( length, 40 ) ) { -#ifdef OPTIMIZE_FFT_STACK assert( 0 ); -#else - factor = 7327; /*0.223 in Q15*/ - move16(); -#endif } ELSE IF( EQ_16( length, 960 ) ) { @@ -79,48 +74,23 @@ static Word16 get_edxt_factor( } ELSE IF( EQ_16( length, 120 ) ) { -#ifdef OPTIMIZE_FFT_STACK assert( 0 ); -#else - factor = 4230; /*0.1290 in Q15*/ - move16(); -#endif } ELSE IF( EQ_16( length, 1200 ) ) { -#ifdef OPTIMIZE_FFT_STACK assert( 0 ); -#else - factor = 1338; /*0.040 in Q15*/ - move16(); -#endif } ELSE IF( EQ_16( length, 800 ) ) { -#ifdef OPTIMIZE_FFT_STACK assert( 0 ); -#else - factor = 1638; /*0.05 in Q15*/ - move16(); -#endif } ELSE IF( EQ_16( length, 400 ) ) { -#ifdef OPTIMIZE_FFT_STACK assert( 0 ); -#else - factor = 2317; /*0.070 in Q15*/ - move16(); -#endif } ELSE IF( EQ_16( length, 200 ) ) { -#ifdef OPTIMIZE_FFT_STACK assert( 0 ); -#else - factor = 3277; /*0.1 in Q15*/ - move16(); -#endif } return factor; /*Q15*/ @@ -219,11 +189,7 @@ void edct_fx( Word32 re; Word32 im; const Word16 *edct_table; /*Q16 */ -#ifdef OPTIMIZE_FFT_STACK cmplx spec[L_FRAME_PLUS / 2]; -#else - Word32 complex_buf[2 * ( L_FRAME48k / 2 + 240 )]; -#endif Word32 L_tmp; Word16 tmp; Word16 len1; @@ -234,19 +200,11 @@ void edct_fx( FOR( i = 0; i < len1; i++ ) { L_tmp = Mult_32_16( x[2 * i], edct_table[i] ); /*Q(q+1) */ -#ifdef OPTIMIZE_FFT_STACK spec[i].re = Madd_32_16( L_tmp, x[( length - ( 1 + ( i * 2 ) ) )], edct_table[( len1 - ( 1 + i ) )] ); /*Q(q+1) */ -#else - complex_buf[2 * i] = Madd_32_16( L_tmp, x[( length - ( 1 + ( i * 2 ) ) )], edct_table[( len1 - ( 1 + i ) )] ); /*Q(q+1) */ -#endif move32(); L_tmp = Mult_32_16( x[( length - ( 1 + ( i * 2 ) ) )], edct_table[i] ); /*Q(q+1) */ -#ifdef OPTIMIZE_FFT_STACK spec[i].im = Msub_32_16( L_tmp, x[( i * 2 )], edct_table[( len1 - ( 1 + i ) )] ); /*Q(q+1) */ -#else - complex_buf[( ( i * 2 ) + 1 )] = Msub_32_16( L_tmp, x[( i * 2 )], edct_table[( len1 - ( 1 + i ) )] ); /*Q(q+1) */ -#endif move32(); } @@ -256,11 +214,7 @@ void edct_fx( #endif *q = sub( 15, *q ); move16(); -#ifdef OPTIMIZE_FFT_STACK BASOP_cfft( spec, len1, q, y ); -#else - BASOP_cfft( (cmplx *) complex_buf, len1, q, y ); -#endif tmp = div_s( 1, length ); /*Q15 */ tmp = round_fx( L_shl( L_mult( tmp, 19302 /*0.75f * EVS_PI in Q13*/ ), 2 ) ); /*Q15 */ @@ -284,13 +238,8 @@ void edct_fx( FOR( i = 0; i < len1; i++ ) { -#ifdef OPTIMIZE_FFT_STACK re = Msub_32_16( spec[i].re, spec[i].im, tmp ); /*Q(q+1) */ im = Madd_32_16( spec[i].im, spec[i].re, tmp ); /*Q(q+1) */ -#else - re = Msub_32_16( complex_buf[2 * i], complex_buf[( ( i * 2 ) + 1 )], tmp ); /*Q(q+1) */ - im = Madd_32_16( complex_buf[( ( i * 2 ) + 1 )], complex_buf[2 * i], tmp ); /*Q(q+1) */ -#endif y[2 * i] = L_add( Mult_32_16( re, edct_table[i] ), Mult_32_16( im, edct_table[( len1 - ( 1 + i ) )] ) ); /*Q(q+2)*/ move32(); y[( length - ( 1 + ( i * 2 ) ) )] = L_sub( Mult_32_16( re, edct_table[( len1 - ( 1 + i ) )] ), Mult_32_16( im, edct_table[i] ) ); /*Q(q+2)*/ @@ -399,11 +348,7 @@ void edst_fx( Word32 re; Word32 im; const Word16 *edct_table; /*Q16 */ -#ifdef OPTIMIZE_FFT_STACK cmplx complex_buf[L_FRAME_PLUS / 2]; -#else - Word32 complex_buf[2 * ( L_FRAME48k / 2 + 240 )]; -#endif Word32 L_tmp; Word16 tmp; Word16 len1; @@ -414,41 +359,24 @@ void edst_fx( FOR( i = 0; i < len1; i++ ) { L_tmp = Mult_32_16( x[( length - ( 1 + ( i * 2 ) ) )], edct_table[i] ); /*Qq+1*/ -#ifdef OPTIMIZE_FFT_STACK complex_buf[i].re = Madd_32_16( L_tmp, x[2 * i], edct_table[( len1 - ( 1 + i ) )] ); /*Qq+1*/ -#else - complex_buf[2 * i] = Madd_32_16( L_tmp, x[2 * i], edct_table[( len1 - ( 1 + i ) )] ); /*Qq+1*/ -#endif move32(); L_tmp = Mult_32_16( x[2 * i], edct_table[i] ); /*Qq+1*/ -#ifdef OPTIMIZE_FFT_STACK complex_buf[i].im = Msub_32_16( L_tmp, x[( length - ( 1 + ( i * 2 ) ) )], edct_table[( len1 - ( 1 + i ) )] ); /*Qq+1*/ -#else - complex_buf[( ( i * 2 ) + 1 )] = Msub_32_16( L_tmp, x[( length - ( 1 + ( i * 2 ) ) )], edct_table[( len1 - ( 1 + i ) )] ); /*Qq+1*/ -#endif move32(); } *q = sub( 15, *q ); move16(); -#ifdef OPTIMIZE_FFT_STACK BASOP_cfft( complex_buf, len1, q, y ); -#else - BASOP_cfft( (cmplx *) complex_buf, len1, q, y ); -#endif tmp = div_s( 1, length ); /*Q15 */ tmp = round_fx( L_shl( L_mult( tmp, 19302 /*0.75f * EVS_PI in Q13*/ ), 2 ) ); /*Q15 */ FOR( i = 0; i < len1; i++ ) { -#ifdef OPTIMIZE_FFT_STACK re = Msub_32_16( complex_buf[i].re, complex_buf[i].im, tmp ); /*Qq+1*/ im = Madd_32_16( complex_buf[i].im, complex_buf[i].re, tmp ); /*Qq+1*/ -#else - re = Msub_32_16( complex_buf[2 * i], complex_buf[( ( i * 2 ) + 1 )], tmp ); /*Qq+1*/ - im = Madd_32_16( complex_buf[( ( i * 2 ) + 1 )], complex_buf[2 * i], tmp ); /*Qq+1*/ -#endif y[2 * i] = L_add( Mult_32_16( re, edct_table[i] ), Mult_32_16( im, edct_table[( len1 - ( 1 + i ) )] ) ); /*Qq+2*/ move32(); y[( length - ( 1 + ( i * 2 ) ) )] = L_sub( Mult_32_16( im, edct_table[i] ), Mult_32_16( re, edct_table[( len1 - ( 1 + i ) )] ) ); /*Qq+2*/ @@ -496,16 +424,8 @@ void edct_16fx( Word16 re[L_FRAME48k / 2]; Word16 im[L_FRAME48k / 2]; const Word16 *edct_table = NULL; -#ifndef OPTIMIZE_FFT_STACK - Word16 re2[L_FRAME48k / 2]; - Word16 im2[L_FRAME48k / 2]; -#endif Word32 L_tmp, Lacc, Lmax; -#ifdef OPTIMIZE_FFT_STACK Word16 tmp, tmp_re, fact; -#else - Word16 tmp, fact; -#endif Word16 Q_edct; Word16 Len2, i2; const Word16 *px, *pt; @@ -569,46 +489,26 @@ void edct_16fx( L_tmp = L_mult( x[i2], edct_table[i] ); /*Q(Qx+16) */ Lacc = L_mac_sat( L_tmp, *px, *pt ); /*Q(Qx+16) */ -#ifdef OPTIMIZE_FFT_STACK re[i] = round_fx_sat( L_shl_sat( Lacc, Q_edct ) ); /* Q(Qx+Q_edct) */ -#else - re2[i] = round_fx_sat( L_shl_sat( Lacc, Q_edct ) ); /* Q(Qx+Q_edct) */ -#endif move16(); L_tmp = L_mult( *px, edct_table[i] ); /*Q(Qx+16) */ Lacc = L_msu_sat( L_tmp, x[i2], *pt ); /*Q(Qx+16) */ -#ifdef OPTIMIZE_FFT_STACK im[i] = round_fx_sat( L_shl_sat( Lacc, Q_edct ) ); /* Q(Qx+Q_edct) */ -#else - im2[i] = round_fx_sat( L_shl_sat( Lacc, Q_edct ) ); /* Q(Qx+Q_edct) */ -#endif move16(); px -= 2; pt--; } IF( EQ_16( length, L_FRAME32k ) ) { -#ifdef OPTIMIZE_FFT_STACK DoRTFT320_16fx( re, im ); -#else - DoRTFT320_16fx( re2, im2 ); -#endif } ELSE IF( EQ_16( length, L_FRAME ) ) { -#ifdef OPTIMIZE_FFT_STACK DoRTFT128_16fx( re, im ); -#else - DoRTFT128_16fx( re2, im2 ); -#endif } ELSE IF( EQ_16( length, L_FRAME16k ) ) { -#ifdef OPTIMIZE_FFT_STACK DoRTFT160_16fx( re, im ); -#else - DoRTFT160_16fx( re2, im2 ); -#endif } ELSE { @@ -618,7 +518,6 @@ void edct_16fx( fact = round_fx( L_shl( L_tmp, 2 ) ); /*Q15 */ FOR( i = 0; i < shr( length, 1 ); i++ ) { -#ifdef OPTIMIZE_FFT_STACK tmp = mult_r( im[i], fact ); /*Q(Qx+Q_edct) */ tmp_re = sub_sat( re[i], tmp ); /*Q(Qx+Q_edct) */ move16(); @@ -629,15 +528,6 @@ void edct_16fx( re[i] = tmp_re; move16(); -#else - tmp = mult_r( im2[i], fact ); /*Q(Qx+Q_edct) */ - re[i] = sub_sat( re2[i], tmp ); /*Q(Qx+Q_edct) */ - move16(); - - tmp = mult_r( re2[i], fact ); /*Q(Qx+Q_edct) */ - im[i] = add_sat( im2[i], tmp ); /*Q(Qx+Q_edct) */ - move16(); -#endif } /* Post-rotate and obtain the output data */ @@ -799,14 +689,7 @@ void edxt_fx( } ELSE IF( EQ_16( length, 40 ) ) { -#ifdef OPTIMIZE_FFT_STACK assert( 0 ); -#else - cosPtr = cos_scale_tbl_640; /*Q15*/ - sinPtr = sin_scale_tbl_640; /*Q15*/ - n = 16; - move16(); -#endif } ELSE IF( EQ_16( length, 960 ) ) { @@ -831,58 +714,23 @@ void edxt_fx( } ELSE IF( EQ_16( length, 120 ) ) { -#ifdef OPTIMIZE_FFT_STACK assert( 0 ); -#else - cosPtr = cos_scale_tbl_960; /*Q15*/ - sinPtr = sin_scale_tbl_960; /*Q15*/ - n = 8; - move16(); -#endif } ELSE IF( EQ_16( length, 1200 ) ) { -#ifdef OPTIMIZE_FFT_STACK assert( 0 ); -#else - cosPtr = cos_scale_tbl_1200; /*Q15*/ - sinPtr = sin_scale_tbl_1200; /*Q15*/ - n = 1; - move16(); -#endif } ELSE IF( EQ_16( length, 800 ) ) { -#ifdef OPTIMIZE_FFT_STACK assert( 0 ); -#else - cosPtr = cos_scale_tbl_800; /*Q15*/ - sinPtr = sin_scale_tbl_800; /*Q15*/ - n = 1; - move16(); -#endif } ELSE IF( EQ_16( length, 400 ) ) { -#ifdef OPTIMIZE_FFT_STACK assert( 0 ); -#else - cosPtr = cos_scale_tbl_800; /*Q15*/ - sinPtr = sin_scale_tbl_800; /*Q15*/ - n = 2; - move16(); -#endif } ELSE IF( EQ_16( length, 200 ) ) { -#ifdef OPTIMIZE_FFT_STACK assert( 0 ); -#else - cosPtr = cos_scale_tbl_800; /*Q15*/ - sinPtr = sin_scale_tbl_800; /*Q15*/ - n = 4; - move16(); -#endif } test(); @@ -890,26 +738,15 @@ void edxt_fx( { const Word16 Nm1 = sub( length, 1 ); const Word16 xSign = sub( imult1616( 2, shr( kernelType, 1 ) ), 1 ); /*Q0*/ -#ifdef OPTIMIZE_FFT_STACK cmplx spec[L_FRAME_MAX]; -#else - Word32 re[L_FRAME_PLUS]; - Word32 im[L_FRAME_PLUS]; -#endif IF( !synthesis ) { FOR( k = ( Nm1 / 2 ); k >= 0; k-- ) /* pre-modulation of audio input */ { -#ifdef OPTIMIZE_FFT_STACK spec[k].re = x[2 * k]; /*Qx*/ spec[( Nm1 - k )].re = Mpy_32_16_1( x[( ( k * 2 ) + 1 )], shl_sat( xSign, 15 ) ); /*Qx*/ spec[k].im = spec[( Nm1 - k )].im = 0; -#else - re[k] = x[2 * k]; /*Qx*/ - re[( Nm1 - k )] = Mpy_32_16_1( x[( ( k * 2 ) + 1 )], shl_sat( xSign, 15 ) ); /*Qx*/ - im[k] = im[( Nm1 - k )] = 0; -#endif move32(); move32(); move32(); @@ -918,46 +755,24 @@ void edxt_fx( IF( EQ_16( length, 512 ) ) { /* Scaling down re and im buffers to avoid overflow in DoRTFTn_fx if the minimum headroom is less than 4 bits */ -#ifdef OPTIMIZE_FFT_STACK hdrm = L_norm_arr_cmplx( spec, 512 ); -#else - hdrm = s_min( L_norm_arr( re, 512 ), L_norm_arr( im, 512 ) ); -#endif IF( LT_16( hdrm, 4 ) ) { tmp = sub( hdrm, 4 ); -#ifdef OPTIMIZE_FFT_STACK scale_sig32_cmplx( spec, 512, tmp ); -#else - scale_sig32( re, 512, tmp ); - scale_sig32( im, 512, tmp ); -#endif } -#ifdef OPTIMIZE_FFT_STACK DoRTFTn_fx( NULL, NULL, spec, 512 ); -#else - DoRTFTn_fx( re, im, 512 ); -#endif IF( LT_16( hdrm, 4 ) ) { tmp = negate( tmp ); -#ifdef OPTIMIZE_FFT_STACK scale_sig32_cmplx( spec, 512, tmp ); -#else - scale_sig32( re, 512, tmp ); - scale_sig32( im, 512, tmp ); -#endif } } ELSE /* fft() doesn't support 512 */ { -#ifdef OPTIMIZE_FFT_STACK fft_fx( spec, length ); -#else - fft_fx( re, im, length, 1 ); -#endif } IF( shr( kernelType, 1 ) ) @@ -969,21 +784,12 @@ void edxt_fx( const Word16 wRe = cosPtr[( k * n )]; /*Q15*/ const Word16 wIm = sinPtr[( k * n )]; /*Q15*/ -#ifdef OPTIMIZE_FFT_STACK y[k] /*pt 1*/ = L_add( Mpy_32_16_1( spec[k].re, wRe ), Mpy_32_16_1( spec[k].im, wIm ) ); /*Qx*/ y[( length - k )] = L_sub( Mpy_32_16_1( spec[k].re, wIm ), Mpy_32_16_1( spec[k].im, wRe ) ); /*Qx*/ -#else - y[k] /*pt 1*/ = L_add( Mpy_32_16_1( re[k], wRe ), Mpy_32_16_1( im[k], wIm ) ); /*Qx*/ - y[( length - k )] = L_sub( Mpy_32_16_1( re[k], wIm ), Mpy_32_16_1( im[k], wRe ) ); /*Qx*/ -#endif move32(); move32(); } -#ifdef OPTIMIZE_FFT_STACK y[( length / 2 )] = Mpy_32_16_1( spec[( length / 2 )].re, INV_SQRT_2_Q15 ); /*Qx*/ -#else - y[( length / 2 )] = Mpy_32_16_1( re[( length / 2 )], INV_SQRT_2_Q15 ); /*Qx*/ -#endif move32(); } ELSE /* forw. DST-II */ @@ -995,29 +801,16 @@ void edxt_fx( const Word16 wRe = cosPtr[( k * n )]; /*Q15*/ const Word16 wIm = sinPtr[( k * n )]; /*Q15*/ -#ifdef OPTIMIZE_FFT_STACK y[( Nm1 - k )] = L_add( Mpy_32_16_1( spec[k].re, wRe ), Mpy_32_16_1( spec[k].im, wIm ) ); /*Qx*/ y[k - 1] = L_sub( Mpy_32_16_1( spec[k].re, wIm ), Mpy_32_16_1( spec[k].im, wRe ) ); /*Qx*/ -#else - y[( Nm1 - k )] = L_add( Mpy_32_16_1( re[k], wRe ), Mpy_32_16_1( im[k], wIm ) ); /*Qx*/ - y[k - 1] = L_sub( Mpy_32_16_1( re[k], wIm ), Mpy_32_16_1( im[k], wRe ) ); /*Qx*/ -#endif move32(); move32(); } -#ifdef OPTIMIZE_FFT_STACK y[( Nm1 / 2 )] = Mpy_32_16_1( spec[( length / 2 )].re, INV_SQRT_2_Q15 ); /*Qx*/ -#else - y[( Nm1 / 2 )] = Mpy_32_16_1( re[( length / 2 )], INV_SQRT_2_Q15 ); /*Qx*/ -#endif move32(); } -#ifdef OPTIMIZE_FFT_STACK y[( Nm1 - ( Nm1 * ( kernelType / 2 ) ) )] = L_shr( spec[0].re, 1 ); /*Qx*/ -#else - y[( Nm1 - ( Nm1 * ( kernelType / 2 ) ) )] = L_shr( re[0], 1 ); /*Qx*/ -#endif move32(); } ELSE /* inverse II = III */ @@ -1031,21 +824,12 @@ void edxt_fx( const Word16 wRe = shr( cosPtr[imult1616( k, n )], 1 ); const Word16 wIm = shr( sinPtr[imult1616( k, n )], 1 ); -#ifdef OPTIMIZE_FFT_STACK spec[k].re = L_add( Mpy_32_16_1( x[k], wRe ), Mpy_32_16_1( x[( length - k )], wIm ) ); /*Qx*/ spec[k].im = L_sub( Mpy_32_16_1( x[( length - k )], wRe ), Mpy_32_16_1( x[k], wIm ) ); /*Qx*/ -#else - re[k] = L_add( Mpy_32_16_1( x[k], wRe ), Mpy_32_16_1( x[( length - k )], wIm ) ); /*Qx*/ - im[k] = L_sub( Mpy_32_16_1( x[( length - k )], wRe ), Mpy_32_16_1( x[k], wIm ) ); /*Qx*/ -#endif move32(); move32(); } -#ifdef OPTIMIZE_FFT_STACK spec[( length / 2 )].re = Mpy_32_16_1( x[( length / 2 )], INV_SQRT_2_Q15 ); /*Qx*/ -#else - re[( length / 2 )] = Mpy_32_16_1( x[( length / 2 )], INV_SQRT_2_Q15 ); /*Qx*/ -#endif move32(); } ELSE /* DST type III */ @@ -1057,42 +841,23 @@ void edxt_fx( const Word16 wRe = shr( cosPtr[( k * n )], 1 ); /*Q15*/ const Word16 wIm = shr( sinPtr[( k * n )], 1 ); /*Q15*/ -#ifdef OPTIMIZE_FFT_STACK spec[k].re = L_add( Mpy_32_16_1( x[( Nm1 - k )], wRe ), Mpy_32_16_1( x[( k - 1 )], wIm ) ); /*Qx*/ spec[k].im = L_sub( Mpy_32_16_1( x[( k - 1 )], wRe ), Mpy_32_16_1( x[( Nm1 - k )], wIm ) ); /*Qx*/ -#else - re[k] = L_add( Mpy_32_16_1( x[( Nm1 - k )], wRe ), Mpy_32_16_1( x[( k - 1 )], wIm ) ); /*Qx*/ - im[k] = L_sub( Mpy_32_16_1( x[( k - 1 )], wRe ), Mpy_32_16_1( x[( Nm1 - k )], wIm ) ); /*Qx*/ -#endif move32(); move32(); } -#ifdef OPTIMIZE_FFT_STACK spec[( length / 2 )].re = Mpy_32_16_1( x[( Nm1 / 2 )], INV_SQRT_2_Q15 ); /*Qx*/ -#else - re[( length / 2 )] = Mpy_32_16_1( x[( Nm1 / 2 )], INV_SQRT_2_Q15 ); /*Qx*/ -#endif move32(); } -#ifdef OPTIMIZE_FFT_STACK spec[0].re = x[( Nm1 - ( Nm1 * ( kernelType / 2 ) ) )]; /*Qx*/ spec[0].im = spec[( length / 2 )].im = 0; -#else - re[0] = x[( Nm1 - ( Nm1 * ( kernelType / 2 ) ) )]; /*Qx*/ - im[0] = im[( length / 2 )] = 0; -#endif move32(); move32(); FOR( k = ( Nm1 / 2 ); k > 0; k-- ) { -#ifdef OPTIMIZE_FFT_STACK spec[( length - k )].re = spec[k].re; /*Qx*/ spec[( length - k )].im = L_negate( spec[k].im ); /*Qx*/ -#else - re[( length - k )] = re[k]; /*Qx*/ - im[( length - k )] = L_negate( im[k] ); /*Qx*/ -#endif move32(); move32(); } @@ -1100,63 +865,33 @@ void edxt_fx( IF( EQ_16( length, 512 ) ) { /* Scaling down re and im buffers to avoid overflow in DoRTFTn_fx if the minimum headroom is less than 4 bits */ -#ifdef OPTIMIZE_FFT_STACK hdrm = L_norm_arr_cmplx( spec, 512 ); -#else - hdrm = s_min( L_norm_arr( re, 512 ), L_norm_arr( im, 512 ) ); -#endif IF( LT_16( hdrm, 4 ) ) { tmp = sub( hdrm, 4 ); -#ifdef OPTIMIZE_FFT_STACK scale_sig32_cmplx( spec, 512, tmp ); -#else - scale_sig32( re, 512, tmp ); - scale_sig32( im, 512, tmp ); -#endif } -#ifdef OPTIMIZE_FFT_STACK DoRTFTn_fx( NULL, NULL, spec, 512 ); -#else - DoRTFTn_fx( re, im, 512 ); -#endif IF( LT_16( hdrm, 4 ) ) { tmp = negate( tmp ); -#ifdef OPTIMIZE_FFT_STACK scale_sig32_cmplx( spec, 512, tmp ); -#else - scale_sig32( re, 512, tmp ); - scale_sig32( im, 512, tmp ); -#endif } } ELSE /* fft() doesn't support 512 */ { -#ifdef OPTIMIZE_FFT_STACK fft_fx( spec, length ); -#else - fft_fx( re, im, length, 1 ); -#endif } FOR( k = ( Nm1 / 2 ); k >= 0; k-- ) /* post-modulation of FFT output */ { -#ifdef OPTIMIZE_FFT_STACK y[2 * k] = spec[k].re; /*Qx*/ -#else - y[2 * k] = re[k]; /*Qx*/ -#endif move32(); IF( xSign != 0 ) { -#ifdef OPTIMIZE_FFT_STACK y[( ( k * 2 ) + 1 )] = Mpy_32_16_1( spec[( Nm1 - k )].re, shl_sat( xSign, 15 ) ); /*Qx*/ -#else - y[( ( k * 2 ) + 1 )] = Mpy_32_16_1( re[( Nm1 - k )], shl_sat( xSign, 15 ) ); /*Qx*/ -#endif } ELSE { diff --git a/lib_com/fft_fx_evs.c b/lib_com/fft_fx_evs.c index a17ff1832..49d73dd99 100644 --- a/lib_com/fft_fx_evs.c +++ b/lib_com/fft_fx_evs.c @@ -52,16 +52,13 @@ static void cftmdl_fx( Word16 n, Word16 l, Word32 *a, const Word16 *w ); void DoRTFTn_fx( Word32 *x, /* i/o : real part of input and output data Q(x) */ Word32 *y, /* i/o : imaginary part of input and output data Q(x) */ -#ifdef OPTIMIZE_FFT_STACK cmplx *spec, /* i/o : complex input and output data */ -#endif const Word16 n /* i : size of the FFT up to 1024 */ ) { Word16 i; Word32 z[2048], *pt; -#ifdef OPTIMIZE_FFT_STACK IF( spec != NULL ) { pt = z; @@ -75,7 +72,6 @@ void DoRTFTn_fx( } ELSE { -#endif pt = z; FOR( i = 0; i < n; i++ ) { @@ -84,9 +80,7 @@ void DoRTFTn_fx( *pt++ = y[i]; move16(); } -#ifdef OPTIMIZE_FFT_STACK } -#endif IF( EQ_16( n, 16 ) ) { @@ -117,7 +111,6 @@ void DoRTFTn_fx( assert( 0 ); } -#ifdef OPTIMIZE_FFT_STACK IF( spec != NULL ) { spec[0].re = z[0]; @@ -135,7 +128,6 @@ void DoRTFTn_fx( } ELSE { -#endif x[0] = z[0]; move16(); y[0] = z[1]; @@ -148,9 +140,7 @@ void DoRTFTn_fx( y[i] = *pt++; move16(); } -#ifdef OPTIMIZE_FFT_STACK } -#endif return; } diff --git a/lib_com/options.h b/lib_com/options.h index 32cdefd6a..484294d1b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -92,7 +92,6 @@ #define NONBE_FIX_ISSUE_2206_AVOID_OVERFLOW_MSVQ_Interpol_Tran_fx /* FhG: Fix saturation crash in MSVQ_Interpol_Tran_fx() */ #define FIX_2452_HQ_CORE_PEAQ_AVR_RATIO_HARM /* Eri: Basop issue 2453: Fix alignment of peak_avrg_ratio_fx */ #define FIX_FLOAT_1539_G192_FORMAT_SWITCH /* VA/Nokia: reintroduce format switching for g192 bitstreams */ -#define OPTIMIZE_FFT_STACK /* VA: removal of intermediate FFT buffers */ #define HARMONIZE_DCT /* VA: removal of duplicated DCT functions */ #define FIX_2489_HARMONIZE_FdCng_encodeSID /* FhG: harmonize FdCng_encodeSID_fx() and FdCng_encodeSID_ivas_fx() */ #define FIX_1527_CMR_BITRATE_IDX /* Fix for incorrect bitrate idx packed in rtp CMR E-byte */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 58d19a87a..90f6c13ed 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -1292,14 +1292,12 @@ void scale_sig32( const Word16 exp0 /* i : exponent: x = round(x << exp) Qx xx exp */ ); -#ifdef OPTIMIZE_FFT_STACK void scale_sig32_cmplx( cmplx x[], /* i/o: signal to scale Qx */ const Word16 lg, /* i : size of x[] Q0 */ const Word16 exp0 /* i : exponent: x = round(x << exp) Qx exp */ ); -#endif void Scale_sig64( Word64 x[], /* i/o: signal to scale Qx */ Word16 len, /* i : size of x[] Q0 */ @@ -4046,9 +4044,7 @@ void BASOP_rfft( Word32 *x, Word16 sizeOfFft, Word16 *scale, Word16 isign ); void DoRTFTn_fx( Word32 *x, /* i/o : real part of i and output data */ Word32 *y, /* i/o : imaginary part of i and output data */ -#ifdef OPTIMIZE_FFT_STACK cmplx *spec, /* i/o : complex input and output data */ -#endif const Word16 n /* i : size of the FFT up to 1024 */ ); @@ -4131,9 +4127,7 @@ void DoRTFTn_fx_ivas( Word16 find_guarded_bits_fx( const Word32 n ); Word16 L_norm_arr( const Word32 *arr, Word16 size ); -#ifdef OPTIMIZE_FFT_STACK Word16 L_norm_arr_cmplx( const cmplx *arr, Word16 size ); -#endif #ifdef NONBE_FIX_ISSUE_2206 Word16 norm_arr( const Word16 *arr, Word16 size ); #else diff --git a/lib_com/rom_com.h b/lib_com/rom_com.h index dd73f7c50..74190dc58 100644 --- a/lib_com/rom_com.h +++ b/lib_com/rom_com.h @@ -1556,12 +1556,6 @@ extern const Word16 cos_scale_tbl_640[640]; // Q15 extern const Word16 sin_scale_tbl_640[640]; // Q15 extern const Word16 sin_scale_tbl_512[512]; // Q15 extern const Word16 cos_scale_tbl_512[512]; // Q15 -#ifndef OPTIMIZE_FFT_STACK -extern const Word16 cos_scale_tbl_1200[1200]; // Q15 -extern const Word16 sin_scale_tbl_1200[1200]; // Q15 -extern const Word16 cos_scale_tbl_800[800]; // Q15 -extern const Word16 sin_scale_tbl_800[800]; // Q15 -#endif extern const Word16 scales_ivas_fx[][MAX_NO_SCALES * 2]; // Q11 extern const Word16 scales_p_ivas_fx[][MAX_NO_SCALES * 2]; // Q11 diff --git a/lib_com/rom_com_fx.c b/lib_com/rom_com_fx.c index 14c6b97b8..2f75c5aad 100644 --- a/lib_com/rom_com_fx.c +++ b/lib_com/rom_com_fx.c @@ -27386,519 +27386,6 @@ const Word16 cos_scale_tbl_512[512] = /* Q15 */ 201, 100 }; -#ifndef OPTIMIZE_FFT_STACK -const Word16 sin_scale_tbl_1200[1200] = { /* Q15 */ - 0, 42, 85, 128, 171, 214, 257, 300, - 343, 386, 428, 471, 514, 557, 600, 643, - 686, 729, 771, 814, 857, 900, 943, 986, - 1029, 1072, 1114, 1157, 1200, 1243, 1286, 1329, - 1372, 1414, 1457, 1500, 1543, 1586, 1629, 1672, - 1714, 1757, 1800, 1843, 1886, 1929, 1971, 2014, - 2057, 2100, 2143, 2185, 2228, 2271, 2314, 2357, - 2399, 2442, 2485, 2528, 2570, 2613, 2656, 2699, - 2741, 2784, 2827, 2870, 2912, 2955, 2998, 3040, - 3083, 3126, 3169, 3211, 3254, 3297, 3339, 3382, - 3425, 3467, 3510, 3553, 3595, 3638, 3680, 3723, - 3766, 3808, 3851, 3893, 3936, 3979, 4021, 4064, - 4106, 4149, 4191, 4234, 4276, 4319, 4361, 4404, - 4446, 4489, 4531, 4574, 4616, 4659, 4701, 4744, - 4786, 4829, 4871, 4913, 4956, 4998, 5041, 5083, - 5125, 5168, 5210, 5252, 5295, 5337, 5379, 5422, - 5464, 5506, 5549, 5591, 5633, 5675, 5718, 5760, - 5802, 5844, 5886, 5929, 5971, 6013, 6055, 6097, - 6139, 6182, 6224, 6266, 6308, 6350, 6392, 6434, - 6476, 6518, 6560, 6602, 6644, 6686, 6728, 6770, - 6812, 6854, 6896, 6938, 6980, 7022, 7064, 7106, - 7147, 7189, 7231, 7273, 7315, 7357, 7398, 7440, - 7482, 7524, 7565, 7607, 7649, 7691, 7732, 7774, - 7816, 7857, 7899, 7940, 7982, 8024, 8065, 8107, - 8148, 8190, 8231, 8273, 8314, 8356, 8397, 8439, - 8480, 8522, 8563, 8604, 8646, 8687, 8729, 8770, - 8811, 8853, 8894, 8935, 8976, 9018, 9059, 9100, - 9141, 9182, 9224, 9265, 9306, 9347, 9388, 9429, - 9470, 9511, 9552, 9593, 9634, 9675, 9716, 9757, - 9798, 9839, 9880, 9921, 9962, 10003, 10043, 10084, - 10125, 10166, 10207, 10247, 10288, 10329, 10370, 10410, - 10451, 10491, 10532, 10573, 10613, 10654, 10694, 10735, - 10775, 10816, 10856, 10897, 10937, 10978, 11018, 11059, - 11099, 11139, 11180, 11220, 11260, 11300, 11341, 11381, - 11421, 11461, 11502, 11542, 11582, 11622, 11662, 11702, - 11742, 11782, 11822, 11862, 11902, 11942, 11982, 12022, - 12062, 12102, 12142, 12181, 12221, 12261, 12301, 12340, - 12380, 12420, 12460, 12499, 12539, 12579, 12618, 12658, - 12697, 12737, 12776, 12816, 12855, 12895, 12934, 12973, - 13013, 13052, 13092, 13131, 13170, 13209, 13249, 13288, - 13327, 13366, 13405, 13444, 13484, 13523, 13562, 13601, - 13640, 13679, 13718, 13757, 13796, 13834, 13873, 13912, - 13951, 13990, 14029, 14067, 14106, 14145, 14183, 14222, - 14261, 14299, 14338, 14376, 14415, 14453, 14492, 14530, - 14569, 14607, 14646, 14684, 14722, 14761, 14799, 14837, - 14875, 14914, 14952, 14990, 15028, 15066, 15104, 15142, - 15180, 15218, 15256, 15294, 15332, 15370, 15408, 15446, - 15484, 15521, 15559, 15597, 15635, 15672, 15710, 15748, - 15785, 15823, 15860, 15898, 15935, 15973, 16010, 16048, - 16085, 16122, 16160, 16197, 16234, 16271, 16309, 16346, - 16383, 16420, 16457, 16494, 16531, 16568, 16605, 16642, - 16679, 16716, 16753, 16790, 16827, 16863, 16900, 16937, - 16974, 17010, 17047, 17084, 17120, 17157, 17193, 17230, - 17266, 17303, 17339, 17375, 17412, 17448, 17484, 17521, - 17557, 17593, 17629, 17665, 17702, 17738, 17774, 17810, - 17846, 17882, 17918, 17953, 17989, 18025, 18061, 18097, - 18132, 18168, 18204, 18240, 18275, 18311, 18346, 18382, - 18417, 18453, 18488, 18524, 18559, 18594, 18630, 18665, - 18700, 18735, 18770, 18806, 18841, 18876, 18911, 18946, - 18981, 19016, 19051, 19086, 19120, 19155, 19190, 19225, - 19259, 19294, 19329, 19363, 19398, 19433, 19467, 19502, - 19536, 19570, 19605, 19639, 19673, 19708, 19742, 19776, - 19810, 19845, 19879, 19913, 19947, 19981, 20015, 20049, - 20083, 20117, 20150, 20184, 20218, 20252, 20285, 20319, - 20353, 20386, 20420, 20453, 20487, 20520, 20554, 20587, - 20620, 20654, 20687, 20720, 20753, 20787, 20820, 20853, - 20886, 20919, 20952, 20985, 21018, 21051, 21084, 21116, - 21149, 21182, 21215, 21247, 21280, 21313, 21345, 21378, - 21410, 21443, 21475, 21507, 21540, 21572, 21604, 21637, - 21669, 21701, 21733, 21765, 21797, 21829, 21861, 21893, - 21925, 21957, 21989, 22020, 22052, 22084, 22115, 22147, - 22179, 22210, 22242, 22273, 22305, 22336, 22367, 22399, - 22430, 22461, 22493, 22524, 22555, 22586, 22617, 22648, - 22679, 22710, 22741, 22772, 22802, 22833, 22864, 22895, - 22925, 22956, 22987, 23017, 23048, 23078, 23109, 23139, - 23169, 23200, 23230, 23260, 23290, 23320, 23351, 23381, - 23411, 23441, 23471, 23500, 23530, 23560, 23590, 23620, - 23649, 23679, 23709, 23738, 23768, 23797, 23827, 23856, - 23886, 23915, 23944, 23974, 24003, 24032, 24061, 24090, - 24119, 24148, 24177, 24206, 24235, 24264, 24293, 24321, - 24350, 24379, 24407, 24436, 24465, 24493, 24522, 24550, - 24578, 24607, 24635, 24663, 24692, 24720, 24748, 24776, - 24804, 24832, 24860, 24888, 24916, 24944, 24971, 24999, - 25027, 25054, 25082, 25110, 25137, 25165, 25192, 25220, - 25247, 25274, 25302, 25329, 25356, 25383, 25410, 25437, - 25464, 25491, 25518, 25545, 25572, 25599, 25625, 25652, - 25679, 25705, 25732, 25759, 25785, 25811, 25838, 25864, - 25891, 25917, 25943, 25969, 25995, 26021, 26047, 26073, - 26099, 26125, 26151, 26177, 26203, 26228, 26254, 26280, - 26305, 26331, 26356, 26382, 26407, 26433, 26458, 26483, - 26509, 26534, 26559, 26584, 26609, 26634, 26659, 26684, - 26709, 26734, 26758, 26783, 26808, 26832, 26857, 26882, - 26906, 26931, 26955, 26979, 27004, 27028, 27052, 27076, - 27100, 27125, 27149, 27173, 27197, 27220, 27244, 27268, - 27292, 27316, 27339, 27363, 27386, 27410, 27433, 27457, - 27480, 27504, 27527, 27550, 27573, 27596, 27620, 27643, - 27666, 27689, 27711, 27734, 27757, 27780, 27803, 27825, - 27848, 27871, 27893, 27916, 27938, 27960, 27983, 28005, - 28027, 28049, 28072, 28094, 28116, 28138, 28160, 28182, - 28203, 28225, 28247, 28269, 28290, 28312, 28334, 28355, - 28377, 28398, 28419, 28441, 28462, 28483, 28504, 28525, - 28547, 28568, 28589, 28610, 28630, 28651, 28672, 28693, - 28713, 28734, 28755, 28775, 28796, 28816, 28837, 28857, - 28877, 28897, 28918, 28938, 28958, 28978, 28998, 29018, - 29038, 29058, 29077, 29097, 29117, 29136, 29156, 29176, - 29195, 29215, 29234, 29253, 29273, 29292, 29311, 29330, - 29349, 29368, 29387, 29406, 29425, 29444, 29463, 29482, - 29500, 29519, 29537, 29556, 29575, 29593, 29611, 29630, - 29648, 29666, 29684, 29703, 29721, 29739, 29757, 29775, - 29792, 29810, 29828, 29846, 29863, 29881, 29899, 29916, - 29934, 29951, 29968, 29986, 30003, 30020, 30037, 30055, - 30072, 30089, 30106, 30122, 30139, 30156, 30173, 30190, - 30206, 30223, 30239, 30256, 30272, 30289, 30305, 30321, - 30338, 30354, 30370, 30386, 30402, 30418, 30434, 30450, - 30465, 30481, 30497, 30513, 30528, 30544, 30559, 30575, - 30590, 30605, 30621, 30636, 30651, 30666, 30681, 30696, - 30711, 30726, 30741, 30756, 30771, 30786, 30800, 30815, - 30829, 30844, 30858, 30873, 30887, 30901, 30916, 30930, - 30944, 30958, 30972, 30986, 31000, 31014, 31028, 31041, - 31055, 31069, 31082, 31096, 31109, 31123, 31136, 31149, - 31163, 31176, 31189, 31202, 31215, 31228, 31241, 31254, - 31267, 31280, 31293, 31305, 31318, 31331, 31343, 31356, - 31368, 31380, 31393, 31405, 31417, 31429, 31441, 31453, - 31465, 31477, 31489, 31501, 31513, 31525, 31536, 31548, - 31559, 31571, 31582, 31594, 31605, 31616, 31628, 31639, - 31650, 31661, 31672, 31683, 31694, 31705, 31716, 31726, - 31737, 31748, 31758, 31769, 31779, 31790, 31800, 31810, - 31821, 31831, 31841, 31851, 31861, 31871, 31881, 31891, - 31901, 31911, 31920, 31930, 31940, 31949, 31959, 31968, - 31977, 31987, 31996, 32005, 32014, 32023, 32033, 32042, - 32050, 32059, 32068, 32077, 32086, 32094, 32103, 32112, - 32120, 32128, 32137, 32145, 32154, 32162, 32170, 32178, - 32186, 32194, 32202, 32210, 32218, 32226, 32233, 32241, - 32249, 32256, 32264, 32271, 32279, 32286, 32293, 32300, - 32308, 32315, 32322, 32329, 32336, 32343, 32350, 32356, - 32363, 32370, 32376, 32383, 32389, 32396, 32402, 32409, - 32415, 32421, 32427, 32434, 32440, 32446, 32452, 32457, - 32463, 32469, 32475, 32481, 32486, 32492, 32497, 32503, - 32508, 32513, 32519, 32524, 32529, 32534, 32539, 32544, - 32549, 32554, 32559, 32564, 32569, 32573, 32578, 32582, - 32587, 32591, 32596, 32600, 32604, 32609, 32613, 32617, - 32621, 32625, 32629, 32633, 32637, 32641, 32644, 32648, - 32652, 32655, 32659, 32662, 32665, 32669, 32672, 32675, - 32679, 32682, 32685, 32688, 32691, 32694, 32696, 32699, - 32702, 32705, 32707, 32710, 32712, 32715, 32717, 32719, - 32722, 32724, 32726, 32728, 32730, 32732, 32734, 32736, - 32738, 32740, 32741, 32743, 32744, 32746, 32748, 32749, - 32750, 32752, 32753, 32754, 32755, 32756, 32757, 32758, - 32759, 32760, 32761, 32762, 32762, 32763, 32764, 32764, - 32765, 32765, 32765, 32766, 32766, 32766, 32766, 32766 -}; - -const Word16 cos_scale_tbl_1200[1200] = { /* Q15 */ - 0, 42, 85, 128, 171, 214, 257, 300, - 343, 386, 428, 471, 514, 557, 600, 643, - 686, 729, 771, 814, 857, 900, 943, 986, - 1029, 1072, 1114, 1157, 1200, 1243, 1286, 1329, - 1372, 1414, 1457, 1500, 1543, 1586, 1629, 1672, - 1714, 1757, 1800, 1843, 1886, 1929, 1971, 2014, - 2057, 2100, 2143, 2185, 2228, 2271, 2314, 2357, - 2399, 2442, 2485, 2528, 2570, 2613, 2656, 2699, - 2741, 2784, 2827, 2870, 2912, 2955, 2998, 3040, - 3083, 3126, 3169, 3211, 3254, 3297, 3339, 3382, - 3425, 3467, 3510, 3553, 3595, 3638, 3680, 3723, - 3766, 3808, 3851, 3893, 3936, 3979, 4021, 4064, - 4106, 4149, 4191, 4234, 4276, 4319, 4361, 4404, - 4446, 4489, 4531, 4574, 4616, 4659, 4701, 4744, - 4786, 4829, 4871, 4913, 4956, 4998, 5041, 5083, - 5125, 5168, 5210, 5252, 5295, 5337, 5379, 5422, - 5464, 5506, 5549, 5591, 5633, 5675, 5718, 5760, - 5802, 5844, 5886, 5929, 5971, 6013, 6055, 6097, - 6139, 6182, 6224, 6266, 6308, 6350, 6392, 6434, - 6476, 6518, 6560, 6602, 6644, 6686, 6728, 6770, - 6812, 6854, 6896, 6938, 6980, 7022, 7064, 7106, - 7147, 7189, 7231, 7273, 7315, 7357, 7398, 7440, - 7482, 7524, 7565, 7607, 7649, 7691, 7732, 7774, - 7816, 7857, 7899, 7940, 7982, 8024, 8065, 8107, - 8148, 8190, 8231, 8273, 8314, 8356, 8397, 8439, - 8480, 8522, 8563, 8604, 8646, 8687, 8729, 8770, - 8811, 8853, 8894, 8935, 8976, 9018, 9059, 9100, - 9141, 9182, 9224, 9265, 9306, 9347, 9388, 9429, - 9470, 9511, 9552, 9593, 9634, 9675, 9716, 9757, - 9798, 9839, 9880, 9921, 9962, 10003, 10043, 10084, - 10125, 10166, 10207, 10247, 10288, 10329, 10370, 10410, - 10451, 10491, 10532, 10573, 10613, 10654, 10694, 10735, - 10775, 10816, 10856, 10897, 10937, 10978, 11018, 11059, - 11099, 11139, 11180, 11220, 11260, 11300, 11341, 11381, - 11421, 11461, 11502, 11542, 11582, 11622, 11662, 11702, - 11742, 11782, 11822, 11862, 11902, 11942, 11982, 12022, - 12062, 12102, 12142, 12181, 12221, 12261, 12301, 12340, - 12380, 12420, 12460, 12499, 12539, 12579, 12618, 12658, - 12697, 12737, 12776, 12816, 12855, 12895, 12934, 12973, - 13013, 13052, 13092, 13131, 13170, 13209, 13249, 13288, - 13327, 13366, 13405, 13444, 13484, 13523, 13562, 13601, - 13640, 13679, 13718, 13757, 13796, 13834, 13873, 13912, - 13951, 13990, 14029, 14067, 14106, 14145, 14183, 14222, - 14261, 14299, 14338, 14376, 14415, 14453, 14492, 14530, - 14569, 14607, 14646, 14684, 14722, 14761, 14799, 14837, - 14875, 14914, 14952, 14990, 15028, 15066, 15104, 15142, - 15180, 15218, 15256, 15294, 15332, 15370, 15408, 15446, - 15484, 15521, 15559, 15597, 15635, 15672, 15710, 15748, - 15785, 15823, 15860, 15898, 15935, 15973, 16010, 16048, - 16085, 16122, 16160, 16197, 16234, 16271, 16309, 16346, - 16383, 16420, 16457, 16494, 16531, 16568, 16605, 16642, - 16679, 16716, 16753, 16790, 16827, 16863, 16900, 16937, - 16974, 17010, 17047, 17084, 17120, 17157, 17193, 17230, - 17266, 17303, 17339, 17375, 17412, 17448, 17484, 17521, - 17557, 17593, 17629, 17665, 17702, 17738, 17774, 17810, - 17846, 17882, 17918, 17953, 17989, 18025, 18061, 18097, - 18132, 18168, 18204, 18240, 18275, 18311, 18346, 18382, - 18417, 18453, 18488, 18524, 18559, 18594, 18630, 18665, - 18700, 18735, 18770, 18806, 18841, 18876, 18911, 18946, - 18981, 19016, 19051, 19086, 19120, 19155, 19190, 19225, - 19259, 19294, 19329, 19363, 19398, 19433, 19467, 19502, - 19536, 19570, 19605, 19639, 19673, 19708, 19742, 19776, - 19810, 19845, 19879, 19913, 19947, 19981, 20015, 20049, - 20083, 20117, 20150, 20184, 20218, 20252, 20285, 20319, - 20353, 20386, 20420, 20453, 20487, 20520, 20554, 20587, - 20620, 20654, 20687, 20720, 20753, 20787, 20820, 20853, - 20886, 20919, 20952, 20985, 21018, 21051, 21084, 21116, - 21149, 21182, 21215, 21247, 21280, 21313, 21345, 21378, - 21410, 21443, 21475, 21507, 21540, 21572, 21604, 21637, - 21669, 21701, 21733, 21765, 21797, 21829, 21861, 21893, - 21925, 21957, 21989, 22020, 22052, 22084, 22115, 22147, - 22179, 22210, 22242, 22273, 22305, 22336, 22367, 22399, - 22430, 22461, 22493, 22524, 22555, 22586, 22617, 22648, - 22679, 22710, 22741, 22772, 22802, 22833, 22864, 22895, - 22925, 22956, 22987, 23017, 23048, 23078, 23109, 23139, - 23169, 23200, 23230, 23260, 23290, 23320, 23351, 23381, - 23411, 23441, 23471, 23500, 23530, 23560, 23590, 23620, - 23649, 23679, 23709, 23738, 23768, 23797, 23827, 23856, - 23886, 23915, 23944, 23974, 24003, 24032, 24061, 24090, - 24119, 24148, 24177, 24206, 24235, 24264, 24293, 24321, - 24350, 24379, 24407, 24436, 24465, 24493, 24522, 24550, - 24578, 24607, 24635, 24663, 24692, 24720, 24748, 24776, - 24804, 24832, 24860, 24888, 24916, 24944, 24971, 24999, - 25027, 25054, 25082, 25110, 25137, 25165, 25192, 25220, - 25247, 25274, 25302, 25329, 25356, 25383, 25410, 25437, - 25464, 25491, 25518, 25545, 25572, 25599, 25625, 25652, - 25679, 25705, 25732, 25759, 25785, 25811, 25838, 25864, - 25891, 25917, 25943, 25969, 25995, 26021, 26047, 26073, - 26099, 26125, 26151, 26177, 26203, 26228, 26254, 26280, - 26305, 26331, 26356, 26382, 26407, 26433, 26458, 26483, - 26509, 26534, 26559, 26584, 26609, 26634, 26659, 26684, - 26709, 26734, 26758, 26783, 26808, 26832, 26857, 26882, - 26906, 26931, 26955, 26979, 27004, 27028, 27052, 27076, - 27100, 27125, 27149, 27173, 27197, 27220, 27244, 27268, - 27292, 27316, 27339, 27363, 27386, 27410, 27433, 27457, - 27480, 27504, 27527, 27550, 27573, 27596, 27620, 27643, - 27666, 27689, 27711, 27734, 27757, 27780, 27803, 27825, - 27848, 27871, 27893, 27916, 27938, 27960, 27983, 28005, - 28027, 28049, 28072, 28094, 28116, 28138, 28160, 28182, - 28203, 28225, 28247, 28269, 28290, 28312, 28334, 28355, - 28377, 28398, 28419, 28441, 28462, 28483, 28504, 28525, - 28547, 28568, 28589, 28610, 28630, 28651, 28672, 28693, - 28713, 28734, 28755, 28775, 28796, 28816, 28837, 28857, - 28877, 28897, 28918, 28938, 28958, 28978, 28998, 29018, - 29038, 29058, 29077, 29097, 29117, 29136, 29156, 29176, - 29195, 29215, 29234, 29253, 29273, 29292, 29311, 29330, - 29349, 29368, 29387, 29406, 29425, 29444, 29463, 29482, - 29500, 29519, 29537, 29556, 29575, 29593, 29611, 29630, - 29648, 29666, 29684, 29703, 29721, 29739, 29757, 29775, - 29792, 29810, 29828, 29846, 29863, 29881, 29899, 29916, - 29934, 29951, 29968, 29986, 30003, 30020, 30037, 30055, - 30072, 30089, 30106, 30122, 30139, 30156, 30173, 30190, - 30206, 30223, 30239, 30256, 30272, 30289, 30305, 30321, - 30338, 30354, 30370, 30386, 30402, 30418, 30434, 30450, - 30465, 30481, 30497, 30513, 30528, 30544, 30559, 30575, - 30590, 30605, 30621, 30636, 30651, 30666, 30681, 30696, - 30711, 30726, 30741, 30756, 30771, 30786, 30800, 30815, - 30829, 30844, 30858, 30873, 30887, 30901, 30916, 30930, - 30944, 30958, 30972, 30986, 31000, 31014, 31028, 31041, - 31055, 31069, 31082, 31096, 31109, 31123, 31136, 31149, - 31163, 31176, 31189, 31202, 31215, 31228, 31241, 31254, - 31267, 31280, 31293, 31305, 31318, 31331, 31343, 31356, - 31368, 31380, 31393, 31405, 31417, 31429, 31441, 31453, - 31465, 31477, 31489, 31501, 31513, 31525, 31536, 31548, - 31559, 31571, 31582, 31594, 31605, 31616, 31628, 31639, - 31650, 31661, 31672, 31683, 31694, 31705, 31716, 31726, - 31737, 31748, 31758, 31769, 31779, 31790, 31800, 31810, - 31821, 31831, 31841, 31851, 31861, 31871, 31881, 31891, - 31901, 31911, 31920, 31930, 31940, 31949, 31959, 31968, - 31977, 31987, 31996, 32005, 32014, 32023, 32033, 32042, - 32050, 32059, 32068, 32077, 32086, 32094, 32103, 32112, - 32120, 32128, 32137, 32145, 32154, 32162, 32170, 32178, - 32186, 32194, 32202, 32210, 32218, 32226, 32233, 32241, - 32249, 32256, 32264, 32271, 32279, 32286, 32293, 32300, - 32308, 32315, 32322, 32329, 32336, 32343, 32350, 32356, - 32363, 32370, 32376, 32383, 32389, 32396, 32402, 32409, - 32415, 32421, 32427, 32434, 32440, 32446, 32452, 32457, - 32463, 32469, 32475, 32481, 32486, 32492, 32497, 32503, - 32508, 32513, 32519, 32524, 32529, 32534, 32539, 32544, - 32549, 32554, 32559, 32564, 32569, 32573, 32578, 32582, - 32587, 32591, 32596, 32600, 32604, 32609, 32613, 32617, - 32621, 32625, 32629, 32633, 32637, 32641, 32644, 32648, - 32652, 32655, 32659, 32662, 32665, 32669, 32672, 32675, - 32679, 32682, 32685, 32688, 32691, 32694, 32696, 32699, - 32702, 32705, 32707, 32710, 32712, 32715, 32717, 32719, - 32722, 32724, 32726, 32728, 32730, 32732, 32734, 32736, - 32738, 32740, 32741, 32743, 32744, 32746, 32748, 32749, - 32750, 32752, 32753, 32754, 32755, 32756, 32757, 32758, - 32759, 32760, 32761, 32762, 32762, 32763, 32764, 32764, - 32765, 32765, 32765, 32766, 32766, 32766, 32766, 32766 -}; - -const Word16 sin_scale_tbl_800[800] = { /* Q15 */ - 0, 64, 128, 193, 257, 321, 386, 450, - 514, 579, 643, 707, 771, 836, 900, 964, - 1029, 1093, 1157, 1222, 1286, 1350, 1414, 1479, - 1543, 1607, 1672, 1736, 1800, 1864, 1929, 1993, - 2057, 2121, 2185, 2250, 2314, 2378, 2442, 2506, - 2570, 2635, 2699, 2763, 2827, 2891, 2955, 3019, - 3083, 3147, 3211, 3275, 3339, 3403, 3467, 3531, - 3595, 3659, 3723, 3787, 3851, 3915, 3979, 4042, - 4106, 4170, 4234, 4298, 4361, 4425, 4489, 4553, - 4616, 4680, 4744, 4807, 4871, 4935, 4998, 5062, - 5125, 5189, 5252, 5316, 5379, 5443, 5506, 5570, - 5633, 5696, 5760, 5823, 5886, 5950, 6013, 6076, - 6139, 6203, 6266, 6329, 6392, 6455, 6518, 6581, - 6644, 6707, 6770, 6833, 6896, 6959, 7022, 7085, - 7147, 7210, 7273, 7336, 7398, 7461, 7524, 7586, - 7649, 7711, 7774, 7836, 7899, 7961, 8024, 8086, - 8148, 8211, 8273, 8335, 8397, 8460, 8522, 8584, - 8646, 8708, 8770, 8832, 8894, 8956, 9018, 9079, - 9141, 9203, 9265, 9326, 9388, 9450, 9511, 9573, - 9634, 9696, 9757, 9819, 9880, 9941, 10003, 10064, - 10125, 10186, 10247, 10308, 10370, 10431, 10491, 10552, - 10613, 10674, 10735, 10796, 10856, 10917, 10978, 11038, - 11099, 11159, 11220, 11280, 11341, 11401, 11461, 11522, - 11582, 11642, 11702, 11762, 11822, 11882, 11942, 12002, - 12062, 12122, 12181, 12241, 12301, 12360, 12420, 12479, - 12539, 12598, 12658, 12717, 12776, 12835, 12895, 12954, - 13013, 13072, 13131, 13190, 13249, 13307, 13366, 13425, - 13484, 13542, 13601, 13659, 13718, 13776, 13834, 13893, - 13951, 14009, 14067, 14125, 14183, 14241, 14299, 14357, - 14415, 14473, 14530, 14588, 14646, 14703, 14761, 14818, - 14875, 14933, 14990, 15047, 15104, 15161, 15218, 15275, - 15332, 15389, 15446, 15502, 15559, 15616, 15672, 15729, - 15785, 15841, 15898, 15954, 16010, 16066, 16122, 16178, - 16234, 16290, 16346, 16402, 16457, 16513, 16568, 16624, - 16679, 16735, 16790, 16845, 16900, 16955, 17010, 17065, - 17120, 17175, 17230, 17284, 17339, 17394, 17448, 17503, - 17557, 17611, 17665, 17720, 17774, 17828, 17882, 17936, - 17989, 18043, 18097, 18150, 18204, 18257, 18311, 18364, - 18417, 18470, 18524, 18577, 18630, 18682, 18735, 18788, - 18841, 18893, 18946, 18998, 19051, 19103, 19155, 19207, - 19259, 19311, 19363, 19415, 19467, 19519, 19570, 19622, - 19673, 19725, 19776, 19827, 19879, 19930, 19981, 20032, - 20083, 20133, 20184, 20235, 20285, 20336, 20386, 20437, - 20487, 20537, 20587, 20637, 20687, 20737, 20787, 20836, - 20886, 20936, 20985, 21034, 21084, 21133, 21182, 21231, - 21280, 21329, 21378, 21426, 21475, 21524, 21572, 21620, - 21669, 21717, 21765, 21813, 21861, 21909, 21957, 22004, - 22052, 22100, 22147, 22194, 22242, 22289, 22336, 22383, - 22430, 22477, 22524, 22570, 22617, 22663, 22710, 22756, - 22802, 22849, 22895, 22941, 22987, 23032, 23078, 23124, - 23169, 23215, 23260, 23305, 23351, 23396, 23441, 23486, - 23530, 23575, 23620, 23664, 23709, 23753, 23797, 23842, - 23886, 23930, 23974, 24017, 24061, 24105, 24148, 24192, - 24235, 24278, 24321, 24364, 24407, 24450, 24493, 24536, - 24578, 24621, 24663, 24706, 24748, 24790, 24832, 24874, - 24916, 24957, 24999, 25041, 25082, 25123, 25165, 25206, - 25247, 25288, 25329, 25370, 25410, 25451, 25491, 25532, - 25572, 25612, 25652, 25692, 25732, 25772, 25811, 25851, - 25891, 25930, 25969, 26008, 26047, 26086, 26125, 26164, - 26203, 26241, 26280, 26318, 26356, 26395, 26433, 26471, - 26509, 26546, 26584, 26622, 26659, 26696, 26734, 26771, - 26808, 26845, 26882, 26918, 26955, 26991, 27028, 27064, - 27100, 27137, 27173, 27208, 27244, 27280, 27316, 27351, - 27386, 27422, 27457, 27492, 27527, 27562, 27596, 27631, - 27666, 27700, 27734, 27769, 27803, 27837, 27871, 27904, - 27938, 27972, 28005, 28038, 28072, 28105, 28138, 28171, - 28203, 28236, 28269, 28301, 28334, 28366, 28398, 28430, - 28462, 28494, 28525, 28557, 28589, 28620, 28651, 28682, - 28713, 28744, 28775, 28806, 28837, 28867, 28897, 28928, - 28958, 28988, 29018, 29048, 29077, 29107, 29136, 29166, - 29195, 29224, 29253, 29282, 29311, 29340, 29368, 29397, - 29425, 29453, 29482, 29510, 29537, 29565, 29593, 29621, - 29648, 29675, 29703, 29730, 29757, 29784, 29810, 29837, - 29863, 29890, 29916, 29942, 29968, 29994, 30020, 30046, - 30072, 30097, 30122, 30148, 30173, 30198, 30223, 30248, - 30272, 30297, 30321, 30346, 30370, 30394, 30418, 30442, - 30465, 30489, 30513, 30536, 30559, 30582, 30605, 30628, - 30651, 30674, 30696, 30719, 30741, 30763, 30786, 30807, - 30829, 30851, 30873, 30894, 30916, 30937, 30958, 30979, - 31000, 31021, 31041, 31062, 31082, 31103, 31123, 31143, - 31163, 31183, 31202, 31222, 31241, 31261, 31280, 31299, - 31318, 31337, 31356, 31374, 31393, 31411, 31429, 31447, - 31465, 31483, 31501, 31519, 31536, 31554, 31571, 31588, - 31605, 31622, 31639, 31656, 31672, 31689, 31705, 31721, - 31737, 31753, 31769, 31785, 31800, 31816, 31831, 31846, - 31861, 31876, 31891, 31906, 31920, 31935, 31949, 31963, - 31977, 31991, 32005, 32019, 32033, 32046, 32059, 32073, - 32086, 32099, 32112, 32124, 32137, 32149, 32162, 32174, - 32186, 32198, 32210, 32222, 32233, 32245, 32256, 32267, - 32279, 32290, 32300, 32311, 32322, 32332, 32343, 32353, - 32363, 32373, 32383, 32393, 32402, 32412, 32421, 32430, - 32440, 32449, 32457, 32466, 32475, 32483, 32492, 32500, - 32508, 32516, 32524, 32532, 32539, 32547, 32554, 32561, - 32569, 32576, 32582, 32589, 32596, 32602, 32609, 32615, - 32621, 32627, 32633, 32639, 32644, 32650, 32655, 32660, - 32665, 32670, 32675, 32680, 32685, 32689, 32694, 32698, - 32702, 32706, 32710, 32713, 32717, 32720, 32724, 32727, - 32730, 32733, 32736, 32739, 32741, 32744, 32746, 32748, - 32750, 32752, 32754, 32756, 32757, 32759, 32760, 32761, - 32762, 32763, 32764, 32765, 32765, 32766, 32766, 32766 -}; - -const Word16 cos_scale_tbl_800[800] = { /* Q15 */ - 0, 64, 128, 193, 257, 321, 386, 450, - 514, 579, 643, 707, 771, 836, 900, 964, - 1029, 1093, 1157, 1222, 1286, 1350, 1414, 1479, - 1543, 1607, 1672, 1736, 1800, 1864, 1929, 1993, - 2057, 2121, 2185, 2250, 2314, 2378, 2442, 2506, - 2570, 2635, 2699, 2763, 2827, 2891, 2955, 3019, - 3083, 3147, 3211, 3275, 3339, 3403, 3467, 3531, - 3595, 3659, 3723, 3787, 3851, 3915, 3979, 4042, - 4106, 4170, 4234, 4298, 4361, 4425, 4489, 4553, - 4616, 4680, 4744, 4807, 4871, 4935, 4998, 5062, - 5125, 5189, 5252, 5316, 5379, 5443, 5506, 5570, - 5633, 5696, 5760, 5823, 5886, 5950, 6013, 6076, - 6139, 6203, 6266, 6329, 6392, 6455, 6518, 6581, - 6644, 6707, 6770, 6833, 6896, 6959, 7022, 7085, - 7147, 7210, 7273, 7336, 7398, 7461, 7524, 7586, - 7649, 7711, 7774, 7836, 7899, 7961, 8024, 8086, - 8148, 8211, 8273, 8335, 8397, 8460, 8522, 8584, - 8646, 8708, 8770, 8832, 8894, 8956, 9018, 9079, - 9141, 9203, 9265, 9326, 9388, 9450, 9511, 9573, - 9634, 9696, 9757, 9819, 9880, 9941, 10003, 10064, - 10125, 10186, 10247, 10308, 10370, 10431, 10491, 10552, - 10613, 10674, 10735, 10796, 10856, 10917, 10978, 11038, - 11099, 11159, 11220, 11280, 11341, 11401, 11461, 11522, - 11582, 11642, 11702, 11762, 11822, 11882, 11942, 12002, - 12062, 12122, 12181, 12241, 12301, 12360, 12420, 12479, - 12539, 12598, 12658, 12717, 12776, 12835, 12895, 12954, - 13013, 13072, 13131, 13190, 13249, 13307, 13366, 13425, - 13484, 13542, 13601, 13659, 13718, 13776, 13834, 13893, - 13951, 14009, 14067, 14125, 14183, 14241, 14299, 14357, - 14415, 14473, 14530, 14588, 14646, 14703, 14761, 14818, - 14875, 14933, 14990, 15047, 15104, 15161, 15218, 15275, - 15332, 15389, 15446, 15502, 15559, 15616, 15672, 15729, - 15785, 15841, 15898, 15954, 16010, 16066, 16122, 16178, - 16234, 16290, 16346, 16402, 16457, 16513, 16568, 16624, - 16679, 16735, 16790, 16845, 16900, 16955, 17010, 17065, - 17120, 17175, 17230, 17284, 17339, 17394, 17448, 17503, - 17557, 17611, 17665, 17720, 17774, 17828, 17882, 17936, - 17989, 18043, 18097, 18150, 18204, 18257, 18311, 18364, - 18417, 18470, 18524, 18577, 18630, 18682, 18735, 18788, - 18841, 18893, 18946, 18998, 19051, 19103, 19155, 19207, - 19259, 19311, 19363, 19415, 19467, 19519, 19570, 19622, - 19673, 19725, 19776, 19827, 19879, 19930, 19981, 20032, - 20083, 20133, 20184, 20235, 20285, 20336, 20386, 20437, - 20487, 20537, 20587, 20637, 20687, 20737, 20787, 20836, - 20886, 20936, 20985, 21034, 21084, 21133, 21182, 21231, - 21280, 21329, 21378, 21426, 21475, 21524, 21572, 21620, - 21669, 21717, 21765, 21813, 21861, 21909, 21957, 22004, - 22052, 22100, 22147, 22194, 22242, 22289, 22336, 22383, - 22430, 22477, 22524, 22570, 22617, 22663, 22710, 22756, - 22802, 22849, 22895, 22941, 22987, 23032, 23078, 23124, - 23169, 23215, 23260, 23305, 23351, 23396, 23441, 23486, - 23530, 23575, 23620, 23664, 23709, 23753, 23797, 23842, - 23886, 23930, 23974, 24017, 24061, 24105, 24148, 24192, - 24235, 24278, 24321, 24364, 24407, 24450, 24493, 24536, - 24578, 24621, 24663, 24706, 24748, 24790, 24832, 24874, - 24916, 24957, 24999, 25041, 25082, 25123, 25165, 25206, - 25247, 25288, 25329, 25370, 25410, 25451, 25491, 25532, - 25572, 25612, 25652, 25692, 25732, 25772, 25811, 25851, - 25891, 25930, 25969, 26008, 26047, 26086, 26125, 26164, - 26203, 26241, 26280, 26318, 26356, 26395, 26433, 26471, - 26509, 26546, 26584, 26622, 26659, 26696, 26734, 26771, - 26808, 26845, 26882, 26918, 26955, 26991, 27028, 27064, - 27100, 27137, 27173, 27208, 27244, 27280, 27316, 27351, - 27386, 27422, 27457, 27492, 27527, 27562, 27596, 27631, - 27666, 27700, 27734, 27769, 27803, 27837, 27871, 27904, - 27938, 27972, 28005, 28038, 28072, 28105, 28138, 28171, - 28203, 28236, 28269, 28301, 28334, 28366, 28398, 28430, - 28462, 28494, 28525, 28557, 28589, 28620, 28651, 28682, - 28713, 28744, 28775, 28806, 28837, 28867, 28897, 28928, - 28958, 28988, 29018, 29048, 29077, 29107, 29136, 29166, - 29195, 29224, 29253, 29282, 29311, 29340, 29368, 29397, - 29425, 29453, 29482, 29510, 29537, 29565, 29593, 29621, - 29648, 29675, 29703, 29730, 29757, 29784, 29810, 29837, - 29863, 29890, 29916, 29942, 29968, 29994, 30020, 30046, - 30072, 30097, 30122, 30148, 30173, 30198, 30223, 30248, - 30272, 30297, 30321, 30346, 30370, 30394, 30418, 30442, - 30465, 30489, 30513, 30536, 30559, 30582, 30605, 30628, - 30651, 30674, 30696, 30719, 30741, 30763, 30786, 30807, - 30829, 30851, 30873, 30894, 30916, 30937, 30958, 30979, - 31000, 31021, 31041, 31062, 31082, 31103, 31123, 31143, - 31163, 31183, 31202, 31222, 31241, 31261, 31280, 31299, - 31318, 31337, 31356, 31374, 31393, 31411, 31429, 31447, - 31465, 31483, 31501, 31519, 31536, 31554, 31571, 31588, - 31605, 31622, 31639, 31656, 31672, 31689, 31705, 31721, - 31737, 31753, 31769, 31785, 31800, 31816, 31831, 31846, - 31861, 31876, 31891, 31906, 31920, 31935, 31949, 31963, - 31977, 31991, 32005, 32019, 32033, 32046, 32059, 32073, - 32086, 32099, 32112, 32124, 32137, 32149, 32162, 32174, - 32186, 32198, 32210, 32222, 32233, 32245, 32256, 32267, - 32279, 32290, 32300, 32311, 32322, 32332, 32343, 32353, - 32363, 32373, 32383, 32393, 32402, 32412, 32421, 32430, - 32440, 32449, 32457, 32466, 32475, 32483, 32492, 32500, - 32508, 32516, 32524, 32532, 32539, 32547, 32554, 32561, - 32569, 32576, 32582, 32589, 32596, 32602, 32609, 32615, - 32621, 32627, 32633, 32639, 32644, 32650, 32655, 32660, - 32665, 32670, 32675, 32680, 32685, 32689, 32694, 32698, - 32702, 32706, 32710, 32713, 32717, 32720, 32724, 32727, - 32730, 32733, 32736, 32739, 32741, 32744, 32746, 32748, - 32750, 32752, 32754, 32756, 32757, 32759, 32760, 32761, - 32762, 32763, 32764, 32765, 32765, 32766, 32766, 32766 -}; -#endif const Word16 scales_ivas_fx[][MAX_NO_SCALES * 2] = /* 2 subvectors Q11*/ { { diff --git a/lib_com/scale_mem_fx.c b/lib_com/scale_mem_fx.c index 4f095703a..1bb6fbe3c 100644 --- a/lib_com/scale_mem_fx.c +++ b/lib_com/scale_mem_fx.c @@ -337,7 +337,6 @@ void scale_sig32_r( return; } -#ifdef OPTIMIZE_FFT_STACK void scale_sig32_cmplx( cmplx x[], /* i/o: signal to scale Qx */ const Word16 lg, /* i : size of x[] Q0 */ @@ -365,7 +364,6 @@ void scale_sig32_cmplx( return; } -#endif /*-------------------------------------------------------------------* diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c index c9eb8c9db..7b2c8bfcd 100644 --- a/lib_com/tools_fx.c +++ b/lib_com/tools_fx.c @@ -5465,7 +5465,6 @@ Word16 L_norm_arr( return q; } -#ifdef OPTIMIZE_FFT_STACK Word16 L_norm_arr_cmplx( const cmplx *arr, Word16 size ) @@ -5492,7 +5491,6 @@ Word16 L_norm_arr_cmplx( return q; } -#endif #ifdef NONBE_FIX_ISSUE_2206 Word16 norm_arr( diff --git a/lib_dec/FEC_HQ_phase_ecu_fx.c b/lib_dec/FEC_HQ_phase_ecu_fx.c index 83b560251..1a8361ecf 100644 --- a/lib_dec/FEC_HQ_phase_ecu_fx.c +++ b/lib_dec/FEC_HQ_phase_ecu_fx.c @@ -2556,11 +2556,7 @@ static void fec_ecu_dft_fx( *exp = s_min( *exp, 15 ); } -#ifdef OPTIMIZE_FFT_STACK DoRTFTn_fx( Tfr32, Tfi32, NULL, *Nfft ); -#else - DoRTFTn_fx( Tfr32, Tfi32, *Nfft ); -#endif N_LP = shr( *Nfft, 1 ); L_tmp = L_deposit_l( 0 ); diff --git a/lib_enc/ivas_mdct_core_enc_fx.c b/lib_enc/ivas_mdct_core_enc_fx.c index c3b32f7e2..dbc1d327b 100644 --- a/lib_enc/ivas_mdct_core_enc_fx.c +++ b/lib_enc/ivas_mdct_core_enc_fx.c @@ -1109,7 +1109,6 @@ void enc_prm_igf_mdct( return; } -#ifdef OPTIMIZE_FFT_STACK /*-------------------------------------------------------------------* * compute_power_spec() * @@ -1156,7 +1155,6 @@ static void compute_power_spec( return; } -#endif /*-------------------------------------------------------------------* * ivas_mdct_core_whitening_enc() @@ -1193,9 +1191,6 @@ void ivas_mdct_core_whitening_enc_fx( Word32 temp_buffer[15 * L_FRAME48k / 8]; Word32 *windowedSignal_fx[CPE_CHANNELS]; Word32 *powerSpec_fx = orig_spectrum_long[0]; -#ifndef OPTIMIZE_FFT_STACK - Word64 powerSpec_fx64[N_MAX]; -#endif Word16 nrg_fx; /* Q15 */ Encoder_State *st, **sts; Word32 scf_fx[CPE_CHANNELS][NB_DIV][M]; @@ -1963,36 +1958,7 @@ void ivas_mdct_core_whitening_enc_fx( move16(); FOR( n = 0; n < nSubframes; n++ ) { -#ifdef OPTIMIZE_FFT_STACK compute_power_spec( st->hTcxEnc, mdst_spectrum_fx[ch], powerSpec_fx, &q_pow, n, L_subframeTCX ); -#else - IF( st->hTcxEnc->fUseTns[n] ) - { - FOR( i = 0; i < L_subframeTCX; i++ ) - { - powerSpec_fx64[i] = W_mult_32_32( st->hTcxEnc->spectrum_fx[n][i], st->hTcxEnc->spectrum_fx[n][i] ); - move64(); - } - q_pow = W_norm_arr( powerSpec_fx64, L_subframeTCX ); - } - ELSE - { - FOR( i = 0; i < L_subframeTCX; i++ ) - { - powerSpec_fx64[i] = W_mac_32_32( W_mult_32_32( mdst_spectrum_fx[ch][n][i], mdst_spectrum_fx[ch][n][i] ), st->hTcxEnc->spectrum_fx[n][i], st->hTcxEnc->spectrum_fx[n][i] ); - move64(); - } - q_pow = W_norm_arr( powerSpec_fx64, L_subframeTCX ); - } - - FOR( i = 0; i < L_subframeTCX; i++ ) - { - powerSpec_fx64[i] = W_shl( powerSpec_fx64[i], q_pow ); - move64(); - powerSpec_fx[i] = W_extract_h( powerSpec_fx64[i] ); - move32(); - } -#endif IF( mct_on ) { FOR( i = 0; i < L_subframeTCX; i++ ) -- GitLab From 63bd23875890846721de3b4912380d5a91a0fbae Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 13 Apr 2026 16:48:47 +0200 Subject: [PATCH 09/22] [cleanup] accept HARMONIZE_DCT --- lib_com/edct_fx.c | 86 ------- lib_com/fft_fx.c | 402 ------------------------------ lib_com/gs_inact_switching_fx.c | 12 - lib_com/ivas_mdft_imdft_fx.c | 39 --- lib_com/options.h | 1 - lib_com/prot_fx.h | 32 --- lib_com/tcx_mdct_fx.c | 8 - lib_com/trans_direct_fx.c | 16 -- lib_com/trans_inv_fx.c | 4 - lib_dec/FEC_fx.c | 8 - lib_dec/LD_music_post_filter_fx.c | 8 - lib_dec/core_switching_dec_fx.c | 4 - lib_dec/dec_tcx_fx.c | 12 - lib_dec/gs_dec_amr_wb_fx.c | 8 - lib_dec/gs_dec_fx.c | 9 - lib_dec/hf_synth_fx.c | 8 - lib_dec/ivas_td_low_rate_dec_fx.c | 6 - lib_enc/bw_detect_fx.c | 4 - lib_enc/cod_tcx_fx.c | 12 - lib_enc/ext_sig_ana_fx.c | 8 - lib_enc/gs_enc_fx.c | 10 - lib_enc/ivas_td_low_rate_enc_fx.c | 10 - 22 files changed, 707 deletions(-) diff --git a/lib_com/edct_fx.c b/lib_com/edct_fx.c index d63117cb0..edd361a9b 100644 --- a/lib_com/edct_fx.c +++ b/lib_com/edct_fx.c @@ -177,12 +177,8 @@ void edct_fx( const Word32 *x, /* i : input signal Qq */ Word32 *y, /* o : output transform Qq */ Word16 length, /* i : length Q0*/ -#ifdef HARMONIZE_DCT Word16 *q, /* i : Q value of input signal */ const Word16 element_mode /* i : element mode */ -#else - Word16 *q /* i : Q value of input signal */ -#endif ) { Word16 i; @@ -208,17 +204,14 @@ void edct_fx( move32(); } -#ifdef HARMONIZE_DCT IF( element_mode == EVS_MONO ) { -#endif *q = sub( 15, *q ); move16(); BASOP_cfft( spec, len1, q, y ); tmp = div_s( 1, length ); /*Q15 */ tmp = round_fx( L_shl( L_mult( tmp, 19302 /*0.75f * EVS_PI in Q13*/ ), 2 ) ); /*Q15 */ -#ifdef HARMONIZE_DCT } ELSE { @@ -234,7 +227,6 @@ void edct_fx( tmp = div_s( 4, length ); /*Q17 */ tmp = round_fx( L_mult( tmp, 19302 /*0.75f * EVS_PI in Q13*/ ) ); /*Q15 */ } -#endif FOR( i = 0; i < len1; i++ ) { @@ -248,81 +240,15 @@ void edct_fx( *q = sub( 15 + 2, *q ); move16(); -#ifdef HARMONIZE_DCT IF( element_mode != EVS_MONO ) { *q = add( *q, Q16 ); move16(); } -#endif return; } -#ifndef HARMONIZE_DCT -void edct_ivas_fx( - const Word32 *x, /* i : input signal Qq */ - Word32 *y, /* o : output transform Qq */ - Word16 length, /* i : length Q0*/ - Word16 *q /* i : Q value of input signal */ -) -{ - Word16 i; - const Word16 *edct_table; /*Q16 */ - Word32 re[L_FRAME_PLUS / 2]; - Word32 im[L_FRAME_PLUS / 2]; - Word32 L_tmp; - Word16 tmp; - Word16 len1; - - edct_table = get_edct_table( length, q ); /*q*/ - len1 = shr( length, 1 ); /*Q0*/ - /* Twiddling and Pre-rotate */ - FOR( i = 0; i < len1; i++ ) - { - L_tmp = Mult_32_16( x[2 * i], edct_table[i] ); /*Q(q+1) */ - re[i] = Madd_32_16( L_tmp, x[( length - ( 1 + ( i * 2 ) ) )], edct_table[( len1 - ( 1 + i ) )] ); /*Q(q+1) */ - move32(); - - L_tmp = Mult_32_16( x[( length - ( 1 + ( i * 2 ) ) )], edct_table[i] ); /*Q(q+1) */ - im[i] = Msub_32_16( L_tmp, x[( i * 2 )], edct_table[( len1 - ( 1 + i ) )] ); /*Q(q+1) */ - move32(); - } - - *q = sub( 31, *q ); - move16(); - tmp = sub( s_min( getScaleFactor32( re, len1 ), getScaleFactor32( im, len1 ) ), find_guarded_bits_fx( len1 ) ); - scale_sig32( re, len1, tmp ); - scale_sig32( im, len1, tmp ); - - fft_fx( re, im, len1, 1 ); - *q = sub( *q, tmp ); - move16(); - - tmp = div_s( 4, length ); /*Q17 */ - tmp = round_fx( L_mult( tmp, 19302 /*0.75f * EVS_PI in Q13*/ ) ); /*Q15 */ - FOR( i = 0; i < len1; i++ ) - { - L_tmp = Msub_32_16( re[i], im[i], tmp ); - im[i] = Madd_32_16( im[i], re[i], tmp ); /*Q(q+1) */ - re[i] = L_tmp; /*Q(q+1) */ - move32(); - move32(); - } - FOR( i = 0; i < len1; i++ ) - { - y[2 * i] = L_add( Mult_32_16( re[i], edct_table[i] ), Mult_32_16( im[i], edct_table[( len1 - ( 1 + i ) )] ) ); /*Q(q+2)*/ - move32(); - y[( length - ( 1 + ( i * 2 ) ) )] = L_sub( Mult_32_16( re[i], edct_table[( len1 - ( 1 + i ) )] ), Mult_32_16( im[i], edct_table[i] ) ); /*Q(q+2)*/ - move32(); - } /*Q(q-2) */ - - *q = sub( 31 + 2, *q ); - move16(); - - return; -} -#endif /*-------------------------------------------------------------------------* * FUNCTION : edst_fx() @@ -414,10 +340,6 @@ void edct_16fx( Word16 *y, /* o : output transform Qx */ Word16 length, /* i : length */ Word16 bh /* bit-headroom */ -#ifndef HARMONIZE_DCT - , - const Word16 element_mode -#endif ) { Word16 i; @@ -430,10 +352,6 @@ void edct_16fx( Word16 Len2, i2; const Word16 *px, *pt; Word16 *py; -#ifndef HARMONIZE_DCT - (void) element_mode; - /*COMPLETE: some eDCT sub function are missing */ -#endif IF( EQ_16( length, L_FRAME32k ) ) { @@ -580,11 +498,7 @@ void iedct_short_fx( seg_len_div4 = shr( segment_length, 2 ); /*Q0*/ seg_len_3mul_div4 = add( seg_len_div2, seg_len_div4 ); -#ifdef HARMONIZE_DCT edct_fx( in, alias, seg_len_div2, Q, EVS_MONO ); -#else - edct_fx( in, alias, seg_len_div2, Q ); -#endif FOR( i = 0; i < seg_len_div2; i++ ) { IF( alias[i] != 0 ) diff --git a/lib_com/fft_fx.c b/lib_com/fft_fx.c index 299b45cc2..a9872936b 100644 --- a/lib_com/fft_fx.c +++ b/lib_com/fft_fx.c @@ -109,13 +109,6 @@ static void fft5_8( Word16 n1, Word32 *zRe, Word32 *zIm, const Word16 *Idx ); static void fft4_5( Word32 *x, Word32 *y, const Word16 *Idx ); static void fft5_4( Word16 n1, Word32 *zRe, Word32 *zIm, const Word16 *Idx ); -#ifndef HARMONIZE_DCT -void DoRTFTn_fx_ivas( - Word32 *x, /* i/o: real part of input and output data */ - Word32 *y, /* i/o: imaginary part of input and output data */ - const Word16 n /* i : size of the FFT n=(2^k) up to 1024 */ -); -#endif /*-----------------------------------------------------------------* * fft15_shift2() * 15-point FFT with 2-point circular shift @@ -2440,303 +2433,6 @@ static void cftmdl( return; } -#ifndef HARMONIZE_DCT -static void cftbsub( - Word16 n, // Q0 - Word32 *a, // Qx - const Word16 *w /* i : cos/sin table Q15 */ -) -{ - Word16 j, j1, j2, j3, l; - Word32 x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; - - l = 2; - move16(); - IF( GT_16( n, 8 ) ) - { - cft1st( n, a, w ); - l = 8; - move16(); - - WHILE( ( ( l << 2 ) < n ) ) - { - cftmdl( n, l, a, w ); - l = shl( l, 2 ); - } - } - - IF( EQ_16( shl( l, 2 ), n ) ) - { - FOR( j = 0; j < l; j += 2 ) - { - j1 = add( j, l ); - j2 = add( j1, l ); - j3 = add( j2, l ); - x0r = L_add( a[j], a[j1] ); // Qx - x0i = L_negate( L_add( a[j + 1], a[j1 + 1] ) ); // Qx - x1r = L_sub( a[j], a[j1] ); // Qx - x1i = L_sub( a[j1 + 1], a[j + 1] ); // Qx - x2r = L_add( a[j2], a[j3] ); // Qx - x2i = L_add( a[j2 + 1], a[j3 + 1] ); // Qx - x3r = L_sub( a[j2], a[j3] ); // Qx - x3i = L_sub( a[j2 + 1], a[j3 + 1] ); // Qx - a[j] = L_add( x0r, x2r ); - move32(); - a[j + 1] = L_sub( x0i, x2i ); - move32(); - a[j2] = L_sub( x0r, x2r ); - move32(); - a[j2 + 1] = L_add( x0i, x2i ); - move32(); - a[j1] = L_sub( x1r, x3i ); - move32(); - a[j1 + 1] = L_sub( x1i, x3r ); - move32(); - a[j3] = L_add( x1r, x3i ); - move32(); - a[j3 + 1] = L_add( x1i, x3r ); - move32(); - } - } - ELSE - { - FOR( j = 0; j < l; j += 2 ) - { - j1 = add( j, l ); - x0r = L_sub( a[j], a[j1] ); - x0i = L_sub( a[j1 + 1], a[j + 1] ); - a[j] = L_add( a[j], a[j1] ); - move32(); - a[j + 1] = L_negate( L_add( a[j + 1], a[j1 + 1] ) ); - move32(); - a[j1] = x0r; - move32(); - a[j1 + 1] = x0i; - move32(); - } - } - - return; -} - -static void rftfsub( - Word16 n, // Q0 - Word32 *a, // Qx - Word16 nc, // Q0 - const Word16 *c // Q15 -) -{ - Word16 j, k, kk, ks, m; - Word16 wkr, wki; - Word32 xr, xi, yr, yi; - - m = shr( n, 1 ); - ks = idiv1616( shl( nc, 1 ), m ); - kk = 0; - move16(); - FOR( j = 2; j < m; j += 2 ) - { - k = sub( n, j ); - kk = add( kk, ks ); - wkr = sub( extract_l( 0x4000 ) /*0.5.Q15*/, c[( nc - kk )] ); - wki = c[kk]; // Q15 - move16(); - xr = L_sub( a[j], a[k] ); - xi = L_add( a[j + 1], a[k + 1] ); - yr = L_sub( Mpy_32_16_1( xr, wkr ), Mpy_32_16_1( xi, wki ) ); - yi = L_add( Mpy_32_16_1( xi, wkr ), Mpy_32_16_1( xr, wki ) ); - a[j] = L_sub( a[j], yr ); - move32(); - a[j + 1] = L_sub( a[j + 1], yi ); - move32(); - a[k] = L_add( a[k], yr ); - move32(); - a[k + 1] = L_sub( a[k + 1], yi ); - move32(); - } - - return; -} - - -static void rftbsub( - Word16 n, // Q0 - Word32 *a, // Qx - Word16 nc, // Q0 - const Word16 *c // Q15 -) -{ - Word16 j, k, kk, ks, m; - Word16 wkr, wki; - Word32 xr, xi, yr, yi; - a[1] = L_negate( a[1] ); - move32(); - m = shr( n, 1 ); - ks = idiv1616( shl( nc, 1 ), m ); - kk = 0; - move16(); - FOR( j = 2; j < m; j += 2 ) - { - k = sub( n, j ); - kk = add( kk, ks ); - wkr = sub( extract_l( 0x4000 ) /*0.5.Q15*/, c[( nc - kk )] ); - wki = c[kk]; // Q15 - xr = L_sub( a[j], a[k] ); - xi = L_add( a[j + 1], a[k + 1] ); - yr = L_add( Mpy_32_16_1( xr, wkr ), Mpy_32_16_1( xi, wki ) ); // Qx - yi = L_sub( Mpy_32_16_1( xi, wkr ), Mpy_32_16_1( xr, wki ) ); // Qx - a[j] = L_sub( a[j], yr ); - move32(); - a[j + 1] = L_sub( yi, a[j + 1] ); - move32(); - a[k] = L_add( a[k], yr ); - move32(); - a[k + 1] = L_sub( yi, a[k + 1] ); - move32(); - } - a[m + 1] = L_negate( a[m + 1] ); - - return; -} - - -static void dctsub( - Word16 n, // Q0 - Word32 *a, // Qx - Word16 nc, // Q0 - const Word16 *c // Q15 -) -{ - Word16 j, k, kk, ks, m; - Word16 wkr, wki; - Word32 xr; - - m = shr( n, 1 ); - ks = idiv1616( nc, n ); - kk = 0; - move16(); - FOR( j = 1; j < m; j++ ) - { - k = sub( n, j ); - kk = add( kk, ks ); - wkr = sub( c[kk], c[( nc - kk )] ); // Q15 - wki = add( c[kk], c[( nc - kk )] ); // Q15 - xr = L_sub( Mpy_32_16_1( a[j], wki ), Mpy_32_16_1( a[k], wkr ) ); // Qx - a[j] = L_add( Mpy_32_16_1( a[j], wkr ), Mpy_32_16_1( a[k], wki ) ); // Qx - move32(); - a[k] = xr; - move32(); - } - a[m] = Mpy_32_16_1( a[m], c[0] ); // Qx - move32(); - - return; -} - -/*-----------------------------------------------------------------* - * edct2_fx_ivas() - * - * Transformation of the signal to DCT domain - * OR Inverse EDCT-II for short frames - *-----------------------------------------------------------------*/ - -void edct2_fx_ivas( - const Word16 n, // Q0 - const Word16 isgn, - Word32 *in, // Qx - Word32 *a, // Qx - const Word16 *ip, - const Word16 *w // Q15 -) -{ - Word16 j, nw, nc; - Word32 xr; - - Copy32( in, a, n ); - - nw = ip[0]; - move16(); - IF( GT_16( n, shl( nw, 2 ) ) ) - { - nw = shr( n, 2 ); - } - - nc = ip[1]; - move16(); - if ( GT_16( n, nc ) ) - { - nc = n; - move16(); - } - IF( isgn < 0 ) - { - xr = a[n - 1]; - move16(); - FOR( j = n - 2; j >= 2; j -= 2 ) - { - a[j + 1] = L_sub( a[j], a[j - 1] ); - move32(); - a[j] = L_add( a[j], a[j - 1] ); - move32(); - } - a[1] = L_sub( a[0], xr ); - move32(); - a[0] = L_add( a[0], xr ); - move32(); - - IF( GT_16( n, 4 ) ) - { - rftbsub( n, a, nc, w + nw ); - bitrv2_SR( n, ip + 2, a ); - cftbsub( n, a, w ); - } - ELSE IF( EQ_16( n, 4 ) ) - { - cftfsub( n, a, w ); - } - } - - IF( isgn >= 0 ) - { - a[0] = L_shr( a[0], 1 ); - move32(); - } - - dctsub( n, a, nc, w + nw ); - - IF( isgn >= 0 ) - { - IF( GT_16( n, 4 ) ) - { - bitrv2_SR( n, ip + 2, a ); - cftfsub( n, a, w ); - rftfsub( n, a, nc, w + nw ); - } - ELSE IF( EQ_16( n, 4 ) ) - { - cftfsub( n, a, w ); - } - xr = L_sub( a[0], a[1] ); - a[0] = L_add( a[0], a[1] ); - move32(); - FOR( j = 2; j < n; j += 2 ) - { - a[j - 1] = L_sub( a[j], a[j + 1] ); - move32(); - a[j] = L_add( a[j], a[j + 1] ); - move32(); - } - a[n - 1] = xr; - move32(); - - FOR( j = 0; j < n; j++ ) - { - a[j] = L_shr( a[j], 5 ); - move32(); - } - } -} -#endif void DoRTFTn_fx_ivas( Word32 *x, /* i/o: real part of input and output data Qx */ @@ -6430,93 +6126,6 @@ static void fft_lenN( * Complex-value FFT *-----------------------------------------------------------------*/ -#ifndef HARMONIZE_DCT -void fft_fx( - Word32 *re, /* i/o: real part Qx */ - Word32 *im, /* i/o: imag part Qx */ - const Word16 length, /* i : length of fft */ - const Word16 s /* i : sign */ -) -{ - - cmplx x[960]; - - FOR( Word16 j = 0; j < length; j++ ) - { - x[j].re = re[( s * j )]; - move32(); - x[j].im = im[( s * j )]; - move32(); - } - - SWITCH( length ) - { - case 20: - fft_len20_fx( x ); - BREAK; - case 40: - fft_lenN( x, FFT_RotVector_640_fx, 640, 5, 8, 8, 40 ); - BREAK; - case 64: - fft_lenN( x, FFT_RotVector_256_fx, 256, 8, 8, 8, 64 ); - BREAK; - case 80: - fft_lenN( x, FFT_RotVector_640_fx, 640, 10, 8, 4, 40 ); - BREAK; - case 100: - fft_lenN( x, FFT_RotVector_400_fx, 400, 10, 10, 4, 40 ); - BREAK; - case 120: - fft_lenN( x, FFT_RotVector_960_fx, 960, 15, 8, 4, 60 ); - BREAK; - case 128: - fft_lenN( x, FFT_RotVector_256_fx, 256, 16, 8, 4, 64 ); - BREAK; - case 160: - fft_lenN( x, FFT_RotVector_640_fx, 640, 20, 8, 2, 40 ); - BREAK; - case 200: - fft_lenN( x, FFT_RotVector_400_fx, 400, 20, 10, 2, 40 ); - BREAK; - case 240: - fft_lenN( x, FFT_RotVector_960_fx, 960, 30, 8, 2, 60 ); - BREAK; - case 256: - fft_lenN( x, FFT_RotVector_256_fx, 256, 32, 8, 2, 64 ); - BREAK; - case 320: - fft_lenN( x, FFT_RotVector_640_fx, 640, 20, 16, 2, 40 ); - BREAK; - case 400: - fft_lenN( x, FFT_RotVector_400_fx, 400, 20, 20, 2, 40 ); - BREAK; - case 480: - fft_lenN( x, FFT_RotVector_960_fx, 960, 30, 16, 2, 60 ); - BREAK; - case 600: - fft_lenN( x, FFT_RotVector_600_fx, 600, 30, 20, 2, 60 ); - BREAK; - case 640: - fft_lenN( x, FFT_RotVector_640_fx, 640, 20, 32, 2, 40 ); - BREAK; - case 960: - fft_lenN( x, FFT_RotVector_960_fx, 960, 30, 32, 2, 60 ); - BREAK; - default: - assert( !"fft length is not supported!" ); - } - - FOR( Word16 j = 0; j < length; j++ ) - { - re[( s * j )] = x[j].re; - move32(); - im[( s * j )] = x[j].im; - move32(); - } - - return; -} -#else void fft_fx( cmplx *x, /* i/o: complex data */ const Word16 length /* i : length of fft */ @@ -6581,7 +6190,6 @@ void fft_fx( return; } -#endif void rfft_fx( @@ -6594,9 +6202,7 @@ void rfft_fx( Word16 i, sizeOfFft2, sizeOfFft4; Word32 tmp, t1, t2, t3, t4; Word16 s1, s2; -#ifdef HARMONIZE_DCT cmplx spec[L_FRAME48k]; -#endif sizeOfFft2 = shr( length, 1 ); sizeOfFft4 = shr( length, 2 ); @@ -6669,7 +6275,6 @@ void rfft_fx( { case -1: -#ifdef HARMONIZE_DCT FOR( i = 0; i < sizeOfFft2; i++ ) { spec[i].re = x[2 * i]; @@ -6700,9 +6305,6 @@ void rfft_fx( x[2 * i + 1] = spec[i].im; move32(); } -#else - fft_fx( x, x + 1, sizeOfFft2, 2 ); -#endif // Qx tmp = L_add( x[0], x[1] ); @@ -6759,7 +6361,6 @@ void rfft_fx( move32(); } -#ifdef HARMONIZE_DCT FOR( i = 0; i < sizeOfFft2; i++ ) { spec[i].re = x[2 * i]; @@ -6777,9 +6378,6 @@ void rfft_fx( x[2 * i + 1] = spec[i].im; move32(); } -#else - fft_fx( x, x + 1, sizeOfFft2, 2 ); -#endif FOR( i = 0; i < length; i += 2 ) { diff --git a/lib_com/gs_inact_switching_fx.c b/lib_com/gs_inact_switching_fx.c index 16e72cd58..db833220e 100644 --- a/lib_com/gs_inact_switching_fx.c +++ b/lib_com/gs_inact_switching_fx.c @@ -89,11 +89,7 @@ void Inac_switch_ematch_fx( ELSE IF( EQ_16( coder_type, VOICED ) || EQ_16( coder_type, GENERIC ) || EQ_16( coder_type, TRANSITION ) || ( last_core != ACELP_CORE ) || NE_16( last_codec_mode, MODE1 ) || ( ( element_mode > EVS_MONO ) && EQ_16( coder_type, UNVOICED ) ) ) { /* Find spectrum and energy per band for GC and VC frames */ -#ifdef HARMONIZE_DCT edct_16fx( exc2, dct_exc_tmp, L_frame, 5 ); -#else - edct_16fx( exc2, dct_exc_tmp, L_frame, 5, element_mode ); -#endif Ener_per_band_comp_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1, L_frame ); @@ -107,11 +103,7 @@ void Inac_switch_ematch_fx( ELSE IF( ( coder_type == INACTIVE ) && inactive_coder_type_flag ) { /* Find spectrum and energy per band for inactive frames */ -#ifdef HARMONIZE_DCT edct_16fx( exc2, dct_exc_tmp, L_frame, 5 ); -#else - edct_16fx( exc2, dct_exc_tmp, L_frame, 5, element_mode ); -#endif Ener_per_band_comp_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1, L_frame ); @@ -196,11 +188,7 @@ void Inac_switch_ematch_fx( Scale_sig( dct_exc_tmp, 240, 1 ); // Q_exc Scale_sig( exc2, 240, 1 ); // Q_exc } -#ifdef HARMONIZE_DCT edct_16fx( dct_exc_tmp, exc2, L_frame, 5 ); -#else - edct_16fx( dct_exc_tmp, exc2, L_frame, 5, element_mode ); -#endif } return; diff --git a/lib_com/ivas_mdft_imdft_fx.c b/lib_com/ivas_mdft_imdft_fx.c index 19774e712..ae92fddf3 100644 --- a/lib_com/ivas_mdft_imdft_fx.c +++ b/lib_com/ivas_mdft_imdft_fx.c @@ -214,7 +214,6 @@ static void ivas_ifft_cplx1_fx( move32(); } -#ifdef HARMONIZE_DCT cmplx x[L_FRAME48k]; FOR( i = 0; i < length; i++ ) @@ -234,9 +233,6 @@ static void ivas_ifft_cplx1_fx( im[i] = x[i].im; move32(); } -#else - fft_fx( re, im, length, 1 ); -#endif return; } @@ -255,12 +251,7 @@ void ivas_mdft_fx( const Word16 mdft_length /* i : MDFT length */ ) { -#ifdef HARMONIZE_DCT cmplx spec[L_FRAME48k]; -#else - Word32 re[L_FRAME48k]; - Word32 im[L_FRAME48k]; -#endif Word16 j, len_by_2; const Word32 *pTwid; // Q31 len_by_2 = shr( mdft_length, 1 ); @@ -270,38 +261,23 @@ void ivas_mdft_fx( { FOR( j = 0; j < mdft_length; j++ ) { -#ifdef HARMONIZE_DCT spec[j].re = Mpy_32_32( pIn[j], pTwid[j] ); // ( Qin + Q31 ) - Q31 -> Qin move32(); spec[j].im = Mpy_32_32( L_negate( pIn[j] ), pTwid[mdft_length - j] ); // ( Qin + Q31 ) - Q31 -> Qin move32(); -#else - re[j] = Mpy_32_32( pIn[j], pTwid[j] ); // ( Qin + Q31 ) - Q31 -> Qin - move32(); - im[j] = Mpy_32_32( L_negate( pIn[j] ), pTwid[mdft_length - j] ); // ( Qin + Q31 ) - Q31 -> Qin - move32(); -#endif } } ELSE { FOR( j = 0; j < mdft_length; j++ ) { -#ifdef HARMONIZE_DCT spec[j].re = Msub_32_32( Mpy_32_32( pIn[j], pTwid[j] ), pIn[add( mdft_length, j )], pTwid[mdft_length - j] ); // ( Qin + Q31 ) - Q31 -> Qin move32(); spec[j].im = Msub_32_32( Mpy_32_32( L_negate( pIn[j] ), pTwid[mdft_length - j] ), pIn[mdft_length + j], pTwid[j] ); // ( Qin + Q31 ) - Q31 -> Qin move32(); -#else - re[j] = Msub_32_32( Mpy_32_32( pIn[j], pTwid[j] ), pIn[add( mdft_length, j )], pTwid[mdft_length - j] ); // ( Qin + Q31 ) - Q31 -> Qin - move32(); - im[j] = Msub_32_32( Mpy_32_32( L_negate( pIn[j] ), pTwid[mdft_length - j] ), pIn[mdft_length + j], pTwid[j] ); // ( Qin + Q31 ) - Q31 -> Qin - move32(); -#endif } } -#ifdef HARMONIZE_DCT fft_fx( spec, mdft_length ); FOR( j = 0; j < len_by_2; j++ ) @@ -316,21 +292,6 @@ void ivas_mdft_fx( pOut_im[2 * j + 1] = L_negate( spec[mdft_length - j - 1].im ); move32(); } -#else - fft_fx( re, im, mdft_length, 1 ); - FOR( j = 0; j < len_by_2; j++ ) - { - pOut_re[2 * j] = re[j]; // Qin - move32(); - pOut_re[2 * j + 1] = re[mdft_length - j - 1]; // Qin - move32(); - - pOut_im[2 * j] = im[j]; // Qin - move32(); - pOut_im[2 * j + 1] = L_negate( im[mdft_length - j - 1] ); // Qin - move32(); - } -#endif return; } diff --git a/lib_com/options.h b/lib_com/options.h index 484294d1b..1f6b80842 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -92,7 +92,6 @@ #define NONBE_FIX_ISSUE_2206_AVOID_OVERFLOW_MSVQ_Interpol_Tran_fx /* FhG: Fix saturation crash in MSVQ_Interpol_Tran_fx() */ #define FIX_2452_HQ_CORE_PEAQ_AVR_RATIO_HARM /* Eri: Basop issue 2453: Fix alignment of peak_avrg_ratio_fx */ #define FIX_FLOAT_1539_G192_FORMAT_SWITCH /* VA/Nokia: reintroduce format switching for g192 bitstreams */ -#define HARMONIZE_DCT /* VA: removal of duplicated DCT functions */ #define FIX_2489_HARMONIZE_FdCng_encodeSID /* FhG: harmonize FdCng_encodeSID_fx() and FdCng_encodeSID_ivas_fx() */ #define FIX_1527_CMR_BITRATE_IDX /* Fix for incorrect bitrate idx packed in rtp CMR E-byte */ #define HARMONIZE_2494_FdCng_decodeSID_fx /* FhG: harmonize FdCng_decodeSID_fx with _ivas_ version */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 90f6c13ed..c76a96e24 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -3988,22 +3988,10 @@ void edct_fx( const Word32 *x, /* i : i signal Qq */ Word32 *y, /* o : output transform Qq */ Word16 length, /* i : length */ -#ifdef HARMONIZE_DCT Word16 *q, /* i : Q value of input signal */ const Word16 element_mode /* i : element mode */ -#else - Word16 *q /* i : Q value of i signal */ -#endif ); -#ifndef HARMONIZE_DCT -void edct_ivas_fx( - const Word32 *x, /* i : input signal Qq */ - Word32 *y, /* o : output transform Qq */ - Word16 length, /* i : length Q0*/ - Word16 *q /* i : Q value of input signal */ -); -#endif void edst_fx( const Word32 *x, /* i : i signal Qq */ Word32 *y, /* o : output transform Qq */ @@ -4016,10 +4004,6 @@ void edct_16fx( Word16 *y, /* o : output transform Qx */ Word16 length, /* i : length */ Word16 bh /* bit-headroom */ -#ifndef HARMONIZE_DCT - , - const Word16 element_mode -#endif ); void iedct_short_fx( @@ -4100,15 +4084,8 @@ void DoFFT_fx( const Word16 length ); void fft_fx( -#ifndef HARMONIZE_DCT - Word32 *re, /* i/o: real part */ - Word32 *im, /* i/o: imag part */ - const Word16 length, /* i : length of fft */ - const Word16 s /* i : sign */ -#else cmplx *spec, /* i/o: complex data */ const Word16 length /* i : length of fft */ -#endif ); void rfft_fx( @@ -4141,15 +4118,6 @@ Flag is_zero_arr( Word32 *arr, Word16 size ); Flag is_zero_arr16( Word16 *arr, Word16 size ); Flag is_zero_arr64( Word64 *arr, Word16 size ); -#ifndef HARMONIZE_DCT -void edct2_fx_ivas( - const Word16 n, - const Word16 isgn, - Word32 *in, - Word32 *a, - const Word16 *ip, - const Word16 *w ); -#endif void edct2_fx( Word16 n, Word16 isgn, diff --git a/lib_com/tcx_mdct_fx.c b/lib_com/tcx_mdct_fx.c index d29a4ffed..5903bc31c 100644 --- a/lib_com/tcx_mdct_fx.c +++ b/lib_com/tcx_mdct_fx.c @@ -138,11 +138,7 @@ void TCX_MDCT( *y_e = sub( 15, *y_e ); move16(); -#ifdef HARMONIZE_DCT edct_fx( y, y, l / 2 + m + r / 2, y_e, EVS_MONO ); -#else - edct_fx( y, y, l / 2 + m + r / 2, y_e ); -#endif *y_e = sub( 15 - 1, *y_e ); move16(); return; @@ -224,11 +220,7 @@ void TCX_MDCT_Inverse( R2 = shr( r, 1 ); x_e = sub( 15, x_e ); -#ifdef HARMONIZE_DCT edct_fx( x, tmp_buf + L2, add( add( shr( l, 1 ), m ), shr( r, 1 ) ), &x_e, EVS_MONO ); -#else - edct_fx( x, tmp_buf + L2, add( add( shr( l, 1 ), m ), shr( r, 1 ) ), &x_e ); -#endif x_e = sub( 15, x_e ); fac = TCX_MDCT_Inverse_GetScaleFactor( add( add( shr( l, 1 ), m ), shr( r, 1 ) ), &fac_e ); /* exp(fac_e) */ diff --git a/lib_com/trans_direct_fx.c b/lib_com/trans_direct_fx.c index fa0a27a9a..0f07d3499 100644 --- a/lib_com/trans_direct_fx.c +++ b/lib_com/trans_direct_fx.c @@ -103,11 +103,7 @@ void direct_transform_fx( Qs[0] = *Q; move16(); -#ifdef HARMONIZE_DCT edct_fx( dctin32_fx, oseg_fx, segment_length2, &Qs[0], EVS_MONO ); -#else - edct_fx( dctin32_fx, oseg_fx, segment_length2, &Qs[0] ); -#endif Qmin = s_min( Qs[0], Qmin ); iseg_fx = &in32_r16_fx[segment_length4]; @@ -140,11 +136,7 @@ void direct_transform_fx( Qs[seg] = *Q; move16(); -#ifdef HARMONIZE_DCT edct_fx( dctin32_fx, oseg_fx, segment_length2, &Qs[seg], EVS_MONO ); -#else - edct_fx( dctin32_fx, oseg_fx, segment_length2, &Qs[seg] ); -#endif Qmin = s_min( Qs[seg], Qmin ); iseg_fx += segment_length2; @@ -172,11 +164,7 @@ void direct_transform_fx( } Qs[NUM_TIME_SWITCHING_BLOCKS - 1] = *Q; move16(); -#ifdef HARMONIZE_DCT edct_fx( dctin32_fx, oseg_fx, segment_length2, &Qs[NUM_TIME_SWITCHING_BLOCKS - 1], EVS_MONO ); -#else - edct_fx( dctin32_fx, oseg_fx, segment_length2, &Qs[NUM_TIME_SWITCHING_BLOCKS - 1] ); -#endif Qmin = s_min( Qs[NUM_TIME_SWITCHING_BLOCKS - 1], Qmin ); *Q = Qmin; @@ -195,11 +183,7 @@ void direct_transform_fx( } ELSE { -#ifdef HARMONIZE_DCT edct_fx( in32_fx, out32_fx, L, Q, EVS_MONO ); -#else - edct_fx( in32_fx, out32_fx, L, Q ); -#endif } return; diff --git a/lib_com/trans_inv_fx.c b/lib_com/trans_inv_fx.c index 32e188f2d..33e945ecd 100644 --- a/lib_com/trans_inv_fx.c +++ b/lib_com/trans_inv_fx.c @@ -1122,10 +1122,6 @@ void Inverse_Transform( } ELSE { -#ifdef HARMONIZE_DCT edct_fx( in_mdct, out, L, Q, EVS_MONO ); -#else - edct_fx( in_mdct, out, L, Q ); -#endif } } diff --git a/lib_dec/FEC_fx.c b/lib_dec/FEC_fx.c index 9674ab9c7..9e164827c 100644 --- a/lib_dec/FEC_fx.c +++ b/lib_dec/FEC_fx.c @@ -472,11 +472,7 @@ void FEC_exc_estim_fx( move16(); /* Transform to frequency domain */ -#ifdef HARMONIZE_DCT edct_16fx( exc, exc_dct_in, st_fx->L_frame, 5 ); -#else - edct_16fx( exc, exc_dct_in, st_fx->L_frame, 5, st_fx->element_mode ); -#endif /* Reset unvaluable part of the adaptive (pitch) excitation contribution */ max_len = sub( st_fx->L_frame, Diff_len ); @@ -518,11 +514,7 @@ void FEC_exc_estim_fx( *tmp_noise = shr_r( st_fx->lp_gainc_fx, 3 ); /*Q0*/ move16(); /* Transform back to time domain */ -#ifdef HARMONIZE_DCT edct_16fx( exc_dct_in, exc, st_fx->L_frame, 5 ); -#else - edct_16fx( exc_dct_in, exc, st_fx->L_frame, 5, st_fx->element_mode ); -#endif } ELSE { diff --git a/lib_dec/LD_music_post_filter_fx.c b/lib_dec/LD_music_post_filter_fx.c index 989a47e8d..1fd33d11c 100644 --- a/lib_dec/LD_music_post_filter_fx.c +++ b/lib_dec/LD_music_post_filter_fx.c @@ -877,11 +877,7 @@ void Prep_music_postP_fx( * EDCT and back to 16 bits *------------------------------------------------------------*/ -#ifdef HARMONIZE_DCT edct_16fx( exc16, dct_buffer_out, DCT_L_POST, 6 ); -#else - edct_16fx( exc16, dct_buffer_out, DCT_L_POST, 6, EVS_MONO ); -#endif *qdct = Q_exc; move16(); @@ -961,11 +957,7 @@ void Post_music_postP_fx( * Go back to time domain *------------------------------------------------------------------------*/ -#ifdef HARMONIZE_DCT edct_16fx( dct_buffer_in, exc16, DCT_L_POST, 6 ); -#else - edct_16fx( dct_buffer_in, exc16, DCT_L_POST, 6, EVS_MONO ); -#endif Copy( exc16 + OFFSET2, exc2, L_FRAME ); diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index a0db01d31..a4badec34 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -111,11 +111,7 @@ void bw_switching_pre_proc_fx( * Calculate frequency energy of 0~3.2kHz and 3.2~6.4kHz the ACELP core synthesis *-------------------------------------------------------------------------------*/ -#ifdef HARMONIZE_DCT edct_16fx( old_syn_12k8_16k_fx, syn_dct_fx, L_FRAME, 6 ); -#else - edct_16fx( old_syn_12k8_16k_fx, syn_dct_fx, L_FRAME, 6, st_fx->element_mode ); -#endif L_tmp = L_deposit_l( 0 ); FOR( i = 0; i < L_FRAME / 2; i++ ) diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index f8cd015ea..f48ae67d8 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -2181,11 +2181,7 @@ void IMDCT_fx( Word32 *x, Word16 x_e, Word16 *old_syn_overl, Word16 *syn_Overl_T /* DCT */ Q = sub( 31, x_e ); -#ifdef HARMONIZE_DCT edct_fx( x, tmp_buf, L_frame, &Q, EVS_MONO ); -#else - edct_fx( x, tmp_buf, L_frame, &Q ); -#endif /* scale by sqrt(L / NORM_MDCT_FACTOR) */ tmp1 = mult_r( shl( L_frame, 4 ), 26214 /*128.f / NORM_MDCT_FACTOR Q15*/ ); /* 4Q11 */ @@ -2717,11 +2713,7 @@ static void TCX_MDCT_Inverse_qwin_fx( R2 = shr( r, 1 ); x_e = sub( 15, x_e ); -#ifdef HARMONIZE_DCT edct_fx( x, tmp_buf + L2, add( add( shr( l, 1 ), m ), shr( r, 1 ) ), &x_e, EVS_MONO ); -#else - edct_fx( x, tmp_buf + L2, add( add( shr( l, 1 ), m ), shr( r, 1 ) ), &x_e ); -#endif x_e = sub( 15, x_e ); fac = TCX_MDCT_Inverse_GetScaleFactor( add( add( shr( l, 1 ), m ), shr( r, 1 ) ), &fac_e ); /* exp(fac_e) */ @@ -3313,11 +3305,7 @@ void IMDCT_ivas_fx( } ELSE { -#ifdef HARMONIZE_DCT edct_fx( x_fx, xn_buf_fx_32 + add( shr( overlap, 1 ), nz ), L_frame, &q_xn_buf_fx_32, IVAS_SCE /* just cannot be EVS_MONO */ ); -#else - edct_ivas_fx( x_fx, xn_buf_fx_32 + add( shr( overlap, 1 ), nz ), L_frame, &q_xn_buf_fx_32 ); -#endif Word16 res_m, res_e; res_e = 0; move16(); diff --git a/lib_dec/gs_dec_amr_wb_fx.c b/lib_dec/gs_dec_amr_wb_fx.c index 2670ebfef..49ba5a85c 100644 --- a/lib_dec/gs_dec_amr_wb_fx.c +++ b/lib_dec/gs_dec_amr_wb_fx.c @@ -451,19 +451,11 @@ void improv_amr_wb_gs_fx( * Go back to time domain -> Overwrite exctiation *------------------------------------------------------------*/ -#ifdef HARMONIZE_DCT edct_16fx( exc2_fx, dct_exc_in_fx, L_FRAME, 6 ); -#else - edct_16fx( exc2_fx, dct_exc_in_fx, L_FRAME, 6, EVS_MONO ); -#endif gs_dec_amr_wb_fx( core_brate, seed_tcx, dct_exc_in_fx, Q_exc2, dct_exc_out_fx, Q_exc2, pitch_buf_fx, lt_voice_fac_fx, clas, coder_type ); -#ifdef HARMONIZE_DCT edct_16fx( dct_exc_out_fx, exc2_fx, L_FRAME, 6 ); -#else - edct_16fx( dct_exc_out_fx, exc2_fx, L_FRAME, 6, EVS_MONO ); -#endif /*------------------------------------------------------------* * Redo core synthesis at 12k8 Hz with the modified excitation diff --git a/lib_dec/gs_dec_fx.c b/lib_dec/gs_dec_fx.c index a24bb88dc..eb9845dc8 100644 --- a/lib_dec/gs_dec_fx.c +++ b/lib_dec/gs_dec_fx.c @@ -358,11 +358,7 @@ void decod_audio_fx( * DCT transform *---------------------------------------------------------------*/ -#ifdef HARMONIZE_DCT edct_16fx( exc, dct_epit, st_fx->L_frame, 7 ); -#else - edct_16fx( exc, dct_epit, st_fx->L_frame, 7, st_fx->element_mode ); -#endif /*---------------------------------------------------------------* * Reset unvaluable part of the adaptive (pitch) excitation contribution @@ -501,13 +497,8 @@ void decod_audio_fx( * iDCT transform *--------------------------------------------------------------------------------------*/ -#ifdef HARMONIZE_DCT edct_16fx( dct_epit, exc, st_fx->L_frame, 7 ); edct_16fx( exc_wo_nf, exc_wo_nf, st_fx->L_frame, 7 ); -#else - edct_16fx( dct_epit, exc, st_fx->L_frame, 7, st_fx->element_mode ); - edct_16fx( exc_wo_nf, exc_wo_nf, st_fx->L_frame, 7, st_fx->element_mode ); -#endif /*----------------------------------------------------------------------* * Remove potential pre-echo in case an onset has been detected diff --git a/lib_dec/hf_synth_fx.c b/lib_dec/hf_synth_fx.c index 32fcb3311..f2be9219d 100644 --- a/lib_dec/hf_synth_fx.c +++ b/lib_dec/hf_synth_fx.c @@ -716,11 +716,7 @@ void hf_synth_amr_wb_fx( Copy_Scale_sig_16_32_DEPREC( exc, exc32, L_FRAME, qdct ); /* Qexc + qdct */ qdct = add( qdct, Q_exc ); -#ifdef HARMONIZE_DCT edct_fx( exc32, dct_exc32, L_FRAME, &qdct, EVS_MONO ); -#else - edct_fx( exc32, dct_exc32, L_FRAME, &qdct ); -#endif q_tmp = Exp32Array( L_FRAME, dct_exc32 ); q_tmp = sub( q_tmp, 16 ); @@ -1010,11 +1006,7 @@ void hf_synth_amr_wb_fx( qhf = sub( q_tmp, 1 ); Copy_Scale_sig_16_32_DEPREC( dct_hb, dct_hb32, L_FRAME16k, qhf ); /* qhf + qdct */ qhf = add( qhf, qdct ); -#ifdef HARMONIZE_DCT edct_fx( dct_hb32, exc16k32, L_FRAME16k, &qhf, EVS_MONO ); -#else - edct_fx( dct_hb32, exc16k32, L_FRAME16k, &qhf ); -#endif q_tmp = Exp32Array( L_FRAME16k, exc16k32 ); q_tmp = sub( q_tmp, 16 ); Copy_Scale_sig_32_16( exc16k32, exc16k, L_FRAME16k, q_tmp ); /* qhf + qtmp */ diff --git a/lib_dec/ivas_td_low_rate_dec_fx.c b/lib_dec/ivas_td_low_rate_dec_fx.c index 200443dbc..a5141e398 100644 --- a/lib_dec/ivas_td_low_rate_dec_fx.c +++ b/lib_dec/ivas_td_low_rate_dec_fx.c @@ -134,14 +134,8 @@ void tdm_low_rate_dec_fx( * iDCT transform *--------------------------------------------------------------------------------------*/ -#ifdef HARMONIZE_DCT edct_16fx( dct_epit, exc, L_FRAME, find_guarded_bits_fx( L_FRAME ) ); edct_16fx( exc_wo_nf_fx, exc_wo_nf_fx, L_FRAME, find_guarded_bits_fx( L_FRAME ) ); -#else - edct_16fx( dct_epit, exc, L_FRAME, find_guarded_bits_fx( L_FRAME ), IVAS_CPE_TD ); - - edct_16fx( exc_wo_nf_fx, exc_wo_nf_fx, L_FRAME, find_guarded_bits_fx( L_FRAME ), IVAS_CPE_TD ); -#endif IF( bwe_exc != NULL ) { diff --git a/lib_enc/bw_detect_fx.c b/lib_enc/bw_detect_fx.c index 200ff9098..ff60b94d0 100644 --- a/lib_enc/bw_detect_fx.c +++ b/lib_enc/bw_detect_fx.c @@ -308,11 +308,7 @@ void bw_detect_fx( in_win32[i] = L_mult( *pt++, *pt1-- ); move32(); } -#ifdef HARMONIZE_DCT edct_fx( in_win32, spect32, BWD_TOTAL_WIDTH, &Q_dct, EVS_MONO ); -#else - edct_fx( in_win32, spect32, BWD_TOTAL_WIDTH, &Q_dct /*,st->element_mode*/ ); -#endif FOR( i = 0; i < BWD_TOTAL_WIDTH; i++ ) { diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index 51b958bb2..72a8d01d3 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -2490,11 +2490,7 @@ void QuantizeSpectrum_fx( /* DCT */ Q = sub( 31, *spectrum_e ); -#ifdef HARMONIZE_DCT edct_fx( spectrum, tmp_buf, L_frame, &Q, EVS_MONO ); -#else - edct_fx( spectrum, tmp_buf, L_frame, &Q ); -#endif /* scale by sqrt(L / NORM_MDCT_FACTOR) */ tmp1 = mult_r( shl( L_frame, 4 ), 26214 /*128.f / NORM_MDCT_FACTOR Q15*/ ); /* 4Q11 */ @@ -3726,11 +3722,7 @@ void coder_tcx_fx( Q = sub( Q, tmp2 ); /* DCT */ -#ifdef HARMONIZE_DCT edct_fx( tmp_buf, spectrum, L_frame, &Q, EVS_MONO ); -#else - edct_fx( tmp_buf, spectrum, L_frame, &Q ); -#endif *spectrum_e = sub( 31, Q ); move16(); } @@ -4421,11 +4413,7 @@ void InternalTCXDecoder_fx( /* DCT */ Q = sub( 31, *spectrum_e ); -#ifdef HARMONIZE_DCT edct_fx( spectrum_fx, tmp_buf, L_frame, &Q, IVAS_SCE /* just cannot be EVS_MONO */ ); -#else - edct_ivas_fx( spectrum_fx, tmp_buf, L_frame, &Q ); -#endif /* scale by sqrt(L / NORM_MDCT_FACTOR) */ tmp1 = mult_r( shl( L_frame, 4 ), 26214 /*128.f / NORM_MDCT_FACTOR Q15*/ ); /* 4Q11 */ diff --git a/lib_enc/ext_sig_ana_fx.c b/lib_enc/ext_sig_ana_fx.c index e9ba5ca8b..6ee717fbc 100644 --- a/lib_enc/ext_sig_ana_fx.c +++ b/lib_enc/ext_sig_ana_fx.c @@ -372,11 +372,7 @@ void core_signal_analysis_high_bitrate_fx( Q = sub( Q, tmp2 ); /* DCT */ -#ifdef HARMONIZE_DCT edct_fx( tmp_buf, spectrum[frameno], L_subframe, &Q, EVS_MONO ); -#else - edct_fx( tmp_buf, spectrum[frameno], L_subframe, &Q ); -#endif *spectrum_e = sub( 31, Q ); } ELSE @@ -994,11 +990,7 @@ void core_signal_analysis_high_bitrate_ivas_fx( Word16 Q; Q = q_out_wtda; -#ifdef HARMONIZE_DCT edct_fx( tcx20Win_32, hTcxEnc->spectrum_fx[frameno], L_subframe, &Q, st->element_mode ); -#else - edct_ivas_fx( tcx20Win_32, hTcxEnc->spectrum_fx[frameno], L_subframe, &Q ); -#endif hTcxEnc->spectrum_e[frameno] = sub( 31, Q ); move16(); diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index 7d2ac0208..1e614638f 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -255,13 +255,8 @@ void encod_audio_fx( * DCT transform *---------------------------------------------------------------*/ -#ifdef HARMONIZE_DCT edct_16fx( exc, dct_epit, st_fx->L_frame, 7 ); edct_16fx( res, dct_res, st_fx->L_frame, 7 ); -#else - edct_16fx( exc, dct_epit, st_fx->L_frame, 7, st_fx->element_mode ); - edct_16fx( res, dct_res, st_fx->L_frame, 7, st_fx->element_mode ); -#endif /*---------------------------------------------------------------* * Calculate energy dynamics @@ -377,13 +372,8 @@ void encod_audio_fx( * iDCT transform *--------------------------------------------------------------------------------------*/ -#ifdef HARMONIZE_DCT edct_16fx( dct_epit, exc, st_fx->L_frame, 7 ); edct_16fx( exc_wo_nf, exc_wo_nf, st_fx->L_frame, 7 ); -#else - edct_16fx( dct_epit, exc, st_fx->L_frame, 7, st_fx->element_mode ); - edct_16fx( exc_wo_nf, exc_wo_nf, st_fx->L_frame, 7, st_fx->element_mode ); -#endif IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { diff --git a/lib_enc/ivas_td_low_rate_enc_fx.c b/lib_enc/ivas_td_low_rate_enc_fx.c index 17ca57065..2e50ae321 100644 --- a/lib_enc/ivas_td_low_rate_enc_fx.c +++ b/lib_enc/ivas_td_low_rate_enc_fx.c @@ -94,11 +94,7 @@ void tdm_low_rate_enc_fx( * DCT transform of the residual and create a subsample residual *---------------------------------------------------------------*/ -#ifdef HARMONIZE_DCT edct_16fx( res, dct_res_fx, L_FRAME, 7 ); -#else - edct_16fx( res, dct_res_fx, L_FRAME, 7, st->element_mode ); -#endif /*--------------------------------------------------------------------------------------* * GSC encoder @@ -123,14 +119,8 @@ void tdm_low_rate_enc_fx( * iDCT transform *--------------------------------------------------------------------------------------*/ -#ifdef HARMONIZE_DCT edct_16fx( dct_epit_fx, exc_fx, L_FRAME, 7 ); edct_16fx( exc_wo_nf_fx, exc_wo_nf_fx, L_FRAME, 7 ); -#else - edct_16fx( dct_epit_fx, exc_fx, L_FRAME, 7, st->element_mode ); - - edct_16fx( exc_wo_nf_fx, exc_wo_nf_fx, L_FRAME, 7, st->element_mode ); -#endif /*--------------------------------------------------------------------------------------* * Remove potential pre-echo in case an onset has been detected -- GitLab From cedac632ac0444a68c9f921dbd27a84c3c314e7b Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 13 Apr 2026 16:49:52 +0200 Subject: [PATCH 10/22] [cleanup] accept FIX_2489_HARMONIZE_FdCng_encodeSID --- lib_com/options.h | 1 - lib_enc/acelp_core_enc_fx.c | 8 - lib_enc/enc_acelp_tcx_main_fx.c | 4 - lib_enc/fd_cng_enc_fx.c | 454 -------------------------------- lib_enc/prot_fx_enc.h | 13 - 5 files changed, 480 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 1f6b80842..9fd631c1d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -92,7 +92,6 @@ #define NONBE_FIX_ISSUE_2206_AVOID_OVERFLOW_MSVQ_Interpol_Tran_fx /* FhG: Fix saturation crash in MSVQ_Interpol_Tran_fx() */ #define FIX_2452_HQ_CORE_PEAQ_AVR_RATIO_HARM /* Eri: Basop issue 2453: Fix alignment of peak_avrg_ratio_fx */ #define FIX_FLOAT_1539_G192_FORMAT_SWITCH /* VA/Nokia: reintroduce format switching for g192 bitstreams */ -#define FIX_2489_HARMONIZE_FdCng_encodeSID /* FhG: harmonize FdCng_encodeSID_fx() and FdCng_encodeSID_ivas_fx() */ #define FIX_1527_CMR_BITRATE_IDX /* Fix for incorrect bitrate idx packed in rtp CMR E-byte */ #define HARMONIZE_2494_FdCng_decodeSID_fx /* FhG: harmonize FdCng_decodeSID_fx with _ivas_ version */ #define FIX_BASOP_2509_EVS_CONCEAL_UNINIT_MEM /* FhG: BASOP 2509: st->hTcxCfg->psychParamsCurrent is not initialized */ diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 4c8939c18..9b1257104 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -362,11 +362,7 @@ ivas_error acelp_core_enc_fx( test(); IF( EQ_32( st->core_brate, SID_2k40 ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { -#ifdef FIX_2489_HARMONIZE_FdCng_encodeSID FdCng_encodeSID_fx( st ); -#else - FdCng_encodeSID_fx( st->hFdCngEnc, st, st->preemph_fac ); -#endif st->hDtxEnc->last_CNG_L_frame = st->L_frame; move16(); } @@ -401,11 +397,7 @@ ivas_error acelp_core_enc_fx( test(); IF( EQ_32( st->core_brate, SID_2k40 ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { -#ifdef FIX_2489_HARMONIZE_FdCng_encodeSID FdCng_encodeSID_fx( st ); -#else - FdCng_encodeSID_ivas_fx( st ); -#endif st->hDtxEnc->last_CNG_L_frame = st->L_frame; move16(); } diff --git a/lib_enc/enc_acelp_tcx_main_fx.c b/lib_enc/enc_acelp_tcx_main_fx.c index 1aff6eb3d..34f333ae9 100644 --- a/lib_enc/enc_acelp_tcx_main_fx.c +++ b/lib_enc/enc_acelp_tcx_main_fx.c @@ -88,11 +88,7 @@ void enc_acelp_tcx_main_fx( /* Run SID Coder */ IF( st->core_brate == SID_2k40 ) { -#ifdef FIX_2489_HARMONIZE_FdCng_encodeSID FdCng_encodeSID_fx( st ); -#else - FdCng_encodeSID_fx( st->hFdCngEnc, st, st->preemph_fac ); -#endif } /* Generate Comfort Noise */ diff --git a/lib_enc/fd_cng_enc_fx.c b/lib_enc/fd_cng_enc_fx.c index 5b7a43563..a64ea3cce 100644 --- a/lib_enc/fd_cng_enc_fx.c +++ b/lib_enc/fd_cng_enc_fx.c @@ -763,230 +763,6 @@ static void msvq_encoder( return; } -#ifndef FIX_2489_HARMONIZE_FdCng_encodeSID -/* - FdCng_encodeSID_fx - - Parameters: - - stenc i/o: pointer to FD_CNG structure containing all buffers and variables - bitstream o : pointer to bitstream - total_nbbits o : pointer to total number of encoded bits - bitrate i : bitrate - amrwb_io i : amr wideband mode - preemph_fac i : preemphase factor - - - Function: - Generate a bitstream out of the partition levels - - Returns: - void -*/ - -void FdCng_encodeSID_fx( - HANDLE_FD_CNG_ENC stenc, /* i/o: pointer to FD_CNG structure containing all buffers and variables */ - Encoder_State *corest, - Word16 preemph_fac /* i : preemphase factor */ -) -{ - Word16 i, index, N; - Word16 E_Exp, normFacN, normShiftN; - Word16 normFacGain, normShiftGain, sidNoiseEst_Exp; - - Word32 tmp, gain, e, maxVal; - Word32 *E, E_ExpLd64; - Word32 v[32]; - - Word16 indices[32]; - Word16 v16[32]; - BSTR_ENC_HANDLE hBstr = corest->hBstr; - HANDLE_FD_CNG_COM st; - Word16 maxC_37bits = FD_CNG_maxC_37bits, stages_37bits = FD_CNG_stages_37bits, maxN_37bits = FD_CNG_maxN_37bits; - - /* Init */ - st = stenc->hFdCngCom; - - E_Exp = stenc->msNoiseEst_fx_exp; - move16(); - E_ExpLd64 = L_shl( E_Exp, WORD32_BITS - 1 - LD_DATA_SCALE ); - E = stenc->msNoiseEst_fx; - - N = stenc->npartDec; - move16(); - - normFacN = getNormReciprocalWord16( N ); - normShiftN = BASOP_util_norm_s_bands2shift( N ); - - normFacGain = getNormReciprocalWord16( N_GAIN_MAX - N_GAIN_MIN ); - normShiftGain = BASOP_util_norm_s_bands2shift( N_GAIN_MAX - N_GAIN_MIN ); - - /* Convert to LOG */ - - /* e: Q14.23 format, v: Q9.23 format */ - e = L_deposit_l( 0 ); - tmp = Mpy_32_32_r( L_shl( 1, sub( 31, E_Exp ) ), 214748 ); /* 1e-4f, Q31-E_Exp */ - FOR( i = 0; i < N; i++ ) - { - /* assert( E[i] != 0 ); */ - /* constant: 0.75257498916 = 10.0 * log10(2.0)/log10(10.0) * 0.25 */ - v[i] = Mpy_32_16_1( L_add( BASOP_Util_Log2( L_add( E[i], L_max( 1, tmp ) ) ), E_ExpLd64 ), 24660 /*0.75257498916 Q15*/ ); - move32(); - e = L_add( e, L_shr( v[i], normShiftN ) ); - } - e = L_shl( Mpy_32_16_1( e, shl( normFacN, sub( normShiftN, 1 ) ) ), 1 ); - - /* Normalize MSVQ input */ - - /* gain: Q9.23 format */ - gain = L_deposit_l( 0 ); - FOR( i = N_GAIN_MIN; i < N_GAIN_MAX; i++ ) - { - gain = L_add( gain, L_shr( v[i], normShiftGain ) ); - } - gain = L_shl( Mpy_32_16_1( gain, shl( normFacGain, sub( normShiftGain, 1 ) ) ), 1 ); - - FOR( i = 0; i < N; i++ ) - { - v16[i] = extract_h( L_sub( v[i], gain ) ); - } - - /* MSVQ encoder */ - msvq_encoder( cdk_37bits, v16, levels_37bits, maxC_37bits, stages_37bits, N, maxN_37bits, indices ); - - /* MSVQ decoder */ - msvq_decoder( cdk_37bits, stages_37bits, N, maxN_37bits, indices, v16 ); - - FOR( i = 0; i < N; i++ ) - { - v[i] = L_deposit_h( v16[i] ); - } - - /* Compute gain, Q9.23 format */ - gain = 0; - FOR( i = 0; i < N; i++ ) - { - gain = L_add( gain, L_shr( v[i], normShiftN ) ); - } - gain = L_sub( e, L_shl( Mpy_32_16_1( gain, shl( normFacN, sub( normShiftN, 1 ) ) ), 1 ) ); - - - /* Apply bitrate-dependant scale */ - { - apply_scale( &gain, st->CngBandwidth, st->CngBitrate, scaleTableMono, SIZE_SCALE_TABLE_MONO ); - } - - /* Quantize gain, Q14.23 format */ - gain = L_add( gain, L_shr( gain, 1 ) ); - gain = L_add( gain, 507510784l /*60.5 Q23*/ ); - index = extract_l( L_shr( gain, WORD32_BITS - 1 - 8 ) ); - - if ( index < 0 ) - { - index = 0; - move16(); - } - - if ( GT_16( index, 127 ) ) - { - index = 127; - move16(); - } - - /* gain Q14.23 format */ - gain = L_shl( L_deposit_l( index ), WORD32_BITS - 1 - 8 ); - gain = L_sub( gain, 503316480l /*60.0 Q23*/ ); - gain = Mpy_32_16_1( gain, 21845 /*2.0f/3.0f Q15*/ ); - - /* Apply gain and undo log */ - - /* sidNoiseEst: format Q6.26, 0.66438561897 = log10(10)/log10(2.0) / 10.0 * 2.0 */ - - /* calculate worst case for scaling */ - maxVal = 0x80000000 /*-1.0 Q31*/; - move32(); - FOR( i = 0; i < N; i++ ) - { - maxVal = L_max( maxVal, v[i] ); - } - - maxVal = L_add( maxVal, gain ); - maxVal = L_shl( Mpy_32_16_1( maxVal, 21771 /*0.66438561897 Q15*/ ), 1 ); - sidNoiseEst_Exp = 0; - move16(); - WHILE( maxVal >= 0 ) - { - maxVal = L_sub( maxVal, 33554432l /*0.015625 Q31*/ ); - sidNoiseEst_Exp = add( sidNoiseEst_Exp, 1 ); - } - st->sidNoiseEstExp = sidNoiseEst_Exp; - move16(); - E_ExpLd64 = L_shl( sidNoiseEst_Exp, WORD32_BITS - 1 - LD_DATA_SCALE ); - - FOR( i = 0; i < N; i++ ) - { - tmp = L_add( v[i], gain ); - tmp = L_shl( Mpy_32_16_1( tmp, 21771 /*0.66438561897 Q15*/ ), 1 ); - tmp = L_sub( tmp, E_ExpLd64 ); - assert( tmp < 0 ); - st->sidNoiseEst[i] = BASOP_Util_InvLog2( tmp ); - move32(); - } - - /* NB last band energy compensation */ - IF( EQ_16( st->CngBandwidth, NB ) ) - { - st->sidNoiseEst[N - 1] = Mpy_32_16_1( st->sidNoiseEst[N - 1], NB_LAST_BAND_SCALE ); - move32(); - } - - test(); - if ( EQ_16( st->CngBandwidth, SWB ) && LE_32( st->CngBitrate, ACELP_13k20 ) ) - { - st->sidNoiseEst[N - 1] = Mpy_32_16_1( st->sidNoiseEst[N - 1], SWB_13k2_LAST_BAND_SCALE ); - move32(); - } - - - /* Write bitstream */ - IF( EQ_16( corest->codec_mode, MODE2 ) ) - { - FOR( i = 0; i < stages_37bits; i++ ) - { - push_next_indice( hBstr, indices[i], bits_37bits[i] ); - } - push_next_indice( hBstr, index, 7 ); - } - ELSE - { - push_indice( hBstr, IND_SID_TYPE, 1, 1 ); - push_indice( hBstr, IND_ACELP_16KHZ, corest->bwidth, 2 ); - IF( EQ_16( corest->L_frame, L_FRAME16k ) ) - { - push_indice( hBstr, IND_ACELP_16KHZ, 1, 1 ); - } - ELSE - { - push_indice( hBstr, IND_ACELP_16KHZ, 0, 1 ); - } - FOR( i = 0; i < stages_37bits; i++ ) - { - push_indice( hBstr, IND_LSF, indices[i], bits_37bits[i] ); - } - push_indice( hBstr, IND_ENERGY, index, 7 ); - } - - /* Interpolate the bin/band-wise levels from the partition levels */ - /* sidNoiseEst: Q6.26 format => cngNoiseLevel: Q6.26 format */ - scalebands( st->sidNoiseEst, stenc->partDec, stenc->npartDec, stenc->midbandDec, stenc->nFFTpartDec, sub( stenc->stopBandDec, stenc->startBandDec ), st->cngNoiseLevel, 1 ); - st->cngNoiseLevelExp = st->sidNoiseEstExp; - move16(); - - lpc_from_spectrum( st, stenc->startBandDec, stenc->stopFFTbinDec, preemph_fac ); - - return; -} -#endif /*FIX_2489_HARMONIZE_FdCng_encodeSID*/ void generate_comfort_noise_enc_fx( @@ -1806,7 +1582,6 @@ void perform_noise_estimation_enc_fx( * * Generate a bitstream out of the partition levels *-------------------------------------------------------------------*/ -#ifdef FIX_2489_HARMONIZE_FdCng_encodeSID void FdCng_encodeSID_fx( Encoder_State *st /* i/o: encoder state structure */ ) @@ -2145,235 +1920,6 @@ void FdCng_encodeSID_fx( return; } -#else /*FIX_2489_HARMONIZE_FdCng_encodeSID*/ -void FdCng_encodeSID_ivas_fx( - Encoder_State *st /* i/o: encoder state structure */ -) -{ - Word16 N; - HANDLE_FD_CNG_ENC hFdCngEnc = st->hFdCngEnc; - HANDLE_FD_CNG_COM hFdCngCom = hFdCngEnc->hFdCngCom; - BSTR_ENC_HANDLE hBstr = st->hBstr; - - Word32 *invTrfMatrix_fx, *E_fx; - Word32 tmpRAM_fx[FDCNG_VQ_MAX_LEN][FDCNG_VQ_DCT_MAXTRUNC]; - Word32 v_fx[32], gain_fx, e_fx, temp; - Word16 w_fx[32], indices[32], exp[32]; - Word32 dct_target_fx[FDCNG_VQ_DCT_MAXTRUNC]; - Word32 tot_sig_ext_fx[FDCNG_VQ_MAX_LEN]; - Word16 v_e, gain_q_offset, preemph_fac; - Word16 i, index; - - gain_q_offset = GAIN_Q_OFFSET_IVAS_FX_Q0; - move16(); - - if ( st->element_mode == EVS_MONO ) - { - gain_q_offset = GAIN_Q_OFFSET_EVS_FX_Q0; - move16(); - } - - preemph_fac = st->preemph_fac; // Q15 - move16(); - - /* Init */ - N = hFdCngEnc->npartDec; - move16(); - - E_fx = hFdCngEnc->msNoiseEst_fx; - - invTrfMatrix_fx = (Word32 *) tmpRAM_fx; /* dynamically filled */ - - set_zero_fx( v_fx, FDCNG_VQ_MAX_LEN ); - - /* Convert to LOG */ - e_fx = 0; - move32(); - FOR( i = 0; i < N; i++ ) - { - IF( E_fx[i] == 0 ) - { - /* 10 * log(1e-4) = 10 * (-4) = -40 */ - v_fx[i] = -41943040; // -40.0 in Q20 - move32(); - } - ELSE - { - v_fx[i] = Mpy_32_32( 671088640 /*10 in Q26*/, BASOP_Util_Log10( E_fx[i], hFdCngEnc->msNoiseEst_fx_exp ) ); // Q20 = 26+25-31 - move32(); - } - e_fx = L_add( e_fx, L_shr( v_fx[i], 1 ) ); // Q19, add one bit headroom - } - - /* Normalize MSVQ input */ - gain_fx = 0; - move32(); - FOR( i = N_GAIN_MIN; i < N_GAIN_MAX; i++ ) - { - gain_fx = L_add( gain_fx, v_fx[i] ); // Q20 - } - - /*gain /= (float) ( N_GAIN_MAX - N_GAIN_MIN );*/ - gain_fx = Mpy_32_32( gain_fx, 165191050 /* 1/13 in Q31*/ ); // Q20 - - FOR( i = 0; i < N; i++ ) - { - v_fx[i] = L_sub( v_fx[i], gain_fx ); // Q20 - move32(); - } - - v_e = 11; // Q20 - move16(); - - /* MSVQ encoder */ - set_val_Word16( w_fx, ONE_IN_Q8, N ); - - IF( st->element_mode != EVS_MONO ) - { - /* DCT domain compressed/truncated indices used for first stage */ - /* quantization with stage1 stored in DCT24 domain, stages 2 through 6 directly dearched - in FDCNG band domain - */ - IF( EQ_16( N, FDCNG_VQ_MAX_LEN_WB ) ) - { - /* truncated DCT21 analysis */ - create_IDCT_N_Matrix_fx( invTrfMatrix_fx, N, FDCNG_VQ_DCT_MAXTRUNC, sizeof( tmpRAM_fx ) / ( sizeof( Word32 ) ) ); // Q31 - - dctT2_N_apply_matrix_fx( v_fx /*Q20*/, dct_target_fx, FDCNG_VQ_DCT_MAXTRUNC, N, invTrfMatrix_fx, FDCNG_VQ_DCT_MAXTRUNC, DCT_T2_21_XX ); // Q20 - - /* truncated IDCT21 extension to 24 bands */ - extend_dctN_input_fx( v_fx, dct_target_fx, N, tot_sig_ext_fx, FDCNG_VQ_MAX_LEN, invTrfMatrix_fx, FDCNG_VQ_DCT_MAXTRUNC, IDCT_T2_XX_21 ); // Q20 - - Copy32( tot_sig_ext_fx, v_fx, FDCNG_VQ_MAX_LEN ); /* write extended result as input to VQ stage #1 */ // Q20 - } - - create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, sizeof( tmpRAM_fx ) / ( sizeof( Word32 ) ) ); // Q31 - - msvq_enc_ivas_fx( ivas_cdk_37bits_fx, Q7, NULL, NULL, v_fx, v_e, levels_37bits, FD_CNG_maxC_37bits, FD_CNG_stages_37bits, w_fx, N, FD_CNG_maxN_37bits, 1, invTrfMatrix_fx, indices ); - - msvq_dec_fx( ivas_cdk_37bits_fx, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 1, invTrfMatrix_fx, v_fx, NULL, 7 ); - - v_e = sub( 31, sub( 20, find_guarded_bits_fx( N ) ) ); - } - ELSE - { /* EVS_MONO tables */ - msvq_enc_ivas_fx( ivas_cdk_37bits_fx, Q7, NULL, NULL, v_fx, v_e, levels_37bits, FD_CNG_maxC_37bits, FD_CNG_stages_37bits, w_fx, N, FD_CNG_maxN_37bits, 0, NULL, indices ); - - msvq_dec_fx( ivas_cdk_37bits_fx, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 0, NULL, v_fx, NULL, 7 ); - - v_e = sub( 31, sub( 20, find_guarded_bits_fx( N ) ) ); - } - - /* Compute gain */ - gain_fx = 0; - move32(); - FOR( i = 0; i < N; i++ ) - { - gain_fx = L_add( gain_fx, v_fx[i] ); // Q = 31 - v_e - } - e_fx = L_shl( e_fx, sub( 12, v_e ) ); // Q = 31 - v_e - gain_fx = Mpy_32_16_1( L_sub( e_fx, gain_fx ), div_s( 1, N ) ); // Q = 31 - v_e - gain_fx = L_shl( gain_fx, sub( v_e, 8 ) ); // Q23 - - /* Apply bitrate-dependant scale */ - IF( st->element_mode > EVS_MONO ) - { - apply_scale( &gain_fx, hFdCngCom->CngBandwidth, hFdCngCom->CngBitrate, scaleTableStereo, SIZE_SCALE_TABLE_STEREO ); - } - ELSE - { - apply_scale( &gain_fx, hFdCngCom->CngBandwidth, hFdCngCom->CngBitrate, scaleTableMono, SIZE_SCALE_TABLE_MONO ); - } - - /* Quantize gain */ - temp = Madd_32_32( L_shl( gain_q_offset, 22 ), gain_fx, 1610612736 /*1.5 in Q30*/ ); // Q22 - index = extract_l( L_shr( L_add( temp, ONE_IN_Q21 ), 22 ) ); // Q0 - - if ( index < 0 ) - { - index = 0; - move16(); - } - - if ( GT_16( index, 127 ) ) - { - index = 127; - move16(); - } - - gain_fx = L_shl( L_mult0( sub( index, gain_q_offset ), 21845 /*1.5 in Q15*/ ), sub( 16, v_e ) ); // Q = 31-v_e - - /* Apply gain and undo log */ - FOR( i = 0; i < N; i++ ) - { - temp = Mpy_32_32( L_add( v_fx[i], gain_fx ), 214748365 /* 0.1 in Q31*/ ); // Q = 31-v_e - hFdCngCom->sidNoiseEst[i] = BASOP_Util_fPow( 10, 31, temp, v_e, &exp[i] ); - move32(); - } - - maximum_s( exp, N, &hFdCngCom->sidNoiseEstExp ); - - FOR( i = 0; i < N; i++ ) - { - hFdCngCom->sidNoiseEst[i] = L_shr( hFdCngCom->sidNoiseEst[i], sub( hFdCngCom->sidNoiseEstExp, exp[i] ) ); // exp = hFdCngCom->sidNoiseEstExp - move32(); - } - - /* NB last band energy compensation */ - IF( hFdCngCom->CngBandwidth == NB ) - { - hFdCngCom->sidNoiseEst[N - 1] = Mpy_32_16_1( hFdCngCom->sidNoiseEst[N - 1], NB_LAST_BAND_SCALE ); // exp(hFdCngCom->sidNoiseEstExp) - move32(); - } - - test(); - IF( EQ_16( hFdCngCom->CngBandwidth, SWB ) && LE_32( hFdCngCom->CngBitrate, ACELP_13k20 ) ) - { - hFdCngCom->sidNoiseEst[N - 1] = Mpy_32_16_1( hFdCngCom->sidNoiseEst[N - 1], SWB_13k2_LAST_BAND_SCALE ); // exp(hFdCngCom->sidNoiseEstExp) - move32(); - } - - /* Write bitstream */ - IF( EQ_16( st->codec_mode, MODE2 ) ) - { - FOR( i = 0; i < FD_CNG_stages_37bits; i++ ) - { - push_next_indice( hBstr, indices[i], bits_37bits[i] ); - } - - push_next_indice( hBstr, index, 7 ); - } - ELSE - { - Word16 is_frame_len_16k = 0; - move16(); - if ( EQ_16( st->L_frame, L_FRAME16k ) ) - { - is_frame_len_16k = 1; - move16(); - } - push_indice( hBstr, IND_SID_TYPE, 1, 1 ); - push_indice( hBstr, IND_BWIDTH, st->bwidth, 2 ); - push_indice( hBstr, IND_ACELP_16KHZ, is_frame_len_16k, 1 ); - - FOR( i = 0; i < FD_CNG_stages_37bits; i++ ) - { - push_indice( hBstr, IND_LSF, indices[i], bits_37bits[i] ); - } - - push_indice( hBstr, IND_ENERGY, index, 7 ); - } - - /* Interpolate the bin/band-wise levels from the partition levels */ - scalebands( hFdCngCom->sidNoiseEst, hFdCngEnc->partDec, hFdCngEnc->npartDec, hFdCngEnc->midbandDec, hFdCngEnc->nFFTpartDec, sub( hFdCngEnc->stopBandDec, hFdCngEnc->startBandDec ), hFdCngCom->cngNoiseLevel, 1 ); - hFdCngCom->cngNoiseLevelExp = hFdCngCom->sidNoiseEstExp; - move16(); - - lpc_from_spectrum( hFdCngCom, hFdCngEnc->startBandDec, hFdCngEnc->stopFFTbinDec, preemph_fac ); - - return; -} -#endif /*FIX_2489_HARMONIZE_FdCng_encodeSID*/ /*-------------------------------------------------------------------* diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index cb86ecd56..d59870610 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -1502,16 +1502,8 @@ void CNG_enc_fx( Word16 *sid_bw ); /* Generate a bitstream out of the partition levels */ -#ifdef FIX_2489_HARMONIZE_FdCng_encodeSID void FdCng_encodeSID_fx( Encoder_State *corest ); -#else -void FdCng_encodeSID_fx( - HANDLE_FD_CNG_ENC st, /* i/o: FD_CNG structure containing all buffers and variables */ - Encoder_State *corest, - Word16 preemph_fac /* i : preemphase factor */ -); -#endif /* Generate the comfort noise based on the target noise level */ void generate_comfort_noise_enc_fx( @@ -1658,11 +1650,6 @@ Word16 AdjustFirstSID_fx( Encoder_State *stcod /* i : pointer to Coder_State_Plus structure */ ); -#ifndef FIX_2489_HARMONIZE_FdCng_encodeSID -void FdCng_encodeSID_ivas_fx( - Encoder_State *st /* i/o: encoder state structure */ -); -#endif void resetFdCngEnc_fx( Encoder_State *st ); -- GitLab From 0ea98b95a107819bab2f1d343d65072363ceed68 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 13 Apr 2026 16:52:13 +0200 Subject: [PATCH 11/22] [cleanup] accept FIX_BASOP_2469_OBJ_EDIT_TD_REND_GAIN --- lib_com/options.h | 1 - lib_rend/ivas_objectRenderer_fx.c | 4 --- lib_rend/ivas_objectRenderer_mix_fx.c | 5 --- lib_rend/ivas_objectRenderer_sfx_fx.c | 29 ---------------- lib_rend/ivas_objectRenderer_sources_fx.c | 41 ----------------------- lib_rend/ivas_prot_rend_fx.h | 9 ----- lib_rend/ivas_stat_rend.h | 15 --------- 7 files changed, 104 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 9fd631c1d..0e1798de7 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -101,7 +101,6 @@ /* #################### Start NON-BE switches ############################ */ /* any switch which is non-be wrt. TS 26.251 V3.0 */ -#define FIX_BASOP_2469_OBJ_EDIT_TD_REND_GAIN /* Eri: Basop issue 2469: TD renderer gain has wrong Q and does not support the object editing gain range */ #define FIX_BASOP_2486_HQ_FINE_GAIN_ALIGNMENT /* Eri: Basop issue 2486: IVAS BASOP used calculations with truncation, EVS BASOP used rounding. This aligns the use of a table lookup. */ #define FIX_1543_MID_LSF_BITS /* VA: float issue 1543: Resolve "MSAN: use-of-uninitialized-value in lib_enc/lsf_enc.c:262:5 for EVS encoder" */ #define FIX_2488_PREVENT_NEG_PITCH /* VA: Fix for 2488, use saturation to prevent possible wrap-around, thus negative pitch values */ diff --git a/lib_rend/ivas_objectRenderer_fx.c b/lib_rend/ivas_objectRenderer_fx.c index 19e0d450a..8255fe0b7 100644 --- a/lib_rend/ivas_objectRenderer_fx.c +++ b/lib_rend/ivas_objectRenderer_fx.c @@ -665,11 +665,7 @@ ivas_error TDREND_Update_object_positions_fx( { return error; } -#ifdef FIX_BASOP_2469_OBJ_EDIT_TD_REND_GAIN if ( ( error = TDREND_MIX_SRC_SetGain( hBinRendererTd, nS, hIsmMetaData[nS]->gain_fx ) ) != IVAS_ERR_OK ) -#else - if ( ( error = TDREND_MIX_SRC_SetGain( hBinRendererTd, nS, hIsmMetaData[nS]->gain_fx ) ) != IVAS_ERR_OK ) // TODO: Check Gain has correct Q-value -#endif { return error; } diff --git a/lib_rend/ivas_objectRenderer_mix_fx.c b/lib_rend/ivas_objectRenderer_mix_fx.c index 3d7e42a7e..598308fd4 100644 --- a/lib_rend/ivas_objectRenderer_mix_fx.c +++ b/lib_rend/ivas_objectRenderer_mix_fx.c @@ -177,13 +177,8 @@ ivas_error TDREND_MIX_Init_fx( ) { ivas_error error; -#ifdef FIX_BASOP_2469_OBJ_EDIT_TD_REND_GAIN hBinRendererTd->Gain_fx = ONE_IN_Q29; move32(); -#else - hBinRendererTd->Gain_fx = ONE_IN_Q14; - move16(); -#endif /* Init source list */ /* Spatial settings */ diff --git a/lib_rend/ivas_objectRenderer_sfx_fx.c b/lib_rend/ivas_objectRenderer_sfx_fx.c index 3649d9c98..d83c1912b 100644 --- a/lib_rend/ivas_objectRenderer_sfx_fx.c +++ b/lib_rend/ivas_objectRenderer_sfx_fx.c @@ -278,13 +278,8 @@ void TDREND_firfilt_fx( Word32 *mem_fx, /* i/o: filter memory Qx */ const Word16 subframe_length, /* i : Length of signal Q0 */ const Word16 filterlength, /* i : Filter length Q0 */ -#ifdef FIX_BASOP_2469_OBJ_EDIT_TD_REND_GAIN const Word32 Gain_fx, /* i : Gain Q29 */ const Word32 prevGain_fx /* i : Previous gain Q29 */ -#else - const Word32 Gain_fx, /* i : Gain Q30 */ - const Word32 prevGain_fx /* i : Previous gain Q30 */ -#endif ) { @@ -295,30 +290,16 @@ void TDREND_firfilt_fx( Word32 *p_filter_fx; // exp(filter_e) Word16 i, j; Word32 tmp_fx; -#ifdef FIX_BASOP_2469_OBJ_EDIT_TD_REND_GAIN Word32 step_fx /* Q29 */, gain_tmp_fx /* Q29 */, gain_delta_fx /* Q29 */; -#else - Word32 step_fx /* Q31 */, gain_tmp_fx /* Q31 */, gain_delta_fx /* Q30 */; -#endif Word16 tmp_e; Word64 tmp64_fx; Word16 shift = sub( filter_e, 32 ); -#ifdef FIX_BASOP_2469_OBJ_EDIT_TD_REND_GAIN gain_delta_fx = L_sub( Gain_fx, prevGain_fx ); // Q29 -#else - gain_delta_fx = L_sub( Gain_fx, prevGain_fx ); // Q30 -#endif step_fx = L_deposit_h( BASOP_Util_Divide3232_Scale( gain_delta_fx, subframe_length, &tmp_e ) ); // exp(tmp_e) -#ifdef FIX_BASOP_2469_OBJ_EDIT_TD_REND_GAIN tmp_e = sub( tmp_e, Q31 ); step_fx = L_shl_sat( step_fx, tmp_e ); // Q29 gain_tmp_fx = prevGain_fx; // Q29 move32(); -#else - tmp_e = sub( tmp_e, Q30 ); - step_fx = L_shl_sat( step_fx, tmp_e ); // Q31 - gain_tmp_fx = L_shl_sat( prevGain_fx, 1 ); // Q31 -#endif /* Handle memory */ p_signal_fx = buffer_fx + sub( filterlength, 1 ); // Qx @@ -346,13 +327,8 @@ void TDREND_firfilt_fx( tmp_fx = W_shl_sat_l( tmp64_fx, shift ); // Qx /* Apply linear gain interpolation in case of abrupt gain changes */ -#ifdef FIX_BASOP_2469_OBJ_EDIT_TD_REND_GAIN gain_tmp_fx = L_add_sat( gain_tmp_fx, step_fx ); /* Saturating values which just exceeds 4, Q29*/ signal_fx[i] = L_shl( Mpy_32_32( tmp_fx, gain_tmp_fx ), 2 ); // Qx -#else - gain_tmp_fx = L_add_sat( gain_tmp_fx, step_fx ); /* Saturating values which just exceeds 1, Q31*/ - signal_fx[i] = Mpy_32_32( tmp_fx, gain_tmp_fx ); // Qx -#endif move32(); v_add_fx( filter_fx, filter_delta_fx, filter_fx, filterlength ); // exp(filter_e) } @@ -375,13 +351,8 @@ void TDREND_firfilt_fx( tmp_fx = W_shl_sat_l( tmp64_fx, shift ); // Qx /* Apply linear gain interpolation in case of abrupt gain changes */ -#ifdef FIX_BASOP_2469_OBJ_EDIT_TD_REND_GAIN gain_tmp_fx = L_add_sat( gain_tmp_fx, step_fx ); /* Saturating values which just exceeds 4, Q29*/ signal_fx[i] = L_shl( Mpy_32_32( tmp_fx, gain_tmp_fx ), 2 ); // Qx -#else - gain_tmp_fx = L_add_sat( gain_tmp_fx, step_fx ); /* Saturating values which just exceeds 1, Q31*/ - signal_fx[i] = Mpy_32_32( tmp_fx, gain_tmp_fx ); // Qx -#endif move32(); } diff --git a/lib_rend/ivas_objectRenderer_sources_fx.c b/lib_rend/ivas_objectRenderer_sources_fx.c index 7a278a8bb..fe28fe4ea 100644 --- a/lib_rend/ivas_objectRenderer_sources_fx.c +++ b/lib_rend/ivas_objectRenderer_sources_fx.c @@ -139,11 +139,7 @@ ivas_error TDREND_MIX_SRC_SetDir_fx( ivas_error TDREND_MIX_SRC_SetGain( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ const Word16 SrcInd, /* i : Source index */ -#ifdef FIX_BASOP_2469_OBJ_EDIT_TD_REND_GAIN const Word32 Gain /* i : Gain Q29 */ -#else - const Word32 Gain /* i : Gain */ -#endif ) { TDREND_SRC_SPATIAL_SetGain( hBinRendererTd->Sources[SrcInd], Gain ); @@ -274,17 +270,8 @@ static void TDREND_SRC_REND_Init_fx( /* SrcGain */ FOR( nC = 0; nC < SPAT_BIN_MAX_INPUT_CHANNELS; nC++ ) { -#ifdef FIX_BASOP_2469_OBJ_EDIT_TD_REND_GAIN SrcRend_p->SrcGain_p_fx[nC] = ONE_IN_Q29; /* Q29 */ move32(); -#else - SrcRend_p->SrcGainMin_p_fx[nC] = 0; /* Q15 */ - move16(); - SrcRend_p->SrcGain_p_fx[nC] = ONE_IN_Q14; // Q14 - move16(); - SrcRend_p->SrcGainMax_p_fx[nC] = 32767; // TODO: make it 2, this is one in Q15, i thinki, need to change Q for that - move16(); -#endif } SrcRend_p->SrcGainUpdated = FALSE; move16(); @@ -321,11 +308,7 @@ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams_fx( Word16 *intp_count, /* o : Interpolation count Q0 */ Word16 *filterlength, /* o : Length of filters Q0 */ Word16 *itd, /* o : ITD value Q0 */ -#ifdef FIX_BASOP_2469_OBJ_EDIT_TD_REND_GAIN Word32 *Gain, /* o : Gain value Q29 */ -#else - Word32 *Gain, /* o : Gain value Q30 */ -#endif TDREND_SRC_t *Src_p /* i/o: Source pointer */ ) { @@ -416,16 +399,12 @@ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams_fx( } /* Update total gains */ -#ifdef FIX_BASOP_2469_OBJ_EDIT_TD_REND_GAIN { Word32 tmp1, tmp2; tmp1 = L_shl( Mpy_32_16( extract_h( *SrcRend_p->SrcGain_p_fx ), extract_l( *SrcRend_p->SrcGain_p_fx ), *SrcRend_p->DirGain_p_fx ), 1 ); /* Q29 */ tmp2 = L_shl( Mpy_32_16( extract_h( hBinRendererTd->Gain_fx ), extract_l( hBinRendererTd->Gain_fx ), *SrcRend_p->DistGain_p_fx ), 1 ); /* Q29 */ *Gain = L_shl( Mpy_32_32( tmp1, tmp2 ), 2 ); /* Q29 */ } -#else - *Gain = L_shl( Mpy_32_32( L_shl( L_mult( *SrcRend_p->SrcGain_p_fx, *SrcRend_p->DirGain_p_fx ), 1 ), L_shl( L_mult( *SrcRend_p->DistGain_p_fx, hBinRendererTd->Gain_fx ), 1 ) ), 1 ); // Q30 -#endif move32(); /* Delta for interpolation, in case the angular step exceeds MAX_ANGULAR_STEP=0.01f */ @@ -475,11 +454,7 @@ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams_fx( { *itd = 0; // Q0 move16(); -#ifdef FIX_BASOP_2469_OBJ_EDIT_TD_REND_GAIN *Gain = ONE_IN_Q29; /* Q29 */ -#else - *Gain = ONE_IN_Q30; // Q30 -#endif move32(); set32_fx( hrf_left, 0, *filterlength ); set32_fx( hrf_right, 0, *filterlength ); @@ -718,21 +693,12 @@ static void TDREND_SRC_SPATIAL_SetDistAtten( --------------------------------------------------------------------*/ static void TDREND_SRC_SPATIAL_SetGain( -#ifdef FIX_BASOP_2469_OBJ_EDIT_TD_REND_GAIN const TDREND_SRC_t *Src_p, /* i : Source */ const Word32 Gain /* i : Gain Q29 */ -#else - const TDREND_SRC_t *Src_p, /* i : Directional attenuation specification */ - const Word32 Gain /* i : Front-pointing vector */ -#endif ) { -#ifdef FIX_BASOP_2469_OBJ_EDIT_TD_REND_GAIN Src_p->SrcRend_p->SrcGain_p_fx[0] = Gain; /* Q29 */ move32(); -#else - Src_p->SrcRend_p->SrcGain_p_fx[0] = shl_sat( extract_h( Gain ), Q1 ); // TODO: Check incoming Q-value and fix this -#endif return; } @@ -1014,17 +980,10 @@ void TDREND_SRC_Init_fx( move32(); Src_p->elev_prev_fx = 0; // Q22 move32(); -#ifdef FIX_BASOP_2469_OBJ_EDIT_TD_REND_GAIN Src_p->Gain_fx = ONE_IN_Q29; // Q29 move32(); Src_p->prevGain_fx = ONE_IN_Q29; // Q29 move32(); -#else - Src_p->Gain_fx = ONE_IN_Q30; // Q30 - move32(); - Src_p->prevGain_fx = ONE_IN_Q30; // Q30 - move32(); -#endif return; } diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index 017d66237..ff893ac37 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -817,11 +817,7 @@ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams_fx( Word16 *intp_count, /* o : Interpolation count */ Word16 *filterlength, /* o : Length of filters */ Word16 *itd, /* o : ITD value */ -#ifdef FIX_BASOP_2469_OBJ_EDIT_TD_REND_GAIN Word32 *Gain, /* o : Gain value Q29 */ -#else - Word32 *Gain, /* o : Gain value Q30 */ -#endif TDREND_SRC_t *Src_p /* i/o: Source pointer */ ); @@ -901,13 +897,8 @@ void TDREND_firfilt_fx( Word32 *mem_fx, /* i/o: filter memory Qx */ const Word16 subframe_length, /* i : Length of signal */ const Word16 filterlength, /* i : Filter length */ -#ifdef FIX_BASOP_2469_OBJ_EDIT_TD_REND_GAIN const Word32 Gain_fx, /* i : Gain Q29 */ const Word32 prevGain_fx /* i : Previous gain Q29 */ -#else - const Word32 Gain_fx, /* i : Gain Q30 */ - const Word32 prevGain_fx /* i : Previous gain Q30 */ -#endif ); diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index ea5fbcd4e..f19f12c98 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1208,13 +1208,7 @@ typedef struct TDREND_SRC_REND_s /* Gains */ Word16 SrcGainUpdated; -#ifdef FIX_BASOP_2469_OBJ_EDIT_TD_REND_GAIN Word32 SrcGain_p_fx[SPAT_BIN_MAX_INPUT_CHANNELS]; /* Q29 */ -#else - Word16 SrcGain_p_fx[SPAT_BIN_MAX_INPUT_CHANNELS]; // Q14 - Word16 SrcGainMin_p_fx[SPAT_BIN_MAX_INPUT_CHANNELS]; - Word16 SrcGainMax_p_fx[SPAT_BIN_MAX_INPUT_CHANNELS]; -#endif Word16 DirGain_p_fx[SPAT_BIN_MAX_INPUT_CHANNELS]; // Q14 Word16 DistGain_p_fx[SPAT_BIN_MAX_INPUT_CHANNELS]; // Q14 } TDREND_SRC_REND_t; @@ -1251,13 +1245,8 @@ typedef struct Word16 hrf_right_prev_e; Word32 azim_prev_fx; Word32 elev_prev_fx; -#ifdef FIX_BASOP_2469_OBJ_EDIT_TD_REND_GAIN Word32 Gain_fx; // Q29 Word32 prevGain_fx; // Q29 -#else - Word32 Gain_fx; // Q30 - Word32 prevGain_fx; // Q30 -#endif } TDREND_SRC_t; @@ -1270,11 +1259,7 @@ typedef struct ivas_binaural_td_rendering_struct Word16 MaxSrcInd; TDREND_SRC_t *Sources[MAX_NUM_TDREND_CHANNELS]; -#ifdef FIX_BASOP_2469_OBJ_EDIT_TD_REND_GAIN Word32 Gain_fx; /* Q29 */ -#else - Word16 Gain_fx; /* Q14 */ -#endif TDREND_MIX_Listener_t *Listener_p; /* The virtual listener */ TDREND_HRFILT_FiltSet_t *HrFiltSet_p; /* HR filter set */ -- GitLab From 0c5722647302e55e5ad42d0d3b45656c5cf3a82b Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 13 Apr 2026 16:53:26 +0200 Subject: [PATCH 12/22] [cleanup] accept FIX_1543_MID_LSF_BITS --- lib_com/options.h | 1 - lib_enc/acelp_core_enc_fx.c | 2 -- 2 files changed, 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 0e1798de7..ae9348965 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -102,7 +102,6 @@ /* any switch which is non-be wrt. TS 26.251 V3.0 */ #define FIX_BASOP_2486_HQ_FINE_GAIN_ALIGNMENT /* Eri: Basop issue 2486: IVAS BASOP used calculations with truncation, EVS BASOP used rounding. This aligns the use of a table lookup. */ -#define FIX_1543_MID_LSF_BITS /* VA: float issue 1543: Resolve "MSAN: use-of-uninitialized-value in lib_enc/lsf_enc.c:262:5 for EVS encoder" */ #define FIX_2488_PREVENT_NEG_PITCH /* VA: Fix for 2488, use saturation to prevent possible wrap-around, thus negative pitch values */ #define FIX_1547_ISMDTX_HANDLE /* VA: float issue 1547: fix use of 'hISMDTX' handle */ #define FIX_1540_EXPOSE_PT_IN_RTP_HEADER_API /* Expose Payload Type setting in RTP Header */ diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 9b1257104..964f90f78 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -549,10 +549,8 @@ ivas_error acelp_core_enc_fx( move16(); uc_two_stage_flag = 0; move16(); -#ifdef FIX_1543_MID_LSF_BITS st->acelp_cfg.mid_lsf_bits = -1; move16(); -#endif test(); IF( !nelp_mode && !ppp_mode ) -- GitLab From 15245dfa79561bf88f82bb6d22dc559f33b9e84a Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 13 Apr 2026 16:55:36 +0200 Subject: [PATCH 13/22] [cleanup] accept FIX_2488_PREVENT_NEG_PITCH --- lib_com/options.h | 1 - lib_enc/ivas_mdct_core_enc_fx.c | 4 ---- 2 files changed, 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index ae9348965..99e4af8f0 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -102,7 +102,6 @@ /* any switch which is non-be wrt. TS 26.251 V3.0 */ #define FIX_BASOP_2486_HQ_FINE_GAIN_ALIGNMENT /* Eri: Basop issue 2486: IVAS BASOP used calculations with truncation, EVS BASOP used rounding. This aligns the use of a table lookup. */ -#define FIX_2488_PREVENT_NEG_PITCH /* VA: Fix for 2488, use saturation to prevent possible wrap-around, thus negative pitch values */ #define FIX_1547_ISMDTX_HANDLE /* VA: float issue 1547: fix use of 'hISMDTX' handle */ #define FIX_1540_EXPOSE_PT_IN_RTP_HEADER_API /* Expose Payload Type setting in RTP Header */ #define FIX_BASOP_2491_MDCT_JBM_CLICK /* FhG: BASOP #2491: Fix Q_synth after TCX concealment (using ACELP concealment) */ diff --git a/lib_enc/ivas_mdct_core_enc_fx.c b/lib_enc/ivas_mdct_core_enc_fx.c index dbc1d327b..99ff751e4 100644 --- a/lib_enc/ivas_mdct_core_enc_fx.c +++ b/lib_enc/ivas_mdct_core_enc_fx.c @@ -2483,11 +2483,7 @@ void ivas_mdct_core_whitening_enc_fx( } IF( param_core[ch][1 + NOISE_FILL_RANGES] != 0 ) { -#ifdef FIX_2488_PREVENT_NEG_PITCH set16_fx( pitch_buf_fx[ch], extract_h( L_shl_sat( Mult_32_32( L_add( L_deposit_h( st->hTcxEnc->tcxltp_pitch_int ), L_mult( st->hTcxEnc->tcxltp_pitch_fr, div_s( 1, st->pit_res_max ) ) ), Mult_32_32( L_shl( st->sr_core, Q10 ), ONE_BY_INT_FS_12k8_Q42 ) ), 16 ) ), NB_SUBFR16k ); -#else - set16_fx( pitch_buf_fx[ch], extract_l( Mult_32_32( L_add( L_deposit_h( st->hTcxEnc->tcxltp_pitch_int ), L_mult( st->hTcxEnc->tcxltp_pitch_fr, div_s( 1, st->pit_res_max ) ) ), Mult_32_32( L_shl( st->sr_core, Q10 ), ONE_BY_INT_FS_12k8_Q42 ) ) ), NB_SUBFR16k ); -#endif } ELSE { -- GitLab From 9d92bd14be0e98eb5e724df1f904a6b45b3eb41f Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 13 Apr 2026 16:56:41 +0200 Subject: [PATCH 14/22] [cleanup] accept FIX_1547_ISMDTX_HANDLE --- lib_com/ivas_prot_fx.h | 4 ---- lib_com/options.h | 1 - lib_dec/ivas_dec_fx.c | 8 -------- lib_dec/ivas_ism_metadata_dec_fx.c | 13 ------------- lib_dec/ivas_ism_param_dec_fx.c | 21 --------------------- lib_dec/ivas_omasa_dec_fx.c | 6 ------ lib_dec/ivas_osba_dec_fx.c | 6 ------ 7 files changed, 59 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 4588c8d41..4d150afb3 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -743,11 +743,7 @@ ivas_error ivas_ism_metadata_dec_fx( const Word16 bfi, /* i : bfi flag */ Word16 nb_bits_metadata[], /* o : number of metadata bits */ ISM_MODE ism_mode, /* i : ISM mode */ -#ifdef FIX_1547_ISMDTX_HANDLE ISM_DTX_DATA_DEC *hISMDTX, /* i/o: ISM DTX handle */ -#else - ISM_DTX_DATA_DEC hISMDTX, /* i/o: ISM DTX structure */ -#endif const PARAM_ISM_CONFIG_HANDLE hParamIsm, /* i : Param ISM Config Handle */ Word16 *ism_extmeta_active, /* i/o: Extended metadata active in renderer */ Word16 *ism_extmeta_cnt, /* i/o: Number of change frames observed */ diff --git a/lib_com/options.h b/lib_com/options.h index 99e4af8f0..37bf9c97e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -102,7 +102,6 @@ /* any switch which is non-be wrt. TS 26.251 V3.0 */ #define FIX_BASOP_2486_HQ_FINE_GAIN_ALIGNMENT /* Eri: Basop issue 2486: IVAS BASOP used calculations with truncation, EVS BASOP used rounding. This aligns the use of a table lookup. */ -#define FIX_1547_ISMDTX_HANDLE /* VA: float issue 1547: fix use of 'hISMDTX' handle */ #define FIX_1540_EXPOSE_PT_IN_RTP_HEADER_API /* Expose Payload Type setting in RTP Header */ #define FIX_BASOP_2491_MDCT_JBM_CLICK /* FhG: BASOP #2491: Fix Q_synth after TCX concealment (using ACELP concealment) */ #define FIX_1563_FIX_STEREO_SW /* VA: float issue 1563: fix clicks in stereo switching */ diff --git a/lib_dec/ivas_dec_fx.c b/lib_dec/ivas_dec_fx.c index 4cb4ad146..8113f437a 100644 --- a/lib_dec/ivas_dec_fx.c +++ b/lib_dec/ivas_dec_fx.c @@ -129,11 +129,7 @@ ivas_error ivas_dec_fx( } ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) ) { -#ifdef FIX_1547_ISMDTX_HANDLE IF( NE_32( ( error = ivas_ism_metadata_dec_fx( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, &( st_ivas->hISMDTX ), st_ivas->hParamIsmDec->hParamIsm, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, st_ivas->hSCE[0]->hCoreCoder[0] ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = ivas_ism_metadata_dec_fx( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, st_ivas->hParamIsmDec->hParamIsm, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, st_ivas->hSCE[0]->hCoreCoder[0] ) ), IVAS_ERR_OK ) ) -#endif { return error; } @@ -142,11 +138,7 @@ ivas_error ivas_dec_fx( } ELSE /* ISM_MODE_DISC */ { -#ifdef FIX_1547_ISMDTX_HANDLE IF( NE_32( ( error = ivas_ism_metadata_dec_fx( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, &( st_ivas->hISMDTX ), NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, st_ivas->hSCE[0]->hCoreCoder[0] ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = ivas_ism_metadata_dec_fx( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, st_ivas->hSCE[0]->hCoreCoder[0] ) ), IVAS_ERR_OK ) ) -#endif { return error; } diff --git a/lib_dec/ivas_ism_metadata_dec_fx.c b/lib_dec/ivas_ism_metadata_dec_fx.c index 53d7c4a6d..535207a63 100644 --- a/lib_dec/ivas_ism_metadata_dec_fx.c +++ b/lib_dec/ivas_ism_metadata_dec_fx.c @@ -168,11 +168,7 @@ ivas_error ivas_ism_metadata_dec_fx( const Word16 bfi, /* i : bfi flag */ Word16 nb_bits_metadata[], /* o : number of metadata bits */ ISM_MODE ism_mode, /* i : ISM mode */ -#ifdef FIX_1547_ISMDTX_HANDLE ISM_DTX_DATA_DEC *hISMDTX, /* i/o: ISM DTX handle */ -#else - ISM_DTX_DATA_DEC hISMDTX, /* i/o: ISM DTX structure */ -#endif const PARAM_ISM_CONFIG_HANDLE hParamIsm, /* i : Param ISM Config Handle */ Word16 *ism_extmeta_active, /* i/o: Extended metadata active in renderer */ Word16 *ism_extmeta_cnt, /* i/o: Number of change frames observed */ @@ -640,21 +636,12 @@ ivas_error ivas_ism_metadata_dec_fx( } } -#ifdef FIX_1547_ISMDTX_HANDLE IF( LT_16( hISMDTX->ism_dtx_hangover_cnt, IVAS_ISM_DTX_HO_MAX ) ) { ism_metadata_smooth_fx( hIsmMeta, ism_total_brate, nchan_ism ); hISMDTX->ism_dtx_hangover_cnt = add( hISMDTX->ism_dtx_hangover_cnt, 1 ); move16(); } -#else - IF( LT_16( hISMDTX.ism_dtx_hangover_cnt, IVAS_ISM_DTX_HO_MAX ) ) - { - ism_metadata_smooth_fx( hIsmMeta, ism_total_brate, nchan_ism ); - hISMDTX.ism_dtx_hangover_cnt = add( hISMDTX.ism_dtx_hangover_cnt, 1 ); - move16(); - } -#endif IF( EQ_32( ism_mode, ISM_SBA_MODE_DISC ) ) { diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index c9d241616..e3a4cbf35 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -224,11 +224,7 @@ static void ivas_param_ism_collect_slot_fx( static void ivas_param_ism_compute_mixing_matrix_fx( const Word16 nchan_ism, /* i : number of ISM channels */ PARAM_ISM_DEC_HANDLE hParamIsmDec, /* i/o: decoder ParamISM handle */ -#ifdef FIX_1547_ISMDTX_HANDLE const ISM_DTX_DATA_DEC *hISMDTX, /* i : ISM DTX handle */ -#else - ISM_DTX_DATA_DEC hISMDTX, /* i : ISM DTX handle */ -#endif Word32 direct_response_fx[MAX_NUM_OBJECTS][PARAM_ISM_MAX_CHAN], // Q30 const Word16 nchan_transport, const Word16 nchan_out_woLFE, @@ -255,11 +251,7 @@ static void ivas_param_ism_compute_mixing_matrix_fx( assert( nchan_transport == 2 ); test(); -#ifdef FIX_1547_ISMDTX_HANDLE IF( hParamIsmDec->hParamIsm->flag_noisy_speech || hISMDTX->dtx_flag ) -#else - IF( hParamIsmDec->hParamIsm->flag_noisy_speech || hISMDTX.dtx_flag ) -#endif { num_wave = nchan_ism; move16(); @@ -286,11 +278,7 @@ static void ivas_param_ism_compute_mixing_matrix_fx( { set32_fx( cy_diag_tmp_fx[w], 0, nchan_out_woLFE ); test(); -#ifdef FIX_1547_ISMDTX_HANDLE IF( hParamIsmDec->hParamIsm->flag_noisy_speech || hISMDTX->dtx_flag ) -#else - IF( hParamIsmDec->hParamIsm->flag_noisy_speech || hISMDTX.dtx_flag ) -#endif { dir_res_ptr_fx = direct_response_fx[w]; } @@ -338,11 +326,7 @@ static void ivas_param_ism_compute_mixing_matrix_fx( FOR( w = 0; w < num_wave; w++ ) { test(); -#ifdef FIX_1547_ISMDTX_HANDLE IF( hParamIsmDec->hParamIsm->flag_noisy_speech || hISMDTX->dtx_flag ) -#else - IF( hParamIsmDec->hParamIsm->flag_noisy_speech || hISMDTX.dtx_flag ) -#endif { // direct_power[w] = ( 1.0f / nchan_ism ) * ref_power[bin_idx]; SWITCH( nchan_ism ) @@ -1371,13 +1355,8 @@ void ivas_param_ism_dec_prepare_renderer_fx( } /* Compute mixing matrix */ -#ifdef FIX_1547_ISMDTX_HANDLE ivas_param_ism_compute_mixing_matrix_fx( st_ivas->nchan_ism, hParamIsmDec, &( st_ivas->hISMDTX ), direct_response_fx, nchan_transport, nchan_out_woLFE, cx_diag_fx, exp_cx_diag, hParamIsmDec->hParamIsmRendering->mixing_matrix_lin_fx, hParamIsmDec->hParamIsmRendering->exp_mixing_matrix_lin_fx ); -#else - ivas_param_ism_compute_mixing_matrix_fx( st_ivas->nchan_ism, hParamIsmDec, st_ivas->hISMDTX, direct_response_fx, nchan_transport, nchan_out_woLFE, cx_diag_fx, exp_cx_diag, - hParamIsmDec->hParamIsmRendering->mixing_matrix_lin_fx, hParamIsmDec->hParamIsmRendering->exp_mixing_matrix_lin_fx ); -#endif return; } diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index 20505c0a6..49554d356 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -985,15 +985,9 @@ ivas_error ivas_omasa_ism_metadata_dec_fx( IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) || EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) { /* decode ISM metadata */ -#ifdef FIX_1547_ISMDTX_HANDLE IF( NE_32( ( error = ivas_ism_metadata_dec_fx( ism_total_brate, *nchan_ism, nchan_transport_ism, st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, &( st_ivas->hISMDTX ), NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, st_ivas->hSCE[0]->hCoreCoder[0] ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = ivas_ism_metadata_dec_fx( ism_total_brate, *nchan_ism, nchan_transport_ism, st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, - nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, st_ivas->hSCE[0]->hCoreCoder[0] ) ), - IVAS_ERR_OK ) ) -#endif { return error; } diff --git a/lib_dec/ivas_osba_dec_fx.c b/lib_dec/ivas_osba_dec_fx.c index c40914858..66e92c9fd 100644 --- a/lib_dec/ivas_osba_dec_fx.c +++ b/lib_dec/ivas_osba_dec_fx.c @@ -251,15 +251,9 @@ ivas_error ivas_osba_ism_metadata_dec_fx( move16(); /* decode ISM metadata */ -#ifdef FIX_1547_ISMDTX_HANDLE IF( NE_32( ( error = ivas_ism_metadata_dec_fx( ism_total_brate, *nchan_ism, &nchan_transport_ism, st_ivas->hIsmMetaData, NULL, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, &( st_ivas->hISMDTX ), NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, st_ivas->hCPE[0]->hCoreCoder[0] ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = ivas_ism_metadata_dec_fx( ism_total_brate, *nchan_ism, &nchan_transport_ism, st_ivas->hIsmMetaData, NULL, st_ivas->bfi, - nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, st_ivas->hCPE[0]->hCoreCoder[0] ) ), - IVAS_ERR_OK ) ) -#endif { return error; } -- GitLab From 1bb0f9ff20999955844c9dab18be39f25fd2633b Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 13 Apr 2026 16:58:19 +0200 Subject: [PATCH 15/22] [cleanup] accept FIX_BASOP_2491_MDCT_JBM_CLICK --- lib_com/options.h | 1 - lib_dec/er_dec_tcx_fx.c | 15 --------------- lib_dec/ivas_core_dec_fx.c | 4 ---- 3 files changed, 20 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 37bf9c97e..296bec50d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -103,7 +103,6 @@ #define FIX_BASOP_2486_HQ_FINE_GAIN_ALIGNMENT /* Eri: Basop issue 2486: IVAS BASOP used calculations with truncation, EVS BASOP used rounding. This aligns the use of a table lookup. */ #define FIX_1540_EXPOSE_PT_IN_RTP_HEADER_API /* Expose Payload Type setting in RTP Header */ -#define FIX_BASOP_2491_MDCT_JBM_CLICK /* FhG: BASOP #2491: Fix Q_synth after TCX concealment (using ACELP concealment) */ #define FIX_1563_FIX_STEREO_SW /* VA: float issue 1563: fix clicks in stereo switching */ #define FIX_1562_DTX_CRASH_DECODER /* VA: float issue 1562: fix crash in stereo decoding in DTX and bitrate switching */ #define FIX_BASOP_2498_LOGIC_IN_ENC_DTX_DECISION_MTX /* Nokia: BASOP 2498: Fix the logic */ diff --git a/lib_dec/er_dec_tcx_fx.c b/lib_dec/er_dec_tcx_fx.c index 867ecda51..b6f5823c3 100644 --- a/lib_dec/er_dec_tcx_fx.c +++ b/lib_dec/er_dec_tcx_fx.c @@ -941,22 +941,7 @@ void con_tcx_fx( } ELSE { -#ifdef FIX_BASOP_2491_MDCT_JBM_CLICK tmp_deemph = shl_sat( tmp_deemph, Q_syn ); /*Q_syn*/ -#else - IF( NE_16( st->element_mode, EVS_MONO ) ) // to keep evs bit-exactness - { - if ( GT_16( sub( Q_syn, st->Q_syn_factor ), scf ) ) - { - Q_syn = add( scf, st->Q_syn_factor ); // so that (Q_syn - st->Q_syn_factor) = scf; - } - tmp_deemph = shl_sat( tmp_deemph, sub( Q_syn, st->Q_syn_factor ) ); - } - ELSE - { - tmp_deemph = shl_sat( tmp_deemph, Q_syn ); /*Q_syn*/ - } -#endif st->Q_syn_factor = 0; move16(); st->Q_syn = Q_syn; diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index 56e283a3b..06ae20608 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -766,7 +766,6 @@ ivas_error ivas_core_dec_fx( *---------------------------------------------------------------------*/ /*core_switching_post_dec*/ -#ifdef FIX_BASOP_2491_MDCT_JBM_CLICK IF( EQ_16( sts[n]->element_mode, IVAS_CPE_MDCT ) && GT_32( sts[n]->core_brate, SID_2k40 ) ) // In this case, st->Q_syn_factor was already applied earlier in ivas_mdct_core_reconstruct_fx() { Q_synth = sub( 15, e_sig[0] ); @@ -775,9 +774,6 @@ ivas_error ivas_core_dec_fx( { Q_synth = add( sub( 15, e_sig[0] ), st->Q_syn_factor ); } -#else - Q_synth = add( sub( 15, e_sig[0] ), st->Q_syn_factor ); -#endif IF( st->cldfbSyn != NULL ) { -- GitLab From 6c32f1d809463aba8fa4ba13b8f0021a90428b67 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 13 Apr 2026 16:59:44 +0200 Subject: [PATCH 16/22] [cleanup] accept FIX_1563_FIX_STEREO_SW --- lib_com/options.h | 1 - lib_dec/ivas_stereo_switching_dec_fx.c | 2 -- lib_enc/ivas_stereo_switching_enc_fx.c | 7 ------- 3 files changed, 10 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 296bec50d..7c1281a23 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -103,7 +103,6 @@ #define FIX_BASOP_2486_HQ_FINE_GAIN_ALIGNMENT /* Eri: Basop issue 2486: IVAS BASOP used calculations with truncation, EVS BASOP used rounding. This aligns the use of a table lookup. */ #define FIX_1540_EXPOSE_PT_IN_RTP_HEADER_API /* Expose Payload Type setting in RTP Header */ -#define FIX_1563_FIX_STEREO_SW /* VA: float issue 1563: fix clicks in stereo switching */ #define FIX_1562_DTX_CRASH_DECODER /* VA: float issue 1562: fix crash in stereo decoding in DTX and bitrate switching */ #define FIX_BASOP_2498_LOGIC_IN_ENC_DTX_DECISION_MTX /* Nokia: BASOP 2498: Fix the logic */ #define FIX_BASOP_2497_MCMASA_LFE_WRONG_SF_INDEX /* Nokia: BASOP 2497: Fix wrong subframe index in McMASA LFE synth. */ diff --git a/lib_dec/ivas_stereo_switching_dec_fx.c b/lib_dec/ivas_stereo_switching_dec_fx.c index 77b98ff96..59f2223d0 100644 --- a/lib_dec/ivas_stereo_switching_dec_fx.c +++ b/lib_dec/ivas_stereo_switching_dec_fx.c @@ -2009,13 +2009,11 @@ void stereo_switching_dec_fx( Copy( sts[0]->hTcxDec->old_syn_Overl, sts[1]->hTcxDec->old_syn_Overl, 256 ); /* Q_old_syn_Overl*/ sts[1]->hTcxDec->Q_old_syn_Overl = sts[0]->hTcxDec->Q_old_syn_Overl; } -#ifdef FIX_1563_FIX_STEREO_SW ELSE IF( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) ) { sts[1]->last_core = ACELP_CORE; move16(); } -#endif } ELSE IF( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) && EQ_16( hCPE->last_element_mode, IVAS_CPE_MDCT ) ) { diff --git a/lib_enc/ivas_stereo_switching_enc_fx.c b/lib_enc/ivas_stereo_switching_enc_fx.c index 085fe9c8f..6eb239f1e 100644 --- a/lib_enc/ivas_stereo_switching_enc_fx.c +++ b/lib_enc/ivas_stereo_switching_enc_fx.c @@ -520,14 +520,9 @@ ivas_error stereo_memory_enc_fx( st->hTcxEnc->spectrum_e[0] = st->hTcxEnc->spectrum_e[1] = 0; move16(); move16(); -#ifdef FIX_1563_FIX_STEREO_SW set16_fx( st->hTcxEnc->old_out_fx, 0, L_FRAME32k ); st->hTcxEnc->Q_old_out = 0; move16(); -#else - // set_f( st->hTcxEnc->old_out, 0, L_FRAME32k ); - // set_f( st->hTcxEnc->spectrum_long, 0, N_MAX ); -#endif set32_fx( st->hTcxEnc->spectrum_long_fx, 0, N_MAX ); st->hTcxEnc->spectrum_long_e = 0; st->hTcxEnc->tfm_mem_fx = 1610612736; /* 0.75 in Q31 */ @@ -988,13 +983,11 @@ void stereo_switching_enc_fx( sts[1]->last_bwidth = sts[0]->last_bwidth; /* Q0 */ move16(); } -#ifdef FIX_1563_FIX_STEREO_SW ELSE IF( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) ) { sts[1]->last_core = ACELP_CORE; move16(); } -#endif } ELSE IF( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) && EQ_16( hCPE->last_element_mode, IVAS_CPE_MDCT ) ) { -- GitLab From 97f0c43b8f4458cbaf63d0c9974f74ca5cdb4de1 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 13 Apr 2026 17:00:44 +0200 Subject: [PATCH 17/22] [cleanup] accept FIX_1562_DTX_CRASH_DECODER --- lib_com/options.h | 1 - lib_dec/acelp_core_dec_fx.c | 4 ---- 2 files changed, 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 7c1281a23..131baf364 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -103,7 +103,6 @@ #define FIX_BASOP_2486_HQ_FINE_GAIN_ALIGNMENT /* Eri: Basop issue 2486: IVAS BASOP used calculations with truncation, EVS BASOP used rounding. This aligns the use of a table lookup. */ #define FIX_1540_EXPOSE_PT_IN_RTP_HEADER_API /* Expose Payload Type setting in RTP Header */ -#define FIX_1562_DTX_CRASH_DECODER /* VA: float issue 1562: fix crash in stereo decoding in DTX and bitrate switching */ #define FIX_BASOP_2498_LOGIC_IN_ENC_DTX_DECISION_MTX /* Nokia: BASOP 2498: Fix the logic */ #define FIX_BASOP_2497_MCMASA_LFE_WRONG_SF_INDEX /* Nokia: BASOP 2497: Fix wrong subframe index in McMASA LFE synth. */ #define FIX_BASOP_2496_OMASA_OBJ_EDIT_WRONG_ASSIGN /* Nokia: BASOP 2496: Fix wrong assignment in OMASA object edit code */ diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 48101e1aa..5fe8407e5 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -412,12 +412,8 @@ ivas_error acelp_core_dec_fx( { Word16 dec; -#ifdef FIX_1562_DTX_CRASH_DECODER test(); IF( st->hPFstat != NULL && st->hPFstat->on != 0 ) -#else - IF( ( st->hPFstat->on != 0 ) ) -#endif { Word16 mem_syn_r_size_old, mem_syn_r_size_new; mem_syn_r_size_old = mult_r( 2048, st->last_L_frame ); /* 1.25/20.f = 2048 (Q15)*/ -- GitLab From 9b1f969eff7c5c44f0d25204e42c4f54554d2cce Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 13 Apr 2026 17:01:28 +0200 Subject: [PATCH 18/22] [cleanup] accept FIX_BASOP_2498_LOGIC_IN_ENC_DTX_DECISION_MTX --- lib_com/options.h | 1 - lib_enc/ivas_decision_matrix_enc_fx.c | 4 ---- 2 files changed, 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 131baf364..546f522dc 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -103,7 +103,6 @@ #define FIX_BASOP_2486_HQ_FINE_GAIN_ALIGNMENT /* Eri: Basop issue 2486: IVAS BASOP used calculations with truncation, EVS BASOP used rounding. This aligns the use of a table lookup. */ #define FIX_1540_EXPOSE_PT_IN_RTP_HEADER_API /* Expose Payload Type setting in RTP Header */ -#define FIX_BASOP_2498_LOGIC_IN_ENC_DTX_DECISION_MTX /* Nokia: BASOP 2498: Fix the logic */ #define FIX_BASOP_2497_MCMASA_LFE_WRONG_SF_INDEX /* Nokia: BASOP 2497: Fix wrong subframe index in McMASA LFE synth. */ #define FIX_BASOP_2496_OMASA_OBJ_EDIT_WRONG_ASSIGN /* Nokia: BASOP 2496: Fix wrong assignment in OMASA object edit code */ #define FIX_2495_Q_ALIGN_OSBA_RENDERER /* FhG: Basop issue #2495: Corrected exponent scaling of outAudio.data_fx before buffer accumulation in renderSbaToBinaural(). */ diff --git a/lib_enc/ivas_decision_matrix_enc_fx.c b/lib_enc/ivas_decision_matrix_enc_fx.c index 1e2fb73ce..a06ab8998 100644 --- a/lib_enc/ivas_decision_matrix_enc_fx.c +++ b/lib_enc/ivas_decision_matrix_enc_fx.c @@ -107,11 +107,7 @@ void ivas_decision_matrix_enc_fx( move16(); test(); -#ifdef FIX_BASOP_2498_LOGIC_IN_ENC_DTX_DECISION_MTX if ( GE_32( st->input_Fs, 32000 ) && GE_16( st->bwidth, SWB ) ) -#else - if ( GE_32( st->input_Fs, 32000 ) || GE_16( st->bwidth, SWB ) ) -#endif { st->extl = SWB_CNG; move16(); -- GitLab From 72c185795210e838434d17f18814f63a9fbc0101 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 13 Apr 2026 17:02:09 +0200 Subject: [PATCH 19/22] [cleanup] accept FIX_BASOP_2497_MCMASA_LFE_WRONG_SF_INDEX --- lib_com/options.h | 1 - lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 4 ---- 2 files changed, 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 546f522dc..5843b6e6c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -103,7 +103,6 @@ #define FIX_BASOP_2486_HQ_FINE_GAIN_ALIGNMENT /* Eri: Basop issue 2486: IVAS BASOP used calculations with truncation, EVS BASOP used rounding. This aligns the use of a table lookup. */ #define FIX_1540_EXPOSE_PT_IN_RTP_HEADER_API /* Expose Payload Type setting in RTP Header */ -#define FIX_BASOP_2497_MCMASA_LFE_WRONG_SF_INDEX /* Nokia: BASOP 2497: Fix wrong subframe index in McMASA LFE synth. */ #define FIX_BASOP_2496_OMASA_OBJ_EDIT_WRONG_ASSIGN /* Nokia: BASOP 2496: Fix wrong assignment in OMASA object edit code */ #define FIX_2495_Q_ALIGN_OSBA_RENDERER /* FhG: Basop issue #2495: Corrected exponent scaling of outAudio.data_fx before buffer accumulation in renderSbaToBinaural(). */ #define FIX_BASOP_2511_PROTO_REF_POWER_FIX /* FhG: BASOP 2511; Fix reference power computation in protoSignalComputation_shd_fx() */ diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index 1ee45f1c8..beb4f6617 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -3454,11 +3454,7 @@ void ivas_lfe_synth_with_filters_fx( slotSize = shr_r( output_frame, 4 ); // output_frame / CLDFB_NO_COL_MAX FOR( slot_index = 0; slot_index < CLDFB_NO_COL_MAX; slot_index++ ) { -#ifdef FIX_BASOP_2497_MCMASA_LFE_WRONG_SF_INDEX subframe_index = shr( slot_index, 2 ); -#else - subframe_index = shr( slot_index, 4 ); -#endif mrange[0] = i_mult( slot_index, slotSize ); move16(); -- GitLab From 9b096b58af6377246cfe5c8a9890ae224fc98c8c Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 13 Apr 2026 17:02:54 +0200 Subject: [PATCH 20/22] [cleanup] accept FIX_BASOP_2496_OMASA_OBJ_EDIT_WRONG_ASSIGN --- lib_com/options.h | 1 - lib_rend/ivas_dirac_dec_binaural_functions_fx.c | 4 ---- 2 files changed, 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 5843b6e6c..308256008 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -103,7 +103,6 @@ #define FIX_BASOP_2486_HQ_FINE_GAIN_ALIGNMENT /* Eri: Basop issue 2486: IVAS BASOP used calculations with truncation, EVS BASOP used rounding. This aligns the use of a table lookup. */ #define FIX_1540_EXPOSE_PT_IN_RTP_HEADER_API /* Expose Payload Type setting in RTP Header */ -#define FIX_BASOP_2496_OMASA_OBJ_EDIT_WRONG_ASSIGN /* Nokia: BASOP 2496: Fix wrong assignment in OMASA object edit code */ #define FIX_2495_Q_ALIGN_OSBA_RENDERER /* FhG: Basop issue #2495: Corrected exponent scaling of outAudio.data_fx before buffer accumulation in renderSbaToBinaural(). */ #define FIX_BASOP_2511_PROTO_REF_POWER_FIX /* FhG: BASOP 2511; Fix reference power computation in protoSignalComputation_shd_fx() */ #define FIX_BASOP_2512_WRONG_SHIFT_IN_DIRAC_CONFIG /* Nokia: BASOP 2512: Fix wrong division by shift */ diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index de0877bf7..27017138b 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -5956,11 +5956,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( ELSE { newRatios[0] = L_shr( newRatios[0], 6 ); // Q = 30 + 9 + 1 - 16 = 24 -#ifdef FIX_BASOP_2496_OMASA_OBJ_EDIT_WRONG_ASSIGN newRatios[1] = L_shr( newRatios[1], 6 ); -#else - newRatios[1] = L_shr( newRatios[0], 6 ); -#endif move32(); move32(); } -- GitLab From ba38e591494f1521bdd2b2d751814551682ea136 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 13 Apr 2026 17:03:36 +0200 Subject: [PATCH 21/22] [cleanup] accept FIX_2495_Q_ALIGN_OSBA_RENDERER --- lib_com/options.h | 1 - lib_rend/lib_rend_fx.c | 2 -- 2 files changed, 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 308256008..c274abb89 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -103,7 +103,6 @@ #define FIX_BASOP_2486_HQ_FINE_GAIN_ALIGNMENT /* Eri: Basop issue 2486: IVAS BASOP used calculations with truncation, EVS BASOP used rounding. This aligns the use of a table lookup. */ #define FIX_1540_EXPOSE_PT_IN_RTP_HEADER_API /* Expose Payload Type setting in RTP Header */ -#define FIX_2495_Q_ALIGN_OSBA_RENDERER /* FhG: Basop issue #2495: Corrected exponent scaling of outAudio.data_fx before buffer accumulation in renderSbaToBinaural(). */ #define FIX_BASOP_2511_PROTO_REF_POWER_FIX /* FhG: BASOP 2511; Fix reference power computation in protoSignalComputation_shd_fx() */ #define FIX_BASOP_2512_WRONG_SHIFT_IN_DIRAC_CONFIG /* Nokia: BASOP 2512: Fix wrong division by shift */ #define FIX_BASOP_2513_EXTRA_RETURN_REND_OPEN /* Nokia: BASOP issue 2513: Removes extra return block */ diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index c5a943893..e3ec4e65a 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -8678,9 +8678,7 @@ static ivas_error renderSbaToBinaural( IF( hCrend->hReverb != NULL ) { -#ifdef FIX_2495_Q_ALIGN_OSBA_RENDERER scale_sig32( outAudio.data_fx, i_mult( outAudio.config.numChannels, outAudio.config.numSamplesPerChannel ), -Q2 ); // Align Q of outAudio.data_fx with Q of output_buffer_fx: *pCrend->p_io_qfactor = *outAudio.pq_fact - Q2 -#endif *outAudio.pq_fact = sub( *outAudio.pq_fact, Q2 ); move16(); } -- GitLab From eeb16d973a9a3d8e8a766f524f3ec89c9ae331f4 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 13 Apr 2026 17:04:59 +0200 Subject: [PATCH 22/22] formatting --- lib_com/edct_fx.c | 30 +++++++++++------------ lib_com/fd_cng_com_fx.c | 1 - lib_com/fft_fx_evs.c | 6 ++--- lib_com/prot_fx.h | 12 ++++----- lib_dec/ivas_ism_metadata_dec_fx.c | 18 +++++++------- lib_dec/ivas_ism_param_dec_fx.c | 6 ++--- lib_enc/fd_cng_enc_fx.c | 1 - lib_rend/ivas_objectRenderer_sfx_fx.c | 6 ++--- lib_rend/ivas_objectRenderer_sources_fx.c | 6 ++--- lib_rend/ivas_stat_rend.h | 2 +- 10 files changed, 43 insertions(+), 45 deletions(-) diff --git a/lib_com/edct_fx.c b/lib_com/edct_fx.c index edd361a9b..3ec5981ae 100644 --- a/lib_com/edct_fx.c +++ b/lib_com/edct_fx.c @@ -174,9 +174,9 @@ static Word16 const *get_edct_table( * _ (Word16[]) y : output transform Qx *-------------------------------------------------------------------------*/ void edct_fx( - const Word32 *x, /* i : input signal Qq */ - Word32 *y, /* o : output transform Qq */ - Word16 length, /* i : length Q0*/ + const Word32 *x, /* i : input signal Qq */ + Word32 *y, /* o : output transform Qq */ + Word16 length, /* i : length Q0*/ Word16 *q, /* i : Q value of input signal */ const Word16 element_mode /* i : element mode */ ) @@ -195,11 +195,11 @@ void edct_fx( /* Twiddling and Pre-rotate */ FOR( i = 0; i < len1; i++ ) { - L_tmp = Mult_32_16( x[2 * i], edct_table[i] ); /*Q(q+1) */ + L_tmp = Mult_32_16( x[2 * i], edct_table[i] ); /*Q(q+1) */ spec[i].re = Madd_32_16( L_tmp, x[( length - ( 1 + ( i * 2 ) ) )], edct_table[( len1 - ( 1 + i ) )] ); /*Q(q+1) */ move32(); - L_tmp = Mult_32_16( x[( length - ( 1 + ( i * 2 ) ) )], edct_table[i] ); /*Q(q+1) */ + L_tmp = Mult_32_16( x[( length - ( 1 + ( i * 2 ) ) )], edct_table[i] ); /*Q(q+1) */ spec[i].im = Msub_32_16( L_tmp, x[( i * 2 )], edct_table[( len1 - ( 1 + i ) )] ); /*Q(q+1) */ move32(); } @@ -230,8 +230,8 @@ void edct_fx( FOR( i = 0; i < len1; i++ ) { - re = Msub_32_16( spec[i].re, spec[i].im, tmp ); /*Q(q+1) */ - im = Madd_32_16( spec[i].im, spec[i].re, tmp ); /*Q(q+1) */ + re = Msub_32_16( spec[i].re, spec[i].im, tmp ); /*Q(q+1) */ + im = Madd_32_16( spec[i].im, spec[i].re, tmp ); /*Q(q+1) */ y[2 * i] = L_add( Mult_32_16( re, edct_table[i] ), Mult_32_16( im, edct_table[( len1 - ( 1 + i ) )] ) ); /*Q(q+2)*/ move32(); y[( length - ( 1 + ( i * 2 ) ) )] = L_sub( Mult_32_16( re, edct_table[( len1 - ( 1 + i ) )] ), Mult_32_16( im, edct_table[i] ) ); /*Q(q+2)*/ @@ -284,11 +284,11 @@ void edst_fx( /* Twiddling and Pre-rotate */ FOR( i = 0; i < len1; i++ ) { - L_tmp = Mult_32_16( x[( length - ( 1 + ( i * 2 ) ) )], edct_table[i] ); /*Qq+1*/ + L_tmp = Mult_32_16( x[( length - ( 1 + ( i * 2 ) ) )], edct_table[i] ); /*Qq+1*/ complex_buf[i].re = Madd_32_16( L_tmp, x[2 * i], edct_table[( len1 - ( 1 + i ) )] ); /*Qq+1*/ move32(); - L_tmp = Mult_32_16( x[2 * i], edct_table[i] ); /*Qq+1*/ + L_tmp = Mult_32_16( x[2 * i], edct_table[i] ); /*Qq+1*/ complex_buf[i].im = Msub_32_16( L_tmp, x[( length - ( 1 + ( i * 2 ) ) )], edct_table[( len1 - ( 1 + i ) )] ); /*Qq+1*/ move32(); } @@ -301,8 +301,8 @@ void edst_fx( tmp = round_fx( L_shl( L_mult( tmp, 19302 /*0.75f * EVS_PI in Q13*/ ), 2 ) ); /*Q15 */ FOR( i = 0; i < len1; i++ ) { - re = Msub_32_16( complex_buf[i].re, complex_buf[i].im, tmp ); /*Qq+1*/ - im = Madd_32_16( complex_buf[i].im, complex_buf[i].re, tmp ); /*Qq+1*/ + re = Msub_32_16( complex_buf[i].re, complex_buf[i].im, tmp ); /*Qq+1*/ + im = Madd_32_16( complex_buf[i].im, complex_buf[i].re, tmp ); /*Qq+1*/ y[2 * i] = L_add( Mult_32_16( re, edct_table[i] ), Mult_32_16( im, edct_table[( len1 - ( 1 + i ) )] ) ); /*Qq+2*/ move32(); y[( length - ( 1 + ( i * 2 ) ) )] = L_sub( Mult_32_16( im, edct_table[i] ), Mult_32_16( re, edct_table[( len1 - ( 1 + i ) )] ) ); /*Qq+2*/ @@ -405,12 +405,12 @@ void edct_16fx( { i2 = shl( i, 1 ); - L_tmp = L_mult( x[i2], edct_table[i] ); /*Q(Qx+16) */ - Lacc = L_mac_sat( L_tmp, *px, *pt ); /*Q(Qx+16) */ + L_tmp = L_mult( x[i2], edct_table[i] ); /*Q(Qx+16) */ + Lacc = L_mac_sat( L_tmp, *px, *pt ); /*Q(Qx+16) */ re[i] = round_fx_sat( L_shl_sat( Lacc, Q_edct ) ); /* Q(Qx+Q_edct) */ move16(); - L_tmp = L_mult( *px, edct_table[i] ); /*Q(Qx+16) */ - Lacc = L_msu_sat( L_tmp, x[i2], *pt ); /*Q(Qx+16) */ + L_tmp = L_mult( *px, edct_table[i] ); /*Q(Qx+16) */ + Lacc = L_msu_sat( L_tmp, x[i2], *pt ); /*Q(Qx+16) */ im[i] = round_fx_sat( L_shl_sat( Lacc, Q_edct ) ); /* Q(Qx+Q_edct) */ move16(); px -= 2; diff --git a/lib_com/fd_cng_com_fx.c b/lib_com/fd_cng_com_fx.c index 77b374099..497587635 100644 --- a/lib_com/fd_cng_com_fx.c +++ b/lib_com/fd_cng_com_fx.c @@ -1199,7 +1199,6 @@ void minimum_statistics_fx( } - /*------------------------------------------------------------------- * apply_scale() * diff --git a/lib_com/fft_fx_evs.c b/lib_com/fft_fx_evs.c index 49d73dd99..74349d1d9 100644 --- a/lib_com/fft_fx_evs.c +++ b/lib_com/fft_fx_evs.c @@ -50,9 +50,9 @@ static void cftmdl_fx( Word16 n, Word16 l, Word32 *a, const Word16 *w ); *-----------------------------------------------------------------*/ void DoRTFTn_fx( - Word32 *x, /* i/o : real part of input and output data Q(x) */ - Word32 *y, /* i/o : imaginary part of input and output data Q(x) */ - cmplx *spec, /* i/o : complex input and output data */ + Word32 *x, /* i/o : real part of input and output data Q(x) */ + Word32 *y, /* i/o : imaginary part of input and output data Q(x) */ + cmplx *spec, /* i/o : complex input and output data */ const Word16 n /* i : size of the FFT up to 1024 */ ) { diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index c76a96e24..526512904 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -3985,9 +3985,9 @@ void TCX_MDXT_Inverse_fx( ); void edct_fx( - const Word32 *x, /* i : i signal Qq */ - Word32 *y, /* o : output transform Qq */ - Word16 length, /* i : length */ + const Word32 *x, /* i : i signal Qq */ + Word32 *y, /* o : output transform Qq */ + Word16 length, /* i : length */ Word16 *q, /* i : Q value of input signal */ const Word16 element_mode /* i : element mode */ ); @@ -4026,9 +4026,9 @@ void BASOP_cfft( cmplx *pComplexBuf, Word16 sizeOfFft, Word16 *scale, Word32 wor void BASOP_rfft( Word32 *x, Word16 sizeOfFft, Word16 *scale, Word16 isign ); void DoRTFTn_fx( - Word32 *x, /* i/o : real part of i and output data */ - Word32 *y, /* i/o : imaginary part of i and output data */ - cmplx *spec, /* i/o : complex input and output data */ + Word32 *x, /* i/o : real part of i and output data */ + Word32 *y, /* i/o : imaginary part of i and output data */ + cmplx *spec, /* i/o : complex input and output data */ const Word16 n /* i : size of the FFT up to 1024 */ ); diff --git a/lib_dec/ivas_ism_metadata_dec_fx.c b/lib_dec/ivas_ism_metadata_dec_fx.c index 535207a63..4e9fe4154 100644 --- a/lib_dec/ivas_ism_metadata_dec_fx.c +++ b/lib_dec/ivas_ism_metadata_dec_fx.c @@ -160,15 +160,15 @@ static void ism_metadata_smooth_fx( *-------------------------------------------------------------------------*/ ivas_error ivas_ism_metadata_dec_fx( - const Word32 ism_total_brate, /* i : ISM total bitrate */ - const Word16 nchan_ism, /* i : number of ISM channels */ - Word16 *nchan_transport, /* o : number of transport channels */ - ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */ - SCE_DEC_HANDLE hSCE[], /* i/o: SCE decoder handles */ - const Word16 bfi, /* i : bfi flag */ - Word16 nb_bits_metadata[], /* o : number of metadata bits */ - ISM_MODE ism_mode, /* i : ISM mode */ - ISM_DTX_DATA_DEC *hISMDTX, /* i/o: ISM DTX handle */ + const Word32 ism_total_brate, /* i : ISM total bitrate */ + const Word16 nchan_ism, /* i : number of ISM channels */ + Word16 *nchan_transport, /* o : number of transport channels */ + ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */ + SCE_DEC_HANDLE hSCE[], /* i/o: SCE decoder handles */ + const Word16 bfi, /* i : bfi flag */ + Word16 nb_bits_metadata[], /* o : number of metadata bits */ + ISM_MODE ism_mode, /* i : ISM mode */ + ISM_DTX_DATA_DEC *hISMDTX, /* i/o: ISM DTX handle */ const PARAM_ISM_CONFIG_HANDLE hParamIsm, /* i : Param ISM Config Handle */ Word16 *ism_extmeta_active, /* i/o: Extended metadata active in renderer */ Word16 *ism_extmeta_cnt, /* i/o: Number of change frames observed */ diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index e3a4cbf35..4a00c193c 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -222,9 +222,9 @@ static void ivas_param_ism_collect_slot_fx( } static void ivas_param_ism_compute_mixing_matrix_fx( - const Word16 nchan_ism, /* i : number of ISM channels */ - PARAM_ISM_DEC_HANDLE hParamIsmDec, /* i/o: decoder ParamISM handle */ - const ISM_DTX_DATA_DEC *hISMDTX, /* i : ISM DTX handle */ + const Word16 nchan_ism, /* i : number of ISM channels */ + PARAM_ISM_DEC_HANDLE hParamIsmDec, /* i/o: decoder ParamISM handle */ + const ISM_DTX_DATA_DEC *hISMDTX, /* i : ISM DTX handle */ Word32 direct_response_fx[MAX_NUM_OBJECTS][PARAM_ISM_MAX_CHAN], // Q30 const Word16 nchan_transport, const Word16 nchan_out_woLFE, diff --git a/lib_enc/fd_cng_enc_fx.c b/lib_enc/fd_cng_enc_fx.c index a64ea3cce..21f740c66 100644 --- a/lib_enc/fd_cng_enc_fx.c +++ b/lib_enc/fd_cng_enc_fx.c @@ -764,7 +764,6 @@ static void msvq_encoder( } - void generate_comfort_noise_enc_fx( Encoder_State *stcod, Word16 Q_new, diff --git a/lib_rend/ivas_objectRenderer_sfx_fx.c b/lib_rend/ivas_objectRenderer_sfx_fx.c index d83c1912b..c54dc8676 100644 --- a/lib_rend/ivas_objectRenderer_sfx_fx.c +++ b/lib_rend/ivas_objectRenderer_sfx_fx.c @@ -278,8 +278,8 @@ void TDREND_firfilt_fx( Word32 *mem_fx, /* i/o: filter memory Qx */ const Word16 subframe_length, /* i : Length of signal Q0 */ const Word16 filterlength, /* i : Filter length Q0 */ - const Word32 Gain_fx, /* i : Gain Q29 */ - const Word32 prevGain_fx /* i : Previous gain Q29 */ + const Word32 Gain_fx, /* i : Gain Q29 */ + const Word32 prevGain_fx /* i : Previous gain Q29 */ ) { @@ -294,7 +294,7 @@ void TDREND_firfilt_fx( Word16 tmp_e; Word64 tmp64_fx; Word16 shift = sub( filter_e, 32 ); - gain_delta_fx = L_sub( Gain_fx, prevGain_fx ); // Q29 + gain_delta_fx = L_sub( Gain_fx, prevGain_fx ); // Q29 step_fx = L_deposit_h( BASOP_Util_Divide3232_Scale( gain_delta_fx, subframe_length, &tmp_e ) ); // exp(tmp_e) tmp_e = sub( tmp_e, Q31 ); step_fx = L_shl_sat( step_fx, tmp_e ); // Q29 diff --git a/lib_rend/ivas_objectRenderer_sources_fx.c b/lib_rend/ivas_objectRenderer_sources_fx.c index fe28fe4ea..ad4776fbc 100644 --- a/lib_rend/ivas_objectRenderer_sources_fx.c +++ b/lib_rend/ivas_objectRenderer_sources_fx.c @@ -139,7 +139,7 @@ ivas_error TDREND_MIX_SRC_SetDir_fx( ivas_error TDREND_MIX_SRC_SetGain( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ const Word16 SrcInd, /* i : Source index */ - const Word32 Gain /* i : Gain Q29 */ + const Word32 Gain /* i : Gain Q29 */ ) { TDREND_SRC_SPATIAL_SetGain( hBinRendererTd->Sources[SrcInd], Gain ); @@ -308,8 +308,8 @@ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams_fx( Word16 *intp_count, /* o : Interpolation count Q0 */ Word16 *filterlength, /* o : Length of filters Q0 */ Word16 *itd, /* o : ITD value Q0 */ - Word32 *Gain, /* o : Gain value Q29 */ - TDREND_SRC_t *Src_p /* i/o: Source pointer */ + Word32 *Gain, /* o : Gain value Q29 */ + TDREND_SRC_t *Src_p /* i/o: Source pointer */ ) { TDREND_MIX_Listener_t *Listener_p; diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index f19f12c98..dc5db5e4f 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1208,7 +1208,7 @@ typedef struct TDREND_SRC_REND_s /* Gains */ Word16 SrcGainUpdated; - Word32 SrcGain_p_fx[SPAT_BIN_MAX_INPUT_CHANNELS]; /* Q29 */ + Word32 SrcGain_p_fx[SPAT_BIN_MAX_INPUT_CHANNELS]; /* Q29 */ Word16 DirGain_p_fx[SPAT_BIN_MAX_INPUT_CHANNELS]; // Q14 Word16 DistGain_p_fx[SPAT_BIN_MAX_INPUT_CHANNELS]; // Q14 } TDREND_SRC_REND_t; -- GitLab