From 797a55fc906374ad5c841af1b0519be740ae62b0 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Fri, 30 Sep 2022 12:52:19 +0200 Subject: [PATCH 1/2] FIX_I106_TDREND_5MS: Refactoring of new internal functions to remove dependency on decoder struct --- lib_dec/ivas_objectRenderer.c | 54 +++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/lib_dec/ivas_objectRenderer.c b/lib_dec/ivas_objectRenderer.c index eb7ee0d733..a6a3f3be70 100644 --- a/lib_dec/ivas_objectRenderer.c +++ b/lib_dec/ivas_objectRenderer.c @@ -53,8 +53,8 @@ static ivas_error TDREND_GetMix( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRenderer #endif static void TDREND_Clear_Update_flags( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd ); #ifdef FIX_I106_TDREND_5MS -static void TDREND_Update_listener_orientation( Decoder_Struct *st_ivas, const int16_t subframe_idx ); -static void TDREND_Update_object_positions( Decoder_Struct *st_ivas, float output[][L_FRAME48k] ); +static void TDREND_Update_listener_orientation( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, const int16_t headRotEnabled, const Quaternion headPosition ); +static void TDREND_Update_object_positions( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, const int16_t numSources, const IVAS_FORMAT in_format, const ISM_METADATA_HANDLE *hIsmMetaData, float output[][L_FRAME48k] ); #endif /*---------------------------------------------------------------------* @@ -342,12 +342,12 @@ void ObjRenderIVASFrame( #ifdef FIX_I106_TDREND_5MS /* Update object position(s) */ - TDREND_Update_object_positions( st_ivas, output ); + TDREND_Update_object_positions( st_ivas->hBinRendererTd, st_ivas->nchan_transport, st_ivas->ivas_format, st_ivas->hIsmMetaData, output ); for ( subframe_idx = 0; subframe_idx < MAX_PARAM_SPATIAL_SUBFRAMES; subframe_idx++ ) { /* Update the listener's location/orientation */ - TDREND_Update_listener_orientation( st_ivas, subframe_idx ); + TDREND_Update_listener_orientation( st_ivas->hBinRendererTd, st_ivas->hDecoderConfig->Opt_Headrotation, st_ivas->hHeadTrackData->Quaternions[subframe_idx] ); if ( ( st_ivas->hRenderConfig != NULL ) && ( st_ivas->hRenderConfig->roomAcoustics.late_reverb_on ) ) { @@ -510,8 +510,11 @@ static void TDREND_Clear_Update_flags( *---------------------------------------------------------------------*/ static void TDREND_Update_object_positions( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float output[][L_FRAME48k] /* i/o: SCE/MC channels */ + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o : TD Renderer handle */ + const int16_t numSources, /* i : Number of sources to render */ + const IVAS_FORMAT in_format, /* i : Format of input sources */ + const ISM_METADATA_HANDLE *hIsmMetaData, /* i : Input metadata for ISM objects */ + float output[][L_FRAME48k] /* i/o: SCE/MC channels */ ) { TDREND_DirAtten_t *DirAtten_p; @@ -520,27 +523,27 @@ static void TDREND_Update_object_positions( float Dir[3]; int16_t c_indx; - DirAtten_p = st_ivas->hBinRendererTd->DirAtten_p; + DirAtten_p = hBinRendererTd->DirAtten_p; /* For each source, write the frame data to the source object*/ c_indx = 0; - for ( nS = 0; nS < st_ivas->nchan_transport; nS++ ) + for ( nS = 0; nS < numSources; nS++ ) { - if ( !( st_ivas->ivas_format == MC_FORMAT && nS == LFE_CHANNEL ) ) /* Skip LFE for MC */ + if ( !( in_format == MC_FORMAT && nS == LFE_CHANNEL ) ) /* Skip LFE for MC */ { - st_ivas->hBinRendererTd->Sources[c_indx]->InputFrame_p = output[nS]; - st_ivas->hBinRendererTd->Sources[c_indx]->SrcRend_p->InputAvailable = TRUE; + hBinRendererTd->Sources[c_indx]->InputFrame_p = output[nS]; + hBinRendererTd->Sources[c_indx]->SrcRend_p->InputAvailable = TRUE; c_indx++; } - if ( st_ivas->ivas_format == ISM_FORMAT ) + if ( in_format == ISM_FORMAT ) { /* Update the source positions */ /* Source position and direction */ - Pos[0] = cosf( st_ivas->hIsmMetaData[nS]->elevation * PI_OVER_180 ) * cosf( st_ivas->hIsmMetaData[nS]->azimuth * PI_OVER_180 ); - Pos[1] = cosf( st_ivas->hIsmMetaData[nS]->elevation * PI_OVER_180 ) * sinf( st_ivas->hIsmMetaData[nS]->azimuth * PI_OVER_180 ); - Pos[2] = sinf( st_ivas->hIsmMetaData[nS]->elevation * PI_OVER_180 ); + Pos[0] = cosf( hIsmMetaData[nS]->elevation * PI_OVER_180 ) * cosf( hIsmMetaData[nS]->azimuth * PI_OVER_180 ); + Pos[1] = cosf( hIsmMetaData[nS]->elevation * PI_OVER_180 ) * sinf( hIsmMetaData[nS]->azimuth * PI_OVER_180 ); + Pos[2] = sinf( hIsmMetaData[nS]->elevation * PI_OVER_180 ); Dir[0] = 1.0f; Dir[1] = 0.0f; Dir[2] = 0.0f; @@ -550,11 +553,11 @@ static void TDREND_Update_object_positions( DirAtten_p->ConeOuterAngle = 360.0f; DirAtten_p->ConeOuterGain = 1.0f; - TDREND_MIX_SRC_SetPos( st_ivas->hBinRendererTd, nS, Pos ); - TDREND_MIX_SRC_SetDirAtten( st_ivas->hBinRendererTd, nS, DirAtten_p ); - TDREND_MIX_SRC_SetPlayState( st_ivas->hBinRendererTd, nS, TDREND_PLAYSTATUS_PLAYING ); + TDREND_MIX_SRC_SetPos( hBinRendererTd, nS, Pos ); + TDREND_MIX_SRC_SetDirAtten( hBinRendererTd, nS, DirAtten_p ); + TDREND_MIX_SRC_SetPlayState( hBinRendererTd, nS, TDREND_PLAYSTATUS_PLAYING ); - TDREND_MIX_SRC_SetDir( st_ivas->hBinRendererTd, nS, Dir ); + TDREND_MIX_SRC_SetDir( hBinRendererTd, nS, Dir ); } } @@ -568,8 +571,9 @@ static void TDREND_Update_object_positions( *---------------------------------------------------------------------*/ static void TDREND_Update_listener_orientation( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t subframe_idx /* i: subframe index*/ + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD Renderer handle */ + const int16_t headRotEnabled, /* i : Headrotation flag */ + const Quaternion headPosition /* i : Head Position */ ) { float Pos[3]; @@ -583,10 +587,10 @@ static void TDREND_Update_listener_orientation( Pos[1] = 0.0f; Pos[2] = 0.0f; - if ( st_ivas->hHeadTrackData != NULL ) + if ( headRotEnabled ) { /* Obtain head rotation matrix */ - QuatToRotMat( st_ivas->hHeadTrackData->Quaternions[subframe_idx], Rmat ); + QuatToRotMat( headPosition, Rmat ); /* Apply rotation matrix to looking vector [1;0;0] */ FrontVec[0] = Rmat[0][0]; FrontVec[1] = Rmat[0][1]; @@ -609,8 +613,8 @@ static void TDREND_Update_listener_orientation( } /* Set the listener position and orientation:*/ - TDREND_MIX_LIST_SetPos( st_ivas->hBinRendererTd, Pos ); - TDREND_MIX_LIST_SetOrient( st_ivas->hBinRendererTd, FrontVec, UpVec ); + TDREND_MIX_LIST_SetPos( hBinRendererTd, Pos ); + TDREND_MIX_LIST_SetOrient( hBinRendererTd, FrontVec, UpVec ); return; } -- GitLab From de3ed031e49b83ee382af97fe3a68ecc3e9eb3ee Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Fri, 30 Sep 2022 13:37:20 +0200 Subject: [PATCH 2/2] [fix] use a Quaternion pointer instead --- lib_dec/ivas_objectRenderer.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib_dec/ivas_objectRenderer.c b/lib_dec/ivas_objectRenderer.c index a6a3f3be70..f4df437487 100644 --- a/lib_dec/ivas_objectRenderer.c +++ b/lib_dec/ivas_objectRenderer.c @@ -53,7 +53,7 @@ static ivas_error TDREND_GetMix( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRenderer #endif static void TDREND_Clear_Update_flags( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd ); #ifdef FIX_I106_TDREND_5MS -static void TDREND_Update_listener_orientation( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, const int16_t headRotEnabled, const Quaternion headPosition ); +static void TDREND_Update_listener_orientation( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, const int16_t headRotEnabled, const Quaternion *headPosition ); static void TDREND_Update_object_positions( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, const int16_t numSources, const IVAS_FORMAT in_format, const ISM_METADATA_HANDLE *hIsmMetaData, float output[][L_FRAME48k] ); #endif @@ -347,7 +347,9 @@ void ObjRenderIVASFrame( for ( subframe_idx = 0; subframe_idx < MAX_PARAM_SPATIAL_SUBFRAMES; subframe_idx++ ) { /* Update the listener's location/orientation */ - TDREND_Update_listener_orientation( st_ivas->hBinRendererTd, st_ivas->hDecoderConfig->Opt_Headrotation, st_ivas->hHeadTrackData->Quaternions[subframe_idx] ); + TDREND_Update_listener_orientation( st_ivas->hBinRendererTd, + st_ivas->hDecoderConfig->Opt_Headrotation, + ( st_ivas->hHeadTrackData != NULL ) ? &st_ivas->hHeadTrackData->Quaternions[subframe_idx] : NULL ); if ( ( st_ivas->hRenderConfig != NULL ) && ( st_ivas->hRenderConfig->roomAcoustics.late_reverb_on ) ) { @@ -573,7 +575,7 @@ static void TDREND_Update_object_positions( static void TDREND_Update_listener_orientation( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD Renderer handle */ const int16_t headRotEnabled, /* i : Headrotation flag */ - const Quaternion headPosition /* i : Head Position */ + const Quaternion *headPosition /* i : Head Position */ ) { float Pos[3]; @@ -590,7 +592,7 @@ static void TDREND_Update_listener_orientation( if ( headRotEnabled ) { /* Obtain head rotation matrix */ - QuatToRotMat( headPosition, Rmat ); + QuatToRotMat( *headPosition, Rmat ); /* Apply rotation matrix to looking vector [1;0;0] */ FrontVec[0] = Rmat[0][0]; FrontVec[1] = Rmat[0][1]; -- GitLab