diff --git a/apps/isar_post_rend.c b/apps/isar_post_rend.c index bbda6949d59ddaf6be613c5edab4589919a79afd..8182bfdd3d16d9baab4c8cfce8ff32fc9a71c3af 100644 --- a/apps/isar_post_rend.c +++ b/apps/isar_post_rend.c @@ -992,6 +992,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; @@ -1000,7 +1003,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 ) @@ -1067,19 +1074,33 @@ 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 ) { diff --git a/lib_com/options.h b/lib_com/options.h index 80afcfaf7d2e0ec7e2117bd08f2d8fbe8b5cb0dd..099a8cdd8242790652fe43c9d1ed79ac902afaa8 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -156,6 +156,7 @@ #define NONBE_FIX_1180_HQMDCT_PHECU_LT_MUTING /* Ericsson: issue 1180, corrected long term mute loop attnuation after 200ms in PhECU-PLC */ #define FIX_1179_USAN_PHASEECU /* Eri: issue 1179: better handling of 16 bit wrap around for very long(>200ms) FER-bursts */ #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 diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index d824a19093f276f22a85e1a8d67223fa9378c48b..435417b0fdf19de36a65ab50ef1c39b4a0bc05e7 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1223,12 +1223,18 @@ ivas_error IVAS_DEC_GetSamples( hIvasDec->hasBeenFedFrame = false; move16(); set16_fx( pcmBuf, 0, imult1616( hIvasDec->st_ivas->hDecoderConfig->nchan_out, nSamplesAsked ) ); +#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST + nSamplesRendered = nSamplesAsked; + move16(); +#else hIvasDec->nSamplesRendered = add( hIvasDec->nSamplesRendered, nSamplesAsked ); move16(); *nOutSamples = nSamplesAsked; move16(); +#endif hIvasDec->nSamplesAvailableNext = sub( hIvasDec->nSamplesAvailableNext, nSamplesAsked ); move16(); +#ifndef NONBE_1293_CRASH_FIRST_FRAME_LOST IF( hIvasDec->nSamplesAvailableNext == 0 ) { hIvasDec->needNewFrame = true; @@ -1236,6 +1242,7 @@ ivas_error IVAS_DEC_GetSamples( move16(); move16(); } +#endif } ELSE { @@ -1370,6 +1377,7 @@ ivas_error IVAS_DEC_GetSamples( } nSamplesRendered = add( nSamplesRendered, nSamplesRendered_loop ); +#ifndef NONBE_1293_CRASH_FIRST_FRAME_LOST nSamplesToRender = sub( nSamplesToRender, nSamplesRendered_loop ); IF( hIvasDec->nSamplesAvailableNext == 0 ) { @@ -1383,9 +1391,25 @@ ivas_error IVAS_DEC_GetSamples( *needNewFrame = false; move16(); } +#endif } } +#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST + IF( hIvasDec->nSamplesAvailableNext == 0 ) + { + *needNewFrame = true; + move16(); + hIvasDec->needNewFrame = true; + move16(); + } + ELSE + { + *needNewFrame = false; + move16(); + } +#endif + *nOutSamples = nSamplesRendered; move16(); @@ -1522,6 +1546,13 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( return error; } +#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST + IF( !hIvasDec->hasBeenFedFirstGoodFrame ) + { + return IVAS_ERR_OK; + } +#endif + FOR( i = 0; i < BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES; ++i ) { pOutput[i] = hSplitBinRend->hMultiBinCldfbData->output_fx[i]; @@ -3775,14 +3806,21 @@ ivas_error IVAS_DEC_GetSamplesDecoder( ISAR_SPLIT_REND_BITS_DATA *splitRendBits /* o : output split rendering bits */ ) { - ivas_error error; - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + IF( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } +#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST + test(); + 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 @@ -3946,16 +3984,14 @@ ivas_error IVAS_DEC_GetEditableParameters( IVAS_DEC_HANDLE hIvasDec, IVAS_EDITABLE_PARAMETERS *hIvasEditableParameters ) { - ivas_error error; - test(); test(); test(); test(); test(); - if ( !( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || - ( hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT && hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) || - ( hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT && ( hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) ) ) + IF( !( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || + ( hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT && hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) || + ( hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT && ( hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) ) ) { return IVAS_ERROR( IVAS_ERR_WRONG_MODE, "Object editing no supported in this operation mode." ); } @@ -3967,6 +4003,16 @@ 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; + move16(); + + return IVAS_ERR_OK; + } +#endif + hIvasEditableParameters->gain_bed_fx = ONE_IN_Q30; move32(); hIvasEditableParameters->num_obj = hIvasDec->st_ivas->nchan_ism; @@ -4028,9 +4074,7 @@ ivas_error IVAS_DEC_GetEditableParameters( } } - error = IVAS_ERR_OK; - - return error; + return IVAS_ERR_OK; } @@ -4044,8 +4088,6 @@ ivas_error IVAS_DEC_SetEditableParameters( IVAS_DEC_HANDLE hIvasDec, IVAS_EDITABLE_PARAMETERS hIvasEditableParameters ) { - ivas_error error; - if ( !( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || ( hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT && hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) || ( hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT && ( hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) ) || @@ -4059,8 +4101,12 @@ ivas_error IVAS_DEC_SetEditableParameters( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - error = IVAS_ERR_OK; - +#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST + IF( !hIvasDec->hasBeenFedFirstGoodFrame ) + { + return IVAS_ERR_OK; + } +#endif #ifdef DEBUGGING assert( hIvasEditableParameters.num_obj == hIvasDec->st_ivas->nchan_ism ); #endif @@ -4102,7 +4148,7 @@ ivas_error IVAS_DEC_SetEditableParameters( } } - return error; + return IVAS_ERR_OK; } @@ -4115,18 +4161,22 @@ ivas_error IVAS_DEC_SetEditableParameters( ivas_error IVAS_DEC_PrepareRenderer( IVAS_DEC_HANDLE hIvasDec ) { - ivas_error error; - - error = IVAS_ERR_OK; - if ( hIvasDec == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - ivas_jbm_dec_prepare_renderer( hIvasDec->st_ivas ); +#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST + test(); + 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 diff --git a/lib_isar/lib_isar_post_rend.c b/lib_isar/lib_isar_post_rend.c index d957215d7d776432df253d0b0e9d0a7b1ba37902..5ee7f4a167ca31924f6400155ccc7331a164c961 100644 --- a/lib_isar/lib_isar_post_rend.c +++ b/lib_isar/lib_isar_post_rend.c @@ -1574,6 +1574,20 @@ static ivas_error renderSplitBinauralWithPostRot( } ELSE { + +#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST + IF( splitBinInput->numCachedSamples == 0 ) + { + numSamplesPerChannelCacheSize = (Word16) ( *splitBinInput->base.ctx.pOutSampleRate * bits.isar_frame_size_ms / 1000 ) - outAudio.config.numSamplesPerChannel; + splitBinInput->numCachedSamples = numSamplesPerChannelCacheSize; + move16(); + } + ELSE + { + splitBinInput->numCachedSamples = sub( 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++ ) diff --git a/lib_util/split_render_file_read_write.c b/lib_util/split_render_file_read_write.c index 10684fd7aad4800b6d1c43ba38230f82065061d2..9083d42177a7c43c8ac8bf242bc54cae95c3488c 100644 --- a/lib_util/split_render_file_read_write.c +++ b/lib_util/split_render_file_read_write.c @@ -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]; @@ -390,6 +399,13 @@ 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; } diff --git a/lib_util/split_render_file_read_write.h b/lib_util/split_render_file_read_write.h index 2895dd42687f37c421d3c97734bea2a0c32c8d7e..294d2efa12d30782ea38a1a524f837e2febd4d02 100644 --- a/lib_util/split_render_file_read_write.h +++ b/lib_util/split_render_file_read_write.h @@ -75,11 +75,20 @@ ivas_error split_rend_write_bitstream_to_file( int32_t *bits_written ); /* read split rend coded bits from 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 /* read split pre rend delay */ ivas_error split_rend_read_pre_rend_delay_ns(