Commit ca04c29f authored by bayers's avatar bayers
Browse files

Merge branch '499-head-tracking-api-causes-extra-15ms-of-delay' of...

Merge branch '499-head-tracking-api-causes-extra-15ms-of-delay' of forge.3gpp.org:ivas-codec-pc/ivas-codec into 500-head-tracking-api-causes-extra-15ms-of-delay
parents 3ff239a9 2d5a15a3
Loading
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -2350,12 +2350,16 @@ static ivas_error decodeG192(
#ifdef SPLIT_REND_WITH_HEAD_ROT
            if ( arg.outputFormat == IVAS_DEC_OUTPUT_SPLIT_BINAURAL_CODED || arg.outputFormat == IVAS_DEC_OUTPUT_SPLIT_BINAURAL_PCM )
            {
                error = IVAS_DEC_GetSplitBinauralBitstream( hIvasDec, &splitRendBits, &nSamplesRendered_loop, &needNewFrame );
                error = IVAS_DEC_GetSplitBinauralBitstream( hIvasDec,
                                                            (void *) ( pcmBuf + nOutChannels * nSamplesRendered ),
                                                            &splitRendBits,
                                                            &nSamplesRendered_loop,
                                                            &needNewFrame );
                nSamplesRendered += nSamplesRendered_loop;
                nSamplesToRender -= nSamplesRendered_loop;
                if ( error != IVAS_ERR_OK )
                {
                    fprintf( stderr, "\nError in IVAS_DEC_GetSplitBinaural: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                    fprintf( stderr, "\nError in IVAS_DEC_GetSplitBinauralBitstream: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                    goto cleanup;
                }
            }
@@ -2374,7 +2378,7 @@ static ivas_error decodeG192(
                nSamplesToRender -= nSamplesRendered_loop;
                if ( error != IVAS_ERR_OK )
                {
                    fprintf( stderr, "\nError in IVAS_DEC_VoIP_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                    fprintf( stderr, "\nError in IVAS_DEC_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                    goto cleanup;
                }
#ifdef SPLIT_REND_WITH_HEAD_ROT
+16 −14
Original line number Diff line number Diff line
@@ -1868,25 +1868,27 @@ int main(
#ifdef API_5MS
            if ( splitBinNeedsNewFrame )
            {
                if ( ( error = IVAS_REND_FeedSplitBinauralBitstream( hIvasRend, splitBinIds[i], &bitsBuffer ) ) != IVAS_ERR_OK )
#endif
                if ( ( error = IVAS_REND_GetInputNumChannels( hIvasRend, splitBinIds[i], &numChannels ) ) != IVAS_ERR_OK )
                {
                    fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) );
                    exit( -1 );
                }
            }
#else
            if ( ( error = IVAS_REND_GetInputNumChannels( hIvasRend, splitBinIds[i], &numChannels ) ) != IVAS_ERR_OK )
                IVAS_REND_ReadOnlyAudioBuffer tmpBuffer = getReadOnlySubBuffer( inBuffer, (int16_t) args.inConfig.binBuses[i].inputChannelIndex, numChannels );

                if ( ( error = IVAS_REND_FeedInputAudio( hIvasRend, splitBinIds[i], tmpBuffer ) ) != IVAS_ERR_OK )
                {
                    fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) );
                    exit( -1 );
                }
            IVAS_REND_ReadOnlyAudioBuffer tmpBuffer = getReadOnlySubBuffer( inBuffer, (int16_t) args.inConfig.binBuses[i].inputChannelIndex, numChannels );

            if ( ( error = IVAS_REND_FeedInputAudio( hIvasRend, splitBinIds[i], tmpBuffer ) ) != IVAS_ERR_OK )
                if ( ( error = IVAS_REND_FeedSplitBinauralBitstream( hIvasRend, splitBinIds[i], &bitsBuffer ) ) != IVAS_ERR_OK )
                {
                    fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) );
                    exit( -1 );
                }
#ifdef API_5MS
            }
#endif
        }
