From 8eaac72a4e03c07fb48e6c2815b36013006c4044 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 12 Aug 2025 13:44:57 -0400 Subject: [PATCH 01/18] First version of BE changes --- lib_com/options.h | 14 ++ lib_enc/acelp_core_switch_enc_fx.c | 37 +++++- lib_enc/avq_cod_fx.c | 56 +++++++- lib_enc/cod2t32_fx.c | 6 +- lib_enc/cod4t64_fx.c | 13 +- lib_enc/enc_acelp_fx.c | 32 ++++- lib_enc/enc_acelpx_fx.c | 76 ++++++++++- lib_enc/enc_amr_wb_fx.c | 6 +- lib_enc/enc_gen_voic_fx.c | 57 ++++++++- lib_enc/enc_higher_acelp_fx.c | 6 +- lib_enc/enc_pit_exc_fx.c | 41 +++++- lib_enc/enc_tran_fx.c | 24 ++++ lib_enc/enc_uv_fx.c | 6 + lib_enc/gain_enc_fx.c | 44 ++++++- lib_enc/gaus_enc_fx.c | 17 ++- lib_enc/inov_enc_fx.c | 97 +++++++++++++- lib_enc/ivas_td_low_rate_enc_fx.c | 21 ++- lib_enc/lp_exc_e_fx.c | 3 +- lib_enc/pit_enc_fx.c | 197 ++++++++++++++++++++++++++--- lib_enc/prot_fx_enc.h | 86 +++++++++---- lib_enc/transition_enc_fx.c | 195 +++++++++++++++++++++++----- 21 files changed, 904 insertions(+), 130 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 62bccdca6..75427a07e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -91,6 +91,20 @@ #define FIX_1822 #define FIX_ISSUE_1764 /* NTT: update renorm and use abs */ +//#define EVS_BE_REUSAGE +#ifdef EVS_BE_REUSAGE +#define REUSE_EVS_BE_ACELP_LP_FILT +#define REUSE_EVS_BE_ACELP_4T64 +#define REUSE_EVS_BE_ACELP_2t32 +#define REUSE_EVS_BE_ACELP_1t64 +#define REUSE_EVS_BE_ACELP_AVQ +#define REUSE_EVS_BE_GAUSS +#define REUSE_EVS_BE_GAINQ +#define REUSE_EVS_BE_ACELP_PITCH +#define REUSE_EVS_BE_ACELP_PITCH_PIT_Q +#define REUSE_EVS_BE_GAINQ_LBR // BE by adding one condition, but could be harmonized in a non-BE way. There is a small difference in how Etot is computed + +#endif #define FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW /* FhG: bit-exact, replace carry and overflow operations by 64-bit operations, MR 1931 */ #define FIX_1844_MISSING_FREE /* FhG: add missing free in ivas_binRenderer_convModuleClose_fx() */ diff --git a/lib_enc/acelp_core_switch_enc_fx.c b/lib_enc/acelp_core_switch_enc_fx.c index 2f2efef0f..f389bb0b7 100644 --- a/lib_enc/acelp_core_switch_enc_fx.c +++ b/lib_enc/acelp_core_switch_enc_fx.c @@ -412,7 +412,11 @@ static void encod_gen_voic_core_switch_fx( *----------------------------------------------------------------*/ set16_fx( dummyF, -1, NB_SUBFR16k ); /* hack to signal ACELP->HQ switching frame */ pitch = pit_encode_fx( hBstr, - st_fx->acelp_cfg.pitch_bits, core_bitrate, 0, L_frame, GENERIC, &pitch_limit_flag, 0, exc, L_SUBFR, T_op, &T0_min, &T0_max, &T0, &T0_frac, h1, xn, 0 /*hStereoTD->tdm_Pitch_reuse_flag*/, dummyF /*hStereoTD->tdm_Pri_pitch_buf*/ ); /* Q6 */ + st_fx->acelp_cfg.pitch_bits, core_bitrate, 0, L_frame, GENERIC, &pitch_limit_flag, 0, exc, L_SUBFR, T_op, &T0_min, &T0_max, &T0, &T0_frac, h1, xn, 0 /*hStereoTD->tdm_Pitch_reuse_flag*/, dummyF /*hStereoTD->tdm_Pri_pitch_buf*/ +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , st_fx->element_mode, Q_new +#endif + ); /* Q6 */ /*-----------------------------------------------------------------* * Find adaptive exitation @@ -618,10 +622,17 @@ static void encod_gen_voic_core_switch_ivas_fx( * Adaptive exc. construction *----------------------------------------------------------------*/ set16_fx( dummyF, -1, NB_SUBFR16k ); /* hack to signal ACELP->HQ switching frame */ - +#ifndef REUSE_EVS_BE_ACELP_PITCH pitch = pit_encode_ivas_fx( hBstr, st_fx->acelp_cfg.pitch_bits, core_bitrate, 0, L_frame, GENERIC, &pitch_limit_flag, 0, exc, L_SUBFR, T_op, &T0_min, &T0_max, &T0, &T0_frac, h1, xn, 0 /*hStereoTD->tdm_Pitch_reuse_flag*/, dummyF /*hStereoTD->tdm_Pri_pitch_buf*/, Q_new ); /* Q6 */ - +#else + pitch = pit_encode_fx( hBstr, + st_fx->acelp_cfg.pitch_bits, core_bitrate, 0, L_frame, GENERIC, &pitch_limit_flag, 0, exc, L_SUBFR, T_op, &T0_min, &T0_max, &T0, &T0_frac, h1, xn, 0 /*hStereoTD->tdm_Pitch_reuse_flag*/, dummyF /*hStereoTD->tdm_Pri_pitch_buf*/ +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , st_fx->element_mode, Q_new +#endif + ); /* Q6 */ +#endif /*-----------------------------------------------------------------* * Find adaptive exitation *-----------------------------------------------------------------*/ @@ -640,8 +651,11 @@ static void encod_gen_voic_core_switch_ivas_fx( *-----------------------------------------------------------------*/ lp_flag = st_fx->acelp_cfg.ltf_mode; /* Q0 */ Scale_sig( h1, L_SUBFR, sub( 14, q_h1 ) ); /* set h1[] in Q14 with scaling for convolution Q14+shift*/ +#ifdef REUSE_EVS_BE_ACELP_LP_FILT + lp_select = lp_filt_exc_enc_fx( MODE1, GENERIC, 0, exc, h1, xn, y1, xn2, L_SUBFR, L_frame, g_corr, clip_gain, &gain_pit, &lp_flag ); /* Q0 */ +#else lp_select = lp_filt_exc_enc_ivas_fx( MODE1, GENERIC, 0, exc, h1, xn, y1, xn2, L_SUBFR, 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 ); @@ -657,6 +671,7 @@ static void encod_gen_voic_core_switch_ivas_fx( /*-----------------------------------------------------------------* * Gain encoding *-----------------------------------------------------------------*/ +#ifndef REUSE_EVS_BE_GAINQ IF( EQ_16( L_frame, L_FRAME ) ) { gain_enc_mless_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_frame, 0, -1, xn, y1, shift_wsp, y2, code, st_fx->old_Es_pred_fx, @@ -667,7 +682,18 @@ static void encod_gen_voic_core_switch_ivas_fx( gain_enc_mless_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_frame, 0, -1, xn, y1, shift_wsp, y2, code, st_fx->old_Es_pred_fx, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain ); } - +#else + IF( EQ_16( L_frame, L_FRAME ) ) + { + gain_enc_mless_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_frame, 0, -1, xn, y1, shift_wsp, y2, code, st_fx->old_Es_pred_fx, + &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain ); + } + ELSE + { + gain_enc_mless_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_frame, 0, -1, xn, y1, shift_wsp, y2, code, st_fx->old_Es_pred_fx, + &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain ); + } +#endif gp_clip_test_gain_pit_fx( st_fx->element_mode, core_bitrate, gain_pit, st_fx->clip_var_fx ); Lgcode = L_shl( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ @@ -713,7 +739,6 @@ static void encod_gen_voic_core_switch_ivas_fx( return; } - /*-------------------------------------------------------------------* * bwe_switch_enc() * diff --git a/lib_enc/avq_cod_fx.c b/lib_enc/avq_cod_fx.c index b3a49c59e..8d08dcb4f 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_BE_ACELP_AVQ + 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_BE_ACELP_AVQ + 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_BE_ACELP_AVQ // 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_BE_ACELP_AVQ + 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_BE_ACELP_AVQ + 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_BE_ACELP_AVQ + 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 ) @@ -558,7 +608,7 @@ void AVQ_encmux_fx( return; } - +#ifndef REUSE_EVS_BE_ACELP_AVQ void AVQ_encmux_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ const Word16 extl, /* i : extension layer */ @@ -985,7 +1035,7 @@ void AVQ_encmux_ivas_fx( return; } - +#endif /*-------------------------------------------------------------------* * Function AVQ_cod_lpc_fx() * * * diff --git a/lib_enc/cod2t32_fx.c b/lib_enc/cod2t32_fx.c index dc967e656..e37616182 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_BE_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_BE_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 diff --git a/lib_enc/cod4t64_fx.c b/lib_enc/cod4t64_fx.c index 457a129b8..c4e7c9b6b 100644 --- a/lib_enc/cod4t64_fx.c +++ b/lib_enc/cod4t64_fx.c @@ -66,6 +66,10 @@ Word16 acelp_4t64_fx( Word16 nbbits, /* i : number of bits per codebook */ const Word16 cmpl_flag, /* i : complexity reduction flag */ const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */ +#ifdef REUSE_EVS_BE_ACELP_4T64 + , + const Word16 element_mode +#endif ) { @@ -299,8 +303,11 @@ Word16 acelp_4t64_fx( IF( acelpautoc ) { +#ifdef REUSE_EVS_BE_ACELP_4T64 + E_ACELP_4tsearchx_fx( dn, cn, R, code, &config, ind, element_mode ); +#else E_ACELP_4tsearchx_fx( dn, cn, R, code, &config, ind ); - +#endif /* Generate weighted code */ E_ACELP_weighted_code( code, H, 12, y ); } @@ -468,7 +475,7 @@ Word16 acelp_4t64_fx( return saved_bits; } - +#ifndef REUSE_EVS_BE_ACELP_4T64 Word16 acelp_4t64_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ Word16 dn[], /* i : corr. between target and h[]. */ @@ -882,7 +889,7 @@ Word16 acelp_4t64_ivas_fx( return saved_bits; } - +#endif /*---------------------------------------------------------------------* *encode class for 3p 4p 5p 6p/track * *---------------------------------------------------------------------*/ diff --git a/lib_enc/enc_acelp_fx.c b/lib_enc/enc_acelp_fx.c index f6a8e65b2..85c0a39b7 100644 --- a/lib_enc/enc_acelp_fx.c +++ b/lib_enc/enc_acelp_fx.c @@ -1147,7 +1147,13 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const scale = -2; move16(); } - +#ifdef REUSE_EVS_BE_ACELP_4T64 /* 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 ); @@ -1390,7 +1396,7 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const } return; } - +#ifndef REUSE_EVS_BE_ACELP_4T64 void E_ACELP_4tsearch_ivas_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const Word16 H[] /*Q12*/, Word16 code[] /*Q9*/, const PulseConfig *config, Word16 ind[] /*Q0*/, Word16 y[] /*Qy*/ ) { Word16 sign[L_SUBFR], vec[L_SUBFR]; @@ -1715,7 +1721,7 @@ void E_ACELP_4tsearch_ivas_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, } return; } - +#endif /* * E_ACELP_4t_fx * @@ -1763,7 +1769,12 @@ void E_ACELP_4t_fx( const Word16 last_L_frame, /*Q0*/ const Word32 total_brate, /*Q0*/ const Word16 i_subfr, /*Q0*/ - const Word16 cmpl_flag /*Q0*/ ) + const Word16 cmpl_flag /*Q0*/ +#ifdef REUSE_EVS_BE_ACELP_4T64 + , + const Word16 element_mode /*Q0*/ +#endif +) { PulseConfig config; Word16 ind[NPMAXPT * 4]; @@ -1803,7 +1814,11 @@ void E_ACELP_4t_fx( IF( acelpautoc ) { +#ifndef REUSE_EVS_BE_ACELP_4T64 E_ACELP_4tsearchx_fx( dn, cn, R, code, &config, ind ); +#else + E_ACELP_4tsearchx_fx( dn, cn, R, code, &config, ind, element_mode ); +#endif } ELSE { @@ -1812,7 +1827,7 @@ void E_ACELP_4t_fx( E_ACELP_indexing_fx( code, &config, NB_TRACK_FCB_4T, _index ); return; } - +#ifndef REUSE_EVS_BE_ACELP_4T64 void E_ACELP_4t_ivas_fx( Word16 dn[], /*Qdn*/ Word16 cn[] /* Q_xn */, @@ -1876,7 +1891,7 @@ void E_ACELP_4t_ivas_fx( E_ACELP_indexing_fx( code, &config, NB_TRACK_FCB_4T, _index ); return; } - +#endif static void E_ACELP_indexing_shift( Word16 wordcnt, /* i: 16-bit word count including the newly shifted-in bits Q0*/ Word16 shift_bits, /* i: number of bits to shift in from the lsb Q0*/ @@ -2299,8 +2314,11 @@ void E_ACELP_innovative_codebook_fx( /* Innovative codebook search */ assert( acelp_cfg->fixed_cdk_index[idx] < ACELP_FIXED_CDK_NB ); +#ifdef REUSE_EVS_BE_ACELP_4T64 + E_ACELP_4t_fx( dn, cn2, h2, Rw2, acelpautoc, code, acelp_cfg->fixed_cdk_index[idx], *pt_indice, L_frame, last_L_frame, total_brate, i_subfr, 0, 0 ); +#else E_ACELP_4t_fx( dn, cn2, h2, Rw2, acelpautoc, code, acelp_cfg->fixed_cdk_index[idx], *pt_indice, L_frame, last_L_frame, total_brate, i_subfr, 0 ); - +#endif *pt_indice += 8; /* Generate weighted code */ diff --git a/lib_enc/enc_acelpx_fx.c b/lib_enc/enc_acelpx_fx.c index 1a17a0f9c..e67e4add4 100644 --- a/lib_enc/enc_acelpx_fx.c +++ b/lib_enc/enc_acelpx_fx.c @@ -367,7 +367,12 @@ void E_ACELP_4tsearchx_fx( Word16 Rw[], /*Q9*/ Word16 code[], /*Q9*/ const PulseConfig *config, - Word16 ind[] /*Q0*/ ) + Word16 ind[] /*Q0*/ +#ifdef REUSE_EVS_BE_ACELP_4T64 + , + const Word16 element_mode +#endif +) { Word16 sign[L_SUBFR], vec[L_SUBFR]; Word16 cor[L_SUBFR]; @@ -383,6 +388,11 @@ void E_ACELP_4tsearchx_fx( Word16 scale; Word16 sign_val_1, sign_val_2; Word16 nb_pulse, nb_pulse_m2; +#ifdef REUSE_EVS_BE_ACELP_4T64 + Word16 psk = 0; + Word16 val, index, track; + move16(); +#endif move16(); move16(); @@ -553,7 +563,15 @@ void E_ACELP_4tsearchx_fx( &ind[j], dn, cor, sign, sign_val_1 ); } - +#ifdef REUSE_EVS_BE_ACELP_4T64 + 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 ); } @@ -568,6 +586,10 @@ void E_ACELP_4tsearchx_fx( { ps2k = ps2; move16(); +#ifdef REUSE_EVS_BE_ACELP_4T64 + psk = ps; + move16(); +#endif alpk = alp; move16(); Copy( ind, codvec, nb_pulse ); /* Q0 */ @@ -578,9 +600,56 @@ void E_ACELP_4tsearchx_fx( /* * Store weighted energy of code, build the codeword and index of codevector. */ +#ifdef REUSE_EVS_BE_ACELP_4T64 + IF( EQ_16( element_mode, EVS_MONO ) ) +#endif + { E_ACELP_build_code( nb_pulse, codvec, sign, code, ind ); -} + } +#ifdef REUSE_EVS_BE_ACELP_4T64 + ELSE + { + /* Store weighted energy of code, build the codeword and index of codevector. */ + set16_fx( code, 0, L_SUBFR ); + set16_fx( ind, -1, NPMAXPT * 4 ); + FOR( k = 0; k < config->nb_pulse; k++ ) + { + i = codvec[k]; /* read pulse position Q0*/ + move16(); + val = sign[i]; /* read sign Q13*/ + move16(); + + index = shr( i, 2 ); /* pos of pulse (0..15) */ + // track = i % 4; + track = s_and( i, 3 ); + IF( L_mult0( val, psk ) > 0 ) + { + code[i] = add( code[i], ONE_IN_Q9 /*1.0f*/ ); /* Q9 */ + move16(); + codvec[k] = add( codvec[k], 2 * L_SUBFR ); /* Q0 */ + move16(); + } + ELSE + { + code[i] = sub( code[i], ONE_IN_Q9 /*1.0f*/ ); /* Q9 */ + move16(); + index = add( index, 16 ); /* Q0 */ + } + + i = imult1616( track, NPMAXPT ); + WHILE( ind[i] >= 0 ) + { + i++; + } + + ind[i] = index; + move16(); + } + } +#endif +} +#ifndef REUSE_EVS_BE_ACELP_4T64 void E_ACELP_4tsearchx_ivas_fx( Word16 dn[], /*Qdn*/ const Word16 cn[], /*Q_new*/ @@ -856,3 +925,4 @@ void E_ACELP_4tsearchx_ivas_fx( } } } +#endif \ No newline at end of file diff --git a/lib_enc/enc_amr_wb_fx.c b/lib_enc/enc_amr_wb_fx.c index 4c5268017..9707f565f 100644 --- a/lib_enc/enc_amr_wb_fx.c +++ b/lib_enc/enc_amr_wb_fx.c @@ -146,7 +146,11 @@ void encod_amr_wb_fx( *----------------------------------------------------------------*/ *pt_pitch = pit_encode_fx( hBstr, st->acelp_cfg.pitch_bits, st->core_brate, 1, L_FRAME, -1, &pitch_limit_flag, i_subfr, exc, - L_SUBFR, T_op, &T0_min, &T0_max, &T0, &T0_frac, h1, xn, 0 /*hStereoTD->tdm_Pitch_reuse_flag*/, NULL /*hStereoTD->tdm_Pri_pitch_buf*/ ); + L_SUBFR, T_op, &T0_min, &T0_max, &T0, &T0_frac, h1, xn, 0 /*hStereoTD->tdm_Pitch_reuse_flag*/, NULL /*hStereoTD->tdm_Pri_pitch_buf*/ +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , 0, Q_new +#endif + ); /*-----------------------------------------------------------------* * Find adaptive exitation diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index 4595dc206..ea1efd6dd 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -230,8 +230,11 @@ void encod_gen_voic_fx( 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 */ - + 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 +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , st_fx->element_mode, Q_new +#endif + ); /* Q6 */ tbe_celp_exc( L_frame, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx ); /*-----------------------------------------------------------------* @@ -294,7 +297,11 @@ void encod_gen_voic_fx( IF( LE_32( st_fx->core_brate, ACELP_8k00 ) ) { gain_enc_lbr_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->coder_type, i_subfr_fx, xn_fx, y1_fx, shift_wsp, y2_fx, code_fx, - &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, gc_mem, gp_mem, clip_gain_fx, L_SUBFR ); + &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, gc_mem, gp_mem, clip_gain_fx, L_SUBFR +#ifdef REUSE_EVS_BE_GAINQ_LBR + , st_fx->element_mode +#endif + ); } ELSE IF( GT_32( st_fx->core_brate, ACELP_32k ) ) { @@ -598,8 +605,17 @@ void encod_gen_voic_ivas_fx( rem_offset( cn_fx, cn_fx, L_SUBFR ); } #endif +#ifndef REUSE_EVS_BE_ACELP_PITCH *pt_pitch_fx = pit_encode_ivas_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, Q_new ); /* Q6 */ +#else + *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 +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , st_fx->element_mode, Q_new +#endif + ); /* Q6 */ +#endif move16(); 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 ); @@ -626,9 +642,13 @@ void encod_gen_voic_ivas_fx( /*-----------------------------------------------------------------* * LP filtering of the adaptive excitation, codebook target computation *-----------------------------------------------------------------*/ - +#ifndef REUSE_EVS_BE_ACELP_LP_FILT lp_select = lp_filt_exc_enc_ivas_fx( MODE1, st_fx->coder_type, i_subfr_fx, exc_fx, h1_fx, xn_fx, y1_fx, xn2_fx, L_SUBFR, L_frame, g_corr_fx, clip_gain_fx, &gain_pit_fx, &lp_flag ); +#else + lp_select = lp_filt_exc_enc_fx( MODE1, st_fx->coder_type, i_subfr_fx, exc_fx, h1_fx, + xn_fx, y1_fx, xn2_fx, L_SUBFR, L_frame, g_corr_fx, clip_gain_fx, &gain_pit_fx, &lp_flag ); +#endif IF( EQ_16( lp_flag, NORMAL_OPERATION ) ) { @@ -657,7 +677,7 @@ void encod_gen_voic_ivas_fx( /*-----------------------------------------------------------------* * Gain encoding *-----------------------------------------------------------------*/ - +#ifndef REUSE_EVS_BE_GAINQ IF( LE_32( st_fx->core_brate, ACELP_8k00 ) ) { gain_enc_lbr_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->coder_type, i_subfr_fx, xn_fx, y1_fx, shift_wsp, y2_fx, code_fx, @@ -673,6 +693,33 @@ void encod_gen_voic_ivas_fx( gain_enc_mless_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_frame, i_subfr_fx, -1, xn_fx, y1_fx, shift_wsp, y2_fx, code_fx, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, clip_gain_fx ); } +#else + IF( LE_32( st_fx->core_brate, ACELP_8k00 ) ) + { +#ifndef REUSE_EVS_BE_GAINQ_LBR + gain_enc_lbr_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->coder_type, i_subfr_fx, xn_fx, y1_fx, shift_wsp, y2_fx, code_fx, + &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, gc_mem, gp_mem, clip_gain_fx, L_SUBFR ); +#else + gain_enc_lbr_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->coder_type, i_subfr_fx, xn_fx, y1_fx, shift_wsp, y2_fx, code_fx, + &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, gc_mem, gp_mem, clip_gain_fx, L_SUBFR +#ifdef REUSE_EVS_BE_GAINQ_LBR + , + st_fx->element_mode +#endif + ); +#endif + } + ELSE IF( GT_32( st_fx->core_brate, ACELP_32k ) ) + { + gain_enc_SQ_fx( hBstr, st_fx->acelp_cfg.gains_mode, i_subfr_fx, xn_fx, y1_fx, y2_fx, code_fx, Es_pred_fx, + &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, clip_gain_fx, shift_wsp ); + } + ELSE + { + gain_enc_mless_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_frame, i_subfr_fx, -1, xn_fx, y1_fx, shift_wsp, y2_fx, code_fx, Es_pred_fx, + &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, clip_gain_fx ); + } +#endif IF( st_fx->Opt_SC_VBR ) { if ( EQ_16( hSC_VBR->last_ppp_mode, 1 ) ) diff --git a/lib_enc/enc_higher_acelp_fx.c b/lib_enc/enc_higher_acelp_fx.c index 00b18f79d..986bdde0b 100644 --- a/lib_enc/enc_higher_acelp_fx.c +++ b/lib_enc/enc_higher_acelp_fx.c @@ -616,9 +616,11 @@ void transf_cdbk_enc_ivas_fx( move16(); move16(); } - +#ifndef REUSE_EVS_BE_ACELP_AVQ AVQ_encmux_ivas_fx( st_fx->hBstr, -1, x_norm, &nBits, Nsv, nq, avq_bit_sFlag, trgtSvPos ); - +#else + AVQ_encmux_fx( st_fx->hBstr, -1, x_norm, &nBits, Nsv, nq, avq_bit_sFlag, trgtSvPos ); +#endif /* save # of AVQ unused bits for next subframe */ *unbits = nBits; move16(); diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index 5f173cd7f..0e078de35 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -263,7 +263,11 @@ void enc_pit_exc_fx( * Adaptive exc. construction *----------------------------------------------------------------*/ *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 +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , st_fx->element_mode, Q_new +#endif + ); /* Q6 */ /*-----------------------------------------------------------------* * Find adaptive exitation *-----------------------------------------------------------------*/ @@ -328,7 +332,11 @@ void enc_pit_exc_fx( * 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 ); + 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 +#ifdef REUSE_EVS_BE_GAINQ_LBR + , st_fx->element_mode +#endif + ); } ELSE { @@ -738,10 +746,18 @@ void enc_pit_exc_ivas_fx( * Close-loop pitch search and quantization * Adaptive exc. construction *----------------------------------------------------------------*/ - +#ifndef REUSE_EVS_BE_ACELP_PITCH *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(); +#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 +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , st_fx->element_mode, Q_new +#endif + ); /* Q6 */ +#endif Scale_sig( h1, L_subfr, sub( 14, q_h1 ) ); /* set h1[] in Q14 with scaling for convolution Q14*/ /*-----------------------------------------------------------------* @@ -760,8 +776,13 @@ void enc_pit_exc_ivas_fx( * Codebook target computation * (No LP filtering of the adaptive excitation) *-----------------------------------------------------------------*/ +#ifndef REUSE_EVS_BE_ACELP_LP_FILT 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 ); @@ -805,7 +826,16 @@ void enc_pit_exc_ivas_fx( * Gain encoding *-----------------------------------------------------------------*/ +#ifndef REUSE_EVS_BE_GAINQ_LBR 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 + gain_enc_lbr_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 +#ifdef REUSE_EVS_BE_GAINQ_LBR + , st_fx->element_mode +#endif + ); +#endif + } ELSE { @@ -818,8 +848,13 @@ void enc_pit_exc_ivas_fx( /*-----------------------------------------------------------------* * Gain encoding *-----------------------------------------------------------------*/ +#ifndef REUSE_EVS_BE_GAINQ gain_enc_mless_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, st_fx->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 + gain_enc_mless_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, st_fx->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 ); +#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 fb601aeba..dc624e820 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -587,6 +587,7 @@ Word16 encod_tran_ivas_fx( * Test quantized gain of pitch for pitch clipping algorithm * Update tilt of code: 0.0 (unvoiced) to 0.5 (voiced) *-----------------------------------------------------------------*/ +#ifndef REUSE_EVS_BE_GAINQ IF( Jopt_flag == 0 ) { /* SQ gain_code */ @@ -608,6 +609,29 @@ Word16 encod_tran_ivas_fx( &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain ); } } +#else + IF( Jopt_flag == 0 ) + { + /* SQ gain_code */ + gain_enc_tc_fx( hBstr, st_fx->acelp_cfg.gains_mode, i_subfr, xn, y2, code, Es_pred_fx, + &gain_pit, &gain_code, &gain_inov, &norm_gain_code, shift_wsp ); + } + ELSE + { + IF( GT_32( st_fx->core_brate, ACELP_32k ) ) + { + /* SQ gain_pit and gain_code */ + gain_enc_SQ_fx( hBstr, st_fx->acelp_cfg.gains_mode, i_subfr, xn, y1, y2, code, Es_pred_fx, + &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain, shift_wsp ); + } + ELSE + { + /* VQ gain_pit and gain_code */ + gain_enc_mless_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_frame_fx, i_subfr, tc_subfr, xn, y1, shift_wsp, y2, code, Es_pred_fx, + &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 ); Lgcode = L_shl_o( gain_code, Q_new, &Overflow ); /* scaled gain_code with Qnew -> Q16*/ diff --git a/lib_enc/enc_uv_fx.c b/lib_enc/enc_uv_fx.c index 887b4afb8..8600c0043 100644 --- a/lib_enc/enc_uv_fx.c +++ b/lib_enc/enc_uv_fx.c @@ -331,9 +331,15 @@ void encod_unvoiced_ivas_fx( *----------------------------------------------------------------*/ IF( !uc_two_stage_flag ) { +#ifndef REUSE_EVS_BE_GAUSS *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 diff --git a/lib_enc/gain_enc_fx.c b/lib_enc/gain_enc_fx.c index 5e2a11169..7375331f1 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_BE_GAINQ if ( element_mode > EVS_MONO ) { + qua_table = gain_qua_mless_6b_stereo_fx; } +#endif move16(); if ( EQ_16( clip_gain, 1 ) ) { @@ -521,7 +524,7 @@ void gain_enc_mless_fx( return; } - +#ifndef REUSE_EVS_BE_GAINQ void gain_enc_mless_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 gains_mode[], /* i : gain bits Q0*/ @@ -851,7 +854,7 @@ void gain_enc_mless_ivas_fx( return; } - +#endif /*---------------------------------------------------------------------* * gain_enc_SQ() * @@ -1136,7 +1139,7 @@ void gain_enc_SQ_fx( return; } - +#ifndef REUSE_EVS_BE_GAINQ void gain_enc_SQ_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 gains_mode[], /* i : gain bits Q0*/ @@ -1412,7 +1415,7 @@ void gain_enc_SQ_ivas_fx( return; } - +#endif /*-------------------------------------------------------------------* * gain_enc_gaus() * @@ -1658,7 +1661,7 @@ void gain_enc_tc_fx( move32(); return; } - +#ifndef REUSE_EVS_BE_GAINQ void gain_enc_tc_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 gains_mode[], /* i : gain bits Q0*/ @@ -1841,6 +1844,7 @@ void gain_enc_tc_ivas_fx( move32(); return; } +#endif /*-----------------------------------------------------------------* * Find_Opt_gainQ_fx() * @@ -2018,6 +2022,10 @@ void gain_enc_lbr_fx( Word16 gp_mem[], /* i/o: gain_pitch from previous subframes Q14*/ const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/ const Word16 L_subfr /* i : subframe length Q0*/ +#ifdef REUSE_EVS_BE_GAINQ_LBR + , + const Word16 element_mode /* i : mode element Q0*/ +#endif ) { @@ -2083,7 +2091,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_BE_GAINQ + *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(); @@ -2151,12 +2163,29 @@ void gain_enc_lbr_fx( gcode0 = (float)pow(10, dotp(b, aux, n_pred) - 0.05f * 10 * (float)log10(Ecode)); gcode0 = (float)pow(10, 0.05(20 * dotp(b, aux, n_pred) - 10 * (float)log10(Ecode))); */ +#ifdef REUSE_EVS_BE_GAINQ_LBR + IF( element_mode > EVS_MONO ) + { + // Ecode = (Ecode / L_subfr) + L_tmp = L_shr( L_tmp, L_subfr_sf ); // Q19 + (Q30-exp_code) + /* Calculation for log10(Ecode) exponent for applying log10 = Q31 - q = Q31 - Q19 - Q30 + exp_code = exp_code - Q18*/ + L_tmp = BASOP_Util_Log10( L_tmp, sub( exp_code, 18 ) ); // new q = Q25 + exp = norm_l( L_tmp ); + L_tmp = L_shl( L_tmp, exp ); // Q25 + exp + // 10 in Q27 , ( 10 * log10( Ecode ) ) + L_tmp1 = Mpy_32_32( L_tmp, 1342177280 ); // Q25 + exp + 1 + Q27 - 32 = Q21 + exp + L_tmp1 = L_shr( L_tmp1, add( 7, exp ) ); // Q21 + exp - 7 - exp = Q14 + + } + ELSE +#endif + { exp_code = sub( exp_code, 18 + 6 + 1 ); exp = norm_l( L_tmp ); frac = Log2_norm_lc( L_shl( L_tmp, exp ) ); exp = sub( exp_code, exp ); L_tmp1 = Mpy_32_16( exp, frac, 24660 ); /* Q14 */ /* 10*log10(2) in Q13*/ - + } L_tmp = Dot_product( b, aux, n_pred ); /*Q25*/ L_tmp = Mult_32_16( L_tmp, 320 ); /*Q14, 20 in Q4*/ L_tmp = L_sub( L_tmp, L_tmp1 ); /*Q14*/ @@ -2442,7 +2471,7 @@ void gain_enc_lbr_fx( } return; } - +#ifndef REUSE_EVS_BE_GAINQ_LBR void gain_enc_lbr_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 gains_mode[], /* i : gain bits Q0*/ @@ -2892,6 +2921,7 @@ void gain_enc_lbr_ivas_fx( } return; } +#endif /*-------------------------------------------------------------------* * gain_enc_amr_wb() diff --git a/lib_enc/gaus_enc_fx.c b/lib_enc/gaus_enc_fx.c index b6ef2d84f..986f15bbc 100644 --- a/lib_enc/gaus_enc_fx.c +++ b/lib_enc/gaus_enc_fx.c @@ -26,9 +26,9 @@ static Word16 cod_2pos_fx( const Word16 ind1, const Word16 ind2, const Word16 sign1, const Word16 sign2, const Word16 n ); static void gauss2v_fx( BSTR_ENC_HANDLE hBstr, const Word16 h[], const Word16 xn[], const Word16 dn[], Word16 code[], Word16 y1[], Word32 *gain, const Word16 lg, const Word16 shift, const Word16 Q_new, const Word16 nb_bits ); - +#ifndef REUSE_EVS_BE_GAUSS static void gauss2v_ivas_fx( BSTR_ENC_HANDLE hBstr, const Word16 h[], const Word16 xn[], const Word16 dn[], Word16 code[], Word16 y1[], Word32 *gain, const Word16 lg, const Word16 shift, const Word16 Q_new, const Word16 nb_bits ); - +#endif /*-------------------------------------------------------------------* * Gaus_encode * @@ -134,7 +134,7 @@ Word16 gaus_encode_fx( return ( L_SUBFR << 6 ); } - +#ifndef REUSE_EVS_BE_GAUSS Word16 gaus_encode_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 i_subfr, /* i : subframe index Q0*/ @@ -176,9 +176,11 @@ Word16 gaus_encode_ivas_fx( tmp_idx = shr( i_subfr, 6 ); nb_bits = st_fx->acelp_cfg.fixed_cdk_index[tmp_idx]; /* Q0 */ move16(); - +#ifndef REUSE_EVS_BE_GAUSS gauss2v_ivas_fx( st_fx->hBstr, h1, xn, dn, code, y2, gain_code, L_SUBFR, shift, Q_new, shr( nb_bits, 1 ) ); - +#else + gauss2v_fx( st_fx->hBstr, h1, xn, dn, code, y2, gain_code, L_SUBFR, shift, Q_new, shr( nb_bits, 1 ) ); +#endif /*----------------------------------------------------------------* * Encode gaussian gain *----------------------------------------------------------------*/ @@ -232,6 +234,7 @@ Word16 gaus_encode_ivas_fx( return ( L_SUBFR << 6 ); } +#endif /*-------------------------------------------------------------------* * gauss2v() * @@ -700,7 +703,7 @@ void gauss2v_fx( return; } - +#ifndef REUSE_EVS_BE_GAUSS void gauss2v_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder state structure */ const Word16 h[], /* i : weighted LP filter impulse response Q15 */ @@ -1161,7 +1164,7 @@ void gauss2v_ivas_fx( return; } - +#endif /*---------------------------------------------------------------------* * Put selected codevector positions and signs into quantization index *---------------------------------------------------------------------*/ diff --git a/lib_enc/inov_enc_fx.c b/lib_enc/inov_enc_fx.c index 02ef25096..86200cb43 100644 --- a/lib_enc/inov_enc_fx.c +++ b/lib_enc/inov_enc_fx.c @@ -289,7 +289,11 @@ Word16 inov_encode_fx( } ELSE { +#ifndef REUSE_EVS_BE_ACELP_4T64 *unbits = add( *unbits, acelp_4t64_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, nBits, cmpl_flag, Opt_AMR_WB ) ); +#else + *unbits = add( *unbits, acelp_4t64_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, nBits, cmpl_flag, Opt_AMR_WB, st_fx->element_mode ) ); +#endif move16(); } } @@ -302,35 +306,67 @@ Word16 inov_encode_fx( } ELSE IF( ( EQ_32( core_brate, ACELP_8k85 ) ) ) { +#ifndef REUSE_EVS_BE_ACELP_4T64 acelp_4t64_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 20, cmpl_flag, Opt_AMR_WB ); +#else + acelp_4t64_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 20, cmpl_flag, Opt_AMR_WB, st_fx->element_mode ); +#endif } ELSE IF( EQ_32( core_brate, ACELP_12k65 ) ) { +#ifndef REUSE_EVS_BE_ACELP_4T64 acelp_4t64_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 36, cmpl_flag, Opt_AMR_WB ); +#else + acelp_4t64_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 36, cmpl_flag, Opt_AMR_WB, st_fx->element_mode ); +#endif } ELSE IF( EQ_32( core_brate, ACELP_14k25 ) ) { +#ifndef REUSE_EVS_BE_ACELP_4T64 acelp_4t64_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 44, cmpl_flag, Opt_AMR_WB ); +#else + acelp_4t64_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 44, cmpl_flag, Opt_AMR_WB, st_fx->element_mode ); +#endif } ELSE IF( EQ_32( core_brate, ACELP_15k85 ) ) { +#ifndef REUSE_EVS_BE_ACELP_4T64 acelp_4t64_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 52, cmpl_flag, Opt_AMR_WB ); +#else + acelp_4t64_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 52, cmpl_flag, Opt_AMR_WB, st_fx->element_mode ); +#endif } ELSE IF( EQ_32( core_brate, ACELP_18k25 ) ) { +#ifndef REUSE_EVS_BE_ACELP_4T64 acelp_4t64_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 64, cmpl_flag, Opt_AMR_WB ); +#else + acelp_4t64_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 64, cmpl_flag, Opt_AMR_WB, st_fx->element_mode ); +#endif } ELSE IF( EQ_32( core_brate, ACELP_19k85 ) ) { +#ifndef REUSE_EVS_BE_ACELP_4T64 acelp_4t64_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 72, cmpl_flag, Opt_AMR_WB ); +#else + acelp_4t64_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 72, cmpl_flag, Opt_AMR_WB, st_fx->element_mode ); +#endif } ELSE IF( EQ_32( core_brate, ACELP_23k05 ) ) { +#ifndef REUSE_EVS_BE_ACELP_4T64 acelp_4t64_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 88, cmpl_flag, Opt_AMR_WB ); +#else + acelp_4t64_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 88, cmpl_flag, Opt_AMR_WB, st_fx->element_mode ); +#endif } ELSE IF( EQ_32( core_brate, ACELP_23k85 ) ) { +#ifndef REUSE_EVS_BE_ACELP_4T64 acelp_4t64_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 88, 1, Opt_AMR_WB ); +#else + acelp_4t64_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 88, 1, Opt_AMR_WB, st_fx->element_mode ); +#endif } } @@ -620,7 +656,11 @@ Word16 inov_encode_ivas_fx( IF( EQ_16( nBits, 8 ) ) { +#ifndef REUSE_EVS_BE_ACELP_1t64 acelp_1t64_ivas_fx( hBstr, dn, h2, code, y2, L_subfr ); +#else + acelp_1t64_fx( hBstr, dn, h2, code, y2, L_subfr ); +#endif } ELSE { @@ -631,7 +671,11 @@ Word16 inov_encode_ivas_fx( { IF( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] == 0 ) { +#ifndef REUSE_EVS_BE_ACELP_1t64 acelp_1t64_ivas_fx( hBstr, dn, h2, code, y2, L_subfr ); +#else + acelp_1t64_fx( hBstr, dn, h2, code, y2, L_subfr ); +#endif } ELSE { @@ -640,8 +684,11 @@ Word16 inov_encode_ivas_fx( } ELSE { +#ifndef REUSE_EVS_BE_ACELP_4T64 E_ACELP_4t_ivas_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, st_fx->element_mode ); - +#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, st_fx->element_mode ); +#endif 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 ); @@ -692,15 +739,27 @@ Word16 inov_encode_ivas_fx( IF( EQ_16( nBits, 7 ) ) { +#ifndef REUSE_EVS_BE_ACELP_1t64 acelp_1t64_ivas_fx( hBstr, dn, h2, code, y2, L_SUBFR ); +#else + acelp_1t64_fx( hBstr, dn, h2, code, y2, L_SUBFR ); +#endif } ELSE IF( EQ_16( nBits, 12 ) ) { +#ifndef REUSE_EVS_BE_ACELP_2t32 acelp_2t32_ivas_fx( hBstr, dn, h2, code, y2 ); +#else + acelp_2t32_fx( hBstr, dn, h2, code, y2 ); +#endif } ELSE { +#ifndef REUSE_EVS_BE_ACELP_4T64 *unbits = add( *unbits, acelp_4t64_ivas_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, nBits, cmpl_flag, Opt_AMR_WB, st_fx->element_mode ) ); +#else + *unbits = add( *unbits, acelp_4t64_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, nBits, cmpl_flag, Opt_AMR_WB, st_fx->element_mode ) ); +#endif move16(); } } @@ -709,39 +768,75 @@ Word16 inov_encode_ivas_fx( { IF( EQ_32( core_brate, ACELP_6k60 ) ) { +#ifndef REUSE_EVS_BE_ACELP_2t32 acelp_2t32_ivas_fx( hBstr, dn, h2, code, y2 ); +#else + acelp_2t32_fx( hBstr, dn, h2, code, y2 ); +#endif } ELSE IF( ( EQ_32( core_brate, ACELP_8k85 ) ) ) { +#ifndef REUSE_EVS_BE_ACELP_4T64 acelp_4t64_ivas_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 20, cmpl_flag, Opt_AMR_WB, st_fx->element_mode ); +#else + acelp_4t64_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 20, cmpl_flag, Opt_AMR_WB, st_fx->element_mode ); +#endif } ELSE IF( EQ_32( core_brate, ACELP_12k65 ) ) { +#ifndef REUSE_EVS_BE_ACELP_4T64 acelp_4t64_ivas_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 36, cmpl_flag, Opt_AMR_WB, st_fx->element_mode ); +#else + acelp_4t64_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 36, cmpl_flag, Opt_AMR_WB, st_fx->element_mode ); +#endif } ELSE IF( EQ_32( core_brate, ACELP_14k25 ) ) { +#ifndef REUSE_EVS_BE_ACELP_4T64 acelp_4t64_ivas_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 44, cmpl_flag, Opt_AMR_WB, st_fx->element_mode ); +#else + acelp_4t64_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 44, cmpl_flag, Opt_AMR_WB, st_fx->element_mode ); +#endif } ELSE IF( EQ_32( core_brate, ACELP_15k85 ) ) { +#ifndef REUSE_EVS_BE_ACELP_4T64 acelp_4t64_ivas_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 52, cmpl_flag, Opt_AMR_WB, st_fx->element_mode ); +#else + acelp_4t64_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 52, cmpl_flag, Opt_AMR_WB, st_fx->element_mode ); +#endif } ELSE IF( EQ_32( core_brate, ACELP_18k25 ) ) { +#ifndef REUSE_EVS_BE_ACELP_4T64 acelp_4t64_ivas_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 64, cmpl_flag, Opt_AMR_WB, st_fx->element_mode ); +#else + acelp_4t64_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 64, cmpl_flag, Opt_AMR_WB, st_fx->element_mode ); +#endif } ELSE IF( EQ_32( core_brate, ACELP_19k85 ) ) { +#ifndef REUSE_EVS_BE_ACELP_4T64 acelp_4t64_ivas_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 72, cmpl_flag, Opt_AMR_WB, st_fx->element_mode ); +#else + acelp_4t64_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 72, cmpl_flag, Opt_AMR_WB, st_fx->element_mode ); +#endif } ELSE IF( EQ_32( core_brate, ACELP_23k05 ) ) { +#ifndef REUSE_EVS_BE_ACELP_4T64 acelp_4t64_ivas_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 88, cmpl_flag, Opt_AMR_WB, st_fx->element_mode ); +#else + acelp_4t64_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 88, cmpl_flag, Opt_AMR_WB, st_fx->element_mode ); +#endif } ELSE IF( EQ_32( core_brate, ACELP_23k85 ) ) { +#ifndef REUSE_EVS_BE_ACELP_4T64 acelp_4t64_ivas_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 88, 1, Opt_AMR_WB, st_fx->element_mode ); +#else + acelp_4t64_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 88, 1, Opt_AMR_WB, st_fx->element_mode ); +#endif } } diff --git a/lib_enc/ivas_td_low_rate_enc_fx.c b/lib_enc/ivas_td_low_rate_enc_fx.c index e2c12076d..a0dc77696 100644 --- a/lib_enc/ivas_td_low_rate_enc_fx.c +++ b/lib_enc/ivas_td_low_rate_enc_fx.c @@ -274,7 +274,15 @@ void encod_gen_2sbfr( * Close-loop pitch search on the 1st and 3rd subfr only and quantization * Adaptive exc. construction *------------------------------------------------------------------------*/ +#ifndef REUSE_EVS_BE_ACELP_PITCH *pt_pitch = pit_encode_ivas_fx( st->hBstr, st->acelp_cfg.pitch_bits, st->core_brate, 0, L_frame, coder_type, &pitch_limit_flag, i_subfr, exc, 2 * L_SUBFR, st->pitch, &T0_min, &T0_max, &T0, &T0_frac, h1, xn, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, Q_new ); +#else + *pt_pitch = pit_encode_fx( st->hBstr, st->acelp_cfg.pitch_bits, st->core_brate, 0, L_frame, coder_type, &pitch_limit_flag, i_subfr, exc, 2 * L_SUBFR, st->pitch, &T0_min, &T0_max, &T0, &T0_frac, h1, xn, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , st->element_mode, Q_new +#endif + ); +#endif move16(); Scale_sig( h1, 2 * L_SUBFR, sub( 13, q_h1 ) ); // Q13 @@ -297,7 +305,11 @@ void encod_gen_2sbfr( *-----------------------------------------------------------------*/ Scale_sig( h1, 2 * L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */ +#ifndef REUSE_EVS_BE_ACELP_LP_FILT lp_filt_exc_enc_ivas_fx( MODE1, coder_type, i_subfr, exc, h1, xn, y1, xn2, 2 * L_SUBFR, L_frame, g_corr, clip_gain, &gain_pit, &st->acelp_cfg.ltf_mode ); +#else + lp_filt_exc_enc_fx( MODE1, coder_type, i_subfr, exc, h1, xn, y1, xn2, 2 * L_SUBFR, L_frame, g_corr, clip_gain, &gain_pit, &st->acelp_cfg.ltf_mode ); +#endif /* update long-term pitch gain for speech/music classifier */ st->hSpMusClas->lowrate_pitchGain = add( mult( 29491, st->hSpMusClas->lowrate_pitchGain ), mult( 3277 /*Q15*/, gain_pit ) ); // Q14 move16(); @@ -312,8 +324,15 @@ void encod_gen_2sbfr( * Gain encoding *-----------------------------------------------------------------*/ +#ifndef REUSE_EVS_BE_GAINQ_LBR gain_enc_lbr_ivas_fx( st->hBstr, st->acelp_cfg.gains_mode, coder_type, i_subfr, xn, y1, add( sub( Q_new, 1 ), shift ), y2, code, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, gc_mem, gp_mem, clip_gain, 2 * L_SUBFR ); - +#else + gain_enc_lbr_fx( st->hBstr, st->acelp_cfg.gains_mode, coder_type, i_subfr, xn, y1, add( sub( Q_new, 1 ), shift ), y2, code, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, gc_mem, gp_mem, clip_gain, 2 * L_SUBFR +#ifdef REUSE_EVS_BE_GAINQ_LBR + , st->element_mode +#endif + ); +#endif IF( st->Opt_SC_VBR ) { if ( EQ_16( st->hSC_VBR->last_ppp_mode, 1 ) ) diff --git a/lib_enc/lp_exc_e_fx.c b/lib_enc/lp_exc_e_fx.c index 01005f641..4172f5bca 100644 --- a/lib_enc/lp_exc_e_fx.c +++ b/lib_enc/lp_exc_e_fx.c @@ -173,6 +173,7 @@ Word16 lp_filt_exc_enc_fx( return select; } +#ifndef REUSE_EVS_BE_ACELP_LP_FILT Word16 lp_filt_exc_enc_ivas_fx( const Word16 codec_mode, /* i : MODE1 or MODE2 Q0 */ @@ -329,7 +330,7 @@ Word16 lp_filt_exc_enc_ivas_fx( return select; } - +#endif /*-------------------------------------------------------------------* * adpt_enr_fx() * diff --git a/lib_enc/pit_enc_fx.c b/lib_enc/pit_enc_fx.c index 8eea1b3d5..dd35ba62d 100644 --- a/lib_enc/pit_enc_fx.c +++ b/lib_enc/pit_enc_fx.c @@ -74,14 +74,20 @@ Word16 pit_encode_fx( /* o : Fractional pitc const Word16 *xn, /* i : target vector */ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , + const Word16 element_mode, /* i : mode element */ + const Word16 Q_new /* i : scaling factor */ +#endif ) { Word16 pitch_cl; Word16 pit_flag, delta, mult_Top, nBits; Word16 L_sufr_sft; Word16 T_op[2]; /* values for two half-frames */ +#ifndef REUSE_EVS_BE_ACELP_PITCH (void) tdm_Pitch_reuse_flag; - +#endif L_sufr_sft = 6; move16(); if ( EQ_16( L_subfr, 2 * L_SUBFR ) ) @@ -225,7 +231,11 @@ Word16 pit_encode_fx( /* o : Fractional pitc } /* 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_MAX, PIT_MAX, L_FRAME, L_subfr ); + *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MAX, PIT_MAX, L_FRAME, L_subfr +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , element_mode, Q_new +#endif + ); move16(); pit_Q_enc_fx( hBstr, 0, nBits, delta, pit_flag, *limit_flag, *T0, *T0_frac, T0_min, T0_max ); } @@ -254,17 +264,83 @@ Word16 pit_encode_fx( /* o : Fractional pitc test(); IF( EQ_16( nBits, 9 ) || EQ_16( nBits, 5 ) ) { - *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_FR2_DOUBLEEXTEND_9b, PIT_FR1_DOUBLEEXTEND_9b, L_FRAME, L_SUBFR ); + *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_FR2_DOUBLEEXTEND_9b, PIT_FR1_DOUBLEEXTEND_9b, L_FRAME, L_SUBFR +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , element_mode, Q_new +#endif + ); move16(); } ELSE IF( EQ_16( nBits, 10 ) ) { - *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MAX, PIT_MAX, L_FRAME, L_SUBFR ); + *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MAX, PIT_MAX, L_FRAME, L_SUBFR +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , element_mode, Q_new +#endif + + ); move16(); } pit_Q_enc_fx( hBstr, 0, nBits, delta, pit_flag, *limit_flag, *T0, *T0_frac, T0_min, T0_max ); } +#ifdef REUSE_EVS_BE_ACELP_PITCH + 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 +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , element_mode, Q_new +#endif + ); + move16(); + IF( EQ_16( delta, 8 ) ) + { + *T0_frac = 0; + move16(); + } + pit_Q_enc_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 { /*-------------------------------------------------------* @@ -294,12 +370,20 @@ Word16 pit_encode_fx( /* o : Fractional pitc { IF( *limit_flag == 0 ) { - *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 ); + *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 +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , element_mode, Q_new +#endif + ); move16(); } ELSE { - *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MIN_EXTEND, PIT_FR1_EXTEND_8b, L_FRAME, L_SUBFR ); + *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MIN_EXTEND, PIT_FR1_EXTEND_8b, L_FRAME, L_SUBFR +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , element_mode, Q_new +#endif + ); move16(); } } @@ -307,18 +391,30 @@ Word16 pit_encode_fx( /* o : Fractional pitc { IF( *limit_flag == 0 ) { - *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_FR2_9b, PIT_FR1_9b, L_FRAME, L_SUBFR ); + *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_FR2_9b, PIT_FR1_9b, L_FRAME, L_SUBFR +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , element_mode, Q_new +#endif + ); move16(); } ELSE { - *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_FR2_EXTEND_9b, PIT_FR1_EXTEND_9b, L_FRAME, L_SUBFR ); + *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_FR2_EXTEND_9b, PIT_FR1_EXTEND_9b, L_FRAME, L_SUBFR +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , element_mode, Q_new +#endif + ); move16(); } } ELSE IF( EQ_16( nBits, 10 ) ) { - *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MAX, PIT_MAX, L_FRAME, L_SUBFR ); + *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MAX, PIT_MAX, L_FRAME, L_SUBFR +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , element_mode, Q_new +#endif + ); move16(); } @@ -329,12 +425,20 @@ Word16 pit_encode_fx( /* o : Fractional pitc test(); IF( EQ_16( nBits, 9 ) || EQ_16( nBits, 6 ) ) { - *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT16k_FR2_EXTEND_9b, PIT16k_FR1_EXTEND_9b, L_FRAME16k, L_SUBFR ); + *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT16k_FR2_EXTEND_9b, PIT16k_FR1_EXTEND_9b, L_FRAME16k, L_SUBFR +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , element_mode, Q_new +#endif + ); move16(); } ELSE IF( EQ_16( nBits, 10 ) ) { - *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT16k_FR2_EXTEND_10b, PIT16k_MAX, L_FRAME16k, L_SUBFR ); + *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT16k_FR2_EXTEND_10b, PIT16k_MAX, L_FRAME16k, L_SUBFR +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , element_mode, Q_new +#endif + ); move16(); } @@ -375,7 +479,11 @@ Word16 pit_encode_fx( /* o : Fractional pitc } /* 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 ); + *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 +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , element_mode, Q_new +#endif + ); move16(); } ELSE IF( EQ_32( core_brate, ACELP_8k85 ) ) @@ -398,7 +506,11 @@ Word16 pit_encode_fx( /* o : Fractional pitc } /* 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 ); + *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 +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , element_mode, Q_new +#endif + ); move16(); } ELSE @@ -425,7 +537,11 @@ Word16 pit_encode_fx( /* o : Fractional pitc } /* 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_FR2_9b, PIT_FR1_9b, L_FRAME, L_SUBFR ); + *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_FR2_9b, PIT_FR1_9b, L_FRAME, L_SUBFR +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , element_mode, Q_new +#endif + ); move16(); } @@ -441,7 +557,7 @@ Word16 pit_encode_fx( /* o : Fractional pitc return pitch_cl; } - +#ifndef REUSE_EVS_BE_ACELP_PITCH Word16 pit_encode_ivas_fx( /* o : Fractional pitch for each subframe */ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 pitch_bits[], /* i : pitch bits */ @@ -615,7 +731,11 @@ Word16 pit_encode_ivas_fx( /* o : Fractional /* search and encode the closed loop pitch period */ *T0 = pitch_fr4_ivas_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MAX, PIT_MAX, L_FRAME, L_subfr, Q_new ); move16(); +#ifndef REUSE_EVS_BE_ACELP_PITCH_PIT_Q pit_Q_enc_ivas_fx( hBstr, 0, nBits, delta, pit_flag, *limit_flag, *T0, *T0_frac, T0_min, T0_max ); +#else + pit_Q_enc_fx( hBstr, 0, nBits, delta, pit_flag, *limit_flag, *T0, *T0_frac, T0_min, T0_max ); +#endif } ELSE IF( EQ_16( coder_type, VOICED ) ) { @@ -650,7 +770,11 @@ Word16 pit_encode_ivas_fx( /* o : Fractional move16(); } +#ifndef REUSE_EVS_BE_ACELP_PITCH_PIT_Q pit_Q_enc_ivas_fx( hBstr, 0, nBits, delta, pit_flag, *limit_flag, *T0, *T0_frac, T0_min, T0_max ); +#else + pit_Q_enc_fx( hBstr, 0, nBits, delta, pit_flag, *limit_flag, *T0, *T0_frac, T0_min, T0_max ); +#endif } ELSE IF( EQ_16( tdm_Pitch_reuse_flag, 1 ) || EQ_16( nBits, 4 ) ) { @@ -693,7 +817,11 @@ Word16 pit_encode_ivas_fx( /* o : Fractional *T0_frac = 0; move16(); } +#ifndef REUSE_EVS_BE_ACELP_PITCH_PIT_Q pit_Q_enc_ivas_fx( hBstr, 0, nBits, delta, pit_flag, *limit_flag, *T0, *T0_frac, T0_min, T0_max ); +#else + pit_Q_enc_fx( hBstr, 0, nBits, delta, pit_flag, *limit_flag, *T0, *T0_frac, T0_min, T0_max ); +#endif } ELSE { @@ -759,7 +887,11 @@ Word16 pit_encode_ivas_fx( /* o : Fractional *T0 = pitch_fr4_ivas_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MAX, PIT_MAX, L_FRAME, L_SUBFR, Q_new ); } +#ifndef REUSE_EVS_BE_ACELP_PITCH_PIT_Q pit_Q_enc_ivas_fx( hBstr, 0, nBits, delta, pit_flag, *limit_flag, *T0, *T0_frac, T0_min, T0_max ); +#else + pit_Q_enc_fx( hBstr, 0, nBits, delta, pit_flag, *limit_flag, *T0, *T0_frac, T0_min, T0_max ); +#endif } ELSE /* L_frame == L_FRAME16k */ { @@ -775,7 +907,11 @@ Word16 pit_encode_ivas_fx( /* o : Fractional move16(); } +#ifndef REUSE_EVS_BE_ACELP_PITCH_PIT_Q pit16k_Q_enc_ivas_fx( hBstr, nBits, *limit_flag, *T0, *T0_frac, T0_min, T0_max ); +#else + pit16k_Q_enc_fx( hBstr, nBits, *limit_flag, *T0, *T0_frac, T0_min, T0_max ); +#endif } } } @@ -866,7 +1002,11 @@ Word16 pit_encode_ivas_fx( /* o : Fractional move16(); } +#ifndef REUSE_EVS_BE_ACELP_PITCH_PIT_Q pit_Q_enc_ivas_fx( hBstr, 1, nBits, delta, pit_flag, *limit_flag, *T0, *T0_frac, T0_min, T0_max ); +#else + pit_Q_enc_fx( hBstr, 1, nBits, delta, pit_flag, *limit_flag, *T0, *T0_frac, T0_min, T0_max ); +#endif } /*-------------------------------------------------------* @@ -878,7 +1018,7 @@ Word16 pit_encode_ivas_fx( /* o : Fractional return pitch_cl; } - +#endif /*-------------------------------------------------------------------* * abs_pit_enc() * @@ -1110,6 +1250,7 @@ Word16 delta_pit_enc_fx( /* o : pitch index * * Find the closed loop pitch period with 1/4 subsample resolution. *-------------------------------------------------------------------*/ +#ifndef REUSE_EVS_BE_ACELP_PITCH Word16 pitch_fr4_ivas_fx( /* o : chosen integer pitch lag */ const Word16 exc[], /* i : excitation buffer Q_new */ const Word16 xn[], /* i : target signal Q_new-1 */ @@ -1301,6 +1442,7 @@ Word16 pitch_fr4_ivas_fx( /* o : chosen integer pitch return ( t0 ); } +#endif Word16 pitch_fr4_fx( /* o : chosen integer pitch lag */ const Word16 exc[], /* i : excitation buffer Q_new*/ @@ -1315,6 +1457,11 @@ Word16 pitch_fr4_fx( /* o : chosen integer pitch lag const Word16 t0_fr1, /* i : minimum value for resolution 1 */ const Word16 L_frame, /* i : length of the frame */ const Word16 L_subfr /* i : size of subframe */ +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , + const Word16 element_mode, /* i : mode element */ + const Word16 Q_new /* i : scaling factor */ +#endif ) { Word16 i; @@ -1369,9 +1516,16 @@ Word16 pitch_fr4_fx( /* o : chosen integer pitch lag t_max = add( t0_max, L_INTERPOL1 ); corr = &corr_v[-t_min]; /* corr[t_min..t_max] */ - +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + if ( element_mode > EVS_MONO ) + { + norm_corr_ivas_fx( exc, xn, h, t_min, t_max, corr, L_subfr, Q_new ); + } + else +#endif + { norm_corr_fx( exc, xn, h, t_min, t_max, corr, L_subfr ); - + } /*-----------------------------------------------------------------* * Find integer pitch *-----------------------------------------------------------------*/ @@ -1792,7 +1946,7 @@ void pit_Q_enc_fx( return; } - +#ifndef REUSE_EVS_BE_ACELP_PITCH_PIT_Q void pit_Q_enc_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ @@ -1885,7 +2039,7 @@ void pit_Q_enc_ivas_fx( return; } - +#endif /*-------------------------------------------------------------------* * pit16k_Q_enc() * @@ -1963,6 +2117,7 @@ void pit16k_Q_enc_fx( return; } +#ifndef REUSE_EVS_BE_ACELP_PITCH_PIT_Q void pit16k_Q_enc_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ @@ -2035,7 +2190,7 @@ void pit16k_Q_enc_ivas_fx( return; } - +#endif /*------------------------------------------------------------------* * pit_encode: * diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 48af49619..e11f1886d 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -106,7 +106,7 @@ void AVQ_encmux_fx( Word16 avq_bit_sFlag, /* i : flag for AVQ bit saving solution */ Word16 trgtSvPos /* i : target SV for AVQ bit savings */ ); - +#ifndef REUSE_EVS_BE_ACELP_AVQ void AVQ_encmux_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ const Word16 extl, /* i : extension layer */ @@ -118,7 +118,7 @@ void AVQ_encmux_ivas_fx( Word16 avq_bit_sFlag, /* i : flag for AVQ bit saving solution */ Word16 trgtSvPos /* i : target SV for AVQ bit savings */ ); - +#endif void bw_detect_fx( Encoder_State *st, /* i/o: Encoder State */ const Word16 signal_in[], /* i : input signal */ @@ -984,6 +984,7 @@ void pit16k_Q_enc_fx( Word16 *T0_min, /* i/o: delta search min */ Word16 *T0_max /* o : delta search max */ ); +#ifndef REUSE_EVS_BE_ACELP_PITCH_PIT_Q void pit16k_Q_enc_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ @@ -994,7 +995,7 @@ void pit16k_Q_enc_ivas_fx( Word16 *T0_min, /* i/o: delta search min */ Word16 *T0_max /* o : delta search max_val */ ); - +#endif Word16 pitch_fr4_fx( /* o : chosen integer pitch lag */ const Word16 exc[], /* i : excitation buffer Q_new*/ const Word16 xn[], /* i : target signal Q_new-1+shift*/ @@ -1008,8 +1009,13 @@ Word16 pitch_fr4_fx( /* o : chosen integer pitch lag const Word16 t0_fr1, /* i : minimum value for resolution 1 */ const Word16 L_frame, /* i : length of the frame */ const Word16 L_subfr /* i : size of subframe */ +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , + const Word16 element_mode, /* i : mode element */ + const Word16 Q_new /* i : scaling factor */ +#endif ); - +#ifndef REUSE_EVS_BE_ACELP_PITCH Word16 pitch_fr4_ivas_fx( /* o : chosen integer pitch lag */ const Word16 exc[], /* i : excitation buffer Q_new */ const Word16 xn[], /* i : target signal Q_new-1 */ @@ -1025,7 +1031,7 @@ Word16 pitch_fr4_ivas_fx( /* o : chosen integer pitch const Word16 L_subfr, /* i : size of subframe */ Word16 Q_new /* i */ ); - +#endif void pit_Q_enc_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ @@ -1038,6 +1044,7 @@ void pit_Q_enc_fx( Word16 *T0_min, /* i/o: delta search min */ Word16 *T0_max /* o : delta search max */ ); +#ifndef REUSE_EVS_BE_ACELP_PITCH_PIT_Q void pit_Q_enc_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ @@ -1051,7 +1058,7 @@ void pit_Q_enc_ivas_fx( Word16 *T0_min, /* i/o: delta search min */ Word16 *T0_max /* o : delta search max_val */ ); - +#endif void PsychAdaptLowFreqEmph_fx( Word32 x[], const Word16 lpcGains[], const Word16 lpcGains_e[] ); @@ -1558,9 +1565,9 @@ void Mode2_pit_encode_fx( Word16 pit_max, Word16 pit_res_max ); void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const Word16 H[] /*Q12*/, Word16 code[] /*Q9*/, const PulseConfig *config, Word16 ind[] /*Q0*/, Word16 y[] /*Qy*/ ); - +#ifndef REUSE_EVS_BE_ACELP_4T64 void E_ACELP_4tsearch_ivas_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const Word16 H[] /*Q12*/, Word16 code[] /*Q9*/, const PulseConfig *config, Word16 ind[] /*Q0*/, Word16 y[] /*Qy*/ ); - +#endif void E_ACELP_4t_fx( Word16 dn[], /* Qdn */ Word16 cn[] /* Q_xn */, @@ -1574,8 +1581,14 @@ void E_ACELP_4t_fx( const Word16 last_L_frame, const Word32 total_brate, const Word16 i_subfr, - const Word16 cmpl_flag ); + const Word16 cmpl_flag +#ifdef REUSE_EVS_BE_ACELP_4T64 + , + const Word16 element_mode /*Q0*/ +#endif +); +#ifndef REUSE_EVS_BE_ACELP_4T64 void E_ACELP_4t_ivas_fx( Word16 dn[], /* Qdn */ Word16 cn[] /* Q_xn */, @@ -1591,7 +1604,7 @@ void E_ACELP_4t_ivas_fx( const Word16 i_subfr, const Word16 cmpl_flag, Word16 element_mode ); - +#endif void E_ACELP_innovative_codebook_fx( Word16 *exc, /* i : pointer to the excitation frame Q_new */ Word16 T0, /* i : integer pitch lag Q0 */ @@ -2284,8 +2297,12 @@ void tcx_hm_analyse_fx( const Word16 LtpGain, /* i: LTP gain Q15 */ Word16 *hm_bits_out /* o: bit consumption Q0 */ ); -void E_ACELP_4tsearchx_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_new*/, Word16 Rw[] /*Q9*/, Word16 code[] /*Q9*/, const PulseConfig *config, Word16 ind[] /*Q0*/ ); - +void E_ACELP_4tsearchx_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_new*/, Word16 Rw[] /*Q9*/, Word16 code[] /*Q9*/, const PulseConfig *config, Word16 ind[] /*Q0*/ +#ifdef REUSE_EVS_BE_ACELP_4T64 + , const Word16 element_mode +#endif +); +#ifndef REUSE_EVS_BE_ACELP_4T64 void E_ACELP_4tsearchx_ivas_fx( Word16 dn[], /*Qdn*/ const Word16 cn[], /*Q_new*/ @@ -2294,7 +2311,7 @@ void E_ACELP_4tsearchx_ivas_fx( const PulseConfig *config, Word16 ind[], /*Q0*/ Word16 element_mode ); - +#endif void E_ACELP_weighted_code( const Word16 code[], /* i: code Q9*/ const Word16 H[], /* i: impulse response Q*/ @@ -3444,8 +3461,14 @@ Word16 pit_encode_fx( /* o : Fractional pitc const Word16 *xn, /* i : target vector */ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , + const Word16 element_mode, /* i : mode element */ + const Word16 Q_new /* i : scaling factor */ +#endif ); +#ifndef REUSE_EVS_BE_ACELP_PITCH Word16 pit_encode_ivas_fx( /* o : Fractional pitch for each subframe */ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 pitch_bits[], /* i : pitch bits */ @@ -3468,7 +3491,7 @@ Word16 pit_encode_ivas_fx( /* o : Fractional const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer */ Word16 Q_new /* i */ ); - +#endif Word16 lp_filt_exc_enc_fx( const Word16 codec_mode, /* i : MODE1 or MODE2 Q0 */ const Word16 coder_type, /* i : coding type Q0 */ @@ -3485,7 +3508,7 @@ Word16 lp_filt_exc_enc_fx( Word16 *gain_pit, /* o : adaptive excitation gain Q14 */ Word16 *lp_flag /* i/o: mode selection Q0 */ ); - +#ifndef REUSE_EVS_BE_ACELP_LP_FILT Word16 lp_filt_exc_enc_ivas_fx( const Word16 codec_mode, /* i : MODE1 or MODE2 Q0 */ const Word16 coder_type, /* i : coding type Q0 */ @@ -3502,7 +3525,7 @@ Word16 lp_filt_exc_enc_ivas_fx( Word16 *gain_pit, /* o : adaptive excitation gain Q14 */ Word16 *lp_flag /* i/o: mode selection Q0 */ ); - +#endif Word16 inov_encode_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word32 core_brate, /* i : core bitrate */ @@ -3574,7 +3597,7 @@ void gain_enc_mless_fx( Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 Qx*/ const Word16 clip_gain /* i : gain pitch clipping flag (1 = clipping) Q0*/ ); - +#ifndef REUSE_EVS_BE_GAINQ void gain_enc_mless_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 gains_mode[], /* i : gain bits Q0*/ @@ -3595,6 +3618,7 @@ void gain_enc_mless_ivas_fx( Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 Qx*/ const Word16 clip_gain /* i : gain pitch clipping flag (1 = clipping) Q0*/ ); +#endif void updt_IO_switch_enc_fx( Encoder_State *st, /* i/o: state structure */ const Word16 input_frame /* i : i frame length */ @@ -3769,8 +3793,12 @@ void gain_enc_lbr_fx( Word16 gp_mem[], /* i/o: gain_pitch from previous subframes Q14*/ const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/ const Word16 L_subfr /* i : subframe length Q0*/ +#ifdef REUSE_EVS_BE_GAINQ_LBR + , + const Word16 element_mode /* i : mode element Q0*/ +#endif ); - +#ifndef REUSE_EVS_BE_GAINQ_LBR void gain_enc_lbr_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 gains_mode[], /* i : gain bits Q0*/ @@ -3791,7 +3819,7 @@ void gain_enc_lbr_ivas_fx( const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/ const Word16 L_subfr /* i : subframe length Q0*/ ); - +#endif void gain_enc_SQ_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 gains_mode[], /* i : gain bits Q0*/ @@ -3809,7 +3837,7 @@ void gain_enc_SQ_fx( const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/ const Word16 Q_xn /* i : xn and y1 scaling */ ); - +#ifndef REUSE_EVS_BE_GAINQ void gain_enc_SQ_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 gains_mode[], /* i : gain bits Q0*/ @@ -3827,7 +3855,7 @@ void gain_enc_SQ_ivas_fx( const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/ const Word16 Q_xn /* i : xn and y1 scaling */ ); - +#endif void updt_tar_fx( const Word16 *x, /* i : old target (for pitch search) */ Word16 *x2, /* o : new target (for codebook search) */ @@ -4423,7 +4451,7 @@ void acelp_1t64_fx( Word16 y[], /* o : filtered fixed codebook excitation */ const Word16 L_subfr /* i : subframe length */ ); - +#ifndef REUSE_EVS_BE_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[]. */ @@ -4432,7 +4460,7 @@ void acelp_1t64_ivas_fx( Word16 y[], /* o : filtered fixed codebook excitation */ const Word16 L_subfr /* i : subframe length */ ); - +#endif void acelp_2t32_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 dn[], /* i : corr. between target and h[]. */ @@ -4440,7 +4468,7 @@ void acelp_2t32_fx( Word16 code[], /* o : algebraic (fixed) codebook excitation */ Word16 y[] /* o : filtered fixed codebook excitation */ ); - +#ifndef REUSE_EVS_BE_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[]. */ @@ -4448,7 +4476,7 @@ void acelp_2t32_ivas_fx( Word16 code[], /* o : algebraic (fixed) codebook excitation */ Word16 y[] /* o : filtered fixed codebook excitation */ ); - +#endif Word16 acelp_4t64_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ Word16 dn[], /* i : corr. between target and h[]. */ @@ -4461,8 +4489,12 @@ Word16 acelp_4t64_fx( Word16 nbbits, /* i : number of bits per codebook */ const Word16 cmpl_flag, /* i : coomplexity reduction flag */ const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */ +#ifdef REUSE_EVS_BE_ACELP_4T64 + , + const Word16 element_mode +#endif ); - +#ifndef REUSE_EVS_BE_ACELP_4T64 Word16 acelp_4t64_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ Word16 dn[], /* i : corr. between target and h[]. */ @@ -4476,7 +4508,7 @@ Word16 acelp_4t64_ivas_fx( const Word16 cmpl_flag, /* i : complexity reduction flag */ const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ Word16 element_mode ); - +#endif ivas_error evs_enc_fx( Encoder_State *st, /* i/o: encoder state structure */ const Word16 *data, /* i : input signal Q0*/ diff --git a/lib_enc/transition_enc_fx.c b/lib_enc/transition_enc_fx.c index 4553c5a27..6c147a11a 100644 --- a/lib_enc/transition_enc_fx.c +++ b/lib_enc/transition_enc_fx.c @@ -289,7 +289,11 @@ void transition_enc_fx( /* Find the closed loop pitch period */ - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, pit_start, pit_limit, L_FRAME, L_SUBFR ); + *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, pit_start, pit_limit, L_FRAME, L_SUBFR +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , 0/*st_fx->element_mode*/, Q_new +#endif + ); move16(); offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame ); @@ -423,7 +427,12 @@ void transition_enc_fx( pit_flag = 0; move16(); - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, pit_start, 3 * L_SUBFR, L_FRAME, L_SUBFR ); + *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, pit_start, 3 * L_SUBFR, L_FRAME, L_SUBFR +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , + 0 /*st_fx->element_mode*/, Q_new +#endif + ); move16(); IF( LT_16( add( ( *T0 ), ( *position ) ), 2 * L_SUBFR ) ) @@ -486,7 +495,12 @@ void transition_enc_fx( pit_flag = 0; move16(); - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, PIT_MIN, PIT_FR1_8b, L_FRAME, L_SUBFR ); + *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, PIT_MIN, PIT_FR1_8b, L_FRAME, L_SUBFR +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , + 0 /*st_fx->element_mode*/, Q_new +#endif + ); move16(); IF( LT_16( add( *T0, *position ), 3 * L_SUBFR ) ) @@ -532,7 +546,12 @@ void transition_enc_fx( *--------------------------------------------------------*/ pit_flag = L_SUBFR; move16(); - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, PIT_MIN, PIT_FR1_8b, L_FRAME, L_SUBFR ); + *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, PIT_MIN, PIT_FR1_8b, L_FRAME, L_SUBFR +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , + 0 /*st_fx->element_mode*/, Q_new +#endif + ); move16(); index = delta_pit_enc_fx( 2, *T0, *T0_frac, *T0_min ); push_indice( hBstr, IND_PITCH, index, nBits ); @@ -563,13 +582,21 @@ void transition_enc_fx( test(); IF( !( ( *tc_subfr == 0 ) && ( EQ_16( i_subfr, L_SUBFR ) ) ) ) { - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, PIT_MIN, PIT_FR1_8b, L_FRAME, L_SUBFR ); + *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, PIT_MIN, PIT_FR1_8b, L_FRAME, L_SUBFR +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , 0/*st_fx->element_mode*/, Q_new +#endif + ); move16(); } } ELSE { - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, PIT_FR2_9b, PIT_FR1_9b, L_FRAME, L_SUBFR ); + *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, PIT_FR2_9b, PIT_FR1_9b, L_FRAME, L_SUBFR +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , 0/*st_fx->element_mode*/, Q_new +#endif + ); move16(); } pit_Q_enc_fx( hBstr, 0, nBits, 8, pit_flag, limit_flag, *T0, *T0_frac, T0_min, T0_max ); @@ -745,7 +772,11 @@ void transition_enc_fx( IF( EQ_16( nBits, 10 ) ) { - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, limit_flag, PIT16k_FR2_EXTEND_10b, PIT16k_MAX, st_fx->L_frame, L_SUBFR ); + *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, limit_flag, PIT16k_FR2_EXTEND_10b, PIT16k_MAX, st_fx->L_frame, L_SUBFR +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , 0/*st_fx->element_mode*/, Q_new +#endif + ); move16(); pit16k_Q_enc_fx( hBstr, nBits, limit_flag, *T0, *T0_frac, T0_min, T0_max ); } @@ -756,7 +787,11 @@ void transition_enc_fx( * PIT16k_MIN to PIT16k_FR2_TC0_2SUBFR-1 resolution 1/4 (frac = 0,1,2 or 3) * PIT16k_FR2_TC0_2SUBFR to 2*L_SUBFR resolution 1/2 (frac = 0 or 2) *-----------------------------------------------------------------------------*/ - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, limit_flag, PIT16k_FR2_TC0_2SUBFR, 2 * L_SUBFR, st_fx->L_frame, L_SUBFR ); + *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, limit_flag, PIT16k_FR2_TC0_2SUBFR, 2 * L_SUBFR, st_fx->L_frame, L_SUBFR +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , 0/*st_fx->element_mode*/, Q_new +#endif + ); move16(); IF( GT_16( *T0_max, 2 * L_SUBFR ) ) @@ -782,7 +817,11 @@ void transition_enc_fx( ELSE IF( EQ_16( nBits, 6 ) ) { /* delta search */ - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, L_SUBFR, limit_flag, PIT16k_FR2_EXTEND_9b, PIT16k_FR1_EXTEND_9b, st_fx->L_frame, L_SUBFR ); + *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, L_SUBFR, limit_flag, PIT16k_FR2_EXTEND_9b, PIT16k_FR1_EXTEND_9b, st_fx->L_frame, L_SUBFR +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , 0/*st_fx->element_mode*/, Q_new +#endif + ); move16(); index = delta_pit_enc_fx( 4, *T0, *T0_frac, *T0_min ); @@ -1118,7 +1157,11 @@ void transition_enc_ivas_fx( /* Find the closed loop pitch period */ - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, pit_start, pit_limit, L_FRAME, L_SUBFR ); + *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, pit_start, pit_limit, L_FRAME, L_SUBFR +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , 0/*st_fx->element_mode*/, Q_new +#endif + ); move16(); offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame ); @@ -1252,7 +1295,11 @@ void transition_enc_ivas_fx( pit_flag = 0; move16(); - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, pit_start, 3 * L_SUBFR, L_FRAME, L_SUBFR ); + *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, pit_start, 3 * L_SUBFR, L_FRAME, L_SUBFR +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , 0/*st_fx->element_mode*/, Q_new +#endif + ); move16(); IF( LT_16( add( ( *T0 ), ( *position ) ), 2 * L_SUBFR ) ) @@ -1315,7 +1362,11 @@ void transition_enc_ivas_fx( pit_flag = 0; move16(); - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, PIT_MIN, PIT_FR1_8b, L_FRAME, L_SUBFR ); + *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, PIT_MIN, PIT_FR1_8b, L_FRAME, L_SUBFR +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , 0/*st_fx->element_mode*/, Q_new +#endif + ); move16(); IF( LT_16( add( *T0, *position ), 3 * L_SUBFR ) ) @@ -1362,7 +1413,11 @@ void transition_enc_ivas_fx( pit_flag = L_SUBFR; move16(); - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, PIT_MIN, PIT_FR1_8b, L_FRAME, L_SUBFR ); + *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, PIT_MIN, PIT_FR1_8b, L_FRAME, L_SUBFR +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , 0/*st_fx->element_mode*/, Q_new +#endif + ); move16(); index = delta_pit_enc_fx( 2, *T0, *T0_frac, *T0_min ); push_indice( hBstr, IND_PITCH, index, nBits ); @@ -1392,17 +1447,28 @@ void transition_enc_ivas_fx( test(); IF( !( ( *tc_subfr == 0 ) && ( EQ_16( i_subfr, L_SUBFR ) ) ) ) { - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, PIT_MIN, PIT_FR1_8b, L_FRAME, L_SUBFR ); + *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, PIT_MIN, PIT_FR1_8b, L_FRAME, L_SUBFR +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , 0/*st_fx->element_mode*/, Q_new +#endif + ); move16(); } } ELSE { - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, PIT_FR2_9b, PIT_FR1_9b, L_FRAME, L_SUBFR ); + *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, PIT_FR2_9b, PIT_FR1_9b, L_FRAME, L_SUBFR +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , 0/*st_fx->element_mode*/, Q_new +#endif + ); move16(); } +#ifndef REUSE_EVS_BE_ACELP_PITCH_PIT_Q pit_Q_enc_ivas_fx( hBstr, 0, nBits, 8, pit_flag, limit_flag, *T0, *T0_frac, T0_min, T0_max ); - +#else + pit_Q_enc_fx( hBstr, 0, nBits, 8, pit_flag, limit_flag, *T0, *T0_frac, T0_min, T0_max ); +#endif /* Find the adaptive codebook vector - ACELP long-term prediction */ pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); @@ -1440,9 +1506,13 @@ void transition_enc_ivas_fx( *clip_gain = gp_clip_fx( st_fx->element_mode, st_fx->core_brate, st_fx->voicing_fx, i_subfr, TRANSITION, xn_fx, gp_cl_fx, ( Q_new + shift - 1 ) ); move16(); +#ifndef REUSE_EVS_BE_ACELP_LP_FILT lp_select = lp_filt_exc_enc_ivas_fx( MODE1, TRANSITION, i_subfr, exc_fx, h1_fx, xn_fx, y1_fx, xn2_fx, L_SUBFR, st_fx->L_frame, g_corr_fx, *clip_gain, gain_pit_fx, &lp_flag ); - +#else + lp_select = lp_filt_exc_enc_fx( MODE1, TRANSITION, i_subfr, exc_fx, h1_fx, + xn_fx, y1_fx, xn2_fx, L_SUBFR, st_fx->L_frame, g_corr_fx, *clip_gain, gain_pit_fx, &lp_flag ); +#endif IF( EQ_16( lp_flag, NORMAL_OPERATION ) ) { push_indice( hBstr, IND_LP_FILT_SELECT, lp_select, 1 ); @@ -1574,9 +1644,17 @@ void transition_enc_ivas_fx( IF( EQ_16( nBits, 10 ) ) { - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, limit_flag, PIT16k_FR2_EXTEND_10b, PIT16k_MAX, st_fx->L_frame, L_SUBFR ); + *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, limit_flag, PIT16k_FR2_EXTEND_10b, PIT16k_MAX, st_fx->L_frame, L_SUBFR +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , 0/*st_fx->element_mode*/, Q_new +#endif + ); move16(); +#ifndef REUSE_EVS_BE_ACELP_PITCH_PIT_Q pit16k_Q_enc_ivas_fx( hBstr, nBits, limit_flag, *T0, *T0_frac, T0_min, T0_max ); +#else + pit16k_Q_enc_fx( hBstr, nBits, limit_flag, *T0, *T0_frac, T0_min, T0_max ); +#endif } ELSE IF( EQ_16( nBits, 8 ) ) /* tc_subfr==0 && i_subfr==L_SUBFR */ { @@ -1585,7 +1663,11 @@ void transition_enc_ivas_fx( * PIT16k_MIN to PIT16k_FR2_TC0_2SUBFR-1 resolution 1/4 (frac = 0,1,2 or 3) * PIT16k_FR2_TC0_2SUBFR to 2*L_SUBFR resolution 1/2 (frac = 0 or 2) *-----------------------------------------------------------------------------*/ - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, limit_flag, PIT16k_FR2_TC0_2SUBFR, 2 * L_SUBFR, st_fx->L_frame, L_SUBFR ); + *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, limit_flag, PIT16k_FR2_TC0_2SUBFR, 2 * L_SUBFR, st_fx->L_frame, L_SUBFR +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , 0/*st_fx->element_mode*/, Q_new +#endif + ); move16(); IF( GT_16( *T0_max, 2 * L_SUBFR ) ) @@ -1611,7 +1693,11 @@ void transition_enc_ivas_fx( ELSE IF( EQ_16( nBits, 6 ) ) { /* delta search */ - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, L_SUBFR, limit_flag, PIT16k_FR2_EXTEND_9b, PIT16k_FR1_EXTEND_9b, st_fx->L_frame, L_SUBFR ); + *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, L_SUBFR, limit_flag, PIT16k_FR2_EXTEND_9b, PIT16k_FR1_EXTEND_9b, st_fx->L_frame, L_SUBFR +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , 0/*st_fx->element_mode*/, Q_new +#endif + ); move16(); index = delta_pit_enc_fx( 4, *T0, *T0_frac, *T0_min ); @@ -1676,8 +1762,13 @@ void transition_enc_ivas_fx( *clip_gain = gp_clip_fx( st_fx->element_mode, st_fx->core_brate, st_fx->voicing_fx, i_subfr, TRANSITION, xn_fx, gp_cl_fx, Q_new ); move16(); +#ifndef REUSE_EVS_BE_ACELP_LP_FILT lp_select = lp_filt_exc_enc_ivas_fx( MODE1, TRANSITION, i_subfr, exc_fx, h1_fx, xn_fx, y1_fx, xn2_fx, L_SUBFR, st_fx->L_frame, g_corr_fx, *clip_gain, gain_pit_fx, &lp_flag ); +#else + lp_select = lp_filt_exc_enc_fx( MODE1, TRANSITION, i_subfr, exc_fx, h1_fx, + xn_fx, y1_fx, xn2_fx, L_SUBFR, st_fx->L_frame, g_corr_fx, *clip_gain, gain_pit_fx, &lp_flag ); +#endif IF( EQ_16( lp_flag, NORMAL_OPERATION ) ) { push_indice( hBstr, IND_LP_FILT_SELECT, lp_select, 1 ); @@ -1788,17 +1879,29 @@ static void tc_enc_fx( { IF( EQ_16( nBits, 9 ) ) { - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, 0, PIT_FR2_9b, PIT_FR1_9b, L_FRAME, L_SUBFR ); + *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, 0, PIT_FR2_9b, PIT_FR1_9b, L_FRAME, L_SUBFR +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , 0/*st_fx->element_mode*/, Q_new +#endif + ); move16(); } ELSE IF( EQ_16( nBits, 6 ) ) { - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, 0, PIT_MIN, L_SUBFR, L_FRAME, L_SUBFR ); + *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, 0, PIT_MIN, L_SUBFR, L_FRAME, L_SUBFR +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , 0/*st_fx->element_mode*/, Q_new +#endif + ); move16(); } ELSE { - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, 0, PIT_MAX, PIT_MIN, L_FRAME, L_SUBFR ); + *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, 0, PIT_MAX, PIT_MIN, L_FRAME, L_SUBFR +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , 0/*st_fx->element_mode*/, Q_new +#endif + ); move16(); } } @@ -1818,13 +1921,21 @@ static void tc_enc_fx( { IF( EQ_16( nBits, 10 ) ) { - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, 1, PIT16k_FR2_EXTEND_10b, PIT16k_MAX, L_FRAME16k, L_SUBFR ); + *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, 1, PIT16k_FR2_EXTEND_10b, PIT16k_MAX, L_FRAME16k, L_SUBFR +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , 0/*st_fx->element_mode*/, Q_new +#endif + ); move16(); } ELSE IF( EQ_16( nBits, 6 ) ) { /* T0_frac with 1/2 sample resolution */ - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, 0, PIT16k_MIN, L_SUBFR, L_FRAME16k, L_SUBFR ); + *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, 0, PIT16k_MIN, L_SUBFR, L_FRAME16k, L_SUBFR +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , 0/*st_fx->element_mode*/, Q_new +#endif + ); move16(); IF( *T0 > L_SUBFR ) { @@ -2005,17 +2116,29 @@ static void tc_enc_ivas_fx( { IF( EQ_16( nBits, 9 ) ) { - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1, *T0_min, *T0_max, T0_frac, 0, 0, PIT_FR2_9b, PIT_FR1_9b, L_FRAME, L_SUBFR ); + *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1, *T0_min, *T0_max, T0_frac, 0, 0, PIT_FR2_9b, PIT_FR1_9b, L_FRAME, L_SUBFR +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , 0/*st_fx->element_mode*/, Q_new +#endif + ); move16(); } ELSE IF( EQ_16( nBits, 6 ) ) { - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1, *T0_min, *T0_max, T0_frac, 0, 0, PIT_MIN, L_SUBFR, L_FRAME, L_SUBFR ); + *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1, *T0_min, *T0_max, T0_frac, 0, 0, PIT_MIN, L_SUBFR, L_FRAME, L_SUBFR +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , 0/*st_fx->element_mode*/, Q_new +#endif + ); move16(); } ELSE { - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1, *T0_min, *T0_max, T0_frac, 0, 0, PIT_MAX, PIT_MIN, L_FRAME, L_SUBFR ); + *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1, *T0_min, *T0_max, T0_frac, 0, 0, PIT_MAX, PIT_MIN, L_FRAME, L_SUBFR +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , 0/*st_fx->element_mode*/, Q_new +#endif + ); move16(); } } @@ -2035,13 +2158,21 @@ static void tc_enc_ivas_fx( { IF( EQ_16( nBits, 10 ) ) { - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1, *T0_min, *T0_max, T0_frac, 0, 1, PIT16k_FR2_EXTEND_10b, PIT16k_MAX, L_FRAME16k, L_SUBFR ); + *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1, *T0_min, *T0_max, T0_frac, 0, 1, PIT16k_FR2_EXTEND_10b, PIT16k_MAX, L_FRAME16k, L_SUBFR +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , 0/*st_fx->element_mode*/, Q_new +#endif + ); move16(); } ELSE IF( EQ_16( nBits, 6 ) ) { /* T0_frac with 1/2 sample resolution */ - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1, *T0_min, *T0_max, T0_frac, 0, 0, PIT16k_MIN, L_SUBFR, L_FRAME16k, L_SUBFR ); + *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1, *T0_min, *T0_max, T0_frac, 0, 0, PIT16k_MIN, L_SUBFR, L_FRAME16k, L_SUBFR +#if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR + , 0/*st_fx->element_mode*/, Q_new +#endif + ); IF( *T0 > L_SUBFR ) { *T0 = L_SUBFR; @@ -2152,7 +2283,11 @@ static void tc_enc_ivas_fx( { IF( EQ_16( nBits, 10 ) ) { +#ifndef REUSE_EVS_BE_ACELP_PITCH_PIT_Q pit16k_Q_enc_ivas_fx( hBstr, nBits, 1, *T0, *T0_frac, T0_min, T0_max ); +#else + pit16k_Q_enc_fx( hBstr, nBits, 1, *T0, *T0_frac, T0_min, T0_max ); +#endif } ELSE IF( EQ_16( nBits, 6 ) ) { -- GitLab From 55061746dab721c455358dbdfbd79ba24fab4d70 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 12 Aug 2025 16:35:57 -0400 Subject: [PATCH 02/18] activate switch --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 75427a07e..63e02990f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -91,7 +91,7 @@ #define FIX_1822 #define FIX_ISSUE_1764 /* NTT: update renorm and use abs */ -//#define EVS_BE_REUSAGE +#define EVS_BE_REUSAGE #ifdef EVS_BE_REUSAGE #define REUSE_EVS_BE_ACELP_LP_FILT #define REUSE_EVS_BE_ACELP_4T64 -- GitLab From a881c3b9c885e8ee2678f74c05643771d7b32798 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 12 Aug 2025 18:01:32 -0400 Subject: [PATCH 03/18] fix clang --- lib_enc/acelp_core_switch_enc_fx.c | 22 ++--- lib_enc/enc_acelp_fx.c | 2 +- lib_enc/enc_acelpx_fx.c | 6 +- lib_enc/enc_amr_wb_fx.c | 3 +- lib_enc/enc_gen_voic_fx.c | 25 +++--- lib_enc/enc_pit_exc_fx.c | 21 +++-- lib_enc/enc_tran_fx.c | 8 +- lib_enc/gain_enc_fx.c | 13 ++- lib_enc/ivas_td_low_rate_enc_fx.c | 6 +- lib_enc/pit_enc_fx.c | 64 ++++++++------ lib_enc/prot_fx_enc.h | 9 +- lib_enc/transition_enc_fx.c | 135 +++++++++++++++++------------ 12 files changed, 182 insertions(+), 132 deletions(-) diff --git a/lib_enc/acelp_core_switch_enc_fx.c b/lib_enc/acelp_core_switch_enc_fx.c index f389bb0b7..b8499b94a 100644 --- a/lib_enc/acelp_core_switch_enc_fx.c +++ b/lib_enc/acelp_core_switch_enc_fx.c @@ -414,8 +414,9 @@ static void encod_gen_voic_core_switch_fx( pitch = pit_encode_fx( hBstr, st_fx->acelp_cfg.pitch_bits, core_bitrate, 0, L_frame, GENERIC, &pitch_limit_flag, 0, exc, L_SUBFR, T_op, &T0_min, &T0_max, &T0, &T0_frac, h1, xn, 0 /*hStereoTD->tdm_Pitch_reuse_flag*/, dummyF /*hStereoTD->tdm_Pri_pitch_buf*/ #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , st_fx->element_mode, Q_new -#endif + , + st_fx->element_mode, Q_new +#endif ); /* Q6 */ /*-----------------------------------------------------------------* @@ -627,11 +628,12 @@ static void encod_gen_voic_core_switch_ivas_fx( st_fx->acelp_cfg.pitch_bits, core_bitrate, 0, L_frame, GENERIC, &pitch_limit_flag, 0, exc, L_SUBFR, T_op, &T0_min, &T0_max, &T0, &T0_frac, h1, xn, 0 /*hStereoTD->tdm_Pitch_reuse_flag*/, dummyF /*hStereoTD->tdm_Pri_pitch_buf*/, Q_new ); /* Q6 */ #else pitch = pit_encode_fx( hBstr, - st_fx->acelp_cfg.pitch_bits, core_bitrate, 0, L_frame, GENERIC, &pitch_limit_flag, 0, exc, L_SUBFR, T_op, &T0_min, &T0_max, &T0, &T0_frac, h1, xn, 0 /*hStereoTD->tdm_Pitch_reuse_flag*/, dummyF /*hStereoTD->tdm_Pri_pitch_buf*/ + st_fx->acelp_cfg.pitch_bits, core_bitrate, 0, L_frame, GENERIC, &pitch_limit_flag, 0, exc, L_SUBFR, T_op, &T0_min, &T0_max, &T0, &T0_frac, h1, xn, 0 /*hStereoTD->tdm_Pitch_reuse_flag*/, dummyF /*hStereoTD->tdm_Pri_pitch_buf*/ #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , st_fx->element_mode, Q_new -#endif - ); /* Q6 */ + , + st_fx->element_mode, Q_new +#endif + ); /* Q6 */ #endif /*-----------------------------------------------------------------* * Find adaptive exitation @@ -649,8 +651,8 @@ static void encod_gen_voic_core_switch_ivas_fx( /*-----------------------------------------------------------------* * LP filtering of the adaptive excitation, codebook target computation *-----------------------------------------------------------------*/ - lp_flag = st_fx->acelp_cfg.ltf_mode; /* Q0 */ - Scale_sig( h1, L_SUBFR, sub( 14, q_h1 ) ); /* set h1[] in Q14 with scaling for convolution Q14+shift*/ + lp_flag = st_fx->acelp_cfg.ltf_mode; /* Q0 */ + Scale_sig( h1, L_SUBFR, sub( 14, q_h1 ) ); /* set h1[] in Q14 with scaling for convolution Q14+shift*/ #ifdef REUSE_EVS_BE_ACELP_LP_FILT lp_select = lp_filt_exc_enc_fx( MODE1, GENERIC, 0, exc, h1, xn, y1, xn2, L_SUBFR, L_frame, g_corr, clip_gain, &gain_pit, &lp_flag ); /* Q0 */ #else @@ -686,12 +688,12 @@ static void encod_gen_voic_core_switch_ivas_fx( IF( EQ_16( L_frame, L_FRAME ) ) { gain_enc_mless_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_frame, 0, -1, xn, y1, shift_wsp, y2, code, st_fx->old_Es_pred_fx, - &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 ); } ELSE { gain_enc_mless_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_frame, 0, -1, xn, y1, shift_wsp, y2, code, st_fx->old_Es_pred_fx, - &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, core_bitrate, gain_pit, st_fx->clip_var_fx ); diff --git a/lib_enc/enc_acelp_fx.c b/lib_enc/enc_acelp_fx.c index 85c0a39b7..3dd0bba24 100644 --- a/lib_enc/enc_acelp_fx.c +++ b/lib_enc/enc_acelp_fx.c @@ -1769,7 +1769,7 @@ void E_ACELP_4t_fx( const Word16 last_L_frame, /*Q0*/ const Word32 total_brate, /*Q0*/ const Word16 i_subfr, /*Q0*/ - const Word16 cmpl_flag /*Q0*/ + const Word16 cmpl_flag /*Q0*/ #ifdef REUSE_EVS_BE_ACELP_4T64 , const Word16 element_mode /*Q0*/ diff --git a/lib_enc/enc_acelpx_fx.c b/lib_enc/enc_acelpx_fx.c index e67e4add4..e0cf49264 100644 --- a/lib_enc/enc_acelpx_fx.c +++ b/lib_enc/enc_acelpx_fx.c @@ -367,10 +367,10 @@ void E_ACELP_4tsearchx_fx( Word16 Rw[], /*Q9*/ Word16 code[], /*Q9*/ const PulseConfig *config, - Word16 ind[] /*Q0*/ + Word16 ind[] /*Q0*/ #ifdef REUSE_EVS_BE_ACELP_4T64 , - const Word16 element_mode + const Word16 element_mode #endif ) { @@ -604,7 +604,7 @@ void E_ACELP_4tsearchx_fx( IF( EQ_16( element_mode, EVS_MONO ) ) #endif { - E_ACELP_build_code( nb_pulse, codvec, sign, code, ind ); + E_ACELP_build_code( nb_pulse, codvec, sign, code, ind ); } #ifdef REUSE_EVS_BE_ACELP_4T64 ELSE diff --git a/lib_enc/enc_amr_wb_fx.c b/lib_enc/enc_amr_wb_fx.c index 9707f565f..d9048ac69 100644 --- a/lib_enc/enc_amr_wb_fx.c +++ b/lib_enc/enc_amr_wb_fx.c @@ -148,7 +148,8 @@ void encod_amr_wb_fx( *pt_pitch = pit_encode_fx( hBstr, st->acelp_cfg.pitch_bits, st->core_brate, 1, L_FRAME, -1, &pitch_limit_flag, i_subfr, exc, L_SUBFR, T_op, &T0_min, &T0_max, &T0, &T0_frac, h1, xn, 0 /*hStereoTD->tdm_Pitch_reuse_flag*/, NULL /*hStereoTD->tdm_Pri_pitch_buf*/ #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , 0, Q_new + , + 0, Q_new #endif ); diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index ea1efd6dd..17e75a23a 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -232,9 +232,10 @@ 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 #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , st_fx->element_mode, Q_new + , + st_fx->element_mode, Q_new #endif - ); /* Q6 */ + ); /* Q6 */ tbe_celp_exc( L_frame, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx ); /*-----------------------------------------------------------------* @@ -297,9 +298,10 @@ void encod_gen_voic_fx( IF( LE_32( st_fx->core_brate, ACELP_8k00 ) ) { gain_enc_lbr_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->coder_type, i_subfr_fx, xn_fx, y1_fx, shift_wsp, y2_fx, code_fx, - &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, gc_mem, gp_mem, clip_gain_fx, L_SUBFR + &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, gc_mem, gp_mem, clip_gain_fx, L_SUBFR #ifdef REUSE_EVS_BE_GAINQ_LBR - , st_fx->element_mode + , + st_fx->element_mode #endif ); } @@ -610,9 +612,10 @@ void encod_gen_voic_ivas_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, Q_new ); /* Q6 */ #else *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 + 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 #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , st_fx->element_mode, Q_new + , + st_fx->element_mode, Q_new #endif ); /* Q6 */ #endif @@ -647,7 +650,7 @@ void encod_gen_voic_ivas_fx( xn_fx, y1_fx, xn2_fx, L_SUBFR, L_frame, g_corr_fx, clip_gain_fx, &gain_pit_fx, &lp_flag ); #else lp_select = lp_filt_exc_enc_fx( MODE1, st_fx->coder_type, i_subfr_fx, exc_fx, h1_fx, - xn_fx, y1_fx, xn2_fx, L_SUBFR, L_frame, g_corr_fx, clip_gain_fx, &gain_pit_fx, &lp_flag ); + xn_fx, y1_fx, xn2_fx, L_SUBFR, L_frame, g_corr_fx, clip_gain_fx, &gain_pit_fx, &lp_flag ); #endif IF( EQ_16( lp_flag, NORMAL_OPERATION ) ) @@ -701,7 +704,7 @@ void encod_gen_voic_ivas_fx( &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, gc_mem, gp_mem, clip_gain_fx, L_SUBFR ); #else gain_enc_lbr_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->coder_type, i_subfr_fx, xn_fx, y1_fx, shift_wsp, y2_fx, code_fx, - &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, gc_mem, gp_mem, clip_gain_fx, L_SUBFR + &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, gc_mem, gp_mem, clip_gain_fx, L_SUBFR #ifdef REUSE_EVS_BE_GAINQ_LBR , st_fx->element_mode @@ -712,14 +715,14 @@ void encod_gen_voic_ivas_fx( ELSE IF( GT_32( st_fx->core_brate, ACELP_32k ) ) { gain_enc_SQ_fx( hBstr, st_fx->acelp_cfg.gains_mode, i_subfr_fx, xn_fx, y1_fx, y2_fx, code_fx, Es_pred_fx, - &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, clip_gain_fx, shift_wsp ); + &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, clip_gain_fx, shift_wsp ); } ELSE { gain_enc_mless_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_frame, i_subfr_fx, -1, xn_fx, y1_fx, shift_wsp, y2_fx, code_fx, Es_pred_fx, - &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, clip_gain_fx ); + &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, clip_gain_fx ); } -#endif +#endif IF( st_fx->Opt_SC_VBR ) { if ( EQ_16( hSC_VBR->last_ppp_mode, 1 ) ) diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index 0e078de35..395f7da93 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -263,9 +263,10 @@ void enc_pit_exc_fx( * Adaptive exc. construction *----------------------------------------------------------------*/ *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 + L_subfr, st_fx->pitch, &T0_min, &T0_max, T0, T0_frac, h1, xn, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , st_fx->element_mode, Q_new + , + st_fx->element_mode, Q_new #endif ); /* Q6 */ /*-----------------------------------------------------------------* @@ -334,7 +335,8 @@ void enc_pit_exc_fx( 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 #ifdef REUSE_EVS_BE_GAINQ_LBR - , st_fx->element_mode + , + st_fx->element_mode #endif ); } @@ -754,9 +756,10 @@ void enc_pit_exc_ivas_fx( *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 #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , st_fx->element_mode, Q_new + , + st_fx->element_mode, Q_new #endif - ); /* Q6 */ + ); /* Q6 */ #endif Scale_sig( h1, L_subfr, sub( 14, q_h1 ) ); /* set h1[] in Q14 with scaling for convolution Q14*/ @@ -829,13 +832,13 @@ void enc_pit_exc_ivas_fx( #ifndef REUSE_EVS_BE_GAINQ_LBR 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 - gain_enc_lbr_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 + gain_enc_lbr_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 #ifdef REUSE_EVS_BE_GAINQ_LBR - , st_fx->element_mode + , + st_fx->element_mode #endif ); #endif - } ELSE { @@ -853,7 +856,7 @@ void enc_pit_exc_ivas_fx( &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain ); #else gain_enc_mless_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, st_fx->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 ); + &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 dc624e820..23f1377aa 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -614,7 +614,7 @@ Word16 encod_tran_ivas_fx( { /* SQ gain_code */ gain_enc_tc_fx( hBstr, st_fx->acelp_cfg.gains_mode, i_subfr, xn, y2, code, Es_pred_fx, - &gain_pit, &gain_code, &gain_inov, &norm_gain_code, shift_wsp ); + &gain_pit, &gain_code, &gain_inov, &norm_gain_code, shift_wsp ); } ELSE { @@ -622,16 +622,16 @@ Word16 encod_tran_ivas_fx( { /* SQ gain_pit and gain_code */ gain_enc_SQ_fx( hBstr, st_fx->acelp_cfg.gains_mode, i_subfr, xn, y1, y2, code, Es_pred_fx, - &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain, shift_wsp ); + &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain, shift_wsp ); } ELSE { /* VQ gain_pit and gain_code */ gain_enc_mless_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_frame_fx, i_subfr, tc_subfr, xn, y1, shift_wsp, y2, code, Es_pred_fx, - &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 +#endif gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit, st_fx->clip_var_fx ); Lgcode = L_shl_o( gain_code, Q_new, &Overflow ); /* scaled gain_code with Qnew -> Q16*/ diff --git a/lib_enc/gain_enc_fx.c b/lib_enc/gain_enc_fx.c index 7375331f1..ea7a26685 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_BE_GAINQ +#ifdef REUSE_EVS_BE_GAINQ if ( element_mode > EVS_MONO ) { qua_table = gain_qua_mless_6b_stereo_fx; @@ -2175,16 +2175,15 @@ void gain_enc_lbr_fx( // 10 in Q27 , ( 10 * log10( Ecode ) ) L_tmp1 = Mpy_32_32( L_tmp, 1342177280 ); // Q25 + exp + 1 + Q27 - 32 = Q21 + exp L_tmp1 = L_shr( L_tmp1, add( 7, exp ) ); // Q21 + exp - 7 - exp = Q14 - } ELSE #endif { - exp_code = sub( exp_code, 18 + 6 + 1 ); - exp = norm_l( L_tmp ); - frac = Log2_norm_lc( L_shl( L_tmp, exp ) ); - exp = sub( exp_code, exp ); - L_tmp1 = Mpy_32_16( exp, frac, 24660 ); /* Q14 */ /* 10*log10(2) in Q13*/ + exp_code = sub( exp_code, 18 + 6 + 1 ); + exp = norm_l( L_tmp ); + frac = Log2_norm_lc( L_shl( L_tmp, exp ) ); + exp = sub( exp_code, exp ); + L_tmp1 = Mpy_32_16( exp, frac, 24660 ); /* Q14 */ /* 10*log10(2) in Q13*/ } L_tmp = Dot_product( b, aux, n_pred ); /*Q25*/ L_tmp = Mult_32_16( L_tmp, 320 ); /*Q14, 20 in Q4*/ diff --git a/lib_enc/ivas_td_low_rate_enc_fx.c b/lib_enc/ivas_td_low_rate_enc_fx.c index a0dc77696..d25e222f2 100644 --- a/lib_enc/ivas_td_low_rate_enc_fx.c +++ b/lib_enc/ivas_td_low_rate_enc_fx.c @@ -279,7 +279,8 @@ void encod_gen_2sbfr( #else *pt_pitch = pit_encode_fx( st->hBstr, st->acelp_cfg.pitch_bits, st->core_brate, 0, L_frame, coder_type, &pitch_limit_flag, i_subfr, exc, 2 * L_SUBFR, st->pitch, &T0_min, &T0_max, &T0, &T0_frac, h1, xn, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , st->element_mode, Q_new + , + st->element_mode, Q_new #endif ); #endif @@ -329,7 +330,8 @@ void encod_gen_2sbfr( #else gain_enc_lbr_fx( st->hBstr, st->acelp_cfg.gains_mode, coder_type, i_subfr, xn, y1, add( sub( Q_new, 1 ), shift ), y2, code, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, gc_mem, gp_mem, clip_gain, 2 * L_SUBFR #ifdef REUSE_EVS_BE_GAINQ_LBR - , st->element_mode + , + st->element_mode #endif ); #endif diff --git a/lib_enc/pit_enc_fx.c b/lib_enc/pit_enc_fx.c index dd35ba62d..510761a63 100644 --- a/lib_enc/pit_enc_fx.c +++ b/lib_enc/pit_enc_fx.c @@ -233,8 +233,9 @@ Word16 pit_encode_fx( /* o : Fractional pitc /* 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_MAX, PIT_MAX, L_FRAME, L_subfr #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , element_mode, Q_new -#endif + , + element_mode, Q_new +#endif ); move16(); pit_Q_enc_fx( hBstr, 0, nBits, delta, pit_flag, *limit_flag, *T0, *T0_frac, T0_min, T0_max ); @@ -264,9 +265,10 @@ Word16 pit_encode_fx( /* o : Fractional pitc test(); IF( EQ_16( nBits, 9 ) || EQ_16( nBits, 5 ) ) { - *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_FR2_DOUBLEEXTEND_9b, PIT_FR1_DOUBLEEXTEND_9b, L_FRAME, L_SUBFR + *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_FR2_DOUBLEEXTEND_9b, PIT_FR1_DOUBLEEXTEND_9b, L_FRAME, L_SUBFR #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , element_mode, Q_new + , + element_mode, Q_new #endif ); move16(); @@ -275,8 +277,9 @@ Word16 pit_encode_fx( /* o : Fractional pitc { *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MAX, PIT_MAX, L_FRAME, L_SUBFR #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , element_mode, Q_new -#endif + , + element_mode, Q_new +#endif ); move16(); @@ -321,7 +324,8 @@ Word16 pit_encode_fx( /* o : Fractional pitc /* 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 #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , element_mode, Q_new + , + element_mode, Q_new #endif ); move16(); @@ -372,17 +376,19 @@ Word16 pit_encode_fx( /* o : Fractional pitc { *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 #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , element_mode, Q_new + , + element_mode, Q_new #endif ); move16(); } ELSE { - *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MIN_EXTEND, PIT_FR1_EXTEND_8b, L_FRAME, L_SUBFR + *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MIN_EXTEND, PIT_FR1_EXTEND_8b, L_FRAME, L_SUBFR #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , element_mode, Q_new -#endif + , + element_mode, Q_new +#endif ); move16(); } @@ -393,8 +399,9 @@ Word16 pit_encode_fx( /* o : Fractional pitc { *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_FR2_9b, PIT_FR1_9b, L_FRAME, L_SUBFR #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , element_mode, Q_new -#endif + , + element_mode, Q_new +#endif ); move16(); } @@ -402,8 +409,9 @@ Word16 pit_encode_fx( /* o : Fractional pitc { *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_FR2_EXTEND_9b, PIT_FR1_EXTEND_9b, L_FRAME, L_SUBFR #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , element_mode, Q_new -#endif + , + element_mode, Q_new +#endif ); move16(); } @@ -412,8 +420,9 @@ Word16 pit_encode_fx( /* o : Fractional pitc { *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MAX, PIT_MAX, L_FRAME, L_SUBFR #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , element_mode, Q_new -#endif + , + element_mode, Q_new +#endif ); move16(); } @@ -427,8 +436,9 @@ Word16 pit_encode_fx( /* o : Fractional pitc { *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT16k_FR2_EXTEND_9b, PIT16k_FR1_EXTEND_9b, L_FRAME16k, L_SUBFR #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , element_mode, Q_new -#endif + , + element_mode, Q_new +#endif ); move16(); } @@ -436,8 +446,9 @@ Word16 pit_encode_fx( /* o : Fractional pitc { *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT16k_FR2_EXTEND_10b, PIT16k_MAX, L_FRAME16k, L_SUBFR #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , element_mode, Q_new -#endif + , + element_mode, Q_new +#endif ); move16(); } @@ -481,7 +492,8 @@ Word16 pit_encode_fx( /* o : Fractional pitc /* 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 #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , element_mode, Q_new + , + element_mode, Q_new #endif ); move16(); @@ -508,7 +520,8 @@ Word16 pit_encode_fx( /* o : Fractional pitc /* 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 #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , element_mode, Q_new + , + element_mode, Q_new #endif ); move16(); @@ -539,7 +552,8 @@ Word16 pit_encode_fx( /* o : Fractional pitc /* 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_FR2_9b, PIT_FR1_9b, L_FRAME, L_SUBFR #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , element_mode, Q_new + , + element_mode, Q_new #endif ); move16(); @@ -1524,7 +1538,7 @@ Word16 pitch_fr4_fx( /* o : chosen integer pitch lag else #endif { - norm_corr_fx( exc, xn, h, t_min, t_max, corr, L_subfr ); + norm_corr_fx( exc, xn, h, t_min, t_max, corr, L_subfr ); } /*-----------------------------------------------------------------* * Find integer pitch diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index e11f1886d..011907c19 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -1581,11 +1581,11 @@ void E_ACELP_4t_fx( const Word16 last_L_frame, const Word32 total_brate, const Word16 i_subfr, - const Word16 cmpl_flag + const Word16 cmpl_flag #ifdef REUSE_EVS_BE_ACELP_4T64 , const Word16 element_mode /*Q0*/ -#endif +#endif ); #ifndef REUSE_EVS_BE_ACELP_4T64 @@ -2297,9 +2297,10 @@ void tcx_hm_analyse_fx( const Word16 LtpGain, /* i: LTP gain Q15 */ Word16 *hm_bits_out /* o: bit consumption Q0 */ ); -void E_ACELP_4tsearchx_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_new*/, Word16 Rw[] /*Q9*/, Word16 code[] /*Q9*/, const PulseConfig *config, Word16 ind[] /*Q0*/ +void E_ACELP_4tsearchx_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_new*/, Word16 Rw[] /*Q9*/, Word16 code[] /*Q9*/, const PulseConfig *config, Word16 ind[] /*Q0*/ #ifdef REUSE_EVS_BE_ACELP_4T64 - , const Word16 element_mode + , + const Word16 element_mode #endif ); #ifndef REUSE_EVS_BE_ACELP_4T64 diff --git a/lib_enc/transition_enc_fx.c b/lib_enc/transition_enc_fx.c index 6c147a11a..16f96aae5 100644 --- a/lib_enc/transition_enc_fx.c +++ b/lib_enc/transition_enc_fx.c @@ -291,8 +291,9 @@ void transition_enc_fx( *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, pit_start, pit_limit, L_FRAME, L_SUBFR #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , 0/*st_fx->element_mode*/, Q_new -#endif + , + 0 /*st_fx->element_mode*/, Q_new +#endif ); move16(); @@ -431,7 +432,7 @@ void transition_enc_fx( #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR , 0 /*st_fx->element_mode*/, Q_new -#endif +#endif ); move16(); @@ -499,7 +500,7 @@ void transition_enc_fx( #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR , 0 /*st_fx->element_mode*/, Q_new -#endif +#endif ); move16(); @@ -550,7 +551,7 @@ void transition_enc_fx( #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR , 0 /*st_fx->element_mode*/, Q_new -#endif +#endif ); move16(); index = delta_pit_enc_fx( 2, *T0, *T0_frac, *T0_min ); @@ -584,7 +585,8 @@ void transition_enc_fx( { *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, PIT_MIN, PIT_FR1_8b, L_FRAME, L_SUBFR #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , 0/*st_fx->element_mode*/, Q_new + , + 0 /*st_fx->element_mode*/, Q_new #endif ); move16(); @@ -594,7 +596,8 @@ void transition_enc_fx( { *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, PIT_FR2_9b, PIT_FR1_9b, L_FRAME, L_SUBFR #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , 0/*st_fx->element_mode*/, Q_new + , + 0 /*st_fx->element_mode*/, Q_new #endif ); move16(); @@ -774,8 +777,9 @@ void transition_enc_fx( { *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, limit_flag, PIT16k_FR2_EXTEND_10b, PIT16k_MAX, st_fx->L_frame, L_SUBFR #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , 0/*st_fx->element_mode*/, Q_new -#endif + , + 0 /*st_fx->element_mode*/, Q_new +#endif ); move16(); pit16k_Q_enc_fx( hBstr, nBits, limit_flag, *T0, *T0_frac, T0_min, T0_max ); @@ -789,8 +793,9 @@ void transition_enc_fx( *-----------------------------------------------------------------------------*/ *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, limit_flag, PIT16k_FR2_TC0_2SUBFR, 2 * L_SUBFR, st_fx->L_frame, L_SUBFR #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , 0/*st_fx->element_mode*/, Q_new -#endif + , + 0 /*st_fx->element_mode*/, Q_new +#endif ); move16(); @@ -819,8 +824,9 @@ void transition_enc_fx( /* delta search */ *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, L_SUBFR, limit_flag, PIT16k_FR2_EXTEND_9b, PIT16k_FR1_EXTEND_9b, st_fx->L_frame, L_SUBFR #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , 0/*st_fx->element_mode*/, Q_new -#endif + , + 0 /*st_fx->element_mode*/, Q_new +#endif ); move16(); @@ -1159,8 +1165,9 @@ void transition_enc_ivas_fx( *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, pit_start, pit_limit, L_FRAME, L_SUBFR #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , 0/*st_fx->element_mode*/, Q_new -#endif + , + 0 /*st_fx->element_mode*/, Q_new +#endif ); move16(); @@ -1295,10 +1302,11 @@ void transition_enc_ivas_fx( pit_flag = 0; move16(); - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, pit_start, 3 * L_SUBFR, L_FRAME, L_SUBFR + *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, pit_start, 3 * L_SUBFR, L_FRAME, L_SUBFR #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , 0/*st_fx->element_mode*/, Q_new -#endif + , + 0 /*st_fx->element_mode*/, Q_new +#endif ); move16(); @@ -1364,8 +1372,9 @@ void transition_enc_ivas_fx( *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, PIT_MIN, PIT_FR1_8b, L_FRAME, L_SUBFR #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , 0/*st_fx->element_mode*/, Q_new -#endif + , + 0 /*st_fx->element_mode*/, Q_new +#endif ); move16(); @@ -1415,8 +1424,9 @@ void transition_enc_ivas_fx( *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, PIT_MIN, PIT_FR1_8b, L_FRAME, L_SUBFR #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , 0/*st_fx->element_mode*/, Q_new -#endif + , + 0 /*st_fx->element_mode*/, Q_new +#endif ); move16(); index = delta_pit_enc_fx( 2, *T0, *T0_frac, *T0_min ); @@ -1449,8 +1459,9 @@ void transition_enc_ivas_fx( { *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, PIT_MIN, PIT_FR1_8b, L_FRAME, L_SUBFR #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , 0/*st_fx->element_mode*/, Q_new -#endif + , + 0 /*st_fx->element_mode*/, Q_new +#endif ); move16(); } @@ -1459,8 +1470,9 @@ void transition_enc_ivas_fx( { *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, PIT_FR2_9b, PIT_FR1_9b, L_FRAME, L_SUBFR #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , 0/*st_fx->element_mode*/, Q_new -#endif + , + 0 /*st_fx->element_mode*/, Q_new +#endif ); move16(); } @@ -1511,7 +1523,7 @@ void transition_enc_ivas_fx( xn_fx, y1_fx, xn2_fx, L_SUBFR, st_fx->L_frame, g_corr_fx, *clip_gain, gain_pit_fx, &lp_flag ); #else lp_select = lp_filt_exc_enc_fx( MODE1, TRANSITION, i_subfr, exc_fx, h1_fx, - xn_fx, y1_fx, xn2_fx, L_SUBFR, st_fx->L_frame, g_corr_fx, *clip_gain, gain_pit_fx, &lp_flag ); + xn_fx, y1_fx, xn2_fx, L_SUBFR, st_fx->L_frame, g_corr_fx, *clip_gain, gain_pit_fx, &lp_flag ); #endif IF( EQ_16( lp_flag, NORMAL_OPERATION ) ) { @@ -1646,8 +1658,9 @@ void transition_enc_ivas_fx( { *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, limit_flag, PIT16k_FR2_EXTEND_10b, PIT16k_MAX, st_fx->L_frame, L_SUBFR #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , 0/*st_fx->element_mode*/, Q_new -#endif + , + 0 /*st_fx->element_mode*/, Q_new +#endif ); move16(); #ifndef REUSE_EVS_BE_ACELP_PITCH_PIT_Q @@ -1665,8 +1678,9 @@ void transition_enc_ivas_fx( *-----------------------------------------------------------------------------*/ *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, limit_flag, PIT16k_FR2_TC0_2SUBFR, 2 * L_SUBFR, st_fx->L_frame, L_SUBFR #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , 0/*st_fx->element_mode*/, Q_new -#endif + , + 0 /*st_fx->element_mode*/, Q_new +#endif ); move16(); @@ -1695,8 +1709,9 @@ void transition_enc_ivas_fx( /* delta search */ *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, L_SUBFR, limit_flag, PIT16k_FR2_EXTEND_9b, PIT16k_FR1_EXTEND_9b, st_fx->L_frame, L_SUBFR #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , 0/*st_fx->element_mode*/, Q_new -#endif + , + 0 /*st_fx->element_mode*/, Q_new +#endif ); move16(); @@ -1767,7 +1782,7 @@ void transition_enc_ivas_fx( xn_fx, y1_fx, xn2_fx, L_SUBFR, st_fx->L_frame, g_corr_fx, *clip_gain, gain_pit_fx, &lp_flag ); #else lp_select = lp_filt_exc_enc_fx( MODE1, TRANSITION, i_subfr, exc_fx, h1_fx, - xn_fx, y1_fx, xn2_fx, L_SUBFR, st_fx->L_frame, g_corr_fx, *clip_gain, gain_pit_fx, &lp_flag ); + xn_fx, y1_fx, xn2_fx, L_SUBFR, st_fx->L_frame, g_corr_fx, *clip_gain, gain_pit_fx, &lp_flag ); #endif IF( EQ_16( lp_flag, NORMAL_OPERATION ) ) { @@ -1881,8 +1896,9 @@ static void tc_enc_fx( { *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, 0, PIT_FR2_9b, PIT_FR1_9b, L_FRAME, L_SUBFR #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , 0/*st_fx->element_mode*/, Q_new -#endif + , + 0 /*st_fx->element_mode*/, Q_new +#endif ); move16(); } @@ -1890,8 +1906,9 @@ static void tc_enc_fx( { *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, 0, PIT_MIN, L_SUBFR, L_FRAME, L_SUBFR #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , 0/*st_fx->element_mode*/, Q_new -#endif + , + 0 /*st_fx->element_mode*/, Q_new +#endif ); move16(); } @@ -1899,8 +1916,9 @@ static void tc_enc_fx( { *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, 0, PIT_MAX, PIT_MIN, L_FRAME, L_SUBFR #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , 0/*st_fx->element_mode*/, Q_new -#endif + , + 0 /*st_fx->element_mode*/, Q_new +#endif ); move16(); } @@ -1923,18 +1941,20 @@ static void tc_enc_fx( { *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, 1, PIT16k_FR2_EXTEND_10b, PIT16k_MAX, L_FRAME16k, L_SUBFR #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , 0/*st_fx->element_mode*/, Q_new -#endif + , + 0 /*st_fx->element_mode*/, Q_new +#endif ); move16(); } ELSE IF( EQ_16( nBits, 6 ) ) { /* T0_frac with 1/2 sample resolution */ - *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, 0, PIT16k_MIN, L_SUBFR, L_FRAME16k, L_SUBFR + *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, 0, PIT16k_MIN, L_SUBFR, L_FRAME16k, L_SUBFR #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , 0/*st_fx->element_mode*/, Q_new -#endif + , + 0 /*st_fx->element_mode*/, Q_new +#endif ); move16(); IF( *T0 > L_SUBFR ) @@ -2118,8 +2138,9 @@ static void tc_enc_ivas_fx( { *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1, *T0_min, *T0_max, T0_frac, 0, 0, PIT_FR2_9b, PIT_FR1_9b, L_FRAME, L_SUBFR #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , 0/*st_fx->element_mode*/, Q_new -#endif + , + 0 /*st_fx->element_mode*/, Q_new +#endif ); move16(); } @@ -2127,8 +2148,9 @@ static void tc_enc_ivas_fx( { *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1, *T0_min, *T0_max, T0_frac, 0, 0, PIT_MIN, L_SUBFR, L_FRAME, L_SUBFR #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , 0/*st_fx->element_mode*/, Q_new -#endif + , + 0 /*st_fx->element_mode*/, Q_new +#endif ); move16(); } @@ -2136,8 +2158,9 @@ static void tc_enc_ivas_fx( { *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1, *T0_min, *T0_max, T0_frac, 0, 0, PIT_MAX, PIT_MIN, L_FRAME, L_SUBFR #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , 0/*st_fx->element_mode*/, Q_new -#endif + , + 0 /*st_fx->element_mode*/, Q_new +#endif ); move16(); } @@ -2160,8 +2183,9 @@ static void tc_enc_ivas_fx( { *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1, *T0_min, *T0_max, T0_frac, 0, 1, PIT16k_FR2_EXTEND_10b, PIT16k_MAX, L_FRAME16k, L_SUBFR #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , 0/*st_fx->element_mode*/, Q_new -#endif + , + 0 /*st_fx->element_mode*/, Q_new +#endif ); move16(); } @@ -2170,8 +2194,9 @@ static void tc_enc_ivas_fx( /* T0_frac with 1/2 sample resolution */ *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1, *T0_min, *T0_max, T0_frac, 0, 0, PIT16k_MIN, L_SUBFR, L_FRAME16k, L_SUBFR #if defined REUSE_EVS_BE_ACELP_PITCH && !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , 0/*st_fx->element_mode*/, Q_new -#endif + , + 0 /*st_fx->element_mode*/, Q_new +#endif ); IF( *T0 > L_SUBFR ) { -- GitLab From 252cf9ff36200bf14f7055bfaaf6eb559dd8597b Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 12 Aug 2025 19:57:59 -0400 Subject: [PATCH 04/18] small typo --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 5c0131fec..0ae8abd32 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -98,7 +98,7 @@ #define REUSE_EVS_BE_ACELP_2t32 #define REUSE_EVS_BE_ACELP_1t64 #define REUSE_EVS_BE_ACELP_AVQ -#define REUSE_EVS_BE_GAUSS +#define REUSE_EVS_BE_GAUSS #define REUSE_EVS_BE_GAINQ #define REUSE_EVS_BE_ACELP_PITCH #define REUSE_EVS_BE_ACELP_PITCH_PIT_Q -- GitLab From 49eac681489445145f428ea441297ae2173f29fa Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 12 Aug 2025 20:01:48 -0400 Subject: [PATCH 05/18] fix clang --- lib_enc/enc_acelpx_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/enc_acelpx_fx.c b/lib_enc/enc_acelpx_fx.c index e0cf49264..8b240a362 100644 --- a/lib_enc/enc_acelpx_fx.c +++ b/lib_enc/enc_acelpx_fx.c @@ -925,4 +925,4 @@ void E_ACELP_4tsearchx_ivas_fx( } } } -#endif \ No newline at end of file +#endif -- GitLab From 93a9726877ec69a05f99ea2e2ff22de6c2346fa0 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 12 Aug 2025 20:13:05 -0400 Subject: [PATCH 06/18] fix linux built --- lib_enc/avq_cod_fx.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib_enc/avq_cod_fx.c b/lib_enc/avq_cod_fx.c index 8d08dcb4f..41e0eb03d 100644 --- a/lib_enc/avq_cod_fx.c +++ b/lib_enc/avq_cod_fx.c @@ -14,8 +14,9 @@ * Local prototypes *-------------------------------------------------------------------*/ static void wrte_cv( BSTR_ENC_HANDLE hBstr, const Word16 nq, const Word16 i_ind, const Word16 kv_ind, UWord16 I, Word16 kv[], Word16 *bits ); +#ifndef REUSE_EVS_BE_ACELP_AVQ static void wrte_cv_ivas_fx( BSTR_ENC_HANDLE hBstr, const Word16 nq, const Word16 i_ind, const Word16 kv_ind, UWord16 I, Word16 kv[], Word16 *bits ); - +#endif /*-------------------------------------------------------------------* * Function AVQ_cod() * * * @@ -1184,7 +1185,7 @@ static void wrte_cv( move16(); return; } - +#ifdef REUSE_EVS_BE_ACELP_AVQ static void wrte_cv_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 nq, /* i : AVQ nq index */ @@ -1244,3 +1245,4 @@ static void wrte_cv_ivas_fx( move16(); return; } +#endif \ No newline at end of file -- GitLab From 1cfd99d332c1fc9d14499ed1ce258eae9025d1e2 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 12 Aug 2025 20:26:55 -0400 Subject: [PATCH 07/18] fix clang --- lib_enc/avq_cod_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/avq_cod_fx.c b/lib_enc/avq_cod_fx.c index 41e0eb03d..96e5489c7 100644 --- a/lib_enc/avq_cod_fx.c +++ b/lib_enc/avq_cod_fx.c @@ -1245,4 +1245,4 @@ static void wrte_cv_ivas_fx( move16(); return; } -#endif \ No newline at end of file +#endif -- GitLab From c7bbe25ca5d261ffa17246f80aa10dfc0b51c25f Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 12 Aug 2025 20:29:52 -0400 Subject: [PATCH 08/18] fix clang --- lib_enc/avq_cod_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/avq_cod_fx.c b/lib_enc/avq_cod_fx.c index 96e5489c7..b92208458 100644 --- a/lib_enc/avq_cod_fx.c +++ b/lib_enc/avq_cod_fx.c @@ -1185,7 +1185,7 @@ static void wrte_cv( move16(); return; } -#ifdef REUSE_EVS_BE_ACELP_AVQ +#ifndef REUSE_EVS_BE_ACELP_AVQ static void wrte_cv_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 nq, /* i : AVQ nq index */ -- GitLab From 51e30f559013841a0d23c748470b21f64ec26a06 Mon Sep 17 00:00:00 2001 From: Tommy Date: Wed, 13 Aug 2025 06:22:40 -0400 Subject: [PATCH 09/18] fix an none-bitexact case found for REUSE_EVS_BE_ACELP_4T64 --- lib_enc/enc_acelpx_fx.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/lib_enc/enc_acelpx_fx.c b/lib_enc/enc_acelpx_fx.c index 8b240a362..0ce5bd2aa 100644 --- a/lib_enc/enc_acelpx_fx.c +++ b/lib_enc/enc_acelpx_fx.c @@ -408,12 +408,26 @@ void E_ACELP_4tsearchx_fx( nb_pulse_m2 = sub( nb_pulse, 2 ); /* Init to avoid crash when the search does not find a solution */ - FOR( k = 0; k < nb_pulse; k++ ) +#ifdef REUSE_EVS_BE_ACELP_4T64 + IF( EQ_16( element_mode, EVS_MONO ) ) +#endif { - codvec[k] = k; - move16(); + FOR( k = 0; k < nb_pulse; k++ ) + { + codvec[k] = k; + move16(); + } } - +#ifdef REUSE_EVS_BE_ACELP_4T64 + ELSE + { + FOR( k = 0; k < nb_pulse; k++ ) + { + codvec[k] = s_and( k, 3 ); + move16(); + } + } +#endif scale = 0; move16(); s = L_mult0( Rw[0], Rw[0] ); /*Q18*/ -- GitLab From 50dd9f15ef58ca09044a6960e6c5704377109e26 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Wed, 13 Aug 2025 10:13:14 -0400 Subject: [PATCH 10/18] fix ISM high rate BE issue --- lib_enc/avq_cod_fx.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib_enc/avq_cod_fx.c b/lib_enc/avq_cod_fx.c index b92208458..4c4888184 100644 --- a/lib_enc/avq_cod_fx.c +++ b/lib_enc/avq_cod_fx.c @@ -471,7 +471,11 @@ void AVQ_encmux_fx( bitsMod = 0; move16(); } - ELSE IF( nq_est > 4 && ( ( bitsMod == 0 && GT_16( nullVec, 3 ) && GT_16( nullVec, 6 ) ) || ( EQ_16( bitsMod, 4 ) && EQ_16( nullVec, 5 ) ) ) && nq[svOrder[Nsvm2]] == 0 ) /* wasted bits 4, 5 for nq 6,7..*/ +#ifdef REUSE_EVS_BE_ACELP_AVQ + ELSE IF( GT_16( nq_est, 4 ) && ( ( bitsMod == 0 && GT_16( nullVec, 3 ) && LT_16( nullVec, 6 ) ) || ( EQ_16( bitsMod, 4 ) && EQ_16( nullVec, 5 ) ) ) && nq[svOrder[Nsvm2]] == 0 ) /* wasted bits 4, 5 for nq 6,7..*/ +#else + ELSE IF( nq_est > 4 && ( ( bitsMod == 0 && GT_16( nullVec, 3 ) && GT_16( nullVec, 6 ) ) || ( EQ_16( bitsMod, 4 ) && EQ_16( nullVec, 5 ) ) ) && nq[svOrder[Nsvm2]] == 0 ) /* wasted bits 4, 5 for nq 6,7..*/ +#endif { overflow = 0; move16(); @@ -858,7 +862,7 @@ void AVQ_encmux_ivas_fx( bits = sub( bits, 1 ); } - wrte_cv_ivas_fx( hBstr, nq[k], i_ind, kv_ind, I[k], &kv[k * 8], &bits ); + wrte_cv( hBstr, nq[k], i_ind, kv_ind, I[k], &kv[k * 8], &bits ); } } /* for */ /* Bit Saving Solution */ @@ -1016,7 +1020,7 @@ void AVQ_encmux_ivas_fx( move16(); /* write codebook indices (rank I and event. Voronoi index kv) */ - wrte_cv_ivas_fx( hBstr, nq[i], i_ind, kv_ind, I[i], &kv[i * 8], &bits ); + wrte_cv( hBstr, nq[i], i_ind, kv_ind, I[i], &kv[i * 8], &bits ); bits = sub( bits, dummy_bits ); -- GitLab From 49f1218738e3247252a803e554530498119e0be2 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Wed, 13 Aug 2025 10:40:39 -0400 Subject: [PATCH 11/18] fix EVS bit exact issue related to cod4t64 --- lib_enc/enc_acelpx_fx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_enc/enc_acelpx_fx.c b/lib_enc/enc_acelpx_fx.c index 0ce5bd2aa..cde026fb3 100644 --- a/lib_enc/enc_acelpx_fx.c +++ b/lib_enc/enc_acelpx_fx.c @@ -578,7 +578,8 @@ void E_ACELP_4tsearchx_fx( } #ifdef REUSE_EVS_BE_ACELP_4T64 - IF( GT_16( alp, ONE_IN_Q14 ) ) + test(); + IF( GT_16( alp, ONE_IN_Q14 ) && ( element_mode > EVS_MONO ) ) { alp = shr( alp, 1 ); Scale_sig( cor, L_SUBFR, -1 ); /*Q8*/ -- GitLab From 27b9ab132ce9d599d70ef2bd2b3992cab348a799 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Wed, 13 Aug 2025 10:48:08 -0400 Subject: [PATCH 12/18] fix clang-format --- lib_enc/avq_cod_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/avq_cod_fx.c b/lib_enc/avq_cod_fx.c index 4c4888184..27f385b52 100644 --- a/lib_enc/avq_cod_fx.c +++ b/lib_enc/avq_cod_fx.c @@ -474,7 +474,7 @@ void AVQ_encmux_fx( #ifdef REUSE_EVS_BE_ACELP_AVQ ELSE IF( GT_16( nq_est, 4 ) && ( ( bitsMod == 0 && GT_16( nullVec, 3 ) && LT_16( nullVec, 6 ) ) || ( EQ_16( bitsMod, 4 ) && EQ_16( nullVec, 5 ) ) ) && nq[svOrder[Nsvm2]] == 0 ) /* wasted bits 4, 5 for nq 6,7..*/ #else - ELSE IF( nq_est > 4 && ( ( bitsMod == 0 && GT_16( nullVec, 3 ) && GT_16( nullVec, 6 ) ) || ( EQ_16( bitsMod, 4 ) && EQ_16( nullVec, 5 ) ) ) && nq[svOrder[Nsvm2]] == 0 ) /* wasted bits 4, 5 for nq 6,7..*/ + ELSE IF( nq_est > 4 && ( ( bitsMod == 0 && GT_16( nullVec, 3 ) && GT_16( nullVec, 6 ) ) || ( EQ_16( bitsMod, 4 ) && EQ_16( nullVec, 5 ) ) ) && nq[svOrder[Nsvm2]] == 0 ) /* wasted bits 4, 5 for nq 6,7..*/ #endif { overflow = 0; -- GitLab From de23bf36057b0645bb1c18ff0df16fbbf0b6d29a Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Wed, 13 Aug 2025 12:39:59 -0400 Subject: [PATCH 13/18] fix BE issue with stereo_dmx_evs --- lib_enc/cod4t64_fx.c | 5 ++++- lib_enc/enc_acelp_fx.c | 11 ++++++++++- lib_enc/prot_fx_enc.h | 4 +++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/lib_enc/cod4t64_fx.c b/lib_enc/cod4t64_fx.c index c4e7c9b6b..725fbfe3d 100644 --- a/lib_enc/cod4t64_fx.c +++ b/lib_enc/cod4t64_fx.c @@ -313,8 +313,11 @@ Word16 acelp_4t64_fx( } ELSE { +#ifdef REUSE_EVS_BE_ACELP_4T64 + E_ACELP_4tsearch_fx( dn, cn, H, code, &config, ind, y, element_mode ); +#else E_ACELP_4tsearch_fx( dn, cn, H, code, &config, ind, y ); - +#endif FOR( i = 0; i < L_SUBFR; i++ ) { y[i] = shr( y[i], 3 ); diff --git a/lib_enc/enc_acelp_fx.c b/lib_enc/enc_acelp_fx.c index 3dd0bba24..e9feb81d3 100644 --- a/lib_enc/enc_acelp_fx.c +++ b/lib_enc/enc_acelp_fx.c @@ -1071,7 +1071,11 @@ void E_ACELP_corrmatrix_fx( Word16 h[] /*Q12*/, Word16 sign[] /*Q0*/, Word16 vec return; } +#ifndef REUSE_EVS_BE_ACELP_4T64 void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const Word16 H[] /*Q12*/, Word16 code[] /*Q9*/, const PulseConfig *config, Word16 ind[] /*Q0*/, Word16 y[] /*Qy*/ ) +#else +void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const Word16 H[] /*Q12*/, Word16 code[] /*Q9*/, const PulseConfig *config, Word16 ind[] /*Q0*/, Word16 y[] /*Qy*/, const Word16 element_mode ) +#endif { Word16 sign[L_SUBFR], vec[L_SUBFR]; Word16 cor_x[16], cor_y[16], h_buf[4 * L_SUBFR]; @@ -1148,7 +1152,8 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const move16(); } #ifdef REUSE_EVS_BE_ACELP_4T64 /* To be verified if it affects BE on 26.444, if yes, just a condition for IVAS here*/ - if ( EQ_16( val, 32767 ) ) + test(); + if ( EQ_16( val, 32767 ) && element_mode > EVS_MONO ) { scale = -3; move16(); @@ -1822,7 +1827,11 @@ void E_ACELP_4t_fx( } ELSE { +#ifndef REUSE_EVS_BE_ACELP_4T64 E_ACELP_4tsearch_fx( dn, cn, H, code, &config, ind, y ); +#else + E_ACELP_4tsearch_fx( dn, cn, H, code, &config, ind, y, element_mode ); +#endif } E_ACELP_indexing_fx( code, &config, NB_TRACK_FCB_4T, _index ); return; diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index ba49dea10..a1c09b126 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -1564,9 +1564,11 @@ void Mode2_pit_encode_fx( Word16 pit_fr2, Word16 pit_max, Word16 pit_res_max ); -void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const Word16 H[] /*Q12*/, Word16 code[] /*Q9*/, const PulseConfig *config, Word16 ind[] /*Q0*/, Word16 y[] /*Qy*/ ); #ifndef REUSE_EVS_BE_ACELP_4T64 +void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const Word16 H[] /*Q12*/, Word16 code[] /*Q9*/, const PulseConfig *config, Word16 ind[] /*Q0*/, Word16 y[] /*Qy*/ ); void E_ACELP_4tsearch_ivas_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const Word16 H[] /*Q12*/, Word16 code[] /*Q9*/, const PulseConfig *config, Word16 ind[] /*Q0*/, Word16 y[] /*Qy*/ ); +#else +void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const Word16 H[] /*Q12*/, Word16 code[] /*Q9*/, const PulseConfig *config, Word16 ind[] /*Q0*/, Word16 y[] /*Qy*/, const Word16 element_mode ); #endif void E_ACELP_4t_fx( Word16 dn[], /* Qdn */ -- GitLab From 2c5a674d1b44cae0669f4b8301beed89e6bab772 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Wed, 13 Aug 2025 17:21:13 -0400 Subject: [PATCH 14/18] fix ism4, issue was related to old code no more into the the main --- lib_enc/enc_acelp_fx.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/lib_enc/enc_acelp_fx.c b/lib_enc/enc_acelp_fx.c index e9feb81d3..86a9e2f3d 100644 --- a/lib_enc/enc_acelp_fx.c +++ b/lib_enc/enc_acelp_fx.c @@ -1151,14 +1151,7 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const scale = -2; move16(); } -#ifdef REUSE_EVS_BE_ACELP_4T64 /* To be verified if it affects BE on 26.444, if yes, just a condition for IVAS here*/ - test(); - if ( EQ_16( val, 32767 ) && element_mode > EVS_MONO ) - { - scale = -3; - move16(); - } -#endif + Copy_Scale_sig( H, h, L_SUBFR, scale ); /*Q12+scale*/ E_ACELP_vec_neg_fx( h, h_inv, L_SUBFR ); -- GitLab From a025941b762aac3f6076b038e4f0257ab371d6bd Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Wed, 13 Aug 2025 19:09:13 -0400 Subject: [PATCH 15/18] fix linux build --- lib_enc/cod4t64_fx.c | 5 +---- lib_enc/enc_acelp_fx.c | 8 -------- lib_enc/prot_fx_enc.h | 4 +--- 3 files changed, 2 insertions(+), 15 deletions(-) diff --git a/lib_enc/cod4t64_fx.c b/lib_enc/cod4t64_fx.c index 725fbfe3d..c4e7c9b6b 100644 --- a/lib_enc/cod4t64_fx.c +++ b/lib_enc/cod4t64_fx.c @@ -313,11 +313,8 @@ Word16 acelp_4t64_fx( } ELSE { -#ifdef REUSE_EVS_BE_ACELP_4T64 - E_ACELP_4tsearch_fx( dn, cn, H, code, &config, ind, y, element_mode ); -#else E_ACELP_4tsearch_fx( dn, cn, H, code, &config, ind, y ); -#endif + FOR( i = 0; i < L_SUBFR; i++ ) { y[i] = shr( y[i], 3 ); diff --git a/lib_enc/enc_acelp_fx.c b/lib_enc/enc_acelp_fx.c index 86a9e2f3d..292ae94a3 100644 --- a/lib_enc/enc_acelp_fx.c +++ b/lib_enc/enc_acelp_fx.c @@ -1071,11 +1071,7 @@ void E_ACELP_corrmatrix_fx( Word16 h[] /*Q12*/, Word16 sign[] /*Q0*/, Word16 vec return; } -#ifndef REUSE_EVS_BE_ACELP_4T64 void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const Word16 H[] /*Q12*/, Word16 code[] /*Q9*/, const PulseConfig *config, Word16 ind[] /*Q0*/, Word16 y[] /*Qy*/ ) -#else -void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const Word16 H[] /*Q12*/, Word16 code[] /*Q9*/, const PulseConfig *config, Word16 ind[] /*Q0*/, Word16 y[] /*Qy*/, const Word16 element_mode ) -#endif { Word16 sign[L_SUBFR], vec[L_SUBFR]; Word16 cor_x[16], cor_y[16], h_buf[4 * L_SUBFR]; @@ -1820,11 +1816,7 @@ void E_ACELP_4t_fx( } ELSE { -#ifndef REUSE_EVS_BE_ACELP_4T64 E_ACELP_4tsearch_fx( dn, cn, H, code, &config, ind, y ); -#else - E_ACELP_4tsearch_fx( dn, cn, H, code, &config, ind, y, element_mode ); -#endif } E_ACELP_indexing_fx( code, &config, NB_TRACK_FCB_4T, _index ); return; diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index a1c09b126..ba1b9af5c 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -1565,11 +1565,9 @@ void Mode2_pit_encode_fx( Word16 pit_max, Word16 pit_res_max ); #ifndef REUSE_EVS_BE_ACELP_4T64 -void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const Word16 H[] /*Q12*/, Word16 code[] /*Q9*/, const PulseConfig *config, Word16 ind[] /*Q0*/, Word16 y[] /*Qy*/ ); void E_ACELP_4tsearch_ivas_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const Word16 H[] /*Q12*/, Word16 code[] /*Q9*/, const PulseConfig *config, Word16 ind[] /*Q0*/, Word16 y[] /*Qy*/ ); -#else -void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const Word16 H[] /*Q12*/, Word16 code[] /*Q9*/, const PulseConfig *config, Word16 ind[] /*Q0*/, Word16 y[] /*Qy*/, const Word16 element_mode ); #endif +void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const Word16 H[] /*Q12*/, Word16 code[] /*Q9*/, const PulseConfig *config, Word16 ind[] /*Q0*/, Word16 y[] /*Qy*/ ); void E_ACELP_4t_fx( Word16 dn[], /* Qdn */ Word16 cn[] /* Q_xn */, -- GitLab From 3e393e81bae2122ce10aaaeaac9749f970380639 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Thu, 14 Aug 2025 06:05:16 -0400 Subject: [PATCH 16/18] Revert "fix linux build" This reverts commit a025941b762aac3f6076b038e4f0257ab371d6bd. --- lib_enc/cod4t64_fx.c | 5 ++++- lib_enc/enc_acelp_fx.c | 8 ++++++++ lib_enc/prot_fx_enc.h | 4 +++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib_enc/cod4t64_fx.c b/lib_enc/cod4t64_fx.c index c4e7c9b6b..725fbfe3d 100644 --- a/lib_enc/cod4t64_fx.c +++ b/lib_enc/cod4t64_fx.c @@ -313,8 +313,11 @@ Word16 acelp_4t64_fx( } ELSE { +#ifdef REUSE_EVS_BE_ACELP_4T64 + E_ACELP_4tsearch_fx( dn, cn, H, code, &config, ind, y, element_mode ); +#else E_ACELP_4tsearch_fx( dn, cn, H, code, &config, ind, y ); - +#endif FOR( i = 0; i < L_SUBFR; i++ ) { y[i] = shr( y[i], 3 ); diff --git a/lib_enc/enc_acelp_fx.c b/lib_enc/enc_acelp_fx.c index 292ae94a3..86a9e2f3d 100644 --- a/lib_enc/enc_acelp_fx.c +++ b/lib_enc/enc_acelp_fx.c @@ -1071,7 +1071,11 @@ void E_ACELP_corrmatrix_fx( Word16 h[] /*Q12*/, Word16 sign[] /*Q0*/, Word16 vec return; } +#ifndef REUSE_EVS_BE_ACELP_4T64 void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const Word16 H[] /*Q12*/, Word16 code[] /*Q9*/, const PulseConfig *config, Word16 ind[] /*Q0*/, Word16 y[] /*Qy*/ ) +#else +void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const Word16 H[] /*Q12*/, Word16 code[] /*Q9*/, const PulseConfig *config, Word16 ind[] /*Q0*/, Word16 y[] /*Qy*/, const Word16 element_mode ) +#endif { Word16 sign[L_SUBFR], vec[L_SUBFR]; Word16 cor_x[16], cor_y[16], h_buf[4 * L_SUBFR]; @@ -1816,7 +1820,11 @@ void E_ACELP_4t_fx( } ELSE { +#ifndef REUSE_EVS_BE_ACELP_4T64 E_ACELP_4tsearch_fx( dn, cn, H, code, &config, ind, y ); +#else + E_ACELP_4tsearch_fx( dn, cn, H, code, &config, ind, y, element_mode ); +#endif } E_ACELP_indexing_fx( code, &config, NB_TRACK_FCB_4T, _index ); return; diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index ba1b9af5c..a1c09b126 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -1565,9 +1565,11 @@ void Mode2_pit_encode_fx( Word16 pit_max, Word16 pit_res_max ); #ifndef REUSE_EVS_BE_ACELP_4T64 +void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const Word16 H[] /*Q12*/, Word16 code[] /*Q9*/, const PulseConfig *config, Word16 ind[] /*Q0*/, Word16 y[] /*Qy*/ ); void E_ACELP_4tsearch_ivas_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const Word16 H[] /*Q12*/, Word16 code[] /*Q9*/, const PulseConfig *config, Word16 ind[] /*Q0*/, Word16 y[] /*Qy*/ ); +#else +void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const Word16 H[] /*Q12*/, Word16 code[] /*Q9*/, const PulseConfig *config, Word16 ind[] /*Q0*/, Word16 y[] /*Qy*/, const Word16 element_mode ); #endif -void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const Word16 H[] /*Q12*/, Word16 code[] /*Q9*/, const PulseConfig *config, Word16 ind[] /*Q0*/, Word16 y[] /*Qy*/ ); void E_ACELP_4t_fx( Word16 dn[], /* Qdn */ Word16 cn[] /* Q_xn */, -- GitLab From 6e08f14570bdc31c3a9ab37eed22b9680ad7ffc5 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Thu, 14 Aug 2025 06:05:50 -0400 Subject: [PATCH 17/18] Revert "fix ism4, issue was related to old code no more into the the main" This reverts commit 2c5a674d1b44cae0669f4b8301beed89e6bab772. --- lib_enc/enc_acelp_fx.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib_enc/enc_acelp_fx.c b/lib_enc/enc_acelp_fx.c index 86a9e2f3d..e9feb81d3 100644 --- a/lib_enc/enc_acelp_fx.c +++ b/lib_enc/enc_acelp_fx.c @@ -1151,7 +1151,14 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const scale = -2; move16(); } - +#ifdef REUSE_EVS_BE_ACELP_4T64 /* To be verified if it affects BE on 26.444, if yes, just a condition for IVAS here*/ + test(); + if ( EQ_16( val, 32767 ) && element_mode > EVS_MONO ) + { + scale = -3; + move16(); + } +#endif Copy_Scale_sig( H, h, L_SUBFR, scale ); /*Q12+scale*/ E_ACELP_vec_neg_fx( h, h_inv, L_SUBFR ); -- GitLab From 665d831fc3b0e21d1c38cbd0cdcdad9ca242e1a6 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Thu, 14 Aug 2025 08:46:38 -0400 Subject: [PATCH 18/18] fix BE issue --- lib_enc/cod4t64_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/cod4t64_fx.c b/lib_enc/cod4t64_fx.c index 725fbfe3d..6d9e8fa43 100644 --- a/lib_enc/cod4t64_fx.c +++ b/lib_enc/cod4t64_fx.c @@ -314,7 +314,7 @@ Word16 acelp_4t64_fx( ELSE { #ifdef REUSE_EVS_BE_ACELP_4T64 - E_ACELP_4tsearch_fx( dn, cn, H, code, &config, ind, y, element_mode ); + E_ACELP_4tsearch_fx( dn, cn, H, code, &config, ind, y, 0 ); #else E_ACELP_4tsearch_fx( dn, cn, H, code, &config, ind, y ); #endif -- GitLab