From 988cc9040763c4e49d175960cab4a201957fe865 Mon Sep 17 00:00:00 2001 From: Shikha Shetgeri <100861@ittiam.com> Date: Fri, 19 May 2023 16:51:43 +0530 Subject: [PATCH 01/10] Added flag for bitrate 512kbps and FOA out config check --- lib_com/ivas_fb_mixer.c | 7 +- lib_com/ivas_prot.h | 15 +++ lib_com/ivas_td_decorr.c | 43 ++++++- lib_com/options.h | 2 + lib_dec/ivas_init_dec.c | 19 +++- lib_dec/ivas_masa_dec.c | 8 +- lib_dec/ivas_mcmasa_dec.c | 7 +- lib_dec/ivas_mct_dec.c | 7 +- lib_dec/ivas_sba_dec.c | 24 +++- lib_dec/ivas_spar_decoder.c | 111 ++++++++++++++----- lib_dec/ivas_spar_md_dec.c | 12 +- lib_dec/ivas_stat_dec.h | 4 + lib_rend/ivas_dirac_dec_binaural_functions.c | 17 ++- lib_rend/ivas_reverb.c | 7 +- 14 files changed, 220 insertions(+), 63 deletions(-) diff --git a/lib_com/ivas_fb_mixer.c b/lib_com/ivas_fb_mixer.c index 2598a43d30..aae69cf7e4 100644 --- a/lib_com/ivas_fb_mixer.c +++ b/lib_com/ivas_fb_mixer.c @@ -589,14 +589,11 @@ void ivas_fb_mixer_update_prior_input( ) { int16_t i; - - for ( i = 0; i < #ifdef HODIRAC - nchan_fb_in; + for ( i = 0; i < nchan_fb_in; i++ ) #else - hFbMixer->fb_cfg->num_in_chans; + for ( i = 0; i < hFbMixer->fb_cfg->num_in_chans; i++ ) #endif - i++ ) { mvr2r( &hFbMixer->ppFilterbank_prior_input[i][length], hFbMixer->ppFilterbank_prior_input[i], hFbMixer->fb_cfg->prior_input_length - length ); mvr2r( pcm_in[i], &hFbMixer->ppFilterbank_prior_input[i][hFbMixer->fb_cfg->prior_input_length - length], length ); diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 5d4faf0eb0..2381913f70 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -3741,6 +3741,10 @@ ivas_error ivas_td_decorr_reconfig_dec( const int32_t output_Fs, /* i : output sampling rate */ ivas_td_decorr_state_t **hTdDecorr, /* i/o: TD decorrelator handle */ uint16_t *useTdDecorr /* i/o: TD decorrelator flag */ +#ifdef TD_DECORR_DIS + , + int16_t td_decorr_flag /* i : Disable malloc for td_decorr structure flag */ +#endif ); /*! r: Configured reqularization factor value */ @@ -4359,6 +4363,10 @@ void ivas_spar_dec_close( SPAR_DEC_HANDLE *hSpar, /* i/o: SPAR decoder handle */ const int32_t output_Fs, /* i : output sampling rate */ const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ +#ifdef TD_DECORR_DIS + , + const int16_t td_decorr_flag /* i : Disable malloc for td_decorr structure flag */ +#endif ); ivas_error ivas_spar_dec( @@ -5814,6 +5822,13 @@ int16_t ivas_get_num_bands_from_bw_idx( const int16_t bwidth /* i : audio bandwidth */ ); +#ifdef TD_DECORR_DIS +void ivas_td_decorr_bitrate_check( + const int32_t ivas_total_brate, /* i : IVAS total bitrate */ + AUDIO_CONFIG output_config, /* i : output config. */ + Decoder_Struct *st_ivas /* i/o : IVAS decoder structure */ +); +#endif /* clang-format on */ diff --git a/lib_com/ivas_td_decorr.c b/lib_com/ivas_td_decorr.c index 9a08c06f6a..c54c100385 100644 --- a/lib_com/ivas_td_decorr.c +++ b/lib_com/ivas_td_decorr.c @@ -115,6 +115,10 @@ ivas_error ivas_td_decorr_reconfig_dec( const int32_t output_Fs, /* i : output sampling rate */ ivas_td_decorr_state_t **hTdDecorr, /* i/o: TD decorrelator handle */ uint16_t *useTdDecorr /* i/o: TD decorrelator flag */ +#ifdef TD_DECORR_DIS + , + int16_t td_decorr_flag /* i : Disable malloc for td_decorr structure flag */ +#endif ) { uint16_t useTdDecorr_new; @@ -151,13 +155,20 @@ ivas_error ivas_td_decorr_reconfig_dec( { if ( ivas_total_brate >= IVAS_13k2 && ivas_format == SBA_FORMAT ) { - if ( *hTdDecorr == NULL ) +#ifdef TD_DECORR_DIS + if ( !td_decorr_flag ) { - if ( ( error = ivas_td_decorr_dec_open( hTdDecorr, output_Fs, 3, 1 ) ) != IVAS_ERR_OK ) +#endif + if ( *hTdDecorr == NULL ) { - return error; + if ( ( error = ivas_td_decorr_dec_open( hTdDecorr, output_Fs, 3, 1 ) ) != IVAS_ERR_OK ) + { + return error; + } } +#ifdef TD_DECORR_DIS } +#endif if ( ivas_total_brate < IVAS_24k4 ) { @@ -215,7 +226,6 @@ ivas_error ivas_td_decorr_dec_open( num_out_chans = nchan_internal - 1; error = IVAS_ERR_OK; - if ( ( hTdDecorr_loc = (ivas_td_decorr_state_t *) malloc( sizeof( ivas_td_decorr_state_t ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR COV decoder" ); @@ -226,6 +236,7 @@ ivas_error ivas_td_decorr_dec_open( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR COV decoder" ); } set_f( hTdDecorr_loc->look_ahead_buf, 0, (int16_t) ( output_Fs * IVAS_DECORR_PARM_LOOKAHEAD_TAU ) ); + #ifdef JBM_TSM_ON_TCS hTdDecorr_loc->offset = (int16_t) ( output_Fs * IVAS_DECORR_PARM_LOOKAHEAD_TAU ); #endif @@ -539,3 +550,27 @@ void ivas_td_decorr_process( return; } + +/*-----------------------------------------------------------------------------------------* + * Function ivas_td_decorr_bitrate_check() + * + * TD decorr bitrate and outfit_config check call + *-----------------------------------------------------------------------------------------*/ + +#ifdef TD_DECORR_DIS +void ivas_td_decorr_bitrate_check( + const int32_t ivas_total_brate, /* i : IVAS total bitrate */ + AUDIO_CONFIG output_config, /* i : output config. */ + Decoder_Struct *st_ivas /* i/o : IVAS decoder structure */ +) +{ + if ( ivas_total_brate == IVAS_512k && output_config == AUDIO_CONFIG_FOA ) + { + st_ivas->td_decorr_flag = 1; + } + else + { + st_ivas->td_decorr_flag = 0; + } +} +#endif \ No newline at end of file diff --git a/lib_com/options.h b/lib_com/options.h index be54df0c71..5d5fb6d896 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -223,6 +223,8 @@ #define FIX_487_LOWRATE_SBA_TUNING_FIX /* Dlb: TUning fix for low bitrate cases to match theoretical longest SPAR MD bitstream */ +#define TD_DECORR_DIS /* Dlb : Issue 163 : Malloc of td_deccor structure at 512 kbps and output configuration FOA*/ + /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index d5982c63a0..7606ea18fd 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -695,6 +695,9 @@ ivas_error ivas_init_decoder( hDecoderConfig->last_ivas_total_brate = ivas_total_brate; st_ivas->last_active_ivas_total_brate = ivas_total_brate; +#ifdef TD_DECORR_DIS + ivas_td_decorr_bitrate_check( ivas_total_brate, output_config, st_ivas ); +#endif if ( output_config == AUDIO_CONFIG_EXTERNAL ) { @@ -1840,7 +1843,12 @@ void ivas_destroy_dec( } /* SPAR handle */ - ivas_spar_dec_close( &( st_ivas->hSpar ), st_ivas->hDecoderConfig->output_Fs, 0 ); + ivas_spar_dec_close( &( st_ivas->hSpar ), st_ivas->hDecoderConfig->output_Fs, 0 +#ifdef TD_DECORR_DIS + , + st_ivas->td_decorr_flag +#endif + ); /* HOA decoder matrix */ if ( st_ivas->hoa_dec_mtx != NULL ) @@ -1863,7 +1871,14 @@ void ivas_destroy_dec( #ifdef MC_PARAMUPMIX_MODE /* Param-Upmix MC handle */ - ivas_mc_paramupmix_dec_close( &( st_ivas->hMCParamUpmix ) ); +#ifdef TD_DECORR_DIS + if ( !st_ivas->td_decorr_flag ) + { +#endif + ivas_mc_paramupmix_dec_close( &( st_ivas->hMCParamUpmix ) ); +#ifdef TD_DECORR_DIS + } +#endif #endif /* Parametric MC handle */ diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 2c9fcbd008..aad2c5b24d 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -1244,10 +1244,14 @@ ivas_error ivas_masa_dec_reconfigure( /*-----------------------------------------------------------------* * TD Decorrelator *-----------------------------------------------------------------*/ - if ( st_ivas->hDiracDecBin != NULL ) { - if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) +#ifdef TD_DECORR_DIS + , + 0 +#endif + ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_mcmasa_dec.c b/lib_dec/ivas_mcmasa_dec.c index 59d215e22c..4abf4cea34 100755 --- a/lib_dec/ivas_mcmasa_dec.c +++ b/lib_dec/ivas_mcmasa_dec.c @@ -133,7 +133,12 @@ ivas_error ivas_mcmasa_dec_reconfig( { #ifdef FIX_417_TD_DECORR_BRATE_SW /* if necessary, close/open td-decorrs */ - if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) +#ifdef TD_DECORR_DIS + , + 0 +#endif + ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 19a0909461..519988b40c 100755 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -1311,7 +1311,12 @@ static ivas_error ivas_mc_dec_reconfig( if ( st_ivas->hDiracDecBin != NULL ) { - if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) +#ifdef TD_DECORR_DIS + , + 0 +#endif + ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 0dcaec91da..ea105f5494 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -181,8 +181,12 @@ ivas_error ivas_sba_dec_reconfigure( ) { - ivas_spar_dec_close( &( st_ivas->hSpar ), hDecoderConfig->output_Fs, 1 ); - + ivas_spar_dec_close( &( st_ivas->hSpar ), hDecoderConfig->output_Fs, 1 +#ifdef TD_DECORR_DIS + , + st_ivas->td_decorr_flag +#endif + ); if ( ( error = ivas_spar_dec_open( st_ivas, 1 ) ) != IVAS_ERR_OK ) { return error; @@ -359,7 +363,12 @@ ivas_error ivas_sba_dec_reconfigure( if ( st_ivas->hDiracDecBin != NULL ) { - if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) +#ifdef TD_DECORR_DIS + , + st_ivas->td_decorr_flag +#endif + ) ) != IVAS_ERR_OK ) { return error; } @@ -464,7 +473,14 @@ ivas_error ivas_sba_dec_digest_tc( while ( nSamplesLeftForTD ) { int16_t nSamplesToDecorr = min( nSamplesLeftForTD, default_frame ); - ivas_td_decorr_process( st_ivas->hDiracDecBin->hTdDecorr, p_tc, decorr_signal, nSamplesToDecorr ); +#ifdef TD_DECORR_DIS + if ( !st_ivas->td_decorr_flag ) + { +#endif + ivas_td_decorr_process( st_ivas->hDiracDecBin->hTdDecorr, p_tc, decorr_signal, nSamplesToDecorr ); +#ifdef TD_DECORR_DIS + } +#endif for ( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) { decorr_signal[ch_idx] += nSamplesToDecorr; diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index d1104594a1..b6b568ab5d 100755 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -110,10 +110,17 @@ ivas_error ivas_spar_dec_open( #ifdef HODIRAC /* TD decorr. */ - if ( ( error = ivas_td_decorr_dec_open( &hSpar->hTdDecorr, output_Fs, num_decor_chs + 1, 1 ) ) != IVAS_ERR_OK ) +#ifdef TD_DECORR_DIS + if ( !st_ivas->td_decorr_flag ) { - return error; +#endif + if ( ( error = ivas_td_decorr_dec_open( &hSpar->hTdDecorr, output_Fs, num_decor_chs + 1, 1 ) ) != IVAS_ERR_OK ) + { + return error; + } +#ifdef TD_DECORR_DIS } +#endif #else /* TD decorr. */ if ( ( error = ivas_td_decorr_dec_open( &hSpar->hTdDecorr, output_Fs, num_channels_internal, 1 ) ) != IVAS_ERR_OK ) @@ -265,6 +272,10 @@ void ivas_spar_dec_close( SPAR_DEC_HANDLE *hSpar, /* i/o: SPAR decoder handle */ const int32_t output_Fs, /* i : output sampling rate */ const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ +#ifdef TD_DECORR_DIS + , + const int16_t td_decorr_flag /* i : Disable malloc for td_decorr structure flag */ +#endif ) { if ( *hSpar == NULL || hSpar == NULL ) @@ -276,8 +287,14 @@ void ivas_spar_dec_close( ivas_spar_md_dec_close( &( *hSpar )->hMdDec ); /* TD decorrelator handle */ - ivas_td_decorr_dec_close( &( *hSpar )->hTdDecorr ); - +#ifdef TD_DECORR_DIS + if ( !td_decorr_flag ) + { +#endif + ivas_td_decorr_dec_close( &( *hSpar )->hTdDecorr ); +#ifdef TD_DECORR_DIS + } +#endif /* FB mixer handle */ ivas_FB_mixer_close( &( *hSpar )->hFbMixer, output_Fs, spar_reconfig_flag ); @@ -757,8 +774,14 @@ static void ivas_spar_dec_MD( if ( hSpar->hMdDec->table_idx != table_idx ) { hSpar->hMdDec->table_idx = table_idx; - hSpar->hTdDecorr->ducking_flag = ivas_spar_br_table_consts[table_idx].td_ducking; - +#ifdef TD_DECORR_DIS + if ( !st_ivas->td_decorr_flag ) + { +#endif + hSpar->hTdDecorr->ducking_flag = ivas_spar_br_table_consts[table_idx].td_ducking; +#ifdef TD_DECORR_DIS + } +#endif ivas_spar_md_dec_init( hSpar->hMdDec, hDecoderConfig, num_channels, sba_order ); } } @@ -1271,26 +1294,40 @@ void ivas_spar_dec_digest_tc( while ( nSamplesLeftForTD ) { int16_t nSamplesToDecorr = min( nSamplesLeftForTD, default_frame ); - ivas_td_decorr_process( hSpar->hTdDecorr, p_tc, pPcm_tmp, nSamplesToDecorr ); -#ifdef HODIRAC - if ( hSpar->hTdDecorr->num_apd_outputs >= ( nchan_internal - nchan_transport ) ) +#ifdef TD_DECORR_DIS + if ( !st_ivas->td_decorr_flag ) { - for ( ch = 0; ch < nchan_internal - nchan_transport; ch++ ) - { - mvr2r( pPcm_tmp[hSpar->hTdDecorr->num_apd_outputs - 1 - ch], p_tc[nchan_internal - 1 - ch], nSamplesToDecorr ); - } +#endif + ivas_td_decorr_process( hSpar->hTdDecorr, p_tc, pPcm_tmp, nSamplesToDecorr ); +#ifdef TD_DECORR_DIS } - else +#endif +#ifdef HODIRAC +#ifdef TD_DECORR_DIS + if ( !st_ivas->td_decorr_flag ) { - for ( ch = 0; ch < nchan_internal - nchan_transport; ch++ ) +#endif + if ( hSpar->hTdDecorr->num_apd_outputs >= ( nchan_internal - nchan_transport ) ) { - set_zero( p_tc[nchan_internal - 1 - ch], nSamplesToDecorr ); + for ( ch = 0; ch < nchan_internal - nchan_transport; ch++ ) + { + mvr2r( pPcm_tmp[hSpar->hTdDecorr->num_apd_outputs - 1 - ch], p_tc[nchan_internal - 1 - ch], nSamplesToDecorr ); + } } - for ( ch = 0; ch < hSpar->hTdDecorr->num_apd_outputs; ch++ ) + else { - mvr2r( pPcm_tmp[hSpar->hTdDecorr->num_apd_outputs - 1 - ch], p_tc[nchan_internal - 1 - ch], nSamplesToDecorr ); + for ( ch = 0; ch < nchan_internal - nchan_transport; ch++ ) + { + set_zero( p_tc[nchan_internal - 1 - ch], nSamplesToDecorr ); + } + for ( ch = 0; ch < hSpar->hTdDecorr->num_apd_outputs; ch++ ) + { + mvr2r( pPcm_tmp[hSpar->hTdDecorr->num_apd_outputs - 1 - ch], p_tc[nchan_internal - 1 - ch], nSamplesToDecorr ); + } } +#ifdef TD_DECORR_DIS } +#endif #else for ( ch = 0; ch < nchan_internal - nchan_transport; ch++ ) { @@ -1348,26 +1385,40 @@ void ivas_spar_dec_upmixer( } if ( hSpar->hMdDec->td_decorr_flag ) { - ivas_td_decorr_process( hSpar->hTdDecorr, st_ivas->hTcBuffer->tc, pPcm_tmp, output_frame ); -#ifdef HODIRAC - if ( hSpar->hTdDecorr->num_apd_outputs >= ( nchan_internal - nchan_transport ) ) +#ifdef TD_DECORR_DIS + if ( !st_ivas->td_decorr_flag ) { - for ( i = 0; i < nchan_internal - nchan_transport; i++ ) - { - mvr2r( pPcm_tmp[hSpar->hTdDecorr->num_apd_outputs - 1 - i], st_ivas->hTcBuffer->tc[nchan_internal - 1 - i], output_frame ); - } +#endif + ivas_td_decorr_process( hSpar->hTdDecorr, st_ivas->hTcBuffer->tc, pPcm_tmp, output_frame ); +#ifdef TD_DECORR_DIS } - else +#endif +#ifdef HODIRAC +#ifdef TD_DECORR_DIS + if ( !st_ivas->td_decorr_flag ) { - for ( i = 0; i < nchan_internal - nchan_transport; i++ ) +#endif + if ( hSpar->hTdDecorr->num_apd_outputs >= ( nchan_internal - nchan_transport ) ) { - set_zero( st_ivas->hTcBuffer->tc[nchan_internal - 1 - i], output_frame ); + for ( i = 0; i < nchan_internal - nchan_transport; i++ ) + { + mvr2r( pPcm_tmp[hSpar->hTdDecorr->num_apd_outputs - 1 - i], st_ivas->hTcBuffer->tc[nchan_internal - 1 - i], output_frame ); + } } - for ( i = 0; i < hSpar->hTdDecorr->num_apd_outputs; i++ ) + else { - mvr2r( pPcm_tmp[hSpar->hTdDecorr->num_apd_outputs - 1 - i], st_ivas->hTcBuffer->tc[nchan_internal - 1 - i], output_frame ); + for ( i = 0; i < nchan_internal - nchan_transport; i++ ) + { + set_zero( st_ivas->hTcBuffer->tc[nchan_internal - 1 - i], output_frame ); + } + for ( i = 0; i < hSpar->hTdDecorr->num_apd_outputs; i++ ) + { + mvr2r( pPcm_tmp[hSpar->hTdDecorr->num_apd_outputs - 1 - i], st_ivas->hTcBuffer->tc[nchan_internal - 1 - i], output_frame ); + } } +#ifdef TD_DECORR_DIS } +#endif #else for ( i = 0; i < nchan_internal - nchan_transport; i++ ) { diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c index bfca6c6280..1889cbacf6 100755 --- a/lib_dec/ivas_spar_md_dec.c +++ b/lib_dec/ivas_spar_md_dec.c @@ -1064,18 +1064,10 @@ void ivas_spar_md_dec_process( } #ifdef HODIRAC - ivas_get_spar_matrices( hMdDec, num_bands_out, num_md_sub_frames, bw, dtx_vad, nB, + ivas_get_spar_matrices( hMdDec, num_bands_out, num_md_sub_frames, bw, dtx_vad, nB, num_md_chs, active_w_vlbr ); #else - ivas_get_spar_matrices( hMdDec, num_bands_out, MAX_PARAM_SPATIAL_SUBFRAMES, bw, dtx_vad, nB, + ivas_get_spar_matrices( hMdDec, num_bands_out, MAX_PARAM_SPATIAL_SUBFRAMES, bw, dtx_vad, nB, sba_order, active_w_vlbr ); #endif -#ifdef HODIRAC - num_md_chs, -#else - sba_order, -#endif - active_w_vlbr - - ); #ifdef DEBUG_SPAR_DIRAC_WRITE_OUT_PRED_PARS { diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 727b01c0ed..c13874aa00 100755 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1365,6 +1365,10 @@ typedef struct Decoder_Struct #ifdef JBM_TSM_ON_TCS DECODER_TC_BUFFER_HANDLE hTcBuffer; #endif + +#ifdef TD_DECORR_DIS + int16_t td_decorr_flag; /* Disable malloc for td_decorr structure flag */ +#endif } Decoder_Struct; /* clang-format on */ diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 06fd160bb2..aa7902ffcf 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -358,7 +358,12 @@ ivas_error ivas_dirac_dec_init_binaural_data( hBinaural->useTdDecorr = 0; } - if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( hBinaural->hTdDecorr ), &( hBinaural->useTdDecorr ) ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( hBinaural->hTdDecorr ), &( hBinaural->useTdDecorr ) +#ifdef TD_DECORR_DIS + , + st_ivas->td_decorr_flag +#endif + ) ) != IVAS_ERR_OK ) { return error; } @@ -383,6 +388,7 @@ ivas_error ivas_dirac_dec_init_binaural_data( } else { + ivas_td_decorr_dec_open( &( hBinaural->hTdDecorr ), output_Fs, 3, 0 ); } } @@ -614,7 +620,14 @@ void ivas_dirac_dec_binaural( output_frame = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); #ifdef JBM_TSM_ON_TCS { - ivas_td_decorr_process( st_ivas->hDiracDecBin->hTdDecorr, p_output, decorr_signal, output_frame ); +#ifdef TD_DECORR_DIS + if ( !st_ivas->td_decorr_flag ) + { +#endif + ivas_td_decorr_process( st_ivas->hDiracDecBin->hTdDecorr, p_output, decorr_signal, output_frame ); +#ifdef TD_DECORR_DIS + } +#endif } #else ivas_td_decorr_process( st_ivas->hDiracDecBin->hTdDecorr, output_f, decorr_signal, output_frame ); diff --git a/lib_rend/ivas_reverb.c b/lib_rend/ivas_reverb.c index 12a8b55ddb..3db8e0990b 100644 --- a/lib_rend/ivas_reverb.c +++ b/lib_rend/ivas_reverb.c @@ -1770,9 +1770,9 @@ void ivas_binaural_reverb_processFrame( /* Add from temporally decaying sparse tap locations the audio to the output. */ for ( tapIdx = 0; tapIdx < hReverb->taps[bin][ch]; tapIdx++ ) { +#ifdef JBM_TSM_ON_TCS switch ( phaseShiftTypePr[tapIdx] ) { -#ifdef JBM_TSM_ON_TCS case 0: /* 0 degrees phase */ v_add( hReverb->outputBufferReal[bin][ch], tapRealPr[tapIdx], hReverb->outputBufferReal[bin][ch], numSlots ); v_add( hReverb->outputBufferImag[bin][ch], tapImagPr[tapIdx], hReverb->outputBufferImag[bin][ch], numSlots ); @@ -1789,7 +1789,10 @@ void ivas_binaural_reverb_processFrame( v_add( hReverb->outputBufferReal[bin][ch], tapImagPr[tapIdx], hReverb->outputBufferReal[bin][ch], numSlots ); v_sub( hReverb->outputBufferImag[bin][ch], tapRealPr[tapIdx], hReverb->outputBufferImag[bin][ch], numSlots ); break; + } #else + switch ( phaseShiftTypePr[tapIdx] ) + { case 0: /* 0 degrees phase */ v_add( hReverb->outputBufferReal[bin][ch], tapRealPr[tapIdx], hReverb->outputBufferReal[bin][ch], hReverb->blockSize ); v_add( hReverb->outputBufferImag[bin][ch], tapImagPr[tapIdx], hReverb->outputBufferImag[bin][ch], hReverb->blockSize ); @@ -1806,8 +1809,8 @@ void ivas_binaural_reverb_processFrame( v_add( hReverb->outputBufferReal[bin][ch], tapImagPr[tapIdx], hReverb->outputBufferReal[bin][ch], hReverb->blockSize ); v_sub( hReverb->outputBufferImag[bin][ch], tapRealPr[tapIdx], hReverb->outputBufferImag[bin][ch], hReverb->blockSize ); break; -#endif } +#endif } } -- GitLab From 4c636c532ed92875308b4ca4b1b0e6955dcafd8e Mon Sep 17 00:00:00 2001 From: Shikha Shetgeri <100861@ittiam.com> Date: Fri, 19 May 2023 17:06:20 +0530 Subject: [PATCH 02/10] clang-format-fix --- lib_com/ivas_td_decorr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/ivas_td_decorr.c b/lib_com/ivas_td_decorr.c index c54c100385..5617702958 100644 --- a/lib_com/ivas_td_decorr.c +++ b/lib_com/ivas_td_decorr.c @@ -573,4 +573,4 @@ void ivas_td_decorr_bitrate_check( st_ivas->td_decorr_flag = 0; } } -#endif \ No newline at end of file +#endif -- GitLab From 74dbc0128620340c22c036ae632fe51ff0d0da50 Mon Sep 17 00:00:00 2001 From: Rivukanta Bhattacharya <100792@ittiam.com> Date: Tue, 23 May 2023 14:09:25 +0530 Subject: [PATCH 03/10] Added condition for not allocating when output config is MONO or STEREO and for the case when bitrate is not less than 256kbps and output config is FOA. --- lib_com/ivas_td_decorr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/ivas_td_decorr.c b/lib_com/ivas_td_decorr.c index 7fb5905eba..3b1d8faf47 100644 --- a/lib_com/ivas_td_decorr.c +++ b/lib_com/ivas_td_decorr.c @@ -556,7 +556,7 @@ void ivas_td_decorr_bitrate_check( Decoder_Struct *st_ivas /* i/o : IVAS decoder structure */ ) { - if ( ivas_total_brate == IVAS_512k && output_config == AUDIO_CONFIG_FOA ) + if ( ( output_config == AUDIO_CONFIG_MONO || output_config == AUDIO_CONFIG_STEREO ) || ( ivas_total_brate >= IVAS_256k && output_config == AUDIO_CONFIG_FOA ) ) { st_ivas->td_decorr_flag = 1; } -- GitLab From ca3351757352760113bc33cddef31182b9d08740 Mon Sep 17 00:00:00 2001 From: Rivukanta Bhattacharya <100792@ittiam.com> Date: Tue, 23 May 2023 15:42:46 +0530 Subject: [PATCH 04/10] Added check for SBA format --- lib_com/ivas_td_decorr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/ivas_td_decorr.c b/lib_com/ivas_td_decorr.c index 3b1d8faf47..d0d15086e4 100644 --- a/lib_com/ivas_td_decorr.c +++ b/lib_com/ivas_td_decorr.c @@ -556,7 +556,7 @@ void ivas_td_decorr_bitrate_check( Decoder_Struct *st_ivas /* i/o : IVAS decoder structure */ ) { - if ( ( output_config == AUDIO_CONFIG_MONO || output_config == AUDIO_CONFIG_STEREO ) || ( ivas_total_brate >= IVAS_256k && output_config == AUDIO_CONFIG_FOA ) ) + if ( ( st_ivas->ivas_format == SBA_FORMAT ) && ( ( output_config == AUDIO_CONFIG_MONO || output_config == AUDIO_CONFIG_STEREO ) || ( ivas_total_brate >= IVAS_256k && output_config == AUDIO_CONFIG_FOA ) ) ) { st_ivas->td_decorr_flag = 1; } -- GitLab From 688c8e1ea1bdd0da87a46c28ec2710f88f0682ef Mon Sep 17 00:00:00 2001 From: Rivukanta Bhattacharya <100792@ittiam.com> Date: Fri, 26 May 2023 15:57:26 +0530 Subject: [PATCH 05/10] Review comment changes --- lib_com/ivas_prot.h | 10 ++--- lib_com/ivas_td_decorr.c | 27 ++++------- lib_com/options.h | 2 +- lib_dec/ivas_init_dec.c | 14 +++--- lib_dec/ivas_masa_dec.c | 8 +--- lib_dec/ivas_mcmasa_dec.c | 7 +-- lib_dec/ivas_mct_dec.c | 7 +-- lib_dec/ivas_sba_dec.c | 17 +++---- lib_dec/ivas_spar_decoder.c | 47 +++++++------------- lib_dec/ivas_stat_dec.h | 7 ++- lib_rend/ivas_dirac_dec_binaural_functions.c | 13 ++---- 11 files changed, 53 insertions(+), 106 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 51fbcd7fa6..cb39e2ffdd 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -3715,10 +3715,6 @@ ivas_error ivas_td_decorr_reconfig_dec( const int32_t output_Fs, /* i : output sampling rate */ ivas_td_decorr_state_t **hTdDecorr, /* i/o: TD decorrelator handle */ uint16_t *useTdDecorr /* i/o: TD decorrelator flag */ -#ifdef TD_DECORR_DIS - , - int16_t td_decorr_flag /* i : Disable malloc for td_decorr structure flag */ -#endif ); /*! r: Configured reqularization factor value */ @@ -4317,7 +4313,7 @@ void ivas_spar_dec_close( SPAR_DEC_HANDLE *hSpar, /* i/o: SPAR decoder handle */ const int32_t output_Fs, /* i : output sampling rate */ const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ -#ifdef TD_DECORR_DIS +#ifdef FIX_163_SBA_TD_DECORR_OPT , const int16_t td_decorr_flag /* i : Disable malloc for td_decorr structure flag */ #endif @@ -5747,8 +5743,8 @@ int16_t ivas_get_num_bands_from_bw_idx( const int16_t bwidth /* i : audio bandwidth */ ); -#ifdef TD_DECORR_DIS -void ivas_td_decorr_bitrate_check( +#ifdef FIX_163_SBA_TD_DECORR_OPT +void ivas_get_td_decorr_flag( const int32_t ivas_total_brate, /* i : IVAS total bitrate */ AUDIO_CONFIG output_config, /* i : output config. */ Decoder_Struct *st_ivas /* i/o : IVAS decoder structure */ diff --git a/lib_com/ivas_td_decorr.c b/lib_com/ivas_td_decorr.c index d0d15086e4..dbe4422103 100644 --- a/lib_com/ivas_td_decorr.c +++ b/lib_com/ivas_td_decorr.c @@ -112,10 +112,6 @@ ivas_error ivas_td_decorr_reconfig_dec( const int32_t output_Fs, /* i : output sampling rate */ ivas_td_decorr_state_t **hTdDecorr, /* i/o: TD decorrelator handle */ uint16_t *useTdDecorr /* i/o: TD decorrelator flag */ -#ifdef TD_DECORR_DIS - , - int16_t td_decorr_flag /* i : Disable malloc for td_decorr structure flag */ -#endif ) { uint16_t useTdDecorr_new; @@ -152,20 +148,13 @@ ivas_error ivas_td_decorr_reconfig_dec( { if ( ivas_total_brate >= IVAS_13k2 && ivas_format == SBA_FORMAT ) { -#ifdef TD_DECORR_DIS - if ( !td_decorr_flag ) + if ( *hTdDecorr == NULL ) { -#endif - if ( *hTdDecorr == NULL ) + if ( ( error = ivas_td_decorr_dec_open( hTdDecorr, output_Fs, 3, 1 ) ) != IVAS_ERR_OK ) { - if ( ( error = ivas_td_decorr_dec_open( hTdDecorr, output_Fs, 3, 1 ) ) != IVAS_ERR_OK ) - { - return error; - } + return error; } -#ifdef TD_DECORR_DIS } -#endif if ( ivas_total_brate < IVAS_24k4 ) { @@ -544,13 +533,13 @@ void ivas_td_decorr_process( } /*-----------------------------------------------------------------------------------------* - * Function ivas_td_decorr_bitrate_check() + * Function ivas_get_td_decorr_flag() * * TD decorr bitrate and outfit_config check call *-----------------------------------------------------------------------------------------*/ -#ifdef TD_DECORR_DIS -void ivas_td_decorr_bitrate_check( +#ifdef FIX_163_SBA_TD_DECORR_OPT +void ivas_get_td_decorr_flag( const int32_t ivas_total_brate, /* i : IVAS total bitrate */ AUDIO_CONFIG output_config, /* i : output config. */ Decoder_Struct *st_ivas /* i/o : IVAS decoder structure */ @@ -558,11 +547,11 @@ void ivas_td_decorr_bitrate_check( { if ( ( st_ivas->ivas_format == SBA_FORMAT ) && ( ( output_config == AUDIO_CONFIG_MONO || output_config == AUDIO_CONFIG_STEREO ) || ( ivas_total_brate >= IVAS_256k && output_config == AUDIO_CONFIG_FOA ) ) ) { - st_ivas->td_decorr_flag = 1; + st_ivas->hSpar->td_decorr_flag = 0; } else { - st_ivas->td_decorr_flag = 0; + st_ivas->hSpar->td_decorr_flag = 1; } } #endif diff --git a/lib_com/options.h b/lib_com/options.h index 10374b0ab7..4a5e3a112e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -164,7 +164,7 @@ #define FIX_487_LOWRATE_SBA_TUNING_FIX /* Dlb: TUning fix for low bitrate cases to match theoretical longest SPAR MD bitstream */ #define FIX_490_MASA_2TC_LBR_DTX /* Nokia: Fixes issue 490 by correcting condition. */ -#define TD_DECORR_DIS /* Dlb : Issue 163 : Malloc of td_deccor structure at 512 kbps and output configuration FOA*/ +#define FIX_163_SBA_TD_DECORR_OPT /* Dlb : Issue 163 : Malloc of td_deccor structure at 512 kbps and output configuration FOA*/ #define FIX_HBR_MASAMETA /* Nokia: Fixes to HBR MASA metadata at 384 and 512 kbps. Addresses issues 438 and 477 as well. */ #define FIX_482_DUMMYDEC_INIT /* Nokia: fix issue #428: missing inits for dummyDec in IVAS_rend */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 20e5ab0777..13662e542e 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -691,8 +691,8 @@ ivas_error ivas_init_decoder( hDecoderConfig->last_ivas_total_brate = ivas_total_brate; st_ivas->last_active_ivas_total_brate = ivas_total_brate; -#ifdef TD_DECORR_DIS - ivas_td_decorr_bitrate_check( ivas_total_brate, output_config, st_ivas ); +#ifdef FIX_163_SBA_TD_DECORR_OPT + ivas_get_td_decorr_flag( ivas_total_brate, output_config, st_ivas ); #endif if ( output_config == AUDIO_CONFIG_EXTERNAL ) @@ -1821,9 +1821,9 @@ void ivas_destroy_dec( /* SPAR handle */ ivas_spar_dec_close( &( st_ivas->hSpar ), st_ivas->hDecoderConfig->output_Fs, 0 -#ifdef TD_DECORR_DIS +#ifdef FIX_163_SBA_TD_DECORR_OPT , - st_ivas->td_decorr_flag + st_ivas->hSpar->td_decorr_flag #endif ); @@ -1847,12 +1847,12 @@ void ivas_destroy_dec( ivas_lfe_dec_close( &( st_ivas->hLFE ) ); /* Param-Upmix MC handle */ -#ifdef TD_DECORR_DIS - if ( !st_ivas->td_decorr_flag ) +#ifdef FIX_163_SBA_TD_DECORR_OPT + if ( st_ivas->hSpar->td_decorr_flag ) { #endif ivas_mc_paramupmix_dec_close( &( st_ivas->hMCParamUpmix ) ); -#ifdef TD_DECORR_DIS +#ifdef FIX_163_SBA_TD_DECORR_OPT } #endif diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 8f332e5b4f..7445bfb489 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -1266,14 +1266,10 @@ ivas_error ivas_masa_dec_reconfigure( /*-----------------------------------------------------------------* * TD Decorrelator *-----------------------------------------------------------------*/ + if ( st_ivas->hDiracDecBin != NULL ) { - if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) -#ifdef TD_DECORR_DIS - , - 0 -#endif - ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_mcmasa_dec.c b/lib_dec/ivas_mcmasa_dec.c index a70f98506d..99b3ff6874 100755 --- a/lib_dec/ivas_mcmasa_dec.c +++ b/lib_dec/ivas_mcmasa_dec.c @@ -132,12 +132,7 @@ ivas_error ivas_mcmasa_dec_reconfig( else { /* if necessary, close/open td-decorrs */ - if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) -#ifdef TD_DECORR_DIS - , - 0 -#endif - ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 9f3e809a59..6eada0e18b 100755 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -1276,12 +1276,7 @@ static ivas_error ivas_mc_dec_reconfig( if ( st_ivas->hDiracDecBin != NULL ) { - if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) -#ifdef TD_DECORR_DIS - , - 0 -#endif - ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 70508a34fb..f9e035028c 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -174,9 +174,9 @@ ivas_error ivas_sba_dec_reconfigure( { ivas_spar_dec_close( &( st_ivas->hSpar ), hDecoderConfig->output_Fs, 1 -#ifdef TD_DECORR_DIS +#ifdef FIX_163_SBA_TD_DECORR_OPT , - st_ivas->td_decorr_flag + st_ivas->hSpar->td_decorr_flag #endif ); if ( ( error = ivas_spar_dec_open( st_ivas, 1 ) ) != IVAS_ERR_OK ) @@ -346,12 +346,7 @@ ivas_error ivas_sba_dec_reconfigure( if ( st_ivas->hDiracDecBin != NULL ) { - if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) -#ifdef TD_DECORR_DIS - , - st_ivas->td_decorr_flag -#endif - ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) ) ) != IVAS_ERR_OK ) { return error; } @@ -451,12 +446,12 @@ ivas_error ivas_sba_dec_digest_tc( while ( nSamplesLeftForTD ) { int16_t nSamplesToDecorr = min( nSamplesLeftForTD, default_frame ); -#ifdef TD_DECORR_DIS - if ( !st_ivas->td_decorr_flag ) +#ifdef FIX_163_SBA_TD_DECORR_OPT + if ( st_ivas->hSpar->td_decorr_flag ) { #endif ivas_td_decorr_process( st_ivas->hDiracDecBin->hTdDecorr, p_tc, decorr_signal, nSamplesToDecorr ); -#ifdef TD_DECORR_DIS +#ifdef FIX_163_SBA_TD_DECORR_OPT } #endif for ( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index b5462fb692..0b0bd73d20 100755 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -101,15 +101,16 @@ ivas_error ivas_spar_dec_open( } /* TD decorr. */ -#ifdef TD_DECORR_DIS - if ( !st_ivas->td_decorr_flag ) +#ifdef FIX_163_SBA_TD_DECORR_OPT + if ( st_ivas->hSpar->td_decorr_flag ) { #endif if ( ( error = ivas_td_decorr_dec_open( &hSpar->hTdDecorr, output_Fs, num_decor_chs + 1, 1 ) ) != IVAS_ERR_OK ) { + hSpar->hTdDecorr = NULL; return error; } -#ifdef TD_DECORR_DIS +#ifdef FIX_163_SBA_TD_DECORR_OPT } #endif @@ -252,7 +253,7 @@ void ivas_spar_dec_close( SPAR_DEC_HANDLE *hSpar, /* i/o: SPAR decoder handle */ const int32_t output_Fs, /* i : output sampling rate */ const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ -#ifdef TD_DECORR_DIS +#ifdef FIX_163_SBA_TD_DECORR_OPT , const int16_t td_decorr_flag /* i : Disable malloc for td_decorr structure flag */ #endif @@ -267,12 +268,12 @@ void ivas_spar_dec_close( ivas_spar_md_dec_close( &( *hSpar )->hMdDec ); /* TD decorrelator handle */ -#ifdef TD_DECORR_DIS - if ( !td_decorr_flag ) +#ifdef FIX_163_SBA_TD_DECORR_OPT + if ( td_decorr_flag && &( *hSpar )->hTdDecorr != NULL ) { #endif ivas_td_decorr_dec_close( &( *hSpar )->hTdDecorr ); -#ifdef TD_DECORR_DIS +#ifdef FIX_163_SBA_TD_DECORR_OPT } #endif /* FB mixer handle */ @@ -746,12 +747,12 @@ static void ivas_spar_dec_MD( if ( hSpar->hMdDec->table_idx != table_idx ) { hSpar->hMdDec->table_idx = table_idx; -#ifdef TD_DECORR_DIS - if ( !st_ivas->td_decorr_flag ) +#ifdef FIX_163_SBA_TD_DECORR_OPT + if ( st_ivas->hSpar->td_decorr_flag ) { #endif hSpar->hTdDecorr->ducking_flag = ivas_spar_br_table_consts[table_idx].td_ducking; -#ifdef TD_DECORR_DIS +#ifdef FIX_163_SBA_TD_DECORR_OPT } #endif ivas_spar_md_dec_init( hSpar->hMdDec, hDecoderConfig, num_channels, sba_order ); @@ -1222,18 +1223,11 @@ void ivas_spar_dec_digest_tc( while ( nSamplesLeftForTD ) { int16_t nSamplesToDecorr = min( nSamplesLeftForTD, default_frame ); -#ifdef TD_DECORR_DIS - if ( !st_ivas->td_decorr_flag ) +#ifdef FIX_163_SBA_TD_DECORR_OPT + if ( st_ivas->hSpar->td_decorr_flag ) { #endif ivas_td_decorr_process( hSpar->hTdDecorr, p_tc, pPcm_tmp, nSamplesToDecorr ); -#ifdef TD_DECORR_DIS - } -#endif -#ifdef TD_DECORR_DIS - if ( !st_ivas->td_decorr_flag ) - { -#endif if ( hSpar->hTdDecorr->num_apd_outputs >= ( nchan_internal - nchan_transport ) ) { for ( ch = 0; ch < nchan_internal - nchan_transport; ch++ ) @@ -1252,7 +1246,7 @@ void ivas_spar_dec_digest_tc( mvr2r( pPcm_tmp[hSpar->hTdDecorr->num_apd_outputs - 1 - ch], p_tc[nchan_internal - 1 - ch], nSamplesToDecorr ); } } -#ifdef TD_DECORR_DIS +#ifdef FIX_163_SBA_TD_DECORR_OPT } #endif for ( ch = 0; ch < nchan_internal; ch++ ) @@ -1306,18 +1300,11 @@ void ivas_spar_dec_upmixer( } if ( hSpar->hMdDec->td_decorr_flag ) { -#ifdef TD_DECORR_DIS - if ( !st_ivas->td_decorr_flag ) +#ifdef FIX_163_SBA_TD_DECORR_OPT + if ( st_ivas->hSpar->td_decorr_flag ) { #endif ivas_td_decorr_process( hSpar->hTdDecorr, st_ivas->hTcBuffer->tc, pPcm_tmp, output_frame ); -#ifdef TD_DECORR_DIS - } -#endif -#ifdef TD_DECORR_DIS - if ( !st_ivas->td_decorr_flag ) - { -#endif if ( hSpar->hTdDecorr->num_apd_outputs >= ( nchan_internal - nchan_transport ) ) { for ( i = 0; i < nchan_internal - nchan_transport; i++ ) @@ -1336,7 +1323,7 @@ void ivas_spar_dec_upmixer( mvr2r( pPcm_tmp[hSpar->hTdDecorr->num_apd_outputs - 1 - i], st_ivas->hTcBuffer->tc[nchan_internal - 1 - i], output_frame ); } } -#ifdef TD_DECORR_DIS +#ifdef FIX_163_SBA_TD_DECORR_OPT } #endif } diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 29e5665329..cdbab23260 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -921,6 +921,9 @@ typedef struct ivas_spar_dec_lib_t int16_t slots_rendered; int16_t num_slots; #endif +#ifdef FIX_163_SBA_TD_DECORR_OPT + int16_t td_decorr_flag; /* Disable malloc for td_decorr structure flag */ +#endif } SPAR_DEC_DATA, *SPAR_DEC_HANDLE; @@ -1348,10 +1351,6 @@ typedef struct Decoder_Struct #ifdef JBM_TSM_ON_TCS DECODER_TC_BUFFER_HANDLE hTcBuffer; #endif - -#ifdef TD_DECORR_DIS - int16_t td_decorr_flag; /* Disable malloc for td_decorr structure flag */ -#endif } Decoder_Struct; /* clang-format on */ diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 8668efcc08..c2370bfff3 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -228,12 +228,7 @@ ivas_error ivas_dirac_dec_init_binaural_data( hBinaural->useTdDecorr = 0; } - if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( hBinaural->hTdDecorr ), &( hBinaural->useTdDecorr ) -#ifdef TD_DECORR_DIS - , - st_ivas->td_decorr_flag -#endif - ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( hBinaural->hTdDecorr ), &( hBinaural->useTdDecorr ) ) ) != IVAS_ERR_OK ) { return error; } @@ -454,12 +449,12 @@ void ivas_dirac_dec_binaural( output_frame = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); #ifdef JBM_TSM_ON_TCS { -#ifdef TD_DECORR_DIS - if ( !st_ivas->td_decorr_flag ) +#ifdef FIX_163_SBA_TD_DECORR_OPT + if ( st_ivas->hSpar->td_decorr_flag ) { #endif ivas_td_decorr_process( st_ivas->hDiracDecBin->hTdDecorr, p_output, decorr_signal, output_frame ); -#ifdef TD_DECORR_DIS +#ifdef FIX_163_SBA_TD_DECORR_OPT } #endif } -- GitLab From f43119fc21858bdf90881f3bde6d12bd1ac5eeba Mon Sep 17 00:00:00 2001 From: Rivukanta Bhattacharya <100792@ittiam.com> Date: Fri, 26 May 2023 18:14:52 +0530 Subject: [PATCH 06/10] Failure fixes --- lib_com/ivas_prot.h | 9 ++---- lib_com/ivas_td_decorr.c | 14 +++++---- lib_dec/ivas_init_dec.c | 19 ++----------- lib_dec/ivas_sba_dec.c | 8 ++---- lib_dec/ivas_spar_decoder.c | 30 +++++++++----------- lib_dec/ivas_stat_dec.h | 2 +- lib_rend/ivas_dirac_dec_binaural_functions.c | 19 ++----------- 7 files changed, 32 insertions(+), 69 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 1c36956f77..4eb6a15c13 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -4307,10 +4307,6 @@ void ivas_spar_dec_close( SPAR_DEC_HANDLE *hSpar, /* i/o: SPAR decoder handle */ const int32_t output_Fs, /* i : output sampling rate */ const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ -#ifdef FIX_163_SBA_TD_DECORR_OPT - , - const int16_t td_decorr_flag /* i : Disable malloc for td_decorr structure flag */ -#endif ); ivas_error ivas_spar_dec( @@ -5740,9 +5736,8 @@ int16_t ivas_get_num_bands_from_bw_idx( #ifdef FIX_163_SBA_TD_DECORR_OPT void ivas_get_td_decorr_flag( - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - AUDIO_CONFIG output_config, /* i : output config. */ - Decoder_Struct *st_ivas /* i/o : IVAS decoder structure */ + SPAR_DEC_HANDLE hSpar, /* i/o : IVAS SPAR handle structure */ + Decoder_Struct *st_ivas /* i/o : IVAS decoder structure */ ); #endif diff --git a/lib_com/ivas_td_decorr.c b/lib_com/ivas_td_decorr.c index 0f2bca77eb..c5731176f4 100644 --- a/lib_com/ivas_td_decorr.c +++ b/lib_com/ivas_td_decorr.c @@ -532,26 +532,30 @@ void ivas_td_decorr_process( return; } +#ifdef FIX_163_SBA_TD_DECORR_OPT /*-----------------------------------------------------------------------------------------* * Function ivas_get_td_decorr_flag() * * TD decorr bitrate and outfit_config check call *-----------------------------------------------------------------------------------------*/ -#ifdef FIX_163_SBA_TD_DECORR_OPT void ivas_get_td_decorr_flag( - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - AUDIO_CONFIG output_config, /* i : output config. */ + SPAR_DEC_HANDLE hSpar, /* i/o : IVAS SPAR handle structure */ Decoder_Struct *st_ivas /* i/o : IVAS decoder structure */ ) { + int32_t ivas_total_brate; + AUDIO_CONFIG output_config; + + ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; + output_config = st_ivas->hDecoderConfig->output_config; if ( ( st_ivas->ivas_format == SBA_FORMAT ) && ( ( output_config == AUDIO_CONFIG_MONO || output_config == AUDIO_CONFIG_STEREO ) || ( ivas_total_brate >= IVAS_256k && output_config == AUDIO_CONFIG_FOA ) ) ) { - st_ivas->hSpar->td_decorr_flag = 0; + hSpar->td_decorr_flag = 0; } else { - st_ivas->hSpar->td_decorr_flag = 1; + hSpar->td_decorr_flag = 1; } } #endif diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 5ecdeb81c7..ddb6496fce 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -694,9 +694,6 @@ ivas_error ivas_init_decoder( hDecoderConfig->last_ivas_total_brate = ivas_total_brate; st_ivas->last_active_ivas_total_brate = ivas_total_brate; -#ifdef FIX_163_SBA_TD_DECORR_OPT - ivas_get_td_decorr_flag( ivas_total_brate, output_config, st_ivas ); -#endif if ( output_config == AUDIO_CONFIG_EXTERNAL ) { @@ -1827,12 +1824,7 @@ void ivas_destroy_dec( } /* SPAR handle */ - ivas_spar_dec_close( &( st_ivas->hSpar ), st_ivas->hDecoderConfig->output_Fs, 0 -#ifdef FIX_163_SBA_TD_DECORR_OPT - , - st_ivas->hSpar->td_decorr_flag -#endif - ); + ivas_spar_dec_close( &( st_ivas->hSpar ), st_ivas->hDecoderConfig->output_Fs, 0 ); /* HOA decoder matrix */ if ( st_ivas->hoa_dec_mtx != NULL ) @@ -1854,14 +1846,7 @@ void ivas_destroy_dec( ivas_lfe_dec_close( &( st_ivas->hLFE ) ); /* Param-Upmix MC handle */ -#ifdef FIX_163_SBA_TD_DECORR_OPT - if ( st_ivas->hSpar->td_decorr_flag ) - { -#endif - ivas_mc_paramupmix_dec_close( &( st_ivas->hMCParamUpmix ) ); -#ifdef FIX_163_SBA_TD_DECORR_OPT - } -#endif + ivas_mc_paramupmix_dec_close( &( st_ivas->hMCParamUpmix ) ); /* Parametric MC handle */ ivas_param_mc_dec_close( &st_ivas->hParamMC ); diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 5e5eaa4e22..9e5017c83d 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -175,12 +175,8 @@ ivas_error ivas_sba_dec_reconfigure( if ( nchan_transport_old != ivas_get_sba_num_TCs( ivas_total_brate, sba_order_internal ) || ( last_ivas_total_brate >= IVAS_512k && ivas_total_brate < IVAS_512k ) || ( last_ivas_total_brate < IVAS_512k && ivas_total_brate >= IVAS_512k ) ) { - ivas_spar_dec_close( &( st_ivas->hSpar ), hDecoderConfig->output_Fs, 1 -#ifdef FIX_163_SBA_TD_DECORR_OPT - , - st_ivas->hSpar->td_decorr_flag -#endif - ); + ivas_spar_dec_close( &( st_ivas->hSpar ), hDecoderConfig->output_Fs, 1 ); + if ( ( error = ivas_spar_dec_open( st_ivas, 1 ) ) != IVAS_ERR_OK ) { return error; diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 9906b45507..a036ad0d8e 100755 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -88,6 +88,9 @@ ivas_error ivas_spar_dec_open( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR decoder" ); } +#ifdef FIX_163_SBA_TD_DECORR_OPT + ivas_get_td_decorr_flag( hSpar, st_ivas ); +#endif } output_Fs = st_ivas->hDecoderConfig->output_Fs; @@ -102,16 +105,19 @@ ivas_error ivas_spar_dec_open( /* TD decorr. */ #ifdef FIX_163_SBA_TD_DECORR_OPT - if ( st_ivas->hSpar->td_decorr_flag ) + if ( hSpar->td_decorr_flag ) { #endif if ( ( error = ivas_td_decorr_dec_open( &hSpar->hTdDecorr, output_Fs, num_decor_chs + 1, 1 ) ) != IVAS_ERR_OK ) { - hSpar->hTdDecorr = NULL; return error; } #ifdef FIX_163_SBA_TD_DECORR_OPT } + else + { + hSpar->hTdDecorr = NULL; + } #endif /* MD handle */ @@ -255,10 +261,6 @@ void ivas_spar_dec_close( SPAR_DEC_HANDLE *hSpar, /* i/o: SPAR decoder handle */ const int32_t output_Fs, /* i : output sampling rate */ const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ -#ifdef FIX_163_SBA_TD_DECORR_OPT - , - const int16_t td_decorr_flag /* i : Disable malloc for td_decorr structure flag */ -#endif ) { if ( *hSpar == NULL || hSpar == NULL ) @@ -270,14 +272,8 @@ void ivas_spar_dec_close( ivas_spar_md_dec_close( &( *hSpar )->hMdDec ); /* TD decorrelator handle */ -#ifdef FIX_163_SBA_TD_DECORR_OPT - if ( td_decorr_flag && &( *hSpar )->hTdDecorr != NULL ) - { -#endif - ivas_td_decorr_dec_close( &( *hSpar )->hTdDecorr ); -#ifdef FIX_163_SBA_TD_DECORR_OPT - } -#endif + ivas_td_decorr_dec_close( &( *hSpar )->hTdDecorr ); + /* FB mixer handle */ ivas_FB_mixer_close( &( *hSpar )->hFbMixer, output_Fs, spar_reconfig_flag ); @@ -750,7 +746,7 @@ static void ivas_spar_dec_MD( { hSpar->hMdDec->table_idx = table_idx; #ifdef FIX_163_SBA_TD_DECORR_OPT - if ( st_ivas->hSpar->td_decorr_flag ) + if ( hSpar->td_decorr_flag ) { #endif hSpar->hTdDecorr->ducking_flag = ivas_spar_br_table_consts[table_idx].td_ducking; @@ -1255,7 +1251,7 @@ void ivas_spar_dec_digest_tc( { int16_t nSamplesToDecorr = min( nSamplesLeftForTD, default_frame ); #ifdef FIX_163_SBA_TD_DECORR_OPT - if ( st_ivas->hSpar->td_decorr_flag ) + if ( hSpar->td_decorr_flag ) { #endif ivas_td_decorr_process( hSpar->hTdDecorr, p_tc, pPcm_tmp, nSamplesToDecorr ); @@ -1343,7 +1339,7 @@ void ivas_spar_dec_upmixer( if ( hSpar->hMdDec->td_decorr_flag ) { #ifdef FIX_163_SBA_TD_DECORR_OPT - if ( st_ivas->hSpar->td_decorr_flag ) + if ( hSpar->td_decorr_flag ) { #endif ivas_td_decorr_process( hSpar->hTdDecorr, st_ivas->hTcBuffer->tc, pPcm_tmp, output_frame ); diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 79dfa4727a..50a759b0b2 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -923,7 +923,7 @@ typedef struct ivas_spar_dec_lib_t int16_t num_slots; #endif #ifdef FIX_163_SBA_TD_DECORR_OPT - int16_t td_decorr_flag; /* Disable malloc for td_decorr structure flag */ + int16_t td_decorr_flag; /* Disable malloc for td_decorr structure flag */ #endif } SPAR_DEC_DATA, *SPAR_DEC_HANDLE; diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 27514511b9..525935ffbf 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -457,23 +457,10 @@ void ivas_dirac_dec_binaural( output_frame = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); #ifdef JBM_TSM_ON_TCS -#ifdef FIX_163_SBA_TD_DECORR_OPT - if ( st_ivas->hSpar->td_decorr_flag ) - { -#endif - ivas_td_decorr_process( st_ivas->hDiracDecBin->hTdDecorr, p_output, decorr_signal, output_frame ); -#ifdef FIX_163_SBA_TD_DECORR_OPT - } -#endif + ivas_td_decorr_process( st_ivas->hDiracDecBin->hTdDecorr, p_output, decorr_signal, output_frame ); + #else -#ifdef FIX_163_SBA_TD_DECORR_OPT - if ( st_ivas->hSpar->td_decorr_flag ) - { -#endif - ivas_td_decorr_process( st_ivas->hDiracDecBin->hTdDecorr, output_f, decorr_signal, output_frame ); -#ifdef FIX_163_SBA_TD_DECORR_OPT - } -#endif + ivas_td_decorr_process( st_ivas->hDiracDecBin->hTdDecorr, output_f, decorr_signal, output_frame ); #endif } -- GitLab From 33776920370e9e60283de1fd391c77d558f44ec7 Mon Sep 17 00:00:00 2001 From: Rivukanta Bhattacharya <100792@ittiam.com> Date: Fri, 26 May 2023 20:01:06 +0530 Subject: [PATCH 07/10] Moved get decorr flag outside reconfig flag condition --- lib_com/ivas_td_decorr.c | 5 +++-- lib_dec/ivas_spar_decoder.c | 4 +--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib_com/ivas_td_decorr.c b/lib_com/ivas_td_decorr.c index c5731176f4..4886f6bf02 100644 --- a/lib_com/ivas_td_decorr.c +++ b/lib_com/ivas_td_decorr.c @@ -540,8 +540,8 @@ void ivas_td_decorr_process( *-----------------------------------------------------------------------------------------*/ void ivas_get_td_decorr_flag( - SPAR_DEC_HANDLE hSpar, /* i/o : IVAS SPAR handle structure */ - Decoder_Struct *st_ivas /* i/o : IVAS decoder structure */ + SPAR_DEC_HANDLE hSpar, /* i/o : IVAS SPAR handle structure */ + Decoder_Struct *st_ivas /* i/o : IVAS decoder structure */ ) { int32_t ivas_total_brate; @@ -549,6 +549,7 @@ void ivas_get_td_decorr_flag( ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; output_config = st_ivas->hDecoderConfig->output_config; + if ( ( st_ivas->ivas_format == SBA_FORMAT ) && ( ( output_config == AUDIO_CONFIG_MONO || output_config == AUDIO_CONFIG_STEREO ) || ( ivas_total_brate >= IVAS_256k && output_config == AUDIO_CONFIG_FOA ) ) ) { hSpar->td_decorr_flag = 0; diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index a036ad0d8e..c8185c0501 100755 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -88,9 +88,6 @@ ivas_error ivas_spar_dec_open( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR decoder" ); } -#ifdef FIX_163_SBA_TD_DECORR_OPT - ivas_get_td_decorr_flag( hSpar, st_ivas ); -#endif } output_Fs = st_ivas->hDecoderConfig->output_Fs; @@ -105,6 +102,7 @@ ivas_error ivas_spar_dec_open( /* TD decorr. */ #ifdef FIX_163_SBA_TD_DECORR_OPT + ivas_get_td_decorr_flag( hSpar, st_ivas ); if ( hSpar->td_decorr_flag ) { #endif -- GitLab From 37b015f56058e61bdd2554d8f82e14f054f1be0d Mon Sep 17 00:00:00 2001 From: Rivukanta Bhattacharya <100792@ittiam.com> Date: Sun, 28 May 2023 18:02:10 +0530 Subject: [PATCH 08/10] Fix for smoke test failure --- lib_dec/ivas_sba_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 9e5017c83d..5dfef59118 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -461,7 +461,7 @@ ivas_error ivas_sba_dec_digest_tc( { int16_t nSamplesToDecorr = min( nSamplesLeftForTD, default_frame ); #ifdef FIX_163_SBA_TD_DECORR_OPT - if ( st_ivas->hSpar->td_decorr_flag ) + if ( st_ivas->ivas_format != SBA_FORMAT || ( st_ivas->ivas_format == SBA_FORMAT && st_ivas->hSpar->td_decorr_flag ) ) { #endif ivas_td_decorr_process( st_ivas->hDiracDecBin->hTdDecorr, p_tc, decorr_signal, nSamplesToDecorr ); -- GitLab From f467bbdda0a828040001528cb76753aa4eb6715e Mon Sep 17 00:00:00 2001 From: Rivukanta Bhattacharya <100792@ittiam.com> Date: Mon, 29 May 2023 10:06:53 +0530 Subject: [PATCH 09/10] Review comment changes - Part 2 --- lib_com/ivas_td_decorr.c | 2 +- lib_com/options.h | 2 +- lib_rend/ivas_reverb.c | 7 ++----- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/lib_com/ivas_td_decorr.c b/lib_com/ivas_td_decorr.c index 4886f6bf02..7883c13083 100644 --- a/lib_com/ivas_td_decorr.c +++ b/lib_com/ivas_td_decorr.c @@ -536,7 +536,7 @@ void ivas_td_decorr_process( /*-----------------------------------------------------------------------------------------* * Function ivas_get_td_decorr_flag() * - * TD decorr bitrate and outfit_config check call + * TD decorr bitrate and output_config check call *-----------------------------------------------------------------------------------------*/ void ivas_get_td_decorr_flag( diff --git a/lib_com/options.h b/lib_com/options.h index 789ba31834..1aede066d7 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -201,7 +201,7 @@ #define FIX_487_LOWRATE_SBA_TUNING_FIX /* Dlb: TUning fix for low bitrate cases to match theoretical longest SPAR MD bitstream */ #define FIX_490_MASA_2TC_LBR_DTX /* Nokia: Fixes issue 490 by correcting condition. */ -#define FIX_163_SBA_TD_DECORR_OPT /* Dlb : Issue 163 : Malloc of td_deccor structure at 512 kbps and output configuration FOA*/ +#define FIX_163_SBA_TD_DECORR_OPT /* Dlb : Issue 163 : TD decorr state optimization in SBA for certain output formats */ #define FIX_HBR_MASAMETA /* Nokia: Fixes to HBR MASA metadata at 384 and 512 kbps. Addresses issues 438 and 477 as well. */ #define FIX_482_DUMMYDEC_INIT /* Nokia: fix issue #428: missing inits for dummyDec in IVAS_rend */ diff --git a/lib_rend/ivas_reverb.c b/lib_rend/ivas_reverb.c index b5b1a20053..baa83fad0e 100644 --- a/lib_rend/ivas_reverb.c +++ b/lib_rend/ivas_reverb.c @@ -1736,9 +1736,9 @@ void ivas_binaural_reverb_processSubframe( /* Add from temporally decaying sparse tap locations the audio to the output. */ for ( tapIdx = 0; tapIdx < hReverb->taps[bin][ch]; tapIdx++ ) { -#ifdef JBM_TSM_ON_TCS switch ( phaseShiftTypePr[tapIdx] ) { +#ifdef JBM_TSM_ON_TCS case 0: /* 0 degrees phase */ v_add( hReverb->outputBufferReal[bin][ch], tapRealPr[tapIdx], hReverb->outputBufferReal[bin][ch], numSlots ); v_add( hReverb->outputBufferImag[bin][ch], tapImagPr[tapIdx], hReverb->outputBufferImag[bin][ch], numSlots ); @@ -1755,10 +1755,7 @@ void ivas_binaural_reverb_processSubframe( v_add( hReverb->outputBufferReal[bin][ch], tapImagPr[tapIdx], hReverb->outputBufferReal[bin][ch], numSlots ); v_sub( hReverb->outputBufferImag[bin][ch], tapRealPr[tapIdx], hReverb->outputBufferImag[bin][ch], numSlots ); break; - } #else - switch ( phaseShiftTypePr[tapIdx] ) - { case 0: /* 0 degrees phase */ v_add( hReverb->outputBufferReal[bin][ch], tapRealPr[tapIdx], hReverb->outputBufferReal[bin][ch], hReverb->blockSize ); v_add( hReverb->outputBufferImag[bin][ch], tapImagPr[tapIdx], hReverb->outputBufferImag[bin][ch], hReverb->blockSize ); @@ -1775,8 +1772,8 @@ void ivas_binaural_reverb_processSubframe( v_add( hReverb->outputBufferReal[bin][ch], tapImagPr[tapIdx], hReverb->outputBufferReal[bin][ch], hReverb->blockSize ); v_sub( hReverb->outputBufferImag[bin][ch], tapRealPr[tapIdx], hReverb->outputBufferImag[bin][ch], hReverb->blockSize ); break; - } #endif + } } } -- GitLab From 0a678819869a24fac1e3de1b329ae9db9d24fda5 Mon Sep 17 00:00:00 2001 From: Rivukanta Bhattacharya <100792@ittiam.com> Date: Tue, 30 May 2023 11:09:25 +0530 Subject: [PATCH 10/10] Review comment changes - Part 3 --- lib_com/ivas_prot.h | 6 ------ lib_com/ivas_td_decorr.c | 31 +------------------------------ lib_dec/ivas_sba_dec.c | 2 +- lib_dec/ivas_spar_decoder.c | 19 ++++++++++--------- lib_dec/ivas_stat_dec.h | 3 --- 5 files changed, 12 insertions(+), 49 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 4eb6a15c13..556daf327b 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5734,12 +5734,6 @@ int16_t ivas_get_num_bands_from_bw_idx( const int16_t bwidth /* i : audio bandwidth */ ); -#ifdef FIX_163_SBA_TD_DECORR_OPT -void ivas_get_td_decorr_flag( - SPAR_DEC_HANDLE hSpar, /* i/o : IVAS SPAR handle structure */ - Decoder_Struct *st_ivas /* i/o : IVAS decoder structure */ -); -#endif /* clang-format on */ diff --git a/lib_com/ivas_td_decorr.c b/lib_com/ivas_td_decorr.c index 7883c13083..f2dd0871dc 100644 --- a/lib_com/ivas_td_decorr.c +++ b/lib_com/ivas_td_decorr.c @@ -211,6 +211,7 @@ ivas_error ivas_td_decorr_dec_open( num_out_chans = nchan_internal - 1; error = IVAS_ERR_OK; + if ( ( hTdDecorr_loc = (ivas_td_decorr_state_t *) malloc( sizeof( ivas_td_decorr_state_t ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR COV decoder" ); @@ -221,7 +222,6 @@ ivas_error ivas_td_decorr_dec_open( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR COV decoder" ); } set_f( hTdDecorr_loc->look_ahead_buf, 0, (int16_t) ( output_Fs * IVAS_DECORR_PARM_LOOKAHEAD_TAU ) ); - #ifdef JBM_TSM_ON_TCS hTdDecorr_loc->offset = (int16_t) ( output_Fs * IVAS_DECORR_PARM_LOOKAHEAD_TAU ); #endif @@ -531,32 +531,3 @@ void ivas_td_decorr_process( return; } - -#ifdef FIX_163_SBA_TD_DECORR_OPT -/*-----------------------------------------------------------------------------------------* - * Function ivas_get_td_decorr_flag() - * - * TD decorr bitrate and output_config check call - *-----------------------------------------------------------------------------------------*/ - -void ivas_get_td_decorr_flag( - SPAR_DEC_HANDLE hSpar, /* i/o : IVAS SPAR handle structure */ - Decoder_Struct *st_ivas /* i/o : IVAS decoder structure */ -) -{ - int32_t ivas_total_brate; - AUDIO_CONFIG output_config; - - ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; - output_config = st_ivas->hDecoderConfig->output_config; - - if ( ( st_ivas->ivas_format == SBA_FORMAT ) && ( ( output_config == AUDIO_CONFIG_MONO || output_config == AUDIO_CONFIG_STEREO ) || ( ivas_total_brate >= IVAS_256k && output_config == AUDIO_CONFIG_FOA ) ) ) - { - hSpar->td_decorr_flag = 0; - } - else - { - hSpar->td_decorr_flag = 1; - } -} -#endif diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 5dfef59118..dd7174eae0 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -461,7 +461,7 @@ ivas_error ivas_sba_dec_digest_tc( { int16_t nSamplesToDecorr = min( nSamplesLeftForTD, default_frame ); #ifdef FIX_163_SBA_TD_DECORR_OPT - if ( st_ivas->ivas_format != SBA_FORMAT || ( st_ivas->ivas_format == SBA_FORMAT && st_ivas->hSpar->td_decorr_flag ) ) + if ( st_ivas->hDiracDecBin->hTdDecorr ) { #endif ivas_td_decorr_process( st_ivas->hDiracDecBin->hTdDecorr, p_tc, decorr_signal, nSamplesToDecorr ); diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index c8185c0501..a2cdfe1562 100755 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -102,8 +102,11 @@ ivas_error ivas_spar_dec_open( /* TD decorr. */ #ifdef FIX_163_SBA_TD_DECORR_OPT - ivas_get_td_decorr_flag( hSpar, st_ivas ); - if ( hSpar->td_decorr_flag ) + if ( ( st_ivas->ivas_format == SBA_FORMAT ) && ( ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_MONO || st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_STEREO ) || ( st_ivas->hDecoderConfig->ivas_total_brate >= IVAS_256k && st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_FOA ) ) ) + { + hSpar->hTdDecorr = NULL; + } + else { #endif if ( ( error = ivas_td_decorr_dec_open( &hSpar->hTdDecorr, output_Fs, num_decor_chs + 1, 1 ) ) != IVAS_ERR_OK ) @@ -112,10 +115,6 @@ ivas_error ivas_spar_dec_open( } #ifdef FIX_163_SBA_TD_DECORR_OPT } - else - { - hSpar->hTdDecorr = NULL; - } #endif /* MD handle */ @@ -744,12 +743,13 @@ static void ivas_spar_dec_MD( { hSpar->hMdDec->table_idx = table_idx; #ifdef FIX_163_SBA_TD_DECORR_OPT - if ( hSpar->td_decorr_flag ) + if ( hSpar->hTdDecorr ) { #endif hSpar->hTdDecorr->ducking_flag = ivas_spar_br_table_consts[table_idx].td_ducking; #ifdef FIX_163_SBA_TD_DECORR_OPT } + #endif ivas_spar_md_dec_init( hSpar->hMdDec, hDecoderConfig, num_channels, sba_order ); } @@ -1248,8 +1248,9 @@ void ivas_spar_dec_digest_tc( while ( nSamplesLeftForTD ) { int16_t nSamplesToDecorr = min( nSamplesLeftForTD, default_frame ); + #ifdef FIX_163_SBA_TD_DECORR_OPT - if ( hSpar->td_decorr_flag ) + if ( hSpar->hTdDecorr ) { #endif ivas_td_decorr_process( hSpar->hTdDecorr, p_tc, pPcm_tmp, nSamplesToDecorr ); @@ -1337,7 +1338,7 @@ void ivas_spar_dec_upmixer( if ( hSpar->hMdDec->td_decorr_flag ) { #ifdef FIX_163_SBA_TD_DECORR_OPT - if ( hSpar->td_decorr_flag ) + if ( hSpar->hTdDecorr ) { #endif ivas_td_decorr_process( hSpar->hTdDecorr, st_ivas->hTcBuffer->tc, pPcm_tmp, output_frame ); diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 50a759b0b2..834ce32ab5 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -922,9 +922,6 @@ typedef struct ivas_spar_dec_lib_t int16_t slots_rendered; int16_t num_slots; #endif -#ifdef FIX_163_SBA_TD_DECORR_OPT - int16_t td_decorr_flag; /* Disable malloc for td_decorr structure flag */ -#endif } SPAR_DEC_DATA, *SPAR_DEC_HANDLE; -- GitLab