From ac2eb527b7e16da523069d814d9ce0f0c8cadcbd Mon Sep 17 00:00:00 2001 From: Mark Borgerding Date: Tue, 24 Feb 2004 01:38:52 +0000 Subject: [PATCH] fftnd now uses forward struct declaration --- tools/Makefile | 4 ++-- tools/kiss_fftnd.c | 18 +++++++++--------- tools/kiss_fftnd.h | 6 ++++-- tools/psdpng.c | 4 ++-- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/tools/Makefile b/tools/Makefile index 59bd695..365a7f2 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -23,9 +23,9 @@ endif all: $(FFTUTIL) $(FASTFILT) $(FASTFILTREAL) $(PSDPNG) -#CFLAGS=-Wall -O3 -pedantic -march=pentiumpro -ffast-math -fomit-frame-pointer +CFLAGS=-Wall -O3 -pedantic -march=pentiumpro -ffast-math -fomit-frame-pointer # If the above flags do not work, try the following -CFLAGS=-Wall -O3 +#CFLAGS=-Wall -O3 $(FASTFILTREAL): ../kiss_fft.c kiss_fastfir.c kiss_fftr.c $(CC) -o $@ $(CFLAGS) -I.. $(TYPEFLAGS) -DREAL_FASTFIR -lm $+ -DFAST_FILT_UTIL diff --git a/tools/kiss_fftnd.c b/tools/kiss_fftnd.c index eec89ce..6e6fc1e 100644 --- a/tools/kiss_fftnd.c +++ b/tools/kiss_fftnd.c @@ -14,22 +14,23 @@ Redistribution and use in source and binary forms, with or without modification, THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "kiss_fftnd.h" #include "_kiss_fft_guts.h" -typedef struct { +struct kiss_fftnd_state{ int dimprod; /* dimsum would be mighty tasty right now */ int ndims; int *dims; kiss_fft_cfg *states; /* cfg states for each dimension */ kiss_fft_cpx * tmpbuf; /*buffer capable of hold the entire buffer */ -}kiss_fftnd_state; +}; -void * kiss_fftnd_alloc(int *dims,int ndims,int inverse_fft,void*mem,size_t*lenmem) +kiss_fftnd_cfg kiss_fftnd_alloc(int *dims,int ndims,int inverse_fft,void*mem,size_t*lenmem) { - kiss_fftnd_state *st = NULL; + kiss_fftnd_cfg st = NULL; int i; int dimprod=1; - size_t memneeded = sizeof(kiss_fftnd_state); + size_t memneeded = sizeof(struct kiss_fftnd_state); char * ptr; for (i=0;itmpbuf */ if (lenmem == NULL) {/* allocate for the caller*/ - st = (kiss_fftnd_state *) malloc (memneeded); + st = (kiss_fftnd_cfg) malloc (memneeded); } else { /* initialize supplied buffer if big enough */ if (*lenmem >= memneeded) - st = (kiss_fftnd_state *) mem; + st = (kiss_fftnd_cfg) mem; *lenmem = memneeded; /*tell caller how big struct is (or would be) */ } if (!st) @@ -137,10 +138,9 @@ Stage 2 ( D=4) treats this buffer as a 4*6 matrix, , i.e. the summation of all 24 input elements. */ -void kiss_fftnd(void * cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout) +void kiss_fftnd(kiss_fftnd_cfg st,const kiss_fft_cpx *fin,kiss_fft_cpx *fout) { int i,k; - kiss_fftnd_state *st = ( kiss_fftnd_state *)cfg; const kiss_fft_cpx * bufin=fin; kiss_fft_cpx * bufout; diff --git a/tools/kiss_fftnd.h b/tools/kiss_fftnd.h index 23d93bd..75e8785 100644 --- a/tools/kiss_fftnd.h +++ b/tools/kiss_fftnd.h @@ -7,8 +7,10 @@ extern "C" { #endif -void * kiss_fftnd_alloc(int *dims,int ndims,int inverse_fft,void*mem,size_t*lenmem); -void kiss_fftnd(void * cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout); +typedef struct kiss_fftnd_state * kiss_fftnd_cfg; + +kiss_fftnd_cfg kiss_fftnd_alloc(int *dims,int ndims,int inverse_fft,void*mem,size_t*lenmem); +void kiss_fftnd(kiss_fftnd_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout); #ifdef __cplusplus } diff --git a/tools/psdpng.c b/tools/psdpng.c index 9a30dbb..1b18a36 100644 --- a/tools/psdpng.c +++ b/tools/psdpng.c @@ -133,12 +133,12 @@ void transform_signal() CHECKNULL( avgbuf=(kiss_fft_cpx*)malloc(sizeof(kiss_fft_cpx)*nfreqs ) ); while ( ( n = fread(inbuf,sizeof(short)*2,nfft,fin) ) == nfft ) { - //pack the shorts + /* pack the shorts */ for (i=0;i