From 45481634f28a068e7cfc8a835cbe482f4d74349a Mon Sep 17 00:00:00 2001 From: Themaister Date: Fri, 6 Jul 2012 17:04:54 +0100 Subject: [PATCH] Add tests for fixed point sinc. --- audio/test/Makefile | 10 ++++++++-- audio/test/main.c | 16 +++++++++++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/audio/test/Makefile b/audio/test/Makefile index a1f3c9f39d..8f6339da0c 100644 --- a/audio/test/Makefile +++ b/audio/test/Makefile @@ -1,6 +1,6 @@ -TESTS := test-hermite test-sinc test-snr-sinc test-snr-hermite +TESTS := test-hermite test-sinc test-sinc-fixed test-snr-sinc test-snr-hermite -CFLAGS += -O3 -g -Wall -pedantic -std=gnu99 -DRESAMPLER_TEST -march=native +CFLAGS += -O3 -g -Wall -pedantic -std=gnu99 -DRESAMPLER_TEST LDFLAGS += -lm all: $(TESTS) @@ -11,12 +11,18 @@ test-hermite: ../hermite.o ../utils.o main.o test-sinc: ../sinc.o ../utils.o main.o $(CC) -o $@ $^ $(LDFLAGS) +test-sinc-fixed: ../sinc-fixed.o main-fixed.o + $(CC) -o $@ $^ $(LDFLAGS) + test-snr-sinc: ../sinc.o ../utils.o snr.o $(CC) -o $@ $^ $(LDFLAGS) test-snr-hermite: ../hermite.o ../utils.o snr.o $(CC) -o $@ $^ $(LDFLAGS) +%-fixed.o: %.c + $(CC) -c -o $@ $< $(CFLAGS) -DHAVE_FIXED_POINT + %.o: %.c $(CC) -c -o $@ $< $(CFLAGS) diff --git a/audio/test/main.c b/audio/test/main.c index 606ffc026d..3baec853a8 100644 --- a/audio/test/main.c +++ b/audio/test/main.c @@ -24,9 +24,12 @@ int main(int argc, char *argv[]) { int16_t input_i[1024]; - float input_f[1024]; int16_t output_i[1024 * 8]; + +#ifndef HAVE_FIXED_POINT + float input_f[1024]; float output_f[1024 * 8]; +#endif if (argc != 3) { @@ -56,19 +59,30 @@ int main(int argc, char *argv[]) if (fread(input_i, sizeof(int16_t), 1024, stdin) != 1024) break; +#ifndef HAVE_FIXED_POINT audio_convert_s16_to_float(input_f, input_i, 1024); +#endif struct resampler_data data = { +#ifdef HAVE_FIXED_POINT + .data_in = input_i, + .data_out = output_i, + .input_frames = sizeof(input_i) / (2 * sizeof(int16_t)), +#else .data_in = input_f, .data_out = output_f, .input_frames = sizeof(input_f) / (2 * sizeof(float)), +#endif .ratio = ratio, }; resampler_process(resamp, &data); size_t output_samples = data.output_frames * 2; + +#ifndef HAVE_FIXED_POINT audio_convert_float_to_s16(output_i, output_f, output_samples); +#endif if (fwrite(output_i, sizeof(int16_t), output_samples, stdout) != output_samples) break;