From ab9aad237f338dbd0f050c6087f3cd5ba7aeb25e Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 21 Jun 2024 13:30:17 +0530 Subject: [PATCH] MSAN error fix and LTV stereo crash issue fix [x] Fix for LTV crash: test_param_file_tests[ltv-stereo at 16.4 kbps, 32kHz in, 16kHz out, DTX on] [x] MSAN error fix --- lib_dec/ivas_mc_param_dec.c | 3 +++ lib_dec/ivas_stereo_cng_dec.c | 24 ++++++++++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 516080471..8e38d958b 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -5037,6 +5037,9 @@ static void ivas_param_mc_get_mixing_matrices_fx( set_zero_fx( Cproto_fx, MAX_CICP_CHANNELS * MAX_CICP_CHANNELS ); set_zero_fx( mat_mult_buffer1_fx, MAX_CICP_CHANNELS * MAX_CICP_CHANNELS ); set_zero_fx( proto_matrix_noLFE_fx, PARAM_MC_MAX_TRANSPORT_CHANS * MAX_CICP_CHANNELS ); +#ifdef MSAN_FIX + set_zero_fx( mixing_matrix_res_local_fx, MAX_CICP_CHANNELS * MAX_CICP_CHANNELS ); +#endif Word16 proto_matrix_noLFE_e = 0; Word16 guard_bit_cx = find_guarded_bits_fx( nY_intern + 1 ); diff --git a/lib_dec/ivas_stereo_cng_dec.c b/lib_dec/ivas_stereo_cng_dec.c index ddb29199d..54d67d007 100644 --- a/lib_dec/ivas_stereo_cng_dec.c +++ b/lib_dec/ivas_stereo_cng_dec.c @@ -688,7 +688,7 @@ static void stereo_dft_generate_comfort_noise_fx( Word32 *ptr0, *ptr1, *ptr2; Word16 dmpf[M + 2], Atmp[M + 2]; Word32 cngNoiseLevel_upd[L_FRAME16k], cngNoiseLevel_hist[L_FRAME16k - 2]; - Word16 e_cng_temp[L_FRAME16k]; + Word16 e_norm_temp[L_FRAME16k]; Word32 *ptr_tmp, *ptr_cng; Word32 E0, E1; Word16 b, q_cngNoiseLevel_upd, q_cngNoiseLevel; @@ -876,7 +876,7 @@ static void stereo_dft_generate_comfort_noise_fx( Word16 shift = sub( getScaleFactor32( cngNoiseLevel_upd, st->L_frame ), 1 ); scale_sig32( cngNoiseLevel_upd, st->L_frame, shift ); q_cngNoiseLevel_upd = add( q_cngNoiseLevel_upd, shift ); - set16_fx( e_cng_temp, q_cngNoiseLevel_upd, st->L_frame ); + set16_fx( e_norm_temp, q_cngNoiseLevel_upd, st->L_frame ); /* Compute 1/|A| */ ptr0 = cngNoiseLevel_upd; @@ -902,7 +902,7 @@ static void stereo_dft_generate_comfort_noise_fx( q_sqrt = s_max( 0, q_sqrt ); } tmp = ISqrt32( ftmp, &q_sqrt ); - e_cng_temp[i] = sub( 31, add( q_sqrt, q_div ) ); + e_norm_temp[i] = sub( 31, add( q_sqrt, q_div ) ); *ptr0++ = Mpy_32_32( factor, tmp ); ptr1 += 2; ptr2 += 2; @@ -910,11 +910,11 @@ static void stereo_dft_generate_comfort_noise_fx( FOR( i = 0; i < sub( shr( st->L_frame, 1 ), 1 ); i++ ) { - q_cngNoiseLevel_upd = s_min( q_cngNoiseLevel_upd, e_cng_temp[i] + norm_l( cngNoiseLevel_upd[i] ) ); + q_cngNoiseLevel_upd = s_min( q_cngNoiseLevel_upd, e_norm_temp[i] + norm_l( cngNoiseLevel_upd[i] ) ); } FOR( i = 0; i < st->L_frame; i++ ) { - cngNoiseLevel_upd[i] = L_shl( cngNoiseLevel_upd[i], sub( q_cngNoiseLevel_upd, e_cng_temp[i] ) ); + cngNoiseLevel_upd[i] = L_shl( cngNoiseLevel_upd[i], sub( q_cngNoiseLevel_upd, e_norm_temp[i] ) ); } IF( GT_16( sub( s_min( output_frame, L_FRAME32k ), hFdCngCom->stopFFTbin ), 0 ) ) @@ -952,6 +952,7 @@ static void stereo_dft_generate_comfort_noise_fx( ptr0 = shb_shape; ptr1 = ptr0 + 2; ptr2 = ptr1 + 1; + set16_fx( e_norm_temp, q_shb_shape, st->L_frame ); FOR( i = 0; i < L_FRAME16k / 2 - 1; i++ ) { @@ -968,10 +969,21 @@ static void stereo_dft_generate_comfort_noise_fx( and then sum up enr = sum( *ptr0 * *ptr0 ), in a subsequent MAC loop */ enr = BASOP_Util_Add_Mant32Exp( enr, q_enr, ftmp, q_div, &q_enr ); tmp32_1 = Sqrt32( ftmp, &q_div ); - *ptr0++ = L_shl( tmp32_1, sub( q_div, sub( 31, q_shb_shape ) ) ); + *ptr0++ = tmp32_1; + e_norm_temp[i] = sub( 31, q_div ); ptr1 += 2; ptr2 += 2; } + q_shb_shape = MAX_16; + + FOR( i = 0; i < L_FRAME16k; i++ ) + { + q_shb_shape = s_min( q_shb_shape, add( e_norm_temp[i], norm_l( shb_shape[i] ) ) ); + } + FOR( i = 0; i < L_FRAME16k; i++ ) + { + shb_shape[i] = L_shl( shb_shape[i], sub( q_shb_shape, e_norm_temp[i] ) ); + } } /* Update CNG noise level from MS noise estimation */ -- GitLab