From fdf9aff2b523706c6af316d3e5c2a2a86126caf2 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Fri, 23 Aug 2024 14:00:20 +0200 Subject: [PATCH] [fix] prevent divide by zero in GenerateFilter() --- lib_com/options.h | 1 + lib_rend/ivas_objectRenderer_hrFilt.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 68dbb25b4e..e57b3b1bf2 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -176,6 +176,7 @@ #define FIX_1129_EXT_REND_OUTPUT_HIGH /* Philips: issue 1129: External renderer BINAURAL_ROOM_REVERB format output level too high compared to internal rendering output */ #define FIX_1135_EXT_RENDERER_HANDLES /* VA: issue 1135: Memory usage reduction in external renderer: Allocate only handles that are really needed. */ #define FIX_1159_SPLIT_RENDERING_CONFIG /* VA: issue 1159: Execute split rendering config only for split rendering outputs. */ +#define FIX_1166_TDREND_DIV0 /* FhG,Eri: issue 1166: potential divide by zero in TD Renderer */ /* #################### End BE switches ################################## */ diff --git a/lib_rend/ivas_objectRenderer_hrFilt.c b/lib_rend/ivas_objectRenderer_hrFilt.c index 456dbc640c..56cb50b440 100644 --- a/lib_rend/ivas_objectRenderer_hrFilt.c +++ b/lib_rend/ivas_objectRenderer_hrFilt.c @@ -218,8 +218,13 @@ static void GenerateFilter( ESynL += modelEval->BMEnergiesL[modelEval->UseIndsL[i]].val; ESynR += modelEval->BMEnergiesR[modelEval->UseIndsR[i]].val; } +#ifdef FIX_1166_TDREND_DIV0 + ScaleL = sqrtf( ETotL / ( ESynL + EPSILON ) ); + ScaleR = sqrtf( ETotR / ( ESynR + EPSILON ) ); +#else ScaleL = sqrtf( ETotL / ESynL ); ScaleR = sqrtf( ETotR / ESynR ); +#endif /* Build using only the most energetic components. */ for ( k = model->iSecFirst[iSec]; k <= model->iSecLast[iSec]; k++ ) -- GitLab