Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: third_party/openmax_dl/dl/sp/src/omxSP_FFTInit_C_FC32.c

Issue 12317152: Add openmax dl routines for review. MUST NOT BE LANDED (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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 * This is a modification of omxSP_FFTInit_C_SC32.c to support
11 * complex float instead of SC32.
12 */
13
14 #include "dl/api/armCOMM.h"
15 #include "dl/api/armOMX.h"
16 #include "dl/api/omxtypes.h"
17 #include "dl/sp/api/armSP.h"
18 #include "dl/sp/api/omxSP.h"
19
20
21 /**
22 * Function: omxSP_FFTInit_C_FC32
23 *
24 * Description:
25 * Initializes the specification structures required for the
26 * complex FFT and IFFT functions.
27 *
28 * Remarks:
29 * Desired block length is specified as an input. The function is used to
30 * initialize the specification structures for functions <FFTFwd_CToC_FC32_Sfs>
31 * and <FFTInv_CToC_FC32_Sfs>. Memory for the specification structure *pFFTSpec
32 * must be allocated prior to calling this function. The space required for
33 * *pFFTSpec, in bytes, can be determined using <FFTGetBufSize_C_FC32>.
34 *
35 * Parameters:
36 * [in] order base-2 logarithm of the desired block length;
37 * valid in the range [0,12].
38 * [out] pFFTSpec pointer to initialized specification structure.
39 *
40 * Return Value:
41 * Standard omxError result. See enumeration for possible result codes.
42 *
43 */
44
45 OMXResult omxSP_FFTInit_C_FC32(OMXFFTSpec_C_FC32* pFFTSpec, OMX_INT order) {
46 OMX_INT i;
47 OMX_INT j;
48 OMX_FC32* pTwiddle;
49 OMX_FC32* pBuf;
50 OMX_U16* pBitRev;
51 OMX_U32 pTmp;
52 OMX_INT Nby2;
53 OMX_INT N;
54 OMX_INT M;
55 OMX_INT diff;
56 OMX_INT step;
57 ARMsFFTSpec_FC32* pFFTStruct = 0;
58 OMX_F32 x;
59 OMX_F32 y;
60 OMX_F32 xNeg;
61
62 pFFTStruct = (ARMsFFTSpec_FC32 *) pFFTSpec;
63
64 /* if order zero no init is needed */
65 if (order == 0) {
66 pFFTStruct->N = 1;
67 return OMX_Sts_NoErr;
68 }
69
70 /* Validate args */
71 if (!pFFTSpec || (order < 0) || (order > TWIDDLE_TABLE_ORDER))
72 return OMX_Sts_BadArgErr;
73
74 /* Do the initializations */
75 Nby2 = 1 << (order - 1);
76 N = Nby2 << 1;
77 M = N >> 3;
78
79 /* optimized implementations don't use bitreversal */
80 pBitRev = NULL;
81
82 pTwiddle = (OMX_FC32 *) (sizeof(ARMsFFTSpec_FC32) + (OMX_S8*) pFFTSpec);
83
84 /* Align to 32 byte boundary */
85 pTmp = ((OMX_U32) pTwiddle) & 31;
86 if (pTmp)
87 pTwiddle = (OMX_FC32*) ((OMX_S8*)pTwiddle + (32 - pTmp));
88
89 pBuf = (OMX_FC32*) (sizeof(OMX_FC32) * (3 * N / 4) + (OMX_S8*) pTwiddle);
90
91 /* Align to 32 byte boundary */
92 pTmp = ((OMX_U32)pBuf) & 31;
93 if (pTmp)
94 pBuf = (OMX_FC32*) ((OMX_S8*)pBuf + (32 - pTmp));
95
96 /*
97 * Filling Twiddle factors :
98 *
99 * The original twiddle table "armSP_FFT_S32TwiddleTable" is of size
100 * (MaxSize/8 + 1) Rest of the values i.e., upto MaxSize are
101 * calculated using the symmetries of sin and cos The max size of
102 * the twiddle table needed is 3N/4 for a radix-4 stage
103 *
104 * W = (-2 * PI) / N
105 * N = 1 << order
106 * W = -PI >> (order - 1)
107 */
108
109 diff = TWIDDLE_TABLE_ORDER - order;
110 /* step into the twiddle table for the current order */
111 step = 1 << diff;
112
113 x = armSP_FFT_F32TwiddleTable[0];
114 y = armSP_FFT_F32TwiddleTable[1];
115 xNeg = 1;
116
117 if (order >= 3) {
118 /* i = 0 case */
119 pTwiddle[0].Re = x;
120 pTwiddle[0].Im = y;
121 pTwiddle[2 * M].Re = -y;
122 pTwiddle[2 * M].Im = xNeg;
123 pTwiddle[4 * M].Re = xNeg;
124 pTwiddle[4 * M].Im = y;
125
126 for (i = 1; i <= M; i++) {
127 j = i * step;
128
129 x = armSP_FFT_F32TwiddleTable[2 * j];
130 y = armSP_FFT_F32TwiddleTable[2 * j + 1];
131
132 pTwiddle[i].Re = x;
133 pTwiddle[i].Im = y;
134 pTwiddle[2 * M - i].Re = -y;
135 pTwiddle[2 * M - i].Im = -x;
136 pTwiddle[2 * M + i].Re = y;
137 pTwiddle[2 * M + i].Im = -x;
138 pTwiddle[4 * M - i].Re = -x;
139 pTwiddle[4 * M - i].Im = y;
140 pTwiddle[4 * M + i].Re = -x;
141 pTwiddle[4 * M + i].Im = -y;
142 pTwiddle[6 * M - i].Re = y;
143 pTwiddle[6 * M - i].Im = x;
144 }
145 } else if (order == 2) {
146 pTwiddle[0].Re = x;
147 pTwiddle[0].Im = y;
148 pTwiddle[1].Re = -y;
149 pTwiddle[1].Im = xNeg;
150 pTwiddle[2].Re = xNeg;
151 pTwiddle[2].Im = y;
152 } else if (order == 1) {
153 pTwiddle[0].Re = x;
154 pTwiddle[0].Im = y;
155 }
156
157 /* Update the structure */
158 pFFTStruct->N = N;
159 pFFTStruct->pTwiddle = pTwiddle;
160 pFFTStruct->pBitRev = pBitRev;
161 pFFTStruct->pBuf = pBuf;
162
163 return OMX_Sts_NoErr;
164 }
165
166 /*****************************************************************************
167 * END OF FILE
168 *****************************************************************************/
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698