diff --git a/lib_com/options.h b/lib_com/options.h index 8f3a465425a802a00c825390e7ff684b2defa4e1..8ec901855ac5330889b47d21142d36c3cc5cec41 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -85,6 +85,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 FIX_1129_EXT_REND_OUTPUT_HIGH /* Philips: issue 1129: External renderer BINAURAL_ROOM_REVERB format output level too high compared to internal rendering output */ +#define NONBE_1302_FIX_OMASA_JBM_FLUSH /* VA: issue 1302: fix OMASA JBM bitrate switching flush in binaural output */ #define NONBE_1328_FIX_NON_LINEARITY /* VA: Fix possible issue when computing bwe_exc_extended and previous frame were almost 0, float issue 1328 */ #define FIX_1319_STACK_SBA_DECODER /* VA: issue 1319: Optimize the definition of buffer lengths in the SBA decoder */ #define FIX_1320_STACK_CPE_DECODER /* VA: issue 1320: Optimize the stack memory consumption in the CPE decoder */ diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index b8b234d8adba73f60b615fcd0a4a0543d02ef39c..fe36c1ea2fdbfebcbc76fd2e695be57f4d65a0dc 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2661,6 +2661,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( DECODER_TC_BUFFER_HANDLE hTcBuffer; Word32 *p_output_fx[MAX_CICP_CHANNELS + MAX_NUM_OBJECTS]; Word16 nchan_in, nchan_out; + IF( !st_ivas->hDecoderConfig->Opt_tsm ) { return IVAS_ERR_OK; @@ -2829,7 +2830,15 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( IF( EQ_16( ism_mode_old, ISM_MASA_MODE_DISC ) ) { Word32 *tc_local_fx[MAX_NUM_OBJECTS]; +#ifdef NONBE_1302_FIX_OMASA_JBM_FLUSH + Word16 last_dirac_md_idx; + UWord16 nSamplesAvailableNext; + ISM_MODE ism_mode_orig; + RENDERER_TYPE renderer_type_orig; + Word32 ivas_total_brate; +#endif + /* copy from ISM delay buffer to the correct place in TCs */ move16(); FOR( ch_idx = 0; ch_idx < st_ivas->nchan_ism; ch_idx++ ) { @@ -2837,10 +2846,39 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( Copy32( st_ivas->hMasaIsmData->delayBuffer_fx[ch_idx], tc_local_fx[ch_idx], st_ivas->hMasaIsmData->delayBuffer_size ); /*Q11*/ } +#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; + set16_fx( st_ivas->hSpatParamRendCom->render_to_md_map, last_dirac_md_idx, n_slots_still_available ); + + IF( ( error = ivas_omasa_dirac_td_binaural_jbm_fx( st_ivas, (UWord16) hTcBuffer->n_samples_granularity, nSamplesRendered, &nSamplesAvailableNext, CPE_CHANNELS, p_output_fx ) ) != 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( NE_32( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_output_fx, hTcBuffer->n_samples_granularity ) ), IVAS_ERR_OK ) ) { return error; } +#endif } } ELSE IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) @@ -2850,11 +2888,14 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( Word16 last_dirac_md_idx; UWord16 nSamplesAvailableNext; + /* to render flushed samples, use configuration from the last received frame */ + 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]; move16(); move16(); - /* 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_fx[ch_idx] = &st_ivas->hTcBuffer->tc_fx[ch_idx + 2][hTcBuffer->n_samples_rendered]; @@ -2892,6 +2933,8 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( { return error; } + + /* restore original configuration */ } ELSE {