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

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

Powered by Google App Engine
This is Rietveld 408576698