Commit e726d94f authored by Nicolas Roussin's avatar Nicolas Roussin
Browse files

Revert to original implementation.

This reverts commit 822dc1a4.
parent 822dc1a4
Loading
Loading
Loading
Loading
Loading
+49 −15
Original line number Diff line number Diff line
@@ -122,6 +122,12 @@ static void matrixMul_fx( Word32 Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A

static void matrixTransp2Mul_fx( Word32 Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word32 Aim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word16 *q_A, Word32 Bre[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/, Word32 Bim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/, Word16 *q_B, Word32 Ascale, Word32 Bscale, Word32 outRe[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, Word32 outIm[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, Word16 *q_out );

static UWord32 ceil_pow2( UWord32 x );

static UWord32 popcnt( UWord32 x );

static UWord32 ceil_log2( UWord32 x );

static Word64 Mpy_64_32( Word64 W_var1, Word32 L_var2 );

/*-------------------------------------------------------------------------
@@ -1311,9 +1317,43 @@ static void ivas_dirac_dec_decorrelate_slot_fx(
    return;
}

static UWord32 ceil_pow2( UWord32 x )
{
    --x;
    x |= x >> 1;
    x |= x >> 2;
    x |= x >> 4;
    x |= x >> 8;
    x |= x >> 16;
    ++x;
    return x;
}

static UWord32 popcnt( UWord32 x )
{
    // it takes once cycle
    x = ( x & 0x55555555 ) + ( ( x & 0xAAAAAAAA ) >> 1 );
    x = ( x & 0x33333333 ) + ( ( x & 0xCCCCCCCC ) >> 2 );
    x = ( x & 0x0F0F0F0F ) + ( ( x & 0xF0F0F0F0 ) >> 4 );
    x = ( x & 0x00FF00FF ) + ( ( x & 0xFF00FF00 ) >> 8 );
    x = ( x & 0x0000FFFF ) + ( ( x & 0xFFFF0000 ) >> 16 );
    return x;
}

static UWord32 ceil_log2( UWord32 x )
{
    if ( x )
    {
        return popcnt( ceil_pow2( x ) - 1 );
    }
    else
    {
        return 0;
    }
}

static Word64 Mpy_64_32( Word64 W_var1, Word32 L_var2 )
{
#if 1
    Word32 var1_l;
    Word64 var_out;
    var1_l = W_extract_l( W_var1 );                                               // 1
@@ -1321,11 +1361,6 @@ static Word64 Mpy_64_32( Word64 W_var1, Word32 L_var2 )
    var_out = W_mac_32_32( var_out, L_lshr( var1_l, 1 ), L_var2 );                // 2
    var_out = W_mac_32_32( W_shr( var_out, 31 ), W_extract_h( W_var1 ), L_var2 ); // 3
    return var_out;
#else
    Word64 var_out;
    var_out = Mpy_32_32( W_extract_h( W_var1 ), L_var2 ); // 3
    return var_out;
#endif
}

static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices_fx(
@@ -1351,8 +1386,7 @@ static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices_fx(
    Word32 ivas_total_brate;
    Word16 nchan_transport;
#ifdef NONBE_2157_IVAS_DIRAC_DEC_BINAURAL_FORMULATE_INPUT_COVARIANCE_MATRICES
    // Word16 rsh0, rsh1, exp0, exp1;
    Word16 exp0, exp1;
    Word16 rsh0, rsh1, exp0, exp1;
#else
    Word16 exp, exp1;
    Word32 temp;
@@ -1430,10 +1464,10 @@ static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices_fx(
#endif

#ifdef NONBE_2157_IVAS_DIRAC_DEC_BINAURAL_FORMULATE_INPUT_COVARIANCE_MATRICES
    // rsh0 = (Word16) ( ceil_log2( hSpatParamRendCom->subframe_nbslots[subframe] ) - 1 );
    // rsh1 = (Word16) ( ceil_log2( BINAURAL_CHANNELS * hSpatParamRendCom->subframe_nbslots[subframe] ) - 1 );
    exp0 = sub( 63, shl( q, 1 ) );
    exp1 = sub( 63, shl( q, 1 ) );
    rsh0 = (Word16) ( ceil_log2( hSpatParamRendCom->subframe_nbslots[subframe] ) - 1 );
    rsh1 = (Word16) ( ceil_log2( BINAURAL_CHANNELS * hSpatParamRendCom->subframe_nbslots[subframe] ) - 1 );
    exp0 = add( sub( 63, shl( q, 1 ) ), rsh0 );
    exp1 = add( sub( 63, shl( q, 1 ) ), rsh1 );
#else
    exp = sub( 63, shl( q, 1 ) ); // exp for the energy (inRe_fx * inRe_fx + inIm_fx * inIm_fx) computed below
#endif
@@ -1448,8 +1482,8 @@ static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices_fx(
                temp64 = W_mult0_32_32( inRe_fx[ch][slot][bin], inRe_fx[ch][slot][bin] );                  // 2q
                temp64 = W_add( temp64, W_mult0_32_32( inIm_fx[ch][slot][bin], inIm_fx[ch][slot][bin] ) ); // 2q
#ifdef NONBE_2157_IVAS_DIRAC_DEC_BINAURAL_FORMULATE_INPUT_COVARIANCE_MATRICES
                hDiracDecBin->ChEne[ch][bin] = W_add( hDiracDecBin->ChEne[ch][bin], temp64 ); // 2q
                subFrameTotalEne[bin] = W_add( subFrameTotalEne[bin], temp64 );               // 2q
                hDiracDecBin->ChEne[ch][bin] = W_add( hDiracDecBin->ChEne[ch][bin], W_shr( temp64, rsh0 ) ); // 2q - rsh0
                subFrameTotalEne[bin] = W_add( subFrameTotalEne[bin], W_shr( temp64, rsh1 ) );               // 2q - rsh1
                move64();
                move64();
#else
@@ -1541,7 +1575,7 @@ static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices_fx(
                tempIm = L_add( inIm_fx[0][slot][bin], inIm_fx[1][slot][bin] );                     // q
                temp64 = W_add( W_mult0_32_32( tempRe, tempRe ), W_mult0_32_32( tempIm, tempIm ) ); // 2q
#ifdef NONBE_2157_IVAS_DIRAC_DEC_BINAURAL_FORMULATE_INPUT_COVARIANCE_MATRICES
                subFrameSumEne[bin] = W_add( subFrameSumEne[bin], temp64 );
                subFrameSumEne[bin] = W_add( subFrameSumEne[bin], W_shr( temp64, rsh1 ) );
                move64();
#else
                exp1 = W_norm( temp64 );