Commit 61ac32db authored by Devansh Kandpal's avatar Devansh Kandpal
Browse files

Merge branch 'main' of https://forge.3gpp.org/rep/sa4/audio/ivas-basop into...

Merge branch 'main' of https://forge.3gpp.org/rep/sa4/audio/ivas-basop into 1942_basop_fix_assert_low_shelf_filter
parents 9fcefe42 93c5e8ac
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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*/

#define EVS_BE_REUSAGE
#ifdef EVS_BE_REUSAGE
+40 −10
Original line number Diff line number Diff line
@@ -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;
@@ -1850,8 +1869,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++ )
        {
@@ -1863,8 +1890,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++ )