2 This file is part of PulseAudio.
4 Copyright 2009 Lennart Poettering
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.1 of the
9 License, or (at your option) any later version.
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.
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
26 #include <pulsecore/vector.h>
27 #include <pulsecore/log.h>
29 int main(int argc
, char *argv
[]) {
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
;
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);
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);
49 input
.v
= PA_INT16_VECTOR_MAKE(32000);
51 for (u
= 0; u
< PA_INT16_VECTOR_SIZE
; u
++)
52 pa_log("input=%i\n", input
.i
[u
]);
54 unpacked1
.m
= _mm_unpackhi_epi16(zero
.m
, input
.m
);
55 unpacked2
.m
= _mm_unpacklo_epi16(zero
.m
, input
.m
);
57 for (u
= 0; u
< PA_INT32_VECTOR_SIZE
; u
++)
58 pa_log("unpacked1=%i\n", unpacked1
.i
[u
]);
60 unpacked1
.v
/= reduce
.v
;
61 unpacked2
.v
/= reduce
.v
;
63 for (u
= 0; u
< PA_INT32_VECTOR_SIZE
; u
++)
64 pa_log("unpacked1=%i\n", unpacked1
.i
[u
]);
66 for (u
= 0; u
< PA_INT32_VECTOR_SIZE
; u
++)
67 pa_log("volume1=%i\n", volume1
.i
[u
]);
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
;
72 for (u
= 0; u
< PA_INT32_VECTOR_SIZE
; u
++)
73 pa_log("unpacked1=%i\n", unpacked1
.i
[u
]);
75 output
.m
= _mm_packs_epi32(unpacked1
.m
, unpacked2
.m
);
77 for (u
= 0; u
< PA_INT16_VECTOR_SIZE
; u
++)
78 pa_log("output=%i\n", output
.i
[u
]);