diff --git a/apps/renderer.c b/apps/renderer.c index 69c01c28c66cd790deae2bc3aa0875eaf9c9a28c..e434c0ca2a2193c674c2919cf2737efab37db3ed 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -33,6 +33,9 @@ #include "lib_rend.h" #include #include +#ifdef RENDERER_MD_SYNC_DELAY_TO_INTEGER +#include +#endif #include #include "audio_file_reader.h" #include "audio_file_writer.h" @@ -189,7 +192,11 @@ typedef struct float lfeConfigElevation; bool lfeCustomRoutingEnabled; char inLfePanningMatrixFile[RENDERER_MAX_CLI_ARG_LENGTH]; +#ifdef RENDERER_MD_SYNC_DELAY_TO_INTEGER + int16_t syncMdDelay; +#else float syncMdDelay; +#endif IVAS_RENDER_FRAMESIZE render_framesize; uint16_t directivityPatternId[RENDERER_MAX_ISM_INPUTS]; AcousticEnvironmentSequence aeSequence; @@ -2844,7 +2851,11 @@ static void parseOption( case CmdLnOptionId_syncMdDelay: assert( numOptionValues == 1 ); /* Metadata Delay to sync with audio delay in ms */ +#ifdef RENDERER_MD_SYNC_DELAY_TO_INTEGER + args->syncMdDelay = (int16_t) strtol( optionValues[0], NULL, 10 ); +#else args->syncMdDelay = strtof( optionValues[0], NULL ); +#endif break; default: assert( 0 && "This should be unreachable - all command line options should be explicitly handled." ); diff --git a/lib_com/options.h b/lib_com/options.h index c33b9eba21beb15c28c21c06a280cd95275e795f..44dd030447a3f8133eb391fe0e688f618522dae2 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -169,6 +169,7 @@ #define FIX_1119_SPLIT_RENDERING_VOIP /* FhG: Add split rendering support to decoder in VoIP mode */ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define FIX_1413_IGF_INIT_PRINTOUT /* FhG: use correct variable for IGF initiliazation */ +#define RENDERER_MD_SYNC_DELAY_TO_INTEGER /* FhG: change data type of metadata sync delay in ext renderer to int16_t for better BASOP portability (and nicer code) */ /* #################### End BE switches ################################## */ diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index bba3fbb187b09ae7a0bb1502506c125efbb00b99..4bb1024aae19eae7aa5e70822b9296b8052eef83 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -44,6 +44,9 @@ #include #include #include "wmc_auto.h" +#ifdef RENDERER_MD_SYNC_DELAY_TO_INTEGER +#include +#endif /*-------------------------------------------------------------------* @@ -123,7 +126,11 @@ typedef struct OMASA_ANA_HANDLE hOMasa; uint16_t total_num_objects; int16_t object_id; +#ifdef RENDERER_MD_SYNC_DELAY_TO_INTEGER + int16_t ism_metadata_delay_ms; +#else float ism_metadata_delay_ms; +#endif } input_ism; typedef struct @@ -1517,7 +1524,11 @@ static ivas_error alignInputDelay( if ( getAudioConfigType( inputBase->inConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_OBJECT_BASED ) { inputIsm = (input_ism *) inputBase; +#ifdef RENDERER_MD_SYNC_DELAY_TO_INTEGER + inputIsm->ism_metadata_delay_ms = (int16_t) roundf( inputIsm->ism_metadata_delay_ms + maxGlobalDelayNs / 1e6f ); +#else inputIsm->ism_metadata_delay_ms = maxGlobalDelayNs / 1e6f; +#endif } } } @@ -5485,7 +5496,12 @@ static ivas_error renderIsmToBinaural( push_wmops( "renderIsmToBinaural" ); /* Metadata Delay to sync with audio delay converted from ms to 5ms (1000/50/4) subframe index */ +#ifdef RENDERER_MD_SYNC_DELAY_TO_INTEGER + ism_md_subframe_update_ext = (int16_t) roundf( ismInput->ism_metadata_delay_ms / (float) BINAURAL_RENDERING_FRAME_SIZE_MS ); +#else ism_md_subframe_update_ext = (int16_t) roundf( ismInput->ism_metadata_delay_ms / ( 1000.f / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES ) ); +#endif + copyBufferTo2dArray( ismInput->base.inputBuffer, tmpTDRendBuffer ); if ( ( error = ivas_td_binaural_renderer_ext( &ismInput->tdRendWrapper, ismInput->base.inConfig, NULL, ismInput->base.ctx.pCombinedOrientationData, &ismInput->currentPos, ismInput->hReverb, ism_md_subframe_update_ext, @@ -5689,7 +5705,11 @@ static ivas_error renderIsmToBinauralReverb( push_wmops( "renderIsmToBinauralRoom" ); /* Metadata Delay to sync with audio delay converted from ms to 5ms (1000/50/4) subframe index */ +#ifdef RENDERER_MD_SYNC_DELAY_TO_INTEGER + ism_md_subframe_update_ext = (int16_t) roundf( ismInput->ism_metadata_delay_ms / (float) BINAURAL_RENDERING_FRAME_SIZE_MS ); +#else ism_md_subframe_update_ext = (int16_t) roundf( ismInput->ism_metadata_delay_ms / ( 1000.f / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES ) ); +#endif copyBufferTo2dArray( ismInput->base.inputBuffer, tmpRendBuffer ); @@ -5869,7 +5889,11 @@ static ivas_error renderIsmToSplitBinaural( pMultiBinPoseData = &pSplitRendWrapper->multiBinPoseData; /* Metadata Delay to sync with audio delay converted from ms to 5ms (1000/50/4) subframe index */ +#ifdef RENDERER_MD_SYNC_DELAY_TO_INTEGER + ism_md_subframe_update_ext = (int16_t) roundf( ismInput->ism_metadata_delay_ms / (float) BINAURAL_RENDERING_FRAME_SIZE_MS ); +#else ism_md_subframe_update_ext = (int16_t) roundf( ismInput->ism_metadata_delay_ms / ( 1000.f / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES ) ); +#endif pCombinedOrientationData = *ismInput->base.ctx.pCombinedOrientationData; @@ -7685,7 +7709,11 @@ ivas_error IVAS_REND_SetTotalNumberOfObjects( ivas_error IVAS_REND_SetIsmMetadataDelay( IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ - const float sync_md_delay /* i : ISM Metadata Delay in ms to sync with audio delay */ +#ifdef RENDERER_MD_SYNC_DELAY_TO_INTEGER + const int16_t sync_md_delay /* i : ISM Metadata Delay in ms to sync with audio delay */ +#else + const float sync_md_delay /* i : ISM Metadata Delay in ms to sync with audio delay */ +#endif ) { int16_t i; diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 2e635ad4797c82b86a57f3c1a47504ac2f5a4f78..4d84f194f9ba18c7127b5e385a52e50de64fe3b7 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -371,7 +371,11 @@ ivas_error IVAS_REND_SetTotalNumberOfObjects( ivas_error IVAS_REND_SetIsmMetadataDelay( IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ +#ifdef RENDERER_MD_SYNC_DELAY_TO_INTEGER + const int16_t sync_md_delay /* i : Metadata Delay in ms to sync with audio delay */ +#else const float sync_md_delay /* i : Metadata Delay in ms to sync with audio delay */ +#endif ); ivas_error IVAS_REND_GetNumAllObjects(