24 #ifndef AVUTIL_PPC_UTIL_ALTIVEC_H
25 #define AVUTIL_PPC_UTIL_ALTIVEC_H
38 #define vec_u8 vector unsigned char
39 #define vec_s8 vector signed char
40 #define vec_u16 vector unsigned short
41 #define vec_s16 vector signed short
42 #define vec_u32 vector unsigned int
43 #define vec_s32 vector signed int
44 #define vec_f vector float
49 #define LOAD_ZERO const vec_u8 zerov = vec_splat_u8( 0 )
51 #define zero_u8v (vec_u8) zerov
52 #define zero_s8v (vec_s8) zerov
53 #define zero_u16v (vec_u16) zerov
54 #define zero_s16v (vec_s16) zerov
55 #define zero_u32v (vec_u32) zerov
56 #define zero_s32v (vec_s32) zerov
62 #define WORD_0 0x00,0x01,0x02,0x03
63 #define WORD_1 0x04,0x05,0x06,0x07
64 #define WORD_2 0x08,0x09,0x0a,0x0b
65 #define WORD_3 0x0c,0x0d,0x0e,0x0f
66 #define WORD_s0 0x10,0x11,0x12,0x13
67 #define WORD_s1 0x14,0x15,0x16,0x17
68 #define WORD_s2 0x18,0x19,0x1a,0x1b
69 #define WORD_s3 0x1c,0x1d,0x1e,0x1f
70 #define vcprm(a,b,c,d) (const vec_u8){WORD_ ## a, WORD_ ## b, WORD_ ## c, WORD_ ## d}
72 #define SWP_W2S0 0x02,0x03,0x00,0x01
73 #define SWP_W2S1 0x06,0x07,0x04,0x05
74 #define SWP_W2S2 0x0a,0x0b,0x08,0x09
75 #define SWP_W2S3 0x0e,0x0f,0x0c,0x0d
76 #define SWP_W2Ss0 0x12,0x13,0x10,0x11
77 #define SWP_W2Ss1 0x16,0x17,0x14,0x15
78 #define SWP_W2Ss2 0x1a,0x1b,0x18,0x19
79 #define SWP_W2Ss3 0x1e,0x1f,0x1c,0x1d
80 #define vcswapi2s(a,b,c,d) (const vector unsigned char){SWP_W2S ## a, SWP_W2S ## b, SWP_W2S ## c, SWP_W2S ## d}
83 (const vector unsigned char){0x0f,0x0e,0x0d,0x0c,0x0b,0x0a,0x09,0x08,0x07,0x06,0x05,0x04,0x03,0x02,0x01,0x00}
87 #define TRANSPOSE8(a,b,c,d,e,f,g,h) \
89 vec_s16 A1, B1, C1, D1, E1, F1, G1, H1; \
90 vec_s16 A2, B2, C2, D2, E2, F2, G2, H2; \
92 A1 = vec_mergeh (a, e); \
93 B1 = vec_mergel (a, e); \
94 C1 = vec_mergeh (b, f); \
95 D1 = vec_mergel (b, f); \
96 E1 = vec_mergeh (c, g); \
97 F1 = vec_mergel (c, g); \
98 G1 = vec_mergeh (d, h); \
99 H1 = vec_mergel (d, h); \
101 A2 = vec_mergeh (A1, E1); \
102 B2 = vec_mergel (A1, E1); \
103 C2 = vec_mergeh (B1, F1); \
104 D2 = vec_mergel (B1, F1); \
105 E2 = vec_mergeh (C1, G1); \
106 F2 = vec_mergel (C1, G1); \
107 G2 = vec_mergeh (D1, H1); \
108 H2 = vec_mergel (D1, H1); \
110 a = vec_mergeh (A2, E2); \
111 b = vec_mergel (A2, E2); \
112 c = vec_mergeh (B2, F2); \
113 d = vec_mergel (B2, F2); \
114 e = vec_mergeh (C2, G2); \
115 f = vec_mergel (C2, G2); \
116 g = vec_mergeh (D2, H2); \
117 h = vec_mergel (D2, H2); \
122 #define VEC_LD(offset,b) \
123 vec_perm(vec_ld(offset, b), vec_ld((offset)+15, b), vec_lvsl(offset, b))
125 #define VEC_LD(offset,b) \
126 vec_vsx_ld(offset, b)
134 register vec_u8 first = vec_ld(offset, src);
135 register vec_u8 second = vec_ld(offset + 15, src);
137 return vec_perm(first, second, mask);
141 vec_u8 a = vec_ld(offset, src);
142 vec_u8 b = vec_ld(offset + 15, src);
143 return vec_perm(a, b, perm_vec);
146 #define unaligned_load(a,b) VEC_LD(a,b)
147 #define load_with_perm_vec(a,b,c) VEC_LD(a,b)
156 #define vec_unaligned_load(b) VEC_LD(0, b)
159 #define VEC_MERGEH(a, b) vec_mergeh(a, b)
160 #define VEC_MERGEL(a, b) vec_mergel(a, b)
162 #define VEC_MERGEH(a, b) vec_mergeh(b, a)
163 #define VEC_MERGEL(a, b) vec_mergel(b, a)
167 #define VEC_ST(a,b,c) vec_st(a,b,c)
169 #define VEC_ST(a,b,c) vec_vsx_st(a,b,c)
173 #define VEC_SPLAT16(a,b) vec_splat((vec_s16)(a), b)
175 #define VEC_SPLAT16(a,b) vec_splat((vec_s16)(vec_perm(a, a, vcswapi2s(0,1,2,3))), b)
179 #define VEC_SLD16(a,b,c) vec_sld(a, b, c)
181 #define VEC_SLD16(a,b,c) vec_sld(b, a, c)
188 #define vsx_ld_u8_s16(off, p) \
189 ((vec_s16)vec_mergeh((vec_u8)vec_splat_u8(0), \
190 (vec_u8)vec_vsx_ld((off), (p))))
192 #define vsx_ld_u8_s16(off, p) \
193 ((vec_s16)vec_mergeh((vec_u8)vec_vsx_ld((off), (p)), \
194 (vec_u8)vec_splat_u8(0)))
static const uint16_t mask[17]
static const uint8_t offset[127][2]