DSP: Fix bug in scaled non-power-of-2 fixed-point FFT
authorPhil.Wang <phil.wang@arm.com>
Fri, 3 Apr 2015 02:28:58 +0000 (10:28 +0800)
committerPhil.Wang <phil.wang@arm.com>
Fri, 3 Apr 2015 02:28:58 +0000 (10:28 +0800)
    Without this patch, the non-power-of-2 fixed-point FFT does scale
    the output even when the scaled_flag is set to 1.

Change-Id: I0e373f1d2ff110b64905902acf7529eafc2cba19

modules/dsp/NE10_fft_generic_int32.neonintrinsic.h

index c28265d..b46b79f 100644 (file)
@@ -421,7 +421,7 @@ static __attribute__ ((noinline)) void ne10_radix_butterfly_int32_neon (
 
             if (is_scaled)
             {
-                NE10_FFT_SCALING<RADIX> (out);
+                NE10_FFT_SCALING<RADIX> () (out);
             }
 
             NE10_STORE_BY_STEP<RADIX, CPLX> (Fout, out, out_step);
@@ -693,6 +693,19 @@ static void ne10_c2c_1d_last_stage_neon (CPLX *Fout,
             scratch_in[3].i = -scratch_in[3].i;
         }
 
+        if (is_scaled)
+        {
+            scratch_in[0].r = scratch_in[0].r >> 2;
+            scratch_in[1].r = scratch_in[1].r >> 2;
+            scratch_in[2].r = scratch_in[2].r >> 2;
+            scratch_in[3].r = scratch_in[3].r >> 2;
+
+            scratch_in[0].i = scratch_in[0].i >> 2;
+            scratch_in[1].i = scratch_in[1].i >> 2;
+            scratch_in[2].i = scratch_in[2].i >> 2;
+            scratch_in[3].i = scratch_in[3].i >> 2;
+        }
+
         Fout_s[0 * out_step] = scratch_in[0];
         Fout_s[1 * out_step] = scratch_in[1];
         Fout_s[2 * out_step] = scratch_in[2];