summaryrefslogtreecommitdiffstats
path: root/src/tests/resampler-test.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/resampler-test.c')
-rw-r--r--src/tests/resampler-test.c75
1 files changed, 64 insertions, 11 deletions
diff --git a/src/tests/resampler-test.c b/src/tests/resampler-test.c
index 6b4a64ca..7236265a 100644
--- a/src/tests/resampler-test.c
+++ b/src/tests/resampler-test.c
@@ -34,12 +34,6 @@
#include <liboil/liboil.h>
-static float swap_float(float a) {
- uint32_t *b = (uint32_t*) &a;
- *b = PA_UINT32_SWAP(*b);
- return a;
-}
-
static void dump_block(const pa_sample_spec *ss, const pa_memchunk *chunk) {
void *d;
unsigned i;
@@ -54,7 +48,7 @@ static void dump_block(const pa_sample_spec *ss, const pa_memchunk *chunk) {
uint8_t *u = d;
for (i = 0; i < chunk->length / pa_frame_size(ss); i++)
- printf("0x%02x ", *(u++));
+ printf(" 0x%02x ", *(u++));
break;
}
@@ -64,7 +58,7 @@ static void dump_block(const pa_sample_spec *ss, const pa_memchunk *chunk) {
uint16_t *u = d;
for (i = 0; i < chunk->length / pa_frame_size(ss); i++)
- printf("0x%04x ", *(u++));
+ printf(" 0x%04x ", *(u++));
break;
}
@@ -79,18 +73,40 @@ static void dump_block(const pa_sample_spec *ss, const pa_memchunk *chunk) {
break;
}
+ case PA_SAMPLE_S24_32NE:
+ case PA_SAMPLE_S24_32RE: {
+ uint32_t *u = d;
+
+ for (i = 0; i < chunk->length / pa_frame_size(ss); i++)
+ printf("0x%08x ", *(u++));
+
+ break;
+ }
+
case PA_SAMPLE_FLOAT32NE:
case PA_SAMPLE_FLOAT32RE: {
float *u = d;
for (i = 0; i < chunk->length / pa_frame_size(ss); i++) {
- printf("%1.3g ", ss->format == PA_SAMPLE_FLOAT32NE ? *u : swap_float(*u));
+ printf("%4.3g ", ss->format == PA_SAMPLE_FLOAT32NE ? *u : PA_FLOAT32_SWAP(*u));
u++;
}
break;
}
+ case PA_SAMPLE_S24LE:
+ case PA_SAMPLE_S24BE: {
+ uint8_t *u = d;
+
+ for (i = 0; i < chunk->length / pa_frame_size(ss); i++) {
+ printf(" 0x%06x ", PA_READ24NE(u));
+ u += pa_frame_size(ss);
+ }
+
+ break;
+ }
+
default:
pa_assert_not_reached();
}
@@ -162,6 +178,23 @@ static pa_memblock* generate_block(pa_mempool *pool, const pa_sample_spec *ss) {
break;
}
+ case PA_SAMPLE_S24_32NE:
+ case PA_SAMPLE_S24_32RE: {
+ uint32_t *u = d;
+
+ u[0] = 0x000001;
+ u[1] = 0xFF0002;
+ u[2] = 0x7F0003;
+ u[3] = 0x800004;
+ u[4] = 0x9f0005;
+ u[5] = 0x3f0006;
+ u[6] = 0x107;
+ u[7] = 0xF00008;
+ u[8] = 0x2009;
+ u[9] = 0x210A;
+ break;
+ }
+
case PA_SAMPLE_FLOAT32NE:
case PA_SAMPLE_FLOAT32RE: {
float *u = d;
@@ -179,11 +212,28 @@ static pa_memblock* generate_block(pa_mempool *pool, const pa_sample_spec *ss) {
if (ss->format == PA_SAMPLE_FLOAT32RE)
for (i = 0; i < 10; i++)
- u[i] = swap_float(u[i]);
+ u[i] = PA_FLOAT32_SWAP(u[i]);
break;
}
+ case PA_SAMPLE_S24NE:
+ case PA_SAMPLE_S24RE: {
+ uint8_t *u = d;
+
+ PA_WRITE24NE(u, 0x000001);
+ PA_WRITE24NE(u+3, 0xFF0002);
+ PA_WRITE24NE(u+6, 0x7F0003);
+ PA_WRITE24NE(u+9, 0x800004);
+ PA_WRITE24NE(u+12, 0x9f0005);
+ PA_WRITE24NE(u+15, 0x3f0006);
+ PA_WRITE24NE(u+18, 0x107);
+ PA_WRITE24NE(u+21, 0xF00008);
+ PA_WRITE24NE(u+24, 0x2009);
+ PA_WRITE24NE(u+27, 0x210A);
+ break;
+ }
+
default:
pa_assert_not_reached();
}
@@ -211,7 +261,6 @@ int main(int argc, char *argv[]) {
for (a.format = 0; a.format < PA_SAMPLE_MAX; a.format ++) {
for (b.format = 0; b.format < PA_SAMPLE_MAX; b.format ++) {
-
pa_resampler *forth, *back;
pa_memchunk i, j, k;
@@ -229,14 +278,18 @@ int main(int argc, char *argv[]) {
pa_resampler_run(forth, &i, &j);
pa_resampler_run(back, &j, &k);
+ printf("before: ");
dump_block(&a, &i);
+ printf("after : ");
dump_block(&b, &j);
+ printf("reverse: ");
dump_block(&a, &k);
pa_memblock_unref(j.memblock);
pa_memblock_unref(k.memblock);
pa_volume_memchunk(&i, &a, &v);
+ printf("volume: ");
dump_block(&a, &i);
pa_memblock_unref(i.memblock);