Commit f65246ba authored by Archit Tamarapu's avatar Archit Tamarapu
Browse files

[fix] zero output for BINAURAL_SPLIT_PCM; buffers not passed correctly at...

[fix] zero output for BINAURAL_SPLIT_PCM; buffers not passed correctly at decoder or renderer pre-split rendering side
parent a4cbf711
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 );
+15 −0
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                                                 */
    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                                */
@@ -1432,6 +1433,20 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream(
        return error;
    }

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

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

    free( st_ivas->splitBinRend.hMultiBinCldfbData );

    return error;
+1 −0
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,                               /* o  : output synthesis signal                                  */
    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