Intel® Integrated Performance Primitives Developer Guide and Reference

ID 790148
Date 11/07/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

FFTFwd

Applies forward Fast Fourier Transform to an image.

Syntax

Case 1: Not-in-place operation on floating-point data

IppStatus ippiFFTFwd_RToPack_<mod> (const Ipp32f* pSrc, int srcStep, Ipp32f* pDst, int dstStep, const IppiFFTSpec_R_32f* pFFTSpec, Ipp8u* pBuffer);

Supported values for mod:

32f_C1R

32f_C3R

32f_C4R

32f_AC4R

Case 2: Not-in-place operation on complex data

IppStatus ippiFFTFwd_CToC_32fc_C1R(const Ipp32fc* pSrc, int srcStep, Ipp32fc* pDst, int dstStep, const IppiFFTSpec_C_32fc* pFFTSpec, Ipp8u* pBuffer);

Case 3: In-place operation on floating-point data

IppStatus ippiFFTFwd_RToPack_<mod>(Ipp32f* pSrcDst, int srcDstStep, const IppiFFTSpec_R_32f* pFFTSpec, Ipp8u* pBuffer);

Supported values for mod:

32f_C1IR

32f_C3IR

32f_C4IR

32f_AC4IR

Case 4: In-place operation on complex data

IppStatus ippiFFTFwd_CToC_32fc_C1IR(Ipp32fc* pSrcDst, int srcDstStep, const IppiFFTSpec_C_32fc* pFFTSpec, Ipp8u* pBuffer);

Include Files

ippi.h

Domain Dependencies

Headers: ippcore.h, ippvm.h, ipps.h

Libraries: ippcore.lib, ippvm.lib, ipps.lib

Parameters

pSrc

Pointer to the source image ROI.

srcStep

Distance in bytes between starts of consecutive lines in the source image.

pDst

Pointer to the destination image ROI.

dstStep

Distance in bytes between starts of consecutive lines in the destination image.

pSrcDst

Pointer to the source and destination image ROI for the in-place operation.

srcDstStep

Distance in bytes between starts of consecutive lines in the source and destination image for the in-place operation.

pFFTSpec

Pointer to the FFT specification structure.

pBuffer

Pointer to the external work buffer.

Description

This function operates with ROI.

This function performs a forward FFT on each channel of the source image ROI pSrc (pSrcDst for in-place flavors) and writes the Fourier coefficients into the corresponding channel of the destination buffer pDst (pSrcDst for in-place flavors). The size of ROI is N x M, it is specified by the parameters orderX, orderY.

The function flavor ippiFFTFwd_RToPack that operates on images with real data takes advantage of the symmetry property and stores the output data in RCPack2D format. It supports processing of the 1-, 3-, and 4-channel images. Note that the functions with AC4 descriptor do not process alpha channel.

The function flavor ippiFFTFwd_CToC that operates on images with complex data does not perform any packing of the transform results as no symmetry with respect to frequency domain data is observed in this case. Memory layout of images with complex data follows the same conventions as for real images provided that each pixel value consists of two numbers: imaginary and real part.

Before using the forward FFT functions, you need to compute the size of the work buffer by ippiFFTGetSize and initialize the context structure by the ippiFFTInit function. The forward FFT functions use the pFFTSpec context structure to set the mode of calculations and retrieve support data.

Return Values

ippStsNoErr

Indicates no error. Any other value indicates an error or a warning.

ippStsNullPtrErr

Indicates an error condition if pSrc, pDst, or pFFTSpec pointer is NULL.

ippStsStepErr

Indicates an error condition if srcStep or dstStep value is zero or negative.

ippStsContextMatchErr

Indicates an error condition if a pointer to an invalid pFFTSpec structure is passed.

ippStsMemAllocErr

Indicates an error condition if memory allocation fails.

Example

FFTFwd_CToC:

/*******************************************************************************
* Copyright 2015 Intel Corporation.
*
*
* This software and the related documents are Intel copyrighted materials, and your use of them is governed by
* the express license under which they were provided to you ('License'). Unless the License provides otherwise,
* you may not use, modify, copy, publish, distribute, disclose or transmit this software or the related
* documents without Intel's prior written permission.
* This software and the related documents are provided as is, with no express or implied warranties, other than
* those that are expressly stated in the License.
*******************************************************************************/

//   A simple example of performing the forward FFT for processing complex data.
// implemented with Intel(R) Integrated Primitives (Intel(R) IPP) functions:
//     ippiFFTGetSize_C_32fc
//     ippiFFTInit_C_32fc
//     ippiFFTFwd_CToC_32fc_C1R

#include <stdio.h>
#include "ipp.h"

/* Next two defines are created to simplify code reading and understanding */
#define EXIT_MAIN exitLine:                                  /* Label for Exit */
#define check_sts(st) if((st) != ippStsNoErr) goto exitLine; /* Go to Exit if Intel(R) IPP function returned status different from ippStsNoErr */

