Commit c8863ea5 authored by multrus's avatar multrus
Browse files

[cleanup] accept NONBE_SVD_OPTIMIZATION

parent 8e55b360
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -159,7 +159,6 @@
#define FIX_1129_EXT_REND_OUTPUT_HIGH                   /* Philips: issue 1129: External renderer BINAURAL_ROOM_REVERB format output level too high compared to internal rendering output */
#define NONBE_1244_FIX_SWB_BWE_MEMORY                   /* VA: issue 1244: fix to SWB BWE memory in case of switching from FB coding - pending a review by Huawei */
#define FIX_1113_CLDFB_REND_IN_ISAR                     /* issue 1113: fix the use of CLDFB renderer in split-rendering at the external renderer */
#define NONBE_SVD_OPTIMIZATION                          /* FhG: port-2211-svd-optimization */
#define FIX_1135_EXT_RENDERER_HANDLES                   /* VA: issue 1135: Memory usage reduction in external renderer: Allocate only handles that are really needed. */
#define FIX_1209_SID_SIGNALING                          /* VA: issue 1209: remove dead code in IVAS SID signaling */
#define NONBE_1250_MCMASA_LS_OUTPUT                     /* VA: issue 1250: fix crash in McMASA to custom LS output decoding */
+0 −163
Original line number Diff line number Diff line
@@ -57,13 +57,8 @@
 *-----------------------------------------------------------------------*/

static float GivensRotation( const float x, const float z );
#ifdef NONBE_SVD_OPTIMIZATION
static void biDiagonalReductionLeft( float singularVectors[][MAX_OUTPUT_CHANNELS], const int16_t nChannelsL, const int16_t nChannelsC, const int16_t currChannel, float *g );
static void biDiagonalReductionRight( float singularVectors[][MAX_OUTPUT_CHANNELS], const int16_t nChannelsL, const int16_t nChannelsC, const int16_t currChannel, float *g );
#else
static void biDiagonalReductionLeft( float singularVectors[][MAX_OUTPUT_CHANNELS], float singularValues[MAX_OUTPUT_CHANNELS], float secDiag[MAX_OUTPUT_CHANNELS], const int16_t nChannelsL, const int16_t nChannelsC, const int16_t currChannel, float *sig_x, float *g );
static void biDiagonalReductionRight( float singularVectors[][MAX_OUTPUT_CHANNELS], float secDiag[MAX_OUTPUT_CHANNELS], const int16_t nChannelsL, const int16_t nChannelsC, const int16_t currChannel, float *sig_x, float *g );
#endif


