diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 6893be758d09d5467da7e293573858ce00c5c65c..14226ddbd9312bd78fe968c54ae3275f3ddb29cf 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -4522,8 +4522,11 @@ void ivas_spar_update_md_hist( ); int16_t ivas_spar_chk_zero_coefs( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ +#ifndef NONBE_FIX_698_SBA_MSAN + , const int16_t sba_order /* i : Ambisonic (SBA) order */ +#endif ); void ivas_spar_smooth_md_dtx( @@ -4928,10 +4931,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_ts - + ivas_band_coeffs_t *pband_coeffs, + const uint16_t num_bands ); 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 7e7aa4c0842370ca7002f39b6d72922aae1c69de..977f36e37458e2c1aa267c703815fc344db53092 100644 --- a/lib_com/ivas_spar_com_quant_util.c +++ b/lib_com/ivas_spar_com_quant_util.c @@ -293,23 +293,18 @@ 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_ts ) + const uint16_t num_bands ) { - uint16_t i, j; + uint16_t i; - for ( j = 0; j < num_ts; j++ ) + for ( i = 0; i < num_bands; i++ ) { - 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 + j * num_bands].pred_quant_re, ( IVAS_SPAR_MAX_CH - 1 ) ); - } + 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 ) ); + set_zero( pband_coeffs[i].pred_quant_re, ( IVAS_SPAR_MAX_CH - 1 ) ); } return; diff --git a/lib_com/options.h b/lib_com/options.h index 6e0e5324b721c23ebc99e2ef2cb2bd113611987c..9eca13133d17fd46bc263a7453f7796b82d518ca 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -175,6 +175,7 @@ #define NONBE_FIX_736_FOA_BR_SWITCH /* FhG/Dlb : Issue 736: FOA bitrate switching decoding crashes in in ivas_spar_to_dirac */ #define NONBE_FIX_746_NONDIEGETIC_MD /* Eri: Issue 746: The non-diegetic panning flag affects the encoder bitstream even if extended metadata is not enabled. Crashes the decoder.*/ #define NONBE_FIX_729_ASAN_2ISM_ACELP /* VA: issue 729: fix ASAN ACELP errors with 2 ISM coding using LTV */ +#define NONBE_FIX_698_SBA_MSAN /* Dlb: issue 698: Uninitialized memory read in SBA init */ #define NONBE_FIX_694_OMASA_ACELP /* Nokia: Issue #694: OMASA crash in ACELP with extreme item */ #define NONBE_FIX_770_PLANAR_SBA_JBM /* FhG : Issue #770: Crash in planar FOA decoding with JBM caused by uninitialized value */ #define NONBE_FIX_760_COHERENCE_MASA /* Nokia: Issue 760: fixes decoder crash for some cases when all energy ratios are 1 */ diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c index 5796b4859623ee702c783891401292ae2bf9ad63..fd7df428aeb9de26e17c26cffea54320e5a7e79e 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, num_md_sub_frames; + int16_t nchan_transport; 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 +541,7 @@ ivas_error ivas_spar_md_dec_init( hMdDec->spar_plc_enable_fadeout_flag = 1; hMdDec->dtx_md_smoothing_cntr = 1; - 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_coeffs( hMdDec->spar_md.band_coeffs, IVAS_MAX_NUM_BANDS ); 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 ); @@ -638,8 +636,11 @@ static ivas_error ivas_spar_set_dec_config( *-----------------------------------------------------------------------------------------*/ static void ivas_dec_mono_sba_handling( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t sba_order /* i : Ambisonic (SBA) order */ + Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ +#ifndef NONBE_FIX_698_SBA_MSAN + , + const int16_t sba_order /* i : Ambisonic (SBA) order */ +#endif ) { int16_t mono_flag, b, block; @@ -662,8 +663,12 @@ static void ivas_dec_mono_sba_handling( } } } - /* Combine the SPAR prediction coefs flag with the azimuth, elevation and energy ratio flag.*/ +/* Combine the SPAR prediction coefs flag with the azimuth, elevation and energy ratio flag.*/ +#ifdef NONBE_FIX_698_SBA_MSAN + mono_flag = mono_flag && ivas_spar_chk_zero_coefs( st_ivas ); +#else mono_flag = mono_flag && ivas_spar_chk_zero_coefs( st_ivas, sba_order ); +#endif if ( mono_flag ) { @@ -748,7 +753,11 @@ void ivas_spar_md_dec_process( ivas_spar_dec_parse_md_bs( hMdDec, st0, &nB, &bw, &dtx_vad, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->hQMetaData->sba_inactive_mode, st_ivas->last_active_ivas_total_brate ); +#ifdef NONBE_FIX_698_SBA_MSAN + ivas_dec_mono_sba_handling( st_ivas ); +#else ivas_dec_mono_sba_handling( st_ivas, sba_order ); +#endif /* SPAR to DirAC conversion */ if ( hMdDec->spar_hoa_dirac2spar_md_flag == 1 ) @@ -860,31 +869,42 @@ void ivas_spar_md_dec_process( *-----------------------------------------------------------------------------------------*/ int16_t ivas_spar_chk_zero_coefs( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t sba_order /* i : Ambisonic (SBA) order */ + Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ +#ifndef NONBE_FIX_698_SBA_MSAN + , + const int16_t sba_order /* i : Ambisonic (SBA) order */ +#endif ) { +#ifdef NONBE_FIX_698_SBA_MSAN + int16_t j, k, b; +#else int16_t j, k, b, i_ts; - ivas_spar_md_dec_state_t *hMdDec; int16_t num_md_sub_frames; +#endif + ivas_spar_md_dec_state_t *hMdDec; int16_t mono = 1; int16_t ndec, ndm; hMdDec = st_ivas->hSpar->hMdDec; - - num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order, st_ivas->hDecoderConfig->ivas_total_brate, - st_ivas->last_active_ivas_total_brate ); - ndec = hMdDec->spar_md_cfg.num_decorr_per_band[0]; ndm = hMdDec->spar_md_cfg.num_dmx_chans_per_band[0]; +#ifndef NONBE_FIX_698_SBA_MSAN + num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order, st_ivas->hDecoderConfig->ivas_total_brate, + st_ivas->last_active_ivas_total_brate ); for ( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) { +#endif for ( b = 0; b < min( hMdDec->spar_md.num_bands, SPAR_DIRAC_SPLIT_START_BAND ); b++ ) { for ( j = 0; j < ndm + ndec - 1; j++ ) { - if ( hMdDec->spar_md.band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].pred_re[j] != 0.0f ) +#ifdef NONBE_FIX_698_SBA_MSAN + if ( hMdDec->spar_md.band_coeffs[b].pred_re[j] != 0.0f ) +#else + if ( hMdDec->spar_md.band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].pred_re[j] != 0.0f ) +#endif { mono = 0; } @@ -893,7 +913,11 @@ int16_t ivas_spar_chk_zero_coefs( { for ( k = 0; k < ndm - 1; k++ ) { - if ( hMdDec->spar_md.band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].C_re[j][k] != 0.0f ) +#ifdef NONBE_FIX_698_SBA_MSAN + if ( hMdDec->spar_md.band_coeffs[b].C_re[j][k] != 0.0f ) +#else + if ( hMdDec->spar_md.band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].C_re[j][k] != 0.0f ) +#endif { mono = 0; } @@ -901,13 +925,19 @@ int16_t ivas_spar_chk_zero_coefs( } for ( j = 0; j < ndec; j++ ) { - if ( hMdDec->spar_md.band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].P_re[j] != 0.0f ) +#ifdef NONBE_FIX_698_SBA_MSAN + if ( hMdDec->spar_md.band_coeffs[b].P_re[j] != 0.0f ) +#else + if ( hMdDec->spar_md.band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].P_re[j] != 0.0f ) +#endif { mono = 0; } } } +#ifndef NONBE_FIX_698_SBA_MSAN } +#endif return mono; } diff --git a/lib_enc/ivas_spar_md_enc.c b/lib_enc/ivas_spar_md_enc.c index 93dc7daf0a14ac706ef24625cc319bd222d6716a..94ae5e0b1b391a509d54c5f351a8472f94d1381b 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, 1 ); + ivas_clear_band_coeffs( hMdEnc->spar_md.band_coeffs, IVAS_MAX_NUM_BANDS ); 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 );