ref: f9937b667279820ad602d90e4b11f4c9105f082b
parent: b008a5a7e9772a8f76532eea17697f32e77a7f3b
author: Erik de Castro Lopo <erikd@miles>
date: Fri Sep 10 05:21:50 EDT 2004
Move MIN/MAX/ABS/ARRAY_LEN macros to util.h.
--- a/tests/benchmark.c
+++ b/tests/benchmark.c
@@ -12,10 +12,8 @@
#define BUFFER_LEN (1<<23)
#define SNR_LEN (1<<16)
-#define ARRAY_LEN(x) ((int)(sizeof (x)) / (sizeof ((x) [0])))
-
-static float input [BUFFER_LEN];
-static float output [BUFFER_LEN];
+static float input [BUFFER_LEN] ;
+static float output [BUFFER_LEN] ;
int
main (void)
--- a/tests/calc_snr.c
+++ b/tests/calc_snr.c
@@ -33,9 +33,6 @@
#define MAX_SPEC_LEN (1<<18)
#define MAX_PEAKS 10
-#define ARRAY_LEN(x) ((int) (sizeof (x) / sizeof ((x) [0])))
-#define MAX(x,y) (((x) >= (y)) ? (x) : (y))
-
static void log_mag_spectrum (double *input, int len, double *magnitude) ;
static void smooth_mag_spectrum (double *magnitude, int len) ;
static double find_snr (const double *magnitude, int len) ;
--- a/tests/callback_test.c
+++ b/tests/callback_test.c
@@ -28,8 +28,6 @@
#define BUFFER_LEN 90000
#define CB_READ_LEN 256
-#define ARRAY_LEN(x) ((int) (sizeof (x) / sizeof ((x) [0])))
-
static void callback_test (int converter, double ratio) ;
int
--- a/tests/float_short_test.c
+++ b/tests/float_short_test.c
@@ -27,11 +27,6 @@
#define BUFFER_LEN 10000
-#define ARRAY_LEN(x) ((int) (sizeof (x) / sizeof ((x) [0])))
-
-#define ABS(a) (((a) < 0) ? - (a) : (a))
-#define MAX(a,b) (((a) >= (b)) ? (a) : (b))
-
static void float_to_short_test (void) ;
static void short_to_float_test (void) ;
--- a/tests/misc_test.c
+++ b/tests/misc_test.c
@@ -24,8 +24,6 @@
#include "util.h"
-#define ARRAY_LEN(x) ((int) (sizeof (x) / sizeof ((x) [0])))
-
static void name_test (void) ;
static void error_test (void) ;
static void src_ratio_test (void) ;
--- a/tests/multi_channel_test.c
+++ b/tests/multi_channel_test.c
@@ -30,10 +30,6 @@
#define BUFFER_LEN (1<<15)
#define BLOCK_LEN (12)
-#define ARRAY_LEN(x) ((int) (sizeof (x) / sizeof ((x) [0])))
-#define MAX(x,y) ((x) >= (y) ? (x) : (y))
-#define MIN(x,y) ((x) < (y) ? (x) : (y))
-
static void simple_test (int converter, int channel_count, double target_snr) ;
static void process_test (int converter, int channel_count, double target_snr) ;
static void callback_test (int converter, int channel_count, double target_snr) ;
--- a/tests/simple_test.c
+++ b/tests/simple_test.c
@@ -27,8 +27,6 @@
#define BUFFER_LEN 2048
-#define ARRAY_LEN(x) ((int) (sizeof (x) / sizeof ((x) [0])))
-
static void simple_test (int converter, double ratio) ;
int
--- a/tests/snr_bw_test.c
+++ b/tests/snr_bw_test.c
@@ -40,8 +40,6 @@
#define M_PI 3.14159265358979323846264338
#endif
-#define ARRAY_LEN(x) ((int) (sizeof (x) / sizeof ((x) [0])))
-
enum
{ BOOLEAN_FALSE = 0,
BOOLEAN_TRUE = 1
--- a/tests/src-evaluate.c
+++ b/tests/src-evaluate.c
@@ -38,7 +38,6 @@
#define MAX_FREQS 4
#define BUFFER_LEN 40000
-#define ARRAY_LEN(x) ((int) ((sizeof (x)) / (sizeof ((x) [0]))))
#define SAFE_STRNCAT(dest,src,len) \
{ int safe_strncat_count ; \
--- a/tests/streaming_test.c
+++ b/tests/streaming_test.c
@@ -25,10 +25,6 @@
#define BLOCK_LEN 100
-#define ARRAY_LEN(x) ((int) (sizeof (x) / sizeof ((x) [0])))
-
-#define MIN(a,b) (((a) < (b)) ? (a) : (b))
-
static void stream_test (int converter, double ratio) ;
int
--- a/tests/termination_test.c
+++ b/tests/termination_test.c
@@ -27,11 +27,6 @@
#define SHORT_BUFFER_LEN 2048
#define LONG_BUFFER_LEN ((1 << 16) - 20)
-#define ARRAY_LEN(x) ((int) (sizeof (x) / sizeof ((x) [0])))
-
-#define MIN(a,b) (((a) < (b)) ? (a) : (b))
-#define MAX(a,b) (((a) > (b)) ? (a) : (b))
-
static void stream_test (int converter, double ratio) ;
static void term_test (int converter, double ratio) ;
--- a/tests/util.h
+++ b/tests/util.h
@@ -16,6 +16,12 @@
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*/
+#define ABS(a) (((a) < 0) ? - (a) : (a))
+#define MIN(a,b) (((a) < (b)) ? (a) : (b))
+#define MAX(a,b) (((a) >= (b)) ? (a) : (b))
+
+#define ARRAY_LEN(x) ((int) (sizeof (x) / sizeof ((x) [0])))
+
void gen_windowed_sines (float *data, int data_len, double *freqs, int freq_count) ;
void save_oct_float (char *filename, float *input, int in_len, float *output, int out_len) ;