From 6aefd706e6052205965b6013fa6cc49d278ad2b1 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 12 Jun 2025 11:42:04 +0200 Subject: [PATCH] issue 1302: fix OMASA JBM bitrate switching flush in binaural output; under NONBE_1302_FIX_OMASA_JBM_FLUSH --- lib_com/options.h | 2 +- lib_dec/ivas_jbm_dec.c | 42 ++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 80cd7a383b..716c0ae151 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -171,7 +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_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ - +#define NONBE_1302_FIX_OMASA_JBM_FLUSH /* VA: issue 1302: fix OMASA JBM bitrate switching flush in binaural output */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 1c9870433a..2712c757bd 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -1504,17 +1504,54 @@ ivas_error ivas_jbm_dec_flush_renderer( if ( ism_mode_old == ISM_MASA_MODE_DISC ) { float *tc_local[MAX_NUM_OBJECTS]; +#ifdef NONBE_1302_FIX_OMASA_JBM_FLUSH + int16_t last_dirac_md_idx; + uint16_t nSamplesAvailableNext; + ISM_MODE ism_mode_orig; + RENDERER_TYPE renderer_type_orig; + int32_t ivas_total_brate; +#endif + /* copy from ISM delay buffer to the correct place in TCs */ for ( ch_idx = 0; ch_idx < st_ivas->nchan_ism; ch_idx++ ) { tc_local[ch_idx] = &st_ivas->hTcBuffer->tc[ch_idx + 2][hTcBuffer->n_samples_rendered]; mvr2r( st_ivas->hMasaIsmData->delayBuffer[ch_idx], tc_local[ch_idx], st_ivas->hMasaIsmData->delayBuffer_size ); } +#ifdef NONBE_1302_FIX_OMASA_JBM_FLUSH + /* to render flushed samples, use configuration from the last received frame */ + 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; + last_dirac_md_idx = st_ivas->hSpatParamRendCom->render_to_md_map[st_ivas->hSpatParamRendCom->slots_rendered - 1]; + + /* transfer adapted sf info from hTcBuffer to DirAC */ + 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; + set_s( st_ivas->hSpatParamRendCom->render_to_md_map, last_dirac_md_idx, n_slots_still_available ); + + if ( ( error = ivas_omasa_dirac_td_binaural_jbm( st_ivas, (uint16_t) hTcBuffer->n_samples_granularity, nSamplesRendered, &nSamplesAvailableNext, CPE_CHANNELS, p_output ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* restore original configuration */ + st_ivas->ism_mode = ism_mode_orig; + st_ivas->renderer_type = renderer_type_orig; + st_ivas->hDecoderConfig->ivas_total_brate = ivas_total_brate; +#else if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_output, hTcBuffer->n_samples_granularity ) ) != IVAS_ERR_OK ) { return error; } +#endif } } else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) @@ -1529,20 +1566,20 @@ ivas_error ivas_jbm_dec_flush_renderer( RENDERER_TYPE renderer_type_orig; int32_t ivas_total_brate; + /* to render flushed samples, use configuration from the last received frame */ 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; - 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 DEBUGGING assert( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ); #endif - /* copy from ISM delay buffer to the correct place in tcs */ + /* copy from ISM delay buffer to the correct place in TCs */ for ( ch_idx = 0; ch_idx < st_ivas->nchan_ism; ch_idx++ ) { tc_local[ch_idx] = &st_ivas->hTcBuffer->tc[ch_idx][hTcBuffer->n_samples_rendered]; @@ -1571,6 +1608,7 @@ ivas_error ivas_jbm_dec_flush_renderer( return error; } + /* restore original configuration */ st_ivas->ism_mode = ism_mode_orig; st_ivas->renderer_type = renderer_type_orig; st_ivas->hDecoderConfig->ivas_total_brate = ivas_total_brate; -- GitLab