FFmpeg  4.4.9
swscale_vsx.c
Go to the documentation of this file.
1 /*
2  * AltiVec-enhanced yuv2yuvX
3  *
4  * Copyright (C) 2004 Romain Dolbeau <romain@dolbeau.org>
5  * based on the equivalent C code in swscale.c
6  *
7  * This file is part of FFmpeg.
8  *
9  * FFmpeg is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * FFmpeg is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with FFmpeg; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  */
23 
24 #include <inttypes.h>
25 
26 #include "config.h"
27 #include "libswscale/swscale.h"
29 #include "libavutil/attributes.h"
30 #include "libavutil/cpu.h"
31 #include "libavutil/mem_internal.h"
32 #include "yuv2rgb_altivec.h"
34 
35 #if HAVE_VSX
36 #define vzero vec_splat_s32(0)
37 
38 #if !HAVE_BIGENDIAN
39 #define GET_LS(a,b,c,s) {\
40  ls = a;\
41  a = vec_vsx_ld(((b) << 1) + 16, s);\
42  }
43 
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);\
54  } while (0)
55 
56 #define LOAD_FILTER(vf,f) {\
57  vf = vec_splats(f[j]);\
58 }
59 #define LOAD_L1(ll1,s,p){\
60  ll1 = vec_vsx_ld(xoffset, s);\
61 }
62 
63 // The 3 above is 2 (filterSize == 4) + 1 (sizeof(short) == 2).
64 
65 // The neat trick: We only care for half the elements,
66 // high or low depending on (i<<3)%16 (it's 0 or 8 here),
67 // and we're going to use vec_mule, so we choose
68 // carefully how to "unpack" the elements into the even slots.
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);\
72 }
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);\
77 }
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);\
81 }
82 
83 #define FUNC(name) name ## _vsx
84 #include "swscale_ppc_template.c"
85 #undef FUNC
86 
87 #undef vzero
88 
89 #endif /* !HAVE_BIGENDIAN */
90 
91 static void yuv2plane1_8_u(const int16_t *src, uint8_t *dest, int dstW,
92  const uint8_t *dither, int offset, int start)
93 {
94  int i;
95  for (i = start; i < dstW; i++) {
96  int val = (src[i] + dither[(i + offset) & 7]) >> 7;
97  dest[i] = av_clip_uint8(val);
98  }
99 }
100 
101 static void yuv2plane1_8_vsx(const int16_t *src, uint8_t *dest, int dstW,
102  const uint8_t *dither, int offset)
103 {
104  const int dst_u = -(uintptr_t)dest & 15;
105  int i, j;
106  LOCAL_ALIGNED(16, int16_t, val, [16]);
107  const vec_u16 shifts = (vec_u16) {7, 7, 7, 7, 7, 7, 7, 7};
108  vec_s16 vi, vileft, ditherleft, ditherright;
109  vec_u8 vd;
110 
111  for (j = 0; j < 16; j++) {
112  val[j] = dither[(dst_u + offset + j) & 7];
113  }
114 
115  ditherleft = vec_ld(0, val);
116  ditherright = vec_ld(0, &val[8]);
117 
118  yuv2plane1_8_u(src, dest, dst_u, dither, offset, 0);
119 
120  for (i = dst_u; i < dstW - 15; i += 16) {
121 
122  vi = vec_vsx_ld(0, &src[i]);
123  vi = vec_adds(ditherleft, vi);
124  vileft = vec_sra(vi, shifts);
125 
126  vi = vec_vsx_ld(0, &src[i + 8]);
127  vi = vec_adds(ditherright, vi);
128  vi = vec_sra(vi, shifts);
129 
130  vd = vec_packsu(vileft, vi);
131  vec_st(vd, 0, &dest[i]);
132  }
133 
134  yuv2plane1_8_u(src, dest, dstW, dither, offset, i);
135 }
136 
137 #if !HAVE_BIGENDIAN
138 
139 #define output_pixel(pos, val) \
140  if (big_endian) { \
141  AV_WB16(pos, av_clip_uintp2(val >> shift, output_bits)); \
142  } else { \
143  AV_WL16(pos, av_clip_uintp2(val >> shift, output_bits)); \
144  }
145 
146 static void yuv2plane1_nbps_u(const int16_t *src, uint16_t *dest, int dstW,
147  int big_endian, int output_bits, int start)
148 {
149  int i;
150  int shift = 15 - output_bits;
151 
152  for (i = start; i < dstW; i++) {
153  int val = src[i] + (1 << (shift - 1));
154  output_pixel(&dest[i], val);
155  }
156 }
157 
158 static av_always_inline void yuv2plane1_nbps_vsx(const int16_t *src,
159  uint16_t *dest, int dstW,
160  const int big_endian,
161  const int output_bits)
162 {
163  const int dst_u = -(uintptr_t)dest & 7;
164  const int shift = 15 - output_bits;
165  const int add = (1 << (shift - 1));
166  const int clip = (1 << output_bits) - 1;
167  const vec_u16 vadd = (vec_u16) {add, add, add, add, add, add, add, add};
168  const vec_u16 vswap = (vec_u16) vec_splat_u16(big_endian ? 8 : 0);
169  const vec_u16 vshift = (vec_u16) vec_splat_u16(shift);
170  const vec_u16 vlargest = (vec_u16) {clip, clip, clip, clip, clip, clip, clip, clip};
171  vec_u16 v;
172  int i;
173 
174  yuv2plane1_nbps_u(src, dest, dst_u, big_endian, output_bits, 0);
175 
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]);
183  }
184 
185  yuv2plane1_nbps_u(src, dest, dstW, big_endian, output_bits, i);
186 }
187 
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)
191 {
192  int i;
193  int shift = 11 + 16 - output_bits;
194 
195  for (i = start; i < dstW; i++) {
196  int val = 1 << (shift - 1);
197  int j;
198 
199  for (j = 0; j < filterSize; j++)
200  val += src[j][i] * filter[j];
201 
202  output_pixel(&dest[i], val);
203  }
204 }
205 
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)
209 {
210  const int dst_u = -(uintptr_t)dest & 7;
211  const int shift = 11 + 16 - output_bits;
212  const int add = (1 << (shift - 1));
213  const int clip = (1 << output_bits) - 1;
214  const uint16_t swap = big_endian ? 8 : 0;
215  const vec_u32 vadd = (vec_u32) {add, add, add, add};
216  const vec_u32 vshift = (vec_u32) {shift, shift, shift, shift};
217  const vec_u16 vswap = (vec_u16) {swap, swap, swap, swap, swap, swap, swap, swap};
218  const vec_u16 vlargest = (vec_u16) {clip, clip, clip, clip, clip, clip, clip, clip};
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};
221  vec_s16 vfilter[MAX_FILTER_SIZE], vin;
222  vec_u16 v;
223  vec_u32 vleft, vright, vtmp;
224  int i, j;
225 
226  for (i = 0; i < filterSize; i++) {
227  vfilter[i] = (vec_s16) {filter[i], filter[i], filter[i], filter[i],
228  filter[i], filter[i], filter[i], filter[i]};
229  }
230 
231  yuv2planeX_nbps_u(filter, filterSize, src, dest, dst_u, big_endian, output_bits, 0);
232 
233  for (i = dst_u; i < dstW - 7; i += 8) {
234  vleft = vright = vadd;
235 
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);
242  }
243 
244  vleft = vec_sra(vleft, vshift);
245  vright = vec_sra(vright, vshift);
246  v = vec_packsu(vleft, vright);
247  v = (vec_u16) vec_max((vec_s16) v, vzero);
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]);
252  }
253 
254  yuv2planeX_nbps_u(filter, filterSize, src, dest, dstW, big_endian, output_bits, i);
255 }
256 
257 
258 #undef output_pixel
259 
260 #define output_pixel(pos, val, bias, signedness) \
261  if (big_endian) { \
262  AV_WB16(pos, bias + av_clip_ ## signedness ## 16(val >> shift)); \
263  } else { \
264  AV_WL16(pos, bias + av_clip_ ## signedness ## 16(val >> shift)); \
265  }
266 
267 static void yuv2plane1_16_u(const int32_t *src, uint16_t *dest, int dstW,
268  int big_endian, int output_bits, int start)
269 {
270  int i;
271  const int shift = 3;
272 
273  for (i = start; i < dstW; i++) {
274  int val = src[i] + (1 << (shift - 1));
275  output_pixel(&dest[i], val, 0, uint);
276  }
277 }
278 
279 static av_always_inline void yuv2plane1_16_vsx(const int32_t *src,
280  uint16_t *dest, int dstW,
281  const int big_endian,
282  int output_bits)
283 {
284  const int dst_u = -(uintptr_t)dest & 7;
285  const int shift = 3;
286  const int add = (1 << (shift - 1));
287  const vec_u32 vadd = (vec_u32) {add, add, add, add};
288  const vec_u16 vswap = (vec_u16) vec_splat_u16(big_endian ? 8 : 0);
289  const vec_u32 vshift = (vec_u32) vec_splat_u32(shift);
290  vec_u32 v, v2;
291  vec_u16 vd;
292  int i;
293 
294  yuv2plane1_16_u(src, dest, dst_u, big_endian, output_bits, 0);
295 
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);
300 
301  v2 = vec_vsx_ld(0, (const uint32_t *) &src[i + 4]);
302  v2 = vec_add(v2, vadd);
303  v2 = vec_sr(v2, vshift);
304 
305  vd = vec_packsu(v, v2);
306  vd = vec_rl(vd, vswap);
307 
308  vec_st(vd, 0, &dest[i]);
309  }
310 
311  yuv2plane1_16_u(src, dest, dstW, big_endian, output_bits, i);
312 }
313 
314 #if HAVE_POWER8
315 
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)
319 {
320  int i;
321  int shift = 15;
322 
323  for (i = start; i < dstW; i++) {
324  int val = 1 << (shift - 1);
325  int j;
326 
327  /* range of val is [0,0x7FFFFFFF], so 31 bits, but with lanczos/spline
328  * filters (or anything with negative coeffs, the range can be slightly
329  * wider in both directions. To account for this overflow, we subtract
330  * a constant so it always fits in the signed range (assuming a
331  * reasonable filterSize), and re-add that at the end. */
332  val -= 0x40000000;
333  for (j = 0; j < filterSize; j++)
334  val += src[j][i] * (unsigned)filter[j];
335 
336  output_pixel(&dest[i], val, 0x8000, int);
337  }
338 }
339 
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)
343 {
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;
349  const vec_u32 vadd = (vec_u32) {add, add, add, add};
350  const vec_u32 vshift = (vec_u32) {shift, shift, shift, shift};
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};
353  vec_s32 vfilter[MAX_FILTER_SIZE];
354  vec_u16 v;
355  vec_u32 vleft, vright, vtmp;
356  vec_s32 vin32l, vin32r;
357  int i, j;
358 
359  for (i = 0; i < filterSize; i++) {
360  vfilter[i] = (vec_s32) {filter[i], filter[i], filter[i], filter[i]};
361  }
362 
363  yuv2planeX_16_u(filter, filterSize, src, dest, dst_u, big_endian, output_bits, 0);
364 
365  for (i = dst_u; i < dstW - 7; i += 8) {
366  vleft = vright = vadd;
367 
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]);
371 
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);
376  }
377 
378  vleft = vec_sra(vleft, vshift);
379  vright = vec_sra(vright, vshift);
380  v = (vec_u16) vec_packs((vec_s32) vleft, (vec_s32) vright);
381  v = vec_add(v, vbias);
382  v = vec_rl(v, vswap);
383  vec_st(v, 0, &dest[i]);
384  }
385 
386  yuv2planeX_16_u(filter, filterSize, src, dest, dstW, big_endian, output_bits, i);
387 }
388 
389 #endif /* HAVE_POWER8 */
390 
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)
394 
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) \
399 { \
400  yuv2plane1_ ## template_size ## _vsx((const typeX_t *) src, \
401  (uint16_t *) dest, dstW, is_be, bits); \
402 }
403 
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)\
408 { \
409  yuv2planeX_## template_size ## _vsx(filter, \
410  filterSize, (const typeX_t **) src, \
411  (uint16_t *) dest, dstW, is_be, bits); \
412 }
413 
414 yuv2NBPS( 9, BE, 1, nbps, int16_t)
415 yuv2NBPS( 9, LE, 0, nbps, int16_t)
416 yuv2NBPS(10, BE, 1, nbps, int16_t)
417 yuv2NBPS(10, LE, 0, nbps, int16_t)
418 yuv2NBPS(12, BE, 1, nbps, int16_t)
419 yuv2NBPS(12, LE, 0, nbps, int16_t)
420 yuv2NBPS(14, BE, 1, nbps, int16_t)
421 yuv2NBPS(14, LE, 0, nbps, int16_t)
422 
423 yuv2NBPS1(16, BE, 1, 16, int32_t)
424 yuv2NBPS1(16, LE, 0, 16, int32_t)
425 #if HAVE_POWER8
426 yuv2NBPSX(16, BE, 1, 16, int32_t)
427 yuv2NBPSX(16, LE, 0, 16, int32_t)
428 #endif
429 
430 #define WRITERGB \
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); \
437 \
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); \
444 \
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); \
451 \
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); \
458 \
459  switch(target) { \
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); \
466 \
467  vec_vsx_st(out0, 0, dest); \
468  vec_vsx_st(out1, 0, tmp_out); \
469  memcpy(dest + 16, tmp_out, 8); \
470 \
471  dest += 24; \
472  break; } \
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); \
479 \
480  vec_vsx_st(out0, 0, dest); \
481  vec_vsx_st(out1, 0, tmp_out); \
482  memcpy(dest + 16, tmp_out, 8); \
483 \
484  dest += 24; \
485  break; } \
486  case AV_PIX_FMT_BGRA: \
487  out0 = vec_mergeh(bd, gd); \
488  out1 = vec_mergeh(rd, ad); \
489 \
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); \
494 \
495  dest += 32; \
496  break; \
497  case AV_PIX_FMT_RGBA: \
498  out0 = vec_mergeh(rd, gd); \
499  out1 = vec_mergeh(bd, ad); \
500 \
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); \
505 \
506  dest += 32; \
507  break; \
508  case AV_PIX_FMT_ARGB: \
509  out0 = vec_mergeh(ad, rd); \
510  out1 = vec_mergeh(gd, bd); \
511 \
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); \
516 \
517  dest += 32; \
518  break; \
519  case AV_PIX_FMT_ABGR: \
520  out0 = vec_mergeh(ad, bd); \
521  out1 = vec_mergeh(gd, rd); \
522 \
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); \
527 \
528  dest += 32; \
529  break; \
530  }
531 
532 static av_always_inline void
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,
538  int dstW, int y, enum AVPixelFormat target, int hasAlpha)
539 {
540  vec_s16 vv;
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;
543  vec_s32 tmp, tmp2, tmp3, tmp4;
544  vec_u16 rd16, gd16, bd16;
545  vec_u8 rd, bd, gd, ad, out0, out1, tmp8;
546  vec_s16 vlumFilter[MAX_FILTER_SIZE], vchrFilter[MAX_FILTER_SIZE];
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);
561  int i, j;
562 
563  // Various permutations
564  const vec_u8 perm3rg0 = (vec_u8) {0x0, 0x10, 0,
565  0x1, 0x11, 0,
566  0x2, 0x12, 0,
567  0x3, 0x13, 0,
568  0x4, 0x14, 0,
569  0x5 };
570  const vec_u8 perm3rg1 = (vec_u8) { 0x15, 0,
571  0x6, 0x16, 0,
572  0x7, 0x17, 0 };
573  const vec_u8 perm3tb0 = (vec_u8) {0x0, 0x1, 0x10,
574  0x3, 0x4, 0x11,
575  0x6, 0x7, 0x12,
576  0x9, 0xa, 0x13,
577  0xc, 0xd, 0x14,
578  0xf };
579  const vec_u8 perm3tb1 = (vec_u8) { 0x0, 0x15,
580  0x2, 0x3, 0x16,
581  0x5, 0x6, 0x17 };
582 
583  ad = vec_splats((uint8_t) 255);
584 
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]);
589 
590  for (i = 0; i < dstW; i += 8) {
591  vy32_l =
592  vy32_r = ystart;
593  vu32_l =
594  vu32_r =
595  vv32_l =
596  vv32_r = uvstart;
597 
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);
604 
605  vy32_l = vec_adds(vy32_l, tmp3);
606  vy32_r = vec_adds(vy32_r, tmp4);
607  }
608 
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);
615 
616  vu32_l = vec_adds(vu32_l, tmp3);
617  vu32_r = vec_adds(vu32_r, tmp4);
618 
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);
624 
625  vv32_l = vec_adds(vv32_l, tmp3);
626  vv32_r = vec_adds(vv32_r, tmp4);
627  }
628 
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);
635 
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);
642 
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);
655 
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);
660 
661  WRITERGB
662  }
663 }
664 
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); \
671 \
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); \
677 \
678  tmp3 = vec_add(tmp3, tmp5); \
679  tmp4 = vec_add(tmp4, tmp6); \
680 }
681 
682 
683 static av_always_inline void
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,
688  enum AVPixelFormat target, int hasAlpha)
689 {
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;
700  vec_s32 tmp, tmp2, tmp3, tmp4, tmp5, tmp6;
701  vec_u16 rd16, gd16, bd16;
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);
722  int i;
723 
724  // Various permutations
725  const vec_u8 perm3rg0 = (vec_u8) {0x0, 0x10, 0,
726  0x1, 0x11, 0,
727  0x2, 0x12, 0,
728  0x3, 0x13, 0,
729  0x4, 0x14, 0,
730  0x5 };
731  const vec_u8 perm3rg1 = (vec_u8) { 0x15, 0,
732  0x6, 0x16, 0,
733  0x7, 0x17, 0 };
734  const vec_u8 perm3tb0 = (vec_u8) {0x0, 0x1, 0x10,
735  0x3, 0x4, 0x11,
736  0x6, 0x7, 0x12,
737  0x9, 0xa, 0x13,
738  0xc, 0xd, 0x14,
739  0xf };
740  const vec_u8 perm3tb1 = (vec_u8) { 0x0, 0x15,
741  0x2, 0x3, 0x16,
742  0x5, 0x6, 0x17 };
743 
744  av_assert2(yalpha <= 4096U);
745  av_assert2(uvalpha <= 4096U);
746 
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);
751 
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);
757 
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);
763 
764  if (hasAlpha) {
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);
772  } else {
773  ad = vec_splats((uint8_t) 255);
774  }
775 
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);
782 
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);
795 
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);
800 
801  WRITERGB
802  }
803 }
804 
805 static av_always_inline void
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,
810  enum AVPixelFormat target, int hasAlpha)
811 {
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;
822  vec_s32 tmp, tmp2, tmp3, tmp4, tmp5, tmp6;
823  vec_u16 rd16, gd16, bd16;
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);
844  int i;
845 
846  // Various permutations
847  const vec_u8 doubleleft = (vec_u8) {0, 1, 2, 3,
848  0, 1, 2, 3,
849  4, 5, 6, 7,
850  4, 5, 6, 7 };
851  const vec_u8 doubleright = (vec_u8) {8, 9, 10, 11,
852  8, 9, 10, 11,
853  12, 13, 14, 15,
854  12, 13, 14, 15 };
855  const vec_u8 perm3rg0 = (vec_u8) {0x0, 0x10, 0,
856  0x1, 0x11, 0,
857  0x2, 0x12, 0,
858  0x3, 0x13, 0,
859  0x4, 0x14, 0,
860  0x5 };
861  const vec_u8 perm3rg1 = (vec_u8) { 0x15, 0,
862  0x6, 0x16, 0,
863  0x7, 0x17, 0 };
864  const vec_u8 perm3tb0 = (vec_u8) {0x0, 0x1, 0x10,
865  0x3, 0x4, 0x11,
866  0x6, 0x7, 0x12,
867  0x9, 0xa, 0x13,
868  0xc, 0xd, 0x14,
869  0xf };
870  const vec_u8 perm3tb1 = (vec_u8) { 0x0, 0x15,
871  0x2, 0x3, 0x16,
872  0x5, 0x6, 0x17 };
873 
874  av_assert2(yalpha <= 4096U);
875  av_assert2(uvalpha <= 4096U);
876 
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);
881 
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);
887 
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);
893 
894  if (hasAlpha) {
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);
902  } else {
903  ad = vec_splats((uint8_t) 255);
904  }
905 
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);
912 
913  // Use the first UV half
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);
918 
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);
931 
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);
936 
937  WRITERGB
938 
939  // New Y for the second half
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);
943 
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);
950 
951  // Second UV half
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);
956 
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);
969 
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);
974 
975  WRITERGB
976  }
977 }
978 
979 #undef SETUP
980 
981 static av_always_inline void
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,
985  int uvalpha, int y, enum AVPixelFormat target,
986  int hasAlpha)
987 {
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;
993  vec_u16 rd16, gd16, bd16;
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);
1005  const vec_u32 shift2 = vec_splat_u32(2);
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);
1010  const vec_s16 mul8 = vec_splat_s16(8);
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);
1014  int i;
1015 
1016  // Various permutations
1017  const vec_u8 perm3rg0 = (vec_u8) {0x0, 0x10, 0,
1018  0x1, 0x11, 0,
1019  0x2, 0x12, 0,
1020  0x3, 0x13, 0,
1021  0x4, 0x14, 0,
1022  0x5 };
1023  const vec_u8 perm3rg1 = (vec_u8) { 0x15, 0,
1024  0x6, 0x16, 0,
1025  0x7, 0x17, 0 };
1026  const vec_u8 perm3tb0 = (vec_u8) {0x0, 0x1, 0x10,
1027  0x3, 0x4, 0x11,
1028  0x6, 0x7, 0x12,
1029  0x9, 0xa, 0x13,
1030  0xc, 0xd, 0x14,
1031  0xf };
1032  const vec_u8 perm3tb1 = (vec_u8) { 0x0, 0x15,
1033  0x2, 0x3, 0x16,
1034  0x5, 0x6, 0x17 };
1035 
1036  for (i = 0; i < dstW; i += 8) { // The x86 asm also overwrites padding bytes.
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);
1042 
1043  vu = vec_ld(0, &ubuf0[i]);
1044  vv = vec_ld(0, &vbuf0[i]);
1045  if (uvalpha < 2048) {
1046  vu = (vec_s16) vec_sub((vec_u16) vu, sub7);
1047  vv = (vec_s16) vec_sub((vec_u16) vv, sub7);
1048 
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);
1057  } else {
1058  tmp16 = vec_ld(0, &ubuf1[i]);
1059  vu = vec_add(vu, tmp16);
1060  vu = (vec_s16) vec_sub((vec_u16) vu, sub8);
1061  tmp16 = vec_ld(0, &vbuf1[i]);
1062  vv = vec_add(vv, tmp16);
1063  vv = (vec_s16) vec_sub((vec_u16) vv, sub8);
1064 
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);
1069  }
1070 
1071  if (hasAlpha) {
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);
1077  } else {
1078  ad = vec_splats((uint8_t) 255);
1079  }
1080 
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);
1087 
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);
1100 
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);
1105 
1106  WRITERGB
1107  }
1108 }
1109 
1110 static av_always_inline void
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,
1114  int uvalpha, int y, enum AVPixelFormat target,
1115  int hasAlpha)
1116 {
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;
1123  vec_u16 rd16, gd16, bd16;
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);
1135  const vec_u32 shift2 = vec_splat_u32(2);
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);
1140  const vec_s16 mul8 = vec_splat_s16(8);
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);
1144  int i;
1145 
1146  // Various permutations
1147  const vec_u8 doubleleft = (vec_u8) {0, 1, 2, 3,
1148  0, 1, 2, 3,
1149  4, 5, 6, 7,
1150  4, 5, 6, 7 };
1151  const vec_u8 doubleright = (vec_u8) {8, 9, 10, 11,
1152  8, 9, 10, 11,
1153  12, 13, 14, 15,
1154  12, 13, 14, 15 };
1155  const vec_u8 perm3rg0 = (vec_u8) {0x0, 0x10, 0,
1156  0x1, 0x11, 0,
1157  0x2, 0x12, 0,
1158  0x3, 0x13, 0,
1159  0x4, 0x14, 0,
1160  0x5 };
1161  const vec_u8 perm3rg1 = (vec_u8) { 0x15, 0,
1162  0x6, 0x16, 0,
1163  0x7, 0x17, 0 };
1164  const vec_u8 perm3tb0 = (vec_u8) {0x0, 0x1, 0x10,
1165  0x3, 0x4, 0x11,
1166  0x6, 0x7, 0x12,
1167  0x9, 0xa, 0x13,
1168  0xc, 0xd, 0x14,
1169  0xf };
1170  const vec_u8 perm3tb1 = (vec_u8) { 0x0, 0x15,
1171  0x2, 0x3, 0x16,
1172  0x5, 0x6, 0x17 };
1173 
1174  for (i = 0; i < (dstW + 1) >> 1; i += 8) { // The x86 asm also overwrites padding bytes.
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);
1180 
1181  vu = vec_ld(0, &ubuf0[i]);
1182  vv = vec_ld(0, &vbuf0[i]);
1183  if (uvalpha < 2048) {
1184  vu = (vec_s16) vec_sub((vec_u16) vu, sub7);
1185  vv = (vec_s16) vec_sub((vec_u16) vv, sub7);
1186 
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);
1195  } else {
1196  tmp16 = vec_ld(0, &ubuf1[i]);
1197  vu = vec_add(vu, tmp16);
1198  vu = (vec_s16) vec_sub((vec_u16) vu, sub8);
1199  tmp16 = vec_ld(0, &vbuf1[i]);
1200  vv = vec_add(vv, tmp16);
1201  vv = (vec_s16) vec_sub((vec_u16) vv, sub8);
1202 
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);
1207  }
1208 
1209  if (hasAlpha) {
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);
1215  } else {
1216  ad = vec_splats((uint8_t) 255);
1217  }
1218 
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);
1225 
1226  // Use the first UV half
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);
1231 
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);
1244 
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);
1249 
1250  WRITERGB
1251 
1252  // New Y for the second half
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);
1258 
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);
1265 
1266  // Second UV half
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);
1271 
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);
1284 
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);
1289 
1290  WRITERGB
1291  }
1292 }
1293 
1294 #undef WRITERGB
1295 
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, \
1302  int y) \
1303 { \
1304  name ## base ## _X_vsx_template(c, lumFilter, lumSrc, lumFilterSize, \
1305  chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
1306  alpSrc, dest, dstW, y, fmt, hasAlpha); \
1307 }
1308 
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) \
1314 { \
1315  name ## base ## _2_vsx_template(c, buf, ubuf, vbuf, abuf, \
1316  dest, dstW, yalpha, uvalpha, y, fmt, hasAlpha); \
1317 }
1318 
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) \
1324 { \
1325  name ## base ## _1_vsx_template(c, buf0, ubuf, vbuf, abuf0, dest, \
1326  dstW, uvalpha, y, fmt, hasAlpha); \
1327 }
1328 
1329 YUV2RGBWRAPPER(yuv2, rgb, bgrx32, AV_PIX_FMT_BGRA, 0)
1330 YUV2RGBWRAPPER(yuv2, rgb, rgbx32, AV_PIX_FMT_RGBA, 0)
1331 YUV2RGBWRAPPER(yuv2, rgb, xrgb32, AV_PIX_FMT_ARGB, 0)
1332 YUV2RGBWRAPPER(yuv2, rgb, xbgr32, AV_PIX_FMT_ABGR, 0)
1333 
1334 YUV2RGBWRAPPER(yuv2, rgb, rgb24, AV_PIX_FMT_RGB24, 0)
1335 YUV2RGBWRAPPER(yuv2, rgb, bgr24, AV_PIX_FMT_BGR24, 0)
1336 
1337 YUV2RGBWRAPPERX2(yuv2, rgb, bgrx32, AV_PIX_FMT_BGRA, 0)
1338 YUV2RGBWRAPPERX2(yuv2, rgb, rgbx32, AV_PIX_FMT_RGBA, 0)
1339 YUV2RGBWRAPPERX2(yuv2, rgb, xrgb32, AV_PIX_FMT_ARGB, 0)
1340 YUV2RGBWRAPPERX2(yuv2, rgb, xbgr32, AV_PIX_FMT_ABGR, 0)
1341 
1342 YUV2RGBWRAPPERX2(yuv2, rgb, rgb24, AV_PIX_FMT_RGB24, 0)
1343 YUV2RGBWRAPPERX2(yuv2, rgb, bgr24, AV_PIX_FMT_BGR24, 0)
1344 
1345 YUV2RGBWRAPPER(yuv2, rgb_full, bgrx32_full, AV_PIX_FMT_BGRA, 0)
1346 YUV2RGBWRAPPER(yuv2, rgb_full, rgbx32_full, AV_PIX_FMT_RGBA, 0)
1347 YUV2RGBWRAPPER(yuv2, rgb_full, xrgb32_full, AV_PIX_FMT_ARGB, 0)
1348 YUV2RGBWRAPPER(yuv2, rgb_full, xbgr32_full, AV_PIX_FMT_ABGR, 0)
1349 
1350 YUV2RGBWRAPPER(yuv2, rgb_full, rgb24_full, AV_PIX_FMT_RGB24, 0)
1351 YUV2RGBWRAPPER(yuv2, rgb_full, bgr24_full, AV_PIX_FMT_BGR24, 0)
1352 
1353 YUV2RGBWRAPPERX2(yuv2, rgb_full, bgrx32_full, AV_PIX_FMT_BGRA, 0)
1354 YUV2RGBWRAPPERX2(yuv2, rgb_full, rgbx32_full, AV_PIX_FMT_RGBA, 0)
1355 YUV2RGBWRAPPERX2(yuv2, rgb_full, xrgb32_full, AV_PIX_FMT_ARGB, 0)
1356 YUV2RGBWRAPPERX2(yuv2, rgb_full, xbgr32_full, AV_PIX_FMT_ABGR, 0)
1357 
1358 YUV2RGBWRAPPERX2(yuv2, rgb_full, rgb24_full, AV_PIX_FMT_RGB24, 0)
1359 YUV2RGBWRAPPERX2(yuv2, rgb_full, bgr24_full, AV_PIX_FMT_BGR24, 0)
1360 
1361 YUV2RGBWRAPPERX(yuv2, rgb_full, bgrx32_full, AV_PIX_FMT_BGRA, 0)
1362 YUV2RGBWRAPPERX(yuv2, rgb_full, rgbx32_full, AV_PIX_FMT_RGBA, 0)
1363 YUV2RGBWRAPPERX(yuv2, rgb_full, xrgb32_full, AV_PIX_FMT_ARGB, 0)
1364 YUV2RGBWRAPPERX(yuv2, rgb_full, xbgr32_full, AV_PIX_FMT_ABGR, 0)
1365 
1366 YUV2RGBWRAPPERX(yuv2, rgb_full, rgb24_full, AV_PIX_FMT_RGB24, 0)
1367 YUV2RGBWRAPPERX(yuv2, rgb_full, bgr24_full, AV_PIX_FMT_BGR24, 0)
1368 
1369 static av_always_inline void
1370 write422(const vec_s16 vy1, const vec_s16 vy2,
1371  const vec_s16 vu, const vec_s16 vv,
1372  uint8_t *dest, const enum AVPixelFormat target)
1373 {
1374  vec_u8 vd1, vd2, tmp;
1375  const vec_u8 yuyv1 = (vec_u8) {
1376  0x0, 0x10, 0x1, 0x18,
1377  0x2, 0x11, 0x3, 0x19,
1378  0x4, 0x12, 0x5, 0x1a,
1379  0x6, 0x13, 0x7, 0x1b };
1380  const vec_u8 yuyv2 = (vec_u8) {
1381  0x8, 0x14, 0x9, 0x1c,
1382  0xa, 0x15, 0xb, 0x1d,
1383  0xc, 0x16, 0xd, 0x1e,
1384  0xe, 0x17, 0xf, 0x1f };
1385  const vec_u8 yvyu1 = (vec_u8) {
1386  0x0, 0x18, 0x1, 0x10,
1387  0x2, 0x19, 0x3, 0x11,
1388  0x4, 0x1a, 0x5, 0x12,
1389  0x6, 0x1b, 0x7, 0x13 };
1390  const vec_u8 yvyu2 = (vec_u8) {
1391  0x8, 0x1c, 0x9, 0x14,
1392  0xa, 0x1d, 0xb, 0x15,
1393  0xc, 0x1e, 0xd, 0x16,
1394  0xe, 0x1f, 0xf, 0x17 };
1395  const vec_u8 uyvy1 = (vec_u8) {
1396  0x10, 0x0, 0x18, 0x1,
1397  0x11, 0x2, 0x19, 0x3,
1398  0x12, 0x4, 0x1a, 0x5,
1399  0x13, 0x6, 0x1b, 0x7 };
1400  const vec_u8 uyvy2 = (vec_u8) {
1401  0x14, 0x8, 0x1c, 0x9,
1402  0x15, 0xa, 0x1d, 0xb,
1403  0x16, 0xc, 0x1e, 0xd,
1404  0x17, 0xe, 0x1f, 0xf };
1405 
1406  vd1 = vec_packsu(vy1, vy2);
1407  vd2 = vec_packsu(vu, vv);
1408 
1409  switch (target) {
1410  case AV_PIX_FMT_YUYV422:
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);
1415  break;
1416  case AV_PIX_FMT_YVYU422:
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);
1421  break;
1422  case AV_PIX_FMT_UYVY422:
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);
1427  break;
1428  }
1429 }
1430 
1431 static av_always_inline void
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,
1437  int y, enum AVPixelFormat target)
1438 {
1439  int i, j;
1440  vec_s16 vy1, vy2, vu, vv;
1441  vec_s32 vy32[4], vu32[2], vv32[2], tmp, tmp2, tmp3, tmp4;
1442  vec_s16 vlumFilter[MAX_FILTER_SIZE], vchrFilter[MAX_FILTER_SIZE];
1443  const vec_s32 start = vec_splats(1 << 18);
1444  const vec_u32 shift19 = vec_splats(19U);
1445 
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]);
1450 
1451  for (i = 0; i < ((dstW + 1) >> 1); i += 8) {
1452  vy32[0] =
1453  vy32[1] =
1454  vy32[2] =
1455  vy32[3] =
1456  vu32[0] =
1457  vu32[1] =
1458  vv32[0] =
1459  vv32[1] = start;
1460 
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);
1467 
1468  vy32[0] = vec_adds(vy32[0], tmp3);
1469  vy32[1] = vec_adds(vy32[1], tmp4);
1470 
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);
1476 
1477  vy32[2] = vec_adds(vy32[2], tmp3);
1478  vy32[3] = vec_adds(vy32[3], tmp4);
1479  }
1480 
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);
1487 
1488  vu32[0] = vec_adds(vu32[0], tmp3);
1489  vu32[1] = vec_adds(vu32[1], tmp4);
1490 
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);
1496 
1497  vv32[0] = vec_adds(vv32[0], tmp3);
1498  vv32[1] = vec_adds(vv32[1], tmp4);
1499  }
1500 
1501  for (j = 0; j < 4; j++) {
1502  vy32[j] = vec_sra(vy32[j], shift19);
1503  }
1504  for (j = 0; j < 2; j++) {
1505  vu32[j] = vec_sra(vu32[j], shift19);
1506  vv32[j] = vec_sra(vv32[j], shift19);
1507  }
1508 
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]);
1513 
1514  write422(vy1, vy2, vu, vv, &dest[i * 4], target);
1515  }
1516 }
1517 
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); \
1524 \
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); \
1530 \
1531  tmp3 = vec_add(tmp3, tmp5); \
1532  tmp4 = vec_add(tmp4, tmp6); \
1533 \
1534  tmp3 = vec_sra(tmp3, shift19); \
1535  tmp4 = vec_sra(tmp4, shift19); \
1536  x = vec_packs(tmp3, tmp4); \
1537 }
1538 
1539 static av_always_inline void
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,
1544  enum AVPixelFormat target)
1545 {
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;
1551  vec_s16 vy1, vy2, vu, vv;
1552  vec_s32 tmp, tmp2, tmp3, tmp4, tmp5, tmp6;
1553  const vec_s16 vyalpha1 = vec_splats(yalpha1);
1554  const vec_s16 vuvalpha1 = vec_splats(uvalpha1);
1555  const vec_u32 shift19 = vec_splats(19U);
1556  int i;
1557  av_assert2(yalpha <= 4096U);
1558  av_assert2(uvalpha <= 4096U);
1559 
1560  for (i = 0; i < ((dstW + 1) >> 1); i += 8) {
1561 
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)
1566 
1567  write422(vy1, vy2, vu, vv, &dest[i * 4], target);
1568  }
1569 }
1570 
1571 #undef SETUP
1572 
1573 static av_always_inline void
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,
1577  int uvalpha, int y, enum AVPixelFormat target)
1578 {
1579  const int16_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0];
1580  vec_s16 vy1, vy2, vu, vv, tmp;
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);
1585  int i;
1586 
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]);
1593 
1594  vy1 = vec_add(vy1, add64);
1595  vy2 = vec_add(vy2, add64);
1596  vu = vec_add(vu, add64);
1597  vv = vec_add(vv, add64);
1598 
1599  vy1 = vec_sra(vy1, shift7);
1600  vy2 = vec_sra(vy2, shift7);
1601  vu = vec_sra(vu, shift7);
1602  vv = vec_sra(vv, shift7);
1603 
1604  write422(vy1, vy2, vu, vv, &dest[i * 4], target);
1605  }
1606  } else {
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);
1617 
1618  vy1 = vec_add(vy1, add64);
1619  vy2 = vec_add(vy2, add64);
1620  vu = vec_adds(vu, add128);
1621  vv = vec_adds(vv, add128);
1622 
1623  vy1 = vec_sra(vy1, shift7);
1624  vy2 = vec_sra(vy2, shift7);
1625  vu = vec_sra(vu, shift8);
1626  vv = vec_sra(vv, shift8);
1627 
1628  write422(vy1, vy2, vu, vv, &dest[i * 4], target);
1629  }
1630  }
1631 }
1632 
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, \
1639  int y) \
1640 { \
1641  name ## base ## _X_vsx_template(c, lumFilter, lumSrc, lumFilterSize, \
1642  chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
1643  alpSrc, dest, dstW, y, fmt); \
1644 }
1645 
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) \
1652 { \
1653  name ## base ## _2_vsx_template(c, buf, ubuf, vbuf, abuf, \
1654  dest, dstW, yalpha, uvalpha, y, fmt); \
1655 }
1656 
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) \
1663 { \
1664  name ## base ## _1_vsx_template(c, buf0, ubuf, vbuf, \
1665  abuf0, dest, dstW, uvalpha, \
1666  y, fmt); \
1667 }
1668 
1669 YUV2PACKEDWRAPPER(yuv2, 422, yuyv422, AV_PIX_FMT_YUYV422)
1670 YUV2PACKEDWRAPPER(yuv2, 422, yvyu422, AV_PIX_FMT_YVYU422)
1671 YUV2PACKEDWRAPPER(yuv2, 422, uyvy422, AV_PIX_FMT_UYVY422)
1672 
1673 static void hyscale_fast_vsx(SwsContext *c, int16_t *dst, int dstWidth,
1674  const uint8_t *src, int srcW, int xInc)
1675 {
1676  int i;
1677  unsigned int xpos = 0, xx;
1678  vec_u8 vin, vin2, vperm;
1679  vec_s8 vmul, valpha;
1680  vec_s16 vtmp, vtmp2, vtmp3, vtmp4;
1681  vec_u16 vd_l, vd_r, vcoord16[2];
1682  vec_u32 vcoord[4];
1683  const vec_u32 vadd = (vec_u32) {
1684  0,
1685  xInc * 1,
1686  xInc * 2,
1687  xInc * 3,
1688  };
1689  const vec_u16 vadd16 = (vec_u16) { // Modulo math
1690  0,
1691  xInc * 1,
1692  xInc * 2,
1693  xInc * 3,
1694  xInc * 4,
1695  xInc * 5,
1696  xInc * 6,
1697  xInc * 7,
1698  };
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);
1703 
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));
1707 
1708  vcoord16[0] = vec_add(vcoord16[0], vadd16);
1709  vcoord16[1] = vec_add(vcoord16[1], vadd16);
1710 
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]);
1714 
1715  xx = xpos >> 16;
1716  vin = vec_vsx_ld(0, &src[xx]);
1717 
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);
1722 
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);
1727 
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);
1732 
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]);
1736 
1737  vin = vec_perm(vin, vin, vperm);
1738 
1739  vin2 = vec_vsx_ld(1, &src[xx]);
1740  vin2 = vec_perm(vin2, vin2, vperm);
1741 
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);
1747 
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);
1752 
1753  vd_l = vec_add(vd_l, (vec_u16) vtmp3);
1754  vd_r = vec_add(vd_r, (vec_u16) vtmp4);
1755 
1756  vec_st((vec_s16) vd_l, 0, &dst[i]);
1757  vec_st((vec_s16) vd_r, 0, &dst[i + 8]);
1758 
1759  xpos += xInc * 16;
1760  }
1761  for (i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--)
1762  dst[i] = src[srcW-1]*128;
1763 }
1764 
1765 #define HCSCALE(in, out) \
1766  vin = vec_vsx_ld(0, &in[xx]); \
1767  vin = vec_perm(vin, vin, vperm); \
1768 \
1769  vin2 = vec_vsx_ld(1, &in[xx]); \
1770  vin2 = vec_perm(vin2, vin2, vperm); \
1771 \
1772  vtmp = vec_mule(vin, valphaxor); \
1773  vtmp2 = vec_mulo(vin, valphaxor); \
1774  vtmp3 = vec_mergeh(vtmp, vtmp2); \
1775  vtmp4 = vec_mergel(vtmp, vtmp2); \
1776 \
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); \
1781 \
1782  vd_l = vec_add(vd_l, vtmp3); \
1783  vd_r = vec_add(vd_r, vtmp4); \
1784 \
1785  vec_st((vec_s16) vd_l, 0, &out[i]); \
1786  vec_st((vec_s16) vd_r, 0, &out[i + 8])
1787 
1788 static void hcscale_fast_vsx(SwsContext *c, int16_t *dst1, int16_t *dst2,
1789  int dstWidth, const uint8_t *src1,
1790  const uint8_t *src2, int srcW, int xInc)
1791 {
1792  int i;
1793  unsigned int xpos = 0, xx;
1794  vec_u8 vin, vin2, vperm;
1795  vec_u8 valpha, valphaxor;
1796  vec_u16 vtmp, vtmp2, vtmp3, vtmp4;
1797  vec_u16 vd_l, vd_r, vcoord16[2];
1798  vec_u32 vcoord[4];
1799  const vec_u8 vxor = vec_splats((uint8_t) 127);
1800  const vec_u32 vadd = (vec_u32) {
1801  0,
1802  xInc * 1,
1803  xInc * 2,
1804  xInc * 3,
1805  };
1806  const vec_u16 vadd16 = (vec_u16) { // Modulo math
1807  0,
1808  xInc * 1,
1809  xInc * 2,
1810  xInc * 3,
1811  xInc * 4,
1812  xInc * 5,
1813  xInc * 6,
1814  xInc * 7,
1815  };
1816  const vec_u32 vshift16 = vec_splats((uint32_t) 16);
1817  const vec_u16 vshift9 = vec_splat_u16(9);
1818 
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));
1822 
1823  vcoord16[0] = vec_add(vcoord16[0], vadd16);
1824  vcoord16[1] = vec_add(vcoord16[1], vadd16);
1825 
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);
1830 
1831  xx = xpos >> 16;
1832 
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);
1837 
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);
1842 
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);
1847 
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]);
1851 
1852  HCSCALE(src1, dst1);
1853  HCSCALE(src2, dst2);
1854 
1855  xpos += xInc * 16;
1856  }
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;
1860  }
1861 }
1862 
1863 #undef HCSCALE
1864 
1865 static void hScale8To19_vsx(SwsContext *c, int16_t *_dst, int dstW,
1866  const uint8_t *src, const int16_t *filter,
1867  const int32_t *filterPos, int filterSize)
1868 {
1869  int i, j;
1870  int32_t *dst = (int32_t *) _dst;
1871  vec_s16 vfilter, vin;
1872  vec_u8 vin8;
1873  vec_s32 vout;
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},
1892  };
1893  const vec_u8 vunused = vunusedtab[filterSize % 8];
1894 
1895  if (filterSize == 1) {
1896  for (i = 0; i < dstW; i++) {
1897  int srcPos = filterPos[i];
1898  int val = 0;
1899  for (j = 0; j < filterSize; j++) {
1900  val += ((int)src[srcPos + j]) * filter[filterSize * i + j];
1901  }
1902  dst[i] = FFMIN(val >> 3, (1 << 19) - 1); // the cubic equation does overflow ...
1903  }
1904  } else {
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) // Remove the unused elements on the last round
1912  vin = vec_perm(vin, (vec_s16) vzero, vunused);
1913 
1914  vfilter = vec_vsx_ld(0, &filter[filterSize * i + j]);
1915  vout = vec_msums(vin, vfilter, vout);
1916  }
1917  vout = vec_sums(vout, (vec_s32) vzero);
1918  dst[i] = FFMIN(vout[3] >> 3, (1 << 19) - 1);
1919  }
1920  }
1921 }
1922 
1923 static void hScale16To19_vsx(SwsContext *c, int16_t *_dst, int dstW,
1924  const uint8_t *_src, const int16_t *filter,
1925  const int32_t *filterPos, int filterSize)
1926 {
1927  const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->srcFormat);
1928  int i, j;
1929  int32_t *dst = (int32_t *) _dst;
1930  const uint16_t *src = (const uint16_t *) _src;
1931  int bits = desc->comp[0].depth - 1;
1932  int sh = bits - 4;
1933  vec_s16 vfilter, vin;
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},
1953  };
1954  const vec_u8 vunused = vunusedtab[filterSize % 8];
1955 
1956  if ((isAnyRGB(c->srcFormat) || c->srcFormat==AV_PIX_FMT_PAL8) && desc->comp[0].depth<16) {
1957  sh = 9;
1958  } else if (desc->flags & AV_PIX_FMT_FLAG_FLOAT) { /* float input are process like uint 16bpc */
1959  sh = 16 - 1 - 4;
1960  }
1961 
1962  if (filterSize == 1) {
1963  for (i = 0; i < dstW; i++) {
1964  int srcPos = filterPos[i];
1965  int val = 0;
1966 
1967  for (j = 0; j < filterSize; j++) {
1968  val += src[srcPos + j] * filter[filterSize * i + j];
1969  }
1970  // filter=14 bit, input=16 bit, output=30 bit, >> 11 makes 19 bit
1971  dst[i] = FFMIN(val >> sh, (1 << 19) - 1);
1972  }
1973  } else {
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) // Remove the unused elements on the last round
1980  vin = vec_perm(vin, (vec_s16) vzero, vunused);
1981 
1982  vfilter = vec_vsx_ld(0, &filter[filterSize * i + j]);
1983  vfilter32_l = vec_unpackh(vfilter);
1984  vfilter32_r = vec_unpackl(vfilter);
1985 
1986  vtmp = (vec_s32) vec_mergeh(vin, (vec_s16) vzero);
1987  vtmp2 = (vec_s32) vec_mergel(vin, (vec_s16) vzero);
1988 
1989  vtmp = vec_mul(vtmp, vfilter32_l);
1990  vtmp2 = vec_mul(vtmp2, vfilter32_r);
1991 
1992  vout = vec_adds(vout, vtmp);
1993  vout = vec_adds(vout, vtmp2);
1994  }
1995  vout = vec_sums(vout, (vec_s32) vzero);
1996  dst[i] = FFMIN(vout[3] >> sh, (1 << 19) - 1);
1997  }
1998  }
1999 }
2000 
2001 static void hScale16To15_vsx(SwsContext *c, int16_t *dst, int dstW,
2002  const uint8_t *_src, const int16_t *filter,
2003  const int32_t *filterPos, int filterSize)
2004 {
2005  const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->srcFormat);
2006  int i, j;
2007  const uint16_t *src = (const uint16_t *) _src;
2008  int sh = desc->comp[0].depth - 1;
2009  vec_s16 vfilter, vin;
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},
2029  };
2030  const vec_u8 vunused = vunusedtab[filterSize % 8];
2031 
2032  if (sh<15) {
2033  sh = isAnyRGB(c->srcFormat) || c->srcFormat==AV_PIX_FMT_PAL8 ? 13 : (desc->comp[0].depth - 1);
2034  } else if (desc->flags & AV_PIX_FMT_FLAG_FLOAT) { /* float input are process like uint 16bpc */
2035  sh = 16 - 1;
2036  }
2037 
2038  if (filterSize == 1) {
2039  for (i = 0; i < dstW; i++) {
2040  int srcPos = filterPos[i];
2041  int val = 0;
2042 
2043  for (j = 0; j < filterSize; j++) {
2044  val += src[srcPos + j] * filter[filterSize * i + j];
2045  }
2046  // filter=14 bit, input=16 bit, output=30 bit, >> 15 makes 15 bit
2047  dst[i] = FFMIN(val >> sh, (1 << 15) - 1);
2048  }
2049  } else {
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) // Remove the unused elements on the last round
2056  vin = vec_perm(vin, (vec_s16) vzero, vunused);
2057 
2058  vfilter = vec_vsx_ld(0, &filter[filterSize * i + j]);
2059  vfilter32_l = vec_unpackh(vfilter);
2060  vfilter32_r = vec_unpackl(vfilter);
2061 
2062  vtmp = (vec_s32) vec_mergeh(vin, (vec_s16) vzero);
2063  vtmp2 = (vec_s32) vec_mergel(vin, (vec_s16) vzero);
2064 
2065  vtmp = vec_mul(vtmp, vfilter32_l);
2066  vtmp2 = vec_mul(vtmp2, vfilter32_r);
2067 
2068  vout = vec_adds(vout, vtmp);
2069  vout = vec_adds(vout, vtmp2);
2070  }
2071  vout = vec_sums(vout, (vec_s32) vzero);
2072  dst[i] = FFMIN(vout[3] >> sh, (1 << 15) - 1);
2073  }
2074  }
2075 }
2076 
2077 #endif /* !HAVE_BIGENDIAN */
2078 
2079 #endif /* HAVE_VSX */
2080 
2082 {
2083 #if HAVE_VSX
2084  enum AVPixelFormat dstFormat = c->dstFormat;
2085  const int cpu_flags = av_get_cpu_flags();
2086  const unsigned char power8 = HAVE_POWER8 && cpu_flags & AV_CPU_FLAG_POWER8;
2087 
2088  if (!(cpu_flags & AV_CPU_FLAG_VSX))
2089  return;
2090 
2091 #if !HAVE_BIGENDIAN
2092  if (c->srcBpc == 8) {
2093  if (c->dstBpc <= 14) {
2094  c->hyScale = c->hcScale = hScale_real_vsx;
2095  if (c->flags & SWS_FAST_BILINEAR && c->dstW >= c->srcW && c->chrDstW >= c->chrSrcW) {
2096  c->hyscale_fast = hyscale_fast_vsx;
2097  c->hcscale_fast = hcscale_fast_vsx;
2098  }
2099  } else {
2100  c->hyScale = c->hcScale = hScale8To19_vsx;
2101  }
2102  } else {
2103  if (power8) {
2104  c->hyScale = c->hcScale = c->dstBpc > 14 ? hScale16To19_vsx
2105  : hScale16To15_vsx;
2106  }
2107  }
2108  if (!is16BPS(dstFormat) && !isNBPS(dstFormat) && !isSemiPlanarYUV(dstFormat) &&
2109  dstFormat != AV_PIX_FMT_GRAYF32BE && dstFormat != AV_PIX_FMT_GRAYF32LE &&
2110  !c->needAlpha) {
2111  c->yuv2planeX = yuv2planeX_vsx;
2112  }
2113 #endif
2114 
2115  if (!(c->flags & (SWS_BITEXACT | SWS_FULL_CHR_H_INT)) && !c->needAlpha) {
2116  switch (c->dstBpc) {
2117  case 8:
2118  c->yuv2plane1 = yuv2plane1_8_vsx;
2119  break;
2120 #if !HAVE_BIGENDIAN
2121  case 9:
2122  c->yuv2plane1 = isBE(dstFormat) ? yuv2plane1_9BE_vsx : yuv2plane1_9LE_vsx;
2123  c->yuv2planeX = isBE(dstFormat) ? yuv2planeX_9BE_vsx : yuv2planeX_9LE_vsx;
2124  break;
2125  case 10:
2126  c->yuv2plane1 = isBE(dstFormat) ? yuv2plane1_10BE_vsx : yuv2plane1_10LE_vsx;
2127  c->yuv2planeX = isBE(dstFormat) ? yuv2planeX_10BE_vsx : yuv2planeX_10LE_vsx;
2128  break;
2129  case 12:
2130  c->yuv2plane1 = isBE(dstFormat) ? yuv2plane1_12BE_vsx : yuv2plane1_12LE_vsx;
2131  c->yuv2planeX = isBE(dstFormat) ? yuv2planeX_12BE_vsx : yuv2planeX_12LE_vsx;
2132  break;
2133  case 14:
2134  c->yuv2plane1 = isBE(dstFormat) ? yuv2plane1_14BE_vsx : yuv2plane1_14LE_vsx;
2135  c->yuv2planeX = isBE(dstFormat) ? yuv2planeX_14BE_vsx : yuv2planeX_14LE_vsx;
2136  break;
2137  case 16:
2138  c->yuv2plane1 = isBE(dstFormat) ? yuv2plane1_16BE_vsx : yuv2plane1_16LE_vsx;
2139 #if HAVE_POWER8
2140  if (cpu_flags & AV_CPU_FLAG_POWER8) {
2141  c->yuv2planeX = isBE(dstFormat) ? yuv2planeX_16BE_vsx : yuv2planeX_16LE_vsx;
2142  }
2143 #endif /* HAVE_POWER8 */
2144  break;
2145 #endif /* !HAVE_BIGENDIAN */
2146  }
2147  }
2148 
2149  if (c->flags & SWS_BITEXACT)
2150  return;
2151 
2152 #if !HAVE_BIGENDIAN
2153  if (c->flags & SWS_FULL_CHR_H_INT) {
2154  switch (dstFormat) {
2155  case AV_PIX_FMT_RGB24:
2156  if (power8) {
2157  c->yuv2packed1 = yuv2rgb24_full_1_vsx;
2158  c->yuv2packed2 = yuv2rgb24_full_2_vsx;
2159  c->yuv2packedX = yuv2rgb24_full_X_vsx;
2160  }
2161  break;
2162  case AV_PIX_FMT_BGR24:
2163  if (power8) {
2164  c->yuv2packed1 = yuv2bgr24_full_1_vsx;
2165  c->yuv2packed2 = yuv2bgr24_full_2_vsx;
2166  c->yuv2packedX = yuv2bgr24_full_X_vsx;
2167  }
2168  break;
2169  case AV_PIX_FMT_BGRA:
2170  if (power8) {
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;
2175  }
2176  }
2177  break;
2178  case AV_PIX_FMT_RGBA:
2179  if (power8) {
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;
2184  }
2185  }
2186  break;
2187  case AV_PIX_FMT_ARGB:
2188  if (power8) {
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;
2193  }
2194  }
2195  break;
2196  case AV_PIX_FMT_ABGR:
2197  if (power8) {
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;
2202  }
2203  }
2204  break;
2205  }
2206  } else { /* !SWS_FULL_CHR_H_INT */
2207  switch (dstFormat) {
2208  case AV_PIX_FMT_YUYV422:
2209  c->yuv2packed1 = yuv2yuyv422_1_vsx;
2210  c->yuv2packed2 = yuv2yuyv422_2_vsx;
2211  c->yuv2packedX = yuv2yuyv422_X_vsx;
2212  break;
2213  case AV_PIX_FMT_YVYU422:
2214  c->yuv2packed1 = yuv2yvyu422_1_vsx;
2215  c->yuv2packed2 = yuv2yvyu422_2_vsx;
2216  c->yuv2packedX = yuv2yvyu422_X_vsx;
2217  break;
2218  case AV_PIX_FMT_UYVY422:
2219  c->yuv2packed1 = yuv2uyvy422_1_vsx;
2220  c->yuv2packed2 = yuv2uyvy422_2_vsx;
2221  c->yuv2packedX = yuv2uyvy422_X_vsx;
2222  break;
2223  case AV_PIX_FMT_BGRA:
2224  if (power8) {
2225  if (!c->needAlpha) {
2226  c->yuv2packed1 = yuv2bgrx32_1_vsx;
2227  c->yuv2packed2 = yuv2bgrx32_2_vsx;
2228  }
2229  }
2230  break;
2231  case AV_PIX_FMT_RGBA:
2232  if (power8) {
2233  if (!c->needAlpha) {
2234  c->yuv2packed1 = yuv2rgbx32_1_vsx;
2235  c->yuv2packed2 = yuv2rgbx32_2_vsx;
2236  }
2237  }
2238  break;
2239  case AV_PIX_FMT_ARGB:
2240  if (power8) {
2241  if (!c->needAlpha) {
2242  c->yuv2packed1 = yuv2xrgb32_1_vsx;
2243  c->yuv2packed2 = yuv2xrgb32_2_vsx;
2244  }
2245  }
2246  break;
2247  case AV_PIX_FMT_ABGR:
2248  if (power8) {
2249  if (!c->needAlpha) {
2250  c->yuv2packed1 = yuv2xbgr32_1_vsx;
2251  c->yuv2packed2 = yuv2xbgr32_2_vsx;
2252  }
2253  }
2254  break;
2255  case AV_PIX_FMT_RGB24:
2256  if (power8) {
2257  c->yuv2packed1 = yuv2rgb24_1_vsx;
2258  c->yuv2packed2 = yuv2rgb24_2_vsx;
2259  }
2260  break;
2261  case AV_PIX_FMT_BGR24:
2262  if (power8) {
2263  c->yuv2packed1 = yuv2bgr24_1_vsx;
2264  c->yuv2packed2 = yuv2bgr24_2_vsx;
2265  }
2266  break;
2267  }
2268  }
2269 #endif /* !HAVE_BIGENDIAN */
2270 
2271 #endif /* HAVE_VSX */
2272 }
static double val(void *priv, double ch)
Definition: aeval.c:76
#define MAX_FILTER_SIZE
Definition: af_dynaudnorm.c:33
#define A(x)
Definition: vp56_arith.h:28
Macro definitions for various function/variable attributes.
#define av_always_inline
Definition: attributes.h:45
#define av_cold
Definition: attributes.h:88
uint8_t
int32_t
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
Definition: avassert.h:64
static const uint8_t shifts[2][12]
Definition: camellia.c:174
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)
Definition: cfhddsp.c:27
#define FFMIN(a, b)
Definition: common.h:105
#define av_clip_uint8
Definition: common.h:128
#define HAVE_POWER8
Definition: config.h:53
#define NULL
Definition: coverity.c:32
static atomic_int cpu_flags
Definition: cpu.c:50
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
Definition: cpu.c:95
#define AV_CPU_FLAG_VSX
ISA 2.06.
Definition: cpu.h:61
#define AV_CPU_FLAG_POWER8
ISA 2.07.
Definition: cpu.h:62
static float add(float src0, float src1)
int
#define SWS_BITEXACT
Definition: swscale.h:84
#define SWS_FULL_CHR_H_INT
Definition: swscale.h:79
#define SWS_FAST_BILINEAR
Definition: swscale.h:58
int i
Definition: input.c:407
static const int shift2[6]
Definition: dxa.c:51
const char * desc
Definition: libsvtav1.c:83
#define LOCAL_ALIGNED(a, t, v,...)
Definition: mem_internal.h:109
#define output_pixel(pos, val, bias, signedness)
Definition: output.c:896
#define YUV2RGBWRAPPERX(name, base, ext, fmt, hasAlpha)
Definition: output.c:1807
#define YUV2RGBWRAPPER(name, base, ext, fmt, hasAlpha)
Definition: output.c:1831
#define YUV2RGBWRAPPERX2(name, base, ext, fmt, hasAlpha)
Definition: output.c:1820
yuv2NBPS(yuv2NBPS(9, yuv2NBPS(BE, yuv2NBPS(1, yuv2NBPS(10, int16_t)
Definition: output.c:371
#define YUV2PACKEDWRAPPER(name, base, ext, fmt)
Definition: output.c:718
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2573
#define AV_PIX_FMT_FLAG_FLOAT
The pixel format contains IEEE-754 floating point values.
Definition: pixdesc.h:190
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:68
@ AV_PIX_FMT_GRAYF32LE
IEEE-754 single precision Y, 32bpp, little-endian.
Definition: pixfmt.h:341
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
Definition: pixfmt.h:92
@ AV_PIX_FMT_YVYU422
packed YUV 4:2:2, 16bpp, Y0 Cr Y1 Cb
Definition: pixfmt.h:210
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition: pixfmt.h:95
@ AV_PIX_FMT_UYVY422
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
Definition: pixfmt.h:81
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
Definition: pixfmt.h:94
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:93
@ AV_PIX_FMT_GRAYF32BE
IEEE-754 single precision Y, 32bpp, big-endian.
Definition: pixfmt.h:340
@ AV_PIX_FMT_YUYV422
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
Definition: pixfmt.h:67
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
Definition: pixfmt.h:77
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:69
@ SETUP
Definition: rtspcodes.h:133
static int shift(int a, int b)
Definition: sonic.c:82
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:81
Definition: rpzaenc.c:58
external API header
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)
Definition: swscale_vsx.c:2081
static uint8_t tmp[11]
Definition: aes_ctr.c:27
#define src1
Definition: h264pred.c:140
#define src
Definition: vp8dsp.c:255
#define mul8(a, b)
Contains misc utility macros and inline functions.
#define vec_s16
Definition: util_altivec.h:37
#define vec_s8
Definition: util_altivec.h:35
#define vec_u8
Definition: util_altivec.h:34
#define vec_u32
Definition: util_altivec.h:38
#define vec_u16
Definition: util_altivec.h:36
#define vec_s32
Definition: util_altivec.h:39
static const uint8_t dither[8][8]
Definition: vf_fspp.c:59
static double clip(void *opaque, double val)
Clip value val in the minval - maxval range.
Definition: vf_lut.c:163
static const uint8_t offset[127][2]
Definition: vf_spp.c:107
uint8_t bits
Definition: vp3data.h:141
static double c[64]