From e4c2b0054d363b3724934fc7d24fd2f348742212 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Mon, 9 Mar 2026 20:20:39 +0200 Subject: [PATCH 1/4] Adapt removed changes from old commit for G192 bitstream decoder format switching. --- apps/decoder.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++ lib_com/options.h | 1 + 2 files changed, 50 insertions(+) diff --git a/apps/decoder.c b/apps/decoder.c index 44af4ba1e..ed5d67405 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 ) @@ -2597,6 +2615,37 @@ static ivas_error decodeG192( /* Placeholder for memory reallocation */ /* ... */ +#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 + /* Load HRTF binary file data */ if ( arg.hrtfReaderEnabled ) { diff --git a/lib_com/options.h b/lib_com/options.h index 13a0c786d..ce60667f8 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -162,6 +162,7 @@ #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_1535_ARI_RES_Q_CLEANUP /* FhG: remove dead code from tcx_ari_res_Q_spec() */ +#define FIX_FLOAT_1539_G192_FORMAT_SWITCH /* Nokia: reintroduce format switching for g192 bitstreams */ /* #################### End BE switches ################################## */ -- GitLab From 83d013969bfc598a5e8dc441b9ee910214436de0 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 24 Mar 2026 12:03:04 +0100 Subject: [PATCH 2/4] add more instances of FIX_FLOAT_1539_G192_FORMAT_SWITCH --- apps/encoder.c | 3 +++ lib_dec/ivas_init_dec.c | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/apps/encoder.c b/apps/encoder.c index ebb81866e..02a5dffd6 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -885,12 +885,15 @@ int main( goto cleanup; } + if ( frame >= 50 && frame < 60 ) + { /* write bitstream */ if ( ( error = BS_Writer_WriteFrame_short( hBsWriter, bitStream, numBits, totalBitrate ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nBS_Writer_WriteFrame_short failed, error code %d\n\n", error ); goto cleanup; } + } } frame++; diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index b16a31604..fbdcac211 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; -- GitLab From cddf557a80a0828bf270ed503fab40207185d1f4 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 24 Mar 2026 12:05:50 +0100 Subject: [PATCH 3/4] remove experimental code --- apps/decoder.c | 8 ++++---- apps/encoder.c | 3 --- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 9b30ef47d..28861a207 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -2611,10 +2611,7 @@ static ivas_error decodeG192( { return error; } - - /* Placeholder for memory reallocation */ - /* ... */ - + #ifdef FIX_FLOAT_1539_G192_FORMAT_SWITCH if ( ( error = IVAS_DEC_isRestartNeeded( hIvasDec, &restartNeeded ) ) != IVAS_ERR_OK ) { @@ -2646,6 +2643,9 @@ static ivas_error decodeG192( } #endif + /* Placeholder for memory reallocation */ + /* ... */ + /* Load HRTF binary file data */ if ( arg.hrtfReaderEnabled ) { diff --git a/apps/encoder.c b/apps/encoder.c index 02a5dffd6..ebb81866e 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -885,15 +885,12 @@ int main( goto cleanup; } - if ( frame >= 50 && frame < 60 ) - { /* write bitstream */ if ( ( error = BS_Writer_WriteFrame_short( hBsWriter, bitStream, numBits, totalBitrate ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nBS_Writer_WriteFrame_short failed, error code %d\n\n", error ); goto cleanup; } - } } frame++; -- GitLab From 5be207d6f7d56ca1c1e6b0c5609ef0be4dcbd6b5 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 24 Mar 2026 12:06:40 +0100 Subject: [PATCH 4/4] clang-format --- apps/decoder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/decoder.c b/apps/decoder.c index 28861a207..8ef1ad4ec 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -2611,7 +2611,7 @@ static ivas_error decodeG192( { return error; } - + #ifdef FIX_FLOAT_1539_G192_FORMAT_SWITCH if ( ( error = IVAS_DEC_isRestartNeeded( hIvasDec, &restartNeeded ) ) != IVAS_ERR_OK ) { -- GitLab