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 is a modification of omxSP_FFTInit_C_SC32.c to support |
| 11 * complex float instead of SC32. |
| 12 */ |
| 13 |
| 14 #include "dl/api/armOMX.h" |
| 15 #include "dl/api/omxtypes.h" |
| 16 #include "dl/sp/api/armSP.h" |
| 17 #include "dl/sp/api/omxSP.h" |
| 18 |
| 19 |
| 20 /** |
| 21 * Function: omxSP_FFTInit_C_FC32 |
| 22 * |
| 23 * Description: |
| 24 * Initializes the specification structures required for the |
| 25 * complex FFT and IFFT functions. |
| 26 * |
| 27 * Remarks: |
| 28 * Desired block length is specified as an input. The function is used to |
| 29 * initialize the specification structures for functions <FFTFwd_CToC_FC32_Sfs> |
| 30 * and <FFTInv_CToC_FC32_Sfs>. Memory for the specification structure *pFFTSpec |
| 31 * must be allocated prior to calling this function. The space required for |
| 32 * *pFFTSpec, in bytes, can be determined using <FFTGetBufSize_C_FC32>. |
| 33 * |
| 34 * Parameters: |
| 35 * [in] order base-2 logarithm of the desired block length; |
| 36 * valid in the range [1,12]. ([1,15] if |
| 37 * BIG_FFT_TABLE is defined.) |
| 38 * [out] pFFTSpec pointer to initialized specification structure. |
| 39 * |
| 40 * Return Value: |
| 41 * Standard omxError result. See enumeration for possible result codes. |
| 42 * |
| 43 */ |
| 44 |
| 45 OMXResult omxSP_FFTInit_C_FC32(OMXFFTSpec_C_FC32* pFFTSpec, OMX_INT order) { |
| 46 OMX_INT i; |
| 47 OMX_INT j; |
| 48 OMX_FC32* pTwiddle; |
| 49 OMX_FC32* pBuf; |
| 50 OMX_U16* pBitRev; |
| 51 OMX_U32 pTmp; |
| 52 OMX_INT Nby2; |
| 53 OMX_INT N; |
| 54 OMX_INT M; |
| 55 OMX_INT diff; |
| 56 OMX_INT step; |
| 57 ARMsFFTSpec_FC32* pFFTStruct = 0; |
| 58 OMX_F32 x; |
| 59 OMX_F32 y; |
| 60 OMX_F32 xNeg; |
| 61 |
| 62 pFFTStruct = (ARMsFFTSpec_FC32 *) pFFTSpec; |
| 63 |
| 64 /* Validate args */ |
| 65 if (!pFFTSpec || (order < 1) || (order > TWIDDLE_TABLE_ORDER)) |
| 66 return OMX_Sts_BadArgErr; |
| 67 |
| 68 /* Do the initializations */ |
| 69 Nby2 = 1 << (order - 1); |
| 70 N = Nby2 << 1; |
| 71 M = N >> 3; |
| 72 |
| 73 /* optimized implementations don't use bitreversal */ |
| 74 pBitRev = NULL; |
| 75 |
| 76 pTwiddle = (OMX_FC32 *) (sizeof(ARMsFFTSpec_FC32) + (OMX_S8*) pFFTSpec); |
| 77 |
| 78 /* Align to 32 byte boundary */ |
| 79 pTmp = ((OMX_U32) pTwiddle) & 31; |
| 80 if (pTmp) |
| 81 pTwiddle = (OMX_FC32*) ((OMX_S8*)pTwiddle + (32 - pTmp)); |
| 82 |
| 83 pBuf = (OMX_FC32*) (sizeof(OMX_FC32) * (3 * N / 4) + (OMX_S8*) pTwiddle); |
| 84 |
| 85 /* Align to 32 byte boundary */ |
| 86 pTmp = ((OMX_U32)pBuf) & 31; |
| 87 if (pTmp) |
| 88 pBuf = (OMX_FC32*) ((OMX_S8*)pBuf + (32 - pTmp)); |
| 89 |
| 90 /* |
| 91 * Filling Twiddle factors : |
| 92 * |
| 93 * The original twiddle table "armSP_FFT_S32TwiddleTable" is of size |
| 94 * (MaxSize/8 + 1) Rest of the values i.e., upto MaxSize are |
| 95 * calculated using the symmetries of sin and cos The max size of |
| 96 * the twiddle table needed is 3N/4 for a radix-4 stage |
| 97 * |
| 98 * W = (-2 * PI) / N |
| 99 * N = 1 << order |
| 100 * W = -PI >> (order - 1) |
| 101 */ |
| 102 |
| 103 diff = TWIDDLE_TABLE_ORDER - order; |
| 104 /* step into the twiddle table for the current order */ |
| 105 step = 1 << diff; |
| 106 |
| 107 x = armSP_FFT_F32TwiddleTable[0]; |
| 108 y = armSP_FFT_F32TwiddleTable[1]; |
| 109 xNeg = 1; |
| 110 |
| 111 if (order >= 3) { |
| 112 /* i = 0 case */ |
| 113 pTwiddle[0].Re = x; |
| 114 pTwiddle[0].Im = y; |
| 115 pTwiddle[2 * M].Re = -y; |
| 116 pTwiddle[2 * M].Im = xNeg; |
| 117 pTwiddle[4 * M].Re = xNeg; |
| 118 pTwiddle[4 * M].Im = y; |
| 119 |
| 120 for (i = 1; i <= M; i++) { |
| 121 j = i * step; |
| 122 |
| 123 x = armSP_FFT_F32TwiddleTable[2 * j]; |
| 124 y = armSP_FFT_F32TwiddleTable[2 * j + 1]; |
| 125 |
| 126 pTwiddle[i].Re = x; |
| 127 pTwiddle[i].Im = y; |
| 128 pTwiddle[2 * M - i].Re = -y; |
| 129 pTwiddle[2 * M - i].Im = -x; |
| 130 pTwiddle[2 * M + i].Re = y; |
| 131 pTwiddle[2 * M + i].Im = -x; |
| 132 pTwiddle[4 * M - i].Re = -x; |
| 133 pTwiddle[4 * M - i].Im = y; |
| 134 pTwiddle[4 * M + i].Re = -x; |
| 135 pTwiddle[4 * M + i].Im = -y; |
| 136 pTwiddle[6 * M - i].Re = y; |
| 137 pTwiddle[6 * M - i].Im = x; |
| 138 } |
| 139 } else if (order == 2) { |
| 140 pTwiddle[0].Re = x; |
| 141 pTwiddle[0].Im = y; |
| 142 pTwiddle[1].Re = -y; |
| 143 pTwiddle[1].Im = xNeg; |
| 144 pTwiddle[2].Re = xNeg; |
| 145 pTwiddle[2].Im = y; |
| 146 } else if (order == 1) { |
| 147 pTwiddle[0].Re = x; |
| 148 pTwiddle[0].Im = y; |
| 149 } |
| 150 |
| 151 /* Update the structure */ |
| 152 pFFTStruct->N = N; |
| 153 pFFTStruct->pTwiddle = pTwiddle; |
| 154 pFFTStruct->pBitRev = pBitRev; |
| 155 pFFTStruct->pBuf = pBuf; |
| 156 |
| 157 return OMX_Sts_NoErr; |
| 158 } |
| 159 |
| 160 /***************************************************************************** |
| 161 * END OF FILE |
| 162 *****************************************************************************/ |
OLD | NEW |