From 984afbe55784d3659d0d47587640e4b2cb48c897 Mon Sep 17 00:00:00 2001 From: rtyag Date: Thu, 21 Aug 2025 12:20:42 +1000 Subject: [PATCH] fix for issue 1939 --- lib_com/options.h | 1 + lib_dec/ivas_binRenderer_internal_fx.c | 50 ++++++++++++++++++++------ 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index e76fe867c..77aac3d7f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -89,6 +89,7 @@ #define FIX_1931_BIN_COHR_CROSS_MIX /* FhG: correct binauralCoherenceCrossmixGains_fx calculation */ +#define FIX_1939_REVERB_DMX_OUT_Q /*Dlb: output correct q factor for the reverb dmx function*/ /* #################### Start BASOP porting switches ############################ */ #define FIX_1372_ISAR_POST_REND diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index 5a96048be..ac97b539c 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -902,7 +902,16 @@ static ivas_error ivas_binaural_hrtf_open_fx( * * *-------------------------------------------------------------------------*/ - +#ifdef FIX_1939_REVERB_DMX_OUT_Q +static void ivas_binaural_obtain_DMX_fx( + const Word16 numTimeSlots, + BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: fastconv binaural renderer handle */ + Word32 RealBuffer[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Contains the LS signals Q_in_out */ + Word32 ImagBuffer[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Contains the LS signals Q_in_out */ + Word32 realDMX[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /*Q_in_out*/ + Word32 imagDMX[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /*Q_in_out*/ + Word16 *Q_in_out ) /*i/o: input and output Q*/ +#else static void ivas_binaural_obtain_DMX_fx( const Word16 numTimeSlots, BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: fastconv binaural renderer handle */ @@ -910,6 +919,7 @@ static void ivas_binaural_obtain_DMX_fx( Word32 ImagBuffer[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Contains the LS signals Q_in */ Word32 realDMX[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /*Q_in-1*/ Word32 imagDMX[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] ) /*Q_in-1*/ +#endif { Word16 chIdx, bandIdx, k; @@ -948,13 +958,13 @@ static void ivas_binaural_obtain_DMX_fx( { FOR( k = 0; k < numTimeSlots; k++ ) { - temp1_fx = Mpy_32_32( RealBuffer[chIdx][k][bandIdx], dmxConst ); // Q_in - temp2_fx = Mpy_32_32( ImagBuffer[chIdx][k][bandIdx], dmxConst ); // Q_in - realDMX[chOutIdx][k][bandIdx] = L_add( realDMX[chOutIdx][k][bandIdx], temp1_fx ); // Q_in + temp1_fx = Mpy_32_32( RealBuffer[chIdx][k][bandIdx], dmxConst ); // Q_in_out + temp2_fx = Mpy_32_32( ImagBuffer[chIdx][k][bandIdx], dmxConst ); // Q_in_out + realDMX[chOutIdx][k][bandIdx] = L_add( realDMX[chOutIdx][k][bandIdx], temp1_fx ); // Q_in_out move32(); - imagDMX[chOutIdx][k][bandIdx] = L_add( imagDMX[chOutIdx][k][bandIdx], temp2_fx ); // Q_in + imagDMX[chOutIdx][k][bandIdx] = L_add( imagDMX[chOutIdx][k][bandIdx], temp2_fx ); // Q_in_out move32(); - 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 + 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_out move32(); } } @@ -970,7 +980,7 @@ static void ivas_binaural_obtain_DMX_fx( move32(); temp2_fx = imagDMX[chOutIdx][k][bandIdx]; move32(); - 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 + 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_out } test(); IF( ( P_in_fx[bandIdx] <= 0 ) || ( P_out_fx <= 0 ) ) @@ -994,13 +1004,16 @@ static void ivas_binaural_obtain_DMX_fx( factEQ_fx = L_max( L_min( factEQ_fx, 0x7fffffff ), 0x20000000 ); // Q30 , 0x7fffffff -> (1.0f in Q31)-1, 0x20000000 ->1.0f in Q29 FOR( k = 0; k < numTimeSlots; k++ ) { - realDMX[chOutIdx][k][bandIdx] = Mpy_32_32( realDMX[chOutIdx][k][bandIdx], factEQ_fx ); // Q_in - 1 + realDMX[chOutIdx][k][bandIdx] = Mpy_32_32( realDMX[chOutIdx][k][bandIdx], factEQ_fx ); // Q_in_out - 1 move32(); - imagDMX[chOutIdx][k][bandIdx] = Mpy_32_32( imagDMX[chOutIdx][k][bandIdx], factEQ_fx ); // Q_in - 1 + imagDMX[chOutIdx][k][bandIdx] = Mpy_32_32( imagDMX[chOutIdx][k][bandIdx], factEQ_fx ); // Q_in_out - 1 move32(); } } } +#ifdef FIX_1939_REVERB_DMX_OUT_Q + *Q_in_out = sub( *Q_in_out, 1 ); +#endif } ELSE IF( EQ_32( hBinRenderer->ivas_format, SBA_FORMAT ) || EQ_32( hBinRenderer->ivas_format, MASA_FORMAT ) ) { @@ -1068,6 +1081,12 @@ static void ivas_binaural_obtain_DMX_fx( } } } +#ifdef FIX_1939_REVERB_DMX_OUT_Q + IF( NE_16( hBinRenderer->nInChannels, HOA3_CHANNELS ) ) + { + *Q_in_out = sub( *Q_in_out, 1 ); + } +#endif } return; @@ -1846,8 +1865,16 @@ void ivas_binRenderer_fx( Word32 inRe_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; Word32 inIm_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; Word16 shift_q; +#ifdef FIX_1939_REVERB_DMX_OUT_Q + Word16 q_in_out; + q_in_out = *Q_in; +#endif +#ifdef FIX_1939_REVERB_DMX_OUT_Q + ivas_binaural_obtain_DMX_fx( numTimeSlots, hBinRenderer, RealBuffer_fx, ImagBuffer_fx, inRe_fx, inIm_fx, &q_in_out ); +#else ivas_binaural_obtain_DMX_fx( numTimeSlots, hBinRenderer, RealBuffer_fx, ImagBuffer_fx, inRe_fx, inIm_fx ); +#endif FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) { @@ -1859,8 +1886,11 @@ void ivas_binRenderer_fx( } ivas_binaural_reverb_processSubframe_fx( hBinRenderer->hReverb, BINAURAL_CHANNELS, numTimeSlots, inRe_fx, inIm_fx, reverbRe_fx, reverbIm_fx ); - +#ifdef FIX_1939_REVERB_DMX_OUT_Q + shift_q = sub( Q6, q_in_out ); +#else shift_q = sub( Q6, sub( *Q_in, 1 ) ); +#endif FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) { FOR( j = 0; j < numTimeSlots; j++ ) -- GitLab