annotate libswscale/swscale_altivec_template.c @ 19363:2e3981fa938c

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