Commit 9efc75cc authored by vaclav's avatar vaclav
Browse files

port NONBE_1293_CRASH_FIRST_FRAME_LOST

parent c841d5d2
Loading
Loading
Loading
Loading
Loading
+21 −1
Original line number Diff line number Diff line
@@ -953,6 +953,9 @@ int main(

    while ( 1 )
    {
#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST
        int16_t bfi = 0;
#endif
        int16_t num_in_channels;
        num_in_channels = inBuffer.config.numChannels;

@@ -961,7 +964,11 @@ int main(
        {
            ivas_error error_tmp;
            numSamplesRead = (int16_t) inBufferSize;
#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST
            error_tmp = split_rend_read_bits_from_file( hSplitRendFileReadWrite, bitsBuffer.bits, &bitsBuffer.config.bitsRead, &bitsBuffer.config.bitsWritten, &bfi );
#else
            error_tmp = split_rend_read_bits_from_file( hSplitRendFileReadWrite, bitsBuffer.bits, &bitsBuffer.config.bitsRead, &bitsBuffer.config.bitsWritten );
#endif
            if ( error_tmp != IVAS_ERR_OK )
            {
                if ( error_tmp == IVAS_ERR_END_OF_FILE )
@@ -1028,19 +1035,32 @@ int main(
        /* Read from split renderer bfi file if specified */
        if ( splitRendBFIReader != NULL && splitBinNeedsNewFrame )
        {
#ifndef NONBE_1293_CRASH_FIRST_FRAME_LOST
            int16_t bfi;
#endif
            if ( ( error = SplitRendBFIFileReading( splitRendBFIReader, &bfi ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nError in SplitRendBFIFileReading(): %s\n", ivas_error_to_string( error ) );
                goto cleanup;
            }

#ifndef NONBE_1293_CRASH_FIRST_FRAME_LOST
            if ( ( error = ISAR_POST_REND_SetSplitRendBFI( hIsarPostRend, bfi ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nError in ISAR_POST_REND_SetSplitRendBFI(): %s\n", ivas_error_to_string( error ) );
                goto cleanup;
            }
#endif
        }
#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST
        if ( splitBinNeedsNewFrame )
        {
            if ( ( error = ISAR_POST_REND_SetSplitRendBFI( hIsarPostRend, bfi ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nError in ISAR_POST_REND_SetSplitRendBFI(): %s\n", ivas_error_to_string( error ) );
                goto cleanup;
            }
        }
#endif

        for ( i = 0; i < args.inConfig.numBinBuses; ++i )
        {
+1 −0
Original line number Diff line number Diff line
@@ -209,6 +209,7 @@
#define FIX_1349_TNS_CRASH                              /* FhG: Fix crash in TNS entropy coding, in case order of joint TNS coding is reduced to 0 */
#define NONBE_FIX_1180_HQMDCT_PHECU_LT_MUTING           /* Ericsson: issue 1180, corrected long term mute loop attnuation after 200ms  in PhECU-PLC  */ 
#define NONBE_1200_ISM_JBM_BRATE_SW_FLUSH               /* VA: issue 1200: fix bug in renderer flush in ISM JBM bitrate switching */
#define NONBE_1293_CRASH_FIRST_FRAME_LOST               /* VA: issue 1293: fix G.192 decoder crash when first frame is lost */
#define FIX_1384_MSAN_stereo_tcx_core_enc               /* VA: issue 1384: fix use-of-uninitialized value in stereo_tcx_core_enc() */

// object-editing feature porting
+46 −8
Original line number Diff line number Diff line
@@ -1270,6 +1270,13 @@ ivas_error IVAS_DEC_GetSamplesDecoder(
        return IVAS_ERR_UNEXPECTED_NULL_POINTER;
    }

#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST
    if ( !hIvasDec->hasBeenFedFirstGoodFrame && !hIvasDec->isInitialized ) /* note: 'isInitialized' is related to EVS decoder */
    {
        return IVAS_ERR_OK;
    }
#endif

    /* If TSM is generally enabled, we have to wait for the first good frame.
       Otherwise, we directly decode the first frame in any case. */
#ifdef FIX_HRTF_LOAD
@@ -1428,6 +1435,15 @@ ivas_error IVAS_DEC_GetEditableParameters(
        return IVAS_ERR_UNEXPECTED_NULL_POINTER;
    }

#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST
    if ( !hIvasDec->hasBeenFedFirstGoodFrame )
    {
        hIvasEditableParameters->num_obj = 0;

        return IVAS_ERR_OK;
    }
#endif

    hIvasEditableParameters->gain_bed = 1.0f;
    hIvasEditableParameters->num_obj = hIvasDec->st_ivas->nchan_ism;
    if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT )
@@ -1501,6 +1517,13 @@ ivas_error IVAS_DEC_SetEditableParameters(
        return IVAS_ERR_UNEXPECTED_NULL_POINTER;
    }

#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST
    if ( !hIvasDec->hasBeenFedFirstGoodFrame )
    {
        return IVAS_ERR_OK;
    }
#endif

    error = IVAS_ERR_OK;

#ifdef DEBUGGING
@@ -1557,18 +1580,21 @@ ivas_error IVAS_DEC_SetEditableParameters(
ivas_error IVAS_DEC_PrepareRenderer(
    IVAS_DEC_HANDLE hIvasDec )
{
    ivas_error error;

    error = IVAS_ERR_OK;

    if ( hIvasDec == NULL )
    if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL )
    {
        return IVAS_ERR_UNEXPECTED_NULL_POINTER;
    }

#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST
    if ( hIvasDec->hasBeenFedFirstGoodFrame || hIvasDec->isInitialized ) /* note: 'isInitialized' is related to EVS decoder */
#endif
    {
        ivas_jbm_dec_prepare_renderer( hIvasDec->st_ivas );
    }

    hIvasDec->hasBeenPreparedRendering = true;
    return error;

    return IVAS_ERR_OK;
}
#endif

@@ -1797,11 +1823,16 @@ ivas_error IVAS_DEC_GetSamples(
            {
                *needNewFrame = false;
            }

#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST
            *nOutSamples = nSamplesRendered;
#endif
        }
    }

#ifndef NONBE_1293_CRASH_FIRST_FRAME_LOST
    *nOutSamples = nSamplesRendered;

#endif
    return IVAS_ERR_OK;
}

@@ -1909,6 +1940,13 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream(
        return error;
    }

#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST
    if ( !hIvasDec->hasBeenFedFirstGoodFrame )
    {
        return IVAS_ERR_OK;
    }
#endif

    /* change buffer layout */
    for ( i = 0; i < numSamplesPerChannelToDecode; ++i )
    {
+12 −0
Original line number Diff line number Diff line
@@ -1545,6 +1545,18 @@ static ivas_error renderSplitBinauralWithPostRot(
    }
    else
    {
#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST
        if ( splitBinInput->numCachedSamples == 0 )
        {
            numSamplesPerChannelCacheSize = (int16_t) ( *splitBinInput->base.ctx.pOutSampleRate * bits.isar_frame_size_ms / 1000 ) - outAudio.config.numSamplesPerChannel;
            splitBinInput->numCachedSamples = numSamplesPerChannelCacheSize;
        }
        else
        {
            splitBinInput->numCachedSamples -= outAudio.config.numSamplesPerChannel;
        }
#endif

        if ( splitBinInput->base.inConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED )
        {
            for ( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ )
+17 −0
Original line number Diff line number Diff line
@@ -323,11 +323,20 @@ ivas_error split_rend_write_bitstream_to_file(
 *
 *-----------------------------------------------------------------------------------------*/

#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST
ivas_error split_rend_read_bits_from_file(
    SplitFileReadWrite *hSplitRendFileReadWrite,
    uint8_t *bits,
    int32_t *bits_read,
    int32_t *bits_written,
    int16_t *bfi )
#else
ivas_error split_rend_read_bits_from_file(
    SplitFileReadWrite *hSplitRendFileReadWrite,
    uint8_t *bits,
    int32_t *bits_read,
    int32_t *bits_written )
#endif
{
    char header[SPLIT_RENDERER_FRAME_HEADER_LEN] = "SPLIT_FRAME";
    char header_read[SPLIT_RENDERER_FRAME_HEADER_LEN];
@@ -391,6 +400,14 @@ ivas_error split_rend_read_bits_from_file(
    *bits_read = 0;
    *bits_written = bit_len;

#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST
    *bfi = 0;
    if ( bit_len == 0 )
    {
        *bfi = 1;
    }
#endif

    return IVAS_ERR_OK;
}

Loading