diff --git a/lib_com/options.h b/lib_com/options.h index 61a3c10ccfc2662a6854e6d6fc182f24dde9d839..0488d5fe083bf9594a434ac23e4cbf4554e6840d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -94,6 +94,7 @@ #define FIX_2404_HARM_SIGNAL_CLAS /* VA: basop-2404, harmonize signal_clas and signa_ivas_clas */ #define HARMONIZE_ACELP_ENC /* VA: basop issue 2400: Remove duplicated main ACELP encoder function */ #define FIX_2392_MSAN_DESTROY_DEC /* VA: basop issue 2392: fix MSAN in ivas_destroy_dec_fx() */ +#define FIX_2424_REMOVE_GAUSS_L2_ENC /* VA: basop issue 2424: Remove duplicated code in gauss_L2_ivas_fx() */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/dec_uv_fx.c b/lib_dec/dec_uv_fx.c index 83e5666b4f44ad691d655fdaa355ce364695ff40..a2d59c08ab6f35b3d19e10ae8c85e6d38d278040 100644 --- a/lib_dec/dec_uv_fx.c +++ b/lib_dec/dec_uv_fx.c @@ -78,9 +78,10 @@ void decod_unvoiced_fx( &voice_fac_fx, &gain_pit_fx, pt_pitch_fx, exc_fx, &gain_code_fx, exc2_fx, bwe_exc_fx, &( st_fx->Q_exc ), st_fx->Q_subfr ); } ELSE - { /*----------------------------------------------------------------* - * Unvoiced subframe processing in two stages - *----------------------------------------------------------------*/ + { + /*----------------------------------------------------------------* + * Unvoiced subframe processing in two stages + *----------------------------------------------------------------*/ /* No adaptive codebook (UC) */ set16_fx( exc_fx + i_subfr_fx, 0, L_SUBFR ); diff --git a/lib_dec/gaus_dec_fx.c b/lib_dec/gaus_dec_fx.c index 0d38c40bcae3b2bb344d92d0a21cb4c379361fca..4fcbaf5148a8af7830803c6d1346748690aae7d6 100644 --- a/lib_dec/gaus_dec_fx.c +++ b/lib_dec/gaus_dec_fx.c @@ -12,7 +12,7 @@ * Local function prototypes *---------------------------------------------------------------------*/ -void gaus_dec2v_fx( Decoder_State *st_fx, Word16 *code, const Word16 lg, const Word16 nb_bits ); +static void gaus_dec2v_fx( Decoder_State *st_fx, Word16 *code, const Word16 lg, const Word16 nb_bits ); static void dec_2pos_fx( Word16 index, Word16 *ind1, Word16 *ind2, Word16 *sign1, Word16 *sign2, Word16 log2_n ); /*---------------------------------------------------------------------* @@ -22,6 +22,7 @@ static void dec_2pos_fx( Word16 index, Word16 *ind1, Word16 *ind2, Word16 *sign1 * - decode the codebook indices, * - find the excitation *---------------------------------------------------------------------*/ + void gaus_dec_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ const Word16 i_subfr, /* i : subframe index */ @@ -53,6 +54,7 @@ void gaus_dec_fx( /*------------------------------------------------------------------------------------------* * Unvoiced : Gaussian codebook *------------------------------------------------------------------------------------------*/ + nb_bits = st_fx->acelp_cfg.fixed_cdk_index[( i_subfr / 64 )]; move16(); @@ -61,6 +63,7 @@ void gaus_dec_fx( /*------------------------------------------------------------------------------------------* * - Gain of Gaussian excitation and normalized Gaussian excitation *------------------------------------------------------------------------------------------*/ + /* gain_inov = 1.0f / (float)sqrt((dot_product(code, code, L_SUBFR) + 0.01f) / L_SUBFR) */ L_tmp = Dot_product12( code, code, L_SUBFR, &exp ); exp = sub( exp, 18 /*24*/ + 6 ); /* exp: -18 (code in Q9), -6 (/L_SUBFR) */ @@ -141,7 +144,7 @@ void gaus_dec_fx( * One Gaussian vector of 190 values *-----------------------------------------------------*/ -void gaus_dec2v_fx( +static void gaus_dec2v_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 *code, /* o : decoded gaussian vector Q12-exp */ const Word16 lg, /* i : codevector length Q0 */ @@ -211,13 +214,14 @@ void gaus_dec2v_fx( * * Decode the codevectors positions and signs *-----------------------------------------------------*/ + static void dec_2pos_fx( - Word16 index, /* i : quantization index Q0 */ + Word16 index, /* i : quantization index Q0 */ Word16 *ind1, /* o : 1st vector index Q0 */ Word16 *ind2, /* o : 2nd vector index Q0 */ Word16 *sign1, /* o : 1st vector sign Q0 */ Word16 *sign2, /* o : 2nd vector sign Q0 */ - Word16 log2_n /* i : Log2(number of vector) Q0 */ + Word16 log2_n /* i : Log2(number of vector) Q0 */ ) { Word16 i; @@ -257,6 +261,7 @@ static void dec_2pos_fx( * * One Gaussian vector *-----------------------------------------------------*/ + void gaus_L2_dec( Word16 *code, /* o : decoded gaussian codevector Q9 */ Word16 tilt_code, /* i : tilt of code Q15 */ @@ -289,6 +294,5 @@ void gaus_L2_dec( /*Shape the gaussian excitation*/ cb_shape_fx( 1, 0, 0, 1, 0, formant_enh, FORMANT_SHARPENING_G2, A, code, tilt_code, 0, 1, L_SUBFR ); - return; } diff --git a/lib_enc/cod_ace_fx.c b/lib_enc/cod_ace_fx.c index f4b74b351d9928d059ea9a61eb36108a7fe691fc..92b08554e2f772375c34d4974fa773d0ca7cc851 100644 --- a/lib_enc/cod_ace_fx.c +++ b/lib_enc/cod_ace_fx.c @@ -290,8 +290,12 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision * IF( EQ_16( acelp_cfg->gains_mode[j_subfr], 7 ) ) { +#ifdef FIX_2424_REMOVE_GAUSS_L2_ENC + gauss_L2_fx( st->element_mode, h1, code2, y2, y22, &gain_code2, &g_corr, gain_pit, hLPDmem->tilt_code, p_Aq, acelp_cfg->formant_enh_num, &( st->seed_acelp ), shift ); +#else assert( gain_pit == 0 ); gauss_L2_fx( h1, code2, y2, y22, &gain_code2, &g_corr, gain_pit, hLPDmem->tilt_code, p_Aq, acelp_cfg->formant_enh_num, &( st->seed_acelp ), shift ); +#endif } ELSE { diff --git a/lib_enc/cod_uv_fx.c b/lib_enc/cod_uv_fx.c index 684282bdb4db989fab629aeb10529107dcaf0928..99636b306cb84916f3e8fd13c90b62d7e4b090e7 100644 --- a/lib_enc/cod_uv_fx.c +++ b/lib_enc/cod_uv_fx.c @@ -5,7 +5,6 @@ #include #include "options.h" #include -//#include "prot_fx.h" #include "rom_com.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ @@ -19,7 +18,11 @@ * * Gaussian excitation is generated by a white noise and shapes it with LPC-derived filter *-------------------------------------------------------------------*/ + void gauss_L2_fx( +#ifdef FIX_2424_REMOVE_GAUSS_L2_ENC + const Word16 element_mode, /* i : element mode */ +#endif const Word16 h[], /* i : weighted LP filter impulse response Q14+s */ Word16 code[], /* o : gaussian excitation Q9 */ const Word16 y2[], /* i : zero-memory filtered code. excitation Q9 */ @@ -35,7 +38,17 @@ void gauss_L2_fx( { Word16 i, tmp16; Word32 tmp32, tmp32_2; +#ifdef FIX_2424_REMOVE_GAUSS_L2_ENC + Word16 Q_fac; + Q_fac = Q18; + move16(); + if ( element_mode != EVS_MONO ) + { + Q_fac = Q16; + move16(); + } +#endif assert( gain_pit == 0 ); @@ -65,29 +78,61 @@ void gauss_L2_fx( Scale_sig( y11, L_SUBFR, sub( 1, shift ) ); /* Q9 */ *gain = L_deposit_l( 0 ); move32(); + /*Update correlations for gains coding */ +#ifdef FIX_2424_REMOVE_GAUSS_L2_ENC + tmp32 = L_shr( 21474836l /*0.01f Q31*/, 31 - Q_fac ); /* Q_fac */ + tmp32_2 = L_shr( 21474836l /*0.01f Q31*/, 31 - Q_fac ); /* Q_fac */ +#else tmp32 = L_shr( 21474836l /*0.01f Q31*/, 31 - 18 ); /* Q18 */ tmp32_2 = L_shr( 21474836l /*0.01f Q31*/, 31 - 18 ); /* Q18 */ +#endif - FOR( i = 0; i < L_SUBFR; i++ ) +#ifdef FIX_2424_REMOVE_GAUSS_L2_ENC + IF( element_mode == EVS_MONO ) + { +#endif + FOR( i = 0; i < L_SUBFR; i++ ) + { + tmp32 = L_mac0_sat( tmp32, y11[i], y11[i] ); /* Q18 */ + tmp32_2 = L_mac0_sat( tmp32_2, y11[i], y2[i] ); /* Q18 */ + } +#ifdef FIX_2424_REMOVE_GAUSS_L2_ENC + } + ELSE { - tmp32 = L_mac0_sat( tmp32, y11[i], y11[i] ); /* Q18 */ - tmp32_2 = L_mac0_sat( tmp32_2, y11[i], y2[i] ); /* Q18 */ + FOR( i = 0; i < L_SUBFR; i++ ) + { + tmp16 = shr( y11[i], 1 ); + tmp32 = L_mac0( tmp32, tmp16, tmp16 ); /* Q16 */ + tmp32_2 = L_mac0( tmp32_2, tmp16, shr( y2[i], 1 ) ); /* Q16 */ + } } +#endif tmp16 = norm_l( tmp32 ); g_corr->y1y1 = round_fx_sat( L_shl( tmp32, tmp16 ) ); +#ifdef FIX_2424_REMOVE_GAUSS_L2_ENC + g_corr->y1y1_e = sub( sub( 31, Q_fac ), tmp16 ); +#else g_corr->y1y1_e = sub( 31 - 18, tmp16 ); +#endif move16(); move16(); tmp16 = norm_l( tmp32_2 ); g_corr->y1y2 = round_fx_sat( L_shl( tmp32_2, tmp16 ) ); +#ifdef FIX_2424_REMOVE_GAUSS_L2_ENC + g_corr->y1y2_e = sub( sub( 31, Q_fac ), tmp16 ); +#else g_corr->y1y2_e = sub( 31 - 18, tmp16 ); +#endif move16(); move16(); -} + return; +} +#ifndef FIX_2424_REMOVE_GAUSS_L2_ENC void gauss_L2_ivas_fx( const Word16 h[], /* i : weighted LP filter impulse response Q14+s */ Word16 code[], /* o : gaussian excitation Q9 */ @@ -157,3 +202,4 @@ void gauss_L2_ivas_fx( move16(); move16(); } +#endif diff --git a/lib_enc/enc_uv_fx.c b/lib_enc/enc_uv_fx.c index 160814bc07d2e3c1c319d16d9ca90ebd9b80386c..118fc8251e437e6147600220d4a44bd85a402d31 100644 --- a/lib_enc/enc_uv_fx.c +++ b/lib_enc/enc_uv_fx.c @@ -180,6 +180,9 @@ void encod_unvoiced_fx( move16(); move16(); +#ifdef FIX_2424_REMOVE_GAUSS_L2_ENC + gauss_L2_fx( st_fx->element_mode, h1_fx, code2, y2_fx, y22, &gain_code2, &g_corr, gain_pit_fx, hLPDmem->tilt_code, p_Aq_fx, acelp_cfg->formant_enh_num, &( st_fx->seed_acelp ), shift ); +#else assert( gain_pit_fx == 0 ); IF( st_fx->element_mode == EVS_MONO ) { @@ -189,6 +192,7 @@ void encod_unvoiced_fx( { gauss_L2_ivas_fx( h1_fx, code2, y2_fx, y22, &gain_code2, &g_corr, gain_pit_fx, hLPDmem->tilt_code, p_Aq_fx, acelp_cfg->formant_enh_num, &( st_fx->seed_acelp ), shift ); } +#endif /*----------------------------------------------------------* * - Compute the fixed codebook gain * diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 4310137b040c22d4cba43eed431f95a65af86a7d..643d969126629e1b1ff67da01f52395eb4956de8 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -2132,6 +2132,9 @@ void E_ACELP_xy2_corr( Word16 exp_xn ); void gauss_L2_fx( +#ifdef FIX_2424_REMOVE_GAUSS_L2_ENC + const Word16 element_mode, /* i : element mode */ +#endif const Word16 h[], /* i : weighted LP filter impulse response Q14+s */ Word16 code2[], /* o : gaussian excitation Q9 */ const Word16 y2[], /* i : zero-memory filtered code. excitation Q9 */ @@ -2145,6 +2148,7 @@ void gauss_L2_fx( Word16 *seed_acelp, /*i/o : random seed Q0 */ const Word16 shift ); +#ifndef FIX_2424_REMOVE_GAUSS_L2_ENC void gauss_L2_ivas_fx( const Word16 h[], /* i : weighted LP filter impulse response Q14+s */ Word16 code2[], /* o : gaussian excitation Q9 */ @@ -2158,7 +2162,7 @@ void gauss_L2_ivas_fx( const Word16 formant_enh, /* i : formant enhancement factor Q15 */ Word16 *seed_acelp, /*i/o : random seed Q0 */ const Word16 shift ); - +#endif Word32 SFM_Cal_fx( Word32 magn[], Word16 n );