Commit 38d480bf authored by Archit Tamarapu's avatar Archit Tamarapu
Browse files

[fix] do not add filterbank delay for split rendering

parent 2c36836a
Loading
Loading
Loading
Loading
Loading
+27 −26
Original line number Diff line number Diff line
@@ -1272,8 +1272,10 @@ static int32_t getMaxGlobalDelayNs( IVAS_REND_CONST_HANDLE hIvasRend )
    int16_t i;
    int32_t latency_ns;
    int32_t max_latency_ns;
    bool splitPreRendCldfb;

    max_latency_ns = 0;
    splitPreRendCldfb = ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED );

    /* Compute the maximum delay across all inputs */
    for ( i = 0; i < RENDERER_MAX_ISM_INPUTS; i++ )
@@ -1300,22 +1302,10 @@ static int32_t getMaxGlobalDelayNs( IVAS_REND_CONST_HANDLE hIvasRend )
    {
        if ( hIvasRend->inputsSba[i].base.inConfig != IVAS_AUDIO_CONFIG_INVALID )
        {
            if ( hIvasRend->splitRendWrapper != NULL && hIvasRend->splitRendWrapper->hBinHrSplitPreRend != NULL )
            {
                if ( hIvasRend->hRendererConfig->split_rend_config.rendererSelection == IVAS_BIN_RENDERER_TYPE_FASTCONV )
                {
                    latency_ns = hIvasRend->inputsSba[i].cldfbRendWrapper.binaural_latency_ns;
                }
                else
                {
                    latency_ns = ( hIvasRend->inputsSba[i].crendWrapper != NULL ) ? hIvasRend->inputsSba[i].crendWrapper->binaural_latency_ns : 0;
                }
                max_latency_ns = max( max_latency_ns, latency_ns );
            }
            else if ( hIvasRend->inputsSba[i].cldfbRendWrapper.hCldfbRend != NULL )
            if ( hIvasRend->inputsSba[i].cldfbRendWrapper.hCldfbRend != NULL )
            {
                latency_ns = hIvasRend->inputsSba[i].cldfbRendWrapper.binaural_latency_ns;
                latency_ns += IVAS_FB_DEC_DELAY_NS;
                latency_ns += splitPreRendCldfb ? 0.f : IVAS_FB_DEC_DELAY_NS;
                max_latency_ns = max( max_latency_ns, latency_ns );
            }
            else
@@ -1330,7 +1320,7 @@ static int32_t getMaxGlobalDelayNs( IVAS_REND_CONST_HANDLE hIvasRend )
    {
        if ( hIvasRend->inputsMasa[i].base.inConfig != IVAS_AUDIO_CONFIG_INVALID )
        {
            latency_ns = (int32_t) ( (float) IVAS_FB_DEC_DELAY_NS + 0.5f );
            latency_ns = splitPreRendCldfb ? 0 : (int32_t) ( (float) IVAS_FB_DEC_DELAY_NS + 0.5f );
            max_latency_ns = max( max_latency_ns, latency_ns );
        }
    }
@@ -1424,7 +1414,9 @@ static ivas_error initIsmMasaRendering(
    return IVAS_ERR_OK;
}

static void setRendInputDelayIsm( void *input )
static void setRendInputDelayIsm(
    void *input,
    bool splitPreRendCldfb )
{
    int32_t latency_ns;
    input_ism *inputIsm;
@@ -1444,7 +1436,7 @@ static void setRendInputDelayIsm( void *input )
    {
        /* TODO tmu: verify what should be set for MASA prerendering */
        latency_ns = max( latency_ns,
                          (int32_t) ( (float) IVAS_FB_DEC_DELAY_NS + 0.5f ) );
                          (int32_t) ( ( splitPreRendCldfb ? 0 : (float) IVAS_FB_DEC_DELAY_NS + 0.5f ) ) );
    }

    inputIsm->base.delayNumSamples = latencyNsToSamples( *inputIsm->base.ctx.pOutSampleRate, latency_ns );
@@ -2445,7 +2437,9 @@ static lfe_routing defaultLfeRouting(
    return routing;
}

static void setRendInputDelayMc( void *input )
static void setRendInputDelayMc(
    void *input,
    bool splitPreRendCldfb )
{
    int32_t latency_ns;
    input_mc *inputMc;
@@ -2465,7 +2459,7 @@ static void setRendInputDelayMc( void *input )
    {
        /* TODO tmu: verify what should be set for MASA prerendering */
        latency_ns = max( latency_ns,
                          (int32_t) ( (float) IVAS_FB_DEC_DELAY_NS + 0.5f ) );
                          (int32_t) ( ( splitPreRendCldfb ? 0 : (float) IVAS_FB_DEC_DELAY_NS + 0.5f ) ) );
    }

    inputMc->base.delayNumSamples = latencyNsToSamples( *inputMc->base.ctx.pOutSampleRate, latency_ns );
@@ -2816,7 +2810,9 @@ static ivas_error initSbaMasaRendering(
    return IVAS_ERR_OK;
}

static void setRendInputDelaySba( void *input )
static void setRendInputDelaySba(
    void *input,
    bool splitPreRendCldfb )
{
    int32_t latency_ns;
    input_sba *inputSba;
@@ -2828,7 +2824,8 @@ static void setRendInputDelaySba( void *input )
    if ( inputSba->cldfbRendWrapper.hCldfbRend != NULL )
    {
        latency_ns = max( latency_ns,
                          inputSba->cldfbRendWrapper.binaural_latency_ns + IVAS_FB_DEC_DELAY_NS );
                          inputSba->cldfbRendWrapper.binaural_latency_ns +
                              ( splitPreRendCldfb ? 0 : IVAS_FB_DEC_DELAY_NS ) );
    }
    if ( inputSba->crendWrapper != NULL )
    {
@@ -2839,7 +2836,7 @@ static void setRendInputDelaySba( void *input )
    {
        /* TODO tmu: verify what should be set for MASA prerendering */
        latency_ns = max( latency_ns,
                          (int32_t) ( (float) IVAS_FB_DEC_DELAY_NS + 0.5f ) );
                          (int32_t) ( ( splitPreRendCldfb ? 0 : (float) IVAS_FB_DEC_DELAY_NS + 0.5f ) ) );
    }

    inputSba->base.delayNumSamples = latencyNsToSamples( *inputSba->base.ctx.pOutSampleRate, latency_ns );
@@ -2929,7 +2926,9 @@ static void clearInputSba(
    return;
}

static void setRendInputDelayMasa( void *input )
static void setRendInputDelayMasa(
    void *input,
    bool splitPreRendCldfb )
{
    int32_t latency_ns;
    input_masa *inputMasa;
@@ -2941,7 +2940,7 @@ static void setRendInputDelayMasa( void *input )
    if ( inputMasa->hMasaExtRend != NULL && inputMasa->hMasaExtRend->renderer_type != RENDERER_DISABLE )
    {
        latency_ns = max( latency_ns,
                          (int32_t) ( (float) IVAS_FB_DEC_DELAY_NS + 0.5f ) );
                          (int32_t) ( ( splitPreRendCldfb ? 0 : (float) IVAS_FB_DEC_DELAY_NS + 0.5f ) ) );
    }

    inputMasa->base.delayNumSamples = latencyNsToSamples( *inputMasa->base.ctx.pOutSampleRate, latency_ns );
@@ -3734,8 +3733,10 @@ ivas_error IVAS_REND_AddInput(
    void *inputsArray;
    int32_t inputStructSize;
    ivas_error ( *activateInput )( void *, AUDIO_CONFIG, IVAS_REND_InputId, RENDER_CONFIG_DATA *, hrtf_handles * );
    void ( *setInputDelay )( void * );
    void ( *setInputDelay )( void *, bool );
    int32_t inputIndex;
    bool splitPreRendCldfb;
    splitPreRendCldfb = ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED );

    /* Validate function arguments */
    if ( hIvasRend == NULL || inputId == NULL )
@@ -3799,7 +3800,7 @@ ivas_error IVAS_REND_AddInput(
    {
        return error;
    }
    setInputDelay( (uint8_t *) inputsArray + inputStructSize * inputIndex );
    setInputDelay( (uint8_t *) inputsArray + inputStructSize * inputIndex, splitPreRendCldfb );

    /* update global maximum delay after adding an input */
    updateMaxGlobalDelayNs( hIvasRend );