From c328e08fcaa67d08cced5eb22ed156404f9c7573 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Mon, 8 Sep 2025 14:49:19 +0200 Subject: [PATCH 1/5] First changes - porting socket connection features (needs debugging) --- apps/decoder.c | 278 +++++++++++++++++++++++++++++++++++- lib_com/ivas_error.h | 11 ++ lib_com/options.h | 6 +- lib_util/bitstream_reader.c | 16 +++ lib_util/bitstream_reader.h | 3 + 5 files changed, 310 insertions(+), 4 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index a4424c92c..0581864bc 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -32,6 +32,7 @@ #include "lib_dec.h" #include +#include #include "cmdl_tools.h" #include "audio_file_writer.h" #include "bitstream_reader.h" @@ -43,11 +44,17 @@ #include "masa_file_writer.h" #include "render_config_reader.h" #include "rotation_file_reader.h" +#include "common_api_types.h" +#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO +#include "socket_comm.h" +#include "ivas_error_utils.h" +#endif #include "split_render_file_read_write.h" #include "vector3_pair_file_reader.h" #include "wmc_auto.h" #include "options.h" #include "stl.h" +#include "cnst.h" #define WMC_TOOL_SKIP @@ -102,6 +109,10 @@ typedef struct bool voipMode; bool enableHeadRotation; char *headrotTrajFileName; +#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO + bool enableHeadrotTrajSocket; + uint16_t socketPort; +#endif bool enableReferenceRotation; char *refrotTrajFileName; bool enableReferenceVectorTracking; @@ -135,16 +146,22 @@ typedef struct } DecArguments; - /*------------------------------------------------------------------------------------------* * Local functions prototypes *------------------------------------------------------------------------------------------*/ static bool parseCmdlIVAS_dec( int16_t argc, char **argv, DecArguments *arg ); +#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO +static ivas_error parseQuaternionData( char *rxBuffer, IVAS_QUATERNION *pQuaternion ); +#endif static void usage_dec( void ); +#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO +static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, unsigned int hSocket, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); +static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, unsigned int hSocket, IVAS_DEC_HANDLE hIvasDec ); +#else static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec ); - +#endif /*------------------------------------------------------------------------------------------* * main() @@ -177,6 +194,13 @@ int main( IVAS_DEC_HRTF_HANDLE *hHrtfTD = NULL; IVAS_DEC_HRTF_CREND_HANDLE *hSetOfHRTF = NULL; IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics = NULL; +#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO + uint32_t hSocket = (uint32_t) NULL; +#endif + + //hHrtfBinary.hHrtfTD = NULL; /* just to avoid compilation warning */ + //hHrtfBinary.hHrtfStatistics = NULL; /* just to avoid compilation warning */ + #ifdef WMOPS reset_wmops(); @@ -254,17 +278,39 @@ int main( /* sanity check */ if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { +#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO + fprintf( stderr, "\nError: Head-rotation cannot be used in this output configuration.\n\n" ); +#else arg.hrtfReaderEnabled = false; fprintf( stderr, "\nError: HRTF binary file cannot be used in this output configuration.\n\n" ); +#endif goto cleanup; } - +#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO + if ( arg.enableHeadrotTrajSocket ) + { + if ( ( error = SocketComm_start( &hSocket, arg.socketPort ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError: Can't start socket communication \n\n" ); + goto cleanup; + } + } + else + { + if ( ( error = RotationFileReader_open( arg.headrotTrajFileName, &headRotReader ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError: Can't open head-rotation file %s \n\n", arg.headrotTrajFileName ); + goto cleanup; + } + } +#else if ( ( error = hrtfFileReader_open( arg.hrtfFileName, &hrtfReader ) ) != IVAS_ERR_OK ) { arg.hrtfReaderEnabled = false; fprintf( stderr, "\nError: Can't open HRTF binary file %s \n\n", arg.hrtfFileName ); goto cleanup; } +#endif } /*------------------------------------------------------------------------------------------* @@ -681,11 +727,20 @@ int main( if ( arg.voipMode ) { +#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO + error = decodeVoIP( arg, hBsReader, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, hSocket, hIvasDec ); +#else error = decodeVoIP( arg, hBsReader, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, hIvasDec ); +#endif } else { + +#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO + error = decodeG192( arg, hBsReader, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, hSocket, &splitRendBits, hIvasDec, pcmBuf ); +#else error = decodeG192( arg, hBsReader, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, &splitRendBits, hIvasDec, pcmBuf ); +#endif } if ( error == IVAS_ERR_OK || error == IVAS_ERR_END_OF_FILE ) @@ -752,6 +807,13 @@ cleanup: Vector3PairFileReader_close( &referenceVectorReader ); RenderConfigReader_close( &renderConfigReader ); +#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO + if ( arg.enableHeadrotTrajSocket ) + { + SocketComm_close( hSocket ); + } +#endif + if ( BS_Reader_Close( &hBsReader ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError while closing file: %s\nContinuing...\n\n", arg.inputBitstreamFilename ); @@ -885,9 +947,15 @@ static bool parseCmdlIVAS_dec( arg->enableHeadRotation = false; arg->headrotTrajFileName = NULL; +#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO + arg->enableHeadrotTrajSocket = false; + arg->socketPort = 0; +#endif arg->orientation_tracking = ORIENT_TRK_NONE; arg->enableReferenceRotation = false; +#ifndef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO arg->headrotTrajFileName = NULL; +#endif arg->enableReferenceVectorTracking = false; arg->referenceVectorTrajFileName = NULL; arg->enableExternalOrientation = false; @@ -1024,6 +1092,14 @@ static bool parseCmdlIVAS_dec( } else if ( strcmp( argv_to_upper, "-T" ) == 0 ) { +#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO + if ( arg->enableHeadRotation ) + { + fprintf( stderr, "Error: Head rotation file and socket communication cannot be used together!\n\n" ); + usage_dec(); + return false; + } +#endif arg->enableHeadRotation = true; i++; @@ -1037,6 +1113,38 @@ static bool parseCmdlIVAS_dec( arg->headrotTrajFileName = argv[i]; i++; } + +#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO + else if ( strcmp( argv_to_upper, "-SOCKET" ) == 0 ) + { + if ( arg->enableHeadRotation ) + { + fprintf( stderr, "Error: Head rotation file and socket communication cannot be used together!\n\n" ); + usage_dec(); + return false; + } + + arg->enableHeadRotation = true; + arg->enableHeadrotTrajSocket = true; + i++; + + if ( argc - i <= 4 || argv[i][0] == '-' ) + { + fprintf( stderr, "Error: Socket port not specified!\n\n" ); + usage_dec(); + return false; + } + + arg->socketPort = (int16_t) atoi( argv[i++] ); + + if ( arg->socketPort < SOCKET_PORT_MIN || arg->socketPort > SOCKET_PORT_MAX ) + { + fprintf( stderr, "Error: Only ports in the range of %d-%d can be used!\n\n", SOCKET_PORT_MIN, SOCKET_PORT_MAX ); + usage_dec(); + return false; + } + } +#endif else if ( strcmp( argv_to_upper, "-FR" ) == 0 ) { int32_t tmp; @@ -1479,6 +1587,46 @@ static bool parseCmdlIVAS_dec( return true; } +#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO +/*-----------------------------------------------------------------------* + * parseQuaternionData() + * + * Parse Quaternion Data + *-----------------------------------------------------------------------*/ + +static ivas_error parseQuaternionData( + char *rxBuffer, /* i : data buffer */ + IVAS_QUATERNION *pQuaternion /* o : head-tracking data */ +) +{ + float w, x, y, z; + size_t charsConsumed; + const char *messageHeader = "IVAS buffer request"; + const int32_t read_values = sscanf( rxBuffer, "%*[^:]%n: %f, %f, %f, %f", &charsConsumed, &w, &x, &y, &z ); + + if ( read_values == 4 && charsConsumed == strlen( messageHeader ) && strncmp( rxBuffer, messageHeader, charsConsumed ) == 0 ) + { + { + /* Recieved values can be seen in console */ + printf( "[rotation: w=%+.2f, x=%+.2f, y=%+.2f, z=%+.2f]\n", w, x, y, z ); + + //Quaternion data is in float. Conver this to fixed point in Q22 format and set the Qformat of quaternion to 22. + pQuaternion->w_fx = (Word32) w * ONE_IN_Q22; + pQuaternion->x_fx = (Word32) x * ONE_IN_Q22; + pQuaternion->y_fx = (Word32) y * ONE_IN_Q22; + pQuaternion->z_fx = (Word32) z * ONE_IN_Q22; + // Q-factor of IVAS quaternion?? canwe set it to Q0? set to 22 later + pQuaternion->q_fact = 22; + } + } + else + { + return IVAS_ERROR( IVAS_ERR_INTERNAL, "Quaternion Parser: parsing error." ); + } + + return IVAS_ERR_OK; +} +#endif /*---------------------------------------------------------------------* * usage_dec() @@ -1527,6 +1675,10 @@ static void usage_dec( void ) fprintf( stdout, " default bitstream file format is G.192\n" ); fprintf( stdout, "-hrtf File : HRTF filter File used in BINAURAL output configuration\n" ); fprintf( stdout, "-T File : Head rotation specified by external trajectory File\n" ); +#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO + fprintf( stdout, "-socket port : Socket communication for pose input and audio output\n" ); + fprintf( stdout, " port = 49152-65535 (range of dynamic, private or ephemeral ports\n" ); +#endif fprintf( stdout, "-otr tracking_type : Head orientation tracking type: 'none', 'ref', 'avg', 'ref_vec' \n" ); fprintf( stdout, " or 'ref_vec_lev' (only for binaural rendering)\n" ); fprintf( stdout, "-rf File : Reference rotation specified by external trajectory File\n" ); @@ -1864,6 +2016,9 @@ static ivas_error decodeG192( RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, +#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO + uint32_t hSocket, +#endif ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ) @@ -1908,6 +2063,10 @@ static ivas_error decodeG192( return error; } +#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO + char rxBuffer[SOCKET_BUFFER_SIZE]; +#endif + if ( arg.renderConfigEnabled ) { if ( ( error = RenderConfigReader_open( arg.renderConfigFilename, &renderConfigReader ) ) != IVAS_ERR_OK ) @@ -2024,7 +2183,11 @@ static ivas_error decodeG192( { IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; +#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO + if ( headRotReader == NULL && !arg.enableHeadrotTrajSocket ) +#else if ( headRotReader == NULL ) +#endif { for ( i = 0; i < num_subframes; i++ ) { @@ -2043,11 +2206,42 @@ static ivas_error decodeG192( { for ( i = 0; i < num_subframes; i++ ) { +#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO + if ( arg.enableHeadrotTrajSocket ) + { + if ( i % num_subframes != 0 ) + { + Quaternions[i] = Quaternions[0]; + continue; + } + + if ( ( error = SocketComm_recv( hSocket, rxBuffer ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError %s while receiving head orientation\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + + if ( ( error = parseQuaternionData( rxBuffer, &Quaternions[i] ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError %s while parsing head orientation\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + } + else + { + if ( ( error = HeadRotationFileReading( headRotReader, &Quaternions[i], &Pos[i] ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError %s while reading head orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), RotationFileReader_getFilePath( headRotReader ) ); + goto cleanup; + } + } +#else if ( ( error = HeadRotationFileReading( headRotReader, &Quaternions[i], &Pos[i] ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError %s while reading head orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), RotationFileReader_getFilePath( headRotReader ) ); goto cleanup; } +#endif } } @@ -2128,6 +2322,22 @@ static ivas_error decodeG192( { if ( error == IVAS_ERR_END_OF_FILE ) { +#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO + /* Rewind the input bitstream at the end of file in case of socket communication */ + if ( arg.enableHeadrotTrajSocket ) + { + if ( ( error = BS_Reader_Rewind( hBsReader ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError: unable to rewind input bitstream file: %s \n\n", arg.inputBitstreamFilename ); + goto cleanup; + } + if ( ( error = BS_Reader_ReadFrame_short( hBsReader, bit_stream, &num_bits, &bfi ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError: input bitstream file couldn't be read: %s \n\n", arg.inputBitstreamFilename ); + goto cleanup; + } + } +#endif break; } fprintf( stderr, "\nError: input bitstream file couldn't be read: %s \n\n", arg.inputBitstreamFilename ); @@ -2220,6 +2430,16 @@ static ivas_error decodeG192( { if ( delayNumSamples < nOutSamples ) { +#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO + if ( arg.enableHeadrotTrajSocket ) + { + if ( ( error = SocketComm_send( hSocket, (char *) &pcmBuf[delayNumSamples * nOutChannels], ( nOutSamples * nOutChannels - ( delayNumSamples * nOutChannels ) ) * ( sizeof( *pcmBuf ) / sizeof( char ) ) ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError %s while sending audio buffer\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + } +#endif if ( ( error = AudioFileWriter_write( afWriter, &pcmBuf[delayNumSamples * nOutChannels], nOutSamples * nOutChannels - ( delayNumSamples * nOutChannels ) ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nOutput audio file writer error\n" ); @@ -2539,6 +2759,9 @@ static ivas_error decodeVoIP( RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, +#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO + uint32_t hSocket, +#endif IVAS_DEC_HANDLE hIvasDec ) { bool decodingFailed = true; /* Assume failure until cleanup is reached without errors */ @@ -2585,6 +2808,9 @@ static ivas_error decodeVoIP( int16_t vec_pos_update, vec_pos_len; int16_t nOutSamples = 0; +#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO + char rxBuffer[SOCKET_BUFFER_SIZE]; +#endif vec_pos_update = 0; if ( ( error = IVAS_DEC_GetRenderFramesizeMs( hIvasDec, &systemTimeInc_ms ) ) != IVAS_ERR_OK ) { @@ -2748,7 +2974,11 @@ static ivas_error decodeVoIP( { IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; +#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO + if ( headRotReader == NULL && !arg.enableHeadrotTrajSocket ) +#else if ( headRotReader == NULL ) +#endif { for ( i = 0; i < num_subframes; i++ ) { @@ -2767,11 +2997,43 @@ static ivas_error decodeVoIP( { for ( i = 0; i < num_subframes; i++ ) { +#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO + if ( arg.enableHeadrotTrajSocket ) + { + if ( i % num_subframes != 0 ) + { + Quaternions[i] = Quaternions[0]; + continue; + } + + if ( ( error = SocketComm_recv( hSocket, rxBuffer ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError %s while receiving head orientation\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + + if ( ( error = parseQuaternionData( rxBuffer, &Quaternions[i] ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError %s while parsing head orientation\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + } + else + { + if ( ( error = HeadRotationFileReading( headRotReader, &Quaternions[i], &Pos[i] ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError %s while reading head orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), + RotationFileReader_getFilePath( headRotReader ) ); + goto cleanup; + } + } +#else if ( ( error = HeadRotationFileReading( headRotReader, &Quaternions[i], &Pos[i] ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError %s while reading head orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), RotationFileReader_getFilePath( headRotReader ) ); goto cleanup; } +#endif } } @@ -2923,6 +3185,16 @@ static ivas_error decodeVoIP( { if ( delayNumSamples < nOutSamples ) { +#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO + if ( arg.enableHeadrotTrajSocket ) + { + if ( ( error = SocketComm_send( hSocket, (char *) &pcmBuf[delayNumSamples * nOutChannels], ( nOutSamples * nOutChannels - ( delayNumSamples * nOutChannels ) ) * ( sizeof( *pcmBuf ) / sizeof( char ) ) ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError %s while sending audio buffer\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + } +#endif if ( ( error = AudioFileWriter_write( afWriter, &pcmBuf[delayNumSamples * nOutChannels], nOutSamples * nOutChannels - ( delayNumSamples * nOutChannels ) ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nOutput audio file writer error\n" ); diff --git a/lib_com/ivas_error.h b/lib_com/ivas_error.h index cc3e4cd12..909d9faae 100644 --- a/lib_com/ivas_error.h +++ b/lib_com/ivas_error.h @@ -126,6 +126,17 @@ typedef enum IVAS_ERR_NO_FILE_OPEN, IVAS_ERR_SAMPLING_RATE_UNKNOWN, + +#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO + /*----------------------------------------* + * socket errors (lib_util only) * + *----------------------------------------*/ + IVAS_ERR_SOCKET_RECEIVE_FAILED, + IVAS_ERR_SOCKET_SEND_FAILED, + IVAS_ERR_SOCKET_TIMEOUT, +#endif + + /*----------------------------------------* * renderer (lib_rend only) * *----------------------------------------*/ diff --git a/lib_com/options.h b/lib_com/options.h index eb25a4227..15822881f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -41,7 +41,7 @@ /* ################### Start DEBUGGING switches ######################## */ -/*#define DEBUGGING*/ /* Allows debugging message to be printed out during runtime */ +#define DEBUGGING /* Allows debugging message to be printed out during runtime */ #ifdef DEBUGGING /*#define DBG_BITSTREAM_ANALYSIS*/ /* Write bitstream with annotations to a text file */ #define DEBUG_MODE_INFO /* Define to output most important parameters to the subdirectory "res/" */ @@ -91,6 +91,10 @@ #define FIX_1990_SANITIZER_IN_REVERB_LOAD /* Nokia: Fix issue part of issue 1990 by introducing missing free of structure. */ #define FIX_1995_REVERB_INIT /* VA/Nokia: issue 1995: Fix use-of-uninitialized-value in ivas_binaural_reverb_init() */ +#ifdef _MSC_VER +#define SOCKET_INTERFACE_FOR_POSE_AND_AUDIO /* Philips: Socket interface for head rotation - Windows only*/ +#endif + /* #################### Start BASOP porting switches ############################ */ #define NONBE_1244_FIX_SWB_BWE_MEMORY /* VA: issue 1244: fix to SWB BWE memory in case of switching from FB coding - pending a review by Huawei */ diff --git a/lib_util/bitstream_reader.c b/lib_util/bitstream_reader.c index 2bd6f46aa..576ffbede 100644 --- a/lib_util/bitstream_reader.c +++ b/lib_util/bitstream_reader.c @@ -263,6 +263,22 @@ cleanup: return error; } +#if defined( SOCKET_INTERFACE_FOR_POSE_AND_AUDIO ) || defined( DEBUGGING ) +ivas_error BS_Reader_Rewind( BS_READER_HANDLE hBsReader ) +{ + if ( hBsReader == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + if ( hBsReader->rewind == NULL ) + { + return IVAS_ERR_NOT_IMPLEMENTED; + } + + return hBsReader->rewind( hBsReader->hFormatReader ); +} +#endif ivas_error BS_Reader_ReadFrame_short( BS_READER_HANDLE hBsReader, uint16_t *serial, int16_t *num_bits, int16_t *bfi ) { diff --git a/lib_util/bitstream_reader.h b/lib_util/bitstream_reader.h index fb6f9f9b9..9f8c2303e 100644 --- a/lib_util/bitstream_reader.h +++ b/lib_util/bitstream_reader.h @@ -58,6 +58,9 @@ typedef struct BS_Reader *BS_READER_HANDLE; ivas_error BS_Reader_Open_filename( BS_READER_HANDLE *phBsReader, const char *filename, BS_READER_FORMAT format ); +#if defined( SOCKET_INTERFACE_FOR_POSE_AND_AUDIO ) || defined( DEBUGGING ) +ivas_error BS_Reader_Rewind( BS_READER_HANDLE hBsReader ); +#endif ivas_error BS_Reader_ReadFrame_short( BS_READER_HANDLE hBsReader, uint16_t *serial, int16_t *num_bits, int16_t *bfi ); -- GitLab From 2ca895c257d66265f7934dec0dc679f739816e34 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Mon, 8 Sep 2025 14:51:25 +0200 Subject: [PATCH 2/5] Added missing port for invoking socket_comm() --- apps/decoder.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/apps/decoder.c b/apps/decoder.c index 0581864bc..eafcd0bf9 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -322,15 +322,39 @@ int main( /* sanity check */ if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { + +#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO + fprintf( stderr, "\nError: Head-rotation cannot be used in this output configuration.\n\n" ); +#else fprintf( stderr, "\nError: Head-rotation file file cannot be used in this output configuration.\n\n" ); +#endif goto cleanup; } +#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO + if ( arg.enableHeadrotTrajSocket ) + { + if ( ( error = SocketComm_start( &hSocket, arg.socketPort ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError: Can't start socket communication \n\n" ); + goto cleanup; + } + } + else + { + if ( ( error = RotationFileReader_open( arg.headrotTrajFileName, &headRotReader ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError: Can't open head-rotation file %s \n\n", arg.headrotTrajFileName ); + goto cleanup; + } + } +#else if ( ( error = RotationFileReader_open( arg.headrotTrajFileName, &headRotReader ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError: Can't open head-rotation file %s \n\n", arg.headrotTrajFileName ); goto cleanup; } +#endif } /*------------------------------------------------------------------------------------------* -- GitLab From 0e26b3a5d345f5f591099446d0fbd2ca860388ca Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Tue, 9 Sep 2025 14:06:06 +0200 Subject: [PATCH 3/5] removed comments --- Workspace_msvc/decoder.vcxproj | 10 +++++----- Workspace_msvc/encoder.vcxproj | 4 ++-- Workspace_msvc/isar_post_rend.vcxproj | 2 +- Workspace_msvc/lib_com.vcxproj | 4 ++-- Workspace_msvc/lib_com.vcxproj.filters | 3 --- Workspace_msvc/lib_debug.vcxproj | 4 ++-- Workspace_msvc/lib_dec.vcxproj | 4 ++-- Workspace_msvc/lib_enc.vcxproj | 4 ++-- Workspace_msvc/lib_isar.vcxproj | 4 ++-- Workspace_msvc/lib_lc3plus.vcxproj | 2 +- Workspace_msvc/lib_rend.vcxproj | 6 +++--- Workspace_msvc/lib_rend.vcxproj.filters | 3 --- Workspace_msvc/lib_util.vcxproj | 10 ++++++---- Workspace_msvc/renderer.vcxproj | 6 +++--- apps/decoder.c | 14 +++++--------- 15 files changed, 36 insertions(+), 44 deletions(-) diff --git a/Workspace_msvc/decoder.vcxproj b/Workspace_msvc/decoder.vcxproj index 767d89e79..f8fe80329 100644 --- a/Workspace_msvc/decoder.vcxproj +++ b/Workspace_msvc/decoder.vcxproj @@ -14,7 +14,7 @@ decoder {E3DCBC31-7FC9-D127-E000-529F8460D5FD} decoder - 10.0.17763.0 + 10.0.19041.0 @@ -68,7 +68,7 @@ Disabled - ..\lib_dec;..\lib_com;..\lib_util;..\lib_debug;..\lib_isar;%(AdditionalIncludeDirectories) + ..\lib_dec;..\lib_com;..\lib_util;..\lib_debug;..\lib_isar;.\%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;WIN32;$(Macros);%(PreprocessorDefinitions) EnableFastChecks @@ -113,7 +113,7 @@ Neither false false - ..\lib_dec;..\lib_com;..\lib_util;..\lib_debug;..\lib_isar;%(AdditionalIncludeDirectories) + ..\lib_dec;..\lib_com;..\lib_util;..\lib_debug;..\lib_isar;.\%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions) true @@ -161,7 +161,7 @@ {869a305e-d99e-4c3a-bdb3-aa57abcce619} - + {2fa8f384-0775-f3b7-f8c3-85209222fc70} false @@ -175,4 +175,4 @@ - + \ No newline at end of file diff --git a/Workspace_msvc/encoder.vcxproj b/Workspace_msvc/encoder.vcxproj index 122e3e4e0..03e4e7af1 100644 --- a/Workspace_msvc/encoder.vcxproj +++ b/Workspace_msvc/encoder.vcxproj @@ -14,7 +14,7 @@ encoder {B3FC9DFC-7268-8660-7C0D-B60BAF02C554} encoder - 10.0.17763.0 + 10.0.19041.0 @@ -177,4 +177,4 @@ - + \ No newline at end of file diff --git a/Workspace_msvc/isar_post_rend.vcxproj b/Workspace_msvc/isar_post_rend.vcxproj index 170ff2054..e44bc448a 100644 --- a/Workspace_msvc/isar_post_rend.vcxproj +++ b/Workspace_msvc/isar_post_rend.vcxproj @@ -14,7 +14,7 @@ isar_post_rend {12374ADC-0E5C-4FDD-B903-71D572413831} isar_post_rend - 10.0.17763.0 + 10.0.19041.0 diff --git a/Workspace_msvc/lib_com.vcxproj b/Workspace_msvc/lib_com.vcxproj index 82a59ab68..949a27def 100644 --- a/Workspace_msvc/lib_com.vcxproj +++ b/Workspace_msvc/lib_com.vcxproj @@ -13,7 +13,7 @@ {39EC200D-7795-4FF8-B214-B24EDA5526AE} common - 10.0.17763.0 + 10.0.19041.0 @@ -344,4 +344,4 @@ - + \ No newline at end of file diff --git a/Workspace_msvc/lib_com.vcxproj.filters b/Workspace_msvc/lib_com.vcxproj.filters index 3fbbb7bc5..bc88593d9 100644 --- a/Workspace_msvc/lib_com.vcxproj.filters +++ b/Workspace_msvc/lib_com.vcxproj.filters @@ -184,9 +184,6 @@ common_all_c - - common_all_c - common_all_c diff --git a/Workspace_msvc/lib_debug.vcxproj b/Workspace_msvc/lib_debug.vcxproj index e52c492f7..0f66f3395 100644 --- a/Workspace_msvc/lib_debug.vcxproj +++ b/Workspace_msvc/lib_debug.vcxproj @@ -13,7 +13,7 @@ {54509728-928B-44D9-A118-A6F92F08B34F} debug - 10.0.17763.0 + 10.0.19041.0 @@ -120,4 +120,4 @@ - + \ No newline at end of file diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj index f18efbed4..17e192f73 100644 --- a/Workspace_msvc/lib_dec.vcxproj +++ b/Workspace_msvc/lib_dec.vcxproj @@ -14,7 +14,7 @@ lib_dec {E822DDAF-0F5F-4CD0-A694-38AE69DE74D3} evs_dec - 10.0.17763.0 + 10.0.19041.0 StaticLibrary @@ -350,4 +350,4 @@ - + \ No newline at end of file diff --git a/Workspace_msvc/lib_enc.vcxproj b/Workspace_msvc/lib_enc.vcxproj index 311507074..56c698679 100644 --- a/Workspace_msvc/lib_enc.vcxproj +++ b/Workspace_msvc/lib_enc.vcxproj @@ -14,7 +14,7 @@ lib_enc {824DA4CF-06F0-45C9-929A-8792F0E19C3E} evs_enc - 10.0.17763.0 + 10.0.19041.0 @@ -370,4 +370,4 @@ - + \ No newline at end of file diff --git a/Workspace_msvc/lib_isar.vcxproj b/Workspace_msvc/lib_isar.vcxproj index 95f64b54f..35e4eae2e 100644 --- a/Workspace_msvc/lib_isar.vcxproj +++ b/Workspace_msvc/lib_isar.vcxproj @@ -14,7 +14,7 @@ lib_isar {869A305E-D99E-4C3A-BDB3-AA57ABCCE619} isar - 10.0.17763.0 + 10.0.19041.0 @@ -182,4 +182,4 @@ - + \ No newline at end of file diff --git a/Workspace_msvc/lib_lc3plus.vcxproj b/Workspace_msvc/lib_lc3plus.vcxproj index 22b5cddd3..1dcc70d25 100644 --- a/Workspace_msvc/lib_lc3plus.vcxproj +++ b/Workspace_msvc/lib_lc3plus.vcxproj @@ -22,7 +22,7 @@ {95030B82-70CD-4C6B-84D4-61096035BEA2} Win32Proj LC3_FL - 10.0.17763.0 + 10.0.19041.0 diff --git a/Workspace_msvc/lib_rend.vcxproj b/Workspace_msvc/lib_rend.vcxproj index ff8946cc0..3c97e41c0 100644 --- a/Workspace_msvc/lib_rend.vcxproj +++ b/Workspace_msvc/lib_rend.vcxproj @@ -14,7 +14,7 @@ lib_rend {718DE063-A18B-BB72-9150-62B892E6FFA6} evs_dec - 10.0.17763.0 + 10.0.19041.0 StaticLibrary @@ -199,7 +199,7 @@ {95030B82-70CD-4C6B-84D4-61096035BEA2} false - + @@ -209,4 +209,4 @@ - + \ No newline at end of file diff --git a/Workspace_msvc/lib_rend.vcxproj.filters b/Workspace_msvc/lib_rend.vcxproj.filters index 820a5c044..2494e2ee2 100644 --- a/Workspace_msvc/lib_rend.vcxproj.filters +++ b/Workspace_msvc/lib_rend.vcxproj.filters @@ -31,9 +31,6 @@ rend_c - - rend_c - rend_c diff --git a/Workspace_msvc/lib_util.vcxproj b/Workspace_msvc/lib_util.vcxproj index b6b7fedfa..d773da5c0 100644 --- a/Workspace_msvc/lib_util.vcxproj +++ b/Workspace_msvc/lib_util.vcxproj @@ -13,7 +13,7 @@ {2FA8F384-0775-F3B7-F8C3-85209222FC70} utility - 10.0.17763.0 + 10.0.19041.0 @@ -123,7 +123,8 @@ - + + @@ -150,7 +151,8 @@ - + + @@ -160,4 +162,4 @@ - + \ No newline at end of file diff --git a/Workspace_msvc/renderer.vcxproj b/Workspace_msvc/renderer.vcxproj index a88ac29a5..e930db5ed 100644 --- a/Workspace_msvc/renderer.vcxproj +++ b/Workspace_msvc/renderer.vcxproj @@ -14,7 +14,7 @@ renderer {12B4C8A5-1E06-4E30-B443-D1F916F52B47} renderer - 10.0.17763.0 + 10.0.19041.0 @@ -160,7 +160,7 @@ {869a305e-d99e-4c3a-bdb3-aa57abcce619} - + {2FA8F384-0775-F3B7-F8C3-85209222FC70} false @@ -182,4 +182,4 @@ - + \ No newline at end of file diff --git a/apps/decoder.c b/apps/decoder.c index eafcd0bf9..bee6fe251 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -198,10 +198,6 @@ int main( uint32_t hSocket = (uint32_t) NULL; #endif - //hHrtfBinary.hHrtfTD = NULL; /* just to avoid compilation warning */ - //hHrtfBinary.hHrtfStatistics = NULL; /* just to avoid compilation warning */ - - #ifdef WMOPS reset_wmops(); reset_mem( USE_BYTES ); @@ -1635,12 +1631,12 @@ static ivas_error parseQuaternionData( printf( "[rotation: w=%+.2f, x=%+.2f, y=%+.2f, z=%+.2f]\n", w, x, y, z ); //Quaternion data is in float. Conver this to fixed point in Q22 format and set the Qformat of quaternion to 22. - pQuaternion->w_fx = (Word32) w * ONE_IN_Q22; - pQuaternion->x_fx = (Word32) x * ONE_IN_Q22; - pQuaternion->y_fx = (Word32) y * ONE_IN_Q22; - pQuaternion->z_fx = (Word32) z * ONE_IN_Q22; + pQuaternion->w_fx = w * ONE_IN_Q22; + pQuaternion->x_fx = x * ONE_IN_Q22; + pQuaternion->y_fx = y * ONE_IN_Q22; + pQuaternion->z_fx = z * ONE_IN_Q22; // Q-factor of IVAS quaternion?? canwe set it to Q0? set to 22 later - pQuaternion->q_fact = 22; + pQuaternion->q_fact = 25; } } else -- GitLab From 498265754482e0065c7c75328dd2b36813b39fcf Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Tue, 9 Sep 2025 14:25:48 +0200 Subject: [PATCH 4/5] Removed extra porting constructs from decoder.c --- apps/decoder.c | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index bee6fe251..131bdd8d9 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -274,39 +274,16 @@ int main( /* sanity check */ if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { -#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO - fprintf( stderr, "\nError: Head-rotation cannot be used in this output configuration.\n\n" ); -#else arg.hrtfReaderEnabled = false; fprintf( stderr, "\nError: HRTF binary file cannot be used in this output configuration.\n\n" ); -#endif goto cleanup; } -#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO - if ( arg.enableHeadrotTrajSocket ) - { - if ( ( error = SocketComm_start( &hSocket, arg.socketPort ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError: Can't start socket communication \n\n" ); - goto cleanup; - } - } - else - { - if ( ( error = RotationFileReader_open( arg.headrotTrajFileName, &headRotReader ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError: Can't open head-rotation file %s \n\n", arg.headrotTrajFileName ); - goto cleanup; - } - } -#else if ( ( error = hrtfFileReader_open( arg.hrtfFileName, &hrtfReader ) ) != IVAS_ERR_OK ) { arg.hrtfReaderEnabled = false; fprintf( stderr, "\nError: Can't open HRTF binary file %s \n\n", arg.hrtfFileName ); goto cleanup; } -#endif } /*------------------------------------------------------------------------------------------* @@ -506,7 +483,7 @@ int main( * Load renderer configuration from file *--------------------------------------------------------------------*/ - if ( arg.renderConfigEnabled ) + if ( arg.renderConfigEnabled ) { IVAS_RENDER_CONFIG_DATA renderConfig; -- GitLab From 6e0acb76165fb4327fbceb0b84597049eca6c862 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Tue, 21 Oct 2025 12:42:30 +0200 Subject: [PATCH 5/5] Fixed Q-factor assignmnet in parseQuaternionData() to resolve head-tracking issues --- apps/decoder.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 131bdd8d9..6de0df33b 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1607,13 +1607,13 @@ static ivas_error parseQuaternionData( /* Recieved values can be seen in console */ printf( "[rotation: w=%+.2f, x=%+.2f, y=%+.2f, z=%+.2f]\n", w, x, y, z ); - //Quaternion data is in float. Conver this to fixed point in Q22 format and set the Qformat of quaternion to 22. + //Quaternion data is in float. Convert this to fixed point in Q22 format and set the Qformat of quaternion to 22. pQuaternion->w_fx = w * ONE_IN_Q22; pQuaternion->x_fx = x * ONE_IN_Q22; pQuaternion->y_fx = y * ONE_IN_Q22; pQuaternion->z_fx = z * ONE_IN_Q22; - // Q-factor of IVAS quaternion?? canwe set it to Q0? set to 22 later - pQuaternion->q_fact = 25; + // Q-factor of IVAS quaternion?? can we set it to Q0? set to 22 later + pQuaternion->q_fact = 22; } } else -- GitLab