From a181f9a1ae7e1bc9c242858168fe9a65e3f0f296 Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Mon, 10 Nov 2025 15:11:37 +0200 Subject: [PATCH 1/6] Port decoder restart from float MR2279 --- apps/decoder.c | 180 +++++++++++++++++++++++++++++++++++++ lib_com/ivas_prot_fx.h | 5 ++ lib_com/options.h | 1 + lib_dec/ivas_init_dec_fx.c | 164 +++++++++++++++++++++++++++++++++ lib_dec/ivas_stat_dec.h | 3 + lib_dec/lib_dec.h | 6 ++ lib_dec/lib_dec_fx.c | 49 ++++++++++ 7 files changed, 408 insertions(+) diff --git a/apps/decoder.c b/apps/decoder.c index 63c837a38..dbcf01a97 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -173,13 +173,24 @@ static bool parseCmdlIVAS_dec( int16_t argc, char **argv, DecArguments *arg ); static void usage_dec( void ); 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 ); #ifdef FIX_1119_SPLIT_RENDERING_VOIP +#ifdef DECODER_FORMAT_SWITCHING +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_DEC_HANDLE *phIvasDec, int16_t *pcmBuf ); +#else 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_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); +#endif +#else +#ifdef DDECODER_FORMAT_SWITCHING +static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ObjectEditFileReader *objectEditFileReader, IVAS_DEC_HANDLE *phIvasDec, int16_t *pcmBuf ); #else static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ObjectEditFileReader *objectEditFileReader, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); #endif +#endif 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 ); static void do_object_editing_fx( IVAS_EDITABLE_PARAMETERS *editableParameters, ObjectEditFileReader *objectEditFileReader ); +#ifdef DECODER_FORMAT_SWITCHING +static ivas_error restartDecoder( IVAS_DEC_HANDLE *phIvasDec, IVAS_DEC_MODE codec, DecArguments *arg, IVAS_RENDER_CONFIG_DATA *renderConfig, IVAS_CUSTOM_LS_DATA *hLsCustomData ); +#endif /*------------------------------------------------------------------------------------------* * main() @@ -657,9 +668,17 @@ int main( if ( arg.voipMode ) { #ifdef FIX_1119_SPLIT_RENDERING_VOIP +#ifdef DECODER_FORMAT_SWITCHING + error = decodeVoIP( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, objectEditFileReader, &splitRendBits, &hIvasDec, pcmBuf ); +#else error = decodeVoIP( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, objectEditFileReader, &splitRendBits, hIvasDec, pcmBuf ); +#endif +#else +#ifdef DDECODER_FORMAT_SWITCHING + error = decodeVoIP( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, objectEditFileReader, &hIvasDec, pcmBuf ); #else error = decodeVoIP( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, objectEditFileReader, hIvasDec, pcmBuf ); +#endif #endif } else @@ -2866,7 +2885,11 @@ static ivas_error decodeVoIP( #ifdef FIX_1119_SPLIT_RENDERING_VOIP ISAR_SPLIT_REND_BITS_DATA *splitRendBits, #endif +#ifdef DECODER_FORMAT_SWITCHING + IVAS_DEC_HANDLE *phIvasDec, +#else IVAS_DEC_HANDLE hIvasDec, +#endif int16_t *pcmBuf ) { bool decodingFailed = true; /* Assume failure until cleanup is reached without errors */ @@ -2898,6 +2921,9 @@ static ivas_error decodeVoIP( int16_t delayNumSamples = -1; int32_t delayTimeScale = -1; int16_t i; +#ifdef DECODER_FORMAT_SWITCHING + IVAS_DEC_HANDLE hIvasDec = *phIvasDec; +#endif #ifdef IVAS_RTPDUMP IVAS_RTP ivasRtp = { 0 }; IVAS_RTP srRtp = { 0 }; @@ -3079,6 +3105,27 @@ static ivas_error decodeVoIP( fprintf( stdout, "\n-- Start the decoder (quiet mode) --\n\n" ); } +#ifdef DECODER_FORMAT_SWITCHING + if ( ivasRtp.restartNeeded ) + { + IVAS_DEC_MODE newCodecInPacket = ( ivasRtp.codecId == IVAS_RTP_EVS ) ? IVAS_DEC_MODE_EVS : IVAS_DEC_MODE_IVAS; + error = restartDecoder( + &hIvasDec, + newCodecInPacket, + &arg, + NULL, /* ToDo : Provide rendererConfig */ + NULL /* ToDo : Provide LS Custom Data */ + ); + if ( error != IVAS_ERR_OK ) + { + fprintf( stderr, "\nFailed to restart decoder from %d to %d\n", arg.decMode, newCodecInPacket ); + goto cleanup; + } + *phIvasDec = hIvasDec; /* Update for main()' s free */ + ivasRtp.restartNeeded = false; + } +#endif + #ifdef WMOPS reset_stack(); reset_wmops(); @@ -3347,6 +3394,31 @@ static ivas_error decodeVoIP( /* Placeholder for memory reallocation */ /* ... */ +#ifdef DECODER_FORMAT_SWITCHING + if ( IVAS_DEC_isRestartNeeded( hIvasDec ) ) + { + 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 ) @@ -4073,4 +4145,112 @@ static ivas_error load_hrtf_from_file( return IVAS_ERR_OK; } +#ifdef DECODER_FORMAT_SWITCHING + +ivas_error restartDecoder( + IVAS_DEC_HANDLE *phIvasDec, + IVAS_DEC_MODE codec, + DecArguments *arg, + IVAS_RENDER_CONFIG_DATA *renderConfig, + IVAS_CUSTOM_LS_DATA *hLsCustomData ) +{ + ivas_error error = IVAS_ERR_OK; + IVAS_DEC_HANDLE hIvasDec; + + if ( phIvasDec == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + if ( NULL != *phIvasDec ) + { + IVAS_DEC_Close( phIvasDec ); + } + + if ( ( error = IVAS_DEC_Open( phIvasDec, codec ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Open failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + + arg->decMode = codec; + + hIvasDec = *phIvasDec; + + uint16_t aeID = arg->aeSequence.count > 0 ? arg->aeSequence.pID[0] : 65535; + + IVAS_AUDIO_CONFIG outputConfig = ( codec == IVAS_DEC_MODE_IVAS ) ? arg->outputConfig : IVAS_AUDIO_CONFIG_MONO; + if ( ( error = IVAS_DEC_Configure( hIvasDec, arg->output_Fs, outputConfig, arg->renderFramesize, arg->customLsOutputEnabled, arg->hrtfReaderEnabled, + arg->enableHeadRotation, arg->enableExternalOrientation, arg->orientation_tracking, arg->renderConfigEnabled, arg->non_diegetic_pan_enabled, + arg->non_diegetic_pan_gain, arg->dpidEnabled, aeID, arg->objEditEnabled, arg->delayCompensationEnabled ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + + if ( ( error = IVAS_DEC_GetRenderFramesize( hIvasDec, &arg->renderFramesize ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + + if ( arg->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + if ( ( error = IVAS_DEC_EnableSplitRendering( hIvasDec ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nSplit rendering configure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + + if ( ( error = IVAS_DEC_GetRenderFramesize( hIvasDec, &arg->renderFramesize ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + + arg->enableHeadRotation = true; + } + + if ( arg->voipMode ) + { + if ( ( error = IVAS_DEC_EnableVoIP( hIvasDec, 60, arg->inputFormat ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nCould not enable VOIP: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + } + + if ( ( error = IVAS_DEC_PrintConfig( hIvasDec, 1, arg->voipMode ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_DEC_PrintConfig failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + + if ( arg->renderConfigEnabled && renderConfig != NULL ) + { + if ( ( error = IVAS_DEC_FeedRenderConfig( hIvasDec, *renderConfig ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_DEC_FeedRenderConfig failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + } + + if ( arg->customLsOutputEnabled && hLsCustomData != NULL ) + { + if ( ( error = IVAS_DEC_FeedCustomLsData( hIvasDec, *hLsCustomData ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_DEC_FeedCustomLsData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + } + + return IVAS_ERR_OK; + +cleanup: + IVAS_DEC_Close( phIvasDec ); + return error; +} + +#endif + #undef WMC_TOOL_SKIP diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 0e607039f..0cb0174d6 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -4030,7 +4030,12 @@ ivas_error ivas_output_buff_dec_fx( ); ivas_error ivas_dec_get_format_fx( +#ifdef DECODER_FORMAT_SWITCHING + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const bool isVoipMode /* i : voip mode indicator */ +#else Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +#endif ); ivas_error ivas_dec_setup( diff --git a/lib_com/options.h b/lib_com/options.h index c6a4efa4b..3d461aa0f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -161,6 +161,7 @@ #define RTP_S4_251135_CR26253_0016_REV1 /* RTP Pack/Unpack API corresponding to CR 26253 */ #define IVAS_RTPDUMP /* RTPDUMP writing and reading for IVAS payloads */ #define FIXED_RTP_SEQUENCE_NUM /* Remove random sequence number initialization */ +#define DECODER_FORMAT_SWITCHING /* Re-initialize the decoder when the format/subformat of the incoming stream is changed */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index b63ca6e90..abc8f57b1 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -104,7 +104,12 @@ static AUDIO_CONFIG ivas_set_audio_config_from_sba_order( *---------------------------------------------------------------------*/ ivas_error ivas_dec_get_format_fx( +#ifdef DECODER_FORMAT_SWITCHING + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const bool isVoipMode /* i : voip mode indicator */ +#else Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +#endif ) { Word16 k, idx, num_bits_read; @@ -142,10 +147,23 @@ ivas_error ivas_dec_get_format_fx( !( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) && EQ_32( st_ivas->last_ivas_format, MASA_ISM_FORMAT ) ) && !( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_32( st_ivas->last_ivas_format, MASA_FORMAT ) ) ) { +#ifdef DECODER_FORMAT_SWITCHING + IF( isVoipMode ) + { + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } + ELSE + { +#endif #ifdef DEBUGGING fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); #endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); +#ifdef DECODER_FORMAT_SWITCHING + } +#endif } /*-------------------------------------------------------------------* @@ -183,10 +201,23 @@ ivas_error ivas_dec_get_format_fx( test(); IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) { +#ifdef DECODER_FORMAT_SWITCHING + IF( isVoipMode ) + { + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } + ELSE + { +#endif #ifdef DEBUGGING fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); #endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); +#ifdef DECODER_FORMAT_SWITCHING + } +#endif } st_ivas->nchan_ism = nchan_ism; @@ -210,10 +241,23 @@ ivas_error ivas_dec_get_format_fx( test(); IF( st_ivas->ini_frame > 0 && NE_16( sba_planar, st_ivas->sba_planar ) ) { +#ifdef DECODER_FORMAT_SWITCHING + IF( isVoipMode ) + { + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } + ELSE + { +#endif #ifdef DEBUGGING fprintf( stderr, "\nError: Changing the SBA planar/3D layout is not supported!\n" ); #endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA planar flag signalled!" ); +#ifdef DECODER_FORMAT_SWITCHING + } +#endif } /* read Ambisonic (SBA) order */ @@ -224,10 +268,23 @@ ivas_error ivas_dec_get_format_fx( test(); IF( st_ivas->ini_frame > 0 && NE_16( sba_order, st_ivas->sba_order ) ) { +#ifdef DECODER_FORMAT_SWITCHING + IF( isVoipMode ) + { + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } + ELSE + { +#endif #ifdef DEBUGGING fprintf( stderr, "\nError: Changing the SBA order is not supported!\n" ); #endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA order signalled!" ); +#ifdef DECODER_FORMAT_SWITCHING + } +#endif } sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, sba_order ); @@ -235,10 +292,23 @@ ivas_error ivas_dec_get_format_fx( } ELSE IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) ) { +#ifdef DECODER_FORMAT_SWITCHING + UWord8 masaRestartCandidate; + masaRestartCandidate = 0; + move16(); +#endif /* read number of MASA transport channels */ k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); IF( st_ivas->bit_stream[k - 1] ) { +#ifdef DECODER_FORMAT_SWITCHING + test(); + IF( st_ivas->nchan_transport == 1 && isVoipMode ) + { + masaRestartCandidate = 1; + move16(); + } +#endif st_ivas->nchan_transport = 2; move16(); element_mode_flag = 1; @@ -246,6 +316,14 @@ ivas_error ivas_dec_get_format_fx( } ELSE { +#ifdef DECODER_FORMAT_SWITCHING + test(); + IF( st_ivas->nchan_transport == 2 && isVoipMode ) + { + masaRestartCandidate = 1; + move16(); + } +#endif st_ivas->nchan_transport = 1; move16(); } @@ -279,14 +357,35 @@ ivas_error ivas_dec_get_format_fx( element_mode_flag = 1; move16(); } +#ifdef DECODER_FORMAT_SWITCHING + ELSE IF( masaRestartCandidate > 0 ) + { + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } +#endif test(); IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) { +#ifdef DECODER_FORMAT_SWITCHING + IF( isVoipMode ) + { + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } + ELSE + { +#endif #ifdef DEBUGGING fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); #endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); +#ifdef DECODER_FORMAT_SWITCHING + } +#endif } st_ivas->nchan_ism = nchan_ism; @@ -305,10 +404,23 @@ ivas_error ivas_dec_get_format_fx( test(); IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) { +#ifdef DECODER_FORMAT_SWITCHING + IF( isVoipMode ) + { + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } + ELSE + { +#endif #ifdef DEBUGGING fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); #endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); +#ifdef DECODER_FORMAT_SWITCHING + } +#endif } st_ivas->nchan_ism = nchan_ism; @@ -323,10 +435,23 @@ ivas_error ivas_dec_get_format_fx( test(); IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) { +#ifdef DECODER_FORMAT_SWITCHING + IF( isVoipMode ) + { + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } + ELSE + { +#endif #ifdef DEBUGGING fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); #endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); +#ifdef DECODER_FORMAT_SWITCHING + } +#endif } st_ivas->nchan_ism = nchan_ism; @@ -354,10 +479,23 @@ ivas_error ivas_dec_get_format_fx( test(); IF( st_ivas->ini_frame > 0 && NE_16( sba_order, st_ivas->sba_order ) ) { +#ifdef DECODER_FORMAT_SWITCHING + IF( isVoipMode ) + { + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } + ELSE + { +#endif #ifdef DEBUGGING fprintf( stderr, "\nError: Changing the SBA order is not supported!\n" ); #endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA order signalled!" ); +#ifdef DECODER_FORMAT_SWITCHING + } +#endif } st_ivas->ism_mode = ivas_osba_ism_mode_select( ivas_total_brate, st_ivas->nchan_ism ); @@ -384,10 +522,23 @@ ivas_error ivas_dec_get_format_fx( test(); IF( st_ivas->ini_frame > 0 && NE_32( st_ivas->transport_config, signaled_config ) ) { +#ifdef DECODER_FORMAT_SWITCHING + IF( isVoipMode ) + { + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } + ELSE + { +#endif #ifdef DEBUGGING fprintf( stderr, "\nError: Switching of MC configurations is not supported!\n" ); #endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "wrong MC configuration signalled!" ); +#ifdef DECODER_FORMAT_SWITCHING + } +#endif } st_ivas->mc_mode = ivas_mc_mode_select_fx( ivas_mc_map_output_config_to_mc_ls_setup_fx( signaled_config ), ivas_total_brate ); @@ -486,10 +637,23 @@ ivas_error ivas_dec_get_format_fx( test(); IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) { +#ifdef DECODER_FORMAT_SWITCHING + IF( isVoipMode ) + { + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } + else + { +#endif #ifdef DEBUGGING fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); #endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); +#ifdef DECODER_FORMAT_SWITCHING + } +#endif } st_ivas->nchan_ism = nchan_ism; diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 4a464705d..06ed4c4c3 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1215,6 +1215,9 @@ typedef struct Decoder_Struct #ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR Word16 flushing; #endif +#ifdef DECODER_FORMAT_SWITCHING + UWord8 restartNeeded; /* Flag to check if the decoder requires a restart */ +#endif } Decoder_Struct; diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 1167d60b9..38bd39dd4 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -332,6 +332,12 @@ ivas_error IVAS_DEC_Flush( Word16 *nSamplesFlushed /* o : number of samples flushed */ ); +#ifdef DECODER_FORMAT_SWITCHING +bool IVAS_DEC_isRestartNeeded( + IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ +); + +#endif /* Setter functions - apply changes to decoder configuration */ /*! r: error code */ diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 44a8aa54f..021dc5b6a 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -244,6 +244,11 @@ ivas_error IVAS_DEC_Open( /* initialize pointers to handles to NULL */ ivas_initialize_handles_dec( st_ivas ); +#ifdef DECODER_FORMAT_SWITCHING + st_ivas->restartNeeded = 0; + move16(); +#endif + /* set high-level parameters */ IF( EQ_16( mode, IVAS_DEC_MODE_EVS ) ) { @@ -2139,12 +2144,24 @@ ivas_error IVAS_DEC_GetFormat( } move32(); +#ifdef DECODER_FORMAT_SWITCHING + test(); + IF( EQ_32( *format, IVAS_DEC_BS_MASA ) && hIvasDec->st_ivas->hMasa != NULL ) + { + IF( EQ_32( hIvasDec->st_ivas->hMasa->config.input_ivas_format, MASA_ISM_FORMAT ) ) + { + *format = IVAS_DEC_BS_MASA_ISM; + move32(); + } + } +#else test(); if ( EQ_32( *format, IVAS_DEC_BS_MASA ) && EQ_32( hIvasDec->st_ivas->hMasa->config.input_ivas_format, MASA_ISM_FORMAT ) ) { *format = IVAS_DEC_BS_MASA_ISM; move32(); } +#endif return IVAS_ERR_OK; } @@ -3620,7 +3637,9 @@ ivas_error IVAS_DEC_ReadFormat( { ivas_error error; Decoder_Struct *st_ivas; +#ifndef DECODER_FORMAT_SWITCHING IVAS_FORMAT ivas_format_old; +#endif ISM_MODE ism_mode_old; MC_MODE mc_mode_old; Word16 nchan_transport_old; @@ -3634,7 +3653,9 @@ ivas_error IVAS_DEC_ReadFormat( } st_ivas = hIvasDec->st_ivas; +#ifndef DECODER_FORMAT_SWITCHING ivas_format_old = st_ivas->ivas_format; +#endif ism_mode_old = st_ivas->ism_mode; mc_mode_old = st_ivas->mc_mode; nchan_transport_old = st_ivas->nchan_transport; @@ -3661,11 +3682,22 @@ ivas_error IVAS_DEC_ReadFormat( IF( st_ivas->bfi == 0 ) { +#ifdef DECODER_FORMAT_SWITCHING + IF( NE_32( error = ivas_dec_get_format_fx( st_ivas, hIvasDec->hVoIP != NULL ), IVAS_ERR_OK ) ) +#else IF( NE_32( error = ivas_dec_get_format_fx( st_ivas ), IVAS_ERR_OK ) ) +#endif { return error; } +#ifdef DECODER_FORMAT_SWITCHING + IF( st_ivas->restartNeeded > 0 ) + { + return IVAS_ERR_OK; + } +#else + test(); test(); test(); @@ -3673,6 +3705,7 @@ ivas_error IVAS_DEC_ReadFormat( { return ( IVAS_ERROR( IVAS_ERR_INVALID_INPUT_FORMAT, "IVAS format switching is not allowed." ) ); } +#endif /* Select binaural renderer */ ivas_renderer_select( st_ivas ); @@ -5239,6 +5272,22 @@ ivas_error IVAS_DEC_Flush( } +#ifdef DECODER_FORMAT_SWITCHING +/*---------------------------------------------------------------------* + * IVAS_DEC_isRestartNeeded( ) + * + * + *---------------------------------------------------------------------*/ + +bool IVAS_DEC_isRestartNeeded( + IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ +) +{ + return hIvasDec->st_ivas->restartNeeded > 0; +} + + +#endif /*---------------------------------------------------------------------* * IVAS_DEC_VoIP_IsEmpty( ) * -- GitLab From cc88887744c1e5875d53b1c0f1ddde86770b5799 Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Mon, 10 Nov 2025 15:30:42 +0200 Subject: [PATCH 2/6] Clang format --- lib_dec/ivas_init_dec_fx.c | 814 ++++++++++++++++++------------------- 1 file changed, 397 insertions(+), 417 deletions(-) diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index abc8f57b1..8ea034cfe 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -145,545 +145,525 @@ ivas_error ivas_dec_get_format_fx( test(); IF( st_ivas->ini_frame > 0 && NE_32( st_ivas->ivas_format, st_ivas->last_ivas_format ) && !( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) && EQ_32( st_ivas->last_ivas_format, MASA_ISM_FORMAT ) ) && - !( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_32( st_ivas->last_ivas_format, MASA_FORMAT ) ) ) - { + !( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_32( st_ivas->last_ivas_format, MASA_FORMAT ) ) ){ #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ) - { + IF( isVoipMode ){ st_ivas->restartNeeded = 1; - move16(); - return IVAS_ERR_OK; - } - ELSE - { + move16(); + return IVAS_ERR_OK; +} +ELSE +{ #endif #ifdef DEBUGGING - fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); + fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); #endif - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); #ifdef DECODER_FORMAT_SWITCHING - } +} #endif - } +} +/*-------------------------------------------------------------------* + * Read other signaling (ISM/MC mode, number of channels, etc.) + *-------------------------------------------------------------------*/ + +IF( is_DTXrate( ivas_total_brate ) == 0 ) +{ /*-------------------------------------------------------------------* - * Read other signaling (ISM/MC mode, number of channels, etc.) + * Read IVAS format related signaling: + * - in ISM : read number of objects + * - in SBA : read SBA planar flag and SBA order + * - in MASA : read number of TC + * - in MC : read LS setup *-------------------------------------------------------------------*/ - IF( is_DTXrate( ivas_total_brate ) == 0 ) + IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) { - /*-------------------------------------------------------------------* - * Read IVAS format related signaling: - * - in ISM : read number of objects - * - in SBA : read SBA planar flag and SBA order - * - in MASA : read number of TC - * - in MC : read LS setup - *-------------------------------------------------------------------*/ - - IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) - { - element_mode_flag = 1; - move16(); - } - ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) ) + element_mode_flag = 1; + move16(); + } + ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) ) + { + /* read the number of objects */ + nchan_ism = 1; + move16(); + k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); + k = sub( k, 1 ); + WHILE( st_ivas->bit_stream[k] && ( nchan_ism < MAX_NUM_OBJECTS ) ) { - /* read the number of objects */ - nchan_ism = 1; - move16(); - k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); + nchan_ism = add( nchan_ism, 1 ); k = sub( k, 1 ); - WHILE( st_ivas->bit_stream[k] && ( nchan_ism < MAX_NUM_OBJECTS ) ) - { - nchan_ism = add( nchan_ism, 1 ); - k = sub( k, 1 ); - } + } - test(); - IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) - { + test(); + IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ){ #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ) - { - st_ivas->restartNeeded = 1; - move16(); - return IVAS_ERR_OK; - } - ELSE - { + IF( isVoipMode ){ + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } + ELSE + { #endif #ifdef DEBUGGING - fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); + fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); #endif - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); #ifdef DECODER_FORMAT_SWITCHING - } + } #endif - } +} - st_ivas->nchan_ism = nchan_ism; - move16(); - st_ivas->ism_mode = ivas_ism_mode_select( nchan_ism, ivas_total_brate ); +st_ivas->nchan_ism = nchan_ism; +move16(); +st_ivas->ism_mode = ivas_ism_mode_select( nchan_ism, ivas_total_brate ); - st_ivas->nchan_transport = nchan_ism; - move16(); - if ( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) ) - { - st_ivas->nchan_transport = MAX_PARAM_ISM_WAVE; - move16(); - } - } - ELSE IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) ) - { - /* read Ambisonic (SBA) planar flag */ - sba_planar = st_ivas->bit_stream[num_bits_read]; - num_bits_read = add( num_bits_read, SBA_PLANAR_BITS ); +st_ivas->nchan_transport = nchan_ism; +move16(); +if ( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) ) +{ + st_ivas->nchan_transport = MAX_PARAM_ISM_WAVE; + move16(); +} +} +ELSE IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) ) +{ + /* read Ambisonic (SBA) planar flag */ + sba_planar = st_ivas->bit_stream[num_bits_read]; + num_bits_read = add( num_bits_read, SBA_PLANAR_BITS ); - test(); - IF( st_ivas->ini_frame > 0 && NE_16( sba_planar, st_ivas->sba_planar ) ) - { + test(); + IF( st_ivas->ini_frame > 0 && NE_16( sba_planar, st_ivas->sba_planar ) ){ #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ) - { - st_ivas->restartNeeded = 1; - move16(); - return IVAS_ERR_OK; - } - ELSE - { + IF( isVoipMode ){ + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; +} +ELSE +{ #endif #ifdef DEBUGGING - fprintf( stderr, "\nError: Changing the SBA planar/3D layout is not supported!\n" ); + fprintf( stderr, "\nError: Changing the SBA planar/3D layout is not supported!\n" ); #endif - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA planar flag signalled!" ); + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA planar flag signalled!" ); #ifdef DECODER_FORMAT_SWITCHING - } +} #endif - } +} - /* read Ambisonic (SBA) order */ - sba_order = st_ivas->bit_stream[num_bits_read + 1]; - move16(); - sba_order = add( sba_order, shl( st_ivas->bit_stream[num_bits_read], 1 ) ); +/* read Ambisonic (SBA) order */ +sba_order = st_ivas->bit_stream[num_bits_read + 1]; +move16(); +sba_order = add( sba_order, shl( st_ivas->bit_stream[num_bits_read], 1 ) ); - test(); - IF( st_ivas->ini_frame > 0 && NE_16( sba_order, st_ivas->sba_order ) ) - { +test(); +IF( st_ivas->ini_frame > 0 && NE_16( sba_order, st_ivas->sba_order ) ){ #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ) - { - st_ivas->restartNeeded = 1; - move16(); - return IVAS_ERR_OK; - } - ELSE - { + IF( isVoipMode ){ + st_ivas->restartNeeded = 1; +move16(); +return IVAS_ERR_OK; +} +ELSE +{ #endif #ifdef DEBUGGING - fprintf( stderr, "\nError: Changing the SBA order is not supported!\n" ); + fprintf( stderr, "\nError: Changing the SBA order is not supported!\n" ); #endif - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA order signalled!" ); + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA order signalled!" ); #ifdef DECODER_FORMAT_SWITCHING - } +} #endif - } +} - sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, sba_order ); - st_ivas->nchan_transport = ivas_get_sba_num_TCs_fx( ivas_total_brate, sba_analysis_order ); - } - ELSE IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) ) - { +sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, sba_order ); +st_ivas->nchan_transport = ivas_get_sba_num_TCs_fx( ivas_total_brate, sba_analysis_order ); +} +ELSE IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) ) +{ #ifdef DECODER_FORMAT_SWITCHING - UWord8 masaRestartCandidate; - masaRestartCandidate = 0; - move16(); + UWord8 masaRestartCandidate; + masaRestartCandidate = 0; + move16(); #endif - /* read number of MASA transport channels */ - k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); - IF( st_ivas->bit_stream[k - 1] ) - { + /* read number of MASA transport channels */ + k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); + IF( st_ivas->bit_stream[k - 1] ) + { #ifdef DECODER_FORMAT_SWITCHING - test(); - IF( st_ivas->nchan_transport == 1 && isVoipMode ) - { - masaRestartCandidate = 1; - move16(); - } + test(); + IF( st_ivas->nchan_transport == 1 && isVoipMode ) + { + masaRestartCandidate = 1; + move16(); + } #endif - st_ivas->nchan_transport = 2; - move16(); - element_mode_flag = 1; - move16(); - } - ELSE - { + st_ivas->nchan_transport = 2; + move16(); + element_mode_flag = 1; + move16(); + } + ELSE + { #ifdef DECODER_FORMAT_SWITCHING - test(); - IF( st_ivas->nchan_transport == 2 && isVoipMode ) - { - masaRestartCandidate = 1; - move16(); - } + test(); + IF( st_ivas->nchan_transport == 2 && isVoipMode ) + { + masaRestartCandidate = 1; + move16(); + } #endif - st_ivas->nchan_transport = 1; - move16(); - } + st_ivas->nchan_transport = 1; + move16(); + } - /* this should be non-zero if original input format was MASA_ISM_FORMAT */ - st_ivas->ism_mode = ISM_MODE_NONE; + /* this should be non-zero if original input format was MASA_ISM_FORMAT */ + st_ivas->ism_mode = ISM_MODE_NONE; + move16(); + nchan_ism = add( st_ivas->bit_stream[k - 3], shl( st_ivas->bit_stream[k - 2], 1 ) ); + + IF( nchan_ism > 0 ) + { + /* the input_ivas_format should be MASA_ISM_FORMAT, but we cannot initialize it now */ + /* info about the number of objects: + '00' - MASA format at the encoder + '01' - MASA_ISM_FORMAT at the encoder, with 4 objects + '10' - MASA_ISM_FORMAT at the encoder, with 3 objects + '11' - MASA_ISM_FORMAT at the encoder, with 1 or 2 objects + reading if 1 or 2 objects is performed later + */ + nchan_ism = sub( 5, nchan_ism ); + test(); + IF( EQ_16( st_ivas->nchan_transport, 1 ) && EQ_16( nchan_ism, 2 ) ) + { + nchan_ism = 1; move16(); - nchan_ism = add( st_ivas->bit_stream[k - 3], shl( st_ivas->bit_stream[k - 2], 1 ) ); - - IF( nchan_ism > 0 ) - { - /* the input_ivas_format should be MASA_ISM_FORMAT, but we cannot initialize it now */ - /* info about the number of objects: - '00' - MASA format at the encoder - '01' - MASA_ISM_FORMAT at the encoder, with 4 objects - '10' - MASA_ISM_FORMAT at the encoder, with 3 objects - '11' - MASA_ISM_FORMAT at the encoder, with 1 or 2 objects - reading if 1 or 2 objects is performed later - */ - nchan_ism = sub( 5, nchan_ism ); - test(); - IF( EQ_16( st_ivas->nchan_transport, 1 ) && EQ_16( nchan_ism, 2 ) ) - { - nchan_ism = 1; - move16(); - } + } - /* for MASA_ISM_FORMAT at input the number of MASA transport channels is always 2 and the corresponding bit is not used here*/ - st_ivas->nchan_transport = 2; - move16(); - element_mode_flag = 1; - move16(); - } + /* for MASA_ISM_FORMAT at input the number of MASA transport channels is always 2 and the corresponding bit is not used here*/ + st_ivas->nchan_transport = 2; + move16(); + element_mode_flag = 1; + move16(); + } #ifdef DECODER_FORMAT_SWITCHING - ELSE IF( masaRestartCandidate > 0 ) - { - st_ivas->restartNeeded = 1; - move16(); - return IVAS_ERR_OK; - } + ELSE IF( masaRestartCandidate > 0 ) + { + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } #endif - test(); - IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) - { + test(); + IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ){ #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ) - { - st_ivas->restartNeeded = 1; - move16(); - return IVAS_ERR_OK; - } - ELSE - { + IF( isVoipMode ){ + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; +} +ELSE +{ #endif #ifdef DEBUGGING - fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); + fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); #endif - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); #ifdef DECODER_FORMAT_SWITCHING - } +} #endif - } +} - st_ivas->nchan_ism = nchan_ism; - move16(); - } - ELSE IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) - { - st_ivas->nchan_transport = 2; /* always 2 MASA transport channels */ - move16(); +st_ivas->nchan_ism = nchan_ism; +move16(); +} +ELSE IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) +{ + st_ivas->nchan_transport = 2; /* always 2 MASA transport channels */ + move16(); - /* the number of objects are written at the end of the bitstream */ - k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); - nchan_ism = add( add( shl( st_ivas->bit_stream[k - 1], 1 ), st_ivas->bit_stream[k - 2] ), 1 ); - st_ivas->ism_mode = ivas_omasa_ism_mode_select_fx( ivas_total_brate, nchan_ism ); + /* the number of objects are written at the end of the bitstream */ + k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); + nchan_ism = add( add( shl( st_ivas->bit_stream[k - 1], 1 ), st_ivas->bit_stream[k - 2] ), 1 ); + st_ivas->ism_mode = ivas_omasa_ism_mode_select_fx( ivas_total_brate, nchan_ism ); - test(); - IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) - { + test(); + IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ){ #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ) - { - st_ivas->restartNeeded = 1; - move16(); - return IVAS_ERR_OK; - } - ELSE - { + IF( isVoipMode ){ + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; +} +ELSE +{ #endif #ifdef DEBUGGING - fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); + fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); #endif - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); #ifdef DECODER_FORMAT_SWITCHING - } +} #endif - } +} - st_ivas->nchan_ism = nchan_ism; - move16(); - } - ELSE IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) - { - /* the number of objects is written at the end of the bitstream, in the SBA metadata */ - k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); - nchan_ism = add( add( shl( st_ivas->bit_stream[k - 1], 1 ), st_ivas->bit_stream[k - 2] ), 1 ); +st_ivas->nchan_ism = nchan_ism; +move16(); +} +ELSE IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) +{ + /* the number of objects is written at the end of the bitstream, in the SBA metadata */ + k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); + nchan_ism = add( add( shl( st_ivas->bit_stream[k - 1], 1 ), st_ivas->bit_stream[k - 2] ), 1 ); - test(); - IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) - { + test(); + IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ){ #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ) - { - st_ivas->restartNeeded = 1; - move16(); - return IVAS_ERR_OK; - } - ELSE - { + IF( isVoipMode ){ + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; +} +ELSE +{ #endif #ifdef DEBUGGING - fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); + fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); #endif - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); #ifdef DECODER_FORMAT_SWITCHING - } +} #endif - } +} - st_ivas->nchan_ism = nchan_ism; - move16(); +st_ivas->nchan_ism = nchan_ism; +move16(); - /* read Ambisonic (SBA) planar flag */ - /*sba_planar = st_ivas->bit_stream[num_bits_read];*/ - num_bits_read = add( num_bits_read, SBA_PLANAR_BITS ); +/* read Ambisonic (SBA) planar flag */ +/*sba_planar = st_ivas->bit_stream[num_bits_read];*/ +num_bits_read = add( num_bits_read, SBA_PLANAR_BITS ); - /* read Ambisonic (SBA) order (0 for signaling OSBA format at low bitrates)*/ - sba_order = st_ivas->bit_stream[num_bits_read + 1]; - move16(); - sba_order = add( sba_order, shl( st_ivas->bit_stream[num_bits_read], 1 ) ); - num_bits_read = add( num_bits_read, SBA_ORDER_BITS ); +/* read Ambisonic (SBA) order (0 for signaling OSBA format at low bitrates)*/ +sba_order = st_ivas->bit_stream[num_bits_read + 1]; +move16(); +sba_order = add( sba_order, shl( st_ivas->bit_stream[num_bits_read], 1 ) ); +num_bits_read = add( num_bits_read, SBA_ORDER_BITS ); - /* read the real Ambisonic order when the above bits are used to signal OSBA format */ - IF( LT_32( ivas_total_brate, IVAS_24k4 ) ) - { - sba_order = st_ivas->bit_stream[num_bits_read + 1]; - move16(); - sba_order = add( sba_order, shl( st_ivas->bit_stream[num_bits_read], 1 ) ); - num_bits_read = add( num_bits_read, SBA_ORDER_BITS ); - } +/* read the real Ambisonic order when the above bits are used to signal OSBA format */ +IF( LT_32( ivas_total_brate, IVAS_24k4 ) ) +{ + sba_order = st_ivas->bit_stream[num_bits_read + 1]; + move16(); + sba_order = add( sba_order, shl( st_ivas->bit_stream[num_bits_read], 1 ) ); + num_bits_read = add( num_bits_read, SBA_ORDER_BITS ); +} - test(); - IF( st_ivas->ini_frame > 0 && NE_16( sba_order, st_ivas->sba_order ) ) - { +test(); +IF( st_ivas->ini_frame > 0 && NE_16( sba_order, st_ivas->sba_order ) ){ #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ) - { - st_ivas->restartNeeded = 1; - move16(); - return IVAS_ERR_OK; - } - ELSE - { + IF( isVoipMode ){ + st_ivas->restartNeeded = 1; +move16(); +return IVAS_ERR_OK; +} +ELSE +{ #endif #ifdef DEBUGGING - fprintf( stderr, "\nError: Changing the SBA order is not supported!\n" ); + fprintf( stderr, "\nError: Changing the SBA order is not supported!\n" ); #endif - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA order signalled!" ); + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA order signalled!" ); #ifdef DECODER_FORMAT_SWITCHING - } +} #endif - } +} - st_ivas->ism_mode = ivas_osba_ism_mode_select( ivas_total_brate, st_ivas->nchan_ism ); +st_ivas->ism_mode = ivas_osba_ism_mode_select( ivas_total_brate, st_ivas->nchan_ism ); - sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, sba_order ); - st_ivas->nchan_transport = ivas_get_sba_num_TCs_fx( ivas_total_brate, sba_analysis_order ); - } - ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) ) +sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, sba_order ); +st_ivas->nchan_transport = ivas_get_sba_num_TCs_fx( ivas_total_brate, sba_analysis_order ); +} +ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) ) +{ + /* read MC configuration */ + idx = 0; + move16(); + FOR( k = 0; k < MC_LS_SETUP_BITS; k++ ) + { + IF( st_ivas->bit_stream[num_bits_read + k] ) { - /* read MC configuration */ - idx = 0; - move16(); - FOR( k = 0; k < MC_LS_SETUP_BITS; k++ ) - { - IF( st_ivas->bit_stream[num_bits_read + k] ) - { - idx = add( idx, shl( 1, sub( ( MC_LS_SETUP_BITS - 1 ), k ) ) ); - } - } - num_bits_read = add( num_bits_read, MC_LS_SETUP_BITS ); + idx = add( idx, shl( 1, sub( ( MC_LS_SETUP_BITS - 1 ), k ) ) ); + } + } + num_bits_read = add( num_bits_read, MC_LS_SETUP_BITS ); - signaled_config = ivas_mc_map_ls_setup_to_output_config_fx( idx ); + signaled_config = ivas_mc_map_ls_setup_to_output_config_fx( idx ); - test(); - IF( st_ivas->ini_frame > 0 && NE_32( st_ivas->transport_config, signaled_config ) ) - { + test(); + IF( st_ivas->ini_frame > 0 && NE_32( st_ivas->transport_config, signaled_config ) ){ #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ) - { - st_ivas->restartNeeded = 1; - move16(); - return IVAS_ERR_OK; - } - ELSE - { + IF( isVoipMode ){ + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; +} +ELSE +{ #endif #ifdef DEBUGGING - fprintf( stderr, "\nError: Switching of MC configurations is not supported!\n" ); + fprintf( stderr, "\nError: Switching of MC configurations is not supported!\n" ); #endif - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "wrong MC configuration signalled!" ); + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "wrong MC configuration signalled!" ); #ifdef DECODER_FORMAT_SWITCHING - } +} #endif - } +} - st_ivas->mc_mode = ivas_mc_mode_select_fx( ivas_mc_map_output_config_to_mc_ls_setup_fx( signaled_config ), ivas_total_brate ); - st_ivas->transport_config = signaled_config; - move16(); - } +st_ivas->mc_mode = ivas_mc_mode_select_fx( ivas_mc_map_output_config_to_mc_ls_setup_fx( signaled_config ), ivas_total_brate ); +st_ivas->transport_config = signaled_config; +move16(); +} - /*-------------------------------------------------------------------* - * Read element mode - *-------------------------------------------------------------------*/ +/*-------------------------------------------------------------------* + * Read element mode + *-------------------------------------------------------------------*/ - test(); - IF( st_ivas->ini_frame == 0 && element_mode_flag ) +test(); +IF( st_ivas->ini_frame == 0 && element_mode_flag ) +{ + /* read stereo technology info */ + if ( LT_32( ivas_total_brate, MIN_BRATE_MDCT_STEREO ) ) + { + /* 1 bit */ + IF( st_ivas->bit_stream[num_bits_read] ) { - /* read stereo technology info */ - if ( LT_32( ivas_total_brate, MIN_BRATE_MDCT_STEREO ) ) + st_ivas->element_mode_init = add( 1, IVAS_CPE_DFT ); + } + ELSE + { + st_ivas->element_mode_init = add( 0, IVAS_CPE_DFT ); + } + } + ELSE + { + st_ivas->element_mode_init = IVAS_CPE_MDCT; + move16(); + } +} +} +ELSE IF( EQ_32( ivas_total_brate, IVAS_SID_5k2 ) ) +{ + SWITCH( st_ivas->sid_format ) + { + case SID_DFT_STEREO: + st_ivas->element_mode_init = IVAS_CPE_DFT; + move16(); + BREAK; + case SID_MDCT_STEREO: + st_ivas->element_mode_init = IVAS_CPE_MDCT; + move16(); + BREAK; + case SID_ISM: + st_ivas->element_mode_init = IVAS_SCE; + move16(); + BREAK; + case SID_MASA_1TC: + st_ivas->element_mode_init = IVAS_SCE; + move16(); + st_ivas->nchan_transport = 1; + move16(); + BREAK; + case SID_MASA_2TC: + k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); + IF( st_ivas->bit_stream[k - 1 - SID_FORMAT_NBITS] == 1 ) { - /* 1 bit */ - IF( st_ivas->bit_stream[num_bits_read] ) - { - st_ivas->element_mode_init = add( 1, IVAS_CPE_DFT ); - } - ELSE - { - st_ivas->element_mode_init = add( 0, IVAS_CPE_DFT ); - } + st_ivas->element_mode_init = IVAS_CPE_MDCT; + move16(); } ELSE { - st_ivas->element_mode_init = IVAS_CPE_MDCT; + st_ivas->element_mode_init = IVAS_CPE_DFT; move16(); } - } + st_ivas->nchan_transport = 2; + move16(); + BREAK; + case SID_SBA_1TC: + st_ivas->element_mode_init = IVAS_SCE; + move16(); + BREAK; + case SID_SBA_2TC: + st_ivas->element_mode_init = IVAS_CPE_MDCT; + move16(); + BREAK; } - ELSE IF( EQ_32( ivas_total_brate, IVAS_SID_5k2 ) ) - { - SWITCH( st_ivas->sid_format ) - { - case SID_DFT_STEREO: - st_ivas->element_mode_init = IVAS_CPE_DFT; - move16(); - BREAK; - case SID_MDCT_STEREO: - st_ivas->element_mode_init = IVAS_CPE_MDCT; - move16(); - BREAK; - case SID_ISM: - st_ivas->element_mode_init = IVAS_SCE; - move16(); - BREAK; - case SID_MASA_1TC: - st_ivas->element_mode_init = IVAS_SCE; - move16(); - st_ivas->nchan_transport = 1; - move16(); - BREAK; - case SID_MASA_2TC: - k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); - IF( st_ivas->bit_stream[k - 1 - SID_FORMAT_NBITS] == 1 ) - { - st_ivas->element_mode_init = IVAS_CPE_MDCT; - move16(); - } - ELSE - { - st_ivas->element_mode_init = IVAS_CPE_DFT; - move16(); - } - st_ivas->nchan_transport = 2; - move16(); - BREAK; - case SID_SBA_1TC: - st_ivas->element_mode_init = IVAS_SCE; - move16(); - BREAK; - case SID_SBA_2TC: - st_ivas->element_mode_init = IVAS_CPE_MDCT; - move16(); - BREAK; - } - IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) ) + IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) ) + { + /* read the number of objects */ + nchan_ism = 1; + move16(); + k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); + k = sub( sub( k, 1 ), SID_FORMAT_NBITS ); + WHILE( st_ivas->bit_stream[k] && ( nchan_ism < MAX_NUM_OBJECTS ) ) { - /* read the number of objects */ - nchan_ism = 1; - move16(); - k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); - k = sub( sub( k, 1 ), SID_FORMAT_NBITS ); - WHILE( st_ivas->bit_stream[k] && ( nchan_ism < MAX_NUM_OBJECTS ) ) - { - nchan_ism = add( nchan_ism, 1 ); - k = sub( k, 1 ); - } + nchan_ism = add( nchan_ism, 1 ); k = sub( k, 1 ); + } + k = sub( k, 1 ); - test(); - IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) - { + test(); + IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ){ #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ) - { - st_ivas->restartNeeded = 1; - move16(); - return IVAS_ERR_OK; - } - else - { + IF( isVoipMode ){ + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } + else + { #endif #ifdef DEBUGGING - fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); + fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); #endif - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); #ifdef DECODER_FORMAT_SWITCHING - } + } #endif - } +} - st_ivas->nchan_ism = nchan_ism; - move16(); +st_ivas->nchan_ism = nchan_ism; +move16(); - /* read ism_mode */ - st_ivas->ism_mode = ISM_MODE_DISC; - move32(); - IF( GT_16( nchan_ism, 2 ) ) - { - k = sub( k, nchan_ism ); /* SID metadata flags */ - idx = st_ivas->bit_stream[k]; - move16(); - st_ivas->ism_mode = (ISM_MODE) add( idx, 1 ); - move32(); - } +/* read ism_mode */ +st_ivas->ism_mode = ISM_MODE_DISC; +move32(); +IF( GT_16( nchan_ism, 2 ) ) +{ + k = sub( k, nchan_ism ); /* SID metadata flags */ + idx = st_ivas->bit_stream[k]; + move16(); + st_ivas->ism_mode = (ISM_MODE) add( idx, 1 ); + move32(); +} - st_ivas->nchan_transport = nchan_ism; - move16(); - if ( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) ) - { - st_ivas->nchan_transport = MAX_PARAM_ISM_WAVE; - move16(); - } - } - } +st_ivas->nchan_transport = nchan_ism; +move16(); +if ( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) ) +{ + st_ivas->nchan_transport = MAX_PARAM_ISM_WAVE; + move16(); +} +} +} - st_ivas->bit_stream = bit_stream_orig; +st_ivas->bit_stream = bit_stream_orig; - return IVAS_ERR_OK; +return IVAS_ERR_OK; } -- GitLab From c491820267035f7df4597c26ee2e5d62cb36ec6d Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Mon, 10 Nov 2025 22:57:09 +0200 Subject: [PATCH 3/6] Fix function call --- apps/decoder.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/decoder.c b/apps/decoder.c index 0f25996bc..6c5f9a9b9 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -4287,9 +4287,15 @@ ivas_error restartDecoder( uint16_t aeID = arg->aeSequence.count > 0 ? arg->aeSequence.pID[0] : 65535; IVAS_AUDIO_CONFIG outputConfig = ( codec == IVAS_DEC_MODE_IVAS ) ? arg->outputConfig : IVAS_AUDIO_CONFIG_MONO; +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE + if ( ( error = IVAS_DEC_Configure( hIvasDec, arg->output_Fs, outputConfig, arg->renderFramesize, arg->customLsOutputEnabled, arg->hrtfReaderEnabled, + arg->enableHeadRotation, arg->enableExternalOrientation, arg->orientation_tracking, arg->renderConfigEnabled, arg->roomSize, arg->non_diegetic_pan_enabled, + arg->non_diegetic_pan_gain_fx, arg->dpidEnabled, aeID, arg->objEditEnabled, arg->delayCompensationEnabled ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_DEC_Configure( hIvasDec, arg->output_Fs, outputConfig, arg->renderFramesize, arg->customLsOutputEnabled, arg->hrtfReaderEnabled, arg->enableHeadRotation, arg->enableExternalOrientation, arg->orientation_tracking, arg->renderConfigEnabled, arg->non_diegetic_pan_enabled, - arg->non_diegetic_pan_gain, arg->dpidEnabled, aeID, arg->objEditEnabled, arg->delayCompensationEnabled ) ) != IVAS_ERR_OK ) + arg->non_diegetic_pan_gain_fx, arg->dpidEnabled, aeID, arg->objEditEnabled, arg->delayCompensationEnabled ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; -- GitLab From 606baabdde46be462e04fc5167c93fb484e0acc1 Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Mon, 10 Nov 2025 23:57:22 +0200 Subject: [PATCH 4/6] Format code --- lib_dec/ivas_init_dec_fx.c | 959 +++++++++++++++++++------------------ lib_dec/lib_dec_fx.c | 2 + 2 files changed, 504 insertions(+), 457 deletions(-) diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index 5c6649b54..faafc0e3c 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -145,525 +145,570 @@ ivas_error ivas_dec_get_format_fx( test(); IF( st_ivas->ini_frame > 0 && NE_32( st_ivas->ivas_format, st_ivas->last_ivas_format ) && !( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) && EQ_32( st_ivas->last_ivas_format, MASA_ISM_FORMAT ) ) && - !( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_32( st_ivas->last_ivas_format, MASA_FORMAT ) ) ){ + !( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_32( st_ivas->last_ivas_format, MASA_FORMAT ) ) ) + { #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ){ + IF( isVoipMode ) + { st_ivas->restartNeeded = 1; - move16(); - return IVAS_ERR_OK; -} -ELSE -{ + move16(); + return IVAS_ERR_OK; + } + ELSE + { +#ifdef DEBUGGING + fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); #endif + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); + } +#else #ifdef DEBUGGING - fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); + fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); #endif - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); -#ifdef DECODER_FORMAT_SWITCHING -} + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); #endif -} - -/*-------------------------------------------------------------------* - * Read other signaling (ISM/MC mode, number of channels, etc.) - *-------------------------------------------------------------------*/ + } -IF( is_DTXrate( ivas_total_brate ) == 0 ) -{ /*-------------------------------------------------------------------* - * Read IVAS format related signaling: - * - in ISM : read number of objects - * - in SBA : read SBA planar flag and SBA order - * - in MASA : read number of TC - * - in MC : read LS setup + * Read other signaling (ISM/MC mode, number of channels, etc.) *-------------------------------------------------------------------*/ - IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) - { - element_mode_flag = 1; - move16(); - } - ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) ) + IF( is_DTXrate( ivas_total_brate ) == 0 ) { - /* read the number of objects */ - nchan_ism = 1; - move16(); - k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); - k = sub( k, 1 ); - WHILE( st_ivas->bit_stream[k] && ( nchan_ism < MAX_NUM_OBJECTS ) ) + /*-------------------------------------------------------------------* + * Read IVAS format related signaling: + * - in ISM : read number of objects + * - in SBA : read SBA planar flag and SBA order + * - in MASA : read number of TC + * - in MC : read LS setup + *-------------------------------------------------------------------*/ + + IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) { - nchan_ism = add( nchan_ism, 1 ); - k = sub( k, 1 ); + element_mode_flag = 1; + move16(); } + ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) ) + { + /* read the number of objects */ + nchan_ism = 1; + move16(); + k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); + k = sub( k, 1 ); + WHILE( st_ivas->bit_stream[k] && ( nchan_ism < MAX_NUM_OBJECTS ) ) + { + nchan_ism = add( nchan_ism, 1 ); + k = sub( k, 1 ); + } - test(); - IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ){ -#ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ){ - st_ivas->restartNeeded = 1; - move16(); - return IVAS_ERR_OK; - } - ELSE - { -#endif -#ifdef DEBUGGING - fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); -#endif - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); -#ifdef DECODER_FORMAT_SWITCHING - } -#endif -} + test(); + IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) + { + #ifdef DECODER_FORMAT_SWITCHING + IF( isVoipMode ) + { + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } + ELSE + { + #ifdef DEBUGGING + fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); + #endif + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); + } + #else + #ifdef DEBUGGING + fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); + #endif + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); + #endif + } -st_ivas->nchan_ism = nchan_ism; -move16(); -st_ivas->ism_mode = ivas_ism_mode_select( nchan_ism, ivas_total_brate ); + st_ivas->nchan_ism = nchan_ism; + move16(); + st_ivas->ism_mode = ivas_ism_mode_select( nchan_ism, ivas_total_brate ); -st_ivas->nchan_transport = nchan_ism; -move16(); -if ( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) ) -{ - st_ivas->nchan_transport = MAX_PARAM_ISM_WAVE; - move16(); -} -} -ELSE IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) ) -{ - /* read Ambisonic (SBA) planar flag */ - sba_planar = st_ivas->bit_stream[num_bits_read]; - num_bits_read = add( num_bits_read, SBA_PLANAR_BITS ); + st_ivas->nchan_transport = nchan_ism; + move16(); + if ( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) ) + { + st_ivas->nchan_transport = MAX_PARAM_ISM_WAVE; + move16(); + } + } + ELSE IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) ) + { + /* read Ambisonic (SBA) planar flag */ + sba_planar = st_ivas->bit_stream[num_bits_read]; + num_bits_read = add( num_bits_read, SBA_PLANAR_BITS ); - test(); - IF( st_ivas->ini_frame > 0 && NE_16( sba_planar, st_ivas->sba_planar ) ){ -#ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ){ - st_ivas->restartNeeded = 1; - move16(); - return IVAS_ERR_OK; -} -ELSE -{ -#endif -#ifdef DEBUGGING - fprintf( stderr, "\nError: Changing the SBA planar/3D layout is not supported!\n" ); -#endif - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA planar flag signalled!" ); -#ifdef DECODER_FORMAT_SWITCHING -} -#endif -} + test(); + IF( st_ivas->ini_frame > 0 && NE_16( sba_planar, st_ivas->sba_planar ) ) + { + #ifdef DECODER_FORMAT_SWITCHING + IF( isVoipMode ) + { + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } + ELSE + { + #ifdef DEBUGGING + fprintf( stderr, "\nError: Changing the SBA planar/3D layout is not supported!\n" ); + #endif + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA planar flag signalled!" ); + } + #else + #ifdef DEBUGGING + fprintf( stderr, "\nError: Changing the SBA planar/3D layout is not supported!\n" ); + #endif + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA planar flag signalled!" ); + #endif + } -/* read Ambisonic (SBA) order */ -sba_order = st_ivas->bit_stream[num_bits_read + 1]; -move16(); -sba_order = add( sba_order, shl( st_ivas->bit_stream[num_bits_read], 1 ) ); + /* read Ambisonic (SBA) order */ + sba_order = st_ivas->bit_stream[num_bits_read + 1]; + move16(); + sba_order = add( sba_order, shl( st_ivas->bit_stream[num_bits_read], 1 ) ); -test(); -IF( st_ivas->ini_frame > 0 && NE_16( sba_order, st_ivas->sba_order ) ){ -#ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ){ - st_ivas->restartNeeded = 1; -move16(); -return IVAS_ERR_OK; -} -ELSE -{ -#endif -#ifdef DEBUGGING - fprintf( stderr, "\nError: Changing the SBA order is not supported!\n" ); -#endif - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA order signalled!" ); -#ifdef DECODER_FORMAT_SWITCHING -} -#endif -} + test(); + IF( st_ivas->ini_frame > 0 && NE_16( sba_order, st_ivas->sba_order ) ) + { + #ifdef DECODER_FORMAT_SWITCHING + IF( isVoipMode ) + { + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } + ELSE + { + #ifdef DEBUGGING + fprintf( stderr, "\nError: Changing the SBA order is not supported!\n" ); + #endif + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA order signalled!" ); + } + #ifdef DEBUGGING + fprintf( stderr, "\nError: Changing the SBA order is not supported!\n" ); + #endif + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA order signalled!" ); + #else + #endif + } -sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, sba_order ); -st_ivas->nchan_transport = ivas_get_sba_num_TCs_fx( ivas_total_brate, sba_analysis_order ); -} -ELSE IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) ) -{ -#ifdef DECODER_FORMAT_SWITCHING - UWord8 masaRestartCandidate; - masaRestartCandidate = 0; - move16(); -#endif - /* read number of MASA transport channels */ - k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); - IF( st_ivas->bit_stream[k - 1] ) - { -#ifdef DECODER_FORMAT_SWITCHING - test(); - IF( st_ivas->nchan_transport == 1 && isVoipMode ) - { - masaRestartCandidate = 1; - move16(); + sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, sba_order ); + st_ivas->nchan_transport = ivas_get_sba_num_TCs_fx( ivas_total_brate, sba_analysis_order ); } -#endif - st_ivas->nchan_transport = 2; - move16(); - element_mode_flag = 1; - move16(); - } - ELSE - { -#ifdef DECODER_FORMAT_SWITCHING - test(); - IF( st_ivas->nchan_transport == 2 && isVoipMode ) + ELSE IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) ) { - masaRestartCandidate = 1; + #ifdef DECODER_FORMAT_SWITCHING + UWord8 masaRestartCandidate; + masaRestartCandidate = 0; move16(); - } -#endif - st_ivas->nchan_transport = 1; - move16(); - } - - /* this should be non-zero if original input format was MASA_ISM_FORMAT */ - st_ivas->ism_mode = ISM_MODE_NONE; - move16(); - nchan_ism = add( st_ivas->bit_stream[k - 3], shl( st_ivas->bit_stream[k - 2], 1 ) ); + #endif + /* read number of MASA transport channels */ + k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); + IF( st_ivas->bit_stream[k - 1] ) + { + #ifdef DECODER_FORMAT_SWITCHING + test(); + IF( st_ivas->nchan_transport == 1 && isVoipMode ) + { + masaRestartCandidate = 1; + move16(); + } + #endif + st_ivas->nchan_transport = 2; + move16(); + element_mode_flag = 1; + move16(); + } + ELSE + { + #ifdef DECODER_FORMAT_SWITCHING + test(); + IF( st_ivas->nchan_transport == 2 && isVoipMode ) + { + masaRestartCandidate = 1; + move16(); + } + #endif + st_ivas->nchan_transport = 1; + move16(); + } - IF( nchan_ism > 0 ) - { - /* the input_ivas_format should be MASA_ISM_FORMAT, but we cannot initialize it now */ - /* info about the number of objects: - '00' - MASA format at the encoder - '01' - MASA_ISM_FORMAT at the encoder, with 4 objects - '10' - MASA_ISM_FORMAT at the encoder, with 3 objects - '11' - MASA_ISM_FORMAT at the encoder, with 1 or 2 objects - reading if 1 or 2 objects is performed later - */ - nchan_ism = sub( 5, nchan_ism ); - test(); - IF( EQ_16( st_ivas->nchan_transport, 1 ) && EQ_16( nchan_ism, 2 ) ) - { - nchan_ism = 1; + /* this should be non-zero if original input format was MASA_ISM_FORMAT */ + st_ivas->ism_mode = ISM_MODE_NONE; move16(); - } + nchan_ism = add( st_ivas->bit_stream[k - 3], shl( st_ivas->bit_stream[k - 2], 1 ) ); - /* for MASA_ISM_FORMAT at input the number of MASA transport channels is always 2 and the corresponding bit is not used here*/ - st_ivas->nchan_transport = 2; - move16(); - element_mode_flag = 1; - move16(); - } -#ifdef DECODER_FORMAT_SWITCHING - ELSE IF( masaRestartCandidate > 0 ) - { - st_ivas->restartNeeded = 1; - move16(); - return IVAS_ERR_OK; - } -#endif + IF( nchan_ism > 0 ) + { + /* the input_ivas_format should be MASA_ISM_FORMAT, but we cannot initialize it now */ + /* info about the number of objects: + '00' - MASA format at the encoder + '01' - MASA_ISM_FORMAT at the encoder, with 4 objects + '10' - MASA_ISM_FORMAT at the encoder, with 3 objects + '11' - MASA_ISM_FORMAT at the encoder, with 1 or 2 objects + reading if 1 or 2 objects is performed later + */ + nchan_ism = sub( 5, nchan_ism ); + test(); + IF( EQ_16( st_ivas->nchan_transport, 1 ) && EQ_16( nchan_ism, 2 ) ) + { + nchan_ism = 1; + move16(); + } - test(); - IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ){ -#ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ){ - st_ivas->restartNeeded = 1; - move16(); - return IVAS_ERR_OK; -} -ELSE -{ -#endif -#ifdef DEBUGGING - fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); -#endif - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); -#ifdef DECODER_FORMAT_SWITCHING -} -#endif -} + /* for MASA_ISM_FORMAT at input the number of MASA transport channels is always 2 and the corresponding bit is not used here*/ + st_ivas->nchan_transport = 2; + move16(); + element_mode_flag = 1; + move16(); + } + #ifdef DECODER_FORMAT_SWITCHING + ELSE IF( masaRestartCandidate > 0 ) + { + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } + #endif -st_ivas->nchan_ism = nchan_ism; -move16(); -} -ELSE IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) -{ - st_ivas->nchan_transport = 2; /* always 2 MASA transport channels */ - move16(); + test(); + IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) + { + #ifdef DECODER_FORMAT_SWITCHING + IF( isVoipMode ) + { + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } + ELSE + { + #ifdef DEBUGGING + fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); + #endif + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); + } + #else + #ifdef DEBUGGING + fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); + #endif + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); + #endif + } - /* the number of objects are written at the end of the bitstream */ - k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); - nchan_ism = add( add( shl( st_ivas->bit_stream[k - 1], 1 ), st_ivas->bit_stream[k - 2] ), 1 ); - st_ivas->ism_mode = ivas_omasa_ism_mode_select_fx( ivas_total_brate, nchan_ism ); + st_ivas->nchan_ism = nchan_ism; + move16(); + } + ELSE IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) + { + st_ivas->nchan_transport = 2; /* always 2 MASA transport channels */ + move16(); - test(); - IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ){ -#ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ){ - st_ivas->restartNeeded = 1; - move16(); - return IVAS_ERR_OK; -} -ELSE -{ -#endif -#ifdef DEBUGGING - fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); -#endif - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); -#ifdef DECODER_FORMAT_SWITCHING -} -#endif -} + /* the number of objects are written at the end of the bitstream */ + k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); + nchan_ism = add( add( shl( st_ivas->bit_stream[k - 1], 1 ), st_ivas->bit_stream[k - 2] ), 1 ); + st_ivas->ism_mode = ivas_omasa_ism_mode_select_fx( ivas_total_brate, nchan_ism ); -st_ivas->nchan_ism = nchan_ism; -move16(); -} -ELSE IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) -{ - /* the number of objects is written at the end of the bitstream, in the SBA metadata */ - k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); - nchan_ism = add( add( shl( st_ivas->bit_stream[k - 1], 1 ), st_ivas->bit_stream[k - 2] ), 1 ); + test(); + IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) + { + #ifdef DECODER_FORMAT_SWITCHING + IF( isVoipMode ){ + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } + ELSE + { + #ifdef DEBUGGING + fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); + #endif + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); + } + #else + #ifdef DEBUGGING + fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); + #endif + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); + #endif + } - test(); - IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ){ -#ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ){ - st_ivas->restartNeeded = 1; - move16(); - return IVAS_ERR_OK; -} -ELSE -{ -#endif -#ifdef DEBUGGING - fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); -#endif - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); -#ifdef DECODER_FORMAT_SWITCHING -} -#endif -} + st_ivas->nchan_ism = nchan_ism; + move16(); + } + ELSE IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) + { + /* the number of objects is written at the end of the bitstream, in the SBA metadata */ + k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); + nchan_ism = add( add( shl( st_ivas->bit_stream[k - 1], 1 ), st_ivas->bit_stream[k - 2] ), 1 ); -st_ivas->nchan_ism = nchan_ism; -move16(); + test(); + IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) + { + #ifdef DECODER_FORMAT_SWITCHING + IF( isVoipMode ) + { + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } + ELSE + { + #ifdef DEBUGGING + fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); + #endif + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); + } + #else + #ifdef DEBUGGING + fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); + #endif + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); + #endif + } -/* read Ambisonic (SBA) planar flag */ -/*sba_planar = st_ivas->bit_stream[num_bits_read];*/ -num_bits_read = add( num_bits_read, SBA_PLANAR_BITS ); + st_ivas->nchan_ism = nchan_ism; + move16(); -/* read Ambisonic (SBA) order (0 for signaling OSBA format at low bitrates)*/ -sba_order = st_ivas->bit_stream[num_bits_read + 1]; -move16(); -sba_order = add( sba_order, shl( st_ivas->bit_stream[num_bits_read], 1 ) ); -num_bits_read = add( num_bits_read, SBA_ORDER_BITS ); + /* read Ambisonic (SBA) planar flag */ + /*sba_planar = st_ivas->bit_stream[num_bits_read];*/ + num_bits_read = add( num_bits_read, SBA_PLANAR_BITS ); -/* read the real Ambisonic order when the above bits are used to signal OSBA format */ -IF( LT_32( ivas_total_brate, IVAS_24k4 ) ) -{ - sba_order = st_ivas->bit_stream[num_bits_read + 1]; - move16(); - sba_order = add( sba_order, shl( st_ivas->bit_stream[num_bits_read], 1 ) ); - num_bits_read = add( num_bits_read, SBA_ORDER_BITS ); -} + /* read Ambisonic (SBA) order (0 for signaling OSBA format at low bitrates)*/ + sba_order = st_ivas->bit_stream[num_bits_read + 1]; + move16(); + sba_order = add( sba_order, shl( st_ivas->bit_stream[num_bits_read], 1 ) ); + num_bits_read = add( num_bits_read, SBA_ORDER_BITS ); -test(); -IF( st_ivas->ini_frame > 0 && NE_16( sba_order, st_ivas->sba_order ) ){ -#ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ){ - st_ivas->restartNeeded = 1; -move16(); -return IVAS_ERR_OK; -} -ELSE -{ -#endif -#ifdef DEBUGGING - fprintf( stderr, "\nError: Changing the SBA order is not supported!\n" ); -#endif - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA order signalled!" ); -#ifdef DECODER_FORMAT_SWITCHING -} -#endif -} + /* read the real Ambisonic order when the above bits are used to signal OSBA format */ + IF( LT_32( ivas_total_brate, IVAS_24k4 ) ) + { + sba_order = st_ivas->bit_stream[num_bits_read + 1]; + move16(); + sba_order = add( sba_order, shl( st_ivas->bit_stream[num_bits_read], 1 ) ); + num_bits_read = add( num_bits_read, SBA_ORDER_BITS ); + } -st_ivas->ism_mode = ivas_osba_ism_mode_select( ivas_total_brate, st_ivas->nchan_ism ); + test(); + IF( st_ivas->ini_frame > 0 && NE_16( sba_order, st_ivas->sba_order ) ) + { + #ifdef DECODER_FORMAT_SWITCHING + IF( isVoipMode ){ + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } + ELSE + { + #ifdef DEBUGGING + fprintf( stderr, "\nError: Changing the SBA order is not supported!\n" ); + #endif + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA order signalled!" ); + } + #else + #ifdef DEBUGGING + fprintf( stderr, "\nError: Changing the SBA order is not supported!\n" ); + #endif + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA order signalled!" ); + #endif + } -sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, sba_order ); -st_ivas->nchan_transport = ivas_get_sba_num_TCs_fx( ivas_total_brate, sba_analysis_order ); -} -ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) ) -{ - /* read MC configuration */ - idx = 0; - move16(); - FOR( k = 0; k < MC_LS_SETUP_BITS; k++ ) - { - IF( st_ivas->bit_stream[num_bits_read + k] ) - { - idx = add( idx, shl( 1, sub( ( MC_LS_SETUP_BITS - 1 ), k ) ) ); + st_ivas->ism_mode = ivas_osba_ism_mode_select( ivas_total_brate, st_ivas->nchan_ism ); + + sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, sba_order ); + st_ivas->nchan_transport = ivas_get_sba_num_TCs_fx( ivas_total_brate, sba_analysis_order ); } - } - num_bits_read = add( num_bits_read, MC_LS_SETUP_BITS ); + ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) ) + { + /* read MC configuration */ + idx = 0; + move16(); + FOR( k = 0; k < MC_LS_SETUP_BITS; k++ ) + { + IF( st_ivas->bit_stream[num_bits_read + k] ) + { + idx = add( idx, shl( 1, sub( ( MC_LS_SETUP_BITS - 1 ), k ) ) ); + } + } + num_bits_read = add( num_bits_read, MC_LS_SETUP_BITS ); - signaled_config = ivas_mc_map_ls_setup_to_output_config_fx( idx ); + signaled_config = ivas_mc_map_ls_setup_to_output_config_fx( idx ); - test(); - IF( st_ivas->ini_frame > 0 && NE_32( st_ivas->transport_config, signaled_config ) ){ -#ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ){ - st_ivas->restartNeeded = 1; - move16(); - return IVAS_ERR_OK; -} -ELSE -{ -#endif -#ifdef DEBUGGING - fprintf( stderr, "\nError: Switching of MC configurations is not supported!\n" ); -#endif - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "wrong MC configuration signalled!" ); -#ifdef DECODER_FORMAT_SWITCHING -} -#endif -} + test(); + IF( st_ivas->ini_frame > 0 && NE_32( st_ivas->transport_config, signaled_config ) ) + { + #ifdef DECODER_FORMAT_SWITCHING + IF( isVoipMode ){ + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } + ELSE + { + #ifdef DEBUGGING + fprintf( stderr, "\nError: Switching of MC configurations is not supported!\n" ); + #endif + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "wrong MC configuration signalled!" ); + } + #else + #ifdef DEBUGGING + fprintf( stderr, "\nError: Switching of MC configurations is not supported!\n" ); + #endif + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "wrong MC configuration signalled!" ); + #endif + } -st_ivas->mc_mode = ivas_mc_mode_select_fx( ivas_mc_map_output_config_to_mc_ls_setup_fx( signaled_config ), ivas_total_brate ); -st_ivas->transport_config = signaled_config; -move16(); -} + st_ivas->mc_mode = ivas_mc_mode_select_fx( ivas_mc_map_output_config_to_mc_ls_setup_fx( signaled_config ), ivas_total_brate ); + st_ivas->transport_config = signaled_config; + move16(); + } -/*-------------------------------------------------------------------* - * Read element mode - *-------------------------------------------------------------------*/ + /*-------------------------------------------------------------------* + * Read element mode + *-------------------------------------------------------------------*/ -test(); -IF( st_ivas->ini_frame == 0 && element_mode_flag ) -{ - /* read stereo technology info */ - if ( LT_32( ivas_total_brate, MIN_BRATE_MDCT_STEREO ) ) - { - /* 1 bit */ - IF( st_ivas->bit_stream[num_bits_read] ) - { - st_ivas->element_mode_init = add( 1, IVAS_CPE_DFT ); - } - ELSE + test(); + IF( st_ivas->ini_frame == 0 && element_mode_flag ) { - st_ivas->element_mode_init = add( 0, IVAS_CPE_DFT ); - } - } - ELSE - { - st_ivas->element_mode_init = IVAS_CPE_MDCT; - move16(); - } -} -} -ELSE IF( EQ_32( ivas_total_brate, IVAS_SID_5k2 ) ) -{ - SWITCH( st_ivas->sid_format ) - { - case SID_DFT_STEREO: - st_ivas->element_mode_init = IVAS_CPE_DFT; - move16(); - BREAK; - case SID_MDCT_STEREO: - st_ivas->element_mode_init = IVAS_CPE_MDCT; - move16(); - BREAK; - case SID_ISM: - st_ivas->element_mode_init = IVAS_SCE; - move16(); - BREAK; - case SID_MASA_1TC: - st_ivas->element_mode_init = IVAS_SCE; - move16(); - st_ivas->nchan_transport = 1; - move16(); - BREAK; - case SID_MASA_2TC: - k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); - IF( st_ivas->bit_stream[k - 1 - SID_FORMAT_NBITS] == 1 ) + /* read stereo technology info */ + if ( LT_32( ivas_total_brate, MIN_BRATE_MDCT_STEREO ) ) { - st_ivas->element_mode_init = IVAS_CPE_MDCT; - move16(); + /* 1 bit */ + IF( st_ivas->bit_stream[num_bits_read] ) + { + st_ivas->element_mode_init = add( 1, IVAS_CPE_DFT ); + } + ELSE + { + st_ivas->element_mode_init = add( 0, IVAS_CPE_DFT ); + } } ELSE { - st_ivas->element_mode_init = IVAS_CPE_DFT; + st_ivas->element_mode_init = IVAS_CPE_MDCT; move16(); } - st_ivas->nchan_transport = 2; - move16(); - BREAK; - case SID_SBA_1TC: - st_ivas->element_mode_init = IVAS_SCE; - move16(); - BREAK; - case SID_SBA_2TC: - st_ivas->element_mode_init = IVAS_CPE_MDCT; - move16(); - BREAK; + } } - - IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) ) + ELSE IF( EQ_32( ivas_total_brate, IVAS_SID_5k2 ) ) { - /* read the number of objects */ - nchan_ism = 1; - move16(); - k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); - k = sub( sub( k, 1 ), SID_FORMAT_NBITS ); - WHILE( st_ivas->bit_stream[k] && ( nchan_ism < MAX_NUM_OBJECTS ) ) + SWITCH( st_ivas->sid_format ) { - nchan_ism = add( nchan_ism, 1 ); - k = sub( k, 1 ); + case SID_DFT_STEREO: + st_ivas->element_mode_init = IVAS_CPE_DFT; + move16(); + BREAK; + case SID_MDCT_STEREO: + st_ivas->element_mode_init = IVAS_CPE_MDCT; + move16(); + BREAK; + case SID_ISM: + st_ivas->element_mode_init = IVAS_SCE; + move16(); + BREAK; + case SID_MASA_1TC: + st_ivas->element_mode_init = IVAS_SCE; + move16(); + st_ivas->nchan_transport = 1; + move16(); + BREAK; + case SID_MASA_2TC: + k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); + IF( st_ivas->bit_stream[k - 1 - SID_FORMAT_NBITS] == 1 ) + { + st_ivas->element_mode_init = IVAS_CPE_MDCT; + move16(); + } + ELSE + { + st_ivas->element_mode_init = IVAS_CPE_DFT; + move16(); + } + st_ivas->nchan_transport = 2; + move16(); + BREAK; + case SID_SBA_1TC: + st_ivas->element_mode_init = IVAS_SCE; + move16(); + BREAK; + case SID_SBA_2TC: + st_ivas->element_mode_init = IVAS_CPE_MDCT; + move16(); + BREAK; } - k = sub( k, 1 ); - test(); - IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ){ -#ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ){ - st_ivas->restartNeeded = 1; - move16(); - return IVAS_ERR_OK; - } - else - { -#endif -#ifdef DEBUGGING - fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); -#endif - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); -#ifdef DECODER_FORMAT_SWITCHING - } -#endif -} + IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) ) + { + /* read the number of objects */ + nchan_ism = 1; + move16(); + k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); + k = sub( sub( k, 1 ), SID_FORMAT_NBITS ); + WHILE( st_ivas->bit_stream[k] && ( nchan_ism < MAX_NUM_OBJECTS ) ) + { + nchan_ism = add( nchan_ism, 1 ); + k = sub( k, 1 ); + } + k = sub( k, 1 ); + + test(); + IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ){ + #ifdef DECODER_FORMAT_SWITCHING + IF( isVoipMode ){ + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } + ELSE + { + #ifdef DEBUGGING + fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); + #endif + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); + } + #else + #ifdef DEBUGGING + fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); + #endif + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); + #endif + } -st_ivas->nchan_ism = nchan_ism; -move16(); + st_ivas->nchan_ism = nchan_ism; + move16(); -/* read ism_mode */ -st_ivas->ism_mode = ISM_MODE_DISC; -move32(); -IF( GT_16( nchan_ism, 2 ) ) -{ - k = sub( k, nchan_ism ); /* SID metadata flags */ - idx = st_ivas->bit_stream[k]; - move16(); - st_ivas->ism_mode = (ISM_MODE) add( idx, 1 ); - move32(); -} + /* read ism_mode */ + st_ivas->ism_mode = ISM_MODE_DISC; + move32(); + IF( GT_16( nchan_ism, 2 ) ) + { + k = sub( k, nchan_ism ); /* SID metadata flags */ + idx = st_ivas->bit_stream[k]; + move16(); + st_ivas->ism_mode = (ISM_MODE) add( idx, 1 ); + move32(); + } -st_ivas->nchan_transport = nchan_ism; -move16(); -if ( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) ) -{ - st_ivas->nchan_transport = MAX_PARAM_ISM_WAVE; - move16(); -} -} -} + st_ivas->nchan_transport = nchan_ism; + move16(); + if ( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) ) + { + st_ivas->nchan_transport = MAX_PARAM_ISM_WAVE; + move16(); + } + } + } -st_ivas->bit_stream = bit_stream_orig; + st_ivas->bit_stream = bit_stream_orig; -return IVAS_ERR_OK; + return IVAS_ERR_OK; } diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 027baa528..0e99c4c6e 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -3681,7 +3681,9 @@ ivas_error IVAS_DEC_ReadFormat( renderer_type_old = st_ivas->renderer_type; renderer_type_sec_old = ivas_renderer_secondary_select_fx( st_ivas ); move32(); +#ifndef DECODER_FORMAT_SWITCHING move32(); +#endif move32(); move16(); move32(); -- GitLab From ff0d8fd52f101ff20666a23737a317cf9f0e08da Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Tue, 11 Nov 2025 10:41:08 +0200 Subject: [PATCH 5/6] Correct place for rtp restart, clean up --- apps/decoder.c | 42 ++++++++++++++++---------------- lib_dec/ivas_init_dec_fx.c | 50 ++++++++++++++++++++------------------ 2 files changed, 47 insertions(+), 45 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 6c5f9a9b9..baba111e8 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -3161,27 +3161,6 @@ static ivas_error decodeVoIP( fprintf( stdout, "\n-- Start the decoder (quiet mode) --\n\n" ); } -#ifdef DECODER_FORMAT_SWITCHING - if ( ivasRtp.restartNeeded ) - { - IVAS_DEC_MODE newCodecInPacket = ( ivasRtp.codecId == IVAS_RTP_EVS ) ? IVAS_DEC_MODE_EVS : IVAS_DEC_MODE_IVAS; - error = restartDecoder( - &hIvasDec, - newCodecInPacket, - &arg, - NULL, /* ToDo : Provide rendererConfig */ - NULL /* ToDo : Provide LS Custom Data */ - ); - if ( error != IVAS_ERR_OK ) - { - fprintf( stderr, "\nFailed to restart decoder from %d to %d\n", arg.decMode, newCodecInPacket ); - goto cleanup; - } - *phIvasDec = hIvasDec; /* Update for main()' s free */ - ivasRtp.restartNeeded = false; - } -#endif - #ifdef WMOPS reset_stack(); reset_wmops(); @@ -3195,6 +3174,27 @@ static ivas_error decodeVoIP( { nSamplesRendered = 0; +#ifdef DECODER_FORMAT_SWITCHING + if ( ivasRtp.restartNeeded ) + { + IVAS_DEC_MODE newCodecInPacket = ( ivasRtp.codecId == IVAS_RTP_EVS ) ? IVAS_DEC_MODE_EVS : IVAS_DEC_MODE_IVAS; + error = restartDecoder( + &hIvasDec, + newCodecInPacket, + &arg, + NULL, /* ToDo : Provide rendererConfig */ + NULL /* ToDo : Provide LS Custom Data */ + ); + if ( error != IVAS_ERR_OK ) + { + fprintf( stderr, "\nFailed to restart decoder from %d to %d\n", arg.decMode, newCodecInPacket ); + goto cleanup; + } + *phIvasDec = hIvasDec; /* Update for main()' s free */ + ivasRtp.restartNeeded = false; + } +#endif + /* reference vector */ if ( arg.enableReferenceVectorTracking && vec_pos_update == 0 ) { diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index faafc0e3c..f9e3ce80b 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -204,7 +204,7 @@ ivas_error ivas_dec_get_format_fx( test(); IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) { - #ifdef DECODER_FORMAT_SWITCHING +#ifdef DECODER_FORMAT_SWITCHING IF( isVoipMode ) { st_ivas->restartNeeded = 1; @@ -213,17 +213,17 @@ ivas_error ivas_dec_get_format_fx( } ELSE { - #ifdef DEBUGGING +#ifdef DEBUGGING fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); - #endif +#endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); } - #else - #ifdef DEBUGGING +#else +#ifdef DEBUGGING fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); - #endif +#endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); - #endif +#endif } st_ivas->nchan_ism = nchan_ism; @@ -247,7 +247,7 @@ ivas_error ivas_dec_get_format_fx( test(); IF( st_ivas->ini_frame > 0 && NE_16( sba_planar, st_ivas->sba_planar ) ) { - #ifdef DECODER_FORMAT_SWITCHING +#ifdef DECODER_FORMAT_SWITCHING IF( isVoipMode ) { st_ivas->restartNeeded = 1; @@ -256,17 +256,17 @@ ivas_error ivas_dec_get_format_fx( } ELSE { - #ifdef DEBUGGING +#ifdef DEBUGGING fprintf( stderr, "\nError: Changing the SBA planar/3D layout is not supported!\n" ); - #endif +#endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA planar flag signalled!" ); } - #else - #ifdef DEBUGGING +#else +#ifdef DEBUGGING fprintf( stderr, "\nError: Changing the SBA planar/3D layout is not supported!\n" ); - #endif +#endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA planar flag signalled!" ); - #endif +#endif } /* read Ambisonic (SBA) order */ @@ -281,22 +281,22 @@ ivas_error ivas_dec_get_format_fx( IF( isVoipMode ) { st_ivas->restartNeeded = 1; - move16(); - return IVAS_ERR_OK; + move16(); + return IVAS_ERR_OK; } ELSE { - #ifdef DEBUGGING +#ifdef DEBUGGING fprintf( stderr, "\nError: Changing the SBA order is not supported!\n" ); - #endif +#endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA order signalled!" ); } - #ifdef DEBUGGING +#else +#ifdef DEBUGGING fprintf( stderr, "\nError: Changing the SBA order is not supported!\n" ); - #endif +#endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA order signalled!" ); - #else - #endif +#endif } sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, sba_order ); @@ -659,9 +659,11 @@ ivas_error ivas_dec_get_format_fx( k = sub( k, 1 ); test(); - IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ){ + IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) + { #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ){ + IF( isVoipMode ) + { st_ivas->restartNeeded = 1; move16(); return IVAS_ERR_OK; -- GitLab From 5b9ee25dd4a5576c60e4e4f7e256cfc7c233644e Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Tue, 11 Nov 2025 10:44:16 +0200 Subject: [PATCH 6/6] Clang format --- lib_dec/ivas_init_dec_fx.c | 111 +++++++++++++++++++------------------ 1 file changed, 57 insertions(+), 54 deletions(-) diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index f9e3ce80b..2b45965c5 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -277,7 +277,7 @@ ivas_error ivas_dec_get_format_fx( test(); IF( st_ivas->ini_frame > 0 && NE_16( sba_order, st_ivas->sba_order ) ) { - #ifdef DECODER_FORMAT_SWITCHING +#ifdef DECODER_FORMAT_SWITCHING IF( isVoipMode ) { st_ivas->restartNeeded = 1; @@ -304,23 +304,23 @@ ivas_error ivas_dec_get_format_fx( } ELSE IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) ) { - #ifdef DECODER_FORMAT_SWITCHING +#ifdef DECODER_FORMAT_SWITCHING UWord8 masaRestartCandidate; masaRestartCandidate = 0; move16(); - #endif +#endif /* read number of MASA transport channels */ k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); IF( st_ivas->bit_stream[k - 1] ) { - #ifdef DECODER_FORMAT_SWITCHING +#ifdef DECODER_FORMAT_SWITCHING test(); IF( st_ivas->nchan_transport == 1 && isVoipMode ) { masaRestartCandidate = 1; move16(); } - #endif +#endif st_ivas->nchan_transport = 2; move16(); element_mode_flag = 1; @@ -328,14 +328,14 @@ ivas_error ivas_dec_get_format_fx( } ELSE { - #ifdef DECODER_FORMAT_SWITCHING +#ifdef DECODER_FORMAT_SWITCHING test(); IF( st_ivas->nchan_transport == 2 && isVoipMode ) { masaRestartCandidate = 1; move16(); } - #endif +#endif st_ivas->nchan_transport = 1; move16(); } @@ -369,19 +369,19 @@ ivas_error ivas_dec_get_format_fx( element_mode_flag = 1; move16(); } - #ifdef DECODER_FORMAT_SWITCHING +#ifdef DECODER_FORMAT_SWITCHING ELSE IF( masaRestartCandidate > 0 ) { st_ivas->restartNeeded = 1; move16(); return IVAS_ERR_OK; } - #endif +#endif test(); IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) { - #ifdef DECODER_FORMAT_SWITCHING +#ifdef DECODER_FORMAT_SWITCHING IF( isVoipMode ) { st_ivas->restartNeeded = 1; @@ -390,17 +390,17 @@ ivas_error ivas_dec_get_format_fx( } ELSE { - #ifdef DEBUGGING +#ifdef DEBUGGING fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); - #endif +#endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); } - #else - #ifdef DEBUGGING +#else +#ifdef DEBUGGING fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); - #endif +#endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); - #endif +#endif } st_ivas->nchan_ism = nchan_ism; @@ -419,25 +419,26 @@ ivas_error ivas_dec_get_format_fx( test(); IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) { - #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ){ +#ifdef DECODER_FORMAT_SWITCHING + IF( isVoipMode ) + { st_ivas->restartNeeded = 1; move16(); return IVAS_ERR_OK; } ELSE { - #ifdef DEBUGGING +#ifdef DEBUGGING fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); - #endif +#endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); } - #else - #ifdef DEBUGGING +#else +#ifdef DEBUGGING fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); - #endif +#endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); - #endif +#endif } st_ivas->nchan_ism = nchan_ism; @@ -452,7 +453,7 @@ ivas_error ivas_dec_get_format_fx( test(); IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) { - #ifdef DECODER_FORMAT_SWITCHING +#ifdef DECODER_FORMAT_SWITCHING IF( isVoipMode ) { st_ivas->restartNeeded = 1; @@ -461,17 +462,17 @@ ivas_error ivas_dec_get_format_fx( } ELSE { - #ifdef DEBUGGING +#ifdef DEBUGGING fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); - #endif +#endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); } - #else - #ifdef DEBUGGING +#else +#ifdef DEBUGGING fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); - #endif +#endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); - #endif +#endif } st_ivas->nchan_ism = nchan_ism; @@ -499,25 +500,26 @@ ivas_error ivas_dec_get_format_fx( test(); IF( st_ivas->ini_frame > 0 && NE_16( sba_order, st_ivas->sba_order ) ) { - #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ){ +#ifdef DECODER_FORMAT_SWITCHING + IF( isVoipMode ) + { st_ivas->restartNeeded = 1; move16(); return IVAS_ERR_OK; } ELSE { - #ifdef DEBUGGING +#ifdef DEBUGGING fprintf( stderr, "\nError: Changing the SBA order is not supported!\n" ); - #endif +#endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA order signalled!" ); } - #else - #ifdef DEBUGGING +#else +#ifdef DEBUGGING fprintf( stderr, "\nError: Changing the SBA order is not supported!\n" ); - #endif +#endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA order signalled!" ); - #endif +#endif } st_ivas->ism_mode = ivas_osba_ism_mode_select( ivas_total_brate, st_ivas->nchan_ism ); @@ -544,25 +546,26 @@ ivas_error ivas_dec_get_format_fx( test(); IF( st_ivas->ini_frame > 0 && NE_32( st_ivas->transport_config, signaled_config ) ) { - #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ){ +#ifdef DECODER_FORMAT_SWITCHING + IF( isVoipMode ) + { st_ivas->restartNeeded = 1; move16(); return IVAS_ERR_OK; } ELSE { - #ifdef DEBUGGING +#ifdef DEBUGGING fprintf( stderr, "\nError: Switching of MC configurations is not supported!\n" ); - #endif +#endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "wrong MC configuration signalled!" ); } - #else - #ifdef DEBUGGING +#else +#ifdef DEBUGGING fprintf( stderr, "\nError: Switching of MC configurations is not supported!\n" ); - #endif +#endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "wrong MC configuration signalled!" ); - #endif +#endif } st_ivas->mc_mode = ivas_mc_mode_select_fx( ivas_mc_map_output_config_to_mc_ls_setup_fx( signaled_config ), ivas_total_brate ); @@ -661,7 +664,7 @@ ivas_error ivas_dec_get_format_fx( test(); IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) { - #ifdef DECODER_FORMAT_SWITCHING +#ifdef DECODER_FORMAT_SWITCHING IF( isVoipMode ) { st_ivas->restartNeeded = 1; @@ -670,17 +673,17 @@ ivas_error ivas_dec_get_format_fx( } ELSE { - #ifdef DEBUGGING +#ifdef DEBUGGING fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); - #endif +#endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); } - #else - #ifdef DEBUGGING +#else +#ifdef DEBUGGING fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); - #endif +#endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); - #endif +#endif } st_ivas->nchan_ism = nchan_ism; -- GitLab