diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index a36d3ddeb379aed6b05c6cdffcf02535b5885484..769af269246265885b09319b958a202aeb98c982 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -73,7 +73,7 @@ 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 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, @@ -138,6 +138,7 @@ void Comp_and_apply_gain_fx( return; } +#ifndef FIX_2338_HARM_GSC_GAIN_COMP void Comp_and_apply_gain_ivas_fx( @@ -238,6 +239,7 @@ void Comp_and_apply_gain_ivas_fx( return; } +#endif /*========================================================================*/ @@ -258,7 +260,6 @@ void Comp_and_apply_gain_ivas_fx( /* _ (Word32*) etmp14 : Energy band 14 Q_exc_diff*2+1 */ /* _ (Word32*) etmp15 : Energy band 15 Q_exc_diff*2+1 */ /*------------------------------------------------------------------------*/ - /*------------------------------------------------------------------------*/ /* RETURN ARGUMENTS : */ /* _ None */ @@ -266,10 +267,10 @@ void Comp_and_apply_gain_ivas_fx( /* o : Band gain Q12 */ static Word16 Comp_band_log_ener( - const Word16 *pt_fx, /* i : Dct input Q_sc */ - const Word16 Len, /* i : Lenght en energy accumulation */ - const Word16 Q_sc, /* i : scaling of input */ - const Word16 E_sc /* i : Additional scaling factor for energy */ + const Word16 *pt_fx, /* i : Dct input Q_sc */ + const Word16 Len, /* i : Lenght en energy accumulation */ + const Word16 Q_sc, /* i : scaling of input */ + const Word16 E_sc /* i : Additional scaling factor for energy */ ) { Word32 L_tmp; @@ -285,6 +286,7 @@ static Word16 Comp_band_log_ener( return tmp16; } + void Ener_per_band_comp_fx( const Word16 exc_diff_fx[], /* i : target signal Q_exc_diff */ Word16 y_gain4_fx[], /* o : Energy per band to quantize Q12 */ @@ -403,6 +405,7 @@ static void GSC_gain_adj( /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */ Word16 Gain_off, i; Word16 Fac_div; + Fac_div = 102; move16(); @@ -540,6 +543,7 @@ Word16 gsc_gaindec_fx( idx_g_fx = (Word16) get_next_indice_fx( st_fx, 7 ); VDQ_vec_fx( y_gainQ_fx + 6, Mean_dic_NB_fx + 6, Gain_dic3_NBHR_fx, idx_g_fx, 4 ); } + test(); IF( LE_32( core_brate_fx, ACELP_9k60 ) && ( coder_type == INACTIVE ) ) { @@ -576,7 +580,9 @@ Word16 gsc_gaindec_fx( *--------------------------------------------------------------------------------------*/ 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 ); + IF( !( coder_type == INACTIVE && st_fx->tdm_LRTD_flag == 0 && EQ_16( st_fx->idchan, 1 ) ) || GT_32( st_fx->core_brate, GSC_LRES_GAINQ_LIMIT ) ) { idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 ); @@ -600,7 +606,9 @@ Word16 gsc_gaindec_fx( move16(); y_gainQ_fx[11] = 0; move16(); + ifft_rel_fx( y_gainQ_fx + 8, 8, 3 ); + FOR( i = 8; i < 16; i++ ) { y_gainQ_fx[i] = round_fx( L_shl( L_mult( y_gainQ_fx[i], 23101 ), 1 ) ); /*Q12 */ @@ -949,11 +957,11 @@ Word16 gsc_gainQ_fx( *-------------------------------------------------------------------*/ static Word16 VDQ_vec_fx( - Word16 *Qvec_out_fx, /* o: Quanitzed vector */ - const Word16 *mean_dic_fx, /* i: average codebook */ - const Word16 *dic_fx, /* i: codebook */ - const Word16 index_fx, /* i: index of codebook*/ - const Word16 vec_en_fx /* i: vector length */ + Word16 *Qvec_out_fx, /* o : Quanitzed vector */ + const Word16 *mean_dic_fx, /* i : average codebook */ + const Word16 *dic_fx, /* i : codebook */ + const Word16 index_fx, /* i : index of codebook */ + const Word16 vec_en_fx /* i : vector length */ ) { Word16 i, j; diff --git a/lib_com/gs_noisefill_fx.c b/lib_com/gs_noisefill_fx.c index fd296e1a44c8f496df21ea00523bc435509cea02..383e2812da07529ebd415d4beca50b1c21b0f5a3 100644 --- a/lib_com/gs_noisefill_fx.c +++ b/lib_com/gs_noisefill_fx.c @@ -1364,9 +1364,10 @@ void highband_exc_dct_in_ivas_fx( move16(); } } - +#ifndef FIX_2338_HARM_GSC_GAIN_COMP IF( EQ_16( element_mode, EVS_MONO ) ) { +#endif Comp_and_apply_gain_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, Qexc_diffQ, *Q_exc ); IF( exc_wo_nf != NULL ) @@ -1374,6 +1375,7 @@ void highband_exc_dct_in_ivas_fx( Comp_and_apply_gain_fx( exc_wo_nf, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 1, Qexc_diffQ, *Q_exc ); Vr_add( exc_dct_in, exc_wo_nf, exc_wo_nf, L_frame ); } +#ifndef FIX_2338_HARM_GSC_GAIN_COMP } ELSE { @@ -1404,7 +1406,7 @@ void highband_exc_dct_in_ivas_fx( Scale_sig( exc_dct_in, L_frame, sub( *Q_exc, Q_old ) ); } } - +#endif /*--------------------------------------------------------------------------------------* * add the correction layer to the LF bins, * and add the quantized pulses or the noise for the higher part of the spectrum diff --git a/lib_com/options.h b/lib_com/options.h index f47ebc9a42f03f998087b736f76001b66c25cd1d..c7cd38dd8edaf847f3fa16e5528582c5f36fced6 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -118,6 +118,7 @@ #define FIX_2302_LSF_CDBK_THRESHOLD /* VA: basop issue 2302: fix threshold for LSF Q codebook-type decision */ #define FIX_1500_ISM_MD_DTX /* VA: float issue 1500: fix ISM elevation metadata smoothing in DTX */ #define FIX_2348_REPLACE_FEC_ENC /* VA: basop issue 2348: replace FEC_encode_ivas_fx with FEC_encode_fx */ +#define FIX_2338_HARM_GSC_GAIN_COMP /* VA: basop issue 2338: harmonization of band gain computation for both EVS and IVAS */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 210fbd5967f500f9e881889f236b30be735e207d..68b9be4402fe5b7f5115e8ce7d635885d59c55db 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -1711,7 +1711,7 @@ void Comp_and_apply_gain_fx( const Word16 ReUseGain, /* i : Reuse the gain in Ener_per_bd_yQ */ Word16 Qexc_diff, Word16 Q_exc ); - +#ifndef FIX_2338_HARM_GSC_GAIN_COMP 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 */ @@ -1720,7 +1720,7 @@ void Comp_and_apply_gain_ivas_fx( const Word16 ReUseGain, /* i : Reuse the gain in Ener_per_bd_yQ */ Word16 Qexc_diff, Word16 *Q_exc ); - +#endif void pre_echo_att_fx( Word32 *Last_frame_ener_fx, /* i/o: Energy of the last frame 2*Q_new+1*/ Word16 *exc_fx, /* i/o: Excitation of the current frame Q_new*/