/* Common defines for svolume tests */
#define CHANNELS 2
-#define SAMPLES 1022
+#define SAMPLES 1028
#define TIMES 1000
#define TIMES2 100
#define PADDING 16
-static void run_volume_test(pa_do_volume_func_t func, pa_do_volume_func_t orig_func) {
- int16_t samples[SAMPLES];
- int16_t samples_ref[SAMPLES];
- int16_t samples_orig[SAMPLES];
+static void run_volume_test(pa_do_volume_func_t func, pa_do_volume_func_t orig_func, int align, pa_bool_t correct,
+ pa_bool_t perf) {
+ PA_DECLARE_ALIGNED(8, int16_t, s[SAMPLES]) = { 0 };
+ PA_DECLARE_ALIGNED(8, int16_t, s_ref[SAMPLES]) = { 0 };
+ PA_DECLARE_ALIGNED(8, int16_t, s_orig[SAMPLES]) = { 0 };
int32_t volumes[CHANNELS + PADDING];
- int i, padding;
+ int16_t *samples, *samples_ref, *samples_orig;
+ int i, padding, nsamples, size;
+
+ /* Force sample alignment as requested */
+ samples = s + (8 - align);
+ samples_ref = s_ref + (8 - align);
+ samples_orig = s_orig + (8 - align);
+ nsamples = SAMPLES - (8 - align);
+ nsamples += nsamples % CHANNELS;
+ size = nsamples * sizeof(*samples);
- pa_random(samples, sizeof(samples));
- memcpy(samples_ref, samples, sizeof(samples));
- memcpy(samples_orig, samples, sizeof(samples));
+ pa_random(samples, size);
+ memcpy(samples_ref, samples, size);
+ memcpy(samples_orig, samples, size);
for (i = 0; i < CHANNELS; i++)
volumes[i] = PA_CLAMP_VOLUME((pa_volume_t)(rand() >> 15));
for (padding = 0; padding < PADDING; padding++, i++)
volumes[i] = volumes[padding];
- orig_func(samples_ref, volumes, CHANNELS, sizeof(samples));
- func(samples, volumes, CHANNELS, sizeof(samples));
- for (i = 0; i < SAMPLES; i++) {
- if (samples[i] != samples_ref[i]) {
- printf("%d: %04x != %04x (%04x * %08x)\n", i, samples[i], samples_ref[i],
- samples_orig[i], volumes[i % CHANNELS]);
- fail();
+ if (correct) {
+ pa_log_debug("Testing svolume correctness with %d byte alignment", align);
+
+ orig_func(samples_ref, volumes, CHANNELS, size);
+ func(samples, volumes, CHANNELS, size);
+
+ for (i = 0; i < nsamples; i++) {
+ if (samples[i] != samples_ref[i]) {
+ printf("%d: %04x != %04x (%04x * %08x)\n", i, samples[i], samples_ref[i],
+ samples_orig[i], volumes[i % CHANNELS]);
+ fail();
+ }
}
}
- PA_CPU_TEST_RUN_START("func", TIMES, TIMES2) {
- memcpy(samples, samples_orig, sizeof(samples));
- func(samples, volumes, CHANNELS, sizeof(samples));
- } PA_CPU_TEST_RUN_STOP
+ if (perf) {
+ pa_log_debug("Testing svolume performance with %d byte alignment", align);
- PA_CPU_TEST_RUN_START("orig", TIMES, TIMES2) {
- memcpy(samples_ref, samples_orig, sizeof(samples));
- orig_func(samples_ref, volumes, CHANNELS, sizeof(samples));
- } PA_CPU_TEST_RUN_STOP
+ PA_CPU_TEST_RUN_START("func", TIMES, TIMES2) {
+ memcpy(samples, samples_orig, size);
+ func(samples, volumes, CHANNELS, size);
+ } PA_CPU_TEST_RUN_STOP
- fail_unless(memcmp(samples_ref, samples, sizeof(samples)) == 0);
+ PA_CPU_TEST_RUN_START("orig", TIMES, TIMES2) {
+ memcpy(samples_ref, samples_orig, size);
+ orig_func(samples_ref, volumes, CHANNELS, size);
+ } PA_CPU_TEST_RUN_STOP
+
+ fail_unless(memcmp(samples_ref, samples, size) == 0);
+ }
}
#if defined (__i386__) || defined (__amd64__)
mmx_func = pa_get_volume_func(PA_SAMPLE_S16NE);
pa_log_debug("Checking MMX svolume");
- run_volume_test(mmx_func, orig_func);
+ run_volume_test(mmx_func, orig_func, 0, TRUE, FALSE);
+ run_volume_test(mmx_func, orig_func, 1, TRUE, FALSE);
+ run_volume_test(mmx_func, orig_func, 2, TRUE, FALSE);
+ run_volume_test(mmx_func, orig_func, 3, TRUE, FALSE);
+ run_volume_test(mmx_func, orig_func, 4, TRUE, FALSE);
+ run_volume_test(mmx_func, orig_func, 5, TRUE, FALSE);
+ run_volume_test(mmx_func, orig_func, 6, TRUE, FALSE);
+ run_volume_test(mmx_func, orig_func, 7, TRUE, TRUE);
}
END_TEST
sse_func = pa_get_volume_func(PA_SAMPLE_S16NE);
pa_log_debug("Checking SSE2 svolume");
- run_volume_test(sse_func, orig_func);
+ run_volume_test(sse_func, orig_func, 0, TRUE, FALSE);
+ run_volume_test(sse_func, orig_func, 1, TRUE, FALSE);
+ run_volume_test(sse_func, orig_func, 2, TRUE, FALSE);
+ run_volume_test(sse_func, orig_func, 3, TRUE, FALSE);
+ run_volume_test(sse_func, orig_func, 4, TRUE, FALSE);
+ run_volume_test(sse_func, orig_func, 5, TRUE, FALSE);
+ run_volume_test(sse_func, orig_func, 6, TRUE, FALSE);
+ run_volume_test(sse_func, orig_func, 7, TRUE, TRUE);
}
END_TEST
#endif /* defined (__i386__) || defined (__amd64__) */
arm_func = pa_get_volume_func(PA_SAMPLE_S16NE);
pa_log_debug("Checking ARM svolume");
- run_volume_test(arm_func, orig_func);
+ run_volume_test(arm_func, orig_func, 0, TRUE, TRUE);
+ run_volume_test(arm_func, orig_func, 1, TRUE, TRUE);
+ run_volume_test(arm_func, orig_func, 2, TRUE, TRUE);
+ run_volume_test(arm_func, orig_func, 3, TRUE, TRUE);
+ run_volume_test(arm_func, orig_func, 4, TRUE, TRUE);
+ run_volume_test(arm_func, orig_func, 5, TRUE, TRUE);
+ run_volume_test(arm_func, orig_func, 6, TRUE, TRUE);
+ run_volume_test(arm_func, orig_func, 7, TRUE, TRUE);
}
END_TEST
#endif /* defined (__arm__) && defined (__linux__) */
orc_func = pa_get_volume_func(PA_SAMPLE_S16NE);
pa_log_debug("Checking Orc svolume");
- run_volume_test(orc_func, orig_func);
+ run_volume_test(orc_func, orig_func, 0, TRUE, FALSE);
+ run_volume_test(orc_func, orig_func, 1, TRUE, FALSE);
+ run_volume_test(orc_func, orig_func, 2, TRUE, FALSE);
+ run_volume_test(orc_func, orig_func, 3, TRUE, FALSE);
+ run_volume_test(orc_func, orig_func, 4, TRUE, FALSE);
+ run_volume_test(orc_func, orig_func, 5, TRUE, FALSE);
+ run_volume_test(orc_func, orig_func, 6, TRUE, FALSE);
+ run_volume_test(orc_func, orig_func, 7, TRUE, TRUE);
}
END_TEST
tcase_add_test(tc, svolume_arm_test);
#endif
tcase_add_test(tc, svolume_orc_test);
+ tcase_set_timeout(tc, 120);
suite_add_tcase(s, tc);
/* Converstion tests */