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_Inv_Radix4_ls(
15    const OMX_F32 *in,
16    OMX_F32 *out,
17    const OMX_F32 *twiddle,
18    OMX_INT n) {
19  OMX_INT n_by_2 = n >> 1;
20  OMX_INT n_by_4 = n >> 2;
21  OMX_INT n_mul_2 = n << 1;
22  OMX_INT i;
23  OMX_F32 *out0 = out;
24
25  for (i = 0; i < n_by_2; i += 2) {
26    OMX_FC32 t0;
27    OMX_FC32 t1;
28    OMX_FC32 t2;
29    OMX_FC32 t3;
30    OMX_FC32 tt1;
31    OMX_FC32 tt2;
32    OMX_FC32 tt3;
33    const OMX_F32 *tw1 = twiddle + i;
34    const OMX_F32 *tw2 = tw1 + i;
35    const OMX_F32 *tw3 = tw2 + i;
36    const OMX_F32 *in0 = in + (i << 1);
37    const OMX_F32 *in1 = in0 + 1;
38    const OMX_F32 *in2 = in1 + 1;
39    const OMX_F32 *in3 = in2 + 1;
40    OMX_F32 *out1 = out0 + n_by_4;
41    OMX_F32 *out2 = out1 + n_by_4;
42    OMX_F32 *out3 = out2 + n_by_4;
43
44    // CMUL tt1, Tw1, in1
45    tt1.Re = tw1[0] * in1[0] + tw1[n_mul_2] * in1[n];
46    tt1.Im = tw1[0] * in1[n] - tw1[n_mul_2] * in1[0];
47
48    // CMUL tt2, Tw2, in2
49    tt2.Re = tw2[0] * in2[0] + tw2[n_mul_2] * in2[n];
50    tt2.Im = tw2[0] * in2[n] - tw2[n_mul_2] * in2[0];
51
52    // CMUL tt3, Tw3, in3
53    tt3.Re = tw3[0] * in3[0] + tw3[n_mul_2] * in3[n];
54    tt3.Im = tw3[0] * in3[n] - tw3[n_mul_2] * in3[0];
55
56    // CADD t0, in0, tt2
57    t0.Re = in0[0] + tt2.Re;
58    t0.Im = in0[n] + tt2.Im;
59
60    // CSUB t1, in0, tt2
61    t1.Re = in0[0] - tt2.Re;
62    t1.Im = in0[n] - tt2.Im;
63
64    // CADD t2, tt1, tt3
65    t2.Re = tt1.Re + tt3.Re;
66    t2.Im = tt1.Im + tt3.Im;
67
68    // CSUB t3, tt1, tt3
69    t3.Re = tt1.Re - tt3.Re;
70    t3.Im = tt1.Im - tt3.Im;
71
72    // CADD out0, t0, t2
73    out0[0] = t0.Re + t2.Re;
74    out0[n] = t0.Im + t2.Im;
75
76    // CSUB out2, t0, t2
77    out2[0] = t0.Re - t2.Re;
78    out2[n] = t0.Im - t2.Im;
79
80    // CSUB_ADD_X out1, t1, t3
81    out1[0] = t1.Re - t3.Im;
82    out1[n] = t1.Im + t3.Re;
83
84    // CADD_SUB_X out3, t1, t3
85    out3[0] = t1.Re + t3.Im;
86    out3[n] = t1.Im - t3.Re;
87
88    out0 += 1;
89  }
90}
91