diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index 55ced4ea07c8547ec30c4de4d4776754c9158ade..57e6a269048c9a501876d79b0790328e4a3a5f9d 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -43,11 +43,12 @@ #include "wmc_auto.h" /*-------------------------------------------------------------------* - * Local constants + * Local function prototypes *-------------------------------------------------------------------*/ static Word16 VDQ_vec_fx( Word16 *Qvec_out_fx, const Word16 *mean_dic_fx, const Word16 *dic_fx, const Word16 index_fx, const Word16 vec_en_fx ); + /*========================================================================*/ /* FUNCTION : void Comp_and_apply_gain_enc_fx */ /*------------------------------------------------------------------------*/ @@ -72,9 +73,9 @@ static Word16 VDQ_vec_fx( Word16 *Qvec_out_fx, const Word16 *mean_dic_fx, const void Comp_and_apply_gain_fx( Word16 exc_diffQ[], /* i/o: Quantized excitation */ Word16 Ener_per_bd_iQ[], /* i : Target ener per band Q13 */ - Word16 Ener_per_bd_yQ[], /* i/o : Ener per band for norm vector i->Q13/o->Q13 */ - Word16 Mbands_gn, /* i : number of bands */ - const Word16 ReUseGain, /* i : Reuse the gain in Ener_per_bd_yQ */ + Word16 Ener_per_bd_yQ[], /* i/o : Ener per band for norm vector i->Q13/o->Q13 */ + Word16 Mbands_gn, /* i : number of bands */ + const Word16 ReUseGain, /* i : Reuse the gain in Ener_per_bd_yQ */ Word16 Qexc_diff, Word16 Q_exc ) { @@ -114,6 +115,7 @@ void Comp_and_apply_gain_fx( * y_gain = pow(10.0, (Ener_per_bd_iQ[i_band]-Ener_per_bd_yQ[i_band])) * = pow(2, 3.321928*(Ener_per_bd_iQ[i_band]-Ener_per_bd_yQ[i_band])) *-----------------------------------------------------------------*/ + L16 = sub( Ener_per_bd_iQ[i_band], Ener_per_bd_yQ[i_band] ); /*Q12 */ L32 = L_mult( L16, 27213 ); /* 3.321928 in Q13 -> Q26 */ L32 = L_shr( L32, 10 ); /* From Q26 to Q16 */ @@ -137,12 +139,13 @@ void Comp_and_apply_gain_fx( return; } + void Comp_and_apply_gain_ivas_fx( - Word16 exc_diffQ[], /* i/o: Quantized excitation */ - Word16 Ener_per_bd_iQ[], /* i : Target ener per band Q13 */ + Word16 exc_diffQ[], /* i/o: Quantized excitation */ + Word16 Ener_per_bd_iQ[], /* i : Target ener per band Q13 */ Word16 Ener_per_bd_yQ[], /* i/o : Ener per band for norm vector i->Q13/o->Q13 */ - Word16 Mbands_gn, /* i : number of bands */ - const Word16 ReUseGain, /* i : Reuse the gain in Ener_per_bd_yQ */ + Word16 Mbands_gn, /* i : number of bands */ + const Word16 ReUseGain, /* i : Reuse the gain in Ener_per_bd_yQ */ Word16 Qexc_diff, Word16 *Q_exc ) { @@ -192,6 +195,7 @@ void Comp_and_apply_gain_ivas_fx( * y_gain = pow(10.0, (Ener_per_bd_iQ[i_band]-Ener_per_bd_yQ[i_band])) * = pow(2, 3.321928*(Ener_per_bd_iQ[i_band]-Ener_per_bd_yQ[i_band])) *-----------------------------------------------------------------*/ + L16 = sub_sat( Ener_per_bd_iQ[i_band], Ener_per_bd_yQ[i_band] ); /*Q12 */ L32 = L_mult( L16, 27213 ); /* 3.321928 in Q13 -> Q26 */ L32 = L_shr( L32, 10 ); /* From Q26 to Q16 */ @@ -381,13 +385,16 @@ void Ener_per_band_comp_ivas_fx( /*-------------------------------------------------------------------* - * gsc_gainQ() + * GSC_gain_adj() + * * - * Quantization of the energy per band *-------------------------------------------------------------------*/ 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 */ +#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 +404,24 @@ 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 +433,20 @@ 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 +478,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 +490,7 @@ static void GSC_gain_adj( return; } - +#ifndef OPT_NBE_2311_HARM_GSC_GAIN /*-------------------------------------------------------------------* * GSC_gain_adj_ivas_fx() * @@ -533,7 +571,6 @@ static void GSC_gain_adj_ivas_fx( return; } - /*-------------------------------------------------------------------* * GSC_gain_DQ() * @@ -929,8 +966,8 @@ Word16 gsc_gainQ_ivas_fx( return mean_4g_fx[0]; } - - +#endif +#ifndef OPT_BE_2311_HARM_GSC_GAIN /*==========================================================================*/ /* FUNCTION : Word16 gsc_gaindec_fx() */ /*--------------------------------------------------------------------------*/ @@ -951,7 +988,6 @@ Word16 gsc_gainQ_ivas_fx( /* RETURN ARGUMENTS : */ /* _ (Word16) : average frequency 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 +1124,7 @@ Word16 gsc_gaindec_fx( /* o : average frequency gai return mean_4g_fx; } - +#endif /*==========================================================================*/ /* FUNCTION : Word16 gsc_gaindec_ivas_fx() */ @@ -1111,13 +1147,18 @@ Word16 gsc_gaindec_fx( /* o : average frequency gai /* _ (Word16) : average frequency gain */ /*==========================================================================*/ -Word16 gsc_gaindec_ivas_fx( /* o : average frequency gain */ - 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 */ +#ifndef OPT_BE_2311_HARM_GSC_GAIN +Word16 gsc_gaindec_ivas_fx( /* o : average frequency gain */ +#else +/*! 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 */ ) { Word16 idx_g_fx, i; @@ -1125,6 +1166,7 @@ Word16 gsc_gaindec_ivas_fx( /* o : average frequenc 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; @@ -1191,6 +1233,7 @@ Word16 gsc_gaindec_ivas_fx( /* o : average frequenc /*--------------------------------------------------------------------------------------* * 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 ); #ifdef FIX_2312_CONDITION_MISSING_GSC_DEC_LR @@ -1224,9 +1267,11 @@ Word16 gsc_gaindec_ivas_fx( /* o : average frequenc 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*/ @@ -1279,8 +1324,21 @@ 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 ); +#ifndef OPT_NBE_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 ); + } + 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 ); + } +#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; } @@ -1292,6 +1350,20 @@ Word16 gsc_gaindec_ivas_fx( /* o : average frequenc * 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 */ + 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 */ @@ -1300,24 +1372,39 @@ 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 ) ) { - /*ftmp1 = mean(y_gain4, 10)-0.6f;*/ L_tmp = L_deposit_l( 0 ); FOR( cnt = 0; cnt < 10; cnt++ ) @@ -1401,7 +1488,6 @@ Word16 gsc_gainQ_fx( /*Q12*/ ELSE { /*ftmp1 = mean(y_gain4, 16);*/ - L_tmp = 0; move32(); FOR( cnt = 0; cnt < 16; cnt++ ) @@ -1410,7 +1496,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(); @@ -1466,54 +1552,101 @@ 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 ); - /* Update to quantized vector */ - Copy( y_gain_tmp2, y_gain_tmp, 8 ); +#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 + 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 ); - 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 } } /* 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/gs_preech_fx.c b/lib_com/gs_preech_fx.c index 28092088e19351a9701a3282a4813901c58469a4..5a35108ece1f91bb49daa6933df86ab5a52a6a4b 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 3c8a06c23f855e301a39f1b9443df6d923a1018c..583a9d0dcd8fccca8454e3cef0124ee209c9e555 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,20 +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 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 diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 56dd026a2a1a9319f22e242ee83f7b75d946f23f..e6557e277ca9a777186bfca52eca3f2a9bfd53a8 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -1504,6 +1504,7 @@ Word16 gsc_gaindec_fx( 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 */ @@ -1513,7 +1514,8 @@ Word16 gsc_gaindec_ivas_fx( const Word16 coder_type, /* i : coding type */ 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 */ @@ -1537,6 +1539,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 */ @@ -4984,6 +5001,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 c10306bc8a55b7cfb9bc90f9ab53f7b1013f4c68..05b111fbe2175c5fb70fe493c2a9650356dcfb44 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,6 +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(); @@ -860,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, @@ -871,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 0498c0c339ae05f1d570273c3a44968100bd27c8..79b419633f9180a9ff033a5ae5dc5172bb38f1e2 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,8 @@ 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 +1011,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