From 54a62ff95df0fbd04dcb3548d11fd8da304b9835 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 17 Jun 2025 17:22:45 +0530 Subject: [PATCH] Extension of #1593 fix into Encoder: plugged in pred_lt4_ivas_fx in encoder --- lib_com/rom_com.c | 29 +++++++-------------------- lib_com/rom_com.h | 18 ++++++++--------- lib_enc/acelp_core_switch_enc_fx.c | 4 ++-- lib_enc/enc_gen_voic_fx.c | 2 +- lib_enc/enc_pit_exc_fx.c | 2 +- lib_enc/ivas_core_pre_proc_front_fx.c | 8 ++++---- lib_enc/ivas_td_low_rate_enc_fx.c | 2 +- lib_enc/pitch_ol2_fx.c | 12 +++++++++-- lib_enc/pitch_ol_fx.c | 8 ++++---- lib_enc/pre_proc_fx.c | 8 ++++---- lib_enc/prot_fx_enc.h | 7 ++++--- lib_enc/transition_enc_fx.c | 12 +++++------ 12 files changed, 53 insertions(+), 59 deletions(-) diff --git a/lib_com/rom_com.c b/lib_com/rom_com.c index 5d0a7f303..a64b37f7b 100644 --- a/lib_com/rom_com.c +++ b/lib_com/rom_com.c @@ -1273,28 +1273,6 @@ const Word16 sin_table256_fx[] = * 1/4 resolution interpolation filter (-3 dB at 0.913*fs/2) *----------------------------------------------------------------------------------*/ - -const Word16 inter4_2_fx_Q15[65] = -{//Q15 - 30801, - 28062, 20718, 11061, 1935, - -4294, -6533, -5195, -1846, - 1559, 3497, 3398, 1705, - -497, -2087, -2413, -1523, - -32, 1252, 1741, 1312, - 305, -710, -1237, -1087, - -426, 350, 848, 862, - 452, -119, -550, -650, - -418, -17, 330, 462, - 349, 85, -175, -306, - -265, -104, 76, 184, - 182, 93, -20, -98, - -110, -66, -3, 43, - 55, 37, 8, -13, - -20, -14, -4, 2, - 3, 1, 0, 0, -}; - const Word16 inter4_2_fx[] = {//evs table , some mismatch in values compared to float is observed 0, 1, 2, 1, @@ -1366,6 +1344,13 @@ const Word16 pitch_inter4_2[PIT_FIR_SIZE2] = 3/*0.000098f Q15*/, 2/*0.000048f Q15*/, 0/*0.000007f Q15*/, 0/*0.000000f Q15*/ }; /* 1/4 resolution interpolation filter (-3 dB at 0.791*fs/2) */ +const Word32 L_pitch_inter4_1[UP_SAMP * L_INTERPOL1 + 1] = /* Q31 */ +{ + 1932735283, 1758701061, 1298905484, 711630983, 180298432, -162768528, + -280712608, -226956816, -100446400, 9592809, 59676424, 55065776, + 26996016, 4138201, -3373696, -1617055, 0 +}; +/* 1/4 resolution interpolation filter (-3 dB at 0.791*fs/2) */ const Word16 pitch_inter4_1[UP_SAMP * L_INTERPOL1 + 1] = { 29491/*0.900000F Q15*/, diff --git a/lib_com/rom_com.h b/lib_com/rom_com.h index a87ee8d0d..a0a388bc6 100644 --- a/lib_com/rom_com.h +++ b/lib_com/rom_com.h @@ -172,16 +172,16 @@ extern const Word32 crit_bands_fx[]; extern const float sincos_t_ext[]; // fft_rel dep extern const Word16 sincos_t_rad3_fx[]; // Q15 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]; /*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 -extern const Word16 grid40_fx[( GRID40_POINTS - 1 ) / 2 - 1]; // Q15 -extern const Word32 crit_bands_fx[]; /* Table of critical bands Q0*/ +extern const Word16 pitch_inter4_1[UP_SAMP * L_INTERPOL1 + 1]; /*1Q14*/ +extern const Word16 pitch_inter4_2[PIT_FIR_SIZE2]; /*Q15*/ +extern const Word32 L_pitch_inter4_1[UP_SAMP * L_INTERPOL1 + 1]; /*Q31*/ +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 +extern const Word16 grid40_fx[( GRID40_POINTS - 1 ) / 2 - 1]; // Q15 +extern const Word32 crit_bands_fx[]; /* Table of critical bands Q0*/ extern const Word16 wind_sss_fx[LEN_WIN_SSS]; // Q15 /*window for modify_sf ana*/ extern const Word16 filter5_39s320_120_fx[]; // Q15 diff --git a/lib_enc/acelp_core_switch_enc_fx.c b/lib_enc/acelp_core_switch_enc_fx.c index 76fa6f151..aaaf08b26 100644 --- a/lib_enc/acelp_core_switch_enc_fx.c +++ b/lib_enc/acelp_core_switch_enc_fx.c @@ -632,7 +632,7 @@ static void encod_gen_voic_core_switch_ivas_fx( * Find adaptive exitation *-----------------------------------------------------------------*/ - pred_lt4( &exc[0], &exc[0], T0, T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + pred_lt4_ivas_fx( &exc[0], &exc[0], T0, T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); /*-----------------------------------------------------------------* * Gain clipping test to avoid unstable synthesis on frame erasure @@ -708,7 +708,7 @@ static void encod_gen_voic_core_switch_ivas_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 ); + 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 ); FOR( i = L_SUBFR; i < 2 * L_SUBFR; i++ ) { diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index a485a1bf3..da3555cdb 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -578,7 +578,7 @@ void encod_gen_voic_ivas_fx( * Find adaptive exitation *-----------------------------------------------------------------*/ - 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 ); + 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 ); /*-----------------------------------------------------------------* * Gain clipping test to avoid unstable synthesis on frame erasure diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index bfdf46ea0..21cd474bd 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -744,7 +744,7 @@ void enc_pit_exc_ivas_fx( * Find adaptive exitation *-----------------------------------------------------------------*/ - pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_subfr + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + 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 ); /*-----------------------------------------------------------------* * Gain clipping test to avoid unstable synthesis on frame erasure * or in case of floating point encoder & fixed p. decoder diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index fbd207e26..b378eabad 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -1199,10 +1199,10 @@ ivas_error pre_proc_front_ivas_fx( IF( LE_32( element_brate, IVAS_32k ) ) { /* 1/4 pitch precision improvement */ - pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[0], &pitch_fr_fx[0], &voicing_fr_fx[0], 0, wsp_fx, 7 ); - pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[0], &pitch_fr_fx[1], &voicing_fr_fx[1], L_SUBFR, wsp_fx, 7 ); - pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[1], &pitch_fr_fx[2], &voicing_fr_fx[2], 2 * L_SUBFR, wsp_fx, 7 ); - pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[1], &pitch_fr_fx[3], &voicing_fr_fx[3], 3 * L_SUBFR, wsp_fx, 7 ); + pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[0], &pitch_fr_fx[0], &voicing_fr_fx[0], 0, wsp_fx, 7, element_mode ); + pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[0], &pitch_fr_fx[1], &voicing_fr_fx[1], L_SUBFR, wsp_fx, 7, element_mode ); + pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[1], &pitch_fr_fx[2], &voicing_fr_fx[2], 2 * L_SUBFR, wsp_fx, 7, element_mode ); + pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[1], &pitch_fr_fx[3], &voicing_fr_fx[3], 3 * L_SUBFR, wsp_fx, 7, element_mode ); } ELSE { diff --git a/lib_enc/ivas_td_low_rate_enc_fx.c b/lib_enc/ivas_td_low_rate_enc_fx.c index d10527a24..e2c12076d 100644 --- a/lib_enc/ivas_td_low_rate_enc_fx.c +++ b/lib_enc/ivas_td_low_rate_enc_fx.c @@ -285,7 +285,7 @@ void encod_gen_2sbfr( * Find adaptive exitation *-----------------------------------------------------------------*/ - pred_lt4( &exc[i_subfr], &exc[i_subfr], T0, T0_frac, 2 * L_SUBFR + 1, inter4_2_fx_Q15, L_INTERPOL2, PIT_UP_SAMP ); + 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 ); /*-----------------------------------------------------------------* * Gain clipping test to avoid unstable synthesis on frame erasure diff --git a/lib_enc/pitch_ol2_fx.c b/lib_enc/pitch_ol2_fx.c index 7ca13171e..cbeea8f1d 100644 --- a/lib_enc/pitch_ol2_fx.c +++ b/lib_enc/pitch_ol2_fx.c @@ -36,7 +36,8 @@ void pitch_ol2_fx( const Word16 pos, /* i : position in frame where to calculate the improv. */ const Word16 *wsp_fx, /* i : weighted speech for current frame and look-ahead */ /*Q_new-1+shift*/ - const Word16 delta /* i : delta for pitch search (2 or 7) */ + const Word16 delta, /* i : delta for pitch search (2 or 7) */ + const Word16 element_mode /* i : EVS or IVAS */ ) { Word16 i, t, step, fraction, t0_min, t0_max, t_min, t_max; @@ -158,7 +159,14 @@ void pitch_ol2_fx( IF( NE_32( t1, 1L ) ) { - pred_lt4( pt_wsp_fx, wsp_fr_fx, t0s, fraction, L_SUBFR, pitch_inter4_1, 4, PIT_UP_SAMP ); + IF( element_mode != EVS_MONO ) + { + pred_lt4_ivas_fx( pt_wsp_fx, wsp_fr_fx, t0s, fraction, L_SUBFR, L_pitch_inter4_1, 4, PIT_UP_SAMP ); + } + ELSE + { + pred_lt4( pt_wsp_fx, wsp_fr_fx, t0s, fraction, L_SUBFR, pitch_inter4_1, 4, PIT_UP_SAMP ); + } R0 = cor_max_fx; move16(); diff --git a/lib_enc/pitch_ol_fx.c b/lib_enc/pitch_ol_fx.c index fdadcd318..79c55821e 100644 --- a/lib_enc/pitch_ol_fx.c +++ b/lib_enc/pitch_ol_fx.c @@ -2425,8 +2425,8 @@ void pitchDoubling_det_fx( IF( GE_16( T, PIT_MIN_12k8 ) ) { - pitch_ol2_fx( PIT_MIN_SHORTER, T, &( new_op_fr[0] ), &new_voicing[0], 0, wspeech, 2 ); - pitch_ol2_fx( PIT_MIN_SHORTER, T, &( new_op_fr[1] ), &new_voicing[1], L_SUBFR, wspeech, 2 ); + pitch_ol2_fx( PIT_MIN_SHORTER, T, &( new_op_fr[0] ), &new_voicing[0], 0, wspeech, 2, EVS_MONO ); + pitch_ol2_fx( PIT_MIN_SHORTER, T, &( new_op_fr[1] ), &new_voicing[1], L_SUBFR, wspeech, 2, EVS_MONO ); /* IF(sub(add(new_voicing[0],new_voicing[1]),add(voicing_fr[0],voicing_fr[1]))>0 */ IF( L_msu( L_msu( L_mac( L_mult( new_voicing[0], 8192 ), new_voicing[1], 8192 ), voicing_fr[0], 8192 ), voicing_fr[1], 8192 ) > 0 ) { @@ -2448,8 +2448,8 @@ void pitchDoubling_det_fx( IF( GE_16( T, PIT_MIN_12k8 ) ) { - pitch_ol2_fx( PIT_MIN_SHORTER, T, &( new_op_fr[0] ), &new_voicing[0], 2 * L_SUBFR, wspeech, 2 ); - pitch_ol2_fx( PIT_MIN_SHORTER, T, &( new_op_fr[1] ), &new_voicing[1], 3 * L_SUBFR, wspeech, 2 ); + pitch_ol2_fx( PIT_MIN_SHORTER, T, &( new_op_fr[0] ), &new_voicing[0], 2 * L_SUBFR, wspeech, 2, EVS_MONO ); + pitch_ol2_fx( PIT_MIN_SHORTER, T, &( new_op_fr[1] ), &new_voicing[1], 3 * L_SUBFR, wspeech, 2, EVS_MONO ); /* IF(sub(add(new_voicing[0],new_voicing[1]),add(voicing_fr[2],voicing_fr[3]))>0) */ IF( L_msu( L_msu( L_mac( L_mult( new_voicing[0], 8192 ), new_voicing[1], 8192 ), voicing_fr[2], 8192 ), voicing_fr[3], 8192 ) > 0 ) { diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c index f7ebc8298..dc3ec020a 100644 --- a/lib_enc/pre_proc_fx.c +++ b/lib_enc/pre_proc_fx.c @@ -458,10 +458,10 @@ void pre_proc_fx( IF( LE_32( st->total_brate, ACELP_24k40 ) ) { /* 1/4 pitch precision improvement */ - pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[0], &pitch_fr[0], &voicing_fr[0], 0, wsp, 7 ); - pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[0], &pitch_fr[1], &voicing_fr[1], L_SUBFR, wsp, 7 ); - pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[1], &pitch_fr[2], &voicing_fr[2], 2 * L_SUBFR, wsp, 7 ); - pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[1], &pitch_fr[3], &voicing_fr[3], 3 * L_SUBFR, wsp, 7 ); + pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[0], &pitch_fr[0], &voicing_fr[0], 0, wsp, 7, EVS_MONO ); + pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[0], &pitch_fr[1], &voicing_fr[1], L_SUBFR, wsp, 7, EVS_MONO ); + pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[1], &pitch_fr[2], &voicing_fr[2], 2 * L_SUBFR, wsp, 7, EVS_MONO ); + pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[1], &pitch_fr[3], &voicing_fr[3], 3 * L_SUBFR, wsp, 7, EVS_MONO ); } ELSE { diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 6ef6991d4..dcdce25b6 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -437,13 +437,14 @@ void pitch_ol2_fx( const Word16 pit_min, /* i : minimum pitch value (20 or 29) */ const Word16 pitch_ol, /* i : pitch to be improved */ Word16 *pitch_fr_fx, - /* o : adjusted 1/4 fractional pitch */ /*Q7 */ + /* o : adjusted 1/4 fractional pitch */ /*Q7*/ Word16 *voicing_fr_fx, - /* o : adjusted 1/4 fractional voicing */ /*Q15 */ + /* o : adjusted 1/4 fractional voicing */ /*Q15*/ const Word16 pos, /* i : position in frame where to calculate the improv. */ const Word16 *wsp_fx, /* i : weighted speech for current frame and look-ahead */ /*Q_new-1+shift*/ - const Word16 delta /* i : delta for pitch search (2 or 7) */ + const Word16 delta, /* i : delta for pitch search (2 or 7) */ + const Word16 element_mode /* i : EVS or IVAS */ ); void pitch_ol_ivas_fx( diff --git a/lib_enc/transition_enc_fx.c b/lib_enc/transition_enc_fx.c index d0d627697..82e41026d 100644 --- a/lib_enc/transition_enc_fx.c +++ b/lib_enc/transition_enc_fx.c @@ -1214,7 +1214,7 @@ void transition_enc_ivas_fx( push_indice( hBstr, IND_PITCH, index, nBits ); /* Find the adaptive codebook vector - ACELP long-term prediction */ - pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + 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 ); offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame ); @@ -1263,7 +1263,7 @@ void transition_enc_ivas_fx( push_indice( hBstr, IND_PITCH, index, nBits ); /* Find the adaptive codebook vector - ACELP long-term prediction */ - pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + 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 ); offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame ); @@ -1327,7 +1327,7 @@ void transition_enc_ivas_fx( push_indice( hBstr, IND_PITCH, index, nBits ); /* Find the adaptive codebook vector - ACELP long-term prediction */ - pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + 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 ); offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame ); @@ -1352,7 +1352,7 @@ void transition_enc_ivas_fx( push_indice( hBstr, IND_PITCH, index, nBits ); /* Find the adaptive codebook vector - ACELP long-term prediction */ - pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + 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 ); offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame ); @@ -1388,7 +1388,7 @@ void transition_enc_ivas_fx( pit_Q_enc_ivas_fx( hBstr, 0, nBits, 8, pit_flag, limit_flag, *T0, *T0_frac, T0_min, T0_max ); /* Find the adaptive codebook vector - ACELP long-term prediction */ - pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + 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 ); offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame ); @@ -1639,7 +1639,7 @@ void transition_enc_ivas_fx( ELSE { /* Find the adaptive codebook vector - ACELP long-term prediction */ - pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + 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 ); offset = L_deposit_l( 0 ); tmp = extract_l( L_mult( *T0_frac, 32 ) ); /*Q8, 0.25 in Q7*/ -- GitLab