Commit 0e1e6e96 authored by norvell's avatar norvell
Browse files

Correct delay compensation in standalone renderer with FIX_ITD

parent 7f9f24a4
Loading
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -115,7 +115,9 @@ int main( int argc, char *argv[] )
{
    int16_t nFrameLength;
    int16_t n, nS, nSamplesRead, i, j;
#ifndef FIX_ITD
    int16_t offset;
#endif

    float *MixFrame;
    float output[MAX_CICP_CHANNELS][L_FRAME48k];
@@ -433,6 +435,8 @@ int main( int argc, char *argv[] )
        /* Apply limiter */
        ivas_limiter_dec( st_ivas->hLimiter, output, st_ivas->hDecoderConfig->nchan_out, nFrameLength, FALSE );

        
#ifndef FIX_ITD
        /* Trim first frame to compensate for delay */
        if ( nFrameCount == 0 )
        {
@@ -442,16 +446,29 @@ int main( int argc, char *argv[] )
        {
            offset = 0;
        }
#endif

        /* For Wav: Interleave, convert to int16_t */
#ifdef FIX_ITD
        for ( n = 0; n < currFrameLength; n++ )
#else
        for ( n = 0; n < ( currFrameLength - offset ); n++ )
#endif
        {
            for ( nS = 0; nS < NumLdspks; nS++ )
            {
#ifdef FIX_ITD
                MixFrameWav[n * NumLdspks + nS] = (int16_t) ( output[nS][n] + 0.5f * sign( output[nS][n] ) );
#else
                MixFrameWav[n * NumLdspks + nS] = (int16_t) ( output[nS][n + offset] + 0.5f * sign( output[nS][n + offset] ) );
#endif
            }
        }
#ifdef FIX_ITD
        fwrite( MixFrameWav, sizeof( int16_t ), ( currFrameLength ) * NumLdspks, f_output );
#else
        fwrite( MixFrameWav, sizeof( int16_t ), ( currFrameLength - offset ) * NumLdspks, f_output );
#endif

        nFrameCount++;