static void singularVectorsAccumulationLeft( float singularVectors_Left[][MAX_OUTPUT_CHANNELS], float singularValues[MAX_OUTPUT_CHANNELS], const int16_t nChannelsL, const int16_t nChannelsC );
@@ -491,26 +486,16 @@ static void HouseholderReduction(
    float *eps_x )
{
    int16_t nCh;
#ifdef NONBE_SVD_OPTIMIZATION
    float g_left = 0.0f;
    float g_right = 0.0f;
#else
    float sig_x = 0.0f;
    float g = 0.0f;
#endif

    /* Bidiagonal Reduction for every channel */
    for ( nCh = 0; nCh < nChannelsC; nCh++ ) /* nChannelsC */
    {
#ifdef NONBE_SVD_OPTIMIZATION
        secDiag[nCh] = g_right; /* from the previous channel */
        biDiagonalReductionLeft( singularVectors_Left, nChannelsL, nChannelsC, nCh, &g_left );
        singularValues[nCh] = g_left;
        biDiagonalReductionRight( singularVectors_Left, nChannelsL, nChannelsC, nCh, &g_right );
#else
        biDiagonalReductionLeft( singularVectors_Left, singularValues, secDiag, nChannelsL, nChannelsC, nCh, &sig_x, &g );
        biDiagonalReductionRight( singularVectors_Left, secDiag, nChannelsL, nChannelsC, nCh, &sig_x, &g );
#endif
        *eps_x = max( *eps_x, ( fabsf( singularValues[nCh] ) + fabsf( secDiag[nCh] ) ) );
    }

@@ -523,7 +508,6 @@ static void HouseholderReduction(
}


#ifdef NONBE_SVD_OPTIMIZATION
/*-------------------------------------------------------------------------
 * biDiagonalReductionLeft()
 *
@@ -633,160 +617,13 @@ static void biDiagonalReductionRight(
    return;
}

#else

/*-------------------------------------------------------------------------
 * biDiagonalReductionLeft()
 *
 *
 *-------------------------------------------------------------------------*/
static void biDiagonalReductionLeft(
    float singularVectors[][MAX_OUTPUT_CHANNELS],
    float singularValues[MAX_OUTPUT_CHANNELS],
    float secDiag[MAX_OUTPUT_CHANNELS],
    const int16_t nChannelsL,
    const int16_t nChannelsC,
    const int16_t currChannel,
    float *sig_x,
    float *g )
{
    int16_t iCh, jCh, idx;
    float norm_x, f, r;

    secDiag[currChannel] = ( *sig_x ) * ( *g );

    /* Setting values to 0 */
    ( *sig_x ) = 0.0f;
    ( *g ) = 0.0f;

    if ( currChannel < nChannelsL ) /* i <= m */
    {
        idx = currChannel;

        for ( jCh = idx; jCh < nChannelsL; jCh++ ) /* nChannelsL */
        {
            ( *sig_x ) += fabsf( singularVectors[jCh][currChannel] );
        }

        if ( ( *sig_x ) ) /*(fabsf(*sig_x) > EPSILON * fabsf(*sig_x)) { */
        {
            norm_x = 0.0f;

            for ( jCh = idx; jCh < nChannelsL; jCh++ ) /* nChannelsL */
            {
                singularVectors[jCh][currChannel] = ( singularVectors[jCh][currChannel] / maxWithSign( ( *sig_x ) ) );
                norm_x += ( singularVectors[jCh][currChannel] * singularVectors[jCh][currChannel] );
            }
            ( *g ) = -( singularVectors[currChannel][idx] >= 0 ? 1 : ( -1 ) ) * sqrtf( norm_x );
            r = ( *g ) * singularVectors[currChannel][idx] - norm_x;
            singularVectors[currChannel][idx] = ( singularVectors[currChannel][idx] - ( *g ) );

            for ( iCh = currChannel + 1; iCh < nChannelsC; iCh++ ) /* nChannelsC */
            {
                norm_x = 0.0f;
                for ( jCh = idx; jCh < nChannelsL; jCh++ ) /* nChannelsL */
                {
                    norm_x += ( singularVectors[jCh][currChannel] * singularVectors[jCh][iCh] );
                }

                f = norm_x / maxWithSign( r );


                for ( jCh = idx; jCh < nChannelsL; jCh++ ) /* nChannelsL */
                {
                    singularVectors[jCh][iCh] += ( f * singularVectors[jCh][currChannel] );
                }
            }


            for ( jCh = idx; jCh < nChannelsL; jCh++ ) /* nChannelsL */
            {
                singularVectors[jCh][currChannel] = ( singularVectors[jCh][currChannel] * ( *sig_x ) );
            }
        }

        singularValues[currChannel] = ( ( *sig_x ) * ( *g ) );
    }

    return;
}
#endif

/*-------------------------------------------------------------------------
 * biDiagonalReductionRight()
 *
 *
 *-------------------------------------------------------------------------*/
#ifdef NONBE_SVD_OPTIMIZATION

#else
static void biDiagonalReductionRight(
    float singularVectors[][MAX_OUTPUT_CHANNELS],
    float secDiag[MAX_OUTPUT_CHANNELS],
    const int16_t nChannelsL,
    const int16_t nChannelsC,
    const int16_t currChannel,
    float *sig_x,
    float *g )
{
    int16_t iCh, jCh, idx;
    float norm_x, r;

    /* Setting values to 0 */
    ( *sig_x ) = 0.0f;
    ( *g ) = 0.0f;

    if ( currChannel < nChannelsL && currChannel != ( nChannelsC - 1 ) ) /* i <=m && i !=n */
    {
        idx = currChannel + 1;

        for ( jCh = idx; jCh < nChannelsC; jCh++ ) /* nChannelsC */
        {
            ( *sig_x ) += fabsf( singularVectors[currChannel][jCh] );
        }

        if ( ( *sig_x ) ) /*(fabsf(*sig_x) > EPSILON * fabsf(*sig_x)) { */
        {
            norm_x = 0.0f;

            for ( jCh = idx; jCh < nChannelsC; jCh++ ) /*nChannelsC */
            {
                singularVectors[currChannel][jCh] = ( singularVectors[currChannel][jCh] / maxWithSign( ( *sig_x ) ) );
                norm_x += ( singularVectors[currChannel][jCh] * singularVectors[currChannel][jCh] );
            }
            ( *g ) = -( singularVectors[currChannel][idx] >= 0 ? 1 : ( -1 ) ) * sqrtf( norm_x );
            r = ( *g ) * singularVectors[currChannel][idx] - norm_x;
            singularVectors[currChannel][idx] = ( singularVectors[currChannel][idx] - ( *g ) );

            for ( jCh = idx; jCh < nChannelsC; jCh++ ) /* nChannelsC */
            {
                secDiag[jCh] = singularVectors[currChannel][jCh] / maxWithSign( r );
            }
            for ( iCh = currChannel + 1; iCh < nChannelsL; iCh++ ) /*  nChannelsL */
            {
                norm_x = 0.0f;
                for ( jCh = idx; jCh < nChannelsC; jCh++ ) /* nChannelsC */
                {
                    norm_x += ( singularVectors[iCh][jCh] * singularVectors[currChannel][jCh] );
                }

                for ( jCh = idx; jCh < nChannelsC; jCh++ ) /*  nChannelsC */
                {
                    singularVectors[iCh][jCh] += ( norm_x * secDiag[jCh] );
                }
            }

            for ( jCh = idx; jCh < nChannelsC; jCh++ ) /*  nChannelsC */
            {
                singularVectors[currChannel][jCh] = ( singularVectors[currChannel][jCh] * ( *sig_x ) );
            }
        }
    }

    return;
}

#endif
/*-------------------------------------------------------------------------
 * singularVectorsAccumulationLeft()
 *