37 #define vzero vec_splat_s32(0)
39 #define GET_LS(a,b,c,s) {\
40 vector signed short l2 = vec_ld(((b) << 1) + 16, s);\
41 ls = vec_perm(a, l2, c);\
45 #define yuv2planeX_8(d1, d2, l1, src, x, perm, filter) do {\
46 vector signed short ls;\
47 vector signed int vf1, vf2, i1, i2;\
48 GET_LS(l1, x, perm, src);\
49 i1 = vec_mule(filter, ls);\
50 i2 = vec_mulo(filter, ls);\
51 vf1 = vec_mergeh(i1, i2);\
52 vf2 = vec_mergel(i1, i2);\
53 d1 = vec_add(d1, vf1);\
54 d2 = vec_add(d2, vf2);\
57 #define LOAD_FILTER(vf,f) {\
58 vector unsigned char perm0 = vec_lvsl(joffset, f);\
59 vf = vec_ld(joffset, f);\
60 vf = vec_perm(vf, vf, perm0);\
62 #define LOAD_L1(ll1,s,p){\
63 p = vec_lvsl(xoffset, s);\
64 ll1 = vec_ld(xoffset, s);\
73 #define GET_VF4(a, vf, f) {\
74 vf = vec_ld(a<< 3, f);\
76 vf = vec_mergel(vf, (vector signed short)vzero);\
78 vf = vec_mergeh(vf, (vector signed short)vzero);\
80 #define FIRST_LOAD(sv, pos, s, per) {\
82 per = vec_lvsl(pos, s);\
84 #define UPDATE_PTR(s0, d0, s1, d1) {\
88 #define LOAD_SRCV(pos, a, s, per, v0, v1, vf) {\
89 v1 = vec_ld(pos + a + 16, s);\
90 vf = vec_perm(v0, v1, per);\
92 #define LOAD_SRCV8(pos, a, s, per, v0, v1, vf) {\
93 if ((((uintptr_t)s + pos) % 16) > 8) {\
94 v1 = vec_ld(pos + a + 16, s);\
96 vf = vec_perm(v0, src_v1, per);\
98 #define GET_VFD(a, b, f, vf0, vf1, per, vf, off) {\
99 vf1 = vec_ld((a * 2 * filterSize) + (b * 2) + 16 + off, f);\
100 vf = vec_perm(vf0, vf1, per);\
103 #define FUNC(name) name ## _altivec
113 #define get_pixel(val, bias, signedness) \
114 (bias + av_clip_ ## signedness ## 16(val >> shift))
117 yuv2plane1_float_u(
const int32_t *
src,
float *dest,
int dstW,
int start)
119 static const int shift = 3;
120 static const float float_mult = 1.0f / 65535.0f;
124 for (
i = start;
i < dstW; ++
i){
126 val_uint = get_pixel(
val, 0, uint);
127 dest[
i] = float_mult * (
float)val_uint;
132 yuv2plane1_float_bswap_u(
const int32_t *
src, uint32_t *dest,
int dstW,
int start)
134 static const int shift = 3;
135 static const float float_mult = 1.0f / 65535.0f;
139 for (
i = start;
i < dstW; ++
i){
141 val_uint = get_pixel(
val, 0, uint);
146 static void yuv2plane1_float_altivec(
const int32_t *
src,
float *dest,
int dstW)
148 const int dst_u = -(uintptr_t)dest & 3;
149 const int add = (1 << (
SHIFT - 1));
150 const int clip = (1 << 16) - 1;
151 const float fmult = 1.0f / 65535.0f;
155 const vec_f vmul = (
vec_f) {fmult, fmult, fmult, fmult};
161 yuv2plane1_float_u(
src, dest, dst_u, 0);
163 for (
i = dst_u;
i < dstW - 3;
i += 4) {
164 v = vec_ld(0, (
const uint32_t *) &
src[
i]);
165 v = vec_add(v, vadd);
167 v = vec_min(v, vlargest);
170 vd = vec_madd(vd, vmul, vzero);
172 vec_st(vd, 0, &dest[
i]);
175 yuv2plane1_float_u(
src, dest, dstW,
i);
178 static void yuv2plane1_float_bswap_altivec(
const int32_t *
src, uint32_t *dest,
int dstW)
180 const int dst_u = -(uintptr_t)dest & 3;
181 const int add = (1 << (
SHIFT - 1));
182 const int clip = (1 << 16) - 1;
183 const float fmult = 1.0f / 65535.0f;
187 const vec_f vmul = (
vec_f) {fmult, fmult, fmult, fmult};
190 const vec_u16 vswapsmall = vec_splat_u16(8);
195 yuv2plane1_float_bswap_u(
src, dest, dst_u, 0);
197 for (
i = dst_u;
i < dstW - 3;
i += 4) {
198 v = vec_ld(0, (
const uint32_t *) &
src[
i]);
199 v = vec_add(v, vadd);
201 v = vec_min(v, vlargest);
204 vd = vec_madd(vd, vmul, vzero);
209 vec_st(vd, 0, (
float *) &dest[
i]);
212 yuv2plane1_float_bswap_u(
src, dest, dstW,
i);
215 #define yuv2plane1_float(template, dest_type, BE_LE) \
216 static void yuv2plane1_float ## BE_LE ## _altivec(const int16_t *src, uint8_t *dest, \
218 const uint8_t *dither, int offset) \
220 template((const int32_t *)src, (dest_type *)dest, dstW); \
242 if (
c->srcBpc == 8 &&
c->dstBpc <= 14) {
243 c->hyScale =
c->hcScale = hScale_real_altivec;
248 c->yuv2planeX = yuv2planeX_altivec;
253 c->yuv2plane1 = yuv2plane1_floatBE_altivec;
255 c->yuv2plane1 = yuv2plane1_floatLE_altivec;
261 switch (
c->opts.dst_format) {
263 c->yuv2packedX = ff_yuv2abgr_X_altivec;
266 c->yuv2packedX = ff_yuv2bgra_X_altivec;
269 c->yuv2packedX = ff_yuv2argb_X_altivec;
272 c->yuv2packedX = ff_yuv2rgba_X_altivec;
275 c->yuv2packedX = ff_yuv2bgr24_X_altivec;
278 c->yuv2packedX = ff_yuv2rgb24_X_altivec;