From 493a8aea2d692b33829bf712e5c58dd40487f87d Mon Sep 17 00:00:00 2001 From: aliaspider Date: Wed, 17 Sep 2014 19:07:40 +0100 Subject: [PATCH] fix resampler tests. --- audio/test/Makefile | 55 +++++++++++++++++++++++++++------------------ audio/test/main.c | 10 ++++++--- audio/test/snr.c | 12 ++++++---- 3 files changed, 48 insertions(+), 29 deletions(-) diff --git a/audio/test/Makefile b/audio/test/Makefile index a5838ab00f..197621189b 100644 --- a/audio/test/Makefile +++ b/audio/test/Makefile @@ -11,69 +11,80 @@ TESTS := test-sinc-lowest \ test-cc \ test-snr-cc -CFLAGS += -O3 -ffast-math -g -Wall -pedantic -march=native -std=gnu99 -DRESAMPLER_TEST -DRARCH_DUMMY_LOG +CFLAGS += -O3 -ffast-math -g -Wall -pedantic -march=native -std=gnu99 +CFLAGS += -DRESAMPLER_TEST -DRARCH_DUMMY_LOG + LDFLAGS += -lm all: $(TESTS) -resampler-sinc.o: ../resampler.c +resampler-sinc.o: ../resamplers/resampler.c $(CC) -c -o $@ $< $(CFLAGS) -resampler-cc.o: ../resampler.c - $(CC) -c -o $@ $< $(CFLAGS) -DHAVE_CC_RESAMPLER +resampler-cc.o: ../resamplers/resampler.c + $(CC) -c -o $@ $< $(CFLAGS) -DHAVE_CC_RESAMPLER -DRESAMPLER_IDENT='"CC"' -cc-resampler.o: ../cc_resampler.c +main-cc.o: main.c + $(CC) -c -o $@ $< $(CFLAGS) -DHAVE_CC_RESAMPLER -DRESAMPLER_IDENT='"CC"' + +snr-cc.o: snr.c + $(CC) -c -o $@ $< $(CFLAGS) -DHAVE_CC_RESAMPLER -DRESAMPLER_IDENT='"CC"' + +cc-resampler.o: ../resamplers/cc_resampler.c $(CC) -c -o $@ $< $(CFLAGS) -sinc-lowest.o: ../sinc.c +sinc-lowest.o: ../resamplers/sinc.c $(CC) -c -o $@ $< $(CFLAGS) -DSINC_LOWEST_QUALITY -sinc-lower.o: ../sinc.c +sinc-lower.o: ../resamplers/sinc.c $(CC) -c -o $@ $< $(CFLAGS) -DSINC_LOWER_QUALITY -sinc.o: ../sinc.c +sinc.o: ../resamplers/sinc.c $(CC) -c -o $@ $< $(CFLAGS) -sinc-higher.o: ../sinc.c +nearest.o: ../resamplers/nearest.c + $(CC) -c -o $@ $< $(CFLAGS) + +sinc-higher.o: ../resamplers/sinc.c $(CC) -c -o $@ $< $(CFLAGS) -DSINC_HIGHER_QUALITY -sinc-highest.o: ../sinc.c +sinc-highest.o: ../resamplers/sinc.c $(CC) -c -o $@ $< $(CFLAGS) -DSINC_HIGHEST_QUALITY -test-sinc-lowest: sinc-lowest.o ../utils.o main.o resampler-sinc.o +test-sinc-lowest: sinc-lowest.o ../utils.o main.o resampler-sinc.o nearest.o $(CC) -o $@ $^ $(LDFLAGS) -test-snr-sinc-lowest: sinc-lowest.o ../utils.o snr.o resampler-sinc.o +test-snr-sinc-lowest: sinc-lowest.o ../utils.o snr.o resampler-sinc.o nearest.o $(CC) -o $@ $^ $(LDFLAGS) -test-sinc-lower: sinc-lower.o ../utils.o main.o resampler-sinc.o +test-sinc-lower: sinc-lower.o ../utils.o main.o resampler-sinc.o nearest.o $(CC) -o $@ $^ $(LDFLAGS) -test-snr-sinc-lower: sinc-lower.o ../utils.o snr.o resampler-sinc.o +test-snr-sinc-lower: sinc-lower.o ../utils.o snr.o resampler-sinc.o nearest.o $(CC) -o $@ $^ $(LDFLAGS) -test-sinc: sinc.o ../utils.o main.o resampler-sinc.o +test-sinc: sinc.o ../utils.o main.o resampler-sinc.o nearest.o $(CC) -o $@ $^ $(LDFLAGS) -test-snr-sinc: sinc.o ../utils.o snr.o resampler-sinc.o +test-snr-sinc: sinc.o ../utils.o snr.o resampler-sinc.o nearest.o $(CC) -o $@ $^ $(LDFLAGS) -test-sinc-higher: sinc-higher.o ../utils.o main.o resampler-sinc.o +test-sinc-higher: sinc-higher.o ../utils.o main.o resampler-sinc.o nearest.o $(CC) -o $@ $^ $(LDFLAGS) -test-snr-sinc-higher: sinc-higher.o ../utils.o snr.o resampler-sinc.o +test-snr-sinc-higher: sinc-higher.o ../utils.o snr.o resampler-sinc.o nearest.o $(CC) -o $@ $^ $(LDFLAGS) -test-sinc-highest: sinc-highest.o ../utils.o main.o resampler-sinc.o +test-sinc-highest: sinc-highest.o ../utils.o main.o resampler-sinc.o nearest.o $(CC) -o $@ $^ $(LDFLAGS) -test-snr-sinc-highest: sinc-highest.o ../utils.o snr.o resampler-sinc.o +test-snr-sinc-highest: sinc-highest.o ../utils.o snr.o resampler-sinc.o nearest.o $(CC) -o $@ $^ $(LDFLAGS) -test-cc: cc-resampler.o ../utils.o main.o resampler-cc.o sinc.o +test-cc: cc-resampler.o ../utils.o main-cc.o resampler-cc.o sinc.o nearest.o $(CC) -o $@ $^ $(LDFLAGS) -test-snr-cc: cc-resampler.o ../utils.o snr.o resampler-cc.o sinc.o +test-snr-cc: cc-resampler.o ../utils.o snr-cc.o resampler-cc.o sinc.o nearest.o $(CC) -o $@ $^ $(LDFLAGS) %.o: %.c diff --git a/audio/test/main.c b/audio/test/main.c index 5930bdcb9f..fe04bebe15 100644 --- a/audio/test/main.c +++ b/audio/test/main.c @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -16,12 +16,16 @@ // Resampler that reads raw S16NE/stereo from stdin and outputs to stdout in S16NE/stereo. // Used for testing and performance benchmarking. -#include "../resampler.h" +#include "../resamplers/resampler.h" #include "../utils.h" #include #include #include +#ifndef RESAMPLER_IDENT +#define RESAMPLER_IDENT "sinc" +#endif + int main(int argc, char *argv[]) { srand(time(NULL)); @@ -56,7 +60,7 @@ int main(int argc, char *argv[]) const rarch_resampler_t *resampler = NULL; void *re = NULL; - if (!rarch_resampler_realloc(&re, &resampler, NULL, out_rate / in_rate)) + if (!rarch_resampler_realloc(&re, &resampler, RESAMPLER_IDENT, out_rate / in_rate)) { fprintf(stderr, "Failed to allocate resampler ...\n"); return 1; diff --git a/audio/test/snr.c b/audio/test/snr.c index 994d83384d..565c417010 100644 --- a/audio/test/snr.c +++ b/audio/test/snr.c @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -13,7 +13,7 @@ * If not, see . */ -#include "../resampler.h" +#include "../resamplers/resampler.h" #include "../utils.h" #include #include @@ -23,6 +23,10 @@ #include #include +#ifndef RESAMPLER_IDENT +#define RESAMPLER_IDENT "sinc" +#endif + #undef min #define min(a, b) (((a) < (b)) ? (a) : (b)) @@ -63,7 +67,7 @@ static unsigned bitswap(unsigned i, unsigned range) } // When interleaving the butterfly buffer, addressing puts bits in reverse. -// [0, 1, 2, 3, 4, 5, 6, 7] => [0, 4, 2, 6, 1, 5, 3, 7] +// [0, 1, 2, 3, 4, 5, 6, 7] => [0, 4, 2, 6, 1, 5, 3, 7] static void interleave(complex double *butterfly_buf, size_t samples) { unsigned range = bitrange(samples); @@ -269,7 +273,7 @@ int main(int argc, char *argv[]) void *re = NULL; const rarch_resampler_t *resampler = NULL; - if (!rarch_resampler_realloc(&re, &resampler, NULL, ratio)) + if (!rarch_resampler_realloc(&re, &resampler, RESAMPLER_IDENT, ratio)) return 1; test_fft();