From 6b28ec96a8816f961ce143c0e8c53658cd9eae0d Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 15 Apr 2025 14:22:13 -0400 Subject: [PATCH 01/20] Reuse EVS for GENERIC LR --- lib_com/options.h | 1 + lib_enc/acelp_core_enc_fx.c | 11 +++++ lib_enc/enc_acelp_fx.c | 8 ++- lib_enc/enc_acelpx_fx.c | 10 +++- lib_enc/enc_gen_voic_fx.c | 40 ++++++++++++--- lib_enc/gain_enc_fx.c | 3 ++ lib_enc/inov_enc_fx.c | 99 +++++++++++++++++++++++++++++++++++++ 7 files changed, 162 insertions(+), 10 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 5ed2aa912..30e724c39 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -86,5 +86,6 @@ #define MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE /* FhG: reduce WMOPS of Cy calculation in ivas_param_mc_param_est_enc_fx() by using 64 Bit addition. Obsoletes IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_NONBE. */ #define TEST_HR +#define REUSE_EVS_ACELP #endif diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 795f03403..1079efe6a 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -777,6 +777,9 @@ ivas_error acelp_core_enc_ivas_fx( Word16 att_fx; Word16 tmpF_fx; +#ifdef REUSE_EVS_ACELP + Word16 shift = 0; +#endif test(); IF( !st->Opt_AMR_WB && st->hBWE_TD != NULL ) @@ -1379,7 +1382,11 @@ ivas_error acelp_core_enc_ivas_fx( st->hTdCngEnc->burst_ho_cnt = 0; move16(); /* VOICED frames in SC-VBR */ +#ifdef REUSE_EVS_ACELP + encod_gen_voic_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, shift, Q_new ); +#else encod_gen_voic_ivas_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, 0, Q_new ); +#endif } } ELSE IF( EQ_16( st->coder_type, AUDIO ) || ( st->coder_type == INACTIVE && st->inactive_coder_type_flag ) ) @@ -1390,7 +1397,11 @@ ivas_error acelp_core_enc_ivas_fx( ELSE { /* GENERIC, VOICED and INACTIVE frames (coded by AVQ technology) */ +#ifdef REUSE_EVS_ACELP + encod_gen_voic_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, shift, Q_new ); +#else encod_gen_voic_ivas_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, 0, Q_new ); +#endif } /* update mem_syn1_flt for ACELP core switching */ diff --git a/lib_enc/enc_acelp_fx.c b/lib_enc/enc_acelp_fx.c index 4317bdbb3..a8a1c0c5a 100644 --- a/lib_enc/enc_acelp_fx.c +++ b/lib_enc/enc_acelp_fx.c @@ -1143,7 +1143,13 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const scale = -2; move16(); } - +#ifdef REUSE_EVS_ACELP /* To be verified if it affects BE on 26.444, if yes, just a condition for IVAS here*/ + if ( EQ_16( val, 32767 ) ) + { + scale = -3; + move16(); + } +#endif Copy_Scale_sig( H, h, L_SUBFR, scale ); /*Q12+scale*/ E_ACELP_vec_neg_fx( h, h_inv, L_SUBFR ); diff --git a/lib_enc/enc_acelpx_fx.c b/lib_enc/enc_acelpx_fx.c index 240f9859c..7ed52e946 100644 --- a/lib_enc/enc_acelpx_fx.c +++ b/lib_enc/enc_acelpx_fx.c @@ -553,7 +553,15 @@ void E_ACELP_4tsearchx_fx( &ind[j], dn, cor, sign, sign_val_1 ); } - +#ifdef REUSE_EVS_ACELP + IF( GT_16( alp, ONE_IN_Q14 ) ) + { + alp = shr( alp, 1 ); + Scale_sig( cor, L_SUBFR, -1 ); /*Q8*/ + Scale_sig( R_buf, 2 * L_SUBFR - 1, -1 ); /*Q8+scale*/ + Scale_sig( dn, L_SUBFR, -1 ); /*Qdn-1*/ + } +#endif st = add( st, 1 ); } diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index e694b60c2..2235bc126 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -114,6 +114,9 @@ void encod_gen_voic_fx( #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif +#ifdef REUSE_EVS_ACELP + Word16 q_h1; #endif SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR; BSTR_ENC_HANDLE hBstr = st_fx->hBstr; @@ -165,7 +168,12 @@ void encod_gen_voic_fx( set16_fx( code_preQ_fx, 0, L_SUBFR ); shift_wsp = add( Q_new, shift ); - +#ifdef REUSE_EVS_ACELP + if ( st_fx->element_mode > EVS_MONO && LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) ) + { + shift_wsp = sub( shift_wsp, 1 ); + } +#endif /* set and write harmonicity flag */ harm_flag_acelp = 0; move16(); @@ -196,19 +204,33 @@ void encod_gen_voic_fx( *----------------------------------------------------------------*/ Copy( &res_fx[i_subfr_fx], &exc_fx[i_subfr_fx], L_SUBFR ); /*Q_new*/ +#ifdef REUSE_EVS_ACELP + IF( st_fx->element_mode > EVS_MONO ) + { + find_targets_ivas_new_fx( speech_fx, hLPDmem->mem_syn, i_subfr_fx, &hLPDmem->mem_w0, p_Aq_fx, + res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx ); + q_h1 = sub( 14, norm_s( h1_fx[0] ) ); + Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/ + Scale_sig( h1_fx, L_SUBFR, add( sub( 14, q_h1 ), shift ) ); + } + ELSE +#endif + { - find_targets_fx( speech_fx, hLPDmem->mem_syn, i_subfr_fx, &hLPDmem->mem_w0, p_Aq_fx, - res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx ); - - Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, -2 ); /*Q11*/ - Scale_sig( h1_fx, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution Q(14+shift)*/ + find_targets_fx( speech_fx, hLPDmem->mem_syn, i_subfr_fx, &hLPDmem->mem_w0, p_Aq_fx, + res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx ); + Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, -2 ); /*Q11*/ + Scale_sig( h1_fx, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution Q(14+shift)*/ + } /* scaling of xn[] to limit dynamic at 12 bits */ Scale_sig( xn_fx, L_SUBFR, shift ); *pt_pitch_fx = pit_encode_fx( hBstr, st_fx->acelp_cfg.pitch_bits, st_fx->core_brate, 0, L_frame, st_fx->coder_type, &pitch_limit_flag, i_subfr_fx, exc_fx, L_SUBFR, st_fx->pitch, &T0_min_fx, &T0_max_fx, &T0_fx, &T0_frac_fx, h1_fx, xn_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf ); /* Q6 */ - +#ifdef REUSE_EVS_ACELP + //tbe_celp_exc, can be use EVS version in a bit-exact manner, just to add one condition and change L_SUBFR to L_subfr in the EVS version +#endif tbe_celp_exc( L_frame, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx ); /*-----------------------------------------------------------------* @@ -400,7 +422,7 @@ void encod_gen_voic_fx( } return; } - +#ifndef REUSE_EVS_ACELP void encod_gen_voic_ivas_fx( Encoder_State *st_fx, /* i/o: state structure */ const Word16 speech_fx[], /* i : input speech Qnew -1 */ @@ -790,3 +812,5 @@ void encod_gen_voic_ivas_fx( } return; } + +#endif \ No newline at end of file diff --git a/lib_enc/gain_enc_fx.c b/lib_enc/gain_enc_fx.c index 0ccb31ccf..fc90f2263 100644 --- a/lib_enc/gain_enc_fx.c +++ b/lib_enc/gain_enc_fx.c @@ -464,9 +464,12 @@ void gain_enc_mless_fx( case 6: { qua_table = gain_qua_mless_6b_fx; +#ifdef REUSE_EVS_ACELP if ( element_mode > EVS_MONO ) { + qua_table = gain_qua_mless_6b_stereo_fx; } +#endif move16(); if ( EQ_16( clip_gain, 1 ) ) { diff --git a/lib_enc/inov_enc_fx.c b/lib_enc/inov_enc_fx.c index fe22ee398..cb23ffa5d 100644 --- a/lib_enc/inov_enc_fx.c +++ b/lib_enc/inov_enc_fx.c @@ -89,6 +89,9 @@ Word16 inov_encode_fx( Word16 Rw[L_SUBFR]; Word16 acelpautoc; BSTR_ENC_HANDLE hBstr = st_fx->hBstr; +#ifdef REUSE_EVS_ACELP // -> this might need ajsutement in acelp_fast + Word16 i, k, Qdn = 9; +#endif (void) last_L_frame; stack_pulses = 0; move16(); @@ -139,7 +142,12 @@ Word16 inov_encode_fx( Scale_sig( cn, L_subfr, shift ); cb_shape_fx( 1, 1, 0, sharpFlag, 0, g1, g2, p_Aq, h2, tilt_code, shr( add( pt_pitch, 26 ), 6 ), 0, L_subfr ); +#ifdef REUSE_EVS_ACELP + assert( L_SUBFR == 64 ); + corr_xh_fx( xn2, dn, h2 ); +#else corr_xh_fx( xn2, dn, h2 ); +#endif } /*-----------------------------------------------------------------* @@ -272,6 +280,97 @@ Word16 inov_encode_fx( { IF( st_fx->acelp_cfg.fcb_mode ) { +#ifdef REUSE_EVS_ACELP + Word16 idx = 0, idx2 = 0; + move16(); + move16(); + + IF( i_subfr != 0 ) + { + idx = idiv1616( i_subfr, L_subfr ); + idx2 = idiv1616( i_subfr, L_SUBFR ); + } + + IF( LT_16( st_fx->acelp_cfg.fixed_cdk_index[idx], ACELP_FIXED_CDK_NB ) ) + { + Word16 wordcnt, bitcnt; + Word16 prm[8]; + + IF( st_fx->acelp_cfg.fixed_cdk_index[idx] >= 0 ) + { + test(); + test(); + test(); + IF( EQ_16( L_subfr, 2 * L_SUBFR ) ) + { + nBits = st_fx->acelp_cfg.fixed_cdk_index[idx]; + move16(); + + IF( EQ_16( nBits, 8 ) ) + { + acelp_1t64_ivas_fx( hBstr, dn, h2, code, y2, L_subfr ); + } + ELSE + { + acelp_fast_fx( hBstr, nBits, dn, Qdn, cn, 0, h2, code, y2, L_subfr ); + } + } + ELSE IF( ( EQ_16( st_fx->idchan, 1 ) && LE_16( st_fx->acelp_cfg.fixed_cdk_index[idx2], 7 ) ) || ( st_fx->idchan == 0 && LE_16( st_fx->acelp_cfg.fixed_cdk_index[idx2], 3 ) ) ) + { + IF( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] == 0 ) + { + acelp_1t64_ivas_fx( hBstr, dn, h2, code, y2, L_subfr ); + } + ELSE + { + acelp_fast_fx( hBstr, st_fx->acelp_cfg.fixed_cdk_index[idx2], dn, Qdn, cn, 0, h2, code, y2, L_SUBFR ); + } + } + ELSE + { + E_ACELP_4t_fx( dn, cn, h2, Rw, (Word8) acelpautoc, code, st_fx->acelp_cfg.fixed_cdk_index[idx2], prm, L_frame, last_L_frame, st_fx->total_brate, i_subfr, cmpl_flag ); + wordcnt = shr( ACELP_FIXED_CDK_BITS( st_fx->acelp_cfg.fixed_cdk_index[idx2] ), 4 ); + bitcnt = s_and( ACELP_FIXED_CDK_BITS( st_fx->acelp_cfg.fixed_cdk_index[idx2] ), 15 ); + + FOR( i = 0; i < wordcnt; i++ ) + { + push_indice( hBstr, IND_ALG_CDBK_4T64, prm[i], 16 ); + } + IF( bitcnt ) + { + push_indice( hBstr, IND_ALG_CDBK_4T64, prm[i], bitcnt ); + } + + /* Generate weighted code */ + set16_fx( y2, 0, L_SUBFR ); + Word16 sh = add( norm_s( h2[0] ), 1 ); + FOR( i = 0; i < L_SUBFR; i++ ) + { + /* Code is sparse, so check which samples are non-zero */ + IF( code[i] != 0 ) + { + FOR( k = 0; k < L_SUBFR - i; k++ ) + { + y2[i + k] = add_sat( y2[i + k], round_fx( L_shl( L_mult( code[i], h2[k] ), sh ) ) ); // Q9 Added saturation: needs to be rechecked + move16(); + } + } + } + } + } + ELSE + { + set16_fx( code, 0, L_SUBFR ); + set16_fx( y2, 0, L_SUBFR ); + } + } +#ifdef DEBUGGING + else + { + IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "invalid mode for acelp frame!\n" ); + } +#endif +#endif } ELSE { -- GitLab From 2693e3fffe15d12865f80fbee89ffb616bbb9cc3 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 15 Apr 2025 15:51:47 -0400 Subject: [PATCH 02/20] Reuse EVS for GENERIC HR --- lib_com/options.h | 1 + lib_enc/acelp_core_enc_fx.c | 13 ++++++++++ lib_enc/avq_cod_fx.c | 52 ++++++++++++++++++++++++++++++++++++- lib_enc/corr_xh_fx.c | 21 ++++++++++++++- lib_enc/gaus_enc_fx.c | 10 +++++-- lib_enc/inov_enc_fx.c | 5 ++-- 6 files changed, 95 insertions(+), 7 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 30e724c39..13f25fbdd 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -87,5 +87,6 @@ #define TEST_HR #define REUSE_EVS_ACELP +#define REUSE_EVS_ACELP_SHIFT #endif diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 1079efe6a..07910b905 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -1296,7 +1296,20 @@ ivas_error acelp_core_enc_ivas_fx( /*---------------------------------------------------------------* * Calculation of LP residual (filtering through A[z] filter) *---------------------------------------------------------------*/ +#ifdef REUSE_EVS_ACELP_SHIFT // This should be moved outside of ACELP + { + Word16 tmp, max; + max = 0; + FOR( i = 0; i < st->L_frame; i++ ) + { + tmp = abs_s( inp[i] ); + max = s_max( max, tmp ); + } + shift = sub( norm_s( max ), 3 ); + shift = s_min( shift, 0 ); + } +#endif calc_residu_fx( st, inp, res_fx, Aq ); calculate_hangover_attenuation_gain_ivas_fx( st, &att_fx, vad_hover_flag ); diff --git a/lib_enc/avq_cod_fx.c b/lib_enc/avq_cod_fx.c index b3a49c59e..1e9c71464 100644 --- a/lib_enc/avq_cod_fx.c +++ b/lib_enc/avq_cod_fx.c @@ -182,7 +182,9 @@ void AVQ_encmux_fx( Word16 bitsMod, Nsvm1, Nsvm2; Word16 unusedbitsFlag; Word16 svOrder[NSV_MAX], k, nullVec, dummy_bits; - +#ifdef REUSE_EVS_ACELP + Word16 tmp; +#endif test(); IF( EQ_16( extl, SWB_BWE_HIGHRATE ) || EQ_16( extl, FB_BWE_HIGHRATE ) ) { @@ -344,7 +346,19 @@ void AVQ_encmux_fx( test(); test(); test(); +#ifdef REUSE_EVS_ACELP + tmp = bits; + move16(); + WHILE( GE_16( tmp, 5 ) ) + { + tmp = sub( tmp, 5 ); + } + assert( tmp == bits % 5 ); + IF( EQ_16( avq_bit_sFlag, 2 ) && EQ_16( tmp, 4 ) && GT_16( bits, 8 ) && LT_16( bits, 30 ) && GE_16( k, trgtSvPos ) && LT_16( i, Nsvm1 ) ) + +#else IF( EQ_16( avq_bit_sFlag, 2 ) && EQ_16( s_and( bits, 4 ), 4 ) && GT_16( bits, 8 ) && LT_16( bits, 30 ) && GE_16( k, trgtSvPos ) && LT_16( i, Nsvm1 ) ) +#endif { ordr_esti( sub( Nsv, i ), &trgtSvPos, &svOrder[i], Nsv ); k = svOrder[i]; @@ -408,8 +422,19 @@ void AVQ_encmux_fx( test(); IF( avq_bit_sFlag > 0 && GT_16( bits, 8 ) ) { +#ifndef REUSE_EVS_ACELP // PMT("code not validated yet") bitsMod = s_and( bits, 4 /*bits%5*/ ); +#else + /* bitsMod = bits % 5;*/ + bitsMod = bits; + move16(); + WHILE( bitsMod >= 5 ) + { + bitsMod = sub( bitsMod, 5 ); + } + assert( bitsMod == bits % 5 ); +#endif i = svOrder[Nsvm1]; move16(); IF( NE_16( i, Nsvm1 ) ) @@ -449,7 +474,17 @@ void AVQ_encmux_fx( { overflow = 0; move16(); +#ifdef REUSE_EVS_ACELP + tmp = add( bitsMod, nullVec ); + WHILE( tmp >= 5 ) + { + tmp = sub( tmp, 5 ); + } + assert( tmp == add( bitsMod, nullVec ) % 5 ); + if ( tmp != 0 ) +#else if ( s_and( add( bitsMod, nullVec ), 4 ) != 0 ) +#endif { overflow = 1; move16(); @@ -476,7 +511,18 @@ void AVQ_encmux_fx( unused_bits = sub( unused_bits, 1 ); /*Stop Bit*/ } /*unused_bits_idx = (int16_t)unused_bits / 5;*/ +#ifdef REUSE_EVS_ACELP + IF( unused_bits >= 0 ) + { + unused_bits_idx = mult( unused_bits, 6554 /*1/5 in Q15*/ ); + } + ELSE + { + unused_bits_idx = negate( mult( negate( unused_bits ), 6554 /*1/5 in Q15*/ ) ); + } +#else unused_bits_idx = mult( unused_bits, 6554 ); +#endif assert( unused_bits_idx == unused_bits / 5 ); unusedbitsFlag = 0; move16(); @@ -506,7 +552,11 @@ void AVQ_encmux_fx( IF( j > 0 ) { /* write the unary code */ +#ifdef REUSE_EVS_ACELP + push_indice( hBstr, nq_ind, u_extract_l( L_sub( L_shl_sat( 1, j ), 1 ) ), j ); +#else push_indice( hBstr, nq_ind, sub( shl( 1, j ), 1 ), j ); +#endif } IF( nq[i] != 0 ) diff --git a/lib_enc/corr_xh_fx.c b/lib_enc/corr_xh_fx.c index 51165d141..57c0c0450 100644 --- a/lib_enc/corr_xh_fx.c +++ b/lib_enc/corr_xh_fx.c @@ -27,10 +27,18 @@ void corr_xh_fx( const Word16 x[], /* i : target signal Qx*/ Word16 dn[], /* o : correlation between x[] and h[] Qdn = Qx+j-1*/ const Word16 h[] /* i : impulse response (of weighted synthesis filter) Q14*/ +#ifdef REUSE_EVS_ACELP + , + const Word16 L_subfr /* i : sub-frame lenght Q0 */ +#endif ) { Word16 i, j, k; +#ifdef REUSE_EVS_ACELP + Word32 L_tmp, y32[2 * L_SUBFR], L_maxloc, L_tot; +#else Word32 L_tmp, y32[L_SUBFR], L_maxloc, L_tot; +#endif #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); @@ -42,10 +50,18 @@ void corr_xh_fx( FOR( k = 0; k < NB_TRACK; k++ ) { L_maxloc = L_deposit_l( 0 ); +#ifdef REUSE_EVS_ACELP + FOR( i = k; i < L_subfr; i += STEP ) +#else FOR( i = k; i < L_SUBFR; i += STEP ) +#endif { L_tmp = L_mac( 1L, x[i], h[0] ); /* 1 -> to avoid null dn[] Qx+15*/ +#ifdef REUSE_EVS_ACELP + FOR( j = i; j < L_subfr - 1; j++ ) +#else FOR( j = i; j < L_SUBFR - 1; j++ ) +#endif { L_tmp = L_mac_o( L_tmp, x[j + 1], h[j + 1 - i], &Overflow ); /*Qx+15*/ } @@ -66,7 +82,11 @@ void corr_xh_fx( j = sub( norm_l( L_tot ), 4 ); /* 4 -> 16 x tot */ +#ifdef REUSE_EVS_ACELP + FOR( i = 0; i < L_subfr; i++ ) +#else FOR( i = 0; i < L_SUBFR; i++ ) +#endif { dn[i] = round_fx( L_shl( y32[i], j ) ); /*Qx+15+j-16*/ } @@ -127,7 +147,6 @@ void corr_hh_ivas_fx( move16(); return; } - void corr_xh_ivas_fx( const Word16 x[], /* i : target signal Qx*/ const Word16 Qx, diff --git a/lib_enc/gaus_enc_fx.c b/lib_enc/gaus_enc_fx.c index 2aa9a5dff..4c7d8c479 100644 --- a/lib_enc/gaus_enc_fx.c +++ b/lib_enc/gaus_enc_fx.c @@ -73,8 +73,11 @@ Word16 gaus_encode_fx( *----------------------------------------------------------------*/ /* Correlation between target xn2[] and impulse response h1[] */ +#ifdef REUSE_EVS_ACELP + corr_xh_fx( xn, dn, h1, L_SUBFR ); +#else corr_xh_fx( xn, dn, h1 ); - +#endif tmp_idx = shr( i_subfr, 6 ); nb_bits = st_fx->acelp_cfg.fixed_cdk_index[tmp_idx]; /* Q0 */ move16(); @@ -171,8 +174,11 @@ Word16 gaus_encode_ivas_fx( *----------------------------------------------------------------*/ /* Correlation between target xn2[] and impulse response h1[] */ +#ifdef REUSE_EVS_ACELP + corr_xh_fx( xn, dn, h1, L_SUBFR ); +#else corr_xh_fx( xn, dn, h1 ); - +#endif tmp_idx = shr( i_subfr, 6 ); nb_bits = st_fx->acelp_cfg.fixed_cdk_index[tmp_idx]; /* Q0 */ move16(); diff --git a/lib_enc/inov_enc_fx.c b/lib_enc/inov_enc_fx.c index cb23ffa5d..8826682c6 100644 --- a/lib_enc/inov_enc_fx.c +++ b/lib_enc/inov_enc_fx.c @@ -90,7 +90,7 @@ Word16 inov_encode_fx( Word16 acelpautoc; BSTR_ENC_HANDLE hBstr = st_fx->hBstr; #ifdef REUSE_EVS_ACELP // -> this might need ajsutement in acelp_fast - Word16 i, k, Qdn = 9; + Word16 i, k, Qdn = 9 /*// -> this needs to be looked at in acelp_fast*/; #endif (void) last_L_frame; stack_pulses = 0; @@ -143,8 +143,7 @@ Word16 inov_encode_fx( cb_shape_fx( 1, 1, 0, sharpFlag, 0, g1, g2, p_Aq, h2, tilt_code, shr( add( pt_pitch, 26 ), 6 ), 0, L_subfr ); #ifdef REUSE_EVS_ACELP - assert( L_SUBFR == 64 ); - corr_xh_fx( xn2, dn, h2 ); + corr_xh_fx( xn2, dn, h2, L_subfr ); #else corr_xh_fx( xn2, dn, h2 ); #endif -- GitLab From 912cd006d20a05e54f95116b1001f447f06e0e82 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 15 Apr 2025 16:07:42 -0400 Subject: [PATCH 03/20] Reuse EVS for TC --- lib_com/options.h | 1 + lib_enc/acelp_core_enc_fx.c | 4 ++++ lib_enc/enc_tran_fx.c | 33 ++++++++++++++++++++++++++------- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 13f25fbdd..9c293efd5 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -88,5 +88,6 @@ #define TEST_HR #define REUSE_EVS_ACELP #define REUSE_EVS_ACELP_SHIFT +#define REUSE_EVS_ACELP_TC #endif diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 07910b905..763002e3b 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -1369,7 +1369,11 @@ ivas_error acelp_core_enc_ivas_fx( } ELSE IF( EQ_16( st->coder_type, TRANSITION ) ) { +#ifdef REUSE_EVS_ACELP_TC + encod_tran_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, tc_subfr, position, unbits, shift, Q_new ); +#else encod_tran_ivas_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, tc_subfr, position, unbits, 0, Q_new ); +#endif } ELSE IF( ppp_mode ) { diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c index 8e4f13116..14d301209 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -96,6 +96,9 @@ Word16 encod_tran_fx( #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif +#ifdef REUSE_EVS_ACELP_TC + Word16 q_h1; #endif BSTR_ENC_HANDLE hBstr = st_fx->hBstr; SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR; @@ -143,7 +146,12 @@ Word16 encod_tran_fx( move16(); set16_fx( code_preQ, 0, L_SUBFR ); shift_wsp = add( Q_new, shift ); - +#ifdef REUSE_EVS_ACELP_TC + if ( st_fx->element_mode > EVS_MONO && LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) ) + { + shift_wsp = sub( shift_wsp, 1 ); + } +#endif /*----------------------------------------------------------------* * ACELP subframe loop *----------------------------------------------------------------*/ @@ -157,13 +165,24 @@ Word16 encod_tran_fx( *----------------------------------------------------------------*/ Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR ); /* Q_new */ +#ifdef REUSE_EVS_ACELP_TC + IF( st_fx->element_mode > EVS_MONO ) + { + find_targets_ivas_new_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, + res_fx, L_SUBFR, p_Aw, st_fx->preemph_fac, xn, cn, h1 ); + q_h1 = sub( 14, norm_s( h1[0] ) ); + Copy_Scale_sig( h1, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/ + Scale_sig( h1, L_SUBFR, sub( 14, q_h1 ) + shift ); /* set h1[] in Q14 with scaling for convolution Q14*/ + } + ELSE +#endif + { + find_targets_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, + res_fx, L_SUBFR, p_Aw, st_fx->preemph_fac, xn, cn, h1 ); - find_targets_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, - res_fx, L_SUBFR, p_Aw, st_fx->preemph_fac, xn, cn, h1 ); - - Copy_Scale_sig( h1, h2_fx, L_SUBFR, -2 ); - Scale_sig( h1, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */ - + Copy_Scale_sig( h1, h2_fx, L_SUBFR, -2 ); + Scale_sig( h1, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */ + } /* scaling of xn[] to limit dynamic at 12 bits */ Scale_sig( xn, L_SUBFR, shift ); -- GitLab From b2968105e5d1e092d5c795ba7587e2f02b8b97f5 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Wed, 16 Apr 2025 05:44:41 -0400 Subject: [PATCH 04/20] Remove unused code --- lib_enc/enc_higher_acelp_fx.c | 3 +++ lib_enc/enc_tran_fx.c | 2 ++ lib_enc/transition_enc_fx.c | 6 ++++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib_enc/enc_higher_acelp_fx.c b/lib_enc/enc_higher_acelp_fx.c index bf248bb5a..6ddd3d549 100644 --- a/lib_enc/enc_higher_acelp_fx.c +++ b/lib_enc/enc_higher_acelp_fx.c @@ -369,6 +369,8 @@ void transf_cdbk_enc_fx( return; } +#ifndef REUSE_EVS_ACELP_TC + void transf_cdbk_enc_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP Q0*/ @@ -746,6 +748,7 @@ void transf_cdbk_enc_ivas_fx( return; } +#endif /*-------------------------------------------------------------------* * Find target in residual domain - cn[] *-------------------------------------------------------------------*/ diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c index 14d301209..a3440cfd5 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -435,6 +435,7 @@ Word16 encod_tran_fx( return tc_subfr; } +#ifndef REUSE_EVS_ACELP_TC Word16 encod_tran_ivas_fx( Encoder_State *st_fx, /* i/o: state structure */ @@ -840,3 +841,4 @@ Word16 encod_tran_ivas_fx( return tc_subfr; } +#endif \ No newline at end of file diff --git a/lib_enc/transition_enc_fx.c b/lib_enc/transition_enc_fx.c index 9f630da66..0cefdd8b1 100644 --- a/lib_enc/transition_enc_fx.c +++ b/lib_enc/transition_enc_fx.c @@ -876,6 +876,7 @@ void transition_enc_fx( return; } +#ifndef REUSE_EVS_ACELP_TC void transition_enc_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ @@ -1710,7 +1711,7 @@ void transition_enc_ivas_fx( return; } - +#endif /*-------------------------------------------------------------------------------------------* * tc_enc() * @@ -1946,6 +1947,7 @@ static void tc_enc_fx( move16(); return; } +#ifndef REUSE_EVS_ACELP_TC static void tc_enc_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ @@ -2166,7 +2168,7 @@ static void tc_enc_ivas_fx( move16(); return; } - +#endif /*-----------------------------------------------------------------* * gain_trans_enc() -- GitLab From e9921b91496c231287a57216b80c9921070b9948 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Wed, 16 Apr 2025 05:48:06 -0400 Subject: [PATCH 05/20] mod to prot_enc --- lib_enc/prot_fx_enc.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index c83f30ba7..34b580c75 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -3015,6 +3015,10 @@ void corr_xh_fx( const Word16 x[], /* i : target signal Qx*/ Word16 dn[], /* o : correlation between x[] and h[] Qdn*/ const Word16 h[] /* i : impulse response (of weighted synthesis filter) Q14*/ +#ifdef REUSE_EVS_ACELP + , + const Word16 L_subfr /* i : sub-frame lenght Q0 */ +#endif ); void corr_hh_ivas_fx( -- GitLab From 8089ab9f57ced1666bb7e8cceabdcbcd6e90add0 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Wed, 16 Apr 2025 14:43:50 -0400 Subject: [PATCH 06/20] more cleaning and fixed something in inov_enc --- lib_com/options.h | 4 + lib_enc/cod2t32_fx.c | 6 +- lib_enc/enc_tran_fx.c | 2 +- lib_enc/inov_enc_fx.c | 165 +++++++++++++++++++++--------------------- 4 files changed, 92 insertions(+), 85 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 9c293efd5..a1420d016 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -90,4 +90,8 @@ #define REUSE_EVS_ACELP_SHIFT #define REUSE_EVS_ACELP_TC +#if 0 // To be activated when everything is completed +#define REUSE_EVS_ACELP_2t32 +#define REUSE_EVS_ACELP_1t64 +#endif #endif diff --git a/lib_enc/cod2t32_fx.c b/lib_enc/cod2t32_fx.c index dc967e656..135c44063 100644 --- a/lib_enc/cod2t32_fx.c +++ b/lib_enc/cod2t32_fx.c @@ -296,7 +296,7 @@ void acelp_2t32_fx( } return; } - +#ifndef REUSE_EVS_ACELP_2t32 void acelp_2t32_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 dn[], /* i : corr. between target and h[]. Qx*/ @@ -568,6 +568,7 @@ void acelp_2t32_ivas_fx( } return; } +#endif /*---------------------------------------------------------------------------------- * Function acelp_1t64() * @@ -645,7 +646,7 @@ void acelp_1t64_fx( return; } - +#ifndef REUSE_EVS_ACELP_1t64 void acelp_1t64_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 dn[], /* i : corr. between target and h[]. Qx */ @@ -714,3 +715,4 @@ void acelp_1t64_ivas_fx( return; } +#endif \ No newline at end of file diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c index a3440cfd5..0a506dac9 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -172,7 +172,7 @@ Word16 encod_tran_fx( res_fx, L_SUBFR, p_Aw, st_fx->preemph_fac, xn, cn, h1 ); q_h1 = sub( 14, norm_s( h1[0] ) ); Copy_Scale_sig( h1, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/ - Scale_sig( h1, L_SUBFR, sub( 14, q_h1 ) + shift ); /* set h1[] in Q14 with scaling for convolution Q14*/ + Scale_sig( h1, L_SUBFR, add( sub( 14, q_h1 ), shift ) ); /* set h1[] in Q14 with scaling for convolution Q14*/ } ELSE #endif diff --git a/lib_enc/inov_enc_fx.c b/lib_enc/inov_enc_fx.c index 8826682c6..167f31880 100644 --- a/lib_enc/inov_enc_fx.c +++ b/lib_enc/inov_enc_fx.c @@ -166,109 +166,111 @@ Word16 inov_encode_fx( move16(); } } - ELSE IF( EQ_16( L_frame, L_FRAME ) && EQ_16( coder_type, TRANSITION ) ) - { - test(); - test(); - if ( EQ_32( core_brate, ACELP_8k00 ) && i_subfr == 0 && LT_16( tc_subfr, L_SUBFR ) ) - { - cmpl_flag = 3; - move16(); - } - test(); - test(); - test(); - test(); - test(); - if ( EQ_32( core_brate, ACELP_11k60 ) && ( ( i_subfr == 0 && LT_16( tc_subfr, L_SUBFR ) ) || EQ_16( tc_subfr, TC_0_0 ) || ( EQ_16( i_subfr, 3 * L_SUBFR ) && EQ_16( tc_subfr, TC_0_64 ) ) ) ) - { - cmpl_flag = 3; - move16(); - } - test(); - test(); - test(); - test(); - if ( ( EQ_32( core_brate, ACELP_13k20 ) || EQ_32( core_brate, ACELP_12k15 ) ) && ( ( i_subfr == 0 && LT_16( tc_subfr, L_SUBFR ) ) || LE_16( tc_subfr, TC_0_64 ) ) ) - { - cmpl_flag = 3; - move16(); - } - } - - IF( EQ_16( L_frame, L_FRAME16k ) ) + ELSE { - IF( LE_32( core_brate, ACELP_32k ) ) + IF( EQ_16( L_frame, L_FRAME ) && EQ_16( coder_type, TRANSITION ) ) { - cmpl_flag = 4; - move16(); - test(); - IF( EQ_16( coder_type, TRANSITION ) && GT_16( bwidth, WB ) ) + test(); + if ( EQ_32( core_brate, ACELP_8k00 ) && i_subfr == 0 && LT_16( tc_subfr, L_SUBFR ) ) { - IF( LE_16( i_subfr, L_SUBFR ) ) - { - cmpl_flag = sub( cmpl_flag, 1 ); - } - ELSE - { - cmpl_flag = sub( cmpl_flag, 2 ); - } + cmpl_flag = 3; + move16(); } - } - ELSE IF( LE_32( core_brate, ACELP_48k ) ) - { - cmpl_flag = 3; - move16(); - - IF( EQ_16( coder_type, TRANSITION ) ) + test(); + test(); + test(); + test(); + test(); + if ( EQ_32( core_brate, ACELP_11k60 ) && ( ( i_subfr == 0 && LT_16( tc_subfr, L_SUBFR ) ) || EQ_16( tc_subfr, TC_0_0 ) || ( EQ_16( i_subfr, 3 * L_SUBFR ) && EQ_16( tc_subfr, TC_0_64 ) ) ) ) { - IF( LE_16( i_subfr, L_SUBFR ) ) - { - cmpl_flag = sub( cmpl_flag, 1 ); - } - ELSE - { - cmpl_flag = sub( cmpl_flag, 2 ); - } + cmpl_flag = 3; + move16(); + } + test(); + test(); + test(); + test(); + if ( ( EQ_32( core_brate, ACELP_13k20 ) || EQ_32( core_brate, ACELP_12k15 ) ) && ( ( i_subfr == 0 && LT_16( tc_subfr, L_SUBFR ) ) || LE_16( tc_subfr, TC_0_64 ) ) ) + { + cmpl_flag = 3; + move16(); } } - ELSE - { - cmpl_flag = 4; - move16(); - IF( EQ_16( coder_type, TRANSITION ) ) + IF( EQ_16( L_frame, L_FRAME16k ) ) + { + IF( LE_32( core_brate, ACELP_32k ) ) { - IF( LE_16( i_subfr, L_SUBFR ) ) + cmpl_flag = 4; + move16(); + + test(); + IF( EQ_16( coder_type, TRANSITION ) && GT_16( bwidth, WB ) ) { - cmpl_flag = sub( cmpl_flag, 1 ); + IF( LE_16( i_subfr, L_SUBFR ) ) + { + cmpl_flag = sub( cmpl_flag, 1 ); + } + ELSE + { + cmpl_flag = sub( cmpl_flag, 2 ); + } } - ELSE + } + ELSE IF( LE_32( core_brate, ACELP_48k ) ) + { + cmpl_flag = 3; + move16(); + + IF( EQ_16( coder_type, TRANSITION ) ) { - cmpl_flag = sub( cmpl_flag, 2 ); + IF( LE_16( i_subfr, L_SUBFR ) ) + { + cmpl_flag = sub( cmpl_flag, 1 ); + } + ELSE + { + cmpl_flag = sub( cmpl_flag, 2 ); + } } } - - if ( coder_type == INACTIVE ) + ELSE { cmpl_flag = 4; move16(); + + IF( EQ_16( coder_type, TRANSITION ) ) + { + IF( LE_16( i_subfr, L_SUBFR ) ) + { + cmpl_flag = sub( cmpl_flag, 1 ); + } + ELSE + { + cmpl_flag = sub( cmpl_flag, 2 ); + } + } + + if ( coder_type == INACTIVE ) + { + cmpl_flag = 4; + move16(); + } } } - } - test(); - test(); - test(); - IF( NE_16( L_frame, st_fx->last_L_frame ) && GT_32( core_brate, ACELP_13k20 ) && ( LT_32( core_brate, ACELP_32k ) || EQ_16( bwidth, WB ) ) ) - { - if ( GT_16( cmpl_flag, 1 ) ) + test(); + test(); + test(); + IF( NE_16( L_frame, st_fx->last_L_frame ) && GT_32( core_brate, ACELP_13k20 ) && ( LT_32( core_brate, ACELP_32k ) || EQ_16( bwidth, WB ) ) ) { - cmpl_flag = sub( cmpl_flag, 1 ); + if ( GT_16( cmpl_flag, 1 ) ) + { + cmpl_flag = sub( cmpl_flag, 1 ); + } } } - /*-----------------------------------------------------------------* * Find and encode the algebraic innovation *-----------------------------------------------------------------*/ @@ -307,7 +309,7 @@ Word16 inov_encode_fx( IF( EQ_16( nBits, 8 ) ) { - acelp_1t64_ivas_fx( hBstr, dn, h2, code, y2, L_subfr ); + acelp_1t64_fx( hBstr, dn, h2, code, y2, L_subfr ); } ELSE { @@ -318,7 +320,7 @@ Word16 inov_encode_fx( { IF( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] == 0 ) { - acelp_1t64_ivas_fx( hBstr, dn, h2, code, y2, L_subfr ); + acelp_1t64_fx( hBstr, dn, h2, code, y2, L_subfr ); } ELSE { @@ -441,7 +443,6 @@ Word16 inov_encode_fx( return stack_pulses; } - Word16 inov_encode_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word32 core_brate, /* i : core bitrate */ -- GitLab From 8a408c5c5a9ebb99d53ce88a2ba0569ca13f3561 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Wed, 16 Apr 2025 15:16:56 -0400 Subject: [PATCH 07/20] reusing EVS for switching --- lib_com/options.h | 1 + lib_enc/acelp_core_switch_enc_fx.c | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index a1420d016..f2bf1ce01 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -91,6 +91,7 @@ #define REUSE_EVS_ACELP_TC #if 0 // To be activated when everything is completed +#define REUSE_EVS_TBE_CELP_EXC // to be done , just a line to be added #define REUSE_EVS_ACELP_2t32 #define REUSE_EVS_ACELP_1t64 #endif diff --git a/lib_enc/acelp_core_switch_enc_fx.c b/lib_enc/acelp_core_switch_enc_fx.c index 8226748f7..8d1f823aa 100644 --- a/lib_enc/acelp_core_switch_enc_fx.c +++ b/lib_enc/acelp_core_switch_enc_fx.c @@ -25,6 +25,7 @@ static void encod_gen_voic_core_switch_fx( Encoder_State *st_fx, const Word32 core_bitrate_fx, Word16 shift, Word16 Q_new ); +#ifndef REUSE_EVS_ACELP static void encod_gen_voic_core_switch_ivas_fx( Encoder_State *st_fx, const Word16 L_frame_fx, const Word16 inp_fx[], @@ -35,7 +36,7 @@ static void encod_gen_voic_core_switch_ivas_fx( Encoder_State *st_fx, const Word32 core_bitrate_fx, Word16 shift, Word16 Q_new ); - +#endif static void bwe_switch_enc_fx( Encoder_State *st_fx, const Word16 *new_speech ); static void bwe_switch_enc_ivas_fx( Encoder_State *st_fx, const Word16 *new_speech ); @@ -278,8 +279,11 @@ void acelp_core_switch_enc_ivas_fx( config_acelp1_IVAS( ENC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, GENERIC, st_fx->inactive_coder_type_flag, -1, -1, &j, &i, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, 0, 0 /*GSC_IVAS_mode*/ ); +#ifndef REUSE_EVS_ACELP encod_gen_voic_core_switch_ivas_fx( st_fx, st_fx->last_L_frame, inp, Aq, A, T_op, exc, cbrate, shift, Q_new ); - +#else + encod_gen_voic_core_switch_fx( st_fx, st_fx->last_L_frame, inp, Aq, A, T_op, exc, cbrate, shift, Q_new ); +#endif /*----------------------------------------------------------------* * bit-stream: modify the layer of sub frame CELP *----------------------------------------------------------------*/ @@ -521,7 +525,7 @@ static void encod_gen_voic_core_switch_fx( return; } - +#ifndef REUSE_EVS_ACELP static void encod_gen_voic_core_switch_ivas_fx( Encoder_State *st_fx, /* i/o: state structure */ const Word16 L_frame, /* i : length of the frame Q0*/ @@ -734,7 +738,7 @@ static void encod_gen_voic_core_switch_ivas_fx( return; } - +#endif /*-------------------------------------------------------------------* * bwe_switch_enc() -- GitLab From 987467187ff079b31475b569e822a63ead4ff752 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Wed, 16 Apr 2025 16:24:32 -0400 Subject: [PATCH 08/20] reusing EVS for GSC lr --- lib_enc/enc_pit_exc_fx.c | 47 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index 9180d73b8..a00589586 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -730,8 +730,13 @@ void enc_pit_exc_ivas_fx( res, L_subfr, p_Aw, st_fx->preemph_fac, xn, cn, h1 ); q_h1 = sub( 14, norm_s( h1[0] ) ); +#ifndef REUSE_EVS_ACELP Copy_Scale_sig( h1, h2, L_subfr, sub( 11, q_h1 ) ); /*Q11*/ - +#else + Copy_Scale_sig( h1, h2, L_subfr, add( sub( 11, q_h1 ), shift) ); /*Q11*/ + move16(); + Scale_sig( h1, L_subfr, sub( 14, q_h1 ) ); /* set h1[] in Q14 with scaling for convolution Q14*/ +#endif /* scaling of xn[] to limit dynamic at 12 bits */ Scale_sig( xn, L_subfr, shift ); /* Q_new - 1 + shift */ @@ -739,11 +744,15 @@ void enc_pit_exc_ivas_fx( * Close-loop pitch search and quantization * Adaptive exc. construction *----------------------------------------------------------------*/ - +#ifndef REUSE_EVS_ACELP *pt_pitch = pit_encode_ivas_fx( hBstr, st_fx->acelp_cfg.pitch_bits, Pitch_BR, 0, st_fx->L_frame, Pitch_CT, &pitch_limit_flag, i_subfr, exc, L_subfr, st_fx->pitch, &T0_min, &T0_max, T0, T0_frac, h1, xn, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, Q_new ); /* Q6 */ move16(); Scale_sig( h1, L_subfr, sub( 14, q_h1 ) ); /* set h1[] in Q14 with scaling for convolution Q14*/ +#else + *pt_pitch = pit_encode_fx( hBstr, st_fx->acelp_cfg.pitch_bits, Pitch_BR, 0, st_fx->L_frame, Pitch_CT, &pitch_limit_flag, i_subfr, exc, + L_subfr, st_fx->pitch, &T0_min, &T0_max, T0, T0_frac, h1, xn, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf ); /* Q6 */ +#endif /*-----------------------------------------------------------------* * Find adaptive exitation @@ -761,8 +770,13 @@ void enc_pit_exc_ivas_fx( * Codebook target computation * (No LP filtering of the adaptive excitation) *-----------------------------------------------------------------*/ +#ifndef REUSE_EVS_ACELP lp_select = lp_filt_exc_enc_ivas_fx( MODE1, AUDIO, i_subfr, exc, h1, xn, y1, xn2, L_subfr, st_fx->L_frame, g_corr, clip_gain, &gain_pit, &lp_flag ); /* Q0 */ +#else + lp_select = lp_filt_exc_enc_fx( MODE1, AUDIO, i_subfr, exc, h1, + xn, y1, xn2, L_subfr, st_fx->L_frame, g_corr, clip_gain, &gain_pit, &lp_flag ); /* Q0 */ +#endif IF( EQ_16( lp_flag, NORMAL_OPERATION ) ) { push_indice( hBstr, IND_LP_FILT_SELECT, lp_select, 1 ); @@ -773,13 +787,14 @@ void enc_pit_exc_ivas_fx( gpit_tmp = gain_pit; move16(); /*Q14*/ test(); +#ifndef REUSE_EVS_ACELP IF( use_fcb > 0 ) { /* h2 in Q12 for codebook search */ /* h1 has been scaled with 1 + shift so we need to remove 2 and (1+shift) = -3 - shift*/ Copy_Scale_sig( h1, h2, L_subfr, sub( -2 - 1, shift ) ); } - +#endif IF( use_fcb == 0 ) { IF( GE_32( st_fx->core_brate, MIN_RATE_FCB ) ) @@ -798,7 +813,7 @@ void enc_pit_exc_ivas_fx( /*-----------------------------------------------------------------* * Innovation encoding *-----------------------------------------------------------------*/ - +#ifndef REUSE_EVS_ACELP inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, st_fx->L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, i_subfr, -1, p_Aq, gain_pit, cn, exc, h2, st_fx->hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, 2 * L_SUBFR, shift, Q_new ); @@ -807,6 +822,16 @@ void enc_pit_exc_ivas_fx( *-----------------------------------------------------------------*/ gain_enc_lbr_ivas_fx( st_fx->hBstr, st_fx->acelp_cfg.gains_mode, GENERIC, i_subfr, xn, y1, sub( shift_wsp, 1 ), y2, code, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, gc_mem, gp_mem, clip_gain, 2 * L_SUBFR ); +#else + inov_encode_fx( st_fx, st_fx->core_brate, 0, st_fx->L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, i_subfr, -1, p_Aq, + gain_pit, cn, exc, h2, st_fx->hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, 2 * L_SUBFR, shift ); + + /*-----------------------------------------------------------------* + * Gain encoding + *-----------------------------------------------------------------*/ + + gain_enc_lbr_fx( st_fx->hBstr, st_fx->acelp_cfg.gains_mode, GENERIC, i_subfr, xn, y1, shift_wsp, y2, code, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, gc_mem, gp_mem, clip_gain, 2 * L_SUBFR ); +#endif } ELSE { @@ -814,6 +839,7 @@ void enc_pit_exc_ivas_fx( * Innovation & gain encoding *-----------------------------------------------------------------*/ +#ifndef REUSE_EVS_ACELP inov_encode_ivas_fx( st_fx, Local_BR, 0, st_fx->L_frame, st_fx->last_L_frame, LOCAL_CT, WB, 1, i_subfr, -1, p_Aq, gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift, Q_new ); /*-----------------------------------------------------------------* @@ -821,6 +847,15 @@ void enc_pit_exc_ivas_fx( *-----------------------------------------------------------------*/ gain_enc_mless_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_FRAME, i_subfr, -1, xn, y1, sub( shift_wsp, 1 ), y2, code, Es_pred, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain ); +#else + inov_encode_fx( st_fx, Local_BR, 0, st_fx->L_frame, st_fx->last_L_frame, LOCAL_CT, WB, 1, i_subfr, -1, p_Aq, + gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift ); + /*-----------------------------------------------------------------* + * Gain encoding + *-----------------------------------------------------------------*/ + gain_enc_mless_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_FRAME, i_subfr, -1, xn, y1, shift_wsp, y2, code, Es_pred, + &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain ); +#endif } gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit, st_fx->clip_var_fx ); @@ -841,7 +876,11 @@ void enc_pit_exc_ivas_fx( *-----------------------------------------------------------------*/ IF( use_fcb != 0 ) { +#ifndef REUSE_EVS_ACELP Ltmp = L_mult0( gcode16, y2[L_subfr - 1] ); +#else + Ltmp = L_mult( gcode16, y2[L_subfr - 1] ); +#endif Ltmp = L_shl_o( Ltmp, add( 5, shift ), &Overflow ); // Q_new+14+shift Ltmp = L_negate( Ltmp ); Ltmp = L_mac_o( Ltmp, xn[L_subfr - 1], 16384, &Overflow ); // Q_new-1+15+shift -- GitLab From d6fac8b2271fa995d99a914f0f4fdf9375d3753b Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Thu, 17 Apr 2025 08:25:14 -0400 Subject: [PATCH 09/20] reusing EVS unvoiced --- lib_com/options.h | 1 + lib_enc/acelp_core_enc_fx.c | 4 ++++ lib_enc/enc_gen_voic_fx.c | 31 +++++++++++++++++++++++++------ lib_enc/enc_tran_fx.c | 18 ++++++++++++++---- lib_enc/enc_uv_fx.c | 37 ++++++++++++++++++++++++++++++++----- lib_enc/gain_enc_fx.c | 4 ++++ 6 files changed, 80 insertions(+), 15 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index f2bf1ce01..b46bc3f8b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -89,6 +89,7 @@ #define REUSE_EVS_ACELP #define REUSE_EVS_ACELP_SHIFT #define REUSE_EVS_ACELP_TC +#define USE_UC_EVS #if 0 // To be activated when everything is completed #define REUSE_EVS_TBE_CELP_EXC // to be done , just a line to be added diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 763002e3b..becb97d93 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -1365,7 +1365,11 @@ ivas_error acelp_core_enc_ivas_fx( ELSE IF( EQ_16( st->coder_type, UNVOICED ) ) { /* UNVOICED frames (Gauss. excitation) */ +#ifndef USE_UC_EVS encod_unvoiced_ivas_fx( st, inp, Aw, Aq, Es_pred_fx, uc_two_stage_flag, res_fx, syn_fx, &tmp_noise_fx, exc_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, Q_new, 0 ); +#else + encod_unvoiced_fx( st, inp, Aw, Aq, Es_pred_fx, uc_two_stage_flag, res_fx, syn_fx, &tmp_noise_fx, exc_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, Q_new, 0 ); +#endif } ELSE IF( EQ_16( st->coder_type, TRANSITION ) ) { diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index 2235bc126..04a3f1dc7 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -228,10 +228,17 @@ void encod_gen_voic_fx( *pt_pitch_fx = pit_encode_fx( hBstr, st_fx->acelp_cfg.pitch_bits, st_fx->core_brate, 0, L_frame, st_fx->coder_type, &pitch_limit_flag, i_subfr_fx, exc_fx, L_SUBFR, st_fx->pitch, &T0_min_fx, &T0_max_fx, &T0_fx, &T0_frac_fx, h1_fx, xn_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf ); /* Q6 */ -#ifdef REUSE_EVS_ACELP - //tbe_celp_exc, can be use EVS version in a bit-exact manner, just to add one condition and change L_SUBFR to L_subfr in the EVS version +#ifndef REUSE_EVS_TBE_CELP_EXC + IF( st_fx->element_mode > EVS_MONO ) + { + tbe_celp_exc_ivas( st_fx->element_mode, st_fx->idchan, L_frame, L_SUBFR, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx, st_fx->tdm_LRTD_flag ); + } + ELSE #endif - tbe_celp_exc( L_frame, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx ); + { + //tbe_celp_exc, can be use EVS version in a bit-exact manner, just to add one condition and change L_SUBFR to L_subfr in the EVS version + tbe_celp_exc( L_frame, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx ); + } /*-----------------------------------------------------------------* * Find adaptive exitation @@ -389,10 +396,22 @@ void encod_gen_voic_fx( * Prepare TBE excitation *-----------------------------------------------------------------*/ - prep_tbe_exc_fx( L_frame, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx, - &voice_factors_fx[i_subfr_fx / L_SUBFR], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, Q_new, - T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate ); +#ifndef REUSE_EVS_TBE_CELP_EXC + IF( st_fx->element_mode > EVS_MONO ) + { + prep_tbe_exc_ivas_fx( L_frame, L_SUBFR, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx, + &voice_factors_fx[i_subfr_fx / L_SUBFR], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, Q_new, + T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate, + st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag ); + } + ELSE +#endif + { + prep_tbe_exc_fx( L_frame, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx, + &voice_factors_fx[i_subfr_fx / L_SUBFR], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, Q_new, + T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate ); + } /*-----------------------------------------------------------------* * Synthesize speech to update mem_syn[]. * Update A(z) filters diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c index 0a506dac9..3d3785a76 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -326,10 +326,20 @@ Word16 encod_tran_fx( /*-----------------------------------------------------------------* * Prepare TBE excitation *-----------------------------------------------------------------*/ - - prep_tbe_exc_fx( L_frame_fx, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR], - bwe_exc_fx, gain_preQ, code_preQ, Q_new, T0, T0_frac, st_fx->coder_type, st_fx->core_brate ); - +#ifndef REUSE_EVS_TBE_CELP_EXC + IF( st_fx->element_mode > EVS_MONO ) + { + prep_tbe_exc_ivas_fx( L_frame_fx, L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, + &voice_factors[i_subfr/ L_SUBFR], bwe_exc_fx, gain_preQ, code_preQ, Q_new, + T0, T0_frac, st_fx->coder_type, st_fx->core_brate, + st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag ); + } + ELSE +#endif + { + prep_tbe_exc_fx( L_frame_fx, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR], + bwe_exc_fx, gain_preQ, code_preQ, Q_new, T0, T0_frac, st_fx->coder_type, st_fx->core_brate ); + } /*-----------------------------------------------------------------* * Synthesize speech to update mem_syn[]. * Update A(z) filters diff --git a/lib_enc/enc_uv_fx.c b/lib_enc/enc_uv_fx.c index a8612725b..dba999880 100644 --- a/lib_enc/enc_uv_fx.c +++ b/lib_enc/enc_uv_fx.c @@ -14,6 +14,7 @@ * * Encode unvoiced (UC) frames *-------------------------------------------------------------------*/ +#ifndef USE_UC_EVS /*fixed point implementation of unvoiced_encoder*/ void encod_unvoiced_fx( Encoder_State *st_fx, /* i/o: state structure */ @@ -239,6 +240,9 @@ void encod_unvoiced_fx( } void encod_unvoiced_ivas_fx( +#else +void encod_unvoiced_fx( +#endif Encoder_State *st_fx, /* i/o: state structure */ const Word16 *speech_fx, /* i : Input speech Q_new*/ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/ @@ -316,7 +320,7 @@ void encod_unvoiced_ivas_fx( *----------------------------------------------------------------*/ i_subfr_idx = shr( i_subfr, 6 ); Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR ); /* Q_new */ - +#ifndef USE_UC_EVS find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq_fx, res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx ); @@ -326,14 +330,31 @@ void encod_unvoiced_ivas_fx( /* scaling of xn[] to limit dynamic at 12 bits */ Scale_sig( xn_fx, L_SUBFR, shift ); // Q_new - 1 + shift +#else + find_targets_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq_fx, + res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx ); + + /*Copy_Scale_sig(h1_fx, h2_fx, L_SUBFR, -2);*/ + Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, -2 ); /*Q11*/ + Scale_sig( h1_fx, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */ + + /* scaling of xn[] to limit dynamic at 12 bits */ + Scale_sig( xn_fx, L_SUBFR, shift ); +#endif /*----------------------------------------------------------------* * Unvoiced subframe processing *----------------------------------------------------------------*/ IF( !uc_two_stage_flag ) { +#ifndef USE_UC_EVS *pt_pitch_fx = gaus_encode_ivas_fx( st_fx, i_subfr, h1_fx, xn_fx, exc_fx, &hLPDmem->mem_w0, st_fx->clip_var_fx, &hLPDmem->tilt_code, code_fx, &L_gain_code_fx, y2_fx, &gain_inov_fx, &voice_fac_fx, &gain_pit_fx, Q_new, shift, &norm_gain_code_fx ); /* Q0 */ +#else + *pt_pitch_fx = gaus_encode_fx( st_fx, i_subfr, h1_fx, xn_fx, exc_fx, &hLPDmem->mem_w0, st_fx->clip_var_fx, + &hLPDmem->tilt_code, code_fx, &L_gain_code_fx, y2_fx, &gain_inov_fx, + &voice_fac_fx, &gain_pit_fx, Q_new, shift, &norm_gain_code_fx ); /* Q0 */ +#endif move16(); } ELSE @@ -341,7 +362,6 @@ void encod_unvoiced_ivas_fx( /*----------------------------------------------------------------* * Unvoiced subframe processing in two stages *----------------------------------------------------------------*/ - // PMT("The code below needs validation, never been tested") /* No adaptive codebook (UC) */ set16_fx( y1, 0, L_SUBFR ); set16_fx( exc_fx + i_subfr, 0, L_SUBFR ); @@ -356,11 +376,15 @@ void encod_unvoiced_ivas_fx( * Encode the algebraic innovation * *----------------------------------------------------------------------*/ - // E_ACELP_innovative_codebook_fx( exc_fx, *pt_pitch_fx, 0, 1, gain_pit_fx, hLPDmem->tilt_code, acelp_cfg, i_subfr, p_Aq_fx, h1_fx, xn_fx, cn_fx, y1, y2_fx, (Word8) st_fx->acelp_autocorr, &prm, code_fx, shift, st_fx->L_frame, st_fx->last_L_frame, st_fx->total_brate, st_fx->element_mode ); +#ifdef USE_UC_EVS + inov_encode_fx( st_fx, st_fx->core_brate, 0, L_FRAME, st_fx->last_L_frame, + UNVOICED, st_fx->bwidth, st_fx->sharpFlag, i_subfr, -1, p_Aq_fx, + gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn_fx, code_fx, y2_fx, &unbits_PI, L_SUBFR, shift ); +#else inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, L_FRAME, st_fx->last_L_frame, UNVOICED, st_fx->bwidth, st_fx->sharpFlag, i_subfr, -1, p_Aq_fx, gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn_fx, code_fx, y2_fx, &unbits_PI, L_SUBFR, shift, Q_new ); - +#endif E_ACELP_xy2_corr( xn_fx, y1, y2_fx, &g_corr, L_SUBFR, Q_xn ); g_corr.y2y2_e = sub( g_corr.y2y2_e, 18 ); /* -18 (y2*y2: Q9*Q9) */ @@ -373,8 +397,11 @@ void encod_unvoiced_ivas_fx( move16(); assert( gain_pit_fx == 0 ); +#ifdef USE_UC_EVS + gauss_L2_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 ); +#else 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 * * - quantize fixed codebook gain * diff --git a/lib_enc/gain_enc_fx.c b/lib_enc/gain_enc_fx.c index fc90f2263..457b8d24f 100644 --- a/lib_enc/gain_enc_fx.c +++ b/lib_enc/gain_enc_fx.c @@ -2086,7 +2086,11 @@ void gain_enc_lbr_fx( /* output gain_inov*/ exp_inov = sub( exp_code, add( 18, L_subfr_sf ) ); L_inov = Isqrt_lc( L_inov, &exp_inov ); +#ifdef REUSE_EVS_ACELP + *gain_inov = extract_h( L_shl_sat( L_inov, sub( exp_inov, 3 ) ) ); /* gain_inov in Q12 */ +#else *gain_inov = extract_h( L_shl( L_inov, sub( exp_inov, 3 ) ) ); /* gain_inov in Q12 */ +#endif move16(); -- GitLab From 030405680cc9e402a0863fc010d329b66afd7f13 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Thu, 17 Apr 2025 08:29:01 -0400 Subject: [PATCH 10/20] remove warnings --- lib_enc/enc_uv_fx.c | 2 ++ lib_enc/transition_enc_fx.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib_enc/enc_uv_fx.c b/lib_enc/enc_uv_fx.c index dba999880..2dce47e16 100644 --- a/lib_enc/enc_uv_fx.c +++ b/lib_enc/enc_uv_fx.c @@ -283,7 +283,9 @@ void encod_unvoiced_fx( Word16 i_subfr, Q_xn, Q_new_p5, tmp2, j, i; Word16 index, i_subfr_idx; Word16 unbits_PI; +#ifndef USE_UC_EVS Word16 q_h1; +#endif acelp_cfg = &( st_fx->acelp_cfg ); SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR; LPD_state_HANDLE hLPDmem = st_fx->hLPDmem; diff --git a/lib_enc/transition_enc_fx.c b/lib_enc/transition_enc_fx.c index 0cefdd8b1..93dc54d43 100644 --- a/lib_enc/transition_enc_fx.c +++ b/lib_enc/transition_enc_fx.c @@ -17,8 +17,9 @@ static void gain_trans_enc_fx( Word32 gain_trans32, Word16 exc[], Word16 *quant_index, Word16 *quant_sign, Word16 Q_new ); static void tc_enc_fx( Encoder_State *st_fx, const Word16 i_subfr, Word16 *tc_subfr, Word16 *position, const Word16 *h1_fx, const Word16 *xn_fx, Word16 *exc_fx, Word16 *yy1_fx, Word16 *T0_min, Word16 *T0_max, Word16 *T0, Word16 *T0_frac, Word16 *gain_pit_fx, Word16 g_corr_fx[], Word16 *bwe_exc_fx, Word16 Q_new ); +#ifndef REUSE_EVS_ACELP_TC static void tc_enc_ivas_fx( Encoder_State *st_fx, const Word16 i_subfr, Word16 *tc_subfr, Word16 *position, const Word16 *h1_fx, const Word16 *xn_fx, Word16 *exc_fx, Word16 *yy1_fx, Word16 *T0_min, Word16 *T0_max, Word16 *T0, Word16 *T0_frac, Word16 *gain_pit_fx, Word16 g_corr_fx[], Word16 *bwe_exc_fx, Word16 Q_new ); - +#endif /*==========================================================================*/ /* FUNCTION : void transition_enc_fx () */ -- GitLab From 9eba0b5a17291c1a48715fa27b3752decf00c18d Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Thu, 17 Apr 2025 10:33:25 -0400 Subject: [PATCH 11/20] fixing clang --- lib_enc/acelp_core_enc_fx.c | 4 ++-- lib_enc/cod2t32_fx.c | 2 +- lib_enc/enc_gen_voic_fx.c | 4 ++-- lib_enc/enc_pit_exc_fx.c | 12 ++++++------ lib_enc/enc_tran_fx.c | 6 +++--- lib_enc/enc_uv_fx.c | 8 ++++---- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 4765c3024..37c729bb0 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -789,7 +789,7 @@ ivas_error acelp_core_enc_ivas_fx( Word16 att_fx; Word16 tmpF_fx; -#ifdef REUSE_EVS_ACELP +#ifdef REUSE_EVS_ACELP Word16 shift = 0; #endif @@ -1320,7 +1320,7 @@ ivas_error acelp_core_enc_ivas_fx( shift = sub( norm_s( max ), 3 ); shift = s_min( shift, 0 ); - } + } #endif calc_residu_fx( st, inp, res_fx, Aq ); calculate_hangover_attenuation_gain_ivas_fx( st, &att_fx, vad_hover_flag ); diff --git a/lib_enc/cod2t32_fx.c b/lib_enc/cod2t32_fx.c index 135c44063..b8134388a 100644 --- a/lib_enc/cod2t32_fx.c +++ b/lib_enc/cod2t32_fx.c @@ -715,4 +715,4 @@ void acelp_1t64_ivas_fx( return; } -#endif \ No newline at end of file +#endif diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index 079bcae03..1e56d2ce4 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -236,7 +236,7 @@ void encod_gen_voic_fx( ELSE #endif { - //tbe_celp_exc, can be use EVS version in a bit-exact manner, just to add one condition and change L_SUBFR to L_subfr in the EVS version + // tbe_celp_exc, can be use EVS version in a bit-exact manner, just to add one condition and change L_SUBFR to L_subfr in the EVS version tbe_celp_exc( L_frame, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx ); } @@ -828,4 +828,4 @@ void encod_gen_voic_ivas_fx( return; } -#endif \ No newline at end of file +#endif diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index a00589586..4eab25a1d 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -733,7 +733,7 @@ void enc_pit_exc_ivas_fx( #ifndef REUSE_EVS_ACELP Copy_Scale_sig( h1, h2, L_subfr, sub( 11, q_h1 ) ); /*Q11*/ #else - Copy_Scale_sig( h1, h2, L_subfr, add( sub( 11, q_h1 ), shift) ); /*Q11*/ + Copy_Scale_sig( h1, h2, L_subfr, add( sub( 11, q_h1 ), shift ) ); /*Q11*/ move16(); Scale_sig( h1, L_subfr, sub( 14, q_h1 ) ); /* set h1[] in Q14 with scaling for convolution Q14*/ #endif @@ -751,7 +751,7 @@ void enc_pit_exc_ivas_fx( Scale_sig( h1, L_subfr, sub( 14, q_h1 ) ); /* set h1[] in Q14 with scaling for convolution Q14*/ #else *pt_pitch = pit_encode_fx( hBstr, st_fx->acelp_cfg.pitch_bits, Pitch_BR, 0, st_fx->L_frame, Pitch_CT, &pitch_limit_flag, i_subfr, exc, - L_subfr, st_fx->pitch, &T0_min, &T0_max, T0, T0_frac, h1, xn, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf ); /* Q6 */ + L_subfr, st_fx->pitch, &T0_min, &T0_max, T0, T0_frac, h1, xn, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf ); /* Q6 */ #endif /*-----------------------------------------------------------------* @@ -775,7 +775,7 @@ void enc_pit_exc_ivas_fx( xn, y1, xn2, L_subfr, st_fx->L_frame, g_corr, clip_gain, &gain_pit, &lp_flag ); /* Q0 */ #else lp_select = lp_filt_exc_enc_fx( MODE1, AUDIO, i_subfr, exc, h1, - xn, y1, xn2, L_subfr, st_fx->L_frame, g_corr, clip_gain, &gain_pit, &lp_flag ); /* Q0 */ + xn, y1, xn2, L_subfr, st_fx->L_frame, g_corr, clip_gain, &gain_pit, &lp_flag ); /* Q0 */ #endif IF( EQ_16( lp_flag, NORMAL_OPERATION ) ) { @@ -824,7 +824,7 @@ void enc_pit_exc_ivas_fx( gain_enc_lbr_ivas_fx( st_fx->hBstr, st_fx->acelp_cfg.gains_mode, GENERIC, i_subfr, xn, y1, sub( shift_wsp, 1 ), y2, code, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, gc_mem, gp_mem, clip_gain, 2 * L_SUBFR ); #else inov_encode_fx( st_fx, st_fx->core_brate, 0, st_fx->L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, i_subfr, -1, p_Aq, - gain_pit, cn, exc, h2, st_fx->hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, 2 * L_SUBFR, shift ); + gain_pit, cn, exc, h2, st_fx->hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, 2 * L_SUBFR, shift ); /*-----------------------------------------------------------------* * Gain encoding @@ -849,12 +849,12 @@ void enc_pit_exc_ivas_fx( &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain ); #else inov_encode_fx( st_fx, Local_BR, 0, st_fx->L_frame, st_fx->last_L_frame, LOCAL_CT, WB, 1, i_subfr, -1, p_Aq, - gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift ); + gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift ); /*-----------------------------------------------------------------* * Gain encoding *-----------------------------------------------------------------*/ gain_enc_mless_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_FRAME, i_subfr, -1, xn, y1, shift_wsp, y2, code, Es_pred, - &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain ); + &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain ); #endif } gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit, st_fx->clip_var_fx ); diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c index 8a1234c36..f92b3ba4d 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -171,8 +171,8 @@ Word16 encod_tran_fx( find_targets_ivas_new_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, res_fx, L_SUBFR, p_Aw, st_fx->preemph_fac, xn, cn, h1 ); q_h1 = sub( 14, norm_s( h1[0] ) ); - Copy_Scale_sig( h1, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/ - Scale_sig( h1, L_SUBFR, add( sub( 14, q_h1 ), shift ) ); /* set h1[] in Q14 with scaling for convolution Q14*/ + Copy_Scale_sig( h1, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/ + Scale_sig( h1, L_SUBFR, add( sub( 14, q_h1 ), shift ) ); /* set h1[] in Q14 with scaling for convolution Q14*/ } ELSE #endif @@ -846,4 +846,4 @@ Word16 encod_tran_ivas_fx( return tc_subfr; } -#endif \ No newline at end of file +#endif diff --git a/lib_enc/enc_uv_fx.c b/lib_enc/enc_uv_fx.c index 2dce47e16..80485c61b 100644 --- a/lib_enc/enc_uv_fx.c +++ b/lib_enc/enc_uv_fx.c @@ -354,8 +354,8 @@ void encod_unvoiced_fx( &voice_fac_fx, &gain_pit_fx, Q_new, shift, &norm_gain_code_fx ); /* Q0 */ #else *pt_pitch_fx = gaus_encode_fx( st_fx, i_subfr, h1_fx, xn_fx, exc_fx, &hLPDmem->mem_w0, st_fx->clip_var_fx, - &hLPDmem->tilt_code, code_fx, &L_gain_code_fx, y2_fx, &gain_inov_fx, - &voice_fac_fx, &gain_pit_fx, Q_new, shift, &norm_gain_code_fx ); /* Q0 */ + &hLPDmem->tilt_code, code_fx, &L_gain_code_fx, y2_fx, &gain_inov_fx, + &voice_fac_fx, &gain_pit_fx, Q_new, shift, &norm_gain_code_fx ); /* Q0 */ #endif move16(); } @@ -380,8 +380,8 @@ void encod_unvoiced_fx( #ifdef USE_UC_EVS inov_encode_fx( st_fx, st_fx->core_brate, 0, L_FRAME, st_fx->last_L_frame, - UNVOICED, st_fx->bwidth, st_fx->sharpFlag, i_subfr, -1, p_Aq_fx, - gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn_fx, code_fx, y2_fx, &unbits_PI, L_SUBFR, shift ); + UNVOICED, st_fx->bwidth, st_fx->sharpFlag, i_subfr, -1, p_Aq_fx, + gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn_fx, code_fx, y2_fx, &unbits_PI, L_SUBFR, shift ); #else inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, L_FRAME, st_fx->last_L_frame, UNVOICED, st_fx->bwidth, st_fx->sharpFlag, i_subfr, -1, p_Aq_fx, -- GitLab From 1ceb786f71a27acd9e9383b5160106cd4b2272ba Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Wed, 4 Jun 2025 15:03:17 -0400 Subject: [PATCH 12/20] fix BE issue when switch are deactivated --- lib_enc/enc_uv_fx.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib_enc/enc_uv_fx.c b/lib_enc/enc_uv_fx.c index d6517349d..e7c699605 100644 --- a/lib_enc/enc_uv_fx.c +++ b/lib_enc/enc_uv_fx.c @@ -273,7 +273,7 @@ void encod_unvoiced_fx( Word16 y1[L_SUBFR]; /* Filtered adaptive excitation */ Word16 code2[L_SUBFR]; /* Gaussian excitation */ Word16 y22[L_SUBFR]; /* Filtered Gaussian excitation */ - Word16 prm_t[2 * NPRM_DIV], *prm = prm_t; + // Word16 prm_t[2 * NPRM_DIV], *prm = prm_t; const Word16 *p_Aw_fx, *p_Aq_fx; /* pointer to LP filter coeff. vector */ Word32 norm_gain_code_fx; ACELP_config *acelp_cfg; @@ -323,6 +323,7 @@ void encod_unvoiced_fx( Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR ); /* Q_new */ #ifdef USE_UC_EVS IF( st_fx->element_mode > EVS_MONO ) +#endif { find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq_fx, @@ -331,13 +332,12 @@ void encod_unvoiced_fx( q_h1 = sub( 14, norm_s( h1_fx[0] ) ); Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); Scale_sig( h1_fx, L_SUBFR, sub( 14, q_h1 ) ); - //Scale_sig( h1, L_SUBFR, add( sub( 14, q_h1 ), shift ) ); /* set h1[] in Q14 with scaling for convolution Q14*/ /* scaling of xn[] to limit dynamic at 12 bits */ Scale_sig( xn_fx, L_SUBFR, shift ); // Q_new - 1 + shift } +#ifdef USE_UC_EVS else -#endif { find_targets_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq_fx, res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx ); @@ -348,6 +348,7 @@ void encod_unvoiced_fx( /* scaling of xn[] to limit dynamic at 12 bits */ Scale_sig( xn_fx, L_SUBFR, shift ); } +#endif /*----------------------------------------------------------------* * Unvoiced subframe processing *----------------------------------------------------------------*/ -- GitLab From ebe02e190954a5b5f96ad04f085158af7aae8bda Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Wed, 4 Jun 2025 15:10:55 -0400 Subject: [PATCH 13/20] activation of switches --- lib_com/options.h | 4 ++-- lib_enc/acelp_core_enc_fx.c | 2 +- lib_enc/enc_uv_fx.c | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index eac24a4be..3b91b3306 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -104,10 +104,10 @@ #define TEST_HR #define REMOVE_EVS_DUPLICATES /* remove core-coder duplicated functions, ACELP low-band decoder */ -#if 0 -//#define REUSE_EVS_ACELP +#define REUSE_EVS_ACELP #define REUSE_EVS_ACELP_SHIFT #define USE_UC_EVS // works at 13.2, 16.4m 32, issues at 24.4 +#if 1 #define REUSE_EVS_ACELP_TC diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index ae4fedfdf..4687d8636 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -1296,7 +1296,7 @@ ivas_error acelp_core_enc_ivas_fx( *---------------------------------------------------------------*/ calc_residu_fx( st, inp, res_fx, Aq ); -#if 0 // def REUSE_EVS_ACELP_SHIFT // This should be moved outside of ACELP +#if 1 // def REUSE_EVS_ACELP_SHIFT // This should be moved outside of ACELP { Word16 tmp, max; max = 0; diff --git a/lib_enc/enc_uv_fx.c b/lib_enc/enc_uv_fx.c index e7c699605..cddd9ac68 100644 --- a/lib_enc/enc_uv_fx.c +++ b/lib_enc/enc_uv_fx.c @@ -273,7 +273,9 @@ void encod_unvoiced_fx( Word16 y1[L_SUBFR]; /* Filtered adaptive excitation */ Word16 code2[L_SUBFR]; /* Gaussian excitation */ Word16 y22[L_SUBFR]; /* Filtered Gaussian excitation */ - // Word16 prm_t[2 * NPRM_DIV], *prm = prm_t; +#ifdef USE_UC_EVS + Word16 prm_t[2 * NPRM_DIV], *prm = prm_t; +#endif const Word16 *p_Aw_fx, *p_Aq_fx; /* pointer to LP filter coeff. vector */ Word32 norm_gain_code_fx; ACELP_config *acelp_cfg; -- GitLab From c03c91fb641cd49345549de329c4b70e10d4cf80 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Wed, 4 Jun 2025 15:13:54 -0400 Subject: [PATCH 14/20] fix clang --- lib_enc/acelp_core_enc_fx.c | 2 +- lib_enc/enc_gen_voic_fx.c | 12 ++++++------ lib_enc/enc_tran_fx.c | 15 +++++++-------- lib_enc/enc_uv_fx.c | 2 +- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 4687d8636..c89d9fe5c 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -1302,7 +1302,7 @@ ivas_error acelp_core_enc_ivas_fx( max = 0; FOR( i = 0; i < st->L_frame; i++ ) { - tmp = s_max( abs_s( res_fx[i] ), abs_s( inp[i] ) ); + tmp = s_max( abs_s( res_fx[i] ), abs_s( inp[i] ) ); max = s_max( max, tmp ); } diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index d2f78f5a4..87d438bff 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -207,11 +207,11 @@ void encod_gen_voic_fx( #ifdef REUSE_EVS_ACELP IF( st_fx->element_mode > EVS_MONO ) { - //find_targets_ivas_new_fx( speech_fx, hLPDmem->mem_syn, i_subfr_fx, &hLPDmem->mem_w0, p_Aq_fx, - // res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx ); - //q_h1 = sub( 14, norm_s( h1_fx[0] ) ); - //Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/ - //Scale_sig( h1_fx, L_SUBFR, add( sub( 14, q_h1 ), shift ) ); + // find_targets_ivas_new_fx( speech_fx, hLPDmem->mem_syn, i_subfr_fx, &hLPDmem->mem_w0, p_Aq_fx, + // res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx ); + // q_h1 = sub( 14, norm_s( h1_fx[0] ) ); + // Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/ + // Scale_sig( h1_fx, L_SUBFR, add( sub( 14, q_h1 ), shift ) ); find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr_fx, &hLPDmem->mem_w0, p_Aq_fx, @@ -219,7 +219,7 @@ void encod_gen_voic_fx( q_h1 = sub( 14, norm_s( h1_fx[0] ) ); Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/ - //Scale_sig( h1_fx, L_SUBFR, sub( 14, q_h1 ) ); /* set h1[] in Q14 with scaling for convolution Q14*/ + // Scale_sig( h1_fx, L_SUBFR, sub( 14, q_h1 ) ); /* set h1[] in Q14 with scaling for convolution Q14*/ Scale_sig( h1_fx, L_SUBFR, add( sub( 14, q_h1 ), shift ) ); } ELSE diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c index 1f6d721b8..1a15a1947 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -168,19 +168,18 @@ Word16 encod_tran_fx( #ifdef REUSE_EVS_ACELP_TC IF( st_fx->element_mode > EVS_MONO ) { - //find_targets_ivas_new_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, - // res_fx, L_SUBFR, p_Aw, st_fx->preemph_fac, xn, cn, h1 ); - //q_h1 = sub( 14, norm_s( h1[0] ) ); - //Copy_Scale_sig( h1, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/ - //Scale_sig( h1, L_SUBFR, add( sub( 14, q_h1 ), shift ) ); /* set h1[] in Q14 with scaling for convolution Q14*/ + // find_targets_ivas_new_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, + // res_fx, L_SUBFR, p_Aw, st_fx->preemph_fac, xn, cn, h1 ); + // q_h1 = sub( 14, norm_s( h1[0] ) ); + // Copy_Scale_sig( h1, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/ + // Scale_sig( h1, L_SUBFR, add( sub( 14, q_h1 ), shift ) ); /* set h1[] in Q14 with scaling for convolution Q14*/ find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, - res_fx, L_SUBFR, p_Aw, st_fx->preemph_fac, xn, cn, h1); + res_fx, L_SUBFR, p_Aw, st_fx->preemph_fac, xn, cn, h1 ); q_h1 = sub( 14, norm_s( h1[0] ) ); Copy_Scale_sig( h1, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/ - //Scale_sig( h1, L_SUBFR, sub( 14, q_h1 ) ); /* set h1[] in Q14 with scaling for convolution Q14*/ + // Scale_sig( h1, L_SUBFR, sub( 14, q_h1 ) ); /* set h1[] in Q14 with scaling for convolution Q14*/ Scale_sig( h1, L_SUBFR, add( sub( 14, q_h1 ), shift ) ); /* set h1[] in Q14 with scaling for convolution Q14*/ - } ELSE #endif diff --git a/lib_enc/enc_uv_fx.c b/lib_enc/enc_uv_fx.c index cddd9ac68..e3872a48b 100644 --- a/lib_enc/enc_uv_fx.c +++ b/lib_enc/enc_uv_fx.c @@ -274,7 +274,7 @@ void encod_unvoiced_fx( Word16 code2[L_SUBFR]; /* Gaussian excitation */ Word16 y22[L_SUBFR]; /* Filtered Gaussian excitation */ #ifdef USE_UC_EVS - Word16 prm_t[2 * NPRM_DIV], *prm = prm_t; + Word16 prm_t[2 * NPRM_DIV], *prm = prm_t; #endif const Word16 *p_Aw_fx, *p_Aq_fx; /* pointer to LP filter coeff. vector */ Word32 norm_gain_code_fx; -- GitLab From 21969231a7b86b99d2740e53dca56762b4529968 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Wed, 4 Jun 2025 20:23:59 -0400 Subject: [PATCH 15/20] remove debugging code --- lib_enc/acelp_core_enc_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index c89d9fe5c..a04604379 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -1308,8 +1308,8 @@ ivas_error acelp_core_enc_ivas_fx( shift = sub( norm_s( max ), 3 ); shift = s_min( shift, 0 ); - if ( shift != 0 ) - printf( "shift %d\n", shift ); + // if ( shift != 0 ) + // printf( "shift %d\n", shift ); } #endif calculate_hangover_attenuation_gain_ivas_fx( st, &att_fx, vad_hover_flag ); -- GitLab From 9ed13c1061a64c60b52126d274dee66180ec86c7 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Thu, 5 Jun 2025 11:03:53 -0400 Subject: [PATCH 16/20] add missing code to reuse EVS pit_enc --- lib_enc/pit_enc_fx.c | 56 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/lib_enc/pit_enc_fx.c b/lib_enc/pit_enc_fx.c index 8eea1b3d5..036eadea6 100644 --- a/lib_enc/pit_enc_fx.c +++ b/lib_enc/pit_enc_fx.c @@ -80,8 +80,9 @@ Word16 pit_encode_fx( /* o : Fractional pitc Word16 pit_flag, delta, mult_Top, nBits; Word16 L_sufr_sft; Word16 T_op[2]; /* values for two half-frames */ +#ifndef REUSE_EVS_ACELP (void) tdm_Pitch_reuse_flag; - +#endif L_sufr_sft = 6; move16(); if ( EQ_16( L_subfr, 2 * L_SUBFR ) ) @@ -265,6 +266,59 @@ Word16 pit_encode_fx( /* o : Fractional pitc pit_Q_enc_fx( hBstr, 0, nBits, delta, pit_flag, *limit_flag, *T0, *T0_frac, T0_min, T0_max ); } +#ifdef REUSE_EVS_ACELP + ELSE IF( EQ_16( tdm_Pitch_reuse_flag, 1 ) || EQ_16( nBits, 4 ) ) + { + /*-------------------------------------------------------* + * Pitch encoding with reusing primary channel information + *-------------------------------------------------------*/ + Word16 loc_T0, loc_frac; + + delta = 4; + move16(); + + pit_flag = L_SUBFR; + move16(); + + Word16 idx1 = shr( i_subfr, L_sufr_sft ); + Word16 idx2 = shr( add( i_subfr, 64 ), L_sufr_sft ); + + IF( EQ_16( L_subfr, 2 * L_SUBFR ) ) + { + loc_T0 = add( shr( tdm_Pri_pitch_buf[idx1], 1 ), shr( tdm_Pri_pitch_buf[idx2], 1 ) ); // Q6 + loc_frac = shr( sub( loc_T0, shl( shr( loc_T0, 6 ), 6 ) ), 4 ); // Q2 + loc_T0 = shr( loc_T0, 6 ); // Q0 + } + ELSE + { + loc_T0 = tdm_Pri_pitch_buf[idx1]; // Q6 + loc_frac = shr( sub( loc_T0, shl( shr( loc_T0, 6 ), 6 ) ), 4 ); // Q2 + loc_T0 = shr( loc_T0, 6 ); // Q0 + } + + /* pitch lag search limitation */ + limit_T0_fx( L_FRAME, delta, pit_flag, *limit_flag, loc_T0, loc_frac, T0_min, T0_max ); + IF( nBits > 0 ) + { + /* search and encode the closed loop pitch period */ + *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MIN, PIT_FR1_8b, L_FRAME, L_SUBFR ); + move16(); + IF( EQ_16( delta, 8 ) ) + { + *T0_frac = 0; + move16(); + } + pit_Q_enc_ivas_fx( hBstr, 0, nBits, delta, pit_flag, *limit_flag, *T0, *T0_frac, T0_min, T0_max ); + } + ELSE + { + *T0 = loc_T0; + move16(); + *T0_frac = loc_frac; + move16(); + } + } +#endif ELSE { /*-------------------------------------------------------* -- GitLab From f10f08a450b76a4b5f854d07f20767b309642954 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Thu, 5 Jun 2025 14:31:13 -0400 Subject: [PATCH 17/20] fixing small issues --- lib_com/options.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 3b91b3306..a6ff23165 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -104,17 +104,19 @@ #define TEST_HR #define REMOVE_EVS_DUPLICATES /* remove core-coder duplicated functions, ACELP low-band decoder */ + #define REUSE_EVS_ACELP +#ifdef REUSE_EVS_ACELP +//#define USE_NEW_TARGET +#define REUSE_EVS_ACELP_GEN #define REUSE_EVS_ACELP_SHIFT -#define USE_UC_EVS // works at 13.2, 16.4m 32, issues at 24.4 -#if 1 #define REUSE_EVS_ACELP_TC - - -//#define REUSE_EVS_TBE_CELP_EXC // to be done , just a line to be added +#endif #define REUSE_EVS_ACELP_2t32 #define REUSE_EVS_ACELP_1t64 -#endif +#define USE_UC_EVS + +//#define REUSE_EVS_TBE_CELP_EXC // to be done , just a line to be added #define FIX_1713_EXP /* VA: proposed correction to exp in ic-BWE*/ #endif -- GitLab From a71e14cef94e59c454b7a5705f475685bfff0f7b Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Thu, 5 Jun 2025 14:33:29 -0400 Subject: [PATCH 18/20] fixing small issues --- lib_enc/acelp_core_enc_fx.c | 2 +- lib_enc/enc_gen_voic_fx.c | 21 ++++++++------------- lib_enc/enc_pit_exc_fx.c | 8 +++++++- lib_enc/enc_tran_fx.c | 23 ++++++++--------------- lib_enc/enc_uv_fx.c | 17 ++++++++--------- lib_enc/find_tar_fx.c | 13 +++++++++++++ lib_enc/gain_enc_fx.c | 2 +- 7 files changed, 46 insertions(+), 40 deletions(-) diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index a04604379..b27784c25 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -1296,7 +1296,7 @@ ivas_error acelp_core_enc_ivas_fx( *---------------------------------------------------------------*/ calc_residu_fx( st, inp, res_fx, Aq ); -#if 1 // def REUSE_EVS_ACELP_SHIFT // This should be moved outside of ACELP +#ifdef REUSE_EVS_ACELP_SHIFT // This should be moved outside of ACELP { Word16 tmp, max; max = 0; diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index 87d438bff..18c2dc358 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -115,9 +115,7 @@ void encod_gen_voic_fx( Flag Overflow = 0; move32(); #endif -#ifdef REUSE_EVS_ACELP - Word16 q_h1; -#endif + SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR; BSTR_ENC_HANDLE hBstr = st_fx->hBstr; SP_MUS_CLAS_HANDLE hSpMusClas = st_fx->hSpMusClas; @@ -204,22 +202,15 @@ void encod_gen_voic_fx( *----------------------------------------------------------------*/ Copy( &res_fx[i_subfr_fx], &exc_fx[i_subfr_fx], L_SUBFR ); /*Q_new*/ -#ifdef REUSE_EVS_ACELP - IF( st_fx->element_mode > EVS_MONO ) +#ifdef USE_NEW_TARGET + IF( st_fx->element_mode > EVS_MONO && GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) ) { - // find_targets_ivas_new_fx( speech_fx, hLPDmem->mem_syn, i_subfr_fx, &hLPDmem->mem_w0, p_Aq_fx, - // res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx ); - // q_h1 = sub( 14, norm_s( h1_fx[0] ) ); - // Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/ - // Scale_sig( h1_fx, L_SUBFR, add( sub( 14, q_h1 ), shift ) ); - - + Word16 q_h1; find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr_fx, &hLPDmem->mem_w0, p_Aq_fx, res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx ); q_h1 = sub( 14, norm_s( h1_fx[0] ) ); Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/ - // Scale_sig( h1_fx, L_SUBFR, sub( 14, q_h1 ) ); /* set h1[] in Q14 with scaling for convolution Q14*/ Scale_sig( h1_fx, L_SUBFR, add( sub( 14, q_h1 ), shift ) ); } ELSE @@ -343,7 +334,11 @@ void encod_gen_voic_fx( *-----------------------------------------------------------------*/ test(); +#ifdef REUSE_EVS_ACELP + IF( !st_fx->inactive_coder_type_flag && EQ_16( st_fx->coder_type, INACTIVE ) ) +#else IF( GE_32( st_fx->core_brate, MAX_GSC_INACTIVE_BRATE ) && EQ_16( st_fx->coder_type, INACTIVE ) ) +#endif { transf_cdbk_enc_fx( st_fx, 0, i_subfr_fx, cn_fx, exc_fx, p_Aq_fx, p_Aw_fx, h1_fx, xn_fx, xn2_fx, y1_fx, y2_fx, Es_pred_fx, &gain_pit_fx, gain_code_fx, g_corr_fx, clip_gain_fx, &gain_preQ_fx, code_preQ_fx, unbits_fx, Q_new, shift ); diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index 3522ba1a1..5c2f7304a 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -720,7 +720,7 @@ void enc_pit_exc_ivas_fx( *----------------------------------------------------------------*/ Copy( &res[i_subfr], &exc[i_subfr], L_subfr ); /* Q_new */ /* condition on target (compared to float) has been put outside the loop */ - +#ifdef USE_NEW_TARGET find_targets_ivas_fx( speech, hGSCEnc->mem_syn_tmp_fx, i_subfr, &hGSCEnc->mem_w0_tmp_fx, p_Aq, res, L_subfr, p_Aw, st_fx->preemph_fac, xn, cn, h1 ); @@ -731,6 +731,12 @@ void enc_pit_exc_ivas_fx( Copy_Scale_sig( h1, h2, L_subfr, add( sub( 11, q_h1 ), shift ) ); /*Q11*/ move16(); Scale_sig( h1, L_subfr, sub( 14, q_h1 ) ); /* set h1[] in Q14 with scaling for convolution Q14*/ +#endif +#else + find_targets_fx( speech, hGSCEnc->mem_syn_tmp_fx, i_subfr, &hGSCEnc->mem_w0_tmp_fx, p_Aq, + res, L_subfr, p_Aw, st_fx->preemph_fac, xn, cn, h1 ); + Copy_Scale_sig( h1, h2, L_subfr, -2 ); + Scale_sig( h1, L_subfr, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */ #endif /* scaling of xn[] to limit dynamic at 12 bits */ Scale_sig( xn, L_subfr, shift ); /* Q_new - 1 + shift */ diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c index 1a15a1947..4677c9ffe 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -96,14 +96,13 @@ Word16 encod_tran_fx( #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif -#ifdef REUSE_EVS_ACELP_TC - Word16 q_h1; #endif BSTR_ENC_HANDLE hBstr = st_fx->hBstr; SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR; LPD_state_HANDLE hLPDmem = st_fx->hLPDmem; - +#ifdef REUSE_EVS_ACELP_TC + set16_fx( h1, 0, L_SUBFR + ( M + 1 ) ); +#endif L_frame_fx = st_fx->L_frame; move16(); /*------------------------------------------------------------------* @@ -165,21 +164,15 @@ Word16 encod_tran_fx( *----------------------------------------------------------------*/ Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR ); /* Q_new */ -#ifdef REUSE_EVS_ACELP_TC - IF( st_fx->element_mode > EVS_MONO ) +#ifdef USE_NEW_TARGET + IF( st_fx->element_mode > EVS_MONO && GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) ) { - // find_targets_ivas_new_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, - // res_fx, L_SUBFR, p_Aw, st_fx->preemph_fac, xn, cn, h1 ); - // q_h1 = sub( 14, norm_s( h1[0] ) ); - // Copy_Scale_sig( h1, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/ - // Scale_sig( h1, L_SUBFR, add( sub( 14, q_h1 ), shift ) ); /* set h1[] in Q14 with scaling for convolution Q14*/ + Word16 q_h1; find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, - res_fx, L_SUBFR, p_Aw, st_fx->preemph_fac, xn, cn, h1 ); - + res_fx, L_SUBFR, p_Aw, st_fx->preemph_fac, xn, cn, h1 ); q_h1 = sub( 14, norm_s( h1[0] ) ); Copy_Scale_sig( h1, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/ - // Scale_sig( h1, L_SUBFR, sub( 14, q_h1 ) ); /* set h1[] in Q14 with scaling for convolution Q14*/ - Scale_sig( h1, L_SUBFR, add( sub( 14, q_h1 ), shift ) ); /* set h1[] in Q14 with scaling for convolution Q14*/ + Scale_sig( h1, L_SUBFR, add( sub( 14, q_h1 ), shift ) ); } ELSE #endif diff --git a/lib_enc/enc_uv_fx.c b/lib_enc/enc_uv_fx.c index e3872a48b..5b75f2c1a 100644 --- a/lib_enc/enc_uv_fx.c +++ b/lib_enc/enc_uv_fx.c @@ -285,7 +285,6 @@ void encod_unvoiced_fx( Word16 i_subfr, Q_xn, Q_new_p5, tmp2, j, i; Word16 index, i_subfr_idx; Word16 unbits_PI; - Word16 q_h1; acelp_cfg = &( st_fx->acelp_cfg ); SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR; @@ -323,11 +322,11 @@ void encod_unvoiced_fx( *----------------------------------------------------------------*/ i_subfr_idx = shr( i_subfr, 6 ); Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR ); /* Q_new */ -#ifdef USE_UC_EVS - IF( st_fx->element_mode > EVS_MONO ) -#endif - { +#ifdef USE_NEW_TARGET + IF( st_fx->element_mode > EVS_MONO && GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) ) + { + Word16 q_h1; find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq_fx, res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx ); @@ -338,19 +337,19 @@ void encod_unvoiced_fx( /* scaling of xn[] to limit dynamic at 12 bits */ Scale_sig( xn_fx, L_SUBFR, shift ); // Q_new - 1 + shift } -#ifdef USE_UC_EVS - else + ELSE +#endif { + find_targets_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq_fx, res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx ); - /*Copy_Scale_sig(h1_fx, h2_fx, L_SUBFR, -2);*/ + Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, -2 ); Scale_sig( h1_fx, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */ /* scaling of xn[] to limit dynamic at 12 bits */ Scale_sig( xn_fx, L_SUBFR, shift ); } -#endif /*----------------------------------------------------------------* * Unvoiced subframe processing *----------------------------------------------------------------*/ diff --git a/lib_enc/find_tar_fx.c b/lib_enc/find_tar_fx.c index 989f309d2..66b61309b 100644 --- a/lib_enc/find_tar_fx.c +++ b/lib_enc/find_tar_fx.c @@ -65,6 +65,18 @@ void find_targets_fx( *--------------------------------------------------------------*/ IF( cn != NULL ) { +#ifdef REUSE_EVS_ACELP + /* first half: xn[] --> cn[] */ + temp[0] = 0; + move16(); + preemph_copy_fx( xn, cn, tilt_fac, L_subfr / 2, temp ); + syn_filt_s_lc_fx( 1, Ap, cn, temp, L_subfr / 2 ); /* Q-1 -> Q-2 */ + Residu3_lc_fx( p_Aq, M, temp, cn, L_subfr / 2, 1 ); /* Q-2 -> Q-1 */ + Scale_sig( cn, L_subfr / 2, 1 ); + + /* second half: res[] --> cn[] (approximated and faster) */ + Copy( &res[i_subfr + ( L_subfr / 2 )], cn + ( L_subfr / 2 ), L_subfr / 2 ); /* Q_new */ +#else /* first half: xn[] --> cn[] */ temp[0] = 0; move16(); @@ -75,6 +87,7 @@ void find_targets_fx( /* second half: res[] --> cn[] (approximated and faster) */ Copy( &res[i_subfr + ( L_SUBFR / 2 )], cn + ( L_SUBFR / 2 ), L_SUBFR / 2 ); /* Q_new */ +#endif } /*---------------------------------------------------------------* diff --git a/lib_enc/gain_enc_fx.c b/lib_enc/gain_enc_fx.c index 457b8d24f..6e12deb4f 100644 --- a/lib_enc/gain_enc_fx.c +++ b/lib_enc/gain_enc_fx.c @@ -464,7 +464,7 @@ void gain_enc_mless_fx( case 6: { qua_table = gain_qua_mless_6b_fx; -#ifdef REUSE_EVS_ACELP +#if defined REUSE_EVS_ACELP || defined REUSE_EVS_ACELP_TC if ( element_mode > EVS_MONO ) { qua_table = gain_qua_mless_6b_stereo_fx; -- GitLab From 403d9e5ccffc60f9e67f95937ae0b203b4d47376 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Thu, 5 Jun 2025 14:35:47 -0400 Subject: [PATCH 19/20] remove unused --- lib_enc/enc_pit_exc_fx.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index 5c2f7304a..fd32f05bb 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -573,7 +573,9 @@ void enc_pit_exc_ivas_fx( Word16 use_fcb; Word32 gc_mem[NB_SUBFR - 1]; /* gain_code from previous subframes */ Word16 gp_mem[NB_SUBFR - 1]; /* gain_pitch from previous subframes*/ +#ifdef USE_NEW_TARGET Word16 q_h1; +#endif BSTR_ENC_HANDLE hBstr = st_fx->hBstr; GSC_ENC_HANDLE hGSCEnc = st_fx->hGSCEnc; LPD_state_HANDLE hLPDmem = st_fx->hLPDmem; -- GitLab From 1589c5e0c97f9cb2d8c788985b25d87592ae2260 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Thu, 5 Jun 2025 14:36:53 -0400 Subject: [PATCH 20/20] fix clang --- lib_enc/enc_pit_exc_fx.c | 2 +- lib_enc/enc_tran_fx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index fd32f05bb..e031e1f79 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -721,7 +721,7 @@ void enc_pit_exc_ivas_fx( * Compute impulse response, h1[], of weighted synthesis filter *----------------------------------------------------------------*/ Copy( &res[i_subfr], &exc[i_subfr], L_subfr ); /* Q_new */ - /* condition on target (compared to float) has been put outside the loop */ + /* condition on target (compared to float) has been put outside the loop */ #ifdef USE_NEW_TARGET find_targets_ivas_fx( speech, hGSCEnc->mem_syn_tmp_fx, i_subfr, &hGSCEnc->mem_w0_tmp_fx, p_Aq, res, L_subfr, p_Aw, st_fx->preemph_fac, xn, cn, h1 ); diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c index 4677c9ffe..e6d27ab5b 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -169,7 +169,7 @@ Word16 encod_tran_fx( { Word16 q_h1; find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, - res_fx, L_SUBFR, p_Aw, st_fx->preemph_fac, xn, cn, h1 ); + res_fx, L_SUBFR, p_Aw, st_fx->preemph_fac, xn, cn, h1 ); q_h1 = sub( 14, norm_s( h1[0] ) ); Copy_Scale_sig( h1, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/ Scale_sig( h1, L_SUBFR, add( sub( 14, q_h1 ), shift ) ); -- GitLab