From 919c38035b2d02ce5c2a80d20aa9be3e4a5346ca Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Fri, 22 Sep 2023 08:45:19 +0200 Subject: [PATCH] fix JBM MC rate switching (#808) --- lib_com/options.h | 2 +- lib_dec/ivas_mc_paramupmix_dec.c | 17 ++++++++++++++++- lib_dec/ivas_mct_dec.c | 13 +++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index db4ab9dcdd..0631502a8a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -210,7 +210,7 @@ #define NONBE_FIX_778_TNS_UNFIED_STEREO_MSAN /* FhG: Issue 778: MSAN error due to uninitialized TNS configuration */ #define NONBE_FIX_797_OMASA_INACTIVE_SEP_OBJ /* VA: issue 797: fix of crash when the separated object is inactive and the MASA metadata is using very few bits */ #define NONBE_FIX_798_OSBA_MC_DEC_CRASH - +#define NONBE_FIX_808_JBM_PARAMUPMIX_RS /* FhG: Issue 808: fix JBM MC rate switching */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index 07c3695600..c44cfd6e29 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -709,6 +709,18 @@ ivas_error ivas_mc_paramupmix_dec_open( /* allocate transport channels*/ hMCParamUpmix->free_param_interpolator = 0; hMCParamUpmix->param_interpolator = NULL; +#ifdef NONBE_FIX_808_JBM_PARAMUPMIX_RS + if ( st_ivas->hDecoderConfig->Opt_5ms == 1 ) + { + if ( ( hMCParamUpmix->param_interpolator = (float *) malloc( MAX_JBM_CLDFB_TIMESLOTS * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for interpolator\n" ) ); + } + hMCParamUpmix->free_param_interpolator = 1; + + ivas_jbm_dec_get_adapted_linear_interpolator( DEFAULT_JBM_CLDFB_TIMESLOTS, DEFAULT_JBM_CLDFB_TIMESLOTS, hMCParamUpmix->param_interpolator ); + } +#endif if ( st_ivas->hDecoderConfig->Opt_5ms == 1 && st_ivas->hTcBuffer == NULL ) { int16_t nchan_to_allocate; @@ -718,11 +730,12 @@ ivas_error ivas_mc_paramupmix_dec_open( buffer_mode = TC_BUFFER_MODE_RENDERER; nchan_tc = ivas_jbm_dec_get_num_tc_channels( st_ivas ); nchan_to_allocate = MC_PARAMUPMIX_MAX_INPUT_CHANS; +#ifndef NONBE_FIX_808_JBM_PARAMUPMIX_RS if ( ( hMCParamUpmix->param_interpolator = (float *) malloc( MAX_JBM_CLDFB_TIMESLOTS * sizeof( float ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for interpolator\n" ) ); } - +#endif if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO ) { buffer_mode = TC_BUFFER_MODE_BUFFER; @@ -737,9 +750,11 @@ ivas_error ivas_mc_paramupmix_dec_open( { return error; } +#ifndef NONBE_FIX_808_JBM_PARAMUPMIX_RS hMCParamUpmix->free_param_interpolator = 1; ivas_jbm_dec_get_adapted_linear_interpolator( DEFAULT_JBM_CLDFB_TIMESLOTS, DEFAULT_JBM_CLDFB_TIMESLOTS, hMCParamUpmix->param_interpolator ); +#endif } st_ivas->hMCParamUpmix = hMCParamUpmix; diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 7012165c85..1eaf75b4e5 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -1358,6 +1358,19 @@ static ivas_error ivas_mc_dec_reconfig( { tc_nchan_full_new = 0; } +#ifdef NONBE_FIX_808_JBM_PARAMUPMIX_RS + else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) + { + tc_nchan_allocate_new = MC_PARAMUPMIX_MAX_INPUT_CHANS; + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO ) + { + tc_buffer_mode_new = TC_BUFFER_MODE_BUFFER; + tc_nchan_tc_new = st_ivas->hDecoderConfig->nchan_out; + tc_nchan_allocate_new = tc_nchan_tc_new; + } + tc_nchan_full_new = tc_nchan_allocate_new; + } +#endif /* reconfigure buffer */ if ( hTcBuffer->tc_buffer_mode != tc_buffer_mode_new || hTcBuffer->nchan_transport_jbm != tc_nchan_tc_new || -- GitLab