From a595598469ba1b5dc3fd4d50cb032333e9607249 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Thu, 16 Apr 2026 10:30:14 +0200 Subject: [PATCH 1/3] Add FIX_BASOP_2023_TDREND_DISTATT_PRECISION for synching with range-checks implemented in BASOP --- lib_com/options.h | 3 ++- lib_rend/ivas_objectRenderer_hrFilt.c | 2 ++ lib_util/render_config_reader.c | 15 +++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index c5197b92a..37d1e4cfe 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -48,7 +48,7 @@ /* ################### Start DEBUGGING switches ########################### */ #ifndef RELEASE -/*#define DEBUGGING*/ /* Activate debugging part of the code */ +#define DEBUGGING /* Activate debugging part of the code */ #endif /*#define WMOPS*/ /* Activate complexity and memory counters */ /*#define WMOPS_PER_FRAME*/ /* Output per-frame complexity (writes one float value per frame to the file "wmops_analysis") */ @@ -178,6 +178,7 @@ #define FIX_1540_EXPOSE_PT_IN_RTP_HEADER_API /* Expose Payload Type setting in RTP Header */ #define FIX_1563_FIX_STEREO_SW /* VA: float issue 1563: fix clicks in stereo switching */ #define FIX_1562_DTX_CRASH_DECODER /* VA: float issue 1562: fix crash in stereo decoding in DTX and bitrate switching */ +#define FIX_BASOP_2023_TDREND_DISTATT_PRECISION /* Eri: Distance attenuation scaling */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_rend/ivas_objectRenderer_hrFilt.c b/lib_rend/ivas_objectRenderer_hrFilt.c index 411c3d11b..fd360c2f9 100644 --- a/lib_rend/ivas_objectRenderer_hrFilt.c +++ b/lib_rend/ivas_objectRenderer_hrFilt.c @@ -70,6 +70,8 @@ ivas_error TDREND_REND_RenderSourceHRFilt( float LeftOutputFrame[L_SPATIAL_SUBFR_48k]; float RightOutputFrame[L_SPATIAL_SUBFR_48k]; + dbgwrite( &Src_p->Gain, sizeof( float ), 1, 1, "Gain.float" ); + TDREND_Apply_ITD( Src_p->InputFrame_p, LeftOutputFrame, RightOutputFrame, &Src_p->previtd, Src_p->itd, Src_p->mem_itd, subframe_length ); TDREND_firfilt( LeftOutputFrame, Src_p->hrf_left_prev, hrf_left_delta, intp_count, Src_p->mem_hrf_left, subframe_length, Src_p->filterlength, Src_p->Gain, Src_p->prevGain ); TDREND_firfilt( RightOutputFrame, Src_p->hrf_right_prev, hrf_right_delta, intp_count, Src_p->mem_hrf_right, subframe_length, Src_p->filterlength, Src_p->Gain, Src_p->prevGain ); diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 41d3e1044..789c0358a 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -71,6 +71,12 @@ #define IVAS_ER_LIST_ORIGIN_X 0.0f #define IVAS_ER_LIST_ORIGIN_Y 0.0f +#ifdef FIX_BASOP_2023_TDREND_DISTATT_PRECISION +#define DIST_ATT_MAX_MAXDIST 63.0f +#define DIST_ATT_MAX_REFDIST 6.3f +#define DIST_ATT_MAX_ROLLOFF 4.0f +#endif + #ifndef TRUE #define TRUE 1 #endif @@ -1331,11 +1337,20 @@ ivas_error RenderConfigReader_checkValues( } } +#ifdef FIX_BASOP_2023_TDREND_DISTATT_PRECISION + /* Verify range of distance attenuation parameters: refDist: 0.0 <= distAtt[1] <= 6.3 */ + /* maxDist: distAtt[1] <= distAtt[0] <= 63.0 */ + /* rollOffFactor: 0 <= distAtt[2] <= 4.0 */ + hRenderConfig->distAtt[1] = min( max( 0, hRenderConfig->distAtt[1] ), DIST_ATT_MAX_REFDIST ); + hRenderConfig->distAtt[0] = min( max( hRenderConfig->distAtt[1], hRenderConfig->distAtt[0] ), DIST_ATT_MAX_MAXDIST ); + hRenderConfig->distAtt[2] = min( max( 0.0f, hRenderConfig->distAtt[2] ), DIST_ATT_MAX_ROLLOFF ); +#else /* Verify range of distance attenuation parameters: 0.1 <= distAtt[0] <= distAtt[1] */ /* 0.0 <= distAtt[2] <= 10.0 */ hRenderConfig->distAtt[0] = max( 0.1f, hRenderConfig->distAtt[0] ); hRenderConfig->distAtt[1] = max( hRenderConfig->distAtt[0], hRenderConfig->distAtt[1] ); hRenderConfig->distAtt[2] = max( 0.0f, min( 10.0f, hRenderConfig->distAtt[2] ) ); +#endif /* Verify range of directivity patterns */ for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; i++ ) -- GitLab From 39607ce70cf898151f50392c11ae52c5064aa991 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Thu, 16 Apr 2026 19:17:19 +0200 Subject: [PATCH 2/3] Fix clamping of listener position input to synch with BASOP --- lib_com/common_api_types.h | 4 ++++ lib_com/options.h | 4 ++-- lib_dec/lib_dec.c | 6 ++++++ lib_rend/ivas_objectRenderer_hrFilt.c | 2 -- lib_util/rotation_file_reader.c | 6 ++++++ 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 4e1d09560..1e88b7fd5 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -61,6 +61,10 @@ #define IVAS_REVERB_PREDELAY_MAX 20 /* Max input delay for reverb module */ #define IVAS_ER_LIST_HEIGHT 1.6f #define IVAS_DEFAULT_AEID 65535 +#ifdef FIX_BASOP_2023_TDREND_DISTATT_PRECISION +#define IVAS_LISTENER_POSITION_MAX 327.67f +#endif + /* JBM constants for adaptive-playout */ #define IVAS_TIME_SCALE_MIN 50 /* min. time-scaling [%] */ diff --git a/lib_com/options.h b/lib_com/options.h index 37d1e4cfe..db04ba0ce 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -48,7 +48,7 @@ /* ################### Start DEBUGGING switches ########################### */ #ifndef RELEASE -#define DEBUGGING /* Activate debugging part of the code */ +/*#define DEBUGGING*/ /* Activate debugging part of the code */ #endif /*#define WMOPS*/ /* Activate complexity and memory counters */ /*#define WMOPS_PER_FRAME*/ /* Output per-frame complexity (writes one float value per frame to the file "wmops_analysis") */ @@ -178,7 +178,7 @@ #define FIX_1540_EXPOSE_PT_IN_RTP_HEADER_API /* Expose Payload Type setting in RTP Header */ #define FIX_1563_FIX_STEREO_SW /* VA: float issue 1563: fix clicks in stereo switching */ #define FIX_1562_DTX_CRASH_DECODER /* VA: float issue 1562: fix crash in stereo decoding in DTX and bitrate switching */ -#define FIX_BASOP_2023_TDREND_DISTATT_PRECISION /* Eri: Distance attenuation scaling */ +#define FIX_BASOP_2023_TDREND_DISTATT_PRECISION /* Eri: Basop issue 2023: Distance attenuation scaling, synch with BASOP updates and adding clamping of distance att input and listener position */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 0afec7310..0a5981315 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -2601,9 +2601,15 @@ ivas_error IVAS_DEC_FeedHeadTrackData( return error; } +#ifdef FIX_BASOP_2023_TDREND_DISTATT_PRECISION + hHeadTrackData->Pos[subframe_idx].x = max( min( IVAS_LISTENER_POSITION_MAX, Pos.x ), -IVAS_LISTENER_POSITION_MAX ); + hHeadTrackData->Pos[subframe_idx].y = max( min( IVAS_LISTENER_POSITION_MAX, Pos.y ), -IVAS_LISTENER_POSITION_MAX ); + hHeadTrackData->Pos[subframe_idx].z = max( min( IVAS_LISTENER_POSITION_MAX, Pos.z ), -IVAS_LISTENER_POSITION_MAX ); +#else hHeadTrackData->Pos[subframe_idx].x = Pos.x; hHeadTrackData->Pos[subframe_idx].y = Pos.y; hHeadTrackData->Pos[subframe_idx].z = Pos.z; +#endif hHeadTrackData->sr_pose_pred_axis = rot_axis; hIvasDec->updateOrientation = true; diff --git a/lib_rend/ivas_objectRenderer_hrFilt.c b/lib_rend/ivas_objectRenderer_hrFilt.c index fd360c2f9..411c3d11b 100644 --- a/lib_rend/ivas_objectRenderer_hrFilt.c +++ b/lib_rend/ivas_objectRenderer_hrFilt.c @@ -70,8 +70,6 @@ ivas_error TDREND_REND_RenderSourceHRFilt( float LeftOutputFrame[L_SPATIAL_SUBFR_48k]; float RightOutputFrame[L_SPATIAL_SUBFR_48k]; - dbgwrite( &Src_p->Gain, sizeof( float ), 1, 1, "Gain.float" ); - TDREND_Apply_ITD( Src_p->InputFrame_p, LeftOutputFrame, RightOutputFrame, &Src_p->previtd, Src_p->itd, Src_p->mem_itd, subframe_length ); TDREND_firfilt( LeftOutputFrame, Src_p->hrf_left_prev, hrf_left_delta, intp_count, Src_p->mem_hrf_left, subframe_length, Src_p->filterlength, Src_p->Gain, Src_p->prevGain ); TDREND_firfilt( RightOutputFrame, Src_p->hrf_right_prev, hrf_right_delta, intp_count, Src_p->mem_hrf_right, subframe_length, Src_p->filterlength, Src_p->Gain, Src_p->prevGain ); diff --git a/lib_util/rotation_file_reader.c b/lib_util/rotation_file_reader.c index 68f43bc8a..d564f6a6c 100644 --- a/lib_util/rotation_file_reader.c +++ b/lib_util/rotation_file_reader.c @@ -125,9 +125,15 @@ ivas_error HeadRotationFileReading( pQuaternion->z = z; if ( pPos != NULL ) { +#ifdef FIX_BASOP_2023_TDREND_DISTATT_PRECISION + pPos->x = min( max( -IVAS_LISTENER_POSITION_MAX, posx ), IVAS_LISTENER_POSITION_MAX ); + pPos->y = min( max( -IVAS_LISTENER_POSITION_MAX, posy ), IVAS_LISTENER_POSITION_MAX ); + pPos->z = min( max( -IVAS_LISTENER_POSITION_MAX, posz ), IVAS_LISTENER_POSITION_MAX ); +#else pPos->x = posx; pPos->y = posy; pPos->z = posz; +#endif } return IVAS_ERR_OK; -- GitLab From f1e9c99ff106eae340cafd1117708017226dc2d0 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Fri, 17 Apr 2026 07:54:30 +0200 Subject: [PATCH 3/3] Add definitions of max/min when stdlib.h is not present --- lib_dec/lib_dec.c | 8 ++++++++ lib_util/rotation_file_reader.c | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 0a5981315..8b111588b 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -49,6 +49,14 @@ #endif #include "wmc_auto.h" +#ifndef min +#define min( x, y ) ( ( x ) < ( y ) ? ( x ) : ( y ) ) +#endif + +#ifndef max +#define max( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) ) +#endif + /*---------------------------------------------------------------------* * Local structs *---------------------------------------------------------------------*/ diff --git a/lib_util/rotation_file_reader.c b/lib_util/rotation_file_reader.c index d564f6a6c..24d0acaff 100644 --- a/lib_util/rotation_file_reader.c +++ b/lib_util/rotation_file_reader.c @@ -35,6 +35,16 @@ #include #include +#ifdef FIX_BASOP_2023_TDREND_DISTATT_PRECISION +#ifndef min +#define min( x, y ) ( ( x ) < ( y ) ? ( x ) : ( y ) ) +#endif + +#ifndef max +#define max( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) ) +#endif +#endif + struct RotFileReader { -- GitLab