From f992ee44e0fb6efee4b4610d0b31db8141c46237 Mon Sep 17 00:00:00 2001 From: azmill Date: Mon, 14 Aug 2023 23:50:30 +1000 Subject: [PATCH 1/2] Fixing MSAN issue in SBA decoder --- lib_com/ivas_prot.h | 3 ++- lib_com/ivas_spar_com_quant_util.c | 22 +++++++++++++--------- lib_dec/ivas_spar_md_dec.c | 2 +- lib_enc/ivas_spar_md_enc.c | 2 +- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 02bdaa5d0b..f742c72ec3 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5092,7 +5092,8 @@ void ivas_copy_band_coeffs_idx_to_arr( void ivas_clear_band_coeffs( ivas_band_coeffs_t *pband_coeffs, - const uint16_t num_bands + const uint16_t num_bands, + const uint16_t num_ts ); 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 0b172c0aa0..7e7aa4c084 100644 --- a/lib_com/ivas_spar_com_quant_util.c +++ b/lib_com/ivas_spar_com_quant_util.c @@ -293,19 +293,23 @@ void ivas_copy_band_coeffs_idx_to_arr( void ivas_clear_band_coeffs( ivas_band_coeffs_t *pband_coeffs, - const uint16_t num_bands ) + const uint16_t num_bands, + const uint16_t num_ts ) { - uint16_t i; + uint16_t i, j; - for ( i = 0; i < num_bands; i++ ) + for ( j = 0; j < num_ts; j++ ) { - 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 ) ); + 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 ) ); + set_zero( (float *) pband_coeffs[i + j * num_bands].P_re, ( IVAS_SPAR_MAX_CH - 1 ) ); + set_zero( (float *) pband_coeffs[i + j * num_bands].C_quant_re, ( IVAS_SPAR_MAX_CH - IVAS_SPAR_MAX_DMX_CHS ) * ( IVAS_SPAR_MAX_DMX_CHS - 1 ) ); + set_zero( (float *) pband_coeffs[i + j * num_bands].P_quant_re, ( IVAS_SPAR_MAX_CH - 1 ) ); + set_zero( pband_coeffs[i + j * num_bands].pred_re, ( IVAS_SPAR_MAX_CH - 1 ) ); - set_zero( pband_coeffs[i].pred_quant_re, ( IVAS_SPAR_MAX_CH - 1 ) ); + set_zero( pband_coeffs[i + j * num_bands].pred_quant_re, ( IVAS_SPAR_MAX_CH - 1 ) ); + } } return; diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c index 032de95e09..ae2b73aa00 100644 --- a/lib_dec/ivas_spar_md_dec.c +++ b/lib_dec/ivas_spar_md_dec.c @@ -542,7 +542,7 @@ ivas_error ivas_spar_md_dec_init( hMdDec->spar_plc_enable_fadeout_flag = 1; hMdDec->dtx_md_smoothing_cntr = 1; - ivas_clear_band_coeffs( hMdDec->spar_md.band_coeffs, IVAS_MAX_NUM_BANDS ); + ivas_clear_band_coeffs( hMdDec->spar_md.band_coeffs, IVAS_MAX_NUM_BANDS, MAX_PARAM_SPATIAL_SUBFRAMES ); 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 f32644a286..4556ae7bda 100644 --- a/lib_enc/ivas_spar_md_enc.c +++ b/lib_enc/ivas_spar_md_enc.c @@ -303,7 +303,7 @@ ivas_error ivas_spar_md_enc_init( } } - ivas_clear_band_coeffs( hMdEnc->spar_md.band_coeffs, IVAS_MAX_NUM_BANDS ); + ivas_clear_band_coeffs( hMdEnc->spar_md.band_coeffs, IVAS_MAX_NUM_BANDS, 1 ); 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 28f6e165a2b330b46e35f4d1fb8b392bf6464a50 Mon Sep 17 00:00:00 2001 From: azmill Date: Tue, 15 Aug 2023 11:32:51 +1000 Subject: [PATCH 2/2] Fixing memory issue introduced --- lib_dec/ivas_spar_md_dec.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c index 744d206315..5796b48596 100644 --- a/lib_dec/ivas_spar_md_dec.c +++ b/lib_dec/ivas_spar_md_dec.c @@ -498,7 +498,7 @@ ivas_error ivas_spar_md_dec_init( ) { int16_t i, j; - int16_t nchan_transport; + int16_t nchan_transport, num_md_sub_frames; 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,7 +541,9 @@ ivas_error ivas_spar_md_dec_init( hMdDec->spar_plc_enable_fadeout_flag = 1; hMdDec->dtx_md_smoothing_cntr = 1; - ivas_clear_band_coeffs( hMdDec->spar_md.band_coeffs, IVAS_MAX_NUM_BANDS, MAX_PARAM_SPATIAL_SUBFRAMES ); + 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 ); 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 ); -- GitLab