]> code.delx.au - pulseaudio/blob - src/tests/vector-test.c
Updated catalan po
[pulseaudio] / src / tests / vector-test.c
1 /***
2 This file is part of PulseAudio.
3
4 Copyright 2009 Lennart Poettering
5
6 PulseAudio is free software; you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation; either version 2 of the
9 License, or (at your option) any later version.
10
11 PulseAudio is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with PulseAudio; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19 USA.
20 ***/
21
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
25
26 #include <pulsecore/vector.h>
27 #include <pulsecore/log.h>
28
29 int main(int argc, char *argv[]) {
30
31 #ifdef __SSE2__
32 pa_int16_vector_t input, zero;
33 pa_int32_vector_t unpacked1, unpacked2;
34 pa_int32_vector_t volume1, volume2, volume1_hi, volume1_lo, volume2_hi, volume2_lo, reduce, mask;
35 pa_int16_vector_t output;
36
37 unsigned u;
38
39 zero.v = PA_INT16_VECTOR_MAKE(0);
40 reduce.v = PA_INT32_VECTOR_MAKE(0x10000);
41 volume1.v = volume2.v = PA_INT32_VECTOR_MAKE(0x10000*2+7);
42 mask.v = PA_INT32_VECTOR_MAKE(0xFFFF);
43
44 volume1_lo.m = _mm_and_si128(volume1.m, mask.m);
45 volume2_lo.m = _mm_and_si128(volume2.m, mask.m);
46 volume1_hi.m = _mm_srli_epi32(volume1.m, 16);
47 volume2_hi.m = _mm_srli_epi32(volume2.m, 16);
48
49 input.v = PA_INT16_VECTOR_MAKE(32000);
50
51 for (u = 0; u < PA_INT16_VECTOR_SIZE; u++)
52 pa_log("input=%i\n", input.i[u]);
53
54 unpacked1.m = _mm_unpackhi_epi16(zero.m, input.m);
55 unpacked2.m = _mm_unpacklo_epi16(zero.m, input.m);
56
57 for (u = 0; u < PA_INT32_VECTOR_SIZE; u++)
58 pa_log("unpacked1=%i\n", unpacked1.i[u]);
59
60 unpacked1.v /= reduce.v;
61 unpacked2.v /= reduce.v;
62
63 for (u = 0; u < PA_INT32_VECTOR_SIZE; u++)
64 pa_log("unpacked1=%i\n", unpacked1.i[u]);
65
66 for (u = 0; u < PA_INT32_VECTOR_SIZE; u++)
67 pa_log("volume1=%i\n", volume1.i[u]);
68
69 unpacked1.v = (unpacked1.v * volume1_lo.v) / reduce.v + unpacked1.v * volume1_hi.v;
70 unpacked2.v = (unpacked2.v * volume2_lo.v) / reduce.v + unpacked2.v * volume2_hi.v;
71
72 for (u = 0; u < PA_INT32_VECTOR_SIZE; u++)
73 pa_log("unpacked1=%i\n", unpacked1.i[u]);
74
75 output.m = _mm_packs_epi32(unpacked1.m, unpacked2.m);
76
77 for (u = 0; u < PA_INT16_VECTOR_SIZE; u++)
78 pa_log("output=%i\n", output.i[u]);
79
80 #endif
81
82 return 0;
83 }