From 81129c2c81e87515ed4c4d65fcd1b33407b0168e Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Thu, 6 Apr 2023 10:35:06 +0200 Subject: [PATCH 1/3] Add interpolation of distance/direction gain in 6DoF under FIX_379_GAININTP --- lib_com/options.h | 2 +- lib_rend/ivas_objectRenderer_hrFilt.c | 8 +++++++ lib_rend/ivas_objectRenderer_sfx.c | 30 ++++++++++++++++++++++++++- lib_rend/ivas_prot_rend.h | 5 +++++ lib_rend/ivas_stat_rend.h | 3 +++ 5 files changed, 46 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 43de30fbeb..f961d3788d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -154,7 +154,7 @@ #define SBA2MONO /* FhG: Issue 365: Adapt processing of SBA mono output to be in line with stereo output (less delay, lower complexity) */ #define FIX_379_EXT_METADATA /* Eri: Extended metadata issues */ #define FIX_379_ANGLE /* Eri: Extended metadata issues related to angle structure */ - +#define FIX_379_GAININTP /* Eri: Adds a gain interpolation for directional/distance gain to handle abrupt changes in metadata (Non BE) */ /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ diff --git a/lib_rend/ivas_objectRenderer_hrFilt.c b/lib_rend/ivas_objectRenderer_hrFilt.c index 91b018b148..97d0b68fb8 100644 --- a/lib_rend/ivas_objectRenderer_hrFilt.c +++ b/lib_rend/ivas_objectRenderer_hrFilt.c @@ -69,13 +69,21 @@ ivas_error TDREND_REND_RenderSourceHRFilt( { float LeftOutputFrame[L_SPATIAL_SUBFR_48k]; float RightOutputFrame[L_SPATIAL_SUBFR_48k]; +#ifndef FIX_379_GAININTP float Gain; Gain = ( *Src_p->SrcRend_p->DirGain_p ) * ( *Src_p->SrcRend_p->DistGain_p ); +#endif TDREND_Apply_ITD( Src_p->InputFrame_p, LeftOutputFrame, RightOutputFrame, &Src_p->previtd, Src_p->itd, Src_p->mem_itd, subframe_length ); +#ifdef FIX_379_GAININTP + 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 ); + Src_p->prevGain = Src_p->Gain; +#else TDREND_firfilt( LeftOutputFrame, Src_p->hrf_left_prev, hrf_left_delta, intp_count, Src_p->mem_hrf_left, subframe_length, Src_p->filterlength, Gain ); TDREND_firfilt( RightOutputFrame, Src_p->hrf_right_prev, hrf_right_delta, intp_count, Src_p->mem_hrf_right, subframe_length, Src_p->filterlength, Gain ); +#endif /* Copy to accumulative output frame */ v_add( LeftOutputFrame, output_buf[0], output_buf[0], subframe_length ); diff --git a/lib_rend/ivas_objectRenderer_sfx.c b/lib_rend/ivas_objectRenderer_sfx.c index 98f45a5dd9..d53cf86cef 100644 --- a/lib_rend/ivas_objectRenderer_sfx.c +++ b/lib_rend/ivas_objectRenderer_sfx.c @@ -37,6 +37,9 @@ #include "ivas_rom_rend.h" #include "prot.h" #include "wmc_auto.h" +#ifdef FIX_379_GAININTP +#include "ivas_rom_com.h" +#endif /*---------------------------------------------------------------------* @@ -236,7 +239,12 @@ void TDREND_firfilt( float *mem, /* i/o: filter memory */ const int16_t subframe_length, /* i : Length of signal */ const int16_t filterlength, /* i : Filter length */ - const float Gain /* i : Gain */ +#ifdef FIX_379_GAININTP + const float Gain, /* i : Gain */ + const float prevGain /* i : Previous gain */ +#else + const float Gain /* i : Gain */ +#endif ) { float buffer[SFX_SPAT_BIN_MAX_FILTER_LENGTH - 1 + L_SUBFRAME5MS_48k]; @@ -245,6 +253,18 @@ void TDREND_firfilt( float *p_filter; float tmp; int16_t i, j; +#ifdef FIX_379_GAININTP + float gain_tmp, gain_delta; + const float *pcos; + int16_t step; + float cos_tmp; + + /* Setup pointer for cosine gain transition curve */ + gain_delta = Gain - prevGain; + pcos = ivas_mdft_coeff_cos_twid_960; /* ivas_mdft_coeff_cos_twid_960 */ + step = 960 / subframe_length; + gain_tmp = prevGain; +#endif /* Handle memory */ p_signal = buffer + filterlength - 1; @@ -262,7 +282,15 @@ void TDREND_firfilt( { tmp += ( *p_filter++ ) * ( *p_tmp-- ); } +#ifdef FIX_379_GAININTP + /* Apply cosine gain curve in case of abrupt gain changes */ + cos_tmp = *pcos; + pcos += step; + gain_tmp = prevGain + gain_delta * ( 1 - cos_tmp * cos_tmp ); + signal[i] = tmp * gain_tmp; +#else signal[i] = tmp * Gain; +#endif if ( i < intp_count ) { diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 938e8de02c..d23b30ebbc 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -462,7 +462,12 @@ void TDREND_firfilt( float *mem, /* i/o: filter memory */ const int16_t subframe_length, /* i : Length of signal */ const int16_t filterlength, /* i : Filter length */ +#ifdef FIX_379_GAININTP + const float Gain, /* i : Gain */ + const float prevGain /* i : Previous gain */ +#else const float Gain /* i : Gain */ +#endif ); diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 226b9fcd32..353313200d 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -600,6 +600,9 @@ typedef struct float mem_hrf_left[SFX_SPAT_BIN_MAX_FILTER_LENGTH - 1]; float mem_hrf_right[SFX_SPAT_BIN_MAX_FILTER_LENGTH - 1]; float Gain; +#ifdef FIX_379_GAININTP + float prevGain; +#endif } TDREND_SRC_t; /* Top level TD binaural renderer handle */ -- GitLab From d101d328e5c51c7afbe1fed203a8a2ac0146a846 Mon Sep 17 00:00:00 2001 From: Sumeyra Kanik Date: Wed, 19 Apr 2023 17:06:33 +0200 Subject: [PATCH 2/3] Initialize prevGain --- lib_rend/ivas_objectRenderer_sources.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib_rend/ivas_objectRenderer_sources.c b/lib_rend/ivas_objectRenderer_sources.c index b14db0b7c2..8cedff510e 100644 --- a/lib_rend/ivas_objectRenderer_sources.c +++ b/lib_rend/ivas_objectRenderer_sources.c @@ -691,7 +691,9 @@ void TDREND_SRC_Init( Src_p->hrf_right_prev[0] = 1; Src_p->azim_prev = 0.0f; Src_p->elev_prev = 0.0f; - +#ifdef FIX_379_GAININTP + Src_p->prevGain = 1.0f; +#endif return; } -- GitLab From eb22204f9f20beefb4daaf607caddd82b815b3c4 Mon Sep 17 00:00:00 2001 From: Sumeyra Kanik Date: Mon, 24 Apr 2023 10:57:47 +0200 Subject: [PATCH 3/3] Change from cosine interpolation to linear interpolation to reduce complexity --- lib_rend/ivas_objectRenderer_sfx.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/lib_rend/ivas_objectRenderer_sfx.c b/lib_rend/ivas_objectRenderer_sfx.c index d53cf86cef..af3231df61 100644 --- a/lib_rend/ivas_objectRenderer_sfx.c +++ b/lib_rend/ivas_objectRenderer_sfx.c @@ -37,9 +37,6 @@ #include "ivas_rom_rend.h" #include "prot.h" #include "wmc_auto.h" -#ifdef FIX_379_GAININTP -#include "ivas_rom_com.h" -#endif /*---------------------------------------------------------------------* @@ -254,15 +251,10 @@ void TDREND_firfilt( float tmp; int16_t i, j; #ifdef FIX_379_GAININTP - float gain_tmp, gain_delta; - const float *pcos; - int16_t step; - float cos_tmp; - - /* Setup pointer for cosine gain transition curve */ - gain_delta = Gain - prevGain; - pcos = ivas_mdft_coeff_cos_twid_960; /* ivas_mdft_coeff_cos_twid_960 */ - step = 960 / subframe_length; + float step, gain_tmp, gain_delta; + + gain_delta = ( Gain - prevGain ); + step = gain_delta / ( subframe_length ); gain_tmp = prevGain; #endif @@ -283,10 +275,8 @@ void TDREND_firfilt( tmp += ( *p_filter++ ) * ( *p_tmp-- ); } #ifdef FIX_379_GAININTP - /* Apply cosine gain curve in case of abrupt gain changes */ - cos_tmp = *pcos; - pcos += step; - gain_tmp = prevGain + gain_delta * ( 1 - cos_tmp * cos_tmp ); + /* Apply linear gain interpolation in case of abrupt gain changes */ + gain_tmp = gain_tmp + step; signal[i] = tmp * gain_tmp; #else signal[i] = tmp * Gain; -- GitLab