From 3c627a8d7fc73f5dbfb80b63aa537fce8484e24c Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 26 Nov 2024 22:04:46 +0530 Subject: [PATCH] Fix for ltv crashes, clean-up of float struct elements --- lib_com/ivas_cnst.h | 4 ++-- lib_com/ivas_fb_mixer.c | 4 ++++ lib_enc/acelp_core_enc.c | 2 +- lib_enc/analy_sp_fx.c | 1 + lib_enc/enc_pit_exc_fx.c | 5 ++++- lib_enc/hq_core_enc_fx.c | 6 ++++-- lib_enc/ivas_core_enc.c | 6 +++++- lib_enc/ivas_cpe_enc.c | 6 ++++++ lib_enc/ivas_stereo_dft_td_itd.c | 1 + lib_enc/swb_tbe_enc_fx.c | 4 ++-- 10 files changed, 30 insertions(+), 9 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 4f3aa5ae1..546675368 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1306,7 +1306,7 @@ enum #define MASA_COHERENCE_TOLERANCE 0.1f #define MASA_COHERENCE_THRESHOLD 0.1f #ifdef IVAS_FLOAT_FIXED -#define MASA_COHERENCE_TOLERANCE_FX 419430 // 0.1 in Q22 +#define MASA_COHERENCE_TOLERANCE_FX 3277/*0.1 Q15*/ #define MASA_COHERENCE_THRESHOLD_FX 214748365 // 0.1 in Q31 #endif #define MASA_RATIO_TOLERANCE 0.1f @@ -1314,7 +1314,7 @@ enum #define MASA_ANGLE_TOLERANCE 0.5f #ifdef IVAS_FLOAT_FIXED #define MASA_RATIO_THRESHOLD_FX 214748365 // 0.1 in Q31 -#define MASA_RATIO_TOLERANCE_FX 419430 // 0.1 in Q22 +#define MASA_RATIO_TOLERANCE_FX 214748364/*0.1 Q30*/ #define MASA_ANGLE_TOLERANCE_FX ONE_IN_Q21 // 0.5 in Q22 #endif #define MASA_LIMIT_NO_BANDS_SUR_COH 8 diff --git a/lib_com/ivas_fb_mixer.c b/lib_com/ivas_fb_mixer.c index 643979874..48ebc3389 100644 --- a/lib_com/ivas_fb_mixer.c +++ b/lib_com/ivas_fb_mixer.c @@ -387,6 +387,10 @@ ivas_error ivas_FB_mixer_open_fx( move16(); } +#ifdef MSAN_FIX + set16_fx( hFbMixer->q_ppFilterbank_prior_input_fx, Q31, IVAS_MAX_FB_MIXER_IN_CH ); +#endif + test(); IF( ( NE_16( fb_cfg->active_w_mixing, -1 ) ) && ( fb_cfg->num_out_chans > 0 ) ) { diff --git a/lib_enc/acelp_core_enc.c b/lib_enc/acelp_core_enc.c index e2fb9b4b7..55e936bf3 100644 --- a/lib_enc/acelp_core_enc.c +++ b/lib_enc/acelp_core_enc.c @@ -753,7 +753,7 @@ ivas_error acelp_core_enc( Copy( hLPDmem->mem_syn, hLPDmem->mem_syn1_fx, M ); /* update old synthesis buffer - needed for ACELP internal sampling rate switching */ - Copy( syn_fx + add( st->L_frame, L_SYN_MEM ), hLPDmem->mem_syn_r, L_SYN_MEM ); + Copy( syn_fx + sub( st->L_frame, L_SYN_MEM ), hLPDmem->mem_syn_r, L_SYN_MEM ); Scale_sig( syn_fx, L_FRAME16k, sub( st->Q_syn, Q_new - 1 ) ); /* save and delay synthesis to be used by SWB BWE */ diff --git a/lib_enc/analy_sp_fx.c b/lib_enc/analy_sp_fx.c index c53aa5386..3386cdbe6 100644 --- a/lib_enc/analy_sp_fx.c +++ b/lib_enc/analy_sp_fx.c @@ -999,6 +999,7 @@ static void ivas_find_enr1( Word32 norm_val; norm_val = 131072 /* 4.0f / ( L_FFT * L_FFT ) in Q31 */; + move32(); ptR = &data[1]; /* first real */ ptI = &data[L_FFT - 1]; /* first imaginary */ diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index f9f50bb65..342abbfac 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -634,7 +634,9 @@ void enc_pit_exc_ivas_fx( test(); Pitch_CT = GENERIC; move16(); - +#ifdef MSAN_FIX + set16_fx( cn1, 0, PIT_EXC_L_SUBFR ); +#endif IF( st_fx->GSC_IVAS_mode > 0 && ( st_fx->GSC_noisy_speech || GT_32( st_fx->core_brate, GSC_H_RATE_STG ) ) ) { Local_BR = ACELP_8k00; @@ -843,6 +845,7 @@ void enc_pit_exc_ivas_fx( * Innovation encoding *-----------------------------------------------------------------*/ + inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, st_fx->L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, i_subfr, -1, p_Aq, gain_pit, cn, exc, h2, st_fx->hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, 2 * L_SUBFR, shift, Q_new ); // PMT("code to be validated") diff --git a/lib_enc/hq_core_enc_fx.c b/lib_enc/hq_core_enc_fx.c index ae408f846..948766618 100644 --- a/lib_enc/hq_core_enc_fx.c +++ b/lib_enc/hq_core_enc_fx.c @@ -367,8 +367,10 @@ void HQ_core_enc_init_fx( hHQ_core->last_max_pos_pulse = 0; move16(); - // hHQ_core->crest_lp = HQ_CREST_THRESHOLD; IVAS_CODE - // hHQ_core->crest_mod_lp = HQ_CREST_MOD_THRESHOLD;IVAS_CODE +#ifdef MSAN_FIX + hHQ_core->crest_lp_fx = HQ_CREST_THRESHOLD_FX; + hHQ_core->crest_mod_lp_fx = HQ_CREST_MOD_THRESHOLD_FX; +#endif return; } diff --git a/lib_enc/ivas_core_enc.c b/lib_enc/ivas_core_enc.c index 976bcc67d..3a4275988 100644 --- a/lib_enc/ivas_core_enc.c +++ b/lib_enc/ivas_core_enc.c @@ -415,9 +415,13 @@ ivas_error ivas_core_enc( #ifdef IVAS_FLOAT_FIXED_CONVERSIONS fixedToFloat_arr( st->hTcxEnc->old_out_fx, st->hTcxEnc->old_out, st->hTcxEnc->Q_old_out, L_FRAME32k ); - for ( int k = 0; k < 2; k++ ) + for ( int k = 0; k < nSubframes; k++ ) { +#ifndef MSAN_FIX fixedToFloat_arrL( st->hTcxEnc->spectrum_fx[k], st->hTcxEnc->spectrum[k], 31 - st->hTcxEnc->spectrum_e[k], 720 ); +#else + fixedToFloat_arrL( st->hTcxEnc->spectrum_fx[k], st->hTcxEnc->spectrum[k], 31 - st->hTcxEnc->spectrum_e[k], st->hTcxEnc->L_frameTCX / nSubframes ); +#endif } #endif // IVAS_FLOAT_FIXED_CONVERSIONS #endif diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 8020d8b9e..d158ac537 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -2138,6 +2138,9 @@ ivas_error create_cpe_enc( hCPE->input_mem_fx[n] = NULL; } } +#ifdef MSAN_FIX + set16_fx( hCPE->q_input_mem, Q15, CPE_CHANNELS ); +#endif #endif /*-----------------------------------------------------------------* @@ -2420,6 +2423,9 @@ ivas_error create_cpe_enc_fx( { hCPE->input_mem_fx[n] = NULL; } +#ifdef MSAN_FIX + set16_fx( hCPE->q_input_mem, Q31, CPE_CHANNELS ); +#endif } /*-----------------------------------------------------------------* diff --git a/lib_enc/ivas_stereo_dft_td_itd.c b/lib_enc/ivas_stereo_dft_td_itd.c index f13532975..a13a76083 100644 --- a/lib_enc/ivas_stereo_dft_td_itd.c +++ b/lib_enc/ivas_stereo_dft_td_itd.c @@ -632,6 +632,7 @@ void stereo_td_itd_fx( FOR( n = 0; n < CPE_CHANNELS; n++ ) { + Scale_sig( &input_mem[n][0], dft_ovl, sts[n]->q_inp - q_input_mem[n] ); // Scale_sig(&sts[n]->old_input_signal_fx, 1965, sts[n]->q_inp - sts[n]->q_old_inp); // sts[n]->q_old_inp = sts[n]->q_inp; diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 07958a063..722e7c6e7 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -4174,8 +4174,8 @@ void swb_tbe_enc_ivas_fx( ELSE IF( EQ_16( hBWE_TD->prev_frGainAtten, 1 ) && GT_32( Mult_32_16( GainFrame_fx, 10923 ), hBWE_TD->prev_gainFr_SHB_fx ) ) { /*GainFrame *= (0.8f + 0.5f*feedback); */ - tmp = add( 26214, mult_r( feedback, 16384 ) ); - GainFrame_fx = Mult_32_16( GainFrame_fx, tmp ); /* Q18 */ + tmp = add( 13107 /* 0.8 in Q14 */, shr( feedback, 2 ) ); + GainFrame_fx = L_shl( Mult_32_16( GainFrame_fx, tmp ), 1 ); /* Q18 */ } hBWE_TD->prev_frGainAtten = frGainAttenuate; -- GitLab