fix resampler tests.

This commit is contained in:
aliaspider 2014-09-17 19:07:40 +01:00
parent d1a785823d
commit 493a8aea2d
3 changed files with 48 additions and 29 deletions

View File

@ -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

View File

@ -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 <stdio.h>
#include <stdlib.h>
#include <time.h>
#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;

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#include "../resampler.h"
#include "../resamplers/resampler.h"
#include "../utils.h"
#include <stdio.h>
#include <stdlib.h>
@ -23,6 +23,10 @@
#include <assert.h>
#include <stdbool.h>
#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();