diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index ae25a9f89891d26f168388a089974cb064863d97..adfdcdbaf63ae990b0dbd2e1ebe9420ee34e6c5e 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5159,10 +5159,11 @@ void ivas_binaural_cldfb_sf( #endif void ivas_binRenderer( BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: fastconv binaural renderer handle */ - HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i/o: head track handle */ #ifdef EXTERNAL_ORIENTATIONS COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle */ int16_t subframe_idx, /* i : subframe index */ +#else + HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i/o: head track handle */ #endif const int16_t numTimeSlots, /* i: : number of time slots to process */ float Cldfb_RealBuffer_Binaural[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals */ diff --git a/lib_com/options.h b/lib_com/options.h index 0eaaeba6550fa57f6d12400e0909948deda7169f..aafa43e9af5b6de1ea997816ba41fae928c6feec 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -176,6 +176,7 @@ #define FIX_395_CNG_BW /* Eri: Issue 395 - CNG bandwidth issue for unified stereo */ #define EXTERNAL_ORIENTATIONS /* Nokia: Contribution 41: (external) orientation information handling */ +#define FIX_541_EXT_REND_MASA_ROTATIONS /* Nokia: Issue 541, rotations missing in masa external renderer */ #define MASA_PREREND /* Nokia: Contribution 42: Support for IVAS_rend to merge MASA + other format to MASA */ #define ISM_25k6_HZ_CORE /* VA: issue 540: 1ISM 48 kbps - change ACELP/TCX 16 kHz core to TCX only 25.6 kHz core */ diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index 2d196286da9039dd26b47b188750b75d22061d16..a090d1dc913d30e8ecfd8db6ae61c9c434517ef2 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -1059,7 +1059,7 @@ void ivas_binaural_cldfb( /* Implement binaural rendering */ #ifdef EXTERNAL_ORIENTATIONS - ivas_binRenderer( st_ivas->hBinRenderer, st_ivas->hHeadTrackData, st_ivas->hCombinedOrientationData, subframeIdx, JBM_CLDFB_SLOTS_IN_SUBFRAME, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); + ivas_binRenderer( st_ivas->hBinRenderer, st_ivas->hCombinedOrientationData, subframeIdx, JBM_CLDFB_SLOTS_IN_SUBFRAME, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); #else ivas_binRenderer( st_ivas->hBinRenderer, st_ivas->hHeadTrackData, JBM_CLDFB_SLOTS_IN_SUBFRAME, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); #endif @@ -1155,7 +1155,7 @@ void ivas_binaural_cldfb_sf( /* Implement binaural rendering */ #ifdef EXTERNAL_ORIENTATIONS - ivas_binRenderer( st_ivas->hBinRenderer, st_ivas->hHeadTrackData, st_ivas->hCombinedOrientationData, subframeIdx, st_ivas->hTcBuffer->subframe_nbslots[subframeIdx], Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); + ivas_binRenderer( st_ivas->hBinRenderer, st_ivas->hCombinedOrientationData, subframeIdx, st_ivas->hTcBuffer->subframe_nbslots[subframeIdx], Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); #else ivas_binRenderer( st_ivas->hBinRenderer, st_ivas->hHeadTrackData, st_ivas->hTcBuffer->subframe_nbslots[subframeIdx], Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); #endif @@ -1193,10 +1193,11 @@ void ivas_binaural_cldfb_sf( void ivas_binRenderer( BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: binaural renderer handle */ - HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i/o: head track handle */ #ifdef EXTERNAL_ORIENTATIONS COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle */ int16_t subframe_idx, /* i : subframe index */ +#else + HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i/o: head track handle */ #endif const int16_t numTimeSlots, /* i : number of time slots to render*/ float Cldfb_RealBuffer_Binaural[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals */ @@ -1221,34 +1222,37 @@ void ivas_binRenderer( } /* Head rotation in HOA3 or CICPx */ - if ( hHeadTrackData + if ( #ifdef EXTERNAL_ORIENTATIONS - && hCombinedOrientationData != NULL && hCombinedOrientationData->enableCombinedOrientation[subframe_idx] + hCombinedOrientationData != NULL && hCombinedOrientationData->enableCombinedOrientation[subframe_idx] #else - && hHeadTrackData->num_quaternions >= 0 + hHeadTrackData && hHeadTrackData->num_quaternions >= 0 #endif - && hBinRenderer->rotInCldfb ) + && hBinRenderer->rotInCldfb ) { if ( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 ) { /* Rotation in SHD (HOA3) */ - if ( hHeadTrackData->shd_rot_max_order == -1 ) - { #ifdef EXTERNAL_ORIENTATIONS + if ( hCombinedOrientationData->shd_rot_max_order == -1 ) + { rotateFrame_shd_cldfb( RealBuffer, ImagBuffer, hCombinedOrientationData->Rmat[subframe_idx], 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 ); + } #else + if ( hHeadTrackData->shd_rot_max_order == -1 ) + { QuatToRotMat( hHeadTrackData->Quaternions[hHeadTrackData->num_quaternions++], hHeadTrackData->Rmat ); rotateFrame_shd_cldfb( RealBuffer, ImagBuffer, hHeadTrackData->Rmat, hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, 3 ); -#endif } else if ( hHeadTrackData->shd_rot_max_order > 0 ) { -#ifdef EXTERNAL_ORIENTATIONS - rotateFrame_shd_cldfb( RealBuffer, ImagBuffer, hCombinedOrientationData->Rmat[subframe_idx], hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, hHeadTrackData->shd_rot_max_order ); -#else rotateFrame_shd_cldfb( RealBuffer, ImagBuffer, hHeadTrackData->Rmat, hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, hHeadTrackData->shd_rot_max_order ); -#endif } +#endif } else { diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 5877dc4738b0eaf5b30eca684f4494924b698334..0524ceef704fe3d5899aad912ed1294418f84706 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -2627,7 +2627,7 @@ void ivas_dirac_dec_render_sf( } #ifdef EXTERNAL_ORIENTATIONS - if ( st_ivas->hHeadTrackData && st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[subframe_idx] ) + if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[subframe_idx] ) #else if ( st_ivas->hHeadTrackData ) #endif @@ -2640,7 +2640,11 @@ void ivas_dirac_dec_render_sf( p_Rmat = &st_ivas->hHeadTrackData->Rmat[0][0]; #endif +#ifdef EXTERNAL_ORIENTATIONS + if ( st_ivas->hCombinedOrientationData->shd_rot_max_order == 0 ) +#else if ( st_ivas->hHeadTrackData->shd_rot_max_order == 0 ) +#endif { num_freq_bands = hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band]; #ifdef FIX_393_459_460_SBA_MD @@ -2714,7 +2718,7 @@ void ivas_dirac_dec_render_sf( } } #ifdef EXTERNAL_ORIENTATIONS - if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[subframe_idx] && st_ivas->hHeadTrackData->shd_rot_max_order == 1 ) + if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[subframe_idx] && st_ivas->hCombinedOrientationData->shd_rot_max_order == 1 ) #else if ( st_ivas->hDecoderConfig->Opt_Headrotation && st_ivas->hHeadTrackData->shd_rot_max_order == 1 ) #endif @@ -2731,7 +2735,11 @@ void ivas_dirac_dec_render_sf( #endif md_idx, surCohRatio, +#ifdef EXTERNAL_ORIENTATIONS + st_ivas->hCombinedOrientationData->shd_rot_max_order, +#else st_ivas->hHeadTrackData->shd_rot_max_order, +#endif p_Rmat, hodirac_flag ); } @@ -2821,7 +2829,7 @@ void ivas_dirac_dec_render_sf( if ( hDirAC->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) { #ifdef EXTERNAL_ORIENTATIONS - if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[subframe_idx] && st_ivas->hHeadTrackData->shd_rot_max_order == 0 ) + if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[subframe_idx] && st_ivas->hCombinedOrientationData->shd_rot_max_order == 0 ) #else if ( st_ivas->hDecoderConfig->Opt_Headrotation && st_ivas->hHeadTrackData->shd_rot_max_order == 0 ) #endif @@ -2907,7 +2915,11 @@ void ivas_dirac_dec_render_sf( #ifdef FIX_393_459_460_SBA_MD mvs2s( &hDirAC->azimuth[md_idx][hDirAC->hConfig->enc_param_start_band], &azimuth[hDirAC->hConfig->enc_param_start_band], hDirAC->num_freq_bands - hDirAC->hConfig->enc_param_start_band ); mvs2s( &hDirAC->elevation[md_idx][hDirAC->hConfig->enc_param_start_band], &elevation[hDirAC->hConfig->enc_param_start_band], hDirAC->num_freq_bands - hDirAC->hConfig->enc_param_start_band ); +#ifdef EXTERNAL_ORIENTATIONS + if ( ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) && st_ivas->hCombinedOrientationData->shd_rot_max_order == 0 ) +#else if ( st_ivas->hDecoderConfig->Opt_Headrotation && st_ivas->hHeadTrackData->shd_rot_max_order == 0 ) +#endif { num_freq_bands = hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band]; rotateAziEle_DirAC( azimuth, elevation, num_freq_bands, hDirAC->num_freq_bands, p_Rmat ); @@ -3072,7 +3084,7 @@ void ivas_dirac_dec_render_sf( /*Compute PSDs*/ #ifdef EXTERNAL_ORIENTATIONS - if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[subframe_idx] && st_ivas->hHeadTrackData->shd_rot_max_order > 0 ) + if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[subframe_idx] && st_ivas->hCombinedOrientationData->shd_rot_max_order > 0 ) #else if ( st_ivas->hDecoderConfig->Opt_Headrotation && st_ivas->hHeadTrackData->shd_rot_max_order > 0 ) #endif @@ -3089,7 +3101,11 @@ void ivas_dirac_dec_render_sf( diffuseness_vector[slot_idx], #endif hDirAC, +#ifdef EXTERNAL_ORIENTATIONS + st_ivas->hCombinedOrientationData->shd_rot_max_order, +#else st_ivas->hHeadTrackData->shd_rot_max_order, +#endif p_Rmat, st_ivas->hVBAPdata, hDirAC->hOutSetup, @@ -3241,10 +3257,11 @@ void ivas_dirac_dec_render_sf( { /* Perform binaural rendering */ ivas_binRenderer( st_ivas->hBinRenderer, - st_ivas->hHeadTrackData, #ifdef EXTERNAL_ORIENTATIONS st_ivas->hCombinedOrientationData, subframe_idx, +#else + st_ivas->hHeadTrackData, #endif hDirAC->subframe_nbslots[subframe_idx], Cldfb_RealBuffer_Binaural, diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 045e434d036c54872bbeb1fa093753f7d43630ce..36e8516e29f15b0538f3fa6cad064f1856abfb8f 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -1008,7 +1008,13 @@ 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 ) && st_ivas->hHeadTrackData == NULL ) + if ( ( st_ivas->renderer_type == RENDERER_TD_PANNING || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) && +#ifdef EXTERNAL_ORIENTATIONS + st_ivas->hCombinedOrientationData == NULL +#else + st_ivas->hHeadTrackData == NULL +#endif + ) { if ( st_ivas->hIntSetup.is_planar_setup ) { diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index 2362979ff6c795fdf640e1f638b80351467d12dc..6422c15d292eec7085790a82d8c03e4664b89bb2 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -242,8 +242,10 @@ void ivas_ism_render_sf( int16_t azimuth, elevation; int16_t tc_offset; int16_t interp_offset; - float Rmat[3][3]; float gain, prev_gain; +#ifndef EXTERNAL_ORIENTATIONS + float Rmat[3][3]; +#endif num_objects = st_ivas->nchan_transport; nchan_out_woLFE = st_ivas->hIntSetup.nchan_out_woLFE; @@ -256,11 +258,16 @@ void ivas_ism_render_sf( set_f( output_f[i], 0.0f, n_samples_to_render ); } +#ifdef EXTERNAL_ORIENTATIONS + if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] ) + { +#else if ( st_ivas->hHeadTrackData != NULL && st_ivas->hHeadTrackData->num_quaternions >= 0 ) { /* Calculate rotation matrix from the quaternion */ QuatToRotMat( st_ivas->hHeadTrackData->Quaternions[st_ivas->hHeadTrackData->num_quaternions++], Rmat ); +#endif ivas_jbm_dec_get_adapted_linear_interpolator( n_samples_to_render, n_samples_to_render, st_ivas->hIsmRendererData->interpolator ); @@ -269,10 +276,18 @@ void ivas_ism_render_sf( for ( i = 0; i < num_objects; i++ ) { + +#ifdef EXTERNAL_ORIENTATIONS + /* Combined rotation: rotate the object positions depending the head and external orientations */ + if ( st_ivas->hCombinedOrientationData != NULL && st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] == 1 ) + { + rotateAziEle( st_ivas->hIsmMetaData[i]->azimuth, st_ivas->hIsmMetaData[i]->elevation, &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[0], st_ivas->hIntSetup.is_planar_setup ); +#else /* Head rotation: rotate the object positions depending the head's orientation */ if ( st_ivas->hHeadTrackData != NULL && st_ivas->hHeadTrackData->num_quaternions >= 0 && !st_ivas->hIsmMetaData[i]->non_diegetic_flag ) { rotateAziEle( st_ivas->hIsmMetaData[i]->azimuth, st_ivas->hIsmMetaData[i]->elevation, &azimuth, &elevation, Rmat, st_ivas->hIntSetup.is_planar_setup ); +#endif if ( st_ivas->hEFAPdata != NULL ) { efap_determine_gains( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains[i], azimuth, elevation, EFAP_MODE_EFAP ); @@ -301,7 +316,11 @@ void ivas_ism_render_sf( } /* update here only in case of head rotation */ +#ifdef EXTERNAL_ORIENTATIONS + if ( st_ivas->hCombinedOrientationData != NULL && st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] == 1 ) +#else if ( st_ivas->hHeadTrackData != NULL && st_ivas->hHeadTrackData->num_quaternions >= 0 ) +#endif { st_ivas->hIsmRendererData->prev_gains[i][j] = gain; } diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 3393561c338e4e7ffebdd3a20a8b9b244e88d5f2..5cb3882e89a161fed5791c5e4d1968de45ca5a12 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -638,6 +638,18 @@ ivas_error ivas_jbm_dec_render( p_tc[n] = &st_ivas->hTcBuffer->tc[n][st_ivas->hTcBuffer->n_samples_rendered]; } +#ifdef EXTERNAL_ORIENTATIONS + /*----------------------------------------------------------------* + * Combine orientations + *----------------------------------------------------------------*/ + + if ( ( error = combine_external_and_head_orientations_dec( st_ivas->hHeadTrackData, st_ivas->hExtOrientationData, + st_ivas->hCombinedOrientationData ) ) != IVAS_ERR_OK ) + { + return error; + } +#endif + /*----------------------------------------------------------------* * Rendering *----------------------------------------------------------------*/ diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 78cdbfadc9e5d454b6c261b8a94c9c9ea90f01c0..189c94e9b2283a3b34e683ce4f5ef48dc534bd7b 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -1583,7 +1583,11 @@ void ivas_param_mc_dec_render( { nchan_out_cldfb = BINAURAL_CHANNELS; set_s( channel_active, 1, nchan_out_cldfb ); +#ifdef EXTERNAL_ORIENTATIONS + if ( st_ivas->hCombinedOrientationData ) +#else if ( st_ivas->hHeadTrackData ) +#endif { nchan_out_init = MAX_INTERN_CHANNELS; } @@ -1692,7 +1696,13 @@ void ivas_param_mc_dec_render( if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) ) { - if ( st_ivas->hHeadTrackData && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) + if ( +#ifdef EXTERNAL_ORIENTATIONS + st_ivas->hCombinedOrientationData +#else + st_ivas->hHeadTrackData +#endif + && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) { ivas_param_mc_mc2sba_cldfb( st_ivas->hTransSetup, hParamMC->hoa_encoder, slot_idx, Cldfb_RealBuffer, Cldfb_ImagBuffer, nband_synth, GAIN_LFE ); } @@ -1754,9 +1764,11 @@ void ivas_param_mc_dec_render( if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { - ivas_binRenderer( st_ivas->hBinRenderer, st_ivas->hHeadTrackData, + ivas_binRenderer( st_ivas->hBinRenderer, #ifdef EXTERNAL_ORIENTATIONS st_ivas->hCombinedOrientationData, subframe_idx, +#else + st_ivas->hHeadTrackData, #endif hParamMC->subframe_nbslots[subframe_idx], Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index 644c152c581c957e200ac4da2b82529fbeb7c481..102f0affc54bf3c0c1cc273f5f8966014c8f3709 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -89,10 +89,12 @@ ivas_error ivas_td_binaural_renderer( #ifdef EXTERNAL_ORIENTATIONS ( 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, #else st_ivas->hDecoderConfig->Opt_Headrotation, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->Quaternions : NULL, + ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->Pos : NULL, #endif - ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->Pos : NULL, ism_md_subframe_update, output, output_frame ); + ism_md_subframe_update, output, output_frame ); } @@ -185,11 +187,12 @@ ivas_error ivas_td_binaural_renderer_sf( #ifdef EXTERNAL_ORIENTATIONS ( 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 ); #else st_ivas->hDecoderConfig->Opt_Headrotation, ( st_ivas->hHeadTrackData != NULL ) ? &st_ivas->hHeadTrackData->Quaternions[0] : NULL, -#endif ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->Pos : NULL ); +#endif #ifdef FIX_196_REFACTOR_RENDERER_OUTPUT_CONFIG if ( st_ivas->hRenderConfig != NULL && st_ivas->hIntSetup.output_config == AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c index c287f68125b1e29fd7861443f1e3cadd4cb28779..7a008169f22311545a9dbb92a477dc4481e1bff5 100644 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -71,10 +71,17 @@ void ivas_renderer_select( * Binaural rendering configurations *-----------------------------------------------------------------*/ +#ifdef EXTERNAL_ORIENTATIONS + if ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) + { + st_ivas->hCombinedOrientationData->shd_rot_max_order = -1; + } +#else if ( st_ivas->hDecoderConfig->Opt_Headrotation ) { st_ivas->hHeadTrackData->shd_rot_max_order = -1; } +#endif #ifdef FIX_196_REFACTOR_RENDERER_OUTPUT_CONFIG if ( output_config == AUDIO_CONFIG_BINAURAL || output_config == AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) @@ -160,25 +167,45 @@ void ivas_renderer_select( *renderer_type = RENDERER_BINAURAL_FASTCONV_ROOM; } - if ( st_ivas->hDecoderConfig->Opt_Headrotation ) + if ( st_ivas->hDecoderConfig->Opt_Headrotation +#ifdef EXTERNAL_ORIENTATIONS + || st_ivas->hDecoderConfig->Opt_ExternalOrientation +#endif + ) { nchan_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); if ( nchan_internal == 2 ) { +#ifdef EXTERNAL_ORIENTATIONS + st_ivas->hCombinedOrientationData->shd_rot_max_order = 1; +#else st_ivas->hHeadTrackData->shd_rot_max_order = 1; +#endif } else if ( nchan_internal == 4 || nchan_internal == 3 ) { +#ifdef EXTERNAL_ORIENTATIONS + st_ivas->hCombinedOrientationData->shd_rot_max_order = 0; +#else st_ivas->hHeadTrackData->shd_rot_max_order = 0; +#endif } else if ( nchan_internal == 6 || nchan_internal == 5 ) { +#ifdef EXTERNAL_ORIENTATIONS + st_ivas->hCombinedOrientationData->shd_rot_max_order = 2; +#else st_ivas->hHeadTrackData->shd_rot_max_order = 2; +#endif } else if ( nchan_internal == 8 || nchan_internal == 7 ) { +#ifdef EXTERNAL_ORIENTATIONS + st_ivas->hCombinedOrientationData->shd_rot_max_order = 3; +#else st_ivas->hHeadTrackData->shd_rot_max_order = 3; +#endif } } } diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 2eefb0e1d388c07bc52d166bd2e03592cab3719a..36e83bf71832131e5998954b63bdf3342e241a63 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -414,7 +414,11 @@ void ivas_dirac_dec_binaural_render( for ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) { int16_t n_samples_sf = slot_size * hDirAC->subframe_nbslots[subframe_idx]; +#ifdef EXTERNAL_ORIENTATIONS ivas_dirac_dec_binaural_internal( st_ivas, st_ivas->hCombinedOrientationData, output_f_local, nchan_transport, subframe_idx ); +#else + ivas_dirac_dec_binaural_internal( st_ivas, output_f_local, nchan_transport, subframe_idx ); +#endif for ( ch = 0; ch < nchan_out; ch++ ) { output_f_local[ch] += n_samples_sf; @@ -712,7 +716,12 @@ static void ivas_dirac_dec_binaural_internal( } #ifdef FIX_511_OPTIMIZE_PARAMBIN_GAIN_FETCH - ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices( st_ivas, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, Rmat, subframe, st_ivas->hHeadTrackData && st_ivas->hHeadTrackData->num_quaternions >= 0 ); + ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices( st_ivas, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, Rmat, subframe, +#ifdef EXTERNAL_ORIENTATIONS + hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0 ); +#else + st_ivas->hHeadTrackData && st_ivas->hHeadTrackData->num_quaternions >= 0 ); +#endif #else ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices( st_ivas, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, Rmat, subframe ); #endif @@ -731,7 +740,12 @@ static void ivas_dirac_dec_binaural_internal( } #ifdef FIX_511_OPTIMIZE_PARAMBIN_GAIN_FETCH - ivas_dirac_dec_binaural_determine_processing_matrices( st_ivas, max_band_decorr, Rmat, st_ivas->hHeadTrackData && st_ivas->hHeadTrackData->num_quaternions >= 0 ); + ivas_dirac_dec_binaural_determine_processing_matrices( st_ivas, max_band_decorr, Rmat, +#ifdef EXTERNAL_ORIENTATIONS + hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0 ); +#else + st_ivas->hHeadTrackData && st_ivas->hHeadTrackData->num_quaternions >= 0 ); +#endif #else ivas_dirac_dec_binaural_determine_processing_matrices( st_ivas, max_band_decorr, Rmat ); #endif diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index 9b0059d6463ac1d3ca698f096007be4e6170fcf2..d1858ee97ffc6e658803e858d83a54c462fa3450 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -636,9 +636,10 @@ ivas_error ivas_td_binaural_renderer_ext( const TDREND_WRAPPER *pTDRend, /* i : TD Renderer wrapper structure */ const IVAS_REND_AudioConfig inConfig, /* i : Input audio configuration */ const LSSETUP_CUSTOM_STRUCT *customLsInput, /* i : Input custom loudspeaker layout */ - const IVAS_REND_HeadRotData *headRotData, /* i : Input head positions */ #ifdef EXTERNAL_ORIENTATIONS const COMBINED_ORIENTATION_HANDLE *hCombinedOrientationData, /* i : Combined head and external orientations */ +#else + const IVAS_REND_HeadRotData *headRotData, /* i : Input head positions */ #endif const IVAS_REND_AudioObjectPosition *currentPos, /* i : Object position */ const REVERB_HANDLE hReverb, /* i : Reverberator handle */ @@ -705,11 +706,13 @@ ivas_error ivas_td_binaural_renderer_ext( #ifdef EXTERNAL_ORIENTATIONS ( hCombinedOrientationData != NULL ) ? ( *hCombinedOrientationData )->enableCombinedOrientation : NULL, ( hCombinedOrientationData != NULL ) ? ( *hCombinedOrientationData )->Quaternions : NULL, + ( hCombinedOrientationData != NULL ) ? ( *hCombinedOrientationData )->listenerPos : NULL, #else headRotData->headRotEnabled, ( headRotData != NULL ) ? headRotData->headPositions : NULL, + ( headRotData != NULL ) ? headRotData->Pos : NULL, #endif - ( headRotData != NULL ) ? headRotData->Pos : NULL, ism_md_subframe_update_ext, p_output, output_frame ) ) != IVAS_ERR_OK ) + ism_md_subframe_update_ext, p_output, output_frame ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 1437efbaeef87a69026a2b6ba89ffd70f44a22b0..cf9eed56f40306cae87dddb1d404854def505179 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -246,9 +246,10 @@ ivas_error ivas_td_binaural_renderer_ext( const TDREND_WRAPPER *pTDRend, /* i : TD Renderer wrapper structure */ const IVAS_REND_AudioConfig inConfig, /* i : Input audio configuration */ const LSSETUP_CUSTOM_STRUCT *customLsInput, /* i : Input custom loudspeaker layout */ - const IVAS_REND_HeadRotData *headRotData, /* i : Input head positions */ #ifdef EXTERNAL_ORIENTATIONS const COMBINED_ORIENTATION_HANDLE *hCombinedOrientationData, /* i : Combined head and external orientations */ +#else + const IVAS_REND_HeadRotData *headRotData, /* i : Input head positions */ #endif const IVAS_REND_AudioObjectPosition *currentPos, /* i : Object position */ const REVERB_HANDLE hReverb, /* i : Reverberator handle */ @@ -888,6 +889,7 @@ ivas_error combine_external_and_head_orientations_rend( ivas_error combine_external_and_head_orientations( IVAS_QUATERNION *headRotQuaternions, /* i : quaternions for head rotation */ + IVAS_VECTOR3 *listenerPos, /* i : listener position */ int16_t numHeadRotQuaternions, /* i : number of head rotation quaternions */ EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, /* i : external orientation handle */ COMBINED_ORIENTATION_HANDLE hCombinedOrientationData /* i/o: combined orientation handle */ diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index 7ab33cec891bf979719f71f987270f3b4b217dc5..58d4c7dc089ba2b46fb9c8b4a2b8d195e90598f5 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -799,9 +799,11 @@ ivas_error ivas_combined_orientation_open( { int16_t i, j; IVAS_QUATERNION identity; + IVAS_VECTOR3 origo; identity.w = 1.0f; identity.x = identity.y = identity.z = 0.0f; + origo.x = origo.y = origo.z = 0.0f; /* Allocate handle */ if ( ( *hCombinedOrientationData = (COMBINED_ORIENTATION_HANDLE) malloc( sizeof( COMBINED_ORIENTATION_DATA ) ) ) == NULL ) @@ -827,6 +829,7 @@ ivas_error ivas_combined_orientation_open( ( *hCombinedOrientationData )->Quaternions[i] = identity; ( *hCombinedOrientationData )->Quaternions_prev_headRot[i] = identity; ( *hCombinedOrientationData )->Quaternions_prev_extOrientation[i] = identity; + ( *hCombinedOrientationData )->listenerPos[i] = origo; for ( j = 0; j < 3; j++ ) { @@ -885,6 +888,7 @@ ivas_error combine_external_and_head_orientations_dec( ) { IVAS_QUATERNION *headRotQuaternions = NULL; + IVAS_VECTOR3 *listenerPos = NULL; int16_t numHeadRotQuaternions = 0; if ( hHeadTrackData != NULL ) @@ -893,10 +897,11 @@ ivas_error combine_external_and_head_orientations_dec( if ( hHeadTrackData->num_quaternions >= 0 ) { headRotQuaternions = hHeadTrackData->Quaternions; + listenerPos = hHeadTrackData->Pos; } } - return combine_external_and_head_orientations( headRotQuaternions, numHeadRotQuaternions, hExtOrientationData, hCombinedOrientationData ); + return combine_external_and_head_orientations( headRotQuaternions, listenerPos, numHeadRotQuaternions, hExtOrientationData, hCombinedOrientationData ); } @@ -913,6 +918,7 @@ ivas_error combine_external_and_head_orientations_rend( ) { IVAS_QUATERNION *headRotQuaternions = NULL; + IVAS_VECTOR3 *listenerPos = NULL; int16_t numHeadRotQuaternions = 0; int16_t i; @@ -921,6 +927,7 @@ ivas_error combine_external_and_head_orientations_rend( if ( hHeadTrackData->headRotEnabled ) { headRotQuaternions = hHeadTrackData->headPositions; + listenerPos = hHeadTrackData->Pos; } } else if ( hExtOrientationData != NULL ) @@ -935,7 +942,7 @@ ivas_error combine_external_and_head_orientations_rend( } } - return combine_external_and_head_orientations( headRotQuaternions, numHeadRotQuaternions, hExtOrientationData, hCombinedOrientationData ); + return combine_external_and_head_orientations( headRotQuaternions, listenerPos, numHeadRotQuaternions, hExtOrientationData, hCombinedOrientationData ); } @@ -948,6 +955,7 @@ ivas_error combine_external_and_head_orientations_rend( ivas_error combine_external_and_head_orientations( IVAS_QUATERNION *headRotQuaternions, /* i : quaternions for head rotation */ + IVAS_VECTOR3 *listenerPos, /* i : listener position */ int16_t numHeadRotQuaternions, /* i : number of head rotation quaternions */ EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, /* i : external orientation handle */ COMBINED_ORIENTATION_HANDLE hCombinedOrientationData /* i/o: combined orientation handle */ @@ -955,9 +963,11 @@ ivas_error combine_external_and_head_orientations( { int16_t i, j; IVAS_QUATERNION identity; + IVAS_VECTOR3 origo; identity.w = 1.0f; identity.x = identity.y = identity.z = 0.0f; + origo.x = origo.y = origo.z = 0.0f; /* Form combined orientations or return if no data available */ if ( hCombinedOrientationData == NULL ) @@ -983,6 +993,7 @@ ivas_error combine_external_and_head_orientations( { hCombinedOrientationData->enableCombinedOrientation[i] = 0; hCombinedOrientationData->Quaternions[i] = identity; + hCombinedOrientationData->listenerPos[i] = origo; for ( j = 0; j < 3; j++ ) { @@ -1131,6 +1142,7 @@ ivas_error combine_external_and_head_orientations( hCombinedOrientationData->Quaternions_prev_headRot[i] = identity; } } + hCombinedOrientationData->listenerPos[i] = listenerPos[i]; } } diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 3935bc63bcdd21cbbcaaa400aa9efafa917d1eb6..c99ab168bd9eb57f25cdea7b4ca11086ba2e9a61 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -315,6 +315,8 @@ typedef struct ivas_combined_orientation_struct float Rmat_prev[3][3]; float chEneIIR[2][MASA_FREQUENCY_BANDS]; /* independent of the format. MASA bands are suitable for the task and readily available in ROM. */ float procChEneIIR[2][MASA_FREQUENCY_BANDS]; + int16_t shd_rot_max_order; + IVAS_VECTOR3 listenerPos[MAX_PARAM_SPATIAL_SUBFRAMES]; } COMBINED_ORIENTATION_DATA, *COMBINED_ORIENTATION_HANDLE; #endif diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index cf427c585646347749059d0e3ffb3137bbf462f6..08f6536249901c44f817ddfef6223624bbcfeda9 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -4878,9 +4878,10 @@ static ivas_error renderIsmToBinaural( if ( ( error = ivas_td_binaural_renderer_ext( &ismInput->tdRendWrapper, ismInput->base.inConfig, NULL, - ismInput->base.ctx.pHeadRotData, #ifdef EXTERNAL_ORIENTATIONS ismInput->base.ctx.pCombinedOrientationData, +#else + ismInput->base.ctx.pHeadRotData, #endif &ismInput->currentPos, ismInput->hReverb, @@ -4962,9 +4963,10 @@ static ivas_error renderIsmToBinauralRoom( if ( ( error = ivas_td_binaural_renderer_ext( &ismInput->tdRendWrapper, ismInput->base.inConfig, NULL, - ismInput->base.ctx.pHeadRotData, #ifdef EXTERNAL_ORIENTATIONS ismInput->base.ctx.pCombinedOrientationData, +#else + ismInput->base.ctx.pHeadRotData, #endif &ismInput->currentPos, ismInput->hReverb, @@ -5141,9 +5143,10 @@ static ivas_error renderIsmToBinauralReverb( if ( ( error = ivas_td_binaural_renderer_ext( &ismInput->tdRendWrapper, ismInput->base.inConfig, NULL, - ismInput->base.ctx.pHeadRotData, #ifdef EXTERNAL_ORIENTATIONS ismInput->base.ctx.pCombinedOrientationData, +#else + ismInput->base.ctx.pHeadRotData, #endif &ismInput->currentPos, ismInput->hReverb, @@ -5493,9 +5496,11 @@ static ivas_error renderMcToBinaural( { copyBufferTo2dArray( mcInput->base.inputBuffer, tmpRendBuffer ); - if ( ( error = ivas_td_binaural_renderer_ext( &mcInput->tdRendWrapper, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, + if ( ( error = ivas_td_binaural_renderer_ext( &mcInput->tdRendWrapper, mcInput->base.inConfig, &mcInput->customLsInput, #ifdef EXTERNAL_ORIENTATIONS mcInput->base.ctx.pCombinedOrientationData, +#else + mcInput->base.ctx.pHeadRotData, #endif NULL, mcInput->hReverb, mcInput->base.inputBuffer.config.numSamplesPerChannel, tmpRendBuffer ) ) != IVAS_ERR_OK ) @@ -5618,9 +5623,11 @@ static ivas_error renderMcToBinauralRoom( { copyBufferTo2dArray( mcInput->base.inputBuffer, tmpRendBuffer ); - if ( ( error = ivas_td_binaural_renderer_ext( &mcInput->tdRendWrapper, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, + if ( ( error = ivas_td_binaural_renderer_ext( &mcInput->tdRendWrapper, mcInput->base.inConfig, &mcInput->customLsInput, #ifdef EXTERNAL_ORIENTATIONS mcInput->base.ctx.pCombinedOrientationData, +#else + mcInput->base.ctx.pHeadRotData, #endif NULL, mcInput->hReverb, mcInput->base.inputBuffer.config.numSamplesPerChannel, tmpRendBuffer ) ) != IVAS_ERR_OK ) { @@ -6612,6 +6619,9 @@ static ivas_error renderActiveInputsMasa( int16_t i; input_masa *pCurrentInput; ivas_error error; +#ifdef FIX_541_EXT_REND_MASA_ROTATIONS + int16_t sf_idx; +#endif for ( i = 0, pCurrentInput = hIvasRend->inputsMasa; i < RENDERER_MAX_MASA_INPUTS; ++i, ++pCurrentInput ) { @@ -6621,6 +6631,17 @@ static ivas_error renderActiveInputsMasa( continue; } +#ifdef FIX_541_EXT_REND_MASA_ROTATIONS + if ( getAudioConfigType( hIvasRend->outputConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL && pCurrentInput->decDummy->hHeadTrackData != NULL ) + { + for ( sf_idx = 0; sf_idx < RENDERER_HEAD_POSITIONS_PER_FRAME; ++sf_idx ) + { + pCurrentInput->decDummy->hHeadTrackData->Quaternions[sf_idx] = hIvasRend->headRotData.headPositions[sf_idx]; + pCurrentInput->decDummy->hHeadTrackData->Pos[sf_idx] = hIvasRend->headRotData.Pos[sf_idx]; + } + } +#endif + if ( ( error = renderInputMasa( pCurrentInput, hIvasRend->outputConfig, outAudio ) ) != IVAS_ERR_OK ) { return error;