From 9a020307604d32ea1eb995e8e174c944e2f7d74c Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Tue, 19 Sep 2023 09:52:02 +0200 Subject: [PATCH 01/49] decouple subframe indexing of head rotation/combined orientation from general rendering subframe indexing --- apps/decoder.c | 7 ++ lib_com/ivas_prot.h | 2 + lib_com/options.h | 4 +- lib_dec/ivas_binRenderer_internal.c | 53 +++++++++-- lib_dec/ivas_dec.c | 4 +- lib_dec/ivas_dirac_dec.c | 49 +++++++++-- lib_dec/ivas_init_dec.c | 3 + lib_dec/ivas_ism_renderer.c | 28 +++++- lib_dec/ivas_jbm_dec.c | 2 + lib_dec/ivas_mc_param_dec.c | 6 ++ lib_dec/ivas_mc_paramupmix_dec.c | 14 ++- lib_dec/ivas_objectRenderer_internal.c | 18 +++- lib_dec/ivas_omasa_dec.c | 42 +++++++++ lib_dec/ivas_sba_dec.c | 4 + lib_dec/ivas_spar_decoder.c | 3 + lib_dec/lib_dec.c | 39 ++++++++- lib_rend/ivas_crend.c | 8 ++ lib_rend/ivas_dirac_dec_binaural_functions.c | 26 +++++- lib_rend/ivas_objectRenderer.c | 50 +++++++++-- lib_rend/ivas_prot_rend.h | 23 +++-- lib_rend/ivas_rotation.c | 92 +++++++++++++++++++- lib_rend/ivas_stat_rend.h | 8 ++ lib_rend/lib_rend.c | 6 ++ 23 files changed, 447 insertions(+), 44 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index c9741068f5..468392a6ad 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -2214,6 +2214,13 @@ static ivas_error decodeG192( } } +#ifdef NONBE_UNIFIED_DECODING_PATHS + if ( arg.enableExternalOrientation ) + { + } +#endif + + /* decode and get samples */ nSamplesRendered = 0; nSamplesToRender = nOutSamples; diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 6893be758d..5fae8bf619 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5238,7 +5238,9 @@ void ivas_binRenderer( HEAD_TRACK_DATA_HANDLE hPostRendHeadTrackData, #endif COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle */ +#ifndef NONBE_UNIFIED_DECODING_PATHS int16_t subframe_idx, /* i : subframe index */ +#endif const int16_t numTimeSlots, /* i : number of time slots to process */ #ifdef SPLIT_REND_WITH_HEAD_ROT float Cldfb_RealBuffer_Binaural[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ diff --git a/lib_com/options.h b/lib_com/options.h index d945683e41..3824bbdc29 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -150,7 +150,7 @@ /*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ -/*#define SPLIT_REND_WITH_HEAD_ROT*/ /* Dlb,FhG: Split Rendering contributions 21 and 35 */ +/*#define SPLIT_REND_WITH_HEAD_ROT */ /* Dlb,FhG: Split Rendering contributions 21 and 35 */ #ifdef SPLIT_REND_WITH_HEAD_ROT #define SPLIT_REND_PRED_QUANT_63_PNTS #define SPLIT_REND_WITH_HEAD_ROT_PARAMBIN /* Nokia: Issue 623: Split rendering support for parambin renderer */ @@ -167,7 +167,7 @@ #define NONBE_FIX_736_FOA_BR_SWITCH /* FhG/Dlb : Issue 736: FOA bitrate switching decoding crashes in in ivas_spar_to_dirac */ #define NONBE_FIX_746_NONDIEGETIC_MD /* Eri: Issue 746: The non-diegetic panning flag affects the encoder bitstream even if extended metadata is not enabled. Crashes the decoder.*/ - +#define NONBE_UNIFIED_DECODING_PATHS /* FhG: unify decoding paths */ /* ##################### End NON-BE switches ############################# */ /* ################## End DEVELOPMENT switches ######################### */ diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index 8cd36f7c9e..b890884703 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -1655,7 +1655,9 @@ void ivas_binaural_cldfb( &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, #endif st_ivas->hCombinedOrientationData, +#ifndef NONBE_UNIFIED_DECODING_PATHS subframeIdx, +#endif JBM_CLDFB_SLOTS_IN_SUBFRAME, #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG NULL, @@ -1702,7 +1704,10 @@ void ivas_binaural_cldfb( } } #endif - +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* update combined orientation access index */ + ivas_combined_rotation_update_index( st_ivas->hCombinedOrientationData, maxBand * MAX_PARAM_SPATIAL_SUBFRAMES ); +#endif /* Implement CLDFB synthesis */ for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { @@ -1832,7 +1837,9 @@ void ivas_binaural_cldfb_sf( &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, #endif st_ivas->hCombinedOrientationData, +#ifndef NONBE_UNIFIED_DECODING_PATHS subframeIdx, +#endif st_ivas->hTcBuffer->subframe_nbslots[subframeIdx], Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, @@ -1856,7 +1863,10 @@ void ivas_binaural_cldfb_sf( } } #endif - +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* update combined orientation access index */ + ivas_combined_rotation_update_index( st_ivas->hCombinedOrientationData, maxBand * st_ivas->hTcBuffer->subframe_nbslots[subframeIdx] ); +#endif /* Implement CLDFB synthesis */ for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { @@ -1899,8 +1909,10 @@ void ivas_binRenderer( const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, #endif COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle*/ - int16_t subframe_idx, /* i : subframe index */ - const int16_t numTimeSlots, /* i : number of time slots to render */ +#ifndef NONBE_UNIFIED_DECODING_PATHS + int16_t subframe_idx, /* i : subframe index */ +#endif + const int16_t numTimeSlots, /* i : number of time slots to render */ #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG HEAD_TRACK_DATA_HANDLE hPostRendHeadTrackData, #endif @@ -1951,24 +1963,49 @@ void ivas_binRenderer( #endif /* Head rotation in HOA3 or CICPx */ - if ( hCombinedOrientationData != NULL && hCombinedOrientationData->enableCombinedOrientation[subframe_idx] && hBinRenderer->rotInCldfb ) + if ( hCombinedOrientationData != NULL && +#ifdef NONBE_UNIFIED_DECODING_PATHS + hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] +#else + hCombinedOrientationData->enableCombinedOrientation[subframe_idx] +#endif + + && hBinRenderer->rotInCldfb ) { if ( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 ) { /* Rotation in SHD (HOA3) */ if ( hCombinedOrientationData->shd_rot_max_order == -1 ) { - rotateFrame_shd_cldfb( RealBuffer, ImagBuffer, hCombinedOrientationData->Rmat[subframe_idx], hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, 3 ); + rotateFrame_shd_cldfb( RealBuffer, ImagBuffer, +#ifdef NONBE_UNIFIED_DECODING_PATHS + hCombinedOrientationData->Rmat[hCombinedOrientationData->subframe_idx], +#else + hCombinedOrientationData->Rmat[subframe_idx], +#endif + hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, 3 ); } else if ( hCombinedOrientationData->shd_rot_max_order > 0 ) { - rotateFrame_shd_cldfb( RealBuffer, ImagBuffer, hCombinedOrientationData->Rmat[subframe_idx], hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, hCombinedOrientationData->shd_rot_max_order ); + rotateFrame_shd_cldfb( RealBuffer, ImagBuffer, +#ifdef NONBE_UNIFIED_DECODING_PATHS + hCombinedOrientationData->Rmat[hCombinedOrientationData->subframe_idx], +#else + hCombinedOrientationData->Rmat[subframe_idx], +#endif + hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, hCombinedOrientationData->shd_rot_max_order ); } } else { /* Rotation in SD (CICPx) */ - rotateFrame_sd_cldfb( hCombinedOrientationData->Rmat[subframe_idx], RealBuffer, ImagBuffer, hBinRenderer->hInputSetup, hBinRenderer->hEFAPdata, numTimeSlots, hBinRenderer->conv_band ); + rotateFrame_sd_cldfb( +#ifdef NONBE_UNIFIED_DECODING_PATHS + hCombinedOrientationData->Rmat[hCombinedOrientationData->subframe_idx], +#else + hCombinedOrientationData->Rmat[subframe_idx], +#endif + RealBuffer, ImagBuffer, hBinRenderer->hInputSetup, hBinRenderer->hEFAPdata, numTimeSlots, hBinRenderer->conv_band ); } } diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 8d41109c07..65a4fbacab 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -99,16 +99,16 @@ ivas_error ivas_dec( p_output[n] = output[n]; } - /*----------------------------------------------------------------* * Combine orientations *----------------------------------------------------------------*/ +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( ( error = combine_external_and_head_orientations_dec( st_ivas->hHeadTrackData, st_ivas->hExtOrientationData, st_ivas->hCombinedOrientationData ) ) != IVAS_ERR_OK ) { return error; } - +#endif #if defined SPLIT_REND_WITH_HEAD_ROT if ( ( output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || ( output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index fd94409a02..316f7445d3 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -1650,6 +1650,9 @@ void ivas_dirac_dec( { output_f_local[n] += n_samples_sf; } +#ifdef NONBE_UNIFIED_DECODING_PATHS + ivas_combined_rotation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf ); +#endif } if ( st_ivas->hDirAC->hConfig->dec_param_estim == 1 ) @@ -1730,6 +1733,10 @@ void ivas_dirac_dec_render( { output_f_local[ch] += n_samples_sf; } +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* update combined orientation access index */ + ivas_combined_rotation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf ); +#endif } if ( hSpatParamRendCom->slots_rendered == hSpatParamRendCom->num_slots ) @@ -1877,9 +1884,19 @@ void ivas_dirac_dec_render_sf( set_zero( onset_filter_subframe, hSpatParamRendCom->num_freq_bands ); } - if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[subframe_idx] ) + if ( st_ivas->hCombinedOrientationData && +#ifdef NONBE_UNIFIED_DECODING_PATHS + st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] +#else + st_ivas->hCombinedOrientationData->enableCombinedOrientation[subframe_idx] +#endif + ) { +#ifdef NONBE_UNIFIED_DECODING_PATHS + p_Rmat = &st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx][0][0]; +#else p_Rmat = &st_ivas->hCombinedOrientationData->Rmat[subframe_idx][0][0]; +#endif if ( st_ivas->hCombinedOrientationData->shd_rot_max_order == 0 ) { num_freq_bands = hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band]; @@ -1943,7 +1960,13 @@ void ivas_dirac_dec_render_sf( } } - if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[subframe_idx] && st_ivas->hCombinedOrientationData->shd_rot_max_order == 1 ) + if ( st_ivas->hCombinedOrientationData && +#ifdef NONBE_UNIFIED_DECODING_PATHS + st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] +#else + st_ivas->hCombinedOrientationData->enableCombinedOrientation[subframe_idx] +#endif + && st_ivas->hCombinedOrientationData->shd_rot_max_order == 1 ) { ivas_dirac_dec_compute_directional_responses( hSpatParamRendCom, hDirACRend, @@ -2070,7 +2093,13 @@ void ivas_dirac_dec_render_sf( if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) { - if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[subframe_idx] && st_ivas->hCombinedOrientationData->shd_rot_max_order == 0 ) + if ( st_ivas->hCombinedOrientationData && +#ifdef NONBE_UNIFIED_DECODING_PATHS + st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] +#else + st_ivas->hCombinedOrientationData->enableCombinedOrientation[subframe_idx] +#endif + && st_ivas->hCombinedOrientationData->shd_rot_max_order == 0 ) { protoSignalComputation_shd( Cldfb_RealBuffer, Cldfb_ImagBuffer, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, @@ -2302,7 +2331,13 @@ void ivas_dirac_dec_render_sf( } /*Compute PSDs*/ - if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[subframe_idx] && st_ivas->hCombinedOrientationData->shd_rot_max_order > 0 ) + if ( st_ivas->hCombinedOrientationData && +#ifdef NONBE_UNIFIED_DECODING_PATHS + st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] +#else + st_ivas->hCombinedOrientationData->enableCombinedOrientation[subframe_idx] +#endif + && st_ivas->hCombinedOrientationData->shd_rot_max_order > 0 ) { ivas_dirac_dec_output_synthesis_process_slot( reference_power, p_onset_filter, @@ -2420,7 +2455,11 @@ void ivas_dirac_dec_render_sf( #ifdef SPLIT_REND_WITH_HEAD_ROT &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, #endif - st_ivas->hCombinedOrientationData, subframe_idx, hSpatParamRendCom->subframe_nbslots[subframe_idx], Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); + st_ivas->hCombinedOrientationData, +#ifndef NONBE_UNIFIED_DECODING_PATHS + subframe_idx, +#endif + hSpatParamRendCom->subframe_nbslots[subframe_idx], Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); #ifdef SPLIT_REND_WITH_HEAD_ROT if ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 6a462fcd25..b41ba8b0c3 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1007,6 +1007,9 @@ ivas_error ivas_init_decoder_front( if ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) { if ( ( error = ivas_combined_orientation_open( &( st_ivas->hCombinedOrientationData ), +#ifdef NONBE_UNIFIED_DECODING_PATHS + st_ivas->hDecoderConfig->output_Fs, +#endif ( st_ivas->hDecoderConfig->Opt_5ms ) ? 1 : MAX_PARAM_SPATIAL_SUBFRAMES ) ) != IVAS_ERR_OK ) { return error; diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index fabe708603..ab3681d3d7 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -245,7 +245,13 @@ void ivas_ism_render_sf( } - if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] ) + if ( st_ivas->hCombinedOrientationData && +#ifdef NONBE_UNIFIED_DECODING_PATHS + st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] == 1 +#else + st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] +#endif + ) { ivas_jbm_dec_get_adapted_linear_interpolator( n_samples_to_render, n_samples_to_render, @@ -257,7 +263,13 @@ void ivas_ism_render_sf( { /* Combined rotation: rotate the object positions depending the head and external orientations */ - if ( st_ivas->hCombinedOrientationData != NULL && st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] == 1 ) + if ( st_ivas->hCombinedOrientationData != NULL && +#ifdef NONBE_UNIFIED_DECODING_PATHS + st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] == 1 +#else + st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] == 1 +#endif + ) { rotateAziEle( st_ivas->hIsmMetaData[i]->azimuth, st_ivas->hIsmMetaData[i]->elevation, &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[0], st_ivas->hIntSetup.is_planar_setup ); if ( st_ivas->hEFAPdata != NULL ) @@ -288,12 +300,22 @@ void ivas_ism_render_sf( } /* update here only in case of head rotation */ - if ( st_ivas->hCombinedOrientationData != NULL && st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] == 1 ) + if ( st_ivas->hCombinedOrientationData != NULL && +#ifdef NONBE_UNIFIED_DECODING_PATHS + st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] == 1 +#else + st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] == 1 +#endif + ) { st_ivas->hIsmRendererData->prev_gains[i][j] = gain; } } } +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* update combined orientation access index */ + ivas_combined_rotation_update_index( st_ivas->hCombinedOrientationData, n_samples_to_render ); +#endif return; } diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 1fe58874a0..d4a485bccd 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -824,6 +824,7 @@ ivas_error ivas_jbm_dec_render( p_tc[n] = &st_ivas->hTcBuffer->tc[n][st_ivas->hTcBuffer->n_samples_rendered]; } +#ifndef NONBE_UNIFIED_DECODING_PATHS /*----------------------------------------------------------------* * Combine orientations *----------------------------------------------------------------*/ @@ -833,6 +834,7 @@ ivas_error ivas_jbm_dec_render( { return error; } +#endif /*----------------------------------------------------------------* * Rendering diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index abcf0af5e0..ddfcddb131 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -1774,7 +1774,9 @@ void ivas_param_mc_dec_render( NULL, #endif st_ivas->hCombinedOrientationData, +#ifndef NONBE_UNIFIED_DECODING_PATHS subframe_idx, +#endif hParamMC->subframe_nbslots[subframe_idx], Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); @@ -1794,6 +1796,10 @@ void ivas_param_mc_dec_render( } } } +#endif +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* update combined orientation access index */ + ivas_combined_rotation_update_index( st_ivas->hCombinedOrientationData, hParamMC->num_freq_bands * hParamMC->subframe_nbslots[subframe_idx] ); #endif } else if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_CLDFB ) diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index ecccd9b6e1..324b9a9307 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -353,7 +353,9 @@ void ivas_mc_paramupmix_dec( &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, #endif st_ivas->hCombinedOrientationData, +#ifndef NONBE_UNIFIED_DECODING_PATHS subframeIdx, /* TODO (5ms) : tmu2Dlb please verify */ +#endif JBM_CLDFB_SLOTS_IN_SUBFRAME, #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG NULL, @@ -362,7 +364,6 @@ void ivas_mc_paramupmix_dec( Cldfb_RealBuffer_subfr, Cldfb_ImagBuffer_subfr ); - #ifdef SPLIT_REND_WITH_HEAD_ROT if ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { @@ -400,7 +401,10 @@ void ivas_mc_paramupmix_dec( } } #endif - +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* update combined orientation access index */ + ivas_combined_rotation_update_index( st_ivas->hCombinedOrientationData, maxBand * MAX_PARAM_SPATIAL_SUBFRAMES ); +#endif /* Implement CLDFB synthesis */ for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { @@ -580,6 +584,10 @@ void ivas_mc_paramupmix_dec_render( { output_f_local[ch] += n_samples_sf; } +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* update combined orientation access index */ + ivas_combined_rotation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf ); +#endif } for ( ch = 0; ch < MC_PARAMUPMIX_COMBINATIONS; ch++ ) @@ -1145,7 +1153,9 @@ static void ivas_mc_paramupmix_dec_sf( &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, #endif st_ivas->hCombinedOrientationData, +#ifndef NONBE_UNIFIED_DECODING_PATHS subframeIdx, +#endif st_ivas->hTcBuffer->subframe_nbslots[subframeIdx], Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_subfr, diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index b2857673fe..b1851ee19b 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -107,9 +107,13 @@ ivas_error ivas_td_binaural_renderer( nchan_transport, LFE_CHANNEL, st_ivas->ivas_format, st_ivas->hIsmMetaData, +#ifdef NONBE_UNIFIED_DECODING_PATHS + st_ivas->hCombinedOrientationData, +#else ( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->enableCombinedOrientation : NULL, ( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->Quaternions : NULL, ( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->listenerPos : NULL, +#endif ism_md_subframe_update, output, output_frame, MAX_PARAM_SPATIAL_SUBFRAMES ); } @@ -221,9 +225,17 @@ ivas_error ivas_td_binaural_renderer_sf( /* Update the listener's location/orientation */ TDREND_Update_listener_orientation( st_ivas->hBinRendererTd, +#ifdef NONBE_UNIFIED_DECODING_PATHS + ( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] : 0, + ( st_ivas->hCombinedOrientationData != NULL ) ? &st_ivas->hCombinedOrientationData->Quaternions[st_ivas->hCombinedOrientationData->subframe_idx] : NULL, + ( st_ivas->hCombinedOrientationData != NULL ) ? &st_ivas->hCombinedOrientationData->listenerPos[st_ivas->hCombinedOrientationData->subframe_idx] : NULL +#else ( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->enableCombinedOrientation[subframe_idx] : 0, ( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->Quaternions : NULL, - ( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->listenerPos : NULL ); + ( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->listenerPos : NULL +#endif + + ); if ( st_ivas->hRenderConfig != NULL && st_ivas->hIntSetup.output_config == AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { @@ -258,6 +270,10 @@ ivas_error ivas_td_binaural_renderer_sf( { output_f_local[ch] += output_frame; } +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* update combined orientation access index */ + ivas_combined_rotation_update_index( st_ivas->hCombinedOrientationData, output_frame ); +#endif } st_ivas->hTcBuffer->subframes_rendered = last_sf; diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index b0f2c872ee..b53037092c 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -690,7 +690,20 @@ ivas_error ivas_omasa_dirac_td_binaural( float gain = OMASA_TDREND_MATCHING_GAIN; ivas_error error; float *p_sepobj[MAX_NUM_OBJECTS]; +#ifdef NONBE_UNIFIED_DECODING_PATHS + int16_t orientation_index_start; + int16_t orientation_cur_subframe_samples_rendered; + orientation_index_start = 0; + orientation_cur_subframe_samples_rendered = 0; + + /* we are going through a possible orientation loop twice, save the start values here */ + if ( st_ivas->hCombinedOrientationData != NULL ) + { + orientation_index_start = st_ivas->hCombinedOrientationData->subframe_idx; + orientation_cur_subframe_samples_rendered = st_ivas->hCombinedOrientationData->cur_subframe_samples_rendered; + } +#endif for ( n = 0; n < MAX_NUM_OBJECTS; n++ ) { p_sepobj[n] = &data_separated_objects[n][0]; @@ -710,6 +723,14 @@ ivas_error ivas_omasa_dirac_td_binaural( ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, output, st_ivas->nchan_transport, MAX_PARAM_SPATIAL_SUBFRAMES ); +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* set orientation values again to the start values for the second binaural rendering path */ + if ( st_ivas->hCombinedOrientationData != NULL ) + { + st_ivas->hCombinedOrientationData->subframe_idx = orientation_index_start; + st_ivas->hCombinedOrientationData->cur_subframe_samples_rendered = orientation_cur_subframe_samples_rendered; + } +#endif if ( ( error = ivas_td_binaural_renderer( st_ivas, p_sepobj, output_frame ) ) != IVAS_ERR_OK ) { return error; @@ -745,7 +766,20 @@ ivas_error ivas_omasa_dirac_td_binaural_jbm( ivas_error error; float *p_sepobj[MAX_NUM_OBJECTS]; float *tc_local[MAX_TRANSPORT_CHANNELS]; +#ifdef NONBE_UNIFIED_DECODING_PATHS + int16_t orientation_index_start; + int16_t orientation_cur_subframe_samples_rendered; + orientation_index_start = 0; + orientation_cur_subframe_samples_rendered = 0; + + /* we are going through a possible orientation loop twice, save the start values here */ + if ( st_ivas->hCombinedOrientationData != NULL ) + { + orientation_index_start = st_ivas->hCombinedOrientationData->subframe_idx; + orientation_cur_subframe_samples_rendered = st_ivas->hCombinedOrientationData->cur_subframe_samples_rendered; + } +#endif for ( n = 0; n < MAX_NUM_OBJECTS; n++ ) { p_sepobj[n] = &data_separated_objects[n][0]; @@ -768,6 +802,14 @@ ivas_error ivas_omasa_dirac_td_binaural_jbm( ivas_dirac_dec_binaural_render( st_ivas, nSamplesAsked, nSamplesRendered, nSamplesAvailable, nchan_transport, output_f ); +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* set orientation values again to the start values for the second binaural rendering path */ + if ( st_ivas->hCombinedOrientationData != NULL ) + { + st_ivas->hCombinedOrientationData->subframe_idx = orientation_index_start; + st_ivas->hCombinedOrientationData->cur_subframe_samples_rendered = orientation_cur_subframe_samples_rendered; + } +#endif if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_sepobj, *nSamplesRendered ) ) != IVAS_ERR_OK ) { return error; diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 29136f5a93..0f68cc6a04 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -726,6 +726,10 @@ void ivas_sba_dec_render( { output_f_local[ch] += n_samples_sf; } +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* update combined orientation access index */ + ivas_combined_rotation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf ); +#endif } if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC ) diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 7f014c0a46..139e3d85f9 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -1399,6 +1399,9 @@ void ivas_spar_dec_upmixer( { output_f_local[n] += n_samples_sf; } +#ifdef NONBE_UNIFIED_DECODING_PATHS + ivas_combined_rotation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf ); +#endif } for ( n = 0; n < nchan_internal; n++ ) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index dfbd0d7998..215cf6e3d3 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -82,6 +82,9 @@ struct IVAS_DEC PCMDSP_APA_HANDLE hTimeScaler; bool needNewFrame; bool hasBeenFedFrame; +#ifdef NONBE_UNIFIED_DECODING_PATHS + bool updateOrientation; +#endif uint16_t nSamplesAvailableNext; int16_t nSamplesRendered; int16_t nTransportChannelsOld; @@ -172,6 +175,9 @@ ivas_error IVAS_DEC_Open( hIvasDec->hasBeenFedFirstGoodFrame = false; hIvasDec->hasDecodedFirstGoodFrame = false; hIvasDec->isInitialized = false; +#ifdef NONBE_UNIFIED_DECODING_PATHS + hIvasDec->updateOrientation = false; +#endif hIvasDec->mode = mode; @@ -784,6 +790,21 @@ ivas_error IVAS_DEC_GetSamples( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } +#ifdef NONBE_UNIFIED_DECODING_PATHS + if ( hIvasDec->updateOrientation ) + { + /*----------------------------------------------------------------* + * Combine orientations + *----------------------------------------------------------------*/ + + if ( ( error = combine_external_and_head_orientations_dec( hIvasDec->st_ivas->hHeadTrackData, hIvasDec->st_ivas->hExtOrientationData, hIvasDec->st_ivas->hCombinedOrientationData ) ) != IVAS_ERR_OK ) + { + return error; + } + hIvasDec->updateOrientation = false; + } +#endif + if ( !hIvasDec->hasBeenFedFrame && hIvasDec->nSamplesAvailableNext == 0 ) { /* no frame was fed, do nothing but ask for a frame */ @@ -807,8 +828,6 @@ ivas_error IVAS_DEC_GetSamples( *needNewFrame = true; } } - - /* only for 1st step 5ms API, split rendering still needs to go through the old decoding function */ else { /* check if we need to run the setup function */ @@ -1577,7 +1596,9 @@ ivas_error IVAS_DEC_FeedHeadTrackData( #ifdef SPLIT_REND_WITH_HEAD_ROT hHeadTrackData->sr_pose_pred_axis = rot_axis; #endif - +#ifdef NONBE_UNIFIED_DECODING_PATHS + hIvasDec->updateOrientation = true; +#endif return IVAS_ERR_OK; } @@ -1607,6 +1628,10 @@ ivas_error IVAS_DEC_FeedRefRotData( pOtr->refRot.z = rotation.z; pOtr->refRot.y = rotation.y; +#ifdef NONBE_UNIFIED_DECODING_PATHS + hIvasDec->updateOrientation = true; +#endif + return IVAS_ERR_OK; } @@ -1634,6 +1659,10 @@ ivas_error IVAS_DEC_FeedRefVectorData( pOtr = hIvasDec->st_ivas->hHeadTrackData->OrientationTracker; +#ifdef NONBE_UNIFIED_DECODING_PATHS + hIvasDec->updateOrientation = true; +#endif + return ivas_orient_trk_SetReferenceVector( pOtr, listenerPos, refPos ); } @@ -1676,6 +1705,10 @@ ivas_error IVAS_DEC_FeedExternalOrientationData( hExternalOrientationData->enableRotationInterpolation[subframe_idx] = enableRotationInterpolation; hExternalOrientationData->numFramesToTargetOrientation[subframe_idx] = numFramesToTargetOrientation; +#ifdef NONBE_UNIFIED_DECODING_PATHS + hIvasDec->updateOrientation = true; +#endif + return IVAS_ERR_OK; } diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index 21977a38b8..6b153f79c0 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -1821,6 +1821,10 @@ ivas_error ivas_rend_crendProcess( return error; } } +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* update combined orientation access index */ + ivas_combined_rotation_update_index( hCombinedOrientationData, subframe_len ); +#endif } else { @@ -2000,6 +2004,10 @@ ivas_error ivas_rend_crendProcessSubframe( { return IVAS_ERR_INVALID_INPUT_FORMAT; } +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* update combined orientation access index */ + ivas_combined_rotation_update_index( hCombinedOrientationData, subframe_len ); +#endif } /* move to output */ diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 4e927c78b2..8d99bd624f 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -503,6 +503,10 @@ void ivas_dirac_dec_binaural_render( { output_f_local[ch] += n_samples_sf; } +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* update combined orientation access index */ + ivas_combined_rotation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf ); +#endif } if ( hSpatParamRendCom->slots_rendered == hSpatParamRendCom->num_slots ) @@ -640,6 +644,9 @@ void ivas_dirac_dec_binaural( { p_output[ch] += n_samples_sf; } +#ifdef NONBE_UNIFIED_DECODING_PATHS + ivas_combined_rotation_update_index( hCombinedOrientationData, n_samples_sf ); +#endif hSpatParamRendCom->dirac_read_idx = ( hSpatParamRendCom->dirac_read_idx + 1 ) % hSpatParamRendCom->dirac_md_buffer_length; } @@ -856,7 +863,11 @@ static void ivas_dirac_dec_binaural_internal( { for ( j = 0; j < 3; j++ ) { +#ifdef NONBE_UNIFIED_DECODING_PATHS + Rmat[i][j] = hCombinedOrientationData->Rmat[hCombinedOrientationData->subframe_idx][i][j]; +#else Rmat[i][j] = hCombinedOrientationData->Rmat[subframe][i][j]; +#endif } } @@ -874,7 +885,13 @@ static void ivas_dirac_dec_binaural_internal( #ifndef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, Rmat, subframe, - hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0, st_ivas->hMasaIsmData ); + hCombinedOrientationData && +#ifdef NONBE_UNIFIED_DECODING_PATHS + hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, +#else + hCombinedOrientationData->enableCombinedOrientation[subframe] > 0, +#endif + st_ivas->hMasaIsmData ); #endif if ( config_data.ivas_format == ISM_FORMAT ) @@ -910,7 +927,12 @@ static void ivas_dirac_dec_binaural_internal( } ivas_dirac_dec_binaural_determine_processing_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, max_band_decorr, Rmat, subframe, - hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0, + hCombinedOrientationData && +#ifdef NONBE_UNIFIED_DECODING_PATHS + hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, +#else + hCombinedOrientationData->enableCombinedOrientation[subframe] > 0, +#endif nchanSeparateChannels, st_ivas->hMasaIsmData ); #ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index 61bfcf68ab..4935784c12 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -267,12 +267,16 @@ ivas_error ivas_td_binaural_renderer_unwrap( const int16_t lfe_idx, /* i : LFE channel index */ const IVAS_FORMAT ivas_format, /* i : IVAS format */ ISM_METADATA_HANDLE *hIsmMetaData, /* i : ISM metadata handle */ - const int16_t *enableCombinedOrientation, /* i : Combined orientation flag */ - const IVAS_QUATERNION *Quaternions, /* i : Head tracking data per subframe */ - const IVAS_VECTOR3 *Pos, /* i : Listener position data per subframe */ - const int16_t ism_md_subframe_update, /* i : Number of subframes to delay ism metadata to sync with audio */ - float *output[], /* i/o: SCE channels / Binaural synthesis */ - const int16_t output_frame /* i : output frame length */ +#ifdef NONBE_UNIFIED_DECODING_PATHS + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i/o: combined orientaton data handle */ +#else + const int16_t *enableCombinedOrientation, /* i : Combined orientation flag */ + const IVAS_QUATERNION *Quaternions, /* i : Head tracking data per subframe */ + const IVAS_VECTOR3 *Pos, /* i : Listener position data per subframe */ +#endif + const int16_t ism_md_subframe_update, /* i : Number of subframes to delay ism metadata to sync with audio */ + float *output[], /* i/o: SCE channels / Binaural synthesis */ + const int16_t output_frame /* i : output frame length */ , const int16_t num_subframes /* i : number of subframes to render */ ) @@ -284,6 +288,23 @@ ivas_error ivas_td_binaural_renderer_unwrap( int16_t c_indx, nS; float *p_reverb_signal[BINAURAL_CHANNELS]; int16_t ch; +#ifdef NONBE_UNIFIED_DECODING_PATHS + int16_t *enableCombinedOrientation; /* i : Combined orientation flag */ + IVAS_QUATERNION *Quaternions; /* i : Head tracking data per subframe */ + IVAS_VECTOR3 *Pos; /* i : Listener position data per subframe */ +#endif + +#ifdef NONBE_UNIFIED_DECODING_PATHS + enableCombinedOrientation = NULL; + Quaternions = NULL; + Pos = NULL; + if ( hCombinedOrientationData != NULL ) + { + enableCombinedOrientation = hCombinedOrientationData->enableCombinedOrientation; + Quaternions = hCombinedOrientationData->Quaternions; + Pos = hCombinedOrientationData->listenerPos; + } +#endif for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { @@ -311,7 +332,13 @@ ivas_error ivas_td_binaural_renderer_unwrap( TDREND_Update_object_positions( hBinRendererTd, num_src, ivas_format, hIsmMetaData ); } /* Update the listener's location/orientation */ - TDREND_Update_listener_orientation( hBinRendererTd, ( enableCombinedOrientation != NULL ) ? enableCombinedOrientation[subframe_idx] : 0, ( Quaternions != NULL ) ? &Quaternions[subframe_idx] : NULL, ( Pos != NULL ) ? &Pos[subframe_idx] : NULL ); + TDREND_Update_listener_orientation( hBinRendererTd, +#ifdef NONBE_UNIFIED_DECODING_PATHS + ( enableCombinedOrientation != NULL ) ? enableCombinedOrientation[hCombinedOrientationData->subframe_idx] : 0, ( Quaternions != NULL ) ? &Quaternions[hCombinedOrientationData->subframe_idx] : NULL, ( Pos != NULL ) ? &Pos[hCombinedOrientationData->subframe_idx] : NULL +#else + ( enableCombinedOrientation != NULL ) ? enableCombinedOrientation[subframe_idx] : 0, ( Quaternions != NULL ) ? &Quaternions[subframe_idx] : NULL, ( Pos != NULL ) ? &Pos[subframe_idx] : NULL +#endif + ); if ( hReverb != NULL ) { if ( ( error = ivas_reverb_process( hReverb, transport_config, 0, output, p_reverb_signal, subframe_idx ) ) != IVAS_ERR_OK ) @@ -336,6 +363,11 @@ ivas_error ivas_td_binaural_renderer_unwrap( c_indx++; } } + +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* update combined orientation access index */ + ivas_combined_rotation_update_index( hCombinedOrientationData, subframe_length ); +#endif } if ( hReverb != NULL ) @@ -696,9 +728,13 @@ ivas_error ivas_td_binaural_renderer_ext( } if ( ( error = ivas_td_binaural_renderer_unwrap( hReverb, transport_config, pTDRend->hBinRendererTd, num_src, lfe_idx, ivas_format, hIsmMetaData, +#ifdef NONBE_UNIFIED_DECODING_PATHS + *hCombinedOrientationData, +#else ( hCombinedOrientationData != NULL ) ? ( *hCombinedOrientationData )->enableCombinedOrientation : NULL, ( hCombinedOrientationData != NULL ) ? ( *hCombinedOrientationData )->Quaternions : NULL, ( hCombinedOrientationData != NULL ) ? ( *hCombinedOrientationData )->listenerPos : NULL, +#endif ism_md_subframe_update_ext, p_output, output_frame, (int16_t) ( ( output_frame * FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) / output_Fs ) ) ) != IVAS_ERR_OK ) { diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 6e81113fee..0c62908ef7 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -555,9 +555,13 @@ ivas_error ivas_td_binaural_renderer_unwrap( const int16_t lfe_idx, /* i : LFE channel index */ const IVAS_FORMAT ivas_format, /* i : IVAS format */ ISM_METADATA_HANDLE *hIsmMetaData, /* i : ISM metadata handle */ - const int16_t *enableCombinedOrientation, /* i : Combined orientation flag */ - const IVAS_QUATERNION *Quaternions, /* i : Head tracking data per subframe */ - const IVAS_VECTOR3 *Pos, /* i : Listener position data per subframe */ +#ifdef NONBE_UNIFIED_DECODING_PATHS + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i/o: combined orientaton data handle */ +#else + const int16_t *enableCombinedOrientation, /* i : Combined orientation flag */ + const IVAS_QUATERNION *Quaternions, /* i : Head tracking data per subframe */ + const IVAS_VECTOR3 *Pos, /* i : Listener position data per subframe */ +#endif const int16_t ism_md_subframe_update, float *output[], /* i/o: SCE channels / Binaural synthesis */ const int16_t output_frame /* i : output frame length */ @@ -1229,6 +1233,13 @@ void rotateFrame_sd( const int16_t subframe_idx /* i : subframe index */ ); +#ifdef NONBE_UNIFIED_DECODING_PATHS +ivas_error ivas_combined_rotation_update_index( + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i/o: combined orientation handle */ + const int16_t samples_rendered /* i : samples rendered since the last call */ +); +#endif + void rotateFrame_shd_cldfb( float Cldfb_RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: unrotated HOA3 signal buffer in cldfb domain real part */ float Cldfb_ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: unrotated HOA3 signal buffer in cldfb domain imag part */ @@ -1259,8 +1270,10 @@ void ivas_external_orientation_close( ); ivas_error ivas_combined_orientation_open( - COMBINED_ORIENTATION_HANDLE *hCombinedOrientationData /* o : combined orientation handle */ - , + COMBINED_ORIENTATION_HANDLE *hCombinedOrientationData, /* o : combined orientation handle */ +#ifdef NONBE_UNIFIED_DECODING_PATHS + const int32_t fs, +#endif const int16_t num_subframes ); diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index fac6056f35..cedd5a4f17 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -394,7 +394,11 @@ void rotateFrame_shd( SHrotmatgen( SHrotmat_prev, hCombinedOrientationData->Rmat_prev, shd_rot_max_order ); #endif +#ifdef NONBE_UNIFIED_DECODING_PATHS + SHrotmatgen( SHrotmat, hCombinedOrientationData->Rmat[hCombinedOrientationData->subframe_idx], shd_rot_max_order ); +#else SHrotmatgen( SHrotmat, hCombinedOrientationData->Rmat[subframe_idx], shd_rot_max_order ); +#endif for ( i = 0; i < subframe_len; i++ ) { @@ -447,7 +451,11 @@ void rotateFrame_shd( for ( i = 0; i < 3; i++ ) { mvr2r( +#ifdef NONBE_UNIFIED_DECODING_PATHS + hCombinedOrientationData->Rmat[hCombinedOrientationData->subframe_idx][i], +#else hCombinedOrientationData->Rmat[subframe_idx][i], +#endif #ifdef SPLIT_REND_WITH_HEAD_ROT hCombinedOrientationData->Rmat_prev[0][i], #else @@ -546,7 +554,13 @@ void rotateFrame_sd( /* gains for current subframe rotation */ - rotateAziEle( hTransSetup.ls_azimuth[ch_in_woLFE], hTransSetup.ls_elevation[ch_in_woLFE], &azimuth, &elevation, hCombinedOrientationData->Rmat[subframe_idx], hTransSetup.is_planar_setup ); + rotateAziEle( hTransSetup.ls_azimuth[ch_in_woLFE], hTransSetup.ls_elevation[ch_in_woLFE], &azimuth, &elevation, +#ifdef NONBE_UNIFIED_DECODING_PATHS + hCombinedOrientationData->Rmat[hCombinedOrientationData->subframe_idx], +#else + hCombinedOrientationData->Rmat[subframe_idx], +#endif + hTransSetup.is_planar_setup ); if ( hEFAPdata != NULL && ( hTransSetup.ls_azimuth[ch_in_woLFE] != azimuth || hTransSetup.ls_elevation[ch_in_woLFE] != elevation ) ) { efap_determine_gains( hEFAPdata, tmp_gains, azimuth, elevation, EFAP_MODE_EFAP ); @@ -584,7 +598,11 @@ void rotateFrame_sd( for ( i = 0; i < 3; i++ ) { mvr2r( +#ifdef NONBE_UNIFIED_DECODING_PATHS + hCombinedOrientationData->Rmat[hCombinedOrientationData->subframe_idx][i], +#else hCombinedOrientationData->Rmat[subframe_idx][i], +#endif #ifdef SPLIT_REND_WITH_HEAD_ROT hCombinedOrientationData->Rmat_prev[0][i], #else @@ -875,8 +893,10 @@ void ivas_external_orientation_close( *-----------------------------------------------------------------------*/ ivas_error ivas_combined_orientation_open( - COMBINED_ORIENTATION_HANDLE *hCombinedOrientationData /* o : combined orientation handle */ - , + COMBINED_ORIENTATION_HANDLE *hCombinedOrientationData, /* o : combined orientation handle */ +#ifdef NONBE_UNIFIED_DECODING_PATHS + const int32_t fs, +#endif const int16_t num_subframes ) { int16_t i; @@ -940,6 +960,9 @@ ivas_error ivas_combined_orientation_open( } } ( *hCombinedOrientationData )->sr_pose_pred_axis = DEFAULT_AXIS; +#ifdef NONBE_UNIFIED_DECODING_PATHS + ( *hCombinedOrientationData )->sr_low_res_flag = 1; +#endif #else for ( j = 0; j < 3; j++ ) { @@ -961,6 +984,12 @@ ivas_error ivas_combined_orientation_open( ( *hCombinedOrientationData )->isExtOrientationFrozen = 0; ( *hCombinedOrientationData )->isHeadRotationFrozen = 0; +#ifdef NONBE_UNIFIED_DECODING_PATHS + ( *hCombinedOrientationData )->subframe_idx = 0; + ( *hCombinedOrientationData )->subframe_size = (int16_t) ( fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ); + ( *hCombinedOrientationData )->cur_subframe_samples_rendered = 0; +#endif + return IVAS_ERR_OK; } @@ -1338,6 +1367,10 @@ ivas_error combine_external_and_head_orientations( #ifdef SPLIT_REND_WITH_HEAD_ROT hCombinedOrientationData->sr_pose_pred_axis = sr_pose_pred_axis; #endif +#ifdef NONBE_UNIFIED_DECODING_PATHS + hCombinedOrientationData->subframe_idx = 0; + hCombinedOrientationData->cur_subframe_samples_rendered = 0; +#endif return IVAS_ERR_OK; } @@ -1373,7 +1406,19 @@ void external_target_interpolation( { if ( i > 0 ) { - hCombinedOrientationData->Quaternions_ext_interpolation_start = hExtOrientationData->Quaternions[i - 1]; +#ifdef NONBE_UNIFIED_DECODING_PATHS + if ( hExtOrientationData->enableExternalOrientation[i - 1] != 1 ) + { + IVAS_QUATERNION identity; + identity.w = 1.0f; + identity.x = identity.y = identity.z = 0.0f; + hCombinedOrientationData->Quaternions_ext_interpolation_start = identity; + } + else +#endif + { + hCombinedOrientationData->Quaternions_ext_interpolation_start = hExtOrientationData->Quaternions[i - 1]; + } } else { @@ -1675,3 +1720,42 @@ void SHrotmatgen( return; } + +#ifdef NONBE_UNIFIED_DECODING_PATHS +/*------------------------------------------------------------------------- + * vas_combined_rotation_update_index() + * + * update read index based on the number of rendered samples + *------------------------------------------------------------------------*/ + +ivas_error ivas_combined_rotation_update_index( + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i/o: combined orientation handle */ + const int16_t samples_rendered /* i : samples rendered since the last call */ +) +{ + ivas_error error; + + error = IVAS_ERR_OK; + + if ( hCombinedOrientationData != NULL ) + { + if ( hCombinedOrientationData->num_subframes == 1 +#ifdef SPLIT_REND_WITH_HEAD_ROT + || hCombinedOrientationData->sr_low_res_flag +#endif + ) + { + /* only one orientation available anyway or split rendering with low resolution*/ + hCombinedOrientationData->subframe_idx = 0; + } + else + { + hCombinedOrientationData->cur_subframe_samples_rendered += samples_rendered; + hCombinedOrientationData->subframe_idx += hCombinedOrientationData->cur_subframe_samples_rendered / hCombinedOrientationData->subframe_size; + hCombinedOrientationData->cur_subframe_samples_rendered = hCombinedOrientationData->cur_subframe_samples_rendered % hCombinedOrientationData->subframe_size; + hCombinedOrientationData->subframe_idx = max( hCombinedOrientationData->subframe_idx, hCombinedOrientationData->num_subframes - 1 ); + } + } + return error; +} +#endif diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index b53687587c..53323ef1d9 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -698,12 +698,20 @@ typedef struct ivas_combined_orientation_struct IVAS_VECTOR3 listenerPos[MAX_PARAM_SPATIAL_SUBFRAMES]; #ifdef SPLIT_REND_WITH_HEAD_ROT IVAS_SPLIT_REND_ROT_AXIS sr_pose_pred_axis; +#ifdef NONBE_UNIFIED_DECODING_PATHS + int16_t sr_low_res_flag; +#endif #endif IVAS_QUATERNION Quaternion_frozen_ext; IVAS_QUATERNION Quaternion_frozen_head; int8_t isExtOrientationFrozen; int8_t isHeadRotationFrozen; int16_t num_subframes; +#ifdef NONBE_UNIFIED_DECODING_PATHS + int16_t subframe_idx; + int16_t subframe_size; + int16_t cur_subframe_samples_rendered; +#endif } COMBINED_ORIENTATION_DATA, *COMBINED_ORIENTATION_HANDLE; diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 81efc7d989..3abcec6c55 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -3274,6 +3274,9 @@ static DecoderDummy *initDecoderDummy( /* Combined orientations */ if ( ( error = ivas_combined_orientation_open( &( decDummy->hCombinedOrientationData ), +#ifdef NONBE_UNIFIED_DECODING_PATHS + sampleRate, +#endif num_subframes ) ) != IVAS_ERR_OK ) { assert( error == IVAS_ERR_OK ); @@ -3618,6 +3621,9 @@ ivas_error IVAS_REND_Open( /* Initilize combined orientation data */ if ( ( error = ivas_combined_orientation_open( &( hIvasRend->hCombinedOrientationData ), +#ifdef NONBE_UNIFIED_DECODING_PATHS + outputSampleRate, +#endif num_subframes ) ) != IVAS_ERR_OK ) { return error; -- GitLab From c4a157ed5b93b713a42bdf1b6365fef04d3836ba Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Thu, 21 Sep 2023 11:19:22 +0200 Subject: [PATCH 02/49] further changes for the combined orientation read index handling --- lib_com/options.h | 1 + lib_dec/ivas_binRenderer_internal.c | 4 +- lib_dec/ivas_dec.c | 6 ++ lib_dec/ivas_dirac_dec.c | 4 +- lib_dec/ivas_ism_renderer.c | 2 +- lib_dec/ivas_jbm_dec.c | 19 ++++++ lib_dec/ivas_mc_param_dec.c | 2 +- lib_dec/ivas_mc_paramupmix_dec.c | 4 +- lib_dec/ivas_objectRenderer_internal.c | 2 +- lib_dec/ivas_omasa_dec.c | 40 +----------- lib_dec/ivas_sba_dec.c | 2 +- lib_dec/ivas_spar_decoder.c | 2 +- lib_rend/ivas_crend.c | 4 +- lib_rend/ivas_dirac_dec_binaural_functions.c | 4 +- lib_rend/ivas_objectRenderer.c | 2 +- lib_rend/ivas_prot_rend.h | 11 +++- lib_rend/ivas_rotation.c | 67 +++++++++++++++++++- lib_rend/ivas_stat_rend.h | 2 + lib_rend/lib_rend.c | 26 ++++++++ 19 files changed, 147 insertions(+), 57 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 3824bbdc29..ae43962cf5 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -168,6 +168,7 @@ #define NONBE_FIX_736_FOA_BR_SWITCH /* FhG/Dlb : Issue 736: FOA bitrate switching decoding crashes in in ivas_spar_to_dirac */ #define NONBE_FIX_746_NONDIEGETIC_MD /* Eri: Issue 746: The non-diegetic panning flag affects the encoder bitstream even if extended metadata is not enabled. Crashes the decoder.*/ #define NONBE_UNIFIED_DECODING_PATHS /* FhG: unify decoding paths */ + /* ##################### End NON-BE switches ############################# */ /* ################## End DEVELOPMENT switches ######################### */ diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index b890884703..511cf02931 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -1706,7 +1706,7 @@ void ivas_binaural_cldfb( #endif #ifdef NONBE_UNIFIED_DECODING_PATHS /* update combined orientation access index */ - ivas_combined_rotation_update_index( st_ivas->hCombinedOrientationData, maxBand * MAX_PARAM_SPATIAL_SUBFRAMES ); + ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, maxBand * MAX_PARAM_SPATIAL_SUBFRAMES ); #endif /* Implement CLDFB synthesis */ for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) @@ -1865,7 +1865,7 @@ void ivas_binaural_cldfb_sf( #endif #ifdef NONBE_UNIFIED_DECODING_PATHS /* update combined orientation access index */ - ivas_combined_rotation_update_index( st_ivas->hCombinedOrientationData, maxBand * st_ivas->hTcBuffer->subframe_nbslots[subframeIdx] ); + ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, maxBand * st_ivas->hTcBuffer->subframe_nbslots[subframeIdx] ); #endif /* Implement CLDFB synthesis */ for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 65a4fbacab..608b438b90 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -108,6 +108,8 @@ ivas_error ivas_dec( { return error; } +#else + ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData ); #endif #if defined SPLIT_REND_WITH_HEAD_ROT if ( ( output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || @@ -1095,6 +1097,10 @@ ivas_error ivas_dec( } } +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* update global combined orientation start index */ + ivas_combined_orientation_update_start_index( st_ivas->hCombinedOrientationData, output_frame ); +#endif /*----------------------------------------------------------------* * Write IVAS output channels diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 316f7445d3..6c49fe3697 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -1651,7 +1651,7 @@ void ivas_dirac_dec( output_f_local[n] += n_samples_sf; } #ifdef NONBE_UNIFIED_DECODING_PATHS - ivas_combined_rotation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf ); + ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf ); #endif } @@ -1735,7 +1735,7 @@ void ivas_dirac_dec_render( } #ifdef NONBE_UNIFIED_DECODING_PATHS /* update combined orientation access index */ - ivas_combined_rotation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf ); + ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf ); #endif } diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index ab3681d3d7..a16245fd30 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -314,7 +314,7 @@ void ivas_ism_render_sf( } #ifdef NONBE_UNIFIED_DECODING_PATHS /* update combined orientation access index */ - ivas_combined_rotation_update_index( st_ivas->hCombinedOrientationData, n_samples_to_render ); + ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, n_samples_to_render ); #endif return; diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index d4a485bccd..e2c90f98f7 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -834,6 +834,10 @@ ivas_error ivas_jbm_dec_render( { return error; } +#else + /* take the discard samples into account here to make sure head rotation stays on the correct 5ms grid */ + st_ivas->hCombinedOrientationData->cur_subframe_samples_rendered_start -= st_ivas->hTcBuffer->n_samples_discard; + ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData ); #endif /*----------------------------------------------------------------* @@ -1158,6 +1162,11 @@ ivas_error ivas_jbm_dec_render( st_ivas->hTcBuffer->n_samples_available -= *nSamplesRendered; st_ivas->hTcBuffer->n_samples_rendered += *nSamplesRendered; +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* update global combined orientation start index */ + ivas_combined_orientation_update_start_index( st_ivas->hCombinedOrientationData, *nSamplesRendered ); +#endif + if ( st_ivas->hTcBuffer->n_samples_discard > 0 ) { for ( n = 0; n < MAX_OUTPUT_CHANNELS; n++ ) @@ -1204,6 +1213,7 @@ ivas_error ivas_jbm_dec_render( break; } #endif + *nSamplesAvailableNext = st_ivas->hTcBuffer->n_samples_available; pop_wmops(); return error; @@ -1254,6 +1264,10 @@ ivas_error ivas_jbm_dec_flush_renderer( n_samples_still_available -= n_samples_to_render; assert( n_samples_still_available < tc_granularity_new ); +#ifdef NONBE_UNIFIED_DECODING_PATHS + ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData ); +#endif + if ( n_slots_still_available ) { int16_t ch_idx; @@ -1381,6 +1395,11 @@ ivas_error ivas_jbm_dec_flush_renderer( } } +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* update global combined orientation start index */ + ivas_combined_orientation_update_start_index( st_ivas->hCombinedOrientationData, *nSamplesRendered ); +#endif + /* Only write out the valid data*/ #if defined SPLIT_REND_WITH_HEAD_ROT if ( st_ivas->hDecoderConfig->Opt_Limiter ) diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index ddfcddb131..ec7e423153 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -1799,7 +1799,7 @@ void ivas_param_mc_dec_render( #endif #ifdef NONBE_UNIFIED_DECODING_PATHS /* update combined orientation access index */ - ivas_combined_rotation_update_index( st_ivas->hCombinedOrientationData, hParamMC->num_freq_bands * hParamMC->subframe_nbslots[subframe_idx] ); + ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, hParamMC->num_freq_bands * hParamMC->subframe_nbslots[subframe_idx] ); #endif } else if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_CLDFB ) diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index 324b9a9307..3a6160763a 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -403,7 +403,7 @@ void ivas_mc_paramupmix_dec( #endif #ifdef NONBE_UNIFIED_DECODING_PATHS /* update combined orientation access index */ - ivas_combined_rotation_update_index( st_ivas->hCombinedOrientationData, maxBand * MAX_PARAM_SPATIAL_SUBFRAMES ); + ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, maxBand * MAX_PARAM_SPATIAL_SUBFRAMES ); #endif /* Implement CLDFB synthesis */ for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) @@ -586,7 +586,7 @@ void ivas_mc_paramupmix_dec_render( } #ifdef NONBE_UNIFIED_DECODING_PATHS /* update combined orientation access index */ - ivas_combined_rotation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf ); + ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf ); #endif } diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index b1851ee19b..e100db85ac 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -272,7 +272,7 @@ ivas_error ivas_td_binaural_renderer_sf( } #ifdef NONBE_UNIFIED_DECODING_PATHS /* update combined orientation access index */ - ivas_combined_rotation_update_index( st_ivas->hCombinedOrientationData, output_frame ); + ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, output_frame ); #endif } diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index b53037092c..46db456dd8 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -690,20 +690,7 @@ ivas_error ivas_omasa_dirac_td_binaural( float gain = OMASA_TDREND_MATCHING_GAIN; ivas_error error; float *p_sepobj[MAX_NUM_OBJECTS]; -#ifdef NONBE_UNIFIED_DECODING_PATHS - int16_t orientation_index_start; - int16_t orientation_cur_subframe_samples_rendered; - - orientation_index_start = 0; - orientation_cur_subframe_samples_rendered = 0; - /* we are going through a possible orientation loop twice, save the start values here */ - if ( st_ivas->hCombinedOrientationData != NULL ) - { - orientation_index_start = st_ivas->hCombinedOrientationData->subframe_idx; - orientation_cur_subframe_samples_rendered = st_ivas->hCombinedOrientationData->cur_subframe_samples_rendered; - } -#endif for ( n = 0; n < MAX_NUM_OBJECTS; n++ ) { p_sepobj[n] = &data_separated_objects[n][0]; @@ -724,12 +711,7 @@ ivas_error ivas_omasa_dirac_td_binaural( MAX_PARAM_SPATIAL_SUBFRAMES ); #ifdef NONBE_UNIFIED_DECODING_PATHS - /* set orientation values again to the start values for the second binaural rendering path */ - if ( st_ivas->hCombinedOrientationData != NULL ) - { - st_ivas->hCombinedOrientationData->subframe_idx = orientation_index_start; - st_ivas->hCombinedOrientationData->cur_subframe_samples_rendered = orientation_cur_subframe_samples_rendered; - } + ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData ); #endif if ( ( error = ivas_td_binaural_renderer( st_ivas, p_sepobj, output_frame ) ) != IVAS_ERR_OK ) { @@ -766,20 +748,7 @@ ivas_error ivas_omasa_dirac_td_binaural_jbm( ivas_error error; float *p_sepobj[MAX_NUM_OBJECTS]; float *tc_local[MAX_TRANSPORT_CHANNELS]; -#ifdef NONBE_UNIFIED_DECODING_PATHS - int16_t orientation_index_start; - int16_t orientation_cur_subframe_samples_rendered; - - orientation_index_start = 0; - orientation_cur_subframe_samples_rendered = 0; - /* we are going through a possible orientation loop twice, save the start values here */ - if ( st_ivas->hCombinedOrientationData != NULL ) - { - orientation_index_start = st_ivas->hCombinedOrientationData->subframe_idx; - orientation_cur_subframe_samples_rendered = st_ivas->hCombinedOrientationData->cur_subframe_samples_rendered; - } -#endif for ( n = 0; n < MAX_NUM_OBJECTS; n++ ) { p_sepobj[n] = &data_separated_objects[n][0]; @@ -803,12 +772,7 @@ ivas_error ivas_omasa_dirac_td_binaural_jbm( ivas_dirac_dec_binaural_render( st_ivas, nSamplesAsked, nSamplesRendered, nSamplesAvailable, nchan_transport, output_f ); #ifdef NONBE_UNIFIED_DECODING_PATHS - /* set orientation values again to the start values for the second binaural rendering path */ - if ( st_ivas->hCombinedOrientationData != NULL ) - { - st_ivas->hCombinedOrientationData->subframe_idx = orientation_index_start; - st_ivas->hCombinedOrientationData->cur_subframe_samples_rendered = orientation_cur_subframe_samples_rendered; - } + ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData ); #endif if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_sepobj, *nSamplesRendered ) ) != IVAS_ERR_OK ) { diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 0f68cc6a04..8516dd9f74 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -728,7 +728,7 @@ void ivas_sba_dec_render( } #ifdef NONBE_UNIFIED_DECODING_PATHS /* update combined orientation access index */ - ivas_combined_rotation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf ); + ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf ); #endif } diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 139e3d85f9..3c11388bcf 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -1400,7 +1400,7 @@ void ivas_spar_dec_upmixer( output_f_local[n] += n_samples_sf; } #ifdef NONBE_UNIFIED_DECODING_PATHS - ivas_combined_rotation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf ); + ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf ); #endif } diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index 6b153f79c0..babdadbb93 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -1823,7 +1823,7 @@ ivas_error ivas_rend_crendProcess( } #ifdef NONBE_UNIFIED_DECODING_PATHS /* update combined orientation access index */ - ivas_combined_rotation_update_index( hCombinedOrientationData, subframe_len ); + ivas_combined_orientation_update_index( hCombinedOrientationData, subframe_len ); #endif } else @@ -2006,7 +2006,7 @@ ivas_error ivas_rend_crendProcessSubframe( } #ifdef NONBE_UNIFIED_DECODING_PATHS /* update combined orientation access index */ - ivas_combined_rotation_update_index( hCombinedOrientationData, subframe_len ); + ivas_combined_orientation_update_index( hCombinedOrientationData, subframe_len ); #endif } diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 8d99bd624f..0c7b88e4af 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -505,7 +505,7 @@ void ivas_dirac_dec_binaural_render( } #ifdef NONBE_UNIFIED_DECODING_PATHS /* update combined orientation access index */ - ivas_combined_rotation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf ); + ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf ); #endif } @@ -645,7 +645,7 @@ void ivas_dirac_dec_binaural( p_output[ch] += n_samples_sf; } #ifdef NONBE_UNIFIED_DECODING_PATHS - ivas_combined_rotation_update_index( hCombinedOrientationData, n_samples_sf ); + ivas_combined_orientation_update_index( hCombinedOrientationData, n_samples_sf ); #endif hSpatParamRendCom->dirac_read_idx = ( hSpatParamRendCom->dirac_read_idx + 1 ) % hSpatParamRendCom->dirac_md_buffer_length; } diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index 4935784c12..e2fbb78b89 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -366,7 +366,7 @@ ivas_error ivas_td_binaural_renderer_unwrap( #ifdef NONBE_UNIFIED_DECODING_PATHS /* update combined orientation access index */ - ivas_combined_rotation_update_index( hCombinedOrientationData, subframe_length ); + ivas_combined_orientation_update_index( hCombinedOrientationData, subframe_length ); #endif } diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 0c62908ef7..75e3d51746 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -1234,10 +1234,19 @@ void rotateFrame_sd( ); #ifdef NONBE_UNIFIED_DECODING_PATHS -ivas_error ivas_combined_rotation_update_index( +ivas_error ivas_combined_orientation_update_index( COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i/o: combined orientation handle */ const int16_t samples_rendered /* i : samples rendered since the last call */ ); + +ivas_error ivas_combined_orientation_update_start_index( + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i/o: combined orientation handle */ + const int16_t samples_rendered /* i : samples rendered since the last call */ +); + +ivas_error ivas_combined_orientation_set_to_start_index( + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData /* i/o: combined orientation handle */ +); #endif void rotateFrame_shd_cldfb( diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index cedd5a4f17..fb0a94d7f7 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -1370,6 +1370,8 @@ ivas_error combine_external_and_head_orientations( #ifdef NONBE_UNIFIED_DECODING_PATHS hCombinedOrientationData->subframe_idx = 0; hCombinedOrientationData->cur_subframe_samples_rendered = 0; + hCombinedOrientationData->subframe_idx_start = 0; + hCombinedOrientationData->cur_subframe_samples_rendered_start = 0; #endif return IVAS_ERR_OK; @@ -1723,12 +1725,12 @@ void SHrotmatgen( #ifdef NONBE_UNIFIED_DECODING_PATHS /*------------------------------------------------------------------------- - * vas_combined_rotation_update_index() + * ivas_combined_orientation_update_index() * * update read index based on the number of rendered samples *------------------------------------------------------------------------*/ -ivas_error ivas_combined_rotation_update_index( +ivas_error ivas_combined_orientation_update_index( COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i/o: combined orientation handle */ const int16_t samples_rendered /* i : samples rendered since the last call */ ) @@ -1758,4 +1760,65 @@ ivas_error ivas_combined_rotation_update_index( } return error; } + + +/*------------------------------------------------------------------------- + * ivas_combined_orientation_update_index() + * + * update read index based on the number of rendered samples + *------------------------------------------------------------------------*/ + +ivas_error ivas_combined_orientation_set_to_start_index( + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData /* i/o: combined orientation handle */ +) +{ + ivas_error error; + + error = IVAS_ERR_OK; + + if ( hCombinedOrientationData != NULL ) + { + hCombinedOrientationData->subframe_idx = hCombinedOrientationData->subframe_idx_start; + hCombinedOrientationData->cur_subframe_samples_rendered = hCombinedOrientationData->cur_subframe_samples_rendered_start; + } + return error; +} + +/*------------------------------------------------------------------------- + * ivas_combined_orientation_update_start_index() + * + * update read index based on the number of rendered samples + *------------------------------------------------------------------------*/ + +ivas_error ivas_combined_orientation_update_start_index( + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i/o: combined orientation handle */ + const int16_t samples_rendered /* i : samples rendered since the last call */ +) +{ + ivas_error error; + + error = IVAS_ERR_OK; + + if ( hCombinedOrientationData != NULL ) + { + if ( hCombinedOrientationData->num_subframes == 1 +#ifdef SPLIT_REND_WITH_HEAD_ROT + || hCombinedOrientationData->sr_low_res_flag +#endif + ) + { + /* only one orientation available anyway or split rendering with low resolution*/ + hCombinedOrientationData->subframe_idx = 0; + } + else + { + hCombinedOrientationData->cur_subframe_samples_rendered_start += samples_rendered; + hCombinedOrientationData->subframe_idx_start += hCombinedOrientationData->cur_subframe_samples_rendered / hCombinedOrientationData->subframe_size; + hCombinedOrientationData->cur_subframe_samples_rendered_start = hCombinedOrientationData->cur_subframe_samples_rendered % hCombinedOrientationData->subframe_size; + hCombinedOrientationData->subframe_idx_start = max( hCombinedOrientationData->subframe_idx, hCombinedOrientationData->num_subframes - 1 ); + } + } + return error; +} + #endif diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 53323ef1d9..b5e4a18f10 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -711,6 +711,8 @@ typedef struct ivas_combined_orientation_struct int16_t subframe_idx; int16_t subframe_size; int16_t cur_subframe_samples_rendered; + int16_t subframe_idx_start; + int16_t cur_subframe_samples_rendered_start; #endif } COMBINED_ORIENTATION_DATA, *COMBINED_ORIENTATION_HANDLE; diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 3abcec6c55..8ee65fee94 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -6300,6 +6300,11 @@ static ivas_error renderInputIsm( /* Apply input gain to new audio */ v_multc( inAudio.data, ismInput->base.gain, inAudio.data, inAudio.config.numSamplesPerChannel * inAudio.config.numChannels ); +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* set combined orientation subframe info to start info */ + ivas_combined_orientation_set_to_start_index( *ismInput->base.ctx.pCombinedOrientationData ); +#endif + switch ( getAudioConfigType( outConfig ) ) { case IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED: @@ -7092,6 +7097,11 @@ static ivas_error renderInputMc( inAudio.data, inAudio.config.numSamplesPerChannel * inAudio.config.numChannels ); +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* set combined orientation subframe info to start info */ + ivas_combined_orientation_set_to_start_index( *(mcInput->base.ctx.pCombinedOrientationData) ); +#endif + switch ( getAudioConfigType( outConfig ) ) { case IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED: @@ -8007,6 +8017,12 @@ static ivas_error renderInputSba( inAudio.data, inAudio.config.numSamplesPerChannel * inAudio.config.numChannels ); +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* set combined orientation subframe info to start info */ + ivas_combined_orientation_set_to_start_index( *(sbaInput->base.ctx.pCombinedOrientationData) ); +#endif + + switch ( getAudioConfigType( outConfig ) ) { case IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED: @@ -8400,6 +8416,11 @@ static ivas_error renderInputMasa( inAudio.data, inAudio.config.numSamplesPerChannel * inAudio.config.numChannels ); +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* set combined orientation subframe info to start info */ + ivas_combined_orientation_set_to_start_index( *(masaInput->base.ctx.pCombinedOrientationData) ); +#endif + switch ( getAudioConfigType( outConfig ) ) { case IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED: @@ -8888,6 +8909,11 @@ static ivas_error getSamplesInternal( } #endif /* SPLIT_REND_WITH_HEAD_ROT */ +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* update global cominbed orientation start index */ + ivas_combined_orientation_update_start_index( hIvasRend->hCombinedOrientationData, outAudio.config.numSamplesPerChannel ); +#endif + return IVAS_ERR_OK; } -- GitLab From 2df5ead67216df1b556436243b06683cc558d46d Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Thu, 21 Sep 2023 11:40:38 +0200 Subject: [PATCH 03/49] add binaural rotation capability to the VoIP/JBM decoding --- apps/decoder.c | 192 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 180 insertions(+), 12 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 468392a6ad..23e0426ed1 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -165,7 +165,14 @@ static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, RotF IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); -static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HANDLE hIvasDec ); +static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, +#ifdef NONBE_UNIFIED_DECODING_PATHS + RotFileReader *headRotReader, + RotFileReader *externalOrientationFileReader, + RotFileReader *refRotReader, + Vector3PairFileReader *referenceVectorReader, +#endif + IVAS_DEC_HANDLE hIvasDec ); #ifdef DEBUGGING #ifdef VARIABLE_SPEED_DECODING static ivas_error decodeVariableSpeed( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec ); @@ -791,7 +798,11 @@ int main( if ( arg.voipMode ) { - error = decodeVoIP( arg, hBsReader, hIvasDec ); + error = decodeVoIP( arg, hBsReader, +#ifdef NONBE_UNIFIED_DECODING_PATHS + headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, +#endif + hIvasDec ); } else { @@ -2214,13 +2225,6 @@ static ivas_error decodeG192( } } -#ifdef NONBE_UNIFIED_DECODING_PATHS - if ( arg.enableExternalOrientation ) - { - } -#endif - - /* decode and get samples */ nSamplesRendered = 0; nSamplesToRender = nOutSamples; @@ -2828,6 +2832,12 @@ static ivas_error writeJbmTraceFileFrameWrapper( const void *data, void *writer static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, +#ifdef NONBE_UNIFIED_DECODING_PATHS + RotFileReader *headRotReader, + RotFileReader *externalOrientationFileReader, + RotFileReader *refRotReader, + Vector3PairFileReader *referenceVectorReader, +#endif IVAS_DEC_HANDLE hIvasDec ) { bool decodingFailed = true; /* Assume failure until cleanup is reached without errors */ @@ -2871,8 +2881,36 @@ static ivas_error decodeVoIP( IVAS_DEC_BS_FORMAT bsFormat = IVAS_DEC_BS_UNKOWN; IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS]; +#ifdef NONBE_UNIFIED_DECODING_PATHS + IVAS_VECTOR3 Pos[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES] = { { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } }; + int16_t vec_pos_update, vec_pos_len, i; +#if defined( SPLIT_REND_WITH_HEAD_ROT ) + uint16_t nOutSamples = 0; +#else + int16_t nOutSamples = 0; +#endif +#endif - for ( int16_t i = 0; i < IVAS_MAX_NUM_OBJECTS; ++i ) +#ifdef NONBE_UNIFIED_DECODING_PATHS + vec_pos_update = 0; + if ( arg.enableHeadRotation && arg.enable5ms ) + { + nOutSamples = (int16_t) ( arg.output_Fs / 1000 * HEADROTATION_FETCH_FRAMESIZE_MS ); + vec_pos_len = IVAS_MAX_PARAM_SPATIAL_SUBFRAMES; + } + else + { + nOutSamples = (int16_t) ( arg.output_Fs / 1000 * DEFAULT_FETCH_FRAMESIZE_MS ); + vec_pos_len = 1; + } +#endif + + for ( +#ifndef NONBE_UNIFIED_DECODING_PATHS + int16_t +#endif + i = 0; + i < IVAS_MAX_NUM_OBJECTS; ++i ) { ismWriters[i] = NULL; } @@ -2977,6 +3015,7 @@ static ivas_error decodeVoIP( while ( 1 ) { +#ifndef NONBE_UNIFIED_DECODING_PATHS #if defined( SPLIT_REND_WITH_HEAD_ROT ) uint16_t nOutSamples = 0; #else @@ -2987,6 +3026,129 @@ static ivas_error decodeVoIP( #else nOutSamples = (int16_t) ( arg.output_Fs / 1000 * JBM_FRONTEND_FETCH_FRAMESIZE_MS ); #endif +#endif + +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* reference vector */ + if ( arg.enableReferenceVectorTracking && vec_pos_update == 0 ) + { + IVAS_VECTOR3 listenerPosition, referencePosition; + if ( ( error = Vector3PairFileReader_read( referenceVectorReader, &listenerPosition, &referencePosition ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError %s while reading listener and reference positions from %s\n", IVAS_DEC_GetErrorMessage( error ), Vector3PairFileReader_getFilePath( referenceVectorReader ) ); + goto cleanup; + } + + if ( ( error = IVAS_DEC_FeedRefVectorData( hIvasDec, listenerPosition, referencePosition ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_DEC_FeedRefVectorData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + } + + /* Reference rotation */ + if ( arg.enableReferenceRotation && vec_pos_update == 0 ) + { + IVAS_QUATERNION quaternion; + if ( ( error = HeadRotationFileReading( refRotReader, &quaternion, NULL ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError %s while reading reference rotation from %s\n", IVAS_DEC_GetErrorMessage( error ), RotationFileReader_getFilePath( refRotReader ) ); + goto cleanup; + } + + if ( ( error = IVAS_DEC_FeedRefRotData( hIvasDec, quaternion ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_DEC_FeedRefRotData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + } + int16_t enable5ms, num_subframes; + IVAS_DEC_Get5msFlag( hIvasDec, &enable5ms ); + arg.enable5ms = enable5ms; + num_subframes = ( arg.enable5ms ) ? 1 : IVAS_MAX_PARAM_SPATIAL_SUBFRAMES; + + /* Head-tracking input simulation */ + /* Head-tracking input simulation */ + if ( arg.enableHeadRotation ) + { + IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; + +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( headRotReader == NULL ) + { + for ( i = 0; i < num_subframes; i++ ) + { + Quaternions[i].w = -3.0f; + Quaternions[i].x = 0.0f; + Quaternions[i].y = 0.0f; + Quaternions[i].z = 0.0f; + Pos[i].x = 0.0f; + Pos[i].y = 0.0f; + Pos[i].z = 0.0f; + } + } + else + { +#endif + for ( i = 0; i < num_subframes; i++ ) + { + if ( ( error = HeadRotationFileReading( headRotReader, &Quaternions[i], &Pos[i] ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError %s while reading head orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), + RotationFileReader_getFilePath( headRotReader ) ); + goto cleanup; + } + } +#ifdef SPLIT_REND_WITH_HEAD_ROT + } +#endif + + for ( i = 0; i < num_subframes; i++ ) + { + if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions[i], Pos[i], i +#ifdef SPLIT_REND_WITH_HEAD_ROT + , + DEFAULT_AXIS +#endif + ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_DEC_FeedHeadTrackData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + } + } + + if ( arg.enableExternalOrientation ) + { + IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; + int8_t enableHeadRotation[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; + int8_t enableExternalOrientation[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; + int8_t enableRotationInterpolation[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; + int16_t numFramesToTargetOrientation[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; + + for ( i = 0; i < num_subframes; i++ ) + { + + if ( ( error = ExternalOrientationFileReading( externalOrientationFileReader, &Quaternions[i], &enableHeadRotation[i], &enableExternalOrientation[i], &enableRotationInterpolation[i], &numFramesToTargetOrientation[i] ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError %s while reading external orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), + RotationFileReader_getFilePath( externalOrientationFileReader ) ); + goto cleanup; + } + } + for ( i = 0; i < num_subframes; i++ ) + { + if ( ( error = IVAS_DEC_FeedExternalOrientationData( hIvasDec, Quaternions[i], enableHeadRotation[i], enableExternalOrientation[i], enableRotationInterpolation[i], numFramesToTargetOrientation[i], i ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_DEC_FeedExternalOrientationData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + } + } + +#endif + + /* read all packets with a receive time smaller than the system time */ while ( nextPacketRcvTime_ms <= systemTime_ms ) { @@ -3151,8 +3313,9 @@ static ivas_error decodeVoIP( /* Write ISM metadata to external file(s) */ if ( decodedGoodFrame && arg.outputConfig == AUDIO_CONFIG_EXTERNAL ) { +#ifndef NONBE_UNIFIED_DECODING_PATHS int16_t i; - +#endif if ( bsFormat == IVAS_DEC_BS_OBJ || bsFormat == IVAS_DEC_BS_MASA_ISM ) { if ( ( error = IVAS_DEC_GetNumObjects( hIvasDec, &numObj ) ) != IVAS_ERR_OK ) @@ -3252,7 +3415,12 @@ cleanup: JbmTraceFileWriter_close( &jbmTraceWriter ); #endif MasaFileWriter_close( &masaWriter ); - for ( int16_t i = 0; i < IVAS_MAX_NUM_OBJECTS; i++ ) + for ( +#ifndef NONBE_UNIFIED_DECODING_PATHS + int16_t +#endif + i = 0; + i < IVAS_MAX_NUM_OBJECTS; i++ ) { IsmFileWriter_close( &ismWriters[i] ); } -- GitLab From 6d428d2eecfc2caade698f9dba9e4d56a03e2136 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Thu, 21 Sep 2023 15:23:37 +0200 Subject: [PATCH 04/49] add switch for deactivation of the 5ms flag and the non-JBM decoding path --- apps/decoder.c | 91 ++++++++++++++++---- lib_com/common_api_types.h | 10 +++ lib_com/options.h | 4 +- lib_dec/ivas_dirac_dec.c | 2 + lib_dec/ivas_init_dec.c | 26 +++++- lib_dec/ivas_ism_dec.c | 6 ++ lib_dec/ivas_ism_param_dec.c | 17 +++- lib_dec/ivas_jbm_dec.c | 21 +++-- lib_dec/ivas_masa_dec.c | 6 ++ lib_dec/ivas_mc_param_dec.c | 8 +- lib_dec/ivas_mc_paramupmix_dec.c | 2 + lib_dec/ivas_mct_dec.c | 4 + lib_dec/ivas_omasa_dec.c | 3 +- lib_dec/ivas_sba_dec.c | 5 +- lib_dec/ivas_spar_decoder.c | 2 + lib_dec/ivas_stat_dec.h | 3 + lib_dec/lib_dec.c | 34 +++++++- lib_rend/ivas_dirac_dec_binaural_functions.c | 2 + lib_rend/ivas_rotation.c | 4 +- lib_rend/lib_rend.c | 8 +- 20 files changed, 219 insertions(+), 39 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 23e0426ed1..62d91b9976 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -129,7 +129,11 @@ typedef struct #endif IVAS_DEC_COMPLEXITY_LEVEL complexityLevel; bool tsmEnabled; +#ifndef REMOVE_5MS_FLAG bool enable5ms; +#else + RENDER_FRAMESIZE renderFramesize; +#endif #ifdef DEBUGGING IVAS_DEC_FORCED_REND_MODE forcedRendMode; #ifdef DEBUG_FOA_AGC @@ -502,7 +506,12 @@ int main( #endif if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputConfig, - arg.tsmEnabled, arg.enable5ms, + arg.tsmEnabled, +#ifndef REMOVE_5MS_FLAG + arg.enable5ms, +#else + arg.renderFramesize, +#endif arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.enableExternalOrientation, arg.orientation_tracking, arg.renderConfigEnabled, arg.Opt_non_diegetic_pan, arg.non_diegetic_pan_gain, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); @@ -1055,7 +1064,11 @@ static bool parseCmdlIVAS_dec( arg->Opt_non_diegetic_pan = 0; arg->non_diegetic_pan_gain = 0.f; arg->tsmEnabled = false; +#ifndef REMOVE_5MS_FLAG arg->enable5ms = false; +#else + arg->renderFramesize = RENDER_FRAMESIZE_20MS; +#endif #ifdef DEBUGGING #ifdef VARIABLE_SPEED_DECODING arg->tsmScale = 100; @@ -1281,11 +1294,46 @@ static bool parseCmdlIVAS_dec( arg->headrotTrajFileName = argv[i]; i++; } +#ifndef REMOVE_5MS_FLAG else if ( strcmp( argv_to_upper, "-FR5" ) == 0 ) { arg->enable5ms = true; i++; } +#else + else if ( strcmp( argv_to_upper, "-FR" ) == 0 ) + { + int32_t tmp; + i++; + if ( i < argc - 3 ) + { + if ( !is_digits_only( argv[i] ) ) + { + return false; + } + + if ( sscanf( argv[i], "%d", &tmp ) > 0 ) + { + i++; + } + switch ( (int16_t) tmp ) + { + case 5: + arg->renderFramesize = RENDER_FRAMESIZE_5MS; + break; + case 10: + arg->renderFramesize = RENDER_FRAMESIZE_10MS; + break; + case 20: + arg->renderFramesize = RENDER_FRAMESIZE_20MS; + default: + fprintf( stderr, "Error: Invalid render frame size %d \n\n", tmp ); + usage_dec(); + return false; + } + } + } +#endif else if ( strcmp( argv_to_upper, "-OTR" ) == 0 ) { @@ -1550,10 +1598,12 @@ static bool parseCmdlIVAS_dec( return false; } +#ifndef REMOVE_5MS_FLAG if ( ( !arg->enableHeadRotation ) && ( !arg->enableExternalOrientation ) ) { arg->enable5ms = false; } +#endif return true; } @@ -1610,7 +1660,11 @@ static void usage_dec( void ) fprintf( stdout, "-VOIP_framesize : VoIP mode: acoustic frontend fetch frame size (must be multiples of 5!)\n" ); #endif #endif +#ifndef REMOVE_5MS_FLAG fprintf( stdout, "-fr5 : option to perform rendering + head-tracking with 5ms frame size\n" ); +#else + fprintf( stdout, "-fr : render frame size in ms (5,10,20, default is 20)\n" ); +#endif fprintf( stdout, "-fec_cfg_file : Optimal channel aware configuration computed by the JBM \n" ); fprintf( stdout, " as described in Section 6.3.1 of TS26.448. The output is \n" ); fprintf( stdout, " written into a .txt file. Each line contains the FER indicator \n" ); @@ -2075,6 +2129,10 @@ static ivas_error decodeG192( nSamplesAvailableNext = 0; vec_pos_update = 0; +#ifdef REMOVE_5MS_FLAG + nOutSamples = (int16_t) ( arg.output_Fs * arg.renderFramesize / 1000 * HEADROTATION_FETCH_FRAMESIZE_MS ); + vec_pos_len = (int16_t) ( IVAS_MAX_PARAM_SPATIAL_SUBFRAMES / arg.renderFramesize ); +#else if ( arg.enableHeadRotation && arg.enable5ms ) { nOutSamples = (int16_t) ( arg.output_Fs / 1000 * HEADROTATION_FETCH_FRAMESIZE_MS ); @@ -2085,7 +2143,7 @@ static ivas_error decodeG192( nOutSamples = (int16_t) ( arg.output_Fs / 1000 * DEFAULT_FETCH_FRAMESIZE_MS ); vec_pos_len = 1; } - +#endif #ifdef SPLIT_REND_WITH_HEAD_ROT splitRendBits.bits_buf = splitRendBitsBuf; splitRendBits.bits_read = 0; @@ -2141,11 +2199,15 @@ static ivas_error decodeG192( goto cleanup; } } +#ifndef REMOVE_5MS_FLAG int16_t enable5ms, num_subframes; IVAS_DEC_Get5msFlag( hIvasDec, &enable5ms ); arg.enable5ms = enable5ms; num_subframes = ( arg.enable5ms ) ? 1 : IVAS_MAX_PARAM_SPATIAL_SUBFRAMES; - +#else + int16_t num_subframes; + num_subframes = (int16_t) arg.renderFramesize; +#endif /* Head-tracking input simulation */ /* Head-tracking input simulation */ if ( arg.enableHeadRotation ) @@ -2893,16 +2955,8 @@ static ivas_error decodeVoIP( #ifdef NONBE_UNIFIED_DECODING_PATHS vec_pos_update = 0; - if ( arg.enableHeadRotation && arg.enable5ms ) - { - nOutSamples = (int16_t) ( arg.output_Fs / 1000 * HEADROTATION_FETCH_FRAMESIZE_MS ); - vec_pos_len = IVAS_MAX_PARAM_SPATIAL_SUBFRAMES; - } - else - { - nOutSamples = (int16_t) ( arg.output_Fs / 1000 * DEFAULT_FETCH_FRAMESIZE_MS ); - vec_pos_len = 1; - } + nOutSamples = (int16_t) ( arg.output_Fs * arg.renderFramesize / 1000 * HEADROTATION_FETCH_FRAMESIZE_MS ); + vec_pos_len = (int16_t) ( IVAS_MAX_PARAM_SPATIAL_SUBFRAMES / arg.renderFramesize ); #endif for ( @@ -3062,10 +3116,15 @@ static ivas_error decodeVoIP( goto cleanup; } } +#ifndef REMOVE_5MS_FLAG int16_t enable5ms, num_subframes; IVAS_DEC_Get5msFlag( hIvasDec, &enable5ms ); arg.enable5ms = enable5ms; num_subframes = ( arg.enable5ms ) ? 1 : IVAS_MAX_PARAM_SPATIAL_SUBFRAMES; +#else + int16_t num_subframes; + num_subframes = (int16_t) arg.renderFramesize; +#endif /* Head-tracking input simulation */ /* Head-tracking input simulation */ @@ -3117,7 +3176,7 @@ static ivas_error decodeVoIP( } } } - + if ( arg.enableExternalOrientation ) { IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; @@ -3364,7 +3423,9 @@ static ivas_error decodeVoIP( { fprintf( stdout, "%-8d\b\b\b\b\b\b\b\b", frame ); } - +#ifdef NONBE_UNIFIED_DECODING_PATHS + vec_pos_update = ( vec_pos_update + 1 ) % vec_pos_len; +#endif frame++; systemTime_ms += systemTimeInc_ms; diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 8e4a1d0e13..589474b2a0 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -198,6 +198,16 @@ typedef enum HEAD_ORIENT_TRK_REF_VEC_LEV } HEAD_ORIENT_TRK_T; +#ifdef REMOVE_5MS_FLAG +typedef enum +{ + RENDER_FRAMESIZE_UNKNOWN = 0, + RENDER_FRAMESIZE_5MS = 1, + RENDER_FRAMESIZE_10MS = 2, + RENDER_FRAMESIZE_20MS = 4 +} RENDER_FRAMESIZE; +#endif + typedef struct ivas_masa_metadata_frame_struct *IVAS_MASA_METADATA_HANDLE; typedef struct ivas_masa_decoder_ext_out_meta_struct *MASA_DECODER_EXT_OUT_META_HANDLE; diff --git a/lib_com/options.h b/lib_com/options.h index ae43962cf5..6ccda0acd3 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -168,7 +168,9 @@ #define NONBE_FIX_736_FOA_BR_SWITCH /* FhG/Dlb : Issue 736: FOA bitrate switching decoding crashes in in ivas_spar_to_dirac */ #define NONBE_FIX_746_NONDIEGETIC_MD /* Eri: Issue 746: The non-diegetic panning flag affects the encoder bitstream even if extended metadata is not enabled. Crashes the decoder.*/ #define NONBE_UNIFIED_DECODING_PATHS /* FhG: unify decoding paths */ - +#ifdef NONBE_UNIFIED_DECODING_PATHS +#define REMOVE_5MS_FLAG +#endif /* ##################### End NON-BE switches ############################# */ /* ################## End DEVELOPMENT switches ######################### */ diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 6c49fe3697..64f0112b29 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -975,7 +975,9 @@ ivas_error ivas_dirac_dec_config( if ( dec_config_flag == DIRAC_OPEN ) { if ( +#ifndef REMOVE_5MS_FLAG st_ivas->hDecoderConfig->Opt_5ms && +#endif st_ivas->hTcBuffer == NULL ) { if ( st_ivas->ivas_format == SBA_FORMAT ) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index b41ba8b0c3..805aee6216 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -994,7 +994,12 @@ ivas_error ivas_init_decoder_front( if ( st_ivas->hDecoderConfig->Opt_ExternalOrientation ) { if ( ( error = ivas_external_orientation_open( &( st_ivas->hExtOrientationData ), - ( st_ivas->hDecoderConfig->Opt_5ms ) ? 1 : MAX_PARAM_SPATIAL_SUBFRAMES ) ) != IVAS_ERR_OK ) +#ifdef REMOVE_5MS_FLAG + st_ivas->hDecoderConfig->render_framesize +#else + ( st_ivas->hDecoderConfig->Opt_5ms ) ? 1 : MAX_PARAM_SPATIAL_SUBFRAMES +#endif + ) ) != IVAS_ERR_OK ) { return error; } @@ -1010,7 +1015,12 @@ ivas_error ivas_init_decoder_front( #ifdef NONBE_UNIFIED_DECODING_PATHS st_ivas->hDecoderConfig->output_Fs, #endif - ( st_ivas->hDecoderConfig->Opt_5ms ) ? 1 : MAX_PARAM_SPATIAL_SUBFRAMES ) ) != IVAS_ERR_OK ) +#ifdef REMOVE_5MS_FLAG + st_ivas->hDecoderConfig->render_framesize +#else + ( st_ivas->hDecoderConfig->Opt_5ms ) ? 1 : MAX_PARAM_SPATIAL_SUBFRAMES +#endif + ) ) != IVAS_ERR_OK ) { return error; } @@ -1940,8 +1950,9 @@ ivas_error ivas_init_decoder( } } - +#ifndef REMOVE_5MS_FLAG if ( st_ivas->hDecoderConfig->Opt_5ms ) +#endif { granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); @@ -1989,7 +2000,9 @@ ivas_error ivas_init_decoder( st_ivas->binaural_latency_ns = st_ivas->hCrendWrapper->binaural_latency_ns; +#ifndef REMOVE_5MS_FLAG if ( st_ivas->hDecoderConfig->Opt_5ms ) +#endif { if ( ( st_ivas->ivas_format == MC_FORMAT ) && ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) ) { @@ -2164,7 +2177,9 @@ ivas_error ivas_init_decoder( * Allocate and initialize JBM struct + buffer *-----------------------------------------------------------------*/ if ( +#ifndef REMOVE_5MS_FLAG st_ivas->hDecoderConfig->Opt_5ms && +#endif st_ivas->hTcBuffer == NULL ) { @@ -2200,8 +2215,9 @@ ivas_error ivas_init_decoder( /*-----------------------------------------------------------------* * Allocate floating-point output audio buffers *-----------------------------------------------------------------*/ - +#ifndef REMOVE_5MS_FLAG if ( !st_ivas->hDecoderConfig->Opt_5ms ) +#endif { for ( n = 0; n < ivas_get_nchan_buffers_dec( st_ivas ); n++ ) { @@ -2212,10 +2228,12 @@ ivas_error ivas_init_decoder( } } } +#ifndef REMOVE_5MS_FLAG else { n = 0; } +#endif for ( ; n < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; n++ ) { diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index d83fd7ff07..aacef6bcd8 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -127,7 +127,9 @@ static ivas_error ivas_ism_bitrate_switching_dec( ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->hDecoderConfig->output_config ); } +#ifndef REMOVE_5MS_FLAG if ( st_ivas->hDecoderConfig->Opt_5ms ) +#endif { /* transfer subframe info from DirAC or ParamMC to central tc buffer */ if ( last_ism_mode == ISM_MODE_PARAM && st_ivas->hSpatParamRendCom != NULL && ( st_ivas->renderer_type != RENDERER_MONO_DOWNMIX && st_ivas->renderer_type != RENDERER_DISABLE ) ) @@ -339,7 +341,9 @@ static ivas_error ivas_ism_bitrate_switching_dec( * floating-point output audio buffers *-----------------------------------------------------------------*/ +#ifndef REMOVE_5MS_FLAG if ( !st_ivas->hDecoderConfig->Opt_5ms ) +#endif { nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas ); @@ -367,7 +371,9 @@ static ivas_error ivas_ism_bitrate_switching_dec( /*-----------------------------------------------------------------* * Reconfigure TC buffer *-----------------------------------------------------------------*/ +#ifndef REMOVE_5MS_FLAG if ( st_ivas->hDecoderConfig->Opt_5ms ) +#endif { int16_t tc_nchan_full_new; DECODER_TC_BUFFER_HANDLE hTcBuffer; diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index bf60d8c4d3..34a0527a15 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -590,7 +590,9 @@ ivas_error ivas_param_ism_dec_open( st_ivas->hDirAC = hDirAC; st_ivas->hSpatParamRendCom = hSpatParamRendCom; +#ifndef REMOVE_5MS_FLAG if ( st_ivas->hDecoderConfig->Opt_5ms ) +#endif { if ( st_ivas->renderer_type != RENDERER_MONO_DOWNMIX && st_ivas->renderer_type != RENDERER_DISABLE ) { @@ -648,12 +650,13 @@ ivas_error ivas_param_ism_dec_open( } } } +#ifndef REMOVE_5MS_FLAG else { hDirAC->hParamIsmRendering->Cldfb_RealBuffer_tc = NULL; hDirAC->hParamIsmRendering->Cldfb_ImagBuffer_tc = NULL; } - +#endif pop_wmops(); return error; } @@ -1195,7 +1198,11 @@ void ivas_param_ism_dec_digest_tc( } } } - if ( st_ivas->hDecoderConfig->Opt_tsm || !st_ivas->hDecoderConfig->Opt_5ms ) + if ( st_ivas->hDecoderConfig->Opt_tsm +#ifndef REMOVE_5MS_FLAG + || !st_ivas->hDecoderConfig->Opt_5ms +#endif + ) { /*TODO : FhG to check*/ ivas_ism_param_dec_tc_gain_ajust( st_ivas, output_frame, fade_len, transport_channels_f ); @@ -1208,7 +1215,11 @@ void ivas_param_ism_dec_digest_tc( *-----------------------------------------------------------------*/ for ( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) { - if ( st_ivas->hDecoderConfig->Opt_tsm || !st_ivas->hDecoderConfig->Opt_5ms ) + if ( st_ivas->hDecoderConfig->Opt_tsm +#ifndef REMOVE_5MS_FLAG + || !st_ivas->hDecoderConfig->Opt_5ms +#endif + ) { float RealBuffer[CLDFB_NO_CHANNELS_MAX]; diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index e2c90f98f7..478a4a4b7f 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -603,7 +603,11 @@ ivas_error ivas_jbm_dec_tc( /*----------------------------------------------------------------* * Write IVAS transport channels *----------------------------------------------------------------*/ - if ( st_ivas->hDecoderConfig->Opt_tsm == 1 || !st_ivas->hDecoderConfig->Opt_5ms ) + if ( st_ivas->hDecoderConfig->Opt_tsm == 1 +#ifndef REMOVE_5MS_FLAG + || !st_ivas->hDecoderConfig->Opt_5ms +#endif + ) { ivas_syn_output_f( p_output, output_frame, st_ivas->hTcBuffer->nchan_transport_jbm, data ); } @@ -677,7 +681,11 @@ ivas_error ivas_jbm_dec_feed_tc_to_renderer( { p_data_f[n] = &data_f[n][0]; } - if ( st_ivas->hDecoderConfig->Opt_tsm || !st_ivas->hDecoderConfig->Opt_5ms ) + if ( st_ivas->hDecoderConfig->Opt_tsm +#ifndef REMOVE_5MS_FLAG + || !st_ivas->hDecoderConfig->Opt_5ms +#endif + ) { ivas_jbm_dec_copy_tc( st_ivas, nSamplesForRendering, nSamplesResidual, data, p_data_f ); } @@ -835,9 +843,12 @@ ivas_error ivas_jbm_dec_render( return error; } #else - /* take the discard samples into account here to make sure head rotation stays on the correct 5ms grid */ - st_ivas->hCombinedOrientationData->cur_subframe_samples_rendered_start -= st_ivas->hTcBuffer->n_samples_discard; - ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData ); + if ( st_ivas->hCombinedOrientationData != NULL ) + { + /* take the discard samples into account here to make sure head rotation stays on the correct 5ms grid */ + st_ivas->hCombinedOrientationData->cur_subframe_samples_rendered_start -= st_ivas->hTcBuffer->n_samples_discard; + ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData ); + } #endif /*----------------------------------------------------------------* diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index c5a7c881be..bd82f29f33 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -623,7 +623,9 @@ ivas_error ivas_masa_dec_open( /* allocate transport channels*/ if ( +#ifndef REMOVE_5MS_FLAG st_ivas->hDecoderConfig->Opt_5ms && +#endif st_ivas->hTcBuffer == NULL && st_ivas->renderer_type != RENDERER_DISABLE && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM && st_ivas->renderer_type != RENDERER_STEREO_PARAMETRIC ) { int16_t nchan_to_allocate; @@ -1252,7 +1254,9 @@ ivas_error ivas_masa_dec_reconfigure( ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; last_ivas_total_brate = st_ivas->hDecoderConfig->last_ivas_total_brate; +#ifndef REMOVE_5MS_FLAG if ( st_ivas->hDecoderConfig->Opt_5ms == 1 ) +#endif { if ( st_ivas->hSpatParamRendCom != NULL && st_ivas->hSpatParamRendCom->slot_size == st_ivas->hTcBuffer->n_samples_granularity ) { @@ -1445,7 +1449,9 @@ ivas_error ivas_masa_dec_reconfigure( st_ivas->ism_mode = ISM_MODE_NONE; } +#ifndef REMOVE_5MS_FLAG if ( st_ivas->hDecoderConfig->Opt_5ms == 1 ) +#endif { int16_t tc_nchan_to_allocate; int16_t tc_nchan_transport; diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index ec7e423153..f4293b1893 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -460,7 +460,9 @@ ivas_error ivas_param_mc_dec_open( ivas_param_mc_dec_init( hParamMC, nchan_transport, nchan_out_cov ); if ( +#ifndef REMOVE_5MS_FLAG st_ivas->hDecoderConfig->Opt_5ms && +#endif hParamMC->synthesis_conf != PARAM_MC_SYNTH_MONO_STEREO ) { int16_t n_cldfb_slots; @@ -1473,7 +1475,11 @@ void ivas_param_mc_dec_digest_tc( /* slot loop for gathering the input data */ for ( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) { - if ( st_ivas->hDecoderConfig->Opt_tsm || !st_ivas->hDecoderConfig->Opt_5ms ) + if ( st_ivas->hDecoderConfig->Opt_tsm +#ifndef REMOVE_5MS_FLAG + || !st_ivas->hDecoderConfig->Opt_5ms +#endif + ) { float RealBuffer[CLDFB_NO_CHANNELS_MAX]; float ImagBuffer[CLDFB_NO_CHANNELS_MAX]; diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index 3a6160763a..108d4614cc 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -671,7 +671,9 @@ ivas_error ivas_mc_paramupmix_dec_open( hMCParamUpmix->free_param_interpolator = 0; hMCParamUpmix->param_interpolator = NULL; if ( +#ifndef REMOVE_5MS_FLAG st_ivas->hDecoderConfig->Opt_5ms == 1 && +#endif st_ivas->hTcBuffer == NULL ) { int16_t nchan_to_allocate; diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 9072d8a1b7..222bf88c75 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -755,7 +755,9 @@ static ivas_error ivas_mc_dec_reconfig( /* side effect of the renderer selection can be a changed internal config */ ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->intern_config ); +#ifndef REMOVE_5MS_FLAG if ( st_ivas->hDecoderConfig->Opt_5ms ) +#endif { /* transfer subframe info from DirAC or ParamMC to central tc buffer */ if ( last_mc_mode == MC_MODE_PARAMMC ) @@ -1302,7 +1304,9 @@ static ivas_error ivas_mc_dec_reconfig( /*-----------------------------------------------------------------* * Reconfigure TC buffer *-----------------------------------------------------------------*/ +#ifndef REMOVE_5MS_FLAG if ( st_ivas->hDecoderConfig->Opt_5ms == 1 ) +#endif { int16_t tc_nchan_full_new; DECODER_TC_BUFFER_HANDLE hTcBuffer; diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index 46db456dd8..d727de7de7 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -411,8 +411,9 @@ ivas_error ivas_omasa_dec_config( /*-----------------------------------------------------------------* * floating-point output audio buffers *-----------------------------------------------------------------*/ - +#ifndef REMOVE_5MS_FLAG if ( !st_ivas->hDecoderConfig->Opt_5ms ) +#endif { nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas ); diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 8516dd9f74..9fb9fb26db 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -510,7 +510,9 @@ ivas_error ivas_sba_dec_reconfigure( /*-----------------------------------------------------------------* * JBM TC buffer *-----------------------------------------------------------------*/ +#ifndef REMOVE_5MS_FLAG if ( st_ivas->hDecoderConfig->Opt_5ms == 1 ) +#endif { int16_t tc_nchan_to_allocate; int16_t tc_nchan_tc; @@ -553,8 +555,9 @@ ivas_error ivas_sba_dec_reconfigure( /*-----------------------------------------------------------------* * floating-point output audio buffers *-----------------------------------------------------------------*/ - +#ifndef REMOVE_5MS_FLAG if ( !st_ivas->hDecoderConfig->Opt_5ms ) +#endif { nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas ); diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 3c11388bcf..5849232de4 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -217,7 +217,9 @@ ivas_error ivas_spar_dec_open( /* allocate transport channels*/ if ( +#ifndef REMOVE_5MS_FLAG st_ivas->hDecoderConfig->Opt_5ms && +#endif st_ivas->hTcBuffer == NULL ) { int16_t nchan_to_allocate; diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index e70403488d..94562555db 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -911,6 +911,9 @@ typedef struct decoder_config_structure int16_t Opt_tsm; #ifdef SPLIT_REND_WITH_HEAD_ROT int16_t Opt_Limiter; +#endif +#ifdef REMOVE_5MS_FLAG + RENDER_FRAMESIZE render_framesize; #endif int16_t Opt_5ms; int16_t Opt_delay_comp; /* flag indicating delay compensation active */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 215cf6e3d3..0f90f4a270 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -276,8 +276,9 @@ static void init_decoder_config( #ifdef SPLIT_REND_WITH_HEAD_ROT hDecoderConfig->Opt_Limiter = 1; #endif +#ifndef REMOVE_5MS_FLAG hDecoderConfig->Opt_5ms = 0; - +#endif hDecoderConfig->Opt_delay_comp = 0; hDecoderConfig->Opt_ExternalOrientation = 0; @@ -375,7 +376,11 @@ ivas_error IVAS_DEC_Configure( const uint32_t sampleRate, /* i : output sampling frequency */ const AUDIO_CONFIG outputConfig, /* i : output configuration */ const int16_t tsmEnabled, /* i : enable TSM */ +#ifndef REMOVE_5MS_FLAG const int16_t enable5ms, +#else + const RENDER_FRAMESIZE renderFramesize, +#endif const int16_t customLsOutputEnabled, /* i : enable custom loudspeaker setup handle */ const int16_t hrtfReaderEnabled, /* i : enable HRTF binary file input */ const int16_t enableHeadRotation, /* i : enable head rotation for binaural output */ @@ -440,6 +445,13 @@ ivas_error IVAS_DEC_Configure( hDecoderConfig->non_diegetic_pan_gain = non_diegetic_pan_gain; hDecoderConfig->Opt_delay_comp = delayCompensationEnabled; hDecoderConfig->Opt_ExternalOrientation = enableExternalOrientation; +#ifdef REMOVE_5MS_FLAG + if ( renderFramesize == RENDER_FRAMESIZE_UNKNOWN ) + { + return IVAS_ERR_WRONG_PARAMS; + } + hDecoderConfig->render_framesize = renderFramesize; +#endif /* Set decoder parameters to initial values */ if ( ( error = ivas_init_decoder_front( st_ivas ) ) != IVAS_ERR_OK ) @@ -453,7 +465,10 @@ ivas_error IVAS_DEC_Configure( } hDecoderConfig->Opt_tsm = tsmEnabled; +#ifndef REMOVE_5MS_FLAG hDecoderConfig->Opt_5ms = enable5ms; +#endif + hIvasDec->nSamplesFrame = (uint16_t) ( hDecoderConfig->output_Fs / FRAMES_PER_SEC ); hIvasDec->nSamplesAvailableNext = 0; hIvasDec->nSamplesRendered = 0; @@ -497,6 +512,7 @@ ivas_error IVAS_DEC_EnableSplitRendering( } #endif +#ifndef REMOVE_5MS_FLAG /*---------------------------------------------------------------------* * IVAS_DEC_Get5msFlag( ) * @@ -517,6 +533,7 @@ ivas_error IVAS_DEC_Get5msFlag( return IVAS_ERR_OK; } +#endif /*---------------------------------------------------------------------* * IVAS_DEC_EnableVoIP( ) @@ -547,8 +564,9 @@ ivas_error IVAS_DEC_EnableVoIP( hIvasDec->Opt_VOIP = 1; hDecoderConfig->Opt_tsm = 1; +#ifndef REMOVE_5MS_FLAG hDecoderConfig->Opt_5ms = 1; - +#endif if ( hDecoderConfig->output_config != AUDIO_CONFIG_EXTERNAL ) { hDecoderConfig->nchan_out = audioCfg2channels( hDecoderConfig->output_config ); @@ -696,6 +714,7 @@ ivas_error IVAS_DEC_FeedFrame_Serial( * Main function to decode to PCM data *---------------------------------------------------------------------*/ +#ifndef REMOVE_5MS_FLAG static ivas_error _GetSamples( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ #if defined SPLIT_REND_WITH_HEAD_ROT @@ -759,6 +778,8 @@ static ivas_error _GetSamples( return error; } +#endif + ivas_error IVAS_DEC_GetSamples( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ const int16_t nSamplesAsked, /* i: number of samples wanted by the caller */ @@ -850,6 +871,7 @@ ivas_error IVAS_DEC_GetSamples( /* :TODO: change nSamplesAsked also if we are in 5ms 0dof split rendering... */ #endif } +#ifndef REMOVE_5MS_FLAG if ( !hIvasDec->st_ivas->hDecoderConfig->Opt_5ms ) { if ( ( error = _GetSamples( hIvasDec, @@ -871,6 +893,7 @@ ivas_error IVAS_DEC_GetSamples( *needNewFrame = true; } else +#endif { /* check if we need to run the setup function, tc decoding and feeding the renderer */ if ( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) @@ -2906,6 +2929,7 @@ static ivas_error printConfigInfo_dec( { fprintf( stdout, "TSM mode: ON\n" ); } +#ifndef REMOVE_5MS_FLAG /*-----------------------------------------------------------------* * Print 5ms API mode info *-----------------------------------------------------------------*/ @@ -2913,6 +2937,7 @@ static ivas_error printConfigInfo_dec( { fprintf( stdout, "API 5ms mode: ON\n" ); } +#endif return IVAS_ERR_OK; } @@ -3087,7 +3112,10 @@ static ivas_error evs_dec_main( } - if ( !st_ivas->hDecoderConfig->Opt_tsm && st_ivas->hDecoderConfig->Opt_5ms + if ( !st_ivas->hDecoderConfig->Opt_tsm +#ifndef REMOVE_5MS_FLAG + && st_ivas->hDecoderConfig->Opt_5ms +#endif ) { diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 0c7b88e4af..c868e73b22 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -314,7 +314,9 @@ ivas_error ivas_dirac_dec_init_binaural_data( /* allocate transport channels*/ if ( +#ifndef REMOVE_5MS_FLAG st_ivas->hDecoderConfig->Opt_5ms && +#endif st_ivas->hTcBuffer == NULL ) { int16_t nchan_to_allocate; diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index fb0a94d7f7..9c53829885 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -1408,7 +1408,7 @@ void external_target_interpolation( { if ( i > 0 ) { -#ifdef NONBE_UNIFIED_DECODING_PATHS +#ifdef NONBE_UNIFIED_DECODING_PATHS_1 if ( hExtOrientationData->enableExternalOrientation[i - 1] != 1 ) { IVAS_QUATERNION identity; @@ -1755,7 +1755,7 @@ ivas_error ivas_combined_orientation_update_index( hCombinedOrientationData->cur_subframe_samples_rendered += samples_rendered; hCombinedOrientationData->subframe_idx += hCombinedOrientationData->cur_subframe_samples_rendered / hCombinedOrientationData->subframe_size; hCombinedOrientationData->cur_subframe_samples_rendered = hCombinedOrientationData->cur_subframe_samples_rendered % hCombinedOrientationData->subframe_size; - hCombinedOrientationData->subframe_idx = max( hCombinedOrientationData->subframe_idx, hCombinedOrientationData->num_subframes - 1 ); + hCombinedOrientationData->subframe_idx = min( hCombinedOrientationData->subframe_idx, hCombinedOrientationData->num_subframes - 1 ); } } return error; diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 8ee65fee94..3fef9f5520 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -3193,7 +3193,9 @@ static DecoderDummy *initDecoderDummy( decDummy->hDecoderConfig->nchan_out = numOutChannels; decDummy->hDecoderConfig->Opt_Headrotation = 0; decDummy->hDecoderConfig->Opt_tsm = 0; +#ifndef REMOVE_5MS_FLAG decDummy->hDecoderConfig->Opt_5ms = 0; +#endif decDummy->hBinRenderer = NULL; #ifdef SPLIT_REND_WITH_HEAD_ROT decDummy->hSplitBinRend.hSplitRendBits = NULL; @@ -7099,7 +7101,7 @@ static ivas_error renderInputMc( #ifdef NONBE_UNIFIED_DECODING_PATHS /* set combined orientation subframe info to start info */ - ivas_combined_orientation_set_to_start_index( *(mcInput->base.ctx.pCombinedOrientationData) ); + ivas_combined_orientation_set_to_start_index( *( mcInput->base.ctx.pCombinedOrientationData ) ); #endif switch ( getAudioConfigType( outConfig ) ) @@ -8019,7 +8021,7 @@ static ivas_error renderInputSba( #ifdef NONBE_UNIFIED_DECODING_PATHS /* set combined orientation subframe info to start info */ - ivas_combined_orientation_set_to_start_index( *(sbaInput->base.ctx.pCombinedOrientationData) ); + ivas_combined_orientation_set_to_start_index( *( sbaInput->base.ctx.pCombinedOrientationData ) ); #endif @@ -8418,7 +8420,7 @@ static ivas_error renderInputMasa( #ifdef NONBE_UNIFIED_DECODING_PATHS /* set combined orientation subframe info to start info */ - ivas_combined_orientation_set_to_start_index( *(masaInput->base.ctx.pCombinedOrientationData) ); + ivas_combined_orientation_set_to_start_index( *( masaInput->base.ctx.pCombinedOrientationData ) ); #endif switch ( getAudioConfigType( outConfig ) ) -- GitLab From aa2404ba90b050095f28ad4121e6e590f9174977 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Thu, 21 Sep 2023 16:27:01 +0200 Subject: [PATCH 05/49] fix a few remaining merge problems --- apps/decoder.c | 2 +- lib_dec/ivas_binRenderer_internal.c | 4 +++- lib_dec/ivas_jbm_dec.c | 6 +++--- lib_dec/lib_dec.c | 13 +++++-------- lib_rend/lib_rend.c | 2 +- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index e2a14f62fe..3f78b589ea 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -2955,7 +2955,7 @@ static ivas_error decodeVoIP( IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS]; #ifdef NONBE_UNIFIED_DECODING_PATHS IVAS_VECTOR3 Pos[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES] = { { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } }; - int16_t vec_pos_update, vec_pos_len, i; + int16_t vec_pos_update, vec_pos_len; #if defined( SPLIT_REND_WITH_HEAD_ROT ) uint16_t nOutSamples = 0; #else diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index 3d211ed9d6..95a753ea8e 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -1650,12 +1650,14 @@ void ivas_binaural_cldfb( st_ivas->hCombinedOrientationData, #ifndef NONBE_UNIFIED_DECODING_PATHS subframeIdx, -#endif JBM_CLDFB_SLOTS_IN_SUBFRAME, +#endif + JBM_CLDFB_SLOTS_IN_SUBFRAME, #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG NULL, #endif Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); + #ifdef SPLIT_REND_WITH_HEAD_ROT if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 4c12f58627..5bfe5e0879 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -935,7 +935,7 @@ ivas_error ivas_jbm_dec_render( /* Binaural rendering */ if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { - if ( ( ivas_td_binaural_renderer_sf( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) { return error; } @@ -1054,7 +1054,7 @@ ivas_error ivas_jbm_dec_render( } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { - if ( ( ivas_td_binaural_renderer_sf( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) { return error; } @@ -1107,7 +1107,7 @@ ivas_error ivas_jbm_dec_render( } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { - if ( ( ivas_td_binaural_renderer( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_td_binaural_renderer( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index e765069b56..983fa73899 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -375,12 +375,12 @@ ivas_error IVAS_DEC_Configure( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ const uint32_t sampleRate, /* i : output sampling frequency */ const AUDIO_CONFIG outputConfig, /* i : output configuration */ + const int16_t tsmEnabled, /* i : enable time scale modification */ #ifndef REMOVE_5MS_FLAG - const int16_t enable5ms, + const int16_t enable5ms, /* i : enable 5ms rendering path */ #else - const RENDER_FRAMESIZE renderFramesize, + const RENDER_FRAMESIZE renderFramesize, /* i : rendering frame size */ #endif - const int16_t enable5ms, /* i : enable 5ms rendering path */ const int16_t customLsOutputEnabled, /* i : enable custom loudspeaker setup handle */ const int16_t hrtfReaderEnabled, /* i : enable HRTF binary file input */ const int16_t enableHeadRotation, /* i : enable head rotation for binaural output */ @@ -443,7 +443,9 @@ ivas_error IVAS_DEC_Configure( } hDecoderConfig->Opt_tsm = tsmEnabled; +#ifndef REMOVE_5MS_FLAG hDecoderConfig->Opt_5ms = enable5ms; +#endif hDecoderConfig->Opt_LsCustom = customLsOutputEnabled; hDecoderConfig->Opt_Headrotation = enableHeadRotation; hDecoderConfig->orientation_tracking = orientation_tracking; @@ -485,11 +487,6 @@ ivas_error IVAS_DEC_Configure( hIvasDec->st_ivas->ivas_format = MONO_FORMAT; } - hDecoderConfig->Opt_tsm = tsmEnabled; -#ifndef REMOVE_5MS_FLAG - hDecoderConfig->Opt_5ms = enable5ms; -#endif - hIvasDec->nSamplesFrame = (uint16_t) ( hDecoderConfig->output_Fs / FRAMES_PER_SEC ); hIvasDec->nSamplesAvailableNext = 0; hIvasDec->nSamplesRendered = 0; diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 75cea2e458..f6850dc195 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -3306,7 +3306,7 @@ static DecoderDummy *initDecoderDummy( #ifdef NONBE_UNIFIED_DECODING_PATHS sampleRate, #endif - num_subframes ) ) != IVAS_ERR_OK ) != IVAS_ERR_OK ) + num_subframes ) ) != IVAS_ERR_OK ) { assert( error == IVAS_ERR_OK ); } -- GitLab From 50305462e2738755920007453998456a6f188a9e Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Mon, 25 Sep 2023 12:20:24 +0200 Subject: [PATCH 06/49] temp fix for MC RS, unified usage of allocated output channels (decoding and tc buffers) for non-TSM operation (deactivated) --- lib_com/ivas_prot.h | 33 +- lib_com/options.h | 3 +- lib_dec/ivas_dirac_dec.c | 7 +- lib_dec/ivas_init_dec.c | 27 +- lib_dec/ivas_ism_dec.c | 13 + lib_dec/ivas_ism_param_dec.c | 7 +- lib_dec/ivas_jbm_dec.c | 390 ++++++++++++++++--- lib_dec/ivas_masa_dec.c | 21 +- lib_dec/ivas_mc_param_dec.c | 2 + lib_dec/ivas_mc_paramupmix_dec.c | 22 +- lib_dec/ivas_mct_dec.c | 28 +- lib_dec/ivas_sba_dec.c | 9 + lib_dec/ivas_spar_decoder.c | 3 + lib_rend/ivas_dirac_dec_binaural_functions.c | 3 +- lib_rend/ivas_rotation.c | 10 - 15 files changed, 494 insertions(+), 84 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index c19a3ecf43..c812692554 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -844,6 +844,12 @@ void ivas_jbm_dec_get_md_map( int16_t ivas_jbm_dec_get_num_tc_channels( Decoder_Struct *st_ivas /* i : IVAS decoder handle */ +#ifdef UNIFY_CHANNEL_MEM_HEAP + , + int16_t *nchan_transport_jbm, /* o : number of TSM channels */ + int16_t *nchan_transport_internal, /* o : number of internal channels (i.e. plus e.g. addtl. decorr */ + int16_t *nchan_transport_full /* o : number of channels to allocate fully */ +#endif ); void ivas_jbm_dec_copy_tc_no_tsm( @@ -866,10 +872,14 @@ TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( /*! r: render granularity */ int16_t ivas_jbm_dec_get_render_granularity( - const RENDERER_TYPE rendererType, /* i : renderer type */ - const IVAS_FORMAT ivas_format, /* i : ivas format */ - const MC_MODE mc_mode, /* i : MC mode */ - const int32_t output_Fs /* i : sampling rate */ +#ifdef UNIFY_CHANNEL_MEM_HEAP + Decoder_Struct *st_ivas /* i : main decoder structure */ +#else + const RENDERER_TYPE rendererType, /* i : renderer type */ + const IVAS_FORMAT ivas_format, /* i : ivas format */ + const MC_MODE mc_mode, /* i : MC mode */ + const int32_t output_Fs /* i : sampling rate */ +#endif ); ivas_error ivas_jbm_dec_tc_buffer_open( @@ -882,12 +892,15 @@ ivas_error ivas_jbm_dec_tc_buffer_open( ); ivas_error ivas_jbm_dec_tc_buffer_reconfigure( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const TC_BUFFER_MODE tc_buffer_mode, /* i : new buffer mode */ - const int16_t nchan_transport_jbm, /* i : new number of real transport channels */ - const int16_t nchan_transport_internal, /* i : new number of totally buffered channels */ - const int16_t nchan_full, /* i : new number of channels to fully store */ - const int16_t n_samples_granularity /* i : new granularity of the renderer/buffer */ + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +#ifndef UNIFY_CHANNEL_MEM_HEAP + , + const TC_BUFFER_MODE tc_buffer_mode, /* i : new buffer mode */ + const int16_t nchan_transport_jbm, /* i : new number of real transport channels */ + const int16_t nchan_transport_internal, /* i : new number of totally buffered channels */ + const int16_t nchan_full, /* i : new number of channels to fully store */ + const int16_t n_samples_granularity /* i : new granularity of the renderer/buffer */ +#endif ); void ivas_jbm_dec_tc_buffer_close( diff --git a/lib_com/options.h b/lib_com/options.h index 9820fbbbb3..a6c3d17b60 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -197,10 +197,11 @@ #define NONBE_FIX_752_OSBA_MISCONFIG_MCT /* FhG: issue 752: misconfiguration of MCT causes crashes for coding with sampling rate under 48kHz at 256kbps*/ #define NONBE_FIX_727_MC_PARAMUPMIX_HEADROTATION /* Dlb : issue 727 : headrotation in MC paramupmix mode*/ #define NONBE_FIX_779_ISM_FREE_REVERB_HANDLE /* VA: issue 779: fix Crash in ISM rate switching with BINAURAL_ROOM_REVERB */ - #define NONBE_UNIFIED_DECODING_PATHS /* FhG: unify decoding paths */ #ifdef NONBE_UNIFIED_DECODING_PATHS #define REMOVE_5MS_FLAG +#define FIX_XXX_JBM_PARAMUPMIX_RS +/*#define UNIFY_CHANNEL_MEM_HEAP*/ #endif #define NONBE_FIX_722_MEMORY_LEAK_IN_PARAMUPMIX /* Dlb : issue 722: memory leak fix in MC param upmix mode with BR switching*/ #define NONBE_FIX_780_ISM_STARTS_WITH_SID /* VA: issue 780: fix Crash in ISM decoding when bitstream starts with an SID and output_config is not EXT */ diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 3d5527b4fb..79c1588e18 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -957,6 +957,7 @@ ivas_error ivas_dirac_dec_config( } } +#if 0 /* Allocate transport channel buffers for SBA format when in JBM */ if ( dec_config_flag == DIRAC_OPEN ) { @@ -989,7 +990,7 @@ ivas_error ivas_dirac_dec_config( } } } - +#endif return error; } @@ -2469,11 +2470,11 @@ void ivas_dirac_dec_render_sf( #ifndef NONBE_UNIFIED_DECODING_PATHS subframe_idx, #endif - hSpatParamRendCom->subframe_nbslots[subframe_idx], + hSpatParamRendCom->subframe_nbslots[subframe_idx], #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG NULL, #endif -Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); + Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); #ifdef SPLIT_REND_WITH_HEAD_ROT if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 07bed88968..d205af3bfd 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1098,7 +1098,9 @@ ivas_error ivas_init_decoder( int16_t i, n, k; int16_t sce_id, cpe_id; int16_t numCldfbAnalyses, numCldfbSyntheses; +#ifndef UNIFY_CHANNEL_MEM_HEAP int16_t granularity, n_channels_transport_jbm; +#endif int32_t output_Fs, ivas_total_brate; int32_t binauralization_delay_ns; AUDIO_CONFIG output_config; @@ -1967,6 +1969,7 @@ ivas_error ivas_init_decoder( } } +#ifndef UNIFY_CHANNEL_MEM_HEAP #ifndef REMOVE_5MS_FLAG if ( st_ivas->hDecoderConfig->Opt_5ms ) #endif @@ -1979,6 +1982,7 @@ ivas_error ivas_init_decoder( return error; } } +#endif } else if ( st_ivas->renderer_type == RENDERER_MC ) { @@ -2017,6 +2021,7 @@ ivas_error ivas_init_decoder( st_ivas->binaural_latency_ns = st_ivas->hCrendWrapper->binaural_latency_ns; +#ifndef UNIFY_CHANNEL_MEM_HEAP #ifndef REMOVE_5MS_FLAG if ( st_ivas->hDecoderConfig->Opt_5ms ) #endif @@ -2044,6 +2049,7 @@ ivas_error ivas_init_decoder( } } } +#endif } if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) @@ -2192,6 +2198,7 @@ ivas_error ivas_init_decoder( return error; } +#ifndef UNIFY_CHANNEL_MEM_HEAP /*-----------------------------------------------------------------* * Allocate and initialize JBM struct + buffer *-----------------------------------------------------------------*/ @@ -2200,8 +2207,6 @@ ivas_error ivas_init_decoder( st_ivas->hDecoderConfig->Opt_5ms && #endif st_ivas->hTcBuffer == NULL ) - - if ( st_ivas->hDecoderConfig->Opt_5ms && st_ivas->hTcBuffer == NULL ) { /* no module has yet open the TC buffer, open a default one */ n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); @@ -2220,6 +2225,7 @@ ivas_error ivas_init_decoder( return error; } } +#endif if ( st_ivas->hJbmMetadata == NULL ) { @@ -2260,6 +2266,23 @@ ivas_error ivas_init_decoder( st_ivas->p_output_f[n] = NULL; } +#ifdef UNIFY_CHANNEL_MEM_HEAP + { + int16_t nchan_transport_jbm; + int16_t nchan_transport_internal; + int16_t nchan_transport_full; + int16_t renderer_granularity; + TC_BUFFER_MODE tc_buffer_mode; + ivas_jbm_dec_get_num_tc_channels( st_ivas, &nchan_transport_jbm, &nchan_transport_internal, &nchan_transport_full ); + tc_buffer_mode = ivas_jbm_dec_get_tc_buffer_mode( st_ivas ); + renderer_granularity = ivas_jbm_dec_get_render_granularity( st_ivas ); + if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, tc_buffer_mode, nchan_transport_jbm, nchan_transport_internal, nchan_transport_full, renderer_granularity ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#endif + return error; } diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 2733294d5c..72b9de628e 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -63,9 +63,11 @@ static ivas_error ivas_ism_bitrate_switching_dec( int32_t element_brate_tmp[MAX_NUM_OBJECTS]; int16_t nSCE_old, nCPE_old; int16_t numCldfbAnalyses_old, numCldfbSyntheses_old, ism_mode; +#ifndef UNIFY_CHANNEL_MEM_HEAP TC_BUFFER_MODE tc_buffer_mode_new; int16_t tc_nchan_tc_new; int16_t tc_nchan_allocate_new; +#endif int16_t tc_granularity_new; int16_t ch, nchan_out_buff, nchan_out_buff_old; AUDIO_CONFIG intern_config_old; @@ -144,7 +146,11 @@ static ivas_error ivas_ism_bitrate_switching_dec( /* 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 */ +#ifdef UNIFY_CHANNEL_MEM_HEAP + tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas ); +#else tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); +#endif if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) { @@ -388,6 +394,12 @@ static ivas_error ivas_ism_bitrate_switching_dec( if ( st_ivas->hDecoderConfig->Opt_5ms ) #endif { +#ifdef UNIFY_CHANNEL_MEM_HEAP + if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } +#else int16_t tc_nchan_full_new; DECODER_TC_BUFFER_HANDLE hTcBuffer; @@ -417,6 +429,7 @@ static ivas_error ivas_ism_bitrate_switching_dec( return error; } } +#endif /* transfer subframe info from central tc buffer to ParamMC or McMASA (DirAC) */ if ( st_ivas->hSpatParamRendCom != NULL ) diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index e0ed793cf5..afde3e2da6 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -2179,12 +2179,16 @@ ivas_error ivas_param_ism_dec_open( st_ivas->hParamIsmDec = hParamIsmDec; st_ivas->hSpatParamRendCom = hSpatParamRendCom; + +#ifndef REMOVE_5MS_FLAG if ( st_ivas->hDecoderConfig->Opt_5ms ) +#endif { if ( st_ivas->renderer_type != RENDERER_MONO_DOWNMIX && st_ivas->renderer_type != RENDERER_DISABLE ) { int16_t nchan_transport = st_ivas->nchan_transport; int16_t nchan_full = 0; + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) { nchan_full = nchan_transport; @@ -2237,12 +2241,13 @@ ivas_error ivas_param_ism_dec_open( } } } +#ifndef REMOVE_5MS_FLAG else { hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc = NULL; hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc = NULL; } - +#endif pop_wmops(); return error; } diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 5bfe5e0879..5fddd72bc6 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -71,9 +71,11 @@ ivas_error ivas_jbm_dec_tc( ) { int16_t n, output_frame, nchan_out; - Decoder_State *st; /* used for bitstream handling */ - float *p_output[MAX_TRANSPORT_CHANNELS]; /* 'float' buffer for output synthesis */ + Decoder_State *st; /* used for bitstream handling */ + float *p_output[MAX_TRANSPORT_CHANNELS]; /* 'float' buffer for output synthesis */ +#ifndef UNIFY_CHANNEL_MEM_HEAP float output_f[MAX_TRANSPORT_CHANNELS][L_FRAME48k]; /* TODO: can be allocated dynamically using st_ivas->p_output_f */ +#endif int16_t nchan_remapped; int16_t nb_bits_metadata[MAX_SCE + 1]; int32_t output_Fs, ivas_total_brate; @@ -97,7 +99,11 @@ ivas_error ivas_jbm_dec_tc( for ( n = 0; n < MAX_TRANSPORT_CHANNELS; n++ ) { +#ifdef UNIFY_CHANNEL_MEM_HEAP + p_output[n] = st_ivas->p_output_f[n]; +#else p_output[n] = output_f[n]; +#endif } /*----------------------------------------------------------------* @@ -795,7 +801,9 @@ ivas_error ivas_jbm_dec_render( int16_t n, nchan_out; int16_t nchan_transport; float *p_output[MAX_OUTPUT_CHANNELS]; +#ifndef UNIFY_CHANNEL_MEM_HEAP float output[MAX_OUTPUT_CHANNELS][L_FRAME48k]; /* 'float' buffer for output synthesis */ +#endif int16_t nchan_remapped; int32_t output_Fs; AUDIO_CONFIG output_config; @@ -806,6 +814,9 @@ ivas_error ivas_jbm_dec_render( ivas_error error; float *p_tc[MAX_TRANSPORT_CHANNELS]; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; +#ifdef UNIFY_CHANNEL_MEM_HEAP + int16_t output_offset; +#endif push_wmops( "ivas_dec_render" ); @@ -820,9 +831,26 @@ ivas_error ivas_jbm_dec_render( output_config = st_ivas->hDecoderConfig->output_config; nSamplesAskedLocal = nSamplesAsked + st_ivas->hTcBuffer->n_samples_discard; +#ifdef UNIFY_CHANNEL_MEM_HEAP + /* make sure we do not overwrite anything if we are w/o TSM and rendering in less than 20ms chunks*/ + if ( st_ivas->hDecoderConfig->Opt_tsm ) + { + output_offset = 0; + } + else + { + output_offset = st_ivas->hTcBuffer->n_samples_rendered; + } +#endif + for ( n = 0; n < MAX_OUTPUT_CHANNELS; n++ ) { +#ifdef UNIFY_CHANNEL_MEM_HEAP + + p_output[n] = st_ivas->p_output_f[n] + output_offset; +#else p_output[n] = &output[n][0]; +#endif } #ifdef FIX_676_JBM_USAN @@ -1135,9 +1163,17 @@ ivas_error ivas_jbm_dec_render( if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) { /* we still need to copy the separate channel if available */ - if ( st_ivas->hOutSetup.separateChannelEnabled ) + if ( st_ivas->hOutSetup.separateChannelEnabled +#ifdef UNIFY_CHANNEL_MEM_HEAP + && st_ivas->hDecoderConfig->Opt_tsm /* w/o TSM they are already in the correct buffers */ +#endif + ) { +#ifdef UNIFY_CHANNEL_MEM_HEAP + mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL - 1] + offset, p_output[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); +#else mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL - 1] + offset, output[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); +#endif } ivas_mc2sba( st_ivas->hIntSetup, p_output, p_output, *nSamplesRendered, st_ivas->hOutSetup.ambisonics_order, 0.f ); } @@ -1145,25 +1181,42 @@ ivas_error ivas_jbm_dec_render( { for ( n = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; n < st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; n++ ) { +#ifdef UNIFY_CHANNEL_MEM_HEAP + set_zero( p_output[n], *nSamplesRendered ); +#else set_zero( output[n], *nSamplesRendered ); +#endif } } } /* copy discrete C and TD LFE from internal TC to output */ - if ( st_ivas->hOutSetup.separateChannelEnabled ) + if ( st_ivas->hOutSetup.separateChannelEnabled +#ifdef UNIFY_CHANNEL_MEM_HEAP + && st_ivas->hDecoderConfig->Opt_tsm /* w/o TSM they are already in the correct buffers */ +#endif + ) { if ( output_config == IVAS_AUDIO_CONFIG_5_1 || output_config == IVAS_AUDIO_CONFIG_7_1 || output_config == IVAS_AUDIO_CONFIG_5_1_4 || output_config == IVAS_AUDIO_CONFIG_7_1_4 || output_config == IVAS_AUDIO_CONFIG_5_1_2 || ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.num_lfe > 0 ) ) { +#ifdef UNIFY_CHANNEL_MEM_HEAP + mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL] + offset, p_output[LFE_CHANNEL], *nSamplesRendered ); + mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL - 1] + offset, p_output[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); +#else mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL] + offset, output[LFE_CHANNEL], *nSamplesRendered ); mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL - 1] + offset, output[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); +#endif } else if ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.num_lfe == 0 ) { /* Delay the separated channel to sync with the DirAC rendering */ +#ifdef UNIFY_CHANNEL_MEM_HEAP + mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL - 1] + offset, p_output[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); +#else mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL - 1] + offset, output[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); +#endif } } } @@ -1695,12 +1748,19 @@ void ivas_jbm_dec_get_md_map_even_spacing( int16_t ivas_jbm_dec_get_num_tc_channels( Decoder_Struct *st_ivas /* i : IVAS decoder handle */ +#ifdef UNIFY_CHANNEL_MEM_HEAP + , + int16_t *nchan_transport_jbm, /* o : number of TSM channels */ + int16_t *nchan_transport_internal, /* o : number of internal channels (i.e. plus e.g. addtl. decorr */ + int16_t *nchan_transport_full /* o : number of channels to allocate fully */ +#endif ) { int16_t num_tc; int32_t ivas_total_brate; AUDIO_CONFIG output_config; + if ( st_ivas->renderer_type == RENDERER_DISABLE ) { num_tc = st_ivas->hDecoderConfig->nchan_out; @@ -1709,6 +1769,10 @@ int16_t ivas_jbm_dec_get_num_tc_channels( { num_tc = st_ivas->nchan_transport; } +#ifdef UNIFY_CHANNEL_MEM_HEAP + *nchan_transport_internal = num_tc; + *nchan_transport_full = num_tc; +#endif output_config = st_ivas->hDecoderConfig->output_config; ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; @@ -1721,7 +1785,32 @@ int16_t ivas_jbm_dec_get_num_tc_channels( if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) { num_tc = 1; +#ifdef UNIFY_CHANNEL_MEM_HEAP + *nchan_transport_internal = num_tc; + *nchan_transport_full = num_tc; +#endif + } +#ifdef UNIFY_CHANNEL_MEM_HEAP + else if ( st_ivas->ism_mode == ISM_MODE_PARAM ) + { + if ( st_ivas->renderer_type == RENDERER_DISABLE ) + { + num_tc = st_ivas->hDecoderConfig->nchan_out; + *nchan_transport_full = num_tc; + *nchan_transport_internal = num_tc; + } + else if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + { + *nchan_transport_internal = num_tc; + *nchan_transport_full = num_tc; + } + else + { + *nchan_transport_internal = num_tc; + *nchan_transport_full = 0; + } } +#endif } else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT ) { @@ -1750,6 +1839,43 @@ int16_t ivas_jbm_dec_get_num_tc_channels( num_tc++; } } +#ifdef UNIFY_CHANNEL_MEM_HEAP + if ( st_ivas->ivas_format == SBA_FORMAT ) + { + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO ) + { + num_tc = st_ivas->hDecoderConfig->nchan_out; + *nchan_transport_internal = num_tc; + *nchan_transport_full = num_tc; + } + else if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) + { + *nchan_transport_internal = 2 * BINAURAL_CHANNELS; + *nchan_transport_full = *nchan_transport_internal; + } + else + { + int16_t sba_order_internal, num_channels_internal; + sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); + num_channels_internal = ivas_sba_get_nchan_metadata( sba_order_internal, st_ivas->hDecoderConfig->ivas_total_brate ); + *nchan_transport_internal = num_channels_internal; + *nchan_transport_full = num_channels_internal; + } + } + else + { + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) + { + *nchan_transport_internal = 2 * BINAURAL_CHANNELS; + *nchan_transport_full = *nchan_transport_internal; + } + else + { + *nchan_transport_internal = num_tc; + *nchan_transport_full = num_tc; + } + } +#endif } else if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) { @@ -1763,17 +1889,48 @@ int16_t ivas_jbm_dec_get_num_tc_channels( { num_tc += st_ivas->nchan_ism; } +#ifdef UNIFY_CHANNEL_MEM_HEAP + *nchan_transport_internal = num_tc; + *nchan_transport_full = num_tc; + + if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) + { + num_tc = 1; + *nchan_transport_internal = num_tc; + *nchan_transport_full = num_tc; + } + else if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) + { + *nchan_transport_internal = 2 * BINAURAL_CHANNELS + 2; + *nchan_transport_full = *nchan_transport_internal; + } +#endif + } +#ifdef UNIFY_CHANNEL_MEM_HEAP + else + { + *nchan_transport_internal = num_tc; + *nchan_transport_full = num_tc; } +#endif } else if ( st_ivas->ivas_format == MC_FORMAT ) { if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO ) { num_tc = 1; +#ifdef UNIFY_CHANNEL_MEM_HEAP + *nchan_transport_internal = num_tc; + *nchan_transport_full = num_tc; +#endif } else if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO ) { num_tc = 2; +#ifdef UNIFY_CHANNEL_MEM_HEAP + *nchan_transport_internal = num_tc; + *nchan_transport_full = num_tc; +#endif } else if ( st_ivas->mc_mode == MC_MODE_MCT ) { @@ -1793,6 +1950,10 @@ int16_t ivas_jbm_dec_get_num_tc_channels( else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) { num_tc = MC_PARAMUPMIX_MAX_TRANSPORT_CHANS; +#ifdef UNIFY_CHANNEL_MEM_HEAP + *nchan_transport_internal = MC_PARAMUPMIX_MAX_INPUT_CHANS; + *nchan_transport_full = MC_PARAMUPMIX_MAX_INPUT_CHANS; +#endif } else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { @@ -1807,13 +1968,41 @@ int16_t ivas_jbm_dec_get_num_tc_channels( /* LFE is synthesized in TD with the TCs*/ num_tc++; } +#ifdef UNIFY_CHANNEL_MEM_HEAP + *nchan_transport_internal = num_tc; + *nchan_transport_full = num_tc; + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO ) + { + num_tc = st_ivas->hDecoderConfig->nchan_out; + *nchan_transport_internal = num_tc; + *nchan_transport_full = num_tc; + } + else if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + { + *nchan_transport_internal = 2 * BINAURAL_CHANNELS; + *nchan_transport_full = *nchan_transport_internal; + } +#endif + } +#ifdef UNIFY_CHANNEL_MEM_HEAP + else if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) + { + *nchan_transport_internal = num_tc; + *nchan_transport_full = 0; } +#endif } else if ( st_ivas->ivas_format == MONO_FORMAT && st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX ) { num_tc = MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN; +#ifdef UNIFY_CHANNEL_MEM_HEAP + *nchan_transport_internal = num_tc; + *nchan_transport_full = num_tc; +#endif } - +#ifdef UNIFY_CHANNEL_MEM_HEAP + *nchan_transport_jbm = num_tc; +#endif return num_tc; } @@ -1885,14 +2074,36 @@ static void ivas_jbm_dec_copy_tc( /*! r: render granularity */ int16_t ivas_jbm_dec_get_render_granularity( +#ifdef UNIFY_CHANNEL_MEM_HEAP + Decoder_Struct *st_ivas /* i : main decoder structure */ +#else const RENDERER_TYPE rendererType, /* i : renderer type */ const IVAS_FORMAT ivas_format, /* i : ivas format */ const MC_MODE mc_mode, /* i : MC mode */ const int32_t output_Fs /* i : sampling rate */ +#endif ) { int16_t render_granularity; +#ifdef UNIFY_CHANNEL_MEM_HEAP + render_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) + { + if ( ( st_ivas->ivas_format == MC_FORMAT ) && ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) ) + { + render_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + } + else + { + render_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); + } + } + else if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + { + render_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); /* Use the same granularity as tdrend */ + } +#else if ( rendererType == RENDERER_BINAURAL_OBJECTS_TD || rendererType == RENDERER_BINAURAL_MIXER_CONV || rendererType == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { if ( ( ivas_format == MC_FORMAT ) && ( mc_mode == MC_MODE_PARAMUPMIX ) ) @@ -1908,6 +2119,7 @@ int16_t ivas_jbm_dec_get_render_granularity( { render_granularity = NS2SA( output_Fs, CLDFB_SLOT_NS ); } +#endif return render_granularity; } @@ -1962,6 +2174,9 @@ ivas_error ivas_jbm_dec_tc_buffer_open( hTcBuffer->num_slots = nMaxSlotsPerSubframe * MAX_PARAM_SPATIAL_SUBFRAMES; set_s( hTcBuffer->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS ); set_s( hTcBuffer->subframe_nbslots, nMaxSlotsPerSubframe, MAX_PARAM_SPATIAL_SUBFRAMES ); +#ifdef UNIFY_CHANNEL_MEM_HEAP + hTcBuffer->tc_buffer = NULL; +#endif if ( hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_NONE ) { @@ -1971,21 +2186,38 @@ ivas_error ivas_jbm_dec_tc_buffer_open( hTcBuffer->tc[ch_idx] = NULL; } } +#ifdef UNIFY_CHANNEL_MEM_HEAP + else if ( !st_ivas->hDecoderConfig->Opt_tsm ) + { + /* we can directly use the already allocated in/out buffers */ + for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = st_ivas->p_output_f[ch_idx]; + } + for ( ; ch_idx < MAX_TRANSPORT_CHANNELS; ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = NULL; + } + } +#endif else { int16_t n_samp_full, n_samp_residual; int32_t offset; +#ifndef UNIFY_CHANNEL_MEM_HEAP if ( st_ivas->hDecoderConfig->Opt_tsm ) { +#endif n_samp_full = ( NS2SA( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS ) + hTcBuffer->n_samples_granularity - 1 ); n_samp_residual = hTcBuffer->n_samples_granularity - 1; +#ifndef UNIFY_CHANNEL_MEM_HEAP } else { n_samp_full = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); n_samp_residual = 0; } - +#endif nsamp_to_allocate = hTcBuffer->nchan_buffer_full * n_samp_full; nsamp_to_allocate += nchan_residual * n_samp_residual; @@ -2037,20 +2269,36 @@ ivas_error ivas_jbm_dec_tc_buffer_open( *--------------------------------------------------------------------------*/ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +#ifndef UNIFY_CHANNEL_MEM_HEAP + , const TC_BUFFER_MODE tc_buffer_mode, /* i : new buffer mode */ const int16_t nchan_transport_jbm, /* i : new number of real transport channels */ const int16_t nchan_transport_internal, /* i : new number of totally buffered channels */ const int16_t nchan_full, /* i : new number of channels to fully store */ const int16_t n_samples_granularity /* i : new granularity of the renderer/buffer */ +#endif ) { int16_t nsamp_to_allocate, n_samp_full, n_samp_residual, offset, nchan_residual; int16_t ch_idx; DECODER_TC_BUFFER_HANDLE hTcBuffer; +#ifdef UNIFY_CHANNEL_MEM_HEAP + int16_t nchan_transport_jbm; + int16_t nchan_transport_internal; + int16_t nchan_full; + int16_t n_samples_granularity; + TC_BUFFER_MODE tc_buffer_mode; +#endif hTcBuffer = st_ivas->hTcBuffer; +#ifdef UNIFY_CHANNEL_MEM_HEAP + ivas_jbm_dec_get_num_tc_channels( st_ivas, &nchan_transport_jbm, &nchan_transport_internal, &nchan_full ); + tc_buffer_mode = ivas_jbm_dec_get_tc_buffer_mode( st_ivas ); + n_samples_granularity = ivas_jbm_dec_get_render_granularity( st_ivas ); +#endif + /* if granularity changes, adapt subframe_nb_slots */ if ( n_samples_granularity != hTcBuffer->n_samples_granularity ) { @@ -2084,54 +2332,82 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( } } - hTcBuffer->tc_buffer_mode = tc_buffer_mode; - hTcBuffer->nchan_transport_jbm = nchan_transport_jbm; - hTcBuffer->nchan_transport_internal = nchan_transport_internal; - hTcBuffer->nchan_buffer_full = nchan_full; - nchan_residual = nchan_transport_internal - nchan_full; - hTcBuffer->n_samples_granularity = n_samples_granularity; +#ifdef UNIFY_CHANNEL_MEM_HEAP + if ( nchan_transport_jbm != hTcBuffer->nchan_transport_jbm || nchan_transport_internal != hTcBuffer->nchan_transport_internal || nchan_full != hTcBuffer->nchan_buffer_full || tc_buffer_mode != st_ivas->hTcBuffer->tc_buffer_mode || n_samples_granularity != st_ivas->hTcBuffer->n_samples_granularity ) + { +#endif + hTcBuffer->tc_buffer_mode = tc_buffer_mode; + hTcBuffer->nchan_transport_jbm = nchan_transport_jbm; + hTcBuffer->nchan_transport_internal = nchan_transport_internal; + hTcBuffer->nchan_buffer_full = nchan_full; + nchan_residual = nchan_transport_internal - nchan_full; + hTcBuffer->n_samples_granularity = n_samples_granularity; + #ifdef DEBUGGING - /* what is remaining from last frames needs always be smaller than n_samples_granularity */ - assert( ( hTcBuffer->n_samples_buffered - hTcBuffer->n_samples_rendered ) < n_samples_granularity ); + /* what is remaining from last frames needs always be smaller than n_samples_granularity */ + assert( ( hTcBuffer->n_samples_buffered - hTcBuffer->n_samples_rendered ) < n_samples_granularity ); #endif +#ifdef UNIFY_CHANNEL_MEM_HEAP + if ( !st_ivas->hDecoderConfig->Opt_tsm ) + { + /* we can directly use the already allocated in/out buffers */ + for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = st_ivas->p_output_f[ch_idx]; + } + for ( ; ch_idx < MAX_TRANSPORT_CHANNELS; ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = NULL; + } + } - /* realloc buffers */ - free( hTcBuffer->tc_buffer ); - if ( st_ivas->hDecoderConfig->Opt_tsm ) - { - n_samp_full = ( NS2SA( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS ) + hTcBuffer->n_samples_granularity - 1 ); - n_samp_residual = hTcBuffer->n_samples_granularity - 1; - } - else - { - n_samp_full = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); - n_samp_residual = 0; - } - nsamp_to_allocate = hTcBuffer->nchan_buffer_full * n_samp_full; - nsamp_to_allocate += nchan_residual * n_samp_residual; + else + { +#endif + /* realloc buffers */ + free( hTcBuffer->tc_buffer ); +#ifndef UNIFY_CHANNEL_MEM_HEAP + if ( st_ivas->hDecoderConfig->Opt_tsm ) + { +#endif + n_samp_full = ( NS2SA( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS ) + hTcBuffer->n_samples_granularity - 1 ); + n_samp_residual = hTcBuffer->n_samples_granularity - 1; +#ifndef UNIFY_CHANNEL_MEM_HEAP + } + else + { + n_samp_full = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); + n_samp_residual = 0; + } +#endif + nsamp_to_allocate = hTcBuffer->nchan_buffer_full * n_samp_full; + nsamp_to_allocate += nchan_residual * n_samp_residual; - if ( ( hTcBuffer->tc_buffer = (float *) malloc( nsamp_to_allocate * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) ); - } - set_zero( hTcBuffer->tc_buffer, nsamp_to_allocate ); + if ( ( hTcBuffer->tc_buffer = (float *) malloc( nsamp_to_allocate * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) ); + } + set_zero( hTcBuffer->tc_buffer, nsamp_to_allocate ); - offset = 0; - for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) - { - hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; - offset += n_samp_full; - } - for ( ; ch_idx < hTcBuffer->nchan_transport_internal; ch_idx++ ) - { - hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; - offset += n_samp_residual; - } - for ( ; ch_idx < MAX_TRANSPORT_CHANNELS; ch_idx++ ) - { - hTcBuffer->tc[ch_idx] = NULL; + offset = 0; + for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; + offset += n_samp_full; + } + for ( ; ch_idx < hTcBuffer->nchan_transport_internal; ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; + offset += n_samp_residual; + } + for ( ; ch_idx < MAX_TRANSPORT_CHANNELS; ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = NULL; + } +#ifdef UNIFY_CHANNEL_MEM_HEAP + } } - +#endif return IVAS_ERR_OK; } @@ -2313,11 +2589,21 @@ TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( } break; case RENDERER_MC: +#ifdef UNIFY_CHANNEL_MEM_HEAP + { + int16_t num_tc, tmp1, tmp2; + ivas_jbm_dec_get_num_tc_channels( st_ivas, &num_tc, &tmp1, &tmp2 ); + if ( num_tc != st_ivas->hDecoderConfig->nchan_out ) +#else if ( ivas_jbm_dec_get_num_tc_channels( st_ivas ) != st_ivas->hDecoderConfig->nchan_out ) +#endif { buffer_mode = TC_BUFFER_MODE_RENDERER; } - break; +#ifdef UNIFY_CHANNEL_MEM_HEAP + } +#endif + break; case RENDERER_SBA_LINEAR_ENC: if ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCT && ( st_ivas->renderer_type == RENDERER_MC || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) && ( st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe ) >= ( st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe ) ) { @@ -2369,12 +2655,14 @@ void ivas_jbm_dec_copy_tc_no_tsm( hTcBuffer->n_samples_available = hTcBuffer->n_samples_buffered; n_ch_full_copy = min( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); n_ch_cldfb = hTcBuffer->nchan_transport_jbm - hTcBuffer->nchan_buffer_full; + /* copy full tcs*/ for ( ch_idx = 0; ch_idx < n_ch_full_copy; ch_idx++ ) { +#ifndef UNIFY_CHANNEL_MEM_HEAP mvr2r( tc[ch_idx], st_ivas->hTcBuffer->tc[ch_idx], hTcBuffer->n_samples_buffered ); +#endif } - /* CLDFB ana for ParamMC/ParamISM */ if ( n_ch_cldfb > 0 ) { diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 546d01d27d..708224b53a 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -621,6 +621,7 @@ ivas_error ivas_masa_dec_open( st_ivas->hMasa = hMasa; +#ifndef UNIFY_CHANNEL_MEM_HEAP /* allocate transport channels*/ if ( #ifndef REMOVE_5MS_FLAG @@ -652,6 +653,7 @@ ivas_error ivas_masa_dec_open( return error; } } +#endif return error; } @@ -1452,18 +1454,25 @@ ivas_error ivas_masa_dec_reconfigure( if ( st_ivas->hDecoderConfig->Opt_5ms == 1 ) #endif { +#ifndef UNIFY_CHANNEL_MEM_HEAP int16_t tc_nchan_to_allocate; int16_t tc_nchan_transport; TC_BUFFER_MODE buffer_mode_new; +#endif int16_t n_samples_granularity; +#ifdef UNIFY_CHANNEL_MEM_HEAP + n_samples_granularity = ivas_jbm_dec_get_render_granularity( st_ivas ); +#else n_samples_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode( st_ivas ); tc_nchan_transport = ivas_jbm_dec_get_num_tc_channels( st_ivas ); tc_nchan_to_allocate = tc_nchan_transport; +#endif if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { +#ifndef UNIFY_CHANNEL_MEM_HEAP if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) { tc_nchan_to_allocate = 2 * BINAURAL_CHANNELS + 2; @@ -1472,11 +1481,12 @@ ivas_error ivas_masa_dec_reconfigure( { tc_nchan_to_allocate = 2 * BINAURAL_CHANNELS; } - +#endif if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { +#ifndef UNIFY_CHANNEL_MEM_HEAP n_samples_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); /* Use the same granularity as tdrend */ - +#endif if ( n_samples_granularity > st_ivas->hTcBuffer->n_samples_granularity ) { if ( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK ) @@ -1501,6 +1511,12 @@ ivas_error ivas_masa_dec_reconfigure( } } +#ifdef UNIFY_CHANNEL_MEM_HEAP + if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } +#else if ( tc_nchan_transport != st_ivas->hTcBuffer->nchan_transport_jbm || tc_nchan_to_allocate != st_ivas->hTcBuffer->nchan_transport_internal || buffer_mode_new != st_ivas->hTcBuffer->tc_buffer_mode ) { if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas, buffer_mode_new, tc_nchan_transport, tc_nchan_to_allocate, tc_nchan_to_allocate, n_samples_granularity ) ) != IVAS_ERR_OK ) @@ -1508,6 +1524,7 @@ ivas_error ivas_masa_dec_reconfigure( return error; } } +#endif if ( st_ivas->hSpatParamRendCom != NULL && st_ivas->hSpatParamRendCom->slot_size == st_ivas->hTcBuffer->n_samples_granularity ) { diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index e4fb73e24c..3de5aae653 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -467,6 +467,7 @@ ivas_error ivas_param_mc_dec_open( } set_zero( hParamMC->Cldfb_ImagBuffer_tc, n_cldfb_slots * nchan_transport * hParamMC->num_freq_bands ); +#ifndef UNIFY_CHANNEL_MEM_HEAP if ( st_ivas->hTcBuffer == NULL ) { if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, 0, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) @@ -474,6 +475,7 @@ ivas_error ivas_param_mc_dec_open( return error; } } +#endif } else { diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index 8880d335a4..e498f7a484 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -709,6 +709,22 @@ ivas_error ivas_mc_paramupmix_dec_open( /* allocate transport channels*/ hMCParamUpmix->free_param_interpolator = 0; hMCParamUpmix->param_interpolator = NULL; +#ifdef FIX_XXX_JBM_PARAMUPMIX_RS +#ifndef REMOVE_5MS_FLAG + if ( st_ivas->hDecoderConfig->Opt_5ms == 1 ) +#endif + { + 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 + +#ifndef UNIFY_CHANNEL_MEM_HEAP if ( #ifndef REMOVE_5MS_FLAG st_ivas->hDecoderConfig->Opt_5ms == 1 && @@ -722,10 +738,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 FIX_XXX_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 ) { @@ -741,11 +759,13 @@ ivas_error ivas_mc_paramupmix_dec_open( { return error; } +#ifndef FIX_XXX_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 } - +#endif st_ivas->hMCParamUpmix = hMCParamUpmix; return error; diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 720ca106f2..a4efa926c7 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -733,9 +733,11 @@ static ivas_error ivas_mc_dec_reconfig( Decoder_State *st; ivas_error error; MC_MODE mc_mode, last_mc_mode; +#ifndef UNIFY_CHANNEL_MEM_HEAP TC_BUFFER_MODE tc_buffer_mode_new; int16_t tc_nchan_tc_new; int16_t tc_nchan_allocate_new; +#endif int16_t tc_granularity_new; AUDIO_CONFIG intern_config_old; IVAS_OUTPUT_SETUP hIntSetupOld; @@ -804,7 +806,11 @@ static ivas_error ivas_mc_dec_reconfig( /* JBM: when granularity goes down (e.g. MCT with CREND -> ParamMC with binaural fastconv render what still fits in the new granularity */ +#ifdef UNIFY_CHANNEL_MEM_HEAP + tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas ); +#else tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); +#endif if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) { #ifdef SPLIT_REND_WITH_HEAD_ROT @@ -1344,6 +1350,12 @@ static ivas_error ivas_mc_dec_reconfig( if ( st_ivas->hDecoderConfig->Opt_5ms == 1 ) #endif { +#ifdef UNIFY_CHANNEL_MEM_HEAP + if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } +#else int16_t tc_nchan_full_new; DECODER_TC_BUFFER_HANDLE hTcBuffer; @@ -1361,7 +1373,19 @@ static ivas_error ivas_mc_dec_reconfig( { tc_nchan_full_new = 0; } - +#ifdef FIX_XXX_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 || hTcBuffer->nchan_buffer_full != tc_nchan_full_new || hTcBuffer->nchan_transport_internal != tc_nchan_allocate_new || @@ -1372,7 +1396,7 @@ static ivas_error ivas_mc_dec_reconfig( return error; } } - +#endif /* transfer subframe info from central tc buffer to ParamMC or McMASA (DirAC) */ if ( st_ivas->hSpatParamRendCom != NULL ) { diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 7bc28123d9..ca0d4509bb 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -522,6 +522,7 @@ ivas_error ivas_sba_dec_reconfigure( return error; } +#ifndef UNIFY_CHANNEL_MEM_HEAP /*-----------------------------------------------------------------* * JBM TC buffer *-----------------------------------------------------------------*/ @@ -566,6 +567,7 @@ ivas_error ivas_sba_dec_reconfigure( } } } +#endif /*-----------------------------------------------------------------* * floating-point output audio buffers @@ -597,6 +599,13 @@ ivas_error ivas_sba_dec_reconfigure( } } +#ifdef UNIFY_CHANNEL_MEM_HEAP + if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } +#endif + return error; } diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 92cc99ebc6..307e2ecf0d 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -75,6 +75,7 @@ ivas_error ivas_spar_dec_open( int16_t num_decor_chs, map_idx; error = IVAS_ERR_OK; + sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); num_channels_internal = ivas_sba_get_nchan_metadata( sba_order_internal, st_ivas->hDecoderConfig->ivas_total_brate ); @@ -210,6 +211,7 @@ ivas_error ivas_spar_dec_open( hSpar->render_to_md_map[map_idx] = map_idx; } +#ifndef UNIFY_CHANNEL_MEM_HEAP /* allocate transport channels*/ if ( #ifndef REMOVE_5MS_FLAG @@ -240,6 +242,7 @@ ivas_error ivas_spar_dec_open( return error; } } +#endif st_ivas->hSpar = hSpar; diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 37488b9e7e..01b41f4df1 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -305,6 +305,7 @@ ivas_error ivas_dirac_dec_init_binaural_data( st_ivas->hDiracDecBin = hDiracDecBin; #endif +#ifndef UNIFY_CHANNEL_MEM_HEAP /* allocate transport channels*/ if ( #ifndef REMOVE_5MS_FLAG @@ -332,7 +333,7 @@ ivas_error ivas_dirac_dec_init_binaural_data( return error; } } - +#endif return IVAS_ERR_OK; } diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index bbc1e65e00..19c70a65eb 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -1397,16 +1397,6 @@ static void external_target_interpolation( { if ( i > 0 ) { -#ifdef NONBE_UNIFIED_DECODING_PATHS_1 - if ( hExtOrientationData->enableExternalOrientation[i - 1] != 1 ) - { - IVAS_QUATERNION identity; - identity.w = 1.0f; - identity.x = identity.y = identity.z = 0.0f; - hCombinedOrientationData->Quaternions_ext_interpolation_start = identity; - } - else -#endif { hCombinedOrientationData->Quaternions_ext_interpolation_start = hExtOrientationData->Quaternions[i - 1]; } -- GitLab From 041dac6412969f0edb7d86ddccc643f39dae3042 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Mon, 25 Sep 2023 12:21:58 +0200 Subject: [PATCH 07/49] fix some problems with the unified channel mem handling --- lib_com/ivas_prot.h | 33 +- lib_com/options.h | 3 +- lib_dec/ivas_dirac_dec.c | 7 +- lib_dec/ivas_init_dec.c | 27 +- lib_dec/ivas_ism_dec.c | 23 +- lib_dec/ivas_ism_param_dec.c | 7 +- lib_dec/ivas_jbm_dec.c | 384 ++++++++++++++++--- lib_dec/ivas_masa_dec.c | 21 +- lib_dec/ivas_mc_param_dec.c | 2 + lib_dec/ivas_mc_paramupmix_dec.c | 22 +- lib_dec/ivas_mct_dec.c | 28 +- lib_dec/ivas_omasa_dec.c | 4 + lib_dec/ivas_sba_dec.c | 13 + lib_dec/ivas_spar_decoder.c | 3 + lib_rend/ivas_dirac_dec_binaural_functions.c | 3 +- lib_rend/ivas_output_init.c | 43 +++ lib_rend/ivas_prot_rend.h | 6 +- lib_rend/ivas_rotation.c | 10 - 18 files changed, 551 insertions(+), 88 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index c19a3ecf43..c812692554 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -844,6 +844,12 @@ void ivas_jbm_dec_get_md_map( int16_t ivas_jbm_dec_get_num_tc_channels( Decoder_Struct *st_ivas /* i : IVAS decoder handle */ +#ifdef UNIFY_CHANNEL_MEM_HEAP + , + int16_t *nchan_transport_jbm, /* o : number of TSM channels */ + int16_t *nchan_transport_internal, /* o : number of internal channels (i.e. plus e.g. addtl. decorr */ + int16_t *nchan_transport_full /* o : number of channels to allocate fully */ +#endif ); void ivas_jbm_dec_copy_tc_no_tsm( @@ -866,10 +872,14 @@ TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( /*! r: render granularity */ int16_t ivas_jbm_dec_get_render_granularity( - const RENDERER_TYPE rendererType, /* i : renderer type */ - const IVAS_FORMAT ivas_format, /* i : ivas format */ - const MC_MODE mc_mode, /* i : MC mode */ - const int32_t output_Fs /* i : sampling rate */ +#ifdef UNIFY_CHANNEL_MEM_HEAP + Decoder_Struct *st_ivas /* i : main decoder structure */ +#else + const RENDERER_TYPE rendererType, /* i : renderer type */ + const IVAS_FORMAT ivas_format, /* i : ivas format */ + const MC_MODE mc_mode, /* i : MC mode */ + const int32_t output_Fs /* i : sampling rate */ +#endif ); ivas_error ivas_jbm_dec_tc_buffer_open( @@ -882,12 +892,15 @@ ivas_error ivas_jbm_dec_tc_buffer_open( ); ivas_error ivas_jbm_dec_tc_buffer_reconfigure( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const TC_BUFFER_MODE tc_buffer_mode, /* i : new buffer mode */ - const int16_t nchan_transport_jbm, /* i : new number of real transport channels */ - const int16_t nchan_transport_internal, /* i : new number of totally buffered channels */ - const int16_t nchan_full, /* i : new number of channels to fully store */ - const int16_t n_samples_granularity /* i : new granularity of the renderer/buffer */ + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +#ifndef UNIFY_CHANNEL_MEM_HEAP + , + const TC_BUFFER_MODE tc_buffer_mode, /* i : new buffer mode */ + const int16_t nchan_transport_jbm, /* i : new number of real transport channels */ + const int16_t nchan_transport_internal, /* i : new number of totally buffered channels */ + const int16_t nchan_full, /* i : new number of channels to fully store */ + const int16_t n_samples_granularity /* i : new granularity of the renderer/buffer */ +#endif ); void ivas_jbm_dec_tc_buffer_close( diff --git a/lib_com/options.h b/lib_com/options.h index 9820fbbbb3..92bd3cfe29 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -197,10 +197,11 @@ #define NONBE_FIX_752_OSBA_MISCONFIG_MCT /* FhG: issue 752: misconfiguration of MCT causes crashes for coding with sampling rate under 48kHz at 256kbps*/ #define NONBE_FIX_727_MC_PARAMUPMIX_HEADROTATION /* Dlb : issue 727 : headrotation in MC paramupmix mode*/ #define NONBE_FIX_779_ISM_FREE_REVERB_HANDLE /* VA: issue 779: fix Crash in ISM rate switching with BINAURAL_ROOM_REVERB */ - #define NONBE_UNIFIED_DECODING_PATHS /* FhG: unify decoding paths */ #ifdef NONBE_UNIFIED_DECODING_PATHS #define REMOVE_5MS_FLAG +#define FIX_XXX_JBM_PARAMUPMIX_RS +#define UNIFY_CHANNEL_MEM_HEAP #endif #define NONBE_FIX_722_MEMORY_LEAK_IN_PARAMUPMIX /* Dlb : issue 722: memory leak fix in MC param upmix mode with BR switching*/ #define NONBE_FIX_780_ISM_STARTS_WITH_SID /* VA: issue 780: fix Crash in ISM decoding when bitstream starts with an SID and output_config is not EXT */ diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 3d5527b4fb..79c1588e18 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -957,6 +957,7 @@ ivas_error ivas_dirac_dec_config( } } +#if 0 /* Allocate transport channel buffers for SBA format when in JBM */ if ( dec_config_flag == DIRAC_OPEN ) { @@ -989,7 +990,7 @@ ivas_error ivas_dirac_dec_config( } } } - +#endif return error; } @@ -2469,11 +2470,11 @@ void ivas_dirac_dec_render_sf( #ifndef NONBE_UNIFIED_DECODING_PATHS subframe_idx, #endif - hSpatParamRendCom->subframe_nbslots[subframe_idx], + hSpatParamRendCom->subframe_nbslots[subframe_idx], #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG NULL, #endif -Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); + Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); #ifdef SPLIT_REND_WITH_HEAD_ROT if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 07bed88968..d205af3bfd 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1098,7 +1098,9 @@ ivas_error ivas_init_decoder( int16_t i, n, k; int16_t sce_id, cpe_id; int16_t numCldfbAnalyses, numCldfbSyntheses; +#ifndef UNIFY_CHANNEL_MEM_HEAP int16_t granularity, n_channels_transport_jbm; +#endif int32_t output_Fs, ivas_total_brate; int32_t binauralization_delay_ns; AUDIO_CONFIG output_config; @@ -1967,6 +1969,7 @@ ivas_error ivas_init_decoder( } } +#ifndef UNIFY_CHANNEL_MEM_HEAP #ifndef REMOVE_5MS_FLAG if ( st_ivas->hDecoderConfig->Opt_5ms ) #endif @@ -1979,6 +1982,7 @@ ivas_error ivas_init_decoder( return error; } } +#endif } else if ( st_ivas->renderer_type == RENDERER_MC ) { @@ -2017,6 +2021,7 @@ ivas_error ivas_init_decoder( st_ivas->binaural_latency_ns = st_ivas->hCrendWrapper->binaural_latency_ns; +#ifndef UNIFY_CHANNEL_MEM_HEAP #ifndef REMOVE_5MS_FLAG if ( st_ivas->hDecoderConfig->Opt_5ms ) #endif @@ -2044,6 +2049,7 @@ ivas_error ivas_init_decoder( } } } +#endif } if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) @@ -2192,6 +2198,7 @@ ivas_error ivas_init_decoder( return error; } +#ifndef UNIFY_CHANNEL_MEM_HEAP /*-----------------------------------------------------------------* * Allocate and initialize JBM struct + buffer *-----------------------------------------------------------------*/ @@ -2200,8 +2207,6 @@ ivas_error ivas_init_decoder( st_ivas->hDecoderConfig->Opt_5ms && #endif st_ivas->hTcBuffer == NULL ) - - if ( st_ivas->hDecoderConfig->Opt_5ms && st_ivas->hTcBuffer == NULL ) { /* no module has yet open the TC buffer, open a default one */ n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); @@ -2220,6 +2225,7 @@ ivas_error ivas_init_decoder( return error; } } +#endif if ( st_ivas->hJbmMetadata == NULL ) { @@ -2260,6 +2266,23 @@ ivas_error ivas_init_decoder( st_ivas->p_output_f[n] = NULL; } +#ifdef UNIFY_CHANNEL_MEM_HEAP + { + int16_t nchan_transport_jbm; + int16_t nchan_transport_internal; + int16_t nchan_transport_full; + int16_t renderer_granularity; + TC_BUFFER_MODE tc_buffer_mode; + ivas_jbm_dec_get_num_tc_channels( st_ivas, &nchan_transport_jbm, &nchan_transport_internal, &nchan_transport_full ); + tc_buffer_mode = ivas_jbm_dec_get_tc_buffer_mode( st_ivas ); + renderer_granularity = ivas_jbm_dec_get_render_granularity( st_ivas ); + if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, tc_buffer_mode, nchan_transport_jbm, nchan_transport_internal, nchan_transport_full, renderer_granularity ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#endif + return error; } diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 2733294d5c..e8201d58e3 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -63,9 +63,11 @@ static ivas_error ivas_ism_bitrate_switching_dec( int32_t element_brate_tmp[MAX_NUM_OBJECTS]; int16_t nSCE_old, nCPE_old; int16_t numCldfbAnalyses_old, numCldfbSyntheses_old, ism_mode; +#ifndef UNIFY_CHANNEL_MEM_HEAP TC_BUFFER_MODE tc_buffer_mode_new; int16_t tc_nchan_tc_new; int16_t tc_nchan_allocate_new; +#endif int16_t tc_granularity_new; int16_t ch, nchan_out_buff, nchan_out_buff_old; AUDIO_CONFIG intern_config_old; @@ -81,7 +83,11 @@ static ivas_error ivas_ism_bitrate_switching_dec( st_ivas->ism_mode = last_ism_mode; ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); st_ivas->ism_mode = ism_mode; +#ifdef UNIFY_CHANNEL_MEM_HEAP + nchan_out_buff_old = ivas_count_nchan_buffers_dec( st_ivas ); +#else nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas ); +#endif if ( ( error = ivas_ism_config( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->nchan_ism, NULL, 0, NULL, NULL, element_brate_tmp, NULL, NULL, 0 ) ) != IVAS_ERR_OK ) { @@ -144,7 +150,11 @@ static ivas_error ivas_ism_bitrate_switching_dec( /* 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 */ +#ifdef UNIFY_CHANNEL_MEM_HEAP + tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas ); +#else tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); +#endif if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) { @@ -388,6 +398,12 @@ static ivas_error ivas_ism_bitrate_switching_dec( if ( st_ivas->hDecoderConfig->Opt_5ms ) #endif { +#ifdef UNIFY_CHANNEL_MEM_HEAP + if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } +#else int16_t tc_nchan_full_new; DECODER_TC_BUFFER_HANDLE hTcBuffer; @@ -417,6 +433,7 @@ static ivas_error ivas_ism_bitrate_switching_dec( return error; } } +#endif /* transfer subframe info from central tc buffer to ParamMC or McMASA (DirAC) */ if ( st_ivas->hSpatParamRendCom != NULL ) @@ -442,9 +459,9 @@ static ivas_error ivas_ism_bitrate_switching_dec( *-------------------------------------------------------------------------*/ ivas_error ivas_ism_dec_config( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const ISM_MODE last_ism_mode, /* i/o: last ISM mode */ - uint16_t *nSamplesRendered, /* o : number of samples flushed when the renderer granularity changes */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const ISM_MODE last_ism_mode, /* i/o: last ISM mode */ + uint16_t *nSamplesRendered, /* o : number of samples flushed when the renderer granularity changes */ #ifdef SPLIT_REND_WITH_HEAD_ROT const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ void *data /* o : output synthesis signal */ diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index e0ed793cf5..afde3e2da6 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -2179,12 +2179,16 @@ ivas_error ivas_param_ism_dec_open( st_ivas->hParamIsmDec = hParamIsmDec; st_ivas->hSpatParamRendCom = hSpatParamRendCom; + +#ifndef REMOVE_5MS_FLAG if ( st_ivas->hDecoderConfig->Opt_5ms ) +#endif { if ( st_ivas->renderer_type != RENDERER_MONO_DOWNMIX && st_ivas->renderer_type != RENDERER_DISABLE ) { int16_t nchan_transport = st_ivas->nchan_transport; int16_t nchan_full = 0; + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) { nchan_full = nchan_transport; @@ -2237,12 +2241,13 @@ ivas_error ivas_param_ism_dec_open( } } } +#ifndef REMOVE_5MS_FLAG else { hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc = NULL; hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc = NULL; } - +#endif pop_wmops(); return error; } diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 5bfe5e0879..d413b48d7f 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -71,9 +71,11 @@ ivas_error ivas_jbm_dec_tc( ) { int16_t n, output_frame, nchan_out; - Decoder_State *st; /* used for bitstream handling */ - float *p_output[MAX_TRANSPORT_CHANNELS]; /* 'float' buffer for output synthesis */ + Decoder_State *st; /* used for bitstream handling */ + float *p_output[MAX_TRANSPORT_CHANNELS]; /* 'float' buffer for output synthesis */ +#ifndef UNIFY_CHANNEL_MEM_HEAP float output_f[MAX_TRANSPORT_CHANNELS][L_FRAME48k]; /* TODO: can be allocated dynamically using st_ivas->p_output_f */ +#endif int16_t nchan_remapped; int16_t nb_bits_metadata[MAX_SCE + 1]; int32_t output_Fs, ivas_total_brate; @@ -97,7 +99,11 @@ ivas_error ivas_jbm_dec_tc( for ( n = 0; n < MAX_TRANSPORT_CHANNELS; n++ ) { +#ifdef UNIFY_CHANNEL_MEM_HEAP + p_output[n] = st_ivas->p_output_f[n]; +#else p_output[n] = output_f[n]; +#endif } /*----------------------------------------------------------------* @@ -795,7 +801,9 @@ ivas_error ivas_jbm_dec_render( int16_t n, nchan_out; int16_t nchan_transport; float *p_output[MAX_OUTPUT_CHANNELS]; +#ifndef UNIFY_CHANNEL_MEM_HEAP float output[MAX_OUTPUT_CHANNELS][L_FRAME48k]; /* 'float' buffer for output synthesis */ +#endif int16_t nchan_remapped; int32_t output_Fs; AUDIO_CONFIG output_config; @@ -806,6 +814,9 @@ ivas_error ivas_jbm_dec_render( ivas_error error; float *p_tc[MAX_TRANSPORT_CHANNELS]; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; +#ifdef UNIFY_CHANNEL_MEM_HEAP + int16_t output_offset; +#endif push_wmops( "ivas_dec_render" ); @@ -820,9 +831,26 @@ ivas_error ivas_jbm_dec_render( output_config = st_ivas->hDecoderConfig->output_config; nSamplesAskedLocal = nSamplesAsked + st_ivas->hTcBuffer->n_samples_discard; +#ifdef UNIFY_CHANNEL_MEM_HEAP + /* make sure we do not overwrite anything if we are w/o TSM and rendering in less than 20ms chunks*/ + if ( st_ivas->hDecoderConfig->Opt_tsm ) + { + output_offset = 0; + } + else + { + output_offset = st_ivas->hTcBuffer->n_samples_rendered; + } +#endif + for ( n = 0; n < MAX_OUTPUT_CHANNELS; n++ ) { +#ifdef UNIFY_CHANNEL_MEM_HEAP + + p_output[n] = st_ivas->p_output_f[n] + output_offset; +#else p_output[n] = &output[n][0]; +#endif } #ifdef FIX_676_JBM_USAN @@ -1135,9 +1163,17 @@ ivas_error ivas_jbm_dec_render( if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) { /* we still need to copy the separate channel if available */ - if ( st_ivas->hOutSetup.separateChannelEnabled ) + if ( st_ivas->hOutSetup.separateChannelEnabled +#ifdef UNIFY_CHANNEL_MEM_HEAP + && st_ivas->hDecoderConfig->Opt_tsm /* w/o TSM they are already in the correct buffers */ +#endif + ) { +#ifdef UNIFY_CHANNEL_MEM_HEAP + mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL - 1] + offset, p_output[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); +#else mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL - 1] + offset, output[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); +#endif } ivas_mc2sba( st_ivas->hIntSetup, p_output, p_output, *nSamplesRendered, st_ivas->hOutSetup.ambisonics_order, 0.f ); } @@ -1145,25 +1181,42 @@ ivas_error ivas_jbm_dec_render( { for ( n = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; n < st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; n++ ) { +#ifdef UNIFY_CHANNEL_MEM_HEAP + set_zero( p_output[n], *nSamplesRendered ); +#else set_zero( output[n], *nSamplesRendered ); +#endif } } } /* copy discrete C and TD LFE from internal TC to output */ - if ( st_ivas->hOutSetup.separateChannelEnabled ) + if ( st_ivas->hOutSetup.separateChannelEnabled +#ifdef UNIFY_CHANNEL_MEM_HEAP + && st_ivas->hDecoderConfig->Opt_tsm /* w/o TSM they are already in the correct buffers */ +#endif + ) { if ( output_config == IVAS_AUDIO_CONFIG_5_1 || output_config == IVAS_AUDIO_CONFIG_7_1 || output_config == IVAS_AUDIO_CONFIG_5_1_4 || output_config == IVAS_AUDIO_CONFIG_7_1_4 || output_config == IVAS_AUDIO_CONFIG_5_1_2 || ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.num_lfe > 0 ) ) { +#ifdef UNIFY_CHANNEL_MEM_HEAP + mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL] + offset, p_output[LFE_CHANNEL], *nSamplesRendered ); + mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL - 1] + offset, p_output[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); +#else mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL] + offset, output[LFE_CHANNEL], *nSamplesRendered ); mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL - 1] + offset, output[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); +#endif } else if ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.num_lfe == 0 ) { /* Delay the separated channel to sync with the DirAC rendering */ +#ifdef UNIFY_CHANNEL_MEM_HEAP + mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL - 1] + offset, p_output[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); +#else mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL - 1] + offset, output[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); +#endif } } } @@ -1695,12 +1748,19 @@ void ivas_jbm_dec_get_md_map_even_spacing( int16_t ivas_jbm_dec_get_num_tc_channels( Decoder_Struct *st_ivas /* i : IVAS decoder handle */ +#ifdef UNIFY_CHANNEL_MEM_HEAP + , + int16_t *nchan_transport_jbm, /* o : number of TSM channels */ + int16_t *nchan_transport_internal, /* o : number of internal channels (i.e. plus e.g. addtl. decorr */ + int16_t *nchan_transport_full /* o : number of channels to allocate fully */ +#endif ) { int16_t num_tc; int32_t ivas_total_brate; AUDIO_CONFIG output_config; + if ( st_ivas->renderer_type == RENDERER_DISABLE ) { num_tc = st_ivas->hDecoderConfig->nchan_out; @@ -1709,6 +1769,10 @@ int16_t ivas_jbm_dec_get_num_tc_channels( { num_tc = st_ivas->nchan_transport; } +#ifdef UNIFY_CHANNEL_MEM_HEAP + *nchan_transport_internal = num_tc; + *nchan_transport_full = num_tc; +#endif output_config = st_ivas->hDecoderConfig->output_config; ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; @@ -1721,7 +1785,32 @@ int16_t ivas_jbm_dec_get_num_tc_channels( if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) { num_tc = 1; +#ifdef UNIFY_CHANNEL_MEM_HEAP + *nchan_transport_internal = num_tc; + *nchan_transport_full = num_tc; +#endif } +#ifdef UNIFY_CHANNEL_MEM_HEAP + else if ( st_ivas->ism_mode == ISM_MODE_PARAM ) + { + if ( st_ivas->renderer_type == RENDERER_DISABLE ) + { + num_tc = st_ivas->hDecoderConfig->nchan_out; + *nchan_transport_full = num_tc; + *nchan_transport_internal = num_tc; + } + else if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + { + *nchan_transport_internal = num_tc; + *nchan_transport_full = num_tc; + } + else + { + *nchan_transport_internal = num_tc; + *nchan_transport_full = 0; + } + } +#endif } else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT ) { @@ -1750,6 +1839,43 @@ int16_t ivas_jbm_dec_get_num_tc_channels( num_tc++; } } +#ifdef UNIFY_CHANNEL_MEM_HEAP + if ( st_ivas->ivas_format == SBA_FORMAT ) + { + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO ) + { + num_tc = st_ivas->hDecoderConfig->nchan_out; + *nchan_transport_internal = num_tc; + *nchan_transport_full = num_tc; + } + else if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) + { + *nchan_transport_internal = 2 * BINAURAL_CHANNELS; + *nchan_transport_full = *nchan_transport_internal; + } + else + { + int16_t sba_order_internal, num_channels_internal; + sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); + num_channels_internal = ivas_sba_get_nchan_metadata( sba_order_internal, st_ivas->hDecoderConfig->ivas_total_brate ); + *nchan_transport_internal = num_channels_internal; + *nchan_transport_full = num_channels_internal; + } + } + else + { + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) + { + *nchan_transport_internal = 2 * BINAURAL_CHANNELS; + *nchan_transport_full = *nchan_transport_internal; + } + else + { + *nchan_transport_internal = num_tc; + *nchan_transport_full = num_tc; + } + } +#endif } else if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) { @@ -1763,6 +1889,26 @@ int16_t ivas_jbm_dec_get_num_tc_channels( { num_tc += st_ivas->nchan_ism; } + *nchan_transport_internal = num_tc; + *nchan_transport_full = num_tc; +#ifdef UNIFY_CHANNEL_MEM_HEAP + if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) + { + num_tc = 1; + *nchan_transport_internal = num_tc; + *nchan_transport_full = num_tc; + } + else if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) + { + *nchan_transport_internal = 2 * BINAURAL_CHANNELS + 2; + *nchan_transport_full = *nchan_transport_internal; + } +#endif + } + else + { + *nchan_transport_internal = num_tc; + *nchan_transport_full = num_tc; } } else if ( st_ivas->ivas_format == MC_FORMAT ) @@ -1770,10 +1916,18 @@ int16_t ivas_jbm_dec_get_num_tc_channels( if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO ) { num_tc = 1; +#ifdef UNIFY_CHANNEL_MEM_HEAP + *nchan_transport_internal = num_tc; + *nchan_transport_full = num_tc; +#endif } else if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO ) { num_tc = 2; +#ifdef UNIFY_CHANNEL_MEM_HEAP + *nchan_transport_internal = num_tc; + *nchan_transport_full = num_tc; +#endif } else if ( st_ivas->mc_mode == MC_MODE_MCT ) { @@ -1793,6 +1947,10 @@ int16_t ivas_jbm_dec_get_num_tc_channels( else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) { num_tc = MC_PARAMUPMIX_MAX_TRANSPORT_CHANS; +#ifdef UNIFY_CHANNEL_MEM_HEAP + *nchan_transport_internal = MC_PARAMUPMIX_MAX_INPUT_CHANS; + *nchan_transport_full = MC_PARAMUPMIX_MAX_INPUT_CHANS; +#endif } else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { @@ -1807,13 +1965,41 @@ int16_t ivas_jbm_dec_get_num_tc_channels( /* LFE is synthesized in TD with the TCs*/ num_tc++; } + *nchan_transport_internal = num_tc; + *nchan_transport_full = num_tc; +#ifdef UNIFY_CHANNEL_MEM_HEAP + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO ) + { + num_tc = st_ivas->hDecoderConfig->nchan_out; + *nchan_transport_internal = num_tc; + *nchan_transport_full = num_tc; + } + else if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + { + *nchan_transport_internal = 2 * BINAURAL_CHANNELS; + *nchan_transport_full = *nchan_transport_internal; + } +#endif + } +#ifdef UNIFY_CHANNEL_MEM_HEAP + else if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) + { + *nchan_transport_internal = num_tc; + *nchan_transport_full = 0; } +#endif } else if ( st_ivas->ivas_format == MONO_FORMAT && st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX ) { num_tc = MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN; +#ifdef UNIFY_CHANNEL_MEM_HEAP + *nchan_transport_internal = num_tc; + *nchan_transport_full = num_tc; +#endif } - +#ifdef UNIFY_CHANNEL_MEM_HEAP + *nchan_transport_jbm = num_tc; +#endif return num_tc; } @@ -1885,14 +2071,36 @@ static void ivas_jbm_dec_copy_tc( /*! r: render granularity */ int16_t ivas_jbm_dec_get_render_granularity( +#ifdef UNIFY_CHANNEL_MEM_HEAP + Decoder_Struct *st_ivas /* i : main decoder structure */ +#else const RENDERER_TYPE rendererType, /* i : renderer type */ const IVAS_FORMAT ivas_format, /* i : ivas format */ const MC_MODE mc_mode, /* i : MC mode */ const int32_t output_Fs /* i : sampling rate */ +#endif ) { int16_t render_granularity; +#ifdef UNIFY_CHANNEL_MEM_HEAP + render_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) + { + if ( ( st_ivas->ivas_format == MC_FORMAT ) && ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) ) + { + render_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + } + else + { + render_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); + } + } + else if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + { + render_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); /* Use the same granularity as tdrend */ + } +#else if ( rendererType == RENDERER_BINAURAL_OBJECTS_TD || rendererType == RENDERER_BINAURAL_MIXER_CONV || rendererType == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { if ( ( ivas_format == MC_FORMAT ) && ( mc_mode == MC_MODE_PARAMUPMIX ) ) @@ -1908,6 +2116,7 @@ int16_t ivas_jbm_dec_get_render_granularity( { render_granularity = NS2SA( output_Fs, CLDFB_SLOT_NS ); } +#endif return render_granularity; } @@ -1962,6 +2171,9 @@ ivas_error ivas_jbm_dec_tc_buffer_open( hTcBuffer->num_slots = nMaxSlotsPerSubframe * MAX_PARAM_SPATIAL_SUBFRAMES; set_s( hTcBuffer->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS ); set_s( hTcBuffer->subframe_nbslots, nMaxSlotsPerSubframe, MAX_PARAM_SPATIAL_SUBFRAMES ); +#ifdef UNIFY_CHANNEL_MEM_HEAP + hTcBuffer->tc_buffer = NULL; +#endif if ( hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_NONE ) { @@ -1971,21 +2183,38 @@ ivas_error ivas_jbm_dec_tc_buffer_open( hTcBuffer->tc[ch_idx] = NULL; } } +#ifdef UNIFY_CHANNEL_MEM_HEAP + else if ( !st_ivas->hDecoderConfig->Opt_tsm ) + { + /* we can directly use the already allocated in/out buffers */ + for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = st_ivas->p_output_f[ch_idx]; + } + for ( ; ch_idx < MAX_TRANSPORT_CHANNELS; ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = NULL; + } + } +#endif else { int16_t n_samp_full, n_samp_residual; int32_t offset; +#ifndef UNIFY_CHANNEL_MEM_HEAP if ( st_ivas->hDecoderConfig->Opt_tsm ) { +#endif n_samp_full = ( NS2SA( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS ) + hTcBuffer->n_samples_granularity - 1 ); n_samp_residual = hTcBuffer->n_samples_granularity - 1; +#ifndef UNIFY_CHANNEL_MEM_HEAP } else { n_samp_full = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); n_samp_residual = 0; } - +#endif nsamp_to_allocate = hTcBuffer->nchan_buffer_full * n_samp_full; nsamp_to_allocate += nchan_residual * n_samp_residual; @@ -2037,20 +2266,36 @@ ivas_error ivas_jbm_dec_tc_buffer_open( *--------------------------------------------------------------------------*/ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +#ifndef UNIFY_CHANNEL_MEM_HEAP + , const TC_BUFFER_MODE tc_buffer_mode, /* i : new buffer mode */ const int16_t nchan_transport_jbm, /* i : new number of real transport channels */ const int16_t nchan_transport_internal, /* i : new number of totally buffered channels */ const int16_t nchan_full, /* i : new number of channels to fully store */ const int16_t n_samples_granularity /* i : new granularity of the renderer/buffer */ +#endif ) { int16_t nsamp_to_allocate, n_samp_full, n_samp_residual, offset, nchan_residual; int16_t ch_idx; DECODER_TC_BUFFER_HANDLE hTcBuffer; +#ifdef UNIFY_CHANNEL_MEM_HEAP + int16_t nchan_transport_jbm; + int16_t nchan_transport_internal; + int16_t nchan_full; + int16_t n_samples_granularity; + TC_BUFFER_MODE tc_buffer_mode; +#endif hTcBuffer = st_ivas->hTcBuffer; +#ifdef UNIFY_CHANNEL_MEM_HEAP + ivas_jbm_dec_get_num_tc_channels( st_ivas, &nchan_transport_jbm, &nchan_transport_internal, &nchan_full ); + tc_buffer_mode = ivas_jbm_dec_get_tc_buffer_mode( st_ivas ); + n_samples_granularity = ivas_jbm_dec_get_render_granularity( st_ivas ); +#endif + /* if granularity changes, adapt subframe_nb_slots */ if ( n_samples_granularity != hTcBuffer->n_samples_granularity ) { @@ -2084,54 +2329,81 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( } } - hTcBuffer->tc_buffer_mode = tc_buffer_mode; - hTcBuffer->nchan_transport_jbm = nchan_transport_jbm; - hTcBuffer->nchan_transport_internal = nchan_transport_internal; - hTcBuffer->nchan_buffer_full = nchan_full; - nchan_residual = nchan_transport_internal - nchan_full; - hTcBuffer->n_samples_granularity = n_samples_granularity; +#ifdef UNIFY_CHANNEL_MEM_HEAP + if ( nchan_transport_jbm != hTcBuffer->nchan_transport_jbm || nchan_transport_internal != hTcBuffer->nchan_transport_internal || nchan_full != hTcBuffer->nchan_buffer_full || tc_buffer_mode != st_ivas->hTcBuffer->tc_buffer_mode || n_samples_granularity != st_ivas->hTcBuffer->n_samples_granularity ) + { + hTcBuffer->tc_buffer_mode = tc_buffer_mode; + hTcBuffer->nchan_transport_jbm = nchan_transport_jbm; + hTcBuffer->nchan_transport_internal = nchan_transport_internal; + hTcBuffer->nchan_buffer_full = nchan_full; + nchan_residual = nchan_transport_internal - nchan_full; + hTcBuffer->n_samples_granularity = n_samples_granularity; + #ifdef DEBUGGING - /* what is remaining from last frames needs always be smaller than n_samples_granularity */ - assert( ( hTcBuffer->n_samples_buffered - hTcBuffer->n_samples_rendered ) < n_samples_granularity ); + /* what is remaining from last frames needs always be smaller than n_samples_granularity */ + assert( ( hTcBuffer->n_samples_buffered - hTcBuffer->n_samples_rendered ) < n_samples_granularity ); #endif - /* realloc buffers */ - free( hTcBuffer->tc_buffer ); - if ( st_ivas->hDecoderConfig->Opt_tsm ) - { - n_samp_full = ( NS2SA( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS ) + hTcBuffer->n_samples_granularity - 1 ); - n_samp_residual = hTcBuffer->n_samples_granularity - 1; - } - else - { - n_samp_full = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); - n_samp_residual = 0; - } - nsamp_to_allocate = hTcBuffer->nchan_buffer_full * n_samp_full; - nsamp_to_allocate += nchan_residual * n_samp_residual; + if ( !st_ivas->hDecoderConfig->Opt_tsm ) + { + /* we can directly use the already allocated in/out buffers */ + for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = st_ivas->p_output_f[ch_idx]; + } + for ( ; ch_idx < MAX_TRANSPORT_CHANNELS; ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = NULL; + } + } - if ( ( hTcBuffer->tc_buffer = (float *) malloc( nsamp_to_allocate * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) ); - } - set_zero( hTcBuffer->tc_buffer, nsamp_to_allocate ); + else + { +#endif + /* realloc buffers */ + free( hTcBuffer->tc_buffer ); +#ifndef UNIFY_CHANNEL_MEM_HEAP + if ( st_ivas->hDecoderConfig->Opt_tsm ) + { +#endif + n_samp_full = ( NS2SA( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS ) + hTcBuffer->n_samples_granularity - 1 ); + n_samp_residual = hTcBuffer->n_samples_granularity - 1; +#ifndef UNIFY_CHANNEL_MEM_HEAP + } + else + { + n_samp_full = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); + n_samp_residual = 0; + } +#endif + nsamp_to_allocate = hTcBuffer->nchan_buffer_full * n_samp_full; + nsamp_to_allocate += nchan_residual * n_samp_residual; - offset = 0; - for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) - { - hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; - offset += n_samp_full; - } - for ( ; ch_idx < hTcBuffer->nchan_transport_internal; ch_idx++ ) - { - hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; - offset += n_samp_residual; - } - for ( ; ch_idx < MAX_TRANSPORT_CHANNELS; ch_idx++ ) - { - hTcBuffer->tc[ch_idx] = NULL; - } + if ( ( hTcBuffer->tc_buffer = (float *) malloc( nsamp_to_allocate * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) ); + } + set_zero( hTcBuffer->tc_buffer, nsamp_to_allocate ); + offset = 0; + for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; + offset += n_samp_full; + } + for ( ; ch_idx < hTcBuffer->nchan_transport_internal; ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; + offset += n_samp_residual; + } + for ( ; ch_idx < MAX_TRANSPORT_CHANNELS; ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = NULL; + } +#ifdef UNIFY_CHANNEL_MEM_HEAP + } + } +#endif return IVAS_ERR_OK; } @@ -2313,11 +2585,19 @@ TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( } break; case RENDERER_MC: +#ifdef UNIFY_CHANNEL_MEM_HEAP + { + int16_t num_tc, tmp1, tmp2; + ivas_jbm_dec_get_num_tc_channels( st_ivas, &num_tc, &tmp1, &tmp2 ); + if ( num_tc != st_ivas->hDecoderConfig->nchan_out ) +#else if ( ivas_jbm_dec_get_num_tc_channels( st_ivas ) != st_ivas->hDecoderConfig->nchan_out ) +#endif { buffer_mode = TC_BUFFER_MODE_RENDERER; } - break; + } + break; case RENDERER_SBA_LINEAR_ENC: if ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCT && ( st_ivas->renderer_type == RENDERER_MC || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) && ( st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe ) >= ( st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe ) ) { @@ -2369,12 +2649,14 @@ void ivas_jbm_dec_copy_tc_no_tsm( hTcBuffer->n_samples_available = hTcBuffer->n_samples_buffered; n_ch_full_copy = min( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); n_ch_cldfb = hTcBuffer->nchan_transport_jbm - hTcBuffer->nchan_buffer_full; + /* copy full tcs*/ for ( ch_idx = 0; ch_idx < n_ch_full_copy; ch_idx++ ) { +#ifndef UNIFY_CHANNEL_MEM_HEAP mvr2r( tc[ch_idx], st_ivas->hTcBuffer->tc[ch_idx], hTcBuffer->n_samples_buffered ); +#endif } - /* CLDFB ana for ParamMC/ParamISM */ if ( n_ch_cldfb > 0 ) { diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 546d01d27d..708224b53a 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -621,6 +621,7 @@ ivas_error ivas_masa_dec_open( st_ivas->hMasa = hMasa; +#ifndef UNIFY_CHANNEL_MEM_HEAP /* allocate transport channels*/ if ( #ifndef REMOVE_5MS_FLAG @@ -652,6 +653,7 @@ ivas_error ivas_masa_dec_open( return error; } } +#endif return error; } @@ -1452,18 +1454,25 @@ ivas_error ivas_masa_dec_reconfigure( if ( st_ivas->hDecoderConfig->Opt_5ms == 1 ) #endif { +#ifndef UNIFY_CHANNEL_MEM_HEAP int16_t tc_nchan_to_allocate; int16_t tc_nchan_transport; TC_BUFFER_MODE buffer_mode_new; +#endif int16_t n_samples_granularity; +#ifdef UNIFY_CHANNEL_MEM_HEAP + n_samples_granularity = ivas_jbm_dec_get_render_granularity( st_ivas ); +#else n_samples_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode( st_ivas ); tc_nchan_transport = ivas_jbm_dec_get_num_tc_channels( st_ivas ); tc_nchan_to_allocate = tc_nchan_transport; +#endif if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { +#ifndef UNIFY_CHANNEL_MEM_HEAP if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) { tc_nchan_to_allocate = 2 * BINAURAL_CHANNELS + 2; @@ -1472,11 +1481,12 @@ ivas_error ivas_masa_dec_reconfigure( { tc_nchan_to_allocate = 2 * BINAURAL_CHANNELS; } - +#endif if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { +#ifndef UNIFY_CHANNEL_MEM_HEAP n_samples_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); /* Use the same granularity as tdrend */ - +#endif if ( n_samples_granularity > st_ivas->hTcBuffer->n_samples_granularity ) { if ( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK ) @@ -1501,6 +1511,12 @@ ivas_error ivas_masa_dec_reconfigure( } } +#ifdef UNIFY_CHANNEL_MEM_HEAP + if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } +#else if ( tc_nchan_transport != st_ivas->hTcBuffer->nchan_transport_jbm || tc_nchan_to_allocate != st_ivas->hTcBuffer->nchan_transport_internal || buffer_mode_new != st_ivas->hTcBuffer->tc_buffer_mode ) { if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas, buffer_mode_new, tc_nchan_transport, tc_nchan_to_allocate, tc_nchan_to_allocate, n_samples_granularity ) ) != IVAS_ERR_OK ) @@ -1508,6 +1524,7 @@ ivas_error ivas_masa_dec_reconfigure( return error; } } +#endif if ( st_ivas->hSpatParamRendCom != NULL && st_ivas->hSpatParamRendCom->slot_size == st_ivas->hTcBuffer->n_samples_granularity ) { diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index e4fb73e24c..3de5aae653 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -467,6 +467,7 @@ ivas_error ivas_param_mc_dec_open( } set_zero( hParamMC->Cldfb_ImagBuffer_tc, n_cldfb_slots * nchan_transport * hParamMC->num_freq_bands ); +#ifndef UNIFY_CHANNEL_MEM_HEAP if ( st_ivas->hTcBuffer == NULL ) { if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, 0, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) @@ -474,6 +475,7 @@ ivas_error ivas_param_mc_dec_open( return error; } } +#endif } else { diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index 8880d335a4..e498f7a484 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -709,6 +709,22 @@ ivas_error ivas_mc_paramupmix_dec_open( /* allocate transport channels*/ hMCParamUpmix->free_param_interpolator = 0; hMCParamUpmix->param_interpolator = NULL; +#ifdef FIX_XXX_JBM_PARAMUPMIX_RS +#ifndef REMOVE_5MS_FLAG + if ( st_ivas->hDecoderConfig->Opt_5ms == 1 ) +#endif + { + 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 + +#ifndef UNIFY_CHANNEL_MEM_HEAP if ( #ifndef REMOVE_5MS_FLAG st_ivas->hDecoderConfig->Opt_5ms == 1 && @@ -722,10 +738,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 FIX_XXX_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 ) { @@ -741,11 +759,13 @@ ivas_error ivas_mc_paramupmix_dec_open( { return error; } +#ifndef FIX_XXX_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 } - +#endif st_ivas->hMCParamUpmix = hMCParamUpmix; return error; diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 720ca106f2..a4efa926c7 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -733,9 +733,11 @@ static ivas_error ivas_mc_dec_reconfig( Decoder_State *st; ivas_error error; MC_MODE mc_mode, last_mc_mode; +#ifndef UNIFY_CHANNEL_MEM_HEAP TC_BUFFER_MODE tc_buffer_mode_new; int16_t tc_nchan_tc_new; int16_t tc_nchan_allocate_new; +#endif int16_t tc_granularity_new; AUDIO_CONFIG intern_config_old; IVAS_OUTPUT_SETUP hIntSetupOld; @@ -804,7 +806,11 @@ static ivas_error ivas_mc_dec_reconfig( /* JBM: when granularity goes down (e.g. MCT with CREND -> ParamMC with binaural fastconv render what still fits in the new granularity */ +#ifdef UNIFY_CHANNEL_MEM_HEAP + tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas ); +#else tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); +#endif if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) { #ifdef SPLIT_REND_WITH_HEAD_ROT @@ -1344,6 +1350,12 @@ static ivas_error ivas_mc_dec_reconfig( if ( st_ivas->hDecoderConfig->Opt_5ms == 1 ) #endif { +#ifdef UNIFY_CHANNEL_MEM_HEAP + if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } +#else int16_t tc_nchan_full_new; DECODER_TC_BUFFER_HANDLE hTcBuffer; @@ -1361,7 +1373,19 @@ static ivas_error ivas_mc_dec_reconfig( { tc_nchan_full_new = 0; } - +#ifdef FIX_XXX_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 || hTcBuffer->nchan_buffer_full != tc_nchan_full_new || hTcBuffer->nchan_transport_internal != tc_nchan_allocate_new || @@ -1372,7 +1396,7 @@ static ivas_error ivas_mc_dec_reconfig( return error; } } - +#endif /* transfer subframe info from central tc buffer to ParamMC or McMASA (DirAC) */ if ( st_ivas->hSpatParamRendCom != NULL ) { diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index fe0daa1547..83772206a9 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -180,7 +180,11 @@ ivas_error ivas_omasa_dec_config( ivas_format_orig = st_ivas->ivas_format; st_ivas->ivas_format = st_ivas->last_ivas_format; ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); +#ifdef UNIFY_CHANNEL_MEM_HEAP + nchan_out_buff_old = ivas_count_nchan_buffers_dec( st_ivas ); +#else nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas ); +#endif st_ivas->ivas_format = ivas_format_orig; nSCE_old = st_ivas->nSCE; diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 7bc28123d9..1e41622eef 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -150,7 +150,11 @@ ivas_error ivas_sba_dec_reconfigure( nCPE_old = st_ivas->nCPE; nchan_transport_old = st_ivas->nchan_transport; sba_dirac_stereo_flag_old = st_ivas->sba_dirac_stereo_flag; +#ifdef UNIFY_CHANNEL_MEM_HEAP + nchan_out_buff_old = ivas_count_nchan_buffers_dec( st_ivas ); +#else nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas ); +#endif st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order ); @@ -522,6 +526,7 @@ ivas_error ivas_sba_dec_reconfigure( return error; } +#ifndef UNIFY_CHANNEL_MEM_HEAP /*-----------------------------------------------------------------* * JBM TC buffer *-----------------------------------------------------------------*/ @@ -566,6 +571,7 @@ ivas_error ivas_sba_dec_reconfigure( } } } +#endif /*-----------------------------------------------------------------* * floating-point output audio buffers @@ -597,6 +603,13 @@ ivas_error ivas_sba_dec_reconfigure( } } +#ifdef UNIFY_CHANNEL_MEM_HEAP + if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } +#endif + return error; } diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 92cc99ebc6..307e2ecf0d 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -75,6 +75,7 @@ ivas_error ivas_spar_dec_open( int16_t num_decor_chs, map_idx; error = IVAS_ERR_OK; + sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); num_channels_internal = ivas_sba_get_nchan_metadata( sba_order_internal, st_ivas->hDecoderConfig->ivas_total_brate ); @@ -210,6 +211,7 @@ ivas_error ivas_spar_dec_open( hSpar->render_to_md_map[map_idx] = map_idx; } +#ifndef UNIFY_CHANNEL_MEM_HEAP /* allocate transport channels*/ if ( #ifndef REMOVE_5MS_FLAG @@ -240,6 +242,7 @@ ivas_error ivas_spar_dec_open( return error; } } +#endif st_ivas->hSpar = hSpar; diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 37488b9e7e..01b41f4df1 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -305,6 +305,7 @@ ivas_error ivas_dirac_dec_init_binaural_data( st_ivas->hDiracDecBin = hDiracDecBin; #endif +#ifndef UNIFY_CHANNEL_MEM_HEAP /* allocate transport channels*/ if ( #ifndef REMOVE_5MS_FLAG @@ -332,7 +333,7 @@ ivas_error ivas_dirac_dec_init_binaural_data( return error; } } - +#endif return IVAS_ERR_OK; } diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index 7dceb4a293..2850c8034e 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -36,6 +36,9 @@ #include "prot.h" #include "ivas_prot_rend.h" #include "ivas_rom_com.h" +#ifdef UNIFY_CHANNEL_MEM_HEAP +#include "ivas_prot.h" +#endif #ifdef DEBUGGING #include "debug.h" #include @@ -393,5 +396,45 @@ int16_t ivas_get_nchan_buffers_dec( } #endif +#ifdef UNIFY_CHANNEL_MEM_HEAP + if ( !st_ivas->hDecoderConfig->Opt_tsm ) + { + int16_t nchan_buf_full, tmp1, tmp2; + ivas_jbm_dec_get_num_tc_channels( st_ivas, &tmp1, &tmp2, &nchan_buf_full ); + nchan_out_buff = max( nchan_out_buff, nchan_buf_full ); + } +#endif + return nchan_out_buff; } + +#ifdef UNIFY_CHANNEL_MEM_HEAP +/*-----------------------------------------------------------------* + * ivas_count_nchan_buffers_dec() + * + * Return number of decoder audio buffers + *-----------------------------------------------------------------*/ + +/*! r: number of allocated decoder buffers */ +int16_t ivas_count_nchan_buffers_dec( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +) +{ + int16_t ch_idx, ch_cnt; + for ( ch_idx = 0, ch_cnt = 0; ch_idx < MAX_OUTPUT_CHANNELS; ch_idx++, ch_cnt++ ) + { + if ( st_ivas->p_output_f[ch_idx] == NULL ) + { + break; + } + } +#ifdef DEBUGGING + for (; ch_idx < MAX_OUTPUT_CHANNELS; ch_idx++) + { + assert( st_ivas->p_output_f[ch_idx] == NULL ); + } +#endif + + return ch_cnt; +} +#endif \ No newline at end of file diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index a41dd1d543..c014e07c99 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -74,7 +74,11 @@ void ivas_output_init( int16_t ivas_get_nchan_buffers_dec( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); - +#ifdef UNIFY_CHANNEL_MEM_HEAP +int16_t ivas_count_nchan_buffers_dec( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); +#endif /*----------------------------------------------------------------------------------* * Limiter prototypes diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index bbc1e65e00..19c70a65eb 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -1397,16 +1397,6 @@ static void external_target_interpolation( { if ( i > 0 ) { -#ifdef NONBE_UNIFIED_DECODING_PATHS_1 - if ( hExtOrientationData->enableExternalOrientation[i - 1] != 1 ) - { - IVAS_QUATERNION identity; - identity.w = 1.0f; - identity.x = identity.y = identity.z = 0.0f; - hCombinedOrientationData->Quaternions_ext_interpolation_start = identity; - } - else -#endif { hCombinedOrientationData->Quaternions_ext_interpolation_start = hExtOrientationData->Quaternions[i - 1]; } -- GitLab From e94604a888c2d412785cf83e36e9a567d574b543 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Mon, 25 Sep 2023 13:06:02 +0200 Subject: [PATCH 08/49] fix rs for OMASA and unified channel mem, disable unified channel mem for the moment --- lib_com/options.h | 2 +- lib_dec/ivas_masa_dec.c | 23 +++++++++++++++-------- lib_dec/ivas_omasa_dec.c | 25 +++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 9 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 92bd3cfe29..a6c3d17b60 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -201,7 +201,7 @@ #ifdef NONBE_UNIFIED_DECODING_PATHS #define REMOVE_5MS_FLAG #define FIX_XXX_JBM_PARAMUPMIX_RS -#define UNIFY_CHANNEL_MEM_HEAP +/*#define UNIFY_CHANNEL_MEM_HEAP*/ #endif #define NONBE_FIX_722_MEMORY_LEAK_IN_PARAMUPMIX /* Dlb : issue 722: memory leak fix in MC param upmix mode with BR switching*/ #define NONBE_FIX_780_ISM_STARTS_WITH_SID /* VA: issue 780: fix Crash in ISM decoding when bitstream starts with an SID and output_config is not EXT */ diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 708224b53a..77cfe732aa 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -1512,10 +1512,12 @@ ivas_error ivas_masa_dec_reconfigure( } #ifdef UNIFY_CHANNEL_MEM_HEAP - if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) + if ( st_ivas->ivas_format != MASA_ISM_FORMAT ) { - return error; - } + if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } #else if ( tc_nchan_transport != st_ivas->hTcBuffer->nchan_transport_jbm || tc_nchan_to_allocate != st_ivas->hTcBuffer->nchan_transport_internal || buffer_mode_new != st_ivas->hTcBuffer->tc_buffer_mode ) { @@ -1526,13 +1528,17 @@ ivas_error ivas_masa_dec_reconfigure( } #endif - if ( st_ivas->hSpatParamRendCom != NULL && st_ivas->hSpatParamRendCom->slot_size == st_ivas->hTcBuffer->n_samples_granularity ) - { - mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); - st_ivas->hSpatParamRendCom->nb_subframes = st_ivas->hTcBuffer->nb_subframes; - st_ivas->hSpatParamRendCom->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; + if ( st_ivas->hSpatParamRendCom != NULL && st_ivas->hSpatParamRendCom->slot_size == st_ivas->hTcBuffer->n_samples_granularity ) + { + mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); + st_ivas->hSpatParamRendCom->nb_subframes = st_ivas->hTcBuffer->nb_subframes; + st_ivas->hSpatParamRendCom->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; + } +#ifdef UNIFY_CHANNEL_MEM_HEAP } +#endif +#ifndef UNIFY_CHANNEL_MEM_HEAP if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { int16_t granularityMultiplier = st_ivas->hTcBuffer->n_samples_granularity / st_ivas->hSpatParamRendCom->slot_size; @@ -1542,6 +1548,7 @@ ivas_error ivas_masa_dec_reconfigure( st_ivas->hSpatParamRendCom->subframe_nbslots[n] = st_ivas->hTcBuffer->subframe_nbslots[n] * granularityMultiplier; } } +#endif } return error; diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index 83772206a9..1383a00095 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -442,6 +442,31 @@ ivas_error ivas_omasa_dec_config( } } +#ifdef UNIFY_CHANNEL_MEM_HEAP + if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( st_ivas->hSpatParamRendCom != NULL && st_ivas->hSpatParamRendCom->slot_size == st_ivas->hTcBuffer->n_samples_granularity ) + { + mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); + st_ivas->hSpatParamRendCom->nb_subframes = st_ivas->hTcBuffer->nb_subframes; + st_ivas->hSpatParamRendCom->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; + } + + + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + { + int16_t granularityMultiplier = st_ivas->hTcBuffer->n_samples_granularity / st_ivas->hSpatParamRendCom->slot_size; + int16_t n; + for ( n = 0; n < MAX_JBM_SUBFRAMES_5MS; n++ ) + { + st_ivas->hSpatParamRendCom->subframe_nbslots[n] = st_ivas->hTcBuffer->subframe_nbslots[n] * granularityMultiplier; + } + } +#endif + return IVAS_ERR_OK; } -- GitLab From 90d00854c395f156c7e95e2ddaf34b4d5ced2f92 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Mon, 25 Sep 2023 13:40:35 +0200 Subject: [PATCH 09/49] fix function definition and declaration mismatch --- lib_dec/lib_dec.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index a1e6ea2514..2dd568e611 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -125,7 +125,11 @@ ivas_error IVAS_DEC_Configure( const uint32_t sampleRate, /* i : output sampling frequency */ const IVAS_AUDIO_CONFIG outputConfig, /* i : audio configuration */ const int16_t tsmEnabled, /* i : enable TSM */ - const int16_t enable5ms, /* i : enable 5ms rendering path */ +#ifndef REMOVE_5MS_FLAG + const int16_t enable5ms, /* i : enable 5ms rendering path */ +#else + const RENDER_FRAMESIZE renderFramesize, /* i : rendering frame size */ +#endif const int16_t customLsOutputEnabled, /* i : enable custom loudspeaker setup handle */ const int16_t hrtfReaderEnabled, /* i : enable HRTF binary file input */ const int16_t enableHeadRotation, /* i : enable head rotation for binaural output */ -- GitLab From e22fc5a115b303abf7948b60e5417ca583f616b6 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Mon, 25 Sep 2023 14:04:15 +0200 Subject: [PATCH 10/49] clang-format, fix a few compiler warnings --- apps/decoder.c | 1 + lib_dec/ivas_binRenderer_internal.c | 2 +- lib_dec/ivas_ism_dec.c | 6 +++--- lib_dec/ivas_objectRenderer_internal.c | 28 +++++++++++++------------- lib_dec/lib_dec.c | 14 ++++++------- lib_rend/ivas_objectRenderer.c | 14 ++++++------- lib_rend/ivas_output_init.c | 6 +++--- lib_rend/lib_rend.c | 2 +- 8 files changed, 37 insertions(+), 36 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 3f78b589ea..0f199b6eca 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1310,6 +1310,7 @@ static bool parseCmdlIVAS_dec( break; case 20: arg->renderFramesize = RENDER_FRAMESIZE_20MS; + break; default: fprintf( stderr, "Error: Invalid render frame size %d \n\n", tmp ); usage_dec(); diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index 95a753ea8e..379bbd46e3 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -1650,7 +1650,7 @@ void ivas_binaural_cldfb( st_ivas->hCombinedOrientationData, #ifndef NONBE_UNIFIED_DECODING_PATHS subframeIdx, -#endif +#endif JBM_CLDFB_SLOTS_IN_SUBFRAME, #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG NULL, diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index ddd0c75b3a..c6ee19c44f 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -467,9 +467,9 @@ static ivas_error ivas_ism_bitrate_switching_dec( *-------------------------------------------------------------------------*/ ivas_error ivas_ism_dec_config( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const ISM_MODE last_ism_mode, /* i/o: last ISM mode */ - uint16_t *nSamplesRendered, /* o : number of samples flushed when the renderer granularity changes */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const ISM_MODE last_ism_mode, /* i/o: last ISM mode */ + uint16_t *nSamplesRendered, /* o : number of samples flushed when the renderer granularity changes */ #ifdef SPLIT_REND_WITH_HEAD_ROT const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ void *data /* o : output synthesis signal */ diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index caa3cc25e3..d9e737f062 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -100,14 +100,14 @@ ivas_error ivas_td_binaural_renderer( return ivas_td_binaural_renderer_unwrap( st_ivas->hReverb, st_ivas->transport_config, st_ivas->hBinRendererTd, nchan_transport, LFE_CHANNEL, st_ivas->ivas_format, st_ivas->hIsmMetaData, #ifdef NONBE_UNIFIED_DECODING_PATHS - st_ivas->hCombinedOrientationData, + st_ivas->hCombinedOrientationData, #else - ( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->enableCombinedOrientation : NULL, - ( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->Quaternions : NULL, - ( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->listenerPos : NULL, + ( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->enableCombinedOrientation : NULL, + ( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->Quaternions : NULL, + ( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->listenerPos : NULL, #endif - ism_md_subframe_update, output, output_frame, - MAX_PARAM_SPATIAL_SUBFRAMES ); + ism_md_subframe_update, output, output_frame, + MAX_PARAM_SPATIAL_SUBFRAMES ); } @@ -219,17 +219,17 @@ ivas_error ivas_td_binaural_renderer_sf( } /* Update the listener's location/orientation */ - if ( ( error = TDREND_Update_listener_orientation( st_ivas->hBinRendererTd, + if ( ( error = TDREND_Update_listener_orientation( st_ivas->hBinRendererTd, #ifdef NONBE_UNIFIED_DECODING_PATHS - ( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] : 0, - ( st_ivas->hCombinedOrientationData != NULL ) ? &st_ivas->hCombinedOrientationData->Quaternions[st_ivas->hCombinedOrientationData->subframe_idx] : NULL, - ( st_ivas->hCombinedOrientationData != NULL ) ? &st_ivas->hCombinedOrientationData->listenerPos[st_ivas->hCombinedOrientationData->subframe_idx] : NULL + ( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] : 0, + ( st_ivas->hCombinedOrientationData != NULL ) ? &st_ivas->hCombinedOrientationData->Quaternions[st_ivas->hCombinedOrientationData->subframe_idx] : NULL, + ( st_ivas->hCombinedOrientationData != NULL ) ? &st_ivas->hCombinedOrientationData->listenerPos[st_ivas->hCombinedOrientationData->subframe_idx] : NULL #else - ( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->enableCombinedOrientation[subframe_idx] : 0, - ( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->Quaternions : NULL, - ( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->listenerPos : NULL + ( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->enableCombinedOrientation[subframe_idx] : 0, + ( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->Quaternions : NULL, + ( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->listenerPos : NULL #endif - ) ) != IVAS_ERR_OK ) + ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 983fa73899..c4c9294d6c 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -372,14 +372,14 @@ static IVAS_DEC_BS_FORMAT mapIvasFormat( *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_Configure( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const uint32_t sampleRate, /* i : output sampling frequency */ - const AUDIO_CONFIG outputConfig, /* i : output configuration */ - const int16_t tsmEnabled, /* i : enable time scale modification */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const uint32_t sampleRate, /* i : output sampling frequency */ + const AUDIO_CONFIG outputConfig, /* i : output configuration */ + const int16_t tsmEnabled, /* i : enable time scale modification */ #ifndef REMOVE_5MS_FLAG - const int16_t enable5ms, /* i : enable 5ms rendering path */ + const int16_t enable5ms, /* i : enable 5ms rendering path */ #else - const RENDER_FRAMESIZE renderFramesize, /* i : rendering frame size */ + const RENDER_FRAMESIZE renderFramesize, /* i : rendering frame size */ #endif const int16_t customLsOutputEnabled, /* i : enable custom loudspeaker setup handle */ const int16_t hrtfReaderEnabled, /* i : enable HRTF binary file input */ @@ -826,7 +826,7 @@ ivas_error IVAS_DEC_GetSamples( const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ void *pcmBuf, /* o : output synthesis signal */ #else - int16_t *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ + int16_t *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ #endif int16_t *nOutSamples, /* o : number of samples per channel written to output buffer */ bool *needNewFrame /* o :indication that the decoder needs a new frame */ diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index e4f4feaad6..f153f647e0 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -294,10 +294,10 @@ ivas_error ivas_td_binaural_renderer_unwrap( const IVAS_QUATERNION *Quaternions, /* i : Head tracking data per subframe */ const IVAS_VECTOR3 *Pos, /* i : Listener position data per subframe */ #endif - const int16_t ism_md_subframe_update, /* i : Number of subframes to delay ism metadata to sync with audio */ - float *output[], /* i/o: SCE channels / Binaural synthesis */ - const int16_t output_frame, /* i : output frame length */ - const int16_t num_subframes /* i : number of subframes to render */ + const int16_t ism_md_subframe_update, /* i : Number of subframes to delay ism metadata to sync with audio */ + float *output[], /* i/o: SCE channels / Binaural synthesis */ + const int16_t output_frame, /* i : output frame length */ + const int16_t num_subframes /* i : number of subframes to render */ ) { int16_t subframe_length; @@ -357,11 +357,11 @@ ivas_error ivas_td_binaural_renderer_unwrap( /* Update the listener's location/orientation */ if ( ( error = TDREND_Update_listener_orientation( hBinRendererTd, #ifdef NONBE_UNIFIED_DECODING_PATHS - ( enableCombinedOrientation != NULL ) ? enableCombinedOrientation[hCombinedOrientationData->subframe_idx] : 0, ( Quaternions != NULL ) ? &Quaternions[hCombinedOrientationData->subframe_idx] : NULL, ( Pos != NULL ) ? &Pos[hCombinedOrientationData->subframe_idx] : NULL + ( enableCombinedOrientation != NULL ) ? enableCombinedOrientation[hCombinedOrientationData->subframe_idx] : 0, ( Quaternions != NULL ) ? &Quaternions[hCombinedOrientationData->subframe_idx] : NULL, ( Pos != NULL ) ? &Pos[hCombinedOrientationData->subframe_idx] : NULL #else - ( enableCombinedOrientation != NULL ) ? enableCombinedOrientation[subframe_idx] : 0, ( Quaternions != NULL ) ? &Quaternions[subframe_idx] : NULL, ( Pos != NULL ) ? &Pos[subframe_idx] : NULL + ( enableCombinedOrientation != NULL ) ? enableCombinedOrientation[subframe_idx] : 0, ( Quaternions != NULL ) ? &Quaternions[subframe_idx] : NULL, ( Pos != NULL ) ? &Pos[subframe_idx] : NULL #endif - ) ) != IVAS_ERR_OK ) + ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index 46130f8f53..edd3d885c9 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -36,7 +36,7 @@ #include "prot.h" #include "ivas_prot_rend.h" #include "ivas_rom_com.h" -#if defined (NONBE_FIX_798_OSBA_MC_DEC_CRASH) || defined (UNIFY_CHANNEL_MEM_HEAP) +#if defined( NONBE_FIX_798_OSBA_MC_DEC_CRASH ) || defined( UNIFY_CHANNEL_MEM_HEAP ) #include "ivas_prot.h" #endif #ifdef DEBUGGING @@ -447,7 +447,7 @@ int16_t ivas_count_nchan_buffers_dec( } } #ifdef DEBUGGING - for (; ch_idx < MAX_OUTPUT_CHANNELS; ch_idx++) + for ( ; ch_idx < MAX_OUTPUT_CHANNELS; ch_idx++ ) { assert( st_ivas->p_output_f[ch_idx] == NULL ); } @@ -455,4 +455,4 @@ int16_t ivas_count_nchan_buffers_dec( return ch_cnt; } -#endif \ No newline at end of file +#endif diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index f6850dc195..a6f1b42c4c 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -3302,7 +3302,7 @@ static DecoderDummy *initDecoderDummy( } /* Combined orientations */ - if ( ( error = ivas_combined_orientation_open( &( decDummy->hCombinedOrientationData ), + if ( ( error = ivas_combined_orientation_open( &( decDummy->hCombinedOrientationData ), #ifdef NONBE_UNIFIED_DECODING_PATHS sampleRate, #endif -- GitLab From 0b1afa1c9ccff77d13b4f7d8a2d2096bf193b8cd Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Mon, 25 Sep 2023 15:02:29 +0200 Subject: [PATCH 11/49] temporary sanity check, make sure that OSBA modes crash instead of running into an infinite loop --- lib_dec/ivas_jbm_dec.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 5fddd72bc6..9d101d29f6 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -2000,6 +2000,12 @@ int16_t ivas_jbm_dec_get_num_tc_channels( *nchan_transport_full = num_tc; #endif } +#ifdef NONBE_UNIFIED_DECODING_PATHS + else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + assert( !"Format not implemented in JBM yet!" ); + } +#endif #ifdef UNIFY_CHANNEL_MEM_HEAP *nchan_transport_jbm = num_tc; #endif -- GitLab From 165535858546fec998c5ae47f37a0d4b1a6f9f0e Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Mon, 25 Sep 2023 15:24:49 +0200 Subject: [PATCH 12/49] fix sanitizer errors --- lib_dec/ivas_ism_param_dec.c | 12 ++++++++++-- lib_dec/ivas_sba_dec.c | 7 +++++++ lib_dec/ivas_stat_dec.h | 3 ++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index afde3e2da6..f639d018eb 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -2787,7 +2787,11 @@ void ivas_param_ism_dec_digest_tc( } } } - if ( st_ivas->hDecoderConfig->Opt_tsm || !st_ivas->hDecoderConfig->Opt_5ms ) + if ( st_ivas->hDecoderConfig->Opt_tsm +#ifndef REMOVE_5MS_FLAG + || !st_ivas->hDecoderConfig->Opt_5ms +#endif + ) { /*TODO : FhG to check*/ ivas_ism_param_dec_tc_gain_ajust( st_ivas, output_frame, fade_len, transport_channels_f ); @@ -2800,7 +2804,11 @@ void ivas_param_ism_dec_digest_tc( *-----------------------------------------------------------------*/ for ( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) { - if ( st_ivas->hDecoderConfig->Opt_tsm || !st_ivas->hDecoderConfig->Opt_5ms ) + if ( st_ivas->hDecoderConfig->Opt_tsm +#ifndef REMOVE_5MS_FLAG + || !st_ivas->hDecoderConfig->Opt_5ms +#endif + ) { float RealBuffer[CLDFB_NO_CHANNELS_MAX]; diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 63993c1dac..836e2a0a1d 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -551,6 +551,13 @@ ivas_error ivas_sba_dec_reconfigure( tc_buffer_mode = TC_BUFFER_MODE_RENDERER; tc_nchan_tc = ivas_jbm_dec_get_num_tc_channels( st_ivas ); tc_nchan_to_allocate = tc_nchan_tc; +#ifdef NONBE_UNIFIED_DECODING_PATHS + if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + assert( !"Format not implemented in JBM yet!" ); + } + else +#endif if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO ) { tc_buffer_mode = TC_BUFFER_MODE_BUFFER; diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 114d6f96d7..d875707518 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1064,8 +1064,9 @@ typedef struct decoder_config_structure #endif #ifdef REMOVE_5MS_FLAG RENDER_FRAMESIZE render_framesize; -#endif +#else int16_t Opt_5ms; +#endif int16_t Opt_delay_comp; /* flag indicating delay compensation active */ } DECODER_CONFIG, *DECODER_CONFIG_HANDLE; -- GitLab From 74bc4cb0e92cef9e9a1057269d95ef25a0d11665 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Wed, 27 Sep 2023 07:24:39 +0200 Subject: [PATCH 13/49] several temp fixes for differences between JBM and non-JBM paths (will be removed later, issues #825, #826, #827 and MRs !1111, #1112. !1115 are already existing for those) --- lib_com/options.h | 3 +++ lib_dec/ivas_jbm_dec.c | 5 +++++ lib_dec/ivas_masa_dec.c | 30 ++++++++++++++++++++++++++++++ lib_dec/ivas_sba_dec.c | 15 ++++++++++++++- lib_rend/ivas_crend.c | 4 ++++ 5 files changed, 56 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 8174b82c52..e1f8533668 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -204,7 +204,10 @@ #ifdef NONBE_UNIFIED_DECODING_PATHS #define REMOVE_5MS_FLAG #define FIX_XXX_JBM_PARAMUPMIX_RS +#define FIX_XXX_JBM_SBA +#define FIX_XXX_MASA_CNA /*#define UNIFY_CHANNEL_MEM_HEAP*/ +#define FIX_XXX_CREND_ER #endif #define NONBE_FIX_722_MEMORY_LEAK_IN_PARAMUPMIX /* Dlb : issue 722: memory leak fix in MC param upmix mode with BR switching*/ #define NONBE_FIX_780_ISM_STARTS_WITH_SID /* VA: issue 780: fix Crash in ISM decoding when bitstream starts with an SID and output_config is not EXT */ diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 9d101d29f6..e515dd34da 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -315,7 +315,12 @@ ivas_error ivas_jbm_dec_tc( num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, ivas_total_brate, st_ivas->last_active_ivas_total_brate ); ivas_sba_mix_matrix_determiner( st_ivas->hSpar, p_output, st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames ); } + +#ifdef FIX_XXX_JBM_SBA + else if ( st_ivas->renderer_type != RENDERER_DISABLE ) +#else else +#endif { ivas_spar_dec_agc_pca( st_ivas, p_output, output_frame ); } diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 77cfe732aa..e23c7dfe9d 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -631,6 +631,9 @@ ivas_error ivas_masa_dec_open( { int16_t nchan_to_allocate; TC_BUFFER_MODE buffer_mode; +#ifdef FIX_XXX_MASA_CNA + int16_t nchan_transport; +#endif buffer_mode = TC_BUFFER_MODE_RENDERER; if ( st_ivas->mc_mode == MC_MODE_MCMASA && ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO ) ) @@ -642,13 +645,32 @@ ivas_error ivas_masa_dec_open( buffer_mode = TC_BUFFER_MODE_BUFFER; } +#ifdef FIX_XXX_MASA_CNA + nchan_transport = ivas_jbm_dec_get_num_tc_channels( st_ivas ); + nchan_to_allocate = nchan_transport; +#else nchan_to_allocate = ivas_jbm_dec_get_num_tc_channels( st_ivas ); +#endif if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) { +#ifdef FIX_XXX_MASA_CNA + nchan_transport = 1; +#endif nchan_to_allocate = 1; } +#ifdef FIX_XXX_MASA_CNA + else if ( st_ivas->nchan_transport == 1 && ( st_ivas->renderer_type == RENDERER_DIRAC ) ) + { + /* addtl channel for CNG */ + nchan_to_allocate++; + } +#endif +#ifdef FIX_XXX_MASA_CNA + if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, buffer_mode, nchan_transport, nchan_to_allocate, nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, buffer_mode, nchan_to_allocate, nchan_to_allocate, nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -1510,6 +1532,14 @@ ivas_error ivas_masa_dec_reconfigure( } } } +#ifdef FIX_XXX_MASA_CNA + else if ( st_ivas->nchan_transport == 1 && ( st_ivas->renderer_type == RENDERER_DIRAC && st_ivas->hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) ) + { + /* addtl channel for CNG */ + tc_nchan_to_allocate++; + } +#endif + #ifdef UNIFY_CHANNEL_MEM_HEAP if ( st_ivas->ivas_format != MASA_ISM_FORMAT ) diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 836e2a0a1d..eb5b3163cf 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -558,7 +558,7 @@ ivas_error ivas_sba_dec_reconfigure( } else #endif - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO ) + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO ) { tc_buffer_mode = TC_BUFFER_MODE_BUFFER; tc_nchan_tc = st_ivas->hDecoderConfig->nchan_out; @@ -649,6 +649,9 @@ ivas_error ivas_sba_dec_digest_tc( { int16_t ch_idx; ivas_error error; +#ifdef FIX_XXX_MASA_CNA + int16_t nchan_transport; +#endif error = IVAS_ERR_OK; @@ -709,7 +712,17 @@ ivas_error ivas_sba_dec_digest_tc( } /* if we have a late CNG generation, do it here */ +#ifdef FIX_XXX_MASA_CNA + nchan_transport = st_ivas->nchan_transport; + if ( st_ivas->ivas_format == MASA_FORMAT && st_ivas->hDecoderConfig->ivas_total_brate < MASA_STEREO_MIN_BITRATE && ( st_ivas->hDecoderConfig->ivas_total_brate > IVAS_SID_5k2 || ( st_ivas->hDecoderConfig->ivas_total_brate <= IVAS_SID_5k2 && st_ivas->nCPE > 0 && st_ivas->hCPE[0]->nchan_out == 1 ) ) ) + { + nchan_transport = 1; /* Only one channel transported */ + } + if ( ( st_ivas->ivas_format != SBA_FORMAT && st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag ) || + ( nchan_transport == 1 && st_ivas->nchan_transport != 2 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag ) ) +#else if ( st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag && st_ivas->ivas_format == SBA_FORMAT ) +#endif { Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; generate_masking_noise_lb_dirac( st->hFdCngDec->hFdCngCom, st_ivas->hTcBuffer->tc[1], nCldfbSlots, st->cna_dirac_flag && st->flag_cna ); diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index db52e11019..c10b022e7a 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -1972,7 +1972,11 @@ ivas_error ivas_rend_crendProcessSubframe( { if ( hCrend->reflections->use_er == 1 && hCrend->reflections->is_ready == 1 ) { +#ifdef FIX_XXX_CREND_ER + if ( ( error = ivas_er_process( hCrend->reflections, subframe_len, 0, tc_local, inConfig ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_er_process( hCrend->reflections, subframe_len, subframe_idx, output, inConfig ) ) != IVAS_ERR_OK ) +#endif { return error; } -- GitLab From 6303c12784b3a49b27fd86dd5349c66db110b83d Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Wed, 27 Sep 2023 07:57:07 +0200 Subject: [PATCH 14/49] remove stale code for non-implemented JBM-OSBA --- lib_dec/ivas_jbm_dec.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 80f8759390..cd38a55608 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -2379,12 +2379,6 @@ int16_t ivas_jbm_dec_get_num_tc_channels( *nchan_transport_full = num_tc; #endif } -#ifdef NONBE_UNIFIED_DECODING_PATHS - else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) - { - assert( !"Format not implemented in JBM yet!" ); - } -#endif #ifdef UNIFY_CHANNEL_MEM_HEAP *nchan_transport_jbm = num_tc; #endif -- GitLab From f93f72b6ad9cd32f3e884d5e6f1b0c5fbd4e5dc8 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Wed, 27 Sep 2023 11:10:52 +0200 Subject: [PATCH 15/49] temp fixes for issues #833, #829 (MRs already exist) --- lib_com/options.h | 1 + lib_dec/ivas_ism_param_dec.c | 23 ++++++++++++++++++++--- lib_dec/ivas_jbm_dec.c | 9 +++++++++ 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 7a89a4c6e7..b87e964b91 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -214,6 +214,7 @@ #define FIX_XXX_MASA_CNA /*#define UNIFY_CHANNEL_MEM_HEAP*/ #define FIX_XXX_CREND_ER +#define FIX_XXX_JBM_FOR_OSBA #endif #define NONBE_FIX_722_MEMORY_LEAK_IN_PARAMUPMIX /* Dlb : issue 722: memory leak fix in MC param upmix mode with BR switching*/ #define NONBE_FIX_780_ISM_STARTS_WITH_SID /* VA: issue 780: fix Crash in ISM decoding when bitstream starts with an SID and output_config is not EXT */ diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index aa075c0208..7433388b84 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -2610,6 +2610,11 @@ void ivas_ism_dec_digest_tc( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || +#ifdef FIX_XXX_JBM_FOR_OSBA + st_ivas->renderer_type == RENDERER_OSBA_AMBI || + st_ivas->renderer_type == RENDERER_OSBA_LS || + st_ivas->renderer_type == RENDERER_OSBA_STEREO || +#endif ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM && st_ivas->hDecoderConfig->Opt_Headrotation == 0 ) ) { int16_t i, num_objects; @@ -2620,7 +2625,11 @@ void ivas_ism_dec_digest_tc( if ( ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ) == st_ivas->hTcBuffer->n_samples_available ) { int16_t interpolator_length = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); - if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) + if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || +#ifdef FIX_XXX_JBM_FOR_OSBA + st_ivas->renderer_type == RENDERER_OSBA_AMBI || +#endif + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) { st_ivas->hIsmRendererData->interpolator[0] = 0.0f; for ( i = 1; i < interpolator_length; i++ ) @@ -2657,7 +2666,11 @@ void ivas_ism_dec_digest_tc( azimuth = (int16_t) floorf( st_ivas->hIsmMetaData[i]->azimuth + 0.5f ); elevation = (int16_t) floorf( st_ivas->hIsmMetaData[i]->elevation + 0.5f ); - if ( ( st_ivas->renderer_type == RENDERER_TD_PANNING || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) && + if ( ( st_ivas->renderer_type == RENDERER_TD_PANNING || +#ifdef FIX_XXX_JBM_FOR_OSBA + st_ivas->renderer_type == RENDERER_OSBA_LS || +#endif + st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) && st_ivas->hCombinedOrientationData == NULL ) { if ( st_ivas->hIntSetup.is_planar_setup ) @@ -2671,7 +2684,11 @@ void ivas_ism_dec_digest_tc( efap_determine_gains( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains[i], azimuth, elevation, EFAP_MODE_EFAP ); } } - else if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) + else if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || +#ifdef FIX_XXX_JBM_FOR_OSBA + st_ivas->renderer_type == RENDERER_OSBA_AMBI || +#endif + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) { /*get HOA gets for direction (ACN/SN3D)*/ ivas_dirac_dec_get_response( azimuth, elevation, st_ivas->hIsmRendererData->gains[i], st_ivas->hIntSetup.ambisonics_order ); diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index cd38a55608..3fd260f929 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -617,6 +617,15 @@ ivas_error ivas_jbm_dec_tc( /* Rendering */ if ( ( st_ivas->renderer_type == RENDERER_MC ) && ( output_config == IVAS_AUDIO_CONFIG_MONO || output_config == IVAS_AUDIO_CONFIG_STEREO ) ) { + +#ifdef NONBE_FIX_787_PARAM_UPMIX_LEVEL + /* Compensate loudness for not doing full upmix */ + for ( n = 4; n < 8; n++ ) + { + v_multc( p_output[n], 2.0f, p_output[n], output_frame ); + } +#endif + if ( output_config == IVAS_AUDIO_CONFIG_MONO || output_config == IVAS_AUDIO_CONFIG_STEREO ) { ivas_ls_setup_conversion( st_ivas, audioCfg2channels( IVAS_AUDIO_CONFIG_5_1_2 ), output_frame, p_output, p_output ); -- GitLab From c138b25b534e094a20e653ff26ab9b2e48de8730 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Wed, 27 Sep 2023 15:10:57 +0200 Subject: [PATCH 16/49] fix split rendering compilation, add a few API functions for render frame size handling, add split rendering for JBM and crend and td object renderer --- apps/decoder.c | 101 ++++++++++++-- lib_com/ivas_prot.h | 6 +- lib_com/options.h | 2 +- lib_dec/ivas_binRenderer_internal.c | 10 +- lib_dec/ivas_init_dec.c | 5 +- lib_dec/ivas_jbm_dec.c | 150 ++++++++++++++++---- lib_dec/ivas_objectRenderer_internal.c | 123 +++++++++++++++++ lib_dec/ivas_osba_dec.c | 4 + lib_dec/lib_dec.c | 137 +++++++++++++++++- lib_dec/lib_dec.h | 27 ++++ lib_rend/ivas_crend.c | 184 +++++++++++++++++++++++++ lib_rend/ivas_prot_rend.h | 30 ++++ 12 files changed, 727 insertions(+), 52 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 17f63ec801..638b8587ce 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -630,22 +630,39 @@ int main( } #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( arg.enable5ms && - ( renderConfig.split_rend_config.poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_NONE || - renderConfig.split_rend_config.dof == 0 ) ) + if ( +#ifdef REMOVE_5MS_FLAG + arg.renderFramesize == RENDER_FRAMESIZE_5MS && +#else + arg.enable5ms && +#endif + ( renderConfig.split_rend_config.poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_NONE || + renderConfig.split_rend_config.dof == 0 ) ) { - /*TODO : needs to be refined as this wont work with LCLD codec*/ +/*TODO : needs to be refined as this wont work with LCLD codec*/ +#ifdef REMOVE_5MS_FLAG + arg.renderFramesize = RENDER_FRAMESIZE_5MS; +#else arg.enable5ms = true; +#endif } else { - arg.enable5ms = false; +#ifdef REMOVE_5MS_FLAG + arg.renderFramesize = RENDER_FRAMESIZE_20MS; +#else + arg.enable5ms = true; +#endif } - +#ifdef REMOVE_5MS_FLAG + if ( ( error = IVAS_DEC_SetRenderFramesize( hIvasDec, arg.renderFramesize ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_DEC_Set5msFlag( hIvasDec, arg.enable5ms ) ) != IVAS_ERR_OK ) +#endif { return error; } + #endif if ( RenderConfigReader_read( renderConfigReader, arg.renderConfigFilename, &renderConfig ) != IVAS_ERR_OK ) @@ -2034,13 +2051,27 @@ static ivas_error initOnFirstGoodFrame( #ifdef SPLIT_REND_WITH_HEAD_ROT if ( *splitRendWriter != NULL ) { +#ifndef REMOVE_5MS_FLAG int16_t enable5ms; +#endif if ( numOutSamples == NULL || vec_pos_len == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - +#ifdef REMOVE_5MS_FLAG + /* real setting of the 5ms mode for split rendering is only known after the decoded first good frame, reset the variables needed in the main decoding loop accordingly here*/ + if ( ( error = IVAS_DEC_GetRenderFramesizeSamples( hIvasDec, numOutSamples ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError getting render frame size in samples\n" ); + return error; + } + if ( ( error = IVAS_DEC_GetReferencesUpdateFrequency( hIvasDec, vec_pos_len ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError getting render frame size in samples\n" ); + return error; + } +#else if ( ( error = IVAS_DEC_Get5msFlag( hIvasDec, &enable5ms ) ) != IVAS_ERR_OK ) { return error; @@ -2057,6 +2088,7 @@ static ivas_error initOnFirstGoodFrame( *numOutSamples = (int16_t) ( arg.output_Fs / 1000 * DEFAULT_FETCH_FRAMESIZE_MS ); *vec_pos_len = 1; } +#endif } #endif @@ -2179,8 +2211,16 @@ static ivas_error decodeG192( vec_pos_update = 0; #ifdef REMOVE_5MS_FLAG - nOutSamples = (int16_t) ( arg.output_Fs * arg.renderFramesize / 1000 * HEADROTATION_FETCH_FRAMESIZE_MS ); - vec_pos_len = (int16_t) ( IVAS_MAX_PARAM_SPATIAL_SUBFRAMES / arg.renderFramesize ); + if ( ( error = IVAS_DEC_GetRenderFramesizeSamples( hIvasDec, &nOutSamples ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError getting render frame size in samples\n" ); + return error; + } + if ( ( error = IVAS_DEC_GetReferencesUpdateFrequency( hIvasDec, &vec_pos_len ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError getting render frame size in samples\n" ); + return error; + } #else if ( arg.enableHeadRotation && arg.enable5ms ) { @@ -2247,7 +2287,11 @@ static ivas_error decodeG192( num_subframes = ( arg.enable5ms ) ? 1 : IVAS_MAX_PARAM_SPATIAL_SUBFRAMES; #else int16_t num_subframes; - num_subframes = (int16_t) arg.renderFramesize; + if ( ( error = IVAS_DEC_GetNumOrientationSubframes( hIvasDec, &num_subframes ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_DEC_GetNumOrientationSubframes failed: \n" ); + goto cleanup; + } #endif /* Head-tracking input simulation */ /* Head-tracking input simulation */ @@ -2971,8 +3015,29 @@ static ivas_error decodeVoIP( #ifdef NONBE_UNIFIED_DECODING_PATHS vec_pos_update = 0; - nOutSamples = (int16_t) ( arg.output_Fs * arg.renderFramesize / 1000 * HEADROTATION_FETCH_FRAMESIZE_MS ); - vec_pos_len = (int16_t) ( IVAS_MAX_PARAM_SPATIAL_SUBFRAMES / arg.renderFramesize ); +#ifdef REMOVE_5MS_FLAG + if ( ( error = IVAS_DEC_GetRenderFramesizeSamples( hIvasDec, &nOutSamples ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError getting render frame size in samples\n" ); + return error; + } + if ( ( error = IVAS_DEC_GetReferencesUpdateFrequency( hIvasDec, &vec_pos_len ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError getting render frame size in samples\n" ); + return error; + } +#else + if ( arg.enableHeadRotation && arg.enable5ms ) + { + nOutSamples = (int16_t) ( arg.output_Fs / 1000 * HEADROTATION_FETCH_FRAMESIZE_MS ); + vec_pos_len = IVAS_MAX_PARAM_SPATIAL_SUBFRAMES; + } + else + { + nOutSamples = (int16_t) ( arg.output_Fs / 1000 * DEFAULT_FETCH_FRAMESIZE_MS ); + vec_pos_len = 1; + } +#endif #endif for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; ++i ) @@ -3127,12 +3192,19 @@ static ivas_error decodeVoIP( } #ifndef REMOVE_5MS_FLAG int16_t enable5ms, num_subframes; - IVAS_DEC_Get5msFlag( hIvasDec, &enable5ms ); + if ( ( error = IVAS_DEC_Get5msFlag( hIvasDec, &enable5ms ) ) != IVAS_ERR_OK ) + { + return error; + } arg.enable5ms = enable5ms; num_subframes = ( arg.enable5ms ) ? 1 : IVAS_MAX_PARAM_SPATIAL_SUBFRAMES; #else int16_t num_subframes; - num_subframes = (int16_t) arg.renderFramesize; + if ( ( error = IVAS_DEC_GetNumOrientationSubframes( hIvasDec, &num_subframes ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_DEC_GetNumOrientationSubframes failed: \n" ); + goto cleanup; + } #endif /* Head-tracking input simulation */ @@ -3270,7 +3342,6 @@ static ivas_error decodeVoIP( /* decode and get samples */ #ifdef SPLIT_REND_WITH_HEAD_ROT - #ifdef SUPPORT_JBM_TRACEFILE if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter ) ) != IVAS_ERR_OK ) #else diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index f8b9a9deae..5f8bc791e9 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5287,15 +5287,15 @@ void ivas_binRenderer( BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: binaural renderer handle */ #ifdef SPLIT_REND_WITH_HEAD_ROT const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, -#endif -#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG - HEAD_TRACK_DATA_HANDLE hPostRendHeadTrackData, #endif COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle */ #ifndef NONBE_UNIFIED_DECODING_PATHS int16_t subframe_idx, /* i : subframe index */ #endif const int16_t numTimeSlots, /* i : number of time slots to process */ +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + HEAD_TRACK_DATA_HANDLE hPostRendHeadTrackData, +#endif #ifdef SPLIT_REND_WITH_HEAD_ROT float Cldfb_RealBuffer_Binaural[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ float Cldfb_ImagBuffer_Binaural[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ diff --git a/lib_com/options.h b/lib_com/options.h index b87e964b91..7bc6400304 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -149,7 +149,7 @@ /*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ -/*#define SPLIT_REND_WITH_HEAD_ROT */ /* Dlb,FhG: Split Rendering contributions 21 and 35 */ +#define SPLIT_REND_WITH_HEAD_ROT /* Dlb,FhG: Split Rendering contributions 21 and 35 */ #ifdef SPLIT_REND_WITH_HEAD_ROT #define SPLIT_REND_PRED_QUANT_63_PNTS #define SPLIT_REND_WITH_HEAD_ROT_PARAMBIN /* Nokia: Issue 623: Split rendering support for parambin renderer */ diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index 379bbd46e3..6291d0be36 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -1646,6 +1646,7 @@ void ivas_binaural_cldfb( ivas_binRenderer( st_ivas->hBinRenderer, #ifdef SPLIT_REND_WITH_HEAD_ROT + &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, #endif st_ivas->hCombinedOrientationData, #ifndef NONBE_UNIFIED_DECODING_PATHS @@ -2193,11 +2194,18 @@ void ivas_rend_CldfbMultiBinRendProcess( #endif #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG +#ifdef NONBE_UNIFIED_DECODING_PATHS + ivas_binRenderer( hCldfbRend, pMultiBinPoseData, *pCombinedOrientationData, MAX_PARAM_SPATIAL_SUBFRAMES, &head_track_post, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_sfIn, Cldfb_ImagBuffer_sfIn ); +#else ivas_binRenderer( hCldfbRend, pMultiBinPoseData, *pCombinedOrientationData, sf_idx, MAX_PARAM_SPATIAL_SUBFRAMES, &head_track_post, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_sfIn, Cldfb_ImagBuffer_sfIn ); +#endif +#else +#ifdef NONBE_UNIFIED_DECODING_PATHS + ivas_binRenderer( hCldfbRend, pMultiBinPoseData, *pCombinedOrientationData, MAX_PARAM_SPATIAL_SUBFRAMES, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_sfIn, Cldfb_ImagBuffer_sfIn ); #else ivas_binRenderer( hCldfbRend, pMultiBinPoseData, *pCombinedOrientationData, sf_idx, MAX_PARAM_SPATIAL_SUBFRAMES, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_sfIn, Cldfb_ImagBuffer_sfIn ); #endif - +#endif for ( pose_idx = 0; pose_idx < hCldfbRend->numPoses; pose_idx++ ) { for ( slot_idx = 0; slot_idx < MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index d20e666824..9b1316ab65 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -259,8 +259,11 @@ static ivas_error ivas_dec_init_split_rend( } #endif +#ifdef REMOVE_5MS_FLAG + error = ivas_split_renderer_open( &st_ivas->hSplitBinRend.splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, cldfb_in_flag, pcm_out_flag, st_ivas->hDecoderConfig->render_framesize == RENDER_FRAMESIZE_5MS ); +#else error = ivas_split_renderer_open( &st_ivas->hSplitBinRend.splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, cldfb_in_flag, pcm_out_flag, st_ivas->hDecoderConfig->Opt_5ms ); - +#endif return error; } #endif diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 3fd260f929..dcd545da87 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -622,7 +622,7 @@ ivas_error ivas_jbm_dec_tc( /* Compensate loudness for not doing full upmix */ for ( n = 4; n < 8; n++ ) { - v_multc( p_output[n], 2.0f, p_output[n], output_frame ); + v_multc( p_output[n], 2.0f, p_output[n], output_frame ); } #endif @@ -1029,6 +1029,9 @@ ivas_error ivas_jbm_dec_render( #ifdef UNIFY_CHANNEL_MEM_HEAP int16_t output_offset; #endif +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t nchan_out_syn_output; +#endif push_wmops( "ivas_dec_render" ); @@ -1056,20 +1059,20 @@ ivas_error ivas_jbm_dec_render( #endif for ( n = 0; n < MAX_OUTPUT_CHANNELS; n++ ) - for ( n = 0; n < MAX_OUTPUT_CHANNELS + for ( n = 0; n < MAX_OUTPUT_CHANNELS #ifdef JBM_FOR_OSBA - + MAX_NUM_OBJECTS + + MAX_NUM_OBJECTS #endif - ; - n++ ) - { + ; + n++ ) + { #ifdef UNIFY_CHANNEL_MEM_HEAP - p_output[n] = st_ivas->p_output_f[n] + output_offset; + p_output[n] = st_ivas->p_output_f[n] + output_offset; #else - p_output[n] = &output[n][0]; + p_output[n] = &output[n][0]; #endif - } + } #ifdef FIX_676_JBM_USAN for ( n = 0; n < st_ivas->hTcBuffer->nchan_buffer_full; n++ ) @@ -1181,14 +1184,35 @@ ivas_error ivas_jbm_dec_render( /* Binaural rendering */ if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { - if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { - return error; + if ( ( error = ivas_td_binaural_renderer_sf_splitBinaural( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) + { + return error; + } } + else + { +#endif + if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) + { + return error; + } +#ifdef SPLIT_REND_WITH_HEAD_ROT + } +#endif } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { - if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, NULL, NULL, st_ivas->hTcBuffer, p_output, p_output, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, NULL, NULL, st_ivas->hTcBuffer, p_output, p_output, *nSamplesRendered, output_Fs +#ifdef NONBE_UNIFIED_DECODING_PATHS +#ifdef SPLIT_REND_WITH_HEAD_ROT + , + 0 +#endif +#endif + ) ) != IVAS_ERR_OK ) { return error; } @@ -1382,13 +1406,35 @@ ivas_error ivas_jbm_dec_render( /* Rendering */ if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { - if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, - &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output : p_tc, p_output, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { - return error; + if ( ( error = ivas_rend_crendProcessSubframesSplitBin( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, + &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output : p_tc, p_output, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) + { + return error; + } } + else + { +#endif + if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, + &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output : p_tc, p_output, *nSamplesRendered, output_Fs +#ifdef NONBE_UNIFIED_DECODING_PATHS +#ifdef SPLIT_REND_WITH_HEAD_ROT + , + 0 +#endif +#endif + ) ) != IVAS_ERR_OK ) + { + return error; + } - ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_tc, p_output ); + ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_tc, p_output ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + } +#endif } else if ( st_ivas->renderer_type == RENDERER_MC ) { @@ -1401,12 +1447,26 @@ ivas_error ivas_jbm_dec_render( } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { - if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { - return error; + if ( ( error = ivas_td_binaural_renderer_sf_splitBinaural( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) + { + return error; + } } + else + { +#endif + if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) + { + return error; + } - ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_tc, p_output ); + ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_tc, p_output ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + } +#endif } } else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) @@ -1455,12 +1515,26 @@ ivas_error ivas_jbm_dec_render( } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { - if ( ( error = ivas_td_binaural_renderer( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { - return error; + if ( ( error = ivas_td_binaural_renderer_sf_splitBinaural( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) + { + return error; + } } + else + { +#endif + if ( ( error = ivas_td_binaural_renderer( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) + { + return error; + } - ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_output, p_output ); + ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_output, p_output ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + } +#endif } } else if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) @@ -1567,6 +1641,15 @@ ivas_error ivas_jbm_dec_render( } #ifdef SPLIT_REND_WITH_HEAD_ROT + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + nchan_out_syn_output = BINAURAL_CHANNELS * st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses; + } + else + { + nchan_out_syn_output = nchan_out; + } + if ( st_ivas->hDecoderConfig->Opt_Limiter ) #endif { @@ -1709,7 +1792,14 @@ ivas_error ivas_jbm_dec_flush_renderer( ivas_ism_render_sf( st_ivas, p_output, hTcBuffer->n_samples_granularity ); if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, NULL, - NULL, st_ivas->hTcBuffer, p_output, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + NULL, st_ivas->hTcBuffer, p_output, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs +#ifdef NONBE_UNIFIED_DECODING_PATHS +#ifdef SPLIT_REND_WITH_HEAD_ROT + , + 0 +#endif +#endif + ) ) != IVAS_ERR_OK ) { return error; } @@ -1729,7 +1819,14 @@ ivas_error ivas_jbm_dec_flush_renderer( if ( renderer_type_old == RENDERER_BINAURAL_MIXER_CONV || renderer_type_old == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, intern_config_old, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, - hIntSetupOld, st_ivas->hEFAPdata, st_ivas->hTcBuffer, hTcBuffer->tc, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + hIntSetupOld, st_ivas->hEFAPdata, st_ivas->hTcBuffer, hTcBuffer->tc, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs +#ifdef NONBE_UNIFIED_DECODING_PATHS +#ifdef SPLIT_REND_WITH_HEAD_ROT + , + 0 +#endif +#endif + ) ) != IVAS_ERR_OK ) { return error; } @@ -2805,9 +2902,10 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( } for ( ; ch_idx < MAX_TRANSPORT_CHANNELS #ifdef JBM_FOR_OSBA - + MAX_NUM_OBJECTS + + MAX_NUM_OBJECTS #endif -; ch_idx++ ) + ; + ch_idx++ ) { hTcBuffer->tc[ch_idx] = NULL; } diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index 63ba2db82c..ab9d9dc0e3 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -285,3 +285,126 @@ ivas_error ivas_td_binaural_renderer_sf( return IVAS_ERR_OK; } + +#ifdef NONBE_UNIFIED_DECODING_PATHS +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*---------------------------------------------------------------------* + * ivas_td_binaural_renderer_sf_splitBinaural() + * + * Render to multiple binaural pairs based on relative head positions for split rendering. + *---------------------------------------------------------------------*/ + +ivas_error ivas_td_binaural_renderer_sf_splitBinaural( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float *output[], /* i/o: SCE channels / Binaural synthesis */ + int16_t nSamplesRendered /* i : number of samples to render */ +) +{ + int16_t i; + int16_t pos_idx; + IVAS_QUATERNION originalHeadRot[MAX_PARAM_SPATIAL_SUBFRAMES]; + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData; + BINAURAL_TD_OBJECT_RENDERER_HANDLE origTdRendHandle; + ivas_error error; + int16_t original_subframes_rendered; + float *p_bin_output[BINAURAL_CHANNELS]; + + push_wmops( "ivas_td_binaural_renderer_sf_splitBinaural" ); + + pMultiBinPoseData = &st_ivas->hSplitBinRend.splitrend.multiBinPoseData; + + /* If not yet allocated, open additional instances of TD renderer */ + for ( i = 0; i < pMultiBinPoseData->num_poses - 1; ++i ) + { + if ( st_ivas->hSplitBinRend.splitrend.hTdRendHandles[i] != NULL ) + { + continue; + } + + if ( ( error = ivas_td_binaural_open_unwrap( &st_ivas->hHrtfTD, + st_ivas->hDecoderConfig->output_Fs, + st_ivas->nchan_transport, + st_ivas->ivas_format, + st_ivas->transport_config, + st_ivas->hRenderConfig->directivity, + st_ivas->hTransSetup, + &st_ivas->hSplitBinRend.splitrend.hTdRendHandles[i], + &st_ivas->binaural_latency_ns ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + /* Save current head positions */ + for ( i = 0; i < st_ivas->hCombinedOrientationData->num_subframes; ++i ) + { + originalHeadRot[i] = st_ivas->hCombinedOrientationData->Quaternions[i]; + } + + original_subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; + origTdRendHandle = st_ivas->hBinRendererTd; + + for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses; pos_idx++ ) + { + /* Update head positions */ + if ( pos_idx != 0 ) + { + for ( i = 0; i < st_ivas->hCombinedOrientationData->num_subframes; ++i ) + { + if ( originalHeadRot[i].w == -3.0f ) + { + st_ivas->hCombinedOrientationData->Quaternions[i].w = -3.0f; + st_ivas->hCombinedOrientationData->Quaternions[i].x = originalHeadRot[i].x + pMultiBinPoseData->relative_head_poses[pos_idx][0]; + st_ivas->hCombinedOrientationData->Quaternions[i].y = originalHeadRot[i].y + pMultiBinPoseData->relative_head_poses[pos_idx][1]; + st_ivas->hCombinedOrientationData->Quaternions[i].z = originalHeadRot[i].z + pMultiBinPoseData->relative_head_poses[pos_idx][2]; + } + else + { + st_ivas->hCombinedOrientationData->Quaternions[i].w = -3.0f; + + Quat2EulerDegree( originalHeadRot[i], /* TODO tmu : fix bug with ordering*/ + &st_ivas->hCombinedOrientationData->Quaternions[i].z, + &st_ivas->hCombinedOrientationData->Quaternions[i].y, + &st_ivas->hCombinedOrientationData->Quaternions[i].x ); + + st_ivas->hCombinedOrientationData->Quaternions[i].x += pMultiBinPoseData->relative_head_poses[pos_idx][0]; + st_ivas->hCombinedOrientationData->Quaternions[i].y += pMultiBinPoseData->relative_head_poses[pos_idx][1]; + st_ivas->hCombinedOrientationData->Quaternions[i].z += pMultiBinPoseData->relative_head_poses[pos_idx][2]; + } + } + } + + /* set output channels */ + for ( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + p_bin_output[i] = output[pos_idx * BINAURAL_CHANNELS + i]; + } + st_ivas->hTcBuffer->subframes_rendered = original_subframes_rendered; + ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData ); + + /* Render */ + if ( pos_idx != 0 ) + { + st_ivas->hBinRendererTd = st_ivas->hSplitBinRend.splitrend.hTdRendHandles[pos_idx - 1]; + } + if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_bin_output, nSamplesRendered ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + + /* Restore original head rotation */ + for ( i = 0; i < st_ivas->hCombinedOrientationData->num_subframes; ++i ) + { + st_ivas->hCombinedOrientationData->Quaternions[i] = originalHeadRot[i]; + } + /* restore original td renderer handle */ + st_ivas->hBinRendererTd = origTdRendHandle; + + pop_wmops(); + + return IVAS_ERR_OK; +} +#endif +#endif diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index 0a35e3f5e2..1a84b4968f 100644 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -325,7 +325,11 @@ ivas_error ivas_osba_dirac_td_binaural( num_cldfb_bands = st_ivas->hSplitBinRend.splitrend.hCldfbHandles->cldfbAna[0]->no_channels; nchan_transport_orig = st_ivas->nchan_transport; st_ivas->nchan_transport = st_ivas->nchan_ism; +#ifdef NONBE_UNIFIED_DECODING_PATHS + +#else ObjRenderIvasFrame_splitBinaural( st_ivas, output, output_frame ); +#endif st_ivas->nchan_transport = nchan_transport_orig; for ( n = 0; n < st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses * BINAURAL_CHANNELS; ++n ) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index c4c9294d6c..9ef350d482 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -522,7 +522,9 @@ ivas_error IVAS_DEC_EnableSplitRendering( hDecoderConfig = hIvasDec->st_ivas->hDecoderConfig; hDecoderConfig->Opt_Headrotation = 1; +#ifndef REMOVE_5MS_FLAG hDecoderConfig->Opt_5ms = false; +#endif hDecoderConfig->Opt_Limiter = 0; @@ -573,6 +575,111 @@ ivas_error IVAS_DEC_Get5msFlag( return IVAS_ERR_OK; } +#else +/*---------------------------------------------------------------------* + * IVAS_DEC_SetRenderFramesize( ) + * + * Get the 5ms flag + *---------------------------------------------------------------------*/ + +ivas_error IVAS_DEC_SetRenderFramesize( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const RENDER_FRAMESIZE render_framesize /* i : render framesize */ +) +{ + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hDecoderConfig == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + hIvasDec->st_ivas->hDecoderConfig->render_framesize = render_framesize; + + return IVAS_ERR_OK; +} + +/*---------------------------------------------------------------------* + * IVAS_DEC_GetGetRenderFramesize( ) + * + * Get the 5ms flag + *---------------------------------------------------------------------*/ + +ivas_error IVAS_DEC_GetRenderFramesize( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + RENDER_FRAMESIZE *render_framesize /* o : render framesize */ +) +{ + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || render_framesize == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + *render_framesize = hIvasDec->st_ivas->hDecoderConfig->render_framesize; + + return IVAS_ERR_OK; +} + +/*---------------------------------------------------------------------* + * IVAS_DEC_GetGetRenderFramesizeSamples( ) + * + * Get render framesize in samples + *---------------------------------------------------------------------*/ + +ivas_error IVAS_DEC_GetRenderFramesizeSamples( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + uint16_t *render_framesize /* o : render framesize in samples */ +) +{ + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || render_framesize == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + *render_framesize = (int16_t) ( hIvasDec->st_ivas->hDecoderConfig->output_Fs * hIvasDec->st_ivas->hDecoderConfig->render_framesize / ( 1000 * IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ); + + return IVAS_ERR_OK; +} + +/*---------------------------------------------------------------------* + * IVAS_DEC_GetGetReferencesUpdateFrequency( ) + * + * Get update frequency of the reference vector/orientation + *---------------------------------------------------------------------*/ + +ivas_error IVAS_DEC_GetReferencesUpdateFrequency( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int16_t *update_frequency /* o : update frequency */ +) +{ + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || update_frequency == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + *update_frequency = (int16_t) ( IVAS_MAX_PARAM_SPATIAL_SUBFRAMES / hIvasDec->st_ivas->hDecoderConfig->render_framesize ); + + return IVAS_ERR_OK; +} + +/*---------------------------------------------------------------------* + * IVAS_DEC_GetGetNumOrientationSubframes( ) + * + * Get the number of subframes for head/ecernal orientation per render frame + *---------------------------------------------------------------------*/ + +ivas_error IVAS_DEC_GetNumOrientationSubframes( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int16_t *num_subframes /* o : render framesize */ +) +{ + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || num_subframes == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + *num_subframes = (int16_t) hIvasDec->st_ivas->hDecoderConfig->render_framesize; + + return IVAS_ERR_OK; +} #endif @@ -826,7 +933,7 @@ ivas_error IVAS_DEC_GetSamples( const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ void *pcmBuf, /* o : output synthesis signal */ #else - int16_t *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ + int16_t *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ #endif int16_t *nOutSamples, /* o : number of samples per channel written to output buffer */ bool *needNewFrame /* o :indication that the decoder needs a new frame */ @@ -859,6 +966,17 @@ ivas_error IVAS_DEC_GetSamples( { return error; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + /*----------------------------------------------------------------* + * Binaural split rendering setup + *----------------------------------------------------------------*/ + + if ( hIvasDec->st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || hIvasDec->st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + ivas_set_split_rend_ht_setup( &hIvasDec->st_ivas->hSplitBinRend, hIvasDec->st_ivas->hCombinedOrientationData ); + } +#endif + hIvasDec->updateOrientation = false; } #endif @@ -1069,9 +1187,15 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( numPoses = hSplitBinRend->splitrend.multiBinPoseData.num_poses; - if ( st_ivas->hDecoderConfig->Opt_5ms && hIvasDec->st_ivas->hRenderConfig->split_rend_config.codec == IVAS_SPLIT_REND_CODEC_LC3PLUS && - ( hIvasDec->st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_NONE || - hIvasDec->st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) + if ( +#ifdef REMOVE_5MS_FLAG + st_ivas->hDecoderConfig->render_framesize == RENDER_FRAMESIZE_5MS && +#else + st_ivas->hDecoderConfig->Opt_5ms && +#endif + hIvasDec->st_ivas->hRenderConfig->split_rend_config.codec == IVAS_SPLIT_REND_CODEC_LC3PLUS && + ( hIvasDec->st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_NONE || + hIvasDec->st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) { numSamplesPerChannelToSplitEncode = (int16_t) ( output_Fs / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES ); numSamplesPerChannelCacheSize = numSamplesPerChannelToDecode - numSamplesPerChannelToSplitEncode; @@ -1170,7 +1294,11 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( /* convert to int16 with limiting for BINAURAL_SPLIT_PCM */ if ( pcm_out_flag ) { +#ifdef REMOVE_5MS_FLAG + if ( st_ivas->hDecoderConfig->render_framesize == RENDER_FRAMESIZE_5MS ) +#else if ( st_ivas->hDecoderConfig->Opt_5ms ) +#endif { #ifndef DISABLE_LIMITER ivas_limiter_dec( st_ivas->hLimiter, pOutput, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToSplitEncode, st_ivas->BER_detect ); @@ -1961,7 +2089,6 @@ ivas_error IVAS_DEC_GetRenderConfig( const IVAS_RENDER_CONFIG_HANDLE hRCout /* o : Render configuration handle */ ) { - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hRenderConfig == NULL || hRCout == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 2dd568e611..c6db5d379f 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -313,6 +313,7 @@ ivas_error IVAS_DEC_EnableSplitRendering( ); #endif +#ifndef REMOVE_5MS_FLAG ivas_error IVAS_DEC_Set5msFlag( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ const int16_t enable5ms /* i : 5ms flag */ @@ -322,6 +323,32 @@ ivas_error IVAS_DEC_Get5msFlag( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ int16_t *enable5ms /* o : 5ms flag */ ); +#else +ivas_error IVAS_DEC_SetRenderFramesize( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const RENDER_FRAMESIZE render_framesize /* i : render framesize */ +); + +ivas_error IVAS_DEC_GetRenderFramesize( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + RENDER_FRAMESIZE *render_framesize /* o : render framesize */ +); + +ivas_error IVAS_DEC_GetRenderFramesizeSamples( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + uint16_t *render_framesize /* o : render framesize in samples */ +); + +ivas_error IVAS_DEC_GetReferencesUpdateFrequency( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int16_t *update_frequency /* o : update frequency */ +); + +ivas_error IVAS_DEC_GetNumOrientationSubframes( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int16_t *num_subframes /* o : render framesize */ +); +#endif #ifdef DEBUGGING bool IVAS_DEC_GetBerDetectFlag( diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index c10b022e7a..6711d03ce4 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -1899,6 +1899,12 @@ ivas_error ivas_rend_crendProcessSubframe( float *output[], /* i/o: input/output audio channels */ const int16_t n_samples_to_render, /* i : output frame length per channel */ const int32_t output_Fs /* i : output sampling rate */ +#ifdef NONBE_UNIFIED_DECODING_PATHS +#ifdef SPLIT_REND_WITH_HEAD_ROT + , + const int16_t pos_idx +#endif +#endif ) { int16_t subframe_idx, subframe_len; @@ -1912,7 +1918,11 @@ ivas_error ivas_rend_crendProcessSubframe( CREND_HANDLE hCrend; #ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef NONBE_UNIFIED_DECODING_PATHS + hCrend = pCrend->hCrend[pos_idx]; +#else hCrend = pCrend->hCrend[0]; +#endif #else hCrend = pCrend->hCrend; #endif @@ -2003,7 +2013,11 @@ ivas_error ivas_rend_crendProcessSubframe( if ( ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) || ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS ) ) { #ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef NONBE_UNIFIED_DECODING_PATHS + if ( ( error = ivas_rend_crendConvolver( pCrend, inConfig, outConfig, tc_local, p_pcm_tmp, output_Fs, 0, pos_idx ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_rend_crendConvolver( pCrend, inConfig, outConfig, tc_local, p_pcm_tmp, output_Fs, 0, 0 ) ) != IVAS_ERR_OK ) +#endif #else if ( ( error = ivas_rend_crendConvolver( pCrend, inConfig, outConfig, tc_local, p_pcm_tmp, output_Fs, 0 ) ) != IVAS_ERR_OK ) @@ -2015,7 +2029,11 @@ ivas_error ivas_rend_crendProcessSubframe( #ifdef SPLIT_REND_WITH_HEAD_ROT if ( pCrend->hCrend[0]->hReverb != NULL ) { +#ifdef NONBE_UNIFIED_DECODING_PATHS + if ( ( error = ivas_reverb_process( pCrend->hCrend[pos_idx]->hReverb, inConfig, 1, tc_local, p_pcm_tmp, 0 ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_reverb_process( pCrend->hCrend[0]->hReverb, inConfig, 1, tc_local, p_pcm_tmp, 0 ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -2214,3 +2232,169 @@ ivas_error ivas_rend_crendProcessSplitBin( return IVAS_ERR_OK; } #endif + +#ifdef NONBE_UNIFIED_DECODING_PATHS +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*-----------------------------------------------------------------------------------------* + * Function ivas_rend_crend_ProcessSubframesSplitBin() + * + * Process call for IVAS Crend renderer + *-----------------------------------------------------------------------------------------*/ + +ivas_error ivas_rend_crendProcessSubframesSplitBin( + const CREND_WRAPPER *pCrend, /* i/o: Crend wrapper handle */ + const AUDIO_CONFIG inConfig, /* i : input audio configuration */ + const AUDIO_CONFIG outConfig, /* i : output audio configuration */ + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : decoder config. structure */ + const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ + const IVAS_OUTPUT_SETUP_HANDLE hIntSetup, /* i : internal setup handle */ + const EFAP_HANDLE hEFAPdata, /* i : EFAP handle */ + DECODER_TC_BUFFER_HANDLE hTcBuffer, /* i/o: JBM handle */ + float *input_f[], /* i : transport channels */ + float *output[], /* i/o: input/output audio channels */ + const int16_t n_samples_to_render, /* i : output frame length per channel */ + const int32_t output_Fs /* i : output sampling rate */ +) +{ + int16_t i, j; + int16_t sf; + int16_t pos_idx; + ivas_error error; + float gain_lfe; + float tmpLfeBuffer[L_FRAME48k]; + float *p_bin_output[BINAURAL_CHANNELS]; + int16_t original_subframes_rendered, original_slots_rendered; + float tmpInputBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + float *p_tmpInputBuffer[MAX_OUTPUT_CHANNELS]; + float tmpSplitBinBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + + COMBINED_ORIENTATION_DATA combinedOrientationDataLocal; + COMBINED_ORIENTATION_HANDLE pCombinedOrientationDataLocal; + + /* save current head positions */ + pCombinedOrientationDataLocal = hCombinedOrientationData; + combinedOrientationDataLocal = *pCombinedOrientationDataLocal; + original_subframes_rendered = hTcBuffer->subframes_rendered; + original_slots_rendered = hTcBuffer->slots_rendered; + + /* copy input */ + for ( i = 0; i < hIntSetup->nchan_out_woLFE; ++i ) + { + mvr2r( input_f[i], tmpInputBuffer[i], n_samples_to_render ); + } + + for ( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) + { + p_tmpInputBuffer[i] = tmpInputBuffer[i]; + } + + if ( pMultiBinPoseData->poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) + { + for ( sf = 1; sf < hCombinedOrientationData->num_subframes; ++sf ) + { + combinedOrientationDataLocal.Quaternions[sf] = combinedOrientationDataLocal.Quaternions[0]; + for ( i = 0; i < 3; i++ ) + { + for ( j = 0; j < 3; j++ ) + { + combinedOrientationDataLocal.Rmat[sf][i][j] = combinedOrientationDataLocal.Rmat[0][i][j]; + } + } + } + } + + /* copy LFE to tmpLfeBuffer and apply gain only once */ + if ( hIntSetup->num_lfe > 0 && hIntSetup->index_lfe[0] != -1 ) + { + mvr2r( output[hIntSetup->index_lfe[0]], tmpLfeBuffer, n_samples_to_render ); + gain_lfe = ( ( pCrend != NULL ) && ( pCrend->hHrtfCrend != NULL ) ) ? pCrend->hHrtfCrend->gain_lfe : GAIN_LFE; + v_multc( tmpLfeBuffer, gain_lfe, tmpLfeBuffer, n_samples_to_render ); + } + else + { + set_zero( tmpLfeBuffer, n_samples_to_render ); + } + + for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses; ++pos_idx ) + { + /* Update head positions */ + + IVAS_QUATERNION Quaternions_orig[MAX_PARAM_SPATIAL_SUBFRAMES], Quaternions_abs; + for ( i = 0; i < hCombinedOrientationData->num_subframes; i++ ) + { + Quaternions_orig[i] = combinedOrientationDataLocal.Quaternions[i]; + Quaternions_abs.w = -3.0f; + Quat2EulerDegree( combinedOrientationDataLocal.Quaternions[i], &Quaternions_abs.z, &Quaternions_abs.y, &Quaternions_abs.x ); /*order in Quat2Euler seems to be reversed ?*/ + + Quaternions_abs.x += pMultiBinPoseData->relative_head_poses[pos_idx][0]; + Quaternions_abs.y += pMultiBinPoseData->relative_head_poses[pos_idx][1]; + Quaternions_abs.z += pMultiBinPoseData->relative_head_poses[pos_idx][2]; + combinedOrientationDataLocal.Quaternions[i] = Quaternions_abs; + QuatToRotMat( combinedOrientationDataLocal.Quaternions[i], combinedOrientationDataLocal.Rmat[i] ); + } + + + pCombinedOrientationDataLocal = &combinedOrientationDataLocal; + /* set output channels */ + for ( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + p_bin_output[i] = output[pos_idx * BINAURAL_CHANNELS + i]; + } + hTcBuffer->subframes_rendered = original_subframes_rendered; + hTcBuffer->slots_rendered = original_slots_rendered; + ivas_combined_orientation_set_to_start_index( pCombinedOrientationDataLocal ); + + for ( i = 0; i < 3; i++ ) + { + mvr2r( hCombinedOrientationData->Rmat_prev[pos_idx][i], pCombinedOrientationDataLocal->Rmat_prev[0][i], 3 ); + } + if ( ( error = ivas_rend_crendProcessSubframe( pCrend, + inConfig, + outConfig, + hDecoderConfig, + pCombinedOrientationDataLocal, + hIntSetup, + hEFAPdata, + hTcBuffer, + p_tmpInputBuffer, + p_tmpInputBuffer, + n_samples_to_render, + output_Fs, + pos_idx ) ) != IVAS_ERR_OK ) + { + return error; + } + + for ( i = 0; i < BINAURAL_CHANNELS; ++i ) + { + /* accumulate LFE to output */ + v_add( tmpInputBuffer[i], tmpLfeBuffer, tmpInputBuffer[i], n_samples_to_render ); + + /* move to split bin output buffer */ + mvr2r( tmpInputBuffer[i], tmpSplitBinBuffer[pos_idx * BINAURAL_CHANNELS + i], n_samples_to_render ); + } + + /* overwrite rendered channels with input again for next iteration */ + for ( i = 0; i < hIntSetup->nchan_out_woLFE; ++i ) + { + mvr2r( input_f[i], tmpInputBuffer[i], n_samples_to_render ); + } + + /* restore original headrotation data */ + for ( i = 0; i < hCombinedOrientationData->num_subframes; i++ ) + { + combinedOrientationDataLocal.Quaternions[i] = Quaternions_orig[i]; + } + } + + /* copy split binaural rendered signals to final output */ + for ( i = 0; i < BINAURAL_CHANNELS * pMultiBinPoseData->num_poses; ++i ) + { + mvr2r( tmpSplitBinBuffer[i], output[i], n_samples_to_render ); + } + + return IVAS_ERR_OK; +} +#endif +#endif \ No newline at end of file diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index e550c67815..fd0ce97015 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -885,6 +885,12 @@ ivas_error ivas_rend_crendProcessSubframe( float *output[], /* i/o: input/output audio channels */ const int16_t n_samples_to_render, /* i : output frame length per channel */ const int32_t output_Fs /* i : output sampling rate */ +#ifdef NONBE_UNIFIED_DECODING_PATHS +#ifdef SPLIT_REND_WITH_HEAD_ROT + , + const int16_t pos_idx +#endif +#endif ); @@ -1734,6 +1740,30 @@ ivas_error ObjRenderIvasFrame_splitBinaural( const int16_t output_frame /* i : output frame length */ ); +#ifdef NONBE_UNIFIED_DECODING_PATHS +ivas_error ivas_td_binaural_renderer_sf_splitBinaural( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float *output[], /* i/o: SCE channels / Binaural synthesis */ + int16_t nSamplesRendered /* i : number of samples to render */ +); + +ivas_error ivas_rend_crendProcessSubframesSplitBin( + const CREND_WRAPPER *pCrend, /* i/o: Crend wrapper handle */ + const AUDIO_CONFIG inConfig, /* i : input audio configuration */ + const AUDIO_CONFIG outConfig, /* i : output audio configuration */ + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : decoder config. structure */ + const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ + const IVAS_OUTPUT_SETUP_HANDLE hIntSetup, /* i : internal setup handle */ + const EFAP_HANDLE hEFAPdata, /* i : EFAP handle */ + DECODER_TC_BUFFER_HANDLE hTcBuffer, /* i/o: JBM handle */ + float *input_f[], /* i : transport channels */ + float *output[], /* i/o: input/output audio channels */ + const int16_t n_samples_to_render, /* i : output frame length per channel */ + const int32_t output_Fs /* i : output sampling rate */ +); +#endif + ivas_error ivas_rend_crendProcessSplitBin( const CREND_WRAPPER *pCrend, const AUDIO_CONFIG inConfig, -- GitLab From c75de802d82e34f02eed1c34a9220274b07256d9 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Wed, 27 Sep 2023 16:18:58 +0200 Subject: [PATCH 17/49] fix calculation of render frame size in samples --- lib_dec/lib_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 9ef350d482..4083f06cac 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -634,7 +634,7 @@ ivas_error IVAS_DEC_GetRenderFramesizeSamples( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - *render_framesize = (int16_t) ( hIvasDec->st_ivas->hDecoderConfig->output_Fs * hIvasDec->st_ivas->hDecoderConfig->render_framesize / ( 1000 * IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ); + *render_framesize = (int16_t) ( hIvasDec->st_ivas->hDecoderConfig->output_Fs * hIvasDec->st_ivas->hDecoderConfig->render_framesize / ( FRAMES_PER_SEC * IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ); return IVAS_ERR_OK; } -- GitLab From 98e0e7a1c2faf5555f1946fd940c0cd66b27562a Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Wed, 27 Sep 2023 16:27:20 +0200 Subject: [PATCH 18/49] fix compiler warning --- lib_com/options.h | 2 +- lib_dec/lib_dec.c | 2 +- lib_dec/lib_dec.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 7bc6400304..402a085d8d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -149,7 +149,7 @@ /*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ -#define SPLIT_REND_WITH_HEAD_ROT /* Dlb,FhG: Split Rendering contributions 21 and 35 */ +/*#define SPLIT_REND_WITH_HEAD_ROT*/ /* Dlb,FhG: Split Rendering contributions 21 and 35 */ #ifdef SPLIT_REND_WITH_HEAD_ROT #define SPLIT_REND_PRED_QUANT_63_PNTS #define SPLIT_REND_WITH_HEAD_ROT_PARAMBIN /* Nokia: Issue 623: Split rendering support for parambin renderer */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 4083f06cac..72b3f789e5 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -626,7 +626,7 @@ ivas_error IVAS_DEC_GetRenderFramesize( ivas_error IVAS_DEC_GetRenderFramesizeSamples( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - uint16_t *render_framesize /* o : render framesize in samples */ + int16_t *render_framesize /* o : render framesize in samples */ ) { if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || render_framesize == NULL ) diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index c6db5d379f..50f333bac1 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -336,7 +336,7 @@ ivas_error IVAS_DEC_GetRenderFramesize( ivas_error IVAS_DEC_GetRenderFramesizeSamples( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - uint16_t *render_framesize /* o : render framesize in samples */ + int16_t *render_framesize /* o : render framesize in samples */ ); ivas_error IVAS_DEC_GetReferencesUpdateFrequency( -- GitLab From 611f3838901b2f31197776cf9341e7a5d3e5270d Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Wed, 27 Sep 2023 16:59:53 +0200 Subject: [PATCH 19/49] clang-format, fix compiler warning, small fix for split rendering --- lib_dec/ivas_jbm_dec.c | 2 +- lib_dec/lib_dec.c | 4 ++-- lib_rend/ivas_crend.c | 2 +- lib_rend/ivas_rotation.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index dcd545da87..ceb2ded105 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -1410,7 +1410,7 @@ ivas_error ivas_jbm_dec_render( if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { if ( ( error = ivas_rend_crendProcessSubframesSplitBin( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, - &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output : p_tc, p_output, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) + &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output : p_tc, p_output, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 72b3f789e5..8fd05670eb 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -667,8 +667,8 @@ ivas_error IVAS_DEC_GetReferencesUpdateFrequency( *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_GetNumOrientationSubframes( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - int16_t *num_subframes /* o : render framesize */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int16_t *num_subframes /* o : render framesize */ ) { if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || num_subframes == NULL ) diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index 6711d03ce4..f7644ff9d4 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -2397,4 +2397,4 @@ ivas_error ivas_rend_crendProcessSubframesSplitBin( return IVAS_ERR_OK; } #endif -#endif \ No newline at end of file +#endif diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index dca4026b13..85aa535aef 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -956,7 +956,7 @@ ivas_error ivas_combined_orientation_open( } ( *hCombinedOrientationData )->sr_pose_pred_axis = DEFAULT_AXIS; #ifdef NONBE_UNIFIED_DECODING_PATHS - ( *hCombinedOrientationData )->sr_low_res_flag = 1; + ( *hCombinedOrientationData )->sr_low_res_flag = 0; #endif #else for ( j = 0; j < 3; j++ ) -- GitLab From 5c769f4d35571d54d584f7d6f3d2805f3382ac0f Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Wed, 27 Sep 2023 19:02:48 +0200 Subject: [PATCH 20/49] fix tc buffer reconfiguration --- lib_dec/ivas_jbm_dec.c | 70 +++++++++++++++++++++++++++++------------- 1 file changed, 49 insertions(+), 21 deletions(-) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index ceb2ded105..baab3d6e10 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -2865,7 +2865,15 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( { #endif /* realloc buffers */ - free( hTcBuffer->tc_buffer ); +#ifdef REMOVE_5MS_FLAG + if ( hTcBuffer->tc_buffer != NULL ) + { +#endif + free( hTcBuffer->tc_buffer ); + hTcBuffer->tc_buffer = NULL; +#ifdef REMOVE_5MS_FLAG + } +#endif #ifndef UNIFY_CHANNEL_MEM_HEAP if ( st_ivas->hDecoderConfig->Opt_tsm ) { @@ -2883,32 +2891,52 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( nsamp_to_allocate = hTcBuffer->nchan_buffer_full * n_samp_full; nsamp_to_allocate += nchan_residual * n_samp_residual; - if ( ( hTcBuffer->tc_buffer = (float *) malloc( nsamp_to_allocate * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) ); - } - set_zero( hTcBuffer->tc_buffer, nsamp_to_allocate ); - - offset = 0; - for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) +#ifdef REMOVE_5MS_FLAG + if ( nsamp_to_allocate == 0 ) { - hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; - offset += n_samp_full; + hTcBuffer->tc_buffer = NULL; + for ( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS +#ifdef JBM_FOR_OSBA + + MAX_NUM_OBJECTS +#endif + ; + ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = NULL; + } } - for ( ; ch_idx < hTcBuffer->nchan_transport_internal; ch_idx++ ) + else { - hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; - offset += n_samp_residual; - } - for ( ; ch_idx < MAX_TRANSPORT_CHANNELS +#endif + if ( ( hTcBuffer->tc_buffer = (float *) malloc( nsamp_to_allocate * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) ); + } + set_zero( hTcBuffer->tc_buffer, nsamp_to_allocate ); + + offset = 0; + for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; + offset += n_samp_full; + } + for ( ; ch_idx < hTcBuffer->nchan_transport_internal; ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; + offset += n_samp_residual; + } + for ( ; ch_idx < MAX_TRANSPORT_CHANNELS #ifdef JBM_FOR_OSBA - + MAX_NUM_OBJECTS + + MAX_NUM_OBJECTS #endif - ; - ch_idx++ ) - { - hTcBuffer->tc[ch_idx] = NULL; + ; + ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = NULL; + } +#ifdef REMOVE_5MS_FLAG } +#endif #ifdef UNIFY_CHANNEL_MEM_HEAP } } -- GitLab From 56e710a95ecc95c9160dea6ffdb1892160b5cdc2 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Wed, 27 Sep 2023 19:28:23 +0200 Subject: [PATCH 21/49] temp fix for #834, get correct count of old number of channels allocated on the heap --- lib_com/options.h | 1 + lib_dec/ivas_ism_dec.c | 2 +- lib_dec/ivas_omasa_dec.c | 2 +- lib_dec/ivas_sba_dec.c | 2 +- lib_rend/ivas_output_init.c | 2 +- lib_rend/ivas_prot_rend.h | 2 +- 6 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index dee752292d..56a256e78d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -216,6 +216,7 @@ /*#define UNIFY_CHANNEL_MEM_HEAP*/ #define FIX_XXX_CREND_ER #define FIX_XXX_JBM_FOR_OSBA +#define FIX_XXX_CHANNEL_MEM_COUNT #endif #define NONBE_FIX_722_MEMORY_LEAK_IN_PARAMUPMIX /* Dlb : issue 722: memory leak fix in MC param upmix mode with BR switching*/ #define NONBE_FIX_780_ISM_STARTS_WITH_SID /* VA: issue 780: fix Crash in ISM decoding when bitstream starts with an SID and output_config is not EXT */ diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index c6ee19c44f..f2ab5120d8 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -83,7 +83,7 @@ static ivas_error ivas_ism_bitrate_switching_dec( st_ivas->ism_mode = last_ism_mode; ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); st_ivas->ism_mode = ism_mode; -#ifdef UNIFY_CHANNEL_MEM_HEAP +#ifdef FIX_XXX_CHANNEL_MEM_COUNT nchan_out_buff_old = ivas_count_nchan_buffers_dec( st_ivas ); #else #ifdef NONBE_FIX_798_OSBA_MC_DEC_CRASH diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index c69ede248c..014b49d226 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -180,7 +180,7 @@ ivas_error ivas_omasa_dec_config( ivas_format_orig = st_ivas->ivas_format; st_ivas->ivas_format = st_ivas->last_ivas_format; ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); -#ifdef UNIFY_CHANNEL_MEM_HEAP +#ifdef FIX_XXX_CHANNEL_MEM_COUNT nchan_out_buff_old = ivas_count_nchan_buffers_dec( st_ivas ); #else #ifdef NONBE_FIX_798_OSBA_MC_DEC_CRASH diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 0220944637..3600faa979 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -152,7 +152,7 @@ ivas_error ivas_sba_dec_reconfigure( * Set SBA high-level parameters * Save old SBA high-level parameters *-----------------------------------------------------------------*/ -#ifdef UNIFY_CHANNEL_MEM_HEAP +#ifdef FIX_XXX_CHANNEL_MEM_COUNT nchan_out_buff_old = ivas_count_nchan_buffers_dec( st_ivas ); #else #ifdef NONBE_FIX_798_OSBA_MC_DEC_CRASH diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index ff230fc4f2..da909c96aa 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -431,7 +431,7 @@ int16_t ivas_get_nchan_buffers_dec( return nchan_out_buff; } -#ifdef UNIFY_CHANNEL_MEM_HEAP +#ifdef FIX_XXX_CHANNEL_MEM_COUNT /*-----------------------------------------------------------------* * ivas_count_nchan_buffers_dec() * diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index fd0ce97015..532a01a677 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -79,7 +79,7 @@ int16_t ivas_get_nchan_buffers_dec( const int32_t ivas_total_brate /* i : total IVAS bitrate */ #endif ); -#ifdef UNIFY_CHANNEL_MEM_HEAP +#ifdef FIX_XXX_CHANNEL_MEM_COUNT int16_t ivas_count_nchan_buffers_dec( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); -- GitLab From f6892a98e84c82c9667016dac9c76d6aabbddde7 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Wed, 27 Sep 2023 19:30:32 +0200 Subject: [PATCH 22/49] amend last fix --- lib_dec/ivas_sba_dec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 3600faa979..da7ced0fe0 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -159,6 +159,7 @@ ivas_error ivas_sba_dec_reconfigure( nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, sba_analysis_order_old, last_ivas_total_brate ); #else nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas ); +#endif #endif ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); -- GitLab From 1e8bbd08d4bf326ef63fc5c115351adc6883bcf7 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Wed, 27 Sep 2023 19:32:16 +0200 Subject: [PATCH 23/49] and again fixing the fix --- lib_dec/ivas_sba_dec.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index da7ced0fe0..9270163302 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -184,7 +184,6 @@ ivas_error ivas_sba_dec_reconfigure( nCPE_old = st_ivas->nCPE; nchan_transport_old = st_ivas->nchan_transport; sba_dirac_stereo_flag_old = st_ivas->sba_dirac_stereo_flag; -#endif st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order ); -- GitLab From 60dde54e8fcba4ba09bcb52b7c1aa999404f615f Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Wed, 27 Sep 2023 19:36:03 +0200 Subject: [PATCH 24/49] fix Linux make warning --- lib_dec/ivas_sba_dec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 9270163302..e0db34d798 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -144,8 +144,10 @@ ivas_error ivas_sba_dec_reconfigure( #ifdef JBM_FOR_OSBA sba_analysis_order_old_flush = st_ivas->sba_analysis_order; #endif +#ifndef FIX_XXX_CHANNEL_MEM_COUNT #ifdef NONBE_FIX_798_OSBA_MC_DEC_CRASH sba_analysis_order_old = ivas_sba_get_analysis_order( last_ivas_total_brate, st_ivas->sba_order ); +#endif #endif /*-----------------------------------------------------------------* -- GitLab From 29828386bbdd7fb970070b33f192c409b0827dac Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Thu, 28 Sep 2023 04:30:57 +0200 Subject: [PATCH 25/49] fix compiler warning, fix channel mem on heap counting --- lib_dec/ivas_sba_dec.c | 5 +++++ lib_rend/ivas_output_init.c | 12 ++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index e0db34d798..2a84fc463e 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -122,9 +122,11 @@ ivas_error ivas_sba_dec_reconfigure( int32_t last_ivas_total_brate; int16_t num_channels, num_md_sub_frames; int16_t ch, nchan_out_buff, nchan_out_buff_old; +#ifndef FIX_XXX_CHANNEL_MEM_COUNT #ifdef NONBE_FIX_798_OSBA_MC_DEC_CRASH int16_t sba_analysis_order_old; #endif +#endif #ifdef JBM_FOR_OSBA int16_t sba_analysis_order_old_flush; #endif @@ -809,6 +811,9 @@ ivas_error ivas_sba_dec_reconfigure( if ( !st_ivas->hDecoderConfig->Opt_5ms ) #endif { +#ifdef FIX_XXX_CHANNEL_MEM_COUNT + nchan_out_buff_old = ivas_count_nchan_buffers_dec( st_ivas ); +#endif #ifdef NONBE_FIX_798_OSBA_MC_DEC_CRASH nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); #else diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index da909c96aa..81e4af1dec 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -444,7 +444,11 @@ int16_t ivas_count_nchan_buffers_dec( ) { int16_t ch_idx, ch_cnt; - for ( ch_idx = 0, ch_cnt = 0; ch_idx < MAX_OUTPUT_CHANNELS; ch_idx++, ch_cnt++ ) + for ( ch_idx = 0, ch_cnt = 0; ch_idx < MAX_OUTPUT_CHANNELS +#ifdef JBM_FOR_OSBA + + MAX_NUM_OBJECTS +#endif + ; ch_idx++, ch_cnt++ ) { if ( st_ivas->p_output_f[ch_idx] == NULL ) { @@ -452,7 +456,11 @@ int16_t ivas_count_nchan_buffers_dec( } } #ifdef DEBUGGING - for ( ; ch_idx < MAX_OUTPUT_CHANNELS; ch_idx++ ) + for ( ; ch_idx < MAX_OUTPUT_CHANNELS +#ifdef JBM_FOR_OSBA + + MAX_NUM_OBJECTS +#endif + ; ch_idx++ ) { assert( st_ivas->p_output_f[ch_idx] == NULL ); } -- GitLab From 5e1e17d1d51c422b37abc22d25d889664bc1144d Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Thu, 28 Sep 2023 04:48:52 +0200 Subject: [PATCH 26/49] fix compiler warning --- lib_dec/ivas_ism_dec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index a9b110b2e6..f47ed02c93 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -85,7 +85,8 @@ static ivas_error ivas_ism_bitrate_switching_dec( st_ivas->ism_mode = ism_mode; #ifdef FIX_XXX_CHANNEL_MEM_COUNT nchan_out_buff_old = ivas_count_nchan_buffers_dec( st_ivas ); -#else nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); +#else + nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); #endif if ( ( error = ivas_ism_config( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->nchan_ism, NULL, 0, NULL, NULL, element_brate_tmp, NULL, NULL, 0 ) ) != IVAS_ERR_OK ) -- GitLab From 3874042b9998a7a0f98894f08a4e76b30127c6f9 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Thu, 28 Sep 2023 05:05:39 +0200 Subject: [PATCH 27/49] clang-format --- lib_dec/ivas_ism_dec.c | 2 +- lib_rend/ivas_output_init.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index f47ed02c93..8b089bd986 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -85,7 +85,7 @@ static ivas_error ivas_ism_bitrate_switching_dec( st_ivas->ism_mode = ism_mode; #ifdef FIX_XXX_CHANNEL_MEM_COUNT nchan_out_buff_old = ivas_count_nchan_buffers_dec( st_ivas ); -#else +#else nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); #endif diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index 3f29e02678..4807ade35d 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -436,7 +436,8 @@ int16_t ivas_count_nchan_buffers_dec( #ifdef JBM_FOR_OSBA + MAX_NUM_OBJECTS #endif - ; ch_idx++, ch_cnt++ ) + ; + ch_idx++, ch_cnt++ ) { if ( st_ivas->p_output_f[ch_idx] == NULL ) { @@ -448,7 +449,8 @@ int16_t ivas_count_nchan_buffers_dec( #ifdef JBM_FOR_OSBA + MAX_NUM_OBJECTS #endif - ; ch_idx++ ) + ; + ch_idx++ ) { assert( st_ivas->p_output_f[ch_idx] == NULL ); } -- GitLab From 152dbbdbf20e18fca53923aeced368a9bff6e309 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Thu, 28 Sep 2023 06:29:08 +0200 Subject: [PATCH 28/49] temp fix for #835, fix ParamUpmix binaural rendering with fastconv and head rotation --- lib_dec/ivas_mc_paramupmix_dec.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index f8118db708..a41b1a55c1 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -1038,6 +1038,17 @@ static void ivas_mc_paramupmix_dec_sf( int16_t noparamupmix_delay, n_samples_rendered; MC_PARAMUPMIX_DEC_HANDLE hMCParamUpmix; int16_t subframeIdx, idx_in, maxBand; +#ifdef FIX_XXX_JBM_PARAMUPMIX_HEADROT + float Cldfb_RealBuffer_subfr[MAX_INTERN_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer_subfr[MAX_INTERN_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; +#ifdef SPLIT_REND_WITH_HEAD_ROT + float Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; +#else + float Cldfb_RealBuffer_Binaural[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer_Binaural[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; +#endif +#else #ifdef SPLIT_REND_WITH_HEAD_ROT float Cldfb_RealBuffer_subfr[MC_PARAMUPMIX_MAX_INPUT_CHANS][JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; float Cldfb_ImagBuffer_subfr[MC_PARAMUPMIX_MAX_INPUT_CHANS][JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; @@ -1050,7 +1061,7 @@ static void ivas_mc_paramupmix_dec_sf( float Cldfb_RealBuffer_Binaural[BINAURAL_CHANNELS][JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; float Cldfb_ImagBuffer_Binaural[BINAURAL_CHANNELS][JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; #endif - +#endif hMCParamUpmix = st_ivas->hMCParamUpmix; assert( hMCParamUpmix ); push_wmops( "ivas_mc_paramupmix_dec_sf" ); @@ -1137,10 +1148,21 @@ static void ivas_mc_paramupmix_dec_sf( idx_in += 2; } +#ifdef FIX_XXX_JBM_PARAMUPMIX_HEADROT + if ( st_ivas->hCombinedOrientationData && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) + { + for ( slot_idx = 0; slot_idx < st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->subframes_rendered]; slot_idx++ ) + { + ivas_param_mc_mc2sba_cldfb( st_ivas->hTransSetup, hMCParamUpmix->hoa_encoder, slot_idx, Cldfb_RealBuffer_subfr, Cldfb_ImagBuffer_subfr, maxBand, GAIN_LFE ); + } + } +#endif + #ifdef SPLIT_REND_WITH_HEAD_ROT /*LFE handling for split rendering cases*/ if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { +#ifndef FIX_XXX_JBM_PARAMUPMIX_HEADROT for ( idx_lfe = 0; idx_lfe < st_ivas->hIntSetup.num_lfe; idx_lfe++ ) { ch = st_ivas->hIntSetup.index_lfe[idx_lfe]; @@ -1150,7 +1172,7 @@ static void ivas_mc_paramupmix_dec_sf( } idx_in++; } - +#endif #ifdef SPLIT_REND_WITH_HEAD_ROT if ( st_ivas->hSplitBinRend.hCldfbDataOut != NULL ) { @@ -1199,7 +1221,10 @@ static void ivas_mc_paramupmix_dec_sf( } } #endif - +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* update combined orientation access index */ + ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, maxBand * MAX_PARAM_SPATIAL_SUBFRAMES ); +#endif /* Implement CLDFB synthesis */ for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { -- GitLab From 5c55b5eb206a120d9641ac06a058e1cf131c6f48 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Thu, 28 Sep 2023 06:45:16 +0200 Subject: [PATCH 29/49] temp fix for #835, fix ParamUpmix binaural rendering with fastconv and head rotation, add define to options.h --- lib_com/options.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 9ff01df115..6ba4b77501 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -149,7 +149,7 @@ /*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ -/*#define SPLIT_REND_WITH_HEAD_ROT*/ /* Dlb,FhG: Split Rendering contributions 21 and 35 */ +/*#define SPLIT_REND_WITH_HEAD_ROT*/ /* Dlb,FhG: Split Rendering contributions 21 and 35 */ #ifdef SPLIT_REND_WITH_HEAD_ROT #define SPLIT_REND_PRED_QUANT_63_PNTS #define SPLIT_REND_WITH_HEAD_ROT_PARAMBIN /* Nokia: Issue 623: Split rendering support for parambin renderer */ @@ -196,6 +196,7 @@ #define FIX_XXX_CREND_ER #define FIX_XXX_JBM_FOR_OSBA #define FIX_XXX_CHANNEL_MEM_COUNT +#define FIX_XXX_JBM_PARAMUPMIX_HEADROT #endif /* ##################### End NON-BE switches ########################### */ -- GitLab From 5df8a02f90169fc43a92f42da153c8e0d5a55160 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Thu, 28 Sep 2023 07:35:29 +0200 Subject: [PATCH 30/49] fix split rendering with rendering to time domain --- lib_com/options.h | 2 +- lib_dec/ivas_jbm_dec.c | 6 +++++- lib_dec/ivas_objectRenderer_internal.c | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 6ba4b77501..076b7de34f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -149,7 +149,7 @@ /*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ -/*#define SPLIT_REND_WITH_HEAD_ROT*/ /* Dlb,FhG: Split Rendering contributions 21 and 35 */ +#define SPLIT_REND_WITH_HEAD_ROT /* Dlb,FhG: Split Rendering contributions 21 and 35 */ #ifdef SPLIT_REND_WITH_HEAD_ROT #define SPLIT_REND_PRED_QUANT_63_PNTS #define SPLIT_REND_WITH_HEAD_ROT_PARAMBIN /* Nokia: Issue 623: Split rendering support for parambin renderer */ diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index aab5632b86..bb358a4b35 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -1616,7 +1616,11 @@ ivas_error ivas_jbm_dec_render( if ( st_ivas->ivas_format != MONO_FORMAT ) { #ifndef DISABLE_LIMITER +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_limiter_dec( st_ivas->hLimiter, p_output, nchan_out_syn_output, *nSamplesRendered, st_ivas->BER_detect ); +#else ivas_limiter_dec( st_ivas->hLimiter, p_output, nchan_out, *nSamplesRendered, st_ivas->BER_detect ); +#endif #endif } } @@ -1638,7 +1642,7 @@ ivas_error ivas_jbm_dec_render( #ifdef SPLIT_REND_WITH_HEAD_ROT break; case PCM_FLOAT32: - ivas_syn_output_f( p_output, *nSamplesRendered, nchan_out, (float *) data ); + ivas_syn_output_f( p_output, *nSamplesRendered, nchan_out_syn_output, (float *) data ); break; default: error = IVAS_ERR_UNKNOWN; diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index ab9d9dc0e3..029aa5d11b 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -307,6 +307,7 @@ ivas_error ivas_td_binaural_renderer_sf_splitBinaural( BINAURAL_TD_OBJECT_RENDERER_HANDLE origTdRendHandle; ivas_error error; int16_t original_subframes_rendered; + int16_t original_slots_rendered; float *p_bin_output[BINAURAL_CHANNELS]; push_wmops( "ivas_td_binaural_renderer_sf_splitBinaural" ); @@ -342,6 +343,7 @@ ivas_error ivas_td_binaural_renderer_sf_splitBinaural( } original_subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; + original_slots_rendered = st_ivas->hTcBuffer->slots_rendered; origTdRendHandle = st_ivas->hBinRendererTd; for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses; pos_idx++ ) @@ -380,6 +382,7 @@ ivas_error ivas_td_binaural_renderer_sf_splitBinaural( p_bin_output[i] = output[pos_idx * BINAURAL_CHANNELS + i]; } st_ivas->hTcBuffer->subframes_rendered = original_subframes_rendered; + st_ivas->hTcBuffer->slots_rendered = original_slots_rendered; ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData ); /* Render */ -- GitLab From b13acd40534c1d2357efaa4b338787d602810abd Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Thu, 28 Sep 2023 07:37:47 +0200 Subject: [PATCH 31/49] deactivate switch for split rendering --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 076b7de34f..4dff894c37 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -149,7 +149,7 @@ /*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ -#define SPLIT_REND_WITH_HEAD_ROT /* Dlb,FhG: Split Rendering contributions 21 and 35 */ +/*#define SPLIT_REND_WITH_HEAD_ROT */ /* Dlb,FhG: Split Rendering contributions 21 and 35 */ #ifdef SPLIT_REND_WITH_HEAD_ROT #define SPLIT_REND_PRED_QUANT_63_PNTS #define SPLIT_REND_WITH_HEAD_ROT_PARAMBIN /* Nokia: Issue 623: Split rendering support for parambin renderer */ -- GitLab From d9cd67528e750f677e821beee016f7573c37ef82 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Thu, 28 Sep 2023 08:18:48 +0200 Subject: [PATCH 32/49] fix JBM crend split rendering --- lib_rend/ivas_crend.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index f7644ff9d4..d399579175 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -2289,6 +2289,9 @@ ivas_error ivas_rend_crendProcessSubframesSplitBin( p_tmpInputBuffer[i] = tmpInputBuffer[i]; } + /* save current head positions */ + pCombinedOrientationDataLocal = hCombinedOrientationData; + combinedOrientationDataLocal = *pCombinedOrientationDataLocal; if ( pMultiBinPoseData->poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) { for ( sf = 1; sf < hCombinedOrientationData->num_subframes; ++sf ) @@ -2366,6 +2369,11 @@ ivas_error ivas_rend_crendProcessSubframesSplitBin( return error; } + for ( i = 0; i < 3; i++ ) + { + mvr2r( pCombinedOrientationDataLocal->Rmat_prev[0][i], hCombinedOrientationData->Rmat_prev[pos_idx][i], 3 ); + } + for ( i = 0; i < BINAURAL_CHANNELS; ++i ) { /* accumulate LFE to output */ -- GitLab From dfbbc9d9a0323ae15e3552f21a2c9bfb026e5f10 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Thu, 28 Sep 2023 09:30:05 +0200 Subject: [PATCH 33/49] fix paramupmix JBM split rendering --- lib_dec/ivas_mc_paramupmix_dec.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index a41b1a55c1..07d9738e0c 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -1221,10 +1221,7 @@ static void ivas_mc_paramupmix_dec_sf( } } #endif -#ifdef NONBE_UNIFIED_DECODING_PATHS - /* update combined orientation access index */ - ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, maxBand * MAX_PARAM_SPATIAL_SUBFRAMES ); -#endif + /* Implement CLDFB synthesis */ for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { -- GitLab From 4384cafb7774e8fa8de9daa45f52c1a2870fb1b8 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Thu, 28 Sep 2023 10:25:32 +0200 Subject: [PATCH 34/49] fix OSBA JBM split rendering --- lib_dec/ivas_jbm_dec.c | 20 ++++++++++---- lib_dec/ivas_osba_dec.c | 59 ++++++++++++++++++++++++++++++++++++----- 2 files changed, 67 insertions(+), 12 deletions(-) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index bb358a4b35..9796b0d8b6 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -883,11 +883,20 @@ ivas_error ivas_jbm_dec_feed_tc_to_renderer( ivas_ism_dec_digest_tc( st_ivas ); /* delay the objects here for all renderers where it is needed */ - if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || - st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || - st_ivas->renderer_type == RENDERER_OSBA_AMBI || - st_ivas->renderer_type == RENDERER_OSBA_LS || - st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) + if ( +#ifdef OSBA_SPLIT_RENDERING + ( +#endif + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || + st_ivas->renderer_type == RENDERER_OSBA_AMBI || + st_ivas->renderer_type == RENDERER_OSBA_LS || + st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL +#ifdef OSBA_SPLIT_RENDERING + ) && + ( st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#endif + ) { for ( n = 0; n < st_ivas->nchan_ism; n++ ) { @@ -1449,6 +1458,7 @@ ivas_error ivas_jbm_dec_render( } } #endif + if ( st_ivas->transport_config != st_ivas->intern_config && ( st_ivas->intern_config == IVAS_AUDIO_CONFIG_FOA || st_ivas->intern_config == IVAS_AUDIO_CONFIG_HOA2 || st_ivas->intern_config == IVAS_AUDIO_CONFIG_HOA3 ) ) { ivas_mc2sba( st_ivas->hTransSetup, p_output, p_output, *nSamplesRendered, st_ivas->hIntSetup.ambisonics_order, GAIN_LFE ); diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index 07b4bd23f8..36011c7040 100644 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -138,19 +138,64 @@ ivas_error ivas_osba_dirac_td_binaural_jbm( ivas_sba_dec_render( st_ivas, nSamplesAsked, nSamplesRendered, nSamplesAvailable, &output_f[2] ); - if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, output_f, *nSamplesRendered ) ) != IVAS_ERR_OK ) +#ifdef OSBA_SPLIT_RENDERING + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { - return error; - } + int16_t slot_idx, num_cldfb_bands, b, nchan_transport_orig; + int16_t cldfb_slots, slot_idx_start; + float Cldfb_RealBuffer[CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer[CLDFB_NO_CHANNELS_MAX]; + + num_cldfb_bands = st_ivas->hSplitBinRend.splitrend.hCldfbHandles->cldfbAna[0]->no_channels; + nchan_transport_orig = st_ivas->nchan_transport; + st_ivas->nchan_transport = st_ivas->nchan_ism; + slot_idx_start = st_ivas->hTcBuffer->n_samples_rendered / num_cldfb_bands; + if ( ( error = ivas_td_binaural_renderer_sf_splitBinaural( st_ivas, output_f, *nSamplesRendered ) ) != IVAS_ERR_OK ) + { + return error; + } + st_ivas->nchan_transport = nchan_transport_orig; + cldfb_slots = *nSamplesRendered / num_cldfb_bands; - for ( n = 0; n < BINAURAL_CHANNELS; n++ ) + for ( n = 0; n < st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses * BINAURAL_CHANNELS; ++n ) + { + for ( slot_idx = 0; slot_idx < cldfb_slots; slot_idx++ ) + { + cldfbAnalysis_ts( &( output_f[n][num_cldfb_bands * slot_idx] ), Cldfb_RealBuffer, Cldfb_ImagBuffer, num_cldfb_bands, st_ivas->hSplitBinRend.splitrend.hCldfbHandles->cldfbAna[n] ); + + for ( b = 0; b < num_cldfb_bands; b++ ) + { + st_ivas->hSplitBinRend.hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[n][slot_idx][b] = + ( 0.5f * st_ivas->hSplitBinRend.hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[n][slot_idx_start+slot_idx][b] ) + + ( 0.5f * Cldfb_RealBuffer[b] ); + + st_ivas->hSplitBinRend.hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[n][slot_idx][b] = + ( 0.5f * st_ivas->hSplitBinRend.hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[n][slot_idx_start+slot_idx][b] ) + + ( 0.5f * Cldfb_ImagBuffer[b] ); + } + } + } + } + else { - int16_t i; - for ( i = 0; i < nSamplesAsked; i++ ) +#endif + + if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, output_f, *nSamplesRendered ) ) != IVAS_ERR_OK ) { - output_f[n][i] = 0.5f * output_f[2 + n][i] + 0.5f * output_f[n][i]; + return error; + } + + for ( n = 0; n < BINAURAL_CHANNELS; n++ ) + { + int16_t i; + for ( i = 0; i < nSamplesAsked; i++ ) + { + output_f[n][i] = 0.5f * output_f[2 + n][i] + 0.5f * output_f[n][i]; + } } +#ifdef OSBA_SPLIT_RENDERING } +#endif return IVAS_ERR_OK; } -- GitLab From d2d05f5c8db12290a4841587c575ff92e141c1e7 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Thu, 28 Sep 2023 10:50:06 +0200 Subject: [PATCH 35/49] clang-format --- lib_dec/ivas_osba_dec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index 36011c7040..a0a2ad35f3 100644 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -166,11 +166,11 @@ ivas_error ivas_osba_dirac_td_binaural_jbm( for ( b = 0; b < num_cldfb_bands; b++ ) { st_ivas->hSplitBinRend.hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[n][slot_idx][b] = - ( 0.5f * st_ivas->hSplitBinRend.hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[n][slot_idx_start+slot_idx][b] ) + + ( 0.5f * st_ivas->hSplitBinRend.hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[n][slot_idx_start + slot_idx][b] ) + ( 0.5f * Cldfb_RealBuffer[b] ); st_ivas->hSplitBinRend.hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[n][slot_idx][b] = - ( 0.5f * st_ivas->hSplitBinRend.hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[n][slot_idx_start+slot_idx][b] ) + + ( 0.5f * st_ivas->hSplitBinRend.hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[n][slot_idx_start + slot_idx][b] ) + ( 0.5f * Cldfb_ImagBuffer[b] ); } } -- GitLab From fd0c919f2443bb8f34f1aea016d7c8874644fc82 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Mon, 2 Oct 2023 10:20:50 +0200 Subject: [PATCH 36/49] address some comments on the MR, amend temp fix for MC RS --- apps/decoder.c | 78 +++++++----------------------------- apps/renderer.c | 81 ++++++++++++++++++++++++++++++++++++++ lib_com/common_api_types.h | 10 ++--- lib_com/options.h | 2 +- lib_dec/ivas_dec.c | 10 ++--- lib_dec/ivas_init_dec.c | 2 +- lib_dec/ivas_mct_dec.c | 1 + lib_dec/ivas_stat_dec.h | 2 +- lib_dec/lib_dec.c | 37 +++++++++++++---- lib_dec/lib_dec.h | 11 ++++-- lib_rend/ivas_prot_rend.h | 6 +-- lib_rend/ivas_rotation.c | 24 +++-------- 12 files changed, 155 insertions(+), 109 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index bd48e2156a..1debfec73d 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -131,17 +131,13 @@ typedef struct #ifndef REMOVE_5MS_FLAG bool enable5ms; #else - RENDER_FRAMESIZE renderFramesize; + IVAS_RENDER_FRAMESIZE renderFramesize; #endif #ifdef DEBUGGING IVAS_DEC_FORCED_REND_MODE forcedRendMode; #ifdef DEBUG_FOA_AGC FILE *agcBitstream; /* temporary */ #endif -#ifdef DEBUG_JBM_CMD_OPTION - bool noBadFrameDelay; - uint16_t frontendFetchSizeMs; -#endif #ifdef VARIABLE_SPEED_DECODING bool tsmScaleFileEnabled; char *tsmScaleFileName; @@ -630,7 +626,7 @@ int main( #ifdef SPLIT_REND_WITH_HEAD_ROT if ( #ifdef REMOVE_5MS_FLAG - arg.renderFramesize == RENDER_FRAMESIZE_5MS && + arg.renderFramesize == IVAS_RENDER_FRAMESIZE_5MS && #else arg.enable5ms && #endif @@ -639,7 +635,7 @@ int main( { /*TODO : needs to be refined as this wont work with LCLD codec*/ #ifdef REMOVE_5MS_FLAG - arg.renderFramesize = RENDER_FRAMESIZE_5MS; + arg.renderFramesize = IVAS_RENDER_FRAMESIZE_5MS; #else arg.enable5ms = true; #endif @@ -647,7 +643,7 @@ int main( else { #ifdef REMOVE_5MS_FLAG - arg.renderFramesize = RENDER_FRAMESIZE_20MS; + arg.renderFramesize = IVAS_RENDER_FRAMESIZE_20MS; #else arg.enable5ms = true; #endif @@ -1054,7 +1050,7 @@ static bool parseCmdlIVAS_dec( #ifndef REMOVE_5MS_FLAG arg->enable5ms = false; #else - arg->renderFramesize = RENDER_FRAMESIZE_20MS; + arg->renderFramesize = IVAS_RENDER_FRAMESIZE_20MS; #endif #ifdef DEBUGGING #ifdef VARIABLE_SPEED_DECODING @@ -1062,12 +1058,6 @@ static bool parseCmdlIVAS_dec( arg->tsmScaleFileEnabled = false; arg->tsmScaleFileName = NULL; #endif -#ifdef DEBUG_JBM_CMD_OPTION - arg->frontendFetchSizeMs = JBM_FRONTEND_FETCH_FRAMESIZE_MS; -#endif -#ifdef DEBUG_JBM_CMD_OPTION - arg->noBadFrameDelay = false; -#endif #endif arg->acousticEnvironmentId = 65535; for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; ++i ) @@ -1203,13 +1193,6 @@ static bool parseCmdlIVAS_dec( } #endif /* #ifdef DEBUG_MODE_INFO_TWEAK */ #endif /* #ifdef DEBUG_MODE_INFO */ -#ifdef DEBUG_JBM_CMD_OPTION - else if ( strcmp( argv_to_upper, "-VOIP_NO_BAD_FRAME" ) == 0 ) - { - arg->noBadFrameDelay = true; - i++; - } -#endif #ifdef VARIABLE_SPEED_DECODING else if ( strcmp( argv_to_upper, "-VS" ) == 0 ) { @@ -1243,26 +1226,6 @@ static bool parseCmdlIVAS_dec( } } #endif -#ifdef DEBUG_JBM_CMD_OPTION - else if ( strcmp( argv_to_upper, "-VOIP_FRAMESIZE" ) == 0 ) - { - i++; - int32_t tmp; - if ( i < argc - 3 ) - { - if ( !is_digits_only( argv[i] ) ) - { - return false; - } - - if ( sscanf( argv[i], "%d", &tmp ) > 0 ) - { - i++; - } - arg->frontendFetchSizeMs = (uint16_t) tmp; - } - } -#endif #endif /* #ifdef DEBUGGING */ else if ( strcmp( argv_to_upper, "-MIME" ) == 0 ) @@ -1310,13 +1273,13 @@ static bool parseCmdlIVAS_dec( switch ( (int16_t) tmp ) { case 5: - arg->renderFramesize = RENDER_FRAMESIZE_5MS; + arg->renderFramesize = IVAS_RENDER_FRAMESIZE_5MS; break; case 10: - arg->renderFramesize = RENDER_FRAMESIZE_10MS; + arg->renderFramesize = IVAS_RENDER_FRAMESIZE_10MS; break; case 20: - arg->renderFramesize = RENDER_FRAMESIZE_20MS; + arg->renderFramesize = IVAS_RENDER_FRAMESIZE_20MS; break; default: fprintf( stderr, "Error: Invalid render frame size %d \n\n", tmp ); @@ -1690,9 +1653,6 @@ static void usage_dec( void ) fprintf( stdout, "-VOIP : VoIP mode: RTP in G192\n" ); fprintf( stdout, "-VOIP_hf_only=0 : VoIP mode: EVS RTP Payload Format hf_only=0 in rtpdump\n" ); fprintf( stdout, "-VOIP_hf_only=1 : VoIP mode: EVS RTP Payload Format hf_only=1 in rtpdump\n" ); -#ifdef DEBUG_JBM_CMD_OPTION - fprintf( stdout, "-VOIP_no_bad_frame : VoIP mode: do not put out bad frames in the beginning as silence \n" ); -#endif fprintf( stdout, " The decoder may read rtpdump files containing TS26.445 Annex A.2.2\n" ); fprintf( stdout, " EVS RTP Payload Format. The SDP parameter hf_only is required.\n" ); fprintf( stdout, " Reading RFC4867 AMR/AMR-WB RTP payload format is not supported.\n" ); @@ -1704,14 +1664,11 @@ static void usage_dec( void ) fprintf( stdout, "-VS fac : Variable Speed mode: change speed of playout fac as integer in percent.\n" ); fprintf( stdout, " 50 <= fac <= 150; fac<100 faster, fac>100 slower\n" ); #endif -#ifdef DEBUG_JBM_CMD_OPTION - fprintf( stdout, "-VOIP_framesize : VoIP mode: acoustic frontend fetch frame size (must be multiples of 5!)\n" ); -#endif #endif #ifndef REMOVE_5MS_FLAG fprintf( stdout, "-fr5 : option to perform rendering + head-tracking with 5ms frame size\n" ); #else - fprintf( stdout, "-fr : render frame size in ms (5,10,20, default is 20)\n" ); + fprintf( stdout, "-fr L : render frame size in ms L=(5,10,20), default is 20)\n" ); #endif fprintf( stdout, "-fec_cfg_file : Optimal channel aware configuration computed by the JBM \n" ); fprintf( stdout, " as described in Section 6.3.1 of TS26.448. The output is \n" ); @@ -2997,6 +2954,11 @@ static ivas_error decodeVoIP( #ifdef NONBE_UNIFIED_DECODING_PATHS vec_pos_update = 0; #ifdef REMOVE_5MS_FLAG + if ( ( error = IVAS_DEC_GetRenderFramesizeMs( hIvasDec, &systemTimeInc_ms ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError getting render frame size in samples\n" ); + return error; + } if ( ( error = IVAS_DEC_GetRenderFramesizeSamples( hIvasDec, &nOutSamples ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError getting render frame size in samples\n" ); @@ -3118,10 +3080,6 @@ static ivas_error decodeVoIP( * Main receiving/decoding loop *------------------------------------------------------------------------------------------*/ -#ifdef DEBUG_JBM_CMD_OPTION - systemTimeInc_ms = arg.frontendFetchSizeMs; -#endif - while ( 1 ) { #ifndef NONBE_UNIFIED_DECODING_PATHS @@ -3130,12 +3088,8 @@ static ivas_error decodeVoIP( #else int16_t nOutSamples = 0; #endif -#ifdef DEBUG_JBM_CMD_OPTION - nOutSamples = (int16_t) ( arg.output_Fs / 1000 * arg.frontendFetchSizeMs ); -#else nOutSamples = (int16_t) ( arg.output_Fs / 1000 * JBM_FRONTEND_FETCH_FRAMESIZE_MS ); #endif -#endif #ifdef NONBE_UNIFIED_DECODING_PATHS /* reference vector */ @@ -3383,11 +3337,7 @@ static ivas_error decodeVoIP( goto cleanup; } } -#ifdef DEBUG_JBM_CMD_OPTION - else if ( arg.noBadFrameDelay == false ) -#else else -#endif { ++numInitialBadFrames; } diff --git a/apps/renderer.c b/apps/renderer.c index f121eb241a..d0f770867a 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -187,7 +187,11 @@ typedef struct bool lfeCustomRoutingEnabled; char inLfePanningMatrixFile[RENDERER_MAX_CLI_ARG_LENGTH]; float syncMdDelay; +#ifdef REMOVE_5MS_FLAG + IVAS_RENDER_FRAMESIZE render_framesize; +#else bool framing_5ms; +#endif uint16_t directivityPatternId[RENDERER_MAX_ISM_INPUTS]; uint16_t acousticEnvironmentId; } CmdlnArgs; @@ -219,6 +223,9 @@ typedef enum #endif CmdLnOptionId_referenceVectorFile, CmdLnOptionId_exteriorOrientationFile, +#ifdef REMOVE_5MS_FLAG + CmdLnOptionId_framing, +#endif CmdLnOptionId_framing5ms, CmdLnOptionId_syncMdDelay, CmdLnOptionId_directivityPatternId, @@ -368,6 +375,14 @@ static const CmdLnParser_Option cliOptions[] = { .matchShort = "exof", .description = "External orientation trajectory file for simulation of external orientations", }, +#ifdef REMOVE_5MS_FLAG + { + .id = CmdLnOptionId_framing, + .match = "framing", + .matchShort = "fr", + .description = "Set Render audio framing.", + }, +#endif { .id = CmdLnOptionId_framing5ms, .match = "framing_5ms", @@ -1001,9 +1016,17 @@ int main( #ifdef SPLIT_REND_WITH_HEAD_ROT } #endif +#ifdef REMOVE_5MS_FLAG + const int16_t frameSize_smpls = (int16_t) ( ( args.render_framesize ) * args.sampleRate * 5 / ( 1000 ) ); +#else const int16_t frameSize_smpls = (int16_t) ( ( args.framing_5ms ? 5 : 20 ) * args.sampleRate / 1000 ); +#endif +#ifdef REMOVE_5MS_FLAG + if ( ( error = IVAS_REND_Open( &hIvasRend, args.sampleRate, args.outConfig.audioConfig, args.nonDiegeticPan, args.nonDiegeticPanGain, (int16_t) args.render_framesize ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_REND_Open( &hIvasRend, args.sampleRate, args.outConfig.audioConfig, args.nonDiegeticPan, args.nonDiegeticPanGain, ( args.framing_5ms ) ? 1 : 4 ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "Error opening renderer handle: %s\n", ivas_error_to_string( error ) ); exit( -1 ); @@ -1498,7 +1521,11 @@ int main( { int16_t num_in_channels; num_in_channels = inBuffer.config.numChannels; +#ifdef REMOVE_5MS_FLAG + const bool isCurrentFrameMultipleOf20ms = frame % ( 4 / args.render_framesize ) == 0; +#else const bool isCurrentFrameMultipleOf20ms = !args.framing_5ms || frame % 4 == 0; +#endif #ifdef SPLIT_REND_WITH_HEAD_ROT numSamplesRead = 0; @@ -1550,7 +1577,11 @@ int main( #endif int16_t num_subframes, sf_idx; +#ifdef REMOVE_5MS_FLAG + num_subframes = (int16_t) args.render_framesize; +#else num_subframes = ( args.framing_5ms ) ? 1 : IVAS_MAX_PARAM_SPATIAL_SUBFRAMES; +#endif if ( isCurrentFrameMultipleOf20ms ) { @@ -2338,6 +2369,37 @@ static bool parseDiegeticPan( return true; } + +#ifdef REMOVE_5MS_FLAG +static bool parseRenderFramesize( char *value, + IVAS_RENDER_FRAMESIZE *render_framesize ) +{ + int32_t tmp; + + *render_framesize = IVAS_RENDER_FRAMESIZE_UNKNOWN; + if ( !is_digits_only( value ) ) + { + return false; + } + tmp = (int32_t) strtol( value, NULL, 0 ); + switch ( (int16_t) tmp ) + { + case 5: + *render_framesize = IVAS_RENDER_FRAMESIZE_5MS; + break; + case 10: + *render_framesize = IVAS_RENDER_FRAMESIZE_10MS; + break; + case 20: + *render_framesize = IVAS_RENDER_FRAMESIZE_20MS; + break; + default: + return false; + } + return true; +} +#endif + static bool parseOrientationTracking( char *value, int8_t *orientation_tracking ) @@ -2635,7 +2697,11 @@ static CmdlnArgs defaultArgs( args.lfeCustomRoutingEnabled = false; clearString( args.inLfePanningMatrixFile ); +#ifdef REMOVE_5MS_FLAG + args.render_framesize = IVAS_RENDER_FRAMESIZE_20MS; +#else args.framing_5ms = false; +#endif args.syncMdDelay = 0; for ( int32_t i = 0; i < RENDERER_MAX_ISM_INPUTS; ++i ) @@ -2801,9 +2867,24 @@ static void parseOption( exit( -1 ); } break; +#ifdef REMOVE_5MS_FLAG + case CmdLnOptionId_framing: + assert( numOptionValues == 1 ); + if ( !parseRenderFramesize( optionValues[0], &args->render_framesize ) ) + { + fprintf( stderr, "Unknown or invalid option for LFE position: %s\n", optionValues[0] ); + exit( -1 ); + } + + break; +#endif case CmdLnOptionId_framing5ms: assert( numOptionValues == 0 ); +#ifdef REMOVE_5MS_FLAG + args->render_framesize = IVAS_RENDER_FRAMESIZE_5MS; +#else args->framing_5ms = true; +#endif fprintf( stderr, "Warning: this is a placeholder for 5ms framing.\n" ); break; case CmdLnOptionId_directivityPatternId: diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 7b2d8d849d..f16ac95931 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -200,11 +200,11 @@ typedef enum #ifdef REMOVE_5MS_FLAG typedef enum { - RENDER_FRAMESIZE_UNKNOWN = 0, - RENDER_FRAMESIZE_5MS = 1, - RENDER_FRAMESIZE_10MS = 2, - RENDER_FRAMESIZE_20MS = 4 -} RENDER_FRAMESIZE; + IVAS_RENDER_FRAMESIZE_UNKNOWN = 0, + IVAS_RENDER_FRAMESIZE_5MS = 1, + IVAS_RENDER_FRAMESIZE_10MS = 2, + IVAS_RENDER_FRAMESIZE_20MS = 4 +} IVAS_RENDER_FRAMESIZE; #endif typedef struct ivas_masa_metadata_frame_struct *IVAS_MASA_METADATA_HANDLE; diff --git a/lib_com/options.h b/lib_com/options.h index 4dff894c37..8518ab87b8 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -149,7 +149,7 @@ /*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ -/*#define SPLIT_REND_WITH_HEAD_ROT */ /* Dlb,FhG: Split Rendering contributions 21 and 35 */ +/*#define SPLIT_REND_WITH_HEAD_ROT*/ /* Dlb,FhG: Split Rendering contributions 21 and 35 */ #ifdef SPLIT_REND_WITH_HEAD_ROT #define SPLIT_REND_PRED_QUANT_63_PNTS #define SPLIT_REND_WITH_HEAD_ROT_PARAMBIN /* Nokia: Issue 623: Split rendering support for parambin renderer */ diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 45ec16b3a7..9ed5ada3d8 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -1076,11 +1076,6 @@ ivas_error ivas_dec( } } -#ifdef NONBE_UNIFIED_DECODING_PATHS - /* update global combined orientation start index */ - ivas_combined_orientation_update_start_index( st_ivas->hCombinedOrientationData, output_frame ); -#endif - /*----------------------------------------------------------------* * Write IVAS output channels * - compensation for saturation @@ -1156,6 +1151,11 @@ ivas_error ivas_dec( st_ivas->last_ivas_format = st_ivas->ivas_format; +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* update global combined orientation start index */ + ivas_combined_orientation_update_start_index( st_ivas->hCombinedOrientationData, output_frame ); +#endif + /* in case first frame(s) was/were lost, deallocate output buffers */ if ( st_ivas->bfi && st_ivas->ini_frame == 0 ) { diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 95fa5dc82d..590c0230bf 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -260,7 +260,7 @@ static ivas_error ivas_dec_init_split_rend( #endif #ifdef REMOVE_5MS_FLAG - error = ivas_split_renderer_open( &st_ivas->hSplitBinRend.splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, cldfb_in_flag, pcm_out_flag, st_ivas->hDecoderConfig->render_framesize == RENDER_FRAMESIZE_5MS ); + error = ivas_split_renderer_open( &st_ivas->hSplitBinRend.splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, cldfb_in_flag, pcm_out_flag, st_ivas->hDecoderConfig->render_framesize == IVAS_RENDER_FRAMESIZE_5MS ); #else error = ivas_split_renderer_open( &st_ivas->hSplitBinRend.splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, cldfb_in_flag, pcm_out_flag, st_ivas->hDecoderConfig->Opt_5ms ); #endif diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index f86d6111e6..f9b9477ce1 100755 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -1364,6 +1364,7 @@ static ivas_error ivas_mc_dec_reconfig( #ifdef FIX_XXX_JBM_PARAMUPMIX_RS else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) { + tc_buffer_mode_new = TC_BUFFER_MODE_RENDERER; 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 ) { diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 8da3056b2c..eaa1a41917 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1022,7 +1022,7 @@ typedef struct decoder_config_structure int16_t Opt_Limiter; #endif #ifdef REMOVE_5MS_FLAG - RENDER_FRAMESIZE render_framesize; + IVAS_RENDER_FRAMESIZE render_framesize; #else int16_t Opt_5ms; #endif diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 7f8e1aa2f7..2936ab964a 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -377,7 +377,7 @@ ivas_error IVAS_DEC_Configure( #ifndef REMOVE_5MS_FLAG const int16_t enable5ms, /* i : enable 5ms rendering path */ #else - const RENDER_FRAMESIZE renderFramesize, /* i : rendering frame size */ + const IVAS_RENDER_FRAMESIZE renderFramesize, /* i : rendering frame size */ #endif const int16_t customLsOutputEnabled, /* i : enable custom loudspeaker setup handle */ const int16_t hrtfReaderEnabled, /* i : enable HRTF binary file input */ @@ -456,7 +456,7 @@ ivas_error IVAS_DEC_Configure( #endif hDecoderConfig->Opt_aeid_on = acousticEnvironmentId != 65535 ? TRUE : FALSE; #ifdef REMOVE_5MS_FLAG - if ( renderFramesize == RENDER_FRAMESIZE_UNKNOWN ) + if ( renderFramesize == IVAS_RENDER_FRAMESIZE_UNKNOWN ) { return IVAS_ERR_WRONG_PARAMS; } @@ -577,8 +577,8 @@ ivas_error IVAS_DEC_Get5msFlag( *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_SetRenderFramesize( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const RENDER_FRAMESIZE render_framesize /* i : render framesize */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const IVAS_RENDER_FRAMESIZE render_framesize /* i : render framesize */ ) { if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hDecoderConfig == NULL ) @@ -598,8 +598,8 @@ ivas_error IVAS_DEC_SetRenderFramesize( *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_GetRenderFramesize( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - RENDER_FRAMESIZE *render_framesize /* o : render framesize */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_RENDER_FRAMESIZE *render_framesize /* o : render framesize */ ) { if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || render_framesize == NULL ) @@ -633,6 +633,27 @@ ivas_error IVAS_DEC_GetRenderFramesizeSamples( return IVAS_ERR_OK; } +/*---------------------------------------------------------------------* + * IVAS_DEC_GetGetRenderFramesizeMs( ) + * + * Get render framesize in milliseconds + *---------------------------------------------------------------------*/ + +ivas_error IVAS_DEC_GetRenderFramesizeMs( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + uint32_t *render_framesize /* o : render framesize in samples */ +) +{ + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || render_framesize == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + *render_framesize = (int16_t) ( hIvasDec->st_ivas->hDecoderConfig->render_framesize * ( 1000 / ( FRAMES_PER_SEC * IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ) ); + + return IVAS_ERR_OK; +} + /*---------------------------------------------------------------------* * IVAS_DEC_GetGetReferencesUpdateFrequency( ) * @@ -1183,7 +1204,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( if ( #ifdef REMOVE_5MS_FLAG - st_ivas->hDecoderConfig->render_framesize == RENDER_FRAMESIZE_5MS && + st_ivas->hDecoderConfig->render_framesize == IVAS_RENDER_FRAMESIZE_5MS && #else st_ivas->hDecoderConfig->Opt_5ms && #endif @@ -1289,7 +1310,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( if ( pcm_out_flag ) { #ifdef REMOVE_5MS_FLAG - if ( st_ivas->hDecoderConfig->render_framesize == RENDER_FRAMESIZE_5MS ) + if ( st_ivas->hDecoderConfig->render_framesize == IVAS_RENDER_FRAMESIZE_5MS ) #else if ( st_ivas->hDecoderConfig->Opt_5ms ) #endif diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 3dfac43519..cca815e8fa 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -128,7 +128,7 @@ ivas_error IVAS_DEC_Configure( #ifndef REMOVE_5MS_FLAG const int16_t enable5ms, /* i : enable 5ms rendering path */ #else - const RENDER_FRAMESIZE renderFramesize, /* i : rendering frame size */ + const IVAS_RENDER_FRAMESIZE renderFramesize, /* i : rendering frame size */ #endif const int16_t customLsOutputEnabled, /* i : enable custom loudspeaker setup handle */ const int16_t hrtfReaderEnabled, /* i : enable HRTF binary file input */ @@ -324,12 +324,12 @@ ivas_error IVAS_DEC_Get5msFlag( #else ivas_error IVAS_DEC_SetRenderFramesize( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const RENDER_FRAMESIZE render_framesize /* i : render framesize */ + const IVAS_RENDER_FRAMESIZE render_framesize /* i : render framesize */ ); ivas_error IVAS_DEC_GetRenderFramesize( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - RENDER_FRAMESIZE *render_framesize /* o : render framesize */ + IVAS_RENDER_FRAMESIZE *render_framesize /* o : render framesize */ ); ivas_error IVAS_DEC_GetRenderFramesizeSamples( @@ -346,6 +346,11 @@ ivas_error IVAS_DEC_GetNumOrientationSubframes( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ int16_t *num_subframes /* o : render framesize */ ); + +ivas_error IVAS_DEC_GetRenderFramesizeMs( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + uint32_t *render_framesize /* o : render framesize in samples */ +); #endif #ifdef DEBUGGING diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 154bae5a67..5279db4efc 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -1246,17 +1246,17 @@ void rotateFrame_sd( ); #ifdef NONBE_UNIFIED_DECODING_PATHS -ivas_error ivas_combined_orientation_update_index( +void ivas_combined_orientation_update_index( COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i/o: combined orientation handle */ const int16_t samples_rendered /* i : samples rendered since the last call */ ); -ivas_error ivas_combined_orientation_update_start_index( +void ivas_combined_orientation_update_start_index( COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i/o: combined orientation handle */ const int16_t samples_rendered /* i : samples rendered since the last call */ ); -ivas_error ivas_combined_orientation_set_to_start_index( +void ivas_combined_orientation_set_to_start_index( COMBINED_ORIENTATION_HANDLE hCombinedOrientationData /* i/o: combined orientation handle */ ); #endif diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index 85aa535aef..0405fb13ee 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -1723,15 +1723,11 @@ void SHrotmatgen( * update read index based on the number of rendered samples *------------------------------------------------------------------------*/ -ivas_error ivas_combined_orientation_update_index( +void ivas_combined_orientation_update_index( COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i/o: combined orientation handle */ const int16_t samples_rendered /* i : samples rendered since the last call */ ) { - ivas_error error; - - error = IVAS_ERR_OK; - if ( hCombinedOrientationData != NULL ) { if ( hCombinedOrientationData->num_subframes == 1 @@ -1751,7 +1747,7 @@ ivas_error ivas_combined_orientation_update_index( hCombinedOrientationData->subframe_idx = min( hCombinedOrientationData->subframe_idx, hCombinedOrientationData->num_subframes - 1 ); } } - return error; + return; } @@ -1761,20 +1757,16 @@ ivas_error ivas_combined_orientation_update_index( * update read index based on the number of rendered samples *------------------------------------------------------------------------*/ -ivas_error ivas_combined_orientation_set_to_start_index( +void ivas_combined_orientation_set_to_start_index( COMBINED_ORIENTATION_HANDLE hCombinedOrientationData /* i/o: combined orientation handle */ ) { - ivas_error error; - - error = IVAS_ERR_OK; - if ( hCombinedOrientationData != NULL ) { hCombinedOrientationData->subframe_idx = hCombinedOrientationData->subframe_idx_start; hCombinedOrientationData->cur_subframe_samples_rendered = hCombinedOrientationData->cur_subframe_samples_rendered_start; } - return error; + return; } /*------------------------------------------------------------------------- @@ -1783,15 +1775,11 @@ ivas_error ivas_combined_orientation_set_to_start_index( * update read index based on the number of rendered samples *------------------------------------------------------------------------*/ -ivas_error ivas_combined_orientation_update_start_index( +void ivas_combined_orientation_update_start_index( COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i/o: combined orientation handle */ const int16_t samples_rendered /* i : samples rendered since the last call */ ) { - ivas_error error; - - error = IVAS_ERR_OK; - if ( hCombinedOrientationData != NULL ) { if ( hCombinedOrientationData->num_subframes == 1 @@ -1811,7 +1799,7 @@ ivas_error ivas_combined_orientation_update_start_index( hCombinedOrientationData->subframe_idx_start = max( hCombinedOrientationData->subframe_idx, hCombinedOrientationData->num_subframes - 1 ); } } - return error; + return; } #endif -- GitLab From 700566d8d9a8145a4bc4226bcb6806d2ff51e4a0 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Mon, 2 Oct 2023 11:30:58 +0200 Subject: [PATCH 37/49] fix CNA/CNG also for OSBA@13_2 --- lib_dec/ivas_sba_dec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 27000a58fb..99345e0508 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -871,8 +871,8 @@ ivas_error ivas_sba_dec_digest_tc( { nchan_transport = 1; /* Only one channel transported */ } - if ( ( st_ivas->ivas_format != SBA_FORMAT && st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag ) || - ( nchan_transport == 1 && st_ivas->nchan_transport != 2 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag ) ) + if ( ( ( st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT ) && st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag ) || + ( ( st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->hBinRendererTd == RENDERER_BINAURAL_PARAMETRIC ) && ( nchan_transport == 1 && st_ivas->nchan_transport != 2 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag ) ) ) #else if ( st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag && st_ivas->ivas_format == SBA_FORMAT ) #endif -- GitLab From ed0684f43f3f45e3e697bf0d2e4a4c8ce7b24920 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Mon, 2 Oct 2023 13:46:42 +0200 Subject: [PATCH 38/49] add temp fixes for #840, #841, fix SBA CNA/CNG again --- lib_com/options.h | 2 ++ lib_dec/ivas_mc_param_dec.c | 3 ++- lib_dec/ivas_mct_dec.c | 3 +++ lib_dec/ivas_sba_dec.c | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 8518ab87b8..1bc3d832b4 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -197,6 +197,8 @@ #define FIX_XXX_JBM_FOR_OSBA #define FIX_XXX_CHANNEL_MEM_COUNT #define FIX_XXX_JBM_PARAMUPMIX_HEADROT +#define FIX_XXX_MC_RS_BINAURAL +#define FIX_XXX_PMC_RS #endif /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 06215d3cf5..db48b54062 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -590,8 +590,9 @@ ivas_error ivas_param_mc_dec_reconfig( hTransportSetup = st_ivas->hTransSetup; mc_ls_setup = ivas_mc_map_output_config_to_mc_ls_setup( st_ivas->transport_config ); nchan_out_transport = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; +#ifndef FIX_XXX_PMC_RS hParamMC->hoa_encoder = NULL; - +#endif if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) { nchan_out_cov = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index f9b9477ce1..9f3493c440 100755 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -1226,6 +1226,9 @@ static ivas_error ivas_mc_dec_reconfig( if ( st_ivas->hBinRendererTd != NULL && ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD ) ) { ivas_td_binaural_close( &st_ivas->hBinRendererTd ); +#ifdef FIX_XXX_MC_RS_BINAURAL + st_ivas->hHrtfTD = NULL; +#endif } #ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 99345e0508..22dfd216fe 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -872,7 +872,7 @@ ivas_error ivas_sba_dec_digest_tc( nchan_transport = 1; /* Only one channel transported */ } if ( ( ( st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT ) && st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag ) || - ( ( st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->hBinRendererTd == RENDERER_BINAURAL_PARAMETRIC ) && ( nchan_transport == 1 && st_ivas->nchan_transport != 2 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag ) ) ) + ( ( st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) && ( nchan_transport == 1 && st_ivas->nchan_transport != 2 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag ) ) ) #else if ( st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag && st_ivas->ivas_format == SBA_FORMAT ) #endif -- GitLab From bcd9169351bd0b7dd83745482f10782a8fd8bd2e Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Mon, 2 Oct 2023 14:08:50 +0200 Subject: [PATCH 39/49] remove some defines for temp fixes that were coming in from main in the previous merge, clang-format --- lib_com/options.h | 3 --- lib_dec/lib_dec.c | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 8bf27d2ae4..3fe8465ffc 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -193,11 +193,8 @@ #define NONBE_UNIFIED_DECODING_PATHS /* FhG: unify decoding paths */ #ifdef NONBE_UNIFIED_DECODING_PATHS #define REMOVE_5MS_FLAG -#define FIX_XXX_JBM_PARAMUPMIX_RS -#define FIX_XXX_JBM_SBA #define FIX_XXX_MASA_CNA /*#define UNIFY_CHANNEL_MEM_HEAP*/ -#define FIX_XXX_CREND_ER #define FIX_XXX_JBM_FOR_OSBA #define FIX_XXX_CHANNEL_MEM_COUNT #define FIX_XXX_JBM_PARAMUPMIX_HEADROT diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 2936ab964a..a15cfb4a1b 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -640,7 +640,7 @@ ivas_error IVAS_DEC_GetRenderFramesizeSamples( *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_GetRenderFramesizeMs( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ uint32_t *render_framesize /* o : render framesize in samples */ ) { -- GitLab From 709339e8e8fd9521dfba17564e7f4061fce043fd Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Wed, 4 Oct 2023 07:18:18 +0200 Subject: [PATCH 40/49] temp fix for #846, fix MASA DTX with first frame being a SID frame --- lib_com/options.h | 1 + lib_dec/ivas_jbm_dec.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 3fe8465ffc..060feab06c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -200,6 +200,7 @@ #define FIX_XXX_JBM_PARAMUPMIX_HEADROT #define FIX_XXX_MC_RS_BINAURAL #define FIX_XXX_PMC_RS +#define FIX_XXX_JBM_MASA_SIDSTART #endif /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 5efd551a2e..1bad1dfcb7 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -2264,7 +2264,11 @@ int16_t ivas_jbm_dec_get_num_tc_channels( { num_tc = CPE_CHANNELS; } - else if ( st_ivas->ivas_format == MASA_FORMAT && ivas_total_brate < MASA_STEREO_MIN_BITRATE && ( ivas_total_brate > IVAS_SID_5k2 || ( ivas_total_brate <= IVAS_SID_5k2 && st_ivas->nCPE > 0 && st_ivas->hCPE[0]->nchan_out == 1 ) ) ) + else if ( st_ivas->ivas_format == MASA_FORMAT && ivas_total_brate < MASA_STEREO_MIN_BITRATE && ( ivas_total_brate > IVAS_SID_5k2 || ( ivas_total_brate <= IVAS_SID_5k2 && st_ivas->nCPE > 0 && +#ifdef FIX_XXX_JBM_MASA_SIDSTART + st_ivas->hCPE[0] != NULL && +#endif + st_ivas->hCPE[0]->nchan_out == 1 ) ) ) { num_tc = 1; /* Only one channel transported */ } -- GitLab From aa81c4b932e8a020667ad77a427e02753b651606 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Thu, 5 Oct 2023 10:24:11 +0200 Subject: [PATCH 41/49] fix compiler errors, fix combined rotation start index update --- lib_dec/ivas_jbm_dec.c | 31 +++++++++++++++++++++++++++++++ lib_dec/ivas_masa_dec.c | 2 ++ lib_rend/ivas_rotation.c | 2 +- 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 1bad1dfcb7..eb0206f944 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -1351,11 +1351,19 @@ ivas_error ivas_jbm_dec_render( #endif for ( n = st_ivas->hIntSetup.nchan_out_woLFE - 1; n >= 0; n-- ) { +#ifdef UNIFY_CHANNEL_MEM_HEAP + mvr2r( p_output[n], p_output[n + st_ivas->nchan_ism], *nSamplesRendered ); +#else mvr2r( output[n], output[n + st_ivas->nchan_ism], *nSamplesRendered ); +#endif } for ( n = 0; n < st_ivas->nchan_ism; n++ ) { +#ifdef UNIFY_CHANNEL_MEM_HEAP + set_zero( p_output[n], *nSamplesRendered ); +#else set_zero( output[n], *nSamplesRendered ); +#endif } } } @@ -2286,6 +2294,8 @@ int16_t ivas_jbm_dec_get_num_tc_channels( } } #ifdef UNIFY_CHANNEL_MEM_HEAP + *nchan_transport_internal = num_tc; + *nchan_transport_full = num_tc; if ( st_ivas->ivas_format == SBA_FORMAT ) { if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO ) @@ -2308,6 +2318,11 @@ int16_t ivas_jbm_dec_get_num_tc_channels( *nchan_transport_full = num_channels_internal; } } + else if ( st_ivas->ivas_format == MASA_FORMAT && ( st_ivas->nchan_transport == 1 && ( st_ivas->renderer_type == RENDERER_DIRAC && st_ivas->hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) ) ) + { + *nchan_transport_internal += 1; + *nchan_transport_full += 1; + } else { if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) @@ -2350,6 +2365,11 @@ int16_t ivas_jbm_dec_get_num_tc_channels( *nchan_transport_internal = 2 * BINAURAL_CHANNELS + 2; *nchan_transport_full = *nchan_transport_internal; } + else if ( st_ivas->nchan_transport == 1 && ( st_ivas->renderer_type == RENDERER_DIRAC && st_ivas->hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) ) + { + *nchan_transport_internal += 1; + *nchan_transport_full += 1; + } #endif } #ifdef UNIFY_CHANNEL_MEM_HEAP @@ -3064,6 +3084,17 @@ TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( { /* all renderers where we are done after TC decoding (might include DMX to mono/stereo */ case RENDERER_DISABLE: +#ifdef UNIFY_CHANNEL_MEM_HEAP + if ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_PARAMUPMIX && ( st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_MONO ) ) + { + buffer_mode = TC_BUFFER_MODE_RENDERER; + } + else + { + buffer_mode = TC_BUFFER_MODE_BUFFER; + } + break; +#endif case RENDERER_MCMASA_MONO_STEREO: case RENDERER_OSBA_STEREO: case RENDERER_MONO_DOWNMIX: diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index e23c7dfe9d..6517de8316 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -1533,12 +1533,14 @@ ivas_error ivas_masa_dec_reconfigure( } } #ifdef FIX_XXX_MASA_CNA +#ifndef UNIFY_CHANNEL_MEM_HEAP else if ( st_ivas->nchan_transport == 1 && ( st_ivas->renderer_type == RENDERER_DIRAC && st_ivas->hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) ) { /* addtl channel for CNG */ tc_nchan_to_allocate++; } #endif +#endif #ifdef UNIFY_CHANNEL_MEM_HEAP diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index 0405fb13ee..a608f2d1d0 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -1796,7 +1796,7 @@ void ivas_combined_orientation_update_start_index( hCombinedOrientationData->cur_subframe_samples_rendered_start += samples_rendered; hCombinedOrientationData->subframe_idx_start += hCombinedOrientationData->cur_subframe_samples_rendered / hCombinedOrientationData->subframe_size; hCombinedOrientationData->cur_subframe_samples_rendered_start = hCombinedOrientationData->cur_subframe_samples_rendered % hCombinedOrientationData->subframe_size; - hCombinedOrientationData->subframe_idx_start = max( hCombinedOrientationData->subframe_idx, hCombinedOrientationData->num_subframes - 1 ); + hCombinedOrientationData->subframe_idx_start = min( hCombinedOrientationData->subframe_idx, hCombinedOrientationData->num_subframes - 1 ); } } return; -- GitLab From b99e0981e70395ce1c068e585550845c0fd942a6 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Fri, 6 Oct 2023 06:44:56 +0200 Subject: [PATCH 42/49] amend fix for 808, fix DirAC CNA/CNG with unified channel mem --- lib_com/ivas_prot.h | 3 ++ lib_dec/fd_cng_dec.c | 30 +++++++++++++++++++- lib_dec/ivas_dirac_dec.c | 12 ++++++++ lib_dec/ivas_mct_dec.c | 1 + lib_dec/ivas_sba_dec.c | 4 +++ lib_rend/ivas_dirac_dec_binaural_functions.c | 16 +++++++++++ 6 files changed, 65 insertions(+), 1 deletion(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 55f5e807be..4eba16cc1b 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -3695,6 +3695,9 @@ void generate_masking_noise_lb_dirac( HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ float *tdBuffer, /* i/o: time-domain signal, if NULL no LB-CNA */ const int16_t nCldfbTs, /* i : number of CLDFB slots that will be rendered */ +#ifdef UNIFY_CHANNEL_MEM_HEAP + const SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, +#endif const int16_t cna_flag /* i : CNA flag for LB and HB */ ); diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c index 5e36f024f8..95bb1a9fdc 100644 --- a/lib_dec/fd_cng_dec.c +++ b/lib_dec/fd_cng_dec.c @@ -1804,7 +1804,10 @@ void generate_masking_noise_lb_dirac( HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ float *tdBuffer, /* i/o: time-domain signal, if NULL no LB-CNA */ const int16_t nCldfbTs, /* i : number of CLDFB slots that will be rendered */ - const int16_t cna_flag /* i : CNA flag for LB and HB */ +#ifdef UNIFY_CHANNEL_MEM_HEAP + const SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i : common spatial parameter rendering handle */ +#endif + const int16_t cna_flag /* i : CNA flag for LB and HB */ ) { int16_t i; @@ -1940,6 +1943,31 @@ void generate_masking_noise_lb_dirac( n_samples_start += hFdCngCom->frameSize; } } +#ifdef UNIFY_CHANNEL_MEM_HEAP + /* move to the real subframe start to avoid overwriting the LB signal */ + { + int16_t slot_size_lb, slot_size_fb, move_size; + int16_t n_samples_out_start_fb; + int16_t n_samples_out_start_lb; + slot_size_lb = hFdCngCom->frameSize / DEFAULT_JBM_CLDFB_TIMESLOTS; + slot_size_fb = hSpatParamRendCom->slot_size; + /* move from last to first subframe */ + n_samples_out_start_lb = ( hSpatParamRendCom->num_slots - hSpatParamRendCom->subframe_nbslots[hSpatParamRendCom->nb_subframes - 1] ) * slot_size_lb; + n_samples_out_start_fb = ( hSpatParamRendCom->num_slots - hSpatParamRendCom->subframe_nbslots[hSpatParamRendCom->nb_subframes - 1] ) * slot_size_fb; + + for ( i = hSpatParamRendCom->nb_subframes - 1; i > 0; i-- ) + { + move_size = hSpatParamRendCom->subframe_nbslots[i] * slot_size_lb; + mvr2r( &tdBuffer[n_samples_out_start_lb], &tdBuffer[n_samples_out_start_fb], move_size ); + n_samples_out_start_lb -= hSpatParamRendCom->subframe_nbslots[i] * slot_size_lb; + n_samples_out_start_fb -= hSpatParamRendCom->subframe_nbslots[i] * slot_size_fb; + } +#ifdef DEBUGGING + assert( n_samples_out_start_fb == 0 ); + assert( n_samples_out_start_lb == 0 ); +#endif + } +#endif pop_wmops(); diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 4730d1ece2..104e29abbb 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -1630,7 +1630,11 @@ void ivas_dirac_dec( { Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; st_ivas->hTcBuffer->tc[nchan_transport] = &cng_td_buffer[0]; +#ifdef UNIFY_CHANNEL_MEM_HEAP + generate_masking_noise_lb_dirac( st->hFdCngDec->hFdCngCom, st_ivas->hTcBuffer->tc[1], DEFAULT_JBM_CLDFB_TIMESLOTS, st_ivas->hSpatParamRendCom, st->cna_dirac_flag && st->flag_cna ); +#else generate_masking_noise_lb_dirac( st->hFdCngDec->hFdCngCom, st_ivas->hTcBuffer->tc[1], DEFAULT_JBM_CLDFB_TIMESLOTS, st->cna_dirac_flag && st->flag_cna ); +#endif } ivas_dirac_dec_set_md_map( st_ivas, DEFAULT_JBM_CLDFB_TIMESLOTS ); @@ -2060,10 +2064,18 @@ void ivas_dirac_dec_render_sf( generate_masking_noise_dirac( st->hFdCngDec->hFdCngCom, st_ivas->cldfbAnaDec[1], +#ifdef UNIFY_CHANNEL_MEM_HEAP + &st_ivas->hTcBuffer->tc[1][slot_idx_start * hSpatParamRendCom->num_freq_bands], +#else st_ivas->hTcBuffer->tc[1], +#endif Cldfb_RealBuffer[1][0], Cldfb_ImagBuffer[1][0], +#ifndef UNIFY_CHANNEL_MEM_HEAP index_slot, +#else + slot_idx, +#endif st->cna_dirac_flag && st->flag_cna, ( st->core_brate == FRAME_NO_DATA || st->core_brate == SID_2k40 ) && st->cng_type == FD_CNG && st->cng_sba_flag ); } diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 304b773fea..1ce9471e03 100755 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -1368,6 +1368,7 @@ static ivas_error ivas_mc_dec_reconfig( else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) { tc_nchan_allocate_new = MC_PARAMUPMIX_MAX_INPUT_CHANS; + tc_buffer_mode_new = TC_BUFFER_MODE_RENDERER; 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; diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index e4af7ad823..f5d9f2ec57 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -878,7 +878,11 @@ ivas_error ivas_sba_dec_digest_tc( #endif { Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; +#ifdef UNIFY_CHANNEL_MEM_HEAP + generate_masking_noise_lb_dirac( st->hFdCngDec->hFdCngCom, st_ivas->hTcBuffer->tc[1], nCldfbSlots, st_ivas->hSpatParamRendCom, st->cna_dirac_flag && st->flag_cna ); +#else generate_masking_noise_lb_dirac( st->hFdCngDec->hFdCngCom, st_ivas->hTcBuffer->tc[1], nCldfbSlots, st->cna_dirac_flag && st->flag_cna ); +#endif } return error; diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 01b41f4df1..37cc06ef22 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -626,7 +626,11 @@ void ivas_dirac_dec_binaural( { Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; st_ivas->hTcBuffer->tc[nchan_transport] = &cng_td_buffer[0]; +#ifdef UNIFY_CHANNEL_MEM_HEAP + generate_masking_noise_lb_dirac( st->hFdCngDec->hFdCngCom, st_ivas->hTcBuffer->tc[nchan_transport], DEFAULT_JBM_CLDFB_TIMESLOTS, st_ivas->hSpatParamRendCom, st->cna_dirac_flag && st->flag_cna ); +#else generate_masking_noise_lb_dirac( st->hFdCngDec->hFdCngCom, st_ivas->hTcBuffer->tc[nchan_transport], DEFAULT_JBM_CLDFB_TIMESLOTS, st->cna_dirac_flag && st->flag_cna ); +#endif } for ( subframe = 0; subframe < num_subframes; subframe++ ) @@ -772,9 +776,17 @@ static void ivas_dirac_dec_binaural_internal( generate_masking_noise_dirac( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom, st_ivas->cldfbAnaDec[1], +#ifdef UNIFY_CHANNEL_MEM_HEAP + &st_ivas->hTcBuffer->tc[nchan_transport][offsetSamples], +#else st_ivas->hTcBuffer->tc[nchan_transport], +#endif Cldfb_RealBuffer_in[2][slot], Cldfb_ImagBuffer_in[2][slot], +#ifdef UNIFY_CHANNEL_MEM_HEAP + slot, +#else slotInFrame, +#endif st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag && st_ivas->hSCE[0]->hCoreCoder[0]->flag_cna, ( st_ivas->hSCE[0]->hCoreCoder[0]->core_brate == FRAME_NO_DATA || st_ivas->hSCE[0]->hCoreCoder[0]->core_brate == SID_2k40 ) && ( st_ivas->hSCE[0]->hCoreCoder[0]->cng_type == FD_CNG ) && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag ); @@ -782,7 +794,11 @@ static void ivas_dirac_dec_binaural_internal( st_ivas->cldfbAnaDec[1], /*nothing will be analyzed, just get cnst*/ NULL, Cldfb_RealBuffer_in[1][slot], Cldfb_ImagBuffer_in[1][slot], +#ifdef UNIFY_CHANNEL_MEM_HEAP + slot, +#else slotInFrame, +#endif st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag && st_ivas->hSCE[0]->hCoreCoder[0]->flag_cna, ( st_ivas->hSCE[0]->hCoreCoder[0]->core_brate == FRAME_NO_DATA || st_ivas->hSCE[0]->hCoreCoder[0]->core_brate == SID_2k40 ) && ( st_ivas->hSCE[0]->hCoreCoder[0]->cng_type == FD_CNG ) && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag ); -- GitLab From 18503f6eec76581037317d9cfb0894252af5dfaf Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Tue, 10 Oct 2023 06:37:47 +0200 Subject: [PATCH 43/49] remove temp fix for channel mem realloc, fix unified channel mem heap for EVS, OMASA, ISM to SBA --- lib_com/ivas_cnst.h | 9 ++- lib_com/ivas_prot.h | 3 + lib_com/options.h | 1 - lib_dec/ivas_init_dec.c | 4 ++ lib_dec/ivas_ism_dec.c | 9 ++- lib_dec/ivas_ism_renderer.c | 32 +++++++++-- lib_dec/ivas_jbm_dec.c | 74 +++++++++++++++++++++++++ lib_dec/ivas_mc_paramupmix_dec.c | 4 ++ lib_dec/ivas_omasa_dec.c | 80 +++++++++++++++++++++++++-- lib_dec/ivas_sba_dec.c | 12 ++-- lib_dec/ivas_sba_rendering_internal.c | 18 ++++++ lib_dec/lib_dec.c | 31 +++++++++++ lib_rend/ivas_output_init.c | 60 ++++++-------------- lib_rend/ivas_prot_rend.h | 9 ++- 14 files changed, 279 insertions(+), 67 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 5461f74253..610d216040 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -196,6 +196,11 @@ typedef enum TC_BUFFER_MODE_BUFFER } TC_BUFFER_MODE; +#ifdef UNIFY_CHANNEL_MEM_HEAP +#define TC_BUFFER_NUM_FULL_CHAN_UNKNOWN -1 +#define TC_BUFFER_NUM_FULL_CHAN_DONT_COUNT 0 +#endif + /*----------------------------------------------------------------------------------* * IVAS Bitrates *----------------------------------------------------------------------------------*/ @@ -1219,7 +1224,9 @@ enum #define MASA_STEREO_MIN_BITRATE IVAS_24k4 #define MAXIMUM_OMASA_FREQ_BANDS 8 /* Corresponds to maximum number of coding bands at 32 kbps */ #define OMASA_STEREO_SW_CNT_MAX 100 - +#ifdef UNIFY_CHANNEL_MEM_HEAP +#define OMASA_TDREND_MATCHING_GAIN 0.7943f +#endif #define MASA_BIT_REDUCT_PARAM 10 #define MASA_MAXIMUM_TWO_DIR_BANDS 24 #define NBITS_HR_COH 4 diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index e35249ec7e..261d511323 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5937,6 +5937,9 @@ void ivas_omasa_separate_object_render( void ivas_omasa_separate_object_render_jbm( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const uint16_t nSamplesRendered, /* i : number of samples rendered */ +#ifdef UNIFY_CHANNEL_MEM_HEAP + float *input_f[], /* i : discrete objects transport time signal */ +#endif float *output_f[], /* o : rendered time signal */ const int16_t subframes_rendered, /* i : number of subframes rendered */ const int16_t slots_rendered /* i : number of CLDFB slots rendered */ diff --git a/lib_com/options.h b/lib_com/options.h index f7f351365b..18769e811f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -190,7 +190,6 @@ #ifdef NONBE_UNIFIED_DECODING_PATHS #define REMOVE_5MS_FLAG /*#define UNIFY_CHANNEL_MEM_HEAP*/ -#define FIX_XXX_CHANNEL_MEM_COUNT #endif /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index a217f0d18d..a199f8fac7 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -2272,7 +2272,11 @@ ivas_error ivas_init_decoder( if ( !st_ivas->hDecoderConfig->Opt_5ms ) #endif { +#ifdef UNIFY_CHANNEL_MEM_HEAP + for ( n = 0; n < ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, TC_BUFFER_NUM_FULL_CHAN_UNKNOWN ); n++ ) +#else for ( n = 0; n < ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); n++ ) +#endif { /* note: these are intra-frame heap memories */ if ( ( st_ivas->p_output_f[n] = (float *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL ) diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 8b089bd986..739f78ac07 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -83,12 +83,13 @@ static ivas_error ivas_ism_bitrate_switching_dec( st_ivas->ism_mode = last_ism_mode; ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); st_ivas->ism_mode = ism_mode; -#ifdef FIX_XXX_CHANNEL_MEM_COUNT - nchan_out_buff_old = ivas_count_nchan_buffers_dec( st_ivas ); +#ifdef UNIFY_CHANNEL_MEM_HEAP + nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->hTcBuffer->nchan_buffer_full ); #else nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); #endif + if ( ( error = ivas_ism_config( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->nchan_ism, NULL, 0, NULL, NULL, element_brate_tmp, NULL, NULL, 0 ) ) != IVAS_ERR_OK ) { return error; @@ -345,7 +346,11 @@ static ivas_error ivas_ism_bitrate_switching_dec( if ( !st_ivas->hDecoderConfig->Opt_5ms ) #endif { +#ifdef UNIFY_CHANNEL_MEM_HEAP + nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, TC_BUFFER_NUM_FULL_CHAN_UNKNOWN ); +#else nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); +#endif if ( nchan_out_buff > nchan_out_buff_old ) { diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index 22e38e95ea..08e2febb06 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -258,6 +258,10 @@ void ivas_ism_render_sf( int16_t tc_offset; int16_t interp_offset; float gain, prev_gain; +#ifdef UNIFY_CHANNEL_MEM_HEAP + float input_f[MAX_NUM_OBJECTS][L_FRAME48k]; + int16_t nchan_ism; +#endif num_objects = st_ivas->nchan_transport; #ifdef JBM_FOR_OSBA @@ -271,6 +275,14 @@ void ivas_ism_render_sf( tc_offset = st_ivas->hTcBuffer->n_samples_rendered; interp_offset = st_ivas->hTcBuffer->n_samples_rendered; +#ifdef UNIFY_CHANNEL_MEM_HEAP + nchan_ism = st_ivas->nchan_ism; + for ( i = 0; i < nchan_ism; i++ ) + { + mvr2r( &st_ivas->hTcBuffer->tc[i][tc_offset], input_f[i], n_samples_to_render ); + } +#endif + for ( i = 0; i < nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; i++ ) { set_f( output_f[i], 0.0f, n_samples_to_render ); @@ -320,7 +332,11 @@ void ivas_ism_render_sf( if ( fabsf( gain ) > 0.0f || fabsf( prev_gain ) > 0.0f ) { g1 = &st_ivas->hIsmRendererData->interpolator[interp_offset]; +#ifdef UNIFY_CHANNEL_MEM_HEAP + tc = input_f[i]; +#else tc = &st_ivas->hTcBuffer->tc[i][tc_offset]; +#endif for ( k = 0; k < n_samples_to_render; k++ ) { g2 = 1.0f - *g1; @@ -616,8 +632,11 @@ void ivas_omasa_separate_object_render( *-------------------------------------------------------------------------*/ void ivas_omasa_separate_object_render_jbm( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const uint16_t nSamplesRendered, /* i : number of samples rendered */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const uint16_t nSamplesRendered, /* i : number of samples rendered */ +#ifdef UNIFY_CHANNEL_MEM_HEAP + float *input_f[], /* i : discrete object transport time signal */ +#endif float *output_f[], /* o : rendered time signal */ const int16_t subframes_rendered, /* i : number of subframes rendered */ const int16_t slots_rendered /* i : number of CLDFB slots rendered */ @@ -636,7 +655,9 @@ void ivas_omasa_separate_object_render_jbm( int16_t azimuth, elevation; int16_t num_objects; uint8_t single_separated; +#ifndef UNIFY_CHANNEL_MEM_HEAP float *input_f[MAX_TRANSPORT_CHANNELS]; +#endif float *output_f_local[MAX_OUTPUT_CHANNELS]; int16_t offsetSamples; int16_t n_samples_sf, md_idx; @@ -667,12 +688,12 @@ void ivas_omasa_separate_object_render_jbm( { output_f_local[j] = output_f[j]; } - +#ifndef UNIFY_CHANNEL_MEM_HEAP for ( obj = 0; obj < num_objects; obj++ ) { input_f[obj] = &st_ivas->hTcBuffer->tc[obj + 2][offsetSamples]; } - +#endif slots_to_render = nSamplesRendered / hSpatParamRendCom->slot_size; first_sf = subframes_rendered; last_sf = first_sf; @@ -685,6 +706,7 @@ void ivas_omasa_separate_object_render_jbm( for ( obj = 0; obj < num_objects; obj++ ) { +#ifndef UNIFY_CHANNEL_MEM_HEAP /* Delay the signal to match CLDFB delay. Delay the whole buffer with the first rendering call of the stretched buffer. */ if ( slots_rendered == 0 ) { @@ -693,7 +715,7 @@ void ivas_omasa_separate_object_render_jbm( tcBufferSize = hSpatParamRendCom->num_slots * hSpatParamRendCom->slot_size; delay_signal( input_f[obj], tcBufferSize, st_ivas->hMasaIsmData->delayBuffer[obj], st_ivas->hMasaIsmData->delayBuffer_size ); } - +#endif offsetSamples = 0; for ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index efa3dd7379..ffb0e5bc12 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -909,6 +909,32 @@ ivas_error ivas_jbm_dec_feed_tc_to_renderer( { ivas_ism_dec_digest_tc( st_ivas ); } +#ifdef UNIFY_CHANNEL_MEM_HEAP + /* delay discrete objects */ + if ( ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) || + ( st_ivas->renderer_type == RENDERER_DIRAC ) ) + { + int16_t num_objects, obj; + + + if ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) + { + num_objects = 1; + } + else + { + num_objects = st_ivas->nchan_ism; + } + for ( obj = 0; obj < num_objects; obj++ ) + { + if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) + { + v_multc( st_ivas->hTcBuffer->tc[obj + 2], OMASA_TDREND_MATCHING_GAIN, st_ivas->hTcBuffer->tc[obj + 2], st_ivas->hTcBuffer->n_samples_available ); + } + delay_signal( st_ivas->hTcBuffer->tc[obj + 2], st_ivas->hTcBuffer->n_samples_available, st_ivas->hMasaIsmData->delayBuffer[obj], st_ivas->hMasaIsmData->delayBuffer_size ); + } + } +#endif } else if ( st_ivas->ivas_format == MC_FORMAT ) { @@ -2348,6 +2374,40 @@ int16_t ivas_jbm_dec_get_num_tc_channels( { num_tc += st_ivas->nchan_ism; } +#ifdef UNIFY_CHANNEL_MEM_HEAP + *nchan_transport_full = num_tc; + *nchan_transport_internal = num_tc; + + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO ) + { + if ( ( st_ivas->ism_mode == ISM_SBA_MODE_DISC && st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO ) ) + { + num_tc = st_ivas->hDecoderConfig->nchan_out + st_ivas->nchan_ism; + *nchan_transport_full = num_tc; + *nchan_transport_internal = num_tc; + } + else + { + num_tc = st_ivas->hDecoderConfig->nchan_out; + *nchan_transport_full = num_tc; + *nchan_transport_internal = num_tc; + } + } + else if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) + { + *nchan_transport_internal = 2 * BINAURAL_CHANNELS; + *nchan_transport_full = *nchan_transport_internal; + } + else + { + *nchan_transport_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + *nchan_transport_internal += st_ivas->nchan_ism; + *nchan_transport_full = *nchan_transport_internal; + } + } +#endif } #endif else if ( st_ivas->ivas_format == MC_FORMAT ) @@ -3049,7 +3109,9 @@ TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( break; #endif case RENDERER_MCMASA_MONO_STEREO: +#ifndef UNIFY_CHANNEL_MEM_HEAP case RENDERER_OSBA_STEREO: +#endif case RENDERER_MONO_DOWNMIX: buffer_mode = TC_BUFFER_MODE_BUFFER; break; @@ -3124,6 +3186,18 @@ TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( buffer_mode = TC_BUFFER_MODE_RENDERER; } break; +#ifdef UNIFY_CHANNEL_MEM_HEAP + case RENDERER_OSBA_STEREO: + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + buffer_mode = TC_BUFFER_MODE_RENDERER; + } + else + { + buffer_mode = TC_BUFFER_MODE_BUFFER; + } + break; +#endif #ifdef DEBUGGING default: assert( 0 ); diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index 5ad69d4a52..3b48e8d084 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -447,7 +447,11 @@ void ivas_mc_paramupmix_dec( } } +#ifdef UNIFY_CHANNEL_MEM_HEAP + for ( ch = first_empty_channel; ch < ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, TC_BUFFER_NUM_FULL_CHAN_DONT_COUNT ); ch++ ) +#else for ( ch = first_empty_channel; ch < ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); ch++ ) +#endif { set_f( output_f[ch], 0.0f, output_frame ); } diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index bb9e8e925b..8ecb657d9a 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -47,8 +47,9 @@ * Local constants *------------------------------------------------------------------------*/ +#ifndef UNIFY_CHANNEL_MEM_HEAP #define OMASA_TDREND_MATCHING_GAIN 0.7943f - +#endif /*-------------------------------------------------------------------* * ivas_omasa_data_open() @@ -180,8 +181,8 @@ ivas_error ivas_omasa_dec_config( ivas_format_orig = st_ivas->ivas_format; st_ivas->ivas_format = st_ivas->last_ivas_format; ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); -#ifdef FIX_XXX_CHANNEL_MEM_COUNT - nchan_out_buff_old = ivas_count_nchan_buffers_dec( st_ivas ); +#ifdef UNIFY_CHANNEL_MEM_HEAP + nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->hTcBuffer->nchan_buffer_full ); #else nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); #endif @@ -419,7 +420,11 @@ ivas_error ivas_omasa_dec_config( if ( !st_ivas->hDecoderConfig->Opt_5ms ) #endif { +#ifdef UNIFY_CHANNEL_MEM_HEAP + nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, TC_BUFFER_NUM_FULL_CHAN_UNKNOWN ); +#else nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); +#endif if ( nchan_out_buff > nchan_out_buff_old ) { @@ -689,13 +694,43 @@ void ivas_omasa_dirac_rend_jbm( { int16_t subframes_rendered; int16_t slots_rendered; +#ifdef UNIFY_CHANNEL_MEM_HEAP + float discrete_objects_f[MAX_NUM_OBJECTS][L_FRAME48k]; + float *p_discrete_objects_f[MAX_NUM_OBJECTS]; + int16_t num_objects, offsetSamples, obj, slots_to_render; + + if ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) + { + num_objects = 1; + } + else + { + num_objects = st_ivas->nchan_ism; + } +#endif subframes_rendered = st_ivas->hSpatParamRendCom->subframes_rendered; slots_rendered = st_ivas->hSpatParamRendCom->slots_rendered; +#ifdef UNIFY_CHANNEL_MEM_HEAP + offsetSamples = slots_rendered * st_ivas->hSpatParamRendCom->slot_size; + slots_to_render = min( st_ivas->hSpatParamRendCom->num_slots - st_ivas->hSpatParamRendCom->slots_rendered, nSamplesAsked / st_ivas->hSpatParamRendCom->slot_size ); + *nSamplesRendered = slots_to_render * st_ivas->hSpatParamRendCom->slot_size; + + for ( obj = 0; obj < num_objects; obj++ ) + { + p_discrete_objects_f[obj] = discrete_objects_f[obj]; + mvr2r( &st_ivas->hTcBuffer->tc[obj + 2][offsetSamples], p_discrete_objects_f[obj], *nSamplesRendered ); + } +#endif + ivas_dirac_dec_render( st_ivas, nchan_transport, nSamplesAsked, nSamplesRendered, nSamplesAvailable, output_f ); +#ifdef UNIFY_CHANNEL_MEM_HEAP + ivas_omasa_separate_object_render_jbm( st_ivas, *nSamplesRendered, p_discrete_objects_f, output_f, subframes_rendered, slots_rendered ); +#else ivas_omasa_separate_object_render_jbm( st_ivas, *nSamplesRendered, output_f, subframes_rendered, slots_rendered ); +#endif return; } @@ -770,17 +805,30 @@ ivas_error ivas_omasa_dirac_td_binaural_jbm( ) { int16_t n; +#ifdef UNIFY_CHANNEL_MEM_HEAP + float data_separated_objects[MAX_NUM_OBJECTS][2 * L_FRAME48k]; +#else float data_separated_objects[MAX_NUM_OBJECTS][L_FRAME48k]; +#endif +#ifndef UNIFY_CHANNEL_MEM_HEAP float gain = OMASA_TDREND_MATCHING_GAIN; +#endif ivas_error error; float *p_sepobj[MAX_NUM_OBJECTS]; +#ifndef UNIFY_CHANNEL_MEM_HEAP float *tc_local[MAX_TRANSPORT_CHANNELS]; +#endif +#ifdef UNIFY_CHANNEL_MEM_HEAP + float *p_save_tc[MAX_NUM_OBJECTS]; + int16_t offsetSamples, slots_to_render; +#endif for ( n = 0; n < MAX_NUM_OBJECTS; n++ ) { p_sepobj[n] = &data_separated_objects[n][0]; } +#ifndef UNIFY_CHANNEL_MEM_HEAP /* Delay the object signals to match the CLDFB delay. Delay the whole buffer with the first rendering call of the stretched buffer. */ if ( st_ivas->hSpatParamRendCom->slots_rendered == 0 ) { @@ -795,17 +843,41 @@ ivas_error ivas_omasa_dirac_td_binaural_jbm( delay_signal( tc_local[n], tcBufferSize, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); } } +#else + /* save objects */ + offsetSamples = st_ivas->hSpatParamRendCom->slots_rendered * st_ivas->hSpatParamRendCom->slot_size; + slots_to_render = min( st_ivas->hSpatParamRendCom->num_slots - st_ivas->hSpatParamRendCom->slots_rendered, nSamplesAsked / st_ivas->hSpatParamRendCom->slot_size ); + *nSamplesRendered = slots_to_render * st_ivas->hSpatParamRendCom->slot_size; + for ( n = 0; n < st_ivas->nchan_ism; n++ ) + { + mvr2r( &st_ivas->hTcBuffer->tc[2 + n][offsetSamples], &data_separated_objects[n][offsetSamples], *nSamplesRendered ); + } +#endif ivas_dirac_dec_binaural_render( st_ivas, nSamplesAsked, nSamplesRendered, nSamplesAvailable, nchan_transport, output_f ); #ifdef NONBE_UNIFIED_DECODING_PATHS ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData ); +#endif +#ifdef UNIFY_CHANNEL_MEM_HEAP + /* temporary set the object tc pointers to the locally saved ones */ + for ( n = 0; n < st_ivas->nchan_ism; n++ ) + { + p_save_tc[n] = st_ivas->hTcBuffer->tc[2 + n]; + st_ivas->hTcBuffer->tc[2 + n] = p_sepobj[n]; + } #endif if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_sepobj, *nSamplesRendered ) ) != IVAS_ERR_OK ) { return error; } - +#ifdef UNIFY_CHANNEL_MEM_HEAP + /* bend saved tc pointers back */ + for ( n = 0; n < st_ivas->nchan_ism; n++ ) + { + st_ivas->hTcBuffer->tc[2 + n] = p_save_tc[n]; + } +#endif for ( n = 0; n < BINAURAL_CHANNELS; n++ ) { v_add( output_f[n], p_sepobj[n], output_f[n], *nSamplesRendered ); diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index f4db5a176e..9044120e42 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -122,9 +122,7 @@ ivas_error ivas_sba_dec_reconfigure( int32_t last_ivas_total_brate; int16_t num_channels, num_md_sub_frames; int16_t ch, nchan_out_buff, nchan_out_buff_old; -#ifndef FIX_XXX_CHANNEL_MEM_COUNT int16_t sba_analysis_order_old; -#endif #ifdef JBM_FOR_OSBA int16_t sba_analysis_order_old_flush; #endif @@ -144,16 +142,14 @@ ivas_error ivas_sba_dec_reconfigure( #ifdef JBM_FOR_OSBA sba_analysis_order_old_flush = st_ivas->sba_analysis_order; #endif -#ifndef FIX_XXX_CHANNEL_MEM_COUNT sba_analysis_order_old = ivas_sba_get_analysis_order( last_ivas_total_brate, st_ivas->sba_order ); -#endif /*-----------------------------------------------------------------* * Set SBA high-level parameters * Save old SBA high-level parameters *-----------------------------------------------------------------*/ -#ifdef FIX_XXX_CHANNEL_MEM_COUNT - nchan_out_buff_old = ivas_count_nchan_buffers_dec( st_ivas ); +#ifdef UNIFY_CHANNEL_MEM_HEAP + nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, sba_analysis_order_old, last_ivas_total_brate, st_ivas->hTcBuffer->nchan_buffer_full ); #else nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, sba_analysis_order_old, last_ivas_total_brate ); #endif @@ -747,7 +743,11 @@ ivas_error ivas_sba_dec_reconfigure( if ( !st_ivas->hDecoderConfig->Opt_5ms ) #endif { +#ifdef UNIFY_CHANNEL_MEM_HEAP + nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, TC_BUFFER_NUM_FULL_CHAN_UNKNOWN ); +#else nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); +#endif if ( nchan_out_buff > nchan_out_buff_old ) { diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal.c index f33ef78d53..03ccf84b9c 100644 --- a/lib_dec/ivas_sba_rendering_internal.c +++ b/lib_dec/ivas_sba_rendering_internal.c @@ -422,10 +422,20 @@ void ivas_ism2sba_sf( int16_t i, j, k; float g1, *g2, *tc, *out, gain, prev_gain; int16_t sba_num_chans; +#ifdef UNIFY_CHANNEL_MEM_HEAP + float input_f[MAX_NUM_OBJECTS][L_FRAME48k]; +#endif assert( ( sba_order <= 3 ) && "Only order up to 3 is supported!" ); assert( hIsmRendererData != NULL && "hIsmRendererData not allocated!" ); +#ifdef UNIFY_CHANNEL_MEM_HEAP + for ( i = 0; i < num_objects; i++ ) + { + mvr2r( &buffer_in[i][offset], input_f[i], n_samples_to_render ); + } +#endif + /* Init*/ sba_num_chans = ( sba_order + 1 ) * ( sba_order + 1 ); @@ -439,7 +449,11 @@ void ivas_ism2sba_sf( for ( j = 0; j < sba_num_chans; j++ ) { g2 = hIsmRendererData->interpolator + offset; +#ifdef UNIFY_CHANNEL_MEM_HEAP + tc = input_f[i] + offset; +#else tc = buffer_in[i] + offset; +#endif out = buffer_out[j]; gain = hIsmRendererData->gains[i][j]; prev_gain = hIsmRendererData->prev_gains[i][j]; @@ -491,7 +505,11 @@ ivas_error ivas_sba_upmixer_renderer( sba_ch_idx = st_ivas->nchan_ism; } +#ifdef UNIFY_CHANNEL_MEM_HEAP + for ( ch = 0; ch < ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, TC_BUFFER_NUM_FULL_CHAN_DONT_COUNT ) - sba_ch_idx; ch++ ) +#else for ( ch = 0; ch < ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ) - sba_ch_idx; ch++ ) +#endif { output_f[ch] = output[ch]; } diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index bf5b8d6b39..611a81c349 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -3290,7 +3290,9 @@ static ivas_error evs_dec_main( int16_t *pcmBuf ) { DEC_CORE_HANDLE *hCoreCoder; +#ifndef UNIFY_CHANNEL_MEM_HEAP float output[MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN][L_FRAME48k]; +#endif float mixer_left, mixer_rigth; float *p_output[MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN]; int16_t ch; @@ -3303,7 +3305,11 @@ static ivas_error evs_dec_main( for ( ch = 0; ch < MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN; ch++ ) { +#ifdef UNIFY_CHANNEL_MEM_HEAP + p_output[ch] = st_ivas->p_output_f[ch]; +#else p_output[ch] = output[ch]; +#endif } /* run the main EVS decoding routine */ @@ -3311,14 +3317,22 @@ static ivas_error evs_dec_main( { if ( hCoreCoder[0]->Opt_AMR_WB ) { +#ifdef UNIFY_CHANNEL_MEM_HEAP + if ( ( error = amr_wb_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], p_output[0] ) ) != IVAS_ERR_OK ) +#else if ( ( error = amr_wb_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], output[0] ) ) != IVAS_ERR_OK ) +#endif { return error; } } else { +#ifdef UNIFY_CHANNEL_MEM_HEAP + if ( ( error = evs_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], p_output[0], FRAMEMODE_NORMAL ) ) != IVAS_ERR_OK ) +#else if ( ( error = evs_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], output[0], FRAMEMODE_NORMAL ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -3328,21 +3342,33 @@ static ivas_error evs_dec_main( { if ( hCoreCoder[0]->bfi == 0 ) { +#ifdef UNIFY_CHANNEL_MEM_HEAP + if ( ( error = evs_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], p_output[0], FRAMEMODE_NORMAL ) ) != IVAS_ERR_OK ) +#else if ( ( error = evs_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], output[0], FRAMEMODE_NORMAL ) ) != IVAS_ERR_OK ) +#endif { return error; } } else if ( hCoreCoder[0]->bfi == 2 ) { +#ifdef UNIFY_CHANNEL_MEM_HEAP + if ( ( error = evs_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], p_output[0], FRAMEMODE_FUTURE ) ) != IVAS_ERR_OK ) +#else if ( ( error = evs_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], output[0], FRAMEMODE_FUTURE ) ) != IVAS_ERR_OK ) +#endif { return error; } } else { +#ifdef UNIFY_CHANNEL_MEM_HEAP + if ( ( error = evs_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], p_output[0], FRAMEMODE_MISSING ) ) != IVAS_ERR_OK ) +#else if ( ( error = evs_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], output[0], FRAMEMODE_MISSING ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -3355,8 +3381,13 @@ static ivas_error evs_dec_main( { mixer_left = ( st_ivas->hDecoderConfig->non_diegetic_pan_gain + 1.f ) * 0.5f; mixer_rigth = 1.f - mixer_left; +#ifdef UNIFY_CHANNEL_MEM_HEAP + v_multc( p_output[0], mixer_rigth, p_output[1], nOutSamples ); + v_multc( p_output[0], mixer_left, p_output[0], nOutSamples ); +#else v_multc( output[0], mixer_rigth, output[1], nOutSamples ); v_multc( output[0], mixer_left, output[0], nOutSamples ); +#endif } diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index 4807ade35d..34ac9be528 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -268,6 +268,10 @@ int16_t ivas_get_nchan_buffers_dec( , const int16_t sba_analysis_order, /* i : SBA order evaluated in DirAC/SPAR encoder */ const int32_t ivas_total_brate /* i : total IVAS bitrate */ +#ifdef UNIFY_CHANNEL_MEM_HEAP + , + const int16_t tc_buffer_nchan_full /* i : number of full tc channels needed */ +#endif ) { int16_t nchan_out_buff; @@ -279,7 +283,11 @@ int16_t ivas_get_nchan_buffers_dec( if ( st_ivas->ivas_format == MONO_FORMAT ) { +#ifdef UNIFY_CHANNEL_MEM_HEAP + nchan_out_buff = st_ivas->hDecoderConfig->nchan_out; +#else nchan_out_buff = 0; +#endif } else if ( st_ivas->ivas_format == STEREO_FORMAT ) { @@ -410,52 +418,18 @@ int16_t ivas_get_nchan_buffers_dec( #ifdef UNIFY_CHANNEL_MEM_HEAP if ( !st_ivas->hDecoderConfig->Opt_tsm ) { - int16_t nchan_buf_full, tmp1, tmp2; - ivas_jbm_dec_get_num_tc_channels( st_ivas, &tmp1, &tmp2, &nchan_buf_full ); - nchan_out_buff = max( nchan_out_buff, nchan_buf_full ); - } -#endif - - return nchan_out_buff; -} - -#ifdef FIX_XXX_CHANNEL_MEM_COUNT -/*-----------------------------------------------------------------* - * ivas_count_nchan_buffers_dec() - * - * Return number of decoder audio buffers - *-----------------------------------------------------------------*/ - -/*! r: number of allocated decoder buffers */ -int16_t ivas_count_nchan_buffers_dec( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -) -{ - int16_t ch_idx, ch_cnt; - for ( ch_idx = 0, ch_cnt = 0; ch_idx < MAX_OUTPUT_CHANNELS -#ifdef JBM_FOR_OSBA - + MAX_NUM_OBJECTS -#endif - ; - ch_idx++, ch_cnt++ ) - { - if ( st_ivas->p_output_f[ch_idx] == NULL ) + if ( tc_buffer_nchan_full >= 0 ) { - break; + nchan_out_buff = max( nchan_out_buff, tc_buffer_nchan_full ); + } + else + { + int16_t nchan_buf_full, tmp1, tmp2; + ivas_jbm_dec_get_num_tc_channels( st_ivas, &tmp1, &tmp2, &nchan_buf_full ); + nchan_out_buff = max( nchan_out_buff, nchan_buf_full ); } - } -#ifdef DEBUGGING - for ( ; ch_idx < MAX_OUTPUT_CHANNELS -#ifdef JBM_FOR_OSBA - + MAX_NUM_OBJECTS -#endif - ; - ch_idx++ ) - { - assert( st_ivas->p_output_f[ch_idx] == NULL ); } #endif - return ch_cnt; + return nchan_out_buff; } -#endif diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index c4764ecf4d..21ce94f0b3 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -76,12 +76,11 @@ int16_t ivas_get_nchan_buffers_dec( , const int16_t sba_analysis_order, /* i : SBA order evaluated in DirAC/SPAR encoder */ const int32_t ivas_total_brate /* i : total IVAS bitrate */ -); -#ifdef FIX_XXX_CHANNEL_MEM_COUNT -int16_t ivas_count_nchan_buffers_dec( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); +#ifdef UNIFY_CHANNEL_MEM_HEAP + , + const int16_t tc_buffer_nchan_full /* i : number of full tc channels needed */ #endif +); /*----------------------------------------------------------------------------------* * Limiter prototypes -- GitLab From 81f4a1494ba473b882cfed65e69defe639c7054c Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Tue, 10 Oct 2023 07:57:25 +0200 Subject: [PATCH 44/49] temp fix for OSBA RS, fix for unified channel mem and OSBA --- lib_com/options.h | 1 + lib_dec/ivas_jbm_dec.c | 29 +++++++++++++++++++++++++++-- lib_dec/ivas_osba_dec.c | 36 +++++++++++++++++++++++++++++++++++- lib_dec/ivas_sba_dec.c | 8 ++++++++ 4 files changed, 71 insertions(+), 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 18769e811f..31463df6bf 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -190,6 +190,7 @@ #ifdef NONBE_UNIFIED_DECODING_PATHS #define REMOVE_5MS_FLAG /*#define UNIFY_CHANNEL_MEM_HEAP*/ +#define FIX_XXX_SBA_RS #endif /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index ffb0e5bc12..a7f41b8410 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -1275,13 +1275,29 @@ ivas_error ivas_jbm_dec_render( } else if ( st_ivas->renderer_type == RENDERER_OSBA_STEREO ) { +#ifdef UNIFY_CHANNEL_MEM_HEAP + float output_stereo[CPE_CHANNELS][L_FRAME48k]; + float *p_output_stereo[CPE_CHANNELS]; + for ( n = 0; n < CPE_CHANNELS; n++ ) + { + p_output_stereo[n] = output_stereo[n]; + } +#endif *nSamplesRendered = min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); /* render objects */ +#ifdef UNIFY_CHANNEL_MEM_HEAP + ivas_ism_render_sf( st_ivas, p_output_stereo, *nSamplesRendered ); +#else ivas_ism_render_sf( st_ivas, p_output, *nSamplesRendered ); +#endif /* add already rendererd SBA part */ for ( n = 0; n < nchan_out; n++ ) { +#ifdef UNIFY_CHANNEL_MEM_HEAP + v_add( p_output_stereo[n], p_tc[n + st_ivas->nchan_ism], p_output[n], *nSamplesRendered ); +#else v_add( p_output[n], p_tc[n + st_ivas->nchan_ism], p_output[n], *nSamplesRendered ); +#endif } } else if ( st_ivas->renderer_type == RENDERER_OSBA_AMBI || st_ivas->renderer_type == RENDERER_OSBA_LS @@ -1297,15 +1313,24 @@ ivas_error ivas_jbm_dec_render( { p_output_ism[n] = &output_ism[n][0]; } - - ivas_sba_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ); +#ifdef UNIFY_CHANNEL_MEM_HEAP #ifdef OSBA_ROOM_IR if ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV_ROOM ) #endif { ivas_ism_render_sf( st_ivas, p_output_ism, *nSamplesRendered ); } +#endif + ivas_sba_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ); +#ifndef UNIFY_CHANNEL_MEM_HEAP +#ifdef OSBA_ROOM_IR + if ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV_ROOM ) +#endif + { + ivas_ism_render_sf( st_ivas, p_output_ism, *nSamplesRendered ); + } +#endif for ( n = 0; n < nchan_out; n++ ) { #ifdef OSBA_ROOM_IR diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index a0a2ad35f3..a26a4457f5 100644 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -135,9 +135,37 @@ ivas_error ivas_osba_dirac_td_binaural_jbm( { int16_t n; ivas_error error; +#ifdef UNIFY_CHANNEL_MEM_HEAP + float data_separated_objects[MAX_NUM_OBJECTS][2 * L_FRAME48k]; + float *p_save_tc[MAX_NUM_OBJECTS]; + int16_t offsetSamples, slots_to_render; + float *p_sepobj[MAX_NUM_OBJECTS]; + + for ( n = 0; n < MAX_NUM_OBJECTS; n++ ) + { + p_sepobj[n] = &data_separated_objects[n][0]; + } + /* save objects */ + offsetSamples = st_ivas->hSpatParamRendCom->slots_rendered * st_ivas->hSpatParamRendCom->slot_size; + slots_to_render = min( st_ivas->hSpatParamRendCom->num_slots - st_ivas->hSpatParamRendCom->slots_rendered, nSamplesAsked / st_ivas->hSpatParamRendCom->slot_size ); + *nSamplesRendered = slots_to_render * st_ivas->hSpatParamRendCom->slot_size; + for ( n = 0; n < st_ivas->nchan_ism; n++ ) + { + mvr2r( &st_ivas->hTcBuffer->tc[n][offsetSamples], &data_separated_objects[n][offsetSamples], *nSamplesRendered ); + } +#endif ivas_sba_dec_render( st_ivas, nSamplesAsked, nSamplesRendered, nSamplesAvailable, &output_f[2] ); +#ifdef UNIFY_CHANNEL_MEM_HEAP + /* temporary set the object tc pointers to the locally saved ones */ + for ( n = 0; n < st_ivas->nchan_ism; n++ ) + { + p_save_tc[n] = st_ivas->hTcBuffer->tc[n]; + st_ivas->hTcBuffer->tc[n] = p_sepobj[n]; + } +#endif + #ifdef OSBA_SPLIT_RENDERING if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { @@ -196,7 +224,13 @@ ivas_error ivas_osba_dirac_td_binaural_jbm( #ifdef OSBA_SPLIT_RENDERING } #endif - +#ifdef UNIFY_CHANNEL_MEM_HEAP + /* bend saved tc pointers back */ + for ( n = 0; n < st_ivas->nchan_ism; n++ ) + { + st_ivas->hTcBuffer->tc[2 + n] = p_save_tc[n]; + } +#endif return IVAS_ERR_OK; } #endif diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 9044120e42..3539e5eba2 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -149,9 +149,17 @@ ivas_error ivas_sba_dec_reconfigure( * Save old SBA high-level parameters *-----------------------------------------------------------------*/ #ifdef UNIFY_CHANNEL_MEM_HEAP +#ifdef FIX_XXX_SBA_RS + nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, sba_analysis_order_old_flush, last_ivas_total_brate, st_ivas->hTcBuffer->nchan_buffer_full ); +#else nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, sba_analysis_order_old, last_ivas_total_brate, st_ivas->hTcBuffer->nchan_buffer_full ); +#endif +#else +#ifdef FIX_XXX_SBA_RS + nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, sba_analysis_order_old_flush, last_ivas_total_brate ); #else nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, sba_analysis_order_old, last_ivas_total_brate ); +#endif #endif ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); -- GitLab From ff70a9a80911726e4d0334d9381cbb27fe658597 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Tue, 10 Oct 2023 08:10:29 +0200 Subject: [PATCH 45/49] amend fix for SBA/OSBA RS --- lib_dec/ivas_init_dec.c | 6 ++++++ lib_dec/ivas_sba_dec.c | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index a199f8fac7..484034767c 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -356,8 +356,10 @@ ivas_error ivas_dec_setup( st_ivas->sba_order = st_ivas->bit_stream[num_bits_read + 1]; st_ivas->sba_order += 2 * st_ivas->bit_stream[num_bits_read]; +#ifndef FIX_XXX_SBA_RS /* set Ambisonic (SBA) order used for analysis and coding */ st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order ); +#endif num_bits_read += SBA_ORDER_BITS; if ( st_ivas->ini_frame > 0 && ivas_total_brate != st_ivas->last_active_ivas_total_brate && ivas_total_brate > IVAS_SID_5k2 ) @@ -379,6 +381,10 @@ ivas_error ivas_dec_setup( } else { +#ifdef FIX_XXX_SBA_RS + /* set Ambisonic (SBA) order used for analysis and coding */ + st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order ); +#endif ivas_sba_config( ivas_total_brate, st_ivas->sba_analysis_order, -1, &( st_ivas->nchan_transport ), st_ivas->sba_planar, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init ); } } diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 3539e5eba2..ff10f55981 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -122,7 +122,9 @@ ivas_error ivas_sba_dec_reconfigure( int32_t last_ivas_total_brate; int16_t num_channels, num_md_sub_frames; int16_t ch, nchan_out_buff, nchan_out_buff_old; +#ifndef FIX_XXX_SBA_RS int16_t sba_analysis_order_old; +#endif #ifdef JBM_FOR_OSBA int16_t sba_analysis_order_old_flush; #endif @@ -142,8 +144,9 @@ ivas_error ivas_sba_dec_reconfigure( #ifdef JBM_FOR_OSBA sba_analysis_order_old_flush = st_ivas->sba_analysis_order; #endif +#ifndef FIX_XXX_SBA_RS sba_analysis_order_old = ivas_sba_get_analysis_order( last_ivas_total_brate, st_ivas->sba_order ); - +#endif /*-----------------------------------------------------------------* * Set SBA high-level parameters * Save old SBA high-level parameters -- GitLab From 3cb937f0784e995e74db19c8ff70ff22b07b6347 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Wed, 11 Oct 2023 07:14:33 +0200 Subject: [PATCH 46/49] address comments: fix compiler warnings with split rendering enabled, fix missing update of head rotation indices in the split rendering crend subframe function, remove an unnecessary call to the limiter. --- apps/decoder.c | 10 +++++----- lib_dec/ivas_jbm_dec.c | 6 +----- lib_dec/lib_dec.c | 1 - lib_rend/ivas_crend.c | 3 +++ 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 9552783957..ee69f892bb 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1746,7 +1746,11 @@ static ivas_error initOnFirstGoodFrame( const DecArguments arg, /* i : */ const int16_t numInitialBadFrames, /* i : */ #ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef NONBE_UNIFIED_DECODING_PATHS + int16_t *numOutSamples, /* i/o: */ +#else uint16_t *numOutSamples, /* i/o: */ +#endif int16_t *vec_pos_len, /* i/o: */ #else const uint16_t numOutSamples, /* i : */ @@ -2067,7 +2071,7 @@ static ivas_error decodeG192( int16_t nOutChannels = 0; int16_t delayNumSamples = -1; int16_t delayNumSamples_orig[3]; -#ifdef SPLIT_REND_WITH_HEAD_ROT +#if defined(SPLIT_REND_WITH_HEAD_ROT) && !defined(NONBE_UNIFIED_DECODING_PATHS) uint16_t nOutSamples = 0; #else int16_t nOutSamples = 0; @@ -2936,12 +2940,8 @@ static ivas_error decodeVoIP( #ifdef NONBE_UNIFIED_DECODING_PATHS IVAS_VECTOR3 Pos[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES] = { { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } }; int16_t vec_pos_update, vec_pos_len; -#if defined( SPLIT_REND_WITH_HEAD_ROT ) - uint16_t nOutSamples = 0; -#else int16_t nOutSamples = 0; #endif -#endif #ifdef NONBE_UNIFIED_DECODING_PATHS vec_pos_update = 0; diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index a7f41b8410..8561f157d4 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -1642,11 +1642,7 @@ ivas_error ivas_jbm_dec_render( if ( st_ivas->ivas_format != MONO_FORMAT ) { #ifndef DISABLE_LIMITER -#ifdef SPLIT_REND_WITH_HEAD_ROT - ivas_limiter_dec( st_ivas->hLimiter, p_output, nchan_out_syn_output, *nSamplesRendered, st_ivas->BER_detect ); -#else ivas_limiter_dec( st_ivas->hLimiter, p_output, nchan_out, *nSamplesRendered, st_ivas->BER_detect ); -#endif #endif } } @@ -1660,7 +1656,7 @@ ivas_error ivas_jbm_dec_render( st_ivas->noClipping += #endif #ifdef SPLIT_REND_WITH_HEAD_ROT - ivas_syn_output( p_output, *nSamplesRendered, nchan_out, (int16_t *) data ); + ivas_syn_output( p_output, *nSamplesRendered, nchan_out_syn_output, (int16_t *) data ); #else ivas_syn_output( p_output, *nSamplesRendered, nchan_out, data ); #endif diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 611a81c349..77cef40c6f 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -3782,7 +3782,6 @@ ivas_error IVAS_DEC_GetCldfbSamples( ) { Decoder_Struct *st_ivas; - ivas_error error; int16_t ch, b, slot_idx, num_chs, maxBand, num_samples; if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index 361b78657a..75da2fd12b 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -2398,6 +2398,9 @@ ivas_error ivas_rend_crendProcessSubframesSplitBin( mvr2r( tmpSplitBinBuffer[i], output[i], n_samples_to_render ); } + /* update main combined orientation access index */ + ivas_combined_orientation_update_index( hCombinedOrientationData, n_samples_to_render ); + return IVAS_ERR_OK; } #endif -- GitLab From 37313e7f870a651648fbf940e357442851d921dd Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Wed, 11 Oct 2023 07:54:22 +0200 Subject: [PATCH 47/49] set framesize always to 20ms for split rendering, add a warning if the asked frame size was different in this case, clang-format --- apps/decoder.c | 18 ++++++++++++++++-- lib_dec/lib_dec.c | 22 ++++++++++++++++++++-- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index ee69f892bb..60e4aa7632 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -466,11 +466,25 @@ int main( #ifdef SPLIT_REND_WITH_HEAD_ROT if ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { +#ifdef REMOVE_5MS_FLAG + IVAS_RENDER_FRAMESIZE asked_frame_size = arg.renderFramesize; +#endif if ( ( error = IVAS_DEC_EnableSplitRendering( hIvasDec ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } +#ifdef REMOVE_5MS_FLAG + if ( ( error = IVAS_DEC_GetRenderFramesize( hIvasDec, &arg.renderFramesize ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + if ( arg.renderFramesize != asked_frame_size ) + { + fprintf( stderr, "\nChanged render framesize, only 20ms are allowed for split rendering!\n" ); + } +#endif arg.enableHeadRotation = true; } @@ -1751,7 +1765,7 @@ static ivas_error initOnFirstGoodFrame( #else uint16_t *numOutSamples, /* i/o: */ #endif - int16_t *vec_pos_len, /* i/o: */ + int16_t *vec_pos_len, /* i/o: */ #else const uint16_t numOutSamples, /* i : */ #endif @@ -2071,7 +2085,7 @@ static ivas_error decodeG192( int16_t nOutChannels = 0; int16_t delayNumSamples = -1; int16_t delayNumSamples_orig[3]; -#if defined(SPLIT_REND_WITH_HEAD_ROT) && !defined(NONBE_UNIFIED_DECODING_PATHS) +#if defined( SPLIT_REND_WITH_HEAD_ROT ) && !defined( NONBE_UNIFIED_DECODING_PATHS ) uint16_t nOutSamples = 0; #else int16_t nOutSamples = 0; diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 77cef40c6f..7f586e35b2 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -126,6 +126,9 @@ static PCM_RESOLUTION pcm_type_API_to_internal( const IVAS_DEC_PCM_TYPE pcmType static void *pcm_buffer_offset( void *buffer, const IVAS_DEC_PCM_TYPE pcmType, const int32_t offset ); static ivas_error set_pcm_buffer_to_zero( void *buffer, const IVAS_DEC_PCM_TYPE pcmType, const int16_t nZeroSamples ); #endif +#ifdef REMOVE_5MS_FLAG +static int16_t get_render_frame_size_ms( IVAS_RENDER_FRAMESIZE render_framesize ); +#endif /*---------------------------------------------------------------------* @@ -512,6 +515,8 @@ ivas_error IVAS_DEC_EnableSplitRendering( hDecoderConfig->Opt_Headrotation = 1; #ifndef REMOVE_5MS_FLAG hDecoderConfig->Opt_5ms = false; +#else + hDecoderConfig->render_framesize = IVAS_RENDER_FRAMESIZE_20MS; #endif hDecoderConfig->Opt_Limiter = 0; @@ -564,6 +569,17 @@ ivas_error IVAS_DEC_Get5msFlag( return IVAS_ERR_OK; } #else +/*---------------------------------------------------------------------* + * get_render_framesize_ms( ) + * + * Get the 5ms flag + *---------------------------------------------------------------------*/ + +int16_t get_render_frame_size_ms( IVAS_RENDER_FRAMESIZE render_framesize ) +{ + return (int16_t) ( render_framesize * ( 1000 / ( FRAMES_PER_SEC * IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ) ); +} + /*---------------------------------------------------------------------* * IVAS_DEC_SetRenderFramesize( ) * @@ -643,7 +659,7 @@ ivas_error IVAS_DEC_GetRenderFramesizeMs( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - *render_framesize = (int16_t) ( hIvasDec->st_ivas->hDecoderConfig->render_framesize * ( 1000 / ( FRAMES_PER_SEC * IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ) ); + *render_framesize = get_render_frame_size_ms( hIvasDec->st_ivas->hDecoderConfig->render_framesize ); return IVAS_ERR_OK; } @@ -3111,7 +3127,9 @@ static ivas_error printConfigInfo_dec( get_channel_config( st_ivas->hDecoderConfig->output_config, &config_str[0] ); fprintf( stdout, "Output configuration: %s\n", config_str ); - +#ifdef REMOVE_5MS_FLAG + fprintf( stdout, "Render framesize: %dms\n", get_render_frame_size_ms( st_ivas->hDecoderConfig->render_framesize ) ); +#endif if ( st_ivas->hDecoderConfig->Opt_HRTF_binary ) { fprintf( stdout, "HRIR/BRIR file: ON\n" ); -- GitLab From 17b947f547062d5d2921833899b93d70aadc3efe Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Wed, 11 Oct 2023 08:07:17 +0200 Subject: [PATCH 48/49] integrate subdefine REMOVE_5MS_FLAG into NONBE_UNIFIED_DECODING_PATHS --- apps/decoder.c | 55 ++++++-------------- apps/renderer.c | 22 ++++---- lib_com/common_api_types.h | 2 +- lib_dec/ivas_dirac_dec.c | 2 +- lib_dec/ivas_init_dec.c | 16 +++--- lib_dec/ivas_ism_dec.c | 6 +-- lib_dec/ivas_ism_param_dec.c | 8 +-- lib_dec/ivas_jbm_dec.c | 12 ++--- lib_dec/ivas_masa_dec.c | 6 +-- lib_dec/ivas_mc_param_dec.c | 4 +- lib_dec/ivas_mc_paramupmix_dec.c | 4 +- lib_dec/ivas_mct_dec.c | 4 +- lib_dec/ivas_omasa_dec.c | 2 +- lib_dec/ivas_sba_dec.c | 4 +- lib_dec/ivas_spar_decoder.c | 6 +-- lib_dec/ivas_stat_dec.h | 2 +- lib_dec/lib_dec.c | 30 +++++------ lib_dec/lib_dec.h | 4 +- lib_rend/ivas_dirac_dec_binaural_functions.c | 2 +- lib_rend/lib_rend.c | 2 +- 20 files changed, 85 insertions(+), 108 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 60e4aa7632..6227bbee03 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -128,7 +128,7 @@ typedef struct #endif IVAS_DEC_COMPLEXITY_LEVEL complexityLevel; bool tsmEnabled; -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS bool enable5ms; #else IVAS_RENDER_FRAMESIZE renderFramesize; @@ -445,7 +445,7 @@ int main( *------------------------------------------------------------------------------------------*/ if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputConfig, arg.tsmEnabled, -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS arg.enable5ms, #else arg.renderFramesize, @@ -466,7 +466,7 @@ int main( #ifdef SPLIT_REND_WITH_HEAD_ROT if ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { -#ifdef REMOVE_5MS_FLAG +#ifdef NONBE_UNIFIED_DECODING_PATHS IVAS_RENDER_FRAMESIZE asked_frame_size = arg.renderFramesize; #endif if ( ( error = IVAS_DEC_EnableSplitRendering( hIvasDec ) ) != IVAS_ERR_OK ) @@ -474,7 +474,7 @@ int main( fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } -#ifdef REMOVE_5MS_FLAG +#ifdef NONBE_UNIFIED_DECODING_PATHS if ( ( error = IVAS_DEC_GetRenderFramesize( hIvasDec, &arg.renderFramesize ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); @@ -640,7 +640,7 @@ int main( #ifdef SPLIT_REND_WITH_HEAD_ROT if ( -#ifdef REMOVE_5MS_FLAG +#ifdef NONBE_UNIFIED_DECODING_PATHS arg.renderFramesize == IVAS_RENDER_FRAMESIZE_5MS && #else arg.enable5ms && @@ -649,7 +649,7 @@ int main( renderConfig.split_rend_config.dof == 0 ) ) { /*TODO : needs to be refined as this wont work with LCLD codec*/ -#ifdef REMOVE_5MS_FLAG +#ifdef NONBE_UNIFIED_DECODING_PATHS arg.renderFramesize = IVAS_RENDER_FRAMESIZE_5MS; #else arg.enable5ms = true; @@ -657,13 +657,13 @@ int main( } else { -#ifdef REMOVE_5MS_FLAG +#ifdef NONBE_UNIFIED_DECODING_PATHS arg.renderFramesize = IVAS_RENDER_FRAMESIZE_20MS; #else arg.enable5ms = true; #endif } -#ifdef REMOVE_5MS_FLAG +#ifdef NONBE_UNIFIED_DECODING_PATHS if ( ( error = IVAS_DEC_SetRenderFramesize( hIvasDec, arg.renderFramesize ) ) != IVAS_ERR_OK ) #else if ( ( error = IVAS_DEC_Set5msFlag( hIvasDec, arg.enable5ms ) ) != IVAS_ERR_OK ) @@ -1075,7 +1075,7 @@ static bool parseCmdlIVAS_dec( arg->Opt_non_diegetic_pan = 0; arg->non_diegetic_pan_gain = 0.f; arg->tsmEnabled = false; -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS arg->enable5ms = false; #else arg->renderFramesize = IVAS_RENDER_FRAMESIZE_20MS; @@ -1272,7 +1272,7 @@ static bool parseCmdlIVAS_dec( arg->headrotTrajFileName = argv[i]; i++; } -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS else if ( strcmp( argv_to_upper, "-FR5" ) == 0 ) { arg->enable5ms = true; @@ -1619,7 +1619,7 @@ static bool parseCmdlIVAS_dec( return false; } -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( ( !arg->enableHeadRotation ) && ( !arg->enableExternalOrientation ) && ( !arg->tsmEnabled ) ) { arg->enable5ms = false; @@ -1675,7 +1675,7 @@ static void usage_dec( void ) fprintf( stdout, " 50 <= fac <= 150; fac<100 faster, fac>100 slower\n" ); #endif #endif -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS fprintf( stdout, "-fr5 : option to perform rendering + head-tracking with 5ms frame size\n" ); #else fprintf( stdout, "-fr L : render frame size in ms L=(5,10,20), default is 20)\n" ); @@ -2006,7 +2006,7 @@ static ivas_error initOnFirstGoodFrame( #ifdef SPLIT_REND_WITH_HEAD_ROT if ( *splitRendWriter != NULL ) { -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS int16_t enable5ms; #endif @@ -2014,7 +2014,7 @@ static ivas_error initOnFirstGoodFrame( { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } -#ifdef REMOVE_5MS_FLAG +#ifdef NONBE_UNIFIED_DECODING_PATHS /* real setting of the 5ms mode for split rendering is only known after the decoded first good frame, reset the variables needed in the main decoding loop accordingly here*/ if ( ( error = IVAS_DEC_GetRenderFramesizeSamples( hIvasDec, numOutSamples ) ) != IVAS_ERR_OK ) { @@ -2165,7 +2165,7 @@ static ivas_error decodeG192( nSamplesAvailableNext = 0; vec_pos_update = 0; -#ifdef REMOVE_5MS_FLAG +#ifdef NONBE_UNIFIED_DECODING_PATHS if ( ( error = IVAS_DEC_GetRenderFramesizeSamples( hIvasDec, &nOutSamples ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError getting render frame size in samples\n" ); @@ -2232,7 +2232,7 @@ static ivas_error decodeG192( goto cleanup; } } -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS int16_t enable5ms, num_subframes; if ( ( error = IVAS_DEC_Get5msFlag( hIvasDec, &enable5ms ) ) != IVAS_ERR_OK ) { @@ -2959,7 +2959,6 @@ static ivas_error decodeVoIP( #ifdef NONBE_UNIFIED_DECODING_PATHS vec_pos_update = 0; -#ifdef REMOVE_5MS_FLAG if ( ( error = IVAS_DEC_GetRenderFramesizeMs( hIvasDec, &systemTimeInc_ms ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError getting render frame size in samples\n" ); @@ -2975,18 +2974,6 @@ static ivas_error decodeVoIP( fprintf( stderr, "\nError getting render frame size in samples\n" ); return error; } -#else - if ( arg.enableHeadRotation && arg.enable5ms ) - { - nOutSamples = (int16_t) ( arg.output_Fs / 1000 * HEADROTATION_FETCH_FRAMESIZE_MS ); - vec_pos_len = IVAS_MAX_PARAM_SPATIAL_SUBFRAMES; - } - else - { - nOutSamples = (int16_t) ( arg.output_Fs / 1000 * DEFAULT_FETCH_FRAMESIZE_MS ); - vec_pos_len = 1; - } -#endif #endif for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; ++i ) @@ -3131,22 +3118,12 @@ static ivas_error decodeVoIP( goto cleanup; } } -#ifndef REMOVE_5MS_FLAG - int16_t enable5ms, num_subframes; - if ( ( error = IVAS_DEC_Get5msFlag( hIvasDec, &enable5ms ) ) != IVAS_ERR_OK ) - { - return error; - } - arg.enable5ms = enable5ms; - num_subframes = ( arg.enable5ms ) ? 1 : IVAS_MAX_PARAM_SPATIAL_SUBFRAMES; -#else int16_t num_subframes; if ( ( error = IVAS_DEC_GetNumOrientationSubframes( hIvasDec, &num_subframes ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_DEC_GetNumOrientationSubframes failed: \n" ); goto cleanup; } -#endif /* Head-tracking input simulation */ /* Head-tracking input simulation */ diff --git a/apps/renderer.c b/apps/renderer.c index 354817c22d..3b6ace00f5 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -187,7 +187,7 @@ typedef struct bool lfeCustomRoutingEnabled; char inLfePanningMatrixFile[RENDERER_MAX_CLI_ARG_LENGTH]; float syncMdDelay; -#ifdef REMOVE_5MS_FLAG +#ifdef NONBE_UNIFIED_DECODING_PATHS IVAS_RENDER_FRAMESIZE render_framesize; #else bool framing_5ms; @@ -223,7 +223,7 @@ typedef enum #endif CmdLnOptionId_referenceVectorFile, CmdLnOptionId_exteriorOrientationFile, -#ifdef REMOVE_5MS_FLAG +#ifdef NONBE_UNIFIED_DECODING_PATHS CmdLnOptionId_framing, #endif CmdLnOptionId_framing5ms, @@ -375,7 +375,7 @@ static const CmdLnParser_Option cliOptions[] = { .matchShort = "exof", .description = "External orientation trajectory file for simulation of external orientations", }, -#ifdef REMOVE_5MS_FLAG +#ifdef NONBE_UNIFIED_DECODING_PATHS { .id = CmdLnOptionId_framing, .match = "framing", @@ -1012,13 +1012,13 @@ int main( #ifdef SPLIT_REND_WITH_HEAD_ROT } #endif -#ifdef REMOVE_5MS_FLAG +#ifdef NONBE_UNIFIED_DECODING_PATHS const int16_t frameSize_smpls = (int16_t) ( ( args.render_framesize ) * args.sampleRate * 5 / ( 1000 ) ); #else const int16_t frameSize_smpls = (int16_t) ( ( args.framing_5ms ? 5 : 20 ) * args.sampleRate / 1000 ); #endif -#ifdef REMOVE_5MS_FLAG +#ifdef NONBE_UNIFIED_DECODING_PATHS if ( ( error = IVAS_REND_Open( &hIvasRend, args.sampleRate, args.outConfig.audioConfig, args.nonDiegeticPan, args.nonDiegeticPanGain, (int16_t) args.render_framesize ) ) != IVAS_ERR_OK ) #else if ( ( error = IVAS_REND_Open( &hIvasRend, args.sampleRate, args.outConfig.audioConfig, args.nonDiegeticPan, args.nonDiegeticPanGain, ( args.framing_5ms ) ? 1 : 4 ) ) != IVAS_ERR_OK ) @@ -1517,7 +1517,7 @@ int main( { int16_t num_in_channels; num_in_channels = inBuffer.config.numChannels; -#ifdef REMOVE_5MS_FLAG +#ifdef NONBE_UNIFIED_DECODING_PATHS const bool isCurrentFrameMultipleOf20ms = frame % ( 4 / args.render_framesize ) == 0; #else const bool isCurrentFrameMultipleOf20ms = !args.framing_5ms || frame % 4 == 0; @@ -1573,7 +1573,7 @@ int main( #endif int16_t num_subframes, sf_idx; -#ifdef REMOVE_5MS_FLAG +#ifdef NONBE_UNIFIED_DECODING_PATHS num_subframes = (int16_t) args.render_framesize; #else num_subframes = ( args.framing_5ms ) ? 1 : IVAS_MAX_PARAM_SPATIAL_SUBFRAMES; @@ -2366,7 +2366,7 @@ static bool parseDiegeticPan( } -#ifdef REMOVE_5MS_FLAG +#ifdef NONBE_UNIFIED_DECODING_PATHS static bool parseRenderFramesize( char *value, IVAS_RENDER_FRAMESIZE *render_framesize ) { @@ -2693,7 +2693,7 @@ static CmdlnArgs defaultArgs( args.lfeCustomRoutingEnabled = false; clearString( args.inLfePanningMatrixFile ); -#ifdef REMOVE_5MS_FLAG +#ifdef NONBE_UNIFIED_DECODING_PATHS args.render_framesize = IVAS_RENDER_FRAMESIZE_20MS; #else args.framing_5ms = false; @@ -2859,7 +2859,7 @@ static void parseOption( exit( -1 ); } break; -#ifdef REMOVE_5MS_FLAG +#ifdef NONBE_UNIFIED_DECODING_PATHS case CmdLnOptionId_framing: assert( numOptionValues == 1 ); if ( !parseRenderFramesize( optionValues[0], &args->render_framesize ) ) @@ -2872,7 +2872,7 @@ static void parseOption( #endif case CmdLnOptionId_framing5ms: assert( numOptionValues == 0 ); -#ifdef REMOVE_5MS_FLAG +#ifdef NONBE_UNIFIED_DECODING_PATHS args->render_framesize = IVAS_RENDER_FRAMESIZE_5MS; #else args->framing_5ms = true; diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index e8c4bd41c2..dc9f0d83f3 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -150,7 +150,7 @@ typedef enum } IVAS_HEAD_ORIENT_TRK_T; -#ifdef REMOVE_5MS_FLAG +#ifdef NONBE_UNIFIED_DECODING_PATHS typedef enum { IVAS_RENDER_FRAMESIZE_UNKNOWN = 0, diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 3ab0752054..7257d631ec 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -953,7 +953,7 @@ ivas_error ivas_dirac_dec_config( if ( dec_config_flag == DIRAC_OPEN ) { if ( -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS st_ivas->hDecoderConfig->Opt_5ms && #endif st_ivas->hTcBuffer == NULL ) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 484034767c..96e0c95b23 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -259,7 +259,7 @@ static ivas_error ivas_dec_init_split_rend( } #endif -#ifdef REMOVE_5MS_FLAG +#ifdef NONBE_UNIFIED_DECODING_PATHS error = ivas_split_renderer_open( &st_ivas->hSplitBinRend.splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, cldfb_in_flag, pcm_out_flag, st_ivas->hDecoderConfig->render_framesize == IVAS_RENDER_FRAMESIZE_5MS ); #else error = ivas_split_renderer_open( &st_ivas->hSplitBinRend.splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, cldfb_in_flag, pcm_out_flag, st_ivas->hDecoderConfig->Opt_5ms ); @@ -1050,7 +1050,7 @@ ivas_error ivas_init_decoder_front( if ( st_ivas->hDecoderConfig->Opt_ExternalOrientation ) { if ( ( error = ivas_external_orientation_open( &( st_ivas->hExtOrientationData ), -#ifdef REMOVE_5MS_FLAG +#ifdef NONBE_UNIFIED_DECODING_PATHS st_ivas->hDecoderConfig->render_framesize #else ( st_ivas->hDecoderConfig->Opt_5ms ) ? 1 : MAX_PARAM_SPATIAL_SUBFRAMES @@ -1071,7 +1071,7 @@ ivas_error ivas_init_decoder_front( #ifdef NONBE_UNIFIED_DECODING_PATHS st_ivas->hDecoderConfig->output_Fs, #endif -#ifdef REMOVE_5MS_FLAG +#ifdef NONBE_UNIFIED_DECODING_PATHS st_ivas->hDecoderConfig->render_framesize #else ( st_ivas->hDecoderConfig->Opt_5ms ) ? 1 : MAX_PARAM_SPATIAL_SUBFRAMES @@ -2013,7 +2013,7 @@ ivas_error ivas_init_decoder( } #ifndef UNIFY_CHANNEL_MEM_HEAP -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( st_ivas->hDecoderConfig->Opt_5ms ) #endif { @@ -2065,7 +2065,7 @@ ivas_error ivas_init_decoder( st_ivas->binaural_latency_ns = st_ivas->hCrendWrapper->binaural_latency_ns; #ifndef UNIFY_CHANNEL_MEM_HEAP -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( st_ivas->hDecoderConfig->Opt_5ms ) #endif { @@ -2236,7 +2236,7 @@ ivas_error ivas_init_decoder( * Allocate and initialize JBM struct + buffer *-----------------------------------------------------------------*/ if ( -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS st_ivas->hDecoderConfig->Opt_5ms && #endif st_ivas->hTcBuffer == NULL ) @@ -2274,7 +2274,7 @@ ivas_error ivas_init_decoder( /*-----------------------------------------------------------------* * Allocate floating-point output audio buffers *-----------------------------------------------------------------*/ -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( !st_ivas->hDecoderConfig->Opt_5ms ) #endif { @@ -2291,7 +2291,7 @@ ivas_error ivas_init_decoder( } } } -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS else { n = 0; diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 739f78ac07..97b24b89af 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -135,7 +135,7 @@ static ivas_error ivas_ism_bitrate_switching_dec( ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->hDecoderConfig->output_config ); } -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( st_ivas->hDecoderConfig->Opt_5ms ) #endif { @@ -342,7 +342,7 @@ static ivas_error ivas_ism_bitrate_switching_dec( * floating-point output audio buffers *-----------------------------------------------------------------*/ -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( !st_ivas->hDecoderConfig->Opt_5ms ) #endif { @@ -376,7 +376,7 @@ static ivas_error ivas_ism_bitrate_switching_dec( /*-----------------------------------------------------------------* * Reconfigure TC buffer *-----------------------------------------------------------------*/ -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( st_ivas->hDecoderConfig->Opt_5ms ) #endif { diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index dbe8e37629..b9e8818551 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -591,7 +591,7 @@ ivas_error ivas_param_ism_dec_open( st_ivas->hSpatParamRendCom = hSpatParamRendCom; -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( st_ivas->hDecoderConfig->Opt_5ms ) #endif { @@ -652,7 +652,7 @@ ivas_error ivas_param_ism_dec_open( } } } -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS else { hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc = NULL; @@ -1216,7 +1216,7 @@ void ivas_param_ism_dec_digest_tc( } } if ( st_ivas->hDecoderConfig->Opt_tsm -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS || !st_ivas->hDecoderConfig->Opt_5ms #endif ) @@ -1233,7 +1233,7 @@ void ivas_param_ism_dec_digest_tc( for ( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) { if ( st_ivas->hDecoderConfig->Opt_tsm -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS || !st_ivas->hDecoderConfig->Opt_5ms #endif ) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 8561f157d4..43c333606f 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -719,7 +719,7 @@ ivas_error ivas_jbm_dec_tc( * Write IVAS transport channels *----------------------------------------------------------------*/ if ( st_ivas->hDecoderConfig->Opt_tsm == 1 -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS || !st_ivas->hDecoderConfig->Opt_5ms #endif ) @@ -793,7 +793,7 @@ ivas_error ivas_jbm_dec_feed_tc_to_renderer( p_data_f[n] = &data_f[n][0]; } if ( st_ivas->hDecoderConfig->Opt_tsm -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS || !st_ivas->hDecoderConfig->Opt_5ms #endif ) @@ -2897,13 +2897,13 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( { #endif /* realloc buffers */ -#ifdef REMOVE_5MS_FLAG +#ifdef NONBE_UNIFIED_DECODING_PATHS if ( hTcBuffer->tc_buffer != NULL ) { #endif free( hTcBuffer->tc_buffer ); hTcBuffer->tc_buffer = NULL; -#ifdef REMOVE_5MS_FLAG +#ifdef NONBE_UNIFIED_DECODING_PATHS } #endif #ifndef UNIFY_CHANNEL_MEM_HEAP @@ -2923,7 +2923,7 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( nsamp_to_allocate = hTcBuffer->nchan_buffer_full * n_samp_full; nsamp_to_allocate += nchan_residual * n_samp_residual; -#ifdef REMOVE_5MS_FLAG +#ifdef NONBE_UNIFIED_DECODING_PATHS if ( nsamp_to_allocate == 0 ) { hTcBuffer->tc_buffer = NULL; @@ -2966,7 +2966,7 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( { hTcBuffer->tc[ch_idx] = NULL; } -#ifdef REMOVE_5MS_FLAG +#ifdef NONBE_UNIFIED_DECODING_PATHS } #endif #ifdef UNIFY_CHANNEL_MEM_HEAP diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 9782eafa0b..f523de38cc 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -624,7 +624,7 @@ ivas_error ivas_masa_dec_open( #ifndef UNIFY_CHANNEL_MEM_HEAP /* allocate transport channels*/ if ( -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS st_ivas->hDecoderConfig->Opt_5ms && #endif st_ivas->hTcBuffer == NULL && st_ivas->renderer_type != RENDERER_DISABLE && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM && st_ivas->renderer_type != RENDERER_STEREO_PARAMETRIC ) @@ -1278,7 +1278,7 @@ ivas_error ivas_masa_dec_reconfigure( ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; last_ivas_total_brate = st_ivas->hDecoderConfig->last_ivas_total_brate; -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( st_ivas->hDecoderConfig->Opt_5ms == 1 ) #endif { @@ -1472,7 +1472,7 @@ ivas_error ivas_masa_dec_reconfigure( st_ivas->ism_mode = ISM_MODE_NONE; } -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( st_ivas->hDecoderConfig->Opt_5ms == 1 ) #endif { diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 5141f4e8c9..57cf9234e5 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -440,7 +440,7 @@ ivas_error ivas_param_mc_dec_open( ivas_param_mc_dec_init( hParamMC, nchan_transport, nchan_out_cov ); if ( -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS st_ivas->hDecoderConfig->Opt_5ms && #endif hParamMC->synthesis_conf != PARAM_MC_SYNTH_MONO_STEREO ) @@ -1444,7 +1444,7 @@ void ivas_param_mc_dec_digest_tc( for ( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) { if ( st_ivas->hDecoderConfig->Opt_tsm -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS || !st_ivas->hDecoderConfig->Opt_5ms #endif ) diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index 3b48e8d084..abd7e48262 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -670,7 +670,7 @@ ivas_error ivas_mc_paramupmix_dec_open( hMCParamUpmix->free_param_interpolator = 0; hMCParamUpmix->param_interpolator = NULL; #ifdef NONBE_FIX_808_JBM_PARAMUPMIX_RS -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( st_ivas->hDecoderConfig->Opt_5ms == 1 ) #endif { @@ -686,7 +686,7 @@ ivas_error ivas_mc_paramupmix_dec_open( #ifndef UNIFY_CHANNEL_MEM_HEAP if ( -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS st_ivas->hDecoderConfig->Opt_5ms == 1 && #endif st_ivas->hTcBuffer == NULL ) diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 856ed53bd3..b53d2309eb 100755 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -774,7 +774,7 @@ static ivas_error ivas_mc_dec_reconfig( /* side effect of the renderer selection can be a changed internal config */ ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->intern_config ); -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( st_ivas->hDecoderConfig->Opt_5ms ) #endif { @@ -1329,7 +1329,7 @@ static ivas_error ivas_mc_dec_reconfig( /*-----------------------------------------------------------------* * Reconfigure TC buffer *-----------------------------------------------------------------*/ -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( st_ivas->hDecoderConfig->Opt_5ms == 1 ) #endif { diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index 8ecb657d9a..52ee956194 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -416,7 +416,7 @@ ivas_error ivas_omasa_dec_config( /*-----------------------------------------------------------------* * floating-point output audio buffers *-----------------------------------------------------------------*/ -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( !st_ivas->hDecoderConfig->Opt_5ms ) #endif { diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index ff10f55981..3879ed6894 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -642,7 +642,7 @@ ivas_error ivas_sba_dec_reconfigure( /*-----------------------------------------------------------------* * JBM TC buffer *-----------------------------------------------------------------*/ -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( st_ivas->hDecoderConfig->Opt_5ms == 1 #ifdef JBM_FOR_OSBA || st_ivas->ivas_format == SBA_ISM_FORMAT @@ -750,7 +750,7 @@ ivas_error ivas_sba_dec_reconfigure( /*-----------------------------------------------------------------* * floating-point output audio buffers *-----------------------------------------------------------------*/ -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( !st_ivas->hDecoderConfig->Opt_5ms ) #endif { diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 91c6b2edcb..5fab27e48c 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -214,11 +214,11 @@ ivas_error ivas_spar_dec_open( #ifndef UNIFY_CHANNEL_MEM_HEAP /* allocate transport channels*/ if ( -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS st_ivas->hDecoderConfig->Opt_5ms && #endif st_ivas->hTcBuffer == NULL -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS #ifdef JBM_FOR_OSBA || st_ivas->ivas_format == SBA_ISM_FORMAT #endif @@ -278,7 +278,7 @@ ivas_error ivas_spar_dec_open( } #endif -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS #ifdef JBM_FOR_OSBA /* make sure we have a TC buffer with the correct granularity for rate switching in OSBA */ if ( !st_ivas->hDecoderConfig->Opt_5ms ) diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index a79d3631c4..0bd4db6333 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1018,7 +1018,7 @@ typedef struct decoder_config_structure #ifdef SPLIT_REND_WITH_HEAD_ROT int16_t Opt_Limiter; #endif -#ifdef REMOVE_5MS_FLAG +#ifdef NONBE_UNIFIED_DECODING_PATHS IVAS_RENDER_FRAMESIZE render_framesize; #else int16_t Opt_5ms; diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 7f586e35b2..1ebbd2bf17 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -126,7 +126,7 @@ static PCM_RESOLUTION pcm_type_API_to_internal( const IVAS_DEC_PCM_TYPE pcmType static void *pcm_buffer_offset( void *buffer, const IVAS_DEC_PCM_TYPE pcmType, const int32_t offset ); static ivas_error set_pcm_buffer_to_zero( void *buffer, const IVAS_DEC_PCM_TYPE pcmType, const int16_t nZeroSamples ); #endif -#ifdef REMOVE_5MS_FLAG +#ifdef NONBE_UNIFIED_DECODING_PATHS static int16_t get_render_frame_size_ms( IVAS_RENDER_FRAMESIZE render_framesize ); #endif @@ -274,7 +274,7 @@ static void init_decoder_config( #ifdef SPLIT_REND_WITH_HEAD_ROT hDecoderConfig->Opt_Limiter = 1; #endif -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS hDecoderConfig->Opt_5ms = 0; #endif hDecoderConfig->Opt_delay_comp = 0; @@ -375,7 +375,7 @@ ivas_error IVAS_DEC_Configure( const uint32_t sampleRate, /* i : output sampling frequency */ const AUDIO_CONFIG outputConfig, /* i : output configuration */ const int16_t tsmEnabled, /* i : enable time scale modification */ -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS const int16_t enable5ms, /* i : enable 5ms rendering path */ #else const IVAS_RENDER_FRAMESIZE renderFramesize, /* i : rendering frame size */ @@ -438,7 +438,7 @@ ivas_error IVAS_DEC_Configure( } hDecoderConfig->Opt_tsm = tsmEnabled; -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS hDecoderConfig->Opt_5ms = enable5ms; #endif hDecoderConfig->Opt_LsCustom = customLsOutputEnabled; @@ -452,7 +452,7 @@ ivas_error IVAS_DEC_Configure( hDecoderConfig->Opt_ExternalOrientation = enableExternalOrientation; hDecoderConfig->Opt_dpid_on = Opt_dpid_on; hDecoderConfig->Opt_aeid_on = acousticEnvironmentId != 65535 ? TRUE : FALSE; -#ifdef REMOVE_5MS_FLAG +#ifdef NONBE_UNIFIED_DECODING_PATHS if ( renderFramesize == IVAS_RENDER_FRAMESIZE_UNKNOWN ) { return IVAS_ERR_WRONG_PARAMS; @@ -513,7 +513,7 @@ ivas_error IVAS_DEC_EnableSplitRendering( hDecoderConfig = hIvasDec->st_ivas->hDecoderConfig; hDecoderConfig->Opt_Headrotation = 1; -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS hDecoderConfig->Opt_5ms = false; #else hDecoderConfig->render_framesize = IVAS_RENDER_FRAMESIZE_20MS; @@ -525,7 +525,7 @@ ivas_error IVAS_DEC_EnableSplitRendering( } #endif -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS /*---------------------------------------------------------------------* * IVAS_DEC_Set5msFlag( ) * @@ -737,7 +737,7 @@ ivas_error IVAS_DEC_EnableVoIP( hIvasDec->Opt_VOIP = 1; hDecoderConfig->Opt_tsm = 1; -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS hDecoderConfig->Opt_5ms = 1; #endif if ( hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_EXTERNAL ) @@ -888,7 +888,7 @@ ivas_error IVAS_DEC_FeedFrame_Serial( * Main function to decode to PCM data *---------------------------------------------------------------------*/ -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS static ivas_error _GetSamples( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ #ifdef SPLIT_REND_WITH_HEAD_ROT @@ -1049,7 +1049,7 @@ ivas_error IVAS_DEC_GetSamples( /* :TODO: change nSamplesAsked also if we are in 5ms 0dof split rendering... */ #endif } -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( !hIvasDec->st_ivas->hDecoderConfig->Opt_5ms ) { #ifdef SPLIT_REND_WITH_HEAD_ROT @@ -1213,7 +1213,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( numPoses = hSplitBinRend->splitrend.multiBinPoseData.num_poses; if ( -#ifdef REMOVE_5MS_FLAG +#ifdef NONBE_UNIFIED_DECODING_PATHS st_ivas->hDecoderConfig->render_framesize == IVAS_RENDER_FRAMESIZE_5MS && #else st_ivas->hDecoderConfig->Opt_5ms && @@ -1319,7 +1319,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( /* convert to int16 with limiting for BINAURAL_SPLIT_PCM */ if ( pcm_out_flag ) { -#ifdef REMOVE_5MS_FLAG +#ifdef NONBE_UNIFIED_DECODING_PATHS if ( st_ivas->hDecoderConfig->render_framesize == IVAS_RENDER_FRAMESIZE_5MS ) #else if ( st_ivas->hDecoderConfig->Opt_5ms ) @@ -3127,7 +3127,7 @@ static ivas_error printConfigInfo_dec( get_channel_config( st_ivas->hDecoderConfig->output_config, &config_str[0] ); fprintf( stdout, "Output configuration: %s\n", config_str ); -#ifdef REMOVE_5MS_FLAG +#ifdef NONBE_UNIFIED_DECODING_PATHS fprintf( stdout, "Render framesize: %dms\n", get_render_frame_size_ms( st_ivas->hDecoderConfig->render_framesize ) ); #endif if ( st_ivas->hDecoderConfig->Opt_HRTF_binary ) @@ -3195,7 +3195,7 @@ static ivas_error printConfigInfo_dec( { fprintf( stdout, "TSM mode: ON\n" ); } -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS /*-----------------------------------------------------------------* * Print 5ms API mode info *-----------------------------------------------------------------*/ @@ -3410,7 +3410,7 @@ static ivas_error evs_dec_main( if ( !st_ivas->hDecoderConfig->Opt_tsm -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS && st_ivas->hDecoderConfig->Opt_5ms #endif diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index b5ffd871a5..a68bcdf823 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -125,7 +125,7 @@ ivas_error IVAS_DEC_Configure( const uint32_t sampleRate, /* i : output sampling frequency */ const IVAS_AUDIO_CONFIG outputConfig, /* i : audio configuration */ const int16_t tsmEnabled, /* i : enable TSM */ -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS const int16_t enable5ms, /* i : enable 5ms rendering path */ #else const IVAS_RENDER_FRAMESIZE renderFramesize, /* i : rendering frame size */ @@ -309,7 +309,7 @@ ivas_error IVAS_DEC_EnableSplitRendering( ); #endif -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS ivas_error IVAS_DEC_Set5msFlag( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ const int16_t enable5ms /* i : 5ms flag */ diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 0a1fc41d10..bdfae93de9 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -313,7 +313,7 @@ ivas_error ivas_dirac_dec_init_binaural_data( #ifndef UNIFY_CHANNEL_MEM_HEAP /* allocate transport channels*/ if ( -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS st_ivas->hDecoderConfig->Opt_5ms && #endif st_ivas->hTcBuffer == NULL ) diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index dd9b0cdc9e..a28a9f08e6 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -3230,7 +3230,7 @@ static DecoderDummy *initDecoderDummy( decDummy->hDecoderConfig->nchan_out = numOutChannels; decDummy->hDecoderConfig->Opt_Headrotation = 0; decDummy->hDecoderConfig->Opt_tsm = 0; -#ifndef REMOVE_5MS_FLAG +#ifndef NONBE_UNIFIED_DECODING_PATHS decDummy->hDecoderConfig->Opt_5ms = 0; #endif decDummy->hBinRenderer = NULL; -- GitLab From 2bde0d68165687f9b19fe2f2ace24b6149a6b6ac Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Wed, 11 Oct 2023 08:11:09 +0200 Subject: [PATCH 49/49] integrate sub define into NONBE_UNIFIED_DECODING_PATHS --- lib_com/options.h | 2 -- lib_dec/ivas_init_dec.c | 4 ++-- lib_dec/ivas_sba_dec.c | 8 ++++---- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 31463df6bf..f1519f3b45 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -188,9 +188,7 @@ #define NONBE_UNIFIED_DECODING_PATHS /* FhG: unify decoding paths */ #ifdef NONBE_UNIFIED_DECODING_PATHS -#define REMOVE_5MS_FLAG /*#define UNIFY_CHANNEL_MEM_HEAP*/ -#define FIX_XXX_SBA_RS #endif /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 96e0c95b23..6b9567cb7a 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -356,7 +356,7 @@ ivas_error ivas_dec_setup( st_ivas->sba_order = st_ivas->bit_stream[num_bits_read + 1]; st_ivas->sba_order += 2 * st_ivas->bit_stream[num_bits_read]; -#ifndef FIX_XXX_SBA_RS +#ifndef NONBE_UNIFIED_DECODING_PATHS /* set Ambisonic (SBA) order used for analysis and coding */ st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order ); #endif @@ -381,7 +381,7 @@ ivas_error ivas_dec_setup( } else { -#ifdef FIX_XXX_SBA_RS +#ifdef NONBE_UNIFIED_DECODING_PATHS /* set Ambisonic (SBA) order used for analysis and coding */ st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order ); #endif diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 3879ed6894..b8c63795c3 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -122,7 +122,7 @@ ivas_error ivas_sba_dec_reconfigure( int32_t last_ivas_total_brate; int16_t num_channels, num_md_sub_frames; int16_t ch, nchan_out_buff, nchan_out_buff_old; -#ifndef FIX_XXX_SBA_RS +#ifndef NONBE_UNIFIED_DECODING_PATHS int16_t sba_analysis_order_old; #endif #ifdef JBM_FOR_OSBA @@ -144,7 +144,7 @@ ivas_error ivas_sba_dec_reconfigure( #ifdef JBM_FOR_OSBA sba_analysis_order_old_flush = st_ivas->sba_analysis_order; #endif -#ifndef FIX_XXX_SBA_RS +#ifndef NONBE_UNIFIED_DECODING_PATHS sba_analysis_order_old = ivas_sba_get_analysis_order( last_ivas_total_brate, st_ivas->sba_order ); #endif /*-----------------------------------------------------------------* @@ -152,13 +152,13 @@ ivas_error ivas_sba_dec_reconfigure( * Save old SBA high-level parameters *-----------------------------------------------------------------*/ #ifdef UNIFY_CHANNEL_MEM_HEAP -#ifdef FIX_XXX_SBA_RS +#ifdef NONBE_UNIFIED_DECODING_PATHS nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, sba_analysis_order_old_flush, last_ivas_total_brate, st_ivas->hTcBuffer->nchan_buffer_full ); #else nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, sba_analysis_order_old, last_ivas_total_brate, st_ivas->hTcBuffer->nchan_buffer_full ); #endif #else -#ifdef FIX_XXX_SBA_RS +#ifdef NONBE_UNIFIED_DECODING_PATHS nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, sba_analysis_order_old_flush, last_ivas_total_brate ); #else nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, sba_analysis_order_old, last_ivas_total_brate ); -- GitLab