annotate libswscale/swscale_altivec_template.c @ 23732:0396f6a6d0d1

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