Intel® Integrated Performance Primitives (Intel® IPP) Developer Guide and Reference

ID 790148
Date 3/22/2024
Public
Document Table of Contents

FFTInv

Applies an inverse FFT to complex source data and stores results in a destination image.

Syntax

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

IppStatus ippiFFTInv_PackToR_<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 ippiFFTInv_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 ippiFFTInv_PackToR_<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 ippiFFTInv_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 previously initialized FFT context structure.

pBuffer

Pointer to the external work buffer.

Description

This function operates with ROI.

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

For the ippiFFTInv_PackToR, function flavor, the input buffer must contain data in RCPack2D format.

Before using the inverse FFT functions, you need to compute the size of the work buffer by ippiFFTGetSize and initialize the context structure by the ippiFFTInit function. The inverse 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

FFTInv_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 Performance Primitives (Intel(R) IPP) functions:
//     ippiFFTGetSize_C_32fc
//     ippiFFTInit_C_32fc
//     ippiFFTFwd_CToC_32fc_C1R
//     ippiFFTInv_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 */

    /* Pointers to source/destination images */
    Ipp32fc pSrcFwd[64] = {0}, pDstFwd[64] = {0};
    Ipp32fc pSrcInv[64] = {0}, pDstInv[64] = {0};
    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 */

    pSrcFwd[0] = m3; pSrcFwd[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( pSrcFwd, 8*sizeof(Ipp32fc),
                                                  pDstFwd, 8*sizeof(Ipp32fc), pSpec, pBuffer ) )

    check_sts( status = ippsCopy_32fc( pDstFwd, pSrcInv, 64 ) )

    /* inverse FFT transform */
    check_sts( status = ippiFFTInv_CToC_32fc_C1R( pSrcInv, 8*sizeof(Ipp32fc),
                                                  pDstInv, 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;
}

FFTInv_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 inverse FFT for processing real data.
// implemented with Intel(R) Integrated Performance Primitives (Intel(R) IPP) functions:
//     ippiFFTGetSize_R_32f
//     ippiFFTInit_R_32f
//     ippiFFTFwd_RToPack_32f_C1R
//     ippiFFTInv_PackToR_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};
    Ipp32f pSrcInv[64] = {0}, pDstInv[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 );

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

    /* forward FFT transform */
    check_sts( status = ippiFFTFwd_RToPack_32f_C1R( pSrcFwd, 8*sizeof(Ipp32f),
                                                    pDstFwd, 8*sizeof(Ipp32f), pSpec, pBuffer ) )

    check_sts( status = ippsCopy_32f(pDstFwd, pSrcInv, 64) )

    /* inverse FFT transform */
    check_sts( status = ippiFFTInv_PackToR_32f_C1R( pSrcInv, 8*sizeof(Ipp32f),
                                                    pDstInv, 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