[pulseaudio-discuss] [PATCH 10/13] tests: Add rearrange remapping test cases to cpu-remap-test
Peter Meerwald
pmeerw at pmeerw.net
Thu Apr 24 09:51:02 PDT 2014
From: Peter Meerwald <p.meerwald at bct-electronic.com>
Signed-off-by: Peter Meerwald <pmeerw at pmeerw.net>
---
src/tests/cpu-remap-test.c | 82 ++++++++++++++++++++++++++++++--------------
1 file changed, 56 insertions(+), 26 deletions(-)
diff --git a/src/tests/cpu-remap-test.c b/src/tests/cpu-remap-test.c
index f5af70d..ffc7e49 100644
--- a/src/tests/cpu-remap-test.c
+++ b/src/tests/cpu-remap-test.c
@@ -142,7 +142,8 @@ static void setup_remap_channels(
pa_remap_t *m,
pa_sample_format_t f,
unsigned in_channels,
- unsigned out_channels) {
+ unsigned out_channels,
+ bool rearrange) {
unsigned i, o;
@@ -150,16 +151,25 @@ static void setup_remap_channels(
m->i_ss.channels = in_channels;
m->o_ss.channels = out_channels;
- if (in_channels == 1) {
+ if (rearrange) {
for (o = 0; o < out_channels; o++) {
- m->map_table_f[o][0] = 1.0f;
- m->map_table_i[o][0] = 0x10000;
+ for (i = 0; i < in_channels; i++) {
+ m->map_table_f[o][i] = (o == i) ? 1.0f : 0.0f;
+ m->map_table_i[o][i] = (o == i) ? 0x10000 : 0;
+ }
}
} else {
- for (o = 0; o < out_channels; o++) {
- for (i = 0; i < in_channels; i++) {
- m->map_table_f[o][i] = 1.0f / in_channels;
- m->map_table_i[o][i] = 0x10000 / in_channels;
+ if (in_channels == 1) {
+ for (o = 0; o < out_channels; o++) {
+ m->map_table_f[o][0] = 1.0f;
+ m->map_table_i[o][0] = 0x10000;
+ }
+ } else {
+ for (o = 0; o < out_channels; o++) {
+ for (i = 0; i < in_channels; i++) {
+ m->map_table_f[o][i] = 1.0f / in_channels;
+ m->map_table_i[o][i] = 0x10000 / in_channels;
+ }
}
}
}
@@ -203,14 +213,15 @@ static void remap_init_test_channels(
pa_init_remap_func_t orig_init_func,
pa_sample_format_t f,
unsigned in_channels,
- unsigned out_channels) {
+ unsigned out_channels,
+ bool rearrange) {
pa_remap_t remap_orig, remap_func;
- setup_remap_channels(&remap_orig, f, in_channels, out_channels);
+ setup_remap_channels(&remap_orig, f, in_channels, out_channels, rearrange);
orig_init_func(&remap_orig);
- setup_remap_channels(&remap_func, f, in_channels, out_channels);
+ setup_remap_channels(&remap_func, f, in_channels, out_channels, rearrange);
init_func(&remap_func);
remap_test_channels(&remap_func, &remap_orig);
@@ -219,19 +230,20 @@ static void remap_init_test_channels(
static void remap_init2_test_channels(
pa_sample_format_t f,
unsigned in_channels,
- unsigned out_channels) {
+ unsigned out_channels,
+ bool rearrange) {
pa_cpu_info cpu_info = { PA_CPU_UNDEFINED, {}, false };
pa_remap_t remap_orig, remap_func;
cpu_info.force_generic_code = true;
pa_remap_func_init(cpu_info);
- setup_remap_channels(&remap_orig, f, in_channels, out_channels);
+ setup_remap_channels(&remap_orig, f, in_channels, out_channels, rearrange);
pa_init_remap_func(&remap_orig);
cpu_info.force_generic_code = false;
pa_remap_func_init(cpu_info);
- setup_remap_channels(&remap_func, f, in_channels, out_channels);
+ setup_remap_channels(&remap_func, f, in_channels, out_channels, rearrange);
pa_init_remap_func(&remap_func);
remap_test_channels(&remap_func, &remap_orig);
@@ -239,24 +251,37 @@ static void remap_init2_test_channels(
START_TEST (remap_special_test) {
pa_log_debug("Checking special remap (float, mono->stereo)");
- remap_init2_test_channels(PA_SAMPLE_FLOAT32NE, 1, 2);
+ remap_init2_test_channels(PA_SAMPLE_FLOAT32NE, 1, 2, false);
pa_log_debug("Checking special remap (float, mono->4-channel)");
- remap_init2_test_channels(PA_SAMPLE_FLOAT32NE, 1, 4);
+ remap_init2_test_channels(PA_SAMPLE_FLOAT32NE, 1, 4, false);
pa_log_debug("Checking special remap (s16, mono->stereo)");
- remap_init2_test_channels(PA_SAMPLE_S16NE, 1, 2);
+ remap_init2_test_channels(PA_SAMPLE_S16NE, 1, 2, false);
pa_log_debug("Checking special remap (s16, mono->4-channel)");
- remap_init2_test_channels(PA_SAMPLE_S16NE, 1, 4);
+ remap_init2_test_channels(PA_SAMPLE_S16NE, 1, 4, false);
pa_log_debug("Checking special remap (float, stereo->mono)");
- remap_init2_test_channels(PA_SAMPLE_FLOAT32NE, 2, 1);
+ remap_init2_test_channels(PA_SAMPLE_FLOAT32NE, 2, 1, false);
pa_log_debug("Checking special remap (float, 4-channel->mono)");
- remap_init2_test_channels(PA_SAMPLE_FLOAT32NE, 4, 1);
+ remap_init2_test_channels(PA_SAMPLE_FLOAT32NE, 4, 1, false);
pa_log_debug("Checking special remap (s16, stereo->mono)");
- remap_init2_test_channels(PA_SAMPLE_S16NE, 2, 1);
+ remap_init2_test_channels(PA_SAMPLE_S16NE, 2, 1, false);
pa_log_debug("Checking special remap (s16, 4-channel->mono)");
- remap_init2_test_channels(PA_SAMPLE_S16NE, 4, 1);
+ remap_init2_test_channels(PA_SAMPLE_S16NE, 4, 1, false);
+}
+END_TEST
+
+START_TEST (rearrange_special_test) {
+ pa_log_debug("Checking special remap (s16, stereo rearrange)");
+ remap_init2_test_channels(PA_SAMPLE_S16NE, 2, 2, true);
+ pa_log_debug("Checking special remap (float, stereo rearrange)");
+ remap_init2_test_channels(PA_SAMPLE_FLOAT32NE, 2, 2, true);
+
+ pa_log_debug("Checking special remap (s16, 4-channel rearrange)");
+ remap_init2_test_channels(PA_SAMPLE_S16NE, 4, 4, true);
+ pa_log_debug("Checking special remap (float, 4-channel rearrange)");
+ remap_init2_test_channels(PA_SAMPLE_FLOAT32NE, 4, 4, true);
}
END_TEST
@@ -275,10 +300,10 @@ START_TEST (remap_mmx_test) {
orig_init_func = pa_get_init_remap_func();
pa_remap_func_init_mmx(flags);
init_func = pa_get_init_remap_func();
- remap_init_test_channels(init_func, orig_init_func, PA_SAMPLE_FLOAT32NE, 1, 2);
+ remap_init_test_channels(init_func, orig_init_func, PA_SAMPLE_FLOAT32NE, 1, 2, false);
pa_log_debug("Checking MMX remap (s16, mono->stereo)");
- remap_init_test_channels(init_func, orig_init_func, PA_SAMPLE_S16NE, 1, 2);
+ remap_init_test_channels(init_func, orig_init_func, PA_SAMPLE_S16NE, 1, 2, false);
}
END_TEST
@@ -296,10 +321,10 @@ START_TEST (remap_sse2_test) {
orig_init_func = pa_get_init_remap_func();
pa_remap_func_init_sse(flags);
init_func = pa_get_init_remap_func();
- remap_init_test_channels(init_func, orig_init_func, PA_SAMPLE_FLOAT32NE, 1, 2);
+ remap_init_test_channels(init_func, orig_init_func, PA_SAMPLE_FLOAT32NE, 1, 2, false);
pa_log_debug("Checking SSE2 remap (s16, mono->stereo)");
- remap_init_test_channels(init_func, orig_init_func, PA_SAMPLE_S16NE, 1, 2);
+ remap_init_test_channels(init_func, orig_init_func, PA_SAMPLE_S16NE, 1, 2, false);
}
END_TEST
#endif /* defined (__i386__) || defined (__amd64__) */
@@ -324,6 +349,11 @@ int main(int argc, char *argv[]) {
tcase_set_timeout(tc, 120);
suite_add_tcase(s, tc);
+ tc = tcase_create("rearrange");
+ tcase_add_test(tc, rearrange_special_test);
+ tcase_set_timeout(tc, 120);
+ suite_add_tcase(s, tc);
+
sr = srunner_create(s);
srunner_run_all(sr, CK_NORMAL);
failed = srunner_ntests_failed(sr);
--
1.7.9.5
More information about the pulseaudio-discuss
mailing list