From acabc815b17689b0a78e0bfdbce93b889913b9c0 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 27 Oct 2025 16:46:38 +0100 Subject: [PATCH 1/3] change md sync delay in ext renderer to integer type --- apps/renderer.c | 11 +++++++++++ lib_com/options.h | 1 + lib_rend/lib_rend.c | 45 ++++++++++++++++++++++++++++++++++++++++++++- lib_rend/lib_rend.h | 4 ++++ 4 files changed, 60 insertions(+), 1 deletion(-) diff --git a/apps/renderer.c b/apps/renderer.c index 69c01c28c6..e434c0ca2a 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 4c31c1480c..b92b01a6f0 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 bba3fbb187..5df2ea9230 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 / ( 1000.f / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES ) ); +#else inputIsm->ism_metadata_delay_ms = maxGlobalDelayNs / 1e6f; +#endif } } } @@ -5481,14 +5492,22 @@ static ivas_error renderIsmToBinaural( { float tmpTDRendBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; ivas_error error; +#ifndef RENDERER_MD_SYNC_DELAY_TO_INTEGER int16_t ism_md_subframe_update_ext; +#endif push_wmops( "renderIsmToBinaural" ); +#ifndef RENDERER_MD_SYNC_DELAY_TO_INTEGER /* Metadata Delay to sync with audio delay converted from ms to 5ms (1000/50/4) subframe index */ 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 ); +#ifdef RENDERER_MD_SYNC_DELAY_TO_INTEGER + if ( ( error = ivas_td_binaural_renderer_ext( &ismInput->tdRendWrapper, ismInput->base.inConfig, NULL, ismInput->base.ctx.pCombinedOrientationData, &ismInput->currentPos, ismInput->hReverb, ismInput->ism_metadata_delay_ms, +#else 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, +#endif *ismInput->base.ctx.pOutSampleRate, outAudio.config.numSamplesPerChannel, tmpTDRendBuffer ) ) != IVAS_ERR_OK ) { return error; @@ -5684,17 +5703,25 @@ static ivas_error renderIsmToBinauralReverb( { float tmpRendBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; ivas_error error; +#ifndef RENDERER_MD_SYNC_DELAY_TO_INTEGER int16_t ism_md_subframe_update_ext; +#endif push_wmops( "renderIsmToBinauralRoom" ); +#ifndef RENDERER_MD_SYNC_DELAY_TO_INTEGER /* Metadata Delay to sync with audio delay converted from ms to 5ms (1000/50/4) subframe index */ 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 ); if ( ( error = ivas_td_binaural_renderer_ext( &ismInput->tdRendWrapper, ismInput->base.inConfig, NULL, ismInput->base.ctx.pCombinedOrientationData, &ismInput->currentPos, ismInput->hReverb, +#ifdef RENDERER_MD_SYNC_DELAY_TO_INTEGER + ismInput->ism_metadata_delay_ms, *ismInput->base.ctx.pOutSampleRate, outAudio.config.numSamplesPerChannel, tmpRendBuffer ) ) != IVAS_ERR_OK ) +#else ism_md_subframe_update_ext, *ismInput->base.ctx.pOutSampleRate, outAudio.config.numSamplesPerChannel, tmpRendBuffer ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -5861,16 +5888,20 @@ static ivas_error renderIsmToSplitBinaural( float tmpBinaural_CldfbIm[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; int16_t output_frame = ismInput->base.inputBuffer.config.numSamplesPerChannel; COMBINED_ORIENTATION_HANDLE pCombinedOrientationData; +#ifndef RENDERER_MD_SYNC_DELAY_TO_INTEGER int16_t ism_md_subframe_update_ext; +#endif push_wmops( "renderIsmToSplitBinaural" ); pSplitRendWrapper = ismInput->base.ctx.pSplitRendWrapper; pMultiBinPoseData = &pSplitRendWrapper->multiBinPoseData; +#ifndef RENDERER_MD_SYNC_DELAY_TO_INTEGER /* Metadata Delay to sync with audio delay converted from ms to 5ms (1000/50/4) subframe index */ 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; if ( pMultiBinPoseData->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) @@ -5920,7 +5951,11 @@ static ivas_error renderIsmToSplitBinaural( /* Render */ if ( ( error = ivas_td_binaural_renderer_ext( ( pos_idx == 0 ) ? &ismInput->tdRendWrapper : &ismInput->splitTdRendWrappers[pos_idx - 1], ismInput->base.inConfig, NULL, ismInput->base.ctx.pCombinedOrientationData, &ismInput->currentPos, +#ifdef RENDERER_MD_SYNC_DELAY_TO_INTEGER + NULL, ismInput->ism_metadata_delay_ms, *ismInput->base.ctx.pOutSampleRate, output_frame, tmpProcessing ) ) != IVAS_ERR_OK ) +#else NULL, ism_md_subframe_update_ext, *ismInput->base.ctx.pOutSampleRate, output_frame, tmpProcessing ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -7685,7 +7720,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; @@ -7697,7 +7736,11 @@ ivas_error IVAS_REND_SetIsmMetadataDelay( for ( i = 0; i < RENDERER_MAX_ISM_INPUTS; ++i ) { +#ifdef RENDERER_MD_SYNC_DELAY_TO_INTEGER + hIvasRend->inputsIsm[i].ism_metadata_delay_ms = (int16_t) roundf( sync_md_delay / ( 1000.f / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES ) ); +#else hIvasRend->inputsIsm[i].ism_metadata_delay_ms = sync_md_delay; +#endif } return IVAS_ERR_OK; diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 2e635ad479..4d84f194f9 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( -- GitLab From 02ead286bd1a01900b313079f12b99430dbd91b7 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Wed, 29 Oct 2025 15:05:09 +0100 Subject: [PATCH 2/3] back to storing delay in milliseconds, not subframe indexes --- lib_rend/lib_rend.c | 41 +++++++++++++---------------------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 5df2ea9230..5bc8a82399 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -1525,7 +1525,7 @@ static ivas_error alignInputDelay( { 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 / ( 1000.f / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES ) ); + inputIsm->ism_metadata_delay_ms = (int16_t) roundf( inputIsm->ism_metadata_delay_ms + maxGlobalDelayNs / 1e6f ); #else inputIsm->ism_metadata_delay_ms = maxGlobalDelayNs / 1e6f; #endif @@ -5492,22 +5492,19 @@ static ivas_error renderIsmToBinaural( { float tmpTDRendBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; ivas_error error; -#ifndef RENDERER_MD_SYNC_DELAY_TO_INTEGER int16_t ism_md_subframe_update_ext; -#endif push_wmops( "renderIsmToBinaural" ); -#ifndef RENDERER_MD_SYNC_DELAY_TO_INTEGER /* 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 ); -#ifdef RENDERER_MD_SYNC_DELAY_TO_INTEGER - if ( ( error = ivas_td_binaural_renderer_ext( &ismInput->tdRendWrapper, ismInput->base.inConfig, NULL, ismInput->base.ctx.pCombinedOrientationData, &ismInput->currentPos, ismInput->hReverb, ismInput->ism_metadata_delay_ms, -#else 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, -#endif *ismInput->base.ctx.pOutSampleRate, outAudio.config.numSamplesPerChannel, tmpTDRendBuffer ) ) != IVAS_ERR_OK ) { return error; @@ -5703,25 +5700,21 @@ static ivas_error renderIsmToBinauralReverb( { float tmpRendBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; ivas_error error; -#ifndef RENDERER_MD_SYNC_DELAY_TO_INTEGER int16_t ism_md_subframe_update_ext; -#endif push_wmops( "renderIsmToBinauralRoom" ); -#ifndef RENDERER_MD_SYNC_DELAY_TO_INTEGER /* 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 ); if ( ( error = ivas_td_binaural_renderer_ext( &ismInput->tdRendWrapper, ismInput->base.inConfig, NULL, ismInput->base.ctx.pCombinedOrientationData, &ismInput->currentPos, ismInput->hReverb, -#ifdef RENDERER_MD_SYNC_DELAY_TO_INTEGER - ismInput->ism_metadata_delay_ms, *ismInput->base.ctx.pOutSampleRate, outAudio.config.numSamplesPerChannel, tmpRendBuffer ) ) != IVAS_ERR_OK ) -#else ism_md_subframe_update_ext, *ismInput->base.ctx.pOutSampleRate, outAudio.config.numSamplesPerChannel, tmpRendBuffer ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -5888,20 +5881,20 @@ static ivas_error renderIsmToSplitBinaural( float tmpBinaural_CldfbIm[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; int16_t output_frame = ismInput->base.inputBuffer.config.numSamplesPerChannel; COMBINED_ORIENTATION_HANDLE pCombinedOrientationData; -#ifndef RENDERER_MD_SYNC_DELAY_TO_INTEGER int16_t ism_md_subframe_update_ext; -#endif push_wmops( "renderIsmToSplitBinaural" ); pSplitRendWrapper = ismInput->base.ctx.pSplitRendWrapper; pMultiBinPoseData = &pSplitRendWrapper->multiBinPoseData; -#ifndef RENDERER_MD_SYNC_DELAY_TO_INTEGER /* 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; if ( pMultiBinPoseData->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) @@ -5951,11 +5944,7 @@ static ivas_error renderIsmToSplitBinaural( /* Render */ if ( ( error = ivas_td_binaural_renderer_ext( ( pos_idx == 0 ) ? &ismInput->tdRendWrapper : &ismInput->splitTdRendWrappers[pos_idx - 1], ismInput->base.inConfig, NULL, ismInput->base.ctx.pCombinedOrientationData, &ismInput->currentPos, -#ifdef RENDERER_MD_SYNC_DELAY_TO_INTEGER - NULL, ismInput->ism_metadata_delay_ms, *ismInput->base.ctx.pOutSampleRate, output_frame, tmpProcessing ) ) != IVAS_ERR_OK ) -#else NULL, ism_md_subframe_update_ext, *ismInput->base.ctx.pOutSampleRate, output_frame, tmpProcessing ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -7736,11 +7725,7 @@ ivas_error IVAS_REND_SetIsmMetadataDelay( for ( i = 0; i < RENDERER_MAX_ISM_INPUTS; ++i ) { -#ifdef RENDERER_MD_SYNC_DELAY_TO_INTEGER - hIvasRend->inputsIsm[i].ism_metadata_delay_ms = (int16_t) roundf( sync_md_delay / ( 1000.f / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES ) ); -#else hIvasRend->inputsIsm[i].ism_metadata_delay_ms = sync_md_delay; -#endif } return IVAS_ERR_OK; @@ -8005,7 +7990,7 @@ ivas_error IVAS_REND_GetSplitBinauralBitstream( Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, #endif - ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), + (const int16_t) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, -- GitLab From b9b31e1e3b3b4020b6561ea96bf0c3e97fcdd5f6 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Wed, 29 Oct 2025 15:18:08 +0100 Subject: [PATCH 3/3] clang-format --- lib_rend/lib_rend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 5bc8a82399..4bb1024aae 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -7990,7 +7990,7 @@ ivas_error IVAS_REND_GetSplitBinauralBitstream( Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, #endif - (const int16_t) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), + ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, -- GitLab