diff --git a/lib_com/options.h b/lib_com/options.h index 0c8105d8cabb96dade519b47aa6e7405144bdb82..8204162b7bf817e6e9a2f5a40e1d511a549d0a52 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -164,4 +164,6 @@ #define FIX_ISSUE_1247 #define NONBE_FIX_1087_OOB_SBA_DTX_RS /* VA: issue 1087: Extend the length of the buffer for MCT decoding to avoid out-of-bound writing in SBA SID bitrate switching decoding */ #define FIX_1285_DECODER_CRASH + +#define FIX_1320_LOWRATE_ACELP #endif diff --git a/lib_enc/ivas_td_low_rate_enc.c b/lib_enc/ivas_td_low_rate_enc.c index 95762fa296a63cfcc9d29666eae38654b62754fd..d091349514bccd4f2fbdd7eef7d6d9d8e9fa6441 100644 --- a/lib_enc/ivas_td_low_rate_enc.c +++ b/lib_enc/ivas_td_low_rate_enc.c @@ -222,6 +222,10 @@ void encod_gen_2sbfr( LPD_state_HANDLE hLPDmem = st->hLPDmem; +#ifdef FIX_1320_LOWRATE_ACELP + Word16 gcode16; + Word32 Lgcode, Ltmp; +#endif #ifdef MSAN_FIX set16_fx( cn, 0, 2 * L_SUBFR ); /* Target vector in residual domain */ #endif @@ -269,8 +273,12 @@ void encod_gen_2sbfr( // Scale_sig( &hLPDmem->mem_w0, M + 1, sub( add( *Q_new, hLPDmem->e_mem_syn ), Q16 ) ); // M + 1 to sync mem_syn exponent with mem_w0 exponent // hLPDmem->e_mem_syn = sub( Q16, *Q_new ); - find_targets_fx( speech, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, res, 2 * L_SUBFR, p_Aw, st->preemph_fac, xn, cn, h1 ); +#ifndef FIX_1320_LOWRATE_ACELP + find_targets_fx( speech, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, res, 2 * L_SUBFR, p_Aw, st->preemph_fac, xn, cn, h1 ); +#else + find_targets_ivas_fx( speech, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, res, 2 * L_SUBFR, p_Aw, st->preemph_fac, xn, cn, h1 ); +#endif /*Scale_sig(h1, L_SUBFR, shift); */ /*Q14-shift */ Copy_Scale_sig( h1, h2, 2 * L_SUBFR, -2 ); Scale_sig( h1, 2 * L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */ @@ -294,14 +302,20 @@ void encod_gen_2sbfr( * Gain clipping test to avoid unstable synthesis on frame erasure *-----------------------------------------------------------------*/ +#ifndef FIX_1320_LOWRATE_ACELP clip_gain = gp_clip_fx( st->element_mode, st->core_brate, st->voicing_fx, i_subfr, coder_type, xn, st->clip_var_fx, Q_new ); // Q0 - +#else + clip_gain = gp_clip_fx( st->element_mode, st->core_brate, st->voicing_fx, i_subfr, coder_type, xn, st->clip_var_fx, sub( Q_new, 1 ) ); // Q0 +#endif /*-----------------------------------------------------------------* * LP filtering of the adaptive excitation, codebook target computation *-----------------------------------------------------------------*/ +#ifndef FIX_1320_LOWRATE_ACELP 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 ); - +#else + 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 ); +#endif /* update long-term pitch gain for speech/music classifier */ st->hSpMusClas->lowrate_pitchGain = add( mult( 29491, st->hSpMusClas->lowrate_pitchGain ), mult( 3277, gain_pit ) ); // Q14 move16(); @@ -334,14 +348,30 @@ void encod_gen_2sbfr( gp_clip_test_gain_pit_fx( st->element_mode, st->core_brate, gain_pit, st->clip_var_fx ); +#ifndef FIX_1320_LOWRATE_ACELP hLPDmem->tilt_code = est_tilt_ivas_fx( exc + i_subfr, gain_pit, code, gain_code, &voice_fac, Q_new, 2 * L_SUBFR, 0 ); +#else + Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ + gcode16 = round_fx_sat( Lgcode ); /*Q0*/ + hLPDmem->tilt_code = est_tilt_ivas_fx( exc + i_subfr, gain_pit, code, Lgcode, &voice_fac, Q_new, 2 * L_SUBFR, 0 ); +#endif move16(); /*-----------------------------------------------------------------* * Update memory of the weighting filter *-----------------------------------------------------------------*/ +#ifndef FIX_1320_LOWRATE_ACELP hLPDmem->mem_w0 = sub( sub( xn[2 * L_SUBFR - 1], mult_r( gain_pit, y1[2 * L_SUBFR - 1] ) ), mult_r( extract_h( gain_code ), y2[2 * L_SUBFR - 1] ) ); +#else + Ltmp = L_mult0( gcode16, y2[2 * L_SUBFR - 1] ); /*Q10*/ + Ltmp = L_shl( Ltmp, add( 5, shift ) ); /*Q15+shift*/ + Ltmp = L_negate( Ltmp ); + Ltmp = L_mac( Ltmp, xn[2 * L_SUBFR - 1], 16384 /*Q14*/ ); /* Q_new-1+shift+14+1 */ + Ltmp = L_msu( Ltmp, y1[2 * L_SUBFR - 1], gain_pit /*Q14*/ ); /* Q_new-1+shift+14+1 */ + Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* 15 + Q_new */ + hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */ +#endif move16(); /*-----------------------------------------------------------------* @@ -349,6 +379,7 @@ void encod_gen_2sbfr( * Save the non-enhanced excitation for FEC_exc *-----------------------------------------------------------------*/ +#ifndef FIX_1320_LOWRATE_ACELP FOR( i = 0; i < 2 * L_SUBFR; i++ ) { exc2[i + i_subfr] = mult( gain_pit, exc[i + i_subfr] ); @@ -356,7 +387,20 @@ void encod_gen_2sbfr( exc[i + i_subfr] = add( exc2[i + i_subfr], mult( extract_h( gain_code ), code[i] ) ); move16(); } - +#else + FOR( i = 0; i < 2 * L_SUBFR; i++ ) + { + /* code in Q9, gain_pit in Q14 */ + exc2[i + i_subfr] = shl_sat( mult( gain_pit, exc[i + i_subfr] ), 1 ); + Ltmp = L_mult( gcode16, code[i] ); /* Q10 */ + Ltmp = L_shl_sat( Ltmp, 5 ); /* Q15 */ + Ltmp = L_mac_sat( Ltmp, exc[i + i_subfr], gain_pit ); /* Q15 */ + Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16*/ + exc[i + i_subfr] = round_fx_sat( Ltmp ); + move16(); + move16(); + } +#endif /*-----------------------------------------------------------------* * Prepare TBE excitation *-----------------------------------------------------------------*/ @@ -370,9 +414,11 @@ void encod_gen_2sbfr( * Synthesize speech to update mem_syn_flt[]. * Update A(z) filters *-----------------------------------------------------------------*/ - +#ifndef FIX_1320_LOWRATE_ACELP E_UTIL_synthesis( 0, p_Aq, &exc[i_subfr], &syn[i_subfr], 2 * L_SUBFR, hLPDmem->mem_syn, 1, M ); - +#else + Syn_filt_s( 1, p_Aq, M, &exc[i_subfr], &syn[i_subfr], 2 * L_SUBFR, hLPDmem->mem_syn, 1 ); +#endif p_Aw += 2 * ( M + 1 ); p_Aq += 2 * ( M + 1 );