OLD | NEW |
(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_SC32.c |
| 17 * OpenMAX DL: v1.0.2 |
| 18 * Last Modified Revision: 7769 |
| 19 * Last Modified Date: Thu, 27 Sep 2007 |
| 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_SC32 |
| 36 * |
| 37 * Description: |
| 38 * Initializes 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_SC32_Sfs> |
| 44 * and <FFTInv_CToC_SC32_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_SC32>. |
| 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_SC32( |
| 59 OMXFFTSpec_C_SC32* pFFTSpec, |
| 60 OMX_INT order |
| 61 ) |
| 62 { |
| 63 OMX_INT i,j; |
| 64 OMX_SC32 *pTwiddle, *pBuf; |
| 65 OMX_U16 *pBitRev; |
| 66 OMX_U32 pTmp; |
| 67 OMX_INT Nby2,N,M,diff, step; |
| 68 ARMsFFTSpec_SC32 *pFFTStruct = 0; |
| 69 OMX_S32 x,y,xNeg; |
| 70 |
| 71 pFFTStruct = (ARMsFFTSpec_SC32 *) pFFTSpec; |
| 72 |
| 73 /* if order zero no init is needed */ |
| 74 if (order == 0) |
| 75 { |
| 76 pFFTStruct->N = 1; |
| 77 return OMX_Sts_NoErr; |
| 78 } |
| 79 |
| 80 /* Do the initializations */ |
| 81 Nby2 = 1 << (order - 1); |
| 82 N = Nby2 << 1; |
| 83 M = N>>3; |
| 84 |
| 85 |
| 86 pBitRev = NULL ; /* optimized implementations don't use bitre
versal */ |
| 87 |
| 88 pTwiddle = (OMX_SC32 *) |
| 89 (sizeof(ARMsFFTSpec_SC32) + (OMX_S8*) pFFTSpec); |
| 90 |
| 91 /* Align to 32 byte boundary */ |
| 92 pTmp = ((OMX_U32)pTwiddle)&31; /* (OMX_U32)pTwiddle % 32 */ |
| 93 if(pTmp != 0) |
| 94 pTwiddle = (OMX_SC32*) ((OMX_S8*)pTwiddle + (32-pTmp)); |
| 95 |
| 96 pBuf = (OMX_SC32*) |
| 97 (sizeof(OMX_SC32) * (3*N/4) + (OMX_S8*) pTwiddle); |
| 98 |
| 99 /* Align to 32 byte boundary */ |
| 100 pTmp = ((OMX_U32)pBuf)&31; /* (OMX_U32)pBuf % 32 */ |
| 101 if(pTmp != 0) |
| 102 pBuf = (OMX_SC32*) ((OMX_S8*)pBuf + (32-pTmp)); |
| 103 |
| 104 |
| 105 |
| 106 |
| 107 /* |
| 108 * Filling Twiddle factors : |
| 109 * The original twiddle table "armSP_FFT_S32TwiddleTable" 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 diff = 12 - order; |
| 120 step = 1<<diff; /* step into the twiddle table for the current o
rder */ |
| 121 |
| 122 x = armSP_FFT_S32TwiddleTable[0]; |
| 123 y = armSP_FFT_S32TwiddleTable[1]; |
| 124 xNeg = 0x7FFFFFFF; |
| 125 |
| 126 if(order >=3) |
| 127 { |
| 128 /* i = 0 case */ |
| 129 pTwiddle[0].Re = x; |
| 130 pTwiddle[0].Im = y; |
| 131 pTwiddle[2*M].Re = -y; |
| 132 pTwiddle[2*M].Im = xNeg; |
| 133 pTwiddle[4*M].Re = xNeg; |
| 134 pTwiddle[4*M].Im = y; |
| 135 |
| 136 |
| 137 for (i=1; i<=M; i++) |
| 138 { |
| 139 j = i*step; |
| 140 |
| 141 x = armSP_FFT_S32TwiddleTable[2*j]; |
| 142 y = armSP_FFT_S32TwiddleTable[2*j+1]; |
| 143 |
| 144 pTwiddle[i].Re = x; |
| 145 pTwiddle[i].Im = y; |
| 146 pTwiddle[2*M-i].Re = -y; |
| 147 pTwiddle[2*M-i].Im = -x; |
| 148 pTwiddle[2*M+i].Re = y; |
| 149 pTwiddle[2*M+i].Im = -x; |
| 150 pTwiddle[4*M-i].Re = -x; |
| 151 pTwiddle[4*M-i].Im = y; |
| 152 pTwiddle[4*M+i].Re = -x; |
| 153 pTwiddle[4*M+i].Im = -y; |
| 154 pTwiddle[6*M-i].Re = y; |
| 155 pTwiddle[6*M-i].Im = x; |
| 156 } |
| 157 |
| 158 |
| 159 } |
| 160 else |
| 161 { |
| 162 if (order == 2) |
| 163 { |
| 164 pTwiddle[0].Re = x; |
| 165 pTwiddle[0].Im = y; |
| 166 pTwiddle[1].Re = -y; |
| 167 pTwiddle[1].Im = xNeg; |
| 168 pTwiddle[2].Re = xNeg; |
| 169 pTwiddle[2].Im = y; |
| 170 |
| 171 } |
| 172 if (order == 1) |
| 173 { |
| 174 pTwiddle[0].Re = x; |
| 175 pTwiddle[0].Im = y; |
| 176 |
| 177 } |
| 178 |
| 179 |
| 180 } |
| 181 |
| 182 |
| 183 |
| 184 /* Update the structure */ |
| 185 pFFTStruct->N = N; |
| 186 pFFTStruct->pTwiddle = pTwiddle; |
| 187 pFFTStruct->pBitRev = pBitRev; |
| 188 pFFTStruct->pBuf = pBuf; |
| 189 |
| 190 return OMX_Sts_NoErr; |
| 191 } |
| 192 |
| 193 /***************************************************************************** |
| 194 * END OF FILE |
| 195 *****************************************************************************/ |
| 196 |
OLD | NEW |