this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add common logging mechanism, use NDEBUG to turn off logging

+51 -14
+6 -5
_kiss_fft_guts.h
··· 15 15 #define _kiss_fft_guts_h 16 16 17 17 #include "kiss_fft.h" 18 + #include "kiss_fft_log.h" 18 19 #include <limits.h> 19 20 20 21 #define MAXFACTORS 32 21 - /* e.g. an fft of length 128 has 4 factors 22 + /* e.g. an fft of length 128 has 4 factors 22 23 as far as kissfft is concerned 23 24 4*4*4*2 24 25 */ ··· 56 57 #if defined(CHECK_OVERFLOW) 57 58 # define CHECK_OVERFLOW_OP(a,op,b) \ 58 59 if ( (SAMPPROD)(a) op (SAMPPROD)(b) > SAMP_MAX || (SAMPPROD)(a) op (SAMPPROD)(b) < SAMP_MIN ) { \ 59 - fprintf(stderr,"WARNING:overflow @ " __FILE__ "(%d): (%d " #op" %d) = %ld\n",__LINE__,(a),(b),(SAMPPROD)(a) op (SAMPPROD)(b) ); } 60 + KISS_FFT_WARNING("overflow (%d " #op" %d) = %ld", (a),(b),(SAMPPROD)(a) op (SAMPPROD)(b)); } 60 61 #endif 61 62 62 63 ··· 146 147 147 148 /* a debugging function */ 148 149 #define pcpx(c)\ 149 - fprintf(stderr,"%g + %gi\n",(double)((c)->r),(double)((c)->i) ) 150 + KISS_FFT_DEBUG("%g + %gi\n",(double)((c)->r),(double)((c)->i)) 150 151 151 152 152 153 #ifdef KISS_FFT_USE_ALLOCA 153 154 // define this to allow use of alloca instead of malloc for temporary buffers 154 - // Temporary buffers are used in two case: 155 + // Temporary buffers are used in two case: 155 156 // 1. FFT sizes that have "bad" factors. i.e. not 2,3 and 5 156 157 // 2. "in-place" FFTs. Notice the quotes, since kissfft does not really do an in-place transform. 157 158 #include <alloca.h> 158 159 #define KISS_FFT_TMP_ALLOC(nbytes) alloca(nbytes) 159 - #define KISS_FFT_TMP_FREE(ptr) 160 + #define KISS_FFT_TMP_FREE(ptr) 160 161 #else 161 162 #define KISS_FFT_TMP_ALLOC(nbytes) KISS_FFT_MALLOC(nbytes) 162 163 #define KISS_FFT_TMP_FREE(ptr) KISS_FFT_FREE(ptr)
+36
kiss_fft_log.h
··· 1 + /* 2 + * Copyright (c) 2003-2010, Mark Borgerding. All rights reserved. 3 + * This file is part of KISS FFT - https://github.com/mborgerding/kissfft 4 + * 5 + * SPDX-License-Identifier: BSD-3-Clause 6 + * See COPYING file for more information. 7 + */ 8 + 9 + #ifndef kiss_fft_log_h 10 + #define kiss_fft_log_h 11 + 12 + #define ERROR 1 13 + #define WARNING 2 14 + #define INFO 3 15 + #define DEBUG 4 16 + 17 + #define STRINGIFY(x) #x 18 + #define TOSTRING(x) STRINGIFY(x) 19 + 20 + #if defined(NDEBUG) 21 + # define KISS_FFT_LOG_MSG(severity, ...) ((void)0) 22 + #else 23 + # define KISS_FFT_LOG_MSG(severity, ...) \ 24 + fprintf(stderr, "[" #severity "] " __FILE__ ":" TOSTRING(__LINE__) " "); \ 25 + fprintf(stderr, __VA_ARGS__); \ 26 + fprintf(stderr, "\n") 27 + #endif 28 + 29 + #define KISS_FFT_ERROR(...) KISS_FFT_LOG_MSG(ERROR, __VA_ARGS__) 30 + #define KISS_FFT_WARNING(...) KISS_FFT_LOG_MSG(WARNING, __VA_ARGS__) 31 + #define KISS_FFT_INFO(...) KISS_FFT_LOG_MSG(INFO, __VA_ARGS__) 32 + #define KISS_FFT_DEBUG(...) KISS_FFT_LOG_MSG(DEBUG, __VA_ARGS__) 33 + 34 + 35 + 36 + #endif /* kiss_fft_log_h */
+9 -9
tools/kiss_fftr.c
··· 27 27 size_t subsize = 0, memneeded; 28 28 29 29 if (nfft & 1) { 30 - fprintf(stderr,"Real FFT optimization must be even.\n"); 30 + KISS_FFT_ERROR("Real FFT optimization must be even."); 31 31 return NULL; 32 32 } 33 33 nfft >>= 1; ··· 67 67 kiss_fft_cpx fpnk,fpk,f1k,f2k,tw,tdc; 68 68 69 69 if ( st->substate->inverse) { 70 - fprintf(stderr,"kiss fft usage error: improper alloc\n"); 70 + KISS_FFT_ERROR("kiss fft usage error: improper alloc"); 71 71 exit(1); 72 72 } 73 73 ··· 79 79 * contains the sum of the even-numbered elements of the input time sequence 80 80 * The imag part is the sum of the odd-numbered elements 81 81 * 82 - * The sum of tdc.r and tdc.i is the sum of the input time sequence. 82 + * The sum of tdc.r and tdc.i is the sum of the input time sequence. 83 83 * yielding DC of input time sequence 84 - * The difference of tdc.r - tdc.i is the sum of the input (dot product) [1,-1,1,-1... 84 + * The difference of tdc.r - tdc.i is the sum of the input (dot product) [1,-1,1,-1... 85 85 * yielding Nyquist bin of input time sequence 86 86 */ 87 - 87 + 88 88 tdc.r = st->tmpbuf[0].r; 89 89 tdc.i = st->tmpbuf[0].i; 90 90 C_FIXDIV(tdc,2); ··· 92 92 CHECK_OVERFLOW_OP(tdc.r ,-, tdc.i); 93 93 freqdata[0].r = tdc.r + tdc.i; 94 94 freqdata[ncfft].r = tdc.r - tdc.i; 95 - #ifdef USE_SIMD 95 + #ifdef USE_SIMD 96 96 freqdata[ncfft].i = freqdata[0].i = _mm_set1_ps(0); 97 97 #else 98 98 freqdata[ncfft].i = freqdata[0].i = 0; 99 99 #endif 100 100 101 101 for ( k=1;k <= ncfft/2 ; ++k ) { 102 - fpk = st->tmpbuf[k]; 102 + fpk = st->tmpbuf[k]; 103 103 fpnk.r = st->tmpbuf[ncfft-k].r; 104 104 fpnk.i = - st->tmpbuf[ncfft-k].i; 105 105 C_FIXDIV(fpk,2); ··· 122 122 int k, ncfft; 123 123 124 124 if (st->substate->inverse == 0) { 125 - fprintf (stderr, "kiss fft usage error: improper alloc\n"); 125 + KISS_FFT_ERROR("kiss fft usage error: improper alloc"); 126 126 exit (1); 127 127 } 128 128 ··· 145 145 C_MUL (fok, tmp, st->super_twiddles[k-1]); 146 146 C_ADD (st->tmpbuf[k], fek, fok); 147 147 C_SUB (st->tmpbuf[ncfft - k], fek, fok); 148 - #ifdef USE_SIMD 148 + #ifdef USE_SIMD 149 149 st->tmpbuf[ncfft - k].i *= _mm_set1_ps(-1.0); 150 150 #else 151 151 st->tmpbuf[ncfft - k].i *= -1;