From dcfcedfbff71d625d57d32b30e8f03e2e104241e Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Mon, 26 Jun 2023 15:39:21 +0200 Subject: [PATCH] Add fix FIX_569_TD_FILTER_LENGTH to truncate the filters if a model file produces filters longer than SFX_SPAT_BIN_MAX_FILTER_LENGTH --- lib_com/options.h | 1 + lib_rend/ivas_objectRenderer_hrFilt.c | 14 +++++++++++--- lib_rend/ivas_objectRenderer_sources.c | 8 ++++++++ lib_rend/ivas_prot_rend.h | 3 +++ 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index dbe71e39f1..c6e8cc0002 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -158,6 +158,7 @@ #define FIX_UNCLR_ISSUE /* VoiceAge: issue 574: Fix UNCLR mis-classifications in noisy speech stereo */ #define FIX_TCX_LOWRATE_LIMITATION /* VA: issue 577: TCX bitrate limitation only when DEBUGGING is active */ #define FIX_575_LOW_OVERLAP_PLC_RECOVERY /* FhG: Issue 575 fix for PLC and transistion to TCX5*/ +#define FIX_569_TD_FILTER_LENGTH /* Eri: Issue 569: If an HRTF binary file exceeds the SFX_SPAT_BIN_MAX_FILTER_LENGTH the decoder crashes. This truncates the filter when generated from the model. */ /* ################## End DEVELOPMENT switches ######################### */ diff --git a/lib_rend/ivas_objectRenderer_hrFilt.c b/lib_rend/ivas_objectRenderer_hrFilt.c index 6463261ec4..0df5df6fcd 100644 --- a/lib_rend/ivas_objectRenderer_hrFilt.c +++ b/lib_rend/ivas_objectRenderer_hrFilt.c @@ -97,16 +97,24 @@ void GetFilterFromAngle( TDREND_HRFILT_FiltSet_t *HrFiltSet_p, /* i/o: HR filter set structure */ const float Elev, /* i : Elevation, degrees */ float Azim, /* i : Azimuth, degrees */ - float *hrf_left, /* o : Left HR filter */ - float *hrf_right, /* o : Right HR filter */ - int16_t *itd /* o : ITD value */ +#ifdef FIX_569_TD_FILTER_LENGTH + const int16_t filterlength, /* i : Filter length */ +#endif + float *hrf_left, /* o : Left HR filter */ + float *hrf_right, /* o : Right HR filter */ + int16_t *itd /* o : ITD value */ ) { GenerateFilter( Elev, Azim, &HrFiltSet_p->ModelParams, &HrFiltSet_p->ModelEval ); +#ifdef FIX_569_TD_FILTER_LENGTH + mvr2r( HrFiltSet_p->ModelEval.hrfModL, hrf_left, filterlength ); + mvr2r( HrFiltSet_p->ModelEval.hrfModR, hrf_right, filterlength ); +#else mvr2r( HrFiltSet_p->ModelEval.hrfModL, hrf_left, HrFiltSet_p->ModelParams.K ); mvr2r( HrFiltSet_p->ModelEval.hrfModR, hrf_right, HrFiltSet_p->ModelParams.K ); +#endif /* 4. Evaluate the ITD */ if ( HrFiltSet_p->ModelParams.UseItdModel ) { diff --git a/lib_rend/ivas_objectRenderer_sources.c b/lib_rend/ivas_objectRenderer_sources.c index 8debd6619b..8b4b910c5b 100644 --- a/lib_rend/ivas_objectRenderer_sources.c +++ b/lib_rend/ivas_objectRenderer_sources.c @@ -275,7 +275,11 @@ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams( Listener_p = hBinRendererTd->Listener_p; HrFiltSet_p = hBinRendererTd->HrFiltSet_p; +#ifdef FIX_569_TD_FILTER_LENGTH + *filterlength = min( HrFiltSet_p->FiltLength, SFX_SPAT_BIN_MAX_FILTER_LENGTH ); +#else *filterlength = HrFiltSet_p->FiltLength; +#endif /* 1. Map source pos to the coordinate system of the listener */ switch ( SrcSpatial_p->PosType ) @@ -312,7 +316,11 @@ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams( Azim = -1.0f * _180_OVER_PI * (float) atan2f( ListRelPos[1], ListRelPos[0] ); } +#ifdef FIX_569_TD_FILTER_LENGTH + GetFilterFromAngle( HrFiltSet_p, Elev, Azim, *filterlength, hrf_left, hrf_right, itd ); +#else GetFilterFromAngle( HrFiltSet_p, Elev, Azim, hrf_left, hrf_right, itd ); +#endif /* 6. Evaluate the directional and distance gains */ /* Directional gain */ diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 803a612502..c031392226 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -314,6 +314,9 @@ void GetFilterFromAngle( TDREND_HRFILT_FiltSet_t *HrFiltSet_p, /* i/o: HR filter set structure */ const float Elev, /* i : Elevation, degrees */ float Azim, /* i : Azimuth, degrees */ +#ifdef FIX_569_TD_FILTER_LENGTH + const int16_t filterlength, /* i : Filter length */ +#endif float *LeftFilter, /* o : Left HR filter */ float *RightFilter, /* o : Right HR filter */ int16_t *itd /* o : ITD value */ -- GitLab