Mercurial > mplayer.hg
annotate libswscale/swscale_altivec_template.c @ 19848:07be98a5dd5f
Add \be (blur edges) support to libass.
author | eugeni |
---|---|
date | Sat, 16 Sep 2006 13:32:46 +0000 |
parents | 07769a1d06a9 |
children | bdd8965d6e48 |
rev | line source |
---|---|
19200
07769a1d06a9
Fix compile error due to extra "FF" at beginning of file in the FF{MIN,MAX}
pacman
parents:
19181
diff
changeset
|
1 /* |
18861 | 2 AltiVec-enhanced yuv2yuvX |
3 | |
4 Copyright (C) 2004 Romain Dolbeau <romain@dolbeau.org> | |
5 based on the equivalent C code in "postproc/swscale.c" | |
6 | |
7 | |
8 This program is free software; you can redistribute it and/or modify | |
9 it under the terms of the GNU General Public License as published by | |
10 the Free Software Foundation; either version 2 of the License, or | |
11 (at your option) any later version. | |
12 | |
13 This program is distributed in the hope that it will be useful, | |
14 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 GNU General Public License for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
19 along with this program; if not, write to the Free Software | |
20 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
21 */ | |
22 | |
23 #ifdef CONFIG_DARWIN | |
24 #define AVV(x...) (x) | |
25 #else | |
26 #define AVV(x...) {x} | |
27 #endif | |
28 | |
29 #define vzero vec_splat_s32(0) | |
30 | |
31 static inline void | |
32 altivec_packIntArrayToCharArray(int *val, uint8_t* dest, int dstW) { | |
33 register int i; | |
34 vector unsigned int altivec_vectorShiftInt19 = | |
35 vec_add(vec_splat_u32(10),vec_splat_u32(9)); | |
36 if ((unsigned long)dest % 16) { | |
37 /* badly aligned store, we force store alignement */ | |
38 /* and will handle load misalignement on val w/ vec_perm */ | |
39 for (i = 0 ; (i < dstW) && | |
40 (((unsigned long)dest + i) % 16) ; i++) { | |
41 int t = val[i] >> 19; | |
42 dest[i] = (t < 0) ? 0 : ((t > 255) ? 255 : t); | |
43 } | |
44 vector unsigned char perm1 = vec_lvsl(i << 2, val); | |
45 vector signed int v1 = vec_ld(i << 2, val); | |
46 for ( ; i < (dstW - 15); i+=16) { | |
47 int offset = i << 2; | |
48 vector signed int v2 = vec_ld(offset + 16, val); | |
49 vector signed int v3 = vec_ld(offset + 32, val); | |
50 vector signed int v4 = vec_ld(offset + 48, val); | |
51 vector signed int v5 = vec_ld(offset + 64, val); | |
52 vector signed int v12 = vec_perm(v1,v2,perm1); | |
53 vector signed int v23 = vec_perm(v2,v3,perm1); | |
54 vector signed int v34 = vec_perm(v3,v4,perm1); | |
55 vector signed int v45 = vec_perm(v4,v5,perm1); | |
56 | |
57 vector signed int vA = vec_sra(v12, altivec_vectorShiftInt19); | |
58 vector signed int vB = vec_sra(v23, altivec_vectorShiftInt19); | |
59 vector signed int vC = vec_sra(v34, altivec_vectorShiftInt19); | |
60 vector signed int vD = vec_sra(v45, altivec_vectorShiftInt19); | |
61 vector unsigned short vs1 = vec_packsu(vA, vB); | |
62 vector unsigned short vs2 = vec_packsu(vC, vD); | |
63 vector unsigned char vf = vec_packsu(vs1, vs2); | |
64 vec_st(vf, i, dest); | |
65 v1 = v5; | |
66 } | |
67 } else { // dest is properly aligned, great | |
68 for (i = 0; i < (dstW - 15); i+=16) { | |
69 int offset = i << 2; | |
70 vector signed int v1 = vec_ld(offset, val); | |
71 vector signed int v2 = vec_ld(offset + 16, val); | |
72 vector signed int v3 = vec_ld(offset + 32, val); | |
73 vector signed int v4 = vec_ld(offset + 48, val); | |
74 vector signed int v5 = vec_sra(v1, altivec_vectorShiftInt19); | |
75 vector signed int v6 = vec_sra(v2, altivec_vectorShiftInt19); | |
76 vector signed int v7 = vec_sra(v3, altivec_vectorShiftInt19); | |
77 vector signed int v8 = vec_sra(v4, altivec_vectorShiftInt19); | |
78 vector unsigned short vs1 = vec_packsu(v5, v6); | |
79 vector unsigned short vs2 = vec_packsu(v7, v8); | |
80 vector unsigned char vf = vec_packsu(vs1, vs2); | |
81 vec_st(vf, i, dest); | |
82 } | |
83 } | |
84 for ( ; i < dstW ; i++) { | |
85 int t = val[i] >> 19; | |
86 dest[i] = (t < 0) ? 0 : ((t > 255) ? 255 : t); | |
87 } | |
88 } | |
89 | |
90 static inline void | |
91 yuv2yuvX_altivec_real(int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize, | |
92 int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize, | |
93 uint8_t *dest, uint8_t *uDest, uint8_t *vDest, int dstW, int chrDstW) | |
94 { | |
95 const vector signed int vini = {(1 << 18), (1 << 18), (1 << 18), (1 << 18)}; | |
96 register int i, j; | |
97 { | |
98 int __attribute__ ((aligned (16))) val[dstW]; | |
99 | |
100 for (i = 0; i < (dstW -7); i+=4) { | |
101 vec_st(vini, i << 2, val); | |
102 } | |
103 for (; i < dstW; i++) { | |
104 val[i] = (1 << 18); | |
105 } | |
106 | |
107 for (j = 0; j < lumFilterSize; j++) { | |
108 vector signed short vLumFilter = vec_ld(j << 1, lumFilter); | |
109 vector unsigned char perm0 = vec_lvsl(j << 1, lumFilter); | |
110 vLumFilter = vec_perm(vLumFilter, vLumFilter, perm0); | |
111 vLumFilter = vec_splat(vLumFilter, 0); // lumFilter[j] is loaded 8 times in vLumFilter | |
112 | |
113 vector unsigned char perm = vec_lvsl(0, lumSrc[j]); | |
114 vector signed short l1 = vec_ld(0, lumSrc[j]); | |
115 | |
116 for (i = 0; i < (dstW - 7); i+=8) { | |
117 int offset = i << 2; | |
118 vector signed short l2 = vec_ld((i << 1) + 16, lumSrc[j]); | |
119 | |
120 vector signed int v1 = vec_ld(offset, val); | |
121 vector signed int v2 = vec_ld(offset + 16, val); | |
122 | |
123 vector signed short ls = vec_perm(l1, l2, perm); // lumSrc[j][i] ... lumSrc[j][i+7] | |
124 | |
125 vector signed int i1 = vec_mule(vLumFilter, ls); | |
126 vector signed int i2 = vec_mulo(vLumFilter, ls); | |
127 | |
128 vector signed int vf1 = vec_mergeh(i1, i2); | |
129 vector signed int vf2 = vec_mergel(i1, i2); // lumSrc[j][i] * lumFilter[j] ... lumSrc[j][i+7] * lumFilter[j] | |
130 | |
131 vector signed int vo1 = vec_add(v1, vf1); | |
132 vector signed int vo2 = vec_add(v2, vf2); | |
133 | |
134 vec_st(vo1, offset, val); | |
135 vec_st(vo2, offset + 16, val); | |
136 | |
137 l1 = l2; | |
138 } | |
139 for ( ; i < dstW; i++) { | |
140 val[i] += lumSrc[j][i] * lumFilter[j]; | |
141 } | |
142 } | |
143 altivec_packIntArrayToCharArray(val,dest,dstW); | |
144 } | |
145 if (uDest != 0) { | |
146 int __attribute__ ((aligned (16))) u[chrDstW]; | |
147 int __attribute__ ((aligned (16))) v[chrDstW]; | |
148 | |
149 for (i = 0; i < (chrDstW -7); i+=4) { | |
150 vec_st(vini, i << 2, u); | |
151 vec_st(vini, i << 2, v); | |
152 } | |
153 for (; i < chrDstW; i++) { | |
154 u[i] = (1 << 18); | |
155 v[i] = (1 << 18); | |
156 } | |
157 | |
158 for (j = 0; j < chrFilterSize; j++) { | |
159 vector signed short vChrFilter = vec_ld(j << 1, chrFilter); | |
160 vector unsigned char perm0 = vec_lvsl(j << 1, chrFilter); | |
161 vChrFilter = vec_perm(vChrFilter, vChrFilter, perm0); | |
162 vChrFilter = vec_splat(vChrFilter, 0); // chrFilter[j] is loaded 8 times in vChrFilter | |
163 | |
164 vector unsigned char perm = vec_lvsl(0, chrSrc[j]); | |
165 vector signed short l1 = vec_ld(0, chrSrc[j]); | |
166 vector signed short l1_V = vec_ld(2048 << 1, chrSrc[j]); | |
167 | |
168 for (i = 0; i < (chrDstW - 7); i+=8) { | |
169 int offset = i << 2; | |
170 vector signed short l2 = vec_ld((i << 1) + 16, chrSrc[j]); | |
171 vector signed short l2_V = vec_ld(((i + 2048) << 1) + 16, chrSrc[j]); | |
172 | |
173 vector signed int v1 = vec_ld(offset, u); | |
174 vector signed int v2 = vec_ld(offset + 16, u); | |
175 vector signed int v1_V = vec_ld(offset, v); | |
176 vector signed int v2_V = vec_ld(offset + 16, v); | |
177 | |
178 vector signed short ls = vec_perm(l1, l2, perm); // chrSrc[j][i] ... chrSrc[j][i+7] | |
179 vector signed short ls_V = vec_perm(l1_V, l2_V, perm); // chrSrc[j][i+2048] ... chrSrc[j][i+2055] | |
180 | |
181 vector signed int i1 = vec_mule(vChrFilter, ls); | |
182 vector signed int i2 = vec_mulo(vChrFilter, ls); | |
183 vector signed int i1_V = vec_mule(vChrFilter, ls_V); | |
184 vector signed int i2_V = vec_mulo(vChrFilter, ls_V); | |
185 | |
186 vector signed int vf1 = vec_mergeh(i1, i2); | |
187 vector signed int vf2 = vec_mergel(i1, i2); // chrSrc[j][i] * chrFilter[j] ... chrSrc[j][i+7] * chrFilter[j] | |
188 vector signed int vf1_V = vec_mergeh(i1_V, i2_V); | |
189 vector signed int vf2_V = vec_mergel(i1_V, i2_V); // chrSrc[j][i] * chrFilter[j] ... chrSrc[j][i+7] * chrFilter[j] | |
190 | |
191 vector signed int vo1 = vec_add(v1, vf1); | |
192 vector signed int vo2 = vec_add(v2, vf2); | |
193 vector signed int vo1_V = vec_add(v1_V, vf1_V); | |
194 vector signed int vo2_V = vec_add(v2_V, vf2_V); | |
195 | |
196 vec_st(vo1, offset, u); | |
197 vec_st(vo2, offset + 16, u); | |
198 vec_st(vo1_V, offset, v); | |
199 vec_st(vo2_V, offset + 16, v); | |
200 | |
201 l1 = l2; | |
202 l1_V = l2_V; | |
203 } | |
204 for ( ; i < chrDstW; i++) { | |
205 u[i] += chrSrc[j][i] * chrFilter[j]; | |
206 v[i] += chrSrc[j][i + 2048] * chrFilter[j]; | |
207 } | |
208 } | |
209 altivec_packIntArrayToCharArray(u,uDest,chrDstW); | |
210 altivec_packIntArrayToCharArray(v,vDest,chrDstW); | |
211 } | |
212 } | |
213 | |
214 static inline void hScale_altivec_real(int16_t *dst, int dstW, uint8_t *src, int srcW, int xInc, int16_t *filter, int16_t *filterPos, int filterSize) { | |
215 register int i; | |
216 int __attribute__ ((aligned (16))) tempo[4]; | |
217 | |
218 if (filterSize % 4) { | |
219 for(i=0; i<dstW; i++) { | |
220 register int j; | |
221 register int srcPos = filterPos[i]; | |
222 register int val = 0; | |
223 for(j=0; j<filterSize; j++) { | |
224 val += ((int)src[srcPos + j])*filter[filterSize*i + j]; | |
225 } | |
19181 | 226 dst[i] = FFMIN(FFMAX(0, val>>7), (1<<15)-1); |
18861 | 227 } |
228 } | |
229 else | |
230 switch (filterSize) { | |
231 case 4: | |
232 { | |
233 for(i=0; i<dstW; i++) { | |
234 register int j; | |
235 register int srcPos = filterPos[i]; | |
236 | |
237 vector unsigned char src_v0 = vec_ld(srcPos, src); | |
238 vector unsigned char src_v1; | |
239 if ((((int)src + srcPos)% 16) > 12) { | |
240 src_v1 = vec_ld(srcPos + 16, src); | |
241 } | |
242 vector unsigned char src_vF = vec_perm(src_v0, src_v1, vec_lvsl(srcPos, src)); | |
243 | |
244 vector signed short src_v = // vec_unpackh sign-extends... | |
245 (vector signed short)(vec_mergeh((vector unsigned char)vzero, src_vF)); | |
246 // now put our elements in the even slots | |
247 src_v = vec_mergeh(src_v, (vector signed short)vzero); | |
248 | |
249 vector signed short filter_v = vec_ld(i << 3, filter); | |
250 // the 3 above is 2 (filterSize == 4) + 1 (sizeof(short) == 2) | |
251 | |
252 // the neat trick : we only care for half the elements, | |
253 // high or low depending on (i<<3)%16 (it's 0 or 8 here), | |
254 // and we're going to use vec_mule, so we chose | |
255 // carefully how to "unpack" the elements into the even slots | |
256 if ((i << 3) % 16) | |
257 filter_v = vec_mergel(filter_v,(vector signed short)vzero); | |
258 else | |
259 filter_v = vec_mergeh(filter_v,(vector signed short)vzero); | |
260 | |
261 vector signed int val_vEven = vec_mule(src_v, filter_v); | |
262 vector signed int val_s = vec_sums(val_vEven, vzero); | |
263 vec_st(val_s, 0, tempo); | |
19181 | 264 dst[i] = FFMIN(FFMAX(0, tempo[3]>>7), (1<<15)-1); |
18861 | 265 } |
266 } | |
267 break; | |
268 | |
269 case 8: | |
270 { | |
271 for(i=0; i<dstW; i++) { | |
272 register int srcPos = filterPos[i]; | |
273 | |
274 vector unsigned char src_v0 = vec_ld(srcPos, src); | |
275 vector unsigned char src_v1; | |
276 if ((((int)src + srcPos)% 16) > 8) { | |
277 src_v1 = vec_ld(srcPos + 16, src); | |
278 } | |
279 vector unsigned char src_vF = vec_perm(src_v0, src_v1, vec_lvsl(srcPos, src)); | |
280 | |
281 vector signed short src_v = // vec_unpackh sign-extends... | |
282 (vector signed short)(vec_mergeh((vector unsigned char)vzero, src_vF)); | |
283 vector signed short filter_v = vec_ld(i << 4, filter); | |
284 // the 4 above is 3 (filterSize == 8) + 1 (sizeof(short) == 2) | |
285 | |
286 vector signed int val_v = vec_msums(src_v, filter_v, (vector signed int)vzero); | |
287 vector signed int val_s = vec_sums(val_v, vzero); | |
288 vec_st(val_s, 0, tempo); | |
19181 | 289 dst[i] = FFMIN(FFMAX(0, tempo[3]>>7), (1<<15)-1); |
18861 | 290 } |
291 } | |
292 break; | |
293 | |
294 case 16: | |
295 { | |
296 for(i=0; i<dstW; i++) { | |
297 register int srcPos = filterPos[i]; | |
298 | |
299 vector unsigned char src_v0 = vec_ld(srcPos, src); | |
300 vector unsigned char src_v1 = vec_ld(srcPos + 16, src); | |
301 vector unsigned char src_vF = vec_perm(src_v0, src_v1, vec_lvsl(srcPos, src)); | |
302 | |
303 vector signed short src_vA = // vec_unpackh sign-extends... | |
304 (vector signed short)(vec_mergeh((vector unsigned char)vzero, src_vF)); | |
305 vector signed short src_vB = // vec_unpackh sign-extends... | |
306 (vector signed short)(vec_mergel((vector unsigned char)vzero, src_vF)); | |
307 | |
308 vector signed short filter_v0 = vec_ld(i << 5, filter); | |
309 vector signed short filter_v1 = vec_ld((i << 5) + 16, filter); | |
310 // the 5 above are 4 (filterSize == 16) + 1 (sizeof(short) == 2) | |
311 | |
312 vector signed int val_acc = vec_msums(src_vA, filter_v0, (vector signed int)vzero); | |
313 vector signed int val_v = vec_msums(src_vB, filter_v1, val_acc); | |
314 | |
315 vector signed int val_s = vec_sums(val_v, vzero); | |
316 | |
317 vec_st(val_s, 0, tempo); | |
19181 | 318 dst[i] = FFMIN(FFMAX(0, tempo[3]>>7), (1<<15)-1); |
18861 | 319 } |
320 } | |
321 break; | |
322 | |
323 default: | |
324 { | |
325 for(i=0; i<dstW; i++) { | |
326 register int j; | |
327 register int srcPos = filterPos[i]; | |
328 | |
329 vector signed int val_v = (vector signed int)vzero; | |
330 vector signed short filter_v0R = vec_ld(i * 2 * filterSize, filter); | |
331 vector unsigned char permF = vec_lvsl((i * 2 * filterSize), filter); | |
332 | |
333 vector unsigned char src_v0 = vec_ld(srcPos, src); | |
334 vector unsigned char permS = vec_lvsl(srcPos, src); | |
335 | |
336 for (j = 0 ; j < filterSize - 15; j += 16) { | |
337 vector unsigned char src_v1 = vec_ld(srcPos + j + 16, src); | |
338 vector unsigned char src_vF = vec_perm(src_v0, src_v1, permS); | |
339 | |
340 vector signed short src_vA = // vec_unpackh sign-extends... | |
341 (vector signed short)(vec_mergeh((vector unsigned char)vzero, src_vF)); | |
342 vector signed short src_vB = // vec_unpackh sign-extends... | |
343 (vector signed short)(vec_mergel((vector unsigned char)vzero, src_vF)); | |
344 | |
345 vector signed short filter_v1R = vec_ld((i * 2 * filterSize) + (j * 2) + 16, filter); | |
346 vector signed short filter_v2R = vec_ld((i * 2 * filterSize) + (j * 2) + 32, filter); | |
347 vector signed short filter_v0 = vec_perm(filter_v0R, filter_v1R, permF); | |
348 vector signed short filter_v1 = vec_perm(filter_v1R, filter_v2R, permF); | |
349 | |
350 vector signed int val_acc = vec_msums(src_vA, filter_v0, val_v); | |
351 val_v = vec_msums(src_vB, filter_v1, val_acc); | |
352 | |
353 filter_v0R = filter_v2R; | |
354 src_v0 = src_v1; | |
355 } | |
356 | |
357 if (j < (filterSize-7)) { | |
358 // loading src_v0 is useless, it's already done above | |
359 //vector unsigned char src_v0 = vec_ld(srcPos + j, src); | |
360 vector unsigned char src_v1; | |
361 if ((((int)src + srcPos)% 16) > 8) { | |
362 src_v1 = vec_ld(srcPos + j + 16, src); | |
363 } | |
364 vector unsigned char src_vF = vec_perm(src_v0, src_v1, permS); | |
365 | |
366 vector signed short src_v = // vec_unpackh sign-extends... | |
367 (vector signed short)(vec_mergeh((vector unsigned char)vzero, src_vF)); | |
368 // loading filter_v0R is useless, it's already done above | |
369 //vector signed short filter_v0R = vec_ld((i * 2 * filterSize) + j, filter); | |
370 vector signed short filter_v1R = vec_ld((i * 2 * filterSize) + (j * 2) + 16, filter); | |
371 vector signed short filter_v = vec_perm(filter_v0R, filter_v1R, permF); | |
372 | |
373 val_v = vec_msums(src_v, filter_v, val_v); | |
374 } | |
375 | |
376 vector signed int val_s = vec_sums(val_v, vzero); | |
377 | |
378 vec_st(val_s, 0, tempo); | |
19181 | 379 dst[i] = FFMIN(FFMAX(0, tempo[3]>>7), (1<<15)-1); |
18861 | 380 } |
381 | |
382 } | |
383 } | |
384 } | |
385 | |
386 static inline int yv12toyuy2_unscaled_altivec(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, | |
387 int srcSliceH, uint8_t* dstParam[], int dstStride_a[]) { | |
388 uint8_t *dst=dstParam[0] + dstStride_a[0]*srcSliceY; | |
389 // yv12toyuy2( src[0],src[1],src[2],dst,c->srcW,srcSliceH,srcStride[0],srcStride[1],dstStride[0] ); | |
390 uint8_t *ysrc = src[0]; | |
391 uint8_t *usrc = src[1]; | |
392 uint8_t *vsrc = src[2]; | |
393 const int width = c->srcW; | |
394 const int height = srcSliceH; | |
395 const int lumStride = srcStride[0]; | |
396 const int chromStride = srcStride[1]; | |
397 const int dstStride = dstStride_a[0]; | |
398 const vector unsigned char yperm = vec_lvsl(0, ysrc); | |
399 const int vertLumPerChroma = 2; | |
400 register unsigned int y; | |
401 | |
402 if(width&15){ | |
403 yv12toyuy2( ysrc, usrc, vsrc, dst,c->srcW,srcSliceH, lumStride, chromStride, dstStride); | |
404 return srcSliceH; | |
405 } | |
406 | |
407 /* this code assume: | |
408 | |
409 1) dst is 16 bytes-aligned | |
410 2) dstStride is a multiple of 16 | |
411 3) width is a multiple of 16 | |
412 4) lum&chrom stride are multiple of 8 | |
413 */ | |
414 | |
415 for(y=0; y<height; y++) | |
416 { | |
417 int i; | |
418 for (i = 0; i < width - 31; i+= 32) { | |
419 const unsigned int j = i >> 1; | |
420 vector unsigned char v_yA = vec_ld(i, ysrc); | |
421 vector unsigned char v_yB = vec_ld(i + 16, ysrc); | |
422 vector unsigned char v_yC = vec_ld(i + 32, ysrc); | |
423 vector unsigned char v_y1 = vec_perm(v_yA, v_yB, yperm); | |
424 vector unsigned char v_y2 = vec_perm(v_yB, v_yC, yperm); | |
425 vector unsigned char v_uA = vec_ld(j, usrc); | |
426 vector unsigned char v_uB = vec_ld(j + 16, usrc); | |
427 vector unsigned char v_u = vec_perm(v_uA, v_uB, vec_lvsl(j, usrc)); | |
428 vector unsigned char v_vA = vec_ld(j, vsrc); | |
429 vector unsigned char v_vB = vec_ld(j + 16, vsrc); | |
430 vector unsigned char v_v = vec_perm(v_vA, v_vB, vec_lvsl(j, vsrc)); | |
431 vector unsigned char v_uv_a = vec_mergeh(v_u, v_v); | |
432 vector unsigned char v_uv_b = vec_mergel(v_u, v_v); | |
433 vector unsigned char v_yuy2_0 = vec_mergeh(v_y1, v_uv_a); | |
434 vector unsigned char v_yuy2_1 = vec_mergel(v_y1, v_uv_a); | |
435 vector unsigned char v_yuy2_2 = vec_mergeh(v_y2, v_uv_b); | |
436 vector unsigned char v_yuy2_3 = vec_mergel(v_y2, v_uv_b); | |
437 vec_st(v_yuy2_0, (i << 1), dst); | |
438 vec_st(v_yuy2_1, (i << 1) + 16, dst); | |
439 vec_st(v_yuy2_2, (i << 1) + 32, dst); | |
440 vec_st(v_yuy2_3, (i << 1) + 48, dst); | |
441 } | |
442 if (i < width) { | |
443 const unsigned int j = i >> 1; | |
444 vector unsigned char v_y1 = vec_ld(i, ysrc); | |
445 vector unsigned char v_u = vec_ld(j, usrc); | |
446 vector unsigned char v_v = vec_ld(j, vsrc); | |
447 vector unsigned char v_uv_a = vec_mergeh(v_u, v_v); | |
448 vector unsigned char v_yuy2_0 = vec_mergeh(v_y1, v_uv_a); | |
449 vector unsigned char v_yuy2_1 = vec_mergel(v_y1, v_uv_a); | |
450 vec_st(v_yuy2_0, (i << 1), dst); | |
451 vec_st(v_yuy2_1, (i << 1) + 16, dst); | |
452 } | |
453 if((y&(vertLumPerChroma-1))==(vertLumPerChroma-1) ) | |
454 { | |
455 usrc += chromStride; | |
456 vsrc += chromStride; | |
457 } | |
458 ysrc += lumStride; | |
459 dst += dstStride; | |
460 } | |
461 | |
462 return srcSliceH; | |
463 } | |
464 | |
465 static inline int yv12touyvy_unscaled_altivec(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, | |
466 int srcSliceH, uint8_t* dstParam[], int dstStride_a[]) { | |
467 uint8_t *dst=dstParam[0] + dstStride_a[0]*srcSliceY; | |
468 // yv12toyuy2( src[0],src[1],src[2],dst,c->srcW,srcSliceH,srcStride[0],srcStride[1],dstStride[0] ); | |
469 uint8_t *ysrc = src[0]; | |
470 uint8_t *usrc = src[1]; | |
471 uint8_t *vsrc = src[2]; | |
472 const int width = c->srcW; | |
473 const int height = srcSliceH; | |
474 const int lumStride = srcStride[0]; | |
475 const int chromStride = srcStride[1]; | |
476 const int dstStride = dstStride_a[0]; | |
477 const int vertLumPerChroma = 2; | |
478 const vector unsigned char yperm = vec_lvsl(0, ysrc); | |
479 register unsigned int y; | |
480 | |
481 if(width&15){ | |
482 yv12touyvy( ysrc, usrc, vsrc, dst,c->srcW,srcSliceH, lumStride, chromStride, dstStride); | |
483 return srcSliceH; | |
484 } | |
485 | |
486 /* this code assume: | |
487 | |
488 1) dst is 16 bytes-aligned | |
489 2) dstStride is a multiple of 16 | |
490 3) width is a multiple of 16 | |
491 4) lum&chrom stride are multiple of 8 | |
492 */ | |
493 | |
494 for(y=0; y<height; y++) | |
495 { | |
496 int i; | |
497 for (i = 0; i < width - 31; i+= 32) { | |
498 const unsigned int j = i >> 1; | |
499 vector unsigned char v_yA = vec_ld(i, ysrc); | |
500 vector unsigned char v_yB = vec_ld(i + 16, ysrc); | |
501 vector unsigned char v_yC = vec_ld(i + 32, ysrc); | |
502 vector unsigned char v_y1 = vec_perm(v_yA, v_yB, yperm); | |
503 vector unsigned char v_y2 = vec_perm(v_yB, v_yC, yperm); | |
504 vector unsigned char v_uA = vec_ld(j, usrc); | |
505 vector unsigned char v_uB = vec_ld(j + 16, usrc); | |
506 vector unsigned char v_u = vec_perm(v_uA, v_uB, vec_lvsl(j, usrc)); | |
507 vector unsigned char v_vA = vec_ld(j, vsrc); | |
508 vector unsigned char v_vB = vec_ld(j + 16, vsrc); | |
509 vector unsigned char v_v = vec_perm(v_vA, v_vB, vec_lvsl(j, vsrc)); | |
510 vector unsigned char v_uv_a = vec_mergeh(v_u, v_v); | |
511 vector unsigned char v_uv_b = vec_mergel(v_u, v_v); | |
512 vector unsigned char v_uyvy_0 = vec_mergeh(v_uv_a, v_y1); | |
513 vector unsigned char v_uyvy_1 = vec_mergel(v_uv_a, v_y1); | |
514 vector unsigned char v_uyvy_2 = vec_mergeh(v_uv_b, v_y2); | |
515 vector unsigned char v_uyvy_3 = vec_mergel(v_uv_b, v_y2); | |
516 vec_st(v_uyvy_0, (i << 1), dst); | |
517 vec_st(v_uyvy_1, (i << 1) + 16, dst); | |
518 vec_st(v_uyvy_2, (i << 1) + 32, dst); | |
519 vec_st(v_uyvy_3, (i << 1) + 48, dst); | |
520 } | |
521 if (i < width) { | |
522 const unsigned int j = i >> 1; | |
523 vector unsigned char v_y1 = vec_ld(i, ysrc); | |
524 vector unsigned char v_u = vec_ld(j, usrc); | |
525 vector unsigned char v_v = vec_ld(j, vsrc); | |
526 vector unsigned char v_uv_a = vec_mergeh(v_u, v_v); | |
527 vector unsigned char v_uyvy_0 = vec_mergeh(v_uv_a, v_y1); | |
528 vector unsigned char v_uyvy_1 = vec_mergel(v_uv_a, v_y1); | |
529 vec_st(v_uyvy_0, (i << 1), dst); | |
530 vec_st(v_uyvy_1, (i << 1) + 16, dst); | |
531 } | |
532 if((y&(vertLumPerChroma-1))==(vertLumPerChroma-1) ) | |
533 { | |
534 usrc += chromStride; | |
535 vsrc += chromStride; | |
536 } | |
537 ysrc += lumStride; | |
538 dst += dstStride; | |
539 } | |
540 return srcSliceH; | |
541 } |