]>
code.delx.au - pulseaudio/blob - src/pulsecore/vector.h
2 This file is part of PulseAudio.
4 Copyright 2004-2006 Lennart Poettering
5 Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
7 PulseAudio is free software; you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published
9 by the Free Software Foundation; either version 2 of the License,
10 or (at your option) any later version.
12 PulseAudio is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public License
18 along with PulseAudio; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
25 /* First, define HAVE_VECTOR if we have the gcc vector extensions at all */
26 #if defined(__SSE2__) || defined(__ALTIVEC__)
30 /* This is supposed to be portable to different SIMD instruction
31 * sets. We define vector types for different base types: uint8_t,
32 * int16_t, int32_t, float. The vector type is a union. The fields .i,
33 * .u, .f are arrays for accessing the separate elements of a
34 * vector. .v is a gcc vector type of the right format. .m is the
35 * vector in the type the SIMD extenstion specific intrinsics API
36 * expects. PA_xxx_VECTOR_SIZE is the size of the
37 * entries. PA_xxxx_VECTOR_MAKE constructs a gcc vector variable with
38 * the same value in all elements. */
42 #include <xmmintrin.h>
43 #include <emmintrin.h>
45 #define PA_UINT8_VECTOR_SIZE 16
46 #define PA_INT16_VECTOR_SIZE 8
47 #define PA_INT32_VECTOR_SIZE 4
48 #define PA_FLOAT_VECTOR_SIZE 4
50 #define PA_UINT8_VECTOR_MAKE(x) (pa_v16qi) { x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x }
51 #define PA_INT16_VECTOR_MAKE(x) (pa_v8hi) { x, x, x, x, x, x, x, x }
52 #define PA_INT32_VECTOR_MAKE(x) (pa_v4si) { x, x, x, x }
53 #define PA_FLOAT_VECTOR_MAKE(x) (pa_v4fi) { x, x, x, x }
58 typedef uint8_t pa_v16qi
__attribute__ ((vector_size (PA_UINT8_VECTOR_SIZE
* sizeof(uint8_t))));
59 typedef union pa_uint8_vector
{
60 uint8_t u
[PA_UINT8_VECTOR_SIZE
];
68 typedef int16_t pa_v8hi
__attribute__ ((vector_size (PA_INT16_VECTOR_SIZE
* sizeof(int16_t))));
69 typedef union pa_int16_vector
{
70 int16_t i
[PA_INT16_VECTOR_SIZE
];
78 typedef int32_t pa_v4si
__attribute__ ((vector_size (PA_INT32_VECTOR_SIZE
* sizeof(int32_t))));
79 typedef union pa_int32_vector
{
80 int32_t i
[PA_INT32_VECTOR_SIZE
];
88 typedef float pa_v4sf
__attribute__ ((vector_size (PA_FLOAT_VECTOR_SIZE
* sizeof(float))));
89 typedef union pa_float_vector
{
90 float f
[PA_FLOAT_VECTOR_SIZE
];