[pulseaudio-commits] 10 commits - src/pulsecore src/tests

Tanu Kaskinen tanuk at kemper.freedesktop.org
Fri Feb 1 00:26:36 PST 2013


 src/pulsecore/remap_sse.c |    2 
 src/pulsecore/resampler.c |    6 
 src/pulsecore/sconv_sse.c |    3 
 src/tests/cpu-test.c      |  311 ++++++++++++++++++++++++++++++++++++++++++++--
 4 files changed, 304 insertions(+), 18 deletions(-)

New commits:
commit 3a3c4eb4622feb8115d1387f33a4bfa722e0061a
Author: Peter Meerwald <p.meerwald at bct-electronic.com>
Date:   Wed Jan 30 11:04:05 2013 +0100

    resampler: Improve s16<-->s32 conversion, use s16 work format if input or output is s16
    
    Problem: s16 to s32 conversion is performed as s16->float->s32 (via work
    format float) for resamplers TRIVIAL, COPY, PEAKS.
    Precision and efficiency suffers: e.g. 0x9fff results in 0x9ffe4001 (instead
    of 0x9fff0000) and there are two sample format conversions instead of one
    conversion.
    
    Solution: If input or output format is s16, then choose the work format
    to be s16 as well.
    
    If remapping is to be performed, we could stick to work format float32ne for
    precision reseans. This is debateable.
    
    Signed-off-by: Peter Meerwald <p.meerwald at bct-electronic.com>

