00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00024 #ifndef AVCODEC_PPC_UTIL_ALTIVEC_H
00025 #define AVCODEC_PPC_UTIL_ALTIVEC_H
00026
00027 #include <stdint.h>
00028
00029 #include "config.h"
00030
00031 #if HAVE_ALTIVEC_H
00032 #include <altivec.h>
00033 #endif
00034
00035 #include "types_altivec.h"
00036
00037
00038
00039 #define WORD_0 0x00,0x01,0x02,0x03
00040 #define WORD_1 0x04,0x05,0x06,0x07
00041 #define WORD_2 0x08,0x09,0x0a,0x0b
00042 #define WORD_3 0x0c,0x0d,0x0e,0x0f
00043 #define WORD_s0 0x10,0x11,0x12,0x13
00044 #define WORD_s1 0x14,0x15,0x16,0x17
00045 #define WORD_s2 0x18,0x19,0x1a,0x1b
00046 #define WORD_s3 0x1c,0x1d,0x1e,0x1f
00047
00048 #define vcprm(a,b,c,d) (const vector unsigned char){WORD_ ## a, WORD_ ## b, WORD_ ## c, WORD_ ## d}
00049 #define vcii(a,b,c,d) (const vector float){FLOAT_ ## a, FLOAT_ ## b, FLOAT_ ## c, FLOAT_ ## d}
00050
00051
00052
00053
00054 #define vcprmle(a,b,c,d) vcprm(d,c,b,a)
00055
00056
00057
00058 #define FLOAT_n -1.
00059 #define FLOAT_p 1.
00060
00061
00062
00063 #define TRANSPOSE8(a,b,c,d,e,f,g,h) \
00064 do { \
00065 vector signed short A1, B1, C1, D1, E1, F1, G1, H1; \
00066 vector signed short A2, B2, C2, D2, E2, F2, G2, H2; \
00067 \
00068 A1 = vec_mergeh (a, e); \
00069 B1 = vec_mergel (a, e); \
00070 C1 = vec_mergeh (b, f); \
00071 D1 = vec_mergel (b, f); \
00072 E1 = vec_mergeh (c, g); \
00073 F1 = vec_mergel (c, g); \
00074 G1 = vec_mergeh (d, h); \
00075 H1 = vec_mergel (d, h); \
00076 \
00077 A2 = vec_mergeh (A1, E1); \
00078 B2 = vec_mergel (A1, E1); \
00079 C2 = vec_mergeh (B1, F1); \
00080 D2 = vec_mergel (B1, F1); \
00081 E2 = vec_mergeh (C1, G1); \
00082 F2 = vec_mergel (C1, G1); \
00083 G2 = vec_mergeh (D1, H1); \
00084 H2 = vec_mergel (D1, H1); \
00085 \
00086 a = vec_mergeh (A2, E2); \
00087 b = vec_mergel (A2, E2); \
00088 c = vec_mergeh (B2, F2); \
00089 d = vec_mergel (B2, F2); \
00090 e = vec_mergeh (C2, G2); \
00091 f = vec_mergel (C2, G2); \
00092 g = vec_mergeh (D2, H2); \
00093 h = vec_mergel (D2, H2); \
00094 } while (0)
00095
00096
00099 static inline vector unsigned char unaligned_load(int offset, uint8_t *src)
00100 {
00101 register vector unsigned char first = vec_ld(offset, src);
00102 register vector unsigned char second = vec_ld(offset+15, src);
00103 register vector unsigned char mask = vec_lvsl(offset, src);
00104 return vec_perm(first, second, mask);
00105 }
00106
00111 static inline vec_u8 load_with_perm_vec(int offset, uint8_t *src, vec_u8 perm_vec)
00112 {
00113 vec_u8 a = vec_ld(offset, src);
00114 vec_u8 b = vec_ld(offset+15, src);
00115 return vec_perm(a, b, perm_vec);
00116 }
00117
00118 #endif