# HG changeset patch # User Matti Hamalainen # Date 1528180657 -10800 # Node ID e68f7b0cb53651315213f5b9bb69f1ae9c8bb97d # Parent 12d4da502fa4578cecb6fbc73b2aed80c48a50b5 Cleanups. diff -r 12d4da502fa4 -r e68f7b0cb536 src/dmfft.c --- a/src/dmfft.c Mon Jun 04 03:10:59 2018 +0300 +++ b/src/dmfft.c Tue Jun 05 09:37:37 2018 +0300 @@ -13,10 +13,11 @@ #include +#define DM_PW(a, b, c) (sqrt((a) * (a) + (b) * (b)) * (c)) + + int dmInitializeFFT(DMFFTContext * ctx, const int fftlen) { - int i; - if (ctx == NULL) return DMERR_NULLPTR; @@ -38,7 +39,7 @@ } // Calculate data - for (i = 0; i < ctx->npoints; i++) + for (int i = 0; i < ctx->npoints; i++) { int mask, tmp; for (tmp = 0, mask = ctx->npoints / 2; mask > 0; mask >>= 1) @@ -49,7 +50,7 @@ ctx->breversed[i] = tmp; } - for (i = 0; i < ctx->npoints; i++) + for (int i = 0; i < ctx->npoints; i++) { ctx->sinTable[ctx->breversed[i]] = -sin((2.0f * DM_PI * i) / fftlen); ctx->sinTable[ctx->breversed[i] + 1] = @@ -111,7 +112,6 @@ } // Massage output to get the output for a real input sequence. - while (br1 <= br2) { const DMFFTType vsin = ctx->sinTable[*br1]; @@ -152,14 +152,14 @@ int dmConvertFFTtoFreqDomain(DMFFTContext *ctx, DMFFTType *buffer, DMFFTType *real, DMFFTType *imag) { - int i; - if (ctx == NULL || buffer == NULL || real == NULL || imag == NULL) + if (ctx == NULL || buffer == NULL || + real == NULL || imag == NULL) return DMERR_NULLPTR; // Convert from bitreversed form to normal frequency domain const int *breversed = ctx->breversed; - for (i = 1; i < ctx->npoints; i++) + for (int i = 1; i < ctx->npoints; i++) { real[i] = buffer[breversed[i] ]; imag[i] = buffer[breversed[i]+1]; @@ -175,20 +175,17 @@ } -#define DM_PW(a, b, c) sqrt(a * a + b * b) * c - - int dmConvertFFTtoFreqAndPower(DMFFTContext *ctx, DMFFTType *buffer, DMFFTType *real, DMFFTType *imag, DMFFTType *power, const DMFFTType scale) { - int i; - if (ctx == NULL || buffer == NULL || real == NULL || imag == NULL || power == NULL) + if (ctx == NULL || buffer == NULL || + real == NULL || imag == NULL || power == NULL) return DMERR_NULLPTR; // Convert from bitreversed form to normal frequency domain const int *breversed = ctx->breversed; - for (i = 1; i < ctx->npoints; i++) + for (int i = 1; i < ctx->npoints; i++) { DMFFTType fre = real[i] = buffer[breversed[i] ], fim = imag[i] = buffer[breversed[i]+1]; @@ -212,7 +209,6 @@ int dmConvertFFTtoPowerAndSum(DMFFTContext *ctx, DMFFTType *buffer, DMFFTType *power, const DMFFTType pscale, DMFFTType *sum, const DMFFTType sscale) { - int i; if (ctx == NULL || buffer == NULL || power == NULL || sum == NULL) return DMERR_NULLPTR; @@ -220,7 +216,7 @@ const int *breversed = ctx->breversed; DMFFTType psum = 0; - for (i = 1; i < ctx->npoints; i++) + for (int i = 1; i < ctx->npoints; i++) { DMFFTType fre = buffer[breversed[i] ], fim = buffer[breversed[i]+1],