#endif
@@ -1903,7 +1905,7 @@ int main(
        else if ( args.outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ||
                  args.outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
        {
            if ( ( error = IVAS_REND_GetSplitBinauralBitstream( hIvasRend, &bitsBuffer ) ) != IVAS_ERR_OK )
            if ( ( error = IVAS_REND_GetSplitBinauralBitstream( hIvasRend, outBuffer, &bitsBuffer ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) );
                exit( -1 );
+18 −4
Original line number Diff line number Diff line
@@ -1277,6 +1277,7 @@ ivas_error IVAS_DEC_GetSamples(
#if defined API_5MS && defined SPLIT_REND_WITH_HEAD_ROT
ivas_error IVAS_DEC_GetSplitBinauralBitstream(
    IVAS_DEC_HANDLE hIvasDec,                   /* i/o: IVAS decoder handle                                                     */
    void *pcmBuf_out,                           /* o  : output synthesis signal for BINAURAL_SPLIT_PCM                          */
    IVAS_SPLIT_REND_BITS_HANDLE hSplitRendBits, /* o : bitstream output for split rendering mode*/
    int16_t *nOutSamples,                       /* o  : number of samples per channel written to output buffer                  */
    bool *needNewFrame                          /* indication that the decoder needs a new frame                                */
@@ -1287,9 +1288,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream(
    int32_t output_Fs;
    float *writePtr;
    float *readPtr, *readEnd;
#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP
    float *pOutput[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES];
#endif
    float output[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES][L_FRAME48k];
    float pcmBuf[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES * L_FRAME48k];
    int16_t numSamplesPerChannelCacheSize;
@@ -1398,12 +1397,10 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream(
            output[j][i] = pcmBuf[i * BINAURAL_CHANNELS * numPoses + j];
        }
    }
#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP
    for ( i = 0; i < BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES; ++i )
    {
        pOutput[i] = output[i];
    }
#endif
    max_band = (int16_t) ( ( BINAURAL_MAXBANDS * output_Fs ) / 48000 );
    pcm_out = ( output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0;
    td_input = st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM && st_ivas->renderer_type != RENDERER_STEREO_PARAMETRIC;
@@ -1432,6 +1429,23 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream(
        return error;
    }

    /* convert to int16 with limiting for BINAURAL_SPLIT_PCM */
    if ( pcm_out )
    {
#ifndef DISABLE_LIMITER
        ivas_limiter_dec( st_ivas->hLimiter, pOutput,
                          st_ivas->hDecoderConfig->nchan_out,
                          numSamplesPerChannelToSplitEncode, st_ivas->BER_detect );
#endif

#ifdef DEBUGGING
        st_ivas->noClipping +=
#endif
            ivas_syn_output( pOutput, numSamplesPerChannelToSplitEncode,
                             st_ivas->hDecoderConfig->nchan_out,
                             (int16_t *) pcmBuf_out );
    }

    free( st_ivas->splitBinRend.hMultiBinCldfbData );

    return error;
+2 −1
Original line number Diff line number Diff line
@@ -221,6 +221,7 @@ ivas_error IVAS_DEC_GetSamples(
#if defined API_5MS && defined SPLIT_REND_WITH_HEAD_ROT
ivas_error IVAS_DEC_GetSplitBinauralBitstream(
    IVAS_DEC_HANDLE hIvasDec,    /* i/o: IVAS decoder handle                                                     */
    void *pcmBuf_out,                            /* o  : output synthesis signal for BINAURAL_SPLIT_PCM          */
    IVAS_SPLIT_REND_BITS_HANDLE hSplitRendBits,  /* o : bitstream output for split rendering mode                */
    int16_t *nOutSamples,        /* o  : number of samples per channel written to output buffer                  */
    bool *needNewFrame           /* indication that the decoder needs a new frame                                */
+8 −11
Original line number Diff line number Diff line
@@ -9348,9 +9348,7 @@ ivas_error IVAS_REND_GetSamples(
    int16_t numOutChannels;
#ifdef SPLIT_REND_WITH_HEAD_ROT
    int16_t cldfb2tdSampleFact;
#ifndef API_5MS
    IVAS_REND_AudioBuffer outAudioOrig;
#endif
#endif

    /* Validate function arguments */
@@ -9440,17 +9438,15 @@ ivas_error IVAS_REND_GetSamples(


#ifdef SPLIT_REND_WITH_HEAD_ROT
#ifndef API_5MS
    outAudioOrig = outAudio;
#endif
    /* Use internal buffer if outputting split rendering bitstream */
    if ( ( hIvasRend->outputConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ||
         ( hIvasRend->outputConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
    {
        int16_t num_poses_orig;
        num_poses_orig = hIvasRend->splitRendWrapper.multiBinPoseData.num_poses;
#ifndef API_5MS
        outAudio = hIvasRend->splitRendEncBuffer;
#ifndef API_5MS
        if ( ( outAudioOrig.config.is_cldfb == 0 ) &&
             ( hIvasRend->inputsMasa[0].base.inConfig == IVAS_REND_AUDIO_CONFIG_UNKNOWN ) )
        {
@@ -9464,10 +9460,8 @@ ivas_error IVAS_REND_GetSamples(
            hIvasRend->headRotData.sr_pose_pred_axis );
        assert( num_poses_orig == hIvasRend->splitRendWrapper.multiBinPoseData.num_poses && "number of poses should not change dynamically" );

#ifndef API_5MS
        /* Clear output buffer */
        /* Clear output buffer for split rendering bitstream */
        set_zero( outAudio.data, outAudio.config.numChannels * outAudio.config.numSamplesPerChannel );
#endif
    }
#endif
    if ( ( error = renderActiveInputsIsm( hIvasRend, outAudio ) ) != IVAS_ERR_OK )
@@ -9580,9 +9574,9 @@ ivas_error IVAS_REND_GetSamples(
        }

        convertInternalBitsBuffToBitsBuffer( hBits, bits );
#ifndef API_5MS

        /* reset to outAudioOrig in case of PCM output */
        outAudio = outAudioOrig;
#endif

        if ( hIvasRend->outputConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
        {
@@ -9621,6 +9615,7 @@ ivas_error IVAS_REND_GetSamples(
#ifdef SPLIT_REND_WITH_HEAD_ROT
ivas_error IVAS_REND_GetSplitBinauralBitstream(
    IVAS_REND_HANDLE hIvasRend,      /* i/o: Renderer handle             */
    IVAS_REND_AudioBuffer outAudio,  /* i/o: buffer for output audio     */
    IVAS_REND_BitstreamBuffer *hBits /* o  : buffer for output bitstream */
)
{
@@ -9639,7 +9634,9 @@ ivas_error IVAS_REND_GetSplitBinauralBitstream(
    }
    hIvasRend->splitRendEncBuffer.config.numSamplesPerChannel *= cldfb_in ? 2 : 1;

    return getSamplesInternal( hIvasRend, hIvasRend->splitRendEncBuffer, hBits );
    /* hIvasRend->splitRendEncBuffer used for BINAURAL_SPLIT_CODED output
       outAudio used for BINAURAL_SPLIT_PCM output */
    return getSamplesInternal( hIvasRend, outAudio, hBits );
}

ivas_error IVAS_REND_GetSplitBinauralSamples(
Loading