36 #define vzero vec_splat_s32(0)
39 #define GET_LS(a,b,c,s) {\
41 a = vec_vsx_ld(((b) << 1) + 16, s);\
44 #define yuv2planeX_8(d1, d2, l1, src, x, perm, filter) do {\
45 vector signed short ls;\
46 vector signed int vf1, vf2, i1, i2;\
47 GET_LS(l1, x, perm, src);\
48 i1 = vec_mule(filter, ls);\
49 i2 = vec_mulo(filter, ls);\
50 vf1 = vec_mergeh(i1, i2);\
51 vf2 = vec_mergel(i1, i2);\
52 d1 = vec_add(d1, vf1);\
53 d2 = vec_add(d2, vf2);\
56 #define LOAD_FILTER(vf,f) {\
57 vf = vec_splats(f[j]);\
59 #define LOAD_L1(ll1,s,p){\
60 ll1 = vec_vsx_ld(xoffset, s);\
69 #define GET_VF4(a, vf, f) {\
70 vf = (vector signed short)vec_vsx_ld(a << 3, f);\
71 vf = vec_mergeh(vf, (vector signed short)vzero);\
73 #define FIRST_LOAD(sv, pos, s, per) {}
74 #define UPDATE_PTR(s0, d0, s1, d1) {}
75 #define LOAD_SRCV(pos, a, s, per, v0, v1, vf) {\
76 vf = vec_vsx_ld(pos + a, s);\
78 #define LOAD_SRCV8(pos, a, s, per, v0, v1, vf) LOAD_SRCV(pos, a, s, per, v0, v1, vf)
79 #define GET_VFD(a, b, f, vf0, vf1, per, vf, off) {\
80 vf = vec_vsx_ld((a * 2 * filterSize) + (b * 2) + off, f);\
83 #define FUNC(name) name ## _vsx
91 static void yuv2plane1_8_u(
const int16_t *
src,
uint8_t *dest,
int dstW,
95 for (
i = start;
i < dstW;
i++) {
101 static void yuv2plane1_8_vsx(
const int16_t *
src,
uint8_t *dest,
int dstW,
104 const int dst_u = -(uintptr_t)dest & 15;
108 vec_s16 vi, vileft, ditherleft, ditherright;
111 for (j = 0; j < 16; j++) {
115 ditherleft = vec_ld(0,
val);
116 ditherright = vec_ld(0, &
val[8]);
120 for (
i = dst_u;
i < dstW - 15;
i += 16) {
122 vi = vec_vsx_ld(0, &
src[
i]);
123 vi = vec_adds(ditherleft, vi);
124 vileft = vec_sra(vi,
shifts);
126 vi = vec_vsx_ld(0, &
src[
i + 8]);
127 vi = vec_adds(ditherright, vi);
130 vd = vec_packsu(vileft, vi);
131 vec_st(vd, 0, &dest[
i]);
139 #define output_pixel(pos, val) \
141 AV_WB16(pos, av_clip_uintp2(val >> shift, output_bits)); \
143 AV_WL16(pos, av_clip_uintp2(val >> shift, output_bits)); \
146 static void yuv2plane1_nbps_u(
const int16_t *
src, uint16_t *dest,
int dstW,
147 int big_endian,
int output_bits,
int start)
150 int shift = 15 - output_bits;
152 for (
i = start;
i < dstW;
i++) {
159 uint16_t *dest,
int dstW,
160 const int big_endian,
161 const int output_bits)
163 const int dst_u = -(uintptr_t)dest & 7;
164 const int shift = 15 - output_bits;
166 const int clip = (1 << output_bits) - 1;
168 const vec_u16 vswap = (
vec_u16) vec_splat_u16(big_endian ? 8 : 0);
174 yuv2plane1_nbps_u(
src, dest, dst_u, big_endian, output_bits, 0);
176 for (
i = dst_u;
i < dstW - 7;
i += 8) {
177 v = vec_vsx_ld(0, (
const uint16_t *) &
src[
i]);
178 v = vec_add(v, vadd);
179 v = vec_sr(v, vshift);
180 v = vec_min(v, vlargest);
181 v = vec_rl(v, vswap);
182 vec_st(v, 0, &dest[
i]);
185 yuv2plane1_nbps_u(
src, dest, dstW, big_endian, output_bits,
i);
188 static void yuv2planeX_nbps_u(
const int16_t *
filter,
int filterSize,
189 const int16_t **
src, uint16_t *dest,
int dstW,
190 int big_endian,
int output_bits,
int start)
193 int shift = 11 + 16 - output_bits;
195 for (
i = start;
i < dstW;
i++) {
199 for (j = 0; j < filterSize; j++)
206 static void yuv2planeX_nbps_vsx(
const int16_t *
filter,
int filterSize,
207 const int16_t **
src, uint16_t *dest,
int dstW,
208 int big_endian,
int output_bits)
210 const int dst_u = -(uintptr_t)dest & 7;
211 const int shift = 11 + 16 - output_bits;
213 const int clip = (1 << output_bits) - 1;
214 const uint16_t swap = big_endian ? 8 : 0;
217 const vec_u16 vswap = (
vec_u16) {swap, swap, swap, swap, swap, swap, swap, swap};
219 const vec_s16 vzero = vec_splat_s16(0);
220 const vec_u8 vperm = (
vec_u8) {0, 1, 8, 9, 2, 3, 10, 11, 4, 5, 12, 13, 6, 7, 14, 15};
226 for (
i = 0;
i < filterSize;
i++) {
231 yuv2planeX_nbps_u(
filter, filterSize,
src, dest, dst_u, big_endian, output_bits, 0);
233 for (
i = dst_u;
i < dstW - 7;
i += 8) {
234 vleft = vright = vadd;
236 for (j = 0; j < filterSize; j++) {
237 vin = vec_vsx_ld(0, &
src[j][
i]);
238 vtmp = (
vec_u32) vec_mule(vin, vfilter[j]);
239 vleft = vec_add(vleft, vtmp);
240 vtmp = (
vec_u32) vec_mulo(vin, vfilter[j]);
241 vright = vec_add(vright, vtmp);
244 vleft = vec_sra(vleft, vshift);
245 vright = vec_sra(vright, vshift);
246 v = vec_packsu(vleft, vright);
248 v = vec_min(v, vlargest);
249 v = vec_rl(v, vswap);
250 v = vec_perm(v, v, vperm);
251 vec_st(v, 0, &dest[
i]);
254 yuv2planeX_nbps_u(
filter, filterSize,
src, dest, dstW, big_endian, output_bits,
i);
260 #define output_pixel(pos, val, bias, signedness) \
262 AV_WB16(pos, bias + av_clip_ ## signedness ## 16(val >> shift)); \
264 AV_WL16(pos, bias + av_clip_ ## signedness ## 16(val >> shift)); \
267 static void yuv2plane1_16_u(
const int32_t *
src, uint16_t *dest,
int dstW,
268 int big_endian,
int output_bits,
int start)
273 for (
i = start;
i < dstW;
i++) {
280 uint16_t *dest,
int dstW,
281 const int big_endian,
284 const int dst_u = -(uintptr_t)dest & 7;
288 const vec_u16 vswap = (
vec_u16) vec_splat_u16(big_endian ? 8 : 0);
294 yuv2plane1_16_u(
src, dest, dst_u, big_endian, output_bits, 0);
296 for (
i = dst_u;
i < dstW - 7;
i += 8) {
297 v = vec_vsx_ld(0, (
const uint32_t *) &
src[
i]);
298 v = vec_add(v, vadd);
299 v = vec_sr(v, vshift);
301 v2 = vec_vsx_ld(0, (
const uint32_t *) &
src[
i + 4]);
302 v2 = vec_add(v2, vadd);
303 v2 = vec_sr(v2, vshift);
305 vd = vec_packsu(v, v2);
306 vd = vec_rl(vd, vswap);
308 vec_st(vd, 0, &dest[
i]);
311 yuv2plane1_16_u(
src, dest, dstW, big_endian, output_bits,
i);
316 static void yuv2planeX_16_u(
const int16_t *
filter,
int filterSize,
317 const int32_t **
src, uint16_t *dest,
int dstW,
318 int big_endian,
int output_bits,
int start)
323 for (
i = start;
i < dstW;
i++) {
333 for (j = 0; j < filterSize; j++)
340 static void yuv2planeX_16_vsx(
const int16_t *
filter,
int filterSize,
341 const int32_t **
src, uint16_t *dest,
int dstW,
342 int big_endian,
int output_bits)
344 const int dst_u = -(uintptr_t)dest & 7;
345 const int shift = 15;
346 const int bias = 0x8000;
347 const int add = (1 << (
shift - 1)) - 0x40000000;
348 const uint16_t swap = big_endian ? 8 : 0;
351 const vec_u16 vswap = (
vec_u16) {swap, swap, swap, swap, swap, swap, swap, swap};
352 const vec_u16 vbias = (
vec_u16) {bias, bias, bias, bias, bias, bias, bias, bias};
359 for (
i = 0;
i < filterSize;
i++) {
363 yuv2planeX_16_u(
filter, filterSize,
src, dest, dst_u, big_endian, output_bits, 0);
365 for (
i = dst_u;
i < dstW - 7;
i += 8) {
366 vleft = vright = vadd;
368 for (j = 0; j < filterSize; j++) {
369 vin32l = vec_vsx_ld(0, &
src[j][
i]);
370 vin32r = vec_vsx_ld(0, &
src[j][
i + 4]);
372 vtmp = (
vec_u32) vec_mul(vin32l, vfilter[j]);
373 vleft = vec_add(vleft, vtmp);
374 vtmp = (
vec_u32) vec_mul(vin32r, vfilter[j]);
375 vright = vec_add(vright, vtmp);
378 vleft = vec_sra(vleft, vshift);
379 vright = vec_sra(vright, vshift);
381 v = vec_add(v, vbias);
382 v = vec_rl(v, vswap);
383 vec_st(v, 0, &dest[
i]);
386 yuv2planeX_16_u(
filter, filterSize,
src, dest, dstW, big_endian, output_bits,
i);
391 #define yuv2NBPS(bits, BE_LE, is_be, template_size, typeX_t) \
392 yuv2NBPS1(bits, BE_LE, is_be, template_size, typeX_t) \
393 yuv2NBPSX(bits, BE_LE, is_be, template_size, typeX_t)
395 #define yuv2NBPS1(bits, BE_LE, is_be, template_size, typeX_t) \
396 static void yuv2plane1_ ## bits ## BE_LE ## _vsx(const int16_t *src, \
397 uint8_t *dest, int dstW, \
398 const uint8_t *dither, int offset) \
400 yuv2plane1_ ## template_size ## _vsx((const typeX_t *) src, \
401 (uint16_t *) dest, dstW, is_be, bits); \
404 #define yuv2NBPSX(bits, BE_LE, is_be, template_size, typeX_t) \
405 static void yuv2planeX_ ## bits ## BE_LE ## _vsx(const int16_t *filter, int filterSize, \
406 const int16_t **src, uint8_t *dest, int dstW, \
407 const uint8_t *dither, int offset)\
409 yuv2planeX_## template_size ## _vsx(filter, \
410 filterSize, (const typeX_t **) src, \
411 (uint16_t *) dest, dstW, is_be, bits); \
423 yuv2NBPS1(16, BE, 1, 16,
int32_t)
424 yuv2NBPS1(16, LE, 0, 16,
int32_t)
426 yuv2NBPSX(16, BE, 1, 16,
int32_t)
427 yuv2NBPSX(16, LE, 0, 16,
int32_t)
431 R_l = vec_max(R_l, zero32); \
432 R_r = vec_max(R_r, zero32); \
433 G_l = vec_max(G_l, zero32); \
434 G_r = vec_max(G_r, zero32); \
435 B_l = vec_max(B_l, zero32); \
436 B_r = vec_max(B_r, zero32); \
438 R_l = vec_min(R_l, rgbclip); \
439 R_r = vec_min(R_r, rgbclip); \
440 G_l = vec_min(G_l, rgbclip); \
441 G_r = vec_min(G_r, rgbclip); \
442 B_l = vec_min(B_l, rgbclip); \
443 B_r = vec_min(B_r, rgbclip); \
445 R_l = vec_sr(R_l, shift22); \
446 R_r = vec_sr(R_r, shift22); \
447 G_l = vec_sr(G_l, shift22); \
448 G_r = vec_sr(G_r, shift22); \
449 B_l = vec_sr(B_l, shift22); \
450 B_r = vec_sr(B_r, shift22); \
452 rd16 = vec_packsu(R_l, R_r); \
453 gd16 = vec_packsu(G_l, G_r); \
454 bd16 = vec_packsu(B_l, B_r); \
455 rd = vec_packsu(rd16, zero16); \
456 gd = vec_packsu(gd16, zero16); \
457 bd = vec_packsu(bd16, zero16); \
460 case AV_PIX_FMT_RGB24: { \
461 DECLARE_ALIGNED(16, uint8_t, tmp_out)[16]; \
462 out0 = vec_perm(rd, gd, perm3rg0); \
463 out0 = vec_perm(out0, bd, perm3tb0); \
464 out1 = vec_perm(rd, gd, perm3rg1); \
465 out1 = vec_perm(out1, bd, perm3tb1); \
467 vec_vsx_st(out0, 0, dest); \
468 vec_vsx_st(out1, 0, tmp_out); \
469 memcpy(dest + 16, tmp_out, 8); \
473 case AV_PIX_FMT_BGR24: { \
474 DECLARE_ALIGNED(16, uint8_t, tmp_out)[16]; \
475 out0 = vec_perm(bd, gd, perm3rg0); \
476 out0 = vec_perm(out0, rd, perm3tb0); \
477 out1 = vec_perm(bd, gd, perm3rg1); \
478 out1 = vec_perm(out1, rd, perm3tb1); \
480 vec_vsx_st(out0, 0, dest); \
481 vec_vsx_st(out1, 0, tmp_out); \
482 memcpy(dest + 16, tmp_out, 8); \
486 case AV_PIX_FMT_BGRA: \
487 out0 = vec_mergeh(bd, gd); \
488 out1 = vec_mergeh(rd, ad); \
490 tmp8 = (vec_u8) vec_mergeh((vec_u16) out0, (vec_u16) out1); \
491 vec_vsx_st(tmp8, 0, dest); \
492 tmp8 = (vec_u8) vec_mergel((vec_u16) out0, (vec_u16) out1); \
493 vec_vsx_st(tmp8, 16, dest); \
497 case AV_PIX_FMT_RGBA: \
498 out0 = vec_mergeh(rd, gd); \
499 out1 = vec_mergeh(bd, ad); \
501 tmp8 = (vec_u8) vec_mergeh((vec_u16) out0, (vec_u16) out1); \
502 vec_vsx_st(tmp8, 0, dest); \
503 tmp8 = (vec_u8) vec_mergel((vec_u16) out0, (vec_u16) out1); \
504 vec_vsx_st(tmp8, 16, dest); \
508 case AV_PIX_FMT_ARGB: \
509 out0 = vec_mergeh(ad, rd); \
510 out1 = vec_mergeh(gd, bd); \
512 tmp8 = (vec_u8) vec_mergeh((vec_u16) out0, (vec_u16) out1); \
513 vec_vsx_st(tmp8, 0, dest); \
514 tmp8 = (vec_u8) vec_mergel((vec_u16) out0, (vec_u16) out1); \
515 vec_vsx_st(tmp8, 16, dest); \
519 case AV_PIX_FMT_ABGR: \
520 out0 = vec_mergeh(ad, bd); \
521 out1 = vec_mergeh(gd, rd); \
523 tmp8 = (vec_u8) vec_mergeh((vec_u16) out0, (vec_u16) out1); \
524 vec_vsx_st(tmp8, 0, dest); \
525 tmp8 = (vec_u8) vec_mergel((vec_u16) out0, (vec_u16) out1); \
526 vec_vsx_st(tmp8, 16, dest); \
533 yuv2rgb_full_X_vsx_template(
SwsContext *
c,
const int16_t *lumFilter,
534 const int16_t **lumSrc,
int lumFilterSize,
535 const int16_t *chrFilter,
const int16_t **chrUSrc,
536 const int16_t **chrVSrc,
int chrFilterSize,
537 const int16_t **alpSrc,
uint8_t *dest,
541 vec_s32 vy32_l, vy32_r, vu32_l, vu32_r, vv32_l, vv32_r, tmp32;
542 vec_s32 R_l, R_r, G_l, G_r, B_l, B_r;
545 vec_u8 rd, bd, gd, ad, out0, out1, tmp8;
547 const vec_s32 ystart = vec_splats(1 << 9);
548 const vec_s32 uvstart = vec_splats((1 << 9) - (128 << 19));
549 const vec_u16 zero16 = vec_splat_u16(0);
550 const vec_s32 y_offset = vec_splats(
c->yuv2rgb_y_offset);
551 const vec_s32 y_coeff = vec_splats(
c->yuv2rgb_y_coeff);
552 const vec_s32 y_add = vec_splats(1 << 21);
553 const vec_s32 v2r_coeff = vec_splats(
c->yuv2rgb_v2r_coeff);
554 const vec_s32 v2g_coeff = vec_splats(
c->yuv2rgb_v2g_coeff);
555 const vec_s32 u2g_coeff = vec_splats(
c->yuv2rgb_u2g_coeff);
556 const vec_s32 u2b_coeff = vec_splats(
c->yuv2rgb_u2b_coeff);
557 const vec_s32 rgbclip = vec_splats(1 << 30);
558 const vec_s32 zero32 = vec_splat_s32(0);
559 const vec_u32 shift22 = vec_splats(22U);
560 const vec_u32 shift10 = vec_splat_u32(10);
583 ad = vec_splats((
uint8_t) 255);
585 for (
i = 0;
i < lumFilterSize;
i++)
586 vlumFilter[
i] = vec_splats(lumFilter[
i]);
587 for (
i = 0;
i < chrFilterSize;
i++)
588 vchrFilter[
i] = vec_splats(chrFilter[
i]);
590 for (
i = 0;
i < dstW;
i += 8) {
598 for (j = 0; j < lumFilterSize; j++) {
599 vv = vec_ld(0, &lumSrc[j][
i]);
600 tmp = vec_mule(vv, vlumFilter[j]);
601 tmp2 = vec_mulo(vv, vlumFilter[j]);
602 tmp3 = vec_mergeh(
tmp, tmp2);
603 tmp4 = vec_mergel(
tmp, tmp2);
605 vy32_l = vec_adds(vy32_l, tmp3);
606 vy32_r = vec_adds(vy32_r, tmp4);
609 for (j = 0; j < chrFilterSize; j++) {
610 vv = vec_ld(0, &chrUSrc[j][
i]);
611 tmp = vec_mule(vv, vchrFilter[j]);
612 tmp2 = vec_mulo(vv, vchrFilter[j]);
613 tmp3 = vec_mergeh(
tmp, tmp2);
614 tmp4 = vec_mergel(
tmp, tmp2);
616 vu32_l = vec_adds(vu32_l, tmp3);
617 vu32_r = vec_adds(vu32_r, tmp4);
619 vv = vec_ld(0, &chrVSrc[j][
i]);
620 tmp = vec_mule(vv, vchrFilter[j]);
621 tmp2 = vec_mulo(vv, vchrFilter[j]);
622 tmp3 = vec_mergeh(
tmp, tmp2);
623 tmp4 = vec_mergel(
tmp, tmp2);
625 vv32_l = vec_adds(vv32_l, tmp3);
626 vv32_r = vec_adds(vv32_r, tmp4);
629 vy32_l = vec_sra(vy32_l, shift10);
630 vy32_r = vec_sra(vy32_r, shift10);
631 vu32_l = vec_sra(vu32_l, shift10);
632 vu32_r = vec_sra(vu32_r, shift10);
633 vv32_l = vec_sra(vv32_l, shift10);
634 vv32_r = vec_sra(vv32_r, shift10);
636 vy32_l = vec_sub(vy32_l, y_offset);
637 vy32_r = vec_sub(vy32_r, y_offset);
638 vy32_l = vec_mul(vy32_l, y_coeff);
639 vy32_r = vec_mul(vy32_r, y_coeff);
640 vy32_l = vec_add(vy32_l, y_add);
641 vy32_r = vec_add(vy32_r, y_add);
643 R_l = vec_mul(vv32_l, v2r_coeff);
644 R_l = vec_add(R_l, vy32_l);
645 R_r = vec_mul(vv32_r, v2r_coeff);
646 R_r = vec_add(R_r, vy32_r);
647 G_l = vec_mul(vv32_l, v2g_coeff);
648 tmp32 = vec_mul(vu32_l, u2g_coeff);
649 G_l = vec_add(G_l, vy32_l);
650 G_l = vec_add(G_l, tmp32);
651 G_r = vec_mul(vv32_r, v2g_coeff);
652 tmp32 = vec_mul(vu32_r, u2g_coeff);
653 G_r = vec_add(G_r, vy32_r);
654 G_r = vec_add(G_r, tmp32);
656 B_l = vec_mul(vu32_l, u2b_coeff);
657 B_l = vec_add(B_l, vy32_l);
658 B_r = vec_mul(vu32_r, u2b_coeff);
659 B_r = vec_add(B_r, vy32_r);
665 #define SETUP(x, buf0, alpha1, buf1, alpha) { \
666 x = vec_ld(0, buf0); \
667 tmp = vec_mule(x, alpha1); \
668 tmp2 = vec_mulo(x, alpha1); \
669 tmp3 = vec_mergeh(tmp, tmp2); \
670 tmp4 = vec_mergel(tmp, tmp2); \
672 x = vec_ld(0, buf1); \
673 tmp = vec_mule(x, alpha); \
674 tmp2 = vec_mulo(x, alpha); \
675 tmp5 = vec_mergeh(tmp, tmp2); \
676 tmp6 = vec_mergel(tmp, tmp2); \
678 tmp3 = vec_add(tmp3, tmp5); \
679 tmp4 = vec_add(tmp4, tmp6); \
684 yuv2rgb_full_2_vsx_template(
SwsContext *
c,
const int16_t *buf[2],
685 const int16_t *ubuf[2],
const int16_t *vbuf[2],
686 const int16_t *abuf[2],
uint8_t *dest,
int dstW,
687 int yalpha,
int uvalpha,
int y,
690 const int16_t *buf0 = buf[0], *buf1 = buf[1],
691 *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
692 *vbuf0 = vbuf[0], *vbuf1 = vbuf[1],
693 *abuf0 = hasAlpha ? abuf[0] :
NULL,
694 *abuf1 = hasAlpha ? abuf[1] :
NULL;
695 const int16_t yalpha1 = 4096 - yalpha;
696 const int16_t uvalpha1 = 4096 - uvalpha;
697 vec_s16 vy, vu, vv,
A = vec_splat_s16(0);
698 vec_s32 vy32_l, vy32_r, vu32_l, vu32_r, vv32_l, vv32_r, tmp32;
699 vec_s32 R_l, R_r, G_l, G_r, B_l, B_r;
702 vec_u8 rd, bd, gd, ad, out0, out1, tmp8;
703 const vec_s16 vyalpha1 = vec_splats(yalpha1);
704 const vec_s16 vuvalpha1 = vec_splats(uvalpha1);
705 const vec_s16 vyalpha = vec_splats((int16_t) yalpha);
706 const vec_s16 vuvalpha = vec_splats((int16_t) uvalpha);
707 const vec_u16 zero16 = vec_splat_u16(0);
708 const vec_s32 y_offset = vec_splats(
c->yuv2rgb_y_offset);
709 const vec_s32 y_coeff = vec_splats(
c->yuv2rgb_y_coeff);
710 const vec_s32 y_add = vec_splats(1 << 21);
711 const vec_s32 v2r_coeff = vec_splats(
c->yuv2rgb_v2r_coeff);
712 const vec_s32 v2g_coeff = vec_splats(
c->yuv2rgb_v2g_coeff);
713 const vec_s32 u2g_coeff = vec_splats(
c->yuv2rgb_u2g_coeff);
714 const vec_s32 u2b_coeff = vec_splats(
c->yuv2rgb_u2b_coeff);
715 const vec_s32 rgbclip = vec_splats(1 << 30);
716 const vec_s32 zero32 = vec_splat_s32(0);
717 const vec_u32 shift19 = vec_splats(19U);
718 const vec_u32 shift22 = vec_splats(22U);
719 const vec_u32 shift10 = vec_splat_u32(10);
720 const vec_s32 dec128 = vec_splats(128 << 19);
721 const vec_s32 add18 = vec_splats(1 << 18);
747 for (
i = 0;
i < dstW;
i += 8) {
748 SETUP(vy, &buf0[
i], vyalpha1, &buf1[
i], vyalpha);
749 vy32_l = vec_sra(tmp3, shift10);
750 vy32_r = vec_sra(tmp4, shift10);
752 SETUP(vu, &ubuf0[
i], vuvalpha1, &ubuf1[
i], vuvalpha);
753 tmp3 = vec_sub(tmp3, dec128);
754 tmp4 = vec_sub(tmp4, dec128);
755 vu32_l = vec_sra(tmp3, shift10);
756 vu32_r = vec_sra(tmp4, shift10);
758 SETUP(vv, &vbuf0[
i], vuvalpha1, &vbuf1[
i], vuvalpha);
759 tmp3 = vec_sub(tmp3, dec128);
760 tmp4 = vec_sub(tmp4, dec128);
761 vv32_l = vec_sra(tmp3, shift10);
762 vv32_r = vec_sra(tmp4, shift10);
765 SETUP(
A, &abuf0[
i], vyalpha1, &abuf1[
i], vyalpha);
766 tmp3 = vec_add(tmp3, add18);
767 tmp4 = vec_add(tmp4, add18);
768 tmp3 = vec_sra(tmp3, shift19);
769 tmp4 = vec_sra(tmp4, shift19);
770 A = vec_packs(tmp3, tmp4);
771 ad = vec_packsu(
A, (
vec_s16) zero16);
773 ad = vec_splats((
uint8_t) 255);
776 vy32_l = vec_sub(vy32_l, y_offset);
777 vy32_r = vec_sub(vy32_r, y_offset);
778 vy32_l = vec_mul(vy32_l, y_coeff);
779 vy32_r = vec_mul(vy32_r, y_coeff);
780 vy32_l = vec_add(vy32_l, y_add);
781 vy32_r = vec_add(vy32_r, y_add);
783 R_l = vec_mul(vv32_l, v2r_coeff);
784 R_l = vec_add(R_l, vy32_l);
785 R_r = vec_mul(vv32_r, v2r_coeff);
786 R_r = vec_add(R_r, vy32_r);
787 G_l = vec_mul(vv32_l, v2g_coeff);
788 tmp32 = vec_mul(vu32_l, u2g_coeff);
789 G_l = vec_add(G_l, vy32_l);
790 G_l = vec_add(G_l, tmp32);
791 G_r = vec_mul(vv32_r, v2g_coeff);
792 tmp32 = vec_mul(vu32_r, u2g_coeff);
793 G_r = vec_add(G_r, vy32_r);
794 G_r = vec_add(G_r, tmp32);
796 B_l = vec_mul(vu32_l, u2b_coeff);
797 B_l = vec_add(B_l, vy32_l);
798 B_r = vec_mul(vu32_r, u2b_coeff);
799 B_r = vec_add(B_r, vy32_r);
806 yuv2rgb_2_vsx_template(
SwsContext *
c,
const int16_t *buf[2],
807 const int16_t *ubuf[2],
const int16_t *vbuf[2],
808 const int16_t *abuf[2],
uint8_t *dest,
int dstW,
809 int yalpha,
int uvalpha,
int y,
812 const int16_t *buf0 = buf[0], *buf1 = buf[1],
813 *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
814 *vbuf0 = vbuf[0], *vbuf1 = vbuf[1],
815 *abuf0 = hasAlpha ? abuf[0] :
NULL,
816 *abuf1 = hasAlpha ? abuf[1] :
NULL;
817 const int16_t yalpha1 = 4096 - yalpha;
818 const int16_t uvalpha1 = 4096 - uvalpha;
819 vec_s16 vy, vu, vv,
A = vec_splat_s16(0);
820 vec_s32 vy32_l, vy32_r, vu32_l, vu32_r, vv32_l, vv32_r, tmp32;
821 vec_s32 R_l, R_r, G_l, G_r, B_l, B_r, vud32_l, vud32_r, vvd32_l, vvd32_r;
824 vec_u8 rd, bd, gd, ad, out0, out1, tmp8;
825 const vec_s16 vyalpha1 = vec_splats(yalpha1);
826 const vec_s16 vuvalpha1 = vec_splats(uvalpha1);
827 const vec_s16 vyalpha = vec_splats((int16_t) yalpha);
828 const vec_s16 vuvalpha = vec_splats((int16_t) uvalpha);
829 const vec_u16 zero16 = vec_splat_u16(0);
830 const vec_s32 y_offset = vec_splats(
c->yuv2rgb_y_offset);
831 const vec_s32 y_coeff = vec_splats(
c->yuv2rgb_y_coeff);
832 const vec_s32 y_add = vec_splats(1 << 21);
833 const vec_s32 v2r_coeff = vec_splats(
c->yuv2rgb_v2r_coeff);
834 const vec_s32 v2g_coeff = vec_splats(
c->yuv2rgb_v2g_coeff);
835 const vec_s32 u2g_coeff = vec_splats(
c->yuv2rgb_u2g_coeff);
836 const vec_s32 u2b_coeff = vec_splats(
c->yuv2rgb_u2b_coeff);
837 const vec_s32 rgbclip = vec_splats(1 << 30);
838 const vec_s32 zero32 = vec_splat_s32(0);
839 const vec_u32 shift19 = vec_splats(19U);
840 const vec_u32 shift22 = vec_splats(22U);
841 const vec_u32 shift10 = vec_splat_u32(10);
842 const vec_s32 dec128 = vec_splats(128 << 19);
843 const vec_s32 add18 = vec_splats(1 << 18);
877 for (
i = 0;
i < (dstW + 1) >> 1;
i += 8) {
878 SETUP(vy, &buf0[
i * 2], vyalpha1, &buf1[
i * 2], vyalpha);
879 vy32_l = vec_sra(tmp3, shift10);
880 vy32_r = vec_sra(tmp4, shift10);
882 SETUP(vu, &ubuf0[
i], vuvalpha1, &ubuf1[
i], vuvalpha);
883 tmp3 = vec_sub(tmp3, dec128);
884 tmp4 = vec_sub(tmp4, dec128);
885 vu32_l = vec_sra(tmp3, shift10);
886 vu32_r = vec_sra(tmp4, shift10);
888 SETUP(vv, &vbuf0[
i], vuvalpha1, &vbuf1[
i], vuvalpha);
889 tmp3 = vec_sub(tmp3, dec128);
890 tmp4 = vec_sub(tmp4, dec128);
891 vv32_l = vec_sra(tmp3, shift10);
892 vv32_r = vec_sra(tmp4, shift10);
895 SETUP(
A, &abuf0[
i], vyalpha1, &abuf1[
i], vyalpha);
896 tmp3 = vec_add(tmp3, add18);
897 tmp4 = vec_add(tmp4, add18);
898 tmp3 = vec_sra(tmp3, shift19);
899 tmp4 = vec_sra(tmp4, shift19);
900 A = vec_packs(tmp3, tmp4);
901 ad = vec_packsu(
A, (
vec_s16) zero16);
903 ad = vec_splats((
uint8_t) 255);
906 vy32_l = vec_sub(vy32_l, y_offset);
907 vy32_r = vec_sub(vy32_r, y_offset);
908 vy32_l = vec_mul(vy32_l, y_coeff);
909 vy32_r = vec_mul(vy32_r, y_coeff);
910 vy32_l = vec_add(vy32_l, y_add);
911 vy32_r = vec_add(vy32_r, y_add);
914 vud32_l = vec_perm(vu32_l, vu32_l, doubleleft);
915 vud32_r = vec_perm(vu32_l, vu32_l, doubleright);
916 vvd32_l = vec_perm(vv32_l, vv32_l, doubleleft);
917 vvd32_r = vec_perm(vv32_l, vv32_l, doubleright);
919 R_l = vec_mul(vvd32_l, v2r_coeff);
920 R_l = vec_add(R_l, vy32_l);
921 R_r = vec_mul(vvd32_r, v2r_coeff);
922 R_r = vec_add(R_r, vy32_r);
923 G_l = vec_mul(vvd32_l, v2g_coeff);
924 tmp32 = vec_mul(vud32_l, u2g_coeff);
925 G_l = vec_add(G_l, vy32_l);
926 G_l = vec_add(G_l, tmp32);
927 G_r = vec_mul(vvd32_r, v2g_coeff);
928 tmp32 = vec_mul(vud32_r, u2g_coeff);
929 G_r = vec_add(G_r, vy32_r);
930 G_r = vec_add(G_r, tmp32);
932 B_l = vec_mul(vud32_l, u2b_coeff);
933 B_l = vec_add(B_l, vy32_l);
934 B_r = vec_mul(vud32_r, u2b_coeff);
935 B_r = vec_add(B_r, vy32_r);
940 SETUP(vy, &buf0[
i * 2 + 8], vyalpha1, &buf1[
i * 2 + 8], vyalpha);
941 vy32_l = vec_sra(tmp3, shift10);
942 vy32_r = vec_sra(tmp4, shift10);
944 vy32_l = vec_sub(vy32_l, y_offset);
945 vy32_r = vec_sub(vy32_r, y_offset);
946 vy32_l = vec_mul(vy32_l, y_coeff);
947 vy32_r = vec_mul(vy32_r, y_coeff);
948 vy32_l = vec_add(vy32_l, y_add);
949 vy32_r = vec_add(vy32_r, y_add);
952 vud32_l = vec_perm(vu32_r, vu32_r, doubleleft);
953 vud32_r = vec_perm(vu32_r, vu32_r, doubleright);
954 vvd32_l = vec_perm(vv32_r, vv32_r, doubleleft);
955 vvd32_r = vec_perm(vv32_r, vv32_r, doubleright);
957 R_l = vec_mul(vvd32_l, v2r_coeff);
958 R_l = vec_add(R_l, vy32_l);
959 R_r = vec_mul(vvd32_r, v2r_coeff);
960 R_r = vec_add(R_r, vy32_r);
961 G_l = vec_mul(vvd32_l, v2g_coeff);
962 tmp32 = vec_mul(vud32_l, u2g_coeff);
963 G_l = vec_add(G_l, vy32_l);
964 G_l = vec_add(G_l, tmp32);
965 G_r = vec_mul(vvd32_r, v2g_coeff);
966 tmp32 = vec_mul(vud32_r, u2g_coeff);
967 G_r = vec_add(G_r, vy32_r);
968 G_r = vec_add(G_r, tmp32);
970 B_l = vec_mul(vud32_l, u2b_coeff);
971 B_l = vec_add(B_l, vy32_l);
972 B_r = vec_mul(vud32_r, u2b_coeff);
973 B_r = vec_add(B_r, vy32_r);
982 yuv2rgb_full_1_vsx_template(
SwsContext *
c,
const int16_t *buf0,
983 const int16_t *ubuf[2],
const int16_t *vbuf[2],
984 const int16_t *abuf0,
uint8_t *dest,
int dstW,
988 const int16_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0];
989 const int16_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1];
990 vec_s16 vy, vu, vv,
A = vec_splat_s16(0), tmp16;
991 vec_s32 vy32_l, vy32_r, vu32_l, vu32_r, vv32_l, vv32_r, tmp32, tmp32_2;
992 vec_s32 R_l, R_r, G_l, G_r, B_l, B_r;
994 vec_u8 rd, bd, gd, ad, out0, out1, tmp8;
995 const vec_u16 zero16 = vec_splat_u16(0);
996 const vec_s32 y_offset = vec_splats(
c->yuv2rgb_y_offset);
997 const vec_s32 y_coeff = vec_splats(
c->yuv2rgb_y_coeff);
998 const vec_s32 y_add = vec_splats(1 << 21);
999 const vec_s32 v2r_coeff = vec_splats(
c->yuv2rgb_v2r_coeff);
1000 const vec_s32 v2g_coeff = vec_splats(
c->yuv2rgb_v2g_coeff);
1001 const vec_s32 u2g_coeff = vec_splats(
c->yuv2rgb_u2g_coeff);
1002 const vec_s32 u2b_coeff = vec_splats(
c->yuv2rgb_u2b_coeff);
1003 const vec_s32 rgbclip = vec_splats(1 << 30);
1004 const vec_s32 zero32 = vec_splat_s32(0);
1006 const vec_u32 shift22 = vec_splats(22U);
1007 const vec_u16 sub7 = vec_splats((uint16_t) (128 << 7));
1008 const vec_u16 sub8 = vec_splats((uint16_t) (128 << 8));
1009 const vec_s16 mul4 = vec_splat_s16(4);
1011 const vec_s16 add64 = vec_splat_s16(64);
1012 const vec_u16 shift7 = vec_splat_u16(7);
1013 const vec_s16 max255 = vec_splat_s16(255);
1036 for (
i = 0;
i < dstW;
i += 8) {
1037 vy = vec_ld(0, &buf0[
i]);
1038 vy32_l = vec_unpackh(vy);
1039 vy32_r = vec_unpackl(vy);
1040 vy32_l = vec_sl(vy32_l,
shift2);
1041 vy32_r = vec_sl(vy32_r,
shift2);
1043 vu = vec_ld(0, &ubuf0[
i]);
1044 vv = vec_ld(0, &vbuf0[
i]);
1045 if (uvalpha < 2048) {
1049 tmp32 = vec_mule(vu, mul4);
1050 tmp32_2 = vec_mulo(vu, mul4);
1051 vu32_l = vec_mergeh(tmp32, tmp32_2);
1052 vu32_r = vec_mergel(tmp32, tmp32_2);
1053 tmp32 = vec_mule(vv, mul4);
1054 tmp32_2 = vec_mulo(vv, mul4);
1055 vv32_l = vec_mergeh(tmp32, tmp32_2);
1056 vv32_r = vec_mergel(tmp32, tmp32_2);
1058 tmp16 = vec_ld(0, &ubuf1[
i]);
1059 vu = vec_add(vu, tmp16);
1061 tmp16 = vec_ld(0, &vbuf1[
i]);
1062 vv = vec_add(vv, tmp16);
1065 vu32_l = vec_mule(vu,
mul8);
1066 vu32_r = vec_mulo(vu,
mul8);
1067 vv32_l = vec_mule(vv,
mul8);
1068 vv32_r = vec_mulo(vv,
mul8);
1072 A = vec_ld(0, &abuf0[
i]);
1073 A = vec_add(
A, add64);
1074 A = vec_sr(
A, shift7);
1075 A = vec_max(
A, max255);
1076 ad = vec_packsu(
A, (
vec_s16) zero16);
1078 ad = vec_splats((
uint8_t) 255);
1081 vy32_l = vec_sub(vy32_l, y_offset);
1082 vy32_r = vec_sub(vy32_r, y_offset);
1083 vy32_l = vec_mul(vy32_l, y_coeff);
1084 vy32_r = vec_mul(vy32_r, y_coeff);
1085 vy32_l = vec_add(vy32_l, y_add);
1086 vy32_r = vec_add(vy32_r, y_add);
1088 R_l = vec_mul(vv32_l, v2r_coeff);
1089 R_l = vec_add(R_l, vy32_l);
1090 R_r = vec_mul(vv32_r, v2r_coeff);
1091 R_r = vec_add(R_r, vy32_r);
1092 G_l = vec_mul(vv32_l, v2g_coeff);
1093 tmp32 = vec_mul(vu32_l, u2g_coeff);
1094 G_l = vec_add(G_l, vy32_l);
1095 G_l = vec_add(G_l, tmp32);
1096 G_r = vec_mul(vv32_r, v2g_coeff);
1097 tmp32 = vec_mul(vu32_r, u2g_coeff);
1098 G_r = vec_add(G_r, vy32_r);
1099 G_r = vec_add(G_r, tmp32);
1101 B_l = vec_mul(vu32_l, u2b_coeff);
1102 B_l = vec_add(B_l, vy32_l);
1103 B_r = vec_mul(vu32_r, u2b_coeff);
1104 B_r = vec_add(B_r, vy32_r);
1111 yuv2rgb_1_vsx_template(
SwsContext *
c,
const int16_t *buf0,
1112 const int16_t *ubuf[2],
const int16_t *vbuf[2],
1113 const int16_t *abuf0,
uint8_t *dest,
int dstW,
1117 const int16_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0];
1118 const int16_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1];
1119 vec_s16 vy, vu, vv,
A = vec_splat_s16(0), tmp16;
1120 vec_s32 vy32_l, vy32_r, vu32_l, vu32_r, vv32_l, vv32_r, tmp32, tmp32_2;
1121 vec_s32 vud32_l, vud32_r, vvd32_l, vvd32_r;
1122 vec_s32 R_l, R_r, G_l, G_r, B_l, B_r;
1124 vec_u8 rd, bd, gd, ad, out0, out1, tmp8;
1125 const vec_u16 zero16 = vec_splat_u16(0);
1126 const vec_s32 y_offset = vec_splats(
c->yuv2rgb_y_offset);
1127 const vec_s32 y_coeff = vec_splats(
c->yuv2rgb_y_coeff);
1128 const vec_s32 y_add = vec_splats(1 << 21);
1129 const vec_s32 v2r_coeff = vec_splats(
c->yuv2rgb_v2r_coeff);
1130 const vec_s32 v2g_coeff = vec_splats(
c->yuv2rgb_v2g_coeff);
1131 const vec_s32 u2g_coeff = vec_splats(
c->yuv2rgb_u2g_coeff);
1132 const vec_s32 u2b_coeff = vec_splats(
c->yuv2rgb_u2b_coeff);
1133 const vec_s32 rgbclip = vec_splats(1 << 30);
1134 const vec_s32 zero32 = vec_splat_s32(0);
1136 const vec_u32 shift22 = vec_splats(22U);
1137 const vec_u16 sub7 = vec_splats((uint16_t) (128 << 7));
1138 const vec_u16 sub8 = vec_splats((uint16_t) (128 << 8));
1139 const vec_s16 mul4 = vec_splat_s16(4);
1141 const vec_s16 add64 = vec_splat_s16(64);
1142 const vec_u16 shift7 = vec_splat_u16(7);
1143 const vec_s16 max255 = vec_splat_s16(255);
1174 for (
i = 0;
i < (dstW + 1) >> 1;
i += 8) {
1175 vy = vec_ld(0, &buf0[
i * 2]);
1176 vy32_l = vec_unpackh(vy);
1177 vy32_r = vec_unpackl(vy);
1178 vy32_l = vec_sl(vy32_l,
shift2);
1179 vy32_r = vec_sl(vy32_r,
shift2);
1181 vu = vec_ld(0, &ubuf0[
i]);
1182 vv = vec_ld(0, &vbuf0[
i]);
1183 if (uvalpha < 2048) {
1187 tmp32 = vec_mule(vu, mul4);
1188 tmp32_2 = vec_mulo(vu, mul4);
1189 vu32_l = vec_mergeh(tmp32, tmp32_2);
1190 vu32_r = vec_mergel(tmp32, tmp32_2);
1191 tmp32 = vec_mule(vv, mul4);
1192 tmp32_2 = vec_mulo(vv, mul4);
1193 vv32_l = vec_mergeh(tmp32, tmp32_2);
1194 vv32_r = vec_mergel(tmp32, tmp32_2);
1196 tmp16 = vec_ld(0, &ubuf1[
i]);
1197 vu = vec_add(vu, tmp16);
1199 tmp16 = vec_ld(0, &vbuf1[
i]);
1200 vv = vec_add(vv, tmp16);
1203 vu32_l = vec_mule(vu,
mul8);
1204 vu32_r = vec_mulo(vu,
mul8);
1205 vv32_l = vec_mule(vv,
mul8);
1206 vv32_r = vec_mulo(vv,
mul8);
1210 A = vec_ld(0, &abuf0[
i]);
1211 A = vec_add(
A, add64);
1212 A = vec_sr(
A, shift7);
1213 A = vec_max(
A, max255);
1214 ad = vec_packsu(
A, (
vec_s16) zero16);
1216 ad = vec_splats((
uint8_t) 255);
1219 vy32_l = vec_sub(vy32_l, y_offset);
1220 vy32_r = vec_sub(vy32_r, y_offset);
1221 vy32_l = vec_mul(vy32_l, y_coeff);
1222 vy32_r = vec_mul(vy32_r, y_coeff);
1223 vy32_l = vec_add(vy32_l, y_add);
1224 vy32_r = vec_add(vy32_r, y_add);
1227 vud32_l = vec_perm(vu32_l, vu32_l, doubleleft);
1228 vud32_r = vec_perm(vu32_l, vu32_l, doubleright);
1229 vvd32_l = vec_perm(vv32_l, vv32_l, doubleleft);
1230 vvd32_r = vec_perm(vv32_l, vv32_l, doubleright);
1232 R_l = vec_mul(vvd32_l, v2r_coeff);
1233 R_l = vec_add(R_l, vy32_l);
1234 R_r = vec_mul(vvd32_r, v2r_coeff);
1235 R_r = vec_add(R_r, vy32_r);
1236 G_l = vec_mul(vvd32_l, v2g_coeff);
1237 tmp32 = vec_mul(vud32_l, u2g_coeff);
1238 G_l = vec_add(G_l, vy32_l);
1239 G_l = vec_add(G_l, tmp32);
1240 G_r = vec_mul(vvd32_r, v2g_coeff);
1241 tmp32 = vec_mul(vud32_r, u2g_coeff);
1242 G_r = vec_add(G_r, vy32_r);
1243 G_r = vec_add(G_r, tmp32);
1245 B_l = vec_mul(vud32_l, u2b_coeff);
1246 B_l = vec_add(B_l, vy32_l);
1247 B_r = vec_mul(vud32_r, u2b_coeff);
1248 B_r = vec_add(B_r, vy32_r);
1253 vy = vec_ld(16, &buf0[
i * 2]);
1254 vy32_l = vec_unpackh(vy);
1255 vy32_r = vec_unpackl(vy);
1256 vy32_l = vec_sl(vy32_l,
shift2);
1257 vy32_r = vec_sl(vy32_r,
shift2);
1259 vy32_l = vec_sub(vy32_l, y_offset);
1260 vy32_r = vec_sub(vy32_r, y_offset);
1261 vy32_l = vec_mul(vy32_l, y_coeff);
1262 vy32_r = vec_mul(vy32_r, y_coeff);
1263 vy32_l = vec_add(vy32_l, y_add);
1264 vy32_r = vec_add(vy32_r, y_add);
1267 vud32_l = vec_perm(vu32_r, vu32_r, doubleleft);
1268 vud32_r = vec_perm(vu32_r, vu32_r, doubleright);
1269 vvd32_l = vec_perm(vv32_r, vv32_r, doubleleft);
1270 vvd32_r = vec_perm(vv32_r, vv32_r, doubleright);
1272 R_l = vec_mul(vvd32_l, v2r_coeff);
1273 R_l = vec_add(R_l, vy32_l);
1274 R_r = vec_mul(vvd32_r, v2r_coeff);
1275 R_r = vec_add(R_r, vy32_r);
1276 G_l = vec_mul(vvd32_l, v2g_coeff);
1277 tmp32 = vec_mul(vud32_l, u2g_coeff);
1278 G_l = vec_add(G_l, vy32_l);
1279 G_l = vec_add(G_l, tmp32);
1280 G_r = vec_mul(vvd32_r, v2g_coeff);
1281 tmp32 = vec_mul(vud32_r, u2g_coeff);
1282 G_r = vec_add(G_r, vy32_r);
1283 G_r = vec_add(G_r, tmp32);
1285 B_l = vec_mul(vud32_l, u2b_coeff);
1286 B_l = vec_add(B_l, vy32_l);
1287 B_r = vec_mul(vud32_r, u2b_coeff);
1288 B_r = vec_add(B_r, vy32_r);
1296 #define YUV2RGBWRAPPERX(name, base, ext, fmt, hasAlpha) \
1297 static void name ## ext ## _X_vsx(SwsContext *c, const int16_t *lumFilter, \
1298 const int16_t **lumSrc, int lumFilterSize, \
1299 const int16_t *chrFilter, const int16_t **chrUSrc, \
1300 const int16_t **chrVSrc, int chrFilterSize, \
1301 const int16_t **alpSrc, uint8_t *dest, int dstW, \
1304 name ## base ## _X_vsx_template(c, lumFilter, lumSrc, lumFilterSize, \
1305 chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
1306 alpSrc, dest, dstW, y, fmt, hasAlpha); \
1309 #define YUV2RGBWRAPPERX2(name, base, ext, fmt, hasAlpha) \
1310 static void name ## ext ## _2_vsx(SwsContext *c, const int16_t *buf[2], \
1311 const int16_t *ubuf[2], const int16_t *vbuf[2], \
1312 const int16_t *abuf[2], uint8_t *dest, int dstW, \
1313 int yalpha, int uvalpha, int y) \
1315 name ## base ## _2_vsx_template(c, buf, ubuf, vbuf, abuf, \
1316 dest, dstW, yalpha, uvalpha, y, fmt, hasAlpha); \
1319 #define YUV2RGBWRAPPER(name, base, ext, fmt, hasAlpha) \
1320 static void name ## ext ## _1_vsx(SwsContext *c, const int16_t *buf0, \
1321 const int16_t *ubuf[2], const int16_t *vbuf[2], \
1322 const int16_t *abuf0, uint8_t *dest, int dstW, \
1323 int uvalpha, int y) \
1325 name ## base ## _1_vsx_template(c, buf0, ubuf, vbuf, abuf0, dest, \
1326 dstW, uvalpha, y, fmt, hasAlpha); \
1376 0x0, 0x10, 0x1, 0x18,
1377 0x2, 0x11, 0x3, 0x19,
1378 0x4, 0x12, 0x5, 0x1a,
1379 0x6, 0x13, 0x7, 0x1b };
1381 0x8, 0x14, 0x9, 0x1c,
1382 0xa, 0x15, 0xb, 0x1d,
1383 0xc, 0x16, 0xd, 0x1e,
1384 0xe, 0x17, 0xf, 0x1f };
1386 0x0, 0x18, 0x1, 0x10,
1387 0x2, 0x19, 0x3, 0x11,
1388 0x4, 0x1a, 0x5, 0x12,
1389 0x6, 0x1b, 0x7, 0x13 };
1391 0x8, 0x1c, 0x9, 0x14,
1392 0xa, 0x1d, 0xb, 0x15,
1393 0xc, 0x1e, 0xd, 0x16,
1394 0xe, 0x1f, 0xf, 0x17 };
1396 0x10, 0x0, 0x18, 0x1,
1397 0x11, 0x2, 0x19, 0x3,
1398 0x12, 0x4, 0x1a, 0x5,
1399 0x13, 0x6, 0x1b, 0x7 };
1401 0x14, 0x8, 0x1c, 0x9,
1402 0x15, 0xa, 0x1d, 0xb,
1403 0x16, 0xc, 0x1e, 0xd,
1404 0x17, 0xe, 0x1f, 0xf };
1406 vd1 = vec_packsu(vy1, vy2);
1407 vd2 = vec_packsu(vu, vv);
1411 tmp = vec_perm(vd1, vd2, yuyv1);
1412 vec_st(
tmp, 0, dest);
1413 tmp = vec_perm(vd1, vd2, yuyv2);
1414 vec_st(
tmp, 16, dest);
1417 tmp = vec_perm(vd1, vd2, yvyu1);
1418 vec_st(
tmp, 0, dest);
1419 tmp = vec_perm(vd1, vd2, yvyu2);
1420 vec_st(
tmp, 16, dest);
1423 tmp = vec_perm(vd1, vd2, uyvy1);
1424 vec_st(
tmp, 0, dest);
1425 tmp = vec_perm(vd1, vd2, uyvy2);
1426 vec_st(
tmp, 16, dest);
1432 yuv2422_X_vsx_template(
SwsContext *
c,
const int16_t *lumFilter,
1433 const int16_t **lumSrc,
int lumFilterSize,
1434 const int16_t *chrFilter,
const int16_t **chrUSrc,
1435 const int16_t **chrVSrc,
int chrFilterSize,
1436 const int16_t **alpSrc,
uint8_t *dest,
int dstW,
1441 vec_s32 vy32[4], vu32[2], vv32[2],
tmp, tmp2, tmp3, tmp4;
1443 const vec_s32 start = vec_splats(1 << 18);
1444 const vec_u32 shift19 = vec_splats(19U);
1446 for (
i = 0;
i < lumFilterSize;
i++)
1447 vlumFilter[
i] = vec_splats(lumFilter[
i]);
1448 for (
i = 0;
i < chrFilterSize;
i++)
1449 vchrFilter[
i] = vec_splats(chrFilter[
i]);
1451 for (
i = 0;
i < ((dstW + 1) >> 1);
i += 8) {
1461 for (j = 0; j < lumFilterSize; j++) {
1462 vv = vec_ld(0, &lumSrc[j][
i * 2]);
1463 tmp = vec_mule(vv, vlumFilter[j]);
1464 tmp2 = vec_mulo(vv, vlumFilter[j]);
1465 tmp3 = vec_mergeh(
tmp, tmp2);
1466 tmp4 = vec_mergel(
tmp, tmp2);
1468 vy32[0] = vec_adds(vy32[0], tmp3);
1469 vy32[1] = vec_adds(vy32[1], tmp4);
1471 vv = vec_ld(0, &lumSrc[j][(
i + 4) * 2]);
1472 tmp = vec_mule(vv, vlumFilter[j]);
1473 tmp2 = vec_mulo(vv, vlumFilter[j]);
1474 tmp3 = vec_mergeh(
tmp, tmp2);
1475 tmp4 = vec_mergel(
tmp, tmp2);
1477 vy32[2] = vec_adds(vy32[2], tmp3);
1478 vy32[3] = vec_adds(vy32[3], tmp4);
1481 for (j = 0; j < chrFilterSize; j++) {
1482 vv = vec_ld(0, &chrUSrc[j][
i]);
1483 tmp = vec_mule(vv, vchrFilter[j]);
1484 tmp2 = vec_mulo(vv, vchrFilter[j]);
1485 tmp3 = vec_mergeh(
tmp, tmp2);
1486 tmp4 = vec_mergel(
tmp, tmp2);
1488 vu32[0] = vec_adds(vu32[0], tmp3);
1489 vu32[1] = vec_adds(vu32[1], tmp4);
1491 vv = vec_ld(0, &chrVSrc[j][
i]);
1492 tmp = vec_mule(vv, vchrFilter[j]);
1493 tmp2 = vec_mulo(vv, vchrFilter[j]);
1494 tmp3 = vec_mergeh(
tmp, tmp2);
1495 tmp4 = vec_mergel(
tmp, tmp2);
1497 vv32[0] = vec_adds(vv32[0], tmp3);
1498 vv32[1] = vec_adds(vv32[1], tmp4);
1501 for (j = 0; j < 4; j++) {
1502 vy32[j] = vec_sra(vy32[j], shift19);
1504 for (j = 0; j < 2; j++) {
1505 vu32[j] = vec_sra(vu32[j], shift19);
1506 vv32[j] = vec_sra(vv32[j], shift19);
1509 vy1 = vec_packs(vy32[0], vy32[1]);
1510 vy2 = vec_packs(vy32[2], vy32[3]);
1511 vu = vec_packs(vu32[0], vu32[1]);
1512 vv = vec_packs(vv32[0], vv32[1]);
1514 write422(vy1, vy2, vu, vv, &dest[
i * 4], target);
1518 #define SETUP(x, buf0, buf1, alpha) { \
1519 x = vec_ld(0, buf0); \
1520 tmp = vec_mule(x, alpha); \
1521 tmp2 = vec_mulo(x, alpha); \
1522 tmp3 = vec_mergeh(tmp, tmp2); \
1523 tmp4 = vec_mergel(tmp, tmp2); \
1525 x = vec_ld(0, buf1); \
1526 tmp = vec_mule(x, alpha); \
1527 tmp2 = vec_mulo(x, alpha); \
1528 tmp5 = vec_mergeh(tmp, tmp2); \
1529 tmp6 = vec_mergel(tmp, tmp2); \
1531 tmp3 = vec_add(tmp3, tmp5); \
1532 tmp4 = vec_add(tmp4, tmp6); \
1534 tmp3 = vec_sra(tmp3, shift19); \
1535 tmp4 = vec_sra(tmp4, shift19); \
1536 x = vec_packs(tmp3, tmp4); \
1540 yuv2422_2_vsx_template(
SwsContext *
c,
const int16_t *buf[2],
1541 const int16_t *ubuf[2],
const int16_t *vbuf[2],
1542 const int16_t *abuf[2],
uint8_t *dest,
int dstW,
1543 int yalpha,
int uvalpha,
int y,
1546 const int16_t *buf0 = buf[0], *buf1 = buf[1],
1547 *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
1548 *vbuf0 = vbuf[0], *vbuf1 = vbuf[1];
1549 const int16_t yalpha1 = 4096 - yalpha;
1550 const int16_t uvalpha1 = 4096 - uvalpha;
1553 const vec_s16 vyalpha1 = vec_splats(yalpha1);
1554 const vec_s16 vuvalpha1 = vec_splats(uvalpha1);
1555 const vec_u32 shift19 = vec_splats(19U);
1560 for (
i = 0;
i < ((dstW + 1) >> 1);
i += 8) {
1562 SETUP(vy1, &buf0[
i * 2], &buf1[
i * 2], vyalpha1)
1563 SETUP(vy2, &buf0[(
i + 4) * 2], &buf1[(
i + 4) * 2], vyalpha1)
1564 SETUP(vu, &ubuf0[
i], &ubuf1[
i], vuvalpha1)
1565 SETUP(vv, &vbuf0[
i], &vbuf1[
i], vuvalpha1)
1567 write422(vy1, vy2, vu, vv, &dest[
i * 4], target);
1574 yuv2422_1_vsx_template(
SwsContext *
c,
const int16_t *buf0,
1575 const int16_t *ubuf[2],
const int16_t *vbuf[2],
1576 const int16_t *abuf0,
uint8_t *dest,
int dstW,
1579 const int16_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0];
1581 const vec_s16 add64 = vec_splats((int16_t) 64);
1582 const vec_s16 add128 = vec_splats((int16_t) 128);
1583 const vec_u16 shift7 = vec_splat_u16(7);
1584 const vec_u16 shift8 = vec_splat_u16(8);
1587 if (uvalpha < 2048) {
1588 for (
i = 0;
i < ((dstW + 1) >> 1);
i += 8) {
1589 vy1 = vec_ld(0, &buf0[
i * 2]);
1590 vy2 = vec_ld(0, &buf0[(
i + 4) * 2]);
1591 vu = vec_ld(0, &ubuf0[
i]);
1592 vv = vec_ld(0, &vbuf0[
i]);
1594 vy1 = vec_add(vy1, add64);
1595 vy2 = vec_add(vy2, add64);
1596 vu = vec_add(vu, add64);
1597 vv = vec_add(vv, add64);
1599 vy1 = vec_sra(vy1, shift7);
1600 vy2 = vec_sra(vy2, shift7);
1601 vu = vec_sra(vu, shift7);
1602 vv = vec_sra(vv, shift7);
1604 write422(vy1, vy2, vu, vv, &dest[
i * 4], target);
1607 const int16_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1];
1608 for (
i = 0;
i < ((dstW + 1) >> 1);
i += 8) {
1609 vy1 = vec_ld(0, &buf0[
i * 2]);
1610 vy2 = vec_ld(0, &buf0[(
i + 4) * 2]);
1611 vu = vec_ld(0, &ubuf0[
i]);
1612 tmp = vec_ld(0, &ubuf1[
i]);
1613 vu = vec_adds(vu,
tmp);
1614 vv = vec_ld(0, &vbuf0[
i]);
1615 tmp = vec_ld(0, &vbuf1[
i]);
1616 vv = vec_adds(vv,
tmp);
1618 vy1 = vec_add(vy1, add64);
1619 vy2 = vec_add(vy2, add64);
1620 vu = vec_adds(vu, add128);
1621 vv = vec_adds(vv, add128);
1623 vy1 = vec_sra(vy1, shift7);
1624 vy2 = vec_sra(vy2, shift7);
1625 vu = vec_sra(vu, shift8);
1626 vv = vec_sra(vv, shift8);
1628 write422(vy1, vy2, vu, vv, &dest[
i * 4], target);
1633 #define YUV2PACKEDWRAPPERX(name, base, ext, fmt) \
1634 static void name ## ext ## _X_vsx(SwsContext *c, const int16_t *lumFilter, \
1635 const int16_t **lumSrc, int lumFilterSize, \
1636 const int16_t *chrFilter, const int16_t **chrUSrc, \
1637 const int16_t **chrVSrc, int chrFilterSize, \
1638 const int16_t **alpSrc, uint8_t *dest, int dstW, \
1641 name ## base ## _X_vsx_template(c, lumFilter, lumSrc, lumFilterSize, \
1642 chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
1643 alpSrc, dest, dstW, y, fmt); \
1646 #define YUV2PACKEDWRAPPER2(name, base, ext, fmt) \
1647 YUV2PACKEDWRAPPERX(name, base, ext, fmt) \
1648 static void name ## ext ## _2_vsx(SwsContext *c, const int16_t *buf[2], \
1649 const int16_t *ubuf[2], const int16_t *vbuf[2], \
1650 const int16_t *abuf[2], uint8_t *dest, int dstW, \
1651 int yalpha, int uvalpha, int y) \
1653 name ## base ## _2_vsx_template(c, buf, ubuf, vbuf, abuf, \
1654 dest, dstW, yalpha, uvalpha, y, fmt); \
1657 #define YUV2PACKEDWRAPPER(name, base, ext, fmt) \
1658 YUV2PACKEDWRAPPER2(name, base, ext, fmt) \
1659 static void name ## ext ## _1_vsx(SwsContext *c, const int16_t *buf0, \
1660 const int16_t *ubuf[2], const int16_t *vbuf[2], \
1661 const int16_t *abuf0, uint8_t *dest, int dstW, \
1662 int uvalpha, int y) \
1664 name ## base ## _1_vsx_template(c, buf0, ubuf, vbuf, \
1665 abuf0, dest, dstW, uvalpha, \
1673 static void hyscale_fast_vsx(
SwsContext *
c, int16_t *dst,
int dstWidth,
1677 unsigned int xpos = 0, xx;
1680 vec_s16 vtmp, vtmp2, vtmp3, vtmp4;
1681 vec_u16 vd_l, vd_r, vcoord16[2];
1699 const vec_u32 vshift16 = vec_splats((uint32_t) 16);
1700 const vec_u16 vshift9 = vec_splat_u16(9);
1701 const vec_u8 vzero = vec_splat_u8(0);
1702 const vec_u16 vshift = vec_splat_u16(7);
1704 for (
i = 0;
i < dstWidth;
i += 16) {
1705 vcoord16[0] = vec_splats((uint16_t) xpos);
1706 vcoord16[1] = vec_splats((uint16_t) (xpos + xInc * 8));
1708 vcoord16[0] = vec_add(vcoord16[0], vadd16);
1709 vcoord16[1] = vec_add(vcoord16[1], vadd16);
1711 vcoord16[0] = vec_sr(vcoord16[0], vshift9);
1712 vcoord16[1] = vec_sr(vcoord16[1], vshift9);
1713 valpha = (
vec_s8) vec_pack(vcoord16[0], vcoord16[1]);
1716 vin = vec_vsx_ld(0, &
src[xx]);
1718 vcoord[0] = vec_splats(xpos & 0xffff);
1719 vcoord[1] = vec_splats((xpos & 0xffff) + xInc * 4);
1720 vcoord[2] = vec_splats((xpos & 0xffff) + xInc * 8);
1721 vcoord[3] = vec_splats((xpos & 0xffff) + xInc * 12);
1723 vcoord[0] = vec_add(vcoord[0], vadd);
1724 vcoord[1] = vec_add(vcoord[1], vadd);
1725 vcoord[2] = vec_add(vcoord[2], vadd);
1726 vcoord[3] = vec_add(vcoord[3], vadd);
1728 vcoord[0] = vec_sr(vcoord[0], vshift16);
1729 vcoord[1] = vec_sr(vcoord[1], vshift16);
1730 vcoord[2] = vec_sr(vcoord[2], vshift16);
1731 vcoord[3] = vec_sr(vcoord[3], vshift16);
1733 vcoord16[0] = vec_pack(vcoord[0], vcoord[1]);
1734 vcoord16[1] = vec_pack(vcoord[2], vcoord[3]);
1735 vperm = vec_pack(vcoord16[0], vcoord16[1]);
1737 vin = vec_perm(vin, vin, vperm);
1739 vin2 = vec_vsx_ld(1, &
src[xx]);
1740 vin2 = vec_perm(vin2, vin2, vperm);
1742 vmul = (
vec_s8) vec_sub(vin2, vin);
1743 vtmp = vec_mule(vmul, valpha);
1744 vtmp2 = vec_mulo(vmul, valpha);
1745 vtmp3 = vec_mergeh(vtmp, vtmp2);
1746 vtmp4 = vec_mergel(vtmp, vtmp2);
1748 vd_l = (
vec_u16) vec_mergeh(vin, vzero);
1749 vd_r = (
vec_u16) vec_mergel(vin, vzero);
1750 vd_l = vec_sl(vd_l, vshift);
1751 vd_r = vec_sl(vd_r, vshift);
1753 vd_l = vec_add(vd_l, (
vec_u16) vtmp3);
1754 vd_r = vec_add(vd_r, (
vec_u16) vtmp4);
1756 vec_st((
vec_s16) vd_l, 0, &dst[
i]);
1757 vec_st((
vec_s16) vd_r, 0, &dst[
i + 8]);
1761 for (
i=dstWidth-1; (
i*xInc)>>16 >=srcW-1;
i--)
1762 dst[
i] =
src[srcW-1]*128;
1765 #define HCSCALE(in, out) \
1766 vin = vec_vsx_ld(0, &in[xx]); \
1767 vin = vec_perm(vin, vin, vperm); \
1769 vin2 = vec_vsx_ld(1, &in[xx]); \
1770 vin2 = vec_perm(vin2, vin2, vperm); \
1772 vtmp = vec_mule(vin, valphaxor); \
1773 vtmp2 = vec_mulo(vin, valphaxor); \
1774 vtmp3 = vec_mergeh(vtmp, vtmp2); \
1775 vtmp4 = vec_mergel(vtmp, vtmp2); \
1777 vtmp = vec_mule(vin2, valpha); \
1778 vtmp2 = vec_mulo(vin2, valpha); \
1779 vd_l = vec_mergeh(vtmp, vtmp2); \
1780 vd_r = vec_mergel(vtmp, vtmp2); \
1782 vd_l = vec_add(vd_l, vtmp3); \
1783 vd_r = vec_add(vd_r, vtmp4); \
1785 vec_st((vec_s16) vd_l, 0, &out[i]); \
1786 vec_st((vec_s16) vd_r, 0, &out[i + 8])
1788 static void hcscale_fast_vsx(
SwsContext *
c, int16_t *dst1, int16_t *dst2,
1790 const uint8_t *src2,
int srcW,
int xInc)
1793 unsigned int xpos = 0, xx;
1795 vec_u8 valpha, valphaxor;
1796 vec_u16 vtmp, vtmp2, vtmp3, vtmp4;
1797 vec_u16 vd_l, vd_r, vcoord16[2];
1816 const vec_u32 vshift16 = vec_splats((uint32_t) 16);
1817 const vec_u16 vshift9 = vec_splat_u16(9);
1819 for (
i = 0;
i < dstWidth;
i += 16) {
1820 vcoord16[0] = vec_splats((uint16_t) xpos);
1821 vcoord16[1] = vec_splats((uint16_t) (xpos + xInc * 8));
1823 vcoord16[0] = vec_add(vcoord16[0], vadd16);
1824 vcoord16[1] = vec_add(vcoord16[1], vadd16);
1826 vcoord16[0] = vec_sr(vcoord16[0], vshift9);
1827 vcoord16[1] = vec_sr(vcoord16[1], vshift9);
1828 valpha = vec_pack(vcoord16[0], vcoord16[1]);
1829 valphaxor = vec_xor(valpha, vxor);
1833 vcoord[0] = vec_splats(xpos & 0xffff);
1834 vcoord[1] = vec_splats((xpos & 0xffff) + xInc * 4);
1835 vcoord[2] = vec_splats((xpos & 0xffff) + xInc * 8);
1836 vcoord[3] = vec_splats((xpos & 0xffff) + xInc * 12);
1838 vcoord[0] = vec_add(vcoord[0], vadd);
1839 vcoord[1] = vec_add(vcoord[1], vadd);
1840 vcoord[2] = vec_add(vcoord[2], vadd);
1841 vcoord[3] = vec_add(vcoord[3], vadd);
1843 vcoord[0] = vec_sr(vcoord[0], vshift16);
1844 vcoord[1] = vec_sr(vcoord[1], vshift16);
1845 vcoord[2] = vec_sr(vcoord[2], vshift16);
1846 vcoord[3] = vec_sr(vcoord[3], vshift16);
1848 vcoord16[0] = vec_pack(vcoord[0], vcoord[1]);
1849 vcoord16[1] = vec_pack(vcoord[2], vcoord[3]);
1850 vperm = vec_pack(vcoord16[0], vcoord16[1]);
1852 HCSCALE(
src1, dst1);
1853 HCSCALE(src2, dst2);
1857 for (
i=dstWidth-1; (
i*xInc)>>16 >=srcW-1;
i--) {
1858 dst1[
i] =
src1[srcW-1]*128;
1859 dst2[
i] = src2[srcW-1]*128;
1865 static void hScale8To19_vsx(
SwsContext *
c, int16_t *_dst,
int dstW,
1867 const int32_t *filterPos,
int filterSize)
1874 const vec_u8 vzero = vec_splat_u8(0);
1875 const vec_u8 vunusedtab[8] = {
1876 (
vec_u8) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
1877 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf},
1878 (
vec_u8) {0x0, 0x1, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
1879 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10},
1880 (
vec_u8) {0x0, 0x1, 0x2, 0x3, 0x10, 0x10, 0x10, 0x10,
1881 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10},
1882 (
vec_u8) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x10, 0x10,
1883 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10},
1884 (
vec_u8) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
1885 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10},
1886 (
vec_u8) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
1887 0x8, 0x9, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10},
1888 (
vec_u8) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
1889 0x8, 0x9, 0xa, 0xb, 0x10, 0x10, 0x10, 0x10},
1890 (
vec_u8) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
1891 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0x10, 0x10},
1893 const vec_u8 vunused = vunusedtab[filterSize % 8];
1895 if (filterSize == 1) {
1896 for (
i = 0;
i < dstW;
i++) {
1897 int srcPos = filterPos[
i];
1899 for (j = 0; j < filterSize; j++) {
1902 dst[
i] =
FFMIN(
val >> 3, (1 << 19) - 1);
1905 for (
i = 0;
i < dstW;
i++) {
1906 const int srcPos = filterPos[
i];
1907 vout = vec_splat_s32(0);
1908 for (j = 0; j < filterSize; j += 8) {
1909 vin8 = vec_vsx_ld(0, &
src[srcPos + j]);
1910 vin = (
vec_s16) vec_mergeh(vin8, vzero);
1911 if (j + 8 > filterSize)
1912 vin = vec_perm(vin, (
vec_s16) vzero, vunused);
1914 vfilter = vec_vsx_ld(0, &
filter[filterSize *
i + j]);
1915 vout = vec_msums(vin, vfilter, vout);
1917 vout = vec_sums(vout, (
vec_s32) vzero);
1918 dst[
i] =
FFMIN(vout[3] >> 3, (1 << 19) - 1);
1923 static void hScale16To19_vsx(
SwsContext *
c, int16_t *_dst,
int dstW,
1925 const int32_t *filterPos,
int filterSize)
1930 const uint16_t *
src = (
const uint16_t *) _src;
1931 int bits =
desc->comp[0].depth - 1;
1934 vec_s32 vout, vtmp, vtmp2, vfilter32_l, vfilter32_r;
1935 const vec_u8 vzero = vec_splat_u8(0);
1936 const vec_u8 vunusedtab[8] = {
1937 (
vec_u8) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
1938 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf},
1939 (
vec_u8) {0x0, 0x1, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
1940 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10},
1941 (
vec_u8) {0x0, 0x1, 0x2, 0x3, 0x10, 0x10, 0x10, 0x10,
1942 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10},
1943 (
vec_u8) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x10, 0x10,
1944 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10},
1945 (
vec_u8) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
1946 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10},
1947 (
vec_u8) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
1948 0x8, 0x9, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10},
1949 (
vec_u8) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
1950 0x8, 0x9, 0xa, 0xb, 0x10, 0x10, 0x10, 0x10},
1951 (
vec_u8) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
1952 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0x10, 0x10},
1954 const vec_u8 vunused = vunusedtab[filterSize % 8];
1962 if (filterSize == 1) {
1963 for (
i = 0;
i < dstW;
i++) {
1964 int srcPos = filterPos[
i];
1967 for (j = 0; j < filterSize; j++) {
1971 dst[
i] =
FFMIN(
val >> sh, (1 << 19) - 1);
1974 for (
i = 0;
i < dstW;
i++) {
1975 const int srcPos = filterPos[
i];
1976 vout = vec_splat_s32(0);
1977 for (j = 0; j < filterSize; j += 8) {
1978 vin = (
vec_s16) vec_vsx_ld(0, &
src[srcPos + j]);
1979 if (j + 8 > filterSize)
1980 vin = vec_perm(vin, (
vec_s16) vzero, vunused);
1982 vfilter = vec_vsx_ld(0, &
filter[filterSize *
i + j]);
1983 vfilter32_l = vec_unpackh(vfilter);
1984 vfilter32_r = vec_unpackl(vfilter);
1989 vtmp = vec_mul(vtmp, vfilter32_l);
1990 vtmp2 = vec_mul(vtmp2, vfilter32_r);
1992 vout = vec_adds(vout, vtmp);
1993 vout = vec_adds(vout, vtmp2);
1995 vout = vec_sums(vout, (
vec_s32) vzero);
1996 dst[
i] =
FFMIN(vout[3] >> sh, (1 << 19) - 1);
2001 static void hScale16To15_vsx(
SwsContext *
c, int16_t *dst,
int dstW,
2003 const int32_t *filterPos,
int filterSize)
2007 const uint16_t *
src = (
const uint16_t *) _src;
2008 int sh =
desc->comp[0].depth - 1;
2010 vec_s32 vout, vtmp, vtmp2, vfilter32_l, vfilter32_r;
2011 const vec_u8 vzero = vec_splat_u8(0);
2012 const vec_u8 vunusedtab[8] = {
2013 (
vec_u8) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
2014 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf},
2015 (
vec_u8) {0x0, 0x1, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
2016 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10},
2017 (
vec_u8) {0x0, 0x1, 0x2, 0x3, 0x10, 0x10, 0x10, 0x10,
2018 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10},
2019 (
vec_u8) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x10, 0x10,
2020 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10},
2021 (
vec_u8) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
2022 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10},
2023 (
vec_u8) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
2024 0x8, 0x9, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10},
2025 (
vec_u8) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
2026 0x8, 0x9, 0xa, 0xb, 0x10, 0x10, 0x10, 0x10},
2027 (
vec_u8) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
2028 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0x10, 0x10},
2030 const vec_u8 vunused = vunusedtab[filterSize % 8];
2038 if (filterSize == 1) {
2039 for (
i = 0;
i < dstW;
i++) {
2040 int srcPos = filterPos[
i];
2043 for (j = 0; j < filterSize; j++) {
2047 dst[
i] =
FFMIN(
val >> sh, (1 << 15) - 1);
2050 for (
i = 0;
i < dstW;
i++) {
2051 const int srcPos = filterPos[
i];
2052 vout = vec_splat_s32(0);
2053 for (j = 0; j < filterSize; j += 8) {
2054 vin = (
vec_s16) vec_vsx_ld(0, &
src[srcPos + j]);
2055 if (j + 8 > filterSize)
2056 vin = vec_perm(vin, (
vec_s16) vzero, vunused);
2058 vfilter = vec_vsx_ld(0, &
filter[filterSize *
i + j]);
2059 vfilter32_l = vec_unpackh(vfilter);
2060 vfilter32_r = vec_unpackl(vfilter);
2065 vtmp = vec_mul(vtmp, vfilter32_l);
2066 vtmp2 = vec_mul(vtmp2, vfilter32_r);
2068 vout = vec_adds(vout, vtmp);
2069 vout = vec_adds(vout, vtmp2);
2071 vout = vec_sums(vout, (
vec_s32) vzero);
2072 dst[
i] =
FFMIN(vout[3] >> sh, (1 << 15) - 1);
2092 if (
c->srcBpc == 8) {
2093 if (
c->dstBpc <= 14) {
2094 c->hyScale =
c->hcScale = hScale_real_vsx;
2096 c->hyscale_fast = hyscale_fast_vsx;
2097 c->hcscale_fast = hcscale_fast_vsx;
2100 c->hyScale =
c->hcScale = hScale8To19_vsx;
2104 c->hyScale =
c->hcScale =
c->dstBpc > 14 ? hScale16To19_vsx
2111 c->yuv2planeX = yuv2planeX_vsx;
2116 switch (
c->dstBpc) {
2118 c->yuv2plane1 = yuv2plane1_8_vsx;
2122 c->yuv2plane1 =
isBE(dstFormat) ? yuv2plane1_9BE_vsx : yuv2plane1_9LE_vsx;
2123 c->yuv2planeX =
isBE(dstFormat) ? yuv2planeX_9BE_vsx : yuv2planeX_9LE_vsx;
2126 c->yuv2plane1 =
isBE(dstFormat) ? yuv2plane1_10BE_vsx : yuv2plane1_10LE_vsx;
2127 c->yuv2planeX =
isBE(dstFormat) ? yuv2planeX_10BE_vsx : yuv2planeX_10LE_vsx;
2130 c->yuv2plane1 =
isBE(dstFormat) ? yuv2plane1_12BE_vsx : yuv2plane1_12LE_vsx;
2131 c->yuv2planeX =
isBE(dstFormat) ? yuv2planeX_12BE_vsx : yuv2planeX_12LE_vsx;
2134 c->yuv2plane1 =
isBE(dstFormat) ? yuv2plane1_14BE_vsx : yuv2plane1_14LE_vsx;
2135 c->yuv2planeX =
isBE(dstFormat) ? yuv2planeX_14BE_vsx : yuv2planeX_14LE_vsx;
2138 c->yuv2plane1 =
isBE(dstFormat) ? yuv2plane1_16BE_vsx : yuv2plane1_16LE_vsx;
2141 c->yuv2planeX =
isBE(dstFormat) ? yuv2planeX_16BE_vsx : yuv2planeX_16LE_vsx;
2154 switch (dstFormat) {
2157 c->yuv2packed1 = yuv2rgb24_full_1_vsx;
2158 c->yuv2packed2 = yuv2rgb24_full_2_vsx;
2159 c->yuv2packedX = yuv2rgb24_full_X_vsx;
2164 c->yuv2packed1 = yuv2bgr24_full_1_vsx;
2165 c->yuv2packed2 = yuv2bgr24_full_2_vsx;
2166 c->yuv2packedX = yuv2bgr24_full_X_vsx;
2171 if (!
c->needAlpha) {
2172 c->yuv2packed1 = yuv2bgrx32_full_1_vsx;
2173 c->yuv2packed2 = yuv2bgrx32_full_2_vsx;
2174 c->yuv2packedX = yuv2bgrx32_full_X_vsx;
2180 if (!
c->needAlpha) {
2181 c->yuv2packed1 = yuv2rgbx32_full_1_vsx;
2182 c->yuv2packed2 = yuv2rgbx32_full_2_vsx;
2183 c->yuv2packedX = yuv2rgbx32_full_X_vsx;
2189 if (!
c->needAlpha) {
2190 c->yuv2packed1 = yuv2xrgb32_full_1_vsx;
2191 c->yuv2packed2 = yuv2xrgb32_full_2_vsx;
2192 c->yuv2packedX = yuv2xrgb32_full_X_vsx;
2198 if (!
c->needAlpha) {
2199 c->yuv2packed1 = yuv2xbgr32_full_1_vsx;
2200 c->yuv2packed2 = yuv2xbgr32_full_2_vsx;
2201 c->yuv2packedX = yuv2xbgr32_full_X_vsx;
2207 switch (dstFormat) {
2209 c->yuv2packed1 = yuv2yuyv422_1_vsx;
2210 c->yuv2packed2 = yuv2yuyv422_2_vsx;
2211 c->yuv2packedX = yuv2yuyv422_X_vsx;
2214 c->yuv2packed1 = yuv2yvyu422_1_vsx;
2215 c->yuv2packed2 = yuv2yvyu422_2_vsx;
2216 c->yuv2packedX = yuv2yvyu422_X_vsx;
2219 c->yuv2packed1 = yuv2uyvy422_1_vsx;
2220 c->yuv2packed2 = yuv2uyvy422_2_vsx;
2221 c->yuv2packedX = yuv2uyvy422_X_vsx;
2225 if (!
c->needAlpha) {
2226 c->yuv2packed1 = yuv2bgrx32_1_vsx;
2227 c->yuv2packed2 = yuv2bgrx32_2_vsx;
2233 if (!
c->needAlpha) {
2234 c->yuv2packed1 = yuv2rgbx32_1_vsx;
2235 c->yuv2packed2 = yuv2rgbx32_2_vsx;
2241 if (!
c->needAlpha) {
2242 c->yuv2packed1 = yuv2xrgb32_1_vsx;
2243 c->yuv2packed2 = yuv2xrgb32_2_vsx;
2249 if (!
c->needAlpha) {
2250 c->yuv2packed1 = yuv2xbgr32_1_vsx;
2251 c->yuv2packed2 = yuv2xbgr32_2_vsx;
2257 c->yuv2packed1 = yuv2rgb24_1_vsx;
2258 c->yuv2packed2 = yuv2rgb24_2_vsx;
2263 c->yuv2packed1 = yuv2bgr24_1_vsx;
2264 c->yuv2packed2 = yuv2bgr24_2_vsx;
static double val(void *priv, double ch)
Macro definitions for various function/variable attributes.
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
static const uint8_t shifts[2][12]
static av_always_inline void filter(int16_t *output, ptrdiff_t out_stride, const int16_t *low, ptrdiff_t low_stride, const int16_t *high, ptrdiff_t high_stride, int len, int clip)
static atomic_int cpu_flags
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
#define AV_CPU_FLAG_VSX
ISA 2.06.
#define AV_CPU_FLAG_POWER8
ISA 2.07.
static float add(float src0, float src1)
#define SWS_FULL_CHR_H_INT
#define SWS_FAST_BILINEAR
static const int shift2[6]
#define LOCAL_ALIGNED(a, t, v,...)
#define output_pixel(pos, val, bias, signedness)
#define YUV2RGBWRAPPERX(name, base, ext, fmt, hasAlpha)
#define YUV2RGBWRAPPER(name, base, ext, fmt, hasAlpha)
#define YUV2RGBWRAPPERX2(name, base, ext, fmt, hasAlpha)
yuv2NBPS(yuv2NBPS(9, yuv2NBPS(BE, yuv2NBPS(1, yuv2NBPS(10, int16_t)
#define YUV2PACKEDWRAPPER(name, base, ext, fmt)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_FLAG_FLOAT
The pixel format contains IEEE-754 floating point values.
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
@ AV_PIX_FMT_GRAYF32LE
IEEE-754 single precision Y, 32bpp, little-endian.
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
@ AV_PIX_FMT_YVYU422
packed YUV 4:2:2, 16bpp, Y0 Cr Y1 Cb
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
@ AV_PIX_FMT_UYVY422
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
@ AV_PIX_FMT_GRAYF32BE
IEEE-754 single precision Y, 32bpp, big-endian.
@ AV_PIX_FMT_YUYV422
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
static int shift(int a, int b)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
static av_always_inline int isAnyRGB(enum AVPixelFormat pix_fmt)
static av_always_inline int is16BPS(enum AVPixelFormat pix_fmt)
static av_always_inline int isSemiPlanarYUV(enum AVPixelFormat pix_fmt)
static av_always_inline int isBE(enum AVPixelFormat pix_fmt)
static av_always_inline int isNBPS(enum AVPixelFormat pix_fmt)
av_cold void ff_sws_init_swscale_vsx(SwsContext *c)
Contains misc utility macros and inline functions.
static const uint8_t dither[8][8]
static double clip(void *opaque, double val)
Clip value val in the minval - maxval range.
static const uint8_t offset[127][2]