From 24906b88690c4d0fbc4655ada495d566bc0841ae Mon Sep 17 00:00:00 2001 From: Themaister Date: Sun, 23 Mar 2014 14:27:31 +0100 Subject: [PATCH] Add resampler tests for CC resampler. --- Makefile.psp1 | 2 +- audio/resampler.c | 9 +++++++-- audio/resampler.h | 2 -- audio/test/Makefile | 18 ++++++++++++++++-- griffin/griffin.c | 2 +- 5 files changed, 25 insertions(+), 8 deletions(-) diff --git a/Makefile.psp1 b/Makefile.psp1 index d764ca7e3b..b4b7134725 100644 --- a/Makefile.psp1 +++ b/Makefile.psp1 @@ -15,7 +15,7 @@ INCDIR = $(PSPPATH)/include CFLAGS = $(OPTIMIZE_LV) -G0 -std=gnu99 -ffast-math ASFLAGS = $(CFLAGS) -RARCH_DEFINES = -DPSP -DHAVE_LIBRETRO_MANAGEMENT -DHAVE_ZLIB -DWANT_MINIZ -DHAVE_GRIFFIN=1 -DRARCH_INTERNAL -DRARCH_CONSOLE -DHAVE_MENU -DHAVE_RGUI -DWANT_RPNG -DSINC_LOWEST_QUALITY +RARCH_DEFINES = -DPSP -DHAVE_LIBRETRO_MANAGEMENT -DHAVE_ZLIB -DWANT_MINIZ -DHAVE_GRIFFIN=1 -DRARCH_INTERNAL -DRARCH_CONSOLE -DHAVE_MENU -DHAVE_RGUI -DWANT_RPNG -DSINC_LOWEST_QUALITY -DHAVE_CC_RESAMPLER LIBDIR = LDFLAGS = diff --git a/audio/resampler.c b/audio/resampler.c index b9113a45f5..9d6eafe990 100644 --- a/audio/resampler.c +++ b/audio/resampler.c @@ -23,10 +23,10 @@ #include "../general.h" static const rarch_resampler_t *backends[] = { - &sinc_resampler, -#if defined(PSP) +#ifdef HAVE_CC_RESAMPLER &CC_resampler, #endif + &sinc_resampler, NULL, }; @@ -42,6 +42,9 @@ static int find_resampler_driver_index(const char *driver) // Resampler is used by multiple modules so avoid clobbering g_extern.audio_data.resampler here. static const rarch_resampler_t *find_resampler_driver(const char *ident) { + if (!ident) + return backends[0]; + int i = find_resampler_driver_index(ident); if (i >= 0) return backends[i]; @@ -56,6 +59,7 @@ static const rarch_resampler_t *find_resampler_driver(const char *ident) } } +#ifndef RESAMPLER_TEST void find_prev_resampler_driver(void) { int i = find_resampler_driver_index(g_settings.audio.resampler); @@ -73,6 +77,7 @@ void find_next_resampler_driver(void) else RARCH_WARN("Couldn't find any next resampler driver (current one: \"%s\").\n", g_extern.audio_data.resampler->ident); } +#endif bool rarch_resampler_realloc(void **re, const rarch_resampler_t **backend, const char *ident, double bw_ratio) { diff --git a/audio/resampler.h b/audio/resampler.h index d7cced4bc0..7fe2ee4fc8 100644 --- a/audio/resampler.h +++ b/audio/resampler.h @@ -51,9 +51,7 @@ typedef struct rarch_resampler } rarch_resampler_t; extern const rarch_resampler_t sinc_resampler; -#if defined(PSP) extern const rarch_resampler_t CC_resampler; -#endif // Reallocs resampler. Will free previous handle before allocating a new one. // If ident is NULL, first resampler will be used. diff --git a/audio/test/Makefile b/audio/test/Makefile index a1779b1937..a5838ab00f 100644 --- a/audio/test/Makefile +++ b/audio/test/Makefile @@ -7,9 +7,11 @@ TESTS := test-sinc-lowest \ test-sinc-higher \ test-snr-sinc-higher \ test-sinc-highest \ - test-snr-sinc-highest + test-snr-sinc-highest \ + test-cc \ + test-snr-cc -CFLAGS += -O3 -ffast-math -g -Wall -pedantic -march=native -std=gnu99 -DRESAMPLER_TEST +CFLAGS += -O3 -ffast-math -g -Wall -pedantic -march=native -std=gnu99 -DRESAMPLER_TEST -DRARCH_DUMMY_LOG LDFLAGS += -lm all: $(TESTS) @@ -17,6 +19,12 @@ all: $(TESTS) resampler-sinc.o: ../resampler.c $(CC) -c -o $@ $< $(CFLAGS) +resampler-cc.o: ../resampler.c + $(CC) -c -o $@ $< $(CFLAGS) -DHAVE_CC_RESAMPLER + +cc-resampler.o: ../cc_resampler.c + $(CC) -c -o $@ $< $(CFLAGS) + sinc-lowest.o: ../sinc.c $(CC) -c -o $@ $< $(CFLAGS) -DSINC_LOWEST_QUALITY @@ -62,6 +70,12 @@ test-sinc-highest: sinc-highest.o ../utils.o main.o resampler-sinc.o test-snr-sinc-highest: sinc-highest.o ../utils.o snr.o resampler-sinc.o $(CC) -o $@ $^ $(LDFLAGS) +test-cc: cc-resampler.o ../utils.o main.o resampler-cc.o sinc.o + $(CC) -o $@ $^ $(LDFLAGS) + +test-snr-cc: cc-resampler.o ../utils.o snr.o resampler-cc.o sinc.o + $(CC) -o $@ $^ $(LDFLAGS) + %.o: %.c $(CC) -c -o $@ $< $(CFLAGS) diff --git a/griffin/griffin.c b/griffin/griffin.c index a17bea0301..161321aa63 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -358,7 +358,7 @@ AUDIO RESAMPLER ============================================================ */ #include "../audio/resampler.c" #include "../audio/sinc.c" -#ifdef PSP +#ifdef HAVE_CC_RESAMPLER #include "../audio/cc_resampler.c" #endif