Loading lib_com/options.h +1 −0 Original line number Diff line number Diff line Loading @@ -164,6 +164,7 @@ #define IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT /* RTPDUMP acoustic environment */ #define FIXED_RTP_SEQUENCE_NUM /* Remove random sequence number initialization */ #define ISM_PI_DATA /* Add reading and packing/unpacking of ISM PI data */ #define REVERSE_ISM_PI_DATA /* Add reading and packing/unpacking of reverse ISM PI data */ /* ################### Start BE switches ################################# */ /* only BE switches wrt selection floating point code */ Loading lib_util/ivas_rtp_file.c +39 −0 Original line number Diff line number Diff line Loading @@ -199,7 +199,9 @@ void IVAS_RTP_LogPiData( #ifdef RTP_S4_251135_CR26253_0016_REV1 case IVAS_PI_PLAYBACK_DEVICE_ORIENTATION: case IVAS_PI_HEAD_ORIENTATION: #ifndef REVERSE_ISM_PI_DATA case IVAS_PI_R_ISM_ORIENTATION: #endif #endif { fprintf( f_piDataOut, "{\n\t\t\t\"w\": %f,\n\t\t\t\"x\": %f,\n\t\t\t\"y\": %f,\n\t\t\t\"z\": %f \n\t\t}", Loading @@ -225,7 +227,9 @@ void IVAS_RTP_LogPiData( break; #ifdef RTP_S4_251135_CR26253_0016_REV1 case IVAS_PI_LISTENER_POSITION: #ifndef REVERSE_ISM_PI_DATA case IVAS_PI_R_ISM_POSITION: #endif { fprintf( f_piDataOut, "{\n\t\t\t\"x\": %f,\n\t\t\t\"y\": %f,\n\t\t\t\"z\": %f \n\t\t}", cur->data.listnerPosition.position.x, cur->data.listnerPosition.position.y, cur->data.listnerPosition.position.z ); Loading Loading @@ -443,8 +447,43 @@ void IVAS_RTP_LogPiData( #endif case IVAS_PI_PI_LATENCY: case IVAS_PI_R_ISM_ID: #ifdef REVERSE_ISM_PI_DATA { fprintf( f_piDataOut, "{\n" ); fprintf( f_piDataOut, "\t\t\t\"id\": %d", cur->data.ismEditId.id ); fprintf( f_piDataOut, "\n\t\t}" ); } break; #endif case IVAS_PI_R_ISM_GAIN: #ifdef REVERSE_ISM_PI_DATA { fprintf( f_piDataOut, "{\n" ); fprintf( f_piDataOut, "\t\t\t\"gain\": %d", cur->data.ismEditGain.dB ); fprintf( f_piDataOut, "\n\t\t}" ); } break; case IVAS_PI_R_ISM_ORIENTATION: { fprintf( f_piDataOut, "{\n\t\t\t\"w\": %f,\n\t\t\t\"x\": %f,\n\t\t\t\"y\": %f,\n\t\t\t\"z\": %f \n\t\t}", cur->data.ismEditOrientation.orientation.w, cur->data.ismEditOrientation.orientation.x, cur->data.ismEditOrientation.orientation.y, cur->data.ismEditOrientation.orientation.z ); } break; case IVAS_PI_R_ISM_POSITION: { fprintf( f_piDataOut, "{\n\t\t\t\"x\": %f,\n\t\t\t\"y\": %f,\n\t\t\t\"z\": %f \n\t\t}", cur->data.ismEditPosition.position.x, cur->data.ismEditPosition.position.y, cur->data.ismEditPosition.position.z ); } break; #endif case IVAS_PI_R_ISM_DIRECTION: #ifdef REVERSE_ISM_PI_DATA { fprintf( f_piDataOut, "{\n\t\t\t\"azi\": %f,\n\t\t\t\"elev\": %f \n\t\t}", cur->data.ismEditDirection.azimuth, cur->data.ismEditDirection.elevation ); } break; #endif #endif /* RTP_S4_251135_CR26253_0016_REV1 */ case IVAS_PI_NO_DATA: { Loading lib_util/ivas_rtp_internal.h +3 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,9 @@ enum MASK_BITS MASK_6BIT = 0x3F, MASK_7BIT = 0x7F, MASK_8BIT = 0xFF, #ifdef REVERSE_ISM_PI_DATA MASK_9BIT = 0x1FF, #endif }; Loading lib_util/ivas_rtp_pi_data.c +273 −9 Original line number Diff line number Diff line Loading @@ -32,6 +32,9 @@ #include "ivas_error_utils.h" #include "ivas_rtp_internal.h" #ifdef REVERSE_ISM_PI_DATA #include <math.h> #endif #ifdef ISM_PI_DATA #include <stdlib.h> Loading Loading @@ -510,6 +513,56 @@ static ivas_error unpackDynamicSuppression( const uint8_t *buffer, uint32_t numD return IVAS_ERR_OK; } #ifdef REVERSE_ISM_PI_DATA static ivas_error packPosition( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) { uint32_t nBytes = 0; const IVAS_PIDATA_POSITION *position = (const IVAS_PIDATA_POSITION *) piData; *nBytesWritten = 0; if ( piData->size != sizeof( IVAS_PIDATA_POSITION ) ) { return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect size in position PI data" ); } if ( piData->piDataType != IVAS_PI_LISTENER_POSITION && piData->piDataType != IVAS_PI_R_ISM_POSITION ) { return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect PI ID in position PI data" ); } /* Position data is 6 bytes, header is 2 bytes */ if ( maxDataBytes < 6 + 2 ) { return IVAS_ERROR( IVAS_ERR_RTP_INSUFFICIENT_OUTPUT_SIZE, "Insufficient space to pack position PI data" ); } buffer[nBytes++] = ( position->piDataType & MASK_5BIT ); /* PF/PM populated during final packing */ buffer[nBytes++] = 6; nBytes = writeInt16( buffer, nBytes, ivasPayload_convertToQ15( position->position.x / MAX_PI_POSITION_METERS ) ); nBytes = writeInt16( buffer, nBytes, ivasPayload_convertToQ15( position->position.y / MAX_PI_POSITION_METERS ) ); nBytes = writeInt16( buffer, nBytes, ivasPayload_convertToQ15( position->position.z / MAX_PI_POSITION_METERS ) ); *nBytesWritten = nBytes; return IVAS_ERR_OK; } static ivas_error unpackPosition( const uint8_t *buffer, uint32_t numDataBytes, IVAS_PIDATA_GENERIC *piData ) { IVAS_PIDATA_POSITION *position = (IVAS_PIDATA_POSITION *) piData; /* Position data is 6 bytes */ if ( numDataBytes != 6 ) { return IVAS_ERROR( IVAS_ERR_RTP_UNPACK_PI_DATA, "Incorrect size to unpack position PI data" ); } position->size = sizeof( IVAS_PIDATA_POSITION ); position->position.x = FLOAT_FROM_Q15( readInt16( &buffer[0] ) ) * MAX_PI_POSITION_METERS; position->position.y = FLOAT_FROM_Q15( readInt16( &buffer[2] ) ) * MAX_PI_POSITION_METERS; position->position.z = FLOAT_FROM_Q15( readInt16( &buffer[4] ) ) * MAX_PI_POSITION_METERS; return IVAS_ERR_OK; } #else static ivas_error packListenerPosition( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) { uint32_t nBytes = 0; Loading Loading @@ -559,6 +612,7 @@ static ivas_error unpackListenerPosition( const uint8_t *buffer, uint32_t numDat listener->position.z = FLOAT_FROM_Q15( readInt16( &buffer[4] ) ) * MAX_PI_POSITION_METERS; return IVAS_ERR_OK; } #endif #ifdef ISM_PI_DATA static ivas_error packISMPosition( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) Loading Loading @@ -1144,6 +1198,188 @@ static ivas_error unpackISMDirectivity( const uint8_t *buffer, uint32_t numDataB } #endif #ifdef REVERSE_ISM_PI_DATA static ivas_error packReverseISMID( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) { uint32_t nBytes = 0; const IVAS_PIDATA_ISM_EDIT_ID *r_ism_id = (const IVAS_PIDATA_ISM_EDIT_ID *) piData; *nBytesWritten = 0; if ( piData->size > sizeof( IVAS_PIDATA_ISM_EDIT_ID ) ) { return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect size in R_ISM_ID PI data" ); } if ( piData->piDataType != IVAS_PI_R_ISM_ID ) { return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect PI ID in R_ISM_ID PI data" ); } /* R_ISM_ID data is 1 byte, header is 2 bytes */ if ( maxDataBytes < 1 + 2 ) { return IVAS_ERROR( IVAS_ERR_RTP_INSUFFICIENT_OUTPUT_SIZE, "Insufficient space to pack R_ISM_NUM PI data" ); } buffer[nBytes++] = ( r_ism_id->piDataType & MASK_5BIT ); /* PF/PM populated during final packing */ buffer[nBytes++] = ( r_ism_id->id & MASK_8BIT ); *nBytesWritten = nBytes; return IVAS_ERR_OK; } static ivas_error unpackReverseISMID( const uint8_t *buffer, uint32_t numDataBytes, IVAS_PIDATA_GENERIC *piData ) { IVAS_PIDATA_ISM_EDIT_ID *r_ism_id = (IVAS_PIDATA_ISM_EDIT_ID *) piData; /* ISM_ID data is 1 byte*/ if ( numDataBytes > 1 ) { return IVAS_ERROR( IVAS_ERR_RTP_UNPACK_PI_DATA, "Incorrect size to unpack R_ISM_ID PI data" ); } r_ism_id->size = sizeof( IVAS_PIDATA_ISM_EDIT_ID ); r_ism_id->piDataType = IVAS_PI_R_ISM_ID; r_ism_id->id = *buffer; return IVAS_ERR_OK; } static ivas_error packReverseISMGain( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) { uint32_t nBytes = 0, idx; int16_t gain; const IVAS_PIDATA_ISM_EDIT_GAIN *r_ism_gain = (const IVAS_PIDATA_ISM_EDIT_GAIN *) piData; *nBytesWritten = 0; if ( piData->size > sizeof( IVAS_PIDATA_ISM_EDIT_GAIN ) ) { return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect size in R_ISM_GAIN PI data" ); } if ( piData->piDataType != IVAS_PI_R_ISM_GAIN ) { return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect PI ID in R_ISM_GAIN PI data" ); } /* R_ISM_GAIN data is 1 byte, header is 2 bytes */ if ( maxDataBytes < 1 + 2 ) { return IVAS_ERROR( IVAS_ERR_RTP_INSUFFICIENT_OUTPUT_SIZE, "Insufficient space to pack R_ISM_GAIN PI data" ); } buffer[nBytes++] = ( r_ism_gain->piDataType & MASK_5BIT ); /* PF/PM populated during final packing */ gain = (int16_t) r_ism_gain->dB; idx = min( -gain, 97 ); if ( gain > 0 ) { idx += 97; } buffer[nBytes++] = ( idx & MASK_7BIT ) << 1; *nBytesWritten = nBytes; return IVAS_ERR_OK; } static ivas_error unpackReverseISMGain( const uint8_t *buffer, uint32_t numDataBytes, IVAS_PIDATA_GENERIC *piData ) { uint32_t idx; IVAS_PIDATA_ISM_EDIT_GAIN *r_ism_gain = (IVAS_PIDATA_ISM_EDIT_GAIN *) piData; /* R_ISM_GAIN data is 1 byte */ if ( numDataBytes > 1 ) { return IVAS_ERROR( IVAS_ERR_RTP_UNPACK_PI_DATA, "Incorrect size to unpack R_ISM_GAIN PI data" ); } r_ism_gain->size = sizeof( IVAS_PIDATA_ISM_EDIT_GAIN ); r_ism_gain->piDataType = IVAS_PI_R_ISM_GAIN; /* Unpack gain */ idx = ( *buffer ) >> 1; /* negative gains*/ if ( idx < 97 ) { r_ism_gain->dB = -(int8_t) ( idx ); } /* Set to min for muting, to be interpreted as -Inf */ else if ( idx == 97 ) { r_ism_gain->dB = -128; } /* postive gains */ else if ( idx < 101 ) { r_ism_gain->dB = (int8_t) idx - 97; } else { return IVAS_ERROR( IVAS_ERR_RTP_UNPACK_PI_DATA, "Incorrect index for R_ISM_GAIN PI data" ); } return IVAS_ERR_OK; } static ivas_error packReverseISMDirection( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) { uint32_t nBytes = 0; const IVAS_PIDATA_ISM_EDIT_DIRECTION *r_ism_direction = (const IVAS_PIDATA_ISM_EDIT_DIRECTION *) piData; uint16_t word; *nBytesWritten = 0; if ( piData->size > sizeof( IVAS_PIDATA_ISM_EDIT_DIRECTION ) ) { return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect size in R_ISM_DIRECTION PI data" ); } if ( piData->piDataType != IVAS_PI_R_ISM_DIRECTION ) { return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect PI ID in ISM_DIRECTION PI data" ); } /* R_ISM_DIRECTION data is 2 bytes, header is 2 bytes */ if ( maxDataBytes > 2 + 2 ) { return IVAS_ERROR( IVAS_ERR_RTP_INSUFFICIENT_OUTPUT_SIZE, "Insufficient space to pack R_ISM_DIRECTION PI data" ); } buffer[nBytes++] = ( r_ism_direction->piDataType & MASK_5BIT ); /* PF/PM populated during final packing */ word = (uint16_t) ( min( (uint16_t) ceilf( r_ism_direction->azimuth * REVERSE_ISM_DIRECTION_AZIMUTH_STEP_INV ) + 256, 511 ) << 7 ); word |= (uint16_t) ( min( (uint16_t) ceilf( r_ism_direction->elevation * REVERSE_ISM_DIRECTION_ELEVATION_STEP_INV ) + 64, 127 ) << 6 ); buffer[nBytes++] = ( word >> 8 ) & MASK_8BIT; buffer[nBytes++] = word & MASK_8BIT; *nBytesWritten = nBytes; return IVAS_ERR_OK; } static ivas_error unpackReverseISMDirection( const uint8_t *buffer, uint32_t numDataBytes, IVAS_PIDATA_GENERIC *piData ) { uint16_t word; IVAS_PIDATA_ISM_EDIT_DIRECTION *r_ism_direction = (IVAS_PIDATA_ISM_EDIT_DIRECTION *) piData; /* R_ISM_DIRECTION data is 2 bytes */ if ( numDataBytes > 2 ) { return IVAS_ERROR( IVAS_ERR_RTP_UNPACK_PI_DATA, "Incorrect size to unpack R_ISM_DIRECTION PI data" ); } r_ism_direction->size = sizeof( IVAS_PIDATA_ISM_EDIT_DIRECTION ); r_ism_direction->piDataType = IVAS_PI_R_ISM_DIRECTION; word = ( buffer[0] ) << 8; word |= ( buffer[1] ); r_ism_direction->azimuth = (float) ( ( ( word >> 7 ) & MASK_9BIT ) + 1 ) * REVERSE_ISM_DIRECTION_AZIMUTH_STEP - 180.0f; r_ism_direction->elevation = (float) ( word & MASK_7BIT ) * REVERSE_ISM_DIRECTION_ELEVATION_STEP - 90.0f; return IVAS_ERR_OK; } #endif #endif /* RTP_S4_251135_CR26253_0016_REV1 */ Loading Loading @@ -1189,7 +1425,11 @@ static const PACK_PI_FN packPiDataFuntions[IVAS_PI_MAX_ID] = { #ifdef RTP_S4_251135_CR26253_0016_REV1 packOrientation, /* PLAYBACK_DEVICE_ORIENTATION */ packOrientation, /* HEAD_ORIENTATION */ #ifdef REVERSE_ISM_PI_DATA packPosition, /* LISTENER_POSITION */ #else packListenerPosition, /* LISTENER_POSITION */ #endif packDynamicSuppression, /* DYNAMIC_AUDIO_SUPPRESSION */ packAudioFocusCommon, /* AUDIO_FOCUS_REQUEST */ #else Loading @@ -1200,15 +1440,25 @@ static const PACK_PI_FN packPiDataFuntions[IVAS_PI_MAX_ID] = { packUnsupportedData, /* AUDIO_FOCUS_DIRECTION */ #endif packUnsupportedData, /* PI_LATENCY */ #ifdef REVERSE_ISM_PI_DATA packReverseISMID, /* R_ISM_ID */ packReverseISMGain, /* R_ISM_GAIN */ #else packUnsupportedData, /* R_ISM_ID */ packUnsupportedData, /* R_ISM_GAIN */ #endif #ifdef RTP_S4_251135_CR26253_0016_REV1 packOrientation, /* R_ISM_ORIENTATION */ #else packUnsupportedData, /* R_ISM_ORIENTATION */ #endif #ifdef REVERSE_ISM_PI_DATA packPosition, /* R_ISM_POSITION */ packReverseISMDirection, /* R_ISM_DIRECTION */ #else packUnsupportedData, /* R_ISM_POSITION */ packUnsupportedData, /* R_ISM_DIRECTION */ #endif packUnsupportedData, /* RESERVED27 */ packUnsupportedData, /* RESERVED28 */ packUnsupportedData, /* RESERVED29 */ Loading Loading @@ -1258,7 +1508,11 @@ static const UNPACK_PI_FN unpackPiDataFuntions[IVAS_PI_MAX_ID] = { #ifdef RTP_S4_251135_CR26253_0016_REV1 unpackOrientation, /* PLAYBACK_DEVICE_ORIENTATION */ unpackOrientation, /* HEAD_ORIENTATION */ #ifdef REVERSE_ISM_PI_DATA unpackPosition, /* LISTENER_POSITION */ #else unpackListenerPosition, /* LISTENER_POSITION */ #endif unpackDynamicSuppression, /* DYNAMIC_AUDIO_SUPPRESSION */ unpackAudioFocusCommon, /* AUDIO_FOCUS_REQUEST */ #else Loading @@ -1269,15 +1523,25 @@ static const UNPACK_PI_FN unpackPiDataFuntions[IVAS_PI_MAX_ID] = { unpackUnsupportedData, /* AUDIO_FOCUS_DIRECTION */ #endif unpackUnsupportedData, /* PI_LATENCY */ #ifdef REVERSE_ISM_PI_DATA unpackReverseISMID, /* R_ISM_ID */ unpackReverseISMGain, /* R_ISM_GAIN */ #else unpackUnsupportedData, /* R_ISM_ID */ unpackUnsupportedData, /* R_ISM_GAIN */ #endif #ifdef RTP_S4_251135_CR26253_0016_REV1 unpackOrientation, /* R_ISM_ORIENTATION */ #else unpackUnsupportedData, /* R_ISM_ORIENTATION */ #endif #ifdef REVERSE_ISM_PI_DATA unpackPosition, /* R_ISM_POSITION */ unpackReverseISMDirection, /* R_ISM_DIRECTION */ #else unpackUnsupportedData, /* R_ISM_POSITION */ unpackUnsupportedData, /* R_ISM_DIRECTION */ #endif unpackUnsupportedData, /* RESERVED27 */ unpackUnsupportedData, /* RESERVED28 */ unpackUnsupportedData, /* RESERVED29 */ Loading lib_util/ivas_rtp_pi_data.h +32 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,13 @@ #define IVAS_PI_MAX_DATA_SIZE ( 32 + 2 ) /* max packed PI data bytes + pi header bytes */ #ifdef REVERSE_ISM_PI_DATA #define REVERSE_ISM_DIRECTION_AZIMUTH_STEP 0.703125f #define REVERSE_ISM_DIRECTION_ELEVATION_STEP 1.417322835f #define REVERSE_ISM_DIRECTION_AZIMUTH_STEP_INV 1.4222222222f #define REVERSE_ISM_DIRECTION_ELEVATION_STEP_INV 0.7055555556f #endif /* IVAS PI Data Types */ typedef enum { Loading Loading @@ -347,6 +354,20 @@ typedef struct IVAS_FLVL flvl; /* audio focus level */ } IVAS_PIDATA_AUDIO_FOCUS; #ifdef REVERSE_ISM_PI_DATA /* Position data corresponding to any of the following pi data types :- * - IVAS_PI_LISTENER_POSITION * - IVAS_PI_R_ISM_POSITION * * piDataType is used to identify the correct pi data type contained here */ typedef struct { size_t size; /* sizeof(IVAS_PIDATA_POSITION) */ uint32_t piDataType; /* one of supported position data types */ IVAS_COORDINATE position; /* Position data */ } IVAS_PIDATA_POSITION; #else /* Listener position */ typedef struct { Loading @@ -354,6 +375,7 @@ typedef struct uint32_t piDataType; /* IVAS_PI_LISTENER_POSITION */ IVAS_COORDINATE position; /* Position of audio objects in ISM(s) */ } IVAS_PIDATA_LISTENER_POSITION; #endif /* Dynamic Audio Suppression describes receiver’s preference with respect to the * type of audio content that should be enhanced and the amount of suppression to Loading Loading @@ -428,6 +450,7 @@ typedef struct IVAS_QUATERNION orientation; /* orientation editing request for received ISM */ } IVAS_PIDATA_ISM_EDIT_ORIENTATION; #ifndef REVERSE_ISM_PI_DATA /* Editing request for ISM position */ typedef struct { Loading @@ -435,6 +458,7 @@ typedef struct uint32_t piDataType; /* IVAS_PI_R_ISM_POSITION */ IVAS_COORDINATE position; /* Positional editing request for received ISM */ } IVAS_PIDATA_ISM_EDIT_POSITION; #endif /* Editing request for ISM direction */ typedef struct Loading Loading @@ -474,14 +498,22 @@ typedef union IVAS_PIDATA_ORIENTATION playbackOrientation; IVAS_PIDATA_ORIENTATION headOrientation; #ifdef REVERSE_ISM_PI_DATA IVAS_PIDATA_POSITION listnerPosition; #else IVAS_PIDATA_LISTENER_POSITION listnerPosition; #endif IVAS_PIDATA_DYNAMIC_SUPPRESSION dynSuppressionRequest; IVAS_PIDATA_AUDIO_FOCUS focusRequest; IVAS_PIDATA_REVERSE_PI_LATENCY piLatency; IVAS_PIDATA_ISM_EDIT_ID ismEditId; IVAS_PIDATA_ISM_EDIT_GAIN ismEditGain; IVAS_PIDATA_ISM_EDIT_ORIENTATION ismEditOrientation; #ifdef REVERSE_ISM_PI_DATA IVAS_PIDATA_POSITION ismEditPosition; #else IVAS_PIDATA_ISM_EDIT_POSITION ismEditPosition; #endif IVAS_PIDATA_ISM_EDIT_DIRECTION ismEditDirection; #endif /* RTP_S4_251135_CR26253_0016_REV1 */ IVAS_PIDATA_NO_DATA noPiData; Loading Loading
lib_com/options.h +1 −0 Original line number Diff line number Diff line Loading @@ -164,6 +164,7 @@ #define IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT /* RTPDUMP acoustic environment */ #define FIXED_RTP_SEQUENCE_NUM /* Remove random sequence number initialization */ #define ISM_PI_DATA /* Add reading and packing/unpacking of ISM PI data */ #define REVERSE_ISM_PI_DATA /* Add reading and packing/unpacking of reverse ISM PI data */ /* ################### Start BE switches ################################# */ /* only BE switches wrt selection floating point code */ Loading
lib_util/ivas_rtp_file.c +39 −0 Original line number Diff line number Diff line Loading @@ -199,7 +199,9 @@ void IVAS_RTP_LogPiData( #ifdef RTP_S4_251135_CR26253_0016_REV1 case IVAS_PI_PLAYBACK_DEVICE_ORIENTATION: case IVAS_PI_HEAD_ORIENTATION: #ifndef REVERSE_ISM_PI_DATA case IVAS_PI_R_ISM_ORIENTATION: #endif #endif { fprintf( f_piDataOut, "{\n\t\t\t\"w\": %f,\n\t\t\t\"x\": %f,\n\t\t\t\"y\": %f,\n\t\t\t\"z\": %f \n\t\t}", Loading @@ -225,7 +227,9 @@ void IVAS_RTP_LogPiData( break; #ifdef RTP_S4_251135_CR26253_0016_REV1 case IVAS_PI_LISTENER_POSITION: #ifndef REVERSE_ISM_PI_DATA case IVAS_PI_R_ISM_POSITION: #endif { fprintf( f_piDataOut, "{\n\t\t\t\"x\": %f,\n\t\t\t\"y\": %f,\n\t\t\t\"z\": %f \n\t\t}", cur->data.listnerPosition.position.x, cur->data.listnerPosition.position.y, cur->data.listnerPosition.position.z ); Loading Loading @@ -443,8 +447,43 @@ void IVAS_RTP_LogPiData( #endif case IVAS_PI_PI_LATENCY: case IVAS_PI_R_ISM_ID: #ifdef REVERSE_ISM_PI_DATA { fprintf( f_piDataOut, "{\n" ); fprintf( f_piDataOut, "\t\t\t\"id\": %d", cur->data.ismEditId.id ); fprintf( f_piDataOut, "\n\t\t}" ); } break; #endif case IVAS_PI_R_ISM_GAIN: #ifdef REVERSE_ISM_PI_DATA { fprintf( f_piDataOut, "{\n" ); fprintf( f_piDataOut, "\t\t\t\"gain\": %d", cur->data.ismEditGain.dB ); fprintf( f_piDataOut, "\n\t\t}" ); } break; case IVAS_PI_R_ISM_ORIENTATION: { fprintf( f_piDataOut, "{\n\t\t\t\"w\": %f,\n\t\t\t\"x\": %f,\n\t\t\t\"y\": %f,\n\t\t\t\"z\": %f \n\t\t}", cur->data.ismEditOrientation.orientation.w, cur->data.ismEditOrientation.orientation.x, cur->data.ismEditOrientation.orientation.y, cur->data.ismEditOrientation.orientation.z ); } break; case IVAS_PI_R_ISM_POSITION: { fprintf( f_piDataOut, "{\n\t\t\t\"x\": %f,\n\t\t\t\"y\": %f,\n\t\t\t\"z\": %f \n\t\t}", cur->data.ismEditPosition.position.x, cur->data.ismEditPosition.position.y, cur->data.ismEditPosition.position.z ); } break; #endif case IVAS_PI_R_ISM_DIRECTION: #ifdef REVERSE_ISM_PI_DATA { fprintf( f_piDataOut, "{\n\t\t\t\"azi\": %f,\n\t\t\t\"elev\": %f \n\t\t}", cur->data.ismEditDirection.azimuth, cur->data.ismEditDirection.elevation ); } break; #endif #endif /* RTP_S4_251135_CR26253_0016_REV1 */ case IVAS_PI_NO_DATA: { Loading
lib_util/ivas_rtp_internal.h +3 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,9 @@ enum MASK_BITS MASK_6BIT = 0x3F, MASK_7BIT = 0x7F, MASK_8BIT = 0xFF, #ifdef REVERSE_ISM_PI_DATA MASK_9BIT = 0x1FF, #endif }; Loading
lib_util/ivas_rtp_pi_data.c +273 −9 Original line number Diff line number Diff line Loading @@ -32,6 +32,9 @@ #include "ivas_error_utils.h" #include "ivas_rtp_internal.h" #ifdef REVERSE_ISM_PI_DATA #include <math.h> #endif #ifdef ISM_PI_DATA #include <stdlib.h> Loading Loading @@ -510,6 +513,56 @@ static ivas_error unpackDynamicSuppression( const uint8_t *buffer, uint32_t numD return IVAS_ERR_OK; } #ifdef REVERSE_ISM_PI_DATA static ivas_error packPosition( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) { uint32_t nBytes = 0; const IVAS_PIDATA_POSITION *position = (const IVAS_PIDATA_POSITION *) piData; *nBytesWritten = 0; if ( piData->size != sizeof( IVAS_PIDATA_POSITION ) ) { return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect size in position PI data" ); } if ( piData->piDataType != IVAS_PI_LISTENER_POSITION && piData->piDataType != IVAS_PI_R_ISM_POSITION ) { return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect PI ID in position PI data" ); } /* Position data is 6 bytes, header is 2 bytes */ if ( maxDataBytes < 6 + 2 ) { return IVAS_ERROR( IVAS_ERR_RTP_INSUFFICIENT_OUTPUT_SIZE, "Insufficient space to pack position PI data" ); } buffer[nBytes++] = ( position->piDataType & MASK_5BIT ); /* PF/PM populated during final packing */ buffer[nBytes++] = 6; nBytes = writeInt16( buffer, nBytes, ivasPayload_convertToQ15( position->position.x / MAX_PI_POSITION_METERS ) ); nBytes = writeInt16( buffer, nBytes, ivasPayload_convertToQ15( position->position.y / MAX_PI_POSITION_METERS ) ); nBytes = writeInt16( buffer, nBytes, ivasPayload_convertToQ15( position->position.z / MAX_PI_POSITION_METERS ) ); *nBytesWritten = nBytes; return IVAS_ERR_OK; } static ivas_error unpackPosition( const uint8_t *buffer, uint32_t numDataBytes, IVAS_PIDATA_GENERIC *piData ) { IVAS_PIDATA_POSITION *position = (IVAS_PIDATA_POSITION *) piData; /* Position data is 6 bytes */ if ( numDataBytes != 6 ) { return IVAS_ERROR( IVAS_ERR_RTP_UNPACK_PI_DATA, "Incorrect size to unpack position PI data" ); } position->size = sizeof( IVAS_PIDATA_POSITION ); position->position.x = FLOAT_FROM_Q15( readInt16( &buffer[0] ) ) * MAX_PI_POSITION_METERS; position->position.y = FLOAT_FROM_Q15( readInt16( &buffer[2] ) ) * MAX_PI_POSITION_METERS; position->position.z = FLOAT_FROM_Q15( readInt16( &buffer[4] ) ) * MAX_PI_POSITION_METERS; return IVAS_ERR_OK; } #else static ivas_error packListenerPosition( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) { uint32_t nBytes = 0; Loading Loading @@ -559,6 +612,7 @@ static ivas_error unpackListenerPosition( const uint8_t *buffer, uint32_t numDat listener->position.z = FLOAT_FROM_Q15( readInt16( &buffer[4] ) ) * MAX_PI_POSITION_METERS; return IVAS_ERR_OK; } #endif #ifdef ISM_PI_DATA static ivas_error packISMPosition( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) Loading Loading @@ -1144,6 +1198,188 @@ static ivas_error unpackISMDirectivity( const uint8_t *buffer, uint32_t numDataB } #endif #ifdef REVERSE_ISM_PI_DATA static ivas_error packReverseISMID( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) { uint32_t nBytes = 0; const IVAS_PIDATA_ISM_EDIT_ID *r_ism_id = (const IVAS_PIDATA_ISM_EDIT_ID *) piData; *nBytesWritten = 0; if ( piData->size > sizeof( IVAS_PIDATA_ISM_EDIT_ID ) ) { return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect size in R_ISM_ID PI data" ); } if ( piData->piDataType != IVAS_PI_R_ISM_ID ) { return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect PI ID in R_ISM_ID PI data" ); } /* R_ISM_ID data is 1 byte, header is 2 bytes */ if ( maxDataBytes < 1 + 2 ) { return IVAS_ERROR( IVAS_ERR_RTP_INSUFFICIENT_OUTPUT_SIZE, "Insufficient space to pack R_ISM_NUM PI data" ); } buffer[nBytes++] = ( r_ism_id->piDataType & MASK_5BIT ); /* PF/PM populated during final packing */ buffer[nBytes++] = ( r_ism_id->id & MASK_8BIT ); *nBytesWritten = nBytes; return IVAS_ERR_OK; } static ivas_error unpackReverseISMID( const uint8_t *buffer, uint32_t numDataBytes, IVAS_PIDATA_GENERIC *piData ) { IVAS_PIDATA_ISM_EDIT_ID *r_ism_id = (IVAS_PIDATA_ISM_EDIT_ID *) piData; /* ISM_ID data is 1 byte*/ if ( numDataBytes > 1 ) { return IVAS_ERROR( IVAS_ERR_RTP_UNPACK_PI_DATA, "Incorrect size to unpack R_ISM_ID PI data" ); } r_ism_id->size = sizeof( IVAS_PIDATA_ISM_EDIT_ID ); r_ism_id->piDataType = IVAS_PI_R_ISM_ID; r_ism_id->id = *buffer; return IVAS_ERR_OK; } static ivas_error packReverseISMGain( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) { uint32_t nBytes = 0, idx; int16_t gain; const IVAS_PIDATA_ISM_EDIT_GAIN *r_ism_gain = (const IVAS_PIDATA_ISM_EDIT_GAIN *) piData; *nBytesWritten = 0; if ( piData->size > sizeof( IVAS_PIDATA_ISM_EDIT_GAIN ) ) { return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect size in R_ISM_GAIN PI data" ); } if ( piData->piDataType != IVAS_PI_R_ISM_GAIN ) { return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect PI ID in R_ISM_GAIN PI data" ); } /* R_ISM_GAIN data is 1 byte, header is 2 bytes */ if ( maxDataBytes < 1 + 2 ) { return IVAS_ERROR( IVAS_ERR_RTP_INSUFFICIENT_OUTPUT_SIZE, "Insufficient space to pack R_ISM_GAIN PI data" ); } buffer[nBytes++] = ( r_ism_gain->piDataType & MASK_5BIT ); /* PF/PM populated during final packing */ gain = (int16_t) r_ism_gain->dB; idx = min( -gain, 97 ); if ( gain > 0 ) { idx += 97; } buffer[nBytes++] = ( idx & MASK_7BIT ) << 1; *nBytesWritten = nBytes; return IVAS_ERR_OK; } static ivas_error unpackReverseISMGain( const uint8_t *buffer, uint32_t numDataBytes, IVAS_PIDATA_GENERIC *piData ) { uint32_t idx; IVAS_PIDATA_ISM_EDIT_GAIN *r_ism_gain = (IVAS_PIDATA_ISM_EDIT_GAIN *) piData; /* R_ISM_GAIN data is 1 byte */ if ( numDataBytes > 1 ) { return IVAS_ERROR( IVAS_ERR_RTP_UNPACK_PI_DATA, "Incorrect size to unpack R_ISM_GAIN PI data" ); } r_ism_gain->size = sizeof( IVAS_PIDATA_ISM_EDIT_GAIN ); r_ism_gain->piDataType = IVAS_PI_R_ISM_GAIN; /* Unpack gain */ idx = ( *buffer ) >> 1; /* negative gains*/ if ( idx < 97 ) { r_ism_gain->dB = -(int8_t) ( idx ); } /* Set to min for muting, to be interpreted as -Inf */ else if ( idx == 97 ) { r_ism_gain->dB = -128; } /* postive gains */ else if ( idx < 101 ) { r_ism_gain->dB = (int8_t) idx - 97; } else { return IVAS_ERROR( IVAS_ERR_RTP_UNPACK_PI_DATA, "Incorrect index for R_ISM_GAIN PI data" ); } return IVAS_ERR_OK; } static ivas_error packReverseISMDirection( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) { uint32_t nBytes = 0; const IVAS_PIDATA_ISM_EDIT_DIRECTION *r_ism_direction = (const IVAS_PIDATA_ISM_EDIT_DIRECTION *) piData; uint16_t word; *nBytesWritten = 0; if ( piData->size > sizeof( IVAS_PIDATA_ISM_EDIT_DIRECTION ) ) { return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect size in R_ISM_DIRECTION PI data" ); } if ( piData->piDataType != IVAS_PI_R_ISM_DIRECTION ) { return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect PI ID in ISM_DIRECTION PI data" ); } /* R_ISM_DIRECTION data is 2 bytes, header is 2 bytes */ if ( maxDataBytes > 2 + 2 ) { return IVAS_ERROR( IVAS_ERR_RTP_INSUFFICIENT_OUTPUT_SIZE, "Insufficient space to pack R_ISM_DIRECTION PI data" ); } buffer[nBytes++] = ( r_ism_direction->piDataType & MASK_5BIT ); /* PF/PM populated during final packing */ word = (uint16_t) ( min( (uint16_t) ceilf( r_ism_direction->azimuth * REVERSE_ISM_DIRECTION_AZIMUTH_STEP_INV ) + 256, 511 ) << 7 ); word |= (uint16_t) ( min( (uint16_t) ceilf( r_ism_direction->elevation * REVERSE_ISM_DIRECTION_ELEVATION_STEP_INV ) + 64, 127 ) << 6 ); buffer[nBytes++] = ( word >> 8 ) & MASK_8BIT; buffer[nBytes++] = word & MASK_8BIT; *nBytesWritten = nBytes; return IVAS_ERR_OK; } static ivas_error unpackReverseISMDirection( const uint8_t *buffer, uint32_t numDataBytes, IVAS_PIDATA_GENERIC *piData ) { uint16_t word; IVAS_PIDATA_ISM_EDIT_DIRECTION *r_ism_direction = (IVAS_PIDATA_ISM_EDIT_DIRECTION *) piData; /* R_ISM_DIRECTION data is 2 bytes */ if ( numDataBytes > 2 ) { return IVAS_ERROR( IVAS_ERR_RTP_UNPACK_PI_DATA, "Incorrect size to unpack R_ISM_DIRECTION PI data" ); } r_ism_direction->size = sizeof( IVAS_PIDATA_ISM_EDIT_DIRECTION ); r_ism_direction->piDataType = IVAS_PI_R_ISM_DIRECTION; word = ( buffer[0] ) << 8; word |= ( buffer[1] ); r_ism_direction->azimuth = (float) ( ( ( word >> 7 ) & MASK_9BIT ) + 1 ) * REVERSE_ISM_DIRECTION_AZIMUTH_STEP - 180.0f; r_ism_direction->elevation = (float) ( word & MASK_7BIT ) * REVERSE_ISM_DIRECTION_ELEVATION_STEP - 90.0f; return IVAS_ERR_OK; } #endif #endif /* RTP_S4_251135_CR26253_0016_REV1 */ Loading Loading @@ -1189,7 +1425,11 @@ static const PACK_PI_FN packPiDataFuntions[IVAS_PI_MAX_ID] = { #ifdef RTP_S4_251135_CR26253_0016_REV1 packOrientation, /* PLAYBACK_DEVICE_ORIENTATION */ packOrientation, /* HEAD_ORIENTATION */ #ifdef REVERSE_ISM_PI_DATA packPosition, /* LISTENER_POSITION */ #else packListenerPosition, /* LISTENER_POSITION */ #endif packDynamicSuppression, /* DYNAMIC_AUDIO_SUPPRESSION */ packAudioFocusCommon, /* AUDIO_FOCUS_REQUEST */ #else Loading @@ -1200,15 +1440,25 @@ static const PACK_PI_FN packPiDataFuntions[IVAS_PI_MAX_ID] = { packUnsupportedData, /* AUDIO_FOCUS_DIRECTION */ #endif packUnsupportedData, /* PI_LATENCY */ #ifdef REVERSE_ISM_PI_DATA packReverseISMID, /* R_ISM_ID */ packReverseISMGain, /* R_ISM_GAIN */ #else packUnsupportedData, /* R_ISM_ID */ packUnsupportedData, /* R_ISM_GAIN */ #endif #ifdef RTP_S4_251135_CR26253_0016_REV1 packOrientation, /* R_ISM_ORIENTATION */ #else packUnsupportedData, /* R_ISM_ORIENTATION */ #endif #ifdef REVERSE_ISM_PI_DATA packPosition, /* R_ISM_POSITION */ packReverseISMDirection, /* R_ISM_DIRECTION */ #else packUnsupportedData, /* R_ISM_POSITION */ packUnsupportedData, /* R_ISM_DIRECTION */ #endif packUnsupportedData, /* RESERVED27 */ packUnsupportedData, /* RESERVED28 */ packUnsupportedData, /* RESERVED29 */ Loading Loading @@ -1258,7 +1508,11 @@ static const UNPACK_PI_FN unpackPiDataFuntions[IVAS_PI_MAX_ID] = { #ifdef RTP_S4_251135_CR26253_0016_REV1 unpackOrientation, /* PLAYBACK_DEVICE_ORIENTATION */ unpackOrientation, /* HEAD_ORIENTATION */ #ifdef REVERSE_ISM_PI_DATA unpackPosition, /* LISTENER_POSITION */ #else unpackListenerPosition, /* LISTENER_POSITION */ #endif unpackDynamicSuppression, /* DYNAMIC_AUDIO_SUPPRESSION */ unpackAudioFocusCommon, /* AUDIO_FOCUS_REQUEST */ #else Loading @@ -1269,15 +1523,25 @@ static const UNPACK_PI_FN unpackPiDataFuntions[IVAS_PI_MAX_ID] = { unpackUnsupportedData, /* AUDIO_FOCUS_DIRECTION */ #endif unpackUnsupportedData, /* PI_LATENCY */ #ifdef REVERSE_ISM_PI_DATA unpackReverseISMID, /* R_ISM_ID */ unpackReverseISMGain, /* R_ISM_GAIN */ #else unpackUnsupportedData, /* R_ISM_ID */ unpackUnsupportedData, /* R_ISM_GAIN */ #endif #ifdef RTP_S4_251135_CR26253_0016_REV1 unpackOrientation, /* R_ISM_ORIENTATION */ #else unpackUnsupportedData, /* R_ISM_ORIENTATION */ #endif #ifdef REVERSE_ISM_PI_DATA unpackPosition, /* R_ISM_POSITION */ unpackReverseISMDirection, /* R_ISM_DIRECTION */ #else unpackUnsupportedData, /* R_ISM_POSITION */ unpackUnsupportedData, /* R_ISM_DIRECTION */ #endif unpackUnsupportedData, /* RESERVED27 */ unpackUnsupportedData, /* RESERVED28 */ unpackUnsupportedData, /* RESERVED29 */ Loading
lib_util/ivas_rtp_pi_data.h +32 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,13 @@ #define IVAS_PI_MAX_DATA_SIZE ( 32 + 2 ) /* max packed PI data bytes + pi header bytes */ #ifdef REVERSE_ISM_PI_DATA #define REVERSE_ISM_DIRECTION_AZIMUTH_STEP 0.703125f #define REVERSE_ISM_DIRECTION_ELEVATION_STEP 1.417322835f #define REVERSE_ISM_DIRECTION_AZIMUTH_STEP_INV 1.4222222222f #define REVERSE_ISM_DIRECTION_ELEVATION_STEP_INV 0.7055555556f #endif /* IVAS PI Data Types */ typedef enum { Loading Loading @@ -347,6 +354,20 @@ typedef struct IVAS_FLVL flvl; /* audio focus level */ } IVAS_PIDATA_AUDIO_FOCUS; #ifdef REVERSE_ISM_PI_DATA /* Position data corresponding to any of the following pi data types :- * - IVAS_PI_LISTENER_POSITION * - IVAS_PI_R_ISM_POSITION * * piDataType is used to identify the correct pi data type contained here */ typedef struct { size_t size; /* sizeof(IVAS_PIDATA_POSITION) */ uint32_t piDataType; /* one of supported position data types */ IVAS_COORDINATE position; /* Position data */ } IVAS_PIDATA_POSITION; #else /* Listener position */ typedef struct { Loading @@ -354,6 +375,7 @@ typedef struct uint32_t piDataType; /* IVAS_PI_LISTENER_POSITION */ IVAS_COORDINATE position; /* Position of audio objects in ISM(s) */ } IVAS_PIDATA_LISTENER_POSITION; #endif /* Dynamic Audio Suppression describes receiver’s preference with respect to the * type of audio content that should be enhanced and the amount of suppression to Loading Loading @@ -428,6 +450,7 @@ typedef struct IVAS_QUATERNION orientation; /* orientation editing request for received ISM */ } IVAS_PIDATA_ISM_EDIT_ORIENTATION; #ifndef REVERSE_ISM_PI_DATA /* Editing request for ISM position */ typedef struct { Loading @@ -435,6 +458,7 @@ typedef struct uint32_t piDataType; /* IVAS_PI_R_ISM_POSITION */ IVAS_COORDINATE position; /* Positional editing request for received ISM */ } IVAS_PIDATA_ISM_EDIT_POSITION; #endif /* Editing request for ISM direction */ typedef struct Loading Loading @@ -474,14 +498,22 @@ typedef union IVAS_PIDATA_ORIENTATION playbackOrientation; IVAS_PIDATA_ORIENTATION headOrientation; #ifdef REVERSE_ISM_PI_DATA IVAS_PIDATA_POSITION listnerPosition; #else IVAS_PIDATA_LISTENER_POSITION listnerPosition; #endif IVAS_PIDATA_DYNAMIC_SUPPRESSION dynSuppressionRequest; IVAS_PIDATA_AUDIO_FOCUS focusRequest; IVAS_PIDATA_REVERSE_PI_LATENCY piLatency; IVAS_PIDATA_ISM_EDIT_ID ismEditId; IVAS_PIDATA_ISM_EDIT_GAIN ismEditGain; IVAS_PIDATA_ISM_EDIT_ORIENTATION ismEditOrientation; #ifdef REVERSE_ISM_PI_DATA IVAS_PIDATA_POSITION ismEditPosition; #else IVAS_PIDATA_ISM_EDIT_POSITION ismEditPosition; #endif IVAS_PIDATA_ISM_EDIT_DIRECTION ismEditDirection; #endif /* RTP_S4_251135_CR26253_0016_REV1 */ IVAS_PIDATA_NO_DATA noPiData; Loading