From 5bc4034f7728c330241053945525e4bbc4f20665 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Fri, 10 Oct 2025 14:35:06 +0200 Subject: [PATCH 1/3] Add NONBE_1300_TDREND_LARGE_ITD to port MR2070 --- lib_com/options.h | 1 + lib_rend/ivas_objectRenderer_fx.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index c941842df..2c50e92a4 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -151,6 +151,7 @@ #define FIX_1387_INIT_PRM_SQQ /* FhG: initialize pointer prm_sqQ, which might be uninitialized in case of bfi == 1 */ #define NONBE_1296_TDREND_ITD_OUT_OF_BOUNDS_ACCESS /* Eri: issue 1296: ITD resampling can occasionally read out of bounds, especially when the requested subframes are short (1.25 ms). Seen for headtracking+JBM. */ #define FIX_1349_TNS_CRASH /* FhG: Fix crash in TNS entropy coding, in case order of joint TNS coding is reduced to 0 */ +#define NONBE_1300_TDREND_LARGE_ITD /* Eri: issue 1300: There was a bug feeding 1.25 ms frames to the TD renderer, causing out-of-buffer access. This was resolved. However, it is still possible that modeled HRTF with large ITDs could trigger out-of-buffer access. This adds a check to prevent this.*/ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_rend/ivas_objectRenderer_fx.c b/lib_rend/ivas_objectRenderer_fx.c index 024f5b6ac..c8839b43a 100644 --- a/lib_rend/ivas_objectRenderer_fx.c +++ b/lib_rend/ivas_objectRenderer_fx.c @@ -508,6 +508,10 @@ ivas_error TDREND_GetMix_fx( Word32 hrf_left_delta[SFX_SPAT_BIN_MAX_FILTER_LENGTH]; Word32 hrf_right_delta[SFX_SPAT_BIN_MAX_FILTER_LENGTH]; Word16 intp_count; +#ifdef NONBE_1300_TDREND_LARGE_ITD + Word16 currShift, prevShift, transition_len, length_in2; + Word16 tmp1, tmp2, tmp_e, tmp3, tmp4, tmp_e2, tlen1, tlen2; +#endif Word16 hrf_left_delta_e = 0, hrf_right_delta_e = 0; move16(); @@ -544,6 +548,31 @@ ivas_error TDREND_GetMix_fx( &intp_count, &Src_p->filterlength, &Src_p->itd, &Src_p->Gain_fx, Src_p ); +#ifdef NONBE_1300_TDREND_LARGE_ITD + /* For large ITD values at lower sampling rate, check if the transition can be done */ + IF( i_mult( Src_p->previtd, Src_p->itd ) < 0 ) + { + currShift = abs_s( Src_p->itd ); // Q0 + prevShift = abs_s( Src_p->previtd ); + transition_len = subframe_length - max( 0, SFX_SPAT_BIN_SINC_M - currShift ); + tmp1 = imult1616( transition_len, prevShift ); // Q0 + tmp2 = add( prevShift, currShift ); // Q0 + tmp3 = BASOP_Util_Divide1616_Scale( tmp1, tmp2, &tmp_e ); // exp(tmp_e) + tmp_e2 = BASOP_Util_Add_MantExp( tmp3, tmp_e, ONE_IN_Q14, 0, &tmp4 ); // exp(tmp4) + tmp4 = shr( tmp4, sub( 15, tmp_e2 ) ); // Q0 + tlen1 = tmp4; // Q0 + move16(); + tlen2 = sub( transition_len, tlen1 ); // Q0 + length_in2 = sub( tlen2, currShift ); // Q0 + + IF( LE_16( length_in2, 0 ) ) + { + /* Subframe too short for ITD transition -- change to ITD=0 and push the rest of the transition to next subframe */ + Src_p->itd = 0; + move16(); + } + } +#endif } /* Render source if needed */ -- GitLab From c74a66efa16a047466364086e1e82a2ce3027407 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20Toftg=C3=A5rd?= Date: Wed, 15 Oct 2025 13:42:16 +0200 Subject: [PATCH 2/3] Use LT_16 for if statement Add missing BASOP for transition_length Unify comment on exponent Remove unnecessary move16() --- lib_rend/ivas_objectRenderer_fx.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib_rend/ivas_objectRenderer_fx.c b/lib_rend/ivas_objectRenderer_fx.c index c8839b43a..822010116 100644 --- a/lib_rend/ivas_objectRenderer_fx.c +++ b/lib_rend/ivas_objectRenderer_fx.c @@ -550,18 +550,16 @@ ivas_error TDREND_GetMix_fx( Src_p ); #ifdef NONBE_1300_TDREND_LARGE_ITD /* For large ITD values at lower sampling rate, check if the transition can be done */ - IF( i_mult( Src_p->previtd, Src_p->itd ) < 0 ) + IF( LT_16( i_mult( Src_p->previtd, Src_p->itd ), 0 ) ) { currShift = abs_s( Src_p->itd ); // Q0 prevShift = abs_s( Src_p->previtd ); - transition_len = subframe_length - max( 0, SFX_SPAT_BIN_SINC_M - currShift ); + transition_len = sub( subframe_length, s_max( 0, sub(SFX_SPAT_BIN_SINC_M, currShift) ) ); tmp1 = imult1616( transition_len, prevShift ); // Q0 tmp2 = add( prevShift, currShift ); // Q0 tmp3 = BASOP_Util_Divide1616_Scale( tmp1, tmp2, &tmp_e ); // exp(tmp_e) - tmp_e2 = BASOP_Util_Add_MantExp( tmp3, tmp_e, ONE_IN_Q14, 0, &tmp4 ); // exp(tmp4) - tmp4 = shr( tmp4, sub( 15, tmp_e2 ) ); // Q0 - tlen1 = tmp4; // Q0 - move16(); + tmp_e2 = BASOP_Util_Add_MantExp( tmp3, tmp_e, ONE_IN_Q14, 0, &tmp4 ); // exp(tmp_e2) + tlen1 = shr( tmp4, sub( 15, tmp_e2 ) ); // Q0 tlen2 = sub( transition_len, tlen1 ); // Q0 length_in2 = sub( tlen2, currShift ); // Q0 -- GitLab From 1f6a041cd0bfe7b493ac509fd21c3f801df4ef01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20Toftg=C3=A5rd?= Date: Wed, 15 Oct 2025 14:09:41 +0200 Subject: [PATCH 3/3] Apply formatting --- lib_rend/ivas_objectRenderer_fx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_rend/ivas_objectRenderer_fx.c b/lib_rend/ivas_objectRenderer_fx.c index 59de0a2c7..381992ee6 100644 --- a/lib_rend/ivas_objectRenderer_fx.c +++ b/lib_rend/ivas_objectRenderer_fx.c @@ -554,14 +554,14 @@ ivas_error TDREND_GetMix_fx( { currShift = abs_s( Src_p->itd ); // Q0 prevShift = abs_s( Src_p->previtd ); - transition_len = sub( subframe_length, s_max( 0, sub(SFX_SPAT_BIN_SINC_M, currShift) ) ); + transition_len = sub( subframe_length, s_max( 0, sub( SFX_SPAT_BIN_SINC_M, currShift ) ) ); tmp1 = imult1616( transition_len, prevShift ); // Q0 tmp2 = add( prevShift, currShift ); // Q0 tmp3 = BASOP_Util_Divide1616_Scale( tmp1, tmp2, &tmp_e ); // exp(tmp_e) tmp_e2 = BASOP_Util_Add_MantExp( tmp3, tmp_e, ONE_IN_Q14, 0, &tmp4 ); // exp(tmp_e2) tlen1 = shr( tmp4, sub( 15, tmp_e2 ) ); // Q0 - tlen2 = sub( transition_len, tlen1 ); // Q0 - length_in2 = sub( tlen2, currShift ); // Q0 + tlen2 = sub( transition_len, tlen1 ); // Q0 + length_in2 = sub( tlen2, currShift ); // Q0 IF( LE_16( length_in2, 0 ) ) { -- GitLab