diff --git a/apps/decoder.c b/apps/decoder.c index e362972866613be95f6be0aef0287dc36fac3628..8ef1ad4ec86c5e5dd2f2750fd141b487b1ba7a1a 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -175,7 +175,11 @@ typedef struct static bool parseCmdlIVAS_dec( int16_t argc, char **argv, DecArguments *arg ); static void usage_dec( void ); +#ifdef FIX_FLOAT_1539_G192_FORMAT_SWITCH +static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ObjectEditFileReader *objectEditFileReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_DEC_HANDLE *phIvasDec, int16_t *pcmBuf ); +#else static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ObjectEditFileReader *objectEditFileReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); +#endif static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtf, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ObjectEditFileReader *objectEditFileReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_RENDER_CONFIG_DATA *renderConfig, IVAS_DEC_HANDLE *phIvasDec, int16_t *pcmBuf ); static ivas_error load_hrtf_from_file( IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, IVAS_DEC_HANDLE hIvasDec, const IVAS_AUDIO_CONFIG OutputConfig, const int32_t output_Fs ); #ifdef DEBUGGING @@ -779,7 +783,11 @@ int main( } else { +#ifdef FIX_FLOAT_1539_G192_FORMAT_SWITCH + error = decodeG192( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, objectEditFileReader, &splitRendBits, &hIvasDec, pcmBuf ); +#else error = decodeG192( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, objectEditFileReader, &splitRendBits, hIvasDec, pcmBuf ); +#endif } if ( error == IVAS_ERR_OK || error == IVAS_ERR_END_OF_FILE ) @@ -2225,7 +2233,11 @@ static ivas_error decodeG192( Vector3PairFileReader *referenceVectorReader, ObjectEditFileReader *objectEditFileReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, +#ifdef FIX_FLOAT_1539_G192_FORMAT_SWITCH + IVAS_DEC_HANDLE *phIvasDec, +#else IVAS_DEC_HANDLE hIvasDec, +#endif int16_t *pcmBuf ) { @@ -2233,6 +2245,9 @@ static ivas_error decodeG192( uint16_t bit_stream[IVAS_MAX_BITS_PER_FRAME + 4 * 8]; int16_t i, num_bits; int16_t bfi = 0; +#ifdef FIX_FLOAT_1539_G192_FORMAT_SWITCH + IVAS_DEC_HANDLE hIvasDec = *phIvasDec; +#endif #ifdef DEBUGGING int16_t fec_seed = 12558; /* FEC_SEED */ #endif @@ -2263,6 +2278,9 @@ static ivas_error decodeG192( int16_t vec_pos_update, vec_pos_len; SplitFileReadWrite *splitRendWriter = NULL; int16_t isSplitRend, isSplitCoded; +#ifdef FIX_FLOAT_1539_G192_FORMAT_SWITCH + bool restartNeeded; +#endif #ifdef VARIABLE_SPEED_DECODING if ( arg.tsmEnabled ) @@ -2594,6 +2612,37 @@ static ivas_error decodeG192( return error; } +#ifdef FIX_FLOAT_1539_G192_FORMAT_SWITCH + if ( ( error = IVAS_DEC_isRestartNeeded( hIvasDec, &restartNeeded ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( restartNeeded ) + { + IVAS_DEC_BS_FORMAT tempFormat; + if ( ( error = IVAS_DEC_GetFormat( hIvasDec, &tempFormat ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError in IVAS_DEC_GetFormat, code: %d\n", error ); + goto cleanup; + } + IVAS_DEC_MODE codecMode = ( tempFormat == IVAS_DEC_BS_MONO ) ? IVAS_DEC_MODE_EVS : IVAS_DEC_MODE_IVAS; + error = restartDecoder( + &hIvasDec, + codecMode, + &arg, + NULL, /* ToDo : Provide rendererConfig */ + NULL /* ToDo : Provide LS Custom Data */ + ); + if ( error != IVAS_ERR_OK ) + { + fprintf( stderr, "\nFailed to restart decoder\n" ); + goto cleanup; + } + *phIvasDec = hIvasDec; /* Update for main()' s free */ + } +#endif + /* Placeholder for memory reallocation */ /* ... */ diff --git a/lib_com/options.h b/lib_com/options.h index bbea3aa1534059d14c1f9b80304d8ebe81ea7d42..0d5e44c327a7e872200ef30dee510c66d8b23075 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -161,6 +161,7 @@ /*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ +#define FIX_FLOAT_1539_G192_FORMAT_SWITCH /* Nokia: reintroduce format switching for g192 bitstreams */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index b16a3160419d38c48b3543873cb459e3c23f222c..fbdcac21167c46816500338b6d2f513e45515e4d 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -131,11 +131,14 @@ ivas_error ivas_dec_get_format( !( st_ivas->ivas_format == MASA_FORMAT && st_ivas->last_ivas_format == MASA_ISM_FORMAT ) && !( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->last_ivas_format == MASA_FORMAT ) ) { +#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH if ( Opt_tsm ) { +#endif st_ivas->restartNeeded = 1; return IVAS_ERR_OK; +#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH } else { @@ -144,6 +147,7 @@ ivas_error ivas_dec_get_format( #endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); } +#endif } /*-------------------------------------------------------------------* @@ -177,11 +181,14 @@ ivas_error ivas_dec_get_format( if ( st_ivas->ini_frame > 0 && nchan_ism != st_ivas->nchan_ism ) { +#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH if ( Opt_tsm ) { +#endif st_ivas->restartNeeded = 1; return IVAS_ERR_OK; +#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH } else { @@ -190,6 +197,7 @@ ivas_error ivas_dec_get_format( #endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); } +#endif } st_ivas->nchan_ism = nchan_ism; @@ -209,10 +217,14 @@ ivas_error ivas_dec_get_format( if ( st_ivas->ini_frame > 0 && sba_planar != st_ivas->sba_planar ) { +#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH if ( Opt_tsm ) { +#endif st_ivas->restartNeeded = 1; + return IVAS_ERR_OK; +#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH } else { @@ -221,6 +233,7 @@ ivas_error ivas_dec_get_format( #endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA planar flag signalled!" ); } +#endif } /* read Ambisonic (SBA) order */ @@ -229,11 +242,14 @@ ivas_error ivas_dec_get_format( if ( st_ivas->ini_frame > 0 && sba_order != st_ivas->sba_order ) { +#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH if ( Opt_tsm ) { +#endif st_ivas->restartNeeded = 1; return IVAS_ERR_OK; +#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH } else { @@ -242,6 +258,7 @@ ivas_error ivas_dec_get_format( #endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA order signalled!" ); } +#endif } sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, sba_order ); @@ -305,11 +322,14 @@ ivas_error ivas_dec_get_format( if ( st_ivas->ini_frame > 0 && nchan_ism != st_ivas->nchan_ism ) { +#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH if ( Opt_tsm ) { +#endif st_ivas->restartNeeded = 1; return IVAS_ERR_OK; +#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH } else { @@ -318,6 +338,7 @@ ivas_error ivas_dec_get_format( #endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); } +#endif } st_ivas->nchan_ism = nchan_ism; @@ -332,11 +353,14 @@ ivas_error ivas_dec_get_format( if ( st_ivas->ini_frame > 0 && nchan_ism != st_ivas->nchan_ism ) { +#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH if ( Opt_tsm ) { +#endif st_ivas->restartNeeded = 1; return IVAS_ERR_OK; +#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH } else { @@ -345,6 +369,7 @@ ivas_error ivas_dec_get_format( #endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); } +#endif } st_ivas->nchan_ism = nchan_ism; @@ -356,11 +381,14 @@ ivas_error ivas_dec_get_format( if ( st_ivas->ini_frame > 0 && nchan_ism != st_ivas->nchan_ism ) { +#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH if ( Opt_tsm ) { +#endif st_ivas->restartNeeded = 1; return IVAS_ERR_OK; +#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH } else { @@ -369,6 +397,7 @@ ivas_error ivas_dec_get_format( #endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); } +#endif } st_ivas->nchan_ism = nchan_ism; @@ -392,11 +421,14 @@ ivas_error ivas_dec_get_format( if ( st_ivas->ini_frame > 0 && sba_order != st_ivas->sba_order ) { +#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH if ( Opt_tsm ) { +#endif st_ivas->restartNeeded = 1; return IVAS_ERR_OK; +#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH } else { @@ -405,6 +437,7 @@ ivas_error ivas_dec_get_format( #endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA order signalled!" ); } +#endif } st_ivas->ism_mode = ivas_osba_ism_mode_select( ivas_total_brate, st_ivas->nchan_ism ); @@ -429,11 +462,14 @@ ivas_error ivas_dec_get_format( if ( st_ivas->ini_frame > 0 && st_ivas->transport_config != signaled_config ) { +#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH if ( Opt_tsm ) { +#endif st_ivas->restartNeeded = 1; return IVAS_ERR_OK; +#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH } else { @@ -442,6 +478,7 @@ ivas_error ivas_dec_get_format( #endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "wrong MC configuration signalled!" ); } +#endif } st_ivas->mc_mode = ivas_mc_mode_select( ivas_mc_map_output_config_to_mc_ls_setup( signaled_config ), ivas_total_brate ); @@ -523,11 +560,14 @@ ivas_error ivas_dec_get_format( if ( st_ivas->ini_frame > 0 && nchan_ism != st_ivas->nchan_ism ) { +#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH if ( Opt_tsm ) { +#endif st_ivas->restartNeeded = 1; return IVAS_ERR_OK; +#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH } else { @@ -536,6 +576,7 @@ ivas_error ivas_dec_get_format( #endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); } +#endif } st_ivas->nchan_ism = nchan_ism;