24 #ifndef AVUTIL_PPC_UTIL_ALTIVEC_H
25 #define AVUTIL_PPC_UTIL_ALTIVEC_H
41 #define WORD_0 0x00,0x01,0x02,0x03
42 #define WORD_1 0x04,0x05,0x06,0x07
43 #define WORD_2 0x08,0x09,0x0a,0x0b
44 #define WORD_3 0x0c,0x0d,0x0e,0x0f
45 #define WORD_s0 0x10,0x11,0x12,0x13
46 #define WORD_s1 0x14,0x15,0x16,0x17
47 #define WORD_s2 0x18,0x19,0x1a,0x1b
48 #define WORD_s3 0x1c,0x1d,0x1e,0x1f
49 #define vcprm(a,b,c,d) (const vec_u8){WORD_ ## a, WORD_ ## b, WORD_ ## c, WORD_ ## d}
51 #define SWP_W2S0 0x02,0x03,0x00,0x01
52 #define SWP_W2S1 0x06,0x07,0x04,0x05
53 #define SWP_W2S2 0x0a,0x0b,0x08,0x09
54 #define SWP_W2S3 0x0e,0x0f,0x0c,0x0d
55 #define SWP_W2Ss0 0x12,0x13,0x10,0x11
56 #define SWP_W2Ss1 0x16,0x17,0x14,0x15
57 #define SWP_W2Ss2 0x1a,0x1b,0x18,0x19
58 #define SWP_W2Ss3 0x1e,0x1f,0x1c,0x1d
59 #define vcswapi2s(a,b,c,d) (const vector unsigned char){SWP_W2S ## a, SWP_W2S ## b, SWP_W2S ## c, SWP_W2S ## d}
62 (const vector unsigned char){0x0f,0x0e,0x0d,0x0c,0x0b,0x0a,0x09,0x08,0x07,0x06,0x05,0x04,0x03,0x02,0x01,0x00}
66 #define TRANSPOSE8(a,b,c,d,e,f,g,h) \
68 vec_s16 A1, B1, C1, D1, E1, F1, G1, H1; \
69 vec_s16 A2, B2, C2, D2, E2, F2, G2, H2; \
71 A1 = vec_mergeh (a, e); \
72 B1 = vec_mergel (a, e); \
73 C1 = vec_mergeh (b, f); \
74 D1 = vec_mergel (b, f); \
75 E1 = vec_mergeh (c, g); \
76 F1 = vec_mergel (c, g); \
77 G1 = vec_mergeh (d, h); \
78 H1 = vec_mergel (d, h); \
80 A2 = vec_mergeh (A1, E1); \
81 B2 = vec_mergel (A1, E1); \
82 C2 = vec_mergeh (B1, F1); \
83 D2 = vec_mergel (B1, F1); \
84 E2 = vec_mergeh (C1, G1); \
85 F2 = vec_mergel (C1, G1); \
86 G2 = vec_mergeh (D1, H1); \
87 H2 = vec_mergel (D1, H1); \
89 a = vec_mergeh (A2, E2); \
90 b = vec_mergel (A2, E2); \
91 c = vec_mergeh (B2, F2); \
92 d = vec_mergel (B2, F2); \
93 e = vec_mergeh (C2, G2); \
94 f = vec_mergel (C2, G2); \
95 g = vec_mergeh (D2, H2); \
96 h = vec_mergel (D2, H2); \
101 #define VEC_LD(offset,b) \
102 vec_perm(vec_ld(offset, b), vec_ld((offset)+15, b), vec_lvsl(offset, b))
104 #define VEC_LD(offset,b) \
105 vec_vsx_ld(offset, b)
113 register vec_u8 first = vec_ld(offset, src);
114 register vec_u8 second = vec_ld(offset + 15, src);
116 return vec_perm(first, second, mask);
120 vec_u8 a = vec_ld(offset, src);
121 vec_u8 b = vec_ld(offset + 15, src);
122 return vec_perm(a, b, perm_vec);
125 #define unaligned_load(a,b) VEC_LD(a,b)
126 #define load_with_perm_vec(a,b,c) VEC_LD(a,b)
135 #define vec_unaligned_load(b) VEC_LD(0, b)
138 #define VEC_MERGEH(a, b) vec_mergeh(a, b)
139 #define VEC_MERGEL(a, b) vec_mergel(a, b)
141 #define VEC_MERGEH(a, b) vec_mergeh(b, a)
142 #define VEC_MERGEL(a, b) vec_mergel(b, a)
146 #define VEC_ST(a,b,c) vec_st(a,b,c)
148 #define VEC_ST(a,b,c) vec_vsx_st(a,b,c)
152 #define VEC_SPLAT16(a,b) vec_splat((vec_s16)(a), b)
154 #define VEC_SPLAT16(a,b) vec_splat((vec_s16)(vec_perm(a, a, vcswapi2s(0,1,2,3))), b)
158 #define VEC_SLD16(a,b,c) vec_sld(a, b, c)
160 #define VEC_SLD16(a,b,c) vec_sld(b, a, c)
167 #define vsx_ld_u8_s16(off, p) \
168 ((vec_s16)vec_mergeh((vec_u8)vec_splat_u8(0), \
169 (vec_u8)vec_vsx_ld((off), (p))))
171 #define vsx_ld_u8_s16(off, p) \
172 ((vec_s16)vec_mergeh((vec_u8)vec_vsx_ld((off), (p)), \
173 (vec_u8)vec_splat_u8(0)))
static const uint16_t mask[17]
static const uint8_t offset[127][2]