From b7ec7753af63721ea5007a9aad50e4fa25a08300 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Sat, 18 Jan 2025 10:47:55 +0530 Subject: [PATCH] Fix for 3GPP issue 1163: Assertion in convolve_tc_fx for OMASA LTV input Link #1163 --- lib_enc/enc_tran_fx.c | 4 ++-- lib_enc/lp_exc_e_fx.c | 2 +- lib_enc/prot_fx_enc.h | 2 +- lib_enc/transition_enc_fx.c | 35 +++++++++++++++++------------------ 4 files changed, 21 insertions(+), 22 deletions(-) diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c index 6f9cb9c6a..255c275e7 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -4,7 +4,7 @@ #include #include "options.h" /* Compilation switches */ #include "cnst.h" /* Compilation switches */ -//#include "prot_fx.h" /* Function prototypes */ +// #include "prot_fx.h" /* Function prototypes */ #include "rom_com_fx.h" /* Static table prototypes */ #include "rom_com.h" /* Static table prototypes */ #include "prot.h" /* Function prototypes */ @@ -572,7 +572,6 @@ Word16 encod_tran_ivas_fx( res_fx, L_SUBFR, p_Aw, st_fx->preemph_fac, xn, cn, h1 ); Copy_Scale_sig( h1, h2_fx, L_SUBFR, -2 ); - Scale_sig( h1, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */ /* scaling of xn[] to limit dynamic at 12 bits */ Scale_sig( xn, L_SUBFR, shift ); @@ -591,6 +590,7 @@ Word16 encod_tran_ivas_fx( IF( GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) ) { + Scale_sig( h1, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */ transf_cdbk_enc_ivas_fx( st_fx, 0, i_subfr, cn, exc_fx, p_Aq, Aw_fx, h1, xn, xn2, y1, y2, Es_pred_fx, &gain_pit, gain_code, g_corr, clip_gain, &gain_preQ, code_preQ, unbits, Q_new, shift ); } diff --git a/lib_enc/lp_exc_e_fx.c b/lib_enc/lp_exc_e_fx.c index 8b9cb113e..a8e9f7437 100644 --- a/lib_enc/lp_exc_e_fx.c +++ b/lib_enc/lp_exc_e_fx.c @@ -175,7 +175,7 @@ Word16 lp_filt_exc_enc_ivas_fx( const Word16 coder_type, /* i : coding type Q0 */ const Word16 i_subfr, /* i : subframe index Q0 */ Word16 *exc, /* i/o: pointer to excitation signal frame Q_new */ - const Word16 *h1, /* i : weighted filter input response Q(14+shift) */ + const Word16 *h1, /* i : weighted filter input response Q(15) */ const Word16 *xn, /* i : target vector Q_new-1+shift */ Word16 *y1, /* o : zero-memory filtered adaptive excitation Q_new-1+shift */ Word16 *xn2, /* o : target vector for innovation search Q_new-1+shift */ diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index c96678a7a..c3bfa4f61 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -3424,7 +3424,7 @@ Word16 lp_filt_exc_enc_ivas_fx( const Word16 coder_type, /* i : coding type Q0 */ const Word16 i_subfr, /* i : subframe index Q0 */ Word16 *exc, /* i/o: pointer to excitation signal frame Q_new */ - const Word16 *h1, /* i : weighted filter i response Q(14+shift) */ + const Word16 *h1, /* i : weighted filter i response Q(15) */ const Word16 *xn, /* i : target vector Q_new-1+shift */ Word16 *y1, /* o : zero-memory filtered adaptive excitation Q_new-1+shift */ Word16 *xn2, /* o : target vector for innovation search Q_new-1+shift */ diff --git a/lib_enc/transition_enc_fx.c b/lib_enc/transition_enc_fx.c index c68daa2a7..bc605c2d9 100644 --- a/lib_enc/transition_enc_fx.c +++ b/lib_enc/transition_enc_fx.c @@ -916,7 +916,8 @@ void transition_enc_ivas_fx( /* set limit_flag to 0 for restrained limits, and 1 for extended limits */ limit_flag = 0; move16(); - + Word16 h1_fx_q15[L_SUBFR + ( M + 1 )]; + Copy_Scale_sig( h1_fx, h1_fx_q15, L_SUBFR + ( M + 1 ), 0 ); pit_start = PIT_MIN; move16(); @@ -1423,7 +1424,8 @@ 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(); - lp_select = lp_filt_exc_enc_ivas_fx( MODE1, TRANSITION, i_subfr, exc_fx, h1_fx, + Copy_Scale_sig( h1_fx, h1_fx_q15, L_SUBFR + ( M + 1 ), 1 ); + lp_select = lp_filt_exc_enc_ivas_fx( MODE1, TRANSITION, i_subfr, exc_fx, h1_fx_q15, xn_fx, y1_fx, xn2_fx, L_SUBFR, st_fx->L_frame, g_corr_fx, *clip_gain, gain_pit_fx, &lp_flag ); IF( EQ_16( lp_flag, NORMAL_OPERATION ) ) @@ -1659,9 +1661,9 @@ 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(); - lp_select = lp_filt_exc_enc_ivas_fx( MODE1, TRANSITION, i_subfr, exc_fx, h1_fx, + Copy_Scale_sig( h1_fx, h1_fx_q15, L_SUBFR + ( M + 1 ), 1 ); + lp_select = lp_filt_exc_enc_ivas_fx( MODE1, TRANSITION, i_subfr, exc_fx, h1_fx_q15, xn_fx, y1_fx, xn2_fx, L_SUBFR, st_fx->L_frame, g_corr_fx, *clip_gain, gain_pit_fx, &lp_flag ); - IF( EQ_16( lp_flag, NORMAL_OPERATION ) ) { push_indice( hBstr, IND_LP_FILT_SELECT, lp_select, 1 ); @@ -1947,7 +1949,7 @@ static void tc_enc_ivas_fx( const Word16 i_subfr, /* i : subrame index */ Word16 *tc_subfr, /* i/o: TC subframe index */ Word16 *position, /* i/o: index of the residual signal maximum */ - const Word16 *h1_fx, /* i : weighted filter input response Q(14+shift)*/ + const Word16 *h1, /* i : weighted filter input response Q(14+shift)*/ const Word16 *xn_fx, /* i : target signal Q_new-1+shift*/ Word16 *exc_fx, /* o : glottal codebook contribution Q_new*/ Word16 *yy1_fx, /* o : filtered glottal codebook contribution */ @@ -1961,7 +1963,9 @@ static void tc_enc_ivas_fx( Word16 Q_new /* i : input scaling */ ) { - Word16 i, imp_shape, imp_pos, index, nBits, h1_tmp_fx[L_SUBFR]; + + Word16 h1_fx[L_SUBFR + ( M + 1 )]; + Word16 imp_shape, imp_pos, index, nBits; Word16 pitch_index, pitch_sign_fx; Word32 gain_trans32; BSTR_ENC_HANDLE hBstr = st_fx->hBstr; @@ -1970,11 +1974,6 @@ static void tc_enc_ivas_fx( move32(); #endif imp_pos = sub( *position, i_subfr ); - FOR( i = 0; i < L_SUBFR; i++ ) - { - h1_tmp_fx[i] = h1_fx[i]; - move16(); - } /*-----------------------------------------------------------------* * get number of bits for pitch encoding *-----------------------------------------------------------------*/ @@ -1996,17 +1995,17 @@ static void tc_enc_ivas_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, *T0_min, *T0_max, T0_frac, 0, 0, PIT_FR2_9b, PIT_FR1_9b, L_FRAME, L_SUBFR ); 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, *T0_min, *T0_max, T0_frac, 0, 0, PIT_MIN, L_SUBFR, L_FRAME, L_SUBFR ); 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, *T0_min, *T0_max, T0_frac, 0, 0, PIT_MAX, PIT_MIN, L_FRAME, L_SUBFR ); move16(); } } @@ -2026,13 +2025,13 @@ static void tc_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, 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 ); 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, *T0_min, *T0_max, T0_frac, 0, 0, PIT16k_MIN, L_SUBFR, L_FRAME16k, L_SUBFR ); IF( *T0 > L_SUBFR ) { *T0 = L_SUBFR; @@ -2058,7 +2057,7 @@ static void tc_enc_ivas_fx( * Builds glottal codebook contribution *--------------------------------------------------------------*/ - set_impulse_fx( xn_fx, h1_tmp_fx, &exc_fx[i_subfr], yy1_fx, &imp_shape, &imp_pos, &gain_trans32, Q_new ); /*chk h1_tmp_fx*/ + set_impulse_fx( xn_fx, h1, &exc_fx[i_subfr], yy1_fx, &imp_shape, &imp_pos, &gain_trans32, Q_new ); /*--------------------------------------------------------------* * quantize gain_trans and scale glottal codebook contribution @@ -2088,7 +2087,7 @@ static void tc_enc_ivas_fx( /*--------------------------------------------------------------* * compute glottal-shape codebook excitation *--------------------------------------------------------------*/ - + Copy_Scale_sig( h1, h1_fx, L_SUBFR + ( M + 1 ), 1 ); /* create filtered glottal codebook contribution */ conv_fx( &exc_fx[i_subfr], h1_fx, yy1_fx, L_SUBFR ); -- GitLab