From 97cdbd047413bd169364c773311795b9ccbf07e7 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 17 Jul 2025 16:36:16 +0530 Subject: [PATCH] Fix for 3GPP issue 1784: High frequency noise on binaural room reverb output for main and main-pc branch Link #1784 --- lib_rend/ivas_reverb_fft_filter_fx.c | 3 +++ lib_rend/ivas_reverb_fx.c | 26 ++++++++++++++++++++++++-- lib_rend/ivas_stat_rend.h | 1 + 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/lib_rend/ivas_reverb_fft_filter_fx.c b/lib_rend/ivas_reverb_fft_filter_fx.c index bbe077f8b..09720d202 100644 --- a/lib_rend/ivas_reverb_fft_filter_fx.c +++ b/lib_rend/ivas_reverb_fft_filter_fx.c @@ -232,6 +232,9 @@ void ivas_reverb_t2f_f2t_ClearHistory( move32(); } + t2f_f2t->prev_shift = 31; + move16(); + return; } /*-----------------------------------------------------------------------------------------* diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index 9ea501f10..b90cfa91a 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -1824,6 +1824,7 @@ static void reverb_block_fx( Word32 pTemp_fx[INNER_BLK_SIZE]; Word32 *ppOutput_fx[IVAS_REV_MAX_NR_BRANCHES]; Word32 Output_fx[IVAS_REV_MAX_NR_BRANCHES][INNER_BLK_SIZE]; + Word16 shift; move16(); move16(); move16(); @@ -1894,6 +1895,27 @@ static void reverb_block_fx( } } + shift = s_min( L_norm_arr( pOut0_fx, hReverb->fft_filter_ols.block_size ), L_norm_arr( pOut1_fx, hReverb->fft_filter_ols.block_size ) ); + + IF( LT_16( shift, hReverb->fft_filter_ols.prev_shift ) ) + { + scale_sig32( pOut0_fx, hReverb->fft_filter_ols.block_size, shift ); + scale_sig32( pOut1_fx, hReverb->fft_filter_ols.block_size, shift ); + scale_sig32( hReverb->fft_filter_ols.fft_history_L_fx, hReverb->fft_filter_ols.hist_size, sub( shift, hReverb->fft_filter_ols.prev_shift ) ); + scale_sig32( hReverb->fft_filter_ols.fft_history_R_fx, hReverb->fft_filter_ols.hist_size, sub( shift, hReverb->fft_filter_ols.prev_shift ) ); + + hReverb->fft_filter_ols.prev_shift = shift; + move16(); + } + ELSE + { + scale_sig32( pOut0_fx, hReverb->fft_filter_ols.block_size, hReverb->fft_filter_ols.prev_shift ); + scale_sig32( pOut1_fx, hReverb->fft_filter_ols.block_size, hReverb->fft_filter_ols.prev_shift ); + + shift = hReverb->fft_filter_ols.prev_shift; + move16(); + } + Word16 r_shift; r_shift = add( find_guarded_bits_fx( hReverb->fft_filter_ols.fft_size ), 1 ); // Applying guard bits for the DoRTFT inside the post_fft_filter function @@ -1913,9 +1935,9 @@ static void reverb_block_fx( FOR( k = 0; k < hReverb->fft_filter_ols.block_size; k++ ) { - pOut0_fx[k] = (Word32) L_shl( pOut0_fx[k], 1 ); + pOut0_fx[k] = (Word32) L_shl( pOut0_fx[k], sub( 1, shift ) ); move32(); - pOut1_fx[k] = (Word32) L_shl( pOut1_fx[k], 1 ); + pOut1_fx[k] = (Word32) L_shl( pOut1_fx[k], sub( 1, shift ) ); move32(); } diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index f8dad9a66..9f853102d 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -895,6 +895,7 @@ typedef struct ivas_reverb_t2f_f2t_t Word32 fft_history_L_fx[RV_FILTER_MAX_HISTORY]; // float fft_history_R[RV_FILTER_MAX_HISTORY]; Word32 fft_history_R_fx[RV_FILTER_MAX_HISTORY]; + Word16 prev_shift; } ivas_reverb_t2f_f2t_t; /* FFT filter with its frequency response coefficients */ -- GitLab