2 @// Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
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.
10 @// This file was originally licensed as follows. It has been
11 @// relicensed with permission from the copyright holders.
15 @// File Name: omxSP_FFTFwd_CToC_SC16_Sfs_s.s
16 @// OpenMAX DL: v1.0.2
17 @// Last Modified Revision: 6729
18 @// Last Modified Date: Tue, 17 Jul 2007
20 @// (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
25 @// Compute an inverse FFT for a complex signal
30 @// Include standard headers
32 #include "dl/api/arm/armCOMM_s.h"
33 #include "dl/api/arm/omxtypes_s.h"
36 @// Import symbols required from other files
37 @// (For example tables)
39 .extern armSP_FFTFwd_CToC_SC16_Sfs_Radix2_fs_OutOfPlace_unsafe
40 .extern armSP_FFTFwd_CToC_SC16_Radix2_fs_OutOfPlace_unsafe
41 .extern armSP_FFTFwd_CToC_SC16_Radix4_fs_OutOfPlace_unsafe
42 .extern armSP_FFTFwd_CToC_SC16_Radix4_ls_OutOfPlace_unsafe
43 .extern armSP_FFTFwd_CToC_SC16_Radix8_fs_OutOfPlace_unsafe
44 .extern armSP_FFTFwd_CToC_SC16_Radix4_OutOfPlace_unsafe
45 .extern armSP_FFTFwd_CToC_SC16_Sfs_Radix4_fs_OutOfPlace_unsafe
46 .extern armSP_FFTFwd_CToC_SC16_Sfs_Radix4_ls_OutOfPlace_unsafe
47 .extern armSP_FFTFwd_CToC_SC16_Sfs_Radix8_fs_OutOfPlace_unsafe
48 .extern armSP_FFTFwd_CToC_SC16_Sfs_Radix4_OutOfPlace_unsafe
49 .extern armSP_FFTFwd_CToC_SC16_Sfs_Radix2_OutOfPlace_unsafe
50 .extern armSP_FFTFwd_CToC_SC16_Radix2_OutOfPlace_unsafe
51 .extern armSP_FFTFwd_CToC_SC16_Sfs_Radix2_ls_OutOfPlace_unsafe
52 .extern armSP_FFTFwd_CToC_SC16_Radix2_ls_OutOfPlace_unsafe
54 @// Set debugging level
55 @//DEBUG_ON SETL {TRUE}
59 @// Guarding implementation by the processor name
63 @// Guarding implementation by the processor name
66 .extern armSP_FFTFwd_CToC_SC16_Radix2_ps_OutOfPlace_unsafe
67 .extern armSP_FFTFwd_CToC_SC16_Sfs_Radix2_ps_OutOfPlace_unsafe
80 @//Local Scratch Registers
92 @// Total num of radix stages required to comple the FFT
96 #define diffMinusOne r2
102 #define dShift D1.S16
103 #define dX0S32 D0.S32
107 @// Allocate stack memory required by the function
108 M_ALLOC4 diffOnStack, 4
110 @// Write function header
111 M_START omxSP_FFTFwd_CToC_SC16_Sfs,r11,d15
113 @ Structure offsets for the FFTSpec
114 .set ARMsFFTSpec_N, 0
115 .set ARMsFFTSpec_pBitRev, 4
116 .set ARMsFFTSpec_pTwiddle, 8
117 .set ARMsFFTSpec_pBuf, 12
119 @// Define stack arguments
121 @// Read the size from structure and take log
122 LDR N, [pFFTSpec, #ARMsFFTSpec_N]
124 @// Read other structure parameters
125 LDR pTwiddle, [pFFTSpec, #ARMsFFTSpec_pTwiddle]
126 LDR pOut, [pFFTSpec, #ARMsFFTSpec_pBuf]
128 CLZ order,N @// N = 2^order
134 BGT orderGreaterthan3 @// order > 3
137 BGE orderGreaterthan0 @// order > 0
138 M_STR scale, diffOnStack,LT @// order = 0
145 @// set the buffers appropriately for various orders
149 MOVEQ pOut,pDst @// Pass the first stage destination in RN5
150 MOV argTwiddle,pTwiddle
152 SUBS diff,scale,order
153 M_STR diff,diffOnStack
155 @// Now scale <= order
158 BGT orderGreaterthan1
160 BLEQ armSP_FFTFwd_CToC_SC16_Sfs_Radix2_fs_OutOfPlace_unsafe @// order = 1
161 BLLT armSP_FFTFwd_CToC_SC16_Radix2_fs_OutOfPlace_unsafe @// order = 1
167 BGT orderGreaterthan2
168 SUBS argScale,argScale,#1
169 BLGE armSP_FFTFwd_CToC_SC16_Sfs_Radix2_fs_OutOfPlace_unsafe @// order =2
170 BLLT armSP_FFTFwd_CToC_SC16_Radix2_fs_OutOfPlace_unsafe
171 SUBS argScale,argScale,#1
172 BLEQ armSP_FFTFwd_CToC_SC16_Sfs_Radix2_ls_OutOfPlace_unsafe
173 BLLT armSP_FFTFwd_CToC_SC16_Radix2_ls_OutOfPlace_unsafe
176 orderGreaterthan2: @// order =3
177 SUBS argScale,argScale,#1
178 BLGE armSP_FFTFwd_CToC_SC16_Sfs_Radix2_fs_OutOfPlace_unsafe
179 BLLT armSP_FFTFwd_CToC_SC16_Radix2_fs_OutOfPlace_unsafe
180 SUBS argScale,argScale,#1
181 BLGE armSP_FFTFwd_CToC_SC16_Sfs_Radix2_ps_OutOfPlace_unsafe
182 BLLT armSP_FFTFwd_CToC_SC16_Radix2_ps_OutOfPlace_unsafe
183 SUBS argScale,argScale,#1
184 BLEQ armSP_FFTFwd_CToC_SC16_Sfs_Radix2_ls_OutOfPlace_unsafe
185 BLLT armSP_FFTFwd_CToC_SC16_Radix2_ls_OutOfPlace_unsafe
190 @// check scale = 0 or scale = order
191 SUBS diff, scale, order @// scale > order
193 BGE specialScaleCase @// scale = 0 or scale = order
198 specialScaleCase: @// scale = 0 or scale = order and order > 3
200 TST order, #2 @// Set input args to fft stages
203 MOVEQ pOut,pDst @// Pass the first stage destination in RN5
204 MOV argTwiddle,pTwiddle
207 M_STR diff, diffOnStack
210 @//check for even or odd order
211 @// NOTE: The following combination of BL's would work fine eventhough the first
212 @// BL would corrupt the flags. This is because the end of the "grpZeroSetLoop" loop inside
213 @// armSP_FFTFwd_CToC_SC16_Radix4_fs_OutOfPlace_unsafe sets the Z flag to EQ
215 TST order,#0x00000001
216 BLEQ armSP_FFTFwd_CToC_SC16_Radix4_fs_OutOfPlace_unsafe
217 BLNE armSP_FFTFwd_CToC_SC16_Radix8_fs_OutOfPlace_unsafe
223 BEQ lastStageUnscaledRadix4
224 BL armSP_FFTFwd_CToC_SC16_Radix4_OutOfPlace_unsafe
228 lastStageUnscaledRadix4:
229 BL armSP_FFTFwd_CToC_SC16_Radix4_ls_OutOfPlace_unsafe
233 @//check for even or odd order
234 @// NOTE: The following combination of BL's would work fine eventhough the first
235 @// BL would corrupt the flags. This is because the end of the "grpZeroSetLoop" loop inside
236 @// armSP_FFTFwd_CToC_SC32_Radix4_fs_OutOfPlace_unsafe sets the Z flag to EQ
238 TST order,#0x00000001
239 BLEQ armSP_FFTFwd_CToC_SC16_Sfs_Radix4_fs_OutOfPlace_unsafe
240 BLNE armSP_FFTFwd_CToC_SC16_Sfs_Radix8_fs_OutOfPlace_unsafe
246 BEQ lastStageScaledRadix4
247 BL armSP_FFTFwd_CToC_SC16_Sfs_Radix4_OutOfPlace_unsafe
251 lastStageScaledRadix4:
252 BL armSP_FFTFwd_CToC_SC16_Sfs_Radix4_ls_OutOfPlace_unsafe
257 generalScaleCase: @// 0 < scale < order and order > 3
258 @// Determine the correct destination buffer
261 ADDEQ count,scale,diff,LSR #1 @// count = scale + (order - scale)/2
263 TST count,#0x01 @// Is count even or odd ?
265 MOVNE argDst,pDst @// Set input args to fft stages
267 MOVEQ pOut,pDst @// Pass the first stage destination in RN5
268 MOV argTwiddle,pTwiddle
271 M_STR diff, diffOnStack
272 BEQ scaleps @// scaling including a radix2_ps stage
274 MOV argScale,scale @// Put scale in RN4 so as to save and restore
275 BL armSP_FFTFwd_CToC_SC16_Sfs_Radix2_fs_OutOfPlace_unsafe @// scaled first stage
276 SUBS argScale,argScale,#1
279 BLGT armSP_FFTFwd_CToC_SC16_Sfs_Radix2_OutOfPlace_unsafe
280 SUBS argScale,argScale,#1 @// save and restore scale (RN4) in the scaled stages
285 SUB argScale,scale,#1 @// order>3 and diff=1 => scale >= 3
286 BL armSP_FFTFwd_CToC_SC16_Sfs_Radix2_fs_OutOfPlace_unsafe @// scaled first stage
287 SUBS argScale,argScale,#1
290 BEQ scaledRadix2psStage
291 BLGT armSP_FFTFwd_CToC_SC16_Sfs_Radix2_OutOfPlace_unsafe
292 SUBS argScale,argScale,#1 @// save and restore scale (RN4) in the scaled stages
293 BGE scaledRadix2psLoop
296 BL armSP_FFTFwd_CToC_SC16_Sfs_Radix2_ps_OutOfPlace_unsafe
297 B generalLastStageUnscaledRadix2
301 M_LDR diff, diffOnStack
302 @//check for even or odd order
304 BEQ generalUnscaledRadix4Loop
307 generalUnscaledRadix4Loop:
309 BEQ generalLastStageUnscaledRadix4
310 BL armSP_FFTFwd_CToC_SC16_Radix4_OutOfPlace_unsafe
311 B generalUnscaledRadix4Loop
313 generalLastStageUnscaledRadix4:
314 BL armSP_FFTFwd_CToC_SC16_Radix4_ls_OutOfPlace_unsafe
319 BEQ generalLastTwoStagesUnscaledRadix2
320 BL armSP_FFTFwd_CToC_SC16_Radix2_OutOfPlace_unsafe
323 generalLastTwoStagesUnscaledRadix2:
324 BL armSP_FFTFwd_CToC_SC16_Radix2_ps_OutOfPlace_unsafe
325 generalLastStageUnscaledRadix2:
326 BL armSP_FFTFwd_CToC_SC16_Radix2_ls_OutOfPlace_unsafe
330 FFTEnd: @// Does only the scaling
332 M_LDR diff, diffOnStack
336 RSB diff,diff,#0 @// to use VRSHL for right shift by a variable
339 scaleFFTData: @// N = subFFTSize ; dataptr = pDst ; scale = diff
340 VLD1 {dX0S32[0]},[pSrc] @// pSrc contains pDst pointer
341 SUBS subFFTSize,subFFTSize,#1
343 VST1 {dX0S32[0]},[pSrc]!
351 MOV result, #OMX_Sts_NoErr
353 @// Write function tail