From 9e197c3ac7cb4105fd45faa23947710795f138dd Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 7 May 2025 10:38:14 +0200 Subject: [PATCH] port NONBE_FIX_1000_G1_G2_SWB_TBE --- lib_com/options.h | 1 + lib_com/swb_tbe_com.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 2d952edea..fb5978aa0 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -188,6 +188,7 @@ #define NONBE_FIX_968_ISM_BRIR_WITH_HEADROTATION_5MS_FIX /* FhG : issue #968: differences between 5ms and 20ms rendering for discrete ISM with BRIR and head rotation*/ #define FIX_969_USAN_IGF_ARITH /* FhG: issue 969: fix USAN error in igf_sce_dec; same issue as #962 */ #define FIX_959_MASA_LINEAR_REND /* VA: issue 959: remove unused calling of ivas_sba_linear_renderer() in MASA rendering */ +#define NONBE_FIX_1000_G1_G2_SWB_TBE /* VA: issue 1000: avoid div by zero due to g1 + g2 being zero in SWB TBE */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_com/swb_tbe_com.c b/lib_com/swb_tbe_com.c index 13541d7c3..f10a8e152 100644 --- a/lib_com/swb_tbe_com.c +++ b/lib_com/swb_tbe_com.c @@ -938,6 +938,14 @@ void GenShapedSHBExcitation( } den = 4.0f * c0 * c2 - c4 * c4; + +#ifdef NONBE_FIX_1000_G1_G2_SWB_TBE + if ( den == 0.0f ) + { + den = 1e-7f; + } +#endif + g1 = ( c3 * c4 - 2 * c1 * c2 ) / den; g2 = ( c1 * c4 - 2 * c0 * c3 ) / den; @@ -964,7 +972,17 @@ void GenShapedSHBExcitation( else { /* normalize gain */ +#ifdef NONBE_FIX_1000_G1_G2_SWB_TBE + temp = 0.0f; + if ( g1 + g2 == 0.0f ) + { + temp = 1e-7f; + } + + g = g2 / ( g1 + g2 + temp ); +#else g = g2 / ( g1 + g2 ); +#endif /* quantization of the mixing factor */ cbsize = 1 << NUM_BITS_SHB_VF; -- GitLab