From ee26aca1746766b2b5991738457ee927ebdbd903 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Tue, 15 Aug 2023 21:54:48 +0200 Subject: [PATCH 1/2] Fix for MSAN issue under CR_FIX_698_SBA_MSAN --- lib_com/ivas_prot.h | 5 +++++ lib_com/ivas_spar_com_quant_util.c | 24 ++++++++++++++++++++++++ lib_com/options.h | 1 + lib_dec/ivas_spar_md_dec.c | 8 ++++++++ lib_enc/ivas_spar_md_enc.c | 4 ++++ 5 files changed, 42 insertions(+) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 2e12b0481c..a0d220df2a 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -4892,8 +4892,13 @@ void ivas_copy_band_coeffs_idx_to_arr( void ivas_clear_band_coeffs( ivas_band_coeffs_t *pband_coeffs, +#ifdef CR_FIX_698_SBA_MSAN const uint16_t num_bands, const uint16_t num_ts +#else + const uint16_t num_bands +#endif + ); void ivas_clear_band_coeff_idx( diff --git a/lib_com/ivas_spar_com_quant_util.c b/lib_com/ivas_spar_com_quant_util.c index 7e7aa4c084..bc920081a5 100644 --- a/lib_com/ivas_spar_com_quant_util.c +++ b/lib_com/ivas_spar_com_quant_util.c @@ -293,13 +293,33 @@ void ivas_copy_band_coeffs_idx_to_arr( void ivas_clear_band_coeffs( ivas_band_coeffs_t *pband_coeffs, +#ifdef CR_FIX_698_SBA_MSAN const uint16_t num_bands, const uint16_t num_ts ) +#else + const uint16_t num_bands ) +#endif { +#ifdef CR_FIX_698_SBA_MSAN uint16_t i, j; +#else + uint16_t i; +#endif +#ifdef CR_FIX_698_SBA_MSAN for ( j = 0; j < num_ts; j++ ) +#else + for ( i = 0; i < num_bands; i++ ) +#endif { +#ifndef CR_FIX_698_SBA_MSAN + set_zero( (float *) pband_coeffs[i].C_re, ( IVAS_SPAR_MAX_CH - IVAS_SPAR_MAX_DMX_CHS ) * ( IVAS_SPAR_MAX_DMX_CHS - 1 ) ); + set_zero( (float *) pband_coeffs[i].P_re, ( IVAS_SPAR_MAX_CH - 1 ) ); + set_zero( (float *) pband_coeffs[i].C_quant_re, ( IVAS_SPAR_MAX_CH - IVAS_SPAR_MAX_DMX_CHS ) * ( IVAS_SPAR_MAX_DMX_CHS - 1 ) ); + set_zero( (float *) pband_coeffs[i].P_quant_re, ( IVAS_SPAR_MAX_CH - 1 ) ); + set_zero( pband_coeffs[i].pred_re, ( IVAS_SPAR_MAX_CH - 1 ) ); +#endif +#ifdef CR_FIX_698_SBA_MSAN for ( i = 0; i < num_bands; i++ ) { set_zero( (float *) pband_coeffs[i + j * num_bands].C_re, ( IVAS_SPAR_MAX_CH - IVAS_SPAR_MAX_DMX_CHS ) * ( IVAS_SPAR_MAX_DMX_CHS - 1 ) ); @@ -310,6 +330,10 @@ void ivas_clear_band_coeffs( set_zero( pband_coeffs[i + j * num_bands].pred_quant_re, ( IVAS_SPAR_MAX_CH - 1 ) ); } +#else + set_zero( pband_coeffs[i].pred_quant_re, ( IVAS_SPAR_MAX_CH - 1 ) ); +#endif + } return; diff --git a/lib_com/options.h b/lib_com/options.h index 0f5f3b7fed..b556709497 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -169,6 +169,7 @@ #define CR_FIX_639_HQ_ACELP_TRANSITION /* Ericsson: Issue 639: Wrong sampling rate of SWB TBE excitation memory in 16 kHz core for DFT Stereo@32 kbps */ #define CR_FIX_586_BPF_DFT_MEM /* FhG: issue 586: set input memory of DFT analysis of BPF signal to zero for HQ core to fix issue with PLC and bitrate switching */ #define CR_FIX_ISM_DTX_INFINITE_CNG_ON_TRAILING_SILENCE /* FhG: fix for cng in ISM DTX on sudden silence periods */ +#define CR_FIX_698_SBA_MSAN /* Dlb: issue 698: Uninitialized memory read in SBA init */ /* ##################### End NON-BE CR switches ########################### */ diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c index 5796b48596..909284d810 100644 --- a/lib_dec/ivas_spar_md_dec.c +++ b/lib_dec/ivas_spar_md_dec.c @@ -498,7 +498,11 @@ ivas_error ivas_spar_md_dec_init( ) { int16_t i, j; +#ifdef CR_FIX_698_SBA_MSAN int16_t nchan_transport, num_md_sub_frames; +#else + int16_t nchan_transport; +#endif float pFC[IVAS_MAX_NUM_BANDS], PR_minmax[2]; ivas_sba_get_spar_hoa_md_flag( sba_order, hDecoderConfig->ivas_total_brate, &hMdDec->spar_hoa_md_flag, &hMdDec->spar_hoa_dirac2spar_md_flag ); @@ -541,9 +545,13 @@ ivas_error ivas_spar_md_dec_init( hMdDec->spar_plc_enable_fadeout_flag = 1; hMdDec->dtx_md_smoothing_cntr = 1; +#ifdef CR_FIX_698_SBA_MSAN num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order, hDecoderConfig->ivas_total_brate, hDecoderConfig->ivas_total_brate ); ivas_clear_band_coeffs( hMdDec->spar_md.band_coeffs, IVAS_MAX_NUM_BANDS, num_md_sub_frames ); +#else + ivas_clear_band_coeffs( hMdDec->spar_md.band_coeffs, IVAS_MAX_NUM_BANDS ); +#endif ivas_clear_band_coeff_idx( hMdDec->spar_md.band_coeffs_idx, IVAS_MAX_NUM_BANDS ); ivas_clear_band_coeff_idx( hMdDec->spar_md_prev.band_coeffs_idx, IVAS_MAX_NUM_BANDS ); ivas_clear_band_coeff_idx( hMdDec->spar_md_prev.band_coeffs_idx_mapped, IVAS_MAX_NUM_BANDS ); diff --git a/lib_enc/ivas_spar_md_enc.c b/lib_enc/ivas_spar_md_enc.c index 93dc7daf0a..3aa05843ad 100644 --- a/lib_enc/ivas_spar_md_enc.c +++ b/lib_enc/ivas_spar_md_enc.c @@ -303,7 +303,11 @@ ivas_error ivas_spar_md_enc_init( } } +#ifdef CR_FIX_698_SBA_MSAN ivas_clear_band_coeffs( hMdEnc->spar_md.band_coeffs, IVAS_MAX_NUM_BANDS, 1 ); +#else + ivas_clear_band_coeffs( hMdEnc->spar_md.band_coeffs, IVAS_MAX_NUM_BANDS ); +#endif ivas_clear_band_coeff_idx( hMdEnc->spar_md.band_coeffs_idx, IVAS_MAX_NUM_BANDS ); ivas_clear_band_coeff_idx( hMdEnc->spar_md_prior.band_coeffs_idx, IVAS_MAX_NUM_BANDS ); ivas_clear_band_coeff_idx( hMdEnc->spar_md_prior.band_coeffs_idx_mapped, IVAS_MAX_NUM_BANDS ); -- GitLab From 447d8e4287197cdba4ea3a2c2a508970db1b406c Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Tue, 15 Aug 2023 22:09:06 +0200 Subject: [PATCH 2/2] Clang format --- lib_com/ivas_spar_com_quant_util.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_com/ivas_spar_com_quant_util.c b/lib_com/ivas_spar_com_quant_util.c index bc920081a5..863177130b 100644 --- a/lib_com/ivas_spar_com_quant_util.c +++ b/lib_com/ivas_spar_com_quant_util.c @@ -333,7 +333,6 @@ void ivas_clear_band_coeffs( #else set_zero( pband_coeffs[i].pred_quant_re, ( IVAS_SPAR_MAX_CH - 1 ) ); #endif - } return; -- GitLab