From ec0534a067a296eb648fa37f58e650be016d7420 Mon Sep 17 00:00:00 2001 From: naghibza Date: Wed, 30 Jul 2025 18:31:29 +0200 Subject: [PATCH 1/3] - Fixed if-condition to properly activate reverb_with_bin_room_ir - Modified gain scaling in rotateFrame_sd_cldfd_fixed() - Corrected factEQ_fx calculation - Increased factEQ_fx calculation precision. --- lib_com/options.h | 2 +- lib_dec/ivas_binRenderer_internal_fx.c | 34 ++++++++++++++++++++++++-- lib_rend/ivas_rotation_fx.c | 3 +++ 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 929ae2b05..14fc1ef57 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -164,7 +164,7 @@ #define NONBE_FIX_991_PARAMBIN_BINARY_HRTF /* Nokia: issue #991: fix using of binary file HRTF in ParamBin (to activate when USE_NEW_HRTF_BINARY_FILE_FORMAT and FIX_777_COMBI_RENDER_CONFIG_FILE are on ) */ #define FIX_1741_REVERB_TIMES_Q_FORMAT /* Philips: reverberation times in Q26 format instead of Q31 */ - +#define FIX_1835_REVERB_ACTIVATION /* FhG: reverberation activation logic modification and factEQ calculation correction*/ /* #################### End BASOP porting switches ############################ */ #endif diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index 68886c1ba..d6dcd7deb 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -992,7 +992,19 @@ static void ivas_binaural_obtain_DMX_fx( set32_fx( imagDMX[chOutIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); } } - +#ifdef FIX_1835_REVERB_ACTIVATION + Word16 scaleFactor = s_min( getScaleFactor32( RealBuffer[0], CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX ), + getScaleFactor32( ImagBuffer[0], CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX ) ); + FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) + { + scaleFactor = s_min( getScaleFactor32( RealBuffer[chIdx], CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX ), + getScaleFactor32( ImagBuffer[chIdx], CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX ) ); + } + if ( scaleFactor > 6 ) + scaleFactor -= 6; // Adding headroom for subsequent calculations + else + scaleFactor = 0; +#endif FOR( chOutIdx = 0; chOutIdx < BINAURAL_CHANNELS; chOutIdx++ ) { set32_fx( P_in_fx, 0, hBinRenderer->conv_band ); @@ -1012,7 +1024,10 @@ static void ivas_binaural_obtain_DMX_fx( move32(); imagDMX[chOutIdx][k][bandIdx] = L_add( imagDMX[chOutIdx][k][bandIdx], temp2_fx ); // Q_in move32(); - +#ifdef FIX_1835_REVERB_ACTIVATION + temp1_fx = L_shl( temp1_fx, scaleFactor ); + temp2_fx = L_shl( temp2_fx, scaleFactor ); +#endif P_in_fx[bandIdx] = L_add( P_in_fx[bandIdx], L_add( Mpy_32_32( temp1_fx, temp1_fx ), Mpy_32_32( temp2_fx, temp2_fx ) ) ); // Q31-2*Q_in move32(); } @@ -1025,10 +1040,17 @@ static void ivas_binaural_obtain_DMX_fx( move32(); FOR( k = 0; k < numTimeSlots; k++ ) { +#ifdef FIX_1835_REVERB_ACTIVATION + temp1_fx = L_shl(realDMX[chOutIdx][k][bandIdx], scaleFactor); + move32(); + temp2_fx = L_shl(imagDMX[chOutIdx][k][bandIdx], scaleFactor); + move32(); +#else temp1_fx = realDMX[chOutIdx][k][bandIdx]; move32(); temp2_fx = imagDMX[chOutIdx][k][bandIdx]; move32(); +#endif P_out_fx = L_add( P_out_fx, L_add( Mpy_32_32( temp1_fx, temp1_fx ), Mpy_32_32( temp2_fx, temp2_fx ) ) ); // Q31-2*Q_in } test(); @@ -1040,7 +1062,11 @@ static void ivas_binaural_obtain_DMX_fx( ELSE { Word16 div = divide3232( P_in_fx[bandIdx], P_out_fx ); +#ifdef FIX_1835_REVERB_ACTIVATION + Word16 exp = 0; // divide3232 gives Q15 + following Q16 shift +#else Word16 exp = norm_l( div ); +#endif factEQ_fx = Sqrt32( L_shl( div, Q16 ), &exp ); factEQ_fx = L_shl( factEQ_fx, sub( exp, 1 ) ); // Q30 } @@ -1405,7 +1431,11 @@ ivas_error ivas_binRenderer_open_fx( /* Allocate memories needed for reverb module */ test(); +#ifdef FIX_1835_REVERB_ACTIVATION + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) && EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) ) +#else IF( ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ) && EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) +#endif { IF( NE_32( ( error = ivas_binaural_reverb_init( &( hBinRenderer->hReverb ), st_ivas->hHrtfStatistics, hBinRenderer->conv_band, hBinRenderer->timeSlots, &( st_ivas->hRenderConfig->roomAcoustics ), st_ivas->hDecoderConfig->output_Fs, st_ivas->hHrtfFastConv->fastconvReverberationTimes_fx, st_ivas->hHrtfFastConv->fastconvReverberationEneCorrections_fx ) ), IVAS_ERR_OK ) ) { diff --git a/lib_rend/ivas_rotation_fx.c b/lib_rend/ivas_rotation_fx.c index 92ad8d36f..a2b55a19b 100644 --- a/lib_rend/ivas_rotation_fx.c +++ b/lib_rend/ivas_rotation_fx.c @@ -1173,6 +1173,9 @@ void rotateFrame_sd_cldfb_fixed( IF( hEFAPdata != NULL && ( NE_16( extract_l( L_shr( hOutputSetup->ls_azimuth_fx[n], Q22 ) ), azimuth ) || NE_16( extract_l( L_shr( hOutputSetup->ls_elevation_fx[n], Q22 ) ), elevation ) ) ) { efap_determine_gains_fx( hEFAPdata, gains_fx[n], L_shl( azimuth, Q22 ), L_shl( elevation, Q22 ), EFAP_MODE_EFAP ); +#ifdef FIX_1835_REVERB_ACTIVATION + scale_sig32( gains_fx[n], hEFAPdata->numSpk, Q1 ); //gains_fx: Q31 +#endif } ELSE { -- GitLab From 8c599303f5166c32a98ccf881cf42253db60e5e8 Mon Sep 17 00:00:00 2001 From: naghibza Date: Wed, 30 Jul 2025 18:47:47 +0200 Subject: [PATCH 2/3] Applied clang formatting patch. --- lib_com/options.h | 2 +- lib_dec/ivas_binRenderer_internal_fx.c | 10 +++++----- lib_rend/ivas_rotation_fx.c | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 60fd2e3aa..5257a5d6a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -166,7 +166,7 @@ #define FIX_1741_REVERB_TIMES_Q_FORMAT /* Philips: reverberation times in Q26 format instead of Q31 */ #define FIX_1831_REVERB_REGRESSION /* Philips: fixes reverb regression issues */ -#define FIX_1835_REVERB_ACTIVATION /* FhG: reverberation activation logic modification and factEQ calculation correction*/ +#define FIX_1835_REVERB_ACTIVATION /* FhG: Modified reverberation activation logic and corrected factEQ calculation */ /* #################### End BASOP porting switches ############################ */ #endif diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index d6dcd7deb..e4ffb1549 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -998,13 +998,13 @@ static void ivas_binaural_obtain_DMX_fx( FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) { scaleFactor = s_min( getScaleFactor32( RealBuffer[chIdx], CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX ), - getScaleFactor32( ImagBuffer[chIdx], CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX ) ); + getScaleFactor32( ImagBuffer[chIdx], CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX ) ); } if ( scaleFactor > 6 ) scaleFactor -= 6; // Adding headroom for subsequent calculations else scaleFactor = 0; -#endif +#endif FOR( chOutIdx = 0; chOutIdx < BINAURAL_CHANNELS; chOutIdx++ ) { set32_fx( P_in_fx, 0, hBinRenderer->conv_band ); @@ -1041,9 +1041,9 @@ static void ivas_binaural_obtain_DMX_fx( FOR( k = 0; k < numTimeSlots; k++ ) { #ifdef FIX_1835_REVERB_ACTIVATION - temp1_fx = L_shl(realDMX[chOutIdx][k][bandIdx], scaleFactor); + temp1_fx = L_shl( realDMX[chOutIdx][k][bandIdx], scaleFactor ); move32(); - temp2_fx = L_shl(imagDMX[chOutIdx][k][bandIdx], scaleFactor); + temp2_fx = L_shl( imagDMX[chOutIdx][k][bandIdx], scaleFactor ); move32(); #else temp1_fx = realDMX[chOutIdx][k][bandIdx]; @@ -1432,7 +1432,7 @@ ivas_error ivas_binRenderer_open_fx( /* Allocate memories needed for reverb module */ test(); #ifdef FIX_1835_REVERB_ACTIVATION - IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) && EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) ) + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) && EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) ) #else IF( ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ) && EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) #endif diff --git a/lib_rend/ivas_rotation_fx.c b/lib_rend/ivas_rotation_fx.c index a2b55a19b..5d2f393bb 100644 --- a/lib_rend/ivas_rotation_fx.c +++ b/lib_rend/ivas_rotation_fx.c @@ -1174,7 +1174,7 @@ void rotateFrame_sd_cldfb_fixed( { efap_determine_gains_fx( hEFAPdata, gains_fx[n], L_shl( azimuth, Q22 ), L_shl( elevation, Q22 ), EFAP_MODE_EFAP ); #ifdef FIX_1835_REVERB_ACTIVATION - scale_sig32( gains_fx[n], hEFAPdata->numSpk, Q1 ); //gains_fx: Q31 + scale_sig32( gains_fx[n], hEFAPdata->numSpk, Q1 ); // gains_fx: Q31 #endif } ELSE -- GitLab From 20cd84fab9f400d88e3c1a1e52471d8bf5c09360 Mon Sep 17 00:00:00 2001 From: naghibza Date: Wed, 30 Jul 2025 19:04:31 +0200 Subject: [PATCH 3/3] Reverted factEQ_fx precision improvement. --- lib_dec/ivas_binRenderer_internal_fx.c | 27 ++------------------------ 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index e4ffb1549..d241cd145 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -992,19 +992,7 @@ static void ivas_binaural_obtain_DMX_fx( set32_fx( imagDMX[chOutIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); } } -#ifdef FIX_1835_REVERB_ACTIVATION - Word16 scaleFactor = s_min( getScaleFactor32( RealBuffer[0], CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX ), - getScaleFactor32( ImagBuffer[0], CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX ) ); - FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) - { - scaleFactor = s_min( getScaleFactor32( RealBuffer[chIdx], CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX ), - getScaleFactor32( ImagBuffer[chIdx], CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX ) ); - } - if ( scaleFactor > 6 ) - scaleFactor -= 6; // Adding headroom for subsequent calculations - else - scaleFactor = 0; -#endif + FOR( chOutIdx = 0; chOutIdx < BINAURAL_CHANNELS; chOutIdx++ ) { set32_fx( P_in_fx, 0, hBinRenderer->conv_band ); @@ -1024,10 +1012,6 @@ static void ivas_binaural_obtain_DMX_fx( move32(); imagDMX[chOutIdx][k][bandIdx] = L_add( imagDMX[chOutIdx][k][bandIdx], temp2_fx ); // Q_in move32(); -#ifdef FIX_1835_REVERB_ACTIVATION - temp1_fx = L_shl( temp1_fx, scaleFactor ); - temp2_fx = L_shl( temp2_fx, scaleFactor ); -#endif P_in_fx[bandIdx] = L_add( P_in_fx[bandIdx], L_add( Mpy_32_32( temp1_fx, temp1_fx ), Mpy_32_32( temp2_fx, temp2_fx ) ) ); // Q31-2*Q_in move32(); } @@ -1040,17 +1024,10 @@ static void ivas_binaural_obtain_DMX_fx( move32(); FOR( k = 0; k < numTimeSlots; k++ ) { -#ifdef FIX_1835_REVERB_ACTIVATION - temp1_fx = L_shl( realDMX[chOutIdx][k][bandIdx], scaleFactor ); - move32(); - temp2_fx = L_shl( imagDMX[chOutIdx][k][bandIdx], scaleFactor ); - move32(); -#else temp1_fx = realDMX[chOutIdx][k][bandIdx]; move32(); temp2_fx = imagDMX[chOutIdx][k][bandIdx]; move32(); -#endif P_out_fx = L_add( P_out_fx, L_add( Mpy_32_32( temp1_fx, temp1_fx ), Mpy_32_32( temp2_fx, temp2_fx ) ) ); // Q31-2*Q_in } test(); @@ -1063,7 +1040,7 @@ static void ivas_binaural_obtain_DMX_fx( { Word16 div = divide3232( P_in_fx[bandIdx], P_out_fx ); #ifdef FIX_1835_REVERB_ACTIVATION - Word16 exp = 0; // divide3232 gives Q15 + following Q16 shift + Word16 exp = 0; // divide3232 returns Q15 + following Q16 shift #else Word16 exp = norm_l( div ); #endif -- GitLab