Loading lib_com/options.h +1 −0 Original line number Diff line number Diff line Loading @@ -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 ######################### */ Loading lib_rend/ivas_objectRenderer.c +242 −0 Original line number Diff line number Diff line Loading @@ -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() Loading @@ -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]; Loading @@ -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; Loading @@ -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++ ) { Loading @@ -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; } Loading Loading @@ -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() * Loading @@ -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 Loading @@ -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 ); Loading Loading @@ -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 Loading @@ -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; Loading Loading @@ -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 } /*---------------------------------------------------------------------* Loading @@ -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; Loading @@ -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" ); Loading Loading @@ -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 */ // { Loading Loading @@ -735,6 +975,8 @@ ivas_error ivas_rend_TDObjRenderFrame( // } // } #endif pop_wmops(); return IVAS_ERR_OK; Loading lib_com/ivas_prot.h +1 −1 File changed.Contains only whitespace changes. Show changes Loading
lib_com/options.h +1 −0 Original line number Diff line number Diff line Loading @@ -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 ######################### */ Loading
lib_rend/ivas_objectRenderer.c +242 −0 Original line number Diff line number Diff line Loading @@ -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() Loading @@ -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]; Loading @@ -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; Loading @@ -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++ ) { Loading @@ -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; } Loading Loading @@ -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() * Loading @@ -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 Loading @@ -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 ); Loading Loading @@ -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 Loading @@ -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; Loading Loading @@ -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 } /*---------------------------------------------------------------------* Loading @@ -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; Loading @@ -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" ); Loading Loading @@ -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 */ // { Loading Loading @@ -735,6 +975,8 @@ ivas_error ivas_rend_TDObjRenderFrame( // } // } #endif pop_wmops(); return IVAS_ERR_OK; Loading