From 40a737b4d97c11c03aec57eef6244d6c5a04441a Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Tue, 14 Feb 2023 07:45:29 +0100 Subject: [PATCH 1/8] Harmonization/refactoring under FIX_198_TDREND_INTERFACE --- lib_com/ivas_prot.h | 2 +- lib_com/options.h | 1 + lib_rend/ivas_objectRenderer.c | 242 +++++++++++++++++++++++++++++++++ 3 files changed, 244 insertions(+), 1 deletion(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 6f4d27d5e8..abfc6793a8 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5087,7 +5087,7 @@ void DefaultBSplineModel( ); ivas_error ivas_td_binaural_open( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); void ivas_td_binaural_close( diff --git a/lib_com/options.h b/lib_com/options.h index 35ade80901..b565112845 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -152,6 +152,7 @@ #define FIX_197_CREND_INTERFACE #define FIX_FOR_TEST /* allows tests to pass using old TD binary file, to be removed after merge*/ #define FIX_301_PLC /* FhG: issue 301 - fix bug of missing update of overlap buffer for DFT-stereo PLC*/ +#define FIX_198_TDREND_INTERFACE /* Issue 198: Harmonize interface for TD renderer between decoder and external renderer */ /* ################## End DEVELOPMENT switches ######################### */ diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index 7c8173e222..552e3a82d8 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -60,6 +60,9 @@ static void TDREND_Update_object_positions( BINAURAL_TD_OBJECT_RENDERER_HANDLE h const IVAS_FORMAT in_format, const ISM_METADATA_HANDLE *hIsmMetaData, float output[][L_FRAME48k] ); +#ifdef FIX_198_TDREND_INTERFACE +static ivas_error ivas_td_binaural_open_unwrap( TDREND_HRFILT_FiltSet_t **hHrtfTD, const int32_t output_Fs, const int16_t nchan_transport, const IVAS_FORMAT ivas_format, const AUDIO_CONFIG transport_config, const IVAS_OUTPUT_SETUP hTransSetup, BINAURAL_TD_OBJECT_RENDERER_HANDLE *hBinRendererTd, int32_t *binaural_latency_ns ); +static void ObjRenderIVASFrame_unwrap( RENDER_CONFIG_DATA *hRenderConfig, const int16_t ini_frame, CREND_WRAPPER_HANDLE hCrendWrapper, AUDIO_CONFIG transport_config, const int32_t output_Fs, BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, const int16_t nchan_transport, IVAS_FORMAT ivas_format, ISM_METADATA_HANDLE *hIsmMetaData, const int16_t Opt_Headrotation, const IVAS_QUATERNION *Quaternions, float output[][L_FRAME48k], const int16_t output_frame ); /*---------------------------------------------------------------------* * ivas_td_binaural_open() @@ -71,7 +74,44 @@ ivas_error ivas_td_binaural_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { + return 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->hTransSetup, &st_ivas->hBinRendererTd, &st_ivas->binaural_latency_ns ); +} + + +/*---------------------------------------------------------------------* + * ivas_td_binaural_open_unwrap() + * + * Call TD open/init function without st_ivas + *---------------------------------------------------------------------*/ + +static ivas_error ivas_td_binaural_open_unwrap( + TDREND_HRFILT_FiltSet_t **hHrtfTD, /* i/o: HR filter model (from file or NULL) */ + const int32_t output_Fs, /* i : Output sampling rate */ + const int16_t nchan_transport, /* i : Number of channels */ + const IVAS_FORMAT ivas_format, /* i : IVAS format (ISM/MC) */ + const AUDIO_CONFIG transport_config, /* i : Transport configuration */ + const IVAS_OUTPUT_SETUP hTransSetup, /* i : Loudspeaker layout */ + BINAURAL_TD_OBJECT_RENDERER_HANDLE *hBinRendererTd, /* o : TD renderer handle */ + int32_t *binaural_latency_ns /* i : Binauralization delay */ +) +#else +/*---------------------------------------------------------------------* + * ivas_td_binaural_open() + * + * Open and initialize TD Object binaural renderer + *---------------------------------------------------------------------*/ + +ivas_error ivas_td_binaural_open( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +) +#endif +{ +#ifdef FIX_198_TDREND_INTERFACE + BINAURAL_TD_OBJECT_RENDERER_HANDLE pBinRendTd; +#else BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd; +#endif TDREND_PosType_t PosType; int16_t nS; int16_t SrcInd[MAX_NUM_TDREND_CHANNELS]; @@ -84,55 +124,105 @@ ivas_error ivas_td_binaural_open( error = IVAS_ERR_OK; +#ifdef FIX_198_TDREND_INTERFACE + if ( ( pBinRendTd = malloc( sizeof( BINAURAL_TD_OBJECT_RENDERER ) ) ) == NULL ) +#else if ( ( hBinRendererTd = malloc( sizeof( BINAURAL_TD_OBJECT_RENDERER ) ) ) == NULL ) +#endif { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD renderer\n" ) ); } +#ifdef FIX_198_TDREND_INTERFACE + if ( ( pBinRendTd->TdRend_MixSpatSpec_p = malloc( sizeof( TDREND_MixSpatSpec_t ) ) ) == NULL ) +#else if ( ( hBinRendererTd->TdRend_MixSpatSpec_p = malloc( sizeof( TDREND_MixSpatSpec_t ) ) ) == NULL ) +#endif { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD renderer\n" ) ); } +#ifdef FIX_198_TDREND_INTERFACE + if ( ( pBinRendTd->DirAtten_p = malloc( sizeof( TDREND_DirAtten_t ) ) ) == NULL ) +#else if ( ( hBinRendererTd->DirAtten_p = malloc( sizeof( TDREND_DirAtten_t ) ) ) == NULL ) +#endif { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD renderer\n" ) ); } +#ifdef FIX_198_TDREND_INTERFACE + if ( ( pBinRendTd->Listener_p = malloc( sizeof( TDREND_MIX_Listener_t ) ) ) == NULL ) +#else if ( ( hBinRendererTd->Listener_p = malloc( sizeof( TDREND_MIX_Listener_t ) ) ) == NULL ) +#endif { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD renderer\n" ) ); } +#ifdef FIX_198_TDREND_INTERFACE + pBinRendTd->NumOfSrcs = 0; + pBinRendTd->MaxSrcInd = -1; + + /* Mixer spatial setup */ + pBinRendTd->TdRend_MixSpatSpec_p->UseCommonDistAttenModel = TRUE; + pBinRendTd->TdRend_MixSpatSpec_p->DistAttenModel = 0; /* 0=Turned off, else use TDREND_DIST_ATTEN_MODEL_INV_DIST_CLAMPED */ +#else hBinRendererTd->NumOfSrcs = 0; hBinRendererTd->MaxSrcInd = -1; /* Mixer spatial setup */ hBinRendererTd->TdRend_MixSpatSpec_p->UseCommonDistAttenModel = TRUE; hBinRendererTd->TdRend_MixSpatSpec_p->DistAttenModel = 0; /* 0=Turned off, else use TDREND_DIST_ATTEN_MODEL_INV_DIST_CLAMPED */ +#endif +#ifdef FIX_198_TDREND_INTERFACE + TDREND_MIX_Init( pBinRendTd, hHrtfTD, pBinRendTd->TdRend_MixSpatSpec_p, output_Fs ); +#else TDREND_MIX_Init( hBinRendererTd, &st_ivas->hHrtfTD, hBinRendererTd->TdRend_MixSpatSpec_p, st_ivas->hDecoderConfig->output_Fs ); +#endif /* Set the attenuation (or can set MixSpatSpec.DistAttenModel above) */ +#ifdef FIX_198_TDREND_INTERFACE + TDREND_MIX_SetDistAttenModel( pBinRendTd, TDREND_DIST_ATTEN_MODEL_INV_DIST_CLAMPED ); +#else TDREND_MIX_SetDistAttenModel( hBinRendererTd, TDREND_DIST_ATTEN_MODEL_INV_DIST_CLAMPED ); +#endif /* Add sources to module and mixer, headphones */ PosType = TDREND_POSTYPE_ABSOLUTE; /* or TDREND_POSTYPE_RELATIVE_TO_LISTENER */ +#ifdef FIX_198_TDREND_INTERFACE + nchan_rend = nchan_transport; + if ( ivas_format == MC_FORMAT ) +#else nchan_rend = st_ivas->nchan_transport; if ( st_ivas->ivas_format == MC_FORMAT ) +#endif { nchan_rend--; /* Skip LFE channel -- added to the others */ } for ( nS = 0; nS < nchan_rend; nS++ ) { +#ifdef FIX_198_TDREND_INTERFACE + if ( ( error = TDREND_MIX_AddSrc( pBinRendTd, &SrcInd[nS], PosType ) ) != IVAS_ERR_OK ) +#else if ( ( error = TDREND_MIX_AddSrc( hBinRendererTd, &SrcInd[nS], PosType ) ) != IVAS_ERR_OK ) +#endif { return error; } } +#ifdef FIX_198_TDREND_INTERFACE + if ( ivas_format == MC_FORMAT ) +#else if ( st_ivas->ivas_format == MC_FORMAT ) +#endif { +#ifdef FIX_198_TDREND_INTERFACE + switch ( transport_config ) +#else switch ( st_ivas->transport_config ) +#endif { case AUDIO_CONFIG_5_1: ls_azimuth = ls_azimuth_CICP6; @@ -155,15 +245,24 @@ ivas_error ivas_td_binaural_open( ls_elevation = ls_elevation_CICP19; break; case AUDIO_CONFIG_LS_CUSTOM: +#ifdef FIX_198_TDREND_INTERFACE + ls_azimuth = hTransSetup.ls_azimuth; + ls_elevation = hTransSetup.ls_elevation; +#else ls_azimuth = st_ivas->hTransSetup.ls_azimuth; ls_elevation = st_ivas->hTransSetup.ls_elevation; +#endif break; default: ls_azimuth = NULL; ls_elevation = NULL; } +#ifdef FIX_198_TDREND_INTERFACE + DirAtten_p = pBinRendTd->DirAtten_p; +#else DirAtten_p = hBinRendererTd->DirAtten_p; +#endif for ( nS = 0; nS < nchan_rend; nS++ ) { @@ -180,16 +279,28 @@ ivas_error ivas_td_binaural_open( DirAtten_p->ConeOuterAngle = 360.0f; DirAtten_p->ConeOuterGain = 1.0f; +#ifdef FIX_198_TDREND_INTERFACE + TDREND_MIX_SRC_SetPos( pBinRendTd, nS, Pos ); + TDREND_MIX_SRC_SetDir( pBinRendTd, nS, Dir ); + TDREND_MIX_SRC_SetPlayState( pBinRendTd, nS, TDREND_PLAYSTATUS_PLAYING ); + TDREND_MIX_SRC_SetDirAtten( pBinRendTd, nS, DirAtten_p ); +#else TDREND_MIX_SRC_SetPos( hBinRendererTd, nS, Pos ); TDREND_MIX_SRC_SetDir( hBinRendererTd, nS, Dir ); TDREND_MIX_SRC_SetPlayState( hBinRendererTd, nS, TDREND_PLAYSTATUS_PLAYING ); TDREND_MIX_SRC_SetDirAtten( hBinRendererTd, nS, DirAtten_p ); +#endif } } +#ifdef FIX_198_TDREND_INTERFACE + *binaural_latency_ns = (int32_t) ( BINAURAL_TD_LATENCY_S * 1000000000.f ); + *hBinRendererTd = pBinRendTd; +#else st_ivas->hBinRendererTd = hBinRendererTd; st_ivas->binaural_latency_ns = (int32_t) ( BINAURAL_TD_LATENCY_S * 1000000000.f ); +#endif return error; } @@ -221,7 +332,47 @@ void ivas_td_binaural_close( return; } +#ifdef FIX_198_TDREND_INTERFACE +/*---------------------------------------------------------------------* + * ObjRenderIVASFrame() + * + * Receives the current frames for the object streams, updates metadata + * and renders the current frame. + *---------------------------------------------------------------------*/ + +void ObjRenderIVASFrame( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float output[][L_FRAME48k], /* i/o: SCE channels / Binaural synthesis */ + const int16_t output_frame /* i : output frame length */ +) +{ + ObjRenderIVASFrame_unwrap( st_ivas->hRenderConfig, st_ivas->ini_frame, st_ivas->hCrendWrapper, st_ivas->transport_config, + st_ivas->hDecoderConfig->output_Fs, st_ivas->hBinRendererTd, st_ivas->nchan_transport, st_ivas->ivas_format, + st_ivas->hIsmMetaData, st_ivas->hDecoderConfig->Opt_Headrotation, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->Quaternions : NULL, output, output_frame ); +} + +/*---------------------------------------------------------------------* + * ObjRenderIVASFrame_unwrap() + * + * Call ObjRenderIVASFrame without st_ivas. + *---------------------------------------------------------------------*/ +static void ObjRenderIVASFrame_unwrap( + RENDER_CONFIG_DATA *hRenderConfig, /*i : Renderer configuration */ + const int16_t ini_frame, /*i : Initialization frame counter */ + CREND_WRAPPER_HANDLE hCrendWrapper, /*i : Crend wrapper handle */ + AUDIO_CONFIG transport_config, /*i : Transport configuration */ + const int32_t output_Fs, /*i : Output sampling rate */ + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /*i/o: TD binaural object renderer handle */ + const int16_t nchan_transport, /*i : Transport channels (ISms) */ + IVAS_FORMAT ivas_format, /*i : IVAS format */ + ISM_METADATA_HANDLE *hIsmMetaData, /*i : ISM metadata handle */ + const int16_t Opt_Headrotation, /*i : Head rotation flag */ + const IVAS_QUATERNION *Quaternions, /*i : Head tracking data per subframe */ + float output[][L_FRAME48k], /* i/o: SCE channels / Binaural synthesis */ + const int16_t output_frame /* i : output frame length */ +) +#else /*---------------------------------------------------------------------* * ObjRenderIVASFrame() * @@ -234,19 +385,32 @@ void ObjRenderIVASFrame( float output[][L_FRAME48k], /* i/o: SCE channels / Binaural synthesis */ const int16_t output_frame /* i : output frame length */ ) +#endif { int16_t subframe_length; int16_t subframe_idx; float reverb_signal[BINAURAL_CHANNELS][L_FRAME48k]; subframe_length = output_frame / MAX_PARAM_SPATIAL_SUBFRAMES; +#ifdef FIX_198_TDREND_INTERFACE + if ( hRenderConfig != NULL ) +#else if ( st_ivas->hRenderConfig != NULL ) /* Renderer Configuration not enabled in TD standalone renderer */ +#endif { +#ifdef FIX_198_TDREND_INTERFACE + if ( hRenderConfig->roomAcoustics.late_reverb_on && ( ini_frame == 0 ) ) +#else if ( st_ivas->hRenderConfig->roomAcoustics.late_reverb_on && ( st_ivas->ini_frame == 0 ) ) +#endif { #ifdef FIX_197_CREND_INTERFACE +#ifdef FIX_198_TDREND_INTERFACE + ivas_reverb_open( &hCrendWrapper->hCrend->hReverb, transport_config, NULL, hRenderConfig, output_Fs ); +#else ivas_reverb_open( &st_ivas->hCrendWrapper->hCrend->hReverb, st_ivas->transport_config, NULL, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ); +#endif #else ivas_reverb_open( &st_ivas->hCrend->hReverb, st_ivas->transport_config, NULL, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ); #endif @@ -254,31 +418,59 @@ void ObjRenderIVASFrame( } /* Update object position(s) */ +#ifdef FIX_198_TDREND_INTERFACE + TDREND_Update_object_positions( hBinRendererTd, nchan_transport, LFE_CHANNEL, ivas_format, hIsmMetaData, output ); +#else TDREND_Update_object_positions( st_ivas->hBinRendererTd, st_ivas->nchan_transport, LFE_CHANNEL, st_ivas->ivas_format, st_ivas->hIsmMetaData, output ); +#endif for ( subframe_idx = 0; subframe_idx < MAX_PARAM_SPATIAL_SUBFRAMES; subframe_idx++ ) { /* Update the listener's location/orientation */ +#ifdef FIX_198_TDREND_INTERFACE + TDREND_Update_listener_orientation( hBinRendererTd, Opt_Headrotation, ( Quaternions != NULL ) ? &Quaternions[subframe_idx] : NULL ); +#else TDREND_Update_listener_orientation( st_ivas->hBinRendererTd, st_ivas->hDecoderConfig->Opt_Headrotation, ( st_ivas->hHeadTrackData != NULL ) ? &st_ivas->hHeadTrackData->Quaternions[subframe_idx] : NULL ); +#endif +#ifdef FIX_198_TDREND_INTERFACE + if ( ( hRenderConfig != NULL ) && ( hRenderConfig->roomAcoustics.late_reverb_on ) ) +#else if ( ( st_ivas->hRenderConfig != NULL ) && ( st_ivas->hRenderConfig->roomAcoustics.late_reverb_on ) ) +#endif { #ifdef FIX_197_CREND_INTERFACE +#ifdef FIX_198_TDREND_INTERFACE + ivas_reverb_process( hCrendWrapper->hCrend->hReverb, transport_config, 0, output, reverb_signal, subframe_idx ); +#else ivas_reverb_process( st_ivas->hCrendWrapper->hCrend->hReverb, st_ivas->transport_config, 0, output, reverb_signal, subframe_idx ); +#endif #else ivas_reverb_process( st_ivas->hCrend->hReverb, st_ivas->transport_config, 0, output, reverb_signal, subframe_idx ); #endif } /* Render subframe */ +#ifdef FIX_198_TDREND_INTERFACE + TDREND_GetMix( hBinRendererTd, output, subframe_length, subframe_idx ); +#else TDREND_GetMix( st_ivas->hBinRendererTd, output, subframe_length, subframe_idx ); +#endif } +#ifdef FIX_198_TDREND_INTERFACE + if ( hRenderConfig != NULL ) /* Renderer Configuration not enabled in TD standalone renderer */ +#else if ( st_ivas->hRenderConfig != NULL ) /* Renderer Configuration not enabled in TD standalone renderer */ +#endif { +#ifdef FIX_198_TDREND_INTERFACE + if ( hRenderConfig->roomAcoustics.late_reverb_on ) +#else if ( st_ivas->hRenderConfig->roomAcoustics.late_reverb_on ) +#endif { /* add reverb to rendered signals */ v_add( reverb_signal[0], output[0], output[0], output_frame ); @@ -501,6 +693,7 @@ ivas_error ivas_rend_TDObjRendOpen( LSSETUP_CUSTOM_STRUCT *customLsInput, const int32_t outFs ) { +#ifndef FIX_198_TDREND_INTERFACE /* TODO tmu : Based on ivas_td_binaural_open() - could be harmonized / refactored - review error handling - review hHrtfTD init @@ -513,8 +706,27 @@ ivas_error ivas_rend_TDObjRendOpen( float Pos[3]; float Dir[3]; TDREND_DirAtten_t *DirAtten_p; +#endif +#ifdef FIX_198_TDREND_INTERFACE + int16_t nchan_transport; + AUDIO_CONFIG transport_config; + IVAS_FORMAT ivas_format; + IVAS_OUTPUT_SETUP hTransSetup; +#else int16_t nchan_rend; ivas_error error; +#endif + +#ifdef FIX_198_TDREND_INTERFACE + getAudioConfigNumChannels( inConfig, &nchan_transport ); + transport_config = getIvasAudioConfigFromRendAudioConfig( inConfig ); + ivas_format = ( getAudioConfigType( inConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) ? MC_FORMAT : ISM_FORMAT; + hTransSetup.ls_azimuth = customLsInput->ls_azimuth; + hTransSetup.ls_elevation = customLsInput->ls_elevation; + + return ivas_td_binaural_open_unwrap( &pTDRend->hHrtfTD, outFs, nchan_transport, ivas_format, transport_config, hTransSetup, &pTDRend->hBinRendererTd, + &pTDRend->binaural_latency_ns ); +#else error = IVAS_ERR_OK; @@ -633,6 +845,7 @@ ivas_error ivas_rend_TDObjRendOpen( pTDRend->binaural_latency_ns = (int32_t) ( BINAURAL_TD_LATENCY_S * 1000000000.f ); return IVAS_ERR_OK; +#endif } /*---------------------------------------------------------------------* @@ -654,7 +867,9 @@ ivas_error ivas_rend_TDObjRenderFrame( ) { int16_t subframe_length; +#ifndef FIX_198_TDREND_INTERFACE int16_t subframe_idx; +#endif ISM_METADATA_HANDLE hIsmMetaData[1]; int16_t lfe_idx; int16_t num_src; @@ -662,6 +877,10 @@ ivas_error ivas_rend_TDObjRenderFrame( // float reverb_signal[BINAURAL_CHANNELS][L_FRAME48k]; IVAS_FORMAT ivas_format; IVAS_REND_AudioConfigType inConfigType; +#ifdef FIX_198_TDREND_INTERFACE + AUDIO_CONFIG transport_config; + int32_t output_Fs; +#endif push_wmops( "ivas_rend_TDObjRenderFrame" ); @@ -691,6 +910,27 @@ ivas_error ivas_rend_TDObjRenderFrame( subframe_length = output_frame / MAX_PARAM_SPATIAL_SUBFRAMES; +#ifdef FIX_198_TDREND_INTERFACE + transport_config = getIvasAudioConfigFromRendAudioConfig( inConfig ); + output_Fs = output_frame * 50; + + + ObjRenderIVASFrame_unwrap( NULL, + 1, + NULL, + transport_config, + output_Fs, + pTDRend->hBinRendererTd, + num_src, + ivas_format, + hIsmMetaData, + headRotData->headRotEnabled, + ( headRotData != NULL ) ? headRotData->headPositions : NULL, + output, + output_frame ); + +#else + /* TODO tmu : pass down renderer config struct and decide what to do about ini_frame ? */ // if ( hRenderConfig != NULL ) /* Renderer Configuration not enabled in TD standalone renderer */ // { @@ -735,6 +975,8 @@ ivas_error ivas_rend_TDObjRenderFrame( // } // } + +#endif pop_wmops(); return IVAS_ERR_OK; -- GitLab From a55c9e621b44e559965562bf39e8ffd790ef65c6 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Tue, 14 Feb 2023 08:00:33 +0100 Subject: [PATCH 2/8] Resolve merge conflict with FIX_310_TD_REND_DELAY --- lib_rend/ivas_objectRenderer.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index 7742b47e9a..c536f34be7 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -294,14 +294,19 @@ ivas_error ivas_td_binaural_open( } #ifdef FIX_198_TDREND_INTERFACE - *binaural_latency_ns = (int32_t) ( BINAURAL_TD_LATENCY_S * 1000000000.f ); *hBinRendererTd = pBinRendTd; +#ifdef FIX_310_TD_REND_DELAY + *binaural_latency_ns = (int32_t) ( ( *hBinRendererTd )->HrFiltSet_p->latency_s * 1000000000.f ); +#else + *binaural_latency_ns = (int32_t) ( BINAURAL_TD_LATENCY_S * 1000000000.f ); +#endif #else st_ivas->hBinRendererTd = hBinRendererTd; #ifdef FIX_310_TD_REND_DELAY st_ivas->binaural_latency_ns = (int32_t) ( hBinRendererTd->HrFiltSet_p->latency_s * 1000000000.f ); #else st_ivas->binaural_latency_ns = (int32_t) ( BINAURAL_TD_LATENCY_S * 1000000000.f ); +#endif #endif return error; -- GitLab From ead05636e51372d704cd0f0155398b1783baa6be Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Tue, 14 Feb 2023 08:06:09 +0100 Subject: [PATCH 3/8] Clean out unused variables in FIX_198_TDREND_INTERFACE --- lib_rend/ivas_objectRenderer.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index c536f34be7..28e7cbced1 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -877,12 +877,14 @@ ivas_error ivas_rend_TDObjRenderFrame( float output[][L_FRAME48k] /* i/o: SCE channels / Binaural synthesis */ ) { - int16_t subframe_length; #ifndef FIX_198_TDREND_INTERFACE + int16_t subframe_length; int16_t subframe_idx; #endif ISM_METADATA_HANDLE hIsmMetaData[1]; +#ifndef FIX_198_TDREND_INTERFACE int16_t lfe_idx; +#endif int16_t num_src; /* TODO tmu : pass down renderer config struct */ // float reverb_signal[BINAURAL_CHANNELS][L_FRAME48k]; @@ -896,7 +898,9 @@ ivas_error ivas_rend_TDObjRenderFrame( push_wmops( "ivas_rend_TDObjRenderFrame" ); inConfigType = getAudioConfigType( inConfig ); +#ifndef FIX_198_TDREND_INTERFACE lfe_idx = LFE_CHANNEL; +#endif if ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) { ivas_format = MC_FORMAT; @@ -906,7 +910,9 @@ ivas_error ivas_rend_TDObjRenderFrame( } else { +#ifndef FIX_198_TDREND_INTERFACE lfe_idx = ( customLsInput->num_lfe > 0 ) ? customLsInput->lfe_idx[0] : -1; +#endif num_src = customLsInput->num_spk + customLsInput->num_lfe; } } @@ -919,7 +925,9 @@ ivas_error ivas_rend_TDObjRenderFrame( hIsmMetaData[0]->elevation = currentPos->elevation; } +#ifndef FIX_198_TDREND_INTERFACE subframe_length = output_frame / MAX_PARAM_SPATIAL_SUBFRAMES; +#endif #ifdef FIX_198_TDREND_INTERFACE transport_config = getIvasAudioConfigFromRendAudioConfig( inConfig ); -- GitLab From 670132ec69e75c2062eac4c26fac656f3da78653 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Tue, 14 Feb 2023 08:25:46 +0100 Subject: [PATCH 4/8] Fix for custom LS in FIX_198_TDREND_INTERFACE --- lib_rend/ivas_objectRenderer.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index 28e7cbced1..700280101c 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -725,7 +725,18 @@ ivas_error ivas_rend_TDObjRendOpen( #endif #ifdef FIX_198_TDREND_INTERFACE - getAudioConfigNumChannels( inConfig, &nchan_transport ); + if ( inConfig != IVAS_REND_AUDIO_CONFIG_LS_CUSTOM ) + { + getAudioConfigNumChannels( inConfig, &nchan_transport ); + if ( getAudioConfigType( inConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) + { + nchan_transport--; /* Skip LFE channel -- added to the others */ + } + } + else + { + nchan_transport = customLsInput->num_spk; + } transport_config = getIvasAudioConfigFromRendAudioConfig( inConfig ); ivas_format = ( getAudioConfigType( inConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) ? MC_FORMAT : ISM_FORMAT; hTransSetup.ls_azimuth = customLsInput->ls_azimuth; -- GitLab From a21e1f328ef4c936237ccfb09ce4d20941ef52c5 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Tue, 14 Feb 2023 08:42:06 +0100 Subject: [PATCH 5/8] Fix for LFE channel in FIX_198_TDREND_INTERFACE --- lib_rend/ivas_objectRenderer.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index 700280101c..2f37b74e75 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -728,10 +728,6 @@ ivas_error ivas_rend_TDObjRendOpen( if ( inConfig != IVAS_REND_AUDIO_CONFIG_LS_CUSTOM ) { getAudioConfigNumChannels( inConfig, &nchan_transport ); - if ( getAudioConfigType( inConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) - { - nchan_transport--; /* Skip LFE channel -- added to the others */ - } } else { -- GitLab From efa70256665987b3962d507e0cd12b06f32cda4a Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Tue, 14 Feb 2023 08:56:02 +0100 Subject: [PATCH 6/8] Fix for ISm metadata handling in FIX_198_TDREND_INTERFACE --- lib_rend/ivas_objectRenderer.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index 2f37b74e75..05e04da422 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -887,10 +887,11 @@ ivas_error ivas_rend_TDObjRenderFrame( #ifndef FIX_198_TDREND_INTERFACE int16_t subframe_length; int16_t subframe_idx; -#endif ISM_METADATA_HANDLE hIsmMetaData[1]; -#ifndef FIX_198_TDREND_INTERFACE int16_t lfe_idx; +#else + ISM_METADATA_FRAME hIsmMetaDataFrame; + ISM_METADATA_HANDLE hIsmMetaData[1]; #endif int16_t num_src; /* TODO tmu : pass down renderer config struct */ @@ -907,6 +908,8 @@ ivas_error ivas_rend_TDObjRenderFrame( inConfigType = getAudioConfigType( inConfig ); #ifndef FIX_198_TDREND_INTERFACE lfe_idx = LFE_CHANNEL; +#else + hIsmMetaData[0] = NULL; #endif if ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) { @@ -927,7 +930,11 @@ ivas_error ivas_rend_TDObjRenderFrame( { ivas_format = ISM_FORMAT; num_src = 1; +#ifdef FIX_198_TDREND_INTERFACE + hIsmMetaData[0] = &hIsmMetaDataFrame; +#else hIsmMetaData[0] = malloc( sizeof( ISM_METADATA_FRAME ) ); +#endif hIsmMetaData[0]->azimuth = currentPos->azimuth; hIsmMetaData[0]->elevation = currentPos->elevation; } -- GitLab From ac4be5942797a2cccb049fc6d7425da832798c09 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Tue, 14 Feb 2023 11:29:57 +0100 Subject: [PATCH 7/8] Fix for LFE channel in external renderer in FIX_198_TDREND_INTERFACE --- lib_rend/ivas_objectRenderer.c | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index 05e04da422..05c496e7bd 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -62,7 +62,7 @@ static void TDREND_Update_object_positions( BINAURAL_TD_OBJECT_RENDERER_HANDLE h float output[][L_FRAME48k] ); #ifdef FIX_198_TDREND_INTERFACE static ivas_error ivas_td_binaural_open_unwrap( TDREND_HRFILT_FiltSet_t **hHrtfTD, const int32_t output_Fs, const int16_t nchan_transport, const IVAS_FORMAT ivas_format, const AUDIO_CONFIG transport_config, const IVAS_OUTPUT_SETUP hTransSetup, BINAURAL_TD_OBJECT_RENDERER_HANDLE *hBinRendererTd, int32_t *binaural_latency_ns ); -static void ObjRenderIVASFrame_unwrap( RENDER_CONFIG_DATA *hRenderConfig, const int16_t ini_frame, CREND_WRAPPER_HANDLE hCrendWrapper, AUDIO_CONFIG transport_config, const int32_t output_Fs, BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, const int16_t nchan_transport, IVAS_FORMAT ivas_format, ISM_METADATA_HANDLE *hIsmMetaData, const int16_t Opt_Headrotation, const IVAS_QUATERNION *Quaternions, float output[][L_FRAME48k], const int16_t output_frame ); +static void ObjRenderIVASFrame_unwrap( RENDER_CONFIG_DATA *hRenderConfig, const int16_t ini_frame, CREND_WRAPPER_HANDLE hCrendWrapper, AUDIO_CONFIG transport_config, const int32_t output_Fs, BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, const int16_t nchan_transport, const int16_t lfe_idx, IVAS_FORMAT ivas_format, ISM_METADATA_HANDLE *hIsmMetaData, const int16_t Opt_Headrotation, const IVAS_QUATERNION *Quaternions, float output[][L_FRAME48k], const int16_t output_frame ); /*---------------------------------------------------------------------* * ivas_td_binaural_open() @@ -191,7 +191,7 @@ ivas_error ivas_td_binaural_open( #ifdef FIX_198_TDREND_INTERFACE nchan_rend = nchan_transport; - if ( ivas_format == MC_FORMAT ) + if ( ( ivas_format == MC_FORMAT ) && ( transport_config != AUDIO_CONFIG_LS_CUSTOM ) ) #else nchan_rend = st_ivas->nchan_transport; if ( st_ivas->ivas_format == MC_FORMAT ) @@ -354,7 +354,7 @@ void ObjRenderIVASFrame( ) { ObjRenderIVASFrame_unwrap( st_ivas->hRenderConfig, st_ivas->ini_frame, st_ivas->hCrendWrapper, st_ivas->transport_config, - st_ivas->hDecoderConfig->output_Fs, st_ivas->hBinRendererTd, st_ivas->nchan_transport, st_ivas->ivas_format, + st_ivas->hDecoderConfig->output_Fs, st_ivas->hBinRendererTd, st_ivas->nchan_transport, LFE_CHANNEL, st_ivas->ivas_format, st_ivas->hIsmMetaData, st_ivas->hDecoderConfig->Opt_Headrotation, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->Quaternions : NULL, output, output_frame ); } @@ -372,6 +372,7 @@ static void ObjRenderIVASFrame_unwrap( const int32_t output_Fs, /*i : Output sampling rate */ BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /*i/o: TD binaural object renderer handle */ const int16_t nchan_transport, /*i : Transport channels (ISms) */ + const int16_t lfe_idx, /*i : LFE channel index */ IVAS_FORMAT ivas_format, /*i : IVAS format */ ISM_METADATA_HANDLE *hIsmMetaData, /*i : ISM metadata handle */ const int16_t Opt_Headrotation, /*i : Head rotation flag */ @@ -426,7 +427,7 @@ void ObjRenderIVASFrame( /* Update object position(s) */ #ifdef FIX_198_TDREND_INTERFACE - TDREND_Update_object_positions( hBinRendererTd, nchan_transport, LFE_CHANNEL, ivas_format, hIsmMetaData, output ); + TDREND_Update_object_positions( hBinRendererTd, nchan_transport, lfe_idx, ivas_format, hIsmMetaData, output ); #else TDREND_Update_object_positions( st_ivas->hBinRendererTd, st_ivas->nchan_transport, LFE_CHANNEL, st_ivas->ivas_format, st_ivas->hIsmMetaData, output ); #endif @@ -888,11 +889,11 @@ ivas_error ivas_rend_TDObjRenderFrame( int16_t subframe_length; int16_t subframe_idx; ISM_METADATA_HANDLE hIsmMetaData[1]; - int16_t lfe_idx; #else ISM_METADATA_FRAME hIsmMetaDataFrame; ISM_METADATA_HANDLE hIsmMetaData[1]; #endif + int16_t lfe_idx; int16_t num_src; /* TODO tmu : pass down renderer config struct */ // float reverb_signal[BINAURAL_CHANNELS][L_FRAME48k]; @@ -906,11 +907,11 @@ ivas_error ivas_rend_TDObjRenderFrame( push_wmops( "ivas_rend_TDObjRenderFrame" ); inConfigType = getAudioConfigType( inConfig ); -#ifndef FIX_198_TDREND_INTERFACE lfe_idx = LFE_CHANNEL; -#else +#ifdef FIX_198_TDREND_INTERFACE hIsmMetaData[0] = NULL; #endif + if ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) { ivas_format = MC_FORMAT; @@ -920,9 +921,7 @@ ivas_error ivas_rend_TDObjRenderFrame( } else { -#ifndef FIX_198_TDREND_INTERFACE lfe_idx = ( customLsInput->num_lfe > 0 ) ? customLsInput->lfe_idx[0] : -1; -#endif num_src = customLsInput->num_spk + customLsInput->num_lfe; } } @@ -947,20 +946,9 @@ ivas_error ivas_rend_TDObjRenderFrame( transport_config = getIvasAudioConfigFromRendAudioConfig( inConfig ); output_Fs = output_frame * 50; - - ObjRenderIVASFrame_unwrap( NULL, - 1, - NULL, - transport_config, - output_Fs, - pTDRend->hBinRendererTd, - num_src, - ivas_format, - hIsmMetaData, - headRotData->headRotEnabled, - ( headRotData != NULL ) ? headRotData->headPositions : NULL, - output, - output_frame ); + ObjRenderIVASFrame_unwrap( NULL, 1, NULL, transport_config, output_Fs, pTDRend->hBinRendererTd, num_src, lfe_idx, + ivas_format, hIsmMetaData, headRotData->headRotEnabled, ( headRotData != NULL ) ? headRotData->headPositions : NULL, + output, output_frame ); #else -- GitLab From 4cc9705fa0e2dc4f72627ff1ca53f0173383c7be Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Tue, 14 Feb 2023 11:33:55 +0100 Subject: [PATCH 8/8] Merge with main -- GitLab