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

Side by Side Diff: third_party/openmax_dl/dl/sp/src/omxSP_FFTInit_R_S32.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 file was originally licensed as follows. It has been
11 * relicensed with permission from the copyright holders.
12 */
13
14 /**
15 *
16 * File Name: omxSP_FFTInit_R_S32.c
17 * OpenMAX DL: v1.0.2
18 * Last Modified Revision: 7777
19 * Last Modified Date: Thu, 27 Sep 2007
20 *
21 * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
22 *
23 *
24 * Description:
25 * Initialize the real forward-FFT specification information struct.
26 */
27
28 #include "dl/api/armOMX.h"
29 #include "dl/api/omxtypes.h"
30 #include "dl/sp/api/armSP.h"
31 #include "dl/sp/api/omxSP.h"
32
33
34
35 /**
36 * Function: omxSP_FFTInit_R_S32
37 *
38 * Description:
39 * Initialize the real forward-FFT specification information struct.
40 *
41 * Remarks:
42 * This function is used to initialize the specification structures
43 * for functions <ippsFFTFwd_RToCCS_S32_Sfs> and
44 * <ippsFFTInv_CCSToR_S32_Sfs>. Memory for *pFFTSpec must be
45 * allocated prior to calling this function. The number of bytes
46 * required for *pFFTSpec can be determined using
47 * <FFTGetBufSize_R_S32>.
48 *
49 * Parameters:
50 * [in] order base-2 logarithm of the desired block length;
51 * valid in the range [0,12].
52 * [out] pFFTFwdSpec pointer to the initialized specification structure.
53 *
54 * Return Value:
55 * Standard omxError result. See enumeration for possible result codes.
56 *
57 */
58 OMXResult omxSP_FFTInit_R_S32(
59 OMXFFTSpec_R_S32* pFFTSpec,
60 OMX_INT order
61 )
62 {
63 OMX_INT i,j;
64 OMX_SC32 *pTwiddle,*pTwiddle1,*pTwiddle2,*pTwiddle3,*pTwiddle4;
65 OMX_S32 *pBuf;
66 OMX_U16 *pBitRev;
67 OMX_U32 pTmp;
68 OMX_INT Nby2,N,M,diff, step;
69 OMX_S32 x,y,xNeg;
70 ARMsFFTSpec_R_SC32 *pFFTStruct = 0;
71
72
73 pFFTStruct = (ARMsFFTSpec_R_SC32 *) pFFTSpec;
74
75 /* if order zero no init is needed */
76 if (order == 0)
77 {
78 pFFTStruct->N = 1;
79 pFFTStruct->pTwiddle = NULL;
80 pFFTStruct->pBuf = (OMX_S32 *)
81 (sizeof(ARMsFFTSpec_R_SC32) + (OMX_S8*) pFFTSpec);
82
83 return OMX_Sts_NoErr;
84 }
85
86 /* Do the initializations */
87 Nby2 = 1 << (order - 1);
88 N = Nby2 << 1;
89
90
91
92 pBitRev = NULL ; /* optimized implementations don't use bitre versal */
93
94 pTwiddle = (OMX_SC32 *)
95 (sizeof(ARMsFFTSpec_R_SC32) + (OMX_S8*) pFFTSpec);
96
97 /* Align to 32 byte boundary */
98 pTmp = ((OMX_U32)pTwiddle)&31; /* (OMX_U32)pTwiddle % 32 */
99 if(pTmp != 0)
100 pTwiddle = (OMX_SC32*) ((OMX_S8*)pTwiddle + (32-pTmp));
101
102 pBuf = (OMX_S32*)
103 (sizeof(OMX_SC32) * (5*N/8) + (OMX_S8*) pTwiddle);
104
105 /* Align to 32 byte boundary */
106 pTmp = ((OMX_U32)pBuf)&31; /* (OMX_U32)pBuf % 32 */
107 if(pTmp != 0)
108 pBuf = (OMX_S32*) ((OMX_S8*)pBuf + (32-pTmp));
109
110
111
112
113 /*
114 * Filling Twiddle factors : exp^(-j*2*PI*k/ (N/2) ) ; k=0,1,2,...,3/4(N/2)
115 * N/2 point complex FFT is used to compute N point real FFT
116 * The original twiddle table "armSP_FFT_S32TwiddleTable" is of size (MaxSiz e/8 + 1)
117 * Rest of the values i.e., upto MaxSize are calculated using the symmetries of sin and cos
118 * The max size of the twiddle table needed is 3/4(N/2) for a radix-4 stage
119 *
120 * W = (-2 * PI) / N
121 * N = 1 << order
122 * W = -PI >> (order - 1)
123 */
124
125 M = Nby2>>3;
126 diff = 12 - (order-1);
127 step = 1<<diff; /* step into the twiddle table for the current o rder */
128
129 x = armSP_FFT_S32TwiddleTable[0];
130 y = armSP_FFT_S32TwiddleTable[1];
131 xNeg = 0x7FFFFFFF;
132
133 if((order-1) >=3)
134 {
135 /* i = 0 case */
136 pTwiddle[0].Re = x;
137 pTwiddle[0].Im = y;
138 pTwiddle[2*M].Re = -y;
139 pTwiddle[2*M].Im = xNeg;
140 pTwiddle[4*M].Re = xNeg;
141 pTwiddle[4*M].Im = y;
142
143
144 for (i=1; i<=M; i++)
145 {
146 j = i*step;
147
148 x = armSP_FFT_S32TwiddleTable[2*j];
149 y = armSP_FFT_S32TwiddleTable[2*j+1];
150
151 pTwiddle[i].Re = x;
152 pTwiddle[i].Im = y;
153 pTwiddle[2*M-i].Re = -y;
154 pTwiddle[2*M-i].Im = -x;
155 pTwiddle[2*M+i].Re = y;
156 pTwiddle[2*M+i].Im = -x;
157 pTwiddle[4*M-i].Re = -x;
158 pTwiddle[4*M-i].Im = y;
159 pTwiddle[4*M+i].Re = -x;
160 pTwiddle[4*M+i].Im = -y;
161 pTwiddle[6*M-i].Re = y;
162 pTwiddle[6*M-i].Im = x;
163 }
164
165
166 }
167 else
168 {
169 if ((order-1) == 2)
170 {
171 pTwiddle[0].Re = x;
172 pTwiddle[0].Im = y;
173 pTwiddle[1].Re = -y;
174 pTwiddle[1].Im = xNeg;
175 pTwiddle[2].Re = xNeg;
176 pTwiddle[2].Im = y;
177
178 }
179 if ((order-1) == 1)
180 {
181 pTwiddle[0].Re = x;
182 pTwiddle[0].Im = y;
183
184 }
185
186
187 }
188
189
190 /*
191 * Now fill the last N/4 values : exp^(-j*2*PI*k/N) ; k=1,3,5,...,N/2-1
192 * These are used for the final twiddle fix-up for converting complex to rea l FFT
193 */
194
195 M = N>>3;
196 diff = 12 - order;
197 step = 1<<diff;
198
199 pTwiddle1 = pTwiddle + 3*N/8;
200 pTwiddle4 = pTwiddle1 + (N/4-1);
201 pTwiddle3 = pTwiddle1 + N/8;
202 pTwiddle2 = pTwiddle1 + (N/8-1);
203
204 x = armSP_FFT_S32TwiddleTable[0];
205 y = armSP_FFT_S32TwiddleTable[1];
206 xNeg = 0x7FFFFFFF;
207
208 if((order) >=3)
209 {
210
211
212 for (i=1; i<=M; i+=2 )
213 {
214 j = i*step;
215
216 x = armSP_FFT_S32TwiddleTable[2*j];
217 y = armSP_FFT_S32TwiddleTable[2*j+1];
218
219 pTwiddle1[0].Re = x;
220 pTwiddle1[0].Im = y;
221 pTwiddle1 += 1;
222 pTwiddle2[0].Re = -y;
223 pTwiddle2[0].Im = -x;
224 pTwiddle2 -= 1;
225 pTwiddle3[0].Re = y;
226 pTwiddle3[0].Im = -x;
227 pTwiddle3 += 1;
228 pTwiddle4[0].Re = -x;
229 pTwiddle4[0].Im = y;
230 pTwiddle4 -= 1;
231
232 }
233
234
235 }
236 else
237 {
238 if (order == 2)
239 {
240
241 pTwiddle1[0].Re = -y;
242 pTwiddle1[0].Im = xNeg;
243
244 }
245
246
247 }
248
249
250 /* Update the structure */
251 pFFTStruct->N = N;
252 pFFTStruct->pTwiddle = pTwiddle;
253 pFFTStruct->pBitRev = pBitRev;
254 pFFTStruct->pBuf = pBuf;
255
256 return OMX_Sts_NoErr;
257 }
258 /*****************************************************************************
259 * END OF FILE
260 *****************************************************************************/
261
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698