From dd7104873d393b77f84998e7612c5b1f026fb739 Mon Sep 17 00:00:00 2001 From: Stefan Doehla Date: Tue, 4 Nov 2025 17:54:44 +0100 Subject: [PATCH 1/8] payload implementation of PI latency --- lib_com/options.h | 1 + lib_util/ivas_rtp_pi_data.c | 81 ++++++++++++++++++++++++++++++++++++- tests/rtp/ivasrtp.py | 26 +++++++++++- tests/rtp/test_rtp.py | 18 ++++++++- 4 files changed, 121 insertions(+), 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index a98f995caa..705e93a6b1 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -162,6 +162,7 @@ #define RTP_S4_251135_CR26253_0016_REV1 /* RTP Pack/Unpack API corresponding to CR 26253 */ #define IVAS_RTPDUMP /* RTPDUMP writing and reading for IVAS payloads */ #define FIXED_RTP_SEQUENCE_NUM /* Remove random sequence number initialization */ +#define PI_LATENCY /* Pi latency PI frame */ /* ################### Start BE switches ################################# */ /* only BE switches wrt selection floating point code */ diff --git a/lib_util/ivas_rtp_pi_data.c b/lib_util/ivas_rtp_pi_data.c index 8db9d41f9d..cd10ee71ca 100644 --- a/lib_util/ivas_rtp_pi_data.c +++ b/lib_util/ivas_rtp_pi_data.c @@ -630,6 +630,73 @@ static ivas_error unpackAudioFocusCommon( const uint8_t *buffer, uint32_t numDat return IVAS_ERR_OK; } +#ifdef PI_LATENCY +static ivas_error packPiLatency( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) +{ + uint32_t typeBits; + uint32_t latencyBits; + uint32_t word; + uint32_t nBytes = 0; + const IVAS_PIDATA_REVERSE_PI_LATENCY *p = (const IVAS_PIDATA_REVERSE_PI_LATENCY *) piData; + + *nBytesWritten = 0; + if ( piData->size != sizeof( IVAS_PIDATA_REVERSE_PI_LATENCY ) ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect size for PI_LATENCY data" ); + } + if ( piData->piDataType != IVAS_PI_PI_LATENCY ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect PI ID for PI_LATENCY data" ); + } + if ( maxDataBytes < 2 + 4 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_INSUFFICIENT_OUTPUT_SIZE, "Insufficient space to pack PI_LATENCY data" ); + } + + buffer[nBytes++] = ( p->piDataType & MASK_5BIT ); + buffer[nBytes++] = 4; + + typeBits = (uint32_t)( p->type & MASK_5BIT ); + latencyBits = (uint32_t)( p->latency & 0x07FFFFFF ); + word = ( typeBits << 27 ) | latencyBits; + + buffer[nBytes++] = (uint8_t)( word >> 24 ); + buffer[nBytes++] = (uint8_t)( word >> 16 ); + buffer[nBytes++] = (uint8_t)( word >> 8 ); + buffer[nBytes++] = (uint8_t)( word ); + *nBytesWritten = nBytes; + + return IVAS_ERR_OK; +} + +static ivas_error unpackPiLatency( const uint8_t *buffer, uint32_t numDataBytes, IVAS_PIDATA_GENERIC *piData ) +{ + uint32_t word; + uint32_t lat; + IVAS_PIDATA_REVERSE_PI_LATENCY *p = (IVAS_PIDATA_REVERSE_PI_LATENCY *) piData; + + if ( numDataBytes != 4 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_UNPACK_PI_DATA, "Incorrect size to unpack PI_LATENCY data" ); + } + + p->size = sizeof( IVAS_PIDATA_REVERSE_PI_LATENCY ); + p->piDataType = IVAS_PI_PI_LATENCY; + + word = ((uint32_t)buffer[0] << 24) | ((uint32_t)buffer[1] << 16) | + ((uint32_t)buffer[2] << 8) | (uint32_t)buffer[3]; + p->type = (IVAS_PI_TYPE)( ( word >> 27 ) & MASK_5BIT ); + lat = word & 0x07FFFFFF; + + /* Sign-extend 27-bit value */ + if ( lat & ( 1u << 26 ) ) + p->latency = (int32_t)( lat | ~0x07FFFFFF ); + else + p->latency = (int32_t) lat; + + return IVAS_ERR_OK; +} +#endif #endif /* RTP_S4_251135_CR26253_0016_REV1 */ @@ -668,14 +735,19 @@ static const PACK_PI_FN packPiDataFuntions[IVAS_PI_MAX_ID] = { packListenerPosition, /* LISTENER_POSITION */ packDynamicSuppression, /* DYNAMIC_AUDIO_SUPPRESSION */ packAudioFocusCommon, /* AUDIO_FOCUS_REQUEST */ +#ifdef PI_LATENCY + packPiLatency, /* PI_LATENCY */ +#else + packUnsupportedData, /* PI_LATENCY */ +#endif #else packUnsupportedData, /* PLAYBACK_DEVICE_ORIENTATION */ packUnsupportedData, /* HEAD_ORIENTATION */ packUnsupportedData, /* LISTENER_POSITION */ packUnsupportedData, /* DYNAMIC_AUDIO_SUPPRESSION */ packUnsupportedData, /* AUDIO_FOCUS_DIRECTION */ + packUnsupportedData, /* PI_LATENCY */ #endif - packUnsupportedData, /* PI_LATENCY */ packUnsupportedData, /* R_ISM_ID */ packUnsupportedData, /* R_ISM_GAIN */ #ifdef RTP_S4_251135_CR26253_0016_REV1 @@ -727,14 +799,19 @@ static const UNPACK_PI_FN unpackPiDataFuntions[IVAS_PI_MAX_ID] = { unpackListenerPosition, /* LISTENER_POSITION */ unpackDynamicSuppression, /* DYNAMIC_AUDIO_SUPPRESSION */ unpackAudioFocusCommon, /* AUDIO_FOCUS_REQUEST */ +#ifdef PI_LATENCY + unpackPiLatency, /* PI_LATENCY */ +#else + unpackUnsupportedData, /* PI_LATENCY */ +#endif #else unpackUnsupportedData, /* PLAYBACK_DEVICE_ORIENTATION */ unpackUnsupportedData, /* HEAD_ORIENTATION */ unpackUnsupportedData, /* LISTENER_POSITION */ unpackUnsupportedData, /* DYNAMIC_AUDIO_SUPPRESSION */ unpackUnsupportedData, /* AUDIO_FOCUS_DIRECTION */ -#endif unpackUnsupportedData, /* PI_LATENCY */ +#endif unpackUnsupportedData, /* R_ISM_ID */ unpackUnsupportedData, /* R_ISM_GAIN */ #ifdef RTP_S4_251135_CR26253_0016_REV1 diff --git a/tests/rtp/ivasrtp.py b/tests/rtp/ivasrtp.py index b09333fc46..e948c84732 100644 --- a/tests/rtp/ivasrtp.py +++ b/tests/rtp/ivasrtp.py @@ -394,6 +394,11 @@ class AUDIO_FOCUS: direction: Optional[ORIENTATION] = None level: Optional[AUDIO_FOCUS_LEVEL] = None +@dataclass +class PI_LATENCY: + reverseType: PIDATAS + latency: int + @dataclass class PIDATA: @@ -923,6 +928,23 @@ def packAudioFocus(bitstrm: BitStream, data: any): bitstrm.append(f"uint:4={level}") bitstrm.append(f"uint:4=0") +def unpackPiLatency(bitstrm: ConstBitStream, piSize: int) -> PI_LATENCY: + assert piSize == 4, "PI_LATENCY must be 4 bytes" + word = bitstrm.read(32).uint + typeBits = (word >> 27) & 0x1F + reverseType = PiTypeNames[typeBits] + raw = word & 0x07FFFFFF + # Sign-extend 27-bit + if raw & (1 << 26): + raw = raw | ~0x07FFFFFF + return PI_LATENCY(reverseType, int(raw)) + +def packPiLatency(bitstrm: BitStream, data: any) -> None: + assert type(data) == PI_LATENCY, "PI_LATENCY pack expects PI_LATENCY data" + idx = PiTypeNames.index(data.reverseType) + latency = data.latency & 0x07FFFFFF + word = (idx << 27) | latency + bitstrm.append(f"uint:32={word}") PIDataUnpacker = [ unpackOrientation, # SCENE_ORIENTATION, @@ -946,7 +968,7 @@ PIDataUnpacker = [ unpackPosition, # LISTENER_POSITION unpackDAS, # DYNAMIC_AUDIO_SUPPRESSION_REQUEST unpackAudioFocus, # AUDIO_FOCUS_REQUEST - unpackUnsupported, # PI_LATENCY + unpackPiLatency, # PI_LATENCY unpackUnsupported, # R_ISM_ID unpackUnsupported, # R_ISM_GAIN unpackOrientation, # R_ISM_ORIENTATION @@ -981,7 +1003,7 @@ PIDataPacker = [ packPosition, # LISTENER_POSITION packDAS, # DYNAMIC_AUDIO_SUPPRESSION_REQUEST packAudioFocus, # AUDIO_FOCUS_DIRECTION - packUnsupported, # PI_LATENCY + packPiLatency, # PI_LATENCY packUnsupported, # R_ISM_ID packUnsupported, # R_ISM_GAIN packOrientation, # R_ISM_ORIENTATION diff --git a/tests/rtp/test_rtp.py b/tests/rtp/test_rtp.py index 44d08a91e1..551a1e5c99 100644 --- a/tests/rtp/test_rtp.py +++ b/tests/rtp/test_rtp.py @@ -227,7 +227,18 @@ def generatePiData(startTs: int, endTs: int) -> dict: ) someAuFocusLvl = lambda: AUDIO_FOCUS(level=AUDIO_FOCUS_LEVEL(random.randint(0, 15))) someAuFocusList = [someAuFocusDirLvl, someAuFocusDir, someAuFocusLvl] - + + someLatency = lambda: PI_LATENCY( + reverseType=random.choice([ + "PLAYBACK_DEVICE_ORIENTATION", + "HEAD_ORIENTATION", + "LISTENER_POSITION", + "DYNAMIC_AUDIO_SUPPRESSION_REQUEST", + "AUDIO_FOCUS_REQUEST" + ]), + latency=random.randint(- (1 << 26), (1 << 26) - 1) + ) + for ts in range(startTs, endTs, 320): pidata = dict() pidata["SCENE_ORIENTATION"] = someOrientation() @@ -243,6 +254,7 @@ def generatePiData(startTs: int, endTs: int) -> dict: pidata["ACOUSTIC_ENVIRONMENT"] = ACOUSTIC_ENVIRONMENT( aeid=random.randint(0, 127) ) + pidata["PI_LATENCY"] = someLatency() data[str(ts)] = pidata return data @@ -637,6 +649,10 @@ def run_rtp_bitstream_tests( generatedPIData[ts][pitype], decodedPiData[ts][pitype] ): isEqualAD(AUDIO_DESCRIPTION(**d), r) + elif type(generatedPIData[ts][pitype]) == PI_LATENCY: + # Decoded JSON stores latency as integer + assert int(decodedPiData[ts][pitype]) == data.latency, \ + f"PI_LATENCY mismatch: {decodedPiData[ts][pitype]} != {data.latency}" else: assert False, "Unsupported PI data found" -- GitLab From 468a8038fbe568a6627449f3c0d47697a625faee Mon Sep 17 00:00:00 2001 From: Stefan Doehla Date: Tue, 4 Nov 2025 20:03:14 +0100 Subject: [PATCH 2/8] clang-format --- lib_util/ivas_rtp_pi_data.c | 46 ++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/lib_util/ivas_rtp_pi_data.c b/lib_util/ivas_rtp_pi_data.c index cd10ee71ca..8e1183955d 100644 --- a/lib_util/ivas_rtp_pi_data.c +++ b/lib_util/ivas_rtp_pi_data.c @@ -656,14 +656,14 @@ static ivas_error packPiLatency( const IVAS_PIDATA_GENERIC *piData, uint8_t *buf buffer[nBytes++] = ( p->piDataType & MASK_5BIT ); buffer[nBytes++] = 4; - typeBits = (uint32_t)( p->type & MASK_5BIT ); - latencyBits = (uint32_t)( p->latency & 0x07FFFFFF ); + typeBits = (uint32_t) ( p->type & MASK_5BIT ); + latencyBits = (uint32_t) ( p->latency & 0x07FFFFFF ); word = ( typeBits << 27 ) | latencyBits; - buffer[nBytes++] = (uint8_t)( word >> 24 ); - buffer[nBytes++] = (uint8_t)( word >> 16 ); - buffer[nBytes++] = (uint8_t)( word >> 8 ); - buffer[nBytes++] = (uint8_t)( word ); + buffer[nBytes++] = (uint8_t) ( word >> 24 ); + buffer[nBytes++] = (uint8_t) ( word >> 16 ); + buffer[nBytes++] = (uint8_t) ( word >> 8 ); + buffer[nBytes++] = (uint8_t) ( word ); *nBytesWritten = nBytes; return IVAS_ERR_OK; @@ -683,14 +683,14 @@ static ivas_error unpackPiLatency( const uint8_t *buffer, uint32_t numDataBytes, p->size = sizeof( IVAS_PIDATA_REVERSE_PI_LATENCY ); p->piDataType = IVAS_PI_PI_LATENCY; - word = ((uint32_t)buffer[0] << 24) | ((uint32_t)buffer[1] << 16) | - ((uint32_t)buffer[2] << 8) | (uint32_t)buffer[3]; - p->type = (IVAS_PI_TYPE)( ( word >> 27 ) & MASK_5BIT ); + word = ( (uint32_t) buffer[0] << 24 ) | ( (uint32_t) buffer[1] << 16 ) | + ( (uint32_t) buffer[2] << 8 ) | (uint32_t) buffer[3]; + p->type = (IVAS_PI_TYPE) ( ( word >> 27 ) & MASK_5BIT ); lat = word & 0x07FFFFFF; /* Sign-extend 27-bit value */ if ( lat & ( 1u << 26 ) ) - p->latency = (int32_t)( lat | ~0x07FFFFFF ); + p->latency = (int32_t) ( lat | ~0x07FFFFFF ); else p->latency = (int32_t) lat; @@ -708,7 +708,7 @@ static const PACK_PI_FN packPiDataFuntions[IVAS_PI_MAX_ID] = { #ifdef RTP_S4_251135_CR26253_0016_REV1 packAudioDescription, /* AUDIO_DESCRIPTION */ #else - packUnsupportedData, /* AUDIO_DESCRIPTION */ + packUnsupportedData, /* AUDIO_DESCRIPTION */ #endif /* RTP_S4_251135_CR26253_0016_REV1 */ packUnsupportedData, /* ISM_NUM */ packUnsupportedData, /* ISM_ID */ @@ -720,13 +720,13 @@ static const PACK_PI_FN packPiDataFuntions[IVAS_PI_MAX_ID] = { #ifdef RTP_S4_251135_CR26253_0016_REV1 packDiegetic, /* DIEGETIC_TYPE */ #else - packUnsupportedData, /* DIEGETIC_TYPE */ + packUnsupportedData, /* DIEGETIC_TYPE */ #endif packUnsupportedData, /* RESERVED13 */ #ifdef RTP_S4_251135_CR26253_0016_REV1 packAudioFocusCommon, /* AUDIO_FOCUS_INDICATION */ #else - packUnsupportedData, /* AUDIO_FOCUS_INDICATION */ + packUnsupportedData, /* AUDIO_FOCUS_INDICATION */ #endif packUnsupportedData, /* RESERVED15 */ #ifdef RTP_S4_251135_CR26253_0016_REV1 @@ -736,24 +736,24 @@ static const PACK_PI_FN packPiDataFuntions[IVAS_PI_MAX_ID] = { packDynamicSuppression, /* DYNAMIC_AUDIO_SUPPRESSION */ packAudioFocusCommon, /* AUDIO_FOCUS_REQUEST */ #ifdef PI_LATENCY - packPiLatency, /* PI_LATENCY */ + packPiLatency, /* PI_LATENCY */ #else - packUnsupportedData, /* PI_LATENCY */ + packUnsupportedData, /* PI_LATENCY */ #endif #else - packUnsupportedData, /* PLAYBACK_DEVICE_ORIENTATION */ - packUnsupportedData, /* HEAD_ORIENTATION */ - packUnsupportedData, /* LISTENER_POSITION */ - packUnsupportedData, /* DYNAMIC_AUDIO_SUPPRESSION */ - packUnsupportedData, /* AUDIO_FOCUS_DIRECTION */ - packUnsupportedData, /* PI_LATENCY */ + packUnsupportedData, /* PLAYBACK_DEVICE_ORIENTATION */ + packUnsupportedData, /* HEAD_ORIENTATION */ + packUnsupportedData, /* LISTENER_POSITION */ + packUnsupportedData, /* DYNAMIC_AUDIO_SUPPRESSION */ + packUnsupportedData, /* AUDIO_FOCUS_DIRECTION */ + packUnsupportedData, /* PI_LATENCY */ #endif packUnsupportedData, /* R_ISM_ID */ packUnsupportedData, /* R_ISM_GAIN */ #ifdef RTP_S4_251135_CR26253_0016_REV1 packOrientation, /* R_ISM_ORIENTATION */ #else - packUnsupportedData, /* R_ISM_ORIENTATION */ + packUnsupportedData, /* R_ISM_ORIENTATION */ #endif packUnsupportedData, /* R_ISM_POSITION */ packUnsupportedData, /* R_ISM_DIRECTION */ @@ -800,7 +800,7 @@ static const UNPACK_PI_FN unpackPiDataFuntions[IVAS_PI_MAX_ID] = { unpackDynamicSuppression, /* DYNAMIC_AUDIO_SUPPRESSION */ unpackAudioFocusCommon, /* AUDIO_FOCUS_REQUEST */ #ifdef PI_LATENCY - unpackPiLatency, /* PI_LATENCY */ + unpackPiLatency, /* PI_LATENCY */ #else unpackUnsupportedData, /* PI_LATENCY */ #endif -- GitLab From ee3e194c82553ca6d0926c04654c2527c3bcc2f0 Mon Sep 17 00:00:00 2001 From: Stefan Doehla Date: Tue, 4 Nov 2025 20:06:45 +0100 Subject: [PATCH 3/8] clang-format --- lib_util/ivas_rtp_pi_data.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib_util/ivas_rtp_pi_data.c b/lib_util/ivas_rtp_pi_data.c index 8e1183955d..25b8f189f8 100644 --- a/lib_util/ivas_rtp_pi_data.c +++ b/lib_util/ivas_rtp_pi_data.c @@ -708,7 +708,7 @@ static const PACK_PI_FN packPiDataFuntions[IVAS_PI_MAX_ID] = { #ifdef RTP_S4_251135_CR26253_0016_REV1 packAudioDescription, /* AUDIO_DESCRIPTION */ #else - packUnsupportedData, /* AUDIO_DESCRIPTION */ + packUnsupportedData, /* AUDIO_DESCRIPTION */ #endif /* RTP_S4_251135_CR26253_0016_REV1 */ packUnsupportedData, /* ISM_NUM */ packUnsupportedData, /* ISM_ID */ @@ -720,13 +720,13 @@ static const PACK_PI_FN packPiDataFuntions[IVAS_PI_MAX_ID] = { #ifdef RTP_S4_251135_CR26253_0016_REV1 packDiegetic, /* DIEGETIC_TYPE */ #else - packUnsupportedData, /* DIEGETIC_TYPE */ + packUnsupportedData, /* DIEGETIC_TYPE */ #endif packUnsupportedData, /* RESERVED13 */ #ifdef RTP_S4_251135_CR26253_0016_REV1 packAudioFocusCommon, /* AUDIO_FOCUS_INDICATION */ #else - packUnsupportedData, /* AUDIO_FOCUS_INDICATION */ + packUnsupportedData, /* AUDIO_FOCUS_INDICATION */ #endif packUnsupportedData, /* RESERVED15 */ #ifdef RTP_S4_251135_CR26253_0016_REV1 @@ -738,22 +738,22 @@ static const PACK_PI_FN packPiDataFuntions[IVAS_PI_MAX_ID] = { #ifdef PI_LATENCY packPiLatency, /* PI_LATENCY */ #else - packUnsupportedData, /* PI_LATENCY */ + packUnsupportedData, /* PI_LATENCY */ #endif #else - packUnsupportedData, /* PLAYBACK_DEVICE_ORIENTATION */ - packUnsupportedData, /* HEAD_ORIENTATION */ - packUnsupportedData, /* LISTENER_POSITION */ - packUnsupportedData, /* DYNAMIC_AUDIO_SUPPRESSION */ - packUnsupportedData, /* AUDIO_FOCUS_DIRECTION */ - packUnsupportedData, /* PI_LATENCY */ + packUnsupportedData, /* PLAYBACK_DEVICE_ORIENTATION */ + packUnsupportedData, /* HEAD_ORIENTATION */ + packUnsupportedData, /* LISTENER_POSITION */ + packUnsupportedData, /* DYNAMIC_AUDIO_SUPPRESSION */ + packUnsupportedData, /* AUDIO_FOCUS_DIRECTION */ + packUnsupportedData, /* PI_LATENCY */ #endif packUnsupportedData, /* R_ISM_ID */ packUnsupportedData, /* R_ISM_GAIN */ #ifdef RTP_S4_251135_CR26253_0016_REV1 packOrientation, /* R_ISM_ORIENTATION */ #else - packUnsupportedData, /* R_ISM_ORIENTATION */ + packUnsupportedData, /* R_ISM_ORIENTATION */ #endif packUnsupportedData, /* R_ISM_POSITION */ packUnsupportedData, /* R_ISM_DIRECTION */ -- GitLab From ed0ae06ff53b97843eb8d35098b8772b24e8fb0c Mon Sep 17 00:00:00 2001 From: Stefan Doehla Date: Tue, 4 Nov 2025 23:05:37 +0100 Subject: [PATCH 4/8] fixed tests - now using reverse type and latency --- lib_util/ivas_rtp_file.c | 12 +++++++++++- tests/rtp/test_rtp.py | 8 +++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/lib_util/ivas_rtp_file.c b/lib_util/ivas_rtp_file.c index f7d6d5d867..6912897463 100644 --- a/lib_util/ivas_rtp_file.c +++ b/lib_util/ivas_rtp_file.c @@ -331,7 +331,17 @@ void IVAS_RTP_LogPiData( case IVAS_PI_ISM_POSITION: case IVAS_PI_ISM_DISTANCE_ATTENUATION: case IVAS_PI_ISM_DIRECTIVITY: + { + fprintf( f_piDataOut, "{}" ); + } + break; case IVAS_PI_PI_LATENCY: + { + fprintf( f_piDataOut, "\n\t\t\t\"reverseType\": \"%s\",", PiDataNames[cur->data.piLatency.type] ); + fprintf( f_piDataOut, "\n\t\t\t\"latency\": %d", cur->data.piLatency.latency ); + fprintf( f_piDataOut, "\n\t\t}" ); + } + break; case IVAS_PI_R_ISM_ID: case IVAS_PI_R_ISM_GAIN: case IVAS_PI_R_ISM_DIRECTION: @@ -558,7 +568,7 @@ void IVAS_RTP_WriteExtPiData( break; case IVAS_PI_PI_LATENCY: { - fprintf( f_piDataOut, "%d", cur->data.piLatency.latency ); + fprintf( f_piDataOut, "%s,%d", PiDataNames[cur->data.piLatency.type], cur->data.piLatency.latency ); } break; case IVAS_PI_R_ISM_ID: diff --git a/tests/rtp/test_rtp.py b/tests/rtp/test_rtp.py index 551a1e5c99..a8cf26e788 100644 --- a/tests/rtp/test_rtp.py +++ b/tests/rtp/test_rtp.py @@ -650,9 +650,11 @@ def run_rtp_bitstream_tests( ): isEqualAD(AUDIO_DESCRIPTION(**d), r) elif type(generatedPIData[ts][pitype]) == PI_LATENCY: - # Decoded JSON stores latency as integer - assert int(decodedPiData[ts][pitype]) == data.latency, \ - f"PI_LATENCY mismatch: {decodedPiData[ts][pitype]} != {data.latency}" + entry = decodedPiData[ts][pitype] + assert entry["reverseType"] == data.reverseType, \ + f"PI_LATENCY type mismatch: {entry['reverseType']} != {data.reverseType}" + assert int(entry["latency"]) == data.latency, \ + f"PI_LATENCY latency mismatch: {entry['latency']} != {data.latency}" else: assert False, "Unsupported PI data found" -- GitLab From 8d32ca1fa8e4c885f07a9a2eb2aa80678ead37ef Mon Sep 17 00:00:00 2001 From: Stefan Doehla Date: Tue, 4 Nov 2025 23:27:02 +0100 Subject: [PATCH 5/8] Align to other tests --- tests/rtp/test_rtp.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/rtp/test_rtp.py b/tests/rtp/test_rtp.py index a8cf26e788..1939fcc706 100644 --- a/tests/rtp/test_rtp.py +++ b/tests/rtp/test_rtp.py @@ -344,6 +344,12 @@ def isEqualAudioFocus(ref: AUDIO_FOCUS, dut: AUDIO_FOCUS): abs(ref.direction["z"] - dut.direction.z) < 0.0001 ), "Audio Focus PI Data mismatch in direction z" assert ref.level == dut.level, "Audio Focus PI Data mismatch in level" + +def isEqualPILatency(ref: PI_LATENCY, dut: PI_LATENCY): + assert ref.reverseType == dut.reverseType, \ + f"PI_LATENCY type mismatch: {dut.reverseType} != {ref.reverseType}" + assert ref.latency == dut.latency, \ + f"PI_LATENCY latency mismatch: {dut.latency} != {ref.latency}" class CSVREADER: @@ -644,17 +650,13 @@ def run_rtp_bitstream_tests( isEqualAcousticEnv(ACOUSTIC_ENVIRONMENT(**decoded), data) elif type(generatedPIData[ts][pitype]) == AUDIO_FOCUS: isEqualAudioFocus(AUDIO_FOCUS(**decoded), data) + elif type(generatedPIData[ts][pitype]) == PI_LATENCY: + isEqualPILatency(PI_LATENCY(**decoded), data) elif type(generatedPIData[ts][pitype]) == list: for r, d in zip( generatedPIData[ts][pitype], decodedPiData[ts][pitype] ): isEqualAD(AUDIO_DESCRIPTION(**d), r) - elif type(generatedPIData[ts][pitype]) == PI_LATENCY: - entry = decodedPiData[ts][pitype] - assert entry["reverseType"] == data.reverseType, \ - f"PI_LATENCY type mismatch: {entry['reverseType']} != {data.reverseType}" - assert int(entry["latency"]) == data.latency, \ - f"PI_LATENCY latency mismatch: {entry['latency']} != {data.latency}" else: assert False, "Unsupported PI data found" -- GitLab From f11e9d29f18cb9f1e64f13ec867e04d2a4e3696c Mon Sep 17 00:00:00 2001 From: Stefan Doehla Date: Tue, 4 Nov 2025 23:32:10 +0100 Subject: [PATCH 6/8] white space --- tests/rtp/test_rtp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/rtp/test_rtp.py b/tests/rtp/test_rtp.py index 1939fcc706..35e20c961a 100644 --- a/tests/rtp/test_rtp.py +++ b/tests/rtp/test_rtp.py @@ -344,7 +344,7 @@ def isEqualAudioFocus(ref: AUDIO_FOCUS, dut: AUDIO_FOCUS): abs(ref.direction["z"] - dut.direction.z) < 0.0001 ), "Audio Focus PI Data mismatch in direction z" assert ref.level == dut.level, "Audio Focus PI Data mismatch in level" - + def isEqualPILatency(ref: PI_LATENCY, dut: PI_LATENCY): assert ref.reverseType == dut.reverseType, \ f"PI_LATENCY type mismatch: {dut.reverseType} != {ref.reverseType}" -- GitLab From 26f4aef6a816b3dbfc169b7ac9bcf1017cb5aa80 Mon Sep 17 00:00:00 2001 From: Stefan Doehla Date: Wed, 5 Nov 2025 00:30:04 +0100 Subject: [PATCH 7/8] add debug functionality in case of invalid JSON - needed hat as the JSON is created manually and I had an error that was hard to find for me. Could be reverted if not desired. --- tests/rtp/test_rtp.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/rtp/test_rtp.py b/tests/rtp/test_rtp.py index 35e20c961a..9477da0b8f 100644 --- a/tests/rtp/test_rtp.py +++ b/tests/rtp/test_rtp.py @@ -629,8 +629,17 @@ def run_rtp_bitstream_tests( else: assert rmsdB < -96.0, "Bitdiff in the RTP unpacked and G192 streams" - with open(piDataOutJson, "r") as fd: - decodedPiData = json.load(fd) + try: + with open(piDataOutJson, "r") as fd: + decodedPiData = json.load(fd) + except json.decoder.JSONDecodeError as e: + print(f"JSONDecodeError loading PI data JSON at {piDataOutJson}: {e}") + with open(piDataOutJson, "r") as _f: + for _i, _l in enumerate(_f, start=1): + #if _i > 30: + # break + print(f"{_i:3}: {_l.rstrip()}") + raise assert ( decodedPiData.keys() == generatedPIData.keys() ), f"Timestamp of PI data {generatedPIData.keys()} not found in Decoded PI Data {decodedPiData.keys()}" -- GitLab From a980b8ca7ad9bf687527d60a573859a7a88ea1dc Mon Sep 17 00:00:00 2001 From: Stefan Doehla Date: Wed, 5 Nov 2025 00:31:15 +0100 Subject: [PATCH 8/8] missing curly brace thus malformed JSON --- lib_util/ivas_rtp_file.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib_util/ivas_rtp_file.c b/lib_util/ivas_rtp_file.c index 6912897463..f221c0de23 100644 --- a/lib_util/ivas_rtp_file.c +++ b/lib_util/ivas_rtp_file.c @@ -337,6 +337,7 @@ void IVAS_RTP_LogPiData( break; case IVAS_PI_PI_LATENCY: { + fprintf( f_piDataOut, "{" ); fprintf( f_piDataOut, "\n\t\t\t\"reverseType\": \"%s\",", PiDataNames[cur->data.piLatency.type] ); fprintf( f_piDataOut, "\n\t\t\t\"latency\": %d", cur->data.piLatency.latency ); fprintf( f_piDataOut, "\n\t\t}" ); -- GitLab