35#define vzero vec_splat_s32(0)
38#define GET_LS(a,b,c,s) {\
40 a = vec_vsx_ld(((b) << 1) + 16, s);\
43#define yuv2planeX_8(d1, d2, l1, src, x, perm, filter) do {\
44 vector signed short ls;\
45 vector signed int vf1, vf2, i1, i2;\
46 GET_LS(l1, x, perm, src);\
47 i1 = vec_mule(filter, ls);\
48 i2 = vec_mulo(filter, ls);\
49 vf1 = vec_mergeh(i1, i2);\
50 vf2 = vec_mergel(i1, i2);\
51 d1 = vec_add(d1, vf1);\
52 d2 = vec_add(d2, vf2);\
55#define LOAD_FILTER(vf,f) {\
56 vf = vec_splats(f[j]);\
58#define LOAD_L1(ll1,s,p){\
59 ll1 = vec_vsx_ld(xoffset, s);\
68#define GET_VF4(a, vf, f) {\
69 vf = (vector signed short)vec_vsx_ld(a << 3, f);\
70 vf = vec_mergeh(vf, (vector signed short)vzero);\
72#define FIRST_LOAD(sv, pos, s, per) {}
73#define UPDATE_PTR(s0, d0, s1, d1) {}
74#define LOAD_SRCV(pos, a, s, per, v0, v1, vf) {\
75 vf = vec_vsx_ld(pos + a, s);\
77#define LOAD_SRCV8(pos, a, s, per, v0, v1, vf) LOAD_SRCV(pos, a, s, per, v0, v1, vf)
78#define GET_VFD(a, b, f, vf0, vf1, per, vf, off) {\
79 vf = vec_vsx_ld((a * 2 * filterSize) + (b * 2) + off, f);\
82#define FUNC(name) name ## _vsx
94 for (
i = start;
i < dstW;
i++) {
103 const int dst_u = -(uintptr_t)dest & 15;
107 vec_s16 vi, vileft, ditherleft, ditherright;
110 for (j = 0; j < 16; j++) {
114 ditherleft = vec_ld(0,
val);
115 ditherright = vec_ld(0, &
val[8]);
119 for (
i = dst_u;
i < dstW - 15;
i += 16) {
121 vi = vec_vsx_ld(0, &
src[
i]);
122 vi = vec_adds(ditherleft, vi);
123 vileft = vec_sra(vi,
shifts);
125 vi = vec_vsx_ld(0, &
src[
i + 8]);
126 vi = vec_adds(ditherright, vi);
129 vd = vec_packsu(vileft, vi);
130 vec_st(vd, 0, &dest[
i]);
138#define output_pixel(pos, val) \
140 AV_WB16(pos, av_clip_uintp2(val >> shift, output_bits)); \
142 AV_WL16(pos, av_clip_uintp2(val >> shift, output_bits)); \
146 int big_endian,
int output_bits,
int start)
149 int shift = 15 - output_bits;
151 for (
i = start;
i < dstW;
i++) {
158 uint16_t *dest,
int dstW,
159 const int big_endian,
160 const int output_bits)
162 const int dst_u = -(uintptr_t)dest & 7;
163 const int shift = 15 - output_bits;
164 const int add = (1 << (
shift - 1));
165 const int clip = (1 << output_bits) - 1;
166 const vec_u16 vadd = (
vec_u16) {add, add, add, add, add, add, add, add};
167 const vec_u16 vswap = (
vec_u16) vec_splat_u16(big_endian ? 8 : 0);
175 for (
i = dst_u;
i < dstW - 7;
i += 8) {
176 v = vec_vsx_ld(0, (
const uint16_t *) &
src[
i]);
177 v = vec_add(v, vadd);
178 v = vec_sr(v, vshift);
179 v = vec_min(v, vlargest);
180 v = vec_rl(v, vswap);
181 vec_st(v, 0, &dest[
i]);
188 const int16_t **
src, uint16_t *dest,
int dstW,
189 int big_endian,
int output_bits,
int start)
192 int shift = 11 + 16 - output_bits;
194 for (
i = start;
i < dstW;
i++) {
198 for (j = 0; j < filterSize; j++)
206 const int16_t **
src, uint16_t *dest,
int dstW,
207 int big_endian,
int output_bits)
209 const int dst_u = -(uintptr_t)dest & 7;
210 const int shift = 11 + 16 - output_bits;
211 const int add = (1 << (
shift - 1));
212 const int clip = (1 << output_bits) - 1;
213 const uint16_t swap = big_endian ? 8 : 0;
216 const vec_u16 vswap = (
vec_u16) {swap, swap, swap, swap, swap, swap, swap, swap};
219 const vec_u8 vperm = (
vec_u8) {0, 1, 8, 9, 2, 3, 10, 11, 4, 5, 12, 13, 6, 7, 14, 15};
225 for (
i = 0;
i < filterSize;
i++) {
232 for (
i = dst_u;
i < dstW - 7;
i += 8) {
233 vleft = vright = vadd;
235 for (j = 0; j < filterSize; j++) {
236 vin = vec_vsx_ld(0, &
src[j][
i]);
237 vtmp = (
vec_u32) vec_mule(vin, vfilter[j]);
238 vleft = vec_add(vleft, vtmp);
239 vtmp = (
vec_u32) vec_mulo(vin, vfilter[j]);
240 vright = vec_add(vright, vtmp);
243 vleft = vec_sra(vleft, vshift);
244 vright = vec_sra(vright, vshift);
245 v = vec_packsu(vleft, vright);
247 v = vec_min(v, vlargest);
248 v = vec_rl(v, vswap);
249 v = vec_perm(v, v, vperm);
250 vec_st(v, 0, &dest[
i]);
259#define output_pixel(pos, val, bias, signedness) \
261 AV_WB16(pos, bias + av_clip_ ## signedness ## 16(val >> shift)); \
263 AV_WL16(pos, bias + av_clip_ ## signedness ## 16(val >> shift)); \
267 int big_endian,
int output_bits,
int start)
272 for (
i = start;
i < dstW;
i++) {
279 uint16_t *dest,
int dstW,
280 const int big_endian,
283 const int dst_u = -(uintptr_t)dest & 7;
285 const int add = (1 << (
shift - 1));
287 const vec_u16 vswap = (
vec_u16) vec_splat_u16(big_endian ? 8 : 0);
295 for (
i = dst_u;
i < dstW - 7;
i += 8) {
296 v = vec_vsx_ld(0, (
const uint32_t *) &
src[
i]);
297 v = vec_add(v, vadd);
298 v = vec_sr(v, vshift);
300 v2 = vec_vsx_ld(0, (
const uint32_t *) &
src[
i + 4]);
301 v2 = vec_add(v2, vadd);
302 v2 = vec_sr(v2, vshift);
304 vd = vec_packsu(v, v2);
305 vd = vec_rl(vd, vswap);
307 vec_st(vd, 0, &dest[
i]);
315static void yuv2planeX_16_u(
const int16_t *
filter,
int filterSize,
316 const int32_t **
src, uint16_t *dest,
int dstW,
317 int big_endian,
int output_bits,
int start)
322 for (
i = start;
i < dstW;
i++) {
332 for (j = 0; j < filterSize; j++)
339static void yuv2planeX_16_vsx(
const int16_t *
filter,
int filterSize,
340 const int32_t **
src, uint16_t *dest,
int dstW,
341 int big_endian,
int output_bits)
343 const int dst_u = -(uintptr_t)dest & 7;
344 const int shift = 15;
345 const int bias = 0x8000;
346 const int add = (1 << (
shift - 1)) - 0x40000000;
347 const uint16_t swap = big_endian ? 8 : 0;
350 const vec_u16 vswap = (
vec_u16) {swap, swap, swap, swap, swap, swap, swap, swap};
358 for (
i = 0;
i < filterSize;
i++) {
362 yuv2planeX_16_u(
filter, filterSize,
src, dest, dst_u, big_endian, output_bits, 0);
364 for (
i = dst_u;
i < dstW - 7;
i += 8) {
365 vleft = vright = vadd;
367 for (j = 0; j < filterSize; j++) {
368 vin32l = vec_vsx_ld(0, &
src[j][
i]);
369 vin32r = vec_vsx_ld(0, &
src[j][
i + 4]);
371 vtmp = (
vec_u32) vec_mul(vin32l, vfilter[j]);
372 vleft = vec_add(vleft, vtmp);
373 vtmp = (
vec_u32) vec_mul(vin32r, vfilter[j]);
374 vright = vec_add(vright, vtmp);
377 vleft = vec_sra(vleft, vshift);
378 vright = vec_sra(vright, vshift);
380 v = vec_add(v, vbias);
381 v = vec_rl(v, vswap);
382 vec_st(v, 0, &dest[
i]);
385 yuv2planeX_16_u(
filter, filterSize,
src, dest, dstW, big_endian, output_bits,
i);
390#define yuv2NBPS(bits, BE_LE, is_be, template_size, typeX_t) \
391 yuv2NBPS1(bits, BE_LE, is_be, template_size, typeX_t) \
392 yuv2NBPSX(bits, BE_LE, is_be, template_size, typeX_t)
394#define yuv2NBPS1(bits, BE_LE, is_be, template_size, typeX_t) \
395static void yuv2plane1_ ## bits ## BE_LE ## _vsx(const int16_t *src, \
396 uint8_t *dest, int dstW, \
397 const uint8_t *dither, int offset) \
399 yuv2plane1_ ## template_size ## _vsx((const typeX_t *) src, \
400 (uint16_t *) dest, dstW, is_be, bits); \
403#define yuv2NBPSX(bits, BE_LE, is_be, template_size, typeX_t) \
404static void yuv2planeX_ ## bits ## BE_LE ## _vsx(const int16_t *filter, int filterSize, \
405 const int16_t **src, uint8_t *dest, int dstW, \
406 const uint8_t *dither, int offset)\
408 yuv2planeX_## template_size ## _vsx(filter, \
409 filterSize, (const typeX_t **) src, \
410 (uint16_t *) dest, dstW, is_be, bits); \
430 R_l = vec_max(R_l, zero32); \
431 R_r = vec_max(R_r, zero32); \
432 G_l = vec_max(G_l, zero32); \
433 G_r = vec_max(G_r, zero32); \
434 B_l = vec_max(B_l, zero32); \
435 B_r = vec_max(B_r, zero32); \
437 R_l = vec_min(R_l, rgbclip); \
438 R_r = vec_min(R_r, rgbclip); \
439 G_l = vec_min(G_l, rgbclip); \
440 G_r = vec_min(G_r, rgbclip); \
441 B_l = vec_min(B_l, rgbclip); \
442 B_r = vec_min(B_r, rgbclip); \
444 R_l = vec_sr(R_l, shift22); \
445 R_r = vec_sr(R_r, shift22); \
446 G_l = vec_sr(G_l, shift22); \
447 G_r = vec_sr(G_r, shift22); \
448 B_l = vec_sr(B_l, shift22); \
449 B_r = vec_sr(B_r, shift22); \
451 rd16 = vec_packsu(R_l, R_r); \
452 gd16 = vec_packsu(G_l, G_r); \
453 bd16 = vec_packsu(B_l, B_r); \
454 rd = vec_packsu(rd16, zero16); \
455 gd = vec_packsu(gd16, zero16); \
456 bd = vec_packsu(bd16, zero16); \
459 case AV_PIX_FMT_RGB24: { \
460 DECLARE_ALIGNED(16, uint8_t, tmp_out)[16]; \
461 out0 = vec_perm(rd, gd, perm3rg0); \
462 out0 = vec_perm(out0, bd, perm3tb0); \
463 out1 = vec_perm(rd, gd, perm3rg1); \
464 out1 = vec_perm(out1, bd, perm3tb1); \
466 vec_vsx_st(out0, 0, dest); \
467 vec_vsx_st(out1, 0, tmp_out); \
468 memcpy(dest + 16, tmp_out, 8); \
472 case AV_PIX_FMT_BGR24: { \
473 DECLARE_ALIGNED(16, uint8_t, tmp_out)[16]; \
474 out0 = vec_perm(bd, gd, perm3rg0); \
475 out0 = vec_perm(out0, rd, perm3tb0); \
476 out1 = vec_perm(bd, gd, perm3rg1); \
477 out1 = vec_perm(out1, rd, perm3tb1); \
479 vec_vsx_st(out0, 0, dest); \
480 vec_vsx_st(out1, 0, tmp_out); \
481 memcpy(dest + 16, tmp_out, 8); \
485 case AV_PIX_FMT_BGRA: \
486 out0 = vec_mergeh(bd, gd); \
487 out1 = vec_mergeh(rd, ad); \
489 tmp8 = (vec_u8) vec_mergeh((vec_u16) out0, (vec_u16) out1); \
490 vec_vsx_st(tmp8, 0, dest); \
491 tmp8 = (vec_u8) vec_mergel((vec_u16) out0, (vec_u16) out1); \
492 vec_vsx_st(tmp8, 16, dest); \
496 case AV_PIX_FMT_RGBA: \
497 out0 = vec_mergeh(rd, gd); \
498 out1 = vec_mergeh(bd, ad); \
500 tmp8 = (vec_u8) vec_mergeh((vec_u16) out0, (vec_u16) out1); \
501 vec_vsx_st(tmp8, 0, dest); \
502 tmp8 = (vec_u8) vec_mergel((vec_u16) out0, (vec_u16) out1); \
503 vec_vsx_st(tmp8, 16, dest); \
507 case AV_PIX_FMT_ARGB: \
508 out0 = vec_mergeh(ad, rd); \
509 out1 = vec_mergeh(gd, bd); \
511 tmp8 = (vec_u8) vec_mergeh((vec_u16) out0, (vec_u16) out1); \
512 vec_vsx_st(tmp8, 0, dest); \
513 tmp8 = (vec_u8) vec_mergel((vec_u16) out0, (vec_u16) out1); \
514 vec_vsx_st(tmp8, 16, dest); \
518 case AV_PIX_FMT_ABGR: \
519 out0 = vec_mergeh(ad, bd); \
520 out1 = vec_mergeh(gd, rd); \
522 tmp8 = (vec_u8) vec_mergeh((vec_u16) out0, (vec_u16) out1); \
523 vec_vsx_st(tmp8, 0, dest); \
524 tmp8 = (vec_u8) vec_mergel((vec_u16) out0, (vec_u16) out1); \
525 vec_vsx_st(tmp8, 16, dest); \
532yuv2rgb_full_X_vsx_template(
SwsInternal *
c,
const int16_t *lumFilter,
533 const int16_t **lumSrc,
int lumFilterSize,
534 const int16_t *chrFilter,
const int16_t **chrUSrc,
535 const int16_t **chrVSrc,
int chrFilterSize,
536 const int16_t **alpSrc, uint8_t *dest,
540 vec_s32 vy32_l, vy32_r, vu32_l, vu32_r, vv32_l, vv32_r, tmp32;
541 vec_s32 R_l, R_r, G_l, G_r, B_l, B_r;
544 vec_u8 rd, bd, gd, ad, out0, out1, tmp8;
546 const vec_s32 ystart = vec_splats(1 << 9);
547 const vec_s32 uvstart = vec_splats((1 << 9) - (128 << 19));
548 const vec_u16 zero16 = vec_splat_u16(0);
549 const vec_s32 y_offset = vec_splats(
c->yuv2rgb_y_offset);
550 const vec_s32 y_coeff = vec_splats(
c->yuv2rgb_y_coeff);
551 const vec_s32 y_add = vec_splats(1 << 21);
552 const vec_s32 v2r_coeff = vec_splats(
c->yuv2rgb_v2r_coeff);
553 const vec_s32 v2g_coeff = vec_splats(
c->yuv2rgb_v2g_coeff);
554 const vec_s32 u2g_coeff = vec_splats(
c->yuv2rgb_u2g_coeff);
555 const vec_s32 u2b_coeff = vec_splats(
c->yuv2rgb_u2b_coeff);
556 const vec_s32 rgbclip = vec_splats(1 << 30);
557 const vec_s32 zero32 = vec_splat_s32(0);
558 const vec_u32 shift22 = vec_splats(22U);
559 const vec_u32 shift10 = vec_splat_u32(10);
582 ad = vec_splats((uint8_t) 255);
584 for (
i = 0;
i < lumFilterSize;
i++)
585 vlumFilter[
i] = vec_splats(lumFilter[
i]);
586 for (
i = 0;
i < chrFilterSize;
i++)
587 vchrFilter[
i] = vec_splats(chrFilter[
i]);
589 for (
i = 0;
i < dstW;
i += 8) {
597 for (j = 0; j < lumFilterSize; j++) {
598 vv = vec_ld(0, &lumSrc[j][
i]);
599 tmp = vec_mule(vv, vlumFilter[j]);
600 tmp2 = vec_mulo(vv, vlumFilter[j]);
601 tmp3 = vec_mergeh(
tmp, tmp2);
602 tmp4 = vec_mergel(
tmp, tmp2);
604 vy32_l = vec_adds(vy32_l, tmp3);
605 vy32_r = vec_adds(vy32_r, tmp4);
608 for (j = 0; j < chrFilterSize; j++) {
609 vv = vec_ld(0, &chrUSrc[j][
i]);
610 tmp = vec_mule(vv, vchrFilter[j]);
611 tmp2 = vec_mulo(vv, vchrFilter[j]);
612 tmp3 = vec_mergeh(
tmp, tmp2);
613 tmp4 = vec_mergel(
tmp, tmp2);
615 vu32_l = vec_adds(vu32_l, tmp3);
616 vu32_r = vec_adds(vu32_r, tmp4);
618 vv = vec_ld(0, &chrVSrc[j][
i]);
619 tmp = vec_mule(vv, vchrFilter[j]);
620 tmp2 = vec_mulo(vv, vchrFilter[j]);
621 tmp3 = vec_mergeh(
tmp, tmp2);
622 tmp4 = vec_mergel(
tmp, tmp2);
624 vv32_l = vec_adds(vv32_l, tmp3);
625 vv32_r = vec_adds(vv32_r, tmp4);
628 vy32_l = vec_sra(vy32_l, shift10);
629 vy32_r = vec_sra(vy32_r, shift10);
630 vu32_l = vec_sra(vu32_l, shift10);
631 vu32_r = vec_sra(vu32_r, shift10);
632 vv32_l = vec_sra(vv32_l, shift10);
633 vv32_r = vec_sra(vv32_r, shift10);
635 vy32_l = vec_sub(vy32_l, y_offset);
636 vy32_r = vec_sub(vy32_r, y_offset);
637 vy32_l = vec_mul(vy32_l, y_coeff);
638 vy32_r = vec_mul(vy32_r, y_coeff);
639 vy32_l = vec_add(vy32_l, y_add);
640 vy32_r = vec_add(vy32_r, y_add);
642 R_l = vec_mul(vv32_l, v2r_coeff);
643 R_l = vec_add(R_l, vy32_l);
644 R_r = vec_mul(vv32_r, v2r_coeff);
645 R_r = vec_add(R_r, vy32_r);
646 G_l = vec_mul(vv32_l, v2g_coeff);
647 tmp32 = vec_mul(vu32_l, u2g_coeff);
648 G_l = vec_add(G_l, vy32_l);
649 G_l = vec_add(G_l, tmp32);
650 G_r = vec_mul(vv32_r, v2g_coeff);
651 tmp32 = vec_mul(vu32_r, u2g_coeff);
652 G_r = vec_add(G_r, vy32_r);
653 G_r = vec_add(G_r, tmp32);
655 B_l = vec_mul(vu32_l, u2b_coeff);
656 B_l = vec_add(B_l, vy32_l);
657 B_r = vec_mul(vu32_r, u2b_coeff);
658 B_r = vec_add(B_r, vy32_r);
664#define SETUP(x, buf0, alpha1, buf1, alpha) { \
665 x = vec_ld(0, buf0); \
666 tmp = vec_mule(x, alpha1); \
667 tmp2 = vec_mulo(x, alpha1); \
668 tmp3 = vec_mergeh(tmp, tmp2); \
669 tmp4 = vec_mergel(tmp, tmp2); \
671 x = vec_ld(0, buf1); \
672 tmp = vec_mule(x, alpha); \
673 tmp2 = vec_mulo(x, alpha); \
674 tmp5 = vec_mergeh(tmp, tmp2); \
675 tmp6 = vec_mergel(tmp, tmp2); \
677 tmp3 = vec_add(tmp3, tmp5); \
678 tmp4 = vec_add(tmp4, tmp6); \
684 const int16_t *ubuf[2],
const int16_t *vbuf[2],
685 const int16_t *abuf[2], uint8_t *dest,
int dstW,
686 int yalpha,
int uvalpha,
int y,
689 const int16_t *buf0 = buf[0], *buf1 = buf[1],
690 *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
691 *vbuf0 = vbuf[0], *vbuf1 = vbuf[1],
692 *abuf0 = hasAlpha ? abuf[0] :
NULL,
693 *abuf1 = hasAlpha ? abuf[1] :
NULL;
694 const int16_t yalpha1 = 4096 - yalpha;
695 const int16_t uvalpha1 = 4096 - uvalpha;
696 vec_s16 vy, vu, vv,
A = vec_splat_s16(0);
697 vec_s32 vy32_l, vy32_r, vu32_l, vu32_r, vv32_l, vv32_r, tmp32;
698 vec_s32 R_l, R_r, G_l, G_r, B_l, B_r;
701 vec_u8 rd, bd, gd, ad, out0, out1, tmp8;
702 const vec_s16 vyalpha1 = vec_splats(yalpha1);
703 const vec_s16 vuvalpha1 = vec_splats(uvalpha1);
704 const vec_s16 vyalpha = vec_splats((int16_t) yalpha);
705 const vec_s16 vuvalpha = vec_splats((int16_t) uvalpha);
706 const vec_u16 zero16 = vec_splat_u16(0);
707 const vec_s32 y_offset = vec_splats(
c->yuv2rgb_y_offset);
708 const vec_s32 y_coeff = vec_splats(
c->yuv2rgb_y_coeff);
709 const vec_s32 y_add = vec_splats(1 << 21);
710 const vec_s32 v2r_coeff = vec_splats(
c->yuv2rgb_v2r_coeff);
711 const vec_s32 v2g_coeff = vec_splats(
c->yuv2rgb_v2g_coeff);
712 const vec_s32 u2g_coeff = vec_splats(
c->yuv2rgb_u2g_coeff);
713 const vec_s32 u2b_coeff = vec_splats(
c->yuv2rgb_u2b_coeff);
714 const vec_s32 rgbclip = vec_splats(1 << 30);
715 const vec_s32 zero32 = vec_splat_s32(0);
716 const vec_u32 shift19 = vec_splats(19U);
717 const vec_u32 shift22 = vec_splats(22U);
718 const vec_u32 shift10 = vec_splat_u32(10);
719 const vec_s32 dec128 = vec_splats(128 << 19);
720 const vec_s32 add18 = vec_splats(1 << 18);
746 for (
i = 0;
i < dstW;
i += 8) {
747 SETUP(vy, &buf0[
i], vyalpha1, &buf1[
i], vyalpha);
748 vy32_l = vec_sra(tmp3, shift10);
749 vy32_r = vec_sra(tmp4, shift10);
751 SETUP(vu, &ubuf0[
i], vuvalpha1, &ubuf1[
i], vuvalpha);
752 tmp3 = vec_sub(tmp3, dec128);
753 tmp4 = vec_sub(tmp4, dec128);
754 vu32_l = vec_sra(tmp3, shift10);
755 vu32_r = vec_sra(tmp4, shift10);
757 SETUP(vv, &vbuf0[
i], vuvalpha1, &vbuf1[
i], vuvalpha);
758 tmp3 = vec_sub(tmp3, dec128);
759 tmp4 = vec_sub(tmp4, dec128);
760 vv32_l = vec_sra(tmp3, shift10);
761 vv32_r = vec_sra(tmp4, shift10);
764 SETUP(
A, &abuf0[
i], vyalpha1, &abuf1[
i], vyalpha);
765 tmp3 = vec_add(tmp3, add18);
766 tmp4 = vec_add(tmp4, add18);
767 tmp3 = vec_sra(tmp3, shift19);
768 tmp4 = vec_sra(tmp4, shift19);
769 A = vec_packs(tmp3, tmp4);
770 ad = vec_packsu(
A, (
vec_s16) zero16);
772 ad = vec_splats((uint8_t) 255);
775 vy32_l = vec_sub(vy32_l, y_offset);
776 vy32_r = vec_sub(vy32_r, y_offset);
777 vy32_l = vec_mul(vy32_l, y_coeff);
778 vy32_r = vec_mul(vy32_r, y_coeff);
779 vy32_l = vec_add(vy32_l, y_add);
780 vy32_r = vec_add(vy32_r, y_add);
782 R_l = vec_mul(vv32_l, v2r_coeff);
783 R_l = vec_add(R_l, vy32_l);
784 R_r = vec_mul(vv32_r, v2r_coeff);
785 R_r = vec_add(R_r, vy32_r);
786 G_l = vec_mul(vv32_l, v2g_coeff);
787 tmp32 = vec_mul(vu32_l, u2g_coeff);
788 G_l = vec_add(G_l, vy32_l);
789 G_l = vec_add(G_l, tmp32);
790 G_r = vec_mul(vv32_r, v2g_coeff);
791 tmp32 = vec_mul(vu32_r, u2g_coeff);
792 G_r = vec_add(G_r, vy32_r);
793 G_r = vec_add(G_r, tmp32);
795 B_l = vec_mul(vu32_l, u2b_coeff);
796 B_l = vec_add(B_l, vy32_l);
797 B_r = vec_mul(vu32_r, u2b_coeff);
798 B_r = vec_add(B_r, vy32_r);
806 const int16_t *ubuf[2],
const int16_t *vbuf[2],
807 const int16_t *abuf[2], uint8_t *dest,
int dstW,
808 int yalpha,
int uvalpha,
int y,
811 const int16_t *buf0 = buf[0], *buf1 = buf[1],
812 *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
813 *vbuf0 = vbuf[0], *vbuf1 = vbuf[1],
814 *abuf0 = hasAlpha ? abuf[0] :
NULL,
815 *abuf1 = hasAlpha ? abuf[1] :
NULL;
816 const int16_t yalpha1 = 4096 - yalpha;
817 const int16_t uvalpha1 = 4096 - uvalpha;
818 vec_s16 vy, vu, vv,
A = vec_splat_s16(0);
819 vec_s32 vy32_l, vy32_r, vu32_l, vu32_r, vv32_l, vv32_r, tmp32;
820 vec_s32 R_l, R_r, G_l, G_r, B_l, B_r, vud32_l, vud32_r, vvd32_l, vvd32_r;
823 vec_u8 rd, bd, gd, ad, out0, out1, tmp8;
824 const vec_s16 vyalpha1 = vec_splats(yalpha1);
825 const vec_s16 vuvalpha1 = vec_splats(uvalpha1);
826 const vec_s16 vyalpha = vec_splats((int16_t) yalpha);
827 const vec_s16 vuvalpha = vec_splats((int16_t) uvalpha);
828 const vec_u16 zero16 = vec_splat_u16(0);
829 const vec_s32 y_offset = vec_splats(
c->yuv2rgb_y_offset);
830 const vec_s32 y_coeff = vec_splats(
c->yuv2rgb_y_coeff);
831 const vec_s32 y_add = vec_splats(1 << 21);
832 const vec_s32 v2r_coeff = vec_splats(
c->yuv2rgb_v2r_coeff);
833 const vec_s32 v2g_coeff = vec_splats(
c->yuv2rgb_v2g_coeff);
834 const vec_s32 u2g_coeff = vec_splats(
c->yuv2rgb_u2g_coeff);
835 const vec_s32 u2b_coeff = vec_splats(
c->yuv2rgb_u2b_coeff);
836 const vec_s32 rgbclip = vec_splats(1 << 30);
837 const vec_s32 zero32 = vec_splat_s32(0);
838 const vec_u32 shift19 = vec_splats(19U);
839 const vec_u32 shift22 = vec_splats(22U);
840 const vec_u32 shift10 = vec_splat_u32(10);
841 const vec_s32 dec128 = vec_splats(128 << 19);
842 const vec_s32 add18 = vec_splats(1 << 18);
876 for (
i = 0;
i < (dstW + 1) >> 1;
i += 8) {
877 SETUP(vy, &buf0[
i * 2], vyalpha1, &buf1[
i * 2], vyalpha);
878 vy32_l = vec_sra(tmp3, shift10);
879 vy32_r = vec_sra(tmp4, shift10);
881 SETUP(vu, &ubuf0[
i], vuvalpha1, &ubuf1[
i], vuvalpha);
882 tmp3 = vec_sub(tmp3, dec128);
883 tmp4 = vec_sub(tmp4, dec128);
884 vu32_l = vec_sra(tmp3, shift10);
885 vu32_r = vec_sra(tmp4, shift10);
887 SETUP(vv, &vbuf0[
i], vuvalpha1, &vbuf1[
i], vuvalpha);
888 tmp3 = vec_sub(tmp3, dec128);
889 tmp4 = vec_sub(tmp4, dec128);
890 vv32_l = vec_sra(tmp3, shift10);
891 vv32_r = vec_sra(tmp4, shift10);
894 SETUP(
A, &abuf0[
i], vyalpha1, &abuf1[
i], vyalpha);
895 tmp3 = vec_add(tmp3, add18);
896 tmp4 = vec_add(tmp4, add18);
897 tmp3 = vec_sra(tmp3, shift19);
898 tmp4 = vec_sra(tmp4, shift19);
899 A = vec_packs(tmp3, tmp4);
900 ad = vec_packsu(
A, (
vec_s16) zero16);
902 ad = vec_splats((uint8_t) 255);
905 vy32_l = vec_sub(vy32_l, y_offset);
906 vy32_r = vec_sub(vy32_r, y_offset);
907 vy32_l = vec_mul(vy32_l, y_coeff);
908 vy32_r = vec_mul(vy32_r, y_coeff);
909 vy32_l = vec_add(vy32_l, y_add);
910 vy32_r = vec_add(vy32_r, y_add);
913 vud32_l = vec_perm(vu32_l, vu32_l, doubleleft);
914 vud32_r = vec_perm(vu32_l, vu32_l, doubleright);
915 vvd32_l = vec_perm(vv32_l, vv32_l, doubleleft);
916 vvd32_r = vec_perm(vv32_l, vv32_l, doubleright);
918 R_l = vec_mul(vvd32_l, v2r_coeff);
919 R_l = vec_add(R_l, vy32_l);
920 R_r = vec_mul(vvd32_r, v2r_coeff);
921 R_r = vec_add(R_r, vy32_r);
922 G_l = vec_mul(vvd32_l, v2g_coeff);
923 tmp32 = vec_mul(vud32_l, u2g_coeff);
924 G_l = vec_add(G_l, vy32_l);
925 G_l = vec_add(G_l, tmp32);
926 G_r = vec_mul(vvd32_r, v2g_coeff);
927 tmp32 = vec_mul(vud32_r, u2g_coeff);
928 G_r = vec_add(G_r, vy32_r);
929 G_r = vec_add(G_r, tmp32);
931 B_l = vec_mul(vud32_l, u2b_coeff);
932 B_l = vec_add(B_l, vy32_l);
933 B_r = vec_mul(vud32_r, u2b_coeff);
934 B_r = vec_add(B_r, vy32_r);
939 SETUP(vy, &buf0[
i * 2 + 8], vyalpha1, &buf1[
i * 2 + 8], vyalpha);
940 vy32_l = vec_sra(tmp3, shift10);
941 vy32_r = vec_sra(tmp4, shift10);
943 vy32_l = vec_sub(vy32_l, y_offset);
944 vy32_r = vec_sub(vy32_r, y_offset);
945 vy32_l = vec_mul(vy32_l, y_coeff);
946 vy32_r = vec_mul(vy32_r, y_coeff);
947 vy32_l = vec_add(vy32_l, y_add);
948 vy32_r = vec_add(vy32_r, y_add);
951 vud32_l = vec_perm(vu32_r, vu32_r, doubleleft);
952 vud32_r = vec_perm(vu32_r, vu32_r, doubleright);
953 vvd32_l = vec_perm(vv32_r, vv32_r, doubleleft);
954 vvd32_r = vec_perm(vv32_r, vv32_r, doubleright);
956 R_l = vec_mul(vvd32_l, v2r_coeff);
957 R_l = vec_add(R_l, vy32_l);
958 R_r = vec_mul(vvd32_r, v2r_coeff);
959 R_r = vec_add(R_r, vy32_r);
960 G_l = vec_mul(vvd32_l, v2g_coeff);
961 tmp32 = vec_mul(vud32_l, u2g_coeff);
962 G_l = vec_add(G_l, vy32_l);
963 G_l = vec_add(G_l, tmp32);
964 G_r = vec_mul(vvd32_r, v2g_coeff);
965 tmp32 = vec_mul(vud32_r, u2g_coeff);
966 G_r = vec_add(G_r, vy32_r);
967 G_r = vec_add(G_r, tmp32);
969 B_l = vec_mul(vud32_l, u2b_coeff);
970 B_l = vec_add(B_l, vy32_l);
971 B_r = vec_mul(vud32_r, u2b_coeff);
972 B_r = vec_add(B_r, vy32_r);
982 const int16_t *ubuf[2],
const int16_t *vbuf[2],
983 const int16_t *abuf0, uint8_t *dest,
int dstW,
987 const int16_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0];
988 const int16_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1];
989 vec_s16 vy, vu, vv,
A = vec_splat_s16(0), tmp16;
990 vec_s32 vy32_l, vy32_r, vu32_l, vu32_r, vv32_l, vv32_r, tmp32, tmp32_2;
991 vec_s32 R_l, R_r, G_l, G_r, B_l, B_r;
993 vec_u8 rd, bd, gd, ad, out0, out1, tmp8;
994 const vec_u16 zero16 = vec_splat_u16(0);
995 const vec_s32 y_offset = vec_splats(
c->yuv2rgb_y_offset);
996 const vec_s32 y_coeff = vec_splats(
c->yuv2rgb_y_coeff);
997 const vec_s32 y_add = vec_splats(1 << 21);
998 const vec_s32 v2r_coeff = vec_splats(
c->yuv2rgb_v2r_coeff);
999 const vec_s32 v2g_coeff = vec_splats(
c->yuv2rgb_v2g_coeff);
1000 const vec_s32 u2g_coeff = vec_splats(
c->yuv2rgb_u2g_coeff);
1001 const vec_s32 u2b_coeff = vec_splats(
c->yuv2rgb_u2b_coeff);
1002 const vec_s32 rgbclip = vec_splats(1 << 30);
1003 const vec_s32 zero32 = vec_splat_s32(0);
1005 const vec_u32 shift22 = vec_splats(22U);
1006 const vec_u16 sub7 = vec_splats((uint16_t) (128 << 7));
1007 const vec_u16 sub8 = vec_splats((uint16_t) (128 << 8));
1008 const vec_s16 mul4 = vec_splat_s16(4);
1010 const vec_s16 add64 = vec_splat_s16(64);
1011 const vec_u16 shift7 = vec_splat_u16(7);
1012 const vec_s16 max255 = vec_splat_s16(255);
1035 for (
i = 0;
i < dstW;
i += 8) {
1036 vy = vec_ld(0, &buf0[
i]);
1037 vy32_l = vec_unpackh(vy);
1038 vy32_r = vec_unpackl(vy);
1039 vy32_l = vec_sl(vy32_l,
shift2);
1040 vy32_r = vec_sl(vy32_r,
shift2);
1042 vu = vec_ld(0, &ubuf0[
i]);
1043 vv = vec_ld(0, &vbuf0[
i]);
1044 if (uvalpha < 2048) {
1048 tmp32 = vec_mule(vu, mul4);
1049 tmp32_2 = vec_mulo(vu, mul4);
1050 vu32_l = vec_mergeh(tmp32, tmp32_2);
1051 vu32_r = vec_mergel(tmp32, tmp32_2);
1052 tmp32 = vec_mule(vv, mul4);
1053 tmp32_2 = vec_mulo(vv, mul4);
1054 vv32_l = vec_mergeh(tmp32, tmp32_2);
1055 vv32_r = vec_mergel(tmp32, tmp32_2);
1057 tmp16 = vec_ld(0, &ubuf1[
i]);
1058 vu = vec_add(vu, tmp16);
1060 tmp16 = vec_ld(0, &vbuf1[
i]);
1061 vv = vec_add(vv, tmp16);
1064 vu32_l = vec_mule(vu,
mul8);
1065 vu32_r = vec_mulo(vu,
mul8);
1066 vv32_l = vec_mule(vv,
mul8);
1067 vv32_r = vec_mulo(vv,
mul8);
1071 A = vec_ld(0, &abuf0[
i]);
1072 A = vec_add(
A, add64);
1073 A = vec_sr(
A, shift7);
1074 A = vec_max(
A, max255);
1075 ad = vec_packsu(
A, (
vec_s16) zero16);
1077 ad = vec_splats((uint8_t) 255);
1080 vy32_l = vec_sub(vy32_l, y_offset);
1081 vy32_r = vec_sub(vy32_r, y_offset);
1082 vy32_l = vec_mul(vy32_l, y_coeff);
1083 vy32_r = vec_mul(vy32_r, y_coeff);
1084 vy32_l = vec_add(vy32_l, y_add);
1085 vy32_r = vec_add(vy32_r, y_add);
1087 R_l = vec_mul(vv32_l, v2r_coeff);
1088 R_l = vec_add(R_l, vy32_l);
1089 R_r = vec_mul(vv32_r, v2r_coeff);
1090 R_r = vec_add(R_r, vy32_r);
1091 G_l = vec_mul(vv32_l, v2g_coeff);
1092 tmp32 = vec_mul(vu32_l, u2g_coeff);
1093 G_l = vec_add(G_l, vy32_l);
1094 G_l = vec_add(G_l, tmp32);
1095 G_r = vec_mul(vv32_r, v2g_coeff);
1096 tmp32 = vec_mul(vu32_r, u2g_coeff);
1097 G_r = vec_add(G_r, vy32_r);
1098 G_r = vec_add(G_r, tmp32);
1100 B_l = vec_mul(vu32_l, u2b_coeff);
1101 B_l = vec_add(B_l, vy32_l);
1102 B_r = vec_mul(vu32_r, u2b_coeff);
1103 B_r = vec_add(B_r, vy32_r);
1111 const int16_t *ubuf[2],
const int16_t *vbuf[2],
1112 const int16_t *abuf0, uint8_t *dest,
int dstW,
1116 const int16_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0];
1117 const int16_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1];
1118 vec_s16 vy, vu, vv,
A = vec_splat_s16(0), tmp16;
1119 vec_s32 vy32_l, vy32_r, vu32_l, vu32_r, vv32_l, vv32_r, tmp32, tmp32_2;
1120 vec_s32 vud32_l, vud32_r, vvd32_l, vvd32_r;
1121 vec_s32 R_l, R_r, G_l, G_r, B_l, B_r;
1123 vec_u8 rd, bd, gd, ad, out0, out1, tmp8;
1124 const vec_u16 zero16 = vec_splat_u16(0);
1125 const vec_s32 y_offset = vec_splats(
c->yuv2rgb_y_offset);
1126 const vec_s32 y_coeff = vec_splats(
c->yuv2rgb_y_coeff);
1127 const vec_s32 y_add = vec_splats(1 << 21);
1128 const vec_s32 v2r_coeff = vec_splats(
c->yuv2rgb_v2r_coeff);
1129 const vec_s32 v2g_coeff = vec_splats(
c->yuv2rgb_v2g_coeff);
1130 const vec_s32 u2g_coeff = vec_splats(
c->yuv2rgb_u2g_coeff);
1131 const vec_s32 u2b_coeff = vec_splats(
c->yuv2rgb_u2b_coeff);
1132 const vec_s32 rgbclip = vec_splats(1 << 30);
1133 const vec_s32 zero32 = vec_splat_s32(0);
1135 const vec_u32 shift22 = vec_splats(22U);
1136 const vec_u16 sub7 = vec_splats((uint16_t) (128 << 7));
1137 const vec_u16 sub8 = vec_splats((uint16_t) (128 << 8));
1138 const vec_s16 mul4 = vec_splat_s16(4);
1140 const vec_s16 add64 = vec_splat_s16(64);
1141 const vec_u16 shift7 = vec_splat_u16(7);
1142 const vec_s16 max255 = vec_splat_s16(255);
1173 for (
i = 0;
i < (dstW + 1) >> 1;
i += 8) {
1174 vy = vec_ld(0, &buf0[
i * 2]);
1175 vy32_l = vec_unpackh(vy);
1176 vy32_r = vec_unpackl(vy);
1177 vy32_l = vec_sl(vy32_l,
shift2);
1178 vy32_r = vec_sl(vy32_r,
shift2);
1180 vu = vec_ld(0, &ubuf0[
i]);
1181 vv = vec_ld(0, &vbuf0[
i]);
1182 if (uvalpha < 2048) {
1186 tmp32 = vec_mule(vu, mul4);
1187 tmp32_2 = vec_mulo(vu, mul4);
1188 vu32_l = vec_mergeh(tmp32, tmp32_2);
1189 vu32_r = vec_mergel(tmp32, tmp32_2);
1190 tmp32 = vec_mule(vv, mul4);
1191 tmp32_2 = vec_mulo(vv, mul4);
1192 vv32_l = vec_mergeh(tmp32, tmp32_2);
1193 vv32_r = vec_mergel(tmp32, tmp32_2);
1195 tmp16 = vec_ld(0, &ubuf1[
i]);
1196 vu = vec_add(vu, tmp16);
1198 tmp16 = vec_ld(0, &vbuf1[
i]);
1199 vv = vec_add(vv, tmp16);
1202 vu32_l = vec_mule(vu,
mul8);
1203 vu32_r = vec_mulo(vu,
mul8);
1204 vv32_l = vec_mule(vv,
mul8);
1205 vv32_r = vec_mulo(vv,
mul8);
1209 A = vec_ld(0, &abuf0[
i]);
1210 A = vec_add(
A, add64);
1211 A = vec_sr(
A, shift7);
1212 A = vec_max(
A, max255);
1213 ad = vec_packsu(
A, (
vec_s16) zero16);
1215 ad = vec_splats((uint8_t) 255);
1218 vy32_l = vec_sub(vy32_l, y_offset);
1219 vy32_r = vec_sub(vy32_r, y_offset);
1220 vy32_l = vec_mul(vy32_l, y_coeff);
1221 vy32_r = vec_mul(vy32_r, y_coeff);
1222 vy32_l = vec_add(vy32_l, y_add);
1223 vy32_r = vec_add(vy32_r, y_add);
1226 vud32_l = vec_perm(vu32_l, vu32_l, doubleleft);
1227 vud32_r = vec_perm(vu32_l, vu32_l, doubleright);
1228 vvd32_l = vec_perm(vv32_l, vv32_l, doubleleft);
1229 vvd32_r = vec_perm(vv32_l, vv32_l, doubleright);
1231 R_l = vec_mul(vvd32_l, v2r_coeff);
1232 R_l = vec_add(R_l, vy32_l);
1233 R_r = vec_mul(vvd32_r, v2r_coeff);
1234 R_r = vec_add(R_r, vy32_r);
1235 G_l = vec_mul(vvd32_l, v2g_coeff);
1236 tmp32 = vec_mul(vud32_l, u2g_coeff);
1237 G_l = vec_add(G_l, vy32_l);
1238 G_l = vec_add(G_l, tmp32);
1239 G_r = vec_mul(vvd32_r, v2g_coeff);
1240 tmp32 = vec_mul(vud32_r, u2g_coeff);
1241 G_r = vec_add(G_r, vy32_r);
1242 G_r = vec_add(G_r, tmp32);
1244 B_l = vec_mul(vud32_l, u2b_coeff);
1245 B_l = vec_add(B_l, vy32_l);
1246 B_r = vec_mul(vud32_r, u2b_coeff);
1247 B_r = vec_add(B_r, vy32_r);
1252 vy = vec_ld(16, &buf0[
i * 2]);
1253 vy32_l = vec_unpackh(vy);
1254 vy32_r = vec_unpackl(vy);
1255 vy32_l = vec_sl(vy32_l,
shift2);
1256 vy32_r = vec_sl(vy32_r,
shift2);
1258 vy32_l = vec_sub(vy32_l, y_offset);
1259 vy32_r = vec_sub(vy32_r, y_offset);
1260 vy32_l = vec_mul(vy32_l, y_coeff);
1261 vy32_r = vec_mul(vy32_r, y_coeff);
1262 vy32_l = vec_add(vy32_l, y_add);
1263 vy32_r = vec_add(vy32_r, y_add);
1266 vud32_l = vec_perm(vu32_r, vu32_r, doubleleft);
1267 vud32_r = vec_perm(vu32_r, vu32_r, doubleright);
1268 vvd32_l = vec_perm(vv32_r, vv32_r, doubleleft);
1269 vvd32_r = vec_perm(vv32_r, vv32_r, doubleright);
1271 R_l = vec_mul(vvd32_l, v2r_coeff);
1272 R_l = vec_add(R_l, vy32_l);
1273 R_r = vec_mul(vvd32_r, v2r_coeff);
1274 R_r = vec_add(R_r, vy32_r);
1275 G_l = vec_mul(vvd32_l, v2g_coeff);
1276 tmp32 = vec_mul(vud32_l, u2g_coeff);
1277 G_l = vec_add(G_l, vy32_l);
1278 G_l = vec_add(G_l, tmp32);
1279 G_r = vec_mul(vvd32_r, v2g_coeff);
1280 tmp32 = vec_mul(vud32_r, u2g_coeff);
1281 G_r = vec_add(G_r, vy32_r);
1282 G_r = vec_add(G_r, tmp32);
1284 B_l = vec_mul(vud32_l, u2b_coeff);
1285 B_l = vec_add(B_l, vy32_l);
1286 B_r = vec_mul(vud32_r, u2b_coeff);
1287 B_r = vec_add(B_r, vy32_r);
1295#define YUV2RGBWRAPPERX(name, base, ext, fmt, hasAlpha) \
1296static void name ## ext ## _X_vsx(SwsInternal *c, const int16_t *lumFilter, \
1297 const int16_t **lumSrc, int lumFilterSize, \
1298 const int16_t *chrFilter, const int16_t **chrUSrc, \
1299 const int16_t **chrVSrc, int chrFilterSize, \
1300 const int16_t **alpSrc, uint8_t *dest, int dstW, \
1303 name ## base ## _X_vsx_template(c, lumFilter, lumSrc, lumFilterSize, \
1304 chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
1305 alpSrc, dest, dstW, y, fmt, hasAlpha); \
1308#define YUV2RGBWRAPPERX2(name, base, ext, fmt, hasAlpha) \
1309static void name ## ext ## _2_vsx(SwsInternal *c, const int16_t *buf[2], \
1310 const int16_t *ubuf[2], const int16_t *vbuf[2], \
1311 const int16_t *abuf[2], uint8_t *dest, int dstW, \
1312 int yalpha, int uvalpha, int y) \
1314 name ## base ## _2_vsx_template(c, buf, ubuf, vbuf, abuf, \
1315 dest, dstW, yalpha, uvalpha, y, fmt, hasAlpha); \
1318#define YUV2RGBWRAPPER(name, base, ext, fmt, hasAlpha) \
1319static void name ## ext ## _1_vsx(SwsInternal *c, const int16_t *buf0, \
1320 const int16_t *ubuf[2], const int16_t *vbuf[2], \
1321 const int16_t *abuf0, uint8_t *dest, int dstW, \
1322 int uvalpha, int y) \
1324 name ## base ## _1_vsx_template(c, buf0, ubuf, vbuf, abuf0, dest, \
1325 dstW, uvalpha, y, fmt, hasAlpha); \
1375 0x0, 0x10, 0x1, 0x18,
1376 0x2, 0x11, 0x3, 0x19,
1377 0x4, 0x12, 0x5, 0x1a,
1378 0x6, 0x13, 0x7, 0x1b };
1380 0x8, 0x14, 0x9, 0x1c,
1381 0xa, 0x15, 0xb, 0x1d,
1382 0xc, 0x16, 0xd, 0x1e,
1383 0xe, 0x17, 0xf, 0x1f };
1385 0x0, 0x18, 0x1, 0x10,
1386 0x2, 0x19, 0x3, 0x11,
1387 0x4, 0x1a, 0x5, 0x12,
1388 0x6, 0x1b, 0x7, 0x13 };
1390 0x8, 0x1c, 0x9, 0x14,
1391 0xa, 0x1d, 0xb, 0x15,
1392 0xc, 0x1e, 0xd, 0x16,
1393 0xe, 0x1f, 0xf, 0x17 };
1395 0x10, 0x0, 0x18, 0x1,
1396 0x11, 0x2, 0x19, 0x3,
1397 0x12, 0x4, 0x1a, 0x5,
1398 0x13, 0x6, 0x1b, 0x7 };
1400 0x14, 0x8, 0x1c, 0x9,
1401 0x15, 0xa, 0x1d, 0xb,
1402 0x16, 0xc, 0x1e, 0xd,
1403 0x17, 0xe, 0x1f, 0xf };
1405 vd1 = vec_packsu(vy1, vy2);
1406 vd2 = vec_packsu(vu, vv);
1410 tmp = vec_perm(vd1, vd2, yuyv1);
1411 vec_st(
tmp, 0, dest);
1412 tmp = vec_perm(vd1, vd2, yuyv2);
1413 vec_st(
tmp, 16, dest);
1416 tmp = vec_perm(vd1, vd2, yvyu1);
1417 vec_st(
tmp, 0, dest);
1418 tmp = vec_perm(vd1, vd2, yvyu2);
1419 vec_st(
tmp, 16, dest);
1422 tmp = vec_perm(vd1, vd2, uyvy1);
1423 vec_st(
tmp, 0, dest);
1424 tmp = vec_perm(vd1, vd2, uyvy2);
1425 vec_st(
tmp, 16, dest);
1432 const int16_t **lumSrc,
int lumFilterSize,
1433 const int16_t *chrFilter,
const int16_t **chrUSrc,
1434 const int16_t **chrVSrc,
int chrFilterSize,
1435 const int16_t **alpSrc, uint8_t *dest,
int dstW,
1442 const vec_s32 start = vec_splats(1 << 18);
1443 const vec_u32 shift19 = vec_splats(19U);
1445 for (
i = 0;
i < lumFilterSize;
i++)
1446 vlumFilter[
i] = vec_splats(lumFilter[
i]);
1447 for (
i = 0;
i < chrFilterSize;
i++)
1448 vchrFilter[
i] = vec_splats(chrFilter[
i]);
1450 for (
i = 0;
i < ((dstW + 1) >> 1);
i += 8) {
1460 for (j = 0; j < lumFilterSize; j++) {
1461 vv = vec_ld(0, &lumSrc[j][
i * 2]);
1462 tmp = vec_mule(vv, vlumFilter[j]);
1463 tmp2 = vec_mulo(vv, vlumFilter[j]);
1464 tmp3 = vec_mergeh(
tmp, tmp2);
1465 tmp4 = vec_mergel(
tmp, tmp2);
1467 vy32[0] = vec_adds(vy32[0], tmp3);
1468 vy32[1] = vec_adds(vy32[1], tmp4);
1470 vv = vec_ld(0, &lumSrc[j][(
i + 4) * 2]);
1471 tmp = vec_mule(vv, vlumFilter[j]);
1472 tmp2 = vec_mulo(vv, vlumFilter[j]);
1473 tmp3 = vec_mergeh(
tmp, tmp2);
1474 tmp4 = vec_mergel(
tmp, tmp2);
1476 vy32[2] = vec_adds(vy32[2], tmp3);
1477 vy32[3] = vec_adds(vy32[3], tmp4);
1480 for (j = 0; j < chrFilterSize; j++) {
1481 vv = vec_ld(0, &chrUSrc[j][
i]);
1482 tmp = vec_mule(vv, vchrFilter[j]);
1483 tmp2 = vec_mulo(vv, vchrFilter[j]);
1484 tmp3 = vec_mergeh(
tmp, tmp2);
1485 tmp4 = vec_mergel(
tmp, tmp2);
1490 vv = vec_ld(0, &chrVSrc[j][
i]);
1491 tmp = vec_mule(vv, vchrFilter[j]);
1492 tmp2 = vec_mulo(vv, vchrFilter[j]);
1493 tmp3 = vec_mergeh(
tmp, tmp2);
1494 tmp4 = vec_mergel(
tmp, tmp2);
1496 vv32[0] = vec_adds(vv32[0], tmp3);
1497 vv32[1] = vec_adds(vv32[1], tmp4);
1500 for (j = 0; j < 4; j++) {
1501 vy32[j] = vec_sra(vy32[j], shift19);
1503 for (j = 0; j < 2; j++) {
1504 vu32[j] = vec_sra(
vu32[j], shift19);
1505 vv32[j] = vec_sra(vv32[j], shift19);
1508 vy1 = vec_packs(vy32[0], vy32[1]);
1509 vy2 = vec_packs(vy32[2], vy32[3]);
1511 vv = vec_packs(vv32[0], vv32[1]);
1513 write422(vy1, vy2, vu, vv, &dest[
i * 4], target);
1517#define SETUP(x, buf0, buf1, alpha) { \
1518 x = vec_ld(0, buf0); \
1519 tmp = vec_mule(x, alpha); \
1520 tmp2 = vec_mulo(x, alpha); \
1521 tmp3 = vec_mergeh(tmp, tmp2); \
1522 tmp4 = vec_mergel(tmp, tmp2); \
1524 x = vec_ld(0, buf1); \
1525 tmp = vec_mule(x, alpha); \
1526 tmp2 = vec_mulo(x, alpha); \
1527 tmp5 = vec_mergeh(tmp, tmp2); \
1528 tmp6 = vec_mergel(tmp, tmp2); \
1530 tmp3 = vec_add(tmp3, tmp5); \
1531 tmp4 = vec_add(tmp4, tmp6); \
1533 tmp3 = vec_sra(tmp3, shift19); \
1534 tmp4 = vec_sra(tmp4, shift19); \
1535 x = vec_packs(tmp3, tmp4); \
1540 const int16_t *ubuf[2],
const int16_t *vbuf[2],
1541 const int16_t *abuf[2], uint8_t *dest,
int dstW,
1542 int yalpha,
int uvalpha,
int y,
1545 const int16_t *buf0 = buf[0], *buf1 = buf[1],
1546 *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
1547 *vbuf0 = vbuf[0], *vbuf1 = vbuf[1];
1548 const int16_t yalpha1 = 4096 - yalpha;
1549 const int16_t uvalpha1 = 4096 - uvalpha;
1552 const vec_s16 vyalpha1 = vec_splats(yalpha1);
1553 const vec_s16 vuvalpha1 = vec_splats(uvalpha1);
1554 const vec_u32 shift19 = vec_splats(19U);
1559 for (
i = 0;
i < ((dstW + 1) >> 1);
i += 8) {
1561 SETUP(vy1, &buf0[
i * 2], &buf1[
i * 2], vyalpha1)
1562 SETUP(vy2, &buf0[(
i + 4) * 2], &buf1[(
i + 4) * 2], vyalpha1)
1563 SETUP(vu, &ubuf0[
i], &ubuf1[
i], vuvalpha1)
1564 SETUP(vv, &vbuf0[
i], &vbuf1[
i], vuvalpha1)
1566 write422(vy1, vy2, vu, vv, &dest[
i * 4], target);
1574 const int16_t *ubuf[2],
const int16_t *vbuf[2],
1575 const int16_t *abuf0, uint8_t *dest,
int dstW,
1578 const int16_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0];
1580 const vec_s16 add64 = vec_splats((int16_t) 64);
1581 const vec_s16 add128 = vec_splats((int16_t) 128);
1582 const vec_u16 shift7 = vec_splat_u16(7);
1583 const vec_u16 shift8 = vec_splat_u16(8);
1586 if (uvalpha < 2048) {
1587 for (
i = 0;
i < ((dstW + 1) >> 1);
i += 8) {
1588 vy1 = vec_ld(0, &buf0[
i * 2]);
1589 vy2 = vec_ld(0, &buf0[(
i + 4) * 2]);
1590 vu = vec_ld(0, &ubuf0[
i]);
1591 vv = vec_ld(0, &vbuf0[
i]);
1593 vy1 = vec_add(vy1, add64);
1594 vy2 = vec_add(vy2, add64);
1595 vu = vec_add(vu, add64);
1596 vv = vec_add(vv, add64);
1598 vy1 = vec_sra(vy1, shift7);
1599 vy2 = vec_sra(vy2, shift7);
1600 vu = vec_sra(vu, shift7);
1601 vv = vec_sra(vv, shift7);
1603 write422(vy1, vy2, vu, vv, &dest[
i * 4], target);
1606 const int16_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1];
1607 for (
i = 0;
i < ((dstW + 1) >> 1);
i += 8) {
1608 vy1 = vec_ld(0, &buf0[
i * 2]);
1609 vy2 = vec_ld(0, &buf0[(
i + 4) * 2]);
1610 vu = vec_ld(0, &ubuf0[
i]);
1611 tmp = vec_ld(0, &ubuf1[
i]);
1612 vu = vec_adds(vu,
tmp);
1613 vv = vec_ld(0, &vbuf0[
i]);
1614 tmp = vec_ld(0, &vbuf1[
i]);
1615 vv = vec_adds(vv,
tmp);
1617 vy1 = vec_add(vy1, add64);
1618 vy2 = vec_add(vy2, add64);
1619 vu = vec_adds(vu, add128);
1620 vv = vec_adds(vv, add128);
1622 vy1 = vec_sra(vy1, shift7);
1623 vy2 = vec_sra(vy2, shift7);
1624 vu = vec_sra(vu, shift8);
1625 vv = vec_sra(vv, shift8);
1627 write422(vy1, vy2, vu, vv, &dest[
i * 4], target);
1632#define YUV2PACKEDWRAPPERX(name, base, ext, fmt) \
1633static void name ## ext ## _X_vsx(SwsInternal *c, const int16_t *lumFilter, \
1634 const int16_t **lumSrc, int lumFilterSize, \
1635 const int16_t *chrFilter, const int16_t **chrUSrc, \
1636 const int16_t **chrVSrc, int chrFilterSize, \
1637 const int16_t **alpSrc, uint8_t *dest, int dstW, \
1640 name ## base ## _X_vsx_template(c, lumFilter, lumSrc, lumFilterSize, \
1641 chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
1642 alpSrc, dest, dstW, y, fmt); \
1645#define YUV2PACKEDWRAPPER2(name, base, ext, fmt) \
1646YUV2PACKEDWRAPPERX(name, base, ext, fmt) \
1647static void name ## ext ## _2_vsx(SwsInternal *c, const int16_t *buf[2], \
1648 const int16_t *ubuf[2], const int16_t *vbuf[2], \
1649 const int16_t *abuf[2], uint8_t *dest, int dstW, \
1650 int yalpha, int uvalpha, int y) \
1652 name ## base ## _2_vsx_template(c, buf, ubuf, vbuf, abuf, \
1653 dest, dstW, yalpha, uvalpha, y, fmt); \
1656#define YUV2PACKEDWRAPPER(name, base, ext, fmt) \
1657YUV2PACKEDWRAPPER2(name, base, ext, fmt) \
1658static void name ## ext ## _1_vsx(SwsInternal *c, const int16_t *buf0, \
1659 const int16_t *ubuf[2], const int16_t *vbuf[2], \
1660 const int16_t *abuf0, uint8_t *dest, int dstW, \
1661 int uvalpha, int y) \
1663 name ## base ## _1_vsx_template(c, buf0, ubuf, vbuf, \
1664 abuf0, dest, dstW, uvalpha, \
1673 const uint8_t *
src,
int srcW,
int xInc)
1676 unsigned int xpos = 0, xx;
1679 vec_s16 vtmp, vtmp2, vtmp3, vtmp4;
1680 vec_u16 vd_l, vd_r, vcoord16[2];
1698 const vec_u32 vshift16 = vec_splats((uint32_t) 16);
1699 const vec_u16 vshift9 = vec_splat_u16(9);
1701 const vec_u16 vshift = vec_splat_u16(7);
1703 for (
i = 0;
i < dstWidth;
i += 16) {
1704 vcoord16[0] = vec_splats((uint16_t) xpos);
1705 vcoord16[1] = vec_splats((uint16_t) (xpos + xInc * 8));
1707 vcoord16[0] = vec_add(vcoord16[0], vadd16);
1708 vcoord16[1] = vec_add(vcoord16[1], vadd16);
1710 vcoord16[0] = vec_sr(vcoord16[0], vshift9);
1711 vcoord16[1] = vec_sr(vcoord16[1], vshift9);
1712 valpha = (
vec_s8) vec_pack(vcoord16[0], vcoord16[1]);
1715 vin = vec_vsx_ld(0, &
src[xx]);
1717 vcoord[0] = vec_splats(xpos & 0xffff);
1718 vcoord[1] = vec_splats((xpos & 0xffff) + xInc * 4);
1719 vcoord[2] = vec_splats((xpos & 0xffff) + xInc * 8);
1720 vcoord[3] = vec_splats((xpos & 0xffff) + xInc * 12);
1722 vcoord[0] = vec_add(vcoord[0], vadd);
1723 vcoord[1] = vec_add(vcoord[1], vadd);
1724 vcoord[2] = vec_add(vcoord[2], vadd);
1725 vcoord[3] = vec_add(vcoord[3], vadd);
1727 vcoord[0] = vec_sr(vcoord[0], vshift16);
1728 vcoord[1] = vec_sr(vcoord[1], vshift16);
1729 vcoord[2] = vec_sr(vcoord[2], vshift16);
1730 vcoord[3] = vec_sr(vcoord[3], vshift16);
1732 vcoord16[0] = vec_pack(vcoord[0], vcoord[1]);
1733 vcoord16[1] = vec_pack(vcoord[2], vcoord[3]);
1734 vperm = vec_pack(vcoord16[0], vcoord16[1]);
1736 vin = vec_perm(vin, vin, vperm);
1738 vin2 = vec_vsx_ld(1, &
src[xx]);
1739 vin2 = vec_perm(vin2, vin2, vperm);
1741 vmul = (
vec_s8) vec_sub(vin2, vin);
1742 vtmp = vec_mule(vmul, valpha);
1743 vtmp2 = vec_mulo(vmul, valpha);
1744 vtmp3 = vec_mergeh(vtmp, vtmp2);
1745 vtmp4 = vec_mergel(vtmp, vtmp2);
1749 vd_l = vec_sl(vd_l, vshift);
1750 vd_r = vec_sl(vd_r, vshift);
1752 vd_l = vec_add(vd_l, (
vec_u16) vtmp3);
1753 vd_r = vec_add(vd_r, (
vec_u16) vtmp4);
1760 for (
i=dstWidth-1; (
i*(
int64_t)xInc)>>16 >=srcW-1;
i--)
1764#define HCSCALE(in, out) \
1765 vin = vec_vsx_ld(0, &in[xx]); \
1766 vin = vec_perm(vin, vin, vperm); \
1768 vin2 = vec_vsx_ld(1, &in[xx]); \
1769 vin2 = vec_perm(vin2, vin2, vperm); \
1771 vtmp = vec_mule(vin, valphaxor); \
1772 vtmp2 = vec_mulo(vin, valphaxor); \
1773 vtmp3 = vec_mergeh(vtmp, vtmp2); \
1774 vtmp4 = vec_mergel(vtmp, vtmp2); \
1776 vtmp = vec_mule(vin2, valpha); \
1777 vtmp2 = vec_mulo(vin2, valpha); \
1778 vd_l = vec_mergeh(vtmp, vtmp2); \
1779 vd_r = vec_mergel(vtmp, vtmp2); \
1781 vd_l = vec_add(vd_l, vtmp3); \
1782 vd_r = vec_add(vd_r, vtmp4); \
1784 vec_st((vec_s16) vd_l, 0, &out[i]); \
1785 vec_st((vec_s16) vd_r, 0, &out[i + 8])
1788 int dstWidth,
const uint8_t *
src1,
1789 const uint8_t *
src2,
int srcW,
int xInc)
1792 unsigned int xpos = 0, xx;
1794 vec_u8 valpha, valphaxor;
1795 vec_u16 vtmp, vtmp2, vtmp3, vtmp4;
1796 vec_u16 vd_l, vd_r, vcoord16[2];
1798 const vec_u8 vxor = vec_splats((uint8_t) 127);
1815 const vec_u32 vshift16 = vec_splats((uint32_t) 16);
1816 const vec_u16 vshift9 = vec_splat_u16(9);
1818 for (
i = 0;
i < dstWidth;
i += 16) {
1819 vcoord16[0] = vec_splats((uint16_t) xpos);
1820 vcoord16[1] = vec_splats((uint16_t) (xpos + xInc * 8));
1822 vcoord16[0] = vec_add(vcoord16[0], vadd16);
1823 vcoord16[1] = vec_add(vcoord16[1], vadd16);
1825 vcoord16[0] = vec_sr(vcoord16[0], vshift9);
1826 vcoord16[1] = vec_sr(vcoord16[1], vshift9);
1827 valpha = vec_pack(vcoord16[0], vcoord16[1]);
1828 valphaxor = vec_xor(valpha, vxor);
1832 vcoord[0] = vec_splats(xpos & 0xffff);
1833 vcoord[1] = vec_splats((xpos & 0xffff) + xInc * 4);
1834 vcoord[2] = vec_splats((xpos & 0xffff) + xInc * 8);
1835 vcoord[3] = vec_splats((xpos & 0xffff) + xInc * 12);
1837 vcoord[0] = vec_add(vcoord[0], vadd);
1838 vcoord[1] = vec_add(vcoord[1], vadd);
1839 vcoord[2] = vec_add(vcoord[2], vadd);
1840 vcoord[3] = vec_add(vcoord[3], vadd);
1842 vcoord[0] = vec_sr(vcoord[0], vshift16);
1843 vcoord[1] = vec_sr(vcoord[1], vshift16);
1844 vcoord[2] = vec_sr(vcoord[2], vshift16);
1845 vcoord[3] = vec_sr(vcoord[3], vshift16);
1847 vcoord16[0] = vec_pack(vcoord[0], vcoord[1]);
1848 vcoord16[1] = vec_pack(vcoord[2], vcoord[3]);
1849 vperm = vec_pack(vcoord16[0], vcoord16[1]);
1856 for (
i=dstWidth-1; (
i*(
int64_t)xInc)>>16 >=srcW-1;
i--) {
1857 dst1[
i] =
src1[srcW-1]*128;
1858 dst2[
i] =
src2[srcW-1]*128;
1866 const int32_t *filterPos,
int filterSize)
1871 const uint16_t *
src = (
const uint16_t *)
_src;
1872 int bits =
desc->comp[0].depth - 1;
1875 vec_s32 vout, vtmp, vtmp2, vfilter32_l, vfilter32_r;
1877 const vec_u8 vunusedtab[8] = {
1878 (
vec_u8) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
1879 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf},
1880 (
vec_u8) {0x0, 0x1, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
1881 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10},
1882 (
vec_u8) {0x0, 0x1, 0x2, 0x3, 0x10, 0x10, 0x10, 0x10,
1883 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10},
1884 (
vec_u8) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x10, 0x10,
1885 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10},
1886 (
vec_u8) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
1887 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10},
1888 (
vec_u8) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
1889 0x8, 0x9, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10},
1890 (
vec_u8) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
1891 0x8, 0x9, 0xa, 0xb, 0x10, 0x10, 0x10, 0x10},
1892 (
vec_u8) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
1893 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0x10, 0x10},
1895 const vec_u8 vunused = vunusedtab[filterSize % 8];
1903 if (filterSize == 1) {
1904 for (
i = 0;
i < dstW;
i++) {
1905 int srcPos = filterPos[
i];
1908 for (j = 0; j < filterSize; j++) {
1915 for (
i = 0;
i < dstW;
i++) {
1916 const int srcPos = filterPos[
i];
1917 vout = vec_splat_s32(0);
1918 for (j = 0; j < filterSize; j += 8) {
1919 vin = (
vec_s16) vec_vsx_ld(0, &
src[srcPos + j]);
1920 if (j + 8 > filterSize)
1923 vfilter = vec_vsx_ld(0, &
filter[filterSize *
i + j]);
1924 vfilter32_l = vec_unpackh(vfilter);
1925 vfilter32_r = vec_unpackl(vfilter);
1930 vtmp = vec_mul(vtmp, vfilter32_l);
1931 vtmp2 = vec_mul(vtmp2, vfilter32_r);
1933 vout = vec_adds(vout, vtmp);
1934 vout = vec_adds(vout, vtmp2);
1937 dst[
i] =
FFMIN(vout[3] >> sh, (1 << 19) - 1);
1944 const int32_t *filterPos,
int filterSize)
1948 const uint16_t *
src = (
const uint16_t *)
_src;
1949 int sh =
desc->comp[0].depth - 1;
1951 vec_s32 vout, vtmp, vtmp2, vfilter32_l, vfilter32_r;
1953 const vec_u8 vunusedtab[8] = {
1954 (
vec_u8) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
1955 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf},
1956 (
vec_u8) {0x0, 0x1, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
1957 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10},
1958 (
vec_u8) {0x0, 0x1, 0x2, 0x3, 0x10, 0x10, 0x10, 0x10,
1959 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10},
1960 (
vec_u8) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x10, 0x10,
1961 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10},
1962 (
vec_u8) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
1963 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10},
1964 (
vec_u8) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
1965 0x8, 0x9, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10},
1966 (
vec_u8) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
1967 0x8, 0x9, 0xa, 0xb, 0x10, 0x10, 0x10, 0x10},
1968 (
vec_u8) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
1969 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0x10, 0x10},
1971 const vec_u8 vunused = vunusedtab[filterSize % 8];
1979 if (filterSize == 1) {
1980 for (
i = 0;
i < dstW;
i++) {
1981 int srcPos = filterPos[
i];
1984 for (j = 0; j < filterSize; j++) {
1991 for (
i = 0;
i < dstW;
i++) {
1992 const int srcPos = filterPos[
i];
1993 vout = vec_splat_s32(0);
1994 for (j = 0; j < filterSize; j += 8) {
1995 vin = (
vec_s16) vec_vsx_ld(0, &
src[srcPos + j]);
1996 if (j + 8 > filterSize)
1999 vfilter = vec_vsx_ld(0, &
filter[filterSize *
i + j]);
2000 vfilter32_l = vec_unpackh(vfilter);
2001 vfilter32_r = vec_unpackl(vfilter);
2006 vtmp = vec_mul(vtmp, vfilter32_l);
2007 vtmp2 = vec_mul(vtmp2, vfilter32_r);
2009 vout = vec_adds(vout, vtmp);
2010 vout = vec_adds(vout, vtmp2);
2013 dst[
i] =
FFMIN(vout[3] >> sh, (1 << 15) - 1);
2027 if (
c->srcBpc == 8) {
2028 if (
c->dstBpc <= 14) {
2029 c->hyScale =
c->hcScale = hScale_real_vsx;
2044 c->yuv2planeX = yuv2planeX_vsx;
2049 switch (
c->dstBpc) {
2055 c->yuv2plane1 =
isBE(dstFormat) ? yuv2plane1_9BE_vsx : yuv2plane1_9LE_vsx;
2056 c->yuv2planeX =
isBE(dstFormat) ? yuv2planeX_9BE_vsx : yuv2planeX_9LE_vsx;
2059 c->yuv2plane1 =
isBE(dstFormat) ? yuv2plane1_10BE_vsx : yuv2plane1_10LE_vsx;
2060 c->yuv2planeX =
isBE(dstFormat) ? yuv2planeX_10BE_vsx : yuv2planeX_10LE_vsx;
2063 c->yuv2plane1 =
isBE(dstFormat) ? yuv2plane1_12BE_vsx : yuv2plane1_12LE_vsx;
2064 c->yuv2planeX =
isBE(dstFormat) ? yuv2planeX_12BE_vsx : yuv2planeX_12LE_vsx;
2067 c->yuv2plane1 =
isBE(dstFormat) ? yuv2plane1_14BE_vsx : yuv2plane1_14LE_vsx;
2068 c->yuv2planeX =
isBE(dstFormat) ? yuv2planeX_14BE_vsx : yuv2planeX_14LE_vsx;
2071 c->yuv2plane1 =
isBE(dstFormat) ? yuv2plane1_16BE_vsx : yuv2plane1_16LE_vsx;
2074 c->yuv2planeX =
isBE(dstFormat) ? yuv2planeX_16BE_vsx : yuv2planeX_16LE_vsx;
2087 switch (dstFormat) {
2090 c->yuv2packed1 = yuv2rgb24_full_1_vsx;
2091 c->yuv2packed2 = yuv2rgb24_full_2_vsx;
2092 c->yuv2packedX = yuv2rgb24_full_X_vsx;
2097 c->yuv2packed1 = yuv2bgr24_full_1_vsx;
2098 c->yuv2packed2 = yuv2bgr24_full_2_vsx;
2099 c->yuv2packedX = yuv2bgr24_full_X_vsx;
2104 if (!
c->needAlpha) {
2105 c->yuv2packed1 = yuv2bgrx32_full_1_vsx;
2106 c->yuv2packed2 = yuv2bgrx32_full_2_vsx;
2107 c->yuv2packedX = yuv2bgrx32_full_X_vsx;
2113 if (!
c->needAlpha) {
2114 c->yuv2packed1 = yuv2rgbx32_full_1_vsx;
2115 c->yuv2packed2 = yuv2rgbx32_full_2_vsx;
2116 c->yuv2packedX = yuv2rgbx32_full_X_vsx;
2122 if (!
c->needAlpha) {
2123 c->yuv2packed1 = yuv2xrgb32_full_1_vsx;
2124 c->yuv2packed2 = yuv2xrgb32_full_2_vsx;
2125 c->yuv2packedX = yuv2xrgb32_full_X_vsx;
2131 if (!
c->needAlpha) {
2132 c->yuv2packed1 = yuv2xbgr32_full_1_vsx;
2133 c->yuv2packed2 = yuv2xbgr32_full_2_vsx;
2134 c->yuv2packedX = yuv2xbgr32_full_X_vsx;
2140 switch (dstFormat) {
2142 c->yuv2packed1 = yuv2yuyv422_1_vsx;
2143 c->yuv2packed2 = yuv2yuyv422_2_vsx;
2144 c->yuv2packedX = yuv2yuyv422_X_vsx;
2147 c->yuv2packed1 = yuv2yvyu422_1_vsx;
2148 c->yuv2packed2 = yuv2yvyu422_2_vsx;
2149 c->yuv2packedX = yuv2yvyu422_X_vsx;
2152 c->yuv2packed1 = yuv2uyvy422_1_vsx;
2153 c->yuv2packed2 = yuv2uyvy422_2_vsx;
2154 c->yuv2packedX = yuv2uyvy422_X_vsx;
2158 if (!
c->needAlpha) {
2159 c->yuv2packed1 = yuv2bgrx32_1_vsx;
2160 c->yuv2packed2 = yuv2bgrx32_2_vsx;
2166 if (!
c->needAlpha) {
2167 c->yuv2packed1 = yuv2rgbx32_1_vsx;
2168 c->yuv2packed2 = yuv2rgbx32_2_vsx;
2174 if (!
c->needAlpha) {
2175 c->yuv2packed1 = yuv2xrgb32_1_vsx;
2176 c->yuv2packed2 = yuv2xrgb32_2_vsx;
2182 if (!
c->needAlpha) {
2183 c->yuv2packed1 = yuv2xbgr32_1_vsx;
2184 c->yuv2packed2 = yuv2xbgr32_2_vsx;
2190 c->yuv2packed1 = yuv2rgb24_1_vsx;
2191 c->yuv2packed2 = yuv2rgb24_2_vsx;
2196 c->yuv2packed1 = yuv2bgr24_1_vsx;
2197 c->yuv2packed2 = yuv2bgr24_2_vsx;
uint8_t ptrdiff_t const uint8_t * _src
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static double val(void *priv, double ch)
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
static const uint8_t shifts[2][12]
#define i(width, name, range_min, range_max)
static const uint8_t bits[8]
@ SWS_FAST_BILINEAR
Scaler selection options.
@ SWS_FULL_CHR_H_INT
Perform full chroma upsampling when upscaling to RGB.
static int shift(int a, int b)
static const uint8_t shift2[6]
Macro definitions for various function/variable attributes.
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_POWER8
ISA 2.07.
#define LOCAL_ALIGNED(a, t, v,...)
#define YUV2RGBWRAPPERX(name, base, ext, fmt, hasAlpha)
#define YUV2RGBWRAPPER(name, base, ext, fmt, hasAlpha)
#define YUV2RGBWRAPPERX2(name, base, ext, fmt, hasAlpha)
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...
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
static av_always_inline int isDataInHighBits(enum AVPixelFormat pix_fmt)
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)
static void hScale16To15_vsx(SwsInternal *c, int16_t *dst, int dstW, const uint8_t *_src, const int16_t *filter, const int32_t *filterPos, int filterSize)
static av_always_inline void yuv2plane1_16_vsx(const int32_t *src, uint16_t *dest, int dstW, const int big_endian, int output_bits)
static void yuv2planeX_nbps_u(const int16_t *filter, int filterSize, const int16_t **src, uint16_t *dest, int dstW, int big_endian, int output_bits, int start)
static av_always_inline void yuv2rgb_full_2_vsx_template(SwsInternal *c, const int16_t *buf[2], const int16_t *ubuf[2], const int16_t *vbuf[2], const int16_t *abuf[2], uint8_t *dest, int dstW, int yalpha, int uvalpha, int y, enum AVPixelFormat target, int hasAlpha)
static void hScale16To19_vsx(SwsInternal *c, int16_t *_dst, int dstW, const uint8_t *_src, const int16_t *filter, const int32_t *filterPos, int filterSize)
static void yuv2planeX_nbps_vsx(const int16_t *filter, int filterSize, const int16_t **src, uint16_t *dest, int dstW, int big_endian, int output_bits)
static av_always_inline void yuv2422_X_vsx_template(SwsInternal *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int16_t **chrUSrc, const int16_t **chrVSrc, int chrFilterSize, const int16_t **alpSrc, uint8_t *dest, int dstW, int y, enum AVPixelFormat target)
static av_always_inline void yuv2rgb_1_vsx_template(SwsInternal *c, const int16_t *buf0, const int16_t *ubuf[2], const int16_t *vbuf[2], const int16_t *abuf0, uint8_t *dest, int dstW, int uvalpha, int y, enum AVPixelFormat target, int hasAlpha)
static void yuv2plane1_8_u(const int16_t *src, uint8_t *dest, int dstW, const uint8_t *dither, int offset, int start)
av_cold void ff_sws_init_swscale_vsx(SwsInternal *c)
#define output_pixel(pos, val)
static av_always_inline void yuv2rgb_full_1_vsx_template(SwsInternal *c, const int16_t *buf0, const int16_t *ubuf[2], const int16_t *vbuf[2], const int16_t *abuf0, uint8_t *dest, int dstW, int uvalpha, int y, enum AVPixelFormat target, int hasAlpha)
static void yuv2plane1_8_vsx(const int16_t *src, uint8_t *dest, int dstW, const uint8_t *dither, int offset)
static av_always_inline void yuv2422_1_vsx_template(SwsInternal *c, const int16_t *buf0, const int16_t *ubuf[2], const int16_t *vbuf[2], const int16_t *abuf0, uint8_t *dest, int dstW, int uvalpha, int y, enum AVPixelFormat target)
static av_always_inline void yuv2plane1_nbps_vsx(const int16_t *src, uint16_t *dest, int dstW, const int big_endian, const int output_bits)
static void yuv2plane1_nbps_u(const int16_t *src, uint16_t *dest, int dstW, int big_endian, int output_bits, int start)
#define yuv2NBPSX(bits, BE_LE, is_be, template_size, typeX_t)
static void hcscale_fast_vsx(SwsInternal *c, int16_t *dst1, int16_t *dst2, int dstWidth, const uint8_t *src1, const uint8_t *src2, int srcW, int xInc)
#define yuv2NBPS(bits, BE_LE, is_be, template_size, typeX_t)
static av_always_inline void yuv2rgb_2_vsx_template(SwsInternal *c, const int16_t *buf[2], const int16_t *ubuf[2], const int16_t *vbuf[2], const int16_t *abuf[2], uint8_t *dest, int dstW, int yalpha, int uvalpha, int y, enum AVPixelFormat target, int hasAlpha)
#define YUV2RGBWRAPPER(name, base, ext, fmt, hasAlpha)
static av_always_inline void write422(const vec_s16 vy1, const vec_s16 vy2, const vec_s16 vu, const vec_s16 vv, uint8_t *dest, const enum AVPixelFormat target)
static av_always_inline void yuv2422_2_vsx_template(SwsInternal *c, const int16_t *buf[2], const int16_t *ubuf[2], const int16_t *vbuf[2], const int16_t *abuf[2], uint8_t *dest, int dstW, int yalpha, int uvalpha, int y, enum AVPixelFormat target)
#define SETUP(x, buf0, alpha1, buf1, alpha)
static void yuv2plane1_16_u(const int32_t *src, uint16_t *dest, int dstW, int big_endian, int output_bits, int start)
#define yuv2NBPS1(bits, BE_LE, is_be, template_size, typeX_t)
static void hyscale_fast_vsx(SwsInternal *c, int16_t *dst, int dstWidth, const uint8_t *src, int srcW, int xInc)
#define YUV2PACKEDWRAPPER(name, base, ext, fmt)
void(* filter)(uint8_t *src, ptrdiff_t stride, int qscale)
Contains misc utility macros and inline functions.
static const uint16_t dither[8][8]
static int bias(int x, int c)