changeset 1691:e68f7b0cb536

Cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 05 Jun 2018 09:37:37 +0300
parents 12d4da502fa4
children 9611ecd2c4fb
files src/dmfft.c
diffstat 1 files changed, 12 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- 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 <math.h>
 
 
+#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],