diff --git a/src/pulsecore/resampler.c b/src/pulsecore/resampler.c
index 6c3b1f0..f0b3fd4 100644
--- a/src/pulsecore/resampler.c
+++ b/src/pulsecore/resampler.c
@@ -282,7 +282,9 @@ pa_resampler* pa_resampler_new(
 
         if (r->map_required || a->format != b->format || method == PA_RESAMPLER_PEAKS) {
 
-            if (a->format == PA_SAMPLE_S32NE || a->format == PA_SAMPLE_S32RE ||
+            if (a->format == PA_SAMPLE_S16NE || b->format == PA_SAMPLE_S16NE)
+                r->work_format = PA_SAMPLE_S16NE;
+            else if (a->format == PA_SAMPLE_S32NE || a->format == PA_SAMPLE_S32RE ||
                 a->format == PA_SAMPLE_FLOAT32NE || a->format == PA_SAMPLE_FLOAT32RE ||
                 a->format == PA_SAMPLE_S24NE || a->format == PA_SAMPLE_S24RE ||
                 a->format == PA_SAMPLE_S24_32NE || a->format == PA_SAMPLE_S24_32RE ||

commit 4b3de4422e8b65f9b7da4fe03ceaeda6391280b2
Author: Peter Meerwald <p.meerwald at bct-electronic.com>
Date:   Wed Jan 30 11:04:04 2013 +0100

    resampler: Drop redundant assignment in convert_from_work_format()
    
    r->from_work_format_buf.length is set twice
    
    Signed-off-by: Peter Meerwald <p.meerwald at bct-electronic.com>

diff --git a/src/pulsecore/resampler.c b/src/pulsecore/resampler.c
index a13e700..6c3b1f0 100644
--- a/src/pulsecore/resampler.c
+++ b/src/pulsecore/resampler.c
@@ -1277,8 +1277,6 @@ static pa_memchunk *convert_from_work_format(pa_resampler *r, pa_memchunk *input
     pa_memblock_release(input->memblock);
     pa_memblock_release(r->from_work_format_buf.memblock);
 
-    r->from_work_format_buf.length = r->o_fz * n_frames;
-
     return &r->from_work_format_buf;
 }
 

commit 34c631c0aee9fc84564f351cc3c047cce7251f88
Author: Peter Meerwald <p.meerwald at bct-electronic.com>
Date:   Wed Jan 30 11:04:03 2013 +0100

    tests: Fix sconv sample correctness in cpu-test
    
    do allow up to one sample difference
    cleanup output of signed shorts (use 0xhx)
    
    Signed-off-by: Peter Meerwald <p.meerwald at bct-electronic.com>

diff --git a/src/tests/cpu-test.c b/src/tests/cpu-test.c
index 9612ebd..16259de 100644
--- a/src/tests/cpu-test.c
+++ b/src/tests/cpu-test.c
@@ -110,7 +110,7 @@ static void run_volume_test(
         for (i = 0; i < nsamples; i++) {
             if (samples[i] != samples_ref[i]) {
                 pa_log_debug("Correctness test failed: align=%d, channels=%d", align, channels);
-                pa_log_debug("%d: %04x != %04x (%04x * %08x)\n", i, samples[i], samples_ref[i],
+                pa_log_debug("%d: %04hx != %04hx (%04hx * %08x)\n", i, samples[i], samples_ref[i],
                         samples_orig[i], volumes[i % channels]);
                 fail();
             }
@@ -291,7 +291,7 @@ static void run_conv_test_float_to_s16(
         for (i = 0; i < nsamples; i++) {
             if (abs(samples[i] - samples_ref[i]) > 1) {
                 pa_log_debug("Correctness test failed: align=%d", align);
-                pa_log_debug("%d: %04x != %04x (%.24f)\n", i, samples[i], samples_ref[i], floats[i]);
+                pa_log_debug("%d: %04hx != %04hx (%.24f)\n", i, samples[i], samples_ref[i], floats[i]);
                 fail();
             }
         }
@@ -340,7 +340,7 @@ static void run_conv_test_s16_to_float(
         func(nsamples, samples, floats);
 
         for (i = 0; i < nsamples; i++) {
-            if (abs(floats[i] - floats_ref[i]) > 1) {
+            if (fabsf(floats[i] - floats_ref[i]) > 0.0001) {
                 pa_log_debug("Correctness test failed: align=%d", align);
                 pa_log_debug("%d: %.24f != %.24f (%d)\n", i, floats[i], floats_ref[i], samples[i]);
                 fail();

commit db41a4832d3fe4bd8b235ed7515d29160dbf199f
Author: Peter Meerwald <p.meerwald at bct-electronic.com>
Date:   Wed Jan 30 11:04:01 2013 +0100

    sconv: Check for SSE flag before initializing code
    
    Signed-off-by: Peter Meerwald <p.meerwald at bct-electronic.com>

diff --git a/src/pulsecore/sconv_sse.c b/src/pulsecore/sconv_sse.c
index 19de6fd..34b59fa 100644
--- a/src/pulsecore/sconv_sse.c
+++ b/src/pulsecore/sconv_sse.c
@@ -170,7 +170,8 @@ void pa_convert_func_init_sse(pa_cpu_x86_flag_t flags) {
     if (flags & PA_CPU_X86_SSE2) {
         pa_log_info("Initialising SSE2 optimized conversions.");
         pa_set_convert_from_float32ne_function(PA_SAMPLE_S16LE, (pa_convert_func_t) pa_sconv_s16le_from_f32ne_sse2);
-    } else {
+
+    } else if (flags & PA_CPU_X86_SSE) {
         pa_log_info("Initialising SSE optimized conversions.");
         pa_set_convert_from_float32ne_function(PA_SAMPLE_S16LE, (pa_convert_func_t) pa_sconv_s16le_from_f32ne_sse);
     }

commit e8f1cfd9a5eb9c3229cb4a27a20be389f79ec3b9
Author: Tanu Kaskinen <tanuk at iki.fi>
Date:   Fri Feb 1 09:06:18 2013 +0200

    tests: Fix function argument wrapping style in cpu-test.c.

diff --git a/src/tests/cpu-test.c b/src/tests/cpu-test.c
index f8a8734..9612ebd 100644
--- a/src/tests/cpu-test.c
+++ b/src/tests/cpu-test.c
@@ -70,8 +70,14 @@
 #define TIMES2 100
 #define PADDING 16
 
-static void run_volume_test(pa_do_volume_func_t func, pa_do_volume_func_t orig_func, int align, int channels,
-        pa_bool_t correct, pa_bool_t perf) {
+static void run_volume_test(
+        pa_do_volume_func_t func,
+        pa_do_volume_func_t orig_func,
+        int align,
+        int channels,
+        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 };
@@ -254,8 +260,13 @@ END_TEST
 #define TIMES 1000
 #define TIMES2 100
 
-static void run_conv_test_float_to_s16(pa_convert_func_t func, pa_convert_func_t orig_func, int align, pa_bool_t correct,
+static void run_conv_test_float_to_s16(
+        pa_convert_func_t func,
+        pa_convert_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, float, f[SAMPLES]);
@@ -302,8 +313,13 @@ static void run_conv_test_float_to_s16(pa_convert_func_t func, pa_convert_func_t
 /* This test is currently only run under NEON */
 #if defined (__arm__) && defined (__linux__)
 #ifdef HAVE_NEON
-static void run_conv_test_s16_to_float(pa_convert_func_t func, pa_convert_func_t orig_func, int align, pa_bool_t correct,
+static void run_conv_test_s16_to_float(
+        pa_convert_func_t func,
+        pa_convert_func_t orig_func,
+        int align,
+        pa_bool_t correct,
         pa_bool_t perf) {
+
     PA_DECLARE_ALIGNED(8, float, f[SAMPLES]) = { 0 };
     PA_DECLARE_ALIGNED(8, float, f_ref[SAMPLES]) = { 0 };
     PA_DECLARE_ALIGNED(8, int16_t, s[SAMPLES]);
@@ -456,9 +472,14 @@ END_TEST
 #define TIMES 1000
 #define TIMES2 100
 
- static void run_remap_test_mono_stereo_float(pa_remap_t *remap,
-    pa_do_remap_func_t func, pa_do_remap_func_t orig_func,
-    int align, pa_bool_t correct, pa_bool_t perf) {
+static void run_remap_test_mono_stereo_float(
+        pa_remap_t *remap,
+        pa_do_remap_func_t func,
+        pa_do_remap_func_t orig_func,
+        int align,
+        pa_bool_t correct,
+        pa_bool_t perf) {
+
     PA_DECLARE_ALIGNED(8, float, s_ref[SAMPLES*2]) = { 0 };
     PA_DECLARE_ALIGNED(8, float, s[SAMPLES*2]) = { 0 };
     PA_DECLARE_ALIGNED(8, float, m[SAMPLES]);
@@ -501,9 +522,14 @@ END_TEST
     }
 }
 
- static void run_remap_test_mono_stereo_s16(pa_remap_t *remap,
-    pa_do_remap_func_t func, pa_do_remap_func_t orig_func,
-    int align, pa_bool_t correct, pa_bool_t perf) {
+static void run_remap_test_mono_stereo_s16(
+        pa_remap_t *remap,
+        pa_do_remap_func_t func,
+        pa_do_remap_func_t orig_func,
+        int align,
+        pa_bool_t correct,
+        pa_bool_t perf) {
+
     PA_DECLARE_ALIGNED(8, int16_t, s_ref[SAMPLES*2]) = { 0 };
     PA_DECLARE_ALIGNED(8, int16_t, s[SAMPLES*2]) = { 0 };
     PA_DECLARE_ALIGNED(8, int16_t, m[SAMPLES]);
@@ -545,8 +571,10 @@ END_TEST
     }
 }
 
-static void remap_test_mono_stereo_float(pa_init_remap_func_t init_func,
-    pa_init_remap_func_t orig_init_func) {
+static void remap_test_mono_stereo_float(
+        pa_init_remap_func_t init_func,
+        pa_init_remap_func_t orig_init_func) {
+
     pa_sample_format_t sf;
     pa_remap_t remap;
     pa_sample_spec iss, oss;
@@ -582,8 +610,10 @@ static void remap_test_mono_stereo_float(pa_init_remap_func_t init_func,
     run_remap_test_mono_stereo_float(&remap, func, orig_func, 3, TRUE, TRUE);
 }
 
-static void remap_test_mono_stereo_s16(pa_init_remap_func_t init_func,
-    pa_init_remap_func_t orig_init_func) {
+static void remap_test_mono_stereo_s16(
+        pa_init_remap_func_t init_func,
+        pa_init_remap_func_t orig_init_func) {
+
     pa_sample_format_t sf;
     pa_remap_t remap;
     pa_sample_spec iss, oss;

commit 01a7c6b4e6c079a90b757eb1bf548a79160aad27
Author: Peter Meerwald <p.meerwald at bct-electronic.com>
Date:   Wed Jan 30 11:04:00 2013 +0100

    tests: Add remap test code to cpu-test
    
    v2 (comments by Paul Menzel):
    * generate test samples from -1..1, -0x8000..0x7fff
    * check all output samples (not just half of them)
    
    the idea is to compare the output of the C (reference) implementation
    against the output of the optimized code path; currently, there are MMX
    and SSE implementation for the mono-to-stereo remapper for s16 and float
    sample formats
    
    Signed-off-by: Peter Meerwald <p.meerwald at bct-electronic.com>
    Cc: Paul Menzel <paulepanter at users.sourceforge.net>

diff --git a/src/tests/cpu-test.c b/src/tests/cpu-test.c
index c33414c..f8a8734 100644
--- a/src/tests/cpu-test.c
+++ b/src/tests/cpu-test.c
@@ -32,6 +32,7 @@
 #include <pulsecore/macro.h>
 #include <pulsecore/endianmacros.h>
 #include <pulsecore/sconv.h>
+#include <pulsecore/remap.h>
 #include <pulsecore/sample-util.h>
 
 #define PA_CPU_TEST_RUN_START(l, t1, t2)                        \
@@ -450,6 +451,223 @@ END_TEST
 #undef TIMES
 /* End conversion tests */
 
+/* Start remap tests */
+#define SAMPLES 1028
+#define TIMES 1000
+#define TIMES2 100
+
+ static void run_remap_test_mono_stereo_float(pa_remap_t *remap,
+    pa_do_remap_func_t func, pa_do_remap_func_t orig_func,
+    int align, pa_bool_t correct, pa_bool_t perf) {
+    PA_DECLARE_ALIGNED(8, float, s_ref[SAMPLES*2]) = { 0 };
+    PA_DECLARE_ALIGNED(8, float, s[SAMPLES*2]) = { 0 };
+    PA_DECLARE_ALIGNED(8, float, m[SAMPLES]);
+    float *stereo, *stereo_ref;
+    float *mono;
+    int i, nsamples;
+
+    /* Force sample alignment as requested */
+    stereo = s + (8 - align);
+    stereo_ref = s_ref + (8 - align);
+    mono = m + (8 - align);
+    nsamples = SAMPLES - (8 - align);
+
+    for (i = 0; i < nsamples; i++)
+        mono[i] = 2.1f * (rand()/(float) RAND_MAX - 0.5f);
+
+    if (correct) {
+        orig_func(remap, stereo_ref, mono, nsamples);
+        func(remap, stereo, mono, nsamples);
+
+        for (i = 0; i < nsamples * 2; i++) {
+            if (fabsf(stereo[i] - stereo_ref[i]) > 0.0001) {
+                pa_log_debug("Correctness test failed: align=%d", align);
+                pa_log_debug("%d: %.24f != %.24f (%.24f)\n", i, stereo[i], stereo_ref[i], mono[i]);
+                fail();
+            }
+        }
+    }
+
+    if (perf) {
+        pa_log_debug("Testing remap performance with %d sample alignment", align);
+
+        PA_CPU_TEST_RUN_START("func", TIMES, TIMES2) {
+            func(remap, stereo, mono, nsamples);
+        } PA_CPU_TEST_RUN_STOP
+
+        PA_CPU_TEST_RUN_START("orig", TIMES, TIMES2) {
+            orig_func(remap, stereo_ref, mono, nsamples);
+        } PA_CPU_TEST_RUN_STOP
+    }
+}
+
+ static void run_remap_test_mono_stereo_s16(pa_remap_t *remap,
+    pa_do_remap_func_t func, pa_do_remap_func_t orig_func,
+    int align, pa_bool_t correct, pa_bool_t perf) {
+    PA_DECLARE_ALIGNED(8, int16_t, s_ref[SAMPLES*2]) = { 0 };
+    PA_DECLARE_ALIGNED(8, int16_t, s[SAMPLES*2]) = { 0 };
+    PA_DECLARE_ALIGNED(8, int16_t, m[SAMPLES]);
+    int16_t *stereo, *stereo_ref;
+    int16_t *mono;
+    int i, nsamples;
+
+    /* Force sample alignment as requested */
+    stereo = s + (8 - align);
+    stereo_ref = s_ref + (8 - align);
+    mono = m + (8 - align);
+    nsamples = SAMPLES - (8 - align);
+
+    pa_random(mono, nsamples * sizeof(int16_t));
+
+    if (correct) {
+        orig_func(remap, stereo_ref, mono, nsamples);
+        func(remap, stereo, mono, nsamples);
+
+        for (i = 0; i < nsamples * 2; i++) {
+            if (abs(stereo[i] - stereo_ref[i]) > 1) {
+                pa_log_debug("Correctness test failed: align=%d", align);
+                pa_log_debug("%d: %d != %d (%d)\n", i, stereo[i], stereo_ref[i], mono[i]);
+                fail();
+            }
+        }
+    }
+
+    if (perf) {
+        pa_log_debug("Testing remap performance with %d sample alignment", align);
+
+        PA_CPU_TEST_RUN_START("func", TIMES, TIMES2) {
+            func(remap, stereo, mono, nsamples);
+        } PA_CPU_TEST_RUN_STOP
+
+        PA_CPU_TEST_RUN_START("orig", TIMES, TIMES2) {
+            orig_func(remap, stereo_ref, mono, nsamples);
+        } PA_CPU_TEST_RUN_STOP
+    }
+}
+
+static void remap_test_mono_stereo_float(pa_init_remap_func_t init_func,
+    pa_init_remap_func_t orig_init_func) {
+    pa_sample_format_t sf;
+    pa_remap_t remap;
+    pa_sample_spec iss, oss;
+    pa_do_remap_func_t orig_func, func;
+
+    iss.format = oss.format = sf = PA_SAMPLE_FLOAT32NE;
+    iss.channels = 1;
+    oss.channels = 2;
+    remap.format = &sf;
+    remap.i_ss = &iss;
+    remap.o_ss = &oss;
+    remap.map_table_f[0][0] = 1.0;
+    remap.map_table_f[1][0] = 1.0;
+    remap.map_table_i[0][0] = 0x10000;
+    remap.map_table_i[1][0] = 0x10000;
+    orig_init_func(&remap);
+    orig_func = remap.do_remap;
+    if (!orig_func) {
+        pa_log_warn("No reference remapping function, abort test");
+        return;
+    }
+
+    init_func(&remap);
+    func = remap.do_remap;
+    if (!func || func == orig_func) {
+        pa_log_warn("No remapping function, abort test");
+        return;
+    }
+
+    run_remap_test_mono_stereo_float(&remap, func, orig_func, 0, TRUE, FALSE);
+    run_remap_test_mono_stereo_float(&remap, func, orig_func, 1, TRUE, FALSE);
+    run_remap_test_mono_stereo_float(&remap, func, orig_func, 2, TRUE, FALSE);
+    run_remap_test_mono_stereo_float(&remap, func, orig_func, 3, TRUE, TRUE);
+}
+
+static void remap_test_mono_stereo_s16(pa_init_remap_func_t init_func,
+    pa_init_remap_func_t orig_init_func) {
+    pa_sample_format_t sf;
+    pa_remap_t remap;
+    pa_sample_spec iss, oss;
+    pa_do_remap_func_t orig_func, func;
+
+    iss.format = oss.format = sf = PA_SAMPLE_S16NE;
+    iss.channels = 1;
+    oss.channels = 2;
+    remap.format = &sf;
+    remap.i_ss = &iss;
+    remap.o_ss = &oss;
+    remap.map_table_f[0][0] = 1.0;
+    remap.map_table_f[1][0] = 1.0;
+    remap.map_table_i[0][0] = 0x10000;
+    remap.map_table_i[1][0] = 0x10000;
+    orig_init_func(&remap);
+    orig_func = remap.do_remap;
+    if (!orig_func) {
+        pa_log_warn("No reference remapping function, abort test");
+        return;
+    }
+
+    init_func(&remap);
+    func = remap.do_remap;
+    if (!func || func == orig_func) {
+        pa_log_warn("No remapping function, abort test");
+        return;
+    }
+
+    run_remap_test_mono_stereo_s16(&remap, func, orig_func, 0, TRUE, FALSE);
+    run_remap_test_mono_stereo_s16(&remap, func, orig_func, 1, TRUE, FALSE);
+    run_remap_test_mono_stereo_s16(&remap, func, orig_func, 2, TRUE, FALSE);
+    run_remap_test_mono_stereo_s16(&remap, func, orig_func, 3, TRUE, TRUE);
+}
+
+#if defined (__i386__) || defined (__amd64__)
+START_TEST (remap_mmx_test) {
+    pa_cpu_x86_flag_t flags = 0;
+    pa_init_remap_func_t init_func, orig_init_func;
+
+    pa_cpu_get_x86_flags(&flags);
+    if (!(flags & PA_CPU_X86_MMX)) {
+        pa_log_info("MMX not supported. Skipping");
+        return;
+    }
+
+    pa_log_debug("Checking MMX remap (float, mono->stereo)");
+    orig_init_func = pa_get_init_remap_func();
+    pa_remap_func_init_mmx(flags);
+    init_func = pa_get_init_remap_func();
+    remap_test_mono_stereo_float(init_func, orig_init_func);
+
+    pa_log_debug("Checking MMX remap (s16, mono->stereo)");
+    remap_test_mono_stereo_s16(init_func, orig_init_func);
+}
+END_TEST
+
+START_TEST (remap_sse2_test) {
+    pa_cpu_x86_flag_t flags = 0;
+    pa_init_remap_func_t init_func, orig_init_func;
+
+    pa_cpu_get_x86_flags(&flags);
+    if (!(flags & PA_CPU_X86_SSE2)) {
+        pa_log_info("SSE2 not supported. Skipping");
+        return;
+    }
+
+    pa_log_debug("Checking SSE2 remap (float, mono->stereo)");
+    orig_init_func = pa_get_init_remap_func();
+    pa_remap_func_init_sse(flags);
+    init_func = pa_get_init_remap_func();
+    remap_test_mono_stereo_float(init_func, orig_init_func);
+
+    pa_log_debug("Checking SSE2 remap (s16, mono->stereo)");
+    remap_test_mono_stereo_s16(init_func, orig_init_func);
+}
+END_TEST
+#endif /* defined (__i386__) || defined (__amd64__) */
+
+#undef SAMPLES
+#undef TIMES
+#undef TIMES2
+/* End remap tests */
+
 int main(int argc, char *argv[]) {
     int failed = 0;
     Suite *s;
@@ -488,6 +706,15 @@ int main(int argc, char *argv[]) {
     tcase_set_timeout(tc, 120);
     suite_add_tcase(s, tc);
 
+    /* Remap tests */
+    tc = tcase_create("remap");
+#if defined (__i386__) || defined (__amd64__)
+    tcase_add_test(tc, remap_mmx_test);
+    tcase_add_test(tc, remap_sse2_test);
+#endif
+    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);

commit 60aeb3dd23e4875250d97c873821425455a37b18
Author: Peter Meerwald <p.meerwald at bct-electronic.com>
Date:   Wed Jan 30 11:03:59 2013 +0100

    tests: Test both, SSE and SSE2, sconv in cpu-test
    
    SSE sconv was not tested before, only SSE2 was (on CPUs supporting both
    instruction sets)
    
    now both code path are tested on CPUs supporting both
    
    Signed-off-by: Peter Meerwald <p.meerwald at bct-electronic.com>

diff --git a/src/tests/cpu-test.c b/src/tests/cpu-test.c
index f312edb..c33414c 100644
--- a/src/tests/cpu-test.c
+++ b/src/tests/cpu-test.c
@@ -347,9 +347,9 @@ static void run_conv_test_s16_to_float(pa_convert_func_t func, pa_convert_func_t
 #endif /* defined (__arm__) && defined (__linux__) */
 
 #if defined (__i386__) || defined (__amd64__)
-START_TEST (sconv_sse_test) {
+START_TEST (sconv_sse2_test) {
     pa_cpu_x86_flag_t flags = 0;
-    pa_convert_func_t orig_func, sse_func;
+    pa_convert_func_t orig_func, sse2_func;
 
     pa_cpu_get_x86_flags(&flags);
 
@@ -359,7 +359,34 @@ START_TEST (sconv_sse_test) {
     }
 
     orig_func = pa_get_convert_from_float32ne_function(PA_SAMPLE_S16LE);
-    pa_convert_func_init_sse(flags);
+    pa_convert_func_init_sse(PA_CPU_X86_SSE2);
+    sse2_func = pa_get_convert_from_float32ne_function(PA_SAMPLE_S16LE);
+
+    pa_log_debug("Checking SSE2 sconv (float -> s16)");
+    run_conv_test_float_to_s16(sse2_func, orig_func, 0, TRUE, FALSE);
+    run_conv_test_float_to_s16(sse2_func, orig_func, 1, TRUE, FALSE);
+    run_conv_test_float_to_s16(sse2_func, orig_func, 2, TRUE, FALSE);
+    run_conv_test_float_to_s16(sse2_func, orig_func, 3, TRUE, FALSE);
+    run_conv_test_float_to_s16(sse2_func, orig_func, 4, TRUE, FALSE);
+    run_conv_test_float_to_s16(sse2_func, orig_func, 5, TRUE, FALSE);
+    run_conv_test_float_to_s16(sse2_func, orig_func, 6, TRUE, FALSE);
+    run_conv_test_float_to_s16(sse2_func, orig_func, 7, TRUE, TRUE);
+}
+END_TEST
+
+START_TEST (sconv_sse_test) {
+    pa_cpu_x86_flag_t flags = 0;
+    pa_convert_func_t orig_func, sse_func;
+
+    pa_cpu_get_x86_flags(&flags);
+
+    if (!(flags & PA_CPU_X86_SSE)) {
+        pa_log_info("SSE not supported. Skipping");
+        return;
+    }
+
+    orig_func = pa_get_convert_from_float32ne_function(PA_SAMPLE_S16LE);
+    pa_convert_func_init_sse(PA_CPU_X86_SSE);
     sse_func = pa_get_convert_from_float32ne_function(PA_SAMPLE_S16LE);
 
     pa_log_debug("Checking SSE sconv (float -> s16)");
@@ -450,6 +477,7 @@ int main(int argc, char *argv[]) {
     /* Conversion tests */
     tc = tcase_create("sconv");
 #if defined (__i386__) || defined (__amd64__)
+    tcase_add_test(tc, sconv_sse2_test);
     tcase_add_test(tc, sconv_sse_test);
 #endif
 #if defined (__arm__) && defined (__linux__)

commit 2c5d3d79ad38e867979628299fcc82586ac13abe
Author: Peter Meerwald <p.meerwald at bct-electronic.com>
Date:   Wed Jan 30 11:03:58 2013 +0100

    remap_sse: More specific logging: SSE -> SSE2
    
    Signed-off-by: Peter Meerwald <p.meerwald at bct-electronic.com>

diff --git a/src/pulsecore/remap_sse.c b/src/pulsecore/remap_sse.c
index 8344a27..dd49eb6 100644
--- a/src/pulsecore/remap_sse.c
+++ b/src/pulsecore/remap_sse.c
@@ -140,7 +140,7 @@ static void init_remap_sse2(pa_remap_t *m) {
     if (n_ic == 1 && n_oc == 2 &&
             m->map_table_f[0][0] >= 1.0 && m->map_table_f[1][0] >= 1.0) {
         m->do_remap = (pa_do_remap_func_t) remap_mono_to_stereo_sse2;
-        pa_log_info("Using SSE mono to stereo remapping");
+        pa_log_info("Using SSE2 mono to stereo remapping");
     }
 }
 #endif /* defined (__i386__) || defined (__amd64__) */

commit 2dc51f337110a49fb8e671e3ccf146929c3e892b
Author: Peter Meerwald <p.meerwald at bct-electronic.com>
Date:   Wed Jan 30 11:03:57 2013 +0100

    tests: Fix potential out-of-bound access violation in svolume cpu-test
    
    nsamples should be forced to be a multiple of channels; do so correctly
    and don't make nsamples larger than it actually is
    
    Signed-off-by: Peter Meerwald <p.meerwald at bct-electronic.com>

diff --git a/src/tests/cpu-test.c b/src/tests/cpu-test.c
index 29e4770..f312edb 100644
--- a/src/tests/cpu-test.c
+++ b/src/tests/cpu-test.c
@@ -84,8 +84,8 @@ static void run_volume_test(pa_do_volume_func_t func, pa_do_volume_func_t orig_f
     samples_orig = s_orig + (8 - align);
     nsamples = SAMPLES - (8 - align);
     if (nsamples % channels)
-        nsamples += nsamples % channels;
-    size = nsamples * sizeof(*samples);
+        nsamples -= nsamples % channels;
+    size = nsamples * sizeof(int16_t);
 
     pa_random(samples, size);
     memcpy(samples_ref, samples, size);

commit 3a942fc191aaed9f361d8b280338a351965fcd3c
Author: Peter Meerwald <p.meerwald at bct-electronic.com>
Date:   Wed Jan 30 11:03:56 2013 +0100

    tests: Fix conversion typo in cpu-test
    
    Signed-off-by: Peter Meerwald <p.meerwald at bct-electronic.com>

diff --git a/src/tests/cpu-test.c b/src/tests/cpu-test.c
index 8e196e5..29e4770 100644
--- a/src/tests/cpu-test.c
+++ b/src/tests/cpu-test.c
@@ -447,7 +447,7 @@ int main(int argc, char *argv[]) {
     tcase_set_timeout(tc, 120);
     suite_add_tcase(s, tc);
 
-    /* Converstion tests */
+    /* Conversion tests */
     tc = tcase_create("sconv");
 #if defined (__i386__) || defined (__amd64__)
     tcase_add_test(tc, sconv_sse_test);



More information about the pulseaudio-commits mailing list