From 849c7c502a26d0bf5d9a775ba3eebc151759fb75 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 9 Jan 2026 14:27:58 -0500 Subject: [PATCH 1/9] Harmonization GSC gain part 1 (should be BE --- lib_com/gs_gains_fx.c | 24 ++++++++++++++++++------ lib_com/options.h | 2 +- lib_com/prot_fx.h | 4 ++-- lib_dec/gs_dec_fx.c | 5 ++++- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index 87aa64ec8..9a6338160 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -951,7 +951,7 @@ Word16 gsc_gainQ_ivas_fx( /* RETURN ARGUMENTS : */ /* _ (Word16) : average frequency gain */ /*==========================================================================*/ - +#ifndef OPT_BE_2311_HARM_GSC_GAIN Word16 gsc_gaindec_fx( /* o : average frequency gain */ Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 y_gainQ_fx[], /* o : quantized gain per band */ @@ -1088,7 +1088,7 @@ Word16 gsc_gaindec_fx( /* o : average frequency gai return mean_4g_fx; } - +#endif /*==========================================================================*/ /* FUNCTION : Word16 gsc_gaindec_ivas_fx() */ @@ -1110,8 +1110,11 @@ Word16 gsc_gaindec_fx( /* o : average frequency gai /* RETURN ARGUMENTS : */ /* _ (Word16) : average frequency gain */ /*==========================================================================*/ - +#ifndef OPT_BE_2311_HARM_GSC_GAIN Word16 gsc_gaindec_ivas_fx( /* o : average frequency gain */ +#else +Word16 gsc_gaindec_fx( /* o : average frequency gain */ +#endif Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 y_gainQ_fx[], /* o : quantized gain per band Q12 */ const Word32 core_brate_fx, /* i : core used */ @@ -1269,9 +1272,18 @@ Word16 gsc_gaindec_ivas_fx( /* o : average frequenc } } - /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */ - GSC_gain_adj_ivas_fx( coder_type, Mbands_gn, core_brate_fx, mean_4g_fx, old_y_gain_fx, y_gainQ_fx, y_gainQ_fx ); - + #ifdef OPT_BE_2311_HARM_GSC_GAIN + IF( st_fx->element_mode == EVS_MONO ) + { + GSC_gain_adj( coder_type, core_brate_fx, mean_4g_fx, old_y_gain_fx, y_gainQ_fx, y_gainQ_fx ); + } + ELSE +#endif + { + /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */ + GSC_gain_adj_ivas_fx( coder_type, Mbands_gn, core_brate_fx, mean_4g_fx, old_y_gain_fx, y_gainQ_fx, y_gainQ_fx ); + } + return mean_4g_fx; } diff --git a/lib_com/options.h b/lib_com/options.h index a24403788..fd0205267 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -148,7 +148,7 @@ #define NONBE_OPT_2239_IVAS_FILTER_PROCESS /* Dolby: Issue 2239, optimize ivas_filter_process_fx. */ #define NONBE_OPT_2193_EIG2X2 /* Dolby: Issue 2193, optimize eig2x2_fx. */ #define BE_FIX_2240_COMPUTE_COV_MTC_FX_FAST /* FhG: Speeds up covariance calculation e.g. 60 WMOPS for encoding -mc 7_1_4 24400 48 */ - +#define OPT_BE_2311_HARM_GSC_GAIN /* VA: BE part of the GSC gain harmonisation */ /* #################### End BASOP optimization switches ############################ */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index abb050c02..42e6073b1 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -1546,7 +1546,7 @@ Word16 gsc_gaindec_fx( const Word16 coder_type, /* i : coding type */ const Word16 bwidth_fx /* i : i signal bandwidth */ ); - +#ifndef OPT_BE_2311_HARM_GSC_GAIN /*! r: average frequency gain */ Word16 gsc_gaindec_ivas_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ @@ -1556,7 +1556,7 @@ Word16 gsc_gaindec_ivas_fx( const Word16 coder_type, /* i : coding type */ const Word16 bwidth_fx /* i : input signal bandwidth */ ); - +#endif Word16 gsc_gainQ_fx( BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ const Word16 y_gain4[], /* i : Energy per band Q13 */ diff --git a/lib_dec/gs_dec_fx.c b/lib_dec/gs_dec_fx.c index c10306bc8..cfc9533d6 100644 --- a/lib_dec/gs_dec_fx.c +++ b/lib_dec/gs_dec_fx.c @@ -667,6 +667,7 @@ void gsc_dec_fx( i--; } +#ifndef OPT_BE_2311_HARM_GSC_GAIN IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) { mean_gain = gsc_gaindec_fx( st_fx, Ener_per_bd_iQ, brate_intermed_tbl[i], hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); /* Q3 */ @@ -675,7 +676,9 @@ void gsc_dec_fx( { mean_gain = gsc_gaindec_ivas_fx( st_fx, Ener_per_bd_iQ, brate_intermed_tbl[i], hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); /* Q3 */ } - +#else + mean_gain = gsc_gaindec_fx( st_fx, Ener_per_bd_iQ, brate_intermed_tbl[i], hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); /* Q3 */ +#endif st_fx->lp_gainc_fx = mult_r( 640, mean_gain ); /*10 in Q6 x Q12 -> lp_gainc in Q3 */ move16(); } -- GitLab From 4703bb6deca1e42fc22bc21741239fd8663089a0 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 9 Jan 2026 14:36:56 -0500 Subject: [PATCH 2/9] fix clang-format --- lib_com/gs_gains_fx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index 9a6338160..8c47dfec0 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -1111,9 +1111,9 @@ Word16 gsc_gaindec_fx( /* o : average frequency gai /* _ (Word16) : average frequency gain */ /*==========================================================================*/ #ifndef OPT_BE_2311_HARM_GSC_GAIN -Word16 gsc_gaindec_ivas_fx( /* o : average frequency gain */ +Word16 gsc_gaindec_ivas_fx( /* o : average frequency gain */ #else -Word16 gsc_gaindec_fx( /* o : average frequency gain */ +Word16 gsc_gaindec_fx( /* o : average frequency gain */ #endif Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 y_gainQ_fx[], /* o : quantized gain per band Q12 */ @@ -1272,7 +1272,7 @@ Word16 gsc_gaindec_fx( /* o : average frequency gai } } - #ifdef OPT_BE_2311_HARM_GSC_GAIN +#ifdef OPT_BE_2311_HARM_GSC_GAIN IF( st_fx->element_mode == EVS_MONO ) { GSC_gain_adj( coder_type, core_brate_fx, mean_4g_fx, old_y_gain_fx, y_gainQ_fx, y_gainQ_fx ); @@ -1283,7 +1283,7 @@ Word16 gsc_gaindec_fx( /* o : average frequency gai /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */ GSC_gain_adj_ivas_fx( coder_type, Mbands_gn, core_brate_fx, mean_4g_fx, old_y_gain_fx, y_gainQ_fx, y_gainQ_fx ); } - + return mean_4g_fx; } -- GitLab From 3f87f40f2de255896a68c356b4080a4d7e083d91 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 9 Jan 2026 15:31:08 -0500 Subject: [PATCH 3/9] Firs part of nonBE 2311 harmonisation --- lib_com/gs_gains_fx.c | 52 ++++++++++++++++++++++++++++++++++++------- lib_com/options.h | 3 ++- 2 files changed, 46 insertions(+), 9 deletions(-) diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index 8c47dfec0..8c58fae95 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -388,6 +388,9 @@ void Ener_per_band_comp_ivas_fx( static void GSC_gain_adj( const Word16 coder_type, /* i : Coder type */ +#ifdef OPT_NBE_2311_HARM_GSC_GAIN + const Word16 Mbands_gn, /* i : Number of band */ +#endif const Word32 core_brate, /* i : Bit rate */ const Word16 mean_g, /* i : Average gain Q12 */ Word16 *old_y_gain, /* i/o: Previous frame dequantized vector */ @@ -397,10 +400,23 @@ static void GSC_gain_adj( { /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */ Word16 Gain_off, i; - +#ifdef OPT_NBE_2311_HARM_GSC_GAIN + Word16 Fac_div; + Fac_div = 102; + move16(); +#endif +#ifdef OPT_NBE_2311_HARM_GSC_GAIN + test(); + IF( coder_type != INACTIVE && NE_16( coder_type, UNVOICED ) ) +#else IF( coder_type != INACTIVE ) +#endif { +#ifdef OPT_NBE_2311_HARM_GSC_GAIN + FOR( i = 0; i < Mbands_gn; i++ ) +#else FOR( i = 0; i < MBANDS_GN; i++ ) +#endif { old_y_gain[i] = y_gain_tmp[i]; move16(); @@ -412,7 +428,19 @@ static void GSC_gain_adj( { Gain_off = 0; move16(); +#ifdef OPT_NBE_2311_HARM_GSC_GAIN + test(); + IF( LE_32( core_brate, ACELP_5k00 ) && EQ_16( coder_type, UNVOICED ) ) /* IVAS LR mode only */ + { + Gain_off = 18432; + move16(); /* 9 -> Q11 */ + Fac_div = 205; /* Q15 -> Q16 to compensate for Gain_off being Q11 instead of Q12 */ + move16(); + } + ELSE IF( LE_32( core_brate, ACELP_7k20 ) ) +#else IF( LE_32( core_brate, ACELP_7k20 ) ) +#endif { Gain_off = 32767; move16(); /* 8 -> Q12 */ @@ -444,7 +472,11 @@ static void GSC_gain_adj( old_y_gain[i] = y_gain_tmp[i]; move16(); /*y_gainQ[i] = y_gain_tmp[i]+mean_4g[0]-(i*(Gain_off/20.f)/((float) Mbands_gn));*/ +#ifdef OPT_NBE_2311_HARM_GSC_GAIN + y_gainQ[i] = add( y_gain_tmp[i], sub( mean_g, i_mult2( i, mult_r( Gain_off, Fac_div /* 20/MBANDS_GN in Q15 */ ) ) ) ); +#else y_gainQ[i] = add( y_gain_tmp[i], sub( mean_g, i_mult2( i, mult_r( Gain_off, 102 /* 20/MBANDS_GN in Q15 */ ) ) ) ); +#endif move16(); } } @@ -452,7 +484,7 @@ static void GSC_gain_adj( return; } - +#ifndef OPT_NBE_2311_HARM_GSC_GAIN /*-------------------------------------------------------------------* * GSC_gain_adj_ivas_fx() * @@ -532,7 +564,7 @@ static void GSC_gain_adj_ivas_fx( return; } - +#endif /*-------------------------------------------------------------------* * GSC_gain_DQ() @@ -930,7 +962,7 @@ Word16 gsc_gainQ_ivas_fx( return mean_4g_fx[0]; } - +#ifndef OPT_BE_2311_HARM_GSC_GAIN /*==========================================================================*/ /* FUNCTION : Word16 gsc_gaindec_fx() */ /*--------------------------------------------------------------------------*/ @@ -951,7 +983,6 @@ Word16 gsc_gainQ_ivas_fx( /* RETURN ARGUMENTS : */ /* _ (Word16) : average frequency gain */ /*==========================================================================*/ -#ifndef OPT_BE_2311_HARM_GSC_GAIN Word16 gsc_gaindec_fx( /* o : average frequency gain */ Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 y_gainQ_fx[], /* o : quantized gain per band */ @@ -1271,7 +1302,7 @@ Word16 gsc_gaindec_fx( /* o : average frequency gain */ } } } - +#ifndef OPT_NBE_2311_HARM_GSC_GAIN #ifdef OPT_BE_2311_HARM_GSC_GAIN IF( st_fx->element_mode == EVS_MONO ) { @@ -1283,7 +1314,9 @@ Word16 gsc_gaindec_fx( /* o : average frequency gain */ /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */ GSC_gain_adj_ivas_fx( coder_type, Mbands_gn, core_brate_fx, mean_4g_fx, old_y_gain_fx, y_gainQ_fx, y_gainQ_fx ); } - +#else + GSC_gain_adj( coder_type, Mbands_gn, core_brate_fx, mean_4g_fx, old_y_gain_fx, y_gainQ_fx, y_gainQ_fx ); +#endif return mean_4g_fx; } @@ -1515,8 +1548,11 @@ Word16 gsc_gainQ_fx( /*Q12*/ } /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */ +#ifdef OPT_NBE_2311_HARM_GSC_GAIN + GSC_gain_adj( coder_type, Mbands_gn, core_brate, mean_4g[0], y_gain_tmp2 /* dummy buffer */, y_gain_tmp, y_gainQ ); +#else GSC_gain_adj( coder_type, core_brate, mean_4g[0], y_gain_tmp2 /* dummy buffer */, y_gain_tmp, y_gainQ ); - +#endif return mean_4g[0]; /*Q12*/ } diff --git a/lib_com/options.h b/lib_com/options.h index fd0205267..19f5f88f4 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -148,7 +148,8 @@ #define NONBE_OPT_2239_IVAS_FILTER_PROCESS /* Dolby: Issue 2239, optimize ivas_filter_process_fx. */ #define NONBE_OPT_2193_EIG2X2 /* Dolby: Issue 2193, optimize eig2x2_fx. */ #define BE_FIX_2240_COMPUTE_COV_MTC_FX_FAST /* FhG: Speeds up covariance calculation e.g. 60 WMOPS for encoding -mc 7_1_4 24400 48 */ -#define OPT_BE_2311_HARM_GSC_GAIN /* VA: BE part of the GSC gain harmonisation */ +#define OPT_BE_2311_HARM_GSC_GAIN /* VA: BE part of the GSC gain harmonization */ +#define OPT_NBE_2311_HARM_GSC_GAIN /* VA: NBE part of the GSC gain harmonization */ /* #################### End BASOP optimization switches ############################ */ -- GitLab From af82f7ccc96707dcd556415481a73488ff4fe78e Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 9 Jan 2026 15:53:40 -0500 Subject: [PATCH 4/9] fix clang --- lib_com/gs_gains_fx.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index 8c58fae95..075002480 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -387,9 +387,9 @@ void Ener_per_band_comp_ivas_fx( *-------------------------------------------------------------------*/ static void GSC_gain_adj( - const Word16 coder_type, /* i : Coder type */ + const Word16 coder_type, /* i : Coder type */ #ifdef OPT_NBE_2311_HARM_GSC_GAIN - const Word16 Mbands_gn, /* i : Number of band */ + const Word16 Mbands_gn, /* i : Number of band */ #endif const Word32 core_brate, /* i : Bit rate */ const Word16 mean_g, /* i : Average gain Q12 */ @@ -410,13 +410,13 @@ static void GSC_gain_adj( IF( coder_type != INACTIVE && NE_16( coder_type, UNVOICED ) ) #else IF( coder_type != INACTIVE ) -#endif +#endif { #ifdef OPT_NBE_2311_HARM_GSC_GAIN FOR( i = 0; i < Mbands_gn; i++ ) #else FOR( i = 0; i < MBANDS_GN; i++ ) -#endif +#endif { old_y_gain[i] = y_gain_tmp[i]; move16(); @@ -430,10 +430,10 @@ static void GSC_gain_adj( move16(); #ifdef OPT_NBE_2311_HARM_GSC_GAIN test(); - IF( LE_32( core_brate, ACELP_5k00 ) && EQ_16( coder_type, UNVOICED ) ) /* IVAS LR mode only */ + IF( LE_32( core_brate, ACELP_5k00 ) && EQ_16( coder_type, UNVOICED ) ) /* IVAS LR mode only */ { Gain_off = 18432; - move16(); /* 9 -> Q11 */ + move16(); /* 9 -> Q11 */ Fac_div = 205; /* Q15 -> Q16 to compensate for Gain_off being Q11 instead of Q12 */ move16(); } -- GitLab From ba71ff420aae03ad60c9c49a5c376f9bfa0434a5 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 9 Jan 2026 17:00:21 -0500 Subject: [PATCH 5/9] part 2 of NBE harmonisation --- lib_com/gs_gains_fx.c | 143 ++++++++++++++++++++++++++++++------------ lib_com/options.h | 2 +- lib_com/prot_fx.h | 16 +++++ lib_enc/gs_enc_fx.c | 6 ++ 4 files changed, 126 insertions(+), 41 deletions(-) diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index 075002480..c876a1d8e 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -564,7 +564,6 @@ static void GSC_gain_adj_ivas_fx( return; } -#endif /*-------------------------------------------------------------------* * GSC_gain_DQ() @@ -961,7 +960,7 @@ Word16 gsc_gainQ_ivas_fx( return mean_4g_fx[0]; } - +#endif #ifndef OPT_BE_2311_HARM_GSC_GAIN /*==========================================================================*/ /* FUNCTION : Word16 gsc_gaindec_fx() */ @@ -1326,8 +1325,21 @@ Word16 gsc_gaindec_fx( /* o : average frequency gain */ * * Quantization of the energy per band *-------------------------------------------------------------------*/ - -Word16 gsc_gainQ_fx( /*Q12*/ +#ifdef OPT_NBE_2311_HARM_GSC_GAIN +Word16 gsc_gainQ_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 idchan, /* i : channel ID */ + const Word16 y_gain4[], /* i : Energy per band Q12*/ + Word16 y_gainQ[], /* o : quantized energy per band Q12*/ + const Word32 core_brate, /* i : Core rate */ + const Word16 coder_type, /* i : coding type */ + const Word16 bwidth, /* i : input signal bandwidth */ + const Word16 L_frame, /* i : frame length */ + const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */ + const Word32 core_brate_inp /* i : true core bitrate */ + ) +#else + Word16 gsc_gainQ_fx( /*Q12*/ BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ const Word16 y_gain4[], /* i : Energy per band Q12 */ Word16 y_gainQ[], /* o : quantized energy per band Q12 */ @@ -1335,19 +1347,34 @@ Word16 gsc_gainQ_fx( /*Q12*/ const Word16 coder_type, /* i : coding type */ const Word16 bwidth /* i : input signal bandwidth */ ) +#endif { +#ifdef OPT_NBE_2311_HARM_GSC_GAIN + Word16 y_gain_tmp[MBANDS_GN16k], y_gain_tmp2[MBANDS_GN16k]; +#else Word16 y_gain_tmp[MBANDS_GN], y_gain_tmp2[MBANDS_GN]; +#endif Word16 i, idx_g = 0; move16(); Word16 mean_4g[1] = { 0 }, tmp16, tmp1, tmp2; move16(); Word16 Mbands_gn = MBANDS_GN; +#ifdef OPT_NBE_2311_HARM_GSC_GAIN + Word16 y_gain_tmp3[MBANDS_GN16k]; +#else Word16 y_gain_tmp3[MBANDS_GN]; +#endif Word16 cnt; Word32 L_tmp; mean_4g[0] = 0; - +#ifdef OPT_NBE_2311_HARM_GSC_GAIN + if ( EQ_16( L_frame, L_FRAME16k ) ) + { + Mbands_gn = MBANDS_GN16k; + move16(); + } +#endif test(); test(); IF( ( EQ_16( coder_type, AUDIO ) || ( coder_type == INACTIVE ) ) && ( bwidth == NB ) ) @@ -1445,7 +1472,7 @@ Word16 gsc_gainQ_fx( /*Q12*/ } tmp16 = round_fx( L_tmp ); - tmp1 = sub( tmp16, 4915 ); + tmp1 = sub( tmp16, 4915 ); /* 0.6 Q12 */ tmp2 = add( tmp16, 4915 ); L_tmp = 0; move32(); @@ -1501,49 +1528,85 @@ Word16 gsc_gainQ_fx( /*Q12*/ idx_g = vquant_fx( y_gain_tmp2, YGain_mean_LR_fx, y_gain_tmp2, YGain_dic1_LR_fx, 3, 32 ); push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); - idx_g = vquant_fx( y_gain_tmp2 + 3, YGain_mean_LR_fx + 3, y_gain_tmp2 + 3, YGain_dic2_LR_fx, 4, 32 ); - push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); - idx_g = vquant_fx( y_gain_tmp2 + 7, YGain_mean_LR_fx + 7, y_gain_tmp2 + 7, YGain_dic3_LR_fx, 5, 32 ); - push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); - set16_fx( y_gain_tmp2 + 12, 0, MBANDS_GN - 12 ); +#ifdef OPT_NBE_2311_HARM_GSC_GAIN + IF( !( coder_type == INACTIVE && tdm_LRTD_flag == 0 && EQ_16( idchan, 1 ) ) || GT_32( core_brate_inp, GSC_LRES_GAINQ_LIMIT ) ) + { +#endif + idx_g = vquant_fx( y_gain_tmp2 + 3, YGain_mean_LR_fx + 3, y_gain_tmp2 + 3, YGain_dic2_LR_fx, 4, 32 ); + push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); + idx_g = vquant_fx( y_gain_tmp2 + 7, YGain_mean_LR_fx + 7, y_gain_tmp2 + 7, YGain_dic3_LR_fx, 5, 32 ); + push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); + set16_fx( y_gain_tmp2 + 12, 0, MBANDS_GN - 12 ); - /* Update to quantized vector */ - Copy( y_gain_tmp2, y_gain_tmp, 8 ); + /* Update to quantized vector */ + Copy( y_gain_tmp2, y_gain_tmp, 8 ); - Copy( y_gain_tmp2 + 8, y_gain_tmp3, 4 ); - set16_fx( y_gain_tmp + 8, 0, 8 ); - fft_rel_fx( y_gain_tmp2 + 8, 4, 2 ); + Copy( y_gain_tmp2 + 8, y_gain_tmp3, 4 ); + set16_fx( y_gain_tmp + 8, 0, 8 ); + fft_rel_fx( y_gain_tmp2 + 8, 4, 2 ); - Copy( y_gain_tmp2 + 8, y_gain_tmp + 8, 3 ); - y_gain_tmp[15] = y_gain_tmp2[11]; - move16(); - ifft_rel_fx( y_gain_tmp + 8, 8, 3 ); + Copy( y_gain_tmp2 + 8, y_gain_tmp + 8, 3 ); + y_gain_tmp[15] = y_gain_tmp2[11]; + move16(); + ifft_rel_fx( y_gain_tmp + 8, 8, 3 ); - FOR( i = 8; i < 16; i++ ) - { - y_gain_tmp[i] = shl( mult_r( y_gain_tmp[i], 23101 ), 1 ); + FOR( i = 8; i < 16; i++ ) + { + y_gain_tmp[i] = shl( mult_r( y_gain_tmp[i], 23101 ), 1 ); + move16(); + } + + y_gain_tmp[8] = y_gain_tmp3[0]; move16(); + y_gain_tmp[10] = y_gain_tmp3[1]; + move16(); + y_gain_tmp[12] = y_gain_tmp3[2]; + move16(); + y_gain_tmp[14] = y_gain_tmp3[3]; + move16(); +#ifdef OPT_NBE_2311_HARM_GSC_GAIN } - - y_gain_tmp[8] = y_gain_tmp3[0]; - move16(); - y_gain_tmp[10] = y_gain_tmp3[1]; - move16(); - y_gain_tmp[12] = y_gain_tmp3[2]; - move16(); - y_gain_tmp[14] = y_gain_tmp3[3]; - move16(); + ELSE + { + Copy( y_gain_tmp2, y_gain_tmp, 3 ); + set16_fx( y_gain_tmp + 3, 0, MBANDS_GN16k - 3 ); + } +#endif } ELSE { - idx_g = vquant_fx( y_gain_tmp, YG_mean16_fx, y_gain_tmp, YG_dicMR_1_fx, 4, 64 ); - push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 ); - idx_g = vquant_fx( y_gain_tmp + 4, YG_mean16_fx + 4, y_gain_tmp + 4, YG_dicMR_2_fx, 4, 32 ); - push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); - idx_g = vquant_fx( y_gain_tmp + 8, YG_mean16_fx + 8, y_gain_tmp + 8, YG_dicMR_3_fx, 4, 32 ); - push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); - idx_g = vquant_fx( y_gain_tmp + 12, YG_mean16_fx + 12, y_gain_tmp + 12, YG_dicMR_4_fx, 4, 16 ); - push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 4 ); +#ifdef OPT_NBE_2311_HARM_GSC_GAIN + IF( EQ_16( L_frame, L_FRAME ) ) + { +#endif + idx_g = vquant_fx( y_gain_tmp, YG_mean16_fx, y_gain_tmp, YG_dicMR_1_fx, 4, 64 ); + push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 ); + idx_g = vquant_fx( y_gain_tmp + 4, YG_mean16_fx + 4, y_gain_tmp + 4, YG_dicMR_2_fx, 4, 32 ); + push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); + idx_g = vquant_fx( y_gain_tmp + 8, YG_mean16_fx + 8, y_gain_tmp + 8, YG_dicMR_3_fx, 4, 32 ); + push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); + idx_g = vquant_fx( y_gain_tmp + 12, YG_mean16_fx + 12, y_gain_tmp + 12, YG_dicMR_4_fx, 4, 16 ); + push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 4 ); + } +#ifdef OPT_NBE_2311_HARM_GSC_GAIN + ELSE + { + idx_g = vquant_fx( y_gain_tmp, YG_mean16HR_fx, y_gain_tmp, YG_dicHR_1_fx, 4, 128 ); + push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 7 ); + + idx_g = vquant_fx( y_gain_tmp + 4, YG_mean16HR_fx + 4, y_gain_tmp + 4, YG_dicHR_2_fx, 4, 64 ); + push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 ); + + idx_g = vquant_fx( y_gain_tmp + 8, YG_mean16HR_fx + 8, y_gain_tmp + 8, YG_dicHR_3_fx, 4, 64 ); + push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 ); + + idx_g = vquant_fx( y_gain_tmp + 12, YG_mean16HR_16kHz_fx, y_gain_tmp + 12, YG_dicHR_4_16kHz_fx, 4, 64 ); + push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 ); + + idx_g = vquant_fx( y_gain_tmp + 16, YG_meanL2G_16kHz_fx, y_gain_tmp + 16, YG_dicL2G_16kHz_fx, 2, 8 ); + push_indice( hBstr, IND_Y_GAIN_HF, idx_g, 3 ); + } +#endif } } diff --git a/lib_com/options.h b/lib_com/options.h index 19f5f88f4..99f6e8a60 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -148,7 +148,7 @@ #define NONBE_OPT_2239_IVAS_FILTER_PROCESS /* Dolby: Issue 2239, optimize ivas_filter_process_fx. */ #define NONBE_OPT_2193_EIG2X2 /* Dolby: Issue 2193, optimize eig2x2_fx. */ #define BE_FIX_2240_COMPUTE_COV_MTC_FX_FAST /* FhG: Speeds up covariance calculation e.g. 60 WMOPS for encoding -mc 7_1_4 24400 48 */ -#define OPT_BE_2311_HARM_GSC_GAIN /* VA: BE part of the GSC gain harmonization */ +#define OPT_BE_2311_HARM_GSC_GAIN /* VA: BE part of the GSC gain harmonization pipeline #70380 shows the BE */ #define OPT_NBE_2311_HARM_GSC_GAIN /* VA: NBE part of the GSC gain harmonization */ /* #################### End BASOP optimization switches ############################ */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 42e6073b1..77577976a 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -1557,6 +1557,7 @@ Word16 gsc_gaindec_ivas_fx( const Word16 bwidth_fx /* i : input signal bandwidth */ ); #endif +#ifndef OPT_NBE_2311_HARM_GSC_GAIN Word16 gsc_gainQ_fx( BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ const Word16 y_gain4[], /* i : Energy per band Q13 */ @@ -1580,6 +1581,21 @@ Word16 gsc_gainQ_ivas_fx( const Word32 core_brate_inp /* i : true core bitrate */ ); +#else +Word16 gsc_gainQ_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 idchan, /* i : channel ID */ + const Word16 y_gain4[], /* i : Energy per band Q12 */ + Word16 y_gainQ[], /* o : quantized energy per band Q12 */ + const Word32 core_brate, /* i : Core rate */ + const Word16 coder_type, /* i : coding type */ + const Word16 bwidth, /* i : input signal bandwidth */ + const Word16 L_frame, /* i : frame length */ + const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */ + const Word32 core_brate_inp /* i : true core bitrate */ +); +#endif + void fer_energy_fx( const Word16 L_frame, /* i : frame length */ const Word16 clas, /* i : frame classification */ diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index 0498c0c33..461606b8e 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -993,6 +993,7 @@ void gsc_enc_fx( { i--; } +#ifndef OPT_NBE_2311_HARM_GSC_GAIN #ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) /* This could be harmonized, but won't be BE */ { @@ -1006,6 +1007,11 @@ void gsc_enc_fx( *tmp_noise = mult_r( 320, mean_gain ); /*10 in Q5 lp_gainc in Q3 */ } move16(); +#else + mean_gain = gsc_gainQ_fx( hBstr, st_fx->idchan, Ener_per_bd_iQ, Ener_per_bd_iQ, brate_intermed_tbl[i], st_fx->coder_type, st_fx->bwidth , st_fx->L_frame, st_fx->tdm_LRTD_flag, st_fx->core_brate ); + *tmp_noise = mult_r( 320, mean_gain ); /*10 in Q5 lp_gainc in Q3 */ + move16(); +#endif /*--------------------------------------------------------------------------------------* * Frequency encoder -- GitLab From d91f9bca2192b795b56fb14c7aeb3262dbfb326f Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 9 Jan 2026 17:05:10 -0500 Subject: [PATCH 6/9] fix clang --- lib_com/gs_gains_fx.c | 28 ++++++++++++++-------------- lib_enc/gs_enc_fx.c | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index c876a1d8e..c447c6208 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -1327,19 +1327,19 @@ Word16 gsc_gaindec_fx( /* o : average frequency gain */ *-------------------------------------------------------------------*/ #ifdef OPT_NBE_2311_HARM_GSC_GAIN Word16 gsc_gainQ_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 idchan, /* i : channel ID */ - const Word16 y_gain4[], /* i : Energy per band Q12*/ - Word16 y_gainQ[], /* o : quantized energy per band Q12*/ - const Word32 core_brate, /* i : Core rate */ - const Word16 coder_type, /* i : coding type */ - const Word16 bwidth, /* i : input signal bandwidth */ - const Word16 L_frame, /* i : frame length */ - const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */ - const Word32 core_brate_inp /* i : true core bitrate */ - ) + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 idchan, /* i : channel ID */ + const Word16 y_gain4[], /* i : Energy per band Q12*/ + Word16 y_gainQ[], /* o : quantized energy per band Q12*/ + const Word32 core_brate, /* i : Core rate */ + const Word16 coder_type, /* i : coding type */ + const Word16 bwidth, /* i : input signal bandwidth */ + const Word16 L_frame, /* i : frame length */ + const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */ + const Word32 core_brate_inp /* i : true core bitrate */ +) #else - Word16 gsc_gainQ_fx( /*Q12*/ +Word16 gsc_gainQ_fx( /*Q12*/ BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ const Word16 y_gain4[], /* i : Energy per band Q12 */ Word16 y_gainQ[], /* o : quantized energy per band Q12 */ @@ -1368,7 +1368,7 @@ Word16 gsc_gainQ_fx( Word32 L_tmp; mean_4g[0] = 0; -#ifdef OPT_NBE_2311_HARM_GSC_GAIN +#ifdef OPT_NBE_2311_HARM_GSC_GAIN if ( EQ_16( L_frame, L_FRAME16k ) ) { Mbands_gn = MBANDS_GN16k; @@ -1614,7 +1614,7 @@ Word16 gsc_gainQ_fx( #ifdef OPT_NBE_2311_HARM_GSC_GAIN GSC_gain_adj( coder_type, Mbands_gn, core_brate, mean_4g[0], y_gain_tmp2 /* dummy buffer */, y_gain_tmp, y_gainQ ); #else - GSC_gain_adj( coder_type, core_brate, mean_4g[0], y_gain_tmp2 /* dummy buffer */, y_gain_tmp, y_gainQ ); +GSC_gain_adj( coder_type, core_brate, mean_4g[0], y_gain_tmp2 /* dummy buffer */, y_gain_tmp, y_gainQ ); #endif return mean_4g[0]; /*Q12*/ } diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index 461606b8e..dd35aae58 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -1008,7 +1008,7 @@ void gsc_enc_fx( } move16(); #else - mean_gain = gsc_gainQ_fx( hBstr, st_fx->idchan, Ener_per_bd_iQ, Ener_per_bd_iQ, brate_intermed_tbl[i], st_fx->coder_type, st_fx->bwidth , st_fx->L_frame, st_fx->tdm_LRTD_flag, st_fx->core_brate ); + mean_gain = gsc_gainQ_fx( hBstr, st_fx->idchan, Ener_per_bd_iQ, Ener_per_bd_iQ, brate_intermed_tbl[i], st_fx->coder_type, st_fx->bwidth, st_fx->L_frame, st_fx->tdm_LRTD_flag, st_fx->core_brate ); *tmp_noise = mult_r( 320, mean_gain ); /*10 in Q5 lp_gainc in Q3 */ move16(); #endif -- GitLab From 8fc1f4eadff7717cd17bc091d64805427ae014b8 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 14 Jan 2026 10:12:56 +0100 Subject: [PATCH 7/9] formatting --- lib_com/gs_gains_fx.c | 36 +++++++++++++++++++++++++++--------- lib_com/gs_preech_fx.c | 2 +- lib_com/options.h | 5 +++-- lib_com/prot_fx.h | 2 ++ lib_dec/gs_dec_fx.c | 3 +++ lib_enc/gs_enc_fx.c | 12 ++++++++---- 6 files changed, 44 insertions(+), 16 deletions(-) diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index c447c6208..f77c8442a 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -405,6 +405,7 @@ static void GSC_gain_adj( Fac_div = 102; move16(); #endif + #ifdef OPT_NBE_2311_HARM_GSC_GAIN test(); IF( coder_type != INACTIVE && NE_16( coder_type, UNVOICED ) ) @@ -428,6 +429,7 @@ static void GSC_gain_adj( { Gain_off = 0; move16(); + #ifdef OPT_NBE_2311_HARM_GSC_GAIN test(); IF( LE_32( core_brate, ACELP_5k00 ) && EQ_16( coder_type, UNVOICED ) ) /* IVAS LR mode only */ @@ -1140,17 +1142,19 @@ Word16 gsc_gaindec_fx( /* o : average frequency gai /* RETURN ARGUMENTS : */ /* _ (Word16) : average frequency gain */ /*==========================================================================*/ + #ifndef OPT_BE_2311_HARM_GSC_GAIN Word16 gsc_gaindec_ivas_fx( /* o : average frequency gain */ #else -Word16 gsc_gaindec_fx( /* o : average frequency gain */ +/*! r: average frequency gain */ +Word16 gsc_gaindec_fx( #endif - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 y_gainQ_fx[], /* o : quantized gain per band Q12 */ - const Word32 core_brate_fx, /* i : core used */ - Word16 old_y_gain_fx[], /* i/o: AR gain quantizer for low rate */ - const Word16 coder_type, /* i : coding type */ - const Word16 bwidth_fx /* i : input signal bandwidth */ + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 y_gainQ_fx[], /* o : quantized gain per band Q12 */ + const Word32 core_brate_fx, /* i : core used */ + Word16 old_y_gain_fx[], /* i/o: AR gain quantizer for low rate */ + const Word16 coder_type, /* i : coding type */ + const Word16 bwidth_fx /* i : input signal bandwidth */ ) { Word16 idx_g_fx, i; @@ -1158,6 +1162,7 @@ Word16 gsc_gaindec_fx( /* o : average frequency gain */ Word16 Mbands_gn = MBANDS_GN; move16(); Word16 y_gain_tmp3_fx[MBANDS_GN]; + if ( EQ_16( st_fx->L_frame, L_FRAME16k ) ) { Mbands_gn = MBANDS_GN16k; @@ -1224,6 +1229,7 @@ Word16 gsc_gaindec_fx( /* o : average frequency gain */ /*--------------------------------------------------------------------------------------* * UQ of the first 8 bands and half of the last 8 bands *--------------------------------------------------------------------------------------*/ + idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 ); VDQ_vec_fx( y_gainQ_fx, YGain_mean_LR_fx, YGain_dic1_LR_fx, idx_g_fx, 3 ); @@ -1254,9 +1260,11 @@ Word16 gsc_gaindec_fx( /* o : average frequency gain */ y_gainQ_fx[i] = round_fx( L_shl( L_mult( y_gainQ_fx[i], 23101 ), 1 ) ); /*Q12 */ move16(); } + /*----------------------------------------------------------------------* * Copy the true Q values in the specific bands *----------------------------------------------------------------------*/ + y_gainQ_fx[8] = y_gain_tmp3_fx[0]; /*Q12*/ move16(); y_gainQ_fx[10] = y_gain_tmp3_fx[1]; /*Q12*/ @@ -1301,6 +1309,7 @@ Word16 gsc_gaindec_fx( /* o : average frequency gain */ } } } + #ifndef OPT_NBE_2311_HARM_GSC_GAIN #ifdef OPT_BE_2311_HARM_GSC_GAIN IF( st_fx->element_mode == EVS_MONO ) @@ -1316,6 +1325,7 @@ Word16 gsc_gaindec_fx( /* o : average frequency gain */ #else GSC_gain_adj( coder_type, Mbands_gn, core_brate_fx, mean_4g_fx, old_y_gain_fx, y_gainQ_fx, y_gainQ_fx ); #endif + return mean_4g_fx; } @@ -1325,6 +1335,7 @@ Word16 gsc_gaindec_fx( /* o : average frequency gain */ * * Quantization of the energy per band *-------------------------------------------------------------------*/ + #ifdef OPT_NBE_2311_HARM_GSC_GAIN Word16 gsc_gainQ_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ @@ -1375,11 +1386,11 @@ Word16 gsc_gainQ_fx( /*Q12*/ move16(); } #endif + test(); test(); IF( ( EQ_16( coder_type, AUDIO ) || ( coder_type == INACTIVE ) ) && ( bwidth == NB ) ) { - /*ftmp1 = mean(y_gain4, 10)-0.6f;*/ L_tmp = L_deposit_l( 0 ); FOR( cnt = 0; cnt < 10; cnt++ ) @@ -1463,7 +1474,6 @@ Word16 gsc_gainQ_fx( /*Q12*/ ELSE { /*ftmp1 = mean(y_gain4, 16);*/ - L_tmp = 0; move32(); FOR( cnt = 0; cnt < 16; cnt++ ) @@ -1528,7 +1538,11 @@ Word16 gsc_gainQ_fx( /*Q12*/ idx_g = vquant_fx( y_gain_tmp2, YGain_mean_LR_fx, y_gain_tmp2, YGain_dic1_LR_fx, 3, 32 ); push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); + #ifdef OPT_NBE_2311_HARM_GSC_GAIN + test(); + test(); + test(); IF( !( coder_type == INACTIVE && tdm_LRTD_flag == 0 && EQ_16( idchan, 1 ) ) || GT_32( core_brate_inp, GSC_LRES_GAINQ_LIMIT ) ) { #endif @@ -1581,10 +1595,13 @@ Word16 gsc_gainQ_fx( /*Q12*/ #endif idx_g = vquant_fx( y_gain_tmp, YG_mean16_fx, y_gain_tmp, YG_dicMR_1_fx, 4, 64 ); push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 ); + idx_g = vquant_fx( y_gain_tmp + 4, YG_mean16_fx + 4, y_gain_tmp + 4, YG_dicMR_2_fx, 4, 32 ); push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); + idx_g = vquant_fx( y_gain_tmp + 8, YG_mean16_fx + 8, y_gain_tmp + 8, YG_dicMR_3_fx, 4, 32 ); push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); + idx_g = vquant_fx( y_gain_tmp + 12, YG_mean16_fx + 12, y_gain_tmp + 12, YG_dicMR_4_fx, 4, 16 ); push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 4 ); } @@ -1616,6 +1633,7 @@ Word16 gsc_gainQ_fx( /*Q12*/ #else GSC_gain_adj( coder_type, core_brate, mean_4g[0], y_gain_tmp2 /* dummy buffer */, y_gain_tmp, y_gainQ ); #endif + return mean_4g[0]; /*Q12*/ } diff --git a/lib_com/gs_preech_fx.c b/lib_com/gs_preech_fx.c index 28092088e..5a35108ec 100644 --- a/lib_com/gs_preech_fx.c +++ b/lib_com/gs_preech_fx.c @@ -76,6 +76,7 @@ void pre_echo_att_fx( #ifdef FIX_1904_HARM_GSC_ENC Word16 etmp_e, tmp_e; #endif + test(); IF( gsc_attack_flag_fx > 0 && EQ_16( last_coder_type, AUDIO ) ) /*gsc_attack_flag_fx does not get set for all the test cases */ { @@ -203,7 +204,6 @@ void pre_echo_att_fx( return; } - #ifndef FIX_1904_HARM_GSC_ENC void pre_echo_att_ivas_fx( Word32 *Last_frame_ener_fx, /* i/o: Energy of the last frame 2*Q_new+1*/ diff --git a/lib_com/options.h b/lib_com/options.h index 99f6e8a60..0e255c412 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -148,8 +148,9 @@ #define NONBE_OPT_2239_IVAS_FILTER_PROCESS /* Dolby: Issue 2239, optimize ivas_filter_process_fx. */ #define NONBE_OPT_2193_EIG2X2 /* Dolby: Issue 2193, optimize eig2x2_fx. */ #define BE_FIX_2240_COMPUTE_COV_MTC_FX_FAST /* FhG: Speeds up covariance calculation e.g. 60 WMOPS for encoding -mc 7_1_4 24400 48 */ -#define OPT_BE_2311_HARM_GSC_GAIN /* VA: BE part of the GSC gain harmonization pipeline #70380 shows the BE */ -#define OPT_NBE_2311_HARM_GSC_GAIN /* VA: NBE part of the GSC gain harmonization */ +#define OPT_BE_2311_HARM_GSC_GAIN /* VA: issue 2311: BE part of the GSC gain harmonization pipeline #70380 shows the BE */ +#define OPT_NBE_2311_HARM_GSC_GAIN /* VA: issue 2311: non-BE part of the GSC gain harmonization */ + /* #################### End BASOP optimization switches ############################ */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 77577976a..c84835452 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -1546,6 +1546,7 @@ Word16 gsc_gaindec_fx( const Word16 coder_type, /* i : coding type */ const Word16 bwidth_fx /* i : i signal bandwidth */ ); + #ifndef OPT_BE_2311_HARM_GSC_GAIN /*! r: average frequency gain */ Word16 gsc_gaindec_ivas_fx( @@ -5077,6 +5078,7 @@ void freq_dnw_scaling_fx( Word16 Qx, /* Q format of fy_norm*/ const Word16 L_frame /* i : frame length */ ); + #ifndef FIX_1904_HARM_GSC_ENC void highband_exc_dct_in_fx( const Word32 core_brate, /* i : core bitrate */ diff --git a/lib_dec/gs_dec_fx.c b/lib_dec/gs_dec_fx.c index cfc9533d6..05b111fbe 100644 --- a/lib_dec/gs_dec_fx.c +++ b/lib_dec/gs_dec_fx.c @@ -679,6 +679,7 @@ void gsc_dec_fx( #else mean_gain = gsc_gaindec_fx( st_fx, Ener_per_bd_iQ, brate_intermed_tbl[i], hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); /* Q3 */ #endif + st_fx->lp_gainc_fx = mult_r( 640, mean_gain ); /*10 in Q6 x Q12 -> lp_gainc in Q3 */ move16(); } @@ -863,6 +864,7 @@ void gsc_dec_fx( /*--------------------------------------------------------------------------------------* * Estimate noise level *--------------------------------------------------------------------------------------*/ + #ifdef FIX_1904_HARM_GSC_ENC highband_exc_dct_in_fx( st_fx->core_brate, mfreq_bindiv_loc, *last_bin, Diff_len, hGSCDec->noise_lev, pit_band_idx, exc_diffQ, &hGSCDec->seed_tcx, Ener_per_bd_iQ, nb_subfr, exc_dct_in, st_fx->last_coder_type, bitallocation_band, lsf_new, @@ -874,6 +876,7 @@ void gsc_dec_fx( hGSCDec->last_exc_dct_in_fx, &hGSCDec->last_ener_fx, hGSCDec->last_bitallocation_band, bitallocation_exc, st_fx->bfi, coder_type, st_fx->bwidth, exc_wo_nf, Qexc_diffQ, Q_exc, st_fx->GSC_noisy_speech, hGSCDec->lt_ener_per_band_fx, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode ); #endif + exc_dct_in[0] = 0; move16(); diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index dd35aae58..79b419633 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -105,6 +105,7 @@ void encod_audio_fx( push_indice( hBstr, IND_GSC_IVAS_SP, st_fx->GSC_IVAS_mode, 2 ); } #endif + IF( attack_flag > 0 ) { push_indice( hBstr, IND_GSC_ATTACK, 1, 1 ); @@ -371,6 +372,7 @@ void encod_audio_fx( #ifdef FIX_1904_HARM_GSC_ENC Q_exc = Q_new; move16(); + gsc_enc_fx( st_fx, dct_res, dct_epit, last_pit_bin, tmp_nb_bits_tot, nb_subfr, lsf_new, exc_wo_nf, tmp_noise, &Q_exc ); #else gsc_enc_fx( st_fx, dct_res, dct_epit, last_pit_bin, tmp_nb_bits_tot, nb_subfr, lsf_new, exc_wo_nf, tmp_noise, Q_new ); @@ -418,6 +420,7 @@ void encod_audio_fx( interp_code_5over2_fx( exc, bwe_exc, L_FRAME ); } } + /*--------------------------------------------------------------------------------------* * Synthesis *--------------------------------------------------------------------------------------*/ @@ -840,7 +843,7 @@ void encod_audio_ivas_fx( #endif /*================================================================================*/ -/* FUNCTION : void gsc_enc_fx () */ +/* FUNCTION : void gsc_enc_fx() */ /*--------------------------------------------------------------------------------*/ /* PURPOSE : Generic audio signal encoder */ /*--------------------------------------------------------------------------------*/ @@ -856,7 +859,7 @@ void encod_audio_ivas_fx( /* _ None */ /*--------------------------------------------------------------------------------*/ /* INPUT/OUTPUT ARGUMENTS : */ -/* Encoder_State *st_fx:Encoder State Structure */ +/* Encoder_State *st_fx:Encoder State Structure */ /* _ (Word16[]) exc_dct_in : dctof pitch-only excitation / total excitation Q_exc */ /*--------------------------------------------------------------------------------*/ /* RETURN ARGUMENTS : */ @@ -864,8 +867,8 @@ void encod_audio_ivas_fx( /*================================================================================*/ void gsc_enc_fx( - Encoder_State *st_fx, /* i/o: State structure */ - Word16 res_dct_in[], /* i : dct of residual signal Q_exc*/ + Encoder_State *st_fx, /* i/o: State structure */ + Word16 res_dct_in[], /* i : dct of residual signal Q_exc*/ Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation Q_exc*/ const Word16 Diff_len, const Word16 bits_used, @@ -993,6 +996,7 @@ void gsc_enc_fx( { i--; } + #ifndef OPT_NBE_2311_HARM_GSC_GAIN #ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) /* This could be harmonized, but won't be BE */ -- GitLab From 03049121de35c2fc9769441d9da96bee0292973a Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Wed, 14 Jan 2026 10:50:28 -0500 Subject: [PATCH 8/9] fixed missplaced braket that prevent compiling when 2311 switches are disabled --- lib_com/gs_gains_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index 6e18a5f43..186cf3e98 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -1599,8 +1599,8 @@ Word16 gsc_gainQ_fx( /*Q12*/ { #ifdef OPT_NBE_2311_HARM_GSC_GAIN IF( EQ_16( L_frame, L_FRAME ) ) - { #endif + { idx_g = vquant_fx( y_gain_tmp, YG_mean16_fx, y_gain_tmp, YG_dicMR_1_fx, 4, 64 ); push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 ); @@ -1639,7 +1639,7 @@ Word16 gsc_gainQ_fx( /*Q12*/ #ifdef OPT_NBE_2311_HARM_GSC_GAIN GSC_gain_adj( coder_type, Mbands_gn, core_brate, mean_4g[0], y_gain_tmp2 /* dummy buffer */, y_gain_tmp, y_gainQ ); #else -GSC_gain_adj( coder_type, core_brate, mean_4g[0], y_gain_tmp2 /* dummy buffer */, y_gain_tmp, y_gainQ ); + GSC_gain_adj( coder_type, core_brate, mean_4g[0], y_gain_tmp2 /* dummy buffer */, y_gain_tmp, y_gainQ ); #endif return mean_4g[0]; /*Q12*/ -- GitLab From cbe1ea06f96af9383b8ce606b66f546b32d0c886 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 15 Jan 2026 16:52:42 +0100 Subject: [PATCH 9/9] clang-format --- lib_com/gs_gains_fx.c | 2 +- lib_com/options.h | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index 8057d2a22..57e6a2690 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -1271,7 +1271,7 @@ Word16 gsc_gaindec_fx( /*----------------------------------------------------------------------* * Copy the true Q values in the specific bands *----------------------------------------------------------------------*/ - + y_gainQ_fx[8] = y_gain_tmp3_fx[0]; /*Q12*/ move16(); y_gainQ_fx[10] = y_gain_tmp3_fx[1]; /*Q12*/ diff --git a/lib_com/options.h b/lib_com/options.h index 0645ff282..583a9d0dc 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -97,6 +97,7 @@ #define REMOVE_UNUSED_CODE_IVAS_DEC /* VA: remove unused code in ivas_jbm_dec_tc_fx() */ #define FIX_2294_CLANG_18_WARNINGS_ENC /* VA: Fix some encoder clang-18 warnings, desc. in 2294 */ #define REMOVE_CAM_FROM_IVAS /* VA: basop issue 210: remove obsoelte CAM code from IVAS */ +#define OPT_BE_2311_HARM_GSC_GAIN /* VA: issue 2311: BE part of the GSC gain harmonization pipeline #70380 shows the BE */ #define HARM_CORECODER_UPDT /* VA: basop issue 2342: Remove duplicated code in core-coder common update functions */ /* #################### End BE switches ################################## */ @@ -110,22 +111,20 @@ #define FIX_2315_AGC_MEMORY_RESET /* VA: basop issue 2315: fix reset of the AGC memory */ #define FIX_2312_CONDITION_MISSING_GSC_DEC_LR /* VA: basop issue 2297: addition of condition missing in the GSC gain decoder at low-rate */ #define FIX_2313_HF_RESET_16KHZ /* VA: basop issue 2313: Call hf_synth_reset_fx() also for 16 kHz output_Fs */ +#define OPT_2308_FIND_TARGET /* VA: Issue 2308, Speeds up computation and improve accuracy of the impulse response */ +#define OPT_NBE_2311_HARM_GSC_GAIN /* VA: issue 2311: non-BE part of the GSC gain harmonization */ /* ##################### End NON-BE switches ########################### */ -/* ################## End MAINTENANCE switches ######################### */ - -/* clang-format on */ - /* #################### Start BASOP optimization switches ############################ */ -#define NONBE_OPT_2239_IVAS_FILTER_PROCESS /* Dolby: Issue 2239, optimize ivas_filter_process_fx. */ -#define NONBE_OPT_2193_EIG2X2 /* Dolby: Issue 2193, optimize eig2x2_fx. */ -#define OPT_2308_FIND_TARGET /* VA: Issue 2308, Speeds up computation and improve accuracy of the impulse response */ -#define OPT_BE_2311_HARM_GSC_GAIN /* VA: issue 2311: BE part of the GSC gain harmonization pipeline #70380 shows the BE */ -#define OPT_NBE_2311_HARM_GSC_GAIN /* VA: issue 2311: non-BE part of the GSC gain harmonization */ +#define NONBE_OPT_2239_IVAS_FILTER_PROCESS /* Dolby: Issue 2239, optimize ivas_filter_process_fx. */ +#define NONBE_OPT_2193_EIG2X2 /* Dolby: Issue 2193, optimize eig2x2_fx. */ /* #################### End BASOP optimization switches ############################ */ +/* ################## End MAINTENANCE switches ######################### */ + +/* clang-format on */ #endif -- GitLab