diff --git a/lib_com/options.h b/lib_com/options.h index 572c4762006c83b7f224412714b1deb5d3cbb4d4..794a315daf7d932e8d6d337983795083c4d4c1eb 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -88,6 +88,24 @@ #define FIX_1931_BIN_COHR_CROSS_MIX /* FhG: correct binauralCoherenceCrossmixGains_fx calculation */ + +#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() */ + /* #################### Start BASOP porting switches ############################ */ #define FIX_1372_ISAR_POST_REND diff --git a/lib_enc/acelp_core_switch_enc_fx.c b/lib_enc/acelp_core_switch_enc_fx.c index 4de3ebe7d4237cca85038f9c330ded58dd254b7f..1854b2875afeccd5ed2b3dff9b683f0c2e1431f9 100644 --- a/lib_enc/acelp_core_switch_enc_fx.c +++ b/lib_enc/acelp_core_switch_enc_fx.c @@ -412,7 +412,12 @@ 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 +623,18 @@ 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 *-----------------------------------------------------------------*/ @@ -638,10 +651,13 @@ 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 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 +673,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 +684,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 +741,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 b3a49c59ef44f47907cd76b13c71eb34b8156521..27f385b5212555271c38a3a432c1a3c4659642f6 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() * * * @@ -182,7 +183,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 +347,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 +423,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 ) ) @@ -445,11 +471,25 @@ void AVQ_encmux_fx( bitsMod = 0; move16(); } +#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(); +#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 +516,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 +557,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 +613,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 */ @@ -807,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 */ @@ -965,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 ); @@ -985,7 +1040,7 @@ void AVQ_encmux_ivas_fx( return; } - +#endif /*-------------------------------------------------------------------* * Function AVQ_cod_lpc_fx() * * * @@ -1134,7 +1189,7 @@ static void wrte_cv( move16(); return; } - +#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 */ @@ -1194,3 +1249,4 @@ static void wrte_cv_ivas_fx( move16(); return; } +#endif diff --git a/lib_enc/cod2t32_fx.c b/lib_enc/cod2t32_fx.c index dc967e656015c19b31d029321709cc01eef3608d..e3761618250f513adde23630047a530f3b6f13b5 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 457a129b839cc96400674fb882c3fd05b6e07616..6d9e8fa431ae6bb6435adcf5f16d8b985564d9a5 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,15 +303,21 @@ 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 ); } ELSE { +#ifdef REUSE_EVS_BE_ACELP_4T64 + 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 FOR( i = 0; i < L_SUBFR; i++ ) { y[i] = shr( y[i], 3 ); @@ -468,7 +478,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 +892,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 f6a8e65b26ca963080b429dcf85e0661e0902f0c..e9feb81d381af6bf3de9774d81d49f8e0a8c3c61 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]; @@ -1147,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 ); @@ -1390,7 +1401,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 +1726,7 @@ void E_ACELP_4tsearch_ivas_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, } return; } - +#endif /* * E_ACELP_4t_fx * @@ -1763,7 +1774,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,16 +1819,24 @@ 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 { +#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; } - +#ifndef REUSE_EVS_BE_ACELP_4T64 void E_ACELP_4t_ivas_fx( Word16 dn[], /*Qdn*/ Word16 cn[] /* Q_xn */, @@ -1876,7 +1900,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 +2323,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 1a17a0f9c2a7b1974c63f5e9aca4204e0dd86c40..cde026fb3b3045942741dd2a8f71740a678455bb 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(); @@ -398,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*/ @@ -553,7 +577,16 @@ void E_ACELP_4tsearchx_fx( &ind[j], dn, cor, sign, sign_val_1 ); } - +#ifdef REUSE_EVS_BE_ACELP_4T64 + test(); + IF( GT_16( alp, ONE_IN_Q14 ) && ( element_mode > EVS_MONO ) ) + { + 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 +601,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 +615,56 @@ void E_ACELP_4tsearchx_fx( /* * Store weighted energy of code, build the codeword and index of codevector. */ - E_ACELP_build_code( nb_pulse, codvec, sign, code, ind ); -} +#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 +940,4 @@ void E_ACELP_4tsearchx_ivas_fx( } } } +#endif diff --git a/lib_enc/enc_amr_wb_fx.c b/lib_enc/enc_amr_wb_fx.c index 4c5268017f3c99d751c86272f368064d3209adc2..d9048ac69245bd8fb7928c129b2593615368da9e 100644 --- a/lib_enc/enc_amr_wb_fx.c +++ b/lib_enc/enc_amr_wb_fx.c @@ -146,7 +146,12 @@ 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 01261f78b0172fdaee80500db8481942759f53ce..26b8ec31e1b810798f7241eebad9973833921a59 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -246,8 +246,12 @@ void encod_gen_voic_fx( *----------------------------------------------------------------*/ *pt_pitch_fx = pit_encode_fx( hBstr, st_fx->acelp_cfg.pitch_bits, st_fx->core_brate, 0, L_frame, st_fx->coder_type, &pitch_limit_flag, i_subfr_fx, exc_fx, - L_SUBFR, st_fx->pitch, &T0_min_fx, &T0_max_fx, &T0_fx, &T0_frac_fx, h1_fx, xn_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf ); /* Q6 */ - + 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 ); /*-----------------------------------------------------------------* @@ -310,7 +314,12 @@ 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 ) ) { @@ -619,8 +628,18 @@ void encod_gen_voic_ivas_fx( * Close-loop pitch search and quantization *----------------------------------------------------------------*/ +#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 ); @@ -647,9 +666,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 ) ) { @@ -678,7 +701,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, @@ -694,6 +717,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 00b18f79d21242c3b6a4392a3baf3520dda5eea3..986bdde0bcaff2a50c6e61f8951fea7b2fe86ac1 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 5f173cd7f5e6a9869e3597cef881f91201418885..395f7da93fb1e0ba33e47cea8575e36c542fbd4f 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -263,7 +263,12 @@ 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 +333,12 @@ 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 +748,19 @@ 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 +779,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 +829,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 +851,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 fb601aebad7dc48ac4fea83e31633876ad84ec0e..23f1377aa89361247018aeff3097701bf9158283 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 887b4afb89415cb4b620ecf726a04924a72a21c9..8600c0043ce82a64a071a37e169b4163ee28ab57 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 5e2a111693f72c8b8d5964b36708897b451935dd..ea7a266854120a009a806697a2ea73ededc2176e 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,28 @@ 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))); */ - 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*/ - +#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 +2470,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 +2920,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 b6ef2d84f3e548124c644a3a6b281ff09eaf7b2a..986f15bbc0e5d304b5457b96902d0488e07acf76 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 02ef250961a34f494fcf68dd187155763948c394..86200cb43b972873e64c1605b3ee9d82b33b0f7d 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 e2c12076d416a8fb0787181cdb5b6fab2da2841e..d25e222f2b467ccdf8e2abd1b407947e6680cf74 100644 --- a/lib_enc/ivas_td_low_rate_enc_fx.c +++ b/lib_enc/ivas_td_low_rate_enc_fx.c @@ -274,7 +274,16 @@ 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 +306,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 +325,16 @@ 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 01005f6419fac1fdfb8a1c1dad6f30bdb96f60e1..4172f5bcace767aded76924fcfc739c2d6540432 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 8eea1b3d52b398655e3a8b03fc5a76262f006ed9..510761a63f703a78c7f10063c1a06ae01f1a66b5 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,12 @@ 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 +265,86 @@ 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 +374,22 @@ 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 +397,33 @@ 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 +434,22 @@ 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 +490,12 @@ 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 +518,12 @@ 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 +550,12 @@ 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 +571,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 +745,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 +784,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 +831,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 +901,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 +921,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 +1016,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 +1032,7 @@ Word16 pit_encode_ivas_fx( /* o : Fractional return pitch_cl; } - +#endif /*-------------------------------------------------------------------* * abs_pit_enc() * @@ -1110,6 +1264,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 +1456,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 +1471,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 +1530,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] */ - - norm_corr_fx( exc, xn, h, t_min, t_max, corr, L_subfr ); - +#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 +1960,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 +2053,7 @@ void pit_Q_enc_ivas_fx( return; } - +#endif /*-------------------------------------------------------------------* * pit16k_Q_enc() * @@ -1963,6 +2131,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 +2204,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 a4c439c1d22bb79b0b1b55fbd2fb002aac1d6255..a1c09b1269fa63e2770ec2528f36844192295a70 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[] ); @@ -1557,10 +1564,12 @@ void Mode2_pit_encode_fx( Word16 pit_fr2, 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_4t_fx( Word16 dn[], /* Qdn */ Word16 cn[] /* Q_xn */, @@ -1574,8 +1583,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 +1606,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 +2299,13 @@ 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 +2314,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*/ @@ -3447,8 +3467,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 */ @@ -3471,7 +3497,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 */ @@ -3488,7 +3514,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 */ @@ -3505,7 +3531,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 */ @@ -3577,7 +3603,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*/ @@ -3598,6 +3624,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 */ @@ -3772,8 +3799,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*/ @@ -3794,7 +3825,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*/ @@ -3812,7 +3843,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*/ @@ -3830,7 +3861,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) */ @@ -4422,7 +4453,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[]. */ @@ -4431,7 +4462,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[]. */ @@ -4439,7 +4470,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[]. */ @@ -4447,7 +4478,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[]. */ @@ -4460,8 +4491,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[]. */ @@ -4475,7 +4510,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 76f1485b74225a303c0b5e903ad7abd4943ff5e3..952d706ec7d64d166dadac92413eb0b51b614d86 100644 --- a/lib_enc/transition_enc_fx.c +++ b/lib_enc/transition_enc_fx.c @@ -289,7 +289,12 @@ 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 +428,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 +496,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 +547,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 +583,23 @@ 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 +775,12 @@ 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 +791,12 @@ 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 +822,12 @@ 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 +1163,12 @@ 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 +1302,12 @@ 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 +1370,12 @@ 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 +1422,12 @@ 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 +1457,30 @@ 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 +1518,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 +1656,18 @@ 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 +1676,12 @@ 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 +1707,12 @@ 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 +1777,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 +1894,32 @@ 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 +1939,23 @@ 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 +2136,32 @@ 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 +2181,23 @@ 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 +2308,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 ) ) {