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

Side by Side Diff: third_party/openmax_dl/dl/sp/src/omxSP_FFTInit_R_S16S32.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_S16S32.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_S16_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_S16_S32_Sfs> and
45 * <ippsFFTInv_CCSToR_S32_S16_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_S16_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
60 OMXResult omxSP_FFTInit_R_S16S32(
61 OMXFFTSpec_R_S16S32* pFFTSpec,
62 OMX_INT order
63 )
64 {
65 OMX_INT i,j;
66 OMX_SC32 *pTwiddle,*pTwiddle1,*pTwiddle2,*pTwiddle3,*pTwiddle4;
67 OMX_S32 *pBuf;
68 OMX_U16 *pBitRev;
69 OMX_U32 pTmp;
70 OMX_INT Nby2,N,M,diff, step;
71 OMX_S32 x,y,xNeg;
72 ARMsFFTSpec_R_SC32 *pFFTStruct = 0;
73
74
75 pFFTStruct = (ARMsFFTSpec_R_SC32 *) pFFTSpec;
76
77 /* if order zero no init is needed */
78 if (order == 0)
79 {
80 pFFTStruct->N = 1;
81 pFFTStruct->pTwiddle = NULL;
82 pFFTStruct->pBuf = (OMX_S32 *)
83 (sizeof(ARMsFFTSpec_R_SC32) + (OMX_S8*) pFFTSpec);
84
85 return OMX_Sts_NoErr;
86 }
87
88 /* Do the initializations */
89 Nby2 = 1 << (order - 1);
90 N = Nby2 << 1;
91
92
93
94 pBitRev = NULL ; /* optimized implementations don't use bitre versal */
95
96 pTwiddle = (OMX_SC32 *)
97 (sizeof(ARMsFFTSpec_R_SC32) + (OMX_S8*) pFFTSpec);
98
99 /* Align to 32 byte boundary */
100 pTmp = ((OMX_U32)pTwiddle)&31; /* (OMX_U32)pTwiddle % 32 */
101 if(pTmp != 0)
102 pTwiddle = (OMX_SC32*) ((OMX_S8*)pTwiddle + (32-pTmp));
103
104
105 pBuf = (OMX_S32*)
106 (sizeof(OMX_SC32) * (5*N/8) + (OMX_S8*) pTwiddle);
107
108 /* Align to 32 byte boundary */
109 pTmp = ((OMX_U32)pBuf)&31; /* (OMX_U32)pBuf % 32 */
110 if(pTmp != 0)
111 pBuf = (OMX_S32*) ((OMX_S8*)pBuf + (32-pTmp));
112
113
114
115
116 /*
117 * Filling Twiddle factors : exp^(-j*2*PI*k/ (N/2) ) ; k=0,1,2,...,3/4(N/2)
118 * N/2 point complex FFT is used to compute N point real FFT
119 * The original twiddle table "armSP_FFT_S32TwiddleTable" is of size (MaxSiz e/8 + 1)
120 * Rest of the values i.e., upto MaxSize are calculated using the symmetries of sin and cos
121 * The max size of the twiddle table needed is 3/4(N/2) for a radix-4 stage
122 *
123 * W = (-2 * PI) / N
124 * N = 1 << order
125 * W = -PI >> (order - 1)
126 */
127
128 M = Nby2>>3;
129 diff = 12 - (order-1);
130 step = 1<<diff; /* step into the twiddle table for the current o rder */
131
132 x = armSP_FFT_S32TwiddleTable[0];
133 y = armSP_FFT_S32TwiddleTable[1];
134 xNeg = 0x7FFFFFFF;
135
136 if((order-1) >=3)
137 {
138 /* i = 0 case */
139 pTwiddle[0].Re = x;
140 pTwiddle[0].Im = y;
141 pTwiddle[2*M].Re = -y;
142 pTwiddle[2*M].Im = xNeg;
143 pTwiddle[4*M].Re = xNeg;
144 pTwiddle[4*M].Im = y;
145
146
147 for (i=1; i<=M; i++)
148 {
149 j = i*step;
150
151 x = armSP_FFT_S32TwiddleTable[2*j];
152 y = armSP_FFT_S32TwiddleTable[2*j+1];
153
154 pTwiddle[i].Re = x;
155 pTwiddle[i].Im = y;
156 pTwiddle[2*M-i].Re = -y;
157 pTwiddle[2*M-i].Im = -x;
158 pTwiddle[2*M+i].Re = y;
159 pTwiddle[2*M+i].Im = -x;
160 pTwiddle[4*M-i].Re = -x;
161 pTwiddle[4*M-i].Im = y;
162 pTwiddle[4*M+i].Re = -x;
163 pTwiddle[4*M+i].Im = -y;
164 pTwiddle[6*M-i].Re = y;
165 pTwiddle[6*M-i].Im = x;
166 }
167
168
169 }
170 else
171 {
172 if ((order-1) == 2)
173 {
174 pTwiddle[0].Re = x;
175 pTwiddle[0].Im = y;
176 pTwiddle[1].Re = -y;
177 pTwiddle[1].Im = xNeg;
178 pTwiddle[2].Re = xNeg;
179 pTwiddle[2].Im = y;
180
181 }
182 if ((order-1) == 1)
183 {
184 pTwiddle[0].Re = x;
185 pTwiddle[0].Im = y;
186
187 }
188
189
190 }
191
192
193 /*
194 * Now fill the last N/4 values : exp^(-j*2*PI*k/N) ; k=1,3,5,...,N/2-1
195 * These are used for the final twiddle fix-up for converting complex to rea l FFT
196 */
197
198 M = N>>3;
199 diff = 12 - order;
200 step = 1<<diff;
201
202 pTwiddle1 = pTwiddle + 3*N/8;
203 pTwiddle4 = pTwiddle1 + (N/4-1);
204 pTwiddle3 = pTwiddle1 + N/8;
205 pTwiddle2 = pTwiddle1 + (N/8-1);
206
207 x = armSP_FFT_S32TwiddleTable[0];
208 y = armSP_FFT_S32TwiddleTable[1];
209 xNeg = 0x7FFFFFFF;
210
211 if((order) >=3)
212 {
213
214
215 for (i=1; i<=M; i+=2 )
216 {
217 j = i*step;
218
219 x = armSP_FFT_S32TwiddleTable[2*j];
220 y = armSP_FFT_S32TwiddleTable[2*j+1];
221
222 pTwiddle1[0].Re = x;
223 pTwiddle1[0].Im = y;
224 pTwiddle1 += 1;
225 pTwiddle2[0].Re = -y;
226 pTwiddle2[0].Im = -x;
227 pTwiddle2 -= 1;
228 pTwiddle3[0].Re = y;
229 pTwiddle3[0].Im = -x;
230 pTwiddle3 += 1;
231 pTwiddle4[0].Re = -x;
232 pTwiddle4[0].Im = y;
233 pTwiddle4 -= 1;
234
235 }
236
237
238 }
239 else
240 {
241 if (order == 2)
242 {
243
244 pTwiddle1[0].Re = -y;
245 pTwiddle1[0].Im = xNeg;
246
247 }
248
249
250 }
251
252
253 /* Update the structure */
254 pFFTStruct->N = N;
255 pFFTStruct->pTwiddle = pTwiddle;
256 pFFTStruct->pBitRev = pBitRev;
257 pFFTStruct->pBuf = pBuf;
258
259 return OMX_Sts_NoErr;
260 }
261 /*****************************************************************************
262 * END OF FILE
263 *****************************************************************************/
264
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698