Commit ff40d61c authored by norvell's avatar norvell
Browse files

Added _sat in fft3_fx within FIX_2170_ASSERT_IN_FFT3

parent ba2aad75
Loading
Loading
Loading
Loading
Loading
+188 −71
Original line number Diff line number Diff line
@@ -2322,19 +2322,35 @@ void fft3_fx( const Word16 X[] /*Qx*/, Word16 Y[] /*Qx*/, const Word16 n )
    l = sub( shr( n, 3 ), 1 ); /* (3*m/8) - 1 = (n/8) - 1 */
    FOR( i = 0; i < l; i++ )
    {
#ifdef FIX_2170_ASSERT_IN_FFT3
        acc = L_shl_sat( *RZ0++, 15 );                /* Align with the following non-fractional mode so as to gain 1 more bit headroom. Q15 + Qx*/
        acc = L_mac0_sat( acc, *RZ1, t_sin[c1_ind] ); /* Non-fractional mode gains 1 more bit headroom. Q15 + Qx*/
        acc = L_mac0_sat( acc, *IZ1, t_sin[s1_ind] ); // Q15 + Qx
        acc = L_mac0_sat( acc, *RZ2, t_sin[c2_ind] ); // Q15 + Qx
        acc = L_mac0_sat( acc, *IZ2, t_sin[s2_ind] ); // Q15 + Qx
#else
        acc = L_shl( *RZ0++, 15 );                  /* Align with the following non-fractional mode so as to gain 1 more bit headroom. Q15 + Qx*/
        acc = L_mac0( acc, *RZ1, t_sin[c1_ind] );   /* Non-fractional mode gains 1 more bit headroom. Q15 + Qx*/
        acc = L_mac0( acc, *IZ1, t_sin[s1_ind] );   // Q15 + Qx
        acc = L_mac0( acc, *RZ2, t_sin[c2_ind] );   // Q15 + Qx
        acc = L_mac0( acc, *IZ2, t_sin[s2_ind] );   // Q15 + Qx
#endif
        *RY++ = round_fx( acc ); /* bit growth = 1 (compensated by non-fractional mode MAC). Qx - 1*/
        move16();

#ifdef FIX_2170_ASSERT_IN_FFT3
        acc = L_shl_sat( *IZ0--, 15 );                  // Q15 + Qx
        acc = L_msu0_sat( acc, *RZ1++, t_sin[s1_ind] ); // Q15 + Qx
        acc = L_mac0_sat( acc, *IZ1--, t_sin[c1_ind] ); // Q15 + Qx
        acc = L_msu0_sat( acc, *RZ2++, t_sin[s2_ind] ); // Q15 + Qx
        acc = L_mac0_sat( acc, *IZ2--, t_sin[c2_ind] ); // Q15 + Qx
#else
        acc = L_shl( *IZ0--, 15 );                  // Q15 + Qx
        acc = L_msu0( acc, *RZ1++, t_sin[s1_ind] ); // Q15 + Qx
        acc = L_mac0( acc, *IZ1--, t_sin[c1_ind] ); // Q15 + Qx
        acc = L_msu0( acc, *RZ2++, t_sin[s2_ind] ); // Q15 + Qx
        acc = L_mac0( acc, *IZ2--, t_sin[c2_ind] ); // Q15 + Qx
#endif
        *IY-- = round_fx( acc ); // Qx - 1
        move16();

@@ -2348,19 +2364,35 @@ void fft3_fx( const Word16 X[] /*Qx*/, Word16 Y[] /*Qx*/, const Word16 n )
    l = shr( m, 3 ); /* (4*m/8) - (3*m/8) = m/8 */
    FOR( i = 0; i < l; i++ )
    {
#ifdef FIX_2170_ASSERT_IN_FFT3
        acc = L_shl_sat( *RZ0++, 15 );                // Q15 + Qx
        acc = L_mac0_sat( acc, *RZ1, t_sin[c1_ind] ); /* Non-fractional mode gains 1 more bit headroom. Q15 + Qx*/
        acc = L_mac0_sat( acc, *IZ1, t_sin[s1_ind] ); // Q15 + Qx
        acc = L_msu0_sat( acc, *RZ2, t_sin[c2_ind] ); // Q15 + Qx
        acc = L_mac0_sat( acc, *IZ2, t_sin[s2_ind] ); // Q15 + Qx
#else
        acc = L_shl( *RZ0++, 15 );                  // Q15 + Qx
        acc = L_mac0( acc, *RZ1, t_sin[c1_ind] );   /* Non-fractional mode gains 1 more bit headroom. Q15 + Qx*/
        acc = L_mac0( acc, *IZ1, t_sin[s1_ind] );   // Q15 + Qx
        acc = L_msu0( acc, *RZ2, t_sin[c2_ind] );   // Q15 + Qx
        acc = L_mac0( acc, *IZ2, t_sin[s2_ind] );   // Q15 + Qx
#endif
        *RY++ = round_fx( acc ); // Qx - 1
        move16();

#ifdef FIX_2170_ASSERT_IN_FFT3
        acc = L_shl_sat( *IZ0--, 15 );                  // Q15 + Qx
        acc = L_msu0_sat( acc, *RZ1++, t_sin[s1_ind] ); // Q15 + Qx
        acc = L_mac0_sat( acc, *IZ1--, t_sin[c1_ind] ); // Q15 + Qx
        acc = L_msu0_sat( acc, *RZ2++, t_sin[s2_ind] ); // Q15 + Qx
        acc = L_msu0_sat( acc, *IZ2--, t_sin[c2_ind] ); // Q15 + Qx
#else
        acc = L_shl( *IZ0--, 15 );                  // Q15 + Qx
        acc = L_msu0( acc, *RZ1++, t_sin[s1_ind] ); // Q15 + Qx
        acc = L_mac0( acc, *IZ1--, t_sin[c1_ind] ); // Q15 + Qx
        acc = L_msu0( acc, *RZ2++, t_sin[s2_ind] ); // Q15 + Qx
        acc = L_msu0( acc, *IZ2--, t_sin[c2_ind] ); // Q15 + Qx
#endif
        *IY-- = round_fx( acc ); // Qx - 1
        move16();

@@ -2371,9 +2403,15 @@ void fft3_fx( const Word16 X[] /*Qx*/, Word16 Y[] /*Qx*/, const Word16 n )
    }

    /* special case: i = m/2 i.e. 1/3 */
#ifdef FIX_2170_ASSERT_IN_FFT3
    acc = L_shl_sat( *RZ0--, 15 );                // Q15 + Qx
    acc = L_mac0_sat( acc, *RZ1, t_sin[c1_ind] ); // Q15 + Qx
    acc = L_msu0_sat( acc, *RZ2, t_sin[c2_ind] ); // Q15 + Qx
#else
    acc = L_shl( *RZ0--, 15 );                      // Q15 + Qx
    acc = L_mac0( acc, *RZ1, t_sin[c1_ind] );       // Q15 + Qx
    acc = L_msu0( acc, *RZ2, t_sin[c2_ind] );       // Q15 + Qx
#endif
    *RY++ = round_fx( acc ); // Qx - 1
    move16();

@@ -2396,19 +2434,34 @@ void fft3_fx( const Word16 X[] /*Qx*/, Word16 Y[] /*Qx*/, const Word16 n )
    l = sub( shr( m, 2 ), 1 ); /* (6*m/8) - ((m/2)+1) = m/4 - 1 */
    FOR( i = 0; i < l; i++ )
    {
#ifdef FIX_2170_ASSERT_IN_FFT3
        acc = L_shl_sat( *RZ0--, 15 );                // Q15 + Qx
        acc = L_mac0_sat( acc, *RZ1, t_sin[c1_ind] ); /* Non-fractional mode gains 1 more bit headroom. Q15 + Qx*/
        acc = L_msu0_sat( acc, *IZ1, t_sin[s1_ind] ); // Q15 + Qx
        acc = L_msu0_sat( acc, *RZ2, t_sin[c2_ind] ); // Q15 + Qx
        acc = L_msu0_sat( acc, *IZ2, t_sin[s2_ind] ); // Q15 + Qx
#else
        acc = L_shl( *RZ0--, 15 );                  // Q15 + Qx
        acc = L_mac0( acc, *RZ1, t_sin[c1_ind] );   /* Non-fractional mode gains 1 more bit headroom. Q15 + Qx*/
        acc = L_msu0( acc, *IZ1, t_sin[s1_ind] );   // Q15 + Qx
        acc = L_msu0( acc, *RZ2, t_sin[c2_ind] );   // Q15 + Qx
        acc = L_msu0( acc, *IZ2, t_sin[s2_ind] );   // Q15 + Qx
#endif
        *RY++ = round_fx( acc ); // Qx - 1
        move16();

        acc = L_mult0( *IZ0++, -32768 ); // Q15 + Qx
#ifdef FIX_2170_ASSERT_IN_FFT3
        acc = L_msu0_sat( acc, *RZ1--, t_sin[s1_ind] ); // Q15 + Qx
        acc = L_msu0_sat( acc, *IZ1++, t_sin[c1_ind] ); // Q15 + Qx
        acc = L_msu0_sat( acc, *RZ2--, t_sin[s2_ind] ); // Q15 + Qx
        acc = L_mac0_sat( acc, *IZ2++, t_sin[c2_ind] ); // Q15 + Qx
#else
        acc = L_msu0( acc, *RZ1--, t_sin[s1_ind] ); // Q15 + Qx
        acc = L_msu0( acc, *IZ1++, t_sin[c1_ind] ); // Q15 + Qx
        acc = L_msu0( acc, *RZ2--, t_sin[s2_ind] ); // Q15 + Qx
        acc = L_mac0( acc, *IZ2++, t_sin[c2_ind] ); // Q15 + Qx
#endif
        *IY-- = round_fx( acc ); // Qx - 1
        move16();

@@ -2423,19 +2476,34 @@ void fft3_fx( const Word16 X[] /*Qx*/, Word16 Y[] /*Qx*/, const Word16 n )
    l = shr( m, 2 );
    FOR( i = 0; i < l; i++ )
    {
#ifdef FIX_2170_ASSERT_IN_FFT3
        acc = L_shl_sat( *RZ0--, 15 );                // Q15 + Qx
        acc = L_msu0_sat( acc, *RZ1, t_sin[c1_ind] ); /* Non-fractional mode gains 1 more bit headroom. Q15 + Qx*/
        acc = L_msu0_sat( acc, *IZ1, t_sin[s1_ind] ); // Q15 + Qx
        acc = L_msu0_sat( acc, *RZ2, t_sin[c2_ind] ); // Q15 + Qx
        acc = L_mac0_sat( acc, *IZ2, t_sin[s2_ind] ); // Q15 + Qx
#else
        acc = L_shl( *RZ0--, 15 );                  // Q15 + Qx
        acc = L_msu0( acc, *RZ1, t_sin[c1_ind] );   /* Non-fractional mode gains 1 more bit headroom. Q15 + Qx*/
        acc = L_msu0( acc, *IZ1, t_sin[s1_ind] );   // Q15 + Qx
        acc = L_msu0( acc, *RZ2, t_sin[c2_ind] );   // Q15 + Qx
        acc = L_mac0( acc, *IZ2, t_sin[s2_ind] );   // Q15 + Qx
#endif
        *RY++ = round_fx( acc ); // Qx - 1
        move16();

        acc = L_mult0( *IZ0++, -32768 ); // Q15 + Qx
#ifdef FIX_2170_ASSERT_IN_FFT3
        acc = L_msu0_sat( acc, *RZ1--, t_sin[s1_ind] ); // Q15 + Qx
        acc = L_mac0_sat( acc, *IZ1++, t_sin[c1_ind] ); // Q15 + Qx
        acc = L_mac0_sat( acc, *RZ2--, t_sin[s2_ind] ); // Q15 + Qx
        acc = L_mac0_sat( acc, *IZ2++, t_sin[c2_ind] ); // Q15 + Qx
#else
        acc = L_msu0( acc, *RZ1--, t_sin[s1_ind] ); // Q15 + Qx
        acc = L_mac0( acc, *IZ1++, t_sin[c1_ind] ); // Q15 + Qx
        acc = L_mac0( acc, *RZ2--, t_sin[s2_ind] ); // Q15 + Qx
        acc = L_mac0( acc, *IZ2++, t_sin[c2_ind] ); // Q15 + Qx
#endif
        *IY-- = round_fx( acc ); // Qx - 1
        move16();

@@ -2446,15 +2514,26 @@ void fft3_fx( const Word16 X[] /*Qx*/, Word16 Y[] /*Qx*/, const Word16 n )
    }

    /* special case: i = m, i.e 2/3 */
#ifdef FIX_2170_ASSERT_IN_FFT3
    acc = L_shl_sat( *RZ0++, 15 );                // Q15 + Qx
    acc = L_msu0_sat( acc, *RZ1, t_sin[c1_ind] ); // Q15 + Qx
    acc = L_msu0_sat( acc, *RZ2, t_sin[c2_ind] ); // Q15 + Qx
#else
    acc = L_shl( *RZ0++, 15 );                      // Q15 + Qx
    acc = L_msu0( acc, *RZ1, t_sin[c1_ind] );       // Q15 + Qx
    acc = L_msu0( acc, *RZ2, t_sin[c2_ind] );       // Q15 + Qx
#endif
    *RY++ = round_fx( acc ); // Qx - 1
    move16();

    acc = L_deposit_l( 0 );
#ifdef FIX_2170_ASSERT_IN_FFT3
    acc = L_msu0_sat( acc, *RZ1++, t_sin[s1_ind] ); // Q15 + Qx
    acc = L_mac0_sat( acc, *RZ2++, t_sin[s2_ind] ); // Q15 + Qx
#else
    acc = L_msu0( acc, *RZ1++, t_sin[s1_ind] );     // Q15 + Qx
    acc = L_mac0( acc, *RZ2++, t_sin[s2_ind] );     // Q15 + Qx
#endif
    *IY-- = round_fx( acc ); // Qx - 1
    move16();
    IZ0--; /* Just decrement the address counter */
@@ -2470,19 +2549,35 @@ void fft3_fx( const Word16 X[] /*Qx*/, Word16 Y[] /*Qx*/, const Word16 n )
    l = sub( shr( m, 3 ), 1 ); /* (9*m/8) - (m +1) = m/8 - 1 */
    FOR( i = 0; i < l; i++ )
    {
#ifdef FIX_2170_ASSERT_IN_FFT3
        acc = L_shl_sat( *RZ0++, 15 );                // Q15 + Qx
        acc = L_msu0_sat( acc, *RZ1, t_sin[c1_ind] ); /* Non-fractional mode gains 1 more bit headroom. Q15 + Qx*/
        acc = L_mac0_sat( acc, *IZ1, t_sin[s1_ind] ); // Q15 + Qx
        acc = L_msu0_sat( acc, *RZ2, t_sin[c2_ind] ); // Q15 + Qx
        acc = L_msu0_sat( acc, *IZ2, t_sin[s2_ind] ); // Q15 + Qx
#else
        acc = L_shl( *RZ0++, 15 );                  // Q15 + Qx
        acc = L_msu0( acc, *RZ1, t_sin[c1_ind] );   /* Non-fractional mode gains 1 more bit headroom. Q15 + Qx*/
        acc = L_mac0( acc, *IZ1, t_sin[s1_ind] );   // Q15 + Qx
        acc = L_msu0( acc, *RZ2, t_sin[c2_ind] );   // Q15 + Qx
        acc = L_msu0( acc, *IZ2, t_sin[s2_ind] );   // Q15 + Qx
#endif
        *RY++ = round_fx( acc ); // Qx - 1
        move16();

#ifdef FIX_2170_ASSERT_IN_FFT3
        acc = L_shl_sat( *IZ0--, 15 );                  // Q15 + Qx
        acc = L_msu0_sat( acc, *RZ1++, t_sin[s1_ind] ); // Q15 + Qx
        acc = L_msu0_sat( acc, *IZ1--, t_sin[c1_ind] ); // Q15 + Qx
        acc = L_mac0_sat( acc, *RZ2++, t_sin[s2_ind] ); // Q15 + Qx
        acc = L_msu0_sat( acc, *IZ2--, t_sin[c2_ind] ); // Q15 + Qx
#else
        acc = L_shl( *IZ0--, 15 );                  // Q15 + Qx
        acc = L_msu0( acc, *RZ1++, t_sin[s1_ind] ); // Q15 + Qx
        acc = L_msu0( acc, *IZ1--, t_sin[c1_ind] ); // Q15 + Qx
        acc = L_mac0( acc, *RZ2++, t_sin[s2_ind] ); // Q15 + Qx
        acc = L_msu0( acc, *IZ2--, t_sin[c2_ind] ); // Q15 + Qx
#endif
        *IY-- = round_fx( acc ); // Qx - 1
        move16();

@@ -2496,19 +2591,35 @@ void fft3_fx( const Word16 X[] /*Qx*/, Word16 Y[] /*Qx*/, const Word16 n )
    l = shr( n, 3 ); /* (12*m/8) - (9*m/8) = 3*m/8 = n/8 */
    FOR( i = 0; i < l; i++ )
    {
#ifdef FIX_2170_ASSERT_IN_FFT3
        acc = L_shl_sat( *RZ0++, 15 );                // Q15 + Qx
        acc = L_msu0_sat( acc, *RZ1, t_sin[c1_ind] ); /* Non-fractional mode gains 1 more bit headroom. Q15 + Qx*/
        acc = L_mac0_sat( acc, *IZ1, t_sin[s1_ind] ); // Q15 + Qx
        acc = L_mac0_sat( acc, *RZ2, t_sin[c2_ind] ); // Q15 + Qx
        acc = L_msu0_sat( acc, *IZ2, t_sin[s2_ind] ); // Q15 + Qx
#else
        acc = L_shl( *RZ0++, 15 );                  // Q15 + Qx
        acc = L_msu0( acc, *RZ1, t_sin[c1_ind] );   /* Non-fractional mode gains 1 more bit headroom. Q15 + Qx*/
        acc = L_mac0( acc, *IZ1, t_sin[s1_ind] );   // Q15 + Qx
        acc = L_mac0( acc, *RZ2, t_sin[c2_ind] );   // Q15 + Qx
        acc = L_msu0( acc, *IZ2, t_sin[s2_ind] );   // Q15 + Qx
#endif
        *RY++ = round_fx( acc ); // Qx - 1
        move16();

#ifdef FIX_2170_ASSERT_IN_FFT3
        acc = L_shl_sat( *IZ0--, 15 );                  // Q15 + Qx
        acc = L_msu0_sat( acc, *RZ1++, t_sin[s1_ind] ); // Q15 + Qx
        acc = L_msu0_sat( acc, *IZ1--, t_sin[c1_ind] ); // Q15 + Qx
        acc = L_mac0_sat( acc, *RZ2++, t_sin[s2_ind] ); // Q15 + Qx
        acc = L_mac0_sat( acc, *IZ2--, t_sin[c2_ind] ); // Q15 + Qx
#else
        acc = L_shl( *IZ0--, 15 );                  // Q15 + Qx
        acc = L_msu0( acc, *RZ1++, t_sin[s1_ind] ); // Q15 + Qx
        acc = L_msu0( acc, *IZ1--, t_sin[c1_ind] ); // Q15 + Qx
        acc = L_mac0( acc, *RZ2++, t_sin[s2_ind] ); // Q15 + Qx
        acc = L_mac0( acc, *IZ2--, t_sin[c2_ind] ); // Q15 + Qx
#endif
        *IY-- = round_fx( acc ); // Qx - 1
        move16();

@@ -2519,9 +2630,15 @@ void fft3_fx( const Word16 X[] /*Qx*/, Word16 Y[] /*Qx*/, const Word16 n )
    }

    /* special case: i = 3*m/2 */
#ifdef FIX_2170_ASSERT_IN_FFT3
    acc = L_shl_sat( *RZ0, 15 );                  // Q15 + Qx
    acc = L_msu0_sat( acc, *RZ1, t_sin[c1_ind] ); // Q15 + Qx
    acc = L_mac0_sat( acc, *RZ2, t_sin[c2_ind] ); // Q15 + Qx
#else
    acc = L_shl( *RZ0, 15 );                        // Q15 + Qx
    acc = L_msu0( acc, *RZ1, t_sin[c1_ind] );       // Q15 + Qx
    acc = L_mac0( acc, *RZ2, t_sin[c2_ind] );       // Q15 + Qx
#endif
    *RY = round_fx( acc ); // Qx - 1
    move16();

+1 −0
Original line number Diff line number Diff line
@@ -86,6 +86,7 @@
#define FIX_2166_ASSERT_OSBA_PLC_STEREO_OUT                  /* FhG: fix for issue 2166 - add missing averaging factor 0.5 in for the sum of energies in function stereo_dft_dmx_swb_nrg_fx()*/

#define FIX_1793_DEC_MC_TO_MONO_SCALING_ISSUE                /* FhG: Use dynamic Q factor for synth_fx and synthFB_fx to prevent overflow */
#define FIX_2170_ASSERT_IN_FFT3                              /* Eri: Assert in fft3_fx from EVS, adding _sat */
/* ################### End FIXES switches ########################### */

/* #################### Start BASOP porting switches ############################ */
+4 −0
Original line number Diff line number Diff line
@@ -2142,7 +2142,11 @@ static void ivas_subst_spec_fx(
            im = *pImX;
            move16();
            tmp = sub_sat( mult_r( re, cos_F ), mult_r( im, sin_F ) );
#ifdef FIX_2170_ASSERT_IN_FFT3
            im = add_sat( mult_r( re, sin_F ), mult_r( im, cos_F ) );
#else
            im = add( mult_r( re, sin_F ), mult_r( im, cos_F ) );
#endif
            IF( LT_16( alpha[k], 32766 ) )
            {
                alpha_local = mag_chg_local;