Commit 3f5770a8 authored by TYAGIRIS's avatar TYAGIRIS
Browse files

warning fixes, delay adjustment fix

parent 3e1f61f1
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1166,7 +1166,7 @@ ivas_error ivas_renderMultiBinToSplitBinaural(
    float out[][L_FRAME48k],
	const int16_t low_res_pre_rend_rot,
#ifdef SPLIT_REND_LC3PLUS
    int8_t td_input,
    int16_t td_input,
#endif
    const int16_t pcm_out
);
+10 −7
Original line number Diff line number Diff line
@@ -1608,11 +1608,11 @@ static ivas_error split_renderer_open_lc3plus( SPLIT_REND_WRAPPER *hSplitRendWra
    /* Alocate buffers for delay compensation */
    if ( pSplitRendConfig->codec == IVAS_SPLIT_REND_CODEC_LC3PLUS )
    {
        delayBufferLength = OutSampleRate / FRAMES_PER_SECOND + hSplitRendWrapper->lc3plusDelaySamples;
        delayBufferLength = OutSampleRate / (int32_t) FRAMES_PER_SECOND + hSplitRendWrapper->lc3plusDelaySamples;
        for ( i = 0; i < hSplitRendWrapper->multiBinPoseData.num_poses * BINAURAL_CHANNELS; ++i )
        {
            hSplitRendWrapper->lc3plusDelayBuffers[i] = malloc( delayBufferLength * sizeof( float ) );
            set_zero( hSplitRendWrapper->lc3plusDelayBuffers[i], delayBufferLength );
            set_zero( hSplitRendWrapper->lc3plusDelayBuffers[i], (int16_t) delayBufferLength );
        }
    }
    else
@@ -1625,7 +1625,7 @@ static ivas_error split_renderer_open_lc3plus( SPLIT_REND_WRAPPER *hSplitRendWra
        for ( i = 0; i < hSplitRendWrapper->multiBinPoseData.num_poses * BINAURAL_CHANNELS; ++i )
        {
            hSplitRendWrapper->lc3plusDelayBuffers[i] = malloc( delayBufferLength * sizeof( float ) );
            set_zero( hSplitRendWrapper->lc3plusDelayBuffers[i], delayBufferLength );
            set_zero( hSplitRendWrapper->lc3plusDelayBuffers[i], (int16_t) delayBufferLength );
        }
    }

@@ -1644,6 +1644,7 @@ ivas_error ivas_split_renderer_open( SPLIT_REND_WRAPPER *hSplitRendWrapper,
    CLDFB_TYPE cldfbMode;
    uint8_t useLc3plus;
    uint8_t isCldfbNeeded = 0;
    cldfbMode = CLDFB_ANALYSIS;

    if ( ( error = ivas_split_rend_validate_config( pSplitRendConfig ) ) != IVAS_ERR_OK )
    {
@@ -1891,14 +1892,14 @@ static ivas_error ivas_renderMultiTDBinToSplitBinaural(

    if ( useLc3plus )
    {
        int32_t frame_size = hSplitBin->hLc3plusEnc->config.samplerate / FRAMES_PER_SECOND;
        int32_t frame_size = hSplitBin->hLc3plusEnc->config.samplerate / (int32_t) FRAMES_PER_SECOND;

        for ( i = 0; i < num_poses * BINAURAL_CHANNELS; ++i )
        {
            /* Artificially delay input to head pose correction analysis by LC3plus coding delay, so that audio and metadata are in sync after decoding */
            mvr2r( hSplitBin->lc3plusDelayBuffers[i] + frame_size, hSplitBin->lc3plusDelayBuffers[i], hSplitBin->lc3plusDelaySamples );
            mvr2r( hSplitBin->lc3plusDelayBuffers[i] + frame_size, hSplitBin->lc3plusDelayBuffers[i], (int16_t) hSplitBin->lc3plusDelaySamples );
            in_delayed[i] = hSplitBin->lc3plusDelayBuffers[i];
            mvr2r( in[i], hSplitBin->lc3plusDelayBuffers[i] + hSplitBin->lc3plusDelaySamples, frame_size );
            mvr2r( in[i], hSplitBin->lc3plusDelayBuffers[i] + hSplitBin->lc3plusDelaySamples, (int16_t) frame_size );
        }
    }
    else
@@ -1931,6 +1932,7 @@ static ivas_error ivas_renderMultiTDBinToSplitBinaural(
#endif

#ifdef SPLIT_REND_LC3PLUS
    actual_md_bits = pBits->bits_written;
    if ( hSplitBin->multiBinPoseData.poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB )
    {
        num_cldfb_bands = hSplitBin->hCldfbHandles->cldfbAna[0]->no_channels;
@@ -2093,7 +2095,7 @@ ivas_error ivas_renderMultiBinToSplitBinaural(
    float out[][L_FRAME48k],
    const int16_t low_res_pre_rend_rot,
#ifdef SPLIT_REND_LC3PLUS
    int8_t td_input,
    int16_t td_input,
#endif
    const int16_t pcm_out )
{
@@ -2129,6 +2131,7 @@ ivas_error ivas_renderMultiBinToSplitBinaural(
        lc3plusTimeAlignCldfbPoseCorr( hSplitBin, Cldfb_In_BinReal, Cldfb_In_BinImag );
    }

    actual_md_bits = pBits->bits_written;
    if ( hSplitBin->multiBinPoseData.poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB )
    {
#endif
+14 −8
Original line number Diff line number Diff line
@@ -4586,20 +4586,23 @@ ivas_error IVAS_REND_GetDelay(
        if ( hIvasRend->inputsSplitPost[i].base.inConfig != IVAS_REND_AUDIO_CONFIG_UNKNOWN )
        {
#ifdef SPLIT_REND_LC3PLUS
            latency_ns = 0;
            if ( hIvasRend->inputsSplitPost[i].splitPostRendWrapper.hLc3plusDec != NULL )
            {
                int32_t lc3plusDelaySamples;
                IVAS_LC3PLUS_DEC_GetDelay( hIvasRend->inputsSplitPost[i].splitPostRendWrapper.hLc3plusDec, &lc3plusDelaySamples );
                max_latency_ns = max( max_latency_ns, (int32_t) roundf( lc3plusDelaySamples * 1000000000.f / *timeScale ) );
                latency_ns = (int32_t) roundf( lc3plusDelaySamples * 1000000000.f / *timeScale );
            }
            else
#endif
#ifdef SPLIT_REND_LC3PLUS
            if ( hIvasRend->inputsSplitPost[i].splitPostRendWrapper.multiBinPoseData.poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB )
            {
#endif
                latency_ns = IVAS_FB_DEC_DELAY_NS;
                max_latency_ns = max( max_latency_ns, latency_ns );
                latency_ns += IVAS_FB_DEC_DELAY_NS;
#ifdef SPLIT_REND_LC3PLUS
            }
#endif
            max_latency_ns = max( max_latency_ns, latency_ns );
        }
    }
#endif
@@ -6881,7 +6884,7 @@ static ivas_error renderSplitBinauralWithPostRot(
    int16_t sf_idx;
    ivas_split_rend_bits_t bits;
    float tmpCrendBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k];
    const IVAS_REND_HeadRotData *pHeadRotData;
    COMBINED_ORIENTATION_HANDLE pCombinedOrientationData;
    SPLIT_POST_REND_WRAPPER *hSplitBin;
#ifdef SPLIT_REND_LC3PLUS
    int8_t isPostRendInputCldfb;
@@ -6893,7 +6896,7 @@ static ivas_error renderSplitBinauralWithPostRot(

    error = IVAS_ERR_OK;

    pHeadRotData = splitBinInput->base.ctx.pHeadRotData;
    pCombinedOrientationData = *splitBinInput->base.ctx.pCombinedOrientationData;
    hSplitBin = &splitBinInput->splitPostRendWrapper;
    convertBitsBufferToInternalBitsBuff( *hBits, &bits );

@@ -6924,7 +6927,7 @@ static ivas_error renderSplitBinauralWithPostRot(

    for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ )
    {
        QuaternionsPost[sf_idx] = ivas_split_rend_get_sf_rot_data( pHeadRotData->headPositions, sf_idx );
        QuaternionsPost[sf_idx] = ivas_split_rend_get_sf_rot_data( pCombinedOrientationData->Quaternions, sf_idx );
    }

#ifdef SPLIT_REND_PLC
@@ -6938,7 +6941,6 @@ static ivas_error renderSplitBinauralWithPostRot(
    if ( hSplitBin->first_good_frame_received == 1 )
    {
#endif /* SPLIT_REND_PLC */

        if ( bits.pose_correction == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB )
        {
#ifdef SPLIT_REND_PLC
@@ -6956,6 +6958,10 @@ static ivas_error renderSplitBinauralWithPostRot(
                );
            }
        }
        /*copy pose correction after MD is parsed*/
#ifdef SPLIT_REND_LC3PLUS
        hSplitBin->multiBinPoseData.poseCorrectionMode = bits.pose_correction;
#endif

        if ( splitBinInput->base.inConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_SPLIT_CLDFB )
        {