From 0f6ce2d51e3a8184ac431411be727f50fd50971e Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Mon, 20 Oct 2025 17:15:12 +0200 Subject: [PATCH 1/8] Linking compact room acoustics data provided with RTP to the rendering reconfiguration --- apps/decoder.c | 8 ++ lib_com/common_api_types.h | 3 + lib_com/ivas_cnst.h | 3 + lib_com/options.h | 1 + lib_dec/lib_dec.c | 126 ++++++++++++++++++++++++++++++++ lib_rend/ivas_render_config.c | 3 + lib_rend/lib_rend.c | 6 ++ lib_util/ivas_rtp_pi_data.c | 41 +++++++++++ lib_util/ivas_rtp_pi_data.h | 9 +++ lib_util/render_config_reader.c | 8 +- 10 files changed, 207 insertions(+), 1 deletion(-) diff --git a/apps/decoder.c b/apps/decoder.c index 33e0aeeff9..a378e2fbb3 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -41,6 +41,10 @@ #ifdef IVAS_RTPDUMP #include "ivas_rtp_file.h" #endif +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT +#include "ivas_cnst.h" +#endif + #include "jbm_file_writer.h" #include "hrtf_file_reader.h" #include "ls_custom_file_reader.h" @@ -446,7 +450,11 @@ int main( *------------------------------------------------------------------------------------------*/ asked_frame_size = arg.renderFramesize; +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT + uint16_t aeID = arg.aeSequence.count > 0 ? arg.aeSequence.pID[0] : IVAS_DEFAULT_AEID; +#else uint16_t aeID = arg.aeSequence.count > 0 ? arg.aeSequence.pID[0] : 65535; +#endif if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputConfig, arg.renderFramesize, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.enableExternalOrientation, arg.orientation_tracking, arg.renderConfigEnabled, arg.non_diegetic_pan_enabled, diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 80c90d6b31..15a87a1461 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -312,6 +312,9 @@ typedef enum #endif typedef struct _IVAS_ROOM_ACOUSTICS_CONFIG { +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT + int16_t aeID; /* Acoustic environment ID*/ +#endif int16_t nBands; /* Number of frequency bands for which reverb properties are provided, integer, range [2..256] */ float pFc_input[IVAS_CLDFB_NO_CHANNELS_MAX]; /* Center frequencies for which following values are provided: */ float pAcoustic_rt60[IVAS_CLDFB_NO_CHANNELS_MAX]; /* - The room's T60 per center frequency */ diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 6f679f0fd8..ad41df88a1 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1580,6 +1580,9 @@ typedef enum #define RV_LENGTH_NR_FC ( RV_FILTER_MAX_FFT_SIZE / 2 ) + 1 #define RV_LENGTH_NR_FC_16KHZ ( RV_FILTER_MAX_FFT_SIZE / 4 ) + 1 #define IVAS_REVERB_DEFAULT_N_BANDS 31 +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT +#define IVAS_DEFAULT_AEID ( 65535 ) +#endif #define LR_IAC_LENGTH_NR_FC ( RV_LENGTH_NR_FC ) #define LR_IAC_LENGTH_NR_FC_16KHZ ( RV_LENGTH_NR_FC_16KHZ ) diff --git a/lib_com/options.h b/lib_com/options.h index 6d394089cd..48cb9fe29c 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -161,6 +161,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 IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT /* RTPDUMP acoustic environment */ /* ################### Start BE switches ################################# */ /* only BE switches wrt selection floating point code */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 7ab22259ad..83578d5268 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -3210,6 +3210,9 @@ static ivas_error copyRendererConfigStruct( hRCout->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_NONE; break; } +#endif +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT + hRCout->roomAcoustics.aeID = hRCin->roomAcoustics.aeID; #endif hRCout->roomAcoustics.nBands = hRCin->roomAcoustics.nBands; hRCout->roomAcoustics.acousticPreDelay = hRCin->roomAcoustics.acousticPreDelay; @@ -3307,6 +3310,9 @@ ivas_error IVAS_DEC_FeedRenderConfig( { hRenderConfig->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_CREND; } +#endif +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT + hRenderConfig->roomAcoustics.aeID = renderConfig.roomAcoustics.aeID; #endif hRenderConfig->roomAcoustics.nBands = renderConfig.roomAcoustics.nBands; hRenderConfig->roomAcoustics.acousticPreDelay = renderConfig.roomAcoustics.acousticPreDelay; @@ -3393,6 +3399,112 @@ ivas_error IVAS_DEC_FeedRenderConfig( return IVAS_ERR_OK; } +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT +/*---------------------------------------------------------------------* + * IVAS_DEC_FeedAcousticEnvPI( ) + * + * Set acoustic environment from the PI data + *---------------------------------------------------------------------*/ + +ivas_error IVAS_DEC_FeedAcousticEnvPI( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const IVAS_PIDATA_ACOUSTIC_ENV hAcoustEnvPI /* i : Render configuration struct */ +) +{ + RENDER_CONFIG_HANDLE hRenderConfig; + Decoder_Struct *st_ivas; + ivas_error error; + + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hRenderConfig == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + hRenderConfig = hIvasDec->st_ivas->hRenderConfig; + st_ivas = hIvasDec->st_ivas; + +#ifdef DEBUGGING + hRenderConfig->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_NONE; + if ( renderConfig.renderer_type_override == IVAS_RENDER_TYPE_OVERRIDE_FASTCONV ) + { + hRenderConfig->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_FASTCONV; + } + if ( renderConfig.renderer_type_override == IVAS_RENDER_TYPE_OVERRIDE_CREND ) + { + hRenderConfig->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_CREND; + } +#endif + hRenderConfig->roomAcoustics.aeID = hAcoustEnvPI.aeid; + hRenderConfig->roomAcoustics.nBands = IVAS_PI_AE_NUM_BANDS; + hRenderConfig->roomAcoustics.pFc_input[IVAS_PI_AE_LOW] = IVAS_PI_AE_LOW_FREQ; + hRenderConfig->roomAcoustics.pFc_input[IVAS_PI_AE_MID] = IVAS_PI_AE_MID_FREQ; + hRenderConfig->roomAcoustics.pFc_input[IVAS_PI_AE_HIGH] = IVAS_PI_AE_HIGH_FREQ; + hRenderConfig->roomAcoustics.pAcoustic_rt60[IVAS_PI_AE_LOW] = hAcoustEnvPI.rt60[IVAS_PI_AE_LOW]; + hRenderConfig->roomAcoustics.pAcoustic_rt60[IVAS_PI_AE_MID] = hAcoustEnvPI.rt60[IVAS_PI_AE_MID]; + hRenderConfig->roomAcoustics.pAcoustic_rt60[IVAS_PI_AE_HIGH] = hAcoustEnvPI.rt60[IVAS_PI_AE_HIGH]; + hRenderConfig->roomAcoustics.inputPreDelay = (float)(0.1 * hRenderConfig->roomAcoustics.pAcoustic_rt60[IVAS_PI_AE_MID]); + hRenderConfig->roomAcoustics.pAcoustic_dsr[IVAS_PI_AE_LOW] = hAcoustEnvPI.dsr[IVAS_PI_AE_LOW]; + hRenderConfig->roomAcoustics.pAcoustic_dsr[IVAS_PI_AE_MID] = hAcoustEnvPI.dsr[IVAS_PI_AE_MID]; + hRenderConfig->roomAcoustics.pAcoustic_dsr[IVAS_PI_AE_HIGH] = hAcoustEnvPI.dsr[IVAS_PI_AE_HIGH]; + + hRenderConfig->roomAcoustics.use_er = hAcoustEnvPI.availEarlyReflections; + + if ( hAcoustEnvPI.availEarlyReflections ) + { + hRenderConfig->roomAcoustics.dimensions.x = hAcoustEnvPI.roomDimensions.x; + hRenderConfig->roomAcoustics.dimensions.y = hAcoustEnvPI.roomDimensions.y; + hRenderConfig->roomAcoustics.dimensions.z = hAcoustEnvPI.roomDimensions.z; + mvr2r( hAcoustEnvPI.absorbCoeffs, hRenderConfig->roomAcoustics.AbsCoeff, IVAS_ROOM_ABS_COEFF ); + } + + /* Re-initialize reverb instance if already available */ + + /* TD renderer Jot reverberator */ + if ( st_ivas->hReverb != NULL ) + { + if ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hHrtfStatistics, hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + /* CREND Jot reverberator */ + if ( st_ivas->hCrendWrapper != NULL && st_ivas->hCrendWrapper->hCrend[0] != NULL && st_ivas->hCrendWrapper->hCrend[0]->hReverb != NULL ) + { + if ( ( error = ivas_reverb_open( &st_ivas->hCrendWrapper->hCrend[0]->hReverb, st_ivas->hHrtfStatistics, hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + /* Parametric renderer reverberator */ + if ( st_ivas->hDiracDecBin[0] != NULL && st_ivas->hDiracDecBin[0]->hReverb != NULL ) + { + ivas_binaural_reverb_close( &( st_ivas->hDiracDecBin[0]->hReverb ) ); + + if ( ( error = ivas_binaural_reverb_init( &( st_ivas->hDiracDecBin[0]->hReverb ), st_ivas->hHrtfStatistics, st_ivas->hSpatParamRendCom->num_freq_bands, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, + &( hRenderConfig->roomAcoustics ), st_ivas->hDecoderConfig->output_Fs, NULL, NULL, NULL ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + /* FastConv renderer reverberator */ + if ( st_ivas->hBinRenderer != NULL && st_ivas->hBinRenderer->hReverb != NULL ) + { + ivas_binaural_reverb_close( &( st_ivas->hBinRenderer->hReverb ) ); + + if ( ( error = ivas_binaural_reverb_init( &( st_ivas->hBinRenderer->hReverb ), st_ivas->hHrtfStatistics, st_ivas->hBinRenderer->conv_band, st_ivas->hBinRenderer->timeSlots, + &( hRenderConfig->roomAcoustics ), st_ivas->hDecoderConfig->output_Fs, NULL, NULL, NULL ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + return IVAS_ERR_OK; +} + +#endif /*---------------------------------------------------------------------* * IVAS_DEC_GetDelay( ) @@ -5647,6 +5759,20 @@ ivas_error IVAS_RTP_ApplyPiData( IVAS_DEC_HANDLE hIvasDec, PIDATA_TS *piData, ui } break; +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT + case IVAS_PI_ACOUSTIC_ENVIRONMENT: + { + uint16_t aeid = piData->data.acousticEnv.aeid; + DEBUG_PRINT( stdout, "PI_ACOUSTIC_ENVIRONMENT : AEID : %d\n", aeid ); + + if ( piData->data.acousticEnv.availLateReverb && aeid != hIvasDec->st_ivas->hRenderConfig->roomAcoustics.aeID ) + { + error = IVAS_DEC_FeedAcousticEnvPI( hIvasDec, piData->data.acousticEnv ); + } + } + break; +#endif + #ifdef RTP_S4_251135_CR26253_0016_REV1 case IVAS_PI_DIEGETIC_TYPE: { diff --git a/lib_rend/ivas_render_config.c b/lib_rend/ivas_render_config.c index c3a39b426e..1ba683033a 100644 --- a/lib_rend/ivas_render_config.c +++ b/lib_rend/ivas_render_config.c @@ -112,6 +112,9 @@ ivas_error ivas_render_config_init_from_rom( #ifdef DEBUGGING ( *hRenderConfig )->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_NONE; +#endif +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT + ( *hRenderConfig )->roomAcoustics.aeID = IVAS_DEFAULT_AEID; #endif ( *hRenderConfig )->roomAcoustics.nBands = IVAS_REVERB_DEFAULT_N_BANDS; ( *hRenderConfig )->roomAcoustics.acousticPreDelay = IVAS_REVERB_DEFAULT_PRE_DELAY; diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index bba3fbb187..fbdc2ab505 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -4530,6 +4530,9 @@ ivas_error IVAS_REND_GetRenderConfig( hRCout->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_NONE; break; } +#endif +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT + hRCout->roomAcoustics.aeID = hRCin->roomAcoustics.aeID; #endif hRCout->roomAcoustics.nBands = hRCin->roomAcoustics.nBands; hRCout->roomAcoustics.acousticPreDelay = hRCin->roomAcoustics.acousticPreDelay; @@ -4586,6 +4589,9 @@ ivas_error IVAS_REND_FeedRenderConfig( hRenderConfig = hIvasRend->hRendererConfig; #ifdef DEBUGGING hRenderConfig->renderer_type_override = renderConfig.renderer_type_override; +#endif +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT + hRenderConfig->roomAcoustics.aeID = renderConfig.roomAcoustics.aeID; #endif hRenderConfig->roomAcoustics.nBands = renderConfig.roomAcoustics.nBands; hRenderConfig->roomAcoustics.acousticPreDelay = renderConfig.roomAcoustics.acousticPreDelay; diff --git a/lib_util/ivas_rtp_pi_data.c b/lib_util/ivas_rtp_pi_data.c index 7150cfe4a8..0100c833cc 100644 --- a/lib_util/ivas_rtp_pi_data.c +++ b/lib_util/ivas_rtp_pi_data.c @@ -296,6 +296,46 @@ static ivas_error unpackAcousticEnvironment( const uint8_t *buffer, uint32_t num } dWord <<= ( 8 - numDataBytes ) * 8; +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT + uint32_t offset = numDataBytes * 8; + aeEnv->aeid = (uint8_t) ( ( dWord >> ( offset - 7 ) ) & MASK_AEID ); + offset -= 7; + aeEnv->rt60[IVAS_PI_AE_LOW] = mapRT60[( dWord >> ( offset - 5 ) ) & MASK_RT60]; + offset -= 5; + aeEnv->dsr[IVAS_PI_AE_LOW] = mapDSR[( dWord >> ( offset - 6 ) ) & MASK_DSR]; + offset -= 6; + aeEnv->rt60[IVAS_PI_AE_MID] = mapRT60[( dWord >> ( offset - 5 ) ) & MASK_RT60]; + offset -= 5; + aeEnv->dsr[IVAS_PI_AE_MID] = mapDSR[( dWord >> ( offset - 6 ) ) & MASK_DSR]; + offset -= 6; + aeEnv->rt60[IVAS_PI_AE_HIGH] = mapRT60[( dWord >> ( offset - 5 ) ) & MASK_RT60]; + offset -= 5; + aeEnv->dsr[IVAS_PI_AE_HIGH] = mapDSR[( dWord >> ( offset - 6 ) ) & MASK_DSR]; + offset -= 6; + + if (aeEnv->availEarlyReflections) + { + aeEnv->roomDimensions.x = mapRoomDims[( dWord >> ( offset - 4 ) ) & MASK_DIM]; + offset -= 4; + aeEnv->roomDimensions.y = mapRoomDims[( dWord >> ( offset - 4 ) ) & MASK_DIM]; + offset -= 4; + aeEnv->roomDimensions.z = mapRoomDims[( dWord >> ( offset - 4 ) ) & MASK_DIM]; + offset -= 4; + + aeEnv->absorbCoeffs[IVAS_PI_AE_FRONT] = mapAbsorbtion[( dWord >> ( offset - 2 ) ) & MASK_ABS]; + offset -= 2; + aeEnv->absorbCoeffs[IVAS_PI_AE_BACK] = mapAbsorbtion[( dWord >> ( offset - 2 ) ) & MASK_ABS]; + offset -= 2; + aeEnv->absorbCoeffs[IVAS_PI_AE_LEFT] = mapAbsorbtion[( dWord >> ( offset - 2 ) ) & MASK_ABS]; + offset -= 2; + aeEnv->absorbCoeffs[IVAS_PI_AE_RIGHT] = mapAbsorbtion[( dWord >> ( offset - 2 ) ) & MASK_ABS]; + offset -= 2; + aeEnv->absorbCoeffs[IVAS_PI_AE_CEILING] = mapAbsorbtion[( dWord >> ( offset - 2 ) ) & MASK_ABS]; + offset -= 2; + aeEnv->absorbCoeffs[IVAS_PI_AE_FLOOR] = mapAbsorbtion[( dWord >> ( offset - 2 ) ) & MASK_ABS]; + offset -= 2; + } +#else aeEnv->aeid = (uint8_t) ( ( dWord >> 57 ) & MASK_AEID ); aeEnv->rt60[IVAS_PI_AE_LOW] = mapRT60[( dWord >> 52 ) & MASK_RT60]; aeEnv->dsr[IVAS_PI_AE_LOW] = mapDSR[( dWord >> 46 ) & MASK_DSR]; @@ -314,6 +354,7 @@ static ivas_error unpackAcousticEnvironment( const uint8_t *buffer, uint32_t num aeEnv->absorbCoeffs[IVAS_PI_AE_RIGHT] = mapAbsorbtion[( dWord >> 4 ) & MASK_ABS]; aeEnv->absorbCoeffs[IVAS_PI_AE_CEILING] = mapAbsorbtion[( dWord >> 2 ) & MASK_ABS]; aeEnv->absorbCoeffs[IVAS_PI_AE_FLOOR] = mapAbsorbtion[( dWord >> 0 ) & MASK_ABS]; +#endif } return IVAS_ERR_OK; diff --git a/lib_util/ivas_rtp_pi_data.h b/lib_util/ivas_rtp_pi_data.h index 3fc95f8d8d..3a7931125c 100644 --- a/lib_util/ivas_rtp_pi_data.h +++ b/lib_util/ivas_rtp_pi_data.h @@ -124,6 +124,15 @@ typedef enum IVAS_PI_AE_NUM_BANDS /* number of ae bands */ } IVAS_PI_AE_BANDS; +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT +typedef enum +{ + IVAS_PI_AE_LOW_FREQ = 25, + IVAS_PI_AE_MID_FREQ = 250, + IVAS_PI_AE_HIGH_FREQ = 2500 +} IVAS_PI_AE_BANDS_FREQ; +#endif + typedef enum { IVAS_PI_AE_FRONT, diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 7729efbc7c..3514a986b9 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -36,7 +36,9 @@ #include #include #include "cmdl_tools.h" - +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT +#include "ivas_cnst.h" +#endif /*------------------------------------------------------------------------------------------* * PreProc Local Macros @@ -2978,7 +2980,11 @@ ivas_error RenderConfigReader_getAcousticEnvironment( } /* case when -aeid is not specified, select first ID from config file */ +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT + if ( id == IVAS_DEFAULT_AEID && pRenderConfigReader->nAE > 0 ) +#else if ( id == 65535 && pRenderConfigReader->nAE > 0 ) +#endif { id = (uint16_t) pRenderConfigReader->pAE[0].id; } -- GitLab From 94592af34761036b2fe9710e6c4620b3bcf1fd42 Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Tue, 21 Oct 2025 08:30:03 +0200 Subject: [PATCH 2/8] Minor refactoring --- lib_util/ivas_rtp_pi_data.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/lib_util/ivas_rtp_pi_data.c b/lib_util/ivas_rtp_pi_data.c index 0100c833cc..409e713026 100644 --- a/lib_util/ivas_rtp_pi_data.c +++ b/lib_util/ivas_rtp_pi_data.c @@ -298,42 +298,42 @@ static ivas_error unpackAcousticEnvironment( const uint8_t *buffer, uint32_t num #ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT uint32_t offset = numDataBytes * 8; - aeEnv->aeid = (uint8_t) ( ( dWord >> ( offset - 7 ) ) & MASK_AEID ); offset -= 7; - aeEnv->rt60[IVAS_PI_AE_LOW] = mapRT60[( dWord >> ( offset - 5 ) ) & MASK_RT60]; + aeEnv->aeid = (uint8_t) ( ( dWord >> offset ) & MASK_AEID ); offset -= 5; - aeEnv->dsr[IVAS_PI_AE_LOW] = mapDSR[( dWord >> ( offset - 6 ) ) & MASK_DSR]; + aeEnv->rt60[IVAS_PI_AE_LOW] = mapRT60[( dWord >> offset ) & MASK_RT60]; offset -= 6; - aeEnv->rt60[IVAS_PI_AE_MID] = mapRT60[( dWord >> ( offset - 5 ) ) & MASK_RT60]; + aeEnv->dsr[IVAS_PI_AE_LOW] = mapDSR[( dWord >> offset ) & MASK_DSR]; offset -= 5; - aeEnv->dsr[IVAS_PI_AE_MID] = mapDSR[( dWord >> ( offset - 6 ) ) & MASK_DSR]; + aeEnv->rt60[IVAS_PI_AE_MID] = mapRT60[( dWord >> offset ) & MASK_RT60]; offset -= 6; - aeEnv->rt60[IVAS_PI_AE_HIGH] = mapRT60[( dWord >> ( offset - 5 ) ) & MASK_RT60]; + aeEnv->dsr[IVAS_PI_AE_MID] = mapDSR[( dWord >> offset ) & MASK_DSR]; offset -= 5; - aeEnv->dsr[IVAS_PI_AE_HIGH] = mapDSR[( dWord >> ( offset - 6 ) ) & MASK_DSR]; + aeEnv->rt60[IVAS_PI_AE_HIGH] = mapRT60[( dWord >> offset ) & MASK_RT60]; offset -= 6; + aeEnv->dsr[IVAS_PI_AE_HIGH] = mapDSR[( dWord >> offset ) & MASK_DSR]; if (aeEnv->availEarlyReflections) { - aeEnv->roomDimensions.x = mapRoomDims[( dWord >> ( offset - 4 ) ) & MASK_DIM]; offset -= 4; - aeEnv->roomDimensions.y = mapRoomDims[( dWord >> ( offset - 4 ) ) & MASK_DIM]; + aeEnv->roomDimensions.x = mapRoomDims[( dWord >> offset ) & MASK_DIM]; offset -= 4; - aeEnv->roomDimensions.z = mapRoomDims[( dWord >> ( offset - 4 ) ) & MASK_DIM]; + aeEnv->roomDimensions.y = mapRoomDims[( dWord >> offset ) & MASK_DIM]; offset -= 4; + aeEnv->roomDimensions.z = mapRoomDims[( dWord >> offset ) & MASK_DIM]; - aeEnv->absorbCoeffs[IVAS_PI_AE_FRONT] = mapAbsorbtion[( dWord >> ( offset - 2 ) ) & MASK_ABS]; offset -= 2; - aeEnv->absorbCoeffs[IVAS_PI_AE_BACK] = mapAbsorbtion[( dWord >> ( offset - 2 ) ) & MASK_ABS]; + aeEnv->absorbCoeffs[IVAS_PI_AE_FRONT] = mapAbsorbtion[( dWord >> offset ) & MASK_ABS]; offset -= 2; - aeEnv->absorbCoeffs[IVAS_PI_AE_LEFT] = mapAbsorbtion[( dWord >> ( offset - 2 ) ) & MASK_ABS]; + aeEnv->absorbCoeffs[IVAS_PI_AE_BACK] = mapAbsorbtion[( dWord >> offset ) & MASK_ABS]; offset -= 2; - aeEnv->absorbCoeffs[IVAS_PI_AE_RIGHT] = mapAbsorbtion[( dWord >> ( offset - 2 ) ) & MASK_ABS]; + aeEnv->absorbCoeffs[IVAS_PI_AE_LEFT] = mapAbsorbtion[( dWord >> offset ) & MASK_ABS]; offset -= 2; - aeEnv->absorbCoeffs[IVAS_PI_AE_CEILING] = mapAbsorbtion[( dWord >> ( offset - 2 ) ) & MASK_ABS]; + aeEnv->absorbCoeffs[IVAS_PI_AE_RIGHT] = mapAbsorbtion[( dWord >> offset ) & MASK_ABS]; offset -= 2; - aeEnv->absorbCoeffs[IVAS_PI_AE_FLOOR] = mapAbsorbtion[( dWord >> ( offset - 2 ) ) & MASK_ABS]; + aeEnv->absorbCoeffs[IVAS_PI_AE_CEILING] = mapAbsorbtion[( dWord >> offset ) & MASK_ABS]; offset -= 2; + aeEnv->absorbCoeffs[IVAS_PI_AE_FLOOR] = mapAbsorbtion[( dWord >> offset ) & MASK_ABS]; } #else aeEnv->aeid = (uint8_t) ( ( dWord >> 57 ) & MASK_AEID ); -- GitLab From b045cdd792f6e6f2f0cfe69faa1203ffdf58796c Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Tue, 21 Oct 2025 08:33:33 +0200 Subject: [PATCH 3/8] Minor refactoring --- lib_util/ivas_rtp_pi_data.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/lib_util/ivas_rtp_pi_data.c b/lib_util/ivas_rtp_pi_data.c index 409e713026..4c04a74ff7 100644 --- a/lib_util/ivas_rtp_pi_data.c +++ b/lib_util/ivas_rtp_pi_data.c @@ -298,41 +298,41 @@ static ivas_error unpackAcousticEnvironment( const uint8_t *buffer, uint32_t num #ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT uint32_t offset = numDataBytes * 8; - offset -= 7; + offset -= NBITS_AEID; aeEnv->aeid = (uint8_t) ( ( dWord >> offset ) & MASK_AEID ); - offset -= 5; + offset -= NBITS_RT60; aeEnv->rt60[IVAS_PI_AE_LOW] = mapRT60[( dWord >> offset ) & MASK_RT60]; - offset -= 6; + offset -= NBITS_DSR; aeEnv->dsr[IVAS_PI_AE_LOW] = mapDSR[( dWord >> offset ) & MASK_DSR]; - offset -= 5; + offset -= NBITS_RT60; aeEnv->rt60[IVAS_PI_AE_MID] = mapRT60[( dWord >> offset ) & MASK_RT60]; - offset -= 6; + offset -= NBITS_DSR; aeEnv->dsr[IVAS_PI_AE_MID] = mapDSR[( dWord >> offset ) & MASK_DSR]; - offset -= 5; + offset -= NBITS_RT60; aeEnv->rt60[IVAS_PI_AE_HIGH] = mapRT60[( dWord >> offset ) & MASK_RT60]; - offset -= 6; + offset -= NBITS_DSR; aeEnv->dsr[IVAS_PI_AE_HIGH] = mapDSR[( dWord >> offset ) & MASK_DSR]; if (aeEnv->availEarlyReflections) { - offset -= 4; + offset -= NBITS_DIM; aeEnv->roomDimensions.x = mapRoomDims[( dWord >> offset ) & MASK_DIM]; - offset -= 4; + offset -= NBITS_DIM; aeEnv->roomDimensions.y = mapRoomDims[( dWord >> offset ) & MASK_DIM]; - offset -= 4; + offset -= NBITS_DIM; aeEnv->roomDimensions.z = mapRoomDims[( dWord >> offset ) & MASK_DIM]; - offset -= 2; + offset -= NBITS_ABS; aeEnv->absorbCoeffs[IVAS_PI_AE_FRONT] = mapAbsorbtion[( dWord >> offset ) & MASK_ABS]; - offset -= 2; + offset -= NBITS_ABS; aeEnv->absorbCoeffs[IVAS_PI_AE_BACK] = mapAbsorbtion[( dWord >> offset ) & MASK_ABS]; - offset -= 2; + offset -= NBITS_ABS; aeEnv->absorbCoeffs[IVAS_PI_AE_LEFT] = mapAbsorbtion[( dWord >> offset ) & MASK_ABS]; - offset -= 2; + offset -= NBITS_ABS; aeEnv->absorbCoeffs[IVAS_PI_AE_RIGHT] = mapAbsorbtion[( dWord >> offset ) & MASK_ABS]; - offset -= 2; + offset -= NBITS_ABS; aeEnv->absorbCoeffs[IVAS_PI_AE_CEILING] = mapAbsorbtion[( dWord >> offset ) & MASK_ABS]; - offset -= 2; + offset -= NBITS_ABS; aeEnv->absorbCoeffs[IVAS_PI_AE_FLOOR] = mapAbsorbtion[( dWord >> offset ) & MASK_ABS]; } #else -- GitLab From 02346cc8ad3cec777ee7f086d2aa27c3cea5eeb4 Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Tue, 21 Oct 2025 10:22:17 +0200 Subject: [PATCH 4/8] IVAS_DEC_FeedAcousticEnvPI needs to be static --- lib_dec/lib_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 83578d5268..24c4077f6d 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -3406,7 +3406,7 @@ ivas_error IVAS_DEC_FeedRenderConfig( * Set acoustic environment from the PI data *---------------------------------------------------------------------*/ -ivas_error IVAS_DEC_FeedAcousticEnvPI( +static ivas_error IVAS_DEC_FeedAcousticEnvPI( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ const IVAS_PIDATA_ACOUSTIC_ENV hAcoustEnvPI /* i : Render configuration struct */ ) -- GitLab From cdf736e0f557c1c3143b101a873347aeb7537612 Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Tue, 21 Oct 2025 11:01:39 +0200 Subject: [PATCH 5/8] Fixes for acoustic environment ID data type handling --- lib_com/common_api_types.h | 2 +- lib_rend/ivas_render_config.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 15a87a1461..506b155ef5 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -313,7 +313,7 @@ typedef enum typedef struct _IVAS_ROOM_ACOUSTICS_CONFIG { #ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT - int16_t aeID; /* Acoustic environment ID*/ + uint16_t aeID; /* Acoustic environment ID*/ #endif int16_t nBands; /* Number of frequency bands for which reverb properties are provided, integer, range [2..256] */ float pFc_input[IVAS_CLDFB_NO_CHANNELS_MAX]; /* Center frequencies for which following values are provided: */ diff --git a/lib_rend/ivas_render_config.c b/lib_rend/ivas_render_config.c index 1ba683033a..63eaaf0227 100644 --- a/lib_rend/ivas_render_config.c +++ b/lib_rend/ivas_render_config.c @@ -114,7 +114,7 @@ ivas_error ivas_render_config_init_from_rom( ( *hRenderConfig )->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_NONE; #endif #ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT - ( *hRenderConfig )->roomAcoustics.aeID = IVAS_DEFAULT_AEID; + ( *hRenderConfig )->roomAcoustics.aeID = (uint16_t) IVAS_DEFAULT_AEID; #endif ( *hRenderConfig )->roomAcoustics.nBands = IVAS_REVERB_DEFAULT_N_BANDS; ( *hRenderConfig )->roomAcoustics.acousticPreDelay = IVAS_REVERB_DEFAULT_PRE_DELAY; -- GitLab From e1736a1949b22a3fab5d46055d8e5f1448078ac6 Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Thu, 30 Oct 2025 16:46:51 +0100 Subject: [PATCH 6/8] Removed unnecessary change within unpackAcousticEnvironment --- lib_util/ivas_rtp_pi_data.c | 41 ------------------------------------- 1 file changed, 41 deletions(-) diff --git a/lib_util/ivas_rtp_pi_data.c b/lib_util/ivas_rtp_pi_data.c index 7f04e1c5d0..8db9d41f9d 100644 --- a/lib_util/ivas_rtp_pi_data.c +++ b/lib_util/ivas_rtp_pi_data.c @@ -296,46 +296,6 @@ static ivas_error unpackAcousticEnvironment( const uint8_t *buffer, uint32_t num } dWord <<= ( 8 - numDataBytes ) * 8; -#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT - uint32_t offset = numDataBytes * 8; - offset -= NBITS_AEID; - aeEnv->aeid = (uint8_t) ( ( dWord >> offset ) & MASK_AEID ); - offset -= NBITS_RT60; - aeEnv->rt60[IVAS_PI_AE_LOW] = mapRT60[( dWord >> offset ) & MASK_RT60]; - offset -= NBITS_DSR; - aeEnv->dsr[IVAS_PI_AE_LOW] = mapDSR[( dWord >> offset ) & MASK_DSR]; - offset -= NBITS_RT60; - aeEnv->rt60[IVAS_PI_AE_MID] = mapRT60[( dWord >> offset ) & MASK_RT60]; - offset -= NBITS_DSR; - aeEnv->dsr[IVAS_PI_AE_MID] = mapDSR[( dWord >> offset ) & MASK_DSR]; - offset -= NBITS_RT60; - aeEnv->rt60[IVAS_PI_AE_HIGH] = mapRT60[( dWord >> offset ) & MASK_RT60]; - offset -= NBITS_DSR; - aeEnv->dsr[IVAS_PI_AE_HIGH] = mapDSR[( dWord >> offset ) & MASK_DSR]; - - if (aeEnv->availEarlyReflections) - { - offset -= NBITS_DIM; - aeEnv->roomDimensions.x = mapRoomDims[( dWord >> offset ) & MASK_DIM]; - offset -= NBITS_DIM; - aeEnv->roomDimensions.y = mapRoomDims[( dWord >> offset ) & MASK_DIM]; - offset -= NBITS_DIM; - aeEnv->roomDimensions.z = mapRoomDims[( dWord >> offset ) & MASK_DIM]; - - offset -= NBITS_ABS; - aeEnv->absorbCoeffs[IVAS_PI_AE_FRONT] = mapAbsorbtion[( dWord >> offset ) & MASK_ABS]; - offset -= NBITS_ABS; - aeEnv->absorbCoeffs[IVAS_PI_AE_BACK] = mapAbsorbtion[( dWord >> offset ) & MASK_ABS]; - offset -= NBITS_ABS; - aeEnv->absorbCoeffs[IVAS_PI_AE_LEFT] = mapAbsorbtion[( dWord >> offset ) & MASK_ABS]; - offset -= NBITS_ABS; - aeEnv->absorbCoeffs[IVAS_PI_AE_RIGHT] = mapAbsorbtion[( dWord >> offset ) & MASK_ABS]; - offset -= NBITS_ABS; - aeEnv->absorbCoeffs[IVAS_PI_AE_CEILING] = mapAbsorbtion[( dWord >> offset ) & MASK_ABS]; - offset -= NBITS_ABS; - aeEnv->absorbCoeffs[IVAS_PI_AE_FLOOR] = mapAbsorbtion[( dWord >> offset ) & MASK_ABS]; - } -#else aeEnv->aeid = (uint8_t) ( ( dWord >> 57 ) & MASK_AEID ); aeEnv->rt60[IVAS_PI_AE_LOW] = mapRT60[( dWord >> 52 ) & MASK_RT60]; aeEnv->dsr[IVAS_PI_AE_LOW] = mapDSR[( dWord >> 46 ) & MASK_DSR]; @@ -354,7 +314,6 @@ static ivas_error unpackAcousticEnvironment( const uint8_t *buffer, uint32_t num aeEnv->absorbCoeffs[IVAS_PI_AE_RIGHT] = mapAbsorbtion[( dWord >> 4 ) & MASK_ABS]; aeEnv->absorbCoeffs[IVAS_PI_AE_CEILING] = mapAbsorbtion[( dWord >> 2 ) & MASK_ABS]; aeEnv->absorbCoeffs[IVAS_PI_AE_FLOOR] = mapAbsorbtion[( dWord >> 0 ) & MASK_ABS]; -#endif } return IVAS_ERR_OK; -- GitLab From 1468ce62608741f5ad98f7974713f5c674e3dce5 Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Thu, 30 Oct 2025 17:21:57 +0100 Subject: [PATCH 7/8] Updated RTP tests for acoustic environment (prototype) --- tests/rtp/test_rtp.py | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/tests/rtp/test_rtp.py b/tests/rtp/test_rtp.py index 44d08a91e1..fbf7be9fcb 100644 --- a/tests/rtp/test_rtp.py +++ b/tests/rtp/test_rtp.py @@ -228,6 +228,23 @@ def generatePiData(startTs: int, endTs: int) -> dict: someAuFocusLvl = lambda: AUDIO_FOCUS(level=AUDIO_FOCUS_LEVEL(random.randint(0, 15))) someAuFocusList = [someAuFocusDirLvl, someAuFocusDir, someAuFocusLvl] + someAcousticEnvAEID = lambda: ACOUSTIC_ENVIRONMENT( + aeid=random.randint(0, 127) + ) + someAcousticEnvLR = lambda: ACOUSTIC_ENVIRONMENT( + aeid=random.randint(0, 127), + rt60=[random.randint(0, len(rt60Value)) for _ in range(3)], + dsr=[random.randint(0, len(dsrValue)) for _ in range(3)], + ) + someAcousticEnvERLR = lambda: ACOUSTIC_ENVIRONMENT( + aeid=random.randint(0, 127), + rt60=[random.randint(0, len(rt60Value)) for _ in range(3)], + dsr=[random.randint(0, len(dsrValue)) for _ in range(3)], + dim=[random.randint(0, len(roomDimensionValue)) for _ in range(3)], + abscoeff=[random.randint(0, len(absorptionCoeffValues)) for _ in range(6)], + ) + someAcousticEnvList = [someAcousticEnvAEID, someAcousticEnvLR, someAcousticEnvERLR] + for ts in range(startTs, endTs, 320): pidata = dict() pidata["SCENE_ORIENTATION"] = someOrientation() @@ -240,9 +257,7 @@ def generatePiData(startTs: int, endTs: int) -> dict: pidata["DYNAMIC_AUDIO_SUPPRESSION_REQUEST"] = someDAS() pidata["AUDIO_DESCRIPTION"] = [someDesc() for n in range(random.randint(1, 5))] pidata["DIEGETIC_TYPE"] = someDIG() - pidata["ACOUSTIC_ENVIRONMENT"] = ACOUSTIC_ENVIRONMENT( - aeid=random.randint(0, 127) - ) + pidata["ACOUSTIC_ENVIRONMENT"] = random.choice(someAcousticEnvList)() data[str(ts)] = pidata return data @@ -312,6 +327,12 @@ def isEqualAcousticEnv(ref: ACOUSTIC_ENVIRONMENT, dut: ACOUSTIC_ENVIRONMENT): ), "Acoustic Env PI Data mismatch in len(abscoeff)" for r, d in zip(ref.rt60, dut.rt60): assert r == d, f"Acoustic Env PI Data mismatch in rt60 {r} != {d}" + for r, d in zip(ref.dsr, dut.dsr): + assert r == d, f"Acoustic Env PI Data mismatch in dsr {r} != {d}" + for r, d in zip(ref.dim, dut.dim): + assert r == d, f"Acoustic Env PI Data mismatch in dim {r} != {d}" + for r, d in zip(ref.abscoeff, dut.abscoeff): + assert r == d, f"Acoustic Env PI Data mismatch in abscoeff {r} != {d}" def isEqualAudioFocus(ref: AUDIO_FOCUS, dut: AUDIO_FOCUS): -- GitLab From 5961558073ae814a85fcec8fcc0308accaaa3ce8 Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Thu, 30 Oct 2025 17:24:52 +0100 Subject: [PATCH 8/8] Updated debugging logging --- lib_dec/lib_dec.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index fcf3d69d82..d34a000f7d 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -5761,7 +5761,9 @@ ivas_error IVAS_RTP_FeedPiDataToDecoder( IVAS_DEC_HANDLE hIvasDec, PIDATA_TS *pi case IVAS_PI_ACOUSTIC_ENVIRONMENT: { uint16_t aeid = piData->data.acousticEnv.aeid; - DEBUG_PRINT( stdout, "PI_ACOUSTIC_ENVIRONMENT : AEID : %d\n", aeid ); +#ifdef DEBUGGING + fprintf( stdout, "PI_ACOUSTIC_ENVIRONMENT : AEID : %d\n", aeid ); +#endif if ( piData->data.acousticEnv.availLateReverb && aeid != hIvasDec->st_ivas->hRenderConfig->roomAcoustics.aeID ) { -- GitLab