From 3b179d2598b94944bbc491bc4a0a26adedd7ec23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20Toftg=C3=A5rd?= Date: Thu, 20 Nov 2025 06:04:09 +0100 Subject: [PATCH 1/2] Port of rtp updates --- lib_com/options.h | 2 + lib_util/ivas_rtp_file.c | 64 ++++- lib_util/ivas_rtp_internal.h | 11 + lib_util/ivas_rtp_payload.c | 16 ++ lib_util/ivas_rtp_pi_data.c | 523 +++++++++++++++++++++++++++++++++-- lib_util/ivas_rtp_pi_data.h | 47 ++-- 6 files changed, 621 insertions(+), 42 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 744952c84..31b9785a4 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -167,6 +167,8 @@ #define PI_LATENCY /* Support for PI latency */ #define DECODER_FORMAT_SWITCHING /* Re-initialize the decoder when the format/subformat of the incoming stream is changed */ #define FIX_SPLIT_RENDERING_ON_DECODER_RESTART /* Re-configure split rendering on decoder restart */ +#define RTP_UPDATES_SA4_134 /* Updates to RTP during SA4 134 */ +#define COMPACT_ORIENTATION_PI_DATA /* #################### End BASOP porting switches ############################ */ diff --git a/lib_util/ivas_rtp_file.c b/lib_util/ivas_rtp_file.c index 6ded4e78e..32bd7e815 100644 --- a/lib_util/ivas_rtp_file.c +++ b/lib_util/ivas_rtp_file.c @@ -145,11 +145,10 @@ static ivas_error IvasRtpFile_Read( static const char *const PiDataNames[IVAS_PI_MAX_ID] = { "SCENE_ORIENTATION", "DEVICE_ORIENTATION_COMPENSATED", "DEVICE_ORIENTATION_UNCOMPENSATED", "ACOUSTIC_ENVIRONMENT", "AUDIO_DESCRIPTION", "ISM_NUM", "ISM_ID", "ISM_GAIN", "ISM_ORIENTATION", - "ISM_POSITION", "ISM_DISTANCE_ATTENUATION", "ISM_DIRECTIVITY", "DIEGETIC_TYPE", "DYNAMIC_AUDIO_SUPPRESSION_INDICATION", - "AUDIO_FOCUS_INDICATION", "RESERVED15", "PLAYBACK_DEVICE_ORIENTATION", "HEAD_ORIENTATION", "LISTENER_POSITION", + "ISM_POSITION", "ISM_POSITION_COMPACT", "ISM_DISTANCE_ATTENUATION", "ISM_DIRECTIVITY", "DIEGETIC_TYPE", "DYNAMIC_AUDIO_SUPPRESSION_INDICATION", + "AUDIO_FOCUS_INDICATION", "PLAYBACK_DEVICE_ORIENTATION", "HEAD_ORIENTATION", "LISTENER_POSITION", "DYNAMIC_AUDIO_SUPPRESSION_REQUEST", "AUDIO_FOCUS_REQUEST", "PI_LATENCY", "R_ISM_ID", "R_ISM_GAIN", - "R_ISM_ORIENTATION", "R_ISM_POSITION", "R_ISM_DIRECTION", "RESERVED27", "RESERVED28", "RESERVED29", - "RESERVED30", "NO_DATA" + "R_ISM_ORIENTATION", "R_ISM_POSITION", "R_ISM_POSITION_COMPACT", "R_ISM_DIRECTION", "RESERVED27", "RESERVED28", "RESERVED29", "NO_DATA" }; void IVAS_RTP_LogPiData( @@ -345,11 +344,17 @@ void IVAS_RTP_LogPiData( fprintf( f_piDataOut, "\n\t\t}" ); } break; +#ifdef RTP_S4_251135_CR26253_0016_REV1 + case IVAS_PI_RESERVED27: + case IVAS_PI_RESERVED28: + case IVAS_PI_RESERVED29: +#else case IVAS_PI_RESERVED15: case IVAS_PI_RESERVED27: case IVAS_PI_RESERVED28: case IVAS_PI_RESERVED29: case IVAS_PI_RESERVED30: +#endif { fprintf( f_piDataOut, "{}" ); } @@ -426,6 +431,22 @@ void IVAS_RTP_LogPiData( fprintf( f_piDataOut, "\n\t\t]" ); } break; +#ifdef RTP_UPDATES_SA4_134 + case IVAS_PI_ISM_POSITION_COMPACT: + { + fprintf( f_piDataOut, "[\n" ); + for ( n = 0; n < cur->data.ismPositionCompact.numObjects; n++ ) + { + if ( n != 0 ) + { + fprintf( f_piDataOut, ",\n" ); + } + fprintf( f_piDataOut, "\t\t\t{\n\t\t\t\t\"x\": %f,\n\t\t\t\t\"y\": %f,\n\t\t\t\t\"z\": %f \n\t\t\t}", cur->data.ismPositionCompact.position[n].x, cur->data.ismPositionCompact.position[n].y, cur->data.ismPositionCompact.position[n].z ); + } + fprintf( f_piDataOut, "\n\t\t]" ); + } + break; +#endif case IVAS_PI_ISM_DISTANCE_ATTENUATION: { fprintf( f_piDataOut, "[\n" ); @@ -507,6 +528,14 @@ void IVAS_RTP_LogPiData( cur->data.ismEditPosition.position.x, cur->data.ismEditPosition.position.y, cur->data.ismEditPosition.position.z ); } break; +#ifdef RTP_UPDATES_SA4_134 + case IVAS_PI_R_ISM_POSITION_COMPACT: + { + 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.ismEditPositionCompact.position.x, cur->data.ismEditPositionCompact.position.y, cur->data.ismEditPositionCompact.position.z ); + } + break; +#endif #endif case IVAS_PI_R_ISM_DIRECTION: #ifdef REVERSE_ISM_PI_DATA @@ -663,6 +692,20 @@ void IVAS_RTP_WriteExtPiData( } } break; +#ifdef RTP_UPDATES_SA4_134 + case IVAS_PI_ISM_POSITION_COMPACT: + { + for ( i = 0; i < numObj; ++i ) + { + if ( i != 0 ) + { + fprintf( f_piDataOut, "," ); + } + fprintf( f_piDataOut, "%f,%f,%f", cur->data.ismPositionCompact.position[i].x, cur->data.ismPositionCompact.position[i].y, cur->data.ismPositionCompact.position[i].z ); + } + } + break; +#endif case IVAS_PI_ISM_DISTANCE_ATTENUATION: { for ( i = 0; i < numObj; ++i ) @@ -794,16 +837,29 @@ void IVAS_RTP_WriteExtPiData( fprintf( f_piDataOut, "%f,%f,%f", cur->data.ismEditPosition.position.x, cur->data.ismEditPosition.position.y, cur->data.ismEditPosition.position.z ); } break; +#ifdef RTP_UPDATES_SA4_134 + case IVAS_PI_R_ISM_POSITION_COMPACT: + { + fprintf( f_piDataOut, "%f,%f,%f", cur->data.ismEditPositionCompact.position.x, cur->data.ismEditPositionCompact.position.y, cur->data.ismEditPositionCompact.position.z ); + } + break; +#endif case IVAS_PI_R_ISM_DIRECTION: { fprintf( f_piDataOut, "%f,%f", cur->data.ismEditDirection.azimuth, cur->data.ismEditDirection.elevation ); } break; +#ifdef RTP_UPDATES_SA4_134 + case IVAS_PI_RESERVED27: + case IVAS_PI_RESERVED28: + case IVAS_PI_RESERVED29: +#else case IVAS_PI_RESERVED15: case IVAS_PI_RESERVED27: case IVAS_PI_RESERVED28: case IVAS_PI_RESERVED29: case IVAS_PI_RESERVED30: +#endif break; #endif /* RTP_S4_251135_CR26253_0016_REV1 */ } diff --git a/lib_util/ivas_rtp_internal.h b/lib_util/ivas_rtp_internal.h index 8ee65bbe9..aa06e2b6c 100644 --- a/lib_util/ivas_rtp_internal.h +++ b/lib_util/ivas_rtp_internal.h @@ -51,6 +51,10 @@ enum MASK_BITS #ifdef REVERSE_ISM_PI_DATA MASK_9BIT = 0x1FF, #endif +#ifdef RTP_UPDATES_SA4_134 + MASK_10BIT = 0x3FF, + MASK_11BIT = 0x7FF, +#endif }; @@ -69,6 +73,13 @@ enum MASK_BITS #define MAX_PI_POSITION_METERS ( 327.68f ) #define FLOAT_FROM_Q15( q15Val ) ( (float) ( q15Val ) / 32768.0f ) +#ifdef RTP_UPDATES_SA4_134 +#define MAX_PI_COMPACT_POSITION_XY_METERS ( 10.24f ) +#define MAX_PI_COMPACT_POSITION_Z_METERS ( 5.12f ) +#define FLOAT_FROM_Q10( q10Val ) ( (float) ( q10Val ) / 1024.0f ) +#define FLOAT_FROM_Q9( q9Val ) ( (float) ( q9Val ) / 512.0f ) +#define FLOAT_FROM_Q7( q7Val ) ( (float) ( q7Val ) / 128.0f ) +#endif extern const float mapDSR[1u << NBITS_DSR]; extern const float mapRT60[1u << NBITS_RT60]; diff --git a/lib_util/ivas_rtp_payload.c b/lib_util/ivas_rtp_payload.c index 2f8d3aca9..b4a2983b7 100644 --- a/lib_util/ivas_rtp_payload.c +++ b/lib_util/ivas_rtp_payload.c @@ -1568,6 +1568,9 @@ static ivas_error parsePIData( IVAS_RTP_UNPACK_HANDLE hUnpack, uint32_t rtpTimes { bool PF = true; uint32_t nBytes = *numBytes; +#ifdef RTP_UPDATES_SA4_134 + bool isFirstPiSize = true; +#endif while ( PF ) { @@ -1585,6 +1588,18 @@ static ivas_error parsePIData( IVAS_RTP_UNPACK_HANDLE hUnpack, uint32_t rtpTimes PM = ( piHeader0 & ( ~MASK_5BIT ) ) & MASK_7BIT; /* PI Marker Bits */ piDataType = ( piHeader0 & MASK_5BIT ); +#ifdef RTP_UPDATES_SA4_134 + do + { + byte = payload->buffer[nBytes++]; + piSize += isFirstPiSize ? ( byte & MASK_5BIT ) : byte; + if ( nBytes >= payload->length ) + { + return IVAS_ERROR( IVAS_ERR_RTP_UNDERFLOW, "Underflow during reading piSize" ); + } + isFirstPiSize = false; + } while ( byte == 255 || piSize == 32 ); +#else do { byte = payload->buffer[nBytes++]; @@ -1594,6 +1609,7 @@ static ivas_error parsePIData( IVAS_RTP_UNPACK_HANDLE hUnpack, uint32_t rtpTimes return IVAS_ERROR( IVAS_ERR_RTP_UNDERFLOW, "Underflow during reading piSize" ); } } while ( byte == 255 ); +#endif if ( piDataType == IVAS_PI_NO_DATA ) { diff --git a/lib_util/ivas_rtp_pi_data.c b/lib_util/ivas_rtp_pi_data.c index 0a23a6d7b..bf4bfc828 100644 --- a/lib_util/ivas_rtp_pi_data.c +++ b/lib_util/ivas_rtp_pi_data.c @@ -83,6 +83,136 @@ static int16_t ivasPayload_convertToQ15( float value ) value = value < -32768.0f ? -32768.0f : value; return (int16_t) ( value ); } +#ifdef RTP_UPDATES_SA4_134 +/*-----------------------------------------------------------------------* + * ivasPayload_convertToQ10() + * + * Convert a float value into a Q10 encoded value. + *-----------------------------------------------------------------------*/ +static int16_t ivasPayload_convertToQ10( float value ) +{ + value = ( value * 1024.0f ); + value = value > +1024.0f ? +1024.0f : value; + value = value < -1024.0f ? -1024.0f : value; + return (int16_t) ( value ); +} + +/*-----------------------------------------------------------------------* + * ivasPayload_convertToQ9() + * + * Convert a float value into a Q9 encoded value. + *-----------------------------------------------------------------------*/ +static int16_t ivasPayload_convertToQ9( float value ) +{ + value = ( value * 512.0f ); + value = value > +512.0f ? +512.0f : value; + value = value < -512.0f ? -512.0f : value; + return (int16_t) ( value ); +} + +#ifdef COMPACT_ORIENTATION_PI_DATA +static uint32_t packQuaternion( IVAS_QUATERNION orientation, uint8_t *buffer ) +{ + uint32_t nBytes = 0; + float q[4], q_max; + uint16_t max_q_idx, n, k; + uint32_t lWord; + + q[0] = FLOAT_FROM_Q15( orientation.w_fx >> 16 ); + q[1] = FLOAT_FROM_Q15( orientation.x_fx >> 16 ); + q[2] = FLOAT_FROM_Q15( orientation.y_fx >> 16 ); + q[3] = FLOAT_FROM_Q15( orientation.z_fx >> 16 ); + + max_q_idx = 0; + q_max = (float) fabs( q[0] ); + for ( n = 1; n < 4; n++ ) + { + if ( (float) fabs( q[n] ) > q_max ) + { + q_max = (float) fabs( q[n] ); + max_q_idx = n; + } + } + + if ( q[max_q_idx] < 0 ) + { + for ( n = 0; n < 4; n++ ) + { + q[n] = -q[n]; + } + } + lWord = ( (uint32_t) max_q_idx ) << 30; + + k = 1; + for ( n = 0; n < 4; n++ ) + { + if ( n == max_q_idx ) + { + continue; + } + lWord |= ( ( (int16_t) ( ( q[n] + 1 / sqrt( 2.0f ) ) * 1023 / sqrt( 2.0f ) ) & MASK_10BIT ) << ( 30 - k * 10 ) ); + k++; + } + + buffer[nBytes++] = ( lWord >> 24 ) & MASK_8BIT; + buffer[nBytes++] = ( lWord >> 16 ) & MASK_8BIT; + buffer[nBytes++] = ( lWord >> 8 ) & MASK_8BIT; + buffer[nBytes++] = (lWord) &MASK_8BIT; + + return nBytes; +} + + +static ivas_error unpackQuaternion( const uint8_t *buffer, IVAS_QUATERNION *orientation ) +{ + uint32_t i, k, lWord; + uint16_t max_q_idx, tmp; + float q[4], qs; + + lWord = ( (uint32_t) buffer[0] ) << 24; + lWord |= ( (uint32_t) buffer[1] ) << 16; + lWord |= ( (uint32_t) buffer[2] ) << 8; + lWord |= (uint32_t) buffer[3]; + + max_q_idx = ( lWord >> 30 ) & MASK_2BIT; + k = 1; + qs = 0.0f; + for ( i = 0; i < 4; i++ ) + { + if ( i == max_q_idx ) + { + continue; + } + tmp = ( lWord >> ( 30 - k * 10 ) ) & MASK_10BIT; + q[i] = tmp / 1023.0f * sqrtf( 2.0f ) - 1 / sqrtf( 2.0f ); + qs += q[i] * q[i]; + k++; + } + q[max_q_idx] = sqrtf( 1 - qs ); + orientation->w_fx = ivasPayload_convertToQ15(q[0]); + orientation->x_fx = ivasPayload_convertToQ15(q[1]); + orientation->y_fx = ivasPayload_convertToQ15(q[2]); + orientation->z_fx = ivasPayload_convertToQ15(q[3]); + + return IVAS_ERR_OK; +} + +#else + +/*-----------------------------------------------------------------------* + * ivasPayload_convertToQ7() + * + * Convert a float value into a Q7 encoded value. + *-----------------------------------------------------------------------*/ +static int16_t ivasPayload_convertToQ7( float value ) +{ + value = ( value * 128.0f ); + value = value > +128.0f ? +128.0f : value; + value = value < -128.0f ? -128.0f : value; + return (int16_t) ( value ); +} +#endif +#endif static ivas_error packUnsupportedData( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) { @@ -157,18 +287,38 @@ static ivas_error packOrientation( const IVAS_PIDATA_GENERIC *piData, uint8_t *b return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect PI ID in Orientation PI data" ); } +#ifdef RTP_UPDATES_SA4_134 + /* Orientation data is 4 bytes, header is 2 bytes */ + if ( maxDataBytes < 4 + 2 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_INSUFFICIENT_OUTPUT_SIZE, "Insufficient space to pack Orientation PI data" ); + } +#else /* Orientation data is 8 bytes, header is 2 bytes */ if ( maxDataBytes < 8 + 2 ) { return IVAS_ERROR( IVAS_ERR_RTP_INSUFFICIENT_OUTPUT_SIZE, "Insufficient space to pack Orientation PI data" ); } +#endif buffer[nBytes++] = ( orientation->piDataType & MASK_5BIT ); /* PF/PM populated during final packing */ +#ifdef RTP_UPDATES_SA4_134 + buffer[nBytes++] = 4; +#ifdef COMPACT_ORIENTATION_PI_DATA + nBytes += packQuaternion( orientation->orientation, &buffer[nBytes] ); +#else + buffer[nBytes++] = (uint8_t) ivasPayload_convertToQ7( orientation->orientation.w ); + buffer[nBytes++] = (uint8_t) ivasPayload_convertToQ7( orientation->orientation.x ); + buffer[nBytes++] = (uint8_t) ivasPayload_convertToQ7( orientation->orientation.y ); + buffer[nBytes++] = (uint8_t) ivasPayload_convertToQ7( orientation->orientation.z ); +#endif +#else buffer[nBytes++] = 8; nBytes = writeInt16( buffer, nBytes, round_fx( orientation->orientation.w_fx ) ); nBytes = writeInt16( buffer, nBytes, round_fx( orientation->orientation.x_fx ) ); nBytes = writeInt16( buffer, nBytes, round_fx( orientation->orientation.y_fx ) ); nBytes = writeInt16( buffer, nBytes, round_fx( orientation->orientation.z_fx ) ); +#endif *nBytesWritten = nBytes; return IVAS_ERR_OK; @@ -191,13 +341,35 @@ static ivas_error packISMOrientation( const IVAS_PIDATA_GENERIC *piData, uint8_t { return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect PI ID in Orientation PI data" ); } +#ifdef RTP_UPDATES_SA4_134 + /* Orientation data is 4 bytes, header is 2 bytes */ + if ( maxDataBytes < 4 * IVAS_MAX_NUM_OBJECTS + 2 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_INSUFFICIENT_OUTPUT_SIZE, "Insufficient space to pack Orientation PI data" ); + } +#else /* Orientation data is 8 bytes, header is 2 bytes */ if ( maxDataBytes < 8 * IVAS_MAX_NUM_OBJECTS + 2 ) { return IVAS_ERROR( IVAS_ERR_RTP_INSUFFICIENT_OUTPUT_SIZE, "Insufficient space to pack Orientation PI data" ); } +#endif buffer[nBytes++] = ( orientation->piDataType & MASK_5BIT ); /* PF/PM populated during final packing */ +#ifdef RTP_UPDATES_SA4_134 + buffer[nBytes++] = (uint8_t) orientation->numObjects * 4; + for ( n = 0; n < orientation->numObjects; n++ ) + { +#ifdef COMPACT_ORIENTATION_PI_DATA + nBytes += packQuaternion( orientation->orientation[n], &buffer[nBytes] ); +#else + buffer[nBytes++] = (uint8_t) ivasPayload_convertToQ7( orientation->orientation[n].w ); + buffer[nBytes++] = (uint8_t) ivasPayload_convertToQ7( orientation->orientation[n].x ); + buffer[nBytes++] = (uint8_t) ivasPayload_convertToQ7( orientation->orientation[n].y ); + buffer[nBytes++] = (uint8_t) ivasPayload_convertToQ7( orientation->orientation[n].z ); +#endif + } +#else buffer[nBytes++] = (uint8_t) orientation->numObjects * 8; for ( n = 0; n < orientation->numObjects; n++ ) { @@ -206,6 +378,7 @@ static ivas_error packISMOrientation( const IVAS_PIDATA_GENERIC *piData, uint8_t nBytes = writeInt16( buffer, nBytes, round_fx( orientation->orientation[n].y_fx ) ); nBytes = writeInt16( buffer, nBytes, round_fx( orientation->orientation[n].z_fx ) ); } +#endif *nBytesWritten = nBytes; return IVAS_ERR_OK; } @@ -215,6 +388,23 @@ static ivas_error unpackOrientation( const uint8_t *buffer, uint32_t numDataByte { IVAS_PIDATA_ORIENTATION *orientation = (IVAS_PIDATA_ORIENTATION *) piData; +#ifdef RTP_UPDATES_SA4_134 + /* Orientation data is 4 bytes */ + if ( numDataBytes != 4 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_UNPACK_PI_DATA, "Incorrect size to unpack Orientation PI data" ); + } + + piData->size = sizeof( IVAS_PIDATA_ORIENTATION ); +#ifdef COMPACT_ORIENTATION_PI_DATA + unpackQuaternion( buffer, &( orientation->orientation ) ); +#else + orientation->orientation.w = FLOAT_FROM_Q7( (int8_t) buffer[0] ); + orientation->orientation.x = FLOAT_FROM_Q7( (int8_t) buffer[1] ); + orientation->orientation.y = FLOAT_FROM_Q7( (int8_t) buffer[2] ); + orientation->orientation.z = FLOAT_FROM_Q7( (int8_t) buffer[3] ); +#endif +#else /* Orientation data is 8 bytes */ if ( numDataBytes != 8 ) { @@ -226,7 +416,7 @@ static ivas_error unpackOrientation( const uint8_t *buffer, uint32_t numDataByte orientation->orientation.x_fx = L_deposit_l( readInt16( &buffer[2] ) ); orientation->orientation.y_fx = L_deposit_l( readInt16( &buffer[4] ) ); orientation->orientation.z_fx = L_deposit_l( readInt16( &buffer[6] ) ); - +#endif return IVAS_ERR_OK; } @@ -235,6 +425,29 @@ static ivas_error unpackISMOrientation( const uint8_t *buffer, uint32_t numDataB { IVAS_PIDATA_ISM_ORIENTATION *ism_orientation = (IVAS_PIDATA_ISM_ORIENTATION *) piData; +#ifdef RTP_UPDATES_SA4_134 + /* Orientation data is 4 bytes */ + uint16_t n; + if ( numDataBytes % 4 != 0 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_UNPACK_PI_DATA, "Incorrect size to unpack Orientation PI data" ); + } + + ism_orientation->size = sizeof( IVAS_PIDATA_ISM_ORIENTATION ); + ism_orientation->numObjects = (uint16_t) numDataBytes / 4; + + for ( n = 0; n < ism_orientation->numObjects; n++ ) + { +#ifdef COMPACT_ORIENTATION_PI_DATA + unpackQuaternion( &buffer[4 * n], &( ism_orientation->orientation[n] ) ); +#else + ism_orientation->orientation[n].w = FLOAT_FROM_Q7( (int8_t) buffer[4 * n] ); + ism_orientation->orientation[n].x = FLOAT_FROM_Q7( (int8_t) buffer[4 * n + 1] ); + ism_orientation->orientation[n].y = FLOAT_FROM_Q7( (int8_t) buffer[4 * n + 2] ); + ism_orientation->orientation[n].z = FLOAT_FROM_Q7( (int8_t) buffer[4 * n + 3] ); +#endif + } +#else /* Orientation data is 8 bytes */ uint16_t n; if ( numDataBytes % 8 != 0 ) @@ -252,6 +465,7 @@ static ivas_error unpackISMOrientation( const uint8_t *buffer, uint32_t numDataB ism_orientation->orientation[n].y_fx = L_deposit_l( readInt16( &buffer[8 * n + 4] ) ); ism_orientation->orientation[n].z_fx = L_deposit_l( readInt16( &buffer[8 * n + 6] ) ); } +#endif for ( ; n < IVAS_MAX_NUM_OBJECTS; n++ ) { ism_orientation->orientation[n].w_fx = 0; @@ -639,6 +853,69 @@ static ivas_error unpackListenerPosition( const uint8_t *buffer, uint32_t numDat return IVAS_ERR_OK; } #endif +#ifdef RTP_UPDATES_SA4_134 +static ivas_error packPositionCompact( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) +{ + uint32_t nBytes = 0; + uint16_t posX, posY, posZ = 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 compact position PI data" ); + } + + if ( piData->piDataType != IVAS_PI_R_ISM_POSITION ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect PI ID in compact position PI data" ); + } + + /* Compact position data is 4 bytes, header is 2 bytes */ + if ( maxDataBytes < 4 + 2 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_INSUFFICIENT_OUTPUT_SIZE, "Insufficient space to pack compact position PI data" ); + } + + buffer[nBytes++] = ( position->piDataType & MASK_5BIT ); /* PF/PM populated during final packing */ + buffer[nBytes++] = 4; + posX = (uint16_t) ivasPayload_convertToQ10( position->position.x / MAX_PI_COMPACT_POSITION_XY_METERS ); + posY = (uint16_t) ivasPayload_convertToQ10( position->position.y / MAX_PI_COMPACT_POSITION_XY_METERS ); + posZ = (uint16_t) ivasPayload_convertToQ9( position->position.z / MAX_PI_COMPACT_POSITION_Z_METERS ); + buffer[nBytes++] = (uint8_t) ( posX >> 8 ); + buffer[nBytes++] = (uint8_t) ( ( ( posX & MASK_3BIT ) << 5 ) | posY >> 6 ); + buffer[nBytes++] = (uint8_t) ( ( ( posY & MASK_6BIT ) << 2 ) | posZ >> 8 ); + buffer[nBytes++] = (uint8_t) ( posZ >> 2 ); + + *nBytesWritten = nBytes; + + return IVAS_ERR_OK; +} + +static ivas_error unpackPositionCompact( const uint8_t *buffer, uint32_t numDataBytes, IVAS_PIDATA_GENERIC *piData ) +{ + IVAS_PIDATA_POSITION *position = (IVAS_PIDATA_POSITION *) piData; + int32_t compactRead = 0; + + /* Compact position data is 4 bytes */ + if ( numDataBytes != 4 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_UNPACK_PI_DATA, "Incorrect size to unpack compact position PI data" ); + } + + position->size = sizeof( IVAS_PIDATA_POSITION ); + + compactRead = ( (int32_t) buffer[0] << 24 ) | ( (int32_t) buffer[1] << 16 ) | ( (int32_t) buffer[2] << 8 ) | ( (int32_t) buffer[3] ); + position->position.x = FLOAT_FROM_Q10( (int16_t) ( compactRead >> 21 ) ) * MAX_PI_COMPACT_POSITION_XY_METERS; /* Shift preserves sign bit */ + compactRead = compactRead << 11; /* Discard read bits */ + position->position.y = FLOAT_FROM_Q10( (int16_t) ( compactRead >> 21 ) ) * MAX_PI_COMPACT_POSITION_XY_METERS; /* Shift preserves sign bit */ + compactRead = compactRead << 11; /* Discard read bits */ + position->position.z = FLOAT_FROM_Q9( (int16_t) ( compactRead >> 22 ) ) * MAX_PI_COMPACT_POSITION_Z_METERS; /* Shift preserves sign bit */ + + 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 ) @@ -700,7 +977,75 @@ static ivas_error unpackISMPosition( const uint8_t *buffer, uint32_t numDataByte return IVAS_ERR_OK; } #endif +#ifdef RTP_UPDATES_SA4_134 +static ivas_error packISMPositionCompact( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) +{ + uint32_t nBytes = 0, n; + uint16_t posX, posY, posZ = 0; + const IVAS_PIDATA_ISM_POSITION *ism_position = (const IVAS_PIDATA_ISM_POSITION *) piData; + *nBytesWritten = 0; + + if ( piData->size != sizeof( IVAS_PIDATA_ISM_POSITION ) ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect size in ISM POSITION COMPACT PI data" ); + } + + if ( piData->piDataType != IVAS_PI_ISM_POSITION_COMPACT ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect PI ID in ISM POSITION COMPACT PI data" ); + } + + /* Compact position data is 4 bytes, header is 2 bytes */ + if ( maxDataBytes < 4 * IVAS_MAX_NUM_OBJECTS + 2 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_INSUFFICIENT_OUTPUT_SIZE, "Insufficient space to pack ISM POSITION COMPACT PI data" ); + } + + buffer[nBytes++] = ( ism_position->piDataType & MASK_5BIT ); /* PF/PM populated during final packing */ + buffer[nBytes++] = (uint8_t) ism_position->numObjects * 4; + for ( n = 0; n < ism_position->numObjects; n++ ) + { + posX = (uint16_t) ivasPayload_convertToQ10( ism_position->position[n].x / MAX_PI_COMPACT_POSITION_XY_METERS ); + posY = (uint16_t) ivasPayload_convertToQ10( ism_position->position[n].y / MAX_PI_COMPACT_POSITION_XY_METERS ); + posZ = (uint16_t) ivasPayload_convertToQ9( ism_position->position[n].z / MAX_PI_COMPACT_POSITION_Z_METERS ); + buffer[nBytes++] = (uint8_t) ( posX >> 8 ); + buffer[nBytes++] = (uint8_t) ( ( ( posX & MASK_3BIT ) << 5 ) | posY >> 6 ); + buffer[nBytes++] = (uint8_t) ( ( ( posY & MASK_6BIT ) << 2 ) | posZ >> 8 ); + buffer[nBytes++] = (uint8_t) ( posZ >> 2 ); + } + *nBytesWritten = nBytes; + return IVAS_ERR_OK; +} + +static ivas_error unpackISMPositionCompact( const uint8_t *buffer, uint32_t numDataBytes, IVAS_PIDATA_GENERIC *piData ) +{ + uint16_t n; + int32_t compactRead = 0; + IVAS_PIDATA_ISM_POSITION *ism_position = (IVAS_PIDATA_ISM_POSITION *) piData; + + /* Compact position data is 4 bytes */ + if ( numDataBytes % 4 != 0 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_UNPACK_PI_DATA, "Incorrect size to unpack ISM POSITION COMPACT PI data" ); + } + + ism_position->size = sizeof( IVAS_PIDATA_ISM_POSITION ); + ism_position->piDataType = IVAS_PI_ISM_POSITION_COMPACT; + ism_position->numObjects = (uint16_t) numDataBytes / 4; + + for ( n = 0; n < ism_position->numObjects; n++ ) + { + compactRead = ( (int32_t) buffer[n * 4] << 24 ) | ( (int32_t) buffer[n * 4 + 1] << 16 ) | ( (int32_t) buffer[n * 4 + 2] << 8 ) | ( (int32_t) buffer[n * 4 + 3] ); + ism_position->position[n].x = FLOAT_FROM_Q10( (int16_t) ( compactRead >> 21 ) ) * MAX_PI_COMPACT_POSITION_XY_METERS; /* Shift preserves sign bit */ + compactRead = compactRead << 11; /* Discard read bits */ + ism_position->position[n].y = FLOAT_FROM_Q10( (int16_t) ( compactRead >> 21 ) ) * MAX_PI_COMPACT_POSITION_XY_METERS; /* Shift preserves sign bit */ + compactRead = compactRead << 11; /* Discard read bits */ + ism_position->position[n].z = FLOAT_FROM_Q9( (int16_t) ( compactRead >> 22 ) ) * MAX_PI_COMPACT_POSITION_Z_METERS; /* Shift preserves sign bit */ + } + return IVAS_ERR_OK; +} +#endif static ivas_error packDiegetic( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) { uint32_t nBytes = 0, n; @@ -777,7 +1122,16 @@ static ivas_error packAudioFocusCommon( const IVAS_PIDATA_GENERIC *piData, uint8 { return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect size in PI data of type Audio Focus" ); } - +#ifdef RTP_UPDATES_SA4_134 + if ( audioFocus->availDirection && audioFocus->availLevel ) + { + packedSize = 5; + } + else if ( audioFocus->availDirection ) + { + packedSize = 4; + } +#else if ( audioFocus->availDirection && audioFocus->availLevel ) { packedSize = 9; @@ -786,6 +1140,7 @@ static ivas_error packAudioFocusCommon( const IVAS_PIDATA_GENERIC *piData, uint8 { packedSize = 8; } +#endif else if ( audioFocus->availLevel ) { packedSize = 1; @@ -803,7 +1158,23 @@ static ivas_error packAudioFocusCommon( const IVAS_PIDATA_GENERIC *piData, uint8 buffer[nBytes++] = ( audioFocus->piDataType & MASK_5BIT ); /* PF/PM populated during final packing */ buffer[nBytes++] = packedSize; - +#ifdef RTP_UPDATES_SA4_134 + if ( packedSize == 5 || packedSize == 4 ) + { +#ifdef COMPACT_ORIENTATION_PI_DATA + nBytes += packQuaternion( audioFocus->direction, &buffer[nBytes] ); +#else + buffer[nBytes++] = (uint8_t) ivasPayload_convertToQ7( audioFocus->direction.w ); + buffer[nBytes++] = (uint8_t) ivasPayload_convertToQ7( audioFocus->direction.x ); + buffer[nBytes++] = (uint8_t) ivasPayload_convertToQ7( audioFocus->direction.y ); + buffer[nBytes++] = (uint8_t) ivasPayload_convertToQ7( audioFocus->direction.z ); +#endif + } + if ( packedSize == 5 || packedSize == 1 ) + { + buffer[nBytes++] = ( (uint8_t) audioFocus->flvl & MASK_4BIT ) << 4; + } +#else if ( packedSize == 9 || packedSize == 8 ) { nBytes = writeInt16( buffer, nBytes, round_fx( audioFocus->direction.w_fx ) ); @@ -815,6 +1186,7 @@ static ivas_error packAudioFocusCommon( const IVAS_PIDATA_GENERIC *piData, uint8 { buffer[nBytes++] = ( (uint8_t) audioFocus->flvl & MASK_4BIT ) << 4; } +#endif *nBytesWritten = nBytes; return IVAS_ERR_OK; @@ -824,6 +1196,38 @@ static ivas_error unpackAudioFocusCommon( const uint8_t *buffer, uint32_t numDat { IVAS_PIDATA_AUDIO_FOCUS *audioFocus = (IVAS_PIDATA_AUDIO_FOCUS *) piData; +#ifdef RTP_UPDATES_SA4_134 + /* Audio Focus data is either 1, 4 or 5 bytes */ + if ( numDataBytes != 1 && numDataBytes != 4 && numDataBytes != 5 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_UNPACK_PI_DATA, "Incorrect size to unpack PI data of type Audio Focus" ); + } + + piData->size = sizeof( IVAS_PIDATA_AUDIO_FOCUS ); + audioFocus->availDirection = ( numDataBytes >= 4 ); + audioFocus->availLevel = ( numDataBytes == 1 || numDataBytes == 5 ); + + if ( numDataBytes == 1 ) + { + audioFocus->flvl = ( buffer[0] >> 4 ); + } + else + { +#ifdef COMPACT_ORIENTATION_PI_DATA + unpackQuaternion( buffer, &( audioFocus->direction ) ); +#else + audioFocus->direction.w = FLOAT_FROM_Q7( (int8_t) buffer[0] ); + audioFocus->direction.x = FLOAT_FROM_Q7( (int8_t) buffer[1] ); + audioFocus->direction.y = FLOAT_FROM_Q7( (int8_t) buffer[2] ); + audioFocus->direction.z = FLOAT_FROM_Q7( (int8_t) buffer[3] ); +#endif + + if ( numDataBytes == 5 ) + { + audioFocus->flvl = ( buffer[4] >> 4 ); + } + } +#else /* Audio Focus data is either 1, 8 or 9 bytes */ if ( numDataBytes != 1 && numDataBytes != 8 && numDataBytes != 9 ) { @@ -850,6 +1254,7 @@ static ivas_error unpackAudioFocusCommon( const uint8_t *buffer, uint32_t numDat audioFocus->flvl = ( buffer[8] >> 4 ); } } +#endif return IVAS_ERR_OK; } @@ -1487,11 +1892,14 @@ static const PACK_PI_FN packPiDataFuntions[IVAS_PI_MAX_ID] = { packUnsupportedData, /* AUDIO_DESCRIPTION */ #endif /* RTP_S4_251135_CR26253_0016_REV1 */ #ifdef ISM_PI_DATA - packISMNum, /* ISM_NUM */ - packISMID, /* ISM_ID */ - packISMGain, /* ISM_GAIN */ - packISMOrientation, /* ISM_ORIENTATION */ - packISMPosition, /* ISM_POSITION */ + packISMNum, /* ISM_NUM */ + packISMID, /* ISM_ID */ + packISMGain, /* ISM_GAIN */ + packISMOrientation, /* ISM_ORIENTATION */ + packISMPosition, /* ISM_POSITION */ +#ifdef RTP_UPDATES_SA4_134 + packISMPositionCompact, /* ISM_POSITION_COMPACT */ +#endif packISMDistanceAttenuation, /* ISM_DISTANCE_ATTENUATION */ packISMDirectivity, /* ISM_DIRECTIVITY */ #else @@ -1508,24 +1916,34 @@ static const PACK_PI_FN packPiDataFuntions[IVAS_PI_MAX_ID] = { #else packUnsupportedData, /* DIEGETIC_TYPE */ #endif - packUnsupportedData, /* RESERVED13 */ +#ifdef RTP_UPDATES_SA4_134 + packDynamicSuppression, /* DYNAMIC_AUDIO_SUPPRESSION_INDICATION */ +#else + packUnsupportedData, /* RESERVED13 */ +#endif #ifdef RTP_S4_251135_CR26253_0016_REV1 packAudioFocusCommon, /* AUDIO_FOCUS_INDICATION */ #else packUnsupportedData, /* AUDIO_FOCUS_INDICATION */ #endif +#ifndef RTP_UPDATES_SA4_134 packUnsupportedData, /* RESERVED15 */ +#endif #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 */ + packListenerPosition, /* LISTENER_POSITION */ +#endif +#ifdef RTP_UPDATES_SA4_134 + packDynamicSuppression, /* DYNAMIC_AUDIO_SUPPRESSION_REQUEST */ +#else + packDynamicSuppression, /* DYNAMIC_AUDIO_SUPPRESSION */ #endif - packDynamicSuppression, /* DYNAMIC_AUDIO_SUPPRESSION */ - packAudioFocusCommon, /* AUDIO_FOCUS_REQUEST */ - packPiLatency, /* PI_LATENCY */ + packAudioFocusCommon, /* AUDIO_FOCUS_REQUEST */ + packPiLatency, /* PI_LATENCY */ #else packUnsupportedData, /* PLAYBACK_DEVICE_ORIENTATION */ packUnsupportedData, /* HEAD_ORIENTATION */ @@ -1548,7 +1966,10 @@ static const PACK_PI_FN packPiDataFuntions[IVAS_PI_MAX_ID] = { #endif #ifdef REVERSE_ISM_PI_DATA - packPosition, /* R_ISM_POSITION */ + packPosition, /* R_ISM_POSITION */ +#ifdef RTP_UPDATES_SA4_134 + packPositionCompact, /* R_ISM_POSITION_COMPACT */ +#endif packReverseISMDirection, /* R_ISM_DIRECTION */ #else packUnsupportedData, /* R_ISM_POSITION */ @@ -1557,8 +1978,11 @@ static const PACK_PI_FN packPiDataFuntions[IVAS_PI_MAX_ID] = { packUnsupportedData, /* RESERVED27 */ packUnsupportedData, /* RESERVED28 */ packUnsupportedData, /* RESERVED29 */ +#ifndef RTP_UPDATES_SA4_134 packUnsupportedData, /* RESERVED30 */ packNoPiData /* NO_DATA */ +#endif + packNoPiData /* NO_DATA */ }; static const UNPACK_PI_FN unpackPiDataFuntions[IVAS_PI_MAX_ID] = { @@ -1572,11 +1996,14 @@ static const UNPACK_PI_FN unpackPiDataFuntions[IVAS_PI_MAX_ID] = { unpackUnsupportedData, /* AUDIO_DESCRIPTION */ #endif #ifdef ISM_PI_DATA - unpackISMNum, /* ISM_NUM */ - unpackISMID, /* ISM_ID */ - unpackISMGain, /* ISM_GAIN */ - unpackISMOrientation, /* ISM_ORIENTATION */ - unpackISMPosition, /* ISM_POSITION */ + unpackISMNum, /* ISM_NUM */ + unpackISMID, /* ISM_ID */ + unpackISMGain, /* ISM_GAIN */ + unpackISMOrientation, /* ISM_ORIENTATION */ + unpackISMPosition, /* ISM_POSITION */ +#ifdef RTP_UPDATES_SA4_134 + unpackISMPositionCompact, /* ISM_POSITION_COMPACT */ +#endif unpackISMDistanceAttenuation, /* ISM_DISTANCE_ATTENUATION */ unpackISMDirectivity, /* ISM_DIRECTIVITY */ #else @@ -1593,24 +2020,34 @@ static const UNPACK_PI_FN unpackPiDataFuntions[IVAS_PI_MAX_ID] = { #else unpackUnsupportedData, /* DIEGETIC_TYPE */ #endif +#ifdef RTP_UPDATES_SA4_134 + unpackDynamicSuppression, /* DYNAMIC_AUDIO_SUPPRESSION_INDICATION */ +#else unpackUnsupportedData, /* RESERVED13 */ +#endif #ifdef RTP_S4_251135_CR26253_0016_REV1 unpackAudioFocusCommon, /* AUDIO_FOCUS_INDICATION */ #else unpackUnsupportedData, /* AUDIO_FOCUS_INDICATION */ #endif +#ifndef RTP_UPDATES_SA4_134 unpackUnsupportedData, /* RESERVED15 */ +#endif #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 */ + unpackListenerPosition, /* LISTENER_POSITION */ #endif +#ifdef RTP_UPDATES_SA4_134 + unpackDynamicSuppression, /* DYNAMIC_AUDIO_SUPPRESSION_REQUEST */ +#else unpackDynamicSuppression, /* DYNAMIC_AUDIO_SUPPRESSION */ - unpackAudioFocusCommon, /* AUDIO_FOCUS_REQUEST */ - unpackPiLatency, /* PI_LATENCY */ +#endif + unpackAudioFocusCommon, /* AUDIO_FOCUS_REQUEST */ + unpackPiLatency, /* PI_LATENCY */ #else unpackUnsupportedData, /* PLAYBACK_DEVICE_ORIENTATION */ unpackUnsupportedData, /* HEAD_ORIENTATION */ @@ -1633,6 +2070,9 @@ static const UNPACK_PI_FN unpackPiDataFuntions[IVAS_PI_MAX_ID] = { #endif #ifdef REVERSE_ISM_PI_DATA unpackPosition, /* R_ISM_POSITION */ +#ifdef RTP_UPDATES_SA4_134 + unpackPositionCompact, /* R_ISM_POSITION_COMPACT */ +#endif unpackReverseISMDirection, /* R_ISM_DIRECTION */ #else unpackUnsupportedData, /* R_ISM_POSITION */ @@ -1641,10 +2081,48 @@ static const UNPACK_PI_FN unpackPiDataFuntions[IVAS_PI_MAX_ID] = { unpackUnsupportedData, /* RESERVED27 */ unpackUnsupportedData, /* RESERVED28 */ unpackUnsupportedData, /* RESERVED29 */ +#ifndef RTP_UPDATES_SA4_134 unpackUnsupportedData, /* RESERVED30 */ +#endif unpackNoPiData /* NO_DATA */ }; +#ifdef RTP_UPDATES_SA4_134 +static const uint32_t maxPiDataSize[IVAS_PI_MAX_ID] = { + 4, /* IVAS_PI_SCENE_ORIENTATION */ + 4, /* IVAS_PI_DEVICE_ORIENTATION_COMPENSATED */ + 4, /* IVAS_PI_DEVICE_ORIENTATION_UNCOMPENSATED */ + 8, /* IVAS_PI_ACOUSTIC_ENVIRONMENT */ + 5, /* IVAS_PI_AUDIO_DESCRIPTION */ + 1, /* IVAS_PI_ISM_NUM */ + 4, /* IVAS_PI_ISM_ID */ + 4, /* IVAS_PI_ISM_GAIN */ + 16, /* IVAS_PI_ISM_ORIENTATION */ + 24, /* IVAS_PI_ISM_POSITION */ + 16, /* IVAS_PI_ISM_POSITION_COMPACT */ + 12, /* IVAS_PI_ISM_DISTANCE_ATTENUATION */ + 8, /* IVAS_PI_ISM_DIRECTIVITY */ + 1, /* IVAS_PI_DIEGETIC_TYPE */ + 2, /* IVAS_PI_DYNAMIC_AUDIO_SUPPRESSION_INDICATION */ + 5, /* IVAS_PI_AUDIO_FOCUS_INDICATION */ + 4, /* IVAS_PI_PLAYBACK_DEVICE_ORIENTATION */ + 4, /* IVAS_PI_HEAD_ORIENTATION */ + 6, /* IVAS_PI_LISTENER_POSITION */ + 2, /* IVAS_PI_DYNAMIC_AUDIO_SUPPRESSION */ + 5, /* IVAS_PI_AUDIO_FOCUS_REQUEST */ + 4, /* IVAS_PI_PI_LATENCY */ + 1, /* IVAS_PI_R_ISM_ID */ + 1, /* IVAS_PI_R_ISM_GAIN */ + 4, /* IVAS_PI_R_ISM_ORIENTATION */ + 6, /* IVAS_PI_R_ISM_POSITION */ + 4, /* IVAS_PI_R_ISM_POSITION_COMPACT */ + 2, /* IVAS_PI_R_ISM_DIRECTION */ + 0, /* IVAS_PI_RESERVED27 */ + 0, /* IVAS_PI_RESERVED28 */ + 0, /* IVAS_PI_RESERVED29 */ + 0, /* NO_DATA */ +}; +#else static const uint32_t maxPiDataSize[IVAS_PI_MAX_ID] = { 8, /* IVAS_PI_SCENE_ORIENTATION */ 8, /* IVAS_PI_DEVICE_ORIENTATION_COMPENSATED */ @@ -1679,6 +2157,7 @@ static const uint32_t maxPiDataSize[IVAS_PI_MAX_ID] = { 0, /* IVAS_PI_RESERVED30 */ 0, /* IVAS_PI_NO_DATA = 31 */ }; +#endif ivas_error PI_PackData( const IVAS_PIDATA_GENERIC *piData, PIDATA_PACKED *packed, uint8_t pmBits ) { diff --git a/lib_util/ivas_rtp_pi_data.h b/lib_util/ivas_rtp_pi_data.h index 2bce92fa7..c1f979c94 100644 --- a/lib_util/ivas_rtp_pi_data.h +++ b/lib_util/ivas_rtp_pi_data.h @@ -55,19 +55,23 @@ typedef enum IVAS_PI_DEVICE_ORIENTATION_UNCOMPENSATED, /* orientation of device in unit quaternions (un-compensated) */ IVAS_PI_ACOUSTIC_ENVIRONMENT, /* describe the acoustic environment */ #ifdef RTP_S4_251135_CR26253_0016_REV1 - IVAS_PI_AUDIO_DESCRIPTION, /* audio content description (voice/music/ambiance) */ - IVAS_PI_ISM_NUM, /* Number of objects */ - IVAS_PI_ISM_ID, /* id of each object */ - IVAS_PI_ISM_GAIN, /* gain of each object */ - IVAS_PI_ISM_ORIENTATION, /* orientation of each object */ - IVAS_PI_ISM_POSITION, /* position of each object */ + IVAS_PI_AUDIO_DESCRIPTION, /* audio content description (voice/music/ambiance) */ + IVAS_PI_ISM_NUM, /* Number of objects */ + IVAS_PI_ISM_ID, /* id of each object */ + IVAS_PI_ISM_GAIN, /* gain of each object */ + IVAS_PI_ISM_ORIENTATION, /* orientation of each object */ + IVAS_PI_ISM_POSITION, /* position of each object */ +#ifdef RTP_UPDATES_SA4_134 + IVAS_PI_ISM_POSITION_COMPACT, /* position of each object in compact representation */ +#endif IVAS_PI_ISM_DISTANCE_ATTENUATION, /* distance attenuation for each object */ IVAS_PI_ISM_DIRECTIVITY, /* directivity of each object */ IVAS_PI_DIEGETIC_TYPE, /* digetic audio indication */ IVAS_PI_DYNAMIC_AUDIO_SUPPRESSION_INDICATION, /* audio suppression indication */ IVAS_PI_AUDIO_FOCUS_INDICATION, /* audio focus indication (direction in Quaternions and/or level) */ - IVAS_PI_RESERVED15, /* reserved */ - +#ifndef RTP_UPDATES_SA4_134 + IVAS_PI_RESERVED15, /* reserved */ +#endif /* Reverse direction PI types */ IVAS_PI_PLAYBACK_DEVICE_ORIENTATION, /* orientation of the playback device in quaternions */ IVAS_PI_HEAD_ORIENTATION, /* head orientation of the listener in Quaternions */ @@ -79,14 +83,19 @@ typedef enum IVAS_PI_R_ISM_GAIN, /* editing request for gain factor for received object */ IVAS_PI_R_ISM_ORIENTATION, /* editing request for orientation for received object */ IVAS_PI_R_ISM_POSITION, /* editing request for position for received object */ - IVAS_PI_R_ISM_DIRECTION, /* editing request for direction for received object */ - IVAS_PI_RESERVED27, /* reserved */ - IVAS_PI_RESERVED28, /* reserved */ - IVAS_PI_RESERVED29, /* reserved */ - IVAS_PI_RESERVED30, /* reserved */ -#endif /* RTP_S4_251135_CR26253_0016_REV1 */ - IVAS_PI_NO_DATA = 31, /* Indicates an empty PI data frame */ - IVAS_PI_MAX_ID /* Max number of PI data IDs supprted */ +#ifdef RTP_UPDATES_SA4_134 + IVAS_PI_R_ISM_POSITION_COMPACT, /* editing request for position for received object in a compact representation*/ +#endif + IVAS_PI_R_ISM_DIRECTION, /* editing request for direction for received object */ + IVAS_PI_RESERVED27, /* reserved */ + IVAS_PI_RESERVED28, /* reserved */ + IVAS_PI_RESERVED29, /* reserved */ +#ifndef RTP_UPDATES_SA4_134 + IVAS_PI_RESERVED30, /* reserved */ +#endif +#endif /* RTP_S4_251135_CR26253_0016_REV1 */ + IVAS_PI_NO_DATA = 31, /* Indicates an empty PI data frame */ + IVAS_PI_MAX_ID /* Max number of PI data IDs supprted */ } IVAS_PI_TYPE; /* cartesian coordinates (X,Y,Z) in 3D space */ @@ -502,6 +511,9 @@ typedef union IVAS_PIDATA_ISM_GAIN ismGain; IVAS_PIDATA_ISM_ORIENTATION ismOrientation; IVAS_PIDATA_ISM_POSITION ismPosition; +#ifdef RTP_UPDATES_SA4_134 + IVAS_PIDATA_ISM_POSITION ismPositionCompact; +#endif IVAS_PIDATA_ISM_ATTENUATION ismAttenuation; IVAS_PIDATA_ISM_DIRECTIVITY ismDirectivity; IVAS_PIDATA_DIEGETIC digeticIndicator; @@ -525,6 +537,9 @@ typedef union IVAS_PIDATA_POSITION ismEditPosition; #else IVAS_PIDATA_ISM_EDIT_POSITION ismEditPosition; +#endif +#ifdef RTP_UPDATES_SA4_134 + IVAS_PIDATA_POSITION ismEditPositionCompact; #endif IVAS_PIDATA_ISM_EDIT_DIRECTION ismEditDirection; #endif /* RTP_S4_251135_CR26253_0016_REV1 */ -- GitLab From 7bdf037028f35d01140e57278363d006ec6ac7bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20Toftg=C3=A5rd?= Date: Thu, 20 Nov 2025 06:11:24 +0100 Subject: [PATCH 2/2] formatting --- lib_util/ivas_rtp_pi_data.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib_util/ivas_rtp_pi_data.c b/lib_util/ivas_rtp_pi_data.c index bf4bfc828..1a17318d7 100644 --- a/lib_util/ivas_rtp_pi_data.c +++ b/lib_util/ivas_rtp_pi_data.c @@ -189,10 +189,10 @@ static ivas_error unpackQuaternion( const uint8_t *buffer, IVAS_QUATERNION *orie k++; } q[max_q_idx] = sqrtf( 1 - qs ); - orientation->w_fx = ivasPayload_convertToQ15(q[0]); - orientation->x_fx = ivasPayload_convertToQ15(q[1]); - orientation->y_fx = ivasPayload_convertToQ15(q[2]); - orientation->z_fx = ivasPayload_convertToQ15(q[3]); + orientation->w_fx = ivasPayload_convertToQ15( q[0] ); + orientation->x_fx = ivasPayload_convertToQ15( q[1] ); + orientation->y_fx = ivasPayload_convertToQ15( q[2] ); + orientation->z_fx = ivasPayload_convertToQ15( q[3] ); return IVAS_ERR_OK; } @@ -2069,7 +2069,7 @@ static const UNPACK_PI_FN unpackPiDataFuntions[IVAS_PI_MAX_ID] = { unpackUnsupportedData, /* R_ISM_ORIENTATION */ #endif #ifdef REVERSE_ISM_PI_DATA - unpackPosition, /* R_ISM_POSITION */ + unpackPosition, /* R_ISM_POSITION */ #ifdef RTP_UPDATES_SA4_134 unpackPositionCompact, /* R_ISM_POSITION_COMPACT */ #endif @@ -2084,7 +2084,7 @@ static const UNPACK_PI_FN unpackPiDataFuntions[IVAS_PI_MAX_ID] = { #ifndef RTP_UPDATES_SA4_134 unpackUnsupportedData, /* RESERVED30 */ #endif - unpackNoPiData /* NO_DATA */ + unpackNoPiData /* NO_DATA */ }; #ifdef RTP_UPDATES_SA4_134 -- GitLab