FFT
Performs fast Fourier transform (FFT) on a two-dimensional image.
Before this interface is called for calculation, the HMPPS_FFTCToCInit interface must be called to initialize the HmppsFFTPolicy standard structure.
- Initialization function
HmppResult HMPPI_FFTCToCInit_32fc(int32_t powerX, int32_t powerY, int32_t direction, int32_t flag, HmppsFFTPolicy_32fc **policyX, HmppsFFTPolicy_32fc **policyY);
policyX and policyY need to be initialized by calling HMPPS_FFTCToCInit_32fc. For details, see FFT.
- Main function
HmppResult HMPPI_FFTCToC_32fc_C1R(Hmpp32fc *src, int srcStep, Hmpp32fc *dst, int dstStep, HmppsFFTPolicy_32fc *policyX, HmppsFFTPolicy_32fc *policyY);
- Resource release function
HmppResult HMPPI_FFTCToCRelease_32fc(HmppsFFTPolicy_32fc *policyX, HmppsFFTPolicy_32fc *policyY);
Parameters
Parameter |
Description |
Value Range |
Input/Output |
|---|---|---|---|
powerX |
Signal length in the X axis of the image. The input signal length for the FFT sequence is: |
[0, 27] |
Input |
powerY |
Signal length in the Y axis of the image. The input signal length for the FFT sequence is: |
[0, 27] |
Input |
direction |
Value 1 indicates forward FFT. Value -1 indicates inverse FFT. (Used for the CToC mode) |
± 1 |
Input |
flag |
Result normalization mode |
|
Input |
policyX (in the init function) |
Double pointer to the HmppsFFTPolicy structure for the X axis. The structure contains the pointers to information and buffer block start address required for FFT calculation. |
The value cannot be NULL. |
Output |
policyY (in the init function) |
Double pointer to the HmppsFFTPolicy structure for the Y axis. The structure contains the pointers to information and buffer block start address required for FFT calculation. |
The value cannot be NULL. |
Output |
policy (in the main and release functions) |
Pointer to the HmppsFFTPolicy structure |
The value cannot be NULL. |
Input |
src |
Pointer to the source image ROI |
The value cannot be NULL. |
Input |
dst |
Pointer to the destination image ROI |
The value cannot be NULL. |
Input/Output |
srcStep |
Distance between starts of consecutive lines in the source image, in bytes |
The value must be zero or a positive integer. |
Input |
dstStep |
Distance between starts of consecutive lines in the destination image, in bytes |
The value must be zero or a positive integer. |
Input |
Return Value
- Success: HMPP_STS_NO_ERR
- Failure: An error code is returned.
Error Codes
Error Code |
Description |
|---|---|
HMPP_STS_NULL_PTR_ERR |
Any of the specified pointers is NULL. |
HMPP_STS_FFT_POWER_ERR |
The value of power is less than 0 or greater than 27. |
HMPP_STS_MALLOC_FAILED |
Failed to allocate the required extra memory. |
HMPP_STS_FFT_FLAG_ERR |
The value of flag is not in the range [1, 4]. |
- The initialization of the HmppsFFTPolicy structure needs to be applied for in the Init function. You cannot apply for or define this structure by yourself.
Example
#include <stdio.h>
#include <math.h>
#include "hmppi.h"
#include "hmpp_type.h"
#define PI 3.14159265358979323846
void FFTCToC_Example()
{
Hmpp32fc src[64], dst[64];
for (int32_t i = 0; i < 8; i++) {
for (int32_t j = 0; j < 8; j++) {
src[i * 8 + j].re = cos(2 * PI * i * 16 / 64);
src[i * 8 + j].im = 1;
}
}
HmppResult result;
HmppsFFTPolicy_32fc *policyX = NULL;
HmppsFFTPolicy_32fc *policyY = NULL;
int srcStep = 8 * sizeof(Hmpp32fc);
int dstStep = 8 * sizeof(Hmpp32fc);
result = HMPPI_FFTCToCInit_32fc(3, 3, 1, HMPP_FFT_NODIV_BY_ANY, &policyX, &policyY);// Forward FFT
if (result != HMPP_STS_NO_ERR) {
printf("Create Policy Error!\n");
return;
}
result = HMPPI_FFTCToC_32fc_C1R(src, srcStep, dst, dstStep, policyX, policyY);
if (result != HMPP_STS_NO_ERR) {
printf("FFT Error!\n");
return;
}
HMPPI_FFTCToCRelease_32fc(policyX, policyY);
printf("dstRe =");
for (int32_t i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
printf(" %e", dst[i * 8 + j].re);
}
}
printf("\ndstIm =");
for (int32_t i = 0; i < 64; i++) {
for (int j = 0; j < 8; j++) {
printf(" %e", dst[i * 8 + j].im);
}
}
printf("\n");
}
int main() {
FFTCToC_Example();
return 0;
}
Output:
dstRe = -1.959435e-15 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 -2.771059e-15 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 3.200000e+01 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 2.771059e-15 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 1.959435e-15 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 2.771059e-15 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 3.200000e+01 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 -2.771059e-15 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 dstIm = 6.400000e+01 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 -7.837740e-15 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 7.837740e-15 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 0.000000e+00 8.968310e-44 2.242078e-44 1.121039e-44 1.121039e-44 9.183409e-41 9.183409e-41 0.000000e+00 0.000000e+00 1.401298e-45 9.183409e-41 9.183409e-41 0.000000e+00 0.000000e+00 0.000000e+00 9.183409e-41 0.000000e+00 9.183409e-41 0.000000e+00 0.000000e+00 0.000000e+00 9.183409e-41 -1.973691e+26 9.183409e-41 -1.973691e+26 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 9.183409e-41 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 -1.456977e-27 9.183409e-41 9.183409e-41 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 9.183409e-41 0.000000e+00 9.183409e-41 9.183409e-41 9.183409e-41 9.183409e-41 9.183409e-41 9.183409e-41 9.183409e-41 9.183409e-41 9.183409e-41 9.183409e-41 9.183409e-41 9.183409e-41 9.183409e-41 9.183409e-41 9.183409e-41 9.183409e-41 9.183409e-41 9.183409e-41 9.183409e-41 9.183409e-41 9.183409e-41 9.183409e-41 9.183409e-41 9.183409e-41 9.183409e-41 9.183409e-41 9.183409e-41 0.000000e+00 0.000000e+00 9.183409e-41 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 9.183409e-41 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 9.183409e-41 0.000000e+00 0.000000e+00 0.000000e+00 9.183409e-41 0.000000e+00 9.183409e-41 0.000000e+00 0.000000e+00 -1.456977e-27 -1.979496e+26 4.794963e-39 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00

