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

Side by Side Diff: third_party/openmax_dl/dl/sp/src/omxSP_FFTInit_R_F32.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_R_S32.c to support float
11 * instead of S32.
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 * Function: omxSP_FFTInit_R_F32
22 *
23 * Description:
24 * Initialize the real forward-FFT specification information struct.
25 *
26 * Remarks:
27 * This function is used to initialize the specification structures
28 * for functions <ippsFFTFwd_RToCCS_F32_Sfs> and
29 * <ippsFFTInv_CCSToR_F32_Sfs>. Memory for *pFFTSpec must be
30 * allocated prior to calling this function. The number of bytes
31 * required for *pFFTSpec can be determined using
32 * <FFTGetBufSize_R_F32>.
33 *
34 * Parameters:
35 * [in] order base-2 logarithm of the desired block length;
36 * valid in the range [0,12].
37 * [out] pFFTFwdSpec pointer to the initialized specification structure.
38 *
39 * Return Value:
40 * Standard omxError result. See enumeration for possible result codes.
41 *
42 */
43 OMXResult omxSP_FFTInit_R_F32(OMXFFTSpec_R_F32* pFFTSpec, OMX_INT order) {
44 OMX_INT i;
45 OMX_INT j;
46 OMX_FC32* pTwiddle;
47 OMX_FC32* pTwiddle1;
48 OMX_FC32* pTwiddle2;
49 OMX_FC32* pTwiddle3;
50 OMX_FC32* pTwiddle4;
51 OMX_F32* pBuf;
52 OMX_U16* pBitRev;
53 OMX_U32 pTmp;
54 OMX_INT Nby2;
55 OMX_INT N;
56 OMX_INT M;
57 OMX_INT diff;
58 OMX_INT step;
59 OMX_F32 x;
60 OMX_F32 y;
61 OMX_F32 xNeg;
62 ARMsFFTSpec_R_FC32* pFFTStruct = 0;
63
64 pFFTStruct = (ARMsFFTSpec_R_FC32 *) pFFTSpec;
65
66 /* if order zero no init is needed */
67 if (order == 0) {
68 pFFTStruct->N = 1;
69 pFFTStruct->pTwiddle = NULL;
70 pFFTStruct->pBuf = (OMX_F32 *)
71 (sizeof(ARMsFFTSpec_R_SC32) + (OMX_S8*) pFFTSpec);
72
73 return OMX_Sts_NoErr;
74 }
75
76 /* Validate args */
77 if (!pFFTSpec || (order < 0) || (order > TWIDDLE_TABLE_ORDER))
78 return OMX_Sts_BadArgErr;
79
80 /* Do the initializations */
81 Nby2 = 1 << (order - 1);
82 N = Nby2 << 1;
83
84 /* optimized implementations don't use bitreversal */
85 pBitRev = NULL;
86
87 pTwiddle = (OMX_FC32 *) (sizeof(ARMsFFTSpec_R_SC32) + (OMX_S8*) pFFTSpec);
88
89 /* Align to 32 byte boundary */
90 pTmp = ((OMX_U32)pTwiddle) & 31;
91 if (pTmp)
92 pTwiddle = (OMX_FC32*) ((OMX_S8*)pTwiddle + (32 - pTmp));
93
94 pBuf = (OMX_F32*) (sizeof(OMX_FC32)*(5*N/8) + (OMX_S8*) pTwiddle);
95
96 /* Align to 32 byte boundary */
97 pTmp = ((OMX_U32)pBuf)&31; /* (OMX_U32)pBuf % 32 */
98 if (pTmp)
99 pBuf = (OMX_F32*) ((OMX_S8*)pBuf + (32 - pTmp));
100
101 /*
102 * Filling Twiddle factors :
103 *
104 * exp^(-j*2*PI*k/ (N/2) ) ; k=0,1,2,...,3/4(N/2)
105 *
106 * N/2 point complex FFT is used to compute N point real FFT The
107 * original twiddle table "armSP_FFT_F32TwiddleTable" is of size
108 * (MaxSize/8 + 1) Rest of the values i.e., upto MaxSize are
109 * calculated using the symmetries of sin and cos The max size of
110 * the twiddle table needed is 3/4(N/2) for a radix-4 stage
111 *
112 * W = (-2 * PI) / N
113 * N = 1 << order
114 * W = -PI >> (order - 1)
115 */
116
117 M = Nby2 >> 3;
118 diff = TWIDDLE_TABLE_ORDER - (order - 1);
119 /* step into the twiddle table for the current order */
120 step = 1 << diff;
121
122 x = armSP_FFT_F32TwiddleTable[0];
123 y = armSP_FFT_F32TwiddleTable[1];
124 xNeg = 1;
125
126 if ((order - 1) >= 3) {
127 /* i = 0 case */
128 pTwiddle[0].Re = x;
129 pTwiddle[0].Im = y;
130 pTwiddle[2*M].Re = -y;
131 pTwiddle[2*M].Im = xNeg;
132 pTwiddle[4*M].Re = xNeg;
133 pTwiddle[4*M].Im = y;
134
135 for (i = 1; i <= M; i++) {
136 j = i*step;
137
138 x = armSP_FFT_F32TwiddleTable[2*j];
139 y = armSP_FFT_F32TwiddleTable[2*j+1];
140
141 pTwiddle[i].Re = x;
142 pTwiddle[i].Im = y;
143 pTwiddle[2*M-i].Re = -y;
144 pTwiddle[2*M-i].Im = -x;
145 pTwiddle[2*M+i].Re = y;
146 pTwiddle[2*M+i].Im = -x;
147 pTwiddle[4*M-i].Re = -x;
148 pTwiddle[4*M-i].Im = y;
149 pTwiddle[4*M+i].Re = -x;
150 pTwiddle[4*M+i].Im = -y;
151 pTwiddle[6*M-i].Re = y;
152 pTwiddle[6*M-i].Im = x;
153 }
154 } else if ((order - 1) == 2) {
155 pTwiddle[0].Re = x;
156 pTwiddle[0].Im = y;
157 pTwiddle[1].Re = -y;
158 pTwiddle[1].Im = xNeg;
159 pTwiddle[2].Re = xNeg;
160 pTwiddle[2].Im = y;
161 } else if ((order-1) == 1) {
162 pTwiddle[0].Re = x;
163 pTwiddle[0].Im = y;
164 }
165
166 /*
167 * Now fill the last N/4 values : exp^(-j*2*PI*k/N) ;
168 * k=1,3,5,...,N/2-1 These are used for the final twiddle fix-up for
169 * converting complex to real FFT
170 */
171
172 M = N >> 3;
173 diff = TWIDDLE_TABLE_ORDER - order;
174 step = 1 << diff;
175
176 pTwiddle1 = pTwiddle + 3*N/8;
177 pTwiddle4 = pTwiddle1 + (N/4 - 1);
178 pTwiddle3 = pTwiddle1 + N/8;
179 pTwiddle2 = pTwiddle1 + (N/8 - 1);
180
181 x = armSP_FFT_F32TwiddleTable[0];
182 y = armSP_FFT_F32TwiddleTable[1];
183 xNeg = 1;
184
185 if (order >=3) {
186 for (i = 1; i <= M; i += 2) {
187 j = i*step;
188
189 x = armSP_FFT_F32TwiddleTable[2*j];
190 y = armSP_FFT_F32TwiddleTable[2*j+1];
191
192 pTwiddle1[0].Re = x;
193 pTwiddle1[0].Im = y;
194 pTwiddle1 += 1;
195 pTwiddle2[0].Re = -y;
196 pTwiddle2[0].Im = -x;
197 pTwiddle2 -= 1;
198 pTwiddle3[0].Re = y;
199 pTwiddle3[0].Im = -x;
200 pTwiddle3 += 1;
201 pTwiddle4[0].Re = -x;
202 pTwiddle4[0].Im = y;
203 pTwiddle4 -= 1;
204 }
205 } else {
206 if (order == 2) {
207 pTwiddle1[0].Re = -y;
208 pTwiddle1[0].Im = xNeg;
209 }
210 }
211
212
213 /* Update the structure */
214 pFFTStruct->N = N;
215 pFFTStruct->pTwiddle = pTwiddle;
216 pFFTStruct->pBitRev = pBitRev;
217 pFFTStruct->pBuf = pBuf;
218
219 return OMX_Sts_NoErr;
220 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698