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

Side by Side Diff: third_party/openmax_dl/dl/sp/src/omxSP_FFTInit_C_SC16.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_C_SC16.c
17 * OpenMAX DL: v1.0.2
18 * Last Modified Revision: 15322
19 * Last Modified Date: Wed, 15 Oct 2008
20 *
21 * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
22 *
23 *
24 * Description:
25 * Initializes the specification structures required
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 * Function: omxSP_FFTInit_C_SC16
36 *
37 * Description:
38 * These functions initialize the specification structures required for the
39 * complex FFT and IFFT functions.
40 *
41 * Remarks:
42 * Desired block length is specified as an input. The function is used to
43 * initialize the specification structures for functions <FFTFwd_CToC_SC16_Sfs>
44 * and <FFTInv_CToC_SC16_Sfs>. Memory for the specification structure *pFFTSpec
45 * must be allocated prior to calling this function. The space required for
46 * *pFFTSpec, in bytes, can be determined using <FFTGetBufSize_C_SC16>.
47 *
48 * Parameters:
49 * [in] order base-2 logarithm of the desired block length;
50 * valid in the range [0,12].
51 * [out] pFFTSpec pointer to initialized specification structure.
52 *
53 * Return Value:
54 * Standard omxError result. See enumeration for possible result codes.
55 *
56 */
57
58 OMXResult omxSP_FFTInit_C_SC16(
59 OMXFFTSpec_C_SC16* pFFTSpec,
60 OMX_INT order
61 )
62 {
63 OMX_INT i,j;
64 OMX_SC16 *pTwiddle, *pBuf;
65 OMX_U16 *pBitRev;
66 OMX_INT Nby2,N,M,diff,step;
67 OMX_U32 pTmp;
68 ARMsFFTSpec_SC16 *pFFTStruct = 0;
69 OMX_S16 x,y,xNeg;
70 OMX_S32 xS32,yS32;
71
72
73 pFFTStruct = (ARMsFFTSpec_SC16 *) pFFTSpec;
74
75 /* if order zero no init is needed */
76 if (order == 0)
77 {
78 pFFTStruct->N = 1;
79 return OMX_Sts_NoErr;
80 }
81
82 /* Do the initializations */
83 Nby2 = 1 << (order - 1);
84 N = Nby2 << 1;
85 M = N>>3;
86
87 pBitRev = NULL ;
88
89 pTwiddle = (OMX_SC16 *)
90 (sizeof(ARMsFFTSpec_SC16) + (OMX_S8*) pFFTSpec);
91
92 /* Align to 32 byte boundary */
93 pTmp = ((OMX_U32)pTwiddle)&31; /* (OMX_U32)pTwiddle % 32 */
94 if(pTmp != 0)
95 pTwiddle = (OMX_SC16*) ((OMX_S8*)pTwiddle + (32-pTmp));
96
97 pBuf = (OMX_SC16 *)
98 (sizeof(OMX_SC16) * (3*N/4) + (OMX_S8*) pTwiddle);
99
100 /* Align to 32 byte boundary */
101 pTmp = ((OMX_U32)pBuf)&31; /* (OMX_U32)pBuf % 32 */
102 if(pTmp != 0)
103 pBuf = (OMX_SC16*) ((OMX_S8*)pBuf + (32-pTmp));
104
105
106
107 /*
108 * Filling Twiddle factors :
109 * The original twiddle table "armSP_FFT_S16TwiddleTable" is of size (MaxSiz e/8 + 1)
110 * Rest of the values i.e., upto MaxSize are calculated using the symmetries of sin and cos
111 * The max size of the twiddle table needed is 3N/4 for a radix-4 stage
112 *
113 * W = (-2 * PI) / N
114 * N = 1 << order
115 * W = -PI >> (order - 1)
116 */
117
118
119
120 diff = 12 - order;
121 step = 1<<diff; /* step into the twiddle table for the current o rder */
122
123 xS32 = armSP_FFT_S32TwiddleTable[0];
124 yS32 = armSP_FFT_S32TwiddleTable[1];
125 x = (xS32+0x8000)>>16;
126 y = (yS32+0x8000)>>16;
127
128 xNeg = 0x7FFF;
129
130 if(order >=3)
131 {
132 /* i = 0 case */
133 pTwiddle[0].Re = x;
134 pTwiddle[0].Im = y;
135 pTwiddle[2*M].Re = -y;
136 pTwiddle[2*M].Im = xNeg;
137 pTwiddle[4*M].Re = xNeg;
138 pTwiddle[4*M].Im = y;
139
140
141 for (i=1; i<=M; i++)
142 {
143 j = i*step;
144
145 xS32 = armSP_FFT_S32TwiddleTable[2*j];
146 yS32 = armSP_FFT_S32TwiddleTable[2*j+1];
147 x = (xS32+0x8000)>>16;
148 y = (yS32+0x8000)>>16;
149
150 pTwiddle[i].Re = x;
151 pTwiddle[i].Im = y;
152 pTwiddle[2*M-i].Re = -y;
153 pTwiddle[2*M-i].Im = -x;
154 pTwiddle[2*M+i].Re = y;
155 pTwiddle[2*M+i].Im = -x;
156 pTwiddle[4*M-i].Re = -x;
157 pTwiddle[4*M-i].Im = y;
158 pTwiddle[4*M+i].Re = -x;
159 pTwiddle[4*M+i].Im = -y;
160 pTwiddle[6*M-i].Re = y;
161 pTwiddle[6*M-i].Im = x;
162 }
163
164
165 }
166 else
167 {
168 if (order == 2)
169 {
170 pTwiddle[0].Re = x;
171 pTwiddle[0].Im = y;
172 pTwiddle[1].Re = -y;
173 pTwiddle[1].Im = xNeg;
174 pTwiddle[2].Re = xNeg;
175 pTwiddle[2].Im = y;
176
177 }
178 if (order == 1)
179 {
180 pTwiddle[0].Re = x;
181 pTwiddle[0].Im = y;
182
183 }
184
185
186 }
187
188
189 /* Update the structure */
190 pFFTStruct->N = N;
191 pFFTStruct->pTwiddle = pTwiddle;
192 pFFTStruct->pBitRev = pBitRev;
193 pFFTStruct->pBuf = pBuf;
194
195 return OMX_Sts_NoErr;
196 }
197
198 /*****************************************************************************
199 * END OF FILE
200 *****************************************************************************/
201
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698