diff --git a/lib_enc/amr_wb_enc_fx.c b/lib_enc/amr_wb_enc_fx.c index 6f46e5c120f3a82786e265dd91a50d6f2ea159d2..1580a78186f071f46a99e4bdb4e5154f1d1f9fa3 100644 --- a/lib_enc/amr_wb_enc_fx.c +++ b/lib_enc/amr_wb_enc_fx.c @@ -372,7 +372,7 @@ void amr_wb_enc_fx( * WB, SWB and FB bandwidth detector *----------------------------------------------------------------*/ - bw_detect_fx( st, st->input_fx, NULL, NULL, NULL, MONO_FORMAT, 0 ); + bw_detect_fx( st, st->input_fx, NULL, NULL, NULL, MONO_FORMAT, 0, 0 ); /* in AMR_WB IO, limit the maximum band-width to WB */ if ( GT_16( st->bwidth, WB ) ) diff --git a/lib_enc/bw_detect_fx.c b/lib_enc/bw_detect_fx.c index 2e9b2c5db1fa63e6e80f58b43617227bab6bd2cb..8a150d514caea3fc700b04b8921fc25dd0ddef92 100644 --- a/lib_enc/bw_detect_fx.c +++ b/lib_enc/bw_detect_fx.c @@ -41,12 +41,12 @@ void bw_detect_fx( Encoder_State *st, /* i/o: Encoder State */ const Word16 signal_in[], /* i : input signal */ - Word16 *spectrum, /* i : MDCT spectrum */ + Word16 *spectrum, /* i : MDCT spectrum Q_spec */ const Word32 *enerBuffer, /* i : CLDFB Energy Q31 */ const Word16 *cldfbBuf_Ener_Exp, /* i : CLDFB Energy Exponent */ const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const Word16 mct_on /* i : flag MCT mode */ -) + const Word16 mct_on, /* i : flag MCT mode */ + const Word16 Q_spec ) { Word16 Q_dct; Word16 i, j, k, bw_max, bin_width, n_bins; @@ -312,6 +312,11 @@ void bw_detect_fx( bin_width = i_mult( bin_width, l_frame / BWD_TOTAL_WIDTH ); Copy( spectrum, spect, l_frame ); + if ( st->element_mode != EVS_MONO ) + { + Q_dct = Q_spec; + move16(); + } } /*---------------------------------------------------------------------* * compute energy per spectral bins @@ -903,6 +908,7 @@ void bw_detect_fx( return; } + /*-------------------------------------------------------------------* * set_bw_fx() * diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index 34d90a165c77a4230b5b2240d608eb4458f69644..bb065ae20f2d607c7d69b15b21821eae9a929e9a 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -870,7 +870,7 @@ ivas_error pre_proc_front_ivas_fx( Word16 input_fx_tmp[480]; Copy_Scale_sig( st->input_fx, input_fx_tmp, shr( input_frame, 1 ), negate( st->q_inp ) ); /*scaling from Q_inp_const to q0*/ - bw_detect_fx( st, input_fx_tmp, NULL, enerBuffer_fx, sf_energySum, ivas_format, 0 ); + bw_detect_fx( st, input_fx_tmp, NULL, enerBuffer_fx, sf_energySum, ivas_format, 0, 0 ); } IF( EQ_16( element_mode, IVAS_CPE_DFT ) ) diff --git a/lib_enc/ivas_mdct_core_enc_fx.c b/lib_enc/ivas_mdct_core_enc_fx.c index e27ec8c111e5dd9ec7b05ca79047089a7184de39..7c3daebdad8a531014f8893e525e169012f4030a 100644 --- a/lib_enc/ivas_mdct_core_enc_fx.c +++ b/lib_enc/ivas_mdct_core_enc_fx.c @@ -1283,16 +1283,17 @@ void ivas_mdct_core_whitening_enc_fx( FOR( n = 0; n < nSubframes; n++ ) { Word16 spect_fx[L_FRAME48k]; - Word16 q_spectrum, l_frame; + Word16 q_spectrum, lshift, l_frame; /*l_frame = (int16_t)(st->input_Fs / FRAMES_PER_SEC); 1 / FRAMES_PER_SEC = 0.2f */ l_frame = extract_l( Mpy_32_32( st->input_Fs, 42949673 /* 0.2f in Q31 */ ) ); if ( EQ_16( st->core, TCX_10_CORE ) ) { l_frame = shr( l_frame, 1 ); } - q_spectrum = L_norm_arr( st->hTcxEnc->spectrum_fx[n], l_frame ); - Copy_Scale_sig32_16( st->hTcxEnc->spectrum_fx[n], spect_fx, l_frame, q_spectrum ); - bw_detect_fx( st, NULL, spect_fx, NULL, NULL, MC_FORMAT /*just cannot be ISM_FORMAT*/, mct_on ); + lshift = L_norm_arr( st->hTcxEnc->spectrum_fx[n], l_frame ); + Copy_Scale_sig32_16( st->hTcxEnc->spectrum_fx[n], spect_fx, l_frame, lshift ); + q_spectrum = sub( add( sub( Q31, st->hTcxEnc->spectrum_e[n] ), lshift ), 16 ); + bw_detect_fx( st, NULL, spect_fx, NULL, NULL, MC_FORMAT /*just cannot be ISM_FORMAT*/, mct_on, q_spectrum ); test(); if ( EQ_16( nSubframes, NB_DIV ) && n == 0 ) diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c index efecb33eda3447bc4f199d2d7e7175446d54f538..cbb2cf421564b73d0e51c62baef7b4988667fe3e 100644 --- a/lib_enc/pre_proc_fx.c +++ b/lib_enc/pre_proc_fx.c @@ -298,7 +298,7 @@ void pre_proc_fx( move16(); } - bw_detect_fx( st, signal_in, NULL, enerBuffer, sf_energySum, MONO_FORMAT, 0 ); + bw_detect_fx( st, signal_in, NULL, enerBuffer, sf_energySum, MONO_FORMAT, 0, 0 ); /*----------------------------------------------------------------* * Noise energy down-ward update and total noise energy estimation diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 3f7f17fe7fbb1a6647c87af774a402ed4c524cc1..e54d3025e092e9228bd43c5252429999e3a4f0a7 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -138,13 +138,13 @@ void AVQ_encmux_ivas_fx( void bw_detect_fx( Encoder_State *st, /* i/o: Encoder State */ - const Word16 signal_in[], /* i : i signal */ - Word16 *spectrum, /* i : MDCT spectrum */ - const Word32 *enerBuffer, /* i : CLDFB Energy Q31 */ - const Word16 *cldfbBuf_Ener_Exp, /* i : CLDFB Energy Exponent */ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const Word16 mct_on /* i : flag MCT mode */ -); + const Word16 signal_in[], /* i : input signal */ + Word16 *spectrum, /* i : MDCT spectrum Q_spec */ + const Word32 *enerBuffer, /* i : CLDFB Energy Q31 */ + const Word16 *cldfbBuf_Ener_Exp, /* i : CLDFB Energy Exponent */ + const IVAS_FORMAT ivas_format, /* i : IVAS format */ + const Word16 mct_on, /* i : flag MCT mode */ + const Word16 Q_spec ); void core_switching_post_enc_fx( /*done */ Encoder_State *st_fx, /* i/o: encoder state structure */