From e7c4ef8f89ab3309e6c1b3115238041ac622bb26 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 31 Mar 2026 16:24:26 +0200 Subject: [PATCH 1/7] delete fx-calls and replace by ivas-calls --- lib_com/options.h | 1 + lib_dec/acelp_core_dec_fx.c | 4 ++++ lib_dec/dec_acelp_tcx_main_fx.c | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 7976d55ed..6c5e76a07 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -90,6 +90,7 @@ #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_FLOAT_ISSUE_1546_DEAD_CODE /* FhG: remove dead code reported in the issue*/ +#define HARMONIZE_2494_FdCng_decodeSID_fx /* #################### End BE switches ################################## */ diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 2518d8a3a..08a44ff07 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -658,7 +658,11 @@ ivas_error acelp_core_dec_fx( { IF( EQ_16( st->element_mode, EVS_MONO ) ) { +#ifdef HARMONIZE_2494_FdCng_decodeSID_fx + FdCng_decodeSID_ivas_fx( st ); +#else FdCng_decodeSID_fx( st->hFdCngDec->hFdCngCom, st ); +#endif } ELSE { diff --git a/lib_dec/dec_acelp_tcx_main_fx.c b/lib_dec/dec_acelp_tcx_main_fx.c index 1eccbfeab..3e705466c 100644 --- a/lib_dec/dec_acelp_tcx_main_fx.c +++ b/lib_dec/dec_acelp_tcx_main_fx.c @@ -521,7 +521,11 @@ Word16 dec_acelp_tcx_frame_fx( IF( EQ_16( st->m_frame_type, SID_FRAME ) ) { +#ifdef HARMONIZE_2494_FdCng_decodeSID_fx + FdCng_decodeSID_ivas_fx( st ); +#else FdCng_decodeSID_fx( st->hFdCngDec->hFdCngCom, st ); +#endif } /* updates */ -- GitLab From 7f4684f7b2ceb0bac9347f72e680aad8591c94b5 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 1 Apr 2026 07:45:26 +0200 Subject: [PATCH 2/7] check old EVSbranch in decodeSID_ivas_fx() --- lib_dec/acelp_core_dec_fx.c | 4 ---- lib_dec/dec_acelp_tcx_main_fx.c | 4 ---- lib_dec/fd_cng_dec_fx.c | 6 ++++-- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 08a44ff07..2518d8a3a 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -658,11 +658,7 @@ ivas_error acelp_core_dec_fx( { IF( EQ_16( st->element_mode, EVS_MONO ) ) { -#ifdef HARMONIZE_2494_FdCng_decodeSID_fx - FdCng_decodeSID_ivas_fx( st ); -#else FdCng_decodeSID_fx( st->hFdCngDec->hFdCngCom, st ); -#endif } ELSE { diff --git a/lib_dec/dec_acelp_tcx_main_fx.c b/lib_dec/dec_acelp_tcx_main_fx.c index 3e705466c..1eccbfeab 100644 --- a/lib_dec/dec_acelp_tcx_main_fx.c +++ b/lib_dec/dec_acelp_tcx_main_fx.c @@ -521,11 +521,7 @@ Word16 dec_acelp_tcx_frame_fx( IF( EQ_16( st->m_frame_type, SID_FRAME ) ) { -#ifdef HARMONIZE_2494_FdCng_decodeSID_fx - FdCng_decodeSID_ivas_fx( st ); -#else FdCng_decodeSID_fx( st->hFdCngDec->hFdCngCom, st ); -#endif } /* updates */ diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 901d2c5cb..e49d6c64e 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -4336,13 +4336,14 @@ void FdCng_decodeSID_ivas_fx( Word32 *invTrfMatrix_fx; Word32 tmpRAM_fx[FDCNG_VQ_MAX_LEN][FDCNG_VQ_DCT_MAXTRUNC]; Word16 tmp16; - +#ifndef HARMONIZE_2494_FdCng_decodeSID_fx IF( st->element_mode == EVS_MONO ) { tmp16 = GAIN_Q_OFFSET_EVS_FX_Q0; move16(); } ELSE +#endif { tmp16 = GAIN_Q_OFFSET_IVAS_FX_Q0; move16(); @@ -4374,13 +4375,14 @@ void FdCng_decodeSID_ivas_fx( index = get_next_indice_fx( st, 7 ); /* MSVQ decoder */ - +#ifndef HARMONIZE_2494_FdCng_decodeSID_fx IF( st->element_mode != EVS_MONO ) { create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, FDCNG_VQ_MAX_LEN * FDCNG_VQ_DCT_MAXTRUNC ); msvq_dec_fx( ivas_cdk_37bits_fx, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 1, invTrfMatrix_fx, v, NULL, 7 ); } ELSE +#endif { /* Legacy EVS_MONO MSVQ tables */ msvq_dec_fx( cdk_37bits, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 0, NULL, v, NULL, 7 ); } -- GitLab From 16bc04b7227888820233f90b400902e09ca43c9e Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 1 Apr 2026 08:28:49 +0200 Subject: [PATCH 3/7] bugfix warning --- lib_dec/fd_cng_dec_fx.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index e49d6c64e..65d1591a0 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -4333,10 +4333,10 @@ void FdCng_decodeSID_ivas_fx( Word32 v[32]; Word16 indices[32]; HANDLE_FD_CNG_COM hFdCngCom; - Word32 *invTrfMatrix_fx; - Word32 tmpRAM_fx[FDCNG_VQ_MAX_LEN][FDCNG_VQ_DCT_MAXTRUNC]; Word16 tmp16; #ifndef HARMONIZE_2494_FdCng_decodeSID_fx + Word32 tmpRAM_fx[FDCNG_VQ_MAX_LEN][FDCNG_VQ_DCT_MAXTRUNC]; + Word32 *invTrfMatrix_fx = (Word32 *) tmpRAM_fx; /*Q31*/ IF( st->element_mode == EVS_MONO ) { tmp16 = GAIN_Q_OFFSET_EVS_FX_Q0; @@ -4352,7 +4352,6 @@ void FdCng_decodeSID_ivas_fx( const Word16 gain_q_offset = tmp16; /* Q0 */ move16(); - invTrfMatrix_fx = (Word32 *) tmpRAM_fx; /*Q31*/ hFdCngCom = ( st->hFdCngDec )->hFdCngCom; -- GitLab From b7b4c5278e851e3a521a066d1192891dc8b5af3a Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 1 Apr 2026 09:54:01 +0200 Subject: [PATCH 4/7] added and activated harmonized FdCng_decodeSID_fx() --- lib_com/prot_fx.h | 7 ++ lib_dec/acelp_core_dec_fx.c | 13 ++- lib_dec/dec_acelp_tcx_main_fx.c | 4 + lib_dec/fd_cng_dec_fx.c | 197 +++++++++++++++++++++++++++++++- 4 files changed, 216 insertions(+), 5 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 346bedd07..db3b233f8 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -6590,9 +6590,14 @@ void perform_noise_estimation_dec_ivas_fx( ); /* Decode the CLDFB-CNG bitstream */ +#ifdef HARMONIZE_2494_FdCng_decodeSID_fx +void FdCng_decodeSID_fx( + Decoder_State *corest ); /* i/o: decoder state structure */ +#else void FdCng_decodeSID_fx( HANDLE_FD_CNG_COM st, /* i/o: FD_CNG structure containing all buffers and variables */ Decoder_State *corest ); /* i/o: decoder state structure */ +#endif void noisy_speech_detection_fx( HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: FD_CNG structure */ @@ -9516,9 +9521,11 @@ void SynthesisSTFT_fx( const Word16 nchan_out /* i : number of output channels */ ); +#ifndef HARMONIZE_2494_FdCng_decodeSID_fx void FdCng_decodeSID_ivas_fx( Decoder_State *st /* i/o: decoder state structure */ ); +#endif void cldfb_restore_memory_ivas_fx( HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 2518d8a3a..9a52d49b4 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -166,7 +166,11 @@ ivas_error acelp_core_dec_fx( /* Only run parameter decoding in SID frames */ IF( EQ_32( st->core_brate, SID_2k40 ) ) { +#ifndef HARMONIZE_2494_FdCng_decodeSID_fx FdCng_decodeSID_ivas_fx( st ); +#else + FdCng_decodeSID_fx( st ); +#endif Word16 n1, n2; n1 = L_norm_arr( st->hFdCngDec->hFdCngCom->sidNoiseEst, NPART ); @@ -658,14 +662,21 @@ ivas_error acelp_core_dec_fx( { IF( EQ_16( st->element_mode, EVS_MONO ) ) { +#ifndef HARMONIZE_2494_FdCng_decodeSID_fx FdCng_decodeSID_fx( st->hFdCngDec->hFdCngCom, st ); +#else + FdCng_decodeSID_fx( st ); +#endif } ELSE { Word16 old_NoiseEstExp = st->hFdCngDec->hFdCngCom->sidNoiseEstExp; move16(); - +#ifndef HARMONIZE_2494_FdCng_decodeSID_fx FdCng_decodeSID_ivas_fx( st ); +#else + FdCng_decodeSID_fx( st ); +#endif Scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART, sub( old_NoiseEstExp, st->hFdCngDec->hFdCngCom->sidNoiseEstExp ) ); Scale_sig( st->hFdCngDec->hFdCngCom->A_cng, M + 1, sub( norm_s( st->hFdCngDec->hFdCngCom->A_cng[0] ), Q2 ) ); // Qx diff --git a/lib_dec/dec_acelp_tcx_main_fx.c b/lib_dec/dec_acelp_tcx_main_fx.c index 1eccbfeab..aed46c1ef 100644 --- a/lib_dec/dec_acelp_tcx_main_fx.c +++ b/lib_dec/dec_acelp_tcx_main_fx.c @@ -521,7 +521,11 @@ Word16 dec_acelp_tcx_frame_fx( IF( EQ_16( st->m_frame_type, SID_FRAME ) ) { +#ifndef HARMONIZE_2494_FdCng_decodeSID_fx FdCng_decodeSID_fx( st->hFdCngDec->hFdCngCom, st ); +#else + FdCng_decodeSID_fx( st ); +#endif } /* updates */ diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 65d1591a0..771b8a53c 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -2115,6 +2115,7 @@ void perform_noise_estimation_dec_ivas_fx( } +#ifndef HARMONIZE_2494_FdCng_decodeSID_fx /* FdCng_decodeSID_fx @@ -2252,6 +2253,196 @@ void FdCng_decodeSID_fx( HANDLE_FD_CNG_COM st, Decoder_State *corest ) lpc_from_spectrum( st, st->startBand, st->stopFFTbin, preemph_fac ); } +#else +/* + FdCng_decodeSID_fx + + Parameters: + + st i/o: FD_CNG structure containing all buffers and variables + bs_word16 i : Bitstream + amrwb_io i : amr wideband mode + preemph_fac i : preemphase factor + + Function: + decode the FD-CNG bitstream + + Returns: + void +*/ +void FdCng_decodeSID_fx( Decoder_State *corest ) +{ + Word16 N; + Word32 *sidNoiseEst; + Word16 sidNoiseEst_Exp = 0; + move16(); + Word16 i, index; + HANDLE_FD_CNG_COM hFdCngCom = ( corest->hFdCngDec )->hFdCngCom; + Word16 indices[32]; + Word32 v[32], gain; + Word32 *invTrfMatrix_fx; + Word32 tmpRAM_fx[FDCNG_VQ_MAX_LEN][FDCNG_VQ_DCT_MAXTRUNC]; + + Word32 gain_q_offset = GAIN_Q_OFFSET_IVAS_FX_Q0; + + if ( corest->element_mode == EVS_MONO ) + { + gain_q_offset = GAIN_Q_OFFSET_EVS_FX_Q0; /*60 Q0*/ + move32(); + } + + invTrfMatrix_fx = (Word32 *) tmpRAM_fx; + + + sidNoiseEst = hFdCngCom->sidNoiseEst; /*Q31 - hFdCngCom->sidNoiseEstExp*/ + move16(); + + N = hFdCngCom->npart; /*Q0*/ + move16(); + hFdCngCom->sid_frame_counter = add( hFdCngCom->sid_frame_counter, 1 ); + move16(); + + /* Read bitstream */ + FOR( i = 0; i < stages_37bits; i++ ) + { + indices[i] = get_next_indice_fx( corest, bits_37bits[i] ); /*Q0*/ + move16(); + } + + index = get_next_indice_fx( corest, 7 ); /*Q0*/ + + /* MSVQ decoder */ + + IF( corest->element_mode != EVS_MONO ) + { + create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, FDCNG_VQ_MAX_LEN * FDCNG_VQ_DCT_MAXTRUNC ); + msvq_dec_fx( ivas_cdk_37bits_fx, NULL, NULL, stages_37bits, N, maxN_37bits, indices, 1, invTrfMatrix_fx, v, NULL, 7 ); + } + ELSE + { + Word16 v16[32]; + msvq_decoder( + cdk_37bits, + stages_37bits, + N, + maxN_37bits, + indices, + v16 ); + + FOR( i = 0; i < N; i++ ) + { + v[i] = L_deposit_h( v16[i] ); /*Q23*/ + move32(); + } + } + + + /* Decode gain */ + // gain = ((float)index - gain_q_offset) / 1.5f; + { + /* format gain: Q9.23 */ + Word32 gain_q_offset = GAIN_Q_OFFSET_EVS_FX_Q0; /*60 Q0*/ + move32(); + gain = L_shl( L_deposit_l( index ), WORD32_BITS - 1 - 8 ); + gain = L_sub( gain, L_shl( gain_q_offset, 23 ) /*60.0 Q23*/ ); /*Q23*/ + gain = Mpy_32_16_1( gain, 21845 /*2.0f/3.0f Q15*/ ); /*Q23*/ + } + + + /* Apply gain and undo log */ + IF( corest->element_mode == EVS_MONO ) + { + /* format gain: Q9.23 */ + /* calculate worst case for scaling */ + Word32 maxVal = L_add( 0x80000000 /*-1.0 Q31*/, 0 ); + FOR( i = 0; i < N; i++ ) + { + maxVal = L_max( maxVal, v[i] ); /*Q23*/ + } + + maxVal = L_add( maxVal, gain ); /*Q23*/ + maxVal = L_shl( Mpy_32_16_1( maxVal, 21771 /*0.66438561897 Q15*/ ), 1 ); /*Q23*/ + + FOR( ; maxVal >= 0; maxVal -= 33554432l /*0.015625 Q31*/ ) + { + sidNoiseEst_Exp = add( sidNoiseEst_Exp, 1 ); + } + + /* format v: Q9.23, format sidNoiseEst: Q6.26, 0.66438561897 = log10(10)/log10(2.0) / 10.0 * 2.0 */ + Word32 E_ExpLd64 = L_shl( sidNoiseEst_Exp, WORD32_BITS - 1 - LD_DATA_SCALE ); + FOR( i = 0; i < N; i++ ) + { + Word32 tmp = L_add( v[i], gain ); /*Q23*/ + tmp = L_shl( Mpy_32_16_1( tmp, 21771 /*0.66438561897 Q15*/ ), 1 ); /*Q23*/ + tmp = L_sub( tmp, E_ExpLd64 ); + assert( tmp < 0 ); + sidNoiseEst[i] = BASOP_Util_InvLog2( tmp ); /*Q31 - hFdCngCom->sidNoiseEstExp*/ + move32(); + } + } + ELSE + { + gain = L_shr( gain, 8 ); /*Q23->Q15*/ + Word16 res_exp[NPART]; + FOR( i = 0; i < N; i++ ) + { + sidNoiseEst[i] = BASOP_util_Pow2( Mpy_32_32( L_add( v[i], gain ), LOG_10_BASE_2_BY_10_Q31 ), Q16, &res_exp[i] ); /*Q31 - res_exp[i]*/ + move32(); + if ( LT_16( sidNoiseEst_Exp, res_exp[i] ) ) + { + sidNoiseEst_Exp = res_exp[i]; + move16(); + } + } + + FOR( i = 0; i < N; i++ ) + { + sidNoiseEst[i] = L_shr( sidNoiseEst[i], sub( sidNoiseEst_Exp, res_exp[i] ) ); /*Q31 - sidNoiseEst_Exp*/ + move32(); + } + } + + hFdCngCom->sidNoiseEstExp = sidNoiseEst_Exp; + move16(); + + /* NB last band energy compensation */ + + IF( hFdCngCom->CngBandwidth == NB ) + { + sidNoiseEst[( N - 1 )] = Mpy_32_16_1( sidNoiseEst[( N - 1 )], NB_LAST_BAND_SCALE ); + move32(); + } + + test(); + IF( EQ_16( hFdCngCom->CngBandwidth, SWB ) && LE_32( hFdCngCom->CngBitrate, ACELP_13k20 ) ) + { + sidNoiseEst[( N - 1 )] = Mpy_32_16_1( sidNoiseEst[( N - 1 )], SWB_13k2_LAST_BAND_SCALE ); + move32(); + } + + scalebands( sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), hFdCngCom->cngNoiseLevel, 1 ); + IF( corest->element_mode == EVS_MONO ) + { + hFdCngCom->cngNoiseLevelExp = hFdCngCom->sidNoiseEstExp; + move16(); + } + ELSE + { + Word16 shift1 = L_norm_arr( hFdCngCom->cngNoiseLevel, sub( hFdCngCom->stopBand, hFdCngCom->startBand ) ); + Word16 shift2 = L_norm_arr( hFdCngCom->cngNoiseLevel + sub( hFdCngCom->stopBand, hFdCngCom->startBand ), sub( FFTCLDFBLEN, sub( hFdCngCom->stopBand, hFdCngCom->startBand ) ) ); + Word16 shift = s_max( sub( hFdCngCom->sidNoiseEstExp, shift1 ), sub( hFdCngCom->cngNoiseLevelExp, shift2 ) ); + + scale_sig32( hFdCngCom->cngNoiseLevel, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), sub( hFdCngCom->sidNoiseEstExp, shift ) ); + scale_sig32( hFdCngCom->cngNoiseLevel + sub( hFdCngCom->stopBand, hFdCngCom->startBand ), sub( FFTCLDFBLEN, sub( hFdCngCom->stopBand, hFdCngCom->startBand ) ), sub( hFdCngCom->cngNoiseLevelExp, shift ) ); + + hFdCngCom->cngNoiseLevelExp = shift; + move16(); + } + move16(); + + lpc_from_spectrum( hFdCngCom, hFdCngCom->startBand, hFdCngCom->stopFFTbin, corest->preemph_fac ); +} +#endif /* noisy_speech_detection_fx @@ -4316,6 +4507,7 @@ void configureFdCngDec_ivas_fx( return; } +#ifndef HARMONIZE_2494_FdCng_decodeSID_fx /*------------------------------------------------------------------- * FdCng_decodeSID_ivas_fx() * @@ -4334,7 +4526,6 @@ void FdCng_decodeSID_ivas_fx( Word16 indices[32]; HANDLE_FD_CNG_COM hFdCngCom; Word16 tmp16; -#ifndef HARMONIZE_2494_FdCng_decodeSID_fx Word32 tmpRAM_fx[FDCNG_VQ_MAX_LEN][FDCNG_VQ_DCT_MAXTRUNC]; Word32 *invTrfMatrix_fx = (Word32 *) tmpRAM_fx; /*Q31*/ IF( st->element_mode == EVS_MONO ) @@ -4343,7 +4534,6 @@ void FdCng_decodeSID_ivas_fx( move16(); } ELSE -#endif { tmp16 = GAIN_Q_OFFSET_IVAS_FX_Q0; move16(); @@ -4374,14 +4564,12 @@ void FdCng_decodeSID_ivas_fx( index = get_next_indice_fx( st, 7 ); /* MSVQ decoder */ -#ifndef HARMONIZE_2494_FdCng_decodeSID_fx IF( st->element_mode != EVS_MONO ) { create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, FDCNG_VQ_MAX_LEN * FDCNG_VQ_DCT_MAXTRUNC ); msvq_dec_fx( ivas_cdk_37bits_fx, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 1, invTrfMatrix_fx, v, NULL, 7 ); } ELSE -#endif { /* Legacy EVS_MONO MSVQ tables */ msvq_dec_fx( cdk_37bits, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 0, NULL, v, NULL, 7 ); } @@ -4445,6 +4633,7 @@ void FdCng_decodeSID_ivas_fx( return; } +#endif /*HARMONIZE_2494_FdCng_decodeSID_fx*/ /*------------------------------------------------------------------- * generate_masking_noise_ivas_fx() -- GitLab From 11daea25cd056ea2395f5254cc9901afaff1e627 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 1 Apr 2026 10:08:44 +0200 Subject: [PATCH 5/7] bugfix --- lib_dec/fd_cng_dec_fx.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 771b8a53c..64cd07a24 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -2341,8 +2341,6 @@ void FdCng_decodeSID_fx( Decoder_State *corest ) // gain = ((float)index - gain_q_offset) / 1.5f; { /* format gain: Q9.23 */ - Word32 gain_q_offset = GAIN_Q_OFFSET_EVS_FX_Q0; /*60 Q0*/ - move32(); gain = L_shl( L_deposit_l( index ), WORD32_BITS - 1 - 8 ); gain = L_sub( gain, L_shl( gain_q_offset, 23 ) /*60.0 Q23*/ ); /*Q23*/ gain = Mpy_32_16_1( gain, 21845 /*2.0f/3.0f Q15*/ ); /*Q23*/ -- GitLab From fd52744e2747c1874c865e880c4ac504853025b6 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 2 Apr 2026 08:37:53 +0000 Subject: [PATCH 6/7] use basop comparators for enums - undo unnecessary changes in inactive code - comment harmonization macro --- lib_com/options.h | 2 +- lib_dec/fd_cng_dec_fx.c | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 6c5e76a07..f5ca9d7ca 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -90,7 +90,7 @@ #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_FLOAT_ISSUE_1546_DEAD_CODE /* FhG: remove dead code reported in the issue*/ -#define HARMONIZE_2494_FdCng_decodeSID_fx +#define HARMONIZE_2494_FdCng_decodeSID_fx /* FhG: harmonize FdCng_decodeSID_fx with _ivas_ version */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 64cd07a24..897dbcf20 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -2285,7 +2285,7 @@ void FdCng_decodeSID_fx( Decoder_State *corest ) Word32 gain_q_offset = GAIN_Q_OFFSET_IVAS_FX_Q0; - if ( corest->element_mode == EVS_MONO ) + if ( EQ_16( corest->element_mode, EVS_MONO ) ) { gain_q_offset = GAIN_Q_OFFSET_EVS_FX_Q0; /*60 Q0*/ move32(); @@ -2313,7 +2313,7 @@ void FdCng_decodeSID_fx( Decoder_State *corest ) /* MSVQ decoder */ - IF( corest->element_mode != EVS_MONO ) + IF( NE_16( corest->element_mode, EVS_MONO ) ) { create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, FDCNG_VQ_MAX_LEN * FDCNG_VQ_DCT_MAXTRUNC ); msvq_dec_fx( ivas_cdk_37bits_fx, NULL, NULL, stages_37bits, N, maxN_37bits, indices, 1, invTrfMatrix_fx, v, NULL, 7 ); @@ -2419,7 +2419,7 @@ void FdCng_decodeSID_fx( Decoder_State *corest ) } scalebands( sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), hFdCngCom->cngNoiseLevel, 1 ); - IF( corest->element_mode == EVS_MONO ) + IF( EQ_16( corest->element_mode, EVS_MONO ) ) { hFdCngCom->cngNoiseLevelExp = hFdCngCom->sidNoiseEstExp; move16(); @@ -4523,9 +4523,10 @@ void FdCng_decodeSID_ivas_fx( Word32 v[32]; Word16 indices[32]; HANDLE_FD_CNG_COM hFdCngCom; - Word16 tmp16; + Word32 *invTrfMatrix_fx; Word32 tmpRAM_fx[FDCNG_VQ_MAX_LEN][FDCNG_VQ_DCT_MAXTRUNC]; - Word32 *invTrfMatrix_fx = (Word32 *) tmpRAM_fx; /*Q31*/ + Word16 tmp16; + IF( st->element_mode == EVS_MONO ) { tmp16 = GAIN_Q_OFFSET_EVS_FX_Q0; @@ -4540,6 +4541,7 @@ void FdCng_decodeSID_ivas_fx( const Word16 gain_q_offset = tmp16; /* Q0 */ move16(); + invTrfMatrix_fx = (Word32 *) tmpRAM_fx; /*Q31*/ hFdCngCom = ( st->hFdCngDec )->hFdCngCom; @@ -4562,6 +4564,7 @@ void FdCng_decodeSID_ivas_fx( index = get_next_indice_fx( st, 7 ); /* MSVQ decoder */ + IF( st->element_mode != EVS_MONO ) { create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, FDCNG_VQ_MAX_LEN * FDCNG_VQ_DCT_MAXTRUNC ); -- GitLab From 0a4485a818a87649a58483299466236e4f120ac8 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 6 Apr 2026 20:56:02 +0200 Subject: [PATCH 7/7] some minor editoral edits --- lib_com/prot_fx.h | 2 +- lib_dec/fd_cng_dec_fx.c | 43 ++++++++++++++++------------------------- 2 files changed, 18 insertions(+), 27 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 2eaeb98f2..42f1b39f7 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -6649,7 +6649,7 @@ void perform_noise_estimation_dec_ivas_fx( /* Decode the CLDFB-CNG bitstream */ #ifdef HARMONIZE_2494_FdCng_decodeSID_fx void FdCng_decodeSID_fx( - Decoder_State *corest ); /* i/o: decoder state structure */ + Decoder_State *st ); /* i/o: decoder state structure */ #else void FdCng_decodeSID_fx( HANDLE_FD_CNG_COM st, /* i/o: FD_CNG structure containing all buffers and variables */ diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 68cac6fb4..27772455b 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -2297,22 +2297,22 @@ void FdCng_decodeSID_fx( HANDLE_FD_CNG_COM st, Decoder_State *corest ) Returns: void */ -void FdCng_decodeSID_fx( Decoder_State *corest ) +void FdCng_decodeSID_fx( Decoder_State *st ) { Word16 N; Word32 *sidNoiseEst; Word16 sidNoiseEst_Exp = 0; - move16(); Word16 i, index; - HANDLE_FD_CNG_COM hFdCngCom = ( corest->hFdCngDec )->hFdCngCom; + HANDLE_FD_CNG_COM hFdCngCom = ( st->hFdCngDec )->hFdCngCom; Word16 indices[32]; Word32 v[32], gain; Word32 *invTrfMatrix_fx; Word32 tmpRAM_fx[FDCNG_VQ_MAX_LEN][FDCNG_VQ_DCT_MAXTRUNC]; - Word32 gain_q_offset = GAIN_Q_OFFSET_IVAS_FX_Q0; + move16(); + move32(); - if ( EQ_16( corest->element_mode, EVS_MONO ) ) + if ( EQ_16( st->element_mode, EVS_MONO ) ) { gain_q_offset = GAIN_Q_OFFSET_EVS_FX_Q0; /*60 Q0*/ move32(); @@ -2332,15 +2332,15 @@ void FdCng_decodeSID_fx( Decoder_State *corest ) /* Read bitstream */ FOR( i = 0; i < stages_37bits; i++ ) { - indices[i] = get_next_indice_fx( corest, bits_37bits[i] ); /*Q0*/ + indices[i] = get_next_indice_fx( st, bits_37bits[i] ); /*Q0*/ move16(); } - index = get_next_indice_fx( corest, 7 ); /*Q0*/ + index = get_next_indice_fx( st, 7 ); /*Q0*/ /* MSVQ decoder */ - IF( NE_16( corest->element_mode, EVS_MONO ) ) + IF( NE_16( st->element_mode, EVS_MONO ) ) { create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, FDCNG_VQ_MAX_LEN * FDCNG_VQ_DCT_MAXTRUNC ); msvq_dec_fx( ivas_cdk_37bits_fx, NULL, NULL, stages_37bits, N, maxN_37bits, indices, 1, invTrfMatrix_fx, v, NULL, 7 ); @@ -2348,13 +2348,7 @@ void FdCng_decodeSID_fx( Decoder_State *corest ) ELSE { Word16 v16[32]; - msvq_decoder( - cdk_37bits, - stages_37bits, - N, - maxN_37bits, - indices, - v16 ); + msvq_decoder( cdk_37bits, stages_37bits, N, maxN_37bits, indices, v16 ); FOR( i = 0; i < N; i++ ) { @@ -2366,16 +2360,13 @@ void FdCng_decodeSID_fx( Decoder_State *corest ) /* Decode gain */ // gain = ((float)index - gain_q_offset) / 1.5f; - { - /* format gain: Q9.23 */ - gain = L_shl( L_deposit_l( index ), WORD32_BITS - 1 - 8 ); - gain = L_sub( gain, L_shl( gain_q_offset, 23 ) /*60.0 Q23*/ ); /*Q23*/ - gain = Mpy_32_16_1( gain, 21845 /*2.0f/3.0f Q15*/ ); /*Q23*/ - } - + /* format gain: Q9.23 */ + gain = L_shl( L_deposit_l( index ), WORD32_BITS - 1 - 8 ); + gain = L_sub( gain, L_shl( gain_q_offset, 23 ) /*60.0 Q23*/ ); /*Q23*/ + gain = Mpy_32_16_1( gain, 21845 /*2.0f/3.0f Q15*/ ); /*Q23*/ /* Apply gain and undo log */ - IF( corest->element_mode == EVS_MONO ) + IF( EQ_16( st->element_mode, EVS_MONO ) ) { /* format gain: Q9.23 */ /* calculate worst case for scaling */ @@ -2432,7 +2423,7 @@ void FdCng_decodeSID_fx( Decoder_State *corest ) /* NB last band energy compensation */ - IF( hFdCngCom->CngBandwidth == NB ) + IF( EQ_16( hFdCngCom->CngBandwidth, NB ) ) { sidNoiseEst[( N - 1 )] = Mpy_32_16_1( sidNoiseEst[( N - 1 )], NB_LAST_BAND_SCALE ); move32(); @@ -2446,7 +2437,7 @@ void FdCng_decodeSID_fx( Decoder_State *corest ) } scalebands( sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), hFdCngCom->cngNoiseLevel, 1 ); - IF( EQ_16( corest->element_mode, EVS_MONO ) ) + IF( EQ_16( st->element_mode, EVS_MONO ) ) { hFdCngCom->cngNoiseLevelExp = hFdCngCom->sidNoiseEstExp; move16(); @@ -2465,7 +2456,7 @@ void FdCng_decodeSID_fx( Decoder_State *corest ) } move16(); - lpc_from_spectrum( hFdCngCom, hFdCngCom->startBand, hFdCngCom->stopFFTbin, corest->preemph_fac ); + lpc_from_spectrum( hFdCngCom, hFdCngCom->startBand, hFdCngCom->stopFFTbin, st->preemph_fac ); } #endif -- GitLab