CMSIS DSP Software Library: arm_rfft_f32.c Source File

- Main Page
- Modules
- Data Structures
- Files
- Examples

- File List
- Globals

# arm_rfft_f32.c

Go to the documentation of this file.

    00001 /* ----------------------------------------------------------------------
    00002 * Copyright (C) 2010 ARM Limited. All rights reserved.
    00003 *
    00004 * $Date:        15. July 2011
    00005 * $Revision:    V1.0.10
    00006 *
    00007 * Project:      CMSIS DSP Library
    00008 * Title:        arm_rfft_f32.c
    00009 *
    00010 * Description:  RFFT & RIFFT Floating point process function
    00011 *
    00012 * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
    00013 *
    00014 * Version 1.0.10 2011/7/15
    00015 *    Big Endian support added and Merged M0 and M3/M4 Source code.
    00016 *
    00017 * Version 1.0.3 2010/11/29
    00018 *    Re-organized the CMSIS folders and updated documentation.
    00019 *
    00020 * Version 1.0.2 2010/11/11
    00021 *    Documentation updated.
    00022 *
    00023 * Version 1.0.1 2010/10/05
    00024 *    Production release and review comments incorporated.
    00025 *
    00026 * Version 1.0.0 2010/09/20
    00027 *    Production release and review comments incorporated.
    00028 *
    00029 * Version 0.0.7  2010/06/10
    00030 *    Misra-C changes done
    00031 * -------------------------------------------------------------------- */
    00032
    00033 #include "arm_math.h"
    00034
    00118 /*--------------------------------------------------------------------
    00119  *      Internal functions prototypes
    00120  *--------------------------------------------------------------------*/
    00121
    00122 void arm_split_rfft_f32(
    00123   float32_t * pSrc,
    00124   uint32_t fftLen,
    00125   float32_t * pATable,
    00126   float32_t * pBTable,
    00127   float32_t * pDst,
    00128   uint32_t modifier);
    00129 void arm_split_rifft_f32(
    00130   float32_t * pSrc,
    00131   uint32_t fftLen,
    00132   float32_t * pATable,
    00133   float32_t * pBTable,
    00134   float32_t * pDst,
    00135   uint32_t modifier);
    00136
    00150 void arm_rfft_f32(
    00151   const arm_rfft_instance_f32 * S,
    00152   float32_t * pSrc,
    00153   float32_t * pDst)
    00154 {
    00155   const arm_cfft_radix4_instance_f32 *S_CFFT = S->pCfft;
    00156
    00157
    00158   /* Calculation of Real IFFT of input */
    00159   if(S->ifftFlagR == 1u)
    00160   {
    00161     /*  Real IFFT core process */
    00162     arm_split_rifft_f32(pSrc, S->fftLenBy2, S->pTwiddleAReal,
    00163                         S->pTwiddleBReal, pDst, S->twidCoefRModifier);
    00164
    00165
    00166     /* Complex radix-4 IFFT process */
    00167     arm_radix4_butterfly_inverse_f32(pDst, S_CFFT->fftLen,
    00168                                      S_CFFT->pTwiddle,
    00169                                      S_CFFT->twidCoefModifier,
    00170                                      S_CFFT->onebyfftLen);
    00171
    00172     /* Bit reversal process */
    00173     if(S->bitReverseFlagR == 1u)
    00174     {
    00175       arm_bitreversal_f32(pDst, S_CFFT->fftLen,
    00176                           S_CFFT->bitRevFactor, S_CFFT->pBitRevTable);
    00177     }
    00178   }
    00179   else
    00180   {
    00181
    00182     /* Calculation of RFFT of input */
    00183
    00184     /* Complex radix-4 FFT process */
    00185     arm_radix4_butterfly_f32(pSrc, S_CFFT->fftLen,
    00186                              S_CFFT->pTwiddle, S_CFFT->twidCoefModifier);
    00187
    00188     /* Bit reversal process */
    00189     if(S->bitReverseFlagR == 1u)
    00190     {
    00191       arm_bitreversal_f32(pSrc, S_CFFT->fftLen,
    00192                           S_CFFT->bitRevFactor, S_CFFT->pBitRevTable);
    00193     }
    00194
    00195
    00196     /*  Real FFT core process */
    00197     arm_split_rfft_f32(pSrc, S->fftLenBy2, S->pTwiddleAReal,
    00198                        S->pTwiddleBReal, pDst, S->twidCoefRModifier);
    00199   }
    00200
    00201 }
    00202
    00218 void arm_split_rfft_f32(
    00219   float32_t * pSrc,
    00220   uint32_t fftLen,
    00221   float32_t * pATable,
    00222   float32_t * pBTable,
    00223   float32_t * pDst,
    00224   uint32_t modifier)
    00225 {
    00226   uint32_t i;                                    /* Loop Counter */
    00227   float32_t outR, outI;                          /* Temporary variables for output */
    00228   float32_t *pCoefA, *pCoefB;                    /* Temporary pointers for twiddle factors */
    00229   float32_t CoefA1, CoefA2, CoefB1;              /* Temporary variables for twiddle coefficients */
    00230   float32_t *pDst1 = &pDst[2], *pDst2 = &pDst[(4u * fftLen) - 1u];      /* temp pointers for output buffer */
    00231   float32_t *pSrc1 = &pSrc[2], *pSrc2 = &pSrc[(2u * fftLen) - 1u];      /* temp pointers for input buffer */
    00232
    00233
    00234   pSrc[2u * fftLen] = pSrc[0];
    00235   pSrc[(2u * fftLen) + 1u] = pSrc[1];
    00236
    00237   /* Init coefficient pointers */
    00238   pCoefA = &pATable[modifier * 2u];
    00239   pCoefB = &pBTable[modifier * 2u];
    00240
    00241   i = fftLen - 1u;
    00242
    00243   while(i > 0u)
    00244   {
    00245     /*
    00246        outR = (pSrc[2 * i] * pATable[2 * i] - pSrc[2 * i + 1] * pATable[2 * i + 1]
    00247        + pSrc[2 * n - 2 * i] * pBTable[2 * i] +
    00248        pSrc[2 * n - 2 * i + 1] * pBTable[2 * i + 1]);
    00249      */
    00250
    00251     /* outI = (pIn[2 * i + 1] * pATable[2 * i] + pIn[2 * i] * pATable[2 * i + 1] +
    00252        pIn[2 * n - 2 * i] * pBTable[2 * i + 1] -
    00253        pIn[2 * n - 2 * i + 1] * pBTable[2 * i]); */
    00254
    00255     /* read pATable[2 * i] */
    00256     CoefA1 = *pCoefA++;
    00257     /* pATable[2 * i + 1] */
    00258     CoefA2 = *pCoefA;
    00259
    00260     /* pSrc[2 * i] * pATable[2 * i] */
    00261     outR = *pSrc1 * CoefA1;
    00262     /* pSrc[2 * i] * CoefA2 */
    00263     outI = *pSrc1++ * CoefA2;
    00264
    00265     /* (pSrc[2 * i + 1] + pSrc[2 * fftLen - 2 * i + 1]) * CoefA2 */
    00266     outR -= (*pSrc1 + *pSrc2) * CoefA2;
    00267     /* pSrc[2 * i + 1] * CoefA1 */
    00268     outI += *pSrc1++ * CoefA1;
    00269
    00270     CoefB1 = *pCoefB;
    00271
    00272     /* pSrc[2 * fftLen - 2 * i + 1] * CoefB1 */
    00273     outI -= *pSrc2-- * CoefB1;
    00274     /* pSrc[2 * fftLen - 2 * i] * CoefA2 */
    00275     outI -= *pSrc2 * CoefA2;
    00276
    00277     /* pSrc[2 * fftLen - 2 * i] * CoefB1 */
    00278     outR += *pSrc2-- * CoefB1;
    00279
    00280     /* write output */
    00281     *pDst1++ = outR;
    00282     *pDst1++ = outI;
    00283
    00284     /* write complex conjugate output */
    00285     *pDst2-- = -outI;
    00286     *pDst2-- = outR;
    00287
    00288     /* update coefficient pointer */
    00289     pCoefB = pCoefB + (modifier * 2u);
    00290     pCoefA = pCoefA + ((modifier * 2u) - 1u);
    00291
    00292     i--;
    00293
    00294   }
    00295
    00296   pDst[2u * fftLen] = pSrc[0] - pSrc[1];
    00297   pDst[(2u * fftLen) + 1u] = 0.0f;
    00298
    00299   pDst[0] = pSrc[0] + pSrc[1];
    00300   pDst[1] = 0.0f;
    00301
    00302 }
    00303
    00304
    00316 void arm_split_rifft_f32(
    00317   float32_t * pSrc,
    00318   uint32_t fftLen,
    00319   float32_t * pATable,
    00320   float32_t * pBTable,
    00321   float32_t * pDst,
    00322   uint32_t modifier)
    00323 {
    00324   float32_t outR, outI;                          /* Temporary variables for output */
    00325   float32_t *pCoefA, *pCoefB;                    /* Temporary pointers for twiddle factors */
    00326   float32_t CoefA1, CoefA2, CoefB1;              /* Temporary variables for twiddle coefficients */
    00327   float32_t *pSrc1 = &pSrc[0], *pSrc2 = &pSrc[(2u * fftLen) + 1u];
    00328
    00329   pCoefA = &pATable[0];
    00330   pCoefB = &pBTable[0];
    00331
    00332   while(fftLen > 0u)
    00333   {
    00334     /*
    00335        outR = (pIn[2 * i] * pATable[2 * i] + pIn[2 * i + 1] * pATable[2 * i + 1] +
    00336        pIn[2 * n - 2 * i] * pBTable[2 * i] -
    00337        pIn[2 * n - 2 * i + 1] * pBTable[2 * i + 1]);
    00338
    00339        outI = (pIn[2 * i + 1] * pATable[2 * i] - pIn[2 * i] * pATable[2 * i + 1] -
    00340        pIn[2 * n - 2 * i] * pBTable[2 * i + 1] -
    00341        pIn[2 * n - 2 * i + 1] * pBTable[2 * i]);
    00342
    00343      */
    00344
    00345     CoefA1 = *pCoefA++;
    00346     CoefA2 = *pCoefA;
    00347
    00348     /* outR = (pSrc[2 * i] * CoefA1 */
    00349     outR = *pSrc1 * CoefA1;
    00350
    00351     /* - pSrc[2 * i] * CoefA2 */
    00352     outI = -(*pSrc1++) * CoefA2;
    00353
    00354     /* (pSrc[2 * i + 1] + pSrc[2 * fftLen - 2 * i + 1]) * CoefA2 */
    00355     outR += (*pSrc1 + *pSrc2) * CoefA2;
    00356
    00357     /* pSrc[2 * i + 1] * CoefA1 */
    00358     outI += (*pSrc1++) * CoefA1;
    00359
    00360     CoefB1 = *pCoefB;
    00361
    00362     /* - pSrc[2 * fftLen - 2 * i + 1] * CoefB1 */
    00363     outI -= *pSrc2-- * CoefB1;
    00364
    00365     /* pSrc[2 * fftLen - 2 * i] * CoefB1 */
    00366     outR += *pSrc2 * CoefB1;
    00367
    00368     /* pSrc[2 * fftLen - 2 * i] * CoefA2 */
    00369     outI += *pSrc2-- * CoefA2;
    00370
    00371     /* write output */
    00372     *pDst++ = outR;
    00373     *pDst++ = outI;
    00374
    00375     /* update coefficient pointer */
    00376     pCoefB = pCoefB + (modifier * 2u);
    00377     pCoefA = pCoefA + ((modifier * 2u) - 1u);
    00378
    00379     /* Decrement loop count */
    00380     fftLen--;
    00381   }
    00382
    00383 }

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines