From 583b832e3d02c7fd6eb7c20f484bb3efca3b712a Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Wed, 20 May 2026 20:04:56 +0200 Subject: [PATCH 1/6] harmonize remaining duplicates --- lib_com/options.h | 1 + lib_com/prot_fx.h | 21 +- lib_enc/igf_enc_fx.c | 595 ++++++++++++++--------- lib_enc/ivas_corecoder_enc_reconfig_fx.c | 4 +- lib_enc/ivas_mct_enc_fx.c | 2 +- lib_enc/prot_fx_enc.h | 23 + 6 files changed, 416 insertions(+), 230 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 27e64a41c..208573139 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -92,6 +92,7 @@ #define NONBE_FIX_ISSUE_2206_AVOID_OVERFLOW_MSVQ_Interpol_Tran_fx /* FhG: Fix saturation crash in MSVQ_Interpol_Tran_fx() */ #define NONBE_FIX_ISSUE_2206_SWB_EXPERIMENT_FIX_2527 /* Fix crash from issue #2527 */ #define FIX_FLOAT_1539_G192_FORMAT_SWITCH /* VA/Nokia: reintroduce format switching for g192 bitstreams */ +#define FIX_2346_DUPLICATED_IGF_FUNCTIONS_3 /* Harmonize duplicate IGF functions (getCrest, getSFM, Reconfig) */ /* #################### End BE switches ################################## */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 196a37583..bcedeed89 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -9602,6 +9602,7 @@ Word16 msvq_stage1_dct_recalc_candidates_fdcng_wb_fx( Word16 *dist_ptr_e /* i/o: exp for updated MSE vector for stage1 */ ); +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_3 ivas_error IGF_Reconfig_fx( IGF_ENC_INSTANCE_HANDLE *hIGFEnc, /* i/o: instance handle of IGF Encoder */ const Word16 igf, /* i : IGF on/off */ @@ -9611,6 +9612,17 @@ ivas_error IGF_Reconfig_fx( const Word16 element_mode, /* i : IVAS element mode */ const Word16 rf_mode /* i : flag to signal the RF mode */ ); +#else +ivas_error IGF_Reconfig( + IGF_ENC_INSTANCE_HANDLE *hIGFEnc, /* i/o: instance handle of IGF Encoder */ + const Word16 igf, /* i : IGF on/off */ + const Word16 reset, /* i : reset flag */ + const Word32 brate, /* i : bitrate for configuration */ + const Word16 bwidth, /* i : signal bandwidth */ + const Word16 element_mode, /* i : IVAS element mode */ + const Word16 rf_mode /* i : flag to signal the RF mode */ +); +#endif void residu_ivas_fx( const Word16 *a, /* i : LP filter coefficients Q31-a_exp*/ @@ -10100,14 +10112,5 @@ Word16 is_EVS_bitrate( Word16 *Opt_AMR_WB /* i : AMR-WB IO flag */ ); -ivas_error IGF_Reconfig( - IGF_ENC_INSTANCE_HANDLE *hIGFEnc, /* i/o: instance handle of IGF Encoder */ - const Word16 igf, /* i : IGF on/off */ - const Word16 reset, /* i : reset flag */ - const Word32 brate, /* i : bitrate for configuration */ - const Word16 bwidth, /* i : signal bandwidth */ - const Word16 element_mode, /* i : IVAS element mode */ - const Word16 rf_mode /* i : flag to signal the RF mode */ -); #endif diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c index 27c3a7f2f..48c85c55f 100644 --- a/lib_enc/igf_enc_fx.c +++ b/lib_enc/igf_enc_fx.c @@ -380,6 +380,146 @@ crest factor calculation **************************************************************************/ /* o: Q15| crest factor */ +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_3 +Word16 IGF_getCrest_fx( + Word16 *crest_exp, /* o : exponent of crest factor */ + const Word32 *powerSpectrum, /* i : Q31 | power spectrum (NULL if logSpec provided) */ + const Word16 *powerSpectrum_exp, /* i : exponent of power spectrum (NULL if logSpec provided) */ + const Word16 *logSpec, /* i : pre-calculated log spectrum (NULL if using raw path) */ + const Word16 start, /* i : Q0 | start subband index */ + const Word16 stop, /* i : Q0 | stop subband index */ + const Word16 element_mode /* i : IVAS element mode type */ +) +{ + Word16 i; + Word16 x; + Word32 x_eff32; + Word16 x_max; + Word16 crest; + Word16 s; + Word16 tmp; + Word32 tmp32; + Word16 powSpec_exp; + + x_eff32 = 0; + move32(); + x_max = 0; + move16(); + crest = 16384 /*.5f Q15*/; + move16(); + *crest_exp = 1; + move16(); + + IF( logSpec == NULL ) + { + /* Raw path: compute from powerSpectrum */ + powSpec_exp = powerSpectrum_exp[0]; + move16(); + + FOR( i = start; i < stop; i++ ) + { + if ( GT_16( element_mode, EVS_MONO ) ) + { + powSpec_exp = powerSpectrum_exp[i]; /* exponent is a vector in IVAS (and a scalar in EVS) */ + move16(); + } + x = sub( sub( powSpec_exp, norm_l( powerSpectrum[i] ) ), 1 ); /*Q0*/ + + if ( powerSpectrum[i] == 0 ) /*special case: energy is zero*/ + { + x = 0; + move16(); + } + x = s_max( 0, x ); + x_eff32 = L_mac0( x_eff32, x, x ); /*Q0*/ + x_max = s_max( x_max, x ); /*Q0*/ + } + } + ELSE + { + /* Optimized path: use pre-calculated logSpec */ + FOR( i = start; i < stop; i++ ) + { + x = logSpec[i]; + move16(); + x_eff32 = L_mac0( x_eff32, x, x ); + + if ( GT_16( x, x_max ) ) + { + x_max = x; + move16(); + } + } + } + + /* Common section: crest calculation */ + IF( logSpec == NULL ) + { + /*x_eff /= (stop - start);*/ + x_eff32 = BASOP_Util_Divide3216_Scale( x_eff32, sub( stop, start ), &s ); /*Q-1, s*/ + s = add( s, 32 ); /*make x_eff Q31*/ + + /*trunkate to int*/ + x_eff32 = L_shr( x_eff32, sub( 31, s ) ); + x_eff32 = L_shl( x_eff32, sub( 31, s ) ); + } + ELSE + { + x_eff32 = BASOP_Util_Divide3216_Scale( x_eff32, sub( stop, start ), &tmp ); + tmp = add( tmp, 16 ); /*exp += 31 - 15 + 16(because x_eff is word32)*/ + x_eff32 = L_shr( x_eff32, sub( 15, tmp ) ); + s = 15; + move16(); + } + + test(); + IF( x_eff32 > 0 && x_max > 0 ) + { + IF( logSpec == NULL ) + { + /*crest = max(1.f, (float)x_max/sqrt(x_eff));*/ + tmp32 = ISqrt32( x_eff32, &s ); /*Q31, s*/ + tmp32 = Mpy_32_16_1( tmp32 /*Q31, s*/, x_max /*Q0*/ ); /*Q16, s*/ + i = norm_l( tmp32 ); + tmp32 = L_shl( tmp32, i ); /*Q31, s-i+15*/ + crest = extract_h( tmp32 ); + *crest_exp = add( sub( s, i ), 15 ); + move16(); + /* limit crest factor to a lower bound of 1, may overflow */ + BASOP_SATURATE_WARNING_OFF_EVS + tmp = shl_sat( -1, sub( 15, *crest_exp ) ); /* build negative threshold */ + tmp = add_sat( crest, tmp ); + BASOP_SATURATE_WARNING_ON_EVS + if ( tmp < 0 ) + { + crest = 1; + move16(); + } + if ( tmp < 0 ) + { + *crest_exp = 15; + move16(); + } + } + ELSE + { + tmp = Sqrt16( extract_l( x_eff32 ), &s ); + i = sub( 15, s ); + IF( i < 0 ) + { + x_max = shl( x_max, i ); + i = 0; + move16(); + } + crest = BASOP_Util_Divide1616_Scale( x_max, tmp, crest_exp ); + *crest_exp = add( *crest_exp, i ); + crest = s_max( shl_sat( 1, sub( 15, *crest_exp ) ), crest ); + } + } + + return crest; +} +#else Word16 IGF_getCrest( Word16 *crest_exp, /* o : exponent of crest factor */ const Word32 *powerSpectrum, /* i : Q31 | power spectrum */ @@ -470,13 +610,182 @@ Word16 IGF_getCrest( return crest; } - +#endif /************************************************************************* calculates spectral flatness measurment **************************************************************************/ /* o: Q15| SFM value */ +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_3 +Word16 IGF_getSFM_fx( + Word16 *SFM_exp, /* o : | exponent of SFM Factor */ + const Word32 *energy, /* i : Q31| energies (or powerSpectrum if logSpec provided) */ + const Word16 *energy_exp, /* i : | exponent of energies (or e_ps if logSpec provided) */ + const Word16 *logSpec, /* i : pre-calculated log spectrum (NULL if using raw path) */ + const Word16 start, /* i : Q0 | start subband index */ + const Word16 stop, /* i : Q0 | stop subband index */ + const Word16 element_mode /* i : | IVAS element mode type */ +) +{ + Word16 n, i, s; + Word32 num; + Word32 denom; + Word16 denom_exp; + Word16 invDenom_exp, numf_exp; + Word16 numf; + Word32 SFM32; + Word16 invDenom, SFM; + Word16 en_exp; + Word32 tmp; + Word16 tmp_e; + + num = 0; + move32(); + *SFM_exp = 0; + move16(); + SFM = 32767 /*1.0f Q15*/; + move16(); + en_exp = energy_exp[0]; + move16(); + denom_exp = 0; + move16(); + + IF( logSpec == NULL ) + { + /* Raw path: EVS-style calculation */ + Word64 W_denom; + W_denom = 0; + move64(); + + if ( EQ_16( element_mode, EVS_MONO ) ) + { + denom = L_shr( 2147483 /*0,001 in Q31 - float is "1", here*/, s_min( en_exp, 31 ) ); + denom = L_max( denom, 1 ); + move32(); + move32(); + W_denom = W_deposit32_l( denom ); + move64(); + } + else + { + denom = 65536; // 1.f in Q16 + move32(); + denom_exp = 15; + move16(); + } + + IF( EQ_16( element_mode, EVS_MONO ) ) + { + FOR( i = start; i < stop; i++ ) + { + n = sub( sub( en_exp, norm_l( energy[i] ) ), 1 ); /*<-- short form*/ + + if ( energy[i] == 0 ) /*special case: energy is zero*/ + { + n = 0; + move16(); + } + + n = s_max( 0, n ); + num = L_add( num, L_deposit_l( n ) ); /*Q0*/ + W_denom = W_add( W_deposit32_l( energy[i] ), W_denom ); + } + } + ELSE + { + FOR( i = start; i < stop; i++ ) + { + en_exp = energy_exp[i]; /* exponent is a vector in IVAS (and a scalar in EVS) */ + move16(); + n = sub( sub( en_exp, norm_l( energy[i] ) ), 1 ); /*<-- short form*/ + + if ( energy[i] == 0 ) /*special case: energy is zero*/ + { + n = 0; + move16(); + } + + n = s_max( 0, n ); + num = L_add( num, L_deposit_l( n ) ); /*Q0*/ + denom = BASOP_Util_Add_Mant32Exp( energy[i], en_exp, denom, denom_exp, &denom_exp ); + } + } + + IF( EQ_16( element_mode, EVS_MONO ) ) + { + denom = w_norm_llQ31( W_denom, &denom_exp ); /*Q31*/ + denom_exp = add( denom_exp, en_exp ); + } + } + ELSE + { + /* Optimized path: use pre-calculated logSpec */ + denom = ONE_IN_Q30; + denom_exp = 1; + move32(); + move16(); + + FOR( i = start; i < stop; i++ ) + { + tmp = energy[i]; + n = logSpec[i]; + move32(); + move16(); + num = add( num, n ); + denom = BASOP_Util_Add_Mant32Exp( tmp, energy_exp[i], denom, denom_exp, &denom_exp ); + } + + denom = BASOP_Util_Divide3216_Scale( denom, sub( stop, start ), &tmp_e ); + denom_exp = add( add( denom_exp, tmp_e ), 1 ); /*denom_exp+tmp_e-15 +16(because type of denom is word32)*/ + } + + /* calculate SFM only if signal is present */ + IF( denom != 0 ) + { + /*numf = (float)num / (float)(stop - start);*/ + numf = BASOP_Util_Divide3216_Scale( num, /*Q0*/ + sub( stop, start ), /*Q0*/ + &s ); /*Q-1 s*/ + numf_exp = add( s, 16 ); /*-> numf Q15 numf_exp*/ + /*denom /= (float)(stop - start);*/ + /*return ((float)pow(2.0, numf + 0.5f) / denom);*/ + + /*SFM= ((float)pow(2.0, numf + 0.5f) * invDenom);*/ + invDenom = BASOP_Util_Divide3232_uu_1616_Scale( L_deposit_l( sub( stop, start ) ) /*Q0*/, + denom /*Q31, denom_exp*/, + &s ); /*Q-16, s-denom_exp*/ + invDenom_exp = add( sub( s, denom_exp ), 31 ); /*invDenom: Q15, invDenom_exp*/ + + /*add .5f to numf*/ + SFM32 = L_add( L_shl( L_deposit_l( numf ), numf_exp ) /*16Q15*/, 16384l /*.5f Q15*/ ); /*16Q15*/ + s = norm_l( SFM32 ); + SFM32 = L_shl( SFM32, s ); + s = sub( 16, s ); /*SFM32(numf) is Q31 now*/ + + /*do the pow2 and the mult*/ + SFM32 = BASOP_util_Pow2( SFM32, s, &s ); + SFM32 = Mpy_32_16_1( SFM32, invDenom ); + *SFM_exp = add( s, invDenom_exp ); + + /*Transform to Q15*/ + s = norm_l( SFM32 ); + SFM = round_fx_sat( L_shl_sat( SFM32, s ) ); + *SFM_exp = sub( *SFM_exp, s ); + move16(); + /**SFM_exp = s_min(*SFM_exp, 0);*/ + IF( *SFM_exp > 0 ) + { + *SFM_exp = 0; + move16(); + SFM = 32767 /*1.0f Q15*/; + move16(); + } + } + + return SFM /*Q15*/; +} +#else Word16 IGF_getSFM( Word16 *SFM_exp, /* o : | exponent of SFM Factor */ const Word32 *energy, /* i : Q31| energies */ @@ -526,10 +835,6 @@ Word16 IGF_getSFM( move16(); } - /*ln(x * 2^-Qx * 2^xExp) = ln(x) - Qx + xExp*/ - /* n = sub(sub(31,norm_l(tmp32)),1); */ /*<- ld */ - /* n = sub(n,31); */ /*<- -Qx */ - /* n = add(n,*energy_exp); */ /*<- +xExp */ IF( EQ_16( element_mode, EVS_MONO ) ) { FOR( i = start; i < stop; i++ ) @@ -573,40 +878,29 @@ Word16 IGF_getSFM( denom_exp = add( denom_exp, en_exp ); } - /* calculate SFM only if signal is present */ IF( denom != 0 ) { - /*numf = (float)num / (float)(stop - start);*/ - numf = BASOP_Util_Divide3216_Scale( num, /*Q0*/ - sub( stop, start ), /*Q0*/ - &s ); /*Q-1 s*/ - numf_exp = add( s, 16 ); /*-> numf Q15 numf_exp*/ - /*denom /= (float)(stop - start);*/ - /*return ((float)pow(2.0, numf + 0.5f) / denom);*/ + numf = BASOP_Util_Divide3216_Scale( num, sub( stop, start ), &s ); + numf_exp = add( s, 16 ); - /*SFM= ((float)pow(2.0, numf + 0.5f) * invDenom);*/ invDenom = BASOP_Util_Divide3232_uu_1616_Scale( L_deposit_l( sub( stop, start ) ) /*Q0*/, denom /*Q31, denom_exp*/, &s ); /*Q-16, s-denom_exp*/ - invDenom_exp = add( sub( s, denom_exp ), 31 ); /*invDenom: Q15, invDenom_exp*/ + invDenom_exp = add( sub( s, denom_exp ), 31 ); - /*add .5f to numf*/ SFM32 = L_add( L_shl( L_deposit_l( numf ), numf_exp ) /*16Q15*/, 16384l /*.5f Q15*/ ); /*16Q15*/ s = norm_l( SFM32 ); SFM32 = L_shl( SFM32, s ); - s = sub( 16, s ); /*SFM32(numf) is Q31 now*/ + s = sub( 16, s ); - /*do the pow2 and the mult*/ SFM32 = BASOP_util_Pow2( SFM32, s, &s ); SFM32 = Mpy_32_16_1( SFM32, invDenom ); *SFM_exp = add( s, invDenom_exp ); - /*Transform to Q15*/ s = norm_l( SFM32 ); SFM = round_fx_sat( L_shl_sat( SFM32, s ) ); *SFM_exp = sub( *SFM_exp, s ); move16(); - /**SFM_exp = s_min(*SFM_exp, 0);*/ IF( *SFM_exp > 0 ) { *SFM_exp = 0; @@ -618,139 +912,7 @@ Word16 IGF_getSFM( return SFM /*Q15*/; } - - -/*-------------------------------------------------------------------* - * IGF_getCrest_new() - * - * crest factor calculation - *-------------------------------------------------------------------*/ - -/*! r: crest factor */ -static Word16 IGF_getCrest_new_fx( - const Word16 *logSpec, /* i : power spectrum */ - const Word16 start, /* i : start subband index */ - const Word16 stop, /* i : stop subband index */ - Word16 *crest_exp /*Stores the exponent of the result(return value)*/ -) -{ - Word16 i; - Word16 x; - Word32 x_eff; - Word16 x_max; - Word16 exp; - Word16 temp; - Word16 temp_e; - Word16 crest; /*1.0f in Q15*/ - x_eff = 0; - x_max = 0; - exp = 0; - temp = 0; - crest = 32767; /*1.0f in Q15*/ - move32(); - move16(); - move16(); - move16(); - move16(); - - FOR( i = start; i < stop; i++ ) - { - x = logSpec[i]; - move16(); - x_eff = L_mac0( x_eff, x, x ); - - if ( GT_16( x, x_max ) ) - { - x_max = x; - move16(); - } - } - - x_eff = BASOP_Util_Divide3216_Scale( x_eff, sub( stop, start ), &temp_e ); - temp_e = add( temp_e, 16 ); /*exp += 31 - 15 + 16(because x_eff is word32)*/ - x_eff = L_shr( x_eff, sub( 15, temp_e ) ); - temp_e = 15; - move16(); - temp = Sqrt16( extract_l( x_eff ), &temp_e ); - - test(); - IF( x_eff > 0 && x_max > 0 ) - { - temp = BASOP_Util_Divide1616_Scale( x_max, temp, &exp ); - exp = add( exp, sub( 15, temp_e ) ); - IF( exp < 0 ) - { - temp = shl( temp, exp ); - exp = 0; - move16(); - } - crest = s_max( shl_sat( 1, sub( 15, exp ) ), temp ); - } - *crest_exp = exp; - move16(); - return crest; -} - -/*-------------------------------------------------------------------* - * IGF_getSFM_new() - * - * calculates spectral flatness measurement - *-------------------------------------------------------------------*/ - -/*! r: SFM value */ -static Word16 IGF_getSFM_new_fx( - const Word32 *powerSpectrum, /* i : power spectrum */ - const Word16 *logSpec, /* i : log of power spectrum */ - const Word16 start, /* i : start subband index */ - const Word16 stop, /* i : stop subband index */ - Word16 *e_ps /*Stores exp related to power spectrum*/ -) -{ - Word16 n; - Word16 i; - Word16 num; - Word32 denom; - Word16 numf; - Word32 tmp; - Word16 sfm; - Word16 sfm_e; - Word16 denom_e; - Word16 numf_e; /*stores exponent for numf*/ - Word16 tmp_e; - - num = 0; - denom = ONE_IN_Q30; - denom_e = 1; - sfm = MAX16B; // Q15 - move16(); - move32(); - move16(); - move16(); - - FOR( i = start; i < stop; i++ ) - { - tmp = powerSpectrum[i]; - n = logSpec[i /*-start*/]; - move32(); - move16(); - num = add( num, n ); - denom = BASOP_Util_Add_Mant32Exp( tmp, e_ps[i], denom, denom_e, &denom_e ); - } - - numf = BASOP_Util_Divide1616_Scale( num, sub( stop, start ), &numf_e ); - denom = BASOP_Util_Divide3216_Scale( denom, sub( stop, start ), &tmp_e ); - denom_e = add( add( denom_e, tmp_e ), 1 ); /*denom_e+tmp_e-15 +16(because type of denom is word32)*/ - - IF( denom != 0 ) - { - tmp = BASOP_util_Pow2( L_add( numf, shl_sat( 1, sub( 14, numf_e ) ) ), add( 16, numf_e ), &tmp_e ); - sfm = BASOP_Util_Divide3232_Scale( tmp, denom, &sfm_e ); - sfm_e = add( sfm_e, sub( tmp_e, denom_e ) ); - sfm = shl_sat( extract_l( L_min( sfm, L_shl_sat( 1, sub( 15, sfm_e ) ) ) ), sfm_e ); - } - - return sfm; -} +#endif /*-------------------------------------------------------------------* * IGF_Whitening() @@ -880,8 +1042,8 @@ static void IGF_Whitening( } ELSE IF( EQ_16( element_mode, EVS_MONO ) ) { - SFM = IGF_getSFM( &SFM_e, powerSpectrum, powerSpectrum_e, hGrid->tile[p], hGrid->tile[p + 1], element_mode ); - crest = IGF_getCrest( &crest_e, powerSpectrum, powerSpectrum_e, hGrid->tile[p], hGrid->tile[p + 1], element_mode ); + SFM = IGF_getSFM_fx( &SFM_e, powerSpectrum, powerSpectrum_e, NULL, hGrid->tile[p], hGrid->tile[p + 1], element_mode ); + crest = IGF_getCrest_fx( &crest_e, powerSpectrum, powerSpectrum_e, NULL, hGrid->tile[p], hGrid->tile[p + 1], element_mode ); tmp = BASOP_Util_Divide1616_Scale( SFM, crest, &s ); /* Q15 */ s = add( s, sub( SFM_e, crest_e ) ); @@ -889,8 +1051,8 @@ static void IGF_Whitening( } ELSE { - SFM = IGF_getSFM_new_fx( powerSpectrum, hPrivateData->logSpec, hGrid->tile[p], hGrid->tile[p + 1], powerSpectrum_e ); - crest = IGF_getCrest_new_fx( hPrivateData->logSpec, hGrid->tile[p], hGrid->tile[p + 1], &crest_e ); + SFM = IGF_getSFM_fx( &SFM_e, powerSpectrum, powerSpectrum_e, hPrivateData->logSpec, hGrid->tile[p], hGrid->tile[p + 1], element_mode ); + crest = IGF_getCrest_fx( &crest_e, NULL, NULL, hPrivateData->logSpec, hGrid->tile[p], hGrid->tile[p + 1], element_mode ); tmp = BASOP_Util_Divide1616_Scale( SFM, crest, &tmp_e ); tmp_e = sub( tmp_e, crest_e ); } @@ -1679,6 +1841,7 @@ Word16 IGFEncWriteConcatenatedBitstream_fx( } +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_3 ivas_error IGF_Reconfig_fx( IGF_ENC_INSTANCE_HANDLE *hIGFEnc, /* i/o: instance handle of IGF Encoder */ const Word16 igf, /* i : IGF on/off */ @@ -1717,6 +1880,46 @@ ivas_error IGF_Reconfig_fx( return error; } +#else +ivas_error IGF_Reconfig( + IGF_ENC_INSTANCE_HANDLE *hIGFEnc, /* i/o: instance handle of IGF Encoder */ + const Word16 igf, /* i : IGF on/off */ + const Word16 reset, /* i : reset flag */ + const Word32 brate, /* i : bitrate for configuration */ + const Word16 bwidth, /* i : signal bandwidth */ + const Word16 element_mode, /* i : IVAS element mode */ + const Word16 rf_mode /* i : flag to signal the RF mode */ +) +{ + ivas_error error; + + error = IVAS_ERR_OK; + move32(); + + test(); + test(); + test(); + IF( igf && *hIGFEnc == NULL ) + { + IF( ( *hIGFEnc = (IGF_ENC_INSTANCE_HANDLE) malloc( sizeof( IGF_ENC_INSTANCE ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hIGFEnc\n" ) ); + } + IGFEncSetMode_fx( *hIGFEnc, brate, bwidth, element_mode, rf_mode ); + } + ELSE IF( igf && reset ) + { + IGFEncSetMode_fx( *hIGFEnc, brate, bwidth, element_mode, rf_mode ); + } + ELSE IF( !igf && *hIGFEnc != NULL ) + { + free( *hIGFEnc ); + *hIGFEnc = NULL; + } + + return error; +} +#endif #define INV_Log2_10_Q15 9864 /*1/log2(10) in Q15*/ @@ -2122,16 +2325,16 @@ static void IGF_CalculateEnvelope_fx( move16(); // tmp_tb = IGF_getSFM_new( pPowerSpectrum, hPrivateData->logSpec, swb_offset[sfb], swb_offset[sfb + 1] ) / IGF_getCrest_new( hPrivateData->logSpec, swb_offset[sfb], swb_offset[sfb + 1] ); - sfm = IGF_getSFM_new_fx( pPowerSpectrum_fx, hPrivateData->logSpec, swb_offset[sfb], swb_offset[sfb + 1], e_ps ); + sfm = IGF_getSFM_fx( &sfm_exp, pPowerSpectrum_fx, e_ps, hPrivateData->logSpec, swb_offset[sfb], swb_offset[sfb + 1], IVAS_CPE_MDCT ); sfm_exp = 0; move16(); - crest = IGF_getCrest_new_fx( hPrivateData->logSpec, swb_offset[sfb], swb_offset[sfb + 1], &crest_exp ); + crest = IGF_getCrest_fx( &crest_exp, NULL, NULL, hPrivateData->logSpec, swb_offset[sfb], swb_offset[sfb + 1], IVAS_CPE_MDCT ); tmp_tb = BASOP_Util_Divide1616_Scale( sfm, crest, &tmp_e ); // tmp_tb_e tmp_tb_e = add( tmp_e, sub( sfm_exp, crest_exp ) ); // tmp_sb = IGF_getSFM_new( pPowerSpectrum, hPrivateData->logSpec, tmp, strt_cpy ) / IGF_getCrest_new( hPrivateData->logSpec, tmp, strt_cpy ); - sfm = IGF_getSFM_new_fx( pPowerSpectrum_fx, hPrivateData->logSpec, tmp, strt_cpy, e_ps ); - crest = IGF_getCrest_new_fx( hPrivateData->logSpec, tmp, strt_cpy, &crest_exp ); + sfm = IGF_getSFM_fx( &sfm_exp, pPowerSpectrum_fx, e_ps, hPrivateData->logSpec, tmp, strt_cpy, IVAS_CPE_MDCT ); + crest = IGF_getCrest_fx( &crest_exp, NULL, NULL, hPrivateData->logSpec, tmp, strt_cpy, IVAS_CPE_MDCT ); tmp_sb = BASOP_Util_Divide1616_Scale( sfm, crest, &tmp_e ); // tmp_sb_e tmp_sb_e = add( tmp_e, sub( sfm_exp, crest_exp ) ); @@ -2271,16 +2474,16 @@ static void IGF_CalculateEnvelope_fx( IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( slope, add( slope_e, 16 ), negate( threshold ), add( threshold_e, 16 ) ), -1 ) ) { Word16 shift = shr( width, 1 ); - sfm = IGF_getSFM_new_fx( pPowerSpectrum_fx, hPrivateData->logSpec, swb_offset[sfb] - shift, swb_offset[sfb + 1] - shift, e_ps ); - crest = IGF_getCrest_new_fx( hPrivateData->logSpec, swb_offset[sfb] - shift, swb_offset[sfb + 1] - shift, &crest_exp ); + sfm = IGF_getSFM_fx( &sfm_exp, pPowerSpectrum_fx, e_ps, hPrivateData->logSpec, swb_offset[sfb] - shift, swb_offset[sfb + 1] - shift, IVAS_CPE_MDCT ); + crest = IGF_getCrest_fx( &crest_exp, NULL, NULL, hPrivateData->logSpec, swb_offset[sfb] - shift, swb_offset[sfb + 1] - shift, IVAS_CPE_MDCT ); shiftedSFM = BASOP_Util_Divide1616_Scale( sfm, crest, &shiftedSFM_e ); } ELSE IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( slope, add( slope_e, 16 ), threshold, add( threshold_e, 16 ) ), 1 ) && ( NE_16( sfb, sub( hGrid->sfbWrap[hGrid->nTiles], 1 ) ) ) ) { Word16 shift = shr( width, 1 ); - shiftedSFM = BASOP_Util_Divide1616_Scale( IGF_getSFM_new_fx( pPowerSpectrum_fx, hPrivateData->logSpec, swb_offset[sfb] + shift, swb_offset[sfb + 1] + shift, e_ps ), IGF_getCrest_new_fx( hPrivateData->logSpec, swb_offset[sfb] + shift, swb_offset[sfb + 1] + shift, &crest_exp ), &tmp_e ); - sfm = IGF_getSFM_new_fx( pPowerSpectrum_fx, hPrivateData->logSpec, swb_offset[sfb] + shift, swb_offset[sfb + 1] + shift, e_ps ); - crest = IGF_getCrest_new_fx( hPrivateData->logSpec, swb_offset[sfb] + shift, swb_offset[sfb + 1] + shift, &crest_exp ); + shiftedSFM = BASOP_Util_Divide1616_Scale( IGF_getSFM_fx( &sfm_exp, pPowerSpectrum_fx, e_ps, hPrivateData->logSpec, swb_offset[sfb] + shift, swb_offset[sfb + 1] + shift, IVAS_CPE_MDCT ), IGF_getCrest_fx( &crest_exp, NULL, NULL, hPrivateData->logSpec, swb_offset[sfb] + shift, swb_offset[sfb + 1] + shift, IVAS_CPE_MDCT ), &tmp_e ); + sfm = IGF_getSFM_fx( &sfm_exp, pPowerSpectrum_fx, e_ps, hPrivateData->logSpec, swb_offset[sfb] + shift, swb_offset[sfb + 1] + shift, IVAS_CPE_MDCT ); + crest = IGF_getCrest_fx( &crest_exp, NULL, NULL, hPrivateData->logSpec, swb_offset[sfb] + shift, swb_offset[sfb + 1] + shift, IVAS_CPE_MDCT ); shiftedSFM = BASOP_Util_Divide1616_Scale( sfm, crest, &shiftedSFM_e ); } shiftedSFM_e = add( shiftedSFM_e, sub( sfm_exp, crest_exp ) ); @@ -2763,17 +2966,17 @@ static void IGF_CalculateStereoEnvelope_fx( move16(); // tmp_tb = IGF_getSFM(pPowerSpectrum, swb_offset[sfb], swb_offset[sfb + 1]) / IGF_getCrest(pPowerSpectrum, swb_offset[sfb], swb_offset[sfb + 1]); - sfm = IGF_getSFM( &sfm_exp, pPowerSpectrum_fx, pPowerSpectrum_e, swb_offset[sfb], swb_offset[sfb + 1], IVAS_CPE_MDCT ); + sfm = IGF_getSFM_fx( &sfm_exp, pPowerSpectrum_fx, pPowerSpectrum_e, NULL, swb_offset[sfb], swb_offset[sfb + 1], IVAS_CPE_MDCT ); - crest = IGF_getCrest( &crest_exp, pPowerSpectrum_fx, pPowerSpectrum_e, swb_offset[sfb], swb_offset[sfb + 1], IVAS_CPE_MDCT ); + crest = IGF_getCrest_fx( &crest_exp, pPowerSpectrum_fx, pPowerSpectrum_e, NULL, swb_offset[sfb], swb_offset[sfb + 1], IVAS_CPE_MDCT ); tmp_tb_fx = BASOP_Util_Divide1616_Scale( sfm, crest, &tmp_e ); tmp_tb_e = add( tmp_e, sub( sfm_exp, crest_exp ) ); /*stores the resultant exponent for tmp_tb_fx*/ // tmp_sb = IGF_getSFM(tileSrcSpec, 0, strt_cpy - tmp) / IGF_getCrest(tileSrcSpec, 0, strt_cpy - tmp); - sfm = IGF_getSFM( &sfm_exp, tileSrcSpec_fx, tileSrcSpec_e, 0, sub( strt_cpy, tmp ), IVAS_CPE_MDCT ); + sfm = IGF_getSFM_fx( &sfm_exp, tileSrcSpec_fx, tileSrcSpec_e, NULL, 0, sub( strt_cpy, tmp ), IVAS_CPE_MDCT ); - crest = IGF_getCrest( &crest_exp, tileSrcSpec_fx, tileSrcSpec_e, 0, sub( strt_cpy, tmp ), IVAS_CPE_MDCT ); + crest = IGF_getCrest_fx( &crest_exp, tileSrcSpec_fx, tileSrcSpec_e, NULL, 0, sub( strt_cpy, tmp ), IVAS_CPE_MDCT ); tmp_sb_fx = BASOP_Util_Divide1616_Scale( sfm, crest, &tmp_e ); tmp_sb_e = add( tmp_e, sub( sfm_exp, crest_exp ) ); /*stores the resultant exponent for tmp_sb_fx*/ @@ -2919,9 +3122,9 @@ static void IGF_CalculateStereoEnvelope_fx( Word16 shift = shr( width, 1 ); // shiftedSFM = IGF_getSFM( pPowerSpectrum, swb_offset[sfb] - shift, swb_offset[sfb + 1] - shift ) / IGF_getCrest( pPowerSpectrum, swb_offset[sfb] - shift, swb_offset[sfb + 1] - shift ); - sfm = IGF_getSFM( &sfm_exp, pPowerSpectrum_fx, pPowerSpectrum_e, sub( swb_offset[sfb], shift ), sub( swb_offset[sfb + 1], shift ), IVAS_CPE_MDCT ); + sfm = IGF_getSFM_fx( &sfm_exp, pPowerSpectrum_fx, pPowerSpectrum_e, NULL, sub( swb_offset[sfb], shift ), sub( swb_offset[sfb + 1], shift ), IVAS_CPE_MDCT ); - crest = IGF_getCrest( &crest_exp, pPowerSpectrum_fx, pPowerSpectrum_e, sub( swb_offset[sfb], shift ), sub( swb_offset[sfb + 1], shift ), IVAS_CPE_MDCT ); + crest = IGF_getCrest_fx( &crest_exp, pPowerSpectrum_fx, pPowerSpectrum_e, NULL, sub( swb_offset[sfb], shift ), sub( swb_offset[sfb + 1], shift ), IVAS_CPE_MDCT ); shiftedSFM_fx = BASOP_Util_Divide1616_Scale( sfm, crest, &shiftedSFM_e ); } @@ -2931,9 +3134,9 @@ static void IGF_CalculateStereoEnvelope_fx( shift = shr( width, 1 ); // shiftedSFM = IGF_getSFM( pPowerSpectrum, swb_offset[sfb] + shift, swb_offset[sfb + 1] + shift ) / IGF_getCrest( pPowerSpectrum, swb_offset[sfb] + shift, swb_offset[sfb + 1] + shift ); - sfm = IGF_getSFM( &sfm_exp, pPowerSpectrum_fx, pPowerSpectrum_e, add( swb_offset[sfb], shift ), add( swb_offset[sfb + 1], shift ), IVAS_CPE_MDCT ); + sfm = IGF_getSFM_fx( &sfm_exp, pPowerSpectrum_fx, pPowerSpectrum_e, NULL, add( swb_offset[sfb], shift ), add( swb_offset[sfb + 1], shift ), IVAS_CPE_MDCT ); - crest = IGF_getCrest( &crest_exp, pPowerSpectrum_fx, pPowerSpectrum_e, add( swb_offset[sfb], shift ), add( swb_offset[sfb + 1], shift ), IVAS_CPE_MDCT ); + crest = IGF_getCrest_fx( &crest_exp, pPowerSpectrum_fx, pPowerSpectrum_e, NULL, add( swb_offset[sfb], shift ), add( swb_offset[sfb + 1], shift ), IVAS_CPE_MDCT ); shiftedSFM_fx = BASOP_Util_Divide1616_Scale( sfm, crest, &shiftedSFM_e ); } @@ -3525,47 +3728,3 @@ void IGFSaveSpectrumForITF_ivas_fx( } -/*-------------------------------------------------------------------* - * IGF_Reconfig() - * - * - *-------------------------------------------------------------------*/ - -ivas_error IGF_Reconfig( - IGF_ENC_INSTANCE_HANDLE *hIGFEnc, /* i/o: instance handle of IGF Encoder */ - const Word16 igf, /* i : IGF on/off */ - const Word16 reset, /* i : reset flag */ - const Word32 brate, /* i : bitrate for configuration */ - const Word16 bwidth, /* i : signal bandwidth */ - const Word16 element_mode, /* i : IVAS element mode */ - const Word16 rf_mode /* i : flag to signal the RF mode */ -) -{ - ivas_error error; - - error = IVAS_ERR_OK; - move32(); - - test(); - test(); - test(); - IF( igf && *hIGFEnc == NULL ) - { - IF( ( *hIGFEnc = (IGF_ENC_INSTANCE_HANDLE) malloc( sizeof( IGF_ENC_INSTANCE ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hIGFEnc\n" ) ); - } - IGFEncSetMode_fx( *hIGFEnc, brate, bwidth, element_mode, rf_mode ); - } - ELSE IF( igf && reset ) - { - IGFEncSetMode_fx( *hIGFEnc, brate, bwidth, element_mode, rf_mode ); - } - ELSE IF( !igf && *hIGFEnc != NULL ) - { - free( *hIGFEnc ); - *hIGFEnc = NULL; - } - - return error; -} diff --git a/lib_enc/ivas_corecoder_enc_reconfig_fx.c b/lib_enc/ivas_corecoder_enc_reconfig_fx.c index 9c845eb40..cad67e269 100644 --- a/lib_enc/ivas_corecoder_enc_reconfig_fx.c +++ b/lib_enc/ivas_corecoder_enc_reconfig_fx.c @@ -682,7 +682,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx( st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ); /* Q0 */ move16(); - IF( ( error = IGF_Reconfig( &st_ivas->hCPE[0]->hCoreCoder[n]->hIGFEnc, st_ivas->hCPE[0]->hCoreCoder[n]->igf, 1, st_ivas->hCPE[0]->element_brate, st_ivas->hCPE[0]->hCoreCoder[n]->bwidth, st_ivas->hCPE[0]->hCoreCoder[n]->element_mode, st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ) ) != IVAS_ERR_OK ) + IF( ( error = IGF_Reconfig_fx( &st_ivas->hCPE[0]->hCoreCoder[n]->hIGFEnc, st_ivas->hCPE[0]->hCoreCoder[n]->igf, 1, st_ivas->hCPE[0]->element_brate, st_ivas->hCPE[0]->hCoreCoder[n]->bwidth, st_ivas->hCPE[0]->hCoreCoder[n]->element_mode, st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ) ) != IVAS_ERR_OK ) { return error; } @@ -745,7 +745,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx( move16(); - IF( ( error = IGF_Reconfig( &st_ivas->hCPE[0]->hCoreCoder[n]->hIGFEnc, st_ivas->hCPE[0]->hCoreCoder[n]->igf, 1, st_ivas->hCPE[0]->element_brate, st_ivas->hCPE[0]->hCoreCoder[n]->bwidth, st_ivas->hCPE[0]->hCoreCoder[n]->element_mode, st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ) ) != IVAS_ERR_OK ) + IF( ( error = IGF_Reconfig_fx( &st_ivas->hCPE[0]->hCoreCoder[n]->hIGFEnc, st_ivas->hCPE[0]->hCoreCoder[n]->igf, 1, st_ivas->hCPE[0]->element_brate, st_ivas->hCPE[0]->hCoreCoder[n]->bwidth, st_ivas->hCPE[0]->hCoreCoder[n]->element_mode, st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_enc/ivas_mct_enc_fx.c b/lib_enc/ivas_mct_enc_fx.c index 81a8f7942..4209b82b1 100644 --- a/lib_enc/ivas_mct_enc_fx.c +++ b/lib_enc/ivas_mct_enc_fx.c @@ -753,7 +753,7 @@ ivas_error mct_enc_reconfigure_fx( st->igf = getIgfPresent_fx( st->element_mode, L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC ), st->bwidth, st->rf_mode ); move16(); - IF( ( error = IGF_Reconfig( &st->hIGFEnc, st->igf, 1, st_ivas->hCPE[cpe_id]->element_brate, st->bwidth, st->element_mode, st->rf_mode ) ) != IVAS_ERR_OK ) + IF( ( error = IGF_Reconfig_fx( &st->hIGFEnc, st->igf, 1, st_ivas->hCPE[cpe_id]->element_brate, st->bwidth, st->element_mode, st->rf_mode ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 675710bcb..936e992ba 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -2502,6 +2502,28 @@ void IGF_UpdateInfo( ); /* o: Q15| crest factor */ +#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_3 +Word16 IGF_getCrest_fx( + Word16 *crest_exp, /**< out: | exponent of crest factor */ + const Word32 *powerSpectrum, /**< in: Q31 | power spectrum (NULL if logSpec provided) */ + const Word16 *powerSpectrum_exp, /**< in: | exponent of power spectrum (NULL if logSpec provided) */ + const Word16 *logSpec, /**< in: | pre-calculated log spectrum (NULL if using raw path) */ + const Word16 start, /**< in: Q0 | start subband index */ + const Word16 stop, /**< in: Q0 | stop subband index */ + const Word16 element_mode /**< in: | IVAS element mode type */ +); + +/* o: Q15| SFM value */ +Word16 IGF_getSFM_fx( + Word16 *SFM_exp, /* o : | exponent of SFM Factor */ + const Word32 *energy, /* i : Q31| energies (or powerSpectrum if logSpec provided) */ + const Word16 *energy_exp, /* i : | exponent of energies (or e_ps if logSpec provided) */ + const Word16 *logSpec, /* i : | pre-calculated log spectrum (NULL if using raw path) */ + const Word16 start, /* i : Q0 | start subband index */ + const Word16 stop, /* i : Q0 | stop subband index */ + const Word16 element_mode /* i : | IVAS element mode type */ +); +#else Word16 IGF_getCrest( Word16 *crest_exp, /**< out: | exponent of crest factor */ const Word32 *powerSpectrum, /**< in: Q31 | power spectrum */ @@ -2520,6 +2542,7 @@ Word16 IGF_getSFM( const Word16 stop, /* i : Q0 | stop subband index */ const Word16 element_mode /* i : | IVAS element mode type */ ); +#endif void IGF_ErodeSpectrum( const IGF_ENC_INSTANCE_HANDLE hInstance, /* i : instance handle of IGF Encoder */ -- GitLab From 1e351aee0027358959a5a4ad80447c23e22c9701 Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Wed, 20 May 2026 20:15:10 +0200 Subject: [PATCH 2/6] clang format and fix comment --- lib_com/options.h | 2 +- lib_enc/igf_enc_fx.c | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 208573139..60c5b1e0c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -92,7 +92,7 @@ #define NONBE_FIX_ISSUE_2206_AVOID_OVERFLOW_MSVQ_Interpol_Tran_fx /* FhG: Fix saturation crash in MSVQ_Interpol_Tran_fx() */ #define NONBE_FIX_ISSUE_2206_SWB_EXPERIMENT_FIX_2527 /* Fix crash from issue #2527 */ #define FIX_FLOAT_1539_G192_FORMAT_SWITCH /* VA/Nokia: reintroduce format switching for g192 bitstreams */ -#define FIX_2346_DUPLICATED_IGF_FUNCTIONS_3 /* Harmonize duplicate IGF functions (getCrest, getSFM, Reconfig) */ +#define FIX_2346_DUPLICATED_IGF_FUNCTIONS_3 /* FhG: Harmonize duplicate IGF functions (getCrest, getSFM, Reconfig) */ /* #################### End BE switches ################################## */ diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c index 48c85c55f..edf3c3c81 100644 --- a/lib_enc/igf_enc_fx.c +++ b/lib_enc/igf_enc_fx.c @@ -3726,5 +3726,3 @@ void IGFSaveSpectrumForITF_ivas_fx( return; } - - -- GitLab From f4758c07c1321ea09293594e83d2a64c5f2168f3 Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Thu, 21 May 2026 09:16:14 +0200 Subject: [PATCH 3/6] fix crest initializations --- lib_enc/igf_enc_fx.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c index edf3c3c81..4bfa32197 100644 --- a/lib_enc/igf_enc_fx.c +++ b/lib_enc/igf_enc_fx.c @@ -405,14 +405,14 @@ Word16 IGF_getCrest_fx( move32(); x_max = 0; move16(); - crest = 16384 /*.5f Q15*/; - move16(); - *crest_exp = 1; - move16(); IF( logSpec == NULL ) { /* Raw path: compute from powerSpectrum */ + crest = 16384 /*.5f Q15*/; + move16(); + *crest_exp = 1; + move16(); powSpec_exp = powerSpectrum_exp[0]; move16(); @@ -438,6 +438,11 @@ Word16 IGF_getCrest_fx( ELSE { /* Optimized path: use pre-calculated logSpec */ + crest = 32767 /*1.0f Q15*/; + move16(); + *crest_exp = 0; + move16(); + FOR( i = start; i < stop; i++ ) { x = logSpec[i]; -- GitLab From 81461c6271186a7e7fb1f9ebe429bc04beb67f59 Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Thu, 21 May 2026 17:42:50 +0200 Subject: [PATCH 4/6] Revert "harmonize remaining duplicates" Revert last commits --- lib_com/options.h | 1 - lib_com/prot_fx.h | 21 +- lib_enc/igf_enc_fx.c | 602 +++++++++-------------- lib_enc/ivas_corecoder_enc_reconfig_fx.c | 4 +- lib_enc/ivas_mct_enc_fx.c | 2 +- lib_enc/prot_fx_enc.h | 23 - 6 files changed, 232 insertions(+), 421 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 60c5b1e0c..27e64a41c 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 NONBE_FIX_ISSUE_2206_SWB_EXPERIMENT_FIX_2527 /* Fix crash from issue #2527 */ #define FIX_FLOAT_1539_G192_FORMAT_SWITCH /* VA/Nokia: reintroduce format switching for g192 bitstreams */ -#define FIX_2346_DUPLICATED_IGF_FUNCTIONS_3 /* FhG: Harmonize duplicate IGF functions (getCrest, getSFM, Reconfig) */ /* #################### End BE switches ################################## */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index bcedeed89..196a37583 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -9602,7 +9602,6 @@ Word16 msvq_stage1_dct_recalc_candidates_fdcng_wb_fx( Word16 *dist_ptr_e /* i/o: exp for updated MSE vector for stage1 */ ); -#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_3 ivas_error IGF_Reconfig_fx( IGF_ENC_INSTANCE_HANDLE *hIGFEnc, /* i/o: instance handle of IGF Encoder */ const Word16 igf, /* i : IGF on/off */ @@ -9612,17 +9611,6 @@ ivas_error IGF_Reconfig_fx( const Word16 element_mode, /* i : IVAS element mode */ const Word16 rf_mode /* i : flag to signal the RF mode */ ); -#else -ivas_error IGF_Reconfig( - IGF_ENC_INSTANCE_HANDLE *hIGFEnc, /* i/o: instance handle of IGF Encoder */ - const Word16 igf, /* i : IGF on/off */ - const Word16 reset, /* i : reset flag */ - const Word32 brate, /* i : bitrate for configuration */ - const Word16 bwidth, /* i : signal bandwidth */ - const Word16 element_mode, /* i : IVAS element mode */ - const Word16 rf_mode /* i : flag to signal the RF mode */ -); -#endif void residu_ivas_fx( const Word16 *a, /* i : LP filter coefficients Q31-a_exp*/ @@ -10112,5 +10100,14 @@ Word16 is_EVS_bitrate( Word16 *Opt_AMR_WB /* i : AMR-WB IO flag */ ); +ivas_error IGF_Reconfig( + IGF_ENC_INSTANCE_HANDLE *hIGFEnc, /* i/o: instance handle of IGF Encoder */ + const Word16 igf, /* i : IGF on/off */ + const Word16 reset, /* i : reset flag */ + const Word32 brate, /* i : bitrate for configuration */ + const Word16 bwidth, /* i : signal bandwidth */ + const Word16 element_mode, /* i : IVAS element mode */ + const Word16 rf_mode /* i : flag to signal the RF mode */ +); #endif diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c index 4bfa32197..27c3a7f2f 100644 --- a/lib_enc/igf_enc_fx.c +++ b/lib_enc/igf_enc_fx.c @@ -380,151 +380,6 @@ crest factor calculation **************************************************************************/ /* o: Q15| crest factor */ -#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_3 -Word16 IGF_getCrest_fx( - Word16 *crest_exp, /* o : exponent of crest factor */ - const Word32 *powerSpectrum, /* i : Q31 | power spectrum (NULL if logSpec provided) */ - const Word16 *powerSpectrum_exp, /* i : exponent of power spectrum (NULL if logSpec provided) */ - const Word16 *logSpec, /* i : pre-calculated log spectrum (NULL if using raw path) */ - const Word16 start, /* i : Q0 | start subband index */ - const Word16 stop, /* i : Q0 | stop subband index */ - const Word16 element_mode /* i : IVAS element mode type */ -) -{ - Word16 i; - Word16 x; - Word32 x_eff32; - Word16 x_max; - Word16 crest; - Word16 s; - Word16 tmp; - Word32 tmp32; - Word16 powSpec_exp; - - x_eff32 = 0; - move32(); - x_max = 0; - move16(); - - IF( logSpec == NULL ) - { - /* Raw path: compute from powerSpectrum */ - crest = 16384 /*.5f Q15*/; - move16(); - *crest_exp = 1; - move16(); - powSpec_exp = powerSpectrum_exp[0]; - move16(); - - FOR( i = start; i < stop; i++ ) - { - if ( GT_16( element_mode, EVS_MONO ) ) - { - powSpec_exp = powerSpectrum_exp[i]; /* exponent is a vector in IVAS (and a scalar in EVS) */ - move16(); - } - x = sub( sub( powSpec_exp, norm_l( powerSpectrum[i] ) ), 1 ); /*Q0*/ - - if ( powerSpectrum[i] == 0 ) /*special case: energy is zero*/ - { - x = 0; - move16(); - } - x = s_max( 0, x ); - x_eff32 = L_mac0( x_eff32, x, x ); /*Q0*/ - x_max = s_max( x_max, x ); /*Q0*/ - } - } - ELSE - { - /* Optimized path: use pre-calculated logSpec */ - crest = 32767 /*1.0f Q15*/; - move16(); - *crest_exp = 0; - move16(); - - FOR( i = start; i < stop; i++ ) - { - x = logSpec[i]; - move16(); - x_eff32 = L_mac0( x_eff32, x, x ); - - if ( GT_16( x, x_max ) ) - { - x_max = x; - move16(); - } - } - } - - /* Common section: crest calculation */ - IF( logSpec == NULL ) - { - /*x_eff /= (stop - start);*/ - x_eff32 = BASOP_Util_Divide3216_Scale( x_eff32, sub( stop, start ), &s ); /*Q-1, s*/ - s = add( s, 32 ); /*make x_eff Q31*/ - - /*trunkate to int*/ - x_eff32 = L_shr( x_eff32, sub( 31, s ) ); - x_eff32 = L_shl( x_eff32, sub( 31, s ) ); - } - ELSE - { - x_eff32 = BASOP_Util_Divide3216_Scale( x_eff32, sub( stop, start ), &tmp ); - tmp = add( tmp, 16 ); /*exp += 31 - 15 + 16(because x_eff is word32)*/ - x_eff32 = L_shr( x_eff32, sub( 15, tmp ) ); - s = 15; - move16(); - } - - test(); - IF( x_eff32 > 0 && x_max > 0 ) - { - IF( logSpec == NULL ) - { - /*crest = max(1.f, (float)x_max/sqrt(x_eff));*/ - tmp32 = ISqrt32( x_eff32, &s ); /*Q31, s*/ - tmp32 = Mpy_32_16_1( tmp32 /*Q31, s*/, x_max /*Q0*/ ); /*Q16, s*/ - i = norm_l( tmp32 ); - tmp32 = L_shl( tmp32, i ); /*Q31, s-i+15*/ - crest = extract_h( tmp32 ); - *crest_exp = add( sub( s, i ), 15 ); - move16(); - /* limit crest factor to a lower bound of 1, may overflow */ - BASOP_SATURATE_WARNING_OFF_EVS - tmp = shl_sat( -1, sub( 15, *crest_exp ) ); /* build negative threshold */ - tmp = add_sat( crest, tmp ); - BASOP_SATURATE_WARNING_ON_EVS - if ( tmp < 0 ) - { - crest = 1; - move16(); - } - if ( tmp < 0 ) - { - *crest_exp = 15; - move16(); - } - } - ELSE - { - tmp = Sqrt16( extract_l( x_eff32 ), &s ); - i = sub( 15, s ); - IF( i < 0 ) - { - x_max = shl( x_max, i ); - i = 0; - move16(); - } - crest = BASOP_Util_Divide1616_Scale( x_max, tmp, crest_exp ); - *crest_exp = add( *crest_exp, i ); - crest = s_max( shl_sat( 1, sub( 15, *crest_exp ) ), crest ); - } - } - - return crest; -} -#else Word16 IGF_getCrest( Word16 *crest_exp, /* o : exponent of crest factor */ const Word32 *powerSpectrum, /* i : Q31 | power spectrum */ @@ -615,182 +470,13 @@ Word16 IGF_getCrest( return crest; } -#endif + /************************************************************************* calculates spectral flatness measurment **************************************************************************/ /* o: Q15| SFM value */ -#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_3 -Word16 IGF_getSFM_fx( - Word16 *SFM_exp, /* o : | exponent of SFM Factor */ - const Word32 *energy, /* i : Q31| energies (or powerSpectrum if logSpec provided) */ - const Word16 *energy_exp, /* i : | exponent of energies (or e_ps if logSpec provided) */ - const Word16 *logSpec, /* i : pre-calculated log spectrum (NULL if using raw path) */ - const Word16 start, /* i : Q0 | start subband index */ - const Word16 stop, /* i : Q0 | stop subband index */ - const Word16 element_mode /* i : | IVAS element mode type */ -) -{ - Word16 n, i, s; - Word32 num; - Word32 denom; - Word16 denom_exp; - Word16 invDenom_exp, numf_exp; - Word16 numf; - Word32 SFM32; - Word16 invDenom, SFM; - Word16 en_exp; - Word32 tmp; - Word16 tmp_e; - - num = 0; - move32(); - *SFM_exp = 0; - move16(); - SFM = 32767 /*1.0f Q15*/; - move16(); - en_exp = energy_exp[0]; - move16(); - denom_exp = 0; - move16(); - - IF( logSpec == NULL ) - { - /* Raw path: EVS-style calculation */ - Word64 W_denom; - W_denom = 0; - move64(); - - if ( EQ_16( element_mode, EVS_MONO ) ) - { - denom = L_shr( 2147483 /*0,001 in Q31 - float is "1", here*/, s_min( en_exp, 31 ) ); - denom = L_max( denom, 1 ); - move32(); - move32(); - W_denom = W_deposit32_l( denom ); - move64(); - } - else - { - denom = 65536; // 1.f in Q16 - move32(); - denom_exp = 15; - move16(); - } - - IF( EQ_16( element_mode, EVS_MONO ) ) - { - FOR( i = start; i < stop; i++ ) - { - n = sub( sub( en_exp, norm_l( energy[i] ) ), 1 ); /*<-- short form*/ - - if ( energy[i] == 0 ) /*special case: energy is zero*/ - { - n = 0; - move16(); - } - - n = s_max( 0, n ); - num = L_add( num, L_deposit_l( n ) ); /*Q0*/ - W_denom = W_add( W_deposit32_l( energy[i] ), W_denom ); - } - } - ELSE - { - FOR( i = start; i < stop; i++ ) - { - en_exp = energy_exp[i]; /* exponent is a vector in IVAS (and a scalar in EVS) */ - move16(); - n = sub( sub( en_exp, norm_l( energy[i] ) ), 1 ); /*<-- short form*/ - - if ( energy[i] == 0 ) /*special case: energy is zero*/ - { - n = 0; - move16(); - } - - n = s_max( 0, n ); - num = L_add( num, L_deposit_l( n ) ); /*Q0*/ - denom = BASOP_Util_Add_Mant32Exp( energy[i], en_exp, denom, denom_exp, &denom_exp ); - } - } - - IF( EQ_16( element_mode, EVS_MONO ) ) - { - denom = w_norm_llQ31( W_denom, &denom_exp ); /*Q31*/ - denom_exp = add( denom_exp, en_exp ); - } - } - ELSE - { - /* Optimized path: use pre-calculated logSpec */ - denom = ONE_IN_Q30; - denom_exp = 1; - move32(); - move16(); - - FOR( i = start; i < stop; i++ ) - { - tmp = energy[i]; - n = logSpec[i]; - move32(); - move16(); - num = add( num, n ); - denom = BASOP_Util_Add_Mant32Exp( tmp, energy_exp[i], denom, denom_exp, &denom_exp ); - } - - denom = BASOP_Util_Divide3216_Scale( denom, sub( stop, start ), &tmp_e ); - denom_exp = add( add( denom_exp, tmp_e ), 1 ); /*denom_exp+tmp_e-15 +16(because type of denom is word32)*/ - } - - /* calculate SFM only if signal is present */ - IF( denom != 0 ) - { - /*numf = (float)num / (float)(stop - start);*/ - numf = BASOP_Util_Divide3216_Scale( num, /*Q0*/ - sub( stop, start ), /*Q0*/ - &s ); /*Q-1 s*/ - numf_exp = add( s, 16 ); /*-> numf Q15 numf_exp*/ - /*denom /= (float)(stop - start);*/ - /*return ((float)pow(2.0, numf + 0.5f) / denom);*/ - - /*SFM= ((float)pow(2.0, numf + 0.5f) * invDenom);*/ - invDenom = BASOP_Util_Divide3232_uu_1616_Scale( L_deposit_l( sub( stop, start ) ) /*Q0*/, - denom /*Q31, denom_exp*/, - &s ); /*Q-16, s-denom_exp*/ - invDenom_exp = add( sub( s, denom_exp ), 31 ); /*invDenom: Q15, invDenom_exp*/ - - /*add .5f to numf*/ - SFM32 = L_add( L_shl( L_deposit_l( numf ), numf_exp ) /*16Q15*/, 16384l /*.5f Q15*/ ); /*16Q15*/ - s = norm_l( SFM32 ); - SFM32 = L_shl( SFM32, s ); - s = sub( 16, s ); /*SFM32(numf) is Q31 now*/ - - /*do the pow2 and the mult*/ - SFM32 = BASOP_util_Pow2( SFM32, s, &s ); - SFM32 = Mpy_32_16_1( SFM32, invDenom ); - *SFM_exp = add( s, invDenom_exp ); - - /*Transform to Q15*/ - s = norm_l( SFM32 ); - SFM = round_fx_sat( L_shl_sat( SFM32, s ) ); - *SFM_exp = sub( *SFM_exp, s ); - move16(); - /**SFM_exp = s_min(*SFM_exp, 0);*/ - IF( *SFM_exp > 0 ) - { - *SFM_exp = 0; - move16(); - SFM = 32767 /*1.0f Q15*/; - move16(); - } - } - - return SFM /*Q15*/; -} -#else Word16 IGF_getSFM( Word16 *SFM_exp, /* o : | exponent of SFM Factor */ const Word32 *energy, /* i : Q31| energies */ @@ -840,6 +526,10 @@ Word16 IGF_getSFM( move16(); } + /*ln(x * 2^-Qx * 2^xExp) = ln(x) - Qx + xExp*/ + /* n = sub(sub(31,norm_l(tmp32)),1); */ /*<- ld */ + /* n = sub(n,31); */ /*<- -Qx */ + /* n = add(n,*energy_exp); */ /*<- +xExp */ IF( EQ_16( element_mode, EVS_MONO ) ) { FOR( i = start; i < stop; i++ ) @@ -883,29 +573,40 @@ Word16 IGF_getSFM( denom_exp = add( denom_exp, en_exp ); } + /* calculate SFM only if signal is present */ IF( denom != 0 ) { - numf = BASOP_Util_Divide3216_Scale( num, sub( stop, start ), &s ); - numf_exp = add( s, 16 ); + /*numf = (float)num / (float)(stop - start);*/ + numf = BASOP_Util_Divide3216_Scale( num, /*Q0*/ + sub( stop, start ), /*Q0*/ + &s ); /*Q-1 s*/ + numf_exp = add( s, 16 ); /*-> numf Q15 numf_exp*/ + /*denom /= (float)(stop - start);*/ + /*return ((float)pow(2.0, numf + 0.5f) / denom);*/ + /*SFM= ((float)pow(2.0, numf + 0.5f) * invDenom);*/ invDenom = BASOP_Util_Divide3232_uu_1616_Scale( L_deposit_l( sub( stop, start ) ) /*Q0*/, denom /*Q31, denom_exp*/, &s ); /*Q-16, s-denom_exp*/ - invDenom_exp = add( sub( s, denom_exp ), 31 ); + invDenom_exp = add( sub( s, denom_exp ), 31 ); /*invDenom: Q15, invDenom_exp*/ + /*add .5f to numf*/ SFM32 = L_add( L_shl( L_deposit_l( numf ), numf_exp ) /*16Q15*/, 16384l /*.5f Q15*/ ); /*16Q15*/ s = norm_l( SFM32 ); SFM32 = L_shl( SFM32, s ); - s = sub( 16, s ); + s = sub( 16, s ); /*SFM32(numf) is Q31 now*/ + /*do the pow2 and the mult*/ SFM32 = BASOP_util_Pow2( SFM32, s, &s ); SFM32 = Mpy_32_16_1( SFM32, invDenom ); *SFM_exp = add( s, invDenom_exp ); + /*Transform to Q15*/ s = norm_l( SFM32 ); SFM = round_fx_sat( L_shl_sat( SFM32, s ) ); *SFM_exp = sub( *SFM_exp, s ); move16(); + /**SFM_exp = s_min(*SFM_exp, 0);*/ IF( *SFM_exp > 0 ) { *SFM_exp = 0; @@ -917,7 +618,139 @@ Word16 IGF_getSFM( return SFM /*Q15*/; } -#endif + + +/*-------------------------------------------------------------------* + * IGF_getCrest_new() + * + * crest factor calculation + *-------------------------------------------------------------------*/ + +/*! r: crest factor */ +static Word16 IGF_getCrest_new_fx( + const Word16 *logSpec, /* i : power spectrum */ + const Word16 start, /* i : start subband index */ + const Word16 stop, /* i : stop subband index */ + Word16 *crest_exp /*Stores the exponent of the result(return value)*/ +) +{ + Word16 i; + Word16 x; + Word32 x_eff; + Word16 x_max; + Word16 exp; + Word16 temp; + Word16 temp_e; + Word16 crest; /*1.0f in Q15*/ + x_eff = 0; + x_max = 0; + exp = 0; + temp = 0; + crest = 32767; /*1.0f in Q15*/ + move32(); + move16(); + move16(); + move16(); + move16(); + + FOR( i = start; i < stop; i++ ) + { + x = logSpec[i]; + move16(); + x_eff = L_mac0( x_eff, x, x ); + + if ( GT_16( x, x_max ) ) + { + x_max = x; + move16(); + } + } + + x_eff = BASOP_Util_Divide3216_Scale( x_eff, sub( stop, start ), &temp_e ); + temp_e = add( temp_e, 16 ); /*exp += 31 - 15 + 16(because x_eff is word32)*/ + x_eff = L_shr( x_eff, sub( 15, temp_e ) ); + temp_e = 15; + move16(); + temp = Sqrt16( extract_l( x_eff ), &temp_e ); + + test(); + IF( x_eff > 0 && x_max > 0 ) + { + temp = BASOP_Util_Divide1616_Scale( x_max, temp, &exp ); + exp = add( exp, sub( 15, temp_e ) ); + IF( exp < 0 ) + { + temp = shl( temp, exp ); + exp = 0; + move16(); + } + crest = s_max( shl_sat( 1, sub( 15, exp ) ), temp ); + } + *crest_exp = exp; + move16(); + return crest; +} + +/*-------------------------------------------------------------------* + * IGF_getSFM_new() + * + * calculates spectral flatness measurement + *-------------------------------------------------------------------*/ + +/*! r: SFM value */ +static Word16 IGF_getSFM_new_fx( + const Word32 *powerSpectrum, /* i : power spectrum */ + const Word16 *logSpec, /* i : log of power spectrum */ + const Word16 start, /* i : start subband index */ + const Word16 stop, /* i : stop subband index */ + Word16 *e_ps /*Stores exp related to power spectrum*/ +) +{ + Word16 n; + Word16 i; + Word16 num; + Word32 denom; + Word16 numf; + Word32 tmp; + Word16 sfm; + Word16 sfm_e; + Word16 denom_e; + Word16 numf_e; /*stores exponent for numf*/ + Word16 tmp_e; + + num = 0; + denom = ONE_IN_Q30; + denom_e = 1; + sfm = MAX16B; // Q15 + move16(); + move32(); + move16(); + move16(); + + FOR( i = start; i < stop; i++ ) + { + tmp = powerSpectrum[i]; + n = logSpec[i /*-start*/]; + move32(); + move16(); + num = add( num, n ); + denom = BASOP_Util_Add_Mant32Exp( tmp, e_ps[i], denom, denom_e, &denom_e ); + } + + numf = BASOP_Util_Divide1616_Scale( num, sub( stop, start ), &numf_e ); + denom = BASOP_Util_Divide3216_Scale( denom, sub( stop, start ), &tmp_e ); + denom_e = add( add( denom_e, tmp_e ), 1 ); /*denom_e+tmp_e-15 +16(because type of denom is word32)*/ + + IF( denom != 0 ) + { + tmp = BASOP_util_Pow2( L_add( numf, shl_sat( 1, sub( 14, numf_e ) ) ), add( 16, numf_e ), &tmp_e ); + sfm = BASOP_Util_Divide3232_Scale( tmp, denom, &sfm_e ); + sfm_e = add( sfm_e, sub( tmp_e, denom_e ) ); + sfm = shl_sat( extract_l( L_min( sfm, L_shl_sat( 1, sub( 15, sfm_e ) ) ) ), sfm_e ); + } + + return sfm; +} /*-------------------------------------------------------------------* * IGF_Whitening() @@ -1047,8 +880,8 @@ static void IGF_Whitening( } ELSE IF( EQ_16( element_mode, EVS_MONO ) ) { - SFM = IGF_getSFM_fx( &SFM_e, powerSpectrum, powerSpectrum_e, NULL, hGrid->tile[p], hGrid->tile[p + 1], element_mode ); - crest = IGF_getCrest_fx( &crest_e, powerSpectrum, powerSpectrum_e, NULL, hGrid->tile[p], hGrid->tile[p + 1], element_mode ); + SFM = IGF_getSFM( &SFM_e, powerSpectrum, powerSpectrum_e, hGrid->tile[p], hGrid->tile[p + 1], element_mode ); + crest = IGF_getCrest( &crest_e, powerSpectrum, powerSpectrum_e, hGrid->tile[p], hGrid->tile[p + 1], element_mode ); tmp = BASOP_Util_Divide1616_Scale( SFM, crest, &s ); /* Q15 */ s = add( s, sub( SFM_e, crest_e ) ); @@ -1056,8 +889,8 @@ static void IGF_Whitening( } ELSE { - SFM = IGF_getSFM_fx( &SFM_e, powerSpectrum, powerSpectrum_e, hPrivateData->logSpec, hGrid->tile[p], hGrid->tile[p + 1], element_mode ); - crest = IGF_getCrest_fx( &crest_e, NULL, NULL, hPrivateData->logSpec, hGrid->tile[p], hGrid->tile[p + 1], element_mode ); + SFM = IGF_getSFM_new_fx( powerSpectrum, hPrivateData->logSpec, hGrid->tile[p], hGrid->tile[p + 1], powerSpectrum_e ); + crest = IGF_getCrest_new_fx( hPrivateData->logSpec, hGrid->tile[p], hGrid->tile[p + 1], &crest_e ); tmp = BASOP_Util_Divide1616_Scale( SFM, crest, &tmp_e ); tmp_e = sub( tmp_e, crest_e ); } @@ -1846,7 +1679,6 @@ Word16 IGFEncWriteConcatenatedBitstream_fx( } -#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_3 ivas_error IGF_Reconfig_fx( IGF_ENC_INSTANCE_HANDLE *hIGFEnc, /* i/o: instance handle of IGF Encoder */ const Word16 igf, /* i : IGF on/off */ @@ -1885,46 +1717,6 @@ ivas_error IGF_Reconfig_fx( return error; } -#else -ivas_error IGF_Reconfig( - IGF_ENC_INSTANCE_HANDLE *hIGFEnc, /* i/o: instance handle of IGF Encoder */ - const Word16 igf, /* i : IGF on/off */ - const Word16 reset, /* i : reset flag */ - const Word32 brate, /* i : bitrate for configuration */ - const Word16 bwidth, /* i : signal bandwidth */ - const Word16 element_mode, /* i : IVAS element mode */ - const Word16 rf_mode /* i : flag to signal the RF mode */ -) -{ - ivas_error error; - - error = IVAS_ERR_OK; - move32(); - - test(); - test(); - test(); - IF( igf && *hIGFEnc == NULL ) - { - IF( ( *hIGFEnc = (IGF_ENC_INSTANCE_HANDLE) malloc( sizeof( IGF_ENC_INSTANCE ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hIGFEnc\n" ) ); - } - IGFEncSetMode_fx( *hIGFEnc, brate, bwidth, element_mode, rf_mode ); - } - ELSE IF( igf && reset ) - { - IGFEncSetMode_fx( *hIGFEnc, brate, bwidth, element_mode, rf_mode ); - } - ELSE IF( !igf && *hIGFEnc != NULL ) - { - free( *hIGFEnc ); - *hIGFEnc = NULL; - } - - return error; -} -#endif #define INV_Log2_10_Q15 9864 /*1/log2(10) in Q15*/ @@ -2330,16 +2122,16 @@ static void IGF_CalculateEnvelope_fx( move16(); // tmp_tb = IGF_getSFM_new( pPowerSpectrum, hPrivateData->logSpec, swb_offset[sfb], swb_offset[sfb + 1] ) / IGF_getCrest_new( hPrivateData->logSpec, swb_offset[sfb], swb_offset[sfb + 1] ); - sfm = IGF_getSFM_fx( &sfm_exp, pPowerSpectrum_fx, e_ps, hPrivateData->logSpec, swb_offset[sfb], swb_offset[sfb + 1], IVAS_CPE_MDCT ); + sfm = IGF_getSFM_new_fx( pPowerSpectrum_fx, hPrivateData->logSpec, swb_offset[sfb], swb_offset[sfb + 1], e_ps ); sfm_exp = 0; move16(); - crest = IGF_getCrest_fx( &crest_exp, NULL, NULL, hPrivateData->logSpec, swb_offset[sfb], swb_offset[sfb + 1], IVAS_CPE_MDCT ); + crest = IGF_getCrest_new_fx( hPrivateData->logSpec, swb_offset[sfb], swb_offset[sfb + 1], &crest_exp ); tmp_tb = BASOP_Util_Divide1616_Scale( sfm, crest, &tmp_e ); // tmp_tb_e tmp_tb_e = add( tmp_e, sub( sfm_exp, crest_exp ) ); // tmp_sb = IGF_getSFM_new( pPowerSpectrum, hPrivateData->logSpec, tmp, strt_cpy ) / IGF_getCrest_new( hPrivateData->logSpec, tmp, strt_cpy ); - sfm = IGF_getSFM_fx( &sfm_exp, pPowerSpectrum_fx, e_ps, hPrivateData->logSpec, tmp, strt_cpy, IVAS_CPE_MDCT ); - crest = IGF_getCrest_fx( &crest_exp, NULL, NULL, hPrivateData->logSpec, tmp, strt_cpy, IVAS_CPE_MDCT ); + sfm = IGF_getSFM_new_fx( pPowerSpectrum_fx, hPrivateData->logSpec, tmp, strt_cpy, e_ps ); + crest = IGF_getCrest_new_fx( hPrivateData->logSpec, tmp, strt_cpy, &crest_exp ); tmp_sb = BASOP_Util_Divide1616_Scale( sfm, crest, &tmp_e ); // tmp_sb_e tmp_sb_e = add( tmp_e, sub( sfm_exp, crest_exp ) ); @@ -2479,16 +2271,16 @@ static void IGF_CalculateEnvelope_fx( IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( slope, add( slope_e, 16 ), negate( threshold ), add( threshold_e, 16 ) ), -1 ) ) { Word16 shift = shr( width, 1 ); - sfm = IGF_getSFM_fx( &sfm_exp, pPowerSpectrum_fx, e_ps, hPrivateData->logSpec, swb_offset[sfb] - shift, swb_offset[sfb + 1] - shift, IVAS_CPE_MDCT ); - crest = IGF_getCrest_fx( &crest_exp, NULL, NULL, hPrivateData->logSpec, swb_offset[sfb] - shift, swb_offset[sfb + 1] - shift, IVAS_CPE_MDCT ); + sfm = IGF_getSFM_new_fx( pPowerSpectrum_fx, hPrivateData->logSpec, swb_offset[sfb] - shift, swb_offset[sfb + 1] - shift, e_ps ); + crest = IGF_getCrest_new_fx( hPrivateData->logSpec, swb_offset[sfb] - shift, swb_offset[sfb + 1] - shift, &crest_exp ); shiftedSFM = BASOP_Util_Divide1616_Scale( sfm, crest, &shiftedSFM_e ); } ELSE IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( slope, add( slope_e, 16 ), threshold, add( threshold_e, 16 ) ), 1 ) && ( NE_16( sfb, sub( hGrid->sfbWrap[hGrid->nTiles], 1 ) ) ) ) { Word16 shift = shr( width, 1 ); - shiftedSFM = BASOP_Util_Divide1616_Scale( IGF_getSFM_fx( &sfm_exp, pPowerSpectrum_fx, e_ps, hPrivateData->logSpec, swb_offset[sfb] + shift, swb_offset[sfb + 1] + shift, IVAS_CPE_MDCT ), IGF_getCrest_fx( &crest_exp, NULL, NULL, hPrivateData->logSpec, swb_offset[sfb] + shift, swb_offset[sfb + 1] + shift, IVAS_CPE_MDCT ), &tmp_e ); - sfm = IGF_getSFM_fx( &sfm_exp, pPowerSpectrum_fx, e_ps, hPrivateData->logSpec, swb_offset[sfb] + shift, swb_offset[sfb + 1] + shift, IVAS_CPE_MDCT ); - crest = IGF_getCrest_fx( &crest_exp, NULL, NULL, hPrivateData->logSpec, swb_offset[sfb] + shift, swb_offset[sfb + 1] + shift, IVAS_CPE_MDCT ); + shiftedSFM = BASOP_Util_Divide1616_Scale( IGF_getSFM_new_fx( pPowerSpectrum_fx, hPrivateData->logSpec, swb_offset[sfb] + shift, swb_offset[sfb + 1] + shift, e_ps ), IGF_getCrest_new_fx( hPrivateData->logSpec, swb_offset[sfb] + shift, swb_offset[sfb + 1] + shift, &crest_exp ), &tmp_e ); + sfm = IGF_getSFM_new_fx( pPowerSpectrum_fx, hPrivateData->logSpec, swb_offset[sfb] + shift, swb_offset[sfb + 1] + shift, e_ps ); + crest = IGF_getCrest_new_fx( hPrivateData->logSpec, swb_offset[sfb] + shift, swb_offset[sfb + 1] + shift, &crest_exp ); shiftedSFM = BASOP_Util_Divide1616_Scale( sfm, crest, &shiftedSFM_e ); } shiftedSFM_e = add( shiftedSFM_e, sub( sfm_exp, crest_exp ) ); @@ -2971,17 +2763,17 @@ static void IGF_CalculateStereoEnvelope_fx( move16(); // tmp_tb = IGF_getSFM(pPowerSpectrum, swb_offset[sfb], swb_offset[sfb + 1]) / IGF_getCrest(pPowerSpectrum, swb_offset[sfb], swb_offset[sfb + 1]); - sfm = IGF_getSFM_fx( &sfm_exp, pPowerSpectrum_fx, pPowerSpectrum_e, NULL, swb_offset[sfb], swb_offset[sfb + 1], IVAS_CPE_MDCT ); + sfm = IGF_getSFM( &sfm_exp, pPowerSpectrum_fx, pPowerSpectrum_e, swb_offset[sfb], swb_offset[sfb + 1], IVAS_CPE_MDCT ); - crest = IGF_getCrest_fx( &crest_exp, pPowerSpectrum_fx, pPowerSpectrum_e, NULL, swb_offset[sfb], swb_offset[sfb + 1], IVAS_CPE_MDCT ); + crest = IGF_getCrest( &crest_exp, pPowerSpectrum_fx, pPowerSpectrum_e, swb_offset[sfb], swb_offset[sfb + 1], IVAS_CPE_MDCT ); tmp_tb_fx = BASOP_Util_Divide1616_Scale( sfm, crest, &tmp_e ); tmp_tb_e = add( tmp_e, sub( sfm_exp, crest_exp ) ); /*stores the resultant exponent for tmp_tb_fx*/ // tmp_sb = IGF_getSFM(tileSrcSpec, 0, strt_cpy - tmp) / IGF_getCrest(tileSrcSpec, 0, strt_cpy - tmp); - sfm = IGF_getSFM_fx( &sfm_exp, tileSrcSpec_fx, tileSrcSpec_e, NULL, 0, sub( strt_cpy, tmp ), IVAS_CPE_MDCT ); + sfm = IGF_getSFM( &sfm_exp, tileSrcSpec_fx, tileSrcSpec_e, 0, sub( strt_cpy, tmp ), IVAS_CPE_MDCT ); - crest = IGF_getCrest_fx( &crest_exp, tileSrcSpec_fx, tileSrcSpec_e, NULL, 0, sub( strt_cpy, tmp ), IVAS_CPE_MDCT ); + crest = IGF_getCrest( &crest_exp, tileSrcSpec_fx, tileSrcSpec_e, 0, sub( strt_cpy, tmp ), IVAS_CPE_MDCT ); tmp_sb_fx = BASOP_Util_Divide1616_Scale( sfm, crest, &tmp_e ); tmp_sb_e = add( tmp_e, sub( sfm_exp, crest_exp ) ); /*stores the resultant exponent for tmp_sb_fx*/ @@ -3127,9 +2919,9 @@ static void IGF_CalculateStereoEnvelope_fx( Word16 shift = shr( width, 1 ); // shiftedSFM = IGF_getSFM( pPowerSpectrum, swb_offset[sfb] - shift, swb_offset[sfb + 1] - shift ) / IGF_getCrest( pPowerSpectrum, swb_offset[sfb] - shift, swb_offset[sfb + 1] - shift ); - sfm = IGF_getSFM_fx( &sfm_exp, pPowerSpectrum_fx, pPowerSpectrum_e, NULL, sub( swb_offset[sfb], shift ), sub( swb_offset[sfb + 1], shift ), IVAS_CPE_MDCT ); + sfm = IGF_getSFM( &sfm_exp, pPowerSpectrum_fx, pPowerSpectrum_e, sub( swb_offset[sfb], shift ), sub( swb_offset[sfb + 1], shift ), IVAS_CPE_MDCT ); - crest = IGF_getCrest_fx( &crest_exp, pPowerSpectrum_fx, pPowerSpectrum_e, NULL, sub( swb_offset[sfb], shift ), sub( swb_offset[sfb + 1], shift ), IVAS_CPE_MDCT ); + crest = IGF_getCrest( &crest_exp, pPowerSpectrum_fx, pPowerSpectrum_e, sub( swb_offset[sfb], shift ), sub( swb_offset[sfb + 1], shift ), IVAS_CPE_MDCT ); shiftedSFM_fx = BASOP_Util_Divide1616_Scale( sfm, crest, &shiftedSFM_e ); } @@ -3139,9 +2931,9 @@ static void IGF_CalculateStereoEnvelope_fx( shift = shr( width, 1 ); // shiftedSFM = IGF_getSFM( pPowerSpectrum, swb_offset[sfb] + shift, swb_offset[sfb + 1] + shift ) / IGF_getCrest( pPowerSpectrum, swb_offset[sfb] + shift, swb_offset[sfb + 1] + shift ); - sfm = IGF_getSFM_fx( &sfm_exp, pPowerSpectrum_fx, pPowerSpectrum_e, NULL, add( swb_offset[sfb], shift ), add( swb_offset[sfb + 1], shift ), IVAS_CPE_MDCT ); + sfm = IGF_getSFM( &sfm_exp, pPowerSpectrum_fx, pPowerSpectrum_e, add( swb_offset[sfb], shift ), add( swb_offset[sfb + 1], shift ), IVAS_CPE_MDCT ); - crest = IGF_getCrest_fx( &crest_exp, pPowerSpectrum_fx, pPowerSpectrum_e, NULL, add( swb_offset[sfb], shift ), add( swb_offset[sfb + 1], shift ), IVAS_CPE_MDCT ); + crest = IGF_getCrest( &crest_exp, pPowerSpectrum_fx, pPowerSpectrum_e, add( swb_offset[sfb], shift ), add( swb_offset[sfb + 1], shift ), IVAS_CPE_MDCT ); shiftedSFM_fx = BASOP_Util_Divide1616_Scale( sfm, crest, &shiftedSFM_e ); } @@ -3731,3 +3523,49 @@ void IGFSaveSpectrumForITF_ivas_fx( return; } + + +/*-------------------------------------------------------------------* + * IGF_Reconfig() + * + * + *-------------------------------------------------------------------*/ + +ivas_error IGF_Reconfig( + IGF_ENC_INSTANCE_HANDLE *hIGFEnc, /* i/o: instance handle of IGF Encoder */ + const Word16 igf, /* i : IGF on/off */ + const Word16 reset, /* i : reset flag */ + const Word32 brate, /* i : bitrate for configuration */ + const Word16 bwidth, /* i : signal bandwidth */ + const Word16 element_mode, /* i : IVAS element mode */ + const Word16 rf_mode /* i : flag to signal the RF mode */ +) +{ + ivas_error error; + + error = IVAS_ERR_OK; + move32(); + + test(); + test(); + test(); + IF( igf && *hIGFEnc == NULL ) + { + IF( ( *hIGFEnc = (IGF_ENC_INSTANCE_HANDLE) malloc( sizeof( IGF_ENC_INSTANCE ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hIGFEnc\n" ) ); + } + IGFEncSetMode_fx( *hIGFEnc, brate, bwidth, element_mode, rf_mode ); + } + ELSE IF( igf && reset ) + { + IGFEncSetMode_fx( *hIGFEnc, brate, bwidth, element_mode, rf_mode ); + } + ELSE IF( !igf && *hIGFEnc != NULL ) + { + free( *hIGFEnc ); + *hIGFEnc = NULL; + } + + return error; +} diff --git a/lib_enc/ivas_corecoder_enc_reconfig_fx.c b/lib_enc/ivas_corecoder_enc_reconfig_fx.c index cad67e269..9c845eb40 100644 --- a/lib_enc/ivas_corecoder_enc_reconfig_fx.c +++ b/lib_enc/ivas_corecoder_enc_reconfig_fx.c @@ -682,7 +682,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx( st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ); /* Q0 */ move16(); - IF( ( error = IGF_Reconfig_fx( &st_ivas->hCPE[0]->hCoreCoder[n]->hIGFEnc, st_ivas->hCPE[0]->hCoreCoder[n]->igf, 1, st_ivas->hCPE[0]->element_brate, st_ivas->hCPE[0]->hCoreCoder[n]->bwidth, st_ivas->hCPE[0]->hCoreCoder[n]->element_mode, st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ) ) != IVAS_ERR_OK ) + IF( ( error = IGF_Reconfig( &st_ivas->hCPE[0]->hCoreCoder[n]->hIGFEnc, st_ivas->hCPE[0]->hCoreCoder[n]->igf, 1, st_ivas->hCPE[0]->element_brate, st_ivas->hCPE[0]->hCoreCoder[n]->bwidth, st_ivas->hCPE[0]->hCoreCoder[n]->element_mode, st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ) ) != IVAS_ERR_OK ) { return error; } @@ -745,7 +745,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx( move16(); - IF( ( error = IGF_Reconfig_fx( &st_ivas->hCPE[0]->hCoreCoder[n]->hIGFEnc, st_ivas->hCPE[0]->hCoreCoder[n]->igf, 1, st_ivas->hCPE[0]->element_brate, st_ivas->hCPE[0]->hCoreCoder[n]->bwidth, st_ivas->hCPE[0]->hCoreCoder[n]->element_mode, st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ) ) != IVAS_ERR_OK ) + IF( ( error = IGF_Reconfig( &st_ivas->hCPE[0]->hCoreCoder[n]->hIGFEnc, st_ivas->hCPE[0]->hCoreCoder[n]->igf, 1, st_ivas->hCPE[0]->element_brate, st_ivas->hCPE[0]->hCoreCoder[n]->bwidth, st_ivas->hCPE[0]->hCoreCoder[n]->element_mode, st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_enc/ivas_mct_enc_fx.c b/lib_enc/ivas_mct_enc_fx.c index 4209b82b1..81a8f7942 100644 --- a/lib_enc/ivas_mct_enc_fx.c +++ b/lib_enc/ivas_mct_enc_fx.c @@ -753,7 +753,7 @@ ivas_error mct_enc_reconfigure_fx( st->igf = getIgfPresent_fx( st->element_mode, L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC ), st->bwidth, st->rf_mode ); move16(); - IF( ( error = IGF_Reconfig_fx( &st->hIGFEnc, st->igf, 1, st_ivas->hCPE[cpe_id]->element_brate, st->bwidth, st->element_mode, st->rf_mode ) ) != IVAS_ERR_OK ) + IF( ( error = IGF_Reconfig( &st->hIGFEnc, st->igf, 1, st_ivas->hCPE[cpe_id]->element_brate, st->bwidth, st->element_mode, st->rf_mode ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 936e992ba..675710bcb 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -2502,28 +2502,6 @@ void IGF_UpdateInfo( ); /* o: Q15| crest factor */ -#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_3 -Word16 IGF_getCrest_fx( - Word16 *crest_exp, /**< out: | exponent of crest factor */ - const Word32 *powerSpectrum, /**< in: Q31 | power spectrum (NULL if logSpec provided) */ - const Word16 *powerSpectrum_exp, /**< in: | exponent of power spectrum (NULL if logSpec provided) */ - const Word16 *logSpec, /**< in: | pre-calculated log spectrum (NULL if using raw path) */ - const Word16 start, /**< in: Q0 | start subband index */ - const Word16 stop, /**< in: Q0 | stop subband index */ - const Word16 element_mode /**< in: | IVAS element mode type */ -); - -/* o: Q15| SFM value */ -Word16 IGF_getSFM_fx( - Word16 *SFM_exp, /* o : | exponent of SFM Factor */ - const Word32 *energy, /* i : Q31| energies (or powerSpectrum if logSpec provided) */ - const Word16 *energy_exp, /* i : | exponent of energies (or e_ps if logSpec provided) */ - const Word16 *logSpec, /* i : | pre-calculated log spectrum (NULL if using raw path) */ - const Word16 start, /* i : Q0 | start subband index */ - const Word16 stop, /* i : Q0 | stop subband index */ - const Word16 element_mode /* i : | IVAS element mode type */ -); -#else Word16 IGF_getCrest( Word16 *crest_exp, /**< out: | exponent of crest factor */ const Word32 *powerSpectrum, /**< in: Q31 | power spectrum */ @@ -2542,7 +2520,6 @@ Word16 IGF_getSFM( const Word16 stop, /* i : Q0 | stop subband index */ const Word16 element_mode /* i : | IVAS element mode type */ ); -#endif void IGF_ErodeSpectrum( const IGF_ENC_INSTANCE_HANDLE hInstance, /* i : instance handle of IGF Encoder */ -- GitLab From 839c1555e3278431ea052207e783efc37b20cfab Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Thu, 21 May 2026 18:02:07 +0200 Subject: [PATCH 5/6] remove IGF_reconfig duplicate --- lib_com/options.h | 1 + lib_com/prot_fx.h | 3 +++ lib_enc/igf_enc_fx.c | 3 ++- lib_enc/ivas_corecoder_enc_reconfig_fx.c | 10 ++++++++-- lib_enc/ivas_mct_enc_fx.c | 5 ++++- 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 27e64a41c..f6915ff91 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -92,6 +92,7 @@ #define NONBE_FIX_ISSUE_2206_AVOID_OVERFLOW_MSVQ_Interpol_Tran_fx /* FhG: Fix saturation crash in MSVQ_Interpol_Tran_fx() */ #define NONBE_FIX_ISSUE_2206_SWB_EXPERIMENT_FIX_2527 /* Fix crash from issue #2527 */ #define FIX_FLOAT_1539_G192_FORMAT_SWITCH /* VA/Nokia: reintroduce format switching for g192 bitstreams */ +#define FIX_2346_DUPLICATED_IGF_FUNCTIONS_3 /* FhG: part 3 of basop issue 2346: Remove duplicate reconfig function */ /* #################### End BE switches ################################## */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 196a37583..dd0e46e6f 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -10100,6 +10100,7 @@ Word16 is_EVS_bitrate( Word16 *Opt_AMR_WB /* i : AMR-WB IO flag */ ); +#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS_3 ivas_error IGF_Reconfig( IGF_ENC_INSTANCE_HANDLE *hIGFEnc, /* i/o: instance handle of IGF Encoder */ const Word16 igf, /* i : IGF on/off */ @@ -10111,3 +10112,5 @@ ivas_error IGF_Reconfig( ); #endif + +#endif diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c index 27c3a7f2f..998708c44 100644 --- a/lib_enc/igf_enc_fx.c +++ b/lib_enc/igf_enc_fx.c @@ -3524,7 +3524,7 @@ void IGFSaveSpectrumForITF_ivas_fx( return; } - +#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS_3 /*-------------------------------------------------------------------* * IGF_Reconfig() * @@ -3569,3 +3569,4 @@ ivas_error IGF_Reconfig( return error; } +#endif \ No newline at end of file diff --git a/lib_enc/ivas_corecoder_enc_reconfig_fx.c b/lib_enc/ivas_corecoder_enc_reconfig_fx.c index 9c845eb40..945af196a 100644 --- a/lib_enc/ivas_corecoder_enc_reconfig_fx.c +++ b/lib_enc/ivas_corecoder_enc_reconfig_fx.c @@ -681,8 +681,11 @@ ivas_error ivas_corecoder_enc_reconfig_fx( st_ivas->hCPE[0]->hCoreCoder[n]->bwidth, st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ); /* Q0 */ move16(); - +#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS_3 IF( ( error = IGF_Reconfig( &st_ivas->hCPE[0]->hCoreCoder[n]->hIGFEnc, st_ivas->hCPE[0]->hCoreCoder[n]->igf, 1, st_ivas->hCPE[0]->element_brate, st_ivas->hCPE[0]->hCoreCoder[n]->bwidth, st_ivas->hCPE[0]->hCoreCoder[n]->element_mode, st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ) ) != IVAS_ERR_OK ) +#else + IF( ( error = IGF_Reconfig_fx( &st_ivas->hCPE[0]->hCoreCoder[n]->hIGFEnc, st_ivas->hCPE[0]->hCoreCoder[n]->igf, 1, st_ivas->hCPE[0]->element_brate, st_ivas->hCPE[0]->hCoreCoder[n]->bwidth, st_ivas->hCPE[0]->hCoreCoder[n]->element_mode, st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -744,8 +747,11 @@ ivas_error ivas_corecoder_enc_reconfig_fx( st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ); /* Q0 */ move16(); - +#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS_3 IF( ( error = IGF_Reconfig( &st_ivas->hCPE[0]->hCoreCoder[n]->hIGFEnc, st_ivas->hCPE[0]->hCoreCoder[n]->igf, 1, st_ivas->hCPE[0]->element_brate, st_ivas->hCPE[0]->hCoreCoder[n]->bwidth, st_ivas->hCPE[0]->hCoreCoder[n]->element_mode, st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ) ) != IVAS_ERR_OK ) +#else + IF( ( error = IGF_Reconfig_fx( &st_ivas->hCPE[0]->hCoreCoder[n]->hIGFEnc, st_ivas->hCPE[0]->hCoreCoder[n]->igf, 1, st_ivas->hCPE[0]->element_brate, st_ivas->hCPE[0]->hCoreCoder[n]->bwidth, st_ivas->hCPE[0]->hCoreCoder[n]->element_mode, st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_enc/ivas_mct_enc_fx.c b/lib_enc/ivas_mct_enc_fx.c index 81a8f7942..adc64d70c 100644 --- a/lib_enc/ivas_mct_enc_fx.c +++ b/lib_enc/ivas_mct_enc_fx.c @@ -752,8 +752,11 @@ ivas_error mct_enc_reconfigure_fx( move16(); st->igf = getIgfPresent_fx( st->element_mode, L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC ), st->bwidth, st->rf_mode ); move16(); - +#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS_3 IF( ( error = IGF_Reconfig( &st->hIGFEnc, st->igf, 1, st_ivas->hCPE[cpe_id]->element_brate, st->bwidth, st->element_mode, st->rf_mode ) ) != IVAS_ERR_OK ) +#else + IF( ( error = IGF_Reconfig_fx( &st->hIGFEnc, st->igf, 1, st_ivas->hCPE[cpe_id]->element_brate, st->bwidth, st->element_mode, st->rf_mode ) ) != IVAS_ERR_OK ) +#endif { return error; } -- GitLab From 6c7116ba81f3b6383968195cbbd1a5f9a864959d Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Thu, 21 May 2026 18:06:26 +0200 Subject: [PATCH 6/6] clang format --- lib_enc/igf_enc_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c index 998708c44..39cf655d3 100644 --- a/lib_enc/igf_enc_fx.c +++ b/lib_enc/igf_enc_fx.c @@ -3569,4 +3569,4 @@ ivas_error IGF_Reconfig( return error; } -#endif \ No newline at end of file +#endif -- GitLab