From 1b258ec24ed5bfc7fe0fcabd0fc58568f11db1f2 Mon Sep 17 00:00:00 2001 From: rtyag Date: Wed, 19 Mar 2025 16:27:54 +1100 Subject: [PATCH 1/2] fix for issue 1297 --- lib_com/options.h | 1 + lib_dec/ivas_jbm_dec.c | 93 ++++++++++++++++++++++++++++-------------- lib_dec/lib_dec.c | 7 ++++ 3 files changed, 70 insertions(+), 31 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index f2fe9b93f2..568bd88536 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -171,6 +171,7 @@ #define NONBE_1244_FIX_SWB_BWE_MEMORY /* VA: issue 1244: fix to SWB BWE memory in case of switching from FB coding - pending a review by Huawei */ #define NONBE_FIX_1180_HQMDCT_PHECU_LT_MUTING /* Ericsson: issue 1180, corrected long term mute loop attnuation after 200ms in PhECU-PLC */ +#define NONBE_FIX_1297_SPAR_JBM_MEM_SAN /*Dolby: issue 1297, SPAR + JBM + BR switch memory sanitizer*/ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 2376de298a..648f6a1060 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -1533,44 +1533,75 @@ ivas_error ivas_jbm_dec_flush_renderer( } else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { - float *tc_local[MAX_TRANSPORT_CHANNELS]; - int16_t last_spar_md_idx; - int16_t last_dirac_md_idx; - uint16_t nSamplesAvailableNext; +#ifdef NONBE_FIX_1297_SPAR_JBM_MEM_SAN + if ( ism_mode_old == ISM_SBA_MODE_DISC ) + { +#endif + float *tc_local[MAX_TRANSPORT_CHANNELS]; + int16_t last_spar_md_idx; + int16_t last_dirac_md_idx; + uint16_t nSamplesAvailableNext; +#ifdef NONBE_FIX_1297_SPAR_JBM_MEM_SAN + ISM_MODE ism_mode_orig; + RENDERER_TYPE renderer_type_orig; + int32_t ivas_total_brate; + ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; + renderer_type_orig = st_ivas->renderer_type; + ism_mode_orig = st_ivas->ism_mode; + st_ivas->ism_mode = ism_mode_old; + st_ivas->renderer_type = renderer_type_old; + st_ivas->hDecoderConfig->ivas_total_brate = st_ivas->hDecoderConfig->last_ivas_total_brate; +#endif - last_spar_md_idx = st_ivas->hSpar->render_to_md_map[st_ivas->hSpar->slots_rendered - 1]; - last_dirac_md_idx = st_ivas->hSpatParamRendCom->render_to_md_map[st_ivas->hSpatParamRendCom->slots_rendered - 1]; + last_spar_md_idx = st_ivas->hSpar->render_to_md_map[st_ivas->hSpar->slots_rendered - 1]; + last_dirac_md_idx = st_ivas->hSpatParamRendCom->render_to_md_map[st_ivas->hSpatParamRendCom->slots_rendered - 1]; +#ifdef NONBE_FIX_1297_SPAR_JBM_MEM_SAN +#ifdef DEBUGGING + assert( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ); +#endif +#else #ifdef DEBUGGING assert( ism_mode_old == ISM_SBA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ); #endif - /* copy from ISM delay buffer to the correct place in tcs */ - for ( ch_idx = 0; ch_idx < st_ivas->nchan_ism; ch_idx++ ) - { +#endif + /* copy from ISM delay buffer to the correct place in tcs */ + for ( ch_idx = 0; ch_idx < st_ivas->nchan_ism; ch_idx++ ) + { +#ifdef NONBE_FIX_1297_SPAR_JBM_MEM_SAN + tc_local[ch_idx] = &st_ivas->hTcBuffer->tc[ch_idx][hTcBuffer->n_samples_rendered]; +#else tc_local[ch_idx] = &st_ivas->hTcBuffer->tc[ch_idx + 2][hTcBuffer->n_samples_rendered]; - mvr2r( st_ivas->hSbaIsmData->delayBuffer[ch_idx], tc_local[ch_idx], st_ivas->hSbaIsmData->delayBuffer_size ); - } - - /* transfer adapted sf info from hTcBuffer to SPAR and DirAC */ - st_ivas->hSpar->nb_subframes = 1; - st_ivas->hSpar->subframes_rendered = 0; - st_ivas->hSpar->subframe_nbslots[0] = JBM_CLDFB_SLOTS_IN_SUBFRAME; - st_ivas->hSpar->slots_rendered = 0; - st_ivas->hSpar->num_slots = JBM_CLDFB_SLOTS_IN_SUBFRAME; - st_ivas->hSpatParamRendCom->nb_subframes = 1; - st_ivas->hSpatParamRendCom->subframes_rendered = 0; - st_ivas->hSpatParamRendCom->subframe_nbslots[0] = JBM_CLDFB_SLOTS_IN_SUBFRAME; - st_ivas->hSpatParamRendCom->slots_rendered = 0; - st_ivas->hSpatParamRendCom->num_slots = JBM_CLDFB_SLOTS_IN_SUBFRAME; - - /* also adapt md maps, just use the last index */ - set_s( st_ivas->hSpar->render_to_md_map, last_spar_md_idx, n_slots_still_available ); - set_s( st_ivas->hSpatParamRendCom->render_to_md_map, last_dirac_md_idx, n_slots_still_available ); +#endif + mvr2r( st_ivas->hSbaIsmData->delayBuffer[ch_idx], tc_local[ch_idx], st_ivas->hSbaIsmData->delayBuffer_size ); + } - /* render the last subframe */ - if ( ( error = ivas_osba_dirac_td_binaural_jbm( st_ivas, (uint16_t) hTcBuffer->n_samples_granularity, nSamplesRendered, &nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK ) - { - return error; + /* transfer adapted sf info from hTcBuffer to SPAR and DirAC */ + st_ivas->hSpar->nb_subframes = 1; + st_ivas->hSpar->subframes_rendered = 0; + st_ivas->hSpar->subframe_nbslots[0] = JBM_CLDFB_SLOTS_IN_SUBFRAME; + st_ivas->hSpar->slots_rendered = 0; + st_ivas->hSpar->num_slots = JBM_CLDFB_SLOTS_IN_SUBFRAME; + st_ivas->hSpatParamRendCom->nb_subframes = 1; + st_ivas->hSpatParamRendCom->subframes_rendered = 0; + st_ivas->hSpatParamRendCom->subframe_nbslots[0] = JBM_CLDFB_SLOTS_IN_SUBFRAME; + st_ivas->hSpatParamRendCom->slots_rendered = 0; + st_ivas->hSpatParamRendCom->num_slots = JBM_CLDFB_SLOTS_IN_SUBFRAME; + + /* also adapt md maps, just use the last index */ + set_s( st_ivas->hSpar->render_to_md_map, last_spar_md_idx, n_slots_still_available ); + set_s( st_ivas->hSpatParamRendCom->render_to_md_map, last_dirac_md_idx, n_slots_still_available ); + + /* render the last subframe */ + if ( ( error = ivas_osba_dirac_td_binaural_jbm( st_ivas, (uint16_t) hTcBuffer->n_samples_granularity, nSamplesRendered, &nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK ) + { + return error; + } +#ifdef NONBE_FIX_1297_SPAR_JBM_MEM_SAN + st_ivas->ism_mode = ism_mode_orig; + st_ivas->renderer_type = renderer_type_orig; + st_ivas->hDecoderConfig->ivas_total_brate = ivas_total_brate; } +#endif } else { diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 7640228d3b..b4dc284a00 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1034,8 +1034,15 @@ ivas_error IVAS_DEC_ReadFormat( } } +#ifdef NONBE_FIX_1297_SPAR_JBM_MEM_SAN + if ( ( renderer_type_old != st_ivas->renderer_type && renderer_type_old != RENDERER_DISABLE ) || + ( st_ivas->ini_active_frame > 0 && + ( ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode != ISM_MASA_MODE_DISC ) || + ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ism_mode != ISM_SBA_MODE_DISC ) ) ) +#else if ( ( renderer_type_old != st_ivas->renderer_type && renderer_type_old != RENDERER_DISABLE ) || ( st_ivas->ini_active_frame > 0 && ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode != ISM_MASA_MODE_DISC ) ) +#endif { /* JBM: when granularity goes down (e.g. Discrete ISM with TD Obj Renderer -> ParamISM with binaural fastconv render what still fits in the new granularity */ -- GitLab From e2bf1c222fbd890d812ce97c081cfacdee076c22 Mon Sep 17 00:00:00 2001 From: rtyag Date: Wed, 19 Mar 2025 17:14:11 +1100 Subject: [PATCH 2/2] linux wARNING fix --- lib_dec/lib_dec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index b4dc284a00..7b4eb08f99 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1037,8 +1037,8 @@ ivas_error IVAS_DEC_ReadFormat( #ifdef NONBE_FIX_1297_SPAR_JBM_MEM_SAN if ( ( renderer_type_old != st_ivas->renderer_type && renderer_type_old != RENDERER_DISABLE ) || ( st_ivas->ini_active_frame > 0 && - ( ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode != ISM_MASA_MODE_DISC ) || - ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ism_mode != ISM_SBA_MODE_DISC ) ) ) + ( ( ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode != ISM_MASA_MODE_DISC ) || + ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ism_mode != ISM_SBA_MODE_DISC ) ) ) ) #else if ( ( renderer_type_old != st_ivas->renderer_type && renderer_type_old != RENDERER_DISABLE ) || ( st_ivas->ini_active_frame > 0 && ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode != ISM_MASA_MODE_DISC ) ) -- GitLab