/* Results of ippMalloc() are not validated because Intel(R) IPP functions perform bad arguments check and will return an appropriate status  */

int main(void)
{
    IppStatus           status;
    IppiFFTSpec_C_32fc  *pSpec = NULL;                              /* Pointer to FFT spec structure */

    Ipp32fc             srcFwd[8 * 8] = {0}, dstFwd[8 * 8] = {0};   /* Source/destination images */
    Ipp32fc             m3 = {-3, 0}, one = {1, 0};

    Ipp8u               *pMemInit = NULL, *pBuffer = NULL;          /* Pointer to the work buffers */
    int                 sizeSpec = 0, sizeInit = 0, sizeBuf = 0;    /* Size of FFT spec structure, init and work buffers */

    srcFwd[0] = m3;
    srcFwd[9] = one;

    check_sts( status = ippiFFTGetSize_C_32fc(3, 3, IPP_FFT_DIV_INV_BY_N, ippAlgHintAccurate, &sizeSpec, &sizeInit, &sizeBuf) )

    /* memory allocation */
    pSpec    = (IppiFFTSpec_C_32fc*) ippMalloc(sizeSpec);
    pBuffer  = (Ipp8u*) ippMalloc(sizeBuf);
    pMemInit = (Ipp8u*) ippMalloc(sizeInit);

    check_sts( status = ippiFFTInit_C_32fc(3, 3, IPP_FFT_DIV_INV_BY_N, ippAlgHintAccurate, pSpec, pMemInit) )

    /* forward FFT transform */
    check_sts( status = ippiFFTFwd_CToC_32fc_C1R(srcFwd, 8*sizeof(Ipp32fc), dstFwd, 8*sizeof(Ipp32fc), pSpec, pBuffer) )

EXIT_MAIN
    ippFree(pMemInit);
    ippFree(pSpec);
    ippFree(pBuffer);
    printf("Exit status %d (%s)\n", (int)status, ippGetStatusString(status));
    return (int)status;
}

FFTFwd_RToPack:

/*******************************************************************************
* Copyright 2015 Intel Corporation.
*
*
* This software and the related documents are Intel copyrighted materials, and your use of them is governed by
* the express license under which they were provided to you ('License'). Unless the License provides otherwise,
* you may not use, modify, copy, publish, distribute, disclose or transmit this software or the related
* documents without Intel's prior written permission.
* This software and the related documents are provided as is, with no express or implied warranties, other than
* those that are expressly stated in the License.
*******************************************************************************/

//   A simple example of performing the forward FFT for processing real data.
// implemented with Intel(R) Integrated Primitives (Intel(R) IPP) functions:
//     ippiFFTGetSize_R_32f
//     ippiFFTInit_R_32f
//     ippiFFTFwd_RToPack_32f_C1R


#include <stdio.h>
#include "ipp.h"

/* Next two defines are created to simplify code reading and understanding */
#define EXIT_MAIN exitLine:                                  /* Label for Exit */
#define check_sts(st) if((st) != ippStsNoErr) goto exitLine; /* Go to Exit if Intel(R) IPP function returned status different from ippStsNoErr */

/* Results of ippMalloc() are not validated because Intel(R) IPP functions perform bad arguments check and will return an appropriate status  */

int main(void)
{
    IppStatus status;
    IppiFFTSpec_R_32f *pSpec = NULL;  /* Pointer to FFT spec structure */

    /* Pointers to source/destination images */
    Ipp32f pSrcFwd[64] = {0}, pDstFwd[64] = {0};

    /* Pointer to the work buffers */
    Ipp8u *pMemInit = NULL;
    Ipp8u *pBuffer  = NULL;

    int sizeSpec = 0, sizeInit = 0, sizeBuf = 0; /* size of FFT spec structure, Init and work buffers */

    pSrcFwd[0] = -3; pSrcFwd[9] = 1;

    check_sts( status = ippiFFTGetSize_R_32f(3, 3, IPP_FFT_DIV_INV_BY_N, ippAlgHintAccurate,
                         &sizeSpec, &sizeInit, &sizeBuf) )

    /* memory allocation */
    pSpec    = (IppiFFTSpec_R_32f*) ippMalloc( sizeSpec );
    pBuffer  = (Ipp8u*) ippMalloc( sizeBuf );
    pMemInit = (Ipp8u*) ippMalloc( sizeInit );

    /* inverse FFT transform */
    check_sts( status = ippiFFTInit_R_32f(3, 3, IPP_FFT_DIV_INV_BY_N, ippAlgHintAccurate, pSpec, pMemInit) )

    check_sts( status = ippiFFTFwd_RToPack_32f_C1R( pSrcFwd, 8*sizeof(Ipp32f),
                                         pDstFwd, 8*sizeof(Ipp32f), pSpec, pBuffer ) )

EXIT_MAIN
    ippFree( pMemInit );
    ippFree( pSpec );
    ippFree( pBuffer );
    printf("Exit status %d (%s)\n", (int)status, ippGetStatusString(status));
    return (int)status;
}

See Also