diff --git a/lib_com/pred_lt4_fx.c b/lib_com/pred_lt4_fx.c index 4f8dd871289b8fc78c85678a24cb737da7378c84..465138bde1fd083c8ed2a0beade5da3fa290ea2f 100644 --- a/lib_com/pred_lt4_fx.c +++ b/lib_com/pred_lt4_fx.c @@ -20,6 +20,63 @@ * (adaptive codebook excitation) * *-------------------------------------------------------------------*/ +void pred_lt4_ivas_fx( + const Word16 excI[], /* in : excitation buffer Q_exc*/ + Word16 excO[], /* out: excitation buffer Q_exc*/ + const Word16 T0, /* input : integer pitch lag Q0*/ + Word16 frac, /* input : fraction of lag Q0*/ + const Word16 L_subfr, /* input : subframe size Q0*/ + const Word32 *win, /* i : interpolation window Q31*/ + const Word16 nb_coef, /* i : nb of filter coef Q0*/ + const Word16 up_sample /* i : up_sample Q0*/ +) +{ + Word16 i, j; + Word32 s; + const Word16 *x0, *x1, *x2; + const Word32 *c1, *c2; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; + move32(); +#endif + x0 = &excI[-T0]; + + frac = negate( frac ); + + IF( frac < 0 ) + { + frac = add( frac, up_sample ); /* Q0 */ + x0--; + } + + FOR( j = 0; j < L_subfr; j++ ) + { + x1 = x0++; /* Q_exc */ + x2 = x1 + 1; /* Q_exc */ + c1 = ( &win[frac] ); /* Q14 */ + c2 = ( &win[up_sample - frac] ); /* Q14 */ + + { + Word64 s64 = 0; + move64(); + FOR( i = 0; i < nb_coef; i++ ) + { + /*s += (*x1--) * (*c1) + (*x2++) * (*c2);*/ + s64 = W_mac_32_32( s64, L_deposit_l( *x1-- ), ( *c1 ) ); /* Q_exc + Q32 */ + s64 = W_mac_32_32( s64, L_deposit_l( *x2++ ), ( *c2 ) ); /* Q_exc + Q32 */ + + c1 += up_sample; + c2 += up_sample; + } + s = W_sat_l( W_shr( s64, 16 ) ); /* Q_exc + Q16 */ + } + + excO[j] = round_fx_o( s, &Overflow ); /* Q_exc */ + move16(); + } + return; +} + void pred_lt4( const Word16 excI[], /* in : excitation buffer Q_exc*/ Word16 excO[], /* out: excitation buffer Q_exc*/ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index ec2aec450c1f11bcbd89cc0ae70b9b8c4c4ab3aa..d533c5612793b60e37b237a1d5acf379829e4271 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -7183,6 +7183,16 @@ void pred_lt4( const Word16 up_sample /* i : up_sample Q0*/ ); +void pred_lt4_ivas_fx( + const Word16 excI[], /* in : excitation buffer Q_exc*/ + Word16 excO[], /* out: excitation buffer Q_exc*/ + const Word16 T0, /* input : integer pitch lag Q0*/ + Word16 frac, /* input : fraction of lag Q0*/ + const Word16 L_subfr, /* input : subframe size Q0*/ + const Word32 *win, /* i : interpolation window Q31*/ + const Word16 nb_coef, /* i : nb of filter coef Q0*/ + const Word16 up_sample /* i : up_sample Q0*/ +); void pred_lt4_tc_fx( Word16 exc[], /* i/o: excitation buffer Q0*/ diff --git a/lib_com/rom_com.c b/lib_com/rom_com.c index 9eaf690f1e8577b78fcd52bd305c4aa696d6623d..5d0a7f303652b706a4272935b7ae5e66adfc8827 100644 --- a/lib_com/rom_com.c +++ b/lib_com/rom_com.c @@ -1332,6 +1332,18 @@ const Word16 inter4_2_fx[] = }; /* 1/4 resolution interpolation filter (-3 dB at 0.856*fs/2) */ +const Word32 L_pitch_inter4_2[PIT_FIR_SIZE2] = { /* Q31 */ + 2018634624, 1839083520, 1357785216, 724904576, 126856152, -281447072, + -428193216, -340524320, -121030032, 102233104, 229241728, 222704784, + 111802296, -32603096, -136805440, -158183648, -99851544, -2110976, + 82091856, 114123720, 86026048, 19988778, -46544560, -81104016, + -71266392, -27977416, 22982370, 55621972, 56517476, 29680372, + -7827578, -36105644, -42638288, -27414776, -1138166, 21646636, + 30326764, 22885734, 5570572, -11516955, -20066088, -17396766, + -6833293, 5003637, 12101070, 11944304, 6107443, -1346472, -6427418, + -7219840, -4389456, -249108, 2823941, 3633542, 2471753, 556198, + -895500, -1327144, -932007, -285615, 135291, 210453, 103079, 15032, 0 +}; const Word16 pitch_inter4_2[PIT_FIR_SIZE2] = { /* cut-off frequency at 0.94*fs/2 */ diff --git a/lib_com/rom_com.h b/lib_com/rom_com.h index 73156b9892df5be8df2ea273d450acaf492e1fdc..a87ee8d0d3fdad11bf7d0cd323aa0abce3b4eaee 100644 --- a/lib_com/rom_com.h +++ b/lib_com/rom_com.h @@ -175,7 +175,8 @@ extern const Word16 fft256_read_indexes[]; /* FFT Q0*/ extern const Word16 inter4_2_fx_Q15[]; // Q15 /* 1/4 resolution interpolation filter */ extern const Word16 inter4_2_fx[]; extern const Word16 pitch_inter4_1[UP_SAMP * L_INTERPOL1 + 1]; /*1Q14*/ -extern const Word16 pitch_inter4_2[PIT_FIR_SIZE2]; /*1Q14*/ +extern const Word16 pitch_inter4_2[PIT_FIR_SIZE2]; /*Q15*/ +extern const Word32 L_pitch_inter4_2[PIT_FIR_SIZE2]; /*Q31*/ extern const Word16 Assym_window_W16fx[]; // Q15 extern const Word16 assym_window_16k_fx[]; // Q15 extern const Word16 grid50_fx[( GRID50_POINTS - 1 ) / 2 - 1]; // Q15 diff --git a/lib_dec/LD_music_post_filter_fx.c b/lib_dec/LD_music_post_filter_fx.c index 5b48ab47225f7355d8f46111c86dd939b2fc7461..12a13a4ec141ed145ab1cc55be02b3d825875768 100644 --- a/lib_dec/LD_music_post_filter_fx.c +++ b/lib_dec/LD_music_post_filter_fx.c @@ -832,7 +832,14 @@ void Prep_music_postP_fx( * Extrapolation of the last future part and windowing *------------------------------------------------------------*/ pt1 = exc_buffer_in + DCT_L_POST - OFFSET2; /*Q_exc*/ - pred_lt4( pt1, pt1, s_pit, fr_pit, OFFSET2, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + IF( element_mode != EVS_MONO ) + { + pred_lt4_ivas_fx( pt1, pt1, s_pit, fr_pit, OFFSET2, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } + ELSE + { + pred_lt4( pt1, pt1, s_pit, fr_pit, OFFSET2, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } /*------------------------------------------------------------* * windowing right side *------------------------------------------------------------*/ diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c index 363db82020cf81eefbdb2258c27eb77877faf380..b126823858db562e01e384e307083c48888e3d2d 100644 --- a/lib_dec/acelp_core_switch_dec_fx.c +++ b/lib_dec/acelp_core_switch_dec_fx.c @@ -921,9 +921,14 @@ static void decod_gen_voic_core_switch_fx( /*--------------------------------------------------------------* * Find the adaptive codebook vector. *--------------------------------------------------------------*/ - - pred_lt4( &exc[0], &exc[0], T0, T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); - + IF( st_fx->element_mode != EVS_MONO ) + { + pred_lt4_ivas_fx( &exc[0], &exc[0], T0, T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } + ELSE + { + pred_lt4( &exc[0], &exc[0], T0, T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } /*--------------------------------------------------------------* * LP filtering of the adaptive excitation *--------------------------------------------------------------*/ @@ -991,8 +996,14 @@ static void decod_gen_voic_core_switch_fx( /*-----------------------------------------------------------------* * long term prediction on the 2nd sub frame *-----------------------------------------------------------------*/ - - pred_lt4( &exc[L_SUBFR], &exc[L_SUBFR], T0, T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + IF( st_fx->element_mode != EVS_MONO ) + { + pred_lt4_ivas_fx( &exc[L_SUBFR], &exc[L_SUBFR], T0, T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } + ELSE + { + pred_lt4( &exc[L_SUBFR], &exc[L_SUBFR], T0, T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } pt1 = exc + L_SUBFR; FOR( i = 0; i < L_SUBFR; i++ ) diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index b9f4889426bb8e4b7d45bef73f94d5eb559b49a2..14d9d1772700242840bc8cbfb1bc39769d9d08bf 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -166,8 +166,14 @@ ivas_error decod_gen_voic_fx( /*--------------------------------------------------------------* * Find the adaptive codebook vector *--------------------------------------------------------------*/ - - pred_lt4( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + IF( st_fx->element_mode != EVS_MONO ) + { + pred_lt4_ivas_fx( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } + ELSE + { + pred_lt4( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } // tbe_celp_exc(L_frame, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx); 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 ); diff --git a/lib_dec/dec_pit_exc_fx.c b/lib_dec/dec_pit_exc_fx.c index a18029cdccfe8bb1a5a2c0bd01a939c414b1adc9..ca6660fabe33908ad18c9f466f60afa9a3c88848 100644 --- a/lib_dec/dec_pit_exc_fx.c +++ b/lib_dec/dec_pit_exc_fx.c @@ -182,8 +182,14 @@ void dec_pit_exc_fx( /*--------------------------------------------------------------* * Find the adaptive codebook vector. *--------------------------------------------------------------*/ - - pred_lt4( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_subfr_fx + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + IF( st_fx->element_mode != EVS_MONO ) + { + pred_lt4_ivas_fx( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_subfr_fx + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } + ELSE + { + pred_lt4( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_subfr_fx + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } /*--------------------------------------------------------------* * Innovation decoding diff --git a/lib_dec/ivas_td_low_rate_dec_fx.c b/lib_dec/ivas_td_low_rate_dec_fx.c index f48d3fabc88e41c9da82705f78ff3af44cd2fd07..fb984f11fc32947a3a8f9867e28386c7438d0a0e 100644 --- a/lib_dec/ivas_td_low_rate_dec_fx.c +++ b/lib_dec/ivas_td_low_rate_dec_fx.c @@ -278,8 +278,14 @@ void decod_gen_2sbfr_fx( /*--------------------------------------------------------------* * Find the adaptive codebook vector *--------------------------------------------------------------*/ - - pred_lt4( &exc[i_subfr], &exc[i_subfr], T0, T0_frac, 2 * L_SUBFR + 1, inter4_2_fx_Q15, L_INTERPOL2, PIT_UP_SAMP ); + IF( st->element_mode != EVS_MONO ) + { + pred_lt4_ivas_fx( &exc[i_subfr], &exc[i_subfr], T0, T0_frac, 2 * L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } + ELSE + { + pred_lt4( &exc[i_subfr], &exc[i_subfr], T0, T0_frac, 2 * L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } /*--------------------------------------------------------------* * LP filtering of the adaptive excitation diff --git a/lib_dec/transition_dec_fx.c b/lib_dec/transition_dec_fx.c index b9ad17fcfedb094ff24ca64463b55580d1315305..102a81b9d25868024baec7bb8b0019127d3037c5 100644 --- a/lib_dec/transition_dec_fx.c +++ b/lib_dec/transition_dec_fx.c @@ -209,7 +209,14 @@ void transition_dec_fx( limit_T0_fx( L_FRAME, 8, pit_flag, limit_flag, *T0, 0, T0_min, T0_max ); /* find T0_min and T0_max */ /* Find the adaptive codebook vector - ACELP long-term prediction */ - pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + IF( st_fx->element_mode != EVS_MONO ) + { + pred_lt4_ivas_fx( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } + ELSE + { + pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } offset = tbe_celp_exc_offset( *T0, *T0_frac, L_frame ); move16(); @@ -239,7 +246,14 @@ void transition_dec_fx( limit_T0_fx( L_FRAME, 8, pit_flag, limit_flag, *T0, 0, T0_min, T0_max ); /* find T0_min and T0_max */ /* Find the adaptive codebook vector. ACELP long-term prediction */ - pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + IF( st_fx->element_mode != EVS_MONO ) + { + pred_lt4_ivas_fx( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } + ELSE + { + pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } offset = tbe_celp_exc_offset( *T0, *T0_frac, L_frame ); move16(); move16(); /* penality for 2 ptrs initialization */ @@ -308,7 +322,14 @@ void transition_dec_fx( } /* Find the adaptive codebook vector. ACELP long-term prediction */ - pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + IF( st_fx->element_mode != EVS_MONO ) + { + pred_lt4_ivas_fx( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } + ELSE + { + pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } offset = tbe_celp_exc_offset( *T0, *T0_frac, L_frame ); move16(); move16(); /* penality for 2 ptrs initialization */ @@ -330,7 +351,14 @@ void transition_dec_fx( delta_pit_dec_fx( 2, index, T0, T0_frac, *T0_min ); /* Find the adaptive codebook vector. ACELP long-term prediction */ - pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + IF( st_fx->element_mode != EVS_MONO ) + { + pred_lt4_ivas_fx( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } + ELSE + { + pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } offset = tbe_celp_exc_offset( *T0, *T0_frac, L_frame ); move16(); move16(); /* penality for 2 ptrs initialization */ @@ -351,7 +379,14 @@ void transition_dec_fx( pit_Q_dec_fx( 0, index, nBits, 8, pit_flag, limit_flag, T0, T0_frac, T0_min, T0_max, &st_fx->BER_detect ); /* Find the adaptive codebook vector */ - pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + IF( st_fx->element_mode != EVS_MONO ) + { + pred_lt4_ivas_fx( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } + ELSE + { + pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } offset = tbe_celp_exc_offset( *T0, *T0_frac, L_frame ); move16(); move16(); /* penality for 2 ptrs initialization */ @@ -544,7 +579,14 @@ void transition_dec_fx( ELSE { /* Find the adaptive codebook vector - ACELP long-term prediction */ - pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + IF( st_fx->element_mode != EVS_MONO ) + { + pred_lt4_ivas_fx( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } + ELSE + { + pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } offset = tbe_celp_exc_offset( *T0, *T0_frac, L_frame ); move16(); move16(); /* penalty for 2 ptrs initialization */