Loading Workspace_msvc/lib_util.vcxproj +2 −0 Original line number Diff line number Diff line Loading @@ -108,6 +108,7 @@ <ClCompile Include="..\lib_util\cmdl_tools.c" /> <ClCompile Include="..\lib_util\evs_rtp_payload.c" /> <ClCompile Include="..\lib_util\g192.c" /> <ClCompile Include="..\lib_util\socket_comm.c" /> <ClCompile Include="..\lib_util\vector3_pair_file_reader.c" /> <ClCompile Include="..\lib_util\hrtf_file_reader.c" /> <ClCompile Include="..\lib_util\ism_file_reader.c" /> Loading @@ -134,6 +135,7 @@ <ClInclude Include="..\lib_util\cmdl_tools.h" /> <ClInclude Include="..\lib_util\evs_rtp_payload.h" /> <ClInclude Include="..\lib_util\g192.h" /> <ClInclude Include="..\lib_util\socket_comm.h" /> <ClInclude Include="..\lib_util\vector3_pair_file_reader.h" /> <ClInclude Include="..\lib_util\hrtf_file_reader.h" /> <ClInclude Include="..\lib_util\ism_file_reader.h" /> Loading apps/decoder.c +267 −7 Original line number Diff line number Diff line Loading @@ -43,6 +43,10 @@ #include "masa_file_writer.h" #include "render_config_reader.h" #include "rotation_file_reader.h" #ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO #include "socket_comm.h" #include "ivas_error_utils.h" #endif #ifdef SPLIT_REND_WITH_HEAD_ROT #include "split_render_file_read_write.h" #endif Loading Loading @@ -102,6 +106,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; Loading Loading @@ -153,13 +161,28 @@ typedef struct *------------------------------------------------------------------------------------------*/ 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 SPLIT_REND_WITH_HEAD_ROT #ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, unsigned int hSocket, Vector3PairFileReader *referenceVectorReader, uint8_t *splitRendBitsBuf, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); #else static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, uint8_t *splitRendBitsBuf, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); #endif #else #ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, unsigned int socketCommSocket, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); #else static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); #endif #endif #ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, unsigned int socketCommSocket, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec ); #else static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec ); #endif #ifdef DEBUGGING static ivas_error printBitstreamInfoVoip( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HANDLE hIvasDec ); Loading Loading @@ -199,6 +222,9 @@ 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 #ifdef DEBUGGING int32_t noClipping; int32_t cnt_frames_limited; Loading Loading @@ -312,16 +338,39 @@ int main( #endif ) { #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 } /*------------------------------------------------------------------------------------------* * Open reference rotation file Loading Loading @@ -826,14 +875,26 @@ int main( if ( arg.voipMode ) { #ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO error = decodeVoIP( arg, hBsReader, headRotReader, externalOrientationFileReader, refRotReader, hSocket, referenceVectorReader, hIvasDec ); #else error = decodeVoIP( arg, hBsReader, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, hIvasDec ); #endif } else { #ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO error = decodeG192( arg, hBsReader, headRotReader, externalOrientationFileReader, refRotReader, hSocket, referenceVectorReader, splitRendBitsBuf, hIvasDec, pcmBuf ); #else error = decodeG192( arg, hBsReader, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, splitRendBitsBuf, hIvasDec, pcmBuf ); #endif #else #ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO error = decodeG192( arg, hBsReader, headRotReader, externalOrientationFileReader, refRotReader, hSocket, referenceVectorReader, hIvasDec, pcmBuf ); #else error = decodeG192( arg, hBsReader, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, hIvasDec, pcmBuf ); #endif #endif } Loading Loading @@ -900,6 +961,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 ); Loading Loading @@ -1048,9 +1116,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; Loading Loading @@ -1261,6 +1335,15 @@ 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++; Loading @@ -1274,6 +1357,37 @@ 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; Loading Loading @@ -1632,6 +1746,43 @@ 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 ); */ pQuaternion->w = w; pQuaternion->x = x; pQuaternion->y = y; pQuaternion->z = z; } } else { return IVAS_ERROR( IVAS_ERR_INTERNAL, "Quaternion Parser: parsing error." ); } return IVAS_ERR_OK; } #endif /*---------------------------------------------------------------------* * usage_dec() Loading Loading @@ -1691,6 +1842,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" ); Loading Loading @@ -2043,6 +2198,9 @@ static ivas_error decodeG192( RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, #ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO uint32_t hSocket, #endif Vector3PairFileReader *referenceVectorReader, #ifdef SPLIT_REND_WITH_HEAD_ROT uint8_t *splitRendBitsBuf, Loading Loading @@ -2086,6 +2244,10 @@ static ivas_error decodeG192( SplitFileReadWrite *splitRendWriter = NULL; #endif #ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO char rxBuffer[SOCKET_BUFFER_SIZE]; #endif for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; ++i ) { ismWriters[i] = NULL; Loading Loading @@ -2220,7 +2382,11 @@ static ivas_error decodeG192( IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; #ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO if ( headRotReader == NULL && !arg.enableHeadrotTrajSocket ) #else if ( headRotReader == NULL ) #endif { for ( i = 0; i < num_subframes; i++ ) { Loading @@ -2238,12 +2404,43 @@ static ivas_error decodeG192( #endif 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 } #ifdef SPLIT_REND_WITH_HEAD_ROT } #endif Loading Loading @@ -2457,6 +2654,16 @@ static ivas_error decodeG192( #endif 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" ); Loading Loading @@ -2905,6 +3112,9 @@ static ivas_error decodeVoIP( RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, #ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO uint32_t hSocket, #endif Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec ) { Loading Loading @@ -2952,6 +3162,10 @@ 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 ) { Loading Loading @@ -3116,7 +3330,11 @@ static ivas_error decodeVoIP( IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; #ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO if ( headRotReader == NULL && !arg.enableHeadrotTrajSocket ) #else if ( headRotReader == NULL ) #endif { for ( i = 0; i < num_subframes; i++ ) { Loading @@ -3134,6 +3352,29 @@ static ivas_error decodeVoIP( #endif 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 ), Loading @@ -3141,6 +3382,15 @@ static ivas_error decodeVoIP( 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 } #ifdef SPLIT_REND_WITH_HEAD_ROT } #endif Loading Loading @@ -3312,6 +3562,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" ); Loading lib_com/ivas_error.h +9 −0 Original line number Diff line number Diff line Loading @@ -130,6 +130,15 @@ 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) * *----------------------------------------*/ Loading lib_com/options.h +4 −0 Original line number Diff line number Diff line Loading @@ -173,6 +173,10 @@ /* any switch which is non-be wrt selection floating point code */ /* all switches in this category should start with "NONBE_" */ #ifdef _MSC_VER #define SOCKET_INTERFACE_FOR_POSE_AND_AUDIO /* Philips: issue #1019: Socket interface for head rotation - Windows only */ #endif #define NONBE_FIX_978_MC_TDREND_REVERB /* Eri : activate reverb for TDREND with headtracking */ #define NONBE_FIX_984_OMASA_EXT_OUTPUT /* Nokia: issue #984: complete the OMASA EXT output implementation */ #define NONBE_FIX_1000_G1_G2_SWB_TBE /* VA: issue 1000: avoid div by zero due to g1 + g2 being zero in SWB TBE */ Loading lib_util/socket_comm.c 0 → 100644 +193 −0 File added.Preview size limit exceeded, changes collapsed. Show changes Loading
Workspace_msvc/lib_util.vcxproj +2 −0 Original line number Diff line number Diff line Loading @@ -108,6 +108,7 @@ <ClCompile Include="..\lib_util\cmdl_tools.c" /> <ClCompile Include="..\lib_util\evs_rtp_payload.c" /> <ClCompile Include="..\lib_util\g192.c" /> <ClCompile Include="..\lib_util\socket_comm.c" /> <ClCompile Include="..\lib_util\vector3_pair_file_reader.c" /> <ClCompile Include="..\lib_util\hrtf_file_reader.c" /> <ClCompile Include="..\lib_util\ism_file_reader.c" /> Loading @@ -134,6 +135,7 @@ <ClInclude Include="..\lib_util\cmdl_tools.h" /> <ClInclude Include="..\lib_util\evs_rtp_payload.h" /> <ClInclude Include="..\lib_util\g192.h" /> <ClInclude Include="..\lib_util\socket_comm.h" /> <ClInclude Include="..\lib_util\vector3_pair_file_reader.h" /> <ClInclude Include="..\lib_util\hrtf_file_reader.h" /> <ClInclude Include="..\lib_util\ism_file_reader.h" /> Loading
apps/decoder.c +267 −7 Original line number Diff line number Diff line Loading @@ -43,6 +43,10 @@ #include "masa_file_writer.h" #include "render_config_reader.h" #include "rotation_file_reader.h" #ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO #include "socket_comm.h" #include "ivas_error_utils.h" #endif #ifdef SPLIT_REND_WITH_HEAD_ROT #include "split_render_file_read_write.h" #endif Loading Loading @@ -102,6 +106,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; Loading Loading @@ -153,13 +161,28 @@ typedef struct *------------------------------------------------------------------------------------------*/ 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 SPLIT_REND_WITH_HEAD_ROT #ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, unsigned int hSocket, Vector3PairFileReader *referenceVectorReader, uint8_t *splitRendBitsBuf, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); #else static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, uint8_t *splitRendBitsBuf, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); #endif #else #ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, unsigned int socketCommSocket, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); #else static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); #endif #endif #ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, unsigned int socketCommSocket, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec ); #else static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec ); #endif #ifdef DEBUGGING static ivas_error printBitstreamInfoVoip( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HANDLE hIvasDec ); Loading Loading @@ -199,6 +222,9 @@ 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 #ifdef DEBUGGING int32_t noClipping; int32_t cnt_frames_limited; Loading Loading @@ -312,16 +338,39 @@ int main( #endif ) { #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 } /*------------------------------------------------------------------------------------------* * Open reference rotation file Loading Loading @@ -826,14 +875,26 @@ int main( if ( arg.voipMode ) { #ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO error = decodeVoIP( arg, hBsReader, headRotReader, externalOrientationFileReader, refRotReader, hSocket, referenceVectorReader, hIvasDec ); #else error = decodeVoIP( arg, hBsReader, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, hIvasDec ); #endif } else { #ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO error = decodeG192( arg, hBsReader, headRotReader, externalOrientationFileReader, refRotReader, hSocket, referenceVectorReader, splitRendBitsBuf, hIvasDec, pcmBuf ); #else error = decodeG192( arg, hBsReader, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, splitRendBitsBuf, hIvasDec, pcmBuf ); #endif #else #ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO error = decodeG192( arg, hBsReader, headRotReader, externalOrientationFileReader, refRotReader, hSocket, referenceVectorReader, hIvasDec, pcmBuf ); #else error = decodeG192( arg, hBsReader, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, hIvasDec, pcmBuf ); #endif #endif } Loading Loading @@ -900,6 +961,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 ); Loading Loading @@ -1048,9 +1116,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; Loading Loading @@ -1261,6 +1335,15 @@ 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++; Loading @@ -1274,6 +1357,37 @@ 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; Loading Loading @@ -1632,6 +1746,43 @@ 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 ); */ pQuaternion->w = w; pQuaternion->x = x; pQuaternion->y = y; pQuaternion->z = z; } } else { return IVAS_ERROR( IVAS_ERR_INTERNAL, "Quaternion Parser: parsing error." ); } return IVAS_ERR_OK; } #endif /*---------------------------------------------------------------------* * usage_dec() Loading Loading @@ -1691,6 +1842,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" ); Loading Loading @@ -2043,6 +2198,9 @@ static ivas_error decodeG192( RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, #ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO uint32_t hSocket, #endif Vector3PairFileReader *referenceVectorReader, #ifdef SPLIT_REND_WITH_HEAD_ROT uint8_t *splitRendBitsBuf, Loading Loading @@ -2086,6 +2244,10 @@ static ivas_error decodeG192( SplitFileReadWrite *splitRendWriter = NULL; #endif #ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO char rxBuffer[SOCKET_BUFFER_SIZE]; #endif for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; ++i ) { ismWriters[i] = NULL; Loading Loading @@ -2220,7 +2382,11 @@ static ivas_error decodeG192( IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; #ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO if ( headRotReader == NULL && !arg.enableHeadrotTrajSocket ) #else if ( headRotReader == NULL ) #endif { for ( i = 0; i < num_subframes; i++ ) { Loading @@ -2238,12 +2404,43 @@ static ivas_error decodeG192( #endif 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 } #ifdef SPLIT_REND_WITH_HEAD_ROT } #endif Loading Loading @@ -2457,6 +2654,16 @@ static ivas_error decodeG192( #endif 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" ); Loading Loading @@ -2905,6 +3112,9 @@ static ivas_error decodeVoIP( RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, #ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO uint32_t hSocket, #endif Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec ) { Loading Loading @@ -2952,6 +3162,10 @@ 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 ) { Loading Loading @@ -3116,7 +3330,11 @@ static ivas_error decodeVoIP( IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; #ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO if ( headRotReader == NULL && !arg.enableHeadrotTrajSocket ) #else if ( headRotReader == NULL ) #endif { for ( i = 0; i < num_subframes; i++ ) { Loading @@ -3134,6 +3352,29 @@ static ivas_error decodeVoIP( #endif 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 ), Loading @@ -3141,6 +3382,15 @@ static ivas_error decodeVoIP( 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 } #ifdef SPLIT_REND_WITH_HEAD_ROT } #endif Loading Loading @@ -3312,6 +3562,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" ); Loading
lib_com/ivas_error.h +9 −0 Original line number Diff line number Diff line Loading @@ -130,6 +130,15 @@ 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) * *----------------------------------------*/ Loading
lib_com/options.h +4 −0 Original line number Diff line number Diff line Loading @@ -173,6 +173,10 @@ /* any switch which is non-be wrt selection floating point code */ /* all switches in this category should start with "NONBE_" */ #ifdef _MSC_VER #define SOCKET_INTERFACE_FOR_POSE_AND_AUDIO /* Philips: issue #1019: Socket interface for head rotation - Windows only */ #endif #define NONBE_FIX_978_MC_TDREND_REVERB /* Eri : activate reverb for TDREND with headtracking */ #define NONBE_FIX_984_OMASA_EXT_OUTPUT /* Nokia: issue #984: complete the OMASA EXT output implementation */ #define NONBE_FIX_1000_G1_G2_SWB_TBE /* VA: issue 1000: avoid div by zero due to g1 + g2 being zero in SWB TBE */ Loading
lib_util/socket_comm.c 0 → 100644 +193 −0 File added.Preview size limit exceeded, changes collapsed. Show changes