From 5224af90575367d8abb566b883ea9878b4398986 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 11 Nov 2025 17:23:50 +0100 Subject: [PATCH 01/12] RTP revision --- apps/decoder.c | 93 ++++++++++------- apps/encoder.c | 18 ++-- apps/encoder_fmtsw.c | 55 +++++++--- lib_com/bitstream_fx.c | 1 + lib_com/common_api_types.h | 3 + lib_com/ivas_cnst.h | 3 - lib_com/ivas_prot_fx.h | 7 +- lib_dec/ivas_init_dec_fx.c | 67 +++++++----- lib_dec/ivas_output_config_fx.c | 4 +- lib_dec/ivas_stat_dec.h | 6 +- lib_dec/lib_dec.h | 39 ++++--- lib_dec/lib_dec_fx.c | 174 +++++++++++++++++++++++-------- lib_rend/ivas_render_config_fx.c | 2 +- lib_rend/ivas_rotation_fx.c | 5 + lib_util/ivas_rtp_pi_data.h | 2 +- readme.txt | 48 ++++++--- 16 files changed, 349 insertions(+), 178 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 458c164ac..88b330e8e 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -55,13 +55,7 @@ #ifdef IVAS_RTPDUMP #include "ivas_rtp_file.h" #endif -#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT -#include "ivas_cnst.h" -#endif -#ifdef FIXED_RTP_SEQUENCE_NUM -#define RANDOM_INITSEED_DEC ( 0xFEEDFADE ) -#endif #define WMC_TOOL_SKIP @@ -74,6 +68,10 @@ static #endif int32_t frame = 0; /* Counter of frames */ +#ifdef FIXED_RTP_SEQUENCE_NUM +#define RANDOM_INITSEED_DEC ( 0xFEEDFADE ) +#endif + #ifdef DEBUGGING #define MIN_NUM_BITS_ACTIVE_FRAME 56 #define NUM_BITS_SID_IVAS_5K2 104 @@ -193,11 +191,11 @@ static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS #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 ); +static ivas_error restartDecoder( IVAS_DEC_HANDLE *phIvasDec, const IVAS_DEC_MODE decMode, DecArguments *arg, IVAS_RENDER_CONFIG_DATA *renderConfig, IVAS_CUSTOM_LS_DATA *hLsCustomData ); #endif + /*------------------------------------------------------------------------------------------* * main() * @@ -495,7 +493,6 @@ int main( fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } - #ifndef IVAS_RTPDUMP arg.enableHeadRotation = true; #endif @@ -558,6 +555,7 @@ int main( fprintf( stderr, "Failed to read renderer configuration from file %s\n\n", arg.renderConfigFilename ); goto cleanup; } + #ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT aeCount = RenderConfigReader_getAcousticEnvironmentCount( renderConfigReader ); if ( aeCount > 0 ) @@ -1877,6 +1875,7 @@ static ivas_error initOnFirstGoodFrame( ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrection; int16_t splitRendIsarFrameSizeMs; int16_t lc3plusHighRes; + #ifdef FIXED_RTP_SEQUENCE_NUM /* Ideally ssrc is negotiated via SDP and sequence number is radomized but we use fixed seed for random num generator for regression based tests. Any realtime @@ -2411,7 +2410,7 @@ static ivas_error decodeG192( fprintf( stderr, "\nIVAS_DEC_GetNumOrientationSubframes failed: \n" ); goto cleanup; } - /* Head-tracking input simulation */ + /* Head-tracking input simulation */ if ( arg.enableHeadRotation ) { @@ -3047,6 +3046,7 @@ static ivas_error decodeVoIP( int16_t i; #ifdef DECODER_FORMAT_SWITCHING IVAS_DEC_HANDLE hIvasDec = *phIvasDec; + bool restartNeeded; #endif #ifdef IVAS_RTPDUMP IVAS_RTP ivasRtp = { 0 }; @@ -3243,21 +3243,22 @@ static ivas_error decodeVoIP( nSamplesRendered = 0; #ifdef DECODER_FORMAT_SWITCHING + /* restart decoder in case of format switching */ if ( ivasRtp.restartNeeded ) { - IVAS_DEC_MODE newCodecInPacket = ( ivasRtp.codecId == IVAS_RTP_EVS ) ? IVAS_DEC_MODE_EVS : IVAS_DEC_MODE_IVAS; - error = restartDecoder( + IVAS_DEC_MODE newDecModeInPacket = ( ivasRtp.codecId == IVAS_RTP_EVS ) ? IVAS_DEC_MODE_EVS : IVAS_DEC_MODE_IVAS; + if(( error = restartDecoder( &hIvasDec, - newCodecInPacket, + newDecModeInPacket, &arg, NULL, /* ToDo : Provide rendererConfig */ NULL /* ToDo : Provide LS Custom Data */ - ); - if ( error != IVAS_ERR_OK ) + ) )!= IVAS_ERR_OK ) { - fprintf( stderr, "\nFailed to restart decoder from %d to %d\n", arg.decMode, newCodecInPacket ); + fprintf( stderr, "\nFailed to restart decoder from %d to %d\n", arg.decMode, newDecModeInPacket ); goto cleanup; } + *phIvasDec = hIvasDec; /* Update for main()' s free */ ivasRtp.restartNeeded = false; } @@ -3296,6 +3297,7 @@ static ivas_error decodeVoIP( goto cleanup; } } + int16_t num_subframes; if ( ( error = IVAS_DEC_GetNumOrientationSubframes( hIvasDec, &num_subframes ) ) != IVAS_ERR_OK ) { @@ -3303,7 +3305,6 @@ static ivas_error decodeVoIP( goto cleanup; } - /* Head-tracking input simulation */ /* Head-tracking input simulation */ if ( arg.enableHeadRotation ) { @@ -3446,12 +3447,17 @@ static ivas_error decodeVoIP( /* we are finished when all packets have been received and jitter buffer is empty */ /* also stop when the input file contains less than two frames, because JBM cannot calculate a delay value and won't start decoding */ /* last clause should make sure that for BE tests we end up with the same number of samples...*/ - if ( nextPacketRcvTime_ms == (uint32_t) ( -1 ) && ( IVAS_DEC_VoIP_IsEmpty( hIvasDec, nOutSamples ) || nFramesFed < 2 ) ) + bool isEmpty; + if ( ( error = IVAS_DEC_VoIP_IsEmpty( hIvasDec, nOutSamples, &isEmpty ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError in IVAS_DEC_VoIP_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + if ( nextPacketRcvTime_ms == (uint32_t) ( -1 ) && ( isEmpty || nFramesFed < 2 ) ) { break; } - /* decode and get samples */ while ( nSamplesRendered < nOutSamples ) { @@ -3468,7 +3474,7 @@ static ivas_error decodeVoIP( numPiData++; } - if ( ( error = IVAS_RTP_FeedPiDataToDecoder( hIvasDec, &ivasRtp.piData[ivasRtp.nProcPiData], numPiData ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_FeedPiDataToDecoder( hIvasDec, &ivasRtp.piData[ivasRtp.nProcPiData], numPiData ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_VoIP_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -3477,6 +3483,7 @@ static ivas_error decodeVoIP( ivasRtp.nProcPiData += numPiData; } #endif + #ifdef FIX_1119_SPLIT_RENDERING_VOIP if ( isSplitRend ) { @@ -3516,34 +3523,42 @@ static ivas_error decodeVoIP( return error; } - /* Placeholder for memory reallocation */ - /* ... */ #ifdef DECODER_FORMAT_SWITCHING - if ( IVAS_DEC_isRestartNeeded( hIvasDec ) ) + /* restart decoder in case of format switching */ + if ( ( error = IVAS_DEC_isRestartNeeded( hIvasDec, &restartNeeded ) ) != IVAS_ERR_OK ) { - IVAS_DEC_BS_FORMAT tempFormat; - if ( ( error = IVAS_DEC_GetFormat( hIvasDec, &tempFormat ) ) != IVAS_ERR_OK ) + return error; + } + + if ( restartNeeded ) + { + IVAS_DEC_BS_FORMAT tempBsFormat; + if ( ( error = IVAS_DEC_GetFormat( hIvasDec, &tempBsFormat ) ) != 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( + + IVAS_DEC_MODE newDecModeInPacket = ( tempBsFormat == IVAS_DEC_BS_MONO ) ? IVAS_DEC_MODE_EVS : IVAS_DEC_MODE_IVAS; + if((error = restartDecoder( &hIvasDec, - codecMode, + newDecModeInPacket , &arg, NULL, /* ToDo : Provide rendererConfig */ NULL /* ToDo : Provide LS Custom Data */ - ); - if ( error != IVAS_ERR_OK ) + ) )!= IVAS_ERR_OK ) { fprintf( stderr, "\nFailed to restart decoder\n" ); goto cleanup; } + *phIvasDec = hIvasDec; /* Update for main()' s free */ } #endif + /* Placeholder for memory reallocation */ + /* ... */ + /* Load HRTF binary file data */ if ( arg.hrtfReaderEnabled ) { @@ -3859,7 +3874,6 @@ static ivas_error decodeVoIP( } } - /*------------------------------------------------------------------------------------------* * Add zeros at the end to have equal length of synthesized signals *------------------------------------------------------------------------------------------*/ @@ -4322,9 +4336,15 @@ static ivas_error load_hrtf_from_file( #ifdef DECODER_FORMAT_SWITCHING -ivas_error restartDecoder( +/*---------------------------------------------------------------------* + * restartDecoder() + * + * Restart decoder in case of IVAS format switching + *---------------------------------------------------------------------*/ + +static ivas_error restartDecoder( IVAS_DEC_HANDLE *phIvasDec, - IVAS_DEC_MODE codec, + const IVAS_DEC_MODE decMode, DecArguments *arg, IVAS_RENDER_CONFIG_DATA *renderConfig, IVAS_CUSTOM_LS_DATA *hLsCustomData ) @@ -4342,19 +4362,19 @@ ivas_error restartDecoder( IVAS_DEC_Close( phIvasDec ); } - if ( ( error = IVAS_DEC_Open( phIvasDec, codec ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_Open( phIvasDec, decMode ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Open failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } - arg->decMode = codec; + arg->decMode = decMode; 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; + IVAS_AUDIO_CONFIG outputConfig = ( decMode == 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, @@ -4429,6 +4449,7 @@ ivas_error restartDecoder( cleanup: IVAS_DEC_Close( phIvasDec ); + return error; } diff --git a/apps/encoder.c b/apps/encoder.c index fe64442e1..3e2bd7778 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -63,10 +63,6 @@ #endif #endif -#ifdef FIXED_RTP_SEQUENCE_NUM -#define RANDOM_INITSEED_ENC ( 0xFEEDDEAF ) -#endif - #define WMC_TOOL_SKIP /*------------------------------------------------------------------------------------------* @@ -78,6 +74,10 @@ static #endif int32_t frame = 0; /* Counter of frames */ +#ifdef FIXED_RTP_SEQUENCE_NUM +#define RANDOM_INITSEED_ENC ( 0xFEEDDEAF ) +#endif + #define DEFAULT_FIXED_SID_RATE 8 /* DTX SID rate */ /* Additional config info for each input format */ @@ -468,14 +468,14 @@ int main( if ( ( error = IVAS_ENC_ConfigureForSBAObjects( hIvasEnc, arg.inputFs, totalBitrate, bandwidth, arg.dtxConfig, arg.inputFormatConfig.sba_ism.numObjects, arg.inputFormatConfig.sba_ism.order, arg.inputFormatConfig.sba_ism.isPlanar, arg.pca ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_ENC_ConfigureForSBAObjects failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); - exit( -1 ); + goto cleanup; } break; case IVAS_ENC_INPUT_MASA_ISM: if ( ( error = IVAS_ENC_ConfigureForMASAObjects( hIvasEnc, arg.inputFs, totalBitrate, bandwidth, arg.dtxConfig, arg.inputFormatConfig.masa_ism.numObjects, arg.inputFormatConfig.masa_ism.masaVariant ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_ENC_ConfigureForMASAObjects failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); - exit( -1 ); + goto cleanup; } break; default: @@ -672,6 +672,10 @@ int main( } #endif + /*------------------------------------------------------------------------------------------* + * Run the encoder + *------------------------------------------------------------------------------------------*/ + int16_t numSamplesRead = 0; uint16_t bitStream[IVAS_MAX_BITS_PER_FRAME]; uint16_t numBits = 0; @@ -1841,6 +1845,7 @@ static bool parseCmdlIVAS_enc( { i++; arg->rtpdumpOutput = true; + if ( i < argc - 4 ) { if ( !is_digits_only( argv[i] ) ) @@ -1857,6 +1862,7 @@ static bool parseCmdlIVAS_enc( } } } + fprintf( stdout, "Output format: RTPDump using %d frames/packet \n", arg->numFramesPerPacket ); } diff --git a/apps/encoder_fmtsw.c b/apps/encoder_fmtsw.c index 74efb401f..5d48ec04f 100644 --- a/apps/encoder_fmtsw.c +++ b/apps/encoder_fmtsw.c @@ -63,10 +63,6 @@ #endif #endif -#ifdef FIXED_RTP_SEQUENCE_NUM -#define RANDOM_INITSEED_ENC ( 0xFEEDDEAF ) -#endif - #define WMC_TOOL_SKIP /*------------------------------------------------------------------------------------------* @@ -81,6 +77,10 @@ static #endif int32_t frame = 0; /* Counter of frames */ +#ifdef FIXED_RTP_SEQUENCE_NUM +#define RANDOM_INITSEED_ENC ( 0xFEEDDEAF ) +#endif + #define DEFAULT_FIXED_SID_RATE 8 /* DTX SID rate */ /* Additional config info for each input format */ @@ -199,13 +199,14 @@ static int encoder_main( int argc, char *argv[] ); * main() * * Main IVAS encoder function for command-line interface - * supporting format switching + * supporting IVAS format switching *------------------------------------------------------------------------------------------*/ int main( int argc, char *argv[] ) { + bool mainFailed = true; /* Assume main failed until cleanup is reached without errors */ FILE *FmtSWFile = NULL; char line[2048]; int argc_local = 0; @@ -218,18 +219,18 @@ int main( IVAS_ENC_PrintDisclaimer(); - if ( argc != 2 ) + if ( argc != 3 ) { fprintf( stdout, "Usage: IVAS_cod_fmtsw.exe format_switching_file\n\n" ); fprintf( stdout, "where format_switching_file is a text file containg a valid encoder command line in each line\n\n" ); - exit( 0 ); + goto cleanup; } fprintf( stdout, "Input format switching file: %s\n", argv[1] ); if ( ( FmtSWFile = fopen( argv[1], "r" ) ) == NULL ) { fprintf( stdout, "error: cannot open format switching file %s\n", argv[1] ); - exit( 0 ); + goto cleanup; } while ( fgets( line, sizeof( line ), FmtSWFile ) ) @@ -238,11 +239,15 @@ int main( line[strcspn( line, "\r\n" )] = 0; printf( "Processing format switching commandline: %s\n", line ); str2arg( line, &argc_local, argv_local ); + #ifdef IVAS_RTPDUMP if ( strcmp( argv_local[argc_local - 1], (char *) prev_outputBitstreamFilename ) == 0 ) { /* append to last Rtp file */ - encoder_main( argc_local, argv_local, &ivasRtp, 0 ); + if ( encoder_main( argc_local, argv_local, &ivasRtp, 0 ) != 0 ) + { + goto cleanup; + } } else { @@ -250,8 +255,13 @@ int main( { IVAS_RTP_Term( &ivasRtp ); } + /* write in separate Rtp file */ - encoder_main( argc_local, argv_local, &ivasRtp, 1 ); + if ( encoder_main( argc_local, argv_local, &ivasRtp, 1 ) != 0 ) + { + goto cleanup; + } + rtp_term = 1; } strcpy( (char *) prev_outputBitstreamFilename, argv_local[argc_local - 1] ); @@ -259,11 +269,24 @@ int main( encoder_main( argc_local, argv_local ); #endif } + + /*------------------------------------------------------------------------------------------* + * Close files and deallocate resources + *------------------------------------------------------------------------------------------*/ + + mainFailed = false; /* This will stay set to true if cleanup is reached via a goto due to an error */ + +cleanup: + #ifdef IVAS_RTPDUMP IVAS_RTP_Term( &ivasRtp ); #endif - fclose( FmtSWFile ); - exit( 0 ); + if( FmtSWFile) + { + fclose( FmtSWFile ); + } + + return mainFailed ? -1 : 0; } @@ -568,14 +591,14 @@ int encoder_main( if ( ( error = IVAS_ENC_ConfigureForSBAObjects( hIvasEnc, arg.inputFs, totalBitrate, bandwidth, arg.dtxConfig, arg.inputFormatConfig.sba_ism.numObjects, arg.inputFormatConfig.sba_ism.order, arg.inputFormatConfig.sba_ism.isPlanar, arg.pca ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_ENC_ConfigureForSBAObjects failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); - exit( -1 ); + goto cleanup; } break; case IVAS_ENC_INPUT_MASA_ISM: if ( ( error = IVAS_ENC_ConfigureForMASAObjects( hIvasEnc, arg.inputFs, totalBitrate, bandwidth, arg.dtxConfig, arg.inputFormatConfig.masa_ism.numObjects, arg.inputFormatConfig.masa_ism.masaVariant ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_ENC_ConfigureForMASAObjects failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); - exit( -1 ); + goto cleanup; } break; default: @@ -772,6 +795,10 @@ int encoder_main( } #endif + /*------------------------------------------------------------------------------------------* + * Run the encoder + *------------------------------------------------------------------------------------------*/ + int16_t numSamplesRead = 0; uint16_t bitStream[IVAS_MAX_BITS_PER_FRAME]; uint16_t numBits = 0; diff --git a/lib_com/bitstream_fx.c b/lib_com/bitstream_fx.c index a80929e68..ea576255a 100644 --- a/lib_com/bitstream_fx.c +++ b/lib_com/bitstream_fx.c @@ -3860,6 +3860,7 @@ void convertSerialToBytestream_fx( UWord8 bitinbyte2, bytestream_tmp; assert( num_bits <= MAX_16 ); /* 512 kbps = 10240 bits, num_bits should always fits Word16 */ #endif + FOR( i = 0; i < num_bits; ++i ) { IF( EQ_32( serial[i], 0x0001 ) ) diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 3c3c6b2b7..d41635f8d 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -62,6 +62,9 @@ #define IVAS_REVERB_PREDELAY_MAX 20 /* Max input delay for reverb module */ #define IVAS_ER_LIST_HEIGHT 1.6f #define IVAS_ER_LIST_HEIGHT_FX 6710886 /* 1.6f in Q.22 */ +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT +#define IVAS_DEFAULT_AEID 65535 +#endif /* JBM constants for adaptive-playout */ #define IVAS_TIME_SCALE_MIN 50 /* min. time-scaling [%] */ diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 335721a0a..f3d33b153 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1668,9 +1668,6 @@ typedef enum #else #define IVAS_REVERB_DEFAULT_N_BANDS 31 #endif -#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT -#define IVAS_DEFAULT_AEID ( 65535 ) -#endif #define LR_IAC_LENGTH_NR_FC ( RV_LENGTH_NR_FC ) #define LR_IAC_LENGTH_NR_FC_16KHZ ( RV_LENGTH_NR_FC_16KHZ ) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 0cb0174d6..55a4efde9 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -4030,16 +4030,11 @@ 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( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); ivas_error create_mct_dec_fx( diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index 984f02ece..ffbb0c6ab 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -104,18 +104,17 @@ 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; Word16 nchan_ism, element_mode_flag; Word16 sba_order, sba_planar, sba_analysis_order; Word32 ivas_total_brate; +#ifdef DECODER_FORMAT_SWITCHING + int16_t Opt_tsm; +#endif + UWord16 *bit_stream_orig; AUDIO_CONFIG signaled_config; ivas_error error; @@ -127,6 +126,10 @@ ivas_error ivas_dec_get_format_fx( ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; move32(); +#ifdef DECODER_FORMAT_SWITCHING + Opt_tsm = st_ivas->hDecoderConfig->Opt_tsm; + move16(); +#endif bit_stream_orig = st_ivas->bit_stream; /*-------------------------------------------------------------------* @@ -148,10 +151,11 @@ ivas_error ivas_dec_get_format_fx( !( 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( Opt_tsm ) { st_ivas->restartNeeded = 1; move16(); + return IVAS_ERR_OK; } ELSE @@ -205,10 +209,11 @@ ivas_error ivas_dec_get_format_fx( IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) { #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ) + IF( Opt_tsm ) { st_ivas->restartNeeded = 1; move16(); + return IVAS_ERR_OK; } ELSE @@ -248,10 +253,11 @@ ivas_error ivas_dec_get_format_fx( IF( st_ivas->ini_frame > 0 && NE_16( sba_planar, st_ivas->sba_planar ) ) { #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ) + IF( Opt_tsm ) { st_ivas->restartNeeded = 1; move16(); + return IVAS_ERR_OK; } ELSE @@ -278,10 +284,11 @@ ivas_error ivas_dec_get_format_fx( IF( st_ivas->ini_frame > 0 && NE_16( sba_order, st_ivas->sba_order ) ) { #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ) + IF( Opt_tsm ) { st_ivas->restartNeeded = 1; move16(); + return IVAS_ERR_OK; } ELSE @@ -315,7 +322,7 @@ ivas_error ivas_dec_get_format_fx( { #ifdef DECODER_FORMAT_SWITCHING test(); - IF( st_ivas->nchan_transport == 1 && isVoipMode ) + if( st_ivas->nchan_transport == 1 && Opt_tsm ) { masaRestartCandidate = 1; move16(); @@ -330,7 +337,7 @@ ivas_error ivas_dec_get_format_fx( { #ifdef DECODER_FORMAT_SWITCHING test(); - IF( st_ivas->nchan_transport == 2 && isVoipMode ) + if( st_ivas->nchan_transport == 2 && Opt_tsm ) { masaRestartCandidate = 1; move16(); @@ -374,6 +381,7 @@ ivas_error ivas_dec_get_format_fx( { st_ivas->restartNeeded = 1; move16(); + return IVAS_ERR_OK; } #endif @@ -382,10 +390,11 @@ ivas_error ivas_dec_get_format_fx( IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) { #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ) + IF( Opt_tsm ) { st_ivas->restartNeeded = 1; move16(); + return IVAS_ERR_OK; } ELSE @@ -420,10 +429,11 @@ ivas_error ivas_dec_get_format_fx( IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) { #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ) + IF( Opt_tsm ) { st_ivas->restartNeeded = 1; move16(); + return IVAS_ERR_OK; } ELSE @@ -454,10 +464,11 @@ ivas_error ivas_dec_get_format_fx( IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) { #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ) + IF( Opt_tsm ) { st_ivas->restartNeeded = 1; move16(); + return IVAS_ERR_OK; } ELSE @@ -501,10 +512,11 @@ ivas_error ivas_dec_get_format_fx( IF( st_ivas->ini_frame > 0 && NE_16( sba_order, st_ivas->sba_order ) ) { #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ) + IF( Opt_tsm ) { st_ivas->restartNeeded = 1; move16(); + return IVAS_ERR_OK; } ELSE @@ -547,10 +559,11 @@ ivas_error ivas_dec_get_format_fx( IF( st_ivas->ini_frame > 0 && NE_32( st_ivas->transport_config, signaled_config ) ) { #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ) + IF( Opt_tsm ) { st_ivas->restartNeeded = 1; move16(); + return IVAS_ERR_OK; } ELSE @@ -665,10 +678,11 @@ ivas_error ivas_dec_get_format_fx( IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) { #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ) + IF( Opt_tsm ) { st_ivas->restartNeeded = 1; move16(); + return IVAS_ERR_OK; } ELSE @@ -3699,6 +3713,15 @@ void ivas_destroy_dec_fx( /* Config. Renderer */ ivas_render_config_close_fx( &( st_ivas->hRenderConfig ) ); +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT + /* Acoustic environments */ + IF( st_ivas->pAcousticEnvironments != NULL ) + { + free( st_ivas->pAcousticEnvironments ); + st_ivas->pAcousticEnvironments = NULL; + } +#endif + /* Limiter struct */ ivas_limiter_close_fx( &( st_ivas->hLimiter ) ); @@ -3732,16 +3755,6 @@ void ivas_destroy_dec_fx( #endif } -#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT - /* Acoustic environments */ - IF( st_ivas->pAcousticEnvironments != NULL ) - { - free( st_ivas->pAcousticEnvironments ); - st_ivas->pAcousticEnvironments = NULL; - } -#endif - - /* main IVAS handle */ free( st_ivas ); diff --git a/lib_dec/ivas_output_config_fx.c b/lib_dec/ivas_output_config_fx.c index 0cec1b914..0637ea4c9 100644 --- a/lib_dec/ivas_output_config_fx.c +++ b/lib_dec/ivas_output_config_fx.c @@ -119,9 +119,7 @@ void ivas_renderer_select( #ifdef FIX_1419_MONO_STEREO_UMX IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) || EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) { - ms_bin_upmix_renderer_select( st_ivas->ivas_format, - internal_config, - renderer_type ); + ms_bin_upmix_renderer_select( st_ivas->ivas_format, internal_config, renderer_type ); } ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) ) #else diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index df8607cb5..95030d576 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1217,14 +1217,14 @@ typedef struct Decoder_Struct JBM_METADATA_HANDLE hJbmMetadata; /* Structure for metadata buffering in JBM */ Word32 last_active_ivas_total_brate; - Word16 ism_extmeta_active; /* Extended metadata active in decoder */ - Word16 ism_extmeta_cnt; /* Change frame counter for extended metadata */ + Word16 ism_extmeta_active; /* Extended metadata active in decoder */ + Word16 ism_extmeta_cnt; /* Change frame counter for extended metadata */ #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 */ + Word16 restartNeeded; /* Flag to signal decoder restart */ #endif } Decoder_Struct; diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 23a353ff0..633d2016c 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -90,6 +90,7 @@ typedef enum _IVAS_DEC_BS_FORMAT } IVAS_DEC_BS_FORMAT; typedef struct IVAS_DEC *IVAS_DEC_HANDLE; +typedef struct pidata_ts_struct *hPiDataTs; #ifdef SUPPORT_JBM_TRACEFILE /* Callback function for JBM tracefile writing */ @@ -292,7 +293,7 @@ ivas_error IVAS_DEC_VoIP_SetScale( #ifdef VARIABLE_SPEED_DECODING ivas_error IVAS_DEC_EnableTsm( - IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ + IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ ); ivas_error IVAS_DEC_TSM_SetQuality( @@ -342,11 +343,13 @@ ivas_error IVAS_DEC_Flush( ); #ifdef DECODER_FORMAT_SWITCHING -bool IVAS_DEC_isRestartNeeded( - IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ +ivas_error IVAS_DEC_isRestartNeeded( + IVAS_DEC_HANDLE hIvasDec, /* i : IVAS decoder handle */ + bool *restartNeeded /* o : flag to signal decoder restart */ ); #endif + /* Setter functions - apply changes to decoder configuration */ /*! r: error code */ @@ -463,14 +466,14 @@ ivas_error IVAS_DEC_HRTF_binary_close( #ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT ivas_error IVAS_DEC_AddAcousticEnvironment( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const IVAS_ROOM_ACOUSTICS_CONFIG_DATA roomAcousticsConfig /* i : Room acoustic configuration */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const IVAS_ROOM_ACOUSTICS_CONFIG_DATA roomAcousticsConfig /* i: Room acoustic configuration */ ); ivas_error IVAS_DEC_GetAcousticEnvironment( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - UWord16 aeID, /* i : Acoustic environment ID */ - IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pAcEnv /* o : Room acoustic environment data pointer */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + UWord16 aeID, /* i : Acoustic environment ID */ + IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pAcEnv /* o : Room acoustic environment data pointer */ ); #endif @@ -505,9 +508,10 @@ ivas_error IVAS_DEC_HasDecodedFirstGoodFrame( ); /*! r: true if decoder has no data in VoIP jitter buffer */ -bool IVAS_DEC_VoIP_IsEmpty( +ivas_error IVAS_DEC_VoIP_IsEmpty( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const Word16 nSamplesAsked + const Word16 nSamplesAsked, /* i : number of output samples asked */ + bool *isEmpty /* o : isEmpty flag */ ); ivas_error IVAS_DEC_VoIP_Get_CA_offset( @@ -523,6 +527,14 @@ ivas_error IVAS_DEC_GetJbmData( ); #endif +#ifdef IVAS_RTPDUMP +ivas_error IVAS_DEC_FeedPiDataToDecoder( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + hPiDataTs piData, /* i : PI data received in rtp packet */ + UWord32 numPiData /* i : number of PI data received in rtp packet */ +); +#endif + /* Utility functions */ /*! r: pointer to an error message string */ @@ -540,13 +552,6 @@ void IVAS_DEC_PrintDisclaimer( void ); -#ifdef IVAS_RTPDUMP -#ifndef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT -#include "ivas_rtp_pi_data.h" -#endif -ivas_error IVAS_RTP_FeedPiDataToDecoder( IVAS_DEC_HANDLE hIvasDec, PIDATA_TS *piData, UWord32 numPiData ); -#endif - /* clang-format on */ #endif diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 246fd4e29..178465c10 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -41,6 +41,9 @@ #include "jbm_jb4sb.h" #include "jbm_pcmdsp_apa.h" #include "jbm_pcmdsp_fifo.h" +#ifdef IVAS_RTPDUMP +#include "ivas_rtp_pi_data.h" +#endif #include #include #include "wmc_auto.h" @@ -2987,6 +2990,7 @@ ivas_error IVAS_DEC_HRTF_binary_close( return IVAS_ERR_OK; } + #ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT /*---------------------------------------------------------------------* * IVAS_DEC_AddAcousticEnvironment( ) @@ -3033,6 +3037,7 @@ ivas_error IVAS_DEC_AddAcousticEnvironment( { return IVAS_ERR_FAILED_ALLOC; } + st_ivas->pAcousticEnvironments = ppAE; n = st_ivas->acousticEnvironmentsCount++; pAE = &st_ivas->pAcousticEnvironments[n]; @@ -3058,7 +3063,7 @@ ivas_error IVAS_DEC_AddAcousticEnvironment( move32(); move16(); - IF( pAE->use_er == 1 ) + IF( EQ_16( pAE->use_er, 1 ) ) { pAE->lowComplexity = roomAcousticsConfig.lowComplexity; move32(); @@ -3083,11 +3088,13 @@ ivas_error IVAS_DEC_AddAcousticEnvironment( return IVAS_ERR_OK; } + /*---------------------------------------------------------------------* * IVAS_DEC_GetAcousticEnvironment( ) * * Gets acoustic environment configuration with a given ID *---------------------------------------------------------------------*/ + ivas_error IVAS_DEC_GetAcousticEnvironment( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ UWord16 aeID, /* i : Acoustic environment ID */ @@ -3096,7 +3103,7 @@ ivas_error IVAS_DEC_GetAcousticEnvironment( { Word16 n, m; Word16 found = 0; - + move16(); Decoder_Struct *st_ivas; test(); @@ -3104,6 +3111,7 @@ ivas_error IVAS_DEC_GetAcousticEnvironment( { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } + st_ivas = hIvasDec->st_ivas; move32(); @@ -3111,7 +3119,7 @@ ivas_error IVAS_DEC_GetAcousticEnvironment( test(); IF( aeID == (UWord16) IVAS_DEFAULT_AEID && st_ivas->acousticEnvironmentsCount > 0 ) { - aeID = (UWord16) st_ivas->pAcousticEnvironments[0].aeID; + aeID = st_ivas->pAcousticEnvironments[0].aeID; move32(); } @@ -3143,6 +3151,7 @@ ivas_error IVAS_DEC_GetAcousticEnvironment( /* If ER are allocated then propagate parameters */ pAcEnv->use_er = ae.use_er; move16(); + IF( ae.use_er != 0 ) { pAcEnv->lowComplexity = ae.lowComplexity; @@ -3167,8 +3176,16 @@ ivas_error IVAS_DEC_GetAcousticEnvironment( } } - return found ? IVAS_ERR_OK : IVAS_ERR_ACOUSTIC_ENVIRONMENT_MISSING; + IF( found == 0 ) + { + return IVAS_ERR_ACOUSTIC_ENVIRONMENT_MISSING; + } + ELSE + { + return IVAS_ERR_OK; + } } + #endif /*---------------------------------------------------------------------* @@ -3388,13 +3405,14 @@ ivas_error IVAS_DEC_FeedRenderConfig( } #ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT + /*---------------------------------------------------------------------* - * IVAS_DEC_FeedAcousticEnvPI( ) + * feedAcousticEnvPI( ) * * Set acoustic environment from the PI data *---------------------------------------------------------------------*/ -static ivas_error IVAS_DEC_FeedAcousticEnvPI( +static ivas_error feedAcousticEnvPI( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ const IVAS_PIDATA_ACOUSTIC_ENV hAcoustEnvPI /* i : Render configuration struct */ ) @@ -3416,7 +3434,7 @@ static ivas_error IVAS_DEC_FeedAcousticEnvPI( move32(); /* Ignore if AE ID already in use */ - IF( hRenderConfig->roomAcoustics.aeID == hAcoustEnvPI.aeid ) + IF( EQ_16(hRenderConfig->roomAcoustics.aeID , hAcoustEnvPI.aeid )) { return IVAS_ERR_OK; } @@ -3531,6 +3549,7 @@ static ivas_error IVAS_DEC_FeedAcousticEnvPI( return IVAS_ERR_OK; } + #endif /*---------------------------------------------------------------------* @@ -4041,17 +4060,13 @@ 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 ) + IF( EQ_16( st_ivas->restartNeeded, 1 ) ) { return IVAS_ERR_OK; } @@ -5654,11 +5669,26 @@ ivas_error IVAS_DEC_Flush( * *---------------------------------------------------------------------*/ -bool IVAS_DEC_isRestartNeeded( - IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ +ivas_error IVAS_DEC_isRestartNeeded( + IVAS_DEC_HANDLE hIvasDec, /* i : IVAS decoder handle */ + bool *restartNeeded /* o : flag to signal decoder restart */ ) { - return hIvasDec->st_ivas->restartNeeded > 0; + test(); + IF( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + *restartNeeded = false; + move16(); + if ( EQ_16( hIvasDec->st_ivas->restartNeeded, 1 ) ) + { + *restartNeeded = true; + move16(); + } + + return IVAS_ERR_OK; } @@ -5666,12 +5696,13 @@ bool IVAS_DEC_isRestartNeeded( /*---------------------------------------------------------------------* * IVAS_DEC_VoIP_IsEmpty( ) * - * + * Returns 'true' if decoder has no data in VoIP jitter buffer *---------------------------------------------------------------------*/ -bool IVAS_DEC_VoIP_IsEmpty( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const Word16 nSamplesAsked /* i : number of output samples asked */ +ivas_error IVAS_DEC_VoIP_IsEmpty( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const Word16 nSamplesAsked, /* i : number of output samples asked */ + bool *isEmpty /* o : isEmpty flag */ ) { test(); @@ -5680,8 +5711,16 @@ bool IVAS_DEC_VoIP_IsEmpty( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } + *isEmpty = false; + move16(); test(); - return ( JB4_bufferedDataUnits( hIvasDec->hVoIP->hJBM ) == 0 && LT_16( hIvasDec->nSamplesAvailableNext, nSamplesAsked ) ); + if ( ( JB4_bufferedDataUnits( hIvasDec->hVoIP->hJBM ) == 0 ) && LT_16( hIvasDec->nSamplesAvailableNext, nSamplesAsked ) ) + { + *isEmpty = true; + move16(); + } + + return IVAS_ERR_OK; } @@ -6924,35 +6963,45 @@ ivas_error IVAS_DEC_is_split_rendering_coded_out( } #ifdef IVAS_RTPDUMP + /*---------------------------------------------------------------------* - * IVAS_DEC_feedSinglePIorientation( ) + * feedSinglePIorientation( ) * * Feed a single orientation PI data to external orientation handle. *---------------------------------------------------------------------*/ -static ivas_error IVAS_DEC_feedSinglePIorientation( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - bool isOrientationSaved, /* i : flag to indicate if an orientation for this PI type was previously saved */ - IVAS_QUATERNION *savedOrientation /* i : previously saved orientation for this PI type */ +static ivas_error feedSinglePIorientation( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const bool isOrientationSaved, /* i : flag to indicate if an orientation for this PI type was previously saved */ + IVAS_QUATERNION *savedOrientation /* i : previously saved orientation for this PI type */ ) { Word16 i; - ivas_error error = IVAS_ERR_OK; + ivas_error error; + Decoder_Struct *st_ivas; IVAS_QUATERNION savedInvOrientation; + test(); + IF( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + st_ivas = hIvasDec->st_ivas; + IF( isOrientationSaved ) { - IF( !hIvasDec->st_ivas->hExtOrientationData ) + IF( !st_ivas->hExtOrientationData ) { - IF( NE_32( error = ivas_external_orientation_open_fx( &( hIvasDec->st_ivas->hExtOrientationData ), hIvasDec->st_ivas->hDecoderConfig->render_framesize ), IVAS_ERR_OK ) ) + IF( NE_32( error = ivas_external_orientation_open_fx( &( st_ivas->hExtOrientationData ), st_ivas->hDecoderConfig->render_framesize ), IVAS_ERR_OK ) ) { return error; } } - IF( !hIvasDec->st_ivas->hCombinedOrientationData ) + IF( !st_ivas->hCombinedOrientationData ) { - IF( NE_32( error = ivas_combined_orientation_open_fx( &( hIvasDec->st_ivas->hCombinedOrientationData ), hIvasDec->st_ivas->hDecoderConfig->output_Fs, hIvasDec->st_ivas->hDecoderConfig->render_framesize ), IVAS_ERR_OK ) ) + IF( NE_32( error = ivas_combined_orientation_open_fx( &( st_ivas->hCombinedOrientationData ), st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->render_framesize ), IVAS_ERR_OK ) ) { return error; } @@ -6961,57 +7010,87 @@ static ivas_error IVAS_DEC_feedSinglePIorientation( QuaternionInverse_fx( *savedOrientation, &savedInvOrientation ); /* use the new PI orientation or the previously saved orientation in processing */ - FOR( i = 0; i < hIvasDec->st_ivas->hExtOrientationData->num_subframes; i++ ) + FOR( i = 0; i < st_ivas->hExtOrientationData->num_subframes; i++ ) { - QuaternionProduct_fx( hIvasDec->st_ivas->hExtOrientationData->Quaternions[i], savedInvOrientation, - &hIvasDec->st_ivas->hExtOrientationData->Quaternions[i] ); - hIvasDec->st_ivas->hExtOrientationData->enableExternalOrientation[i] = true; + QuaternionProduct_fx( st_ivas->hExtOrientationData->Quaternions[i], savedInvOrientation, + &st_ivas->hExtOrientationData->Quaternions[i] ); + st_ivas->hExtOrientationData->enableExternalOrientation[i] = true; move16(); } + hIvasDec->updateOrientation = true; move16(); } - return error; + + return IVAS_ERR_OK; } + #endif #ifdef RTP_S4_251135_CR26253_0016_REV1 + /*---------------------------------------------------------------------* - * IVAS_DEC_setDiegeticInput( ) + * setDiegeticInput( ) * * Set isDiegeticInput flag for combined orientation handle based on PI data. *---------------------------------------------------------------------*/ -static void IVAS_DEC_setDiegeticInputPI( +static void setDiegeticInputPI( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ const bool *diegeticPIValues /* i : diegetic values for the input stream */ ) { + Word16 i; + IF( hIvasDec->st_ivas->hCombinedOrientationData != NULL ) { - Word8 i; FOR( i = 0; i < ( 1 + IVAS_MAX_NUM_OBJECTS ); i++ ) { hIvasDec->st_ivas->hCombinedOrientationData->isDiegeticInputPI[i] = diegeticPIValues[i]; move16(); } + hIvasDec->st_ivas->hCombinedOrientationData->isDiegeticInputPISet = true; move16(); } + + return; } + #endif #ifdef IVAS_RTPDUMP -ivas_error IVAS_RTP_FeedPiDataToDecoder( IVAS_DEC_HANDLE hIvasDec, PIDATA_TS *piData, UWord32 numPiData ) +/*---------------------------------------------------------------------* + * IVAS_DEC_FeedPiDataToDecoder( ) + * + * + *---------------------------------------------------------------------*/ + +ivas_error IVAS_DEC_FeedPiDataToDecoder( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + hPiDataTs piData, /* i : PI data received in rtp packet */ + UWord32 numPiData /* i : number of PI data received in rtp packet */ +) { + UWord32 i; + Decoder_Struct *st_ivas; ivas_error error = IVAS_ERR_OK; move32(); - UWord32 i; + + test(); + IF( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + st_ivas = hIvasDec->st_ivas; + FOR( i = 0; i < numPiData; i++ ) { UWord32 piDataType = piData->data.noPiData.piDataType; move32(); numPiData = UL_subNsD( numPiData, 1 ); /* Subtraction of WHILE variable */ + SWITCH( piDataType ) { case IVAS_PI_SCENE_ORIENTATION: @@ -7024,7 +7103,7 @@ ivas_error IVAS_RTP_FeedPiDataToDecoder( IVAS_DEC_HANDLE hIvasDec, PIDATA_TS *pi fixedToFloat( quat->y_fx, Q15 ), fixedToFloat( quat->z_fx, Q15 ) ); #endif - error = IVAS_DEC_feedSinglePIorientation( hIvasDec, true, quat ); + error = feedSinglePIorientation( hIvasDec, true, quat ); } BREAK; @@ -7038,7 +7117,7 @@ ivas_error IVAS_RTP_FeedPiDataToDecoder( IVAS_DEC_HANDLE hIvasDec, PIDATA_TS *pi fixedToFloat( quat->y_fx, Q15 ), fixedToFloat( quat->z_fx, Q15 ) ); #endif - error = IVAS_DEC_feedSinglePIorientation( hIvasDec, true, quat ); + error = feedSinglePIorientation( hIvasDec, true, quat ); } BREAK; @@ -7053,9 +7132,9 @@ ivas_error IVAS_RTP_FeedPiDataToDecoder( IVAS_DEC_HANDLE hIvasDec, PIDATA_TS *pi #endif test(); test(); - IF( piData->data.acousticEnv.availLateReverb && hIvasDec->st_ivas->hRenderConfig != NULL && aeid != hIvasDec->st_ivas->hRenderConfig->roomAcoustics.aeID ) + IF( piData->data.acousticEnv.availLateReverb && st_ivas->hRenderConfig != NULL && aeid != st_ivas->hRenderConfig->roomAcoustics.aeID ) { - error = IVAS_DEC_FeedAcousticEnvPI( hIvasDec, piData->data.acousticEnv ); + error = feedAcousticEnvPI( hIvasDec, piData->data.acousticEnv ); } } BREAK; @@ -7067,7 +7146,7 @@ ivas_error IVAS_RTP_FeedPiDataToDecoder( IVAS_DEC_HANDLE hIvasDec, PIDATA_TS *pi #ifdef DEBUGGING fprintf( stdout, "PI_DIEGETIC_TYPE : %d, %d, %d, %d, %d\n", piData->data.digeticIndicator.isDiegetic[0], piData->data.digeticIndicator.isDiegetic[1], piData->data.digeticIndicator.isDiegetic[2], piData->data.digeticIndicator.isDiegetic[3], piData->data.digeticIndicator.isDiegetic[4] ); #endif - IVAS_DEC_setDiegeticInputPI( hIvasDec, piData->data.digeticIndicator.isDiegetic ); + setDiegeticInputPI( hIvasDec, piData->data.digeticIndicator.isDiegetic ); } BREAK; #endif @@ -7078,12 +7157,15 @@ ivas_error IVAS_RTP_FeedPiDataToDecoder( IVAS_DEC_HANDLE hIvasDec, PIDATA_TS *pi } BREAK; } + IF( NE_32( error, IVAS_ERR_OK ) ) { return error; } + piData++; } - return error; + + return IVAS_ERR_OK; } #endif diff --git a/lib_rend/ivas_render_config_fx.c b/lib_rend/ivas_render_config_fx.c index e8258930a..e4c6f62f7 100644 --- a/lib_rend/ivas_render_config_fx.c +++ b/lib_rend/ivas_render_config_fx.c @@ -119,7 +119,7 @@ ivas_error ivas_render_config_init_from_rom_fx( return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "Unexpected null pointer while attempting to fill renderer configuration from ROM" ); } #ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT - ( *hRenderConfig )->roomAcoustics.aeID = (UWord16) IVAS_DEFAULT_AEID; + ( *hRenderConfig )->roomAcoustics.aeID = IVAS_DEFAULT_AEID; move16(); #endif #ifdef FIX_1318_ROOM_SIZE_CMD_LINE diff --git a/lib_rend/ivas_rotation_fx.c b/lib_rend/ivas_rotation_fx.c index b9762f72c..b96ce5e54 100644 --- a/lib_rend/ivas_rotation_fx.c +++ b/lib_rend/ivas_rotation_fx.c @@ -1777,6 +1777,7 @@ ivas_error combine_external_and_head_orientations( } } } + test(); IF( hExtOrientationData != NULL && headRotQuaternions != NULL ) { @@ -1877,6 +1878,7 @@ ivas_error combine_external_and_head_orientations( } } } + test(); IF( headRotQuaternions != NULL || hExtOrientationData != NULL ) { @@ -1899,6 +1901,7 @@ ivas_error combine_external_and_head_orientations( hCombinedOrientationData->Quaternion_prev_extOrientation = identity; } } + IF( headRotQuaternions != NULL ) { FOR( i = 0; i < hCombinedOrientationData->num_subframes; i++ ) @@ -1906,6 +1909,7 @@ ivas_error combine_external_and_head_orientations( hCombinedOrientationData->listenerPos[i] = listenerPos[i]; } } + /* Check if combined orientation is enabled */ test(); test(); @@ -2014,6 +2018,7 @@ ivas_error combine_external_and_head_orientations( } } #endif + return IVAS_ERR_OK; } diff --git a/lib_util/ivas_rtp_pi_data.h b/lib_util/ivas_rtp_pi_data.h index cc238d97e..2bce92fa7 100644 --- a/lib_util/ivas_rtp_pi_data.h +++ b/lib_util/ivas_rtp_pi_data.h @@ -531,7 +531,7 @@ typedef union IVAS_PIDATA_NO_DATA noPiData; } PIDATA; -typedef struct +typedef struct pidata_ts_struct { PIDATA data; uint32_t timestamp; diff --git a/readme.txt b/readme.txt index c7bbcc4f2..169db9ad7 100644 --- a/readme.txt +++ b/readme.txt @@ -33,13 +33,14 @@ These files represent the 3GPP EVS Codec Extension for Immersive Voice and Audio Services (IVAS) BASOP C simulation. All code is writtten -in ISO/IEC C99. The system is implemented as five separate programs: +in ISO/IEC C99. The system is implemented as six separate programs: IVAS_cod IVAS Encoder IVAS_dec IVAS Decoder IVAS_rend IVAS External Renderer ISAR_post_rend ISAR Post Renderer - ambi_converter Ambisonics format converter + IVAS_cod_fmtsw IVAS Encoder with support for format switching + ambi_converter example program for Ambisonics format conversion For encoding using the coder program, the input is a binary audio file (*.8k, *.16k, *.32k, *.48k) and the output is a binary @@ -123,32 +124,39 @@ should have the following structure: . `-- c-code + |-- readme.txt |-- Makefile |-- Workspace_msvc |-- apps + |-- lib_basop |-- lib_com |-- lib_debug |-- lib_dec |-- lib_enc |-- lib_isar |-- lib_lc3plus - |-- lib_rend + |-- lib_rend |-- lib_util - |-- readme.txt - |-- .clang-format + |-- scripts The package includes a Makefile for gcc, which has been verified on 32-bit Linux systems. The code can be compiled by entering the directory "c-code" and typing the command: make. The resulting encoder/decoder/renderer/ ISAR_post_renderer executables are named "IVAS_cod", "IVAS_dec", "IVAS_rend", -and "ISAR_post_rend". All reside in the c-code directory. +and "ISAR_post_rend". All reside in the c-code directory. In addition, this +directory will contain a version of the encoder with support for format switching +(named "IVAS_cod_fmtsw") and an example program for Ambisonics format conversion +(named "ambi_converter"). The package also includes a solution-file for Microsoft Visual Studio 2017 (x86). To compile the code, please open "Workspace_msvc\Workspace_msvc.sln" and build "encoder" for the encoder, "decoder" for the decoder, and "renderer" for the renderer executable. The resulting encoder/decoder/renderer/ISAR_post_renderer executables are "IVAS_cod.exe", "IVAS_dec.exe", "IVAS_rend.exe", and -"ISAR_post_rend.exe". All reside in the c-code main directory. +"ISAR_post_rend.exe". All reside in the c-code main directory. In addition, this +directory will contain a version of the encoder with support for format switching +(named "IVAS_cod_fmtsw.exe") and an example program for Ambisonics format conversion +(named "ambi_converter.exe"). @@ -176,7 +184,7 @@ some potential race conditions. The usage of the "IVAS_cod" program is as follows: -------------------------------------------------- -Usage: IVAS_cod.exe [Options] R Fs input_file bitstream_file +Usage: IVAS_cod [Options] R Fs input_file bitstream_file Mandatory parameters: --------------------- @@ -261,9 +269,9 @@ EVS mono is default, for IVAS choose one of the following: -stereo, -ism, -sba, The usage of the "IVAS_dec" program is as follows: -------------------------------------------------- -Usage for EVS: IVAS_dec.exe [Options] Fs bitstream_file output_file +Usage for EVS: IVAS_dec [Options] Fs bitstream_file output_file OR usage for IVAS (below) with -evs option and OutputConf -Usage for IVAS: IVAS_dec.exe [Options] OutputConf Fs bitstream_file output_file +Usage for IVAS: IVAS_dec [Options] OutputConf Fs bitstream_file output_file Mandatory parameters: --------------------- @@ -370,8 +378,8 @@ Options: -q : Quiet mode, limit printouts to terminal, default is deactivated -The usage of the "ISAR_post_rend" program: ------------------------------------------- +The usage of the "ISAR_post_rend" program is as follows: +-------------------------------------------------------- Usage: ISAR_post_rend [options] @@ -385,8 +393,8 @@ Options: -prbfi File : BFI File -The usage of the "ambi_converter" program: ------------------------------------------- +The usage of the "ambi_converter" program is as follows: +-------------------------------------------------------- Usage: ambi_converter input_file output_file input_convention output_convention @@ -399,7 +407,17 @@ the following conventions are supported: 4 : SID-SN3D 5 : SID-N3D -Either the input or the output convention must always be ACN-SN3D! +Either the input or the output convention must always be ACN-SN3D. + +The usage of the "IVAS_cod_fmtsw" program is as follows: +-------------------------------------------------------- + +Usage: IVAS_cod_fmtsw format_switching_file + +Mandatory parameters: +--------------------- +format_switching_file: Text file containg a valid encoder command line in each line + MULTICHANNEL LOUDSPEAKER INPUT / OUTPUT CONFIGURATIONS -- GitLab From 885eee3573fc4745c5999cb2a5dfa0798c1486f0 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 11 Nov 2025 17:26:10 +0100 Subject: [PATCH 02/12] fix --- apps/encoder_fmtsw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/encoder_fmtsw.c b/apps/encoder_fmtsw.c index 5d48ec04f..501979b7b 100644 --- a/apps/encoder_fmtsw.c +++ b/apps/encoder_fmtsw.c @@ -219,7 +219,7 @@ int main( IVAS_ENC_PrintDisclaimer(); - if ( argc != 3 ) + if ( argc != 2 ) { fprintf( stdout, "Usage: IVAS_cod_fmtsw.exe format_switching_file\n\n" ); fprintf( stdout, "where format_switching_file is a text file containg a valid encoder command line in each line\n\n" ); -- GitLab From 9412db9f2d7e74c83c7091cf22d49c7ebc15cf1d Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 11 Nov 2025 17:35:47 +0100 Subject: [PATCH 03/12] clang-format --- apps/decoder.c | 28 ++++++++++++++-------------- apps/encoder_fmtsw.c | 4 ++-- lib_com/common_api_types.h | 2 +- lib_dec/ivas_init_dec_fx.c | 4 ++-- lib_dec/ivas_output_config_fx.c | 2 +- lib_dec/lib_dec_fx.c | 2 +- readme.txt | 2 +- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 88b330e8e..b8ec6184e 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -3247,13 +3247,13 @@ static ivas_error decodeVoIP( if ( ivasRtp.restartNeeded ) { IVAS_DEC_MODE newDecModeInPacket = ( ivasRtp.codecId == IVAS_RTP_EVS ) ? IVAS_DEC_MODE_EVS : IVAS_DEC_MODE_IVAS; - if(( error = restartDecoder( - &hIvasDec, - newDecModeInPacket, - &arg, - NULL, /* ToDo : Provide rendererConfig */ - NULL /* ToDo : Provide LS Custom Data */ - ) )!= IVAS_ERR_OK ) + if ( ( error = restartDecoder( + &hIvasDec, + newDecModeInPacket, + &arg, + NULL, /* ToDo : Provide rendererConfig */ + NULL /* ToDo : Provide LS Custom Data */ + ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nFailed to restart decoder from %d to %d\n", arg.decMode, newDecModeInPacket ); goto cleanup; @@ -3540,13 +3540,13 @@ static ivas_error decodeVoIP( } IVAS_DEC_MODE newDecModeInPacket = ( tempBsFormat == IVAS_DEC_BS_MONO ) ? IVAS_DEC_MODE_EVS : IVAS_DEC_MODE_IVAS; - if((error = restartDecoder( - &hIvasDec, - newDecModeInPacket , - &arg, - NULL, /* ToDo : Provide rendererConfig */ - NULL /* ToDo : Provide LS Custom Data */ - ) )!= IVAS_ERR_OK ) + if ( ( error = restartDecoder( + &hIvasDec, + newDecModeInPacket, + &arg, + NULL, /* ToDo : Provide rendererConfig */ + NULL /* ToDo : Provide LS Custom Data */ + ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nFailed to restart decoder\n" ); goto cleanup; diff --git a/apps/encoder_fmtsw.c b/apps/encoder_fmtsw.c index 501979b7b..df8236361 100644 --- a/apps/encoder_fmtsw.c +++ b/apps/encoder_fmtsw.c @@ -222,7 +222,7 @@ int main( if ( argc != 2 ) { fprintf( stdout, "Usage: IVAS_cod_fmtsw.exe format_switching_file\n\n" ); - fprintf( stdout, "where format_switching_file is a text file containg a valid encoder command line in each line\n\n" ); + fprintf( stdout, "where format_switching_file is a text file containing a valid encoder command line in each line\n\n" ); goto cleanup; } fprintf( stdout, "Input format switching file: %s\n", argv[1] ); @@ -281,7 +281,7 @@ cleanup: #ifdef IVAS_RTPDUMP IVAS_RTP_Term( &ivasRtp ); #endif - if( FmtSWFile) + if ( FmtSWFile ) { fclose( FmtSWFile ); } diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index d41635f8d..27290eb18 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -63,7 +63,7 @@ #define IVAS_ER_LIST_HEIGHT 1.6f #define IVAS_ER_LIST_HEIGHT_FX 6710886 /* 1.6f in Q.22 */ #ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT -#define IVAS_DEFAULT_AEID 65535 +#define IVAS_DEFAULT_AEID 65535 #endif /* JBM constants for adaptive-playout */ diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index ffbb0c6ab..3a1576404 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -322,7 +322,7 @@ ivas_error ivas_dec_get_format_fx( { #ifdef DECODER_FORMAT_SWITCHING test(); - if( st_ivas->nchan_transport == 1 && Opt_tsm ) + if ( st_ivas->nchan_transport == 1 && Opt_tsm ) { masaRestartCandidate = 1; move16(); @@ -337,7 +337,7 @@ ivas_error ivas_dec_get_format_fx( { #ifdef DECODER_FORMAT_SWITCHING test(); - if( st_ivas->nchan_transport == 2 && Opt_tsm ) + if ( st_ivas->nchan_transport == 2 && Opt_tsm ) { masaRestartCandidate = 1; move16(); diff --git a/lib_dec/ivas_output_config_fx.c b/lib_dec/ivas_output_config_fx.c index 0637ea4c9..9c988937b 100644 --- a/lib_dec/ivas_output_config_fx.c +++ b/lib_dec/ivas_output_config_fx.c @@ -119,7 +119,7 @@ void ivas_renderer_select( #ifdef FIX_1419_MONO_STEREO_UMX IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) || EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) { - ms_bin_upmix_renderer_select( st_ivas->ivas_format, internal_config, renderer_type ); + ms_bin_upmix_renderer_select( st_ivas->ivas_format, internal_config, renderer_type ); } ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) ) #else diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 178465c10..298d18697 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -3434,7 +3434,7 @@ static ivas_error feedAcousticEnvPI( move32(); /* Ignore if AE ID already in use */ - IF( EQ_16(hRenderConfig->roomAcoustics.aeID , hAcoustEnvPI.aeid )) + IF( EQ_16( hRenderConfig->roomAcoustics.aeID, hAcoustEnvPI.aeid ) ) { return IVAS_ERR_OK; } diff --git a/readme.txt b/readme.txt index 169db9ad7..c1783175a 100644 --- a/readme.txt +++ b/readme.txt @@ -416,7 +416,7 @@ Usage: IVAS_cod_fmtsw format_switching_file Mandatory parameters: --------------------- -format_switching_file: Text file containg a valid encoder command line in each line +format_switching_file: Text file containing a valid encoder command line in each line -- GitLab From 5b61fc19dd4cb1b3c6c36d72fe9d8c9f01c25fa2 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 11 Nov 2025 22:36:39 +0100 Subject: [PATCH 04/12] update Readme.txt --- apps/decoder.c | 9 ++++----- readme.txt | 3 +++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index b8ec6184e..60c3c2020 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1770,6 +1770,10 @@ static void usage_dec( void ) fprintf( stdout, "-rvf File : Reference vector specified by external trajectory File\n" ); fprintf( stdout, " works only in combination with '-otr ref_vec' and 'ref_vec_lev' modes\n" ); fprintf( stdout, "-render_config File : Renderer configuration File\n" ); +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE + fprintf( stdout, "-room_size (S|M|L) : Selects default reverb based on a room size (S - small | M - medium | L - large)\n" ); + fprintf( stdout, " for BINAURAL_ROOM_REVERB output configuration,\n" ); +#endif fprintf( stdout, "-om File : Metadata output File for BINAURAL_SPLIT_PCM OutputConf (only for Fs = 48 kHz)\n" ); fprintf( stdout, "-non_diegetic_pan P : panning mono non-diegetic sound to stereo with panning P, -90<= P <=90,\n" ); fprintf( stdout, " left or l or 90->left, right or r or -90->right, center or c or 0->middle\n" ); @@ -1785,13 +1789,8 @@ static void usage_dec( void ) fprintf( stdout, " ID and duration pairs, where duration is specified in frames\n" ); fprintf( stdout, " for BINAURAL_ROOM_REVERB output configuration.\n" ); fprintf( stdout, "-obj_edit File : Object editing instructions file or NULL for built-in example\n" ); - fprintf( stdout, "-level level : Complexity level, level = (1, 2, 3), will be defined after characterisation. \n" ); fprintf( stdout, " Currently, all values default to level 3 (full functionality).\n" ); -#ifdef FIX_1318_ROOM_SIZE_CMD_LINE - fprintf( stdout, "-room_size (S|M|L) : Selects default reverb based on a room size (S - small | M - medium | L - large)\n" ); - fprintf( stdout, " for BINAURAL_ROOM_REVERB output configuration,\n" ); -#endif fprintf( stdout, "-q : Quiet mode, no frame counter\n" ); fprintf( stdout, " default is deactivated\n" ); fprintf( stdout, "\n" ); diff --git a/readme.txt b/readme.txt index c1783175a..83285ff40 100644 --- a/readme.txt +++ b/readme.txt @@ -318,6 +318,8 @@ Options: -rvf File : Reference vector specified by external trajectory File works only in combination with '-otr ref_vec' and 'ref_vec_lev' modes -render_config File : Binaural renderer configuration parameters in File (only for binaural outputs) +-room_size (S|M|L) : Selects default reverb based on a room size (S - small | M - medium | L - large) + for BINAURAL_ROOM_REVERB output configuration -non_diegetic_pan P : panning mono non-diegetic sound to stereo -90<= P <=90, left or l or 90->left, right or r or -90->right, center or c or 0->middle -exof File : External orientation trajectory File for simulation of external orientations @@ -352,6 +354,7 @@ Options: -rf File : Reference rotation trajectory File for simulation of head tracking (only for binaural outputs) -rvf File : Reference vector trajectory File for simulation of head tracking (only for binaural outputs) -render_config File : Binaural renderer configuration parameters in File (only for binaural outputs) +-room_size (S|M|L) : Selects default reverb based on a room size (S - small | M - medium | L - large) -non_diegetic_pan P : Panning mono non-diegetic sound to stereo -90<= P <= 90 left or l or 90->left, right or r or -90->right, center or c or 0 ->middle -exof File : External orientation trajectory File for simulation of external orientations -- GitLab From 957f6fa31b24d8ad09bae25fdc97e27edb5148e5 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 12 Nov 2025 08:59:20 +0100 Subject: [PATCH 05/12] clang-format --- apps/decoder.c | 2 +- readme.txt | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 60c3c2020..e63caa5a3 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1773,7 +1773,7 @@ static void usage_dec( void ) #ifdef FIX_1318_ROOM_SIZE_CMD_LINE fprintf( stdout, "-room_size (S|M|L) : Selects default reverb based on a room size (S - small | M - medium | L - large)\n" ); fprintf( stdout, " for BINAURAL_ROOM_REVERB output configuration,\n" ); -#endif +#endif fprintf( stdout, "-om File : Metadata output File for BINAURAL_SPLIT_PCM OutputConf (only for Fs = 48 kHz)\n" ); fprintf( stdout, "-non_diegetic_pan P : panning mono non-diegetic sound to stereo with panning P, -90<= P <=90,\n" ); fprintf( stdout, " left or l or 90->left, right or r or -90->right, center or c or 0->middle\n" ); diff --git a/readme.txt b/readme.txt index 83285ff40..5adec9098 100644 --- a/readme.txt +++ b/readme.txt @@ -356,7 +356,7 @@ Options: -render_config File : Binaural renderer configuration parameters in File (only for binaural outputs) -room_size (S|M|L) : Selects default reverb based on a room size (S - small | M - medium | L - large) -non_diegetic_pan P : Panning mono non-diegetic sound to stereo -90<= P <= 90 - left or l or 90->left, right or r or -90->right, center or c or 0 ->middle + left or l or 90->left, right or r or -90->right, center or c or 0 ->middle -exof File : External orientation trajectory File for simulation of external orientations -dpid ID : Directivity pattern ID(s) (space-separated list of up to 4 numbers can be specified) for binaural output configuration @@ -367,10 +367,10 @@ Options: for BINAURAL_ROOM_REVERB output configuration. -lp Position : Output LFE position. Comma-delimited triplet of [gain, azimuth, elevation] where gain is linear (like --gain, -g) and azimuth, elevation are in degrees. - If specified, overrides the default behavior which attempts to map input to output LFE channel(s) + If specified, overrides the default behavior which attempts to map input to output LFE channel(s) -lm File : LFE panning matrix File (CSV table) containing a matrix of dimensions [ num_input_lfe x num_output_channels ] with elements specifying linear routing gain (like --gain, -g). - If specified, overrides the output LFE position option and the default behavior which attempts to map input to output LFE channel(s) + If specified, overrides the output LFE position option and the default behavior which attempts to map input to output LFE channel(s) -no_delay_cmp : Turn off delay compensation -g : Input gain (linear, not in dB) to be applied to input audio file -l : List supported audio formats -- GitLab From c7c69896844d8752d0583abb2ac2ddd35ad03358 Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Wed, 12 Nov 2025 12:42:10 +0100 Subject: [PATCH 06/12] Realloc replaced with calloc/free combination Using fixed-point absorption coeffs in PI frame --- lib_dec/lib_dec_fx.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 298d18697..4d6769668 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -3031,14 +3031,17 @@ ivas_error IVAS_DEC_AddAcousticEnvironment( /* If not found */ IF( pAE == NULL ) { - IVAS_ROOM_ACOUSTICS_CONFIG_DATA *ppAE = realloc( st_ivas->pAcousticEnvironments, ( st_ivas->acousticEnvironmentsCount + 1 ) * sizeof( IVAS_ROOM_ACOUSTICS_CONFIG_DATA ) ); + IVAS_ROOM_ACOUSTICS_CONFIG_DATA *ppAE = malloc( ( st_ivas->acousticEnvironmentsCount + 1 ) * sizeof( IVAS_ROOM_ACOUSTICS_CONFIG_DATA ) ); IF( ppAE == NULL ) { return IVAS_ERR_FAILED_ALLOC; } + memcpy( ppAE, st_ivas->pAcousticEnvironments, st_ivas->acousticEnvironmentsCount * sizeof( IVAS_ROOM_ACOUSTICS_CONFIG_DATA ) ); + free( st_ivas->pAcousticEnvironments ); st_ivas->pAcousticEnvironments = ppAE; + n = st_ivas->acousticEnvironmentsCount++; pAE = &st_ivas->pAcousticEnvironments[n]; move32(); @@ -3485,7 +3488,7 @@ static ivas_error feedAcousticEnvPI( move32(); move32(); - mvr2r( hAcoustEnvPI.absorbCoeffs, hRenderConfig->roomAcoustics.AbsCoeff, IVAS_ROOM_ABS_COEFF ); + Copy32( hRenderConfig->roomAcoustics.AbsCoeff_fx, hAcoustEnvPI.absorbCoeffs_fx, IVAS_ROOM_ABS_COEFF ); } IF( ( error = IVAS_DEC_AddAcousticEnvironment( hIvasDec, acEnv ) ) != IVAS_ERR_OK ) -- GitLab From 1940c7c45bc5cae5578439f0620c7575522cc938 Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Wed, 12 Nov 2025 13:20:16 +0100 Subject: [PATCH 07/12] And avoiding memcpy() --- lib_dec/lib_dec_fx.c | 46 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 4d6769668..e80db73c0 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -3038,7 +3038,49 @@ ivas_error IVAS_DEC_AddAcousticEnvironment( return IVAS_ERR_FAILED_ALLOC; } - memcpy( ppAE, st_ivas->pAcousticEnvironments, st_ivas->acousticEnvironmentsCount * sizeof( IVAS_ROOM_ACOUSTICS_CONFIG_DATA ) ); + FOR( n = 0; n < st_ivas->acousticEnvironmentsCount; n++ ) + { + pAE = &ppAE[n]; + pAE->aeID = roomAcousticsConfig.aeID; + pAE->nBands = roomAcousticsConfig.nBands; + pAE->acousticPreDelay_fx = roomAcousticsConfig.acousticPreDelay_fx; + pAE->inputPreDelay_fx = roomAcousticsConfig.inputPreDelay_fx; + + Copy32( roomAcousticsConfig.pFc_input_fx, pAE->pFc_input_fx, CLDFB_NO_CHANNELS_MAX ); // Q16 + Copy32( roomAcousticsConfig.pAcoustic_rt60_fx, pAE->pAcoustic_rt60_fx, CLDFB_NO_CHANNELS_MAX ); // Q26 + Copy32( roomAcousticsConfig.pAcoustic_dsr_fx, pAE->pAcoustic_dsr_fx, CLDFB_NO_CHANNELS_MAX ); // Q30 + + pAE->use_er = roomAcousticsConfig.use_er; + + move16(); + move16(); + move32(); + move32(); + move16(); + + IF( EQ_16( pAE->use_er, 1 ) ) + { + pAE->lowComplexity = roomAcousticsConfig.lowComplexity; + move32(); + + pAE->dimensions.x_fx = roomAcousticsConfig.dimensions.x_fx; + pAE->dimensions.y_fx = roomAcousticsConfig.dimensions.y_fx; + pAE->dimensions.z_fx = roomAcousticsConfig.dimensions.z_fx; + move32(); + move32(); + move32(); + + pAE->ListenerOrigin.x_fx = roomAcousticsConfig.ListenerOrigin.x_fx; + pAE->ListenerOrigin.y_fx = roomAcousticsConfig.ListenerOrigin.y_fx; + pAE->ListenerOrigin.z_fx = roomAcousticsConfig.ListenerOrigin.z_fx; + move32(); + move32(); + move32(); + + Copy32( roomAcousticsConfig.AbsCoeff_fx, pAE->AbsCoeff_fx, IVAS_ROOM_ABS_COEFF ); + } + } + free( st_ivas->pAcousticEnvironments ); st_ivas->pAcousticEnvironments = ppAE; @@ -3488,7 +3530,7 @@ static ivas_error feedAcousticEnvPI( move32(); move32(); - Copy32( hRenderConfig->roomAcoustics.AbsCoeff_fx, hAcoustEnvPI.absorbCoeffs_fx, IVAS_ROOM_ABS_COEFF ); + Copy32( hAcoustEnvPI.absorbCoeffs_fx, hRenderConfig->roomAcoustics.AbsCoeff_fx, IVAS_ROOM_ABS_COEFF ); } IF( ( error = IVAS_DEC_AddAcousticEnvironment( hIvasDec, acEnv ) ) != IVAS_ERR_OK ) -- GitLab From 89cde47d2deb3c56a96ca5fd5919aaa59ae16bb2 Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Wed, 12 Nov 2025 15:10:43 +0100 Subject: [PATCH 08/12] And copying the right data... --- lib_dec/lib_dec_fx.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index e80db73c0..1dfd15527 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -3041,16 +3041,16 @@ ivas_error IVAS_DEC_AddAcousticEnvironment( FOR( n = 0; n < st_ivas->acousticEnvironmentsCount; n++ ) { pAE = &ppAE[n]; - pAE->aeID = roomAcousticsConfig.aeID; - pAE->nBands = roomAcousticsConfig.nBands; - pAE->acousticPreDelay_fx = roomAcousticsConfig.acousticPreDelay_fx; - pAE->inputPreDelay_fx = roomAcousticsConfig.inputPreDelay_fx; + pAE->aeID = st_ivas->pAcousticEnvironments[n].aeID; + pAE->nBands = st_ivas->pAcousticEnvironments[n].nBands; + pAE->acousticPreDelay_fx = st_ivas->pAcousticEnvironments[n].acousticPreDelay_fx; + pAE->inputPreDelay_fx = st_ivas->pAcousticEnvironments[n].inputPreDelay_fx; - Copy32( roomAcousticsConfig.pFc_input_fx, pAE->pFc_input_fx, CLDFB_NO_CHANNELS_MAX ); // Q16 - Copy32( roomAcousticsConfig.pAcoustic_rt60_fx, pAE->pAcoustic_rt60_fx, CLDFB_NO_CHANNELS_MAX ); // Q26 - Copy32( roomAcousticsConfig.pAcoustic_dsr_fx, pAE->pAcoustic_dsr_fx, CLDFB_NO_CHANNELS_MAX ); // Q30 + Copy32( st_ivas->pAcousticEnvironments[n].pFc_input_fx, pAE->pFc_input_fx, CLDFB_NO_CHANNELS_MAX ); // Q16 + Copy32( st_ivas->pAcousticEnvironments[n].pAcoustic_rt60_fx, pAE->pAcoustic_rt60_fx, CLDFB_NO_CHANNELS_MAX ); // Q26 + Copy32( st_ivas->pAcousticEnvironments[n].pAcoustic_dsr_fx, pAE->pAcoustic_dsr_fx, CLDFB_NO_CHANNELS_MAX ); // Q30 - pAE->use_er = roomAcousticsConfig.use_er; + pAE->use_er = st_ivas->pAcousticEnvironments[n].use_er; move16(); move16(); @@ -3060,24 +3060,24 @@ ivas_error IVAS_DEC_AddAcousticEnvironment( IF( EQ_16( pAE->use_er, 1 ) ) { - pAE->lowComplexity = roomAcousticsConfig.lowComplexity; + pAE->lowComplexity = st_ivas->pAcousticEnvironments[n].lowComplexity; move32(); - pAE->dimensions.x_fx = roomAcousticsConfig.dimensions.x_fx; - pAE->dimensions.y_fx = roomAcousticsConfig.dimensions.y_fx; - pAE->dimensions.z_fx = roomAcousticsConfig.dimensions.z_fx; + pAE->dimensions.x_fx = st_ivas->pAcousticEnvironments[n].dimensions.x_fx; + pAE->dimensions.y_fx = st_ivas->pAcousticEnvironments[n].dimensions.y_fx; + pAE->dimensions.z_fx = st_ivas->pAcousticEnvironments[n].dimensions.z_fx; move32(); move32(); move32(); - pAE->ListenerOrigin.x_fx = roomAcousticsConfig.ListenerOrigin.x_fx; - pAE->ListenerOrigin.y_fx = roomAcousticsConfig.ListenerOrigin.y_fx; - pAE->ListenerOrigin.z_fx = roomAcousticsConfig.ListenerOrigin.z_fx; + pAE->ListenerOrigin.x_fx = st_ivas->pAcousticEnvironments[n].ListenerOrigin.x_fx; + pAE->ListenerOrigin.y_fx = st_ivas->pAcousticEnvironments[n].ListenerOrigin.y_fx; + pAE->ListenerOrigin.z_fx = st_ivas->pAcousticEnvironments[n].ListenerOrigin.z_fx; move32(); move32(); move32(); - Copy32( roomAcousticsConfig.AbsCoeff_fx, pAE->AbsCoeff_fx, IVAS_ROOM_ABS_COEFF ); + Copy32( st_ivas->pAcousticEnvironments[n].AbsCoeff_fx, pAE->AbsCoeff_fx, IVAS_ROOM_ABS_COEFF ); } } -- GitLab From 78e9c0c33ad10e11227ea0ae48dcd6b772dadffe Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Wed, 12 Nov 2025 15:12:42 +0100 Subject: [PATCH 09/12] Clang update --- lib_dec/lib_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 1dfd15527..f584f1c59 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -3046,7 +3046,7 @@ ivas_error IVAS_DEC_AddAcousticEnvironment( pAE->acousticPreDelay_fx = st_ivas->pAcousticEnvironments[n].acousticPreDelay_fx; pAE->inputPreDelay_fx = st_ivas->pAcousticEnvironments[n].inputPreDelay_fx; - Copy32( st_ivas->pAcousticEnvironments[n].pFc_input_fx, pAE->pFc_input_fx, CLDFB_NO_CHANNELS_MAX ); // Q16 + Copy32( st_ivas->pAcousticEnvironments[n].pFc_input_fx, pAE->pFc_input_fx, CLDFB_NO_CHANNELS_MAX ); // Q16 Copy32( st_ivas->pAcousticEnvironments[n].pAcoustic_rt60_fx, pAE->pAcoustic_rt60_fx, CLDFB_NO_CHANNELS_MAX ); // Q26 Copy32( st_ivas->pAcousticEnvironments[n].pAcoustic_dsr_fx, pAE->pAcoustic_dsr_fx, CLDFB_NO_CHANNELS_MAX ); // Q30 -- GitLab From 8b535ee6c5949a9f9f89dec3f39f528599877ae2 Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Thu, 13 Nov 2025 09:19:43 +0200 Subject: [PATCH 10/12] Remove extra operation to numpidata --- lib_dec/lib_dec_fx.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index f584f1c59..398bb1069 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -7134,7 +7134,6 @@ ivas_error IVAS_DEC_FeedPiDataToDecoder( { UWord32 piDataType = piData->data.noPiData.piDataType; move32(); - numPiData = UL_subNsD( numPiData, 1 ); /* Subtraction of WHILE variable */ SWITCH( piDataType ) { -- GitLab From d31e5945b2ee68aaf1a6461b56e758381eb1c533 Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Thu, 13 Nov 2025 11:42:07 +0200 Subject: [PATCH 11/12] Add description for RTP streaming format --- readme.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/readme.txt b/readme.txt index 5adec9098..583499993 100644 --- a/readme.txt +++ b/readme.txt @@ -705,3 +705,15 @@ obj__relele=0|1 if 1, obj__ele is interpreted as a relative modific If a parameter is not specified, that parameter is not edited. An empty line in the file corresponds to not editing any parameter in the item. Example files are available in folder /scripts/object_edit. + + +RTP streaming file +------------------- +IVAS supports a simple packing and unpacking for streaming file for the RTP. In this format a single RTP_streaming_packet +contains the length of an RTP packet followed by the actual RTP packet which is recorded as-is. This format is produced +by the encoder when using the -rtpdump switch and the decoder assumes this format in the input when -VOIP_hf_only=1 is set. + +typedef struct { + u_int32 length; /* size of the RTP packet in bytes */ + (u_int8 * length) RTP_packet; /* RTP packet (sized length * byte) */ +} RTP_streaming_packet; -- GitLab From 9a1e89c1d3921ceb45e194b3bf8a6ef2be56721f Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Thu, 13 Nov 2025 11:59:55 +0200 Subject: [PATCH 12/12] Clang format --- apps/decoder.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index aaca85081..7ffc98379 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -3263,15 +3263,15 @@ static ivas_error decodeVoIP( { IVAS_DEC_MODE newDecModeInPacket = ( ivasRtp.codecId == IVAS_RTP_EVS ) ? IVAS_DEC_MODE_EVS : IVAS_DEC_MODE_IVAS; if ( ( error = restartDecoder( - &hIvasDec, - newDecModeInPacket, - &arg, + &hIvasDec, + newDecModeInPacket, + &arg, #ifdef FIX_SPLIT_RENDERING_ON_DECODER_RESTART - renderConfig, + renderConfig, #else - NULL, /* ToDo : Provide rendererConfig */ + NULL, /* ToDo : Provide rendererConfig */ #endif - NULL /* ToDo : Provide LS Custom Data */ + NULL /* ToDo : Provide LS Custom Data */ ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nFailed to restart decoder from %d to %d\n", arg.decMode, newDecModeInPacket ); -- GitLab