1/*
2 *  Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 *
4 *  Use of this source code is governed by a BSD-style license
5 *  that can be found in the LICENSE file in the root of the source
6 *  tree. An additional intellectual property rights grant can be found
7 *  in the file PATENTS.  All contributing project authors may
8 *  be found in the AUTHORS file in the root of the source tree.
9 *
10 */
11
12#include "dl/api/omxtypes.h"
13
14void x86SP_FFT_CToC_FC32_Fwd_Radix4_fs(
15    const OMX_F32 *in,
16    OMX_F32 *out,
17    OMX_INT n) {
18  OMX_INT i;
19  OMX_INT n_by_4 = n >> 2;
20
21  // Transform from interleaved format to split format.
22  for (i = 0; i < n; i++) {
23    out[i] = in[i << 1];
24    out[i + n] = in[(i << 1) + 1];
25  }
26
27  // As we have already moved data from [in] to [out],
28  // next calculation will be produced in in-place mode.
29  for (i = 0; i < n_by_4; i++) {
30    OMX_F32 *out0 = out + i;
31    OMX_F32 *out1 = out0 + n_by_4;
32    OMX_F32 *out2 = out1 + n_by_4;
33    OMX_F32 *out3 = out2 + n_by_4;
34
35    OMX_FC32 t0;
36    OMX_FC32 t1;
37    OMX_FC32 t2;
38    OMX_FC32 t3;
39
40    // CADD t0, out0, out2
41    t0.Re = out0[0] + out2[0];
42    t0.Im = out0[n] + out2[n];
43
44    // CSUB t1, out0, out2
45    t1.Re = out0[0] - out2[0];
46    t1.Im = out0[n] - out2[n];
47
48    // CADD t2, out1, out3
49    t2.Re = out1[0] + out3[0];
50    t2.Im = out1[n] + out3[n];
51
52    // CSUB t3, out1, out3
53    t3.Re = out1[0] - out3[0];
54    t3.Im = out1[n] - out3[n];
55
56    // CADD out0, t0, t2
57    out0[0] = t0.Re + t2.Re;
58    out0[n] = t0.Im + t2.Im;
59
60    // CSUB out2, t0, t2
61    out2[0] = t0.Re - t2.Re;
62    out2[n] = t0.Im - t2.Im;
63
64    // CADD_SUB_X out1, t1, t3
65    out1[0] = t1.Re + t3.Im;
66    out1[n] = t1.Im - t3.Re;
67
68    // CSUB_ADD_X out3, t1, t3
69    out3[0] = t1.Re - t3.Im;
70    out3[n] = t1.Im + t3.Re;
71  }
72}
73