]> code.delx.au - pulseaudio/blob - src/pulsecore/vector.h
More spelling fixes
[pulseaudio] / src / pulsecore / vector.h
1 /***
2 This file is part of PulseAudio.
3
4 Copyright 2004-2006 Lennart Poettering
5 Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
6
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.1 of the License,
10 or (at your option) any later version.
11
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.
16
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
20 USA.
21 ***/
22
23 #include <inttypes.h>
24
25 /* First, define HAVE_VECTOR if we have the gcc vector extensions at all */
26 #if defined(__SSE2__)
27 /* || defined(__ALTIVEC__)*/
28 #define HAVE_VECTOR
29
30
31 /* This is supposed to be portable to different SIMD instruction
32 * sets. We define vector types for different base types: uint8_t,
33 * int16_t, int32_t, float. The vector type is a union. The fields .i,
34 * .u, .f are arrays for accessing the separate elements of a
35 * vector. .v is a gcc vector type of the right format. .m is the
36 * vector in the type the SIMD extension specific intrinsic API
37 * expects. PA_xxx_VECTOR_SIZE is the size of the
38 * entries. PA_xxxx_VECTOR_MAKE constructs a gcc vector variable with
39 * the same value in all elements. */
40
41 #ifdef __SSE2__
42
43 #include <xmmintrin.h>
44 #include <emmintrin.h>
45
46 #define PA_UINT8_VECTOR_SIZE 16
47 #define PA_INT16_VECTOR_SIZE 8
48 #define PA_INT32_VECTOR_SIZE 4
49 #define PA_FLOAT_VECTOR_SIZE 4
50
51 #define PA_UINT8_VECTOR_MAKE(x) (pa_v16qi) { x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x }
52 #define PA_INT16_VECTOR_MAKE(x) (pa_v8hi) { x, x, x, x, x, x, x, x }
53 #define PA_INT32_VECTOR_MAKE(x) (pa_v4si) { x, x, x, x }
54 #define PA_FLOAT_VECTOR_MAKE(x) (pa_v4fi) { x, x, x, x }
55
56 #endif
57
58 /* uint8_t vector */
59 typedef uint8_t pa_v16qi __attribute__ ((vector_size (PA_UINT8_VECTOR_SIZE * sizeof(uint8_t))));
60 typedef union pa_uint8_vector {
61 uint8_t u[PA_UINT8_VECTOR_SIZE];
62 pa_v16qi v;
63 #ifdef __SSE2__
64 __m128i m;
65 #endif
66 } pa_uint8_vector_t;
67
68 /* int16_t vector*/
69 typedef int16_t pa_v8hi __attribute__ ((vector_size (PA_INT16_VECTOR_SIZE * sizeof(int16_t))));
70 typedef union pa_int16_vector {
71 int16_t i[PA_INT16_VECTOR_SIZE];
72 pa_v8hi v;
73 #ifdef __SSE2__
74 __m128i m;
75 #endif
76 } pa_int16_vector_t;
77
78 /* int32_t vector */
79 typedef int32_t pa_v4si __attribute__ ((vector_size (PA_INT32_VECTOR_SIZE * sizeof(int32_t))));
80 typedef union pa_int32_vector {
81 int32_t i[PA_INT32_VECTOR_SIZE];
82 pa_v4si v;
83 #ifdef __SSE2__
84 __m128i m;
85 #endif
86 } pa_int32_vector_t;
87
88 /* float vector */
89 typedef float pa_v4sf __attribute__ ((vector_size (PA_FLOAT_VECTOR_SIZE * sizeof(float))));
90 typedef union pa_float_vector {
91 float f[PA_FLOAT_VECTOR_SIZE];
92 pa_v4sf v;
93 #ifdef __SSE2__
94 __m128 m;
95 #endif
96 } pa_float_vector_t;
97
98 #endif