From 93a1c79e0be93214ca9a0bb9e1e2881626c6021d Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 25 Sep 2024 20:47:52 +0530 Subject: [PATCH] Reverb crash fix --- lib_rend/ivas_reverb.c | 14 +++++++++++--- lib_rend/ivas_reverb_iir_filter.c | 4 ++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/lib_rend/ivas_reverb.c b/lib_rend/ivas_reverb.c index 26f8122ed..544f4310c 100644 --- a/lib_rend/ivas_reverb.c +++ b/lib_rend/ivas_reverb.c @@ -3089,9 +3089,9 @@ static void reverb_block_fx( ivas_reverb_iir_filt_2taps_feed_blk_fx( &( hReverb->t60[i] ), inner_bsize, pTemp_fx, ppOutput_fx[i] ); FOR( ns = 0; ns < inner_bsize; ns++ ) { - pO0[ns] = L_add( imult3216( pOutput_i_fx[ns], mixer_0_i ), pO0[ns] ); /* mixer ch 0 */ + pO0[ns] = L_add_sat( imult3216( pOutput_i_fx[ns], mixer_0_i ), pO0[ns] ); /* mixer ch 0 */ move32(); - pO1[ns] = L_add( imult3216( pOutput_i_fx[ns], mixer_1_i ), pO1[ns] ); /* mixer ch 1 */ + pO1[ns] = L_add_sat( imult3216( pOutput_i_fx[ns], mixer_1_i ), pO1[ns] ); /* mixer ch 1 */ move32(); } } @@ -3123,7 +3123,7 @@ static void reverb_block_fx( } Word16 r_shift; - r_shift = find_guarded_bits_fx( hReverb->fft_filter_ols.fft_size ); + 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 FOR( k = 0; k < hReverb->fft_filter_ols.block_size; k++ ) { @@ -3139,6 +3139,14 @@ static void reverb_block_fx( post_fft_filter_fx( hReverb, pOut0_fx + start_sample_idx, pOut1_fx + start_sample_idx, pFFT_buf[0], pFFT_buf[1] ); } + FOR( k = 0; k < hReverb->fft_filter_ols.block_size; k++ ) + { + pOut0_fx[k] = (Word32) L_shl( pOut0_fx[k], 1 ); + move32(); + pOut1_fx[k] = (Word32) L_shl( pOut1_fx[k], 1 ); + move32(); + } + return; } #else diff --git a/lib_rend/ivas_reverb_iir_filter.c b/lib_rend/ivas_reverb_iir_filter.c index 454e2930a..85245aadc 100644 --- a/lib_rend/ivas_reverb_iir_filter.c +++ b/lib_rend/ivas_reverb_iir_filter.c @@ -221,8 +221,8 @@ void ivas_reverb_iir_filt_2taps_feed_blk_fx( move32(); FOR( i = 0; i < blk_size; i++ ) { - flt_output_fx = L_add( Mpy_32_32( L_shl( input[i], 1 ), flt_CoefB_0_fx ), flt_pBuffer_0_fx ); - flt_pBuffer_0_fx = L_sub( L_add( flt_pBuffer_1_fx, Mpy_32_32( L_shl( input[i], 1 ), flt_CoefB_1_fx ) ), Mpy_32_32( L_shl( flt_output_fx, 1 ), flt_CoefA_1_fx ) ); + flt_output_fx = L_add( L_shl( Mpy_32_32( input[i], flt_CoefB_0_fx ), 1 ), flt_pBuffer_0_fx ); + flt_pBuffer_0_fx = L_sub( L_add( flt_pBuffer_1_fx, L_shl( Mpy_32_32( input[i], flt_CoefB_1_fx ), 1 ) ), L_shl( Mpy_32_32( flt_output_fx, flt_CoefA_1_fx ), 1 ) ); output[i] = flt_output_fx; move32(); } -- GitLab