Commit acabc815 authored by Jan Kiene's avatar Jan Kiene
Browse files

change md sync delay in ext renderer to integer type

parent 8d2fe124
Loading
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -33,6 +33,9 @@
#include "lib_rend.h"
#include <assert.h>
#include <math.h>
#ifdef RENDERER_MD_SYNC_DELAY_TO_INTEGER
#include <stdint.h>
#endif
#include <string.h>
#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." );
+1 −0
Original line number Diff line number Diff line
@@ -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 ################################## */
+44 −1
Original line number Diff line number Diff line
@@ -44,6 +44,9 @@
#include <math.h>
#include <stdbool.h>
#include "wmc_auto.h"
#ifdef RENDERER_MD_SYNC_DELAY_TO_INTEGER
#include <stdint.h>
#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    */
#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;
+4 −0
Original line number Diff line number Diff line
@@ -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(