Commit 359ba34a authored by vaclav's avatar vaclav
Browse files

reintroduce getScaleFactor32_cmplx()

parent 2b358c38
Loading
Loading
Loading
Loading
+60 −0
Original line number Diff line number Diff line
@@ -714,6 +714,66 @@ Word16 getScaleFactor16( /* o: measured headroom in range [
    return i;
}

#ifdef OPTIMIZE_FFT_STACK
/* o: measured headroom in range [0..31], 0 if all x[i] == 0 */
Word16 getScaleFactor32_cmplx(
    cmplx *x,          /* i: array containing 32-bit data */
    const Word16 len_x /* i: length of the array to scan  */
)
{
    Word16 i, i_min, i_max, i_re, i_im;
    Word32 x_min_re, x_max_re, x_min_im, x_max_im;

    x_max_re = 0;
    move32();
    x_min_re = 0;
    move32();
    x_max_im = 0;
    move32();
    x_min_im = 0;
    move32();
    FOR( i = 0; i < len_x; i++ )
    {
        if ( x[i].re >= 0 )
            x_max_re = L_max( x_max_re, x[i].re );
        if ( x[i].re < 0 )
            x_min_re = L_min( x_min_re, x[i].re );
        if ( x[i].im >= 0 )
            x_max_im = L_max( x_max_im, x[i].im );
        if ( x[i].im < 0 )
            x_min_im = L_min( x_min_im, x[i].im );
    }

    i_max = 0x20;
    move16();
    i_min = 0x20;
    move16();

    if ( x_max_re != 0 )
        i_max = norm_l( x_max_re );

    if ( x_min_re != 0 )
        i_min = norm_l( x_min_re );

    i_re = s_and( s_min( i_max, i_min ), 0x1F );

    i_max = 0x20;
    move16();
    i_min = 0x20;
    move16();

    if ( x_max_im != 0 )
        i_max = norm_l( x_max_im );

    if ( x_min_im != 0 )
        i_min = norm_l( x_min_im );

    i_im = s_and( s_min( i_max, i_min ), 0x1F );

    return s_min( i_re, i_im );
}
#endif


/********************************************************************/
/*!
+12 −3
Original line number Diff line number Diff line
@@ -216,10 +216,19 @@ void BASOP_Util_Sqrt_InvSqrt_MantExp( Word16 mantissa, /*!< mantissa */
    and   -32768 <= x <= -16384 for negative x
*/

Word16 getScaleFactor16(                       /* o: measured headroom in range [0..15], 0 if all x[i] == 0 */
/* o: measured headroom in range [0..15], 0 if all x[i] == 0 */
Word16 getScaleFactor16(
    const Word16 *x,      /* i: array containing 16-bit data */
    const Word16 len_x ); /* i: length of the array to scan  */

#ifdef OPTIMIZE_FFT_STACK
/* o: measured headroom in range [0..31], 0 if all x[i] == 0 */
Word16 getScaleFactor32_cmplx(
    cmplx *x,          /* i: array containing 32-bit data */
    const Word16 len_x /* i: length of the array to scan  */
);
#endif

/********************************************************************/
/*!
  \brief   Calculates the scalefactor needed to normalize input array
+1 −1
Original line number Diff line number Diff line
@@ -270,7 +270,7 @@ void edct_fx(
    {
        *q = sub( 31, *q );
        move16();
        tmp = sub( getScaleFactor32( (Word32 *) spec, shl( len1, 1 ) ), find_guarded_bits_fx( len1 ) );
        tmp = sub( getScaleFactor32_cmplx( spec, len1 ), find_guarded_bits_fx( len1 ) );
        scale_sig32_cmplx( spec, len1, tmp );

        fft_fx( spec, len1 );