Mercurial > mplayer.hg
annotate postproc/swscale_template.c @ 9414:04c6fd75ed96
cleanup
author | michael |
---|---|
date | Thu, 13 Feb 2003 18:24:33 +0000 |
parents | 0d86fe21b281 |
children | 5eea6d903b4c |
rev | line source |
---|---|
4295 | 1 /* |
2 Copyright (C) 2001-2002 Michael Niedermayer <michaelni@gmx.at> | |
2216 | 3 |
4295 | 4 This program is free software; you can redistribute it and/or modify |
5 it under the terms of the GNU General Public License as published by | |
6 the Free Software Foundation; either version 2 of the License, or | |
7 (at your option) any later version. | |
2216 | 8 |
4295 | 9 This program is distributed in the hope that it will be useful, |
10 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 GNU General Public License for more details. | |
13 | |
14 You should have received a copy of the GNU General Public License | |
15 along with this program; if not, write to the Free Software | |
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
17 */ | |
2264
7851375ea156
increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents:
2237
diff
changeset
|
18 |
2540 | 19 #undef MOVNTQ |
2680 | 20 #undef PAVGB |
3136 | 21 #undef PREFETCH |
22 #undef PREFETCHW | |
23 #undef EMMS | |
24 #undef SFENCE | |
25 | |
26 #ifdef HAVE_3DNOW | |
27 /* On K6 femms is faster of emms. On K7 femms is directly mapped on emms. */ | |
28 #define EMMS "femms" | |
29 #else | |
30 #define EMMS "emms" | |
31 #endif | |
32 | |
33 #ifdef HAVE_3DNOW | |
34 #define PREFETCH "prefetch" | |
35 #define PREFETCHW "prefetchw" | |
36 #elif defined ( HAVE_MMX2 ) | |
37 #define PREFETCH "prefetchnta" | |
38 #define PREFETCHW "prefetcht0" | |
39 #else | |
40 #define PREFETCH "/nop" | |
41 #define PREFETCHW "/nop" | |
42 #endif | |
43 | |
44 #ifdef HAVE_MMX2 | |
45 #define SFENCE "sfence" | |
46 #else | |
47 #define SFENCE "/nop" | |
48 #endif | |
2232
65996b3467d7
MMX & MMX2 optimizations (MMX2 is buggy and commented out)
michael
parents:
2230
diff
changeset
|
49 |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
50 #ifdef HAVE_MMX2 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
51 #define PAVGB(a,b) "pavgb " #a ", " #b " \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
52 #elif defined (HAVE_3DNOW) |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
53 #define PAVGB(a,b) "pavgusb " #a ", " #b " \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
54 #endif |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
55 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
56 #ifdef HAVE_MMX2 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
57 #define MOVNTQ(a,b) "movntq " #a ", " #b " \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
58 #else |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
59 #define MOVNTQ(a,b) "movq " #a ", " #b " \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
60 #endif |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
61 |
9413 | 62 #define YSCALEYUV2YV12X(x, offset) \ |
3344 | 63 "xorl %%eax, %%eax \n\t"\ |
64 "pxor %%mm3, %%mm3 \n\t"\ | |
65 "pxor %%mm4, %%mm4 \n\t"\ | |
9413 | 66 "leal " offset "(%0), %%edx \n\t"\ |
67 "movl (%%edx), %%esi \n\t"\ | |
3344 | 68 ".balign 16 \n\t" /* FIXME Unroll? */\ |
69 "1: \n\t"\ | |
9413 | 70 "movq 8(%%edx), %%mm0 \n\t" /* filterCoeff */\ |
3344 | 71 "movq " #x "(%%esi, %%eax, 2), %%mm2 \n\t" /* srcData */\ |
72 "movq 8+" #x "(%%esi, %%eax, 2), %%mm5 \n\t" /* srcData */\ | |
9413 | 73 "addl $16, %%edx \n\t"\ |
74 "movl (%%edx), %%esi \n\t"\ | |
75 "testl %%esi, %%esi \n\t"\ | |
3344 | 76 "pmulhw %%mm0, %%mm2 \n\t"\ |
77 "pmulhw %%mm0, %%mm5 \n\t"\ | |
78 "paddw %%mm2, %%mm3 \n\t"\ | |
79 "paddw %%mm5, %%mm4 \n\t"\ | |
80 " jnz 1b \n\t"\ | |
81 "psraw $3, %%mm3 \n\t"\ | |
82 "psraw $3, %%mm4 \n\t"\ | |
83 "packuswb %%mm4, %%mm3 \n\t"\ | |
9413 | 84 MOVNTQ(%%mm3, (%1, %%eax))\ |
3344 | 85 "addl $8, %%eax \n\t"\ |
9413 | 86 "cmpl %2, %%eax \n\t"\ |
3344 | 87 "pxor %%mm3, %%mm3 \n\t"\ |
88 "pxor %%mm4, %%mm4 \n\t"\ | |
9413 | 89 "leal " offset "(%0), %%edx \n\t"\ |
90 "movl (%%edx), %%esi \n\t"\ | |
3344 | 91 "jb 1b \n\t" |
92 | |
93 #define YSCALEYUV2YV121 \ | |
94 "movl %2, %%eax \n\t"\ | |
95 ".balign 16 \n\t" /* FIXME Unroll? */\ | |
96 "1: \n\t"\ | |
97 "movq (%0, %%eax, 2), %%mm0 \n\t"\ | |
98 "movq 8(%0, %%eax, 2), %%mm1 \n\t"\ | |
99 "psraw $7, %%mm0 \n\t"\ | |
100 "psraw $7, %%mm1 \n\t"\ | |
101 "packuswb %%mm1, %%mm0 \n\t"\ | |
102 MOVNTQ(%%mm0, (%1, %%eax))\ | |
103 "addl $8, %%eax \n\t"\ | |
104 "jnc 1b \n\t" | |
105 | |
106 /* | |
107 :: "m" (-lumFilterSize), "m" (-chrFilterSize), | |
108 "m" (lumMmxFilter+lumFilterSize*4), "m" (chrMmxFilter+chrFilterSize*4), | |
109 "r" (dest), "m" (dstW), | |
110 "m" (lumSrc+lumFilterSize), "m" (chrSrc+chrFilterSize) | |
111 : "%eax", "%ebx", "%ecx", "%edx", "%esi" | |
112 */ | |
7723 | 113 #define YSCALEYUV2PACKEDX \ |
3344 | 114 "xorl %%eax, %%eax \n\t"\ |
115 ".balign 16 \n\t"\ | |
9413 | 116 "nop \n\t"\ |
3344 | 117 "1: \n\t"\ |
9413 | 118 "leal "CHR_MMX_FILTER_OFFSET"(%0), %%edx \n\t"\ |
119 "movl (%%edx), %%esi \n\t"\ | |
3344 | 120 "pxor %%mm3, %%mm3 \n\t"\ |
121 "pxor %%mm4, %%mm4 \n\t"\ | |
9413 | 122 ".balign 16 \n\t"\ |
3344 | 123 "2: \n\t"\ |
9413 | 124 "movq 8(%%edx), %%mm0 \n\t" /* filterCoeff */\ |
3344 | 125 "movq (%%esi, %%eax), %%mm2 \n\t" /* UsrcData */\ |
126 "movq 4096(%%esi, %%eax), %%mm5 \n\t" /* VsrcData */\ | |
9413 | 127 "addl $16, %%edx \n\t"\ |
128 "movl (%%edx), %%esi \n\t"\ | |
3344 | 129 "pmulhw %%mm0, %%mm2 \n\t"\ |
130 "pmulhw %%mm0, %%mm5 \n\t"\ | |
131 "paddw %%mm2, %%mm3 \n\t"\ | |
132 "paddw %%mm5, %%mm4 \n\t"\ | |
9413 | 133 "testl %%esi, %%esi \n\t"\ |
3344 | 134 " jnz 2b \n\t"\ |
135 \ | |
9413 | 136 "leal "LUM_MMX_FILTER_OFFSET"(%0), %%edx \n\t"\ |
137 "movl (%%edx), %%esi \n\t"\ | |
3344 | 138 "pxor %%mm1, %%mm1 \n\t"\ |
139 "pxor %%mm7, %%mm7 \n\t"\ | |
9413 | 140 ".balign 16 \n\t"\ |
3344 | 141 "2: \n\t"\ |
9413 | 142 "movq 8(%%edx), %%mm0 \n\t" /* filterCoeff */\ |
3344 | 143 "movq (%%esi, %%eax, 2), %%mm2 \n\t" /* Y1srcData */\ |
144 "movq 8(%%esi, %%eax, 2), %%mm5 \n\t" /* Y2srcData */\ | |
9413 | 145 "addl $16, %%edx \n\t"\ |
146 "movl (%%edx), %%esi \n\t"\ | |
3344 | 147 "pmulhw %%mm0, %%mm2 \n\t"\ |
148 "pmulhw %%mm0, %%mm5 \n\t"\ | |
149 "paddw %%mm2, %%mm1 \n\t"\ | |
150 "paddw %%mm5, %%mm7 \n\t"\ | |
9413 | 151 "testl %%esi, %%esi \n\t"\ |
3344 | 152 " jnz 2b \n\t"\ |
7723 | 153 |
154 | |
155 #define YSCALEYUV2RGBX \ | |
156 YSCALEYUV2PACKEDX\ | |
9413 | 157 "psubw "U_OFFSET"(%0), %%mm3 \n\t" /* (U-128)8*/\ |
158 "psubw "V_OFFSET"(%0), %%mm4 \n\t" /* (V-128)8*/\ | |
3344 | 159 "movq %%mm3, %%mm2 \n\t" /* (U-128)8*/\ |
160 "movq %%mm4, %%mm5 \n\t" /* (V-128)8*/\ | |
9413 | 161 "pmulhw "UG_COEFF"(%0), %%mm3 \n\t"\ |
162 "pmulhw "VG_COEFF"(%0), %%mm4 \n\t"\ | |
3344 | 163 /* mm2=(U-128)8, mm3=ug, mm4=vg mm5=(V-128)8 */\ |
9413 | 164 "pmulhw "UB_COEFF"(%0), %%mm2 \n\t"\ |
165 "pmulhw "VR_COEFF"(%0), %%mm5 \n\t"\ | |
166 "psubw "Y_OFFSET"(%0), %%mm1 \n\t" /* 8(Y-16)*/\ | |
167 "psubw "Y_OFFSET"(%0), %%mm7 \n\t" /* 8(Y-16)*/\ | |
168 "pmulhw "Y_COEFF"(%0), %%mm1 \n\t"\ | |
169 "pmulhw "Y_COEFF"(%0), %%mm7 \n\t"\ | |
3344 | 170 /* mm1= Y1, mm2=ub, mm3=ug, mm4=vg mm5=vr, mm7=Y2 */\ |
171 "paddw %%mm3, %%mm4 \n\t"\ | |
172 "movq %%mm2, %%mm0 \n\t"\ | |
173 "movq %%mm5, %%mm6 \n\t"\ | |
174 "movq %%mm4, %%mm3 \n\t"\ | |
175 "punpcklwd %%mm2, %%mm2 \n\t"\ | |
176 "punpcklwd %%mm5, %%mm5 \n\t"\ | |
177 "punpcklwd %%mm4, %%mm4 \n\t"\ | |
178 "paddw %%mm1, %%mm2 \n\t"\ | |
179 "paddw %%mm1, %%mm5 \n\t"\ | |
180 "paddw %%mm1, %%mm4 \n\t"\ | |
181 "punpckhwd %%mm0, %%mm0 \n\t"\ | |
182 "punpckhwd %%mm6, %%mm6 \n\t"\ | |
183 "punpckhwd %%mm3, %%mm3 \n\t"\ | |
184 "paddw %%mm7, %%mm0 \n\t"\ | |
185 "paddw %%mm7, %%mm6 \n\t"\ | |
186 "paddw %%mm7, %%mm3 \n\t"\ | |
187 /* mm0=B1, mm2=B2, mm3=G2, mm4=G1, mm5=R1, mm6=R2 */\ | |
188 "packuswb %%mm0, %%mm2 \n\t"\ | |
189 "packuswb %%mm6, %%mm5 \n\t"\ | |
190 "packuswb %%mm3, %%mm4 \n\t"\ | |
191 "pxor %%mm7, %%mm7 \n\t" | |
9413 | 192 #if 0 |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
193 #define FULL_YSCALEYUV2RGB \ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
194 "pxor %%mm7, %%mm7 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
195 "movd %6, %%mm6 \n\t" /*yalpha1*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
196 "punpcklwd %%mm6, %%mm6 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
197 "punpcklwd %%mm6, %%mm6 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
198 "movd %7, %%mm5 \n\t" /*uvalpha1*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
199 "punpcklwd %%mm5, %%mm5 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
200 "punpcklwd %%mm5, %%mm5 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
201 "xorl %%eax, %%eax \n\t"\ |
2800
7847d6b7ad3d
.balign or we¡ll align by 64kb on some architectures
michael
parents:
2799
diff
changeset
|
202 ".balign 16 \n\t"\ |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
203 "1: \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
204 "movq (%0, %%eax, 2), %%mm0 \n\t" /*buf0[eax]*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
205 "movq (%1, %%eax, 2), %%mm1 \n\t" /*buf1[eax]*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
206 "movq (%2, %%eax,2), %%mm2 \n\t" /* uvbuf0[eax]*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
207 "movq (%3, %%eax,2), %%mm3 \n\t" /* uvbuf1[eax]*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
208 "psubw %%mm1, %%mm0 \n\t" /* buf0[eax] - buf1[eax]*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
209 "psubw %%mm3, %%mm2 \n\t" /* uvbuf0[eax] - uvbuf1[eax]*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
210 "pmulhw %%mm6, %%mm0 \n\t" /* (buf0[eax] - buf1[eax])yalpha1>>16*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
211 "pmulhw %%mm5, %%mm2 \n\t" /* (uvbuf0[eax] - uvbuf1[eax])uvalpha1>>16*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
212 "psraw $4, %%mm1 \n\t" /* buf0[eax] - buf1[eax] >>4*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
213 "movq 4096(%2, %%eax,2), %%mm4 \n\t" /* uvbuf0[eax+2048]*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
214 "psraw $4, %%mm3 \n\t" /* uvbuf0[eax] - uvbuf1[eax] >>4*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
215 "paddw %%mm0, %%mm1 \n\t" /* buf0[eax]yalpha1 + buf1[eax](1-yalpha1) >>16*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
216 "movq 4096(%3, %%eax,2), %%mm0 \n\t" /* uvbuf1[eax+2048]*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
217 "paddw %%mm2, %%mm3 \n\t" /* uvbuf0[eax]uvalpha1 - uvbuf1[eax](1-uvalpha1)*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
218 "psubw %%mm0, %%mm4 \n\t" /* uvbuf0[eax+2048] - uvbuf1[eax+2048]*/\ |
4248 | 219 "psubw "MANGLE(w80)", %%mm1 \n\t" /* 8(Y-16)*/\ |
220 "psubw "MANGLE(w400)", %%mm3 \n\t" /* 8(U-128)*/\ | |
221 "pmulhw "MANGLE(yCoeff)", %%mm1 \n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
222 \ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
223 \ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
224 "pmulhw %%mm5, %%mm4 \n\t" /* (uvbuf0[eax+2048] - uvbuf1[eax+2048])uvalpha1>>16*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
225 "movq %%mm3, %%mm2 \n\t" /* (U-128)8*/\ |
4248 | 226 "pmulhw "MANGLE(ubCoeff)", %%mm3\n\t"\ |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
227 "psraw $4, %%mm0 \n\t" /* uvbuf0[eax+2048] - uvbuf1[eax+2048] >>4*/\ |
4248 | 228 "pmulhw "MANGLE(ugCoeff)", %%mm2\n\t"\ |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
229 "paddw %%mm4, %%mm0 \n\t" /* uvbuf0[eax+2048]uvalpha1 - uvbuf1[eax+2048](1-uvalpha1)*/\ |
4248 | 230 "psubw "MANGLE(w400)", %%mm0 \n\t" /* (V-128)8*/\ |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
231 \ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
232 \ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
233 "movq %%mm0, %%mm4 \n\t" /* (V-128)8*/\ |
4248 | 234 "pmulhw "MANGLE(vrCoeff)", %%mm0\n\t"\ |
235 "pmulhw "MANGLE(vgCoeff)", %%mm4\n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
236 "paddw %%mm1, %%mm3 \n\t" /* B*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
237 "paddw %%mm1, %%mm0 \n\t" /* R*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
238 "packuswb %%mm3, %%mm3 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
239 \ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
240 "packuswb %%mm0, %%mm0 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
241 "paddw %%mm4, %%mm2 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
242 "paddw %%mm2, %%mm1 \n\t" /* G*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
243 \ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
244 "packuswb %%mm1, %%mm1 \n\t" |
9413 | 245 #endif |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
246 |
9414 | 247 #define YSCALEYUV2PACKED(index, c) \ |
248 "movq "CHR_MMX_FILTER_OFFSET"+8("#c"), %%mm0\n\t"\ | |
249 "movq "LUM_MMX_FILTER_OFFSET"+8("#c"), %%mm1\n\t"\ | |
250 "psraw $3, %%mm0 \n\t"\ | |
251 "psraw $3, %%mm1 \n\t"\ | |
252 "movq %%mm0, "CHR_MMX_FILTER_OFFSET"+8("#c")\n\t"\ | |
253 "movq %%mm1, "LUM_MMX_FILTER_OFFSET"+8("#c")\n\t"\ | |
254 "xorl "#index", "#index" \n\t"\ | |
7723 | 255 ".balign 16 \n\t"\ |
256 "1: \n\t"\ | |
9414 | 257 "movq (%2, "#index"), %%mm2 \n\t" /* uvbuf0[eax]*/\ |
258 "movq (%3, "#index"), %%mm3 \n\t" /* uvbuf1[eax]*/\ | |
259 "movq 4096(%2, "#index"), %%mm5 \n\t" /* uvbuf0[eax+2048]*/\ | |
260 "movq 4096(%3, "#index"), %%mm4 \n\t" /* uvbuf1[eax+2048]*/\ | |
7723 | 261 "psubw %%mm3, %%mm2 \n\t" /* uvbuf0[eax] - uvbuf1[eax]*/\ |
262 "psubw %%mm4, %%mm5 \n\t" /* uvbuf0[eax+2048] - uvbuf1[eax+2048]*/\ | |
9414 | 263 "movq "CHR_MMX_FILTER_OFFSET"+8("#c"), %%mm0\n\t"\ |
7723 | 264 "pmulhw %%mm0, %%mm2 \n\t" /* (uvbuf0[eax] - uvbuf1[eax])uvalpha1>>16*/\ |
265 "pmulhw %%mm0, %%mm5 \n\t" /* (uvbuf0[eax+2048] - uvbuf1[eax+2048])uvalpha1>>16*/\ | |
266 "psraw $7, %%mm3 \n\t" /* uvbuf0[eax] - uvbuf1[eax] >>4*/\ | |
267 "psraw $7, %%mm4 \n\t" /* uvbuf0[eax+2048] - uvbuf1[eax+2048] >>4*/\ | |
268 "paddw %%mm2, %%mm3 \n\t" /* uvbuf0[eax]uvalpha1 - uvbuf1[eax](1-uvalpha1)*/\ | |
269 "paddw %%mm5, %%mm4 \n\t" /* uvbuf0[eax+2048]uvalpha1 - uvbuf1[eax+2048](1-uvalpha1)*/\ | |
9414 | 270 "movq (%0, "#index", 2), %%mm0 \n\t" /*buf0[eax]*/\ |
271 "movq (%1, "#index", 2), %%mm1 \n\t" /*buf1[eax]*/\ | |
272 "movq 8(%0, "#index", 2), %%mm6 \n\t" /*buf0[eax]*/\ | |
273 "movq 8(%1, "#index", 2), %%mm7 \n\t" /*buf1[eax]*/\ | |
7723 | 274 "psubw %%mm1, %%mm0 \n\t" /* buf0[eax] - buf1[eax]*/\ |
275 "psubw %%mm7, %%mm6 \n\t" /* buf0[eax] - buf1[eax]*/\ | |
9414 | 276 "pmulhw "LUM_MMX_FILTER_OFFSET"+8("#c"), %%mm0\n\t" /* (buf0[eax] - buf1[eax])yalpha1>>16*/\ |
277 "pmulhw "LUM_MMX_FILTER_OFFSET"+8("#c"), %%mm6\n\t" /* (buf0[eax] - buf1[eax])yalpha1>>16*/\ | |
7723 | 278 "psraw $7, %%mm1 \n\t" /* buf0[eax] - buf1[eax] >>4*/\ |
279 "psraw $7, %%mm7 \n\t" /* buf0[eax] - buf1[eax] >>4*/\ | |
280 "paddw %%mm0, %%mm1 \n\t" /* buf0[eax]yalpha1 + buf1[eax](1-yalpha1) >>16*/\ | |
281 "paddw %%mm6, %%mm7 \n\t" /* buf0[eax]yalpha1 + buf1[eax](1-yalpha1) >>16*/\ | |
282 | |
9414 | 283 #define YSCALEYUV2RGB(index, c) \ |
284 "xorl "#index", "#index" \n\t"\ | |
2800
7847d6b7ad3d
.balign or we¡ll align by 64kb on some architectures
michael
parents:
2799
diff
changeset
|
285 ".balign 16 \n\t"\ |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
286 "1: \n\t"\ |
9414 | 287 "movq (%2, "#index"), %%mm2 \n\t" /* uvbuf0[eax]*/\ |
288 "movq (%3, "#index"), %%mm3 \n\t" /* uvbuf1[eax]*/\ | |
289 "movq 4096(%2, "#index"), %%mm5\n\t" /* uvbuf0[eax+2048]*/\ | |
290 "movq 4096(%3, "#index"), %%mm4\n\t" /* uvbuf1[eax+2048]*/\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
291 "psubw %%mm3, %%mm2 \n\t" /* uvbuf0[eax] - uvbuf1[eax]*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
292 "psubw %%mm4, %%mm5 \n\t" /* uvbuf0[eax+2048] - uvbuf1[eax+2048]*/\ |
9414 | 293 "movq "CHR_MMX_FILTER_OFFSET"+8("#c"), %%mm0\n\t"\ |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
294 "pmulhw %%mm0, %%mm2 \n\t" /* (uvbuf0[eax] - uvbuf1[eax])uvalpha1>>16*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
295 "pmulhw %%mm0, %%mm5 \n\t" /* (uvbuf0[eax+2048] - uvbuf1[eax+2048])uvalpha1>>16*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
296 "psraw $4, %%mm3 \n\t" /* uvbuf0[eax] - uvbuf1[eax] >>4*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
297 "psraw $4, %%mm4 \n\t" /* uvbuf0[eax+2048] - uvbuf1[eax+2048] >>4*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
298 "paddw %%mm2, %%mm3 \n\t" /* uvbuf0[eax]uvalpha1 - uvbuf1[eax](1-uvalpha1)*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
299 "paddw %%mm5, %%mm4 \n\t" /* uvbuf0[eax+2048]uvalpha1 - uvbuf1[eax+2048](1-uvalpha1)*/\ |
9414 | 300 "psubw "U_OFFSET"("#c"), %%mm3 \n\t" /* (U-128)8*/\ |
301 "psubw "V_OFFSET"("#c"), %%mm4 \n\t" /* (V-128)8*/\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
302 "movq %%mm3, %%mm2 \n\t" /* (U-128)8*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
303 "movq %%mm4, %%mm5 \n\t" /* (V-128)8*/\ |
9414 | 304 "pmulhw "UG_COEFF"("#c"), %%mm3\n\t"\ |
305 "pmulhw "VG_COEFF"("#c"), %%mm4\n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
306 /* mm2=(U-128)8, mm3=ug, mm4=vg mm5=(V-128)8 */\ |
9414 | 307 "movq (%0, "#index", 2), %%mm0 \n\t" /*buf0[eax]*/\ |
308 "movq (%1, "#index", 2), %%mm1 \n\t" /*buf1[eax]*/\ | |
309 "movq 8(%0, "#index", 2), %%mm6\n\t" /*buf0[eax]*/\ | |
310 "movq 8(%1, "#index", 2), %%mm7\n\t" /*buf1[eax]*/\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
311 "psubw %%mm1, %%mm0 \n\t" /* buf0[eax] - buf1[eax]*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
312 "psubw %%mm7, %%mm6 \n\t" /* buf0[eax] - buf1[eax]*/\ |
9414 | 313 "pmulhw "LUM_MMX_FILTER_OFFSET"+8("#c"), %%mm0\n\t" /* (buf0[eax] - buf1[eax])yalpha1>>16*/\ |
314 "pmulhw "LUM_MMX_FILTER_OFFSET"+8("#c"), %%mm6\n\t" /* (buf0[eax] - buf1[eax])yalpha1>>16*/\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
315 "psraw $4, %%mm1 \n\t" /* buf0[eax] - buf1[eax] >>4*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
316 "psraw $4, %%mm7 \n\t" /* buf0[eax] - buf1[eax] >>4*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
317 "paddw %%mm0, %%mm1 \n\t" /* buf0[eax]yalpha1 + buf1[eax](1-yalpha1) >>16*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
318 "paddw %%mm6, %%mm7 \n\t" /* buf0[eax]yalpha1 + buf1[eax](1-yalpha1) >>16*/\ |
9414 | 319 "pmulhw "UB_COEFF"("#c"), %%mm2\n\t"\ |
320 "pmulhw "VR_COEFF"("#c"), %%mm5\n\t"\ | |
321 "psubw "Y_OFFSET"("#c"), %%mm1 \n\t" /* 8(Y-16)*/\ | |
322 "psubw "Y_OFFSET"("#c"), %%mm7 \n\t" /* 8(Y-16)*/\ | |
323 "pmulhw "Y_COEFF"("#c"), %%mm1 \n\t"\ | |
324 "pmulhw "Y_COEFF"("#c"), %%mm7 \n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
325 /* mm1= Y1, mm2=ub, mm3=ug, mm4=vg mm5=vr, mm7=Y2 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
326 "paddw %%mm3, %%mm4 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
327 "movq %%mm2, %%mm0 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
328 "movq %%mm5, %%mm6 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
329 "movq %%mm4, %%mm3 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
330 "punpcklwd %%mm2, %%mm2 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
331 "punpcklwd %%mm5, %%mm5 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
332 "punpcklwd %%mm4, %%mm4 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
333 "paddw %%mm1, %%mm2 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
334 "paddw %%mm1, %%mm5 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
335 "paddw %%mm1, %%mm4 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
336 "punpckhwd %%mm0, %%mm0 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
337 "punpckhwd %%mm6, %%mm6 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
338 "punpckhwd %%mm3, %%mm3 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
339 "paddw %%mm7, %%mm0 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
340 "paddw %%mm7, %%mm6 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
341 "paddw %%mm7, %%mm3 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
342 /* mm0=B1, mm2=B2, mm3=G2, mm4=G1, mm5=R1, mm6=R2 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
343 "packuswb %%mm0, %%mm2 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
344 "packuswb %%mm6, %%mm5 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
345 "packuswb %%mm3, %%mm4 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
346 "pxor %%mm7, %%mm7 \n\t" |
7723 | 347 |
348 #define YSCALEYUV2PACKED1 \ | |
349 "xorl %%eax, %%eax \n\t"\ | |
350 ".balign 16 \n\t"\ | |
351 "1: \n\t"\ | |
352 "movq (%2, %%eax), %%mm3 \n\t" /* uvbuf0[eax]*/\ | |
353 "movq 4096(%2, %%eax), %%mm4 \n\t" /* uvbuf0[eax+2048]*/\ | |
354 "psraw $7, %%mm3 \n\t" \ | |
355 "psraw $7, %%mm4 \n\t" \ | |
356 "movq (%0, %%eax, 2), %%mm1 \n\t" /*buf0[eax]*/\ | |
357 "movq 8(%0, %%eax, 2), %%mm7 \n\t" /*buf0[eax]*/\ | |
358 "psraw $7, %%mm1 \n\t" \ | |
359 "psraw $7, %%mm7 \n\t" \ | |
360 | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
361 #define YSCALEYUV2RGB1 \ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
362 "xorl %%eax, %%eax \n\t"\ |
2800
7847d6b7ad3d
.balign or we¡ll align by 64kb on some architectures
michael
parents:
2799
diff
changeset
|
363 ".balign 16 \n\t"\ |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
364 "1: \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
365 "movq (%2, %%eax), %%mm3 \n\t" /* uvbuf0[eax]*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
366 "movq 4096(%2, %%eax), %%mm4 \n\t" /* uvbuf0[eax+2048]*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
367 "psraw $4, %%mm3 \n\t" /* uvbuf0[eax] - uvbuf1[eax] >>4*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
368 "psraw $4, %%mm4 \n\t" /* uvbuf0[eax+2048] - uvbuf1[eax+2048] >>4*/\ |
4248 | 369 "psubw "MANGLE(w400)", %%mm3 \n\t" /* (U-128)8*/\ |
370 "psubw "MANGLE(w400)", %%mm4 \n\t" /* (V-128)8*/\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
371 "movq %%mm3, %%mm2 \n\t" /* (U-128)8*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
372 "movq %%mm4, %%mm5 \n\t" /* (V-128)8*/\ |
4248 | 373 "pmulhw "MANGLE(ugCoeff)", %%mm3\n\t"\ |
374 "pmulhw "MANGLE(vgCoeff)", %%mm4\n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
375 /* mm2=(U-128)8, mm3=ug, mm4=vg mm5=(V-128)8 */\ |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
376 "movq (%0, %%eax, 2), %%mm1 \n\t" /*buf0[eax]*/\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
377 "movq 8(%0, %%eax, 2), %%mm7 \n\t" /*buf0[eax]*/\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
378 "psraw $4, %%mm1 \n\t" /* buf0[eax] - buf1[eax] >>4*/\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
379 "psraw $4, %%mm7 \n\t" /* buf0[eax] - buf1[eax] >>4*/\ |
4248 | 380 "pmulhw "MANGLE(ubCoeff)", %%mm2\n\t"\ |
381 "pmulhw "MANGLE(vrCoeff)", %%mm5\n\t"\ | |
382 "psubw "MANGLE(w80)", %%mm1 \n\t" /* 8(Y-16)*/\ | |
383 "psubw "MANGLE(w80)", %%mm7 \n\t" /* 8(Y-16)*/\ | |
384 "pmulhw "MANGLE(yCoeff)", %%mm1 \n\t"\ | |
385 "pmulhw "MANGLE(yCoeff)", %%mm7 \n\t"\ | |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
386 /* mm1= Y1, mm2=ub, mm3=ug, mm4=vg mm5=vr, mm7=Y2 */\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
387 "paddw %%mm3, %%mm4 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
388 "movq %%mm2, %%mm0 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
389 "movq %%mm5, %%mm6 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
390 "movq %%mm4, %%mm3 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
391 "punpcklwd %%mm2, %%mm2 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
392 "punpcklwd %%mm5, %%mm5 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
393 "punpcklwd %%mm4, %%mm4 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
394 "paddw %%mm1, %%mm2 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
395 "paddw %%mm1, %%mm5 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
396 "paddw %%mm1, %%mm4 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
397 "punpckhwd %%mm0, %%mm0 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
398 "punpckhwd %%mm6, %%mm6 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
399 "punpckhwd %%mm3, %%mm3 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
400 "paddw %%mm7, %%mm0 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
401 "paddw %%mm7, %%mm6 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
402 "paddw %%mm7, %%mm3 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
403 /* mm0=B1, mm2=B2, mm3=G2, mm4=G1, mm5=R1, mm6=R2 */\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
404 "packuswb %%mm0, %%mm2 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
405 "packuswb %%mm6, %%mm5 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
406 "packuswb %%mm3, %%mm4 \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
407 "pxor %%mm7, %%mm7 \n\t" |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
408 |
7723 | 409 #define YSCALEYUV2PACKED1b \ |
410 "xorl %%eax, %%eax \n\t"\ | |
411 ".balign 16 \n\t"\ | |
412 "1: \n\t"\ | |
413 "movq (%2, %%eax), %%mm2 \n\t" /* uvbuf0[eax]*/\ | |
414 "movq (%3, %%eax), %%mm3 \n\t" /* uvbuf1[eax]*/\ | |
415 "movq 4096(%2, %%eax), %%mm5 \n\t" /* uvbuf0[eax+2048]*/\ | |
416 "movq 4096(%3, %%eax), %%mm4 \n\t" /* uvbuf1[eax+2048]*/\ | |
417 "paddw %%mm2, %%mm3 \n\t" /* uvbuf0[eax] + uvbuf1[eax]*/\ | |
418 "paddw %%mm5, %%mm4 \n\t" /* uvbuf0[eax+2048] + uvbuf1[eax+2048]*/\ | |
419 "psrlw $8, %%mm3 \n\t" \ | |
420 "psrlw $8, %%mm4 \n\t" \ | |
421 "movq (%0, %%eax, 2), %%mm1 \n\t" /*buf0[eax]*/\ | |
422 "movq 8(%0, %%eax, 2), %%mm7 \n\t" /*buf0[eax]*/\ | |
423 "psraw $7, %%mm1 \n\t" \ | |
424 "psraw $7, %%mm7 \n\t" | |
425 | |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
426 // do vertical chrominance interpolation |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
427 #define YSCALEYUV2RGB1b \ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
428 "xorl %%eax, %%eax \n\t"\ |
2800
7847d6b7ad3d
.balign or we¡ll align by 64kb on some architectures
michael
parents:
2799
diff
changeset
|
429 ".balign 16 \n\t"\ |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
430 "1: \n\t"\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
431 "movq (%2, %%eax), %%mm2 \n\t" /* uvbuf0[eax]*/\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
432 "movq (%3, %%eax), %%mm3 \n\t" /* uvbuf1[eax]*/\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
433 "movq 4096(%2, %%eax), %%mm5 \n\t" /* uvbuf0[eax+2048]*/\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
434 "movq 4096(%3, %%eax), %%mm4 \n\t" /* uvbuf1[eax+2048]*/\ |
2576 | 435 "paddw %%mm2, %%mm3 \n\t" /* uvbuf0[eax] + uvbuf1[eax]*/\ |
436 "paddw %%mm5, %%mm4 \n\t" /* uvbuf0[eax+2048] + uvbuf1[eax+2048]*/\ | |
3344 | 437 "psrlw $5, %%mm3 \n\t" /*FIXME might overflow*/\ |
438 "psrlw $5, %%mm4 \n\t" /*FIXME might overflow*/\ | |
4248 | 439 "psubw "MANGLE(w400)", %%mm3 \n\t" /* (U-128)8*/\ |
440 "psubw "MANGLE(w400)", %%mm4 \n\t" /* (V-128)8*/\ | |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
441 "movq %%mm3, %%mm2 \n\t" /* (U-128)8*/\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
442 "movq %%mm4, %%mm5 \n\t" /* (V-128)8*/\ |
4248 | 443 "pmulhw "MANGLE(ugCoeff)", %%mm3\n\t"\ |
444 "pmulhw "MANGLE(vgCoeff)", %%mm4\n\t"\ | |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
445 /* mm2=(U-128)8, mm3=ug, mm4=vg mm5=(V-128)8 */\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
446 "movq (%0, %%eax, 2), %%mm1 \n\t" /*buf0[eax]*/\ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
447 "movq 8(%0, %%eax, 2), %%mm7 \n\t" /*buf0[eax]*/\ |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
448 "psraw $4, %%mm1 \n\t" /* buf0[eax] - buf1[eax] >>4*/\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
449 "psraw $4, %%mm7 \n\t" /* buf0[eax] - buf1[eax] >>4*/\ |
4248 | 450 "pmulhw "MANGLE(ubCoeff)", %%mm2\n\t"\ |
451 "pmulhw "MANGLE(vrCoeff)", %%mm5\n\t"\ | |
452 "psubw "MANGLE(w80)", %%mm1 \n\t" /* 8(Y-16)*/\ | |
453 "psubw "MANGLE(w80)", %%mm7 \n\t" /* 8(Y-16)*/\ | |
454 "pmulhw "MANGLE(yCoeff)", %%mm1 \n\t"\ | |
455 "pmulhw "MANGLE(yCoeff)", %%mm7 \n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
456 /* mm1= Y1, mm2=ub, mm3=ug, mm4=vg mm5=vr, mm7=Y2 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
457 "paddw %%mm3, %%mm4 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
458 "movq %%mm2, %%mm0 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
459 "movq %%mm5, %%mm6 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
460 "movq %%mm4, %%mm3 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
461 "punpcklwd %%mm2, %%mm2 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
462 "punpcklwd %%mm5, %%mm5 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
463 "punpcklwd %%mm4, %%mm4 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
464 "paddw %%mm1, %%mm2 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
465 "paddw %%mm1, %%mm5 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
466 "paddw %%mm1, %%mm4 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
467 "punpckhwd %%mm0, %%mm0 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
468 "punpckhwd %%mm6, %%mm6 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
469 "punpckhwd %%mm3, %%mm3 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
470 "paddw %%mm7, %%mm0 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
471 "paddw %%mm7, %%mm6 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
472 "paddw %%mm7, %%mm3 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
473 /* mm0=B1, mm2=B2, mm3=G2, mm4=G1, mm5=R1, mm6=R2 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
474 "packuswb %%mm0, %%mm2 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
475 "packuswb %%mm6, %%mm5 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
476 "packuswb %%mm3, %%mm4 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
477 "pxor %%mm7, %%mm7 \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
478 |
9414 | 479 #define WRITEBGR32(dst, dstw, index) \ |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
480 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
481 "movq %%mm2, %%mm1 \n\t" /* B */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
482 "movq %%mm5, %%mm6 \n\t" /* R */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
483 "punpcklbw %%mm4, %%mm2 \n\t" /* GBGBGBGB 0 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
484 "punpcklbw %%mm7, %%mm5 \n\t" /* 0R0R0R0R 0 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
485 "punpckhbw %%mm4, %%mm1 \n\t" /* GBGBGBGB 2 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
486 "punpckhbw %%mm7, %%mm6 \n\t" /* 0R0R0R0R 2 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
487 "movq %%mm2, %%mm0 \n\t" /* GBGBGBGB 0 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
488 "movq %%mm1, %%mm3 \n\t" /* GBGBGBGB 2 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
489 "punpcklwd %%mm5, %%mm0 \n\t" /* 0RGB0RGB 0 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
490 "punpckhwd %%mm5, %%mm2 \n\t" /* 0RGB0RGB 1 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
491 "punpcklwd %%mm6, %%mm1 \n\t" /* 0RGB0RGB 2 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
492 "punpckhwd %%mm6, %%mm3 \n\t" /* 0RGB0RGB 3 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
493 \ |
9414 | 494 MOVNTQ(%%mm0, (dst, index, 4))\ |
495 MOVNTQ(%%mm2, 8(dst, index, 4))\ | |
496 MOVNTQ(%%mm1, 16(dst, index, 4))\ | |
497 MOVNTQ(%%mm3, 24(dst, index, 4))\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
498 \ |
9414 | 499 "addl $8, "#index" \n\t"\ |
500 "cmpl "#dstw", "#index" \n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
501 " jb 1b \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
502 |
9414 | 503 #define WRITEBGR16(dst, dstw, index) \ |
4248 | 504 "pand "MANGLE(bF8)", %%mm2 \n\t" /* B */\ |
505 "pand "MANGLE(bFC)", %%mm4 \n\t" /* G */\ | |
506 "pand "MANGLE(bF8)", %%mm5 \n\t" /* R */\ | |
2669 | 507 "psrlq $3, %%mm2 \n\t"\ |
508 \ | |
509 "movq %%mm2, %%mm1 \n\t"\ | |
510 "movq %%mm4, %%mm3 \n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
511 \ |
2669 | 512 "punpcklbw %%mm7, %%mm3 \n\t"\ |
513 "punpcklbw %%mm5, %%mm2 \n\t"\ | |
514 "punpckhbw %%mm7, %%mm4 \n\t"\ | |
515 "punpckhbw %%mm5, %%mm1 \n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
516 \ |
2669 | 517 "psllq $3, %%mm3 \n\t"\ |
518 "psllq $3, %%mm4 \n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
519 \ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
520 "por %%mm3, %%mm2 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
521 "por %%mm4, %%mm1 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
522 \ |
9414 | 523 MOVNTQ(%%mm2, (dst, index, 2))\ |
524 MOVNTQ(%%mm1, 8(dst, index, 2))\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
525 \ |
9414 | 526 "addl $8, "#index" \n\t"\ |
527 "cmpl "#dstw", "#index" \n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
528 " jb 1b \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
529 |
9414 | 530 #define WRITEBGR15(dst, dstw, index) \ |
4248 | 531 "pand "MANGLE(bF8)", %%mm2 \n\t" /* B */\ |
532 "pand "MANGLE(bF8)", %%mm4 \n\t" /* G */\ | |
533 "pand "MANGLE(bF8)", %%mm5 \n\t" /* R */\ | |
2669 | 534 "psrlq $3, %%mm2 \n\t"\ |
535 "psrlq $1, %%mm5 \n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
536 \ |
2669 | 537 "movq %%mm2, %%mm1 \n\t"\ |
538 "movq %%mm4, %%mm3 \n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
539 \ |
2669 | 540 "punpcklbw %%mm7, %%mm3 \n\t"\ |
541 "punpcklbw %%mm5, %%mm2 \n\t"\ | |
542 "punpckhbw %%mm7, %%mm4 \n\t"\ | |
543 "punpckhbw %%mm5, %%mm1 \n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
544 \ |
2669 | 545 "psllq $2, %%mm3 \n\t"\ |
546 "psllq $2, %%mm4 \n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
547 \ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
548 "por %%mm3, %%mm2 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
549 "por %%mm4, %%mm1 \n\t"\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
550 \ |
9414 | 551 MOVNTQ(%%mm2, (dst, index, 2))\ |
552 MOVNTQ(%%mm1, 8(dst, index, 2))\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
553 \ |
9414 | 554 "addl $8, "#index" \n\t"\ |
555 "cmpl "#dstw", "#index" \n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
556 " jb 1b \n\t" |
2669 | 557 |
9414 | 558 #define WRITEBGR24OLD(dst, dstw, index) \ |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
559 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
560 "movq %%mm2, %%mm1 \n\t" /* B */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
561 "movq %%mm5, %%mm6 \n\t" /* R */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
562 "punpcklbw %%mm4, %%mm2 \n\t" /* GBGBGBGB 0 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
563 "punpcklbw %%mm7, %%mm5 \n\t" /* 0R0R0R0R 0 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
564 "punpckhbw %%mm4, %%mm1 \n\t" /* GBGBGBGB 2 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
565 "punpckhbw %%mm7, %%mm6 \n\t" /* 0R0R0R0R 2 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
566 "movq %%mm2, %%mm0 \n\t" /* GBGBGBGB 0 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
567 "movq %%mm1, %%mm3 \n\t" /* GBGBGBGB 2 */\ |
2326 | 568 "punpcklwd %%mm5, %%mm0 \n\t" /* 0RGB0RGB 0 */\ |
569 "punpckhwd %%mm5, %%mm2 \n\t" /* 0RGB0RGB 1 */\ | |
570 "punpcklwd %%mm6, %%mm1 \n\t" /* 0RGB0RGB 2 */\ | |
571 "punpckhwd %%mm6, %%mm3 \n\t" /* 0RGB0RGB 3 */\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
572 \ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
573 "movq %%mm0, %%mm4 \n\t" /* 0RGB0RGB 0 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
574 "psrlq $8, %%mm0 \n\t" /* 00RGB0RG 0 */\ |
4248 | 575 "pand "MANGLE(bm00000111)", %%mm4\n\t" /* 00000RGB 0 */\ |
576 "pand "MANGLE(bm11111000)", %%mm0\n\t" /* 00RGB000 0.5 */\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
577 "por %%mm4, %%mm0 \n\t" /* 00RGBRGB 0 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
578 "movq %%mm2, %%mm4 \n\t" /* 0RGB0RGB 1 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
579 "psllq $48, %%mm2 \n\t" /* GB000000 1 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
580 "por %%mm2, %%mm0 \n\t" /* GBRGBRGB 0 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
581 \ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
582 "movq %%mm4, %%mm2 \n\t" /* 0RGB0RGB 1 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
583 "psrld $16, %%mm4 \n\t" /* 000R000R 1 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
584 "psrlq $24, %%mm2 \n\t" /* 0000RGB0 1.5 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
585 "por %%mm4, %%mm2 \n\t" /* 000RRGBR 1 */\ |
4248 | 586 "pand "MANGLE(bm00001111)", %%mm2\n\t" /* 0000RGBR 1 */\ |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
587 "movq %%mm1, %%mm4 \n\t" /* 0RGB0RGB 2 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
588 "psrlq $8, %%mm1 \n\t" /* 00RGB0RG 2 */\ |
4248 | 589 "pand "MANGLE(bm00000111)", %%mm4\n\t" /* 00000RGB 2 */\ |
590 "pand "MANGLE(bm11111000)", %%mm1\n\t" /* 00RGB000 2.5 */\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
591 "por %%mm4, %%mm1 \n\t" /* 00RGBRGB 2 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
592 "movq %%mm1, %%mm4 \n\t" /* 00RGBRGB 2 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
593 "psllq $32, %%mm1 \n\t" /* BRGB0000 2 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
594 "por %%mm1, %%mm2 \n\t" /* BRGBRGBR 1 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
595 \ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
596 "psrlq $32, %%mm4 \n\t" /* 000000RG 2.5 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
597 "movq %%mm3, %%mm5 \n\t" /* 0RGB0RGB 3 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
598 "psrlq $8, %%mm3 \n\t" /* 00RGB0RG 3 */\ |
4248 | 599 "pand "MANGLE(bm00000111)", %%mm5\n\t" /* 00000RGB 3 */\ |
600 "pand "MANGLE(bm11111000)", %%mm3\n\t" /* 00RGB000 3.5 */\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
601 "por %%mm5, %%mm3 \n\t" /* 00RGBRGB 3 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
602 "psllq $16, %%mm3 \n\t" /* RGBRGB00 3 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
603 "por %%mm4, %%mm3 \n\t" /* RGBRGBRG 2.5 */\ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
604 \ |
9414 | 605 MOVNTQ(%%mm0, (dst))\ |
606 MOVNTQ(%%mm2, 8(dst))\ | |
607 MOVNTQ(%%mm3, 16(dst))\ | |
608 "addl $24, "#dst" \n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
609 \ |
9414 | 610 "addl $8, "#index" \n\t"\ |
611 "cmpl "#dstw", "#index" \n\t"\ | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
612 " jb 1b \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
613 |
9414 | 614 #define WRITEBGR24MMX(dst, dstw, index) \ |
2730 | 615 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */\ |
616 "movq %%mm2, %%mm1 \n\t" /* B */\ | |
617 "movq %%mm5, %%mm6 \n\t" /* R */\ | |
618 "punpcklbw %%mm4, %%mm2 \n\t" /* GBGBGBGB 0 */\ | |
619 "punpcklbw %%mm7, %%mm5 \n\t" /* 0R0R0R0R 0 */\ | |
620 "punpckhbw %%mm4, %%mm1 \n\t" /* GBGBGBGB 2 */\ | |
621 "punpckhbw %%mm7, %%mm6 \n\t" /* 0R0R0R0R 2 */\ | |
622 "movq %%mm2, %%mm0 \n\t" /* GBGBGBGB 0 */\ | |
623 "movq %%mm1, %%mm3 \n\t" /* GBGBGBGB 2 */\ | |
624 "punpcklwd %%mm5, %%mm0 \n\t" /* 0RGB0RGB 0 */\ | |
625 "punpckhwd %%mm5, %%mm2 \n\t" /* 0RGB0RGB 1 */\ | |
626 "punpcklwd %%mm6, %%mm1 \n\t" /* 0RGB0RGB 2 */\ | |
627 "punpckhwd %%mm6, %%mm3 \n\t" /* 0RGB0RGB 3 */\ | |
628 \ | |
629 "movq %%mm0, %%mm4 \n\t" /* 0RGB0RGB 0 */\ | |
630 "movq %%mm2, %%mm6 \n\t" /* 0RGB0RGB 1 */\ | |
631 "movq %%mm1, %%mm5 \n\t" /* 0RGB0RGB 2 */\ | |
632 "movq %%mm3, %%mm7 \n\t" /* 0RGB0RGB 3 */\ | |
633 \ | |
634 "psllq $40, %%mm0 \n\t" /* RGB00000 0 */\ | |
635 "psllq $40, %%mm2 \n\t" /* RGB00000 1 */\ | |
636 "psllq $40, %%mm1 \n\t" /* RGB00000 2 */\ | |
637 "psllq $40, %%mm3 \n\t" /* RGB00000 3 */\ | |
638 \ | |
639 "punpckhdq %%mm4, %%mm0 \n\t" /* 0RGBRGB0 0 */\ | |
640 "punpckhdq %%mm6, %%mm2 \n\t" /* 0RGBRGB0 1 */\ | |
641 "punpckhdq %%mm5, %%mm1 \n\t" /* 0RGBRGB0 2 */\ | |
642 "punpckhdq %%mm7, %%mm3 \n\t" /* 0RGBRGB0 3 */\ | |
643 \ | |
644 "psrlq $8, %%mm0 \n\t" /* 00RGBRGB 0 */\ | |
645 "movq %%mm2, %%mm6 \n\t" /* 0RGBRGB0 1 */\ | |
646 "psllq $40, %%mm2 \n\t" /* GB000000 1 */\ | |
647 "por %%mm2, %%mm0 \n\t" /* GBRGBRGB 0 */\ | |
9414 | 648 MOVNTQ(%%mm0, (dst))\ |
2730 | 649 \ |
650 "psrlq $24, %%mm6 \n\t" /* 0000RGBR 1 */\ | |
651 "movq %%mm1, %%mm5 \n\t" /* 0RGBRGB0 2 */\ | |
652 "psllq $24, %%mm1 \n\t" /* BRGB0000 2 */\ | |
653 "por %%mm1, %%mm6 \n\t" /* BRGBRGBR 1 */\ | |
9414 | 654 MOVNTQ(%%mm6, 8(dst))\ |
2730 | 655 \ |
656 "psrlq $40, %%mm5 \n\t" /* 000000RG 2 */\ | |
657 "psllq $8, %%mm3 \n\t" /* RGBRGB00 3 */\ | |
658 "por %%mm3, %%mm5 \n\t" /* RGBRGBRG 2 */\ | |
9414 | 659 MOVNTQ(%%mm5, 16(dst))\ |
2730 | 660 \ |
9414 | 661 "addl $24, "#dst" \n\t"\ |
2730 | 662 \ |
9414 | 663 "addl $8, "#index" \n\t"\ |
664 "cmpl "#dstw", "#index" \n\t"\ | |
2730 | 665 " jb 1b \n\t" |
666 | |
9414 | 667 #define WRITEBGR24MMX2(dst, dstw, index) \ |
2730 | 668 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */\ |
4248 | 669 "movq "MANGLE(M24A)", %%mm0 \n\t"\ |
670 "movq "MANGLE(M24C)", %%mm7 \n\t"\ | |
2730 | 671 "pshufw $0x50, %%mm2, %%mm1 \n\t" /* B3 B2 B3 B2 B1 B0 B1 B0 */\ |
672 "pshufw $0x50, %%mm4, %%mm3 \n\t" /* G3 G2 G3 G2 G1 G0 G1 G0 */\ | |
673 "pshufw $0x00, %%mm5, %%mm6 \n\t" /* R1 R0 R1 R0 R1 R0 R1 R0 */\ | |
674 \ | |
675 "pand %%mm0, %%mm1 \n\t" /* B2 B1 B0 */\ | |
676 "pand %%mm0, %%mm3 \n\t" /* G2 G1 G0 */\ | |
677 "pand %%mm7, %%mm6 \n\t" /* R1 R0 */\ | |
678 \ | |
679 "psllq $8, %%mm3 \n\t" /* G2 G1 G0 */\ | |
680 "por %%mm1, %%mm6 \n\t"\ | |
681 "por %%mm3, %%mm6 \n\t"\ | |
9414 | 682 MOVNTQ(%%mm6, (dst))\ |
2730 | 683 \ |
684 "psrlq $8, %%mm4 \n\t" /* 00 G7 G6 G5 G4 G3 G2 G1 */\ | |
685 "pshufw $0xA5, %%mm2, %%mm1 \n\t" /* B5 B4 B5 B4 B3 B2 B3 B2 */\ | |
686 "pshufw $0x55, %%mm4, %%mm3 \n\t" /* G4 G3 G4 G3 G4 G3 G4 G3 */\ | |
687 "pshufw $0xA5, %%mm5, %%mm6 \n\t" /* R5 R4 R5 R4 R3 R2 R3 R2 */\ | |
688 \ | |
4248 | 689 "pand "MANGLE(M24B)", %%mm1 \n\t" /* B5 B4 B3 */\ |
2730 | 690 "pand %%mm7, %%mm3 \n\t" /* G4 G3 */\ |
691 "pand %%mm0, %%mm6 \n\t" /* R4 R3 R2 */\ | |
692 \ | |
693 "por %%mm1, %%mm3 \n\t" /* B5 G4 B4 G3 B3 */\ | |
694 "por %%mm3, %%mm6 \n\t"\ | |
9414 | 695 MOVNTQ(%%mm6, 8(dst))\ |
2730 | 696 \ |
697 "pshufw $0xFF, %%mm2, %%mm1 \n\t" /* B7 B6 B7 B6 B7 B6 B6 B7 */\ | |
698 "pshufw $0xFA, %%mm4, %%mm3 \n\t" /* 00 G7 00 G7 G6 G5 G6 G5 */\ | |
699 "pshufw $0xFA, %%mm5, %%mm6 \n\t" /* R7 R6 R7 R6 R5 R4 R5 R4 */\ | |
700 \ | |
701 "pand %%mm7, %%mm1 \n\t" /* B7 B6 */\ | |
702 "pand %%mm0, %%mm3 \n\t" /* G7 G6 G5 */\ | |
4248 | 703 "pand "MANGLE(M24B)", %%mm6 \n\t" /* R7 R6 R5 */\ |
2730 | 704 \ |
705 "por %%mm1, %%mm3 \n\t"\ | |
706 "por %%mm3, %%mm6 \n\t"\ | |
9414 | 707 MOVNTQ(%%mm6, 16(dst))\ |
2730 | 708 \ |
9414 | 709 "addl $24, "#dst" \n\t"\ |
2730 | 710 \ |
9414 | 711 "addl $8, "#index" \n\t"\ |
712 "cmpl "#dstw", "#index" \n\t"\ | |
2730 | 713 " jb 1b \n\t" |
714 | |
715 #ifdef HAVE_MMX2 | |
3126 | 716 #undef WRITEBGR24 |
2730 | 717 #define WRITEBGR24 WRITEBGR24MMX2 |
718 #else | |
3126 | 719 #undef WRITEBGR24 |
2730 | 720 #define WRITEBGR24 WRITEBGR24MMX |
721 #endif | |
722 | |
9414 | 723 #define WRITEYUY2(dst, dstw, index) \ |
7723 | 724 "packuswb %%mm3, %%mm3 \n\t"\ |
725 "packuswb %%mm4, %%mm4 \n\t"\ | |
726 "packuswb %%mm7, %%mm1 \n\t"\ | |
727 "punpcklbw %%mm4, %%mm3 \n\t"\ | |
728 "movq %%mm1, %%mm7 \n\t"\ | |
729 "punpcklbw %%mm3, %%mm1 \n\t"\ | |
730 "punpckhbw %%mm3, %%mm7 \n\t"\ | |
731 \ | |
9414 | 732 MOVNTQ(%%mm1, (dst, index, 2))\ |
733 MOVNTQ(%%mm7, 8(dst, index, 2))\ | |
7723 | 734 \ |
9414 | 735 "addl $8, "#index" \n\t"\ |
736 "cmpl "#dstw", "#index" \n\t"\ | |
7723 | 737 " jb 1b \n\t" |
738 | |
739 | |
9413 | 740 static inline void RENAME(yuv2yuvX)(SwsContext *c, int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize, |
3344 | 741 int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize, |
9414 | 742 uint8_t *dest, uint8_t *uDest, uint8_t *vDest, int dstW, int chrDstW) |
2519 | 743 { |
9413 | 744 int dummy=0; |
3344 | 745 #ifdef HAVE_MMX |
746 if(uDest != NULL) | |
747 { | |
748 asm volatile( | |
9413 | 749 YSCALEYUV2YV12X(0, CHR_MMX_FILTER_OFFSET) |
750 :: "r" (&c->redDither), | |
751 "r" (uDest), "m" (chrDstW) | |
3344 | 752 : "%eax", "%edx", "%esi" |
753 ); | |
2519 | 754 |
3344 | 755 asm volatile( |
9413 | 756 YSCALEYUV2YV12X(4096, CHR_MMX_FILTER_OFFSET) |
757 :: "r" (&c->redDither), | |
758 "r" (vDest), "m" (chrDstW) | |
3344 | 759 : "%eax", "%edx", "%esi" |
760 ); | |
761 } | |
2521 | 762 |
3344 | 763 asm volatile( |
9413 | 764 YSCALEYUV2YV12X(0, LUM_MMX_FILTER_OFFSET) |
765 :: "r" (&c->redDither), | |
766 "r" (dest), "m" (dstW) | |
3344 | 767 : "%eax", "%edx", "%esi" |
768 ); | |
769 #else | |
6540 | 770 yuv2yuvXinC(lumFilter, lumSrc, lumFilterSize, |
3352 | 771 chrFilter, chrSrc, chrFilterSize, |
6540 | 772 dest, uDest, vDest, dstW, chrDstW); |
3344 | 773 #endif |
774 } | |
775 | |
776 static inline void RENAME(yuv2yuv1)(int16_t *lumSrc, int16_t *chrSrc, | |
6532
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
777 uint8_t *dest, uint8_t *uDest, uint8_t *vDest, int dstW, int chrDstW) |
3344 | 778 { |
779 #ifdef HAVE_MMX | |
780 if(uDest != NULL) | |
781 { | |
782 asm volatile( | |
783 YSCALEYUV2YV121 | |
6532
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
784 :: "r" (chrSrc + chrDstW), "r" (uDest + chrDstW), |
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
785 "g" (-chrDstW) |
3344 | 786 : "%eax" |
787 ); | |
788 | |
789 asm volatile( | |
790 YSCALEYUV2YV121 | |
6532
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
791 :: "r" (chrSrc + 2048 + chrDstW), "r" (vDest + chrDstW), |
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
792 "g" (-chrDstW) |
3344 | 793 : "%eax" |
794 ); | |
2519 | 795 } |
3344 | 796 |
797 asm volatile( | |
798 YSCALEYUV2YV121 | |
799 :: "r" (lumSrc + dstW), "r" (dest + dstW), | |
800 "g" (-dstW) | |
801 : "%eax" | |
802 ); | |
803 #else | |
804 int i; | |
805 for(i=0; i<dstW; i++) | |
806 { | |
807 int val= lumSrc[i]>>7; | |
6503 | 808 |
809 if(val&256){ | |
810 if(val<0) val=0; | |
811 else val=255; | |
812 } | |
3344 | 813 |
6503 | 814 dest[i]= val; |
3344 | 815 } |
816 | |
817 if(uDest != NULL) | |
6532
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
818 for(i=0; i<chrDstW; i++) |
3344 | 819 { |
820 int u=chrSrc[i]>>7; | |
821 int v=chrSrc[i + 2048]>>7; | |
822 | |
6503 | 823 if((u|v)&256){ |
824 if(u<0) u=0; | |
825 else if (u>255) u=255; | |
826 if(v<0) v=0; | |
827 else if (v>255) v=255; | |
828 } | |
829 | |
830 uDest[i]= u; | |
831 vDest[i]= v; | |
3344 | 832 } |
833 #endif | |
2519 | 834 } |
835 | |
3344 | 836 |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
837 /** |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
838 * vertical scale YV12 to RGB |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
839 */ |
7723 | 840 static inline void RENAME(yuv2packedX)(SwsContext *c, int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize, |
3344 | 841 int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize, |
9413 | 842 uint8_t *dest, int dstW, int dstY) |
3344 | 843 { |
9413 | 844 int dummy=0; |
6578 | 845 switch(c->dstFormat) |
3344 | 846 { |
847 #ifdef HAVE_MMX | |
6578 | 848 case IMGFMT_BGR32: |
3344 | 849 { |
850 asm volatile( | |
851 YSCALEYUV2RGBX | |
9414 | 852 WRITEBGR32(%4, %5, %%eax) |
3344 | 853 |
9413 | 854 :: "r" (&c->redDither), |
855 "m" (dummy), "m" (dummy), "m" (dummy), | |
856 "r" (dest), "m" (dstW) | |
857 : "%eax", "%edx", "%esi" | |
3344 | 858 ); |
859 } | |
6578 | 860 break; |
861 case IMGFMT_BGR24: | |
3344 | 862 { |
863 asm volatile( | |
864 YSCALEYUV2RGBX | |
865 "leal (%%eax, %%eax, 2), %%ebx \n\t" //FIXME optimize | |
866 "addl %4, %%ebx \n\t" | |
9414 | 867 WRITEBGR24(%%ebx, %5, %%eax) |
3344 | 868 |
9413 | 869 :: "r" (&c->redDither), |
870 "m" (dummy), "m" (dummy), "m" (dummy), | |
871 "r" (dest), "m" (dstW) | |
872 : "%eax", "%ebx", "%edx", "%esi" //FIXME ebx | |
3344 | 873 ); |
874 } | |
6578 | 875 break; |
876 case IMGFMT_BGR15: | |
3344 | 877 { |
878 asm volatile( | |
879 YSCALEYUV2RGBX | |
880 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */ | |
881 #ifdef DITHER1XBPP | |
4248 | 882 "paddusb "MANGLE(b5Dither)", %%mm2\n\t" |
883 "paddusb "MANGLE(g5Dither)", %%mm4\n\t" | |
884 "paddusb "MANGLE(r5Dither)", %%mm5\n\t" | |
3344 | 885 #endif |
886 | |
9414 | 887 WRITEBGR15(%4, %5, %%eax) |
3344 | 888 |
9413 | 889 :: "r" (&c->redDither), |
890 "m" (dummy), "m" (dummy), "m" (dummy), | |
891 "r" (dest), "m" (dstW) | |
892 : "%eax", "%edx", "%esi" | |
3344 | 893 ); |
894 } | |
6578 | 895 break; |
896 case IMGFMT_BGR16: | |
3344 | 897 { |
898 asm volatile( | |
899 YSCALEYUV2RGBX | |
900 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */ | |
901 #ifdef DITHER1XBPP | |
4248 | 902 "paddusb "MANGLE(b5Dither)", %%mm2\n\t" |
903 "paddusb "MANGLE(g6Dither)", %%mm4\n\t" | |
904 "paddusb "MANGLE(r5Dither)", %%mm5\n\t" | |
3344 | 905 #endif |
906 | |
9414 | 907 WRITEBGR16(%4, %5, %%eax) |
3344 | 908 |
9413 | 909 :: "r" (&c->redDither), |
910 "m" (dummy), "m" (dummy), "m" (dummy), | |
911 "r" (dest), "m" (dstW) | |
912 : "%eax", "%edx", "%esi" | |
3344 | 913 ); |
914 } | |
6578 | 915 break; |
7723 | 916 case IMGFMT_YUY2: |
917 { | |
918 asm volatile( | |
919 YSCALEYUV2PACKEDX | |
920 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */ | |
921 | |
922 "psraw $3, %%mm3 \n\t" | |
923 "psraw $3, %%mm4 \n\t" | |
924 "psraw $3, %%mm1 \n\t" | |
925 "psraw $3, %%mm7 \n\t" | |
9414 | 926 WRITEYUY2(%4, %5, %%eax) |
7723 | 927 |
9413 | 928 :: "r" (&c->redDither), |
929 "m" (dummy), "m" (dummy), "m" (dummy), | |
930 "r" (dest), "m" (dstW) | |
931 : "%eax", "%edx", "%esi" | |
7723 | 932 ); |
933 } | |
934 break; | |
3344 | 935 #endif |
6578 | 936 default: |
7723 | 937 yuv2packedXinC(c, lumFilter, lumSrc, lumFilterSize, |
6578 | 938 chrFilter, chrSrc, chrFilterSize, |
939 dest, dstW, dstY); | |
940 break; | |
941 } | |
3344 | 942 } |
943 | |
944 /** | |
945 * vertical bilinear scale YV12 to RGB | |
946 */ | |
7723 | 947 static inline void RENAME(yuv2packed2)(SwsContext *c, uint16_t *buf0, uint16_t *buf1, uint16_t *uvbuf0, uint16_t *uvbuf1, |
6578 | 948 uint8_t *dest, int dstW, int yalpha, int uvalpha, int y) |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
949 { |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
950 int yalpha1=yalpha^4095; |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
951 int uvalpha1=uvalpha^4095; |
6578 | 952 int i; |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
953 |
6578 | 954 #if 0 //isnt used |
4467 | 955 if(flags&SWS_FULL_CHR_H_INT) |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
956 { |
6578 | 957 switch(dstFormat) |
958 { | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
959 #ifdef HAVE_MMX |
6578 | 960 case IMGFMT_BGR32: |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
961 asm volatile( |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
962 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
963 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
964 FULL_YSCALEYUV2RGB |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
965 "punpcklbw %%mm1, %%mm3 \n\t" // BGBGBGBG |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
966 "punpcklbw %%mm7, %%mm0 \n\t" // R0R0R0R0 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
967 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
968 "movq %%mm3, %%mm1 \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
969 "punpcklwd %%mm0, %%mm3 \n\t" // BGR0BGR0 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
970 "punpckhwd %%mm0, %%mm1 \n\t" // BGR0BGR0 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
971 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
972 MOVNTQ(%%mm3, (%4, %%eax, 4)) |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
973 MOVNTQ(%%mm1, 8(%4, %%eax, 4)) |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
974 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
975 "addl $4, %%eax \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
976 "cmpl %5, %%eax \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
977 " jb 1b \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
978 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
979 |
3209 | 980 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" (dstW), |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
981 "m" (yalpha1), "m" (uvalpha1) |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
982 : "%eax" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
983 ); |
6578 | 984 break; |
985 case IMGFMT_BGR24: | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
986 asm volatile( |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
987 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
988 FULL_YSCALEYUV2RGB |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
989 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
990 // lsb ... msb |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
991 "punpcklbw %%mm1, %%mm3 \n\t" // BGBGBGBG |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
992 "punpcklbw %%mm7, %%mm0 \n\t" // R0R0R0R0 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
993 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
994 "movq %%mm3, %%mm1 \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
995 "punpcklwd %%mm0, %%mm3 \n\t" // BGR0BGR0 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
996 "punpckhwd %%mm0, %%mm1 \n\t" // BGR0BGR0 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
997 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
998 "movq %%mm3, %%mm2 \n\t" // BGR0BGR0 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
999 "psrlq $8, %%mm3 \n\t" // GR0BGR00 |
4248 | 1000 "pand "MANGLE(bm00000111)", %%mm2\n\t" // BGR00000 |
1001 "pand "MANGLE(bm11111000)", %%mm3\n\t" // 000BGR00 | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1002 "por %%mm2, %%mm3 \n\t" // BGRBGR00 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1003 "movq %%mm1, %%mm2 \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1004 "psllq $48, %%mm1 \n\t" // 000000BG |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1005 "por %%mm1, %%mm3 \n\t" // BGRBGRBG |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1006 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1007 "movq %%mm2, %%mm1 \n\t" // BGR0BGR0 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1008 "psrld $16, %%mm2 \n\t" // R000R000 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1009 "psrlq $24, %%mm1 \n\t" // 0BGR0000 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1010 "por %%mm2, %%mm1 \n\t" // RBGRR000 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1011 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1012 "movl %4, %%ebx \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1013 "addl %%eax, %%ebx \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1014 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1015 #ifdef HAVE_MMX2 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1016 //FIXME Alignment |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1017 "movntq %%mm3, (%%ebx, %%eax, 2)\n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1018 "movntq %%mm1, 8(%%ebx, %%eax, 2)\n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1019 #else |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1020 "movd %%mm3, (%%ebx, %%eax, 2) \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1021 "psrlq $32, %%mm3 \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1022 "movd %%mm3, 4(%%ebx, %%eax, 2) \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1023 "movd %%mm1, 8(%%ebx, %%eax, 2) \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1024 #endif |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1025 "addl $4, %%eax \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1026 "cmpl %5, %%eax \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1027 " jb 1b \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1028 |
3209 | 1029 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "m" (dest), "m" (dstW), |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1030 "m" (yalpha1), "m" (uvalpha1) |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1031 : "%eax", "%ebx" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1032 ); |
6578 | 1033 break; |
1034 case IMGFMT_BGR15: | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1035 asm volatile( |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1036 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1037 FULL_YSCALEYUV2RGB |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1038 #ifdef DITHER1XBPP |
4248 | 1039 "paddusb "MANGLE(g5Dither)", %%mm1\n\t" |
1040 "paddusb "MANGLE(r5Dither)", %%mm0\n\t" | |
1041 "paddusb "MANGLE(b5Dither)", %%mm3\n\t" | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1042 #endif |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1043 "punpcklbw %%mm7, %%mm1 \n\t" // 0G0G0G0G |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1044 "punpcklbw %%mm7, %%mm3 \n\t" // 0B0B0B0B |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1045 "punpcklbw %%mm7, %%mm0 \n\t" // 0R0R0R0R |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1046 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1047 "psrlw $3, %%mm3 \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1048 "psllw $2, %%mm1 \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1049 "psllw $7, %%mm0 \n\t" |
4248 | 1050 "pand "MANGLE(g15Mask)", %%mm1 \n\t" |
1051 "pand "MANGLE(r15Mask)", %%mm0 \n\t" | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1052 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1053 "por %%mm3, %%mm1 \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1054 "por %%mm1, %%mm0 \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1055 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1056 MOVNTQ(%%mm0, (%4, %%eax, 2)) |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1057 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1058 "addl $4, %%eax \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1059 "cmpl %5, %%eax \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1060 " jb 1b \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1061 |
3209 | 1062 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" (dstW), |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1063 "m" (yalpha1), "m" (uvalpha1) |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1064 : "%eax" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1065 ); |
6578 | 1066 break; |
1067 case IMGFMT_BGR16: | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1068 asm volatile( |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1069 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1070 FULL_YSCALEYUV2RGB |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1071 #ifdef DITHER1XBPP |
4248 | 1072 "paddusb "MANGLE(g6Dither)", %%mm1\n\t" |
1073 "paddusb "MANGLE(r5Dither)", %%mm0\n\t" | |
1074 "paddusb "MANGLE(b5Dither)", %%mm3\n\t" | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1075 #endif |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1076 "punpcklbw %%mm7, %%mm1 \n\t" // 0G0G0G0G |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1077 "punpcklbw %%mm7, %%mm3 \n\t" // 0B0B0B0B |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1078 "punpcklbw %%mm7, %%mm0 \n\t" // 0R0R0R0R |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1079 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1080 "psrlw $3, %%mm3 \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1081 "psllw $3, %%mm1 \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1082 "psllw $8, %%mm0 \n\t" |
4248 | 1083 "pand "MANGLE(g16Mask)", %%mm1 \n\t" |
1084 "pand "MANGLE(r16Mask)", %%mm0 \n\t" | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1085 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1086 "por %%mm3, %%mm1 \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1087 "por %%mm1, %%mm0 \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1088 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1089 MOVNTQ(%%mm0, (%4, %%eax, 2)) |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1090 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1091 "addl $4, %%eax \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1092 "cmpl %5, %%eax \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1093 " jb 1b \n\t" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1094 |
3209 | 1095 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" (dstW), |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1096 "m" (yalpha1), "m" (uvalpha1) |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1097 : "%eax" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1098 ); |
6578 | 1099 break; |
1100 #endif | |
1101 case IMGFMT_RGB32: | |
1102 #ifndef HAVE_MMX | |
1103 case IMGFMT_BGR32: | |
1104 #endif | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1105 if(dstFormat==IMGFMT_BGR32) |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1106 { |
4794 | 1107 int i; |
4793 | 1108 #ifdef WORDS_BIGENDIAN |
1109 dest++; | |
1110 #endif | |
3209 | 1111 for(i=0;i<dstW;i++){ |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1112 // vertical linear interpolation && yuv2rgb in a single step: |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1113 int Y=yuvtab_2568[((buf0[i]*yalpha1+buf1[i]*yalpha)>>19)]; |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1114 int U=((uvbuf0[i]*uvalpha1+uvbuf1[i]*uvalpha)>>19); |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1115 int V=((uvbuf0[i+2048]*uvalpha1+uvbuf1[i+2048]*uvalpha)>>19); |
2503 | 1116 dest[0]=clip_table[((Y + yuvtab_40cf[U]) >>13)]; |
1117 dest[1]=clip_table[((Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13)]; | |
1118 dest[2]=clip_table[((Y + yuvtab_3343[V]) >>13)]; | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1119 dest+= 4; |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1120 } |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1121 } |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1122 else if(dstFormat==IMGFMT_BGR24) |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1123 { |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1124 int i; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1125 for(i=0;i<dstW;i++){ |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1126 // vertical linear interpolation && yuv2rgb in a single step: |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1127 int Y=yuvtab_2568[((buf0[i]*yalpha1+buf1[i]*yalpha)>>19)]; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1128 int U=((uvbuf0[i]*uvalpha1+uvbuf1[i]*uvalpha)>>19); |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1129 int V=((uvbuf0[i+2048]*uvalpha1+uvbuf1[i+2048]*uvalpha)>>19); |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1130 dest[0]=clip_table[((Y + yuvtab_40cf[U]) >>13)]; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1131 dest[1]=clip_table[((Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13)]; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1132 dest[2]=clip_table[((Y + yuvtab_3343[V]) >>13)]; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1133 dest+= 3; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1134 } |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1135 } |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1136 else if(dstFormat==IMGFMT_BGR16) |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1137 { |
2671 | 1138 int i; |
3209 | 1139 for(i=0;i<dstW;i++){ |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1140 // vertical linear interpolation && yuv2rgb in a single step: |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1141 int Y=yuvtab_2568[((buf0[i]*yalpha1+buf1[i]*yalpha)>>19)]; |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1142 int U=((uvbuf0[i]*uvalpha1+uvbuf1[i]*uvalpha)>>19); |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1143 int V=((uvbuf0[i+2048]*uvalpha1+uvbuf1[i+2048]*uvalpha)>>19); |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1144 |
2572
f2353173d52c
c optimizations (array is faster than pointer) (16bpp variants tested and 2% faster)
michael
parents:
2569
diff
changeset
|
1145 ((uint16_t*)dest)[i] = |
2584 | 1146 clip_table16b[(Y + yuvtab_40cf[U]) >>13] | |
1147 clip_table16g[(Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13] | | |
1148 clip_table16r[(Y + yuvtab_3343[V]) >>13]; | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1149 } |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1150 } |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
1151 else if(dstFormat==IMGFMT_BGR15) |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1152 { |
2671 | 1153 int i; |
3209 | 1154 for(i=0;i<dstW;i++){ |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1155 // vertical linear interpolation && yuv2rgb in a single step: |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1156 int Y=yuvtab_2568[((buf0[i]*yalpha1+buf1[i]*yalpha)>>19)]; |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1157 int U=((uvbuf0[i]*uvalpha1+uvbuf1[i]*uvalpha)>>19); |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1158 int V=((uvbuf0[i+2048]*uvalpha1+uvbuf1[i+2048]*uvalpha)>>19); |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1159 |
2572
f2353173d52c
c optimizations (array is faster than pointer) (16bpp variants tested and 2% faster)
michael
parents:
2569
diff
changeset
|
1160 ((uint16_t*)dest)[i] = |
2584 | 1161 clip_table15b[(Y + yuvtab_40cf[U]) >>13] | |
1162 clip_table15g[(Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13] | | |
1163 clip_table15r[(Y + yuvtab_3343[V]) >>13]; | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1164 } |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1165 } |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1166 }//FULL_UV_IPOL |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1167 else |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1168 { |
6578 | 1169 #endif // if 0 |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1170 #ifdef HAVE_MMX |
6578 | 1171 switch(c->dstFormat) |
1172 { | |
9414 | 1173 //Note 8280 == DSTW_OFFSET but the preprocessor cant handle that there :( |
6578 | 1174 case IMGFMT_BGR32: |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1175 asm volatile( |
9414 | 1176 "movl %%esp, "ESP_OFFSET"(%5) \n\t" |
1177 "movl %4, %%esp \n\t" | |
1178 YSCALEYUV2RGB(%%eax, %5) | |
1179 WRITEBGR32(%%esp, 8280(%5), %%eax) | |
1180 "movl "ESP_OFFSET"(%5), %%esp \n\t" | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1181 |
9414 | 1182 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "m" (dest), |
1183 "r" (&c->redDither) | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1184 : "%eax" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1185 ); |
6578 | 1186 return; |
1187 case IMGFMT_BGR24: | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1188 asm volatile( |
9414 | 1189 "movl %%esp, "ESP_OFFSET"(%5) \n\t" |
1190 "movl %4, %%esp \n\t" | |
1191 YSCALEYUV2RGB(%%eax, %5) | |
1192 WRITEBGR24(%%esp, 8280(%5), %%eax) | |
1193 "movl "ESP_OFFSET"(%5), %%esp \n\t" | |
1194 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "m" (dest), | |
1195 "r" (&c->redDither) | |
1196 : "%eax" | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1197 ); |
6578 | 1198 return; |
1199 case IMGFMT_BGR15: | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1200 asm volatile( |
9414 | 1201 "movl %%esp, "ESP_OFFSET"(%5) \n\t" |
1202 "movl %4, %%esp \n\t" | |
1203 YSCALEYUV2RGB(%%eax, %5) | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1204 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1205 #ifdef DITHER1XBPP |
4248 | 1206 "paddusb "MANGLE(b5Dither)", %%mm2\n\t" |
1207 "paddusb "MANGLE(g5Dither)", %%mm4\n\t" | |
1208 "paddusb "MANGLE(r5Dither)", %%mm5\n\t" | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1209 #endif |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1210 |
9414 | 1211 WRITEBGR15(%%esp, 8280(%5), %%eax) |
1212 "movl "ESP_OFFSET"(%5), %%esp \n\t" | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1213 |
9414 | 1214 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "m" (dest), |
1215 "r" (&c->redDither) | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1216 : "%eax" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1217 ); |
6578 | 1218 return; |
1219 case IMGFMT_BGR16: | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1220 asm volatile( |
9414 | 1221 "movl %%esp, "ESP_OFFSET"(%5) \n\t" |
1222 "movl %4, %%esp \n\t" | |
1223 YSCALEYUV2RGB(%%eax, %5) | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1224 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1225 #ifdef DITHER1XBPP |
4248 | 1226 "paddusb "MANGLE(b5Dither)", %%mm2\n\t" |
1227 "paddusb "MANGLE(g6Dither)", %%mm4\n\t" | |
1228 "paddusb "MANGLE(r5Dither)", %%mm5\n\t" | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1229 #endif |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1230 |
9414 | 1231 WRITEBGR16(%%esp, 8280(%5), %%eax) |
1232 "movl "ESP_OFFSET"(%5), %%esp \n\t" | |
1233 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "m" (dest), | |
1234 "r" (&c->redDither) | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1235 : "%eax" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1236 ); |
6578 | 1237 return; |
7723 | 1238 case IMGFMT_YUY2: |
1239 asm volatile( | |
9414 | 1240 "movl %%esp, "ESP_OFFSET"(%5) \n\t" |
1241 "movl %4, %%esp \n\t" | |
1242 YSCALEYUV2PACKED(%%eax, %5) | |
1243 WRITEYUY2(%%esp, 8280(%5), %%eax) | |
1244 "movl "ESP_OFFSET"(%5), %%esp \n\t" | |
1245 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "m" (dest), | |
1246 "r" (&c->redDither) | |
7723 | 1247 : "%eax" |
1248 ); | |
1249 return; | |
6578 | 1250 default: break; |
1251 } | |
1252 #endif //HAVE_MMX | |
7723 | 1253 YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB2_C, YSCALE_YUV_2_PACKED2_C) |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1254 } |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1255 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1256 /** |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1257 * YV12 to RGB without scaling or interpolating |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1258 */ |
7723 | 1259 static inline void RENAME(yuv2packed1)(SwsContext *c, uint16_t *buf0, uint16_t *uvbuf0, uint16_t *uvbuf1, |
6578 | 1260 uint8_t *dest, int dstW, int uvalpha, int dstFormat, int flags, int y) |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1261 { |
8254
772d6d27fd66
warning patch by (Dominik Mierzejewski <dominik at rangers dot eu dot org>)
michael
parents:
7723
diff
changeset
|
1262 #ifdef HAVE_MMX |
2671 | 1263 int uvalpha1=uvalpha^4095; |
8254
772d6d27fd66
warning patch by (Dominik Mierzejewski <dominik at rangers dot eu dot org>)
michael
parents:
7723
diff
changeset
|
1264 #endif |
3344 | 1265 const int yalpha1=0; |
6578 | 1266 int i; |
1267 | |
1268 uint16_t *buf1= buf0; //FIXME needed for the rgb1/bgr1 | |
1269 const int yalpha= 4096; //FIXME ... | |
2671 | 1270 |
4467 | 1271 if(flags&SWS_FULL_CHR_H_INT) |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1272 { |
7723 | 1273 RENAME(yuv2packed2)(c, buf0, buf0, uvbuf0, uvbuf1, dest, dstW, 0, uvalpha, y); |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1274 return; |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1275 } |
2576 | 1276 |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1277 #ifdef HAVE_MMX |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1278 if( uvalpha < 2048 ) // note this is not correct (shifts chrominance by 0.5 pixels) but its a bit faster |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1279 { |
6578 | 1280 switch(dstFormat) |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1281 { |
6578 | 1282 case IMGFMT_BGR32: |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1283 asm volatile( |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1284 YSCALEYUV2RGB1 |
9414 | 1285 WRITEBGR32(%4, %5, %%eax) |
3344 | 1286 :: "r" (buf0), "r" (buf0), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" (dstW), |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1287 "m" (yalpha1), "m" (uvalpha1) |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1288 : "%eax" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1289 ); |
6578 | 1290 return; |
1291 case IMGFMT_BGR24: | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1292 asm volatile( |
2728 | 1293 "movl %4, %%ebx \n\t" |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1294 YSCALEYUV2RGB1 |
9414 | 1295 WRITEBGR24(%%ebx, %5, %%eax) |
3344 | 1296 :: "r" (buf0), "r" (buf0), "r" (uvbuf0), "r" (uvbuf1), "m" (dest), "m" (dstW), |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1297 "m" (yalpha1), "m" (uvalpha1) |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1298 : "%eax", "%ebx" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1299 ); |
6578 | 1300 return; |
1301 case IMGFMT_BGR15: | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1302 asm volatile( |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1303 YSCALEYUV2RGB1 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1304 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1305 #ifdef DITHER1XBPP |
4248 | 1306 "paddusb "MANGLE(b5Dither)", %%mm2\n\t" |
1307 "paddusb "MANGLE(g5Dither)", %%mm4\n\t" | |
1308 "paddusb "MANGLE(r5Dither)", %%mm5\n\t" | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1309 #endif |
9414 | 1310 WRITEBGR15(%4, %5, %%eax) |
3344 | 1311 :: "r" (buf0), "r" (buf0), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" (dstW), |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1312 "m" (yalpha1), "m" (uvalpha1) |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1313 : "%eax" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1314 ); |
6578 | 1315 return; |
1316 case IMGFMT_BGR16: | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1317 asm volatile( |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1318 YSCALEYUV2RGB1 |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1319 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1320 #ifdef DITHER1XBPP |
4248 | 1321 "paddusb "MANGLE(b5Dither)", %%mm2\n\t" |
1322 "paddusb "MANGLE(g6Dither)", %%mm4\n\t" | |
1323 "paddusb "MANGLE(r5Dither)", %%mm5\n\t" | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1324 #endif |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1325 |
9414 | 1326 WRITEBGR16(%4, %5, %%eax) |
3344 | 1327 :: "r" (buf0), "r" (buf0), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" (dstW), |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1328 "m" (yalpha1), "m" (uvalpha1) |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1329 : "%eax" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1330 ); |
6578 | 1331 return; |
7723 | 1332 case IMGFMT_YUY2: |
1333 asm volatile( | |
1334 YSCALEYUV2PACKED1 | |
9414 | 1335 WRITEYUY2(%4, %5, %%eax) |
7723 | 1336 :: "r" (buf0), "r" (buf0), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" (dstW), |
1337 "m" (yalpha1), "m" (uvalpha1) | |
1338 : "%eax" | |
1339 ); | |
1340 return; | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1341 } |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1342 } |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1343 else |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1344 { |
6578 | 1345 switch(dstFormat) |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1346 { |
6578 | 1347 case IMGFMT_BGR32: |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1348 asm volatile( |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1349 YSCALEYUV2RGB1b |
9414 | 1350 WRITEBGR32(%4, %5, %%eax) |
3344 | 1351 :: "r" (buf0), "r" (buf0), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" (dstW), |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1352 "m" (yalpha1), "m" (uvalpha1) |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1353 : "%eax" |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1354 ); |
6578 | 1355 return; |
1356 case IMGFMT_BGR24: | |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1357 asm volatile( |
2728 | 1358 "movl %4, %%ebx \n\t" |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1359 YSCALEYUV2RGB1b |
9414 | 1360 WRITEBGR24(%%ebx, %5, %%eax) |
3344 | 1361 :: "r" (buf0), "r" (buf0), "r" (uvbuf0), "r" (uvbuf1), "m" (dest), "m" (dstW), |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1362 "m" (yalpha1), "m" (uvalpha1) |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1363 : "%eax", "%ebx" |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1364 ); |
6578 | 1365 return; |
1366 case IMGFMT_BGR15: | |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1367 asm volatile( |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1368 YSCALEYUV2RGB1b |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1369 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1370 #ifdef DITHER1XBPP |
4248 | 1371 "paddusb "MANGLE(b5Dither)", %%mm2\n\t" |
1372 "paddusb "MANGLE(g5Dither)", %%mm4\n\t" | |
1373 "paddusb "MANGLE(r5Dither)", %%mm5\n\t" | |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1374 #endif |
9414 | 1375 WRITEBGR15(%4, %5, %%eax) |
3344 | 1376 :: "r" (buf0), "r" (buf0), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" (dstW), |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1377 "m" (yalpha1), "m" (uvalpha1) |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1378 : "%eax" |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1379 ); |
6578 | 1380 return; |
1381 case IMGFMT_BGR16: | |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1382 asm volatile( |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1383 YSCALEYUV2RGB1b |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1384 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */ |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1385 #ifdef DITHER1XBPP |
4248 | 1386 "paddusb "MANGLE(b5Dither)", %%mm2\n\t" |
1387 "paddusb "MANGLE(g6Dither)", %%mm4\n\t" | |
1388 "paddusb "MANGLE(r5Dither)", %%mm5\n\t" | |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1389 #endif |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1390 |
9414 | 1391 WRITEBGR16(%4, %5, %%eax) |
3344 | 1392 :: "r" (buf0), "r" (buf0), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" (dstW), |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1393 "m" (yalpha1), "m" (uvalpha1) |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1394 : "%eax" |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1395 ); |
6578 | 1396 return; |
7723 | 1397 case IMGFMT_YUY2: |
1398 asm volatile( | |
1399 YSCALEYUV2PACKED1b | |
9414 | 1400 WRITEYUY2(%4, %5, %%eax) |
7723 | 1401 :: "r" (buf0), "r" (buf0), "r" (uvbuf0), "r" (uvbuf1), "r" (dest), "m" (dstW), |
1402 "m" (yalpha1), "m" (uvalpha1) | |
1403 : "%eax" | |
1404 ); | |
1405 return; | |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1406 } |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1407 } |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1408 #endif |
6578 | 1409 if( uvalpha < 2048 ) |
1410 { | |
7723 | 1411 YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB1_C, YSCALE_YUV_2_PACKED1_C) |
6578 | 1412 }else{ |
7723 | 1413 YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB1B_C, YSCALE_YUV_2_PACKED1B_C) |
6578 | 1414 } |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1415 } |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1416 |
4481 | 1417 //FIXME yuy2* can read upto 7 samples to much |
1418 | |
4467 | 1419 static inline void RENAME(yuy2ToY)(uint8_t *dst, uint8_t *src, int width) |
1420 { | |
4481 | 1421 #ifdef HAVE_MMX |
1422 asm volatile( | |
1423 "movq "MANGLE(bm01010101)", %%mm2\n\t" | |
1424 "movl %0, %%eax \n\t" | |
1425 "1: \n\t" | |
1426 "movq (%1, %%eax,2), %%mm0 \n\t" | |
1427 "movq 8(%1, %%eax,2), %%mm1 \n\t" | |
1428 "pand %%mm2, %%mm0 \n\t" | |
1429 "pand %%mm2, %%mm1 \n\t" | |
1430 "packuswb %%mm1, %%mm0 \n\t" | |
1431 "movq %%mm0, (%2, %%eax) \n\t" | |
1432 "addl $8, %%eax \n\t" | |
1433 " js 1b \n\t" | |
1434 : : "g" (-width), "r" (src+width*2), "r" (dst+width) | |
1435 : "%eax" | |
1436 ); | |
4467 | 1437 #else |
1438 int i; | |
1439 for(i=0; i<width; i++) | |
1440 dst[i]= src[2*i]; | |
1441 #endif | |
1442 } | |
1443 | |
1444 static inline void RENAME(yuy2ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width) | |
1445 { | |
4481 | 1446 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) |
1447 asm volatile( | |
1448 "movq "MANGLE(bm01010101)", %%mm4\n\t" | |
1449 "movl %0, %%eax \n\t" | |
1450 "1: \n\t" | |
1451 "movq (%1, %%eax,4), %%mm0 \n\t" | |
1452 "movq 8(%1, %%eax,4), %%mm1 \n\t" | |
1453 "movq (%2, %%eax,4), %%mm2 \n\t" | |
1454 "movq 8(%2, %%eax,4), %%mm3 \n\t" | |
1455 PAVGB(%%mm2, %%mm0) | |
1456 PAVGB(%%mm3, %%mm1) | |
1457 "psrlw $8, %%mm0 \n\t" | |
1458 "psrlw $8, %%mm1 \n\t" | |
1459 "packuswb %%mm1, %%mm0 \n\t" | |
1460 "movq %%mm0, %%mm1 \n\t" | |
1461 "psrlw $8, %%mm0 \n\t" | |
1462 "pand %%mm4, %%mm1 \n\t" | |
1463 "packuswb %%mm0, %%mm0 \n\t" | |
1464 "packuswb %%mm1, %%mm1 \n\t" | |
1465 "movd %%mm0, (%4, %%eax) \n\t" | |
1466 "movd %%mm1, (%3, %%eax) \n\t" | |
1467 "addl $4, %%eax \n\t" | |
1468 " js 1b \n\t" | |
1469 : : "g" (-width), "r" (src1+width*4), "r" (src2+width*4), "r" (dstU+width), "r" (dstV+width) | |
1470 : "%eax" | |
1471 ); | |
4467 | 1472 #else |
1473 int i; | |
1474 for(i=0; i<width; i++) | |
1475 { | |
1476 dstU[i]= (src1[4*i + 1] + src2[4*i + 1])>>1; | |
1477 dstV[i]= (src1[4*i + 3] + src2[4*i + 3])>>1; | |
1478 } | |
1479 #endif | |
1480 } | |
1481 | |
9071 | 1482 //this is allmost identical to the previous, end exists only cuz yuy2ToY/UV)(dst, src+1, ...) would have 100% unaligned accesses |
1483 static inline void RENAME(uyvyToY)(uint8_t *dst, uint8_t *src, int width) | |
1484 { | |
1485 #ifdef HAVE_MMX | |
1486 asm volatile( | |
1487 "movl %0, %%eax \n\t" | |
1488 "1: \n\t" | |
1489 "movq (%1, %%eax,2), %%mm0 \n\t" | |
1490 "movq 8(%1, %%eax,2), %%mm1 \n\t" | |
1491 "psrlw $8, %%mm0 \n\t" | |
1492 "psrlw $8, %%mm1 \n\t" | |
1493 "packuswb %%mm1, %%mm0 \n\t" | |
1494 "movq %%mm0, (%2, %%eax) \n\t" | |
1495 "addl $8, %%eax \n\t" | |
1496 " js 1b \n\t" | |
1497 : : "g" (-width), "r" (src+width*2), "r" (dst+width) | |
1498 : "%eax" | |
1499 ); | |
1500 #else | |
1501 int i; | |
1502 for(i=0; i<width; i++) | |
1503 dst[i]= src[2*i+1]; | |
1504 #endif | |
1505 } | |
1506 | |
1507 static inline void RENAME(uyvyToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width) | |
1508 { | |
1509 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) | |
1510 asm volatile( | |
1511 "movq "MANGLE(bm01010101)", %%mm4\n\t" | |
1512 "movl %0, %%eax \n\t" | |
1513 "1: \n\t" | |
1514 "movq (%1, %%eax,4), %%mm0 \n\t" | |
1515 "movq 8(%1, %%eax,4), %%mm1 \n\t" | |
1516 "movq (%2, %%eax,4), %%mm2 \n\t" | |
1517 "movq 8(%2, %%eax,4), %%mm3 \n\t" | |
1518 PAVGB(%%mm2, %%mm0) | |
1519 PAVGB(%%mm3, %%mm1) | |
1520 "pand %%mm4, %%mm0 \n\t" | |
1521 "pand %%mm4, %%mm1 \n\t" | |
1522 "packuswb %%mm1, %%mm0 \n\t" | |
1523 "movq %%mm0, %%mm1 \n\t" | |
1524 "psrlw $8, %%mm0 \n\t" | |
1525 "pand %%mm4, %%mm1 \n\t" | |
1526 "packuswb %%mm0, %%mm0 \n\t" | |
1527 "packuswb %%mm1, %%mm1 \n\t" | |
1528 "movd %%mm0, (%4, %%eax) \n\t" | |
1529 "movd %%mm1, (%3, %%eax) \n\t" | |
1530 "addl $4, %%eax \n\t" | |
1531 " js 1b \n\t" | |
1532 : : "g" (-width), "r" (src1+width*4), "r" (src2+width*4), "r" (dstU+width), "r" (dstV+width) | |
1533 : "%eax" | |
1534 ); | |
1535 #else | |
1536 int i; | |
1537 for(i=0; i<width; i++) | |
1538 { | |
1539 dstU[i]= (src1[4*i + 0] + src2[4*i + 0])>>1; | |
1540 dstV[i]= (src1[4*i + 2] + src2[4*i + 2])>>1; | |
1541 } | |
1542 #endif | |
1543 } | |
1544 | |
4467 | 1545 static inline void RENAME(bgr32ToY)(uint8_t *dst, uint8_t *src, int width) |
1546 { | |
1547 #ifdef HAVE_MMXFIXME | |
1548 #else | |
1549 int i; | |
1550 for(i=0; i<width; i++) | |
1551 { | |
1552 int b= src[i*4+0]; | |
1553 int g= src[i*4+1]; | |
1554 int r= src[i*4+2]; | |
1555 | |
1556 dst[i]= ((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16; | |
1557 } | |
1558 #endif | |
1559 } | |
1560 | |
1561 static inline void RENAME(bgr32ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width) | |
1562 { | |
1563 #ifdef HAVE_MMXFIXME | |
1564 #else | |
1565 int i; | |
1566 for(i=0; i<width; i++) | |
1567 { | |
1568 int b= src1[8*i + 0] + src1[8*i + 4] + src2[8*i + 0] + src2[8*i + 4]; | |
1569 int g= src1[8*i + 1] + src1[8*i + 5] + src2[8*i + 1] + src2[8*i + 5]; | |
1570 int r= src1[8*i + 2] + src1[8*i + 6] + src2[8*i + 2] + src2[8*i + 6]; | |
1571 | |
1572 dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+2)) + 128; | |
1573 dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+2)) + 128; | |
1574 } | |
1575 #endif | |
1576 } | |
1577 | |
1578 static inline void RENAME(bgr24ToY)(uint8_t *dst, uint8_t *src, int width) | |
1579 { | |
4612 | 1580 #ifdef HAVE_MMX |
1581 asm volatile( | |
1582 "movl %2, %%eax \n\t" | |
4923 | 1583 "movq "MANGLE(bgr2YCoeff)", %%mm6 \n\t" |
1584 "movq "MANGLE(w1111)", %%mm5 \n\t" | |
4612 | 1585 "pxor %%mm7, %%mm7 \n\t" |
1586 "leal (%%eax, %%eax, 2), %%ebx \n\t" | |
1587 ".balign 16 \n\t" | |
1588 "1: \n\t" | |
1589 PREFETCH" 64(%0, %%ebx) \n\t" | |
1590 "movd (%0, %%ebx), %%mm0 \n\t" | |
1591 "movd 3(%0, %%ebx), %%mm1 \n\t" | |
1592 "punpcklbw %%mm7, %%mm0 \n\t" | |
1593 "punpcklbw %%mm7, %%mm1 \n\t" | |
1594 "movd 6(%0, %%ebx), %%mm2 \n\t" | |
1595 "movd 9(%0, %%ebx), %%mm3 \n\t" | |
1596 "punpcklbw %%mm7, %%mm2 \n\t" | |
1597 "punpcklbw %%mm7, %%mm3 \n\t" | |
1598 "pmaddwd %%mm6, %%mm0 \n\t" | |
1599 "pmaddwd %%mm6, %%mm1 \n\t" | |
1600 "pmaddwd %%mm6, %%mm2 \n\t" | |
1601 "pmaddwd %%mm6, %%mm3 \n\t" | |
1602 #ifndef FAST_BGR2YV12 | |
1603 "psrad $8, %%mm0 \n\t" | |
1604 "psrad $8, %%mm1 \n\t" | |
1605 "psrad $8, %%mm2 \n\t" | |
1606 "psrad $8, %%mm3 \n\t" | |
1607 #endif | |
1608 "packssdw %%mm1, %%mm0 \n\t" | |
1609 "packssdw %%mm3, %%mm2 \n\t" | |
1610 "pmaddwd %%mm5, %%mm0 \n\t" | |
1611 "pmaddwd %%mm5, %%mm2 \n\t" | |
1612 "packssdw %%mm2, %%mm0 \n\t" | |
1613 "psraw $7, %%mm0 \n\t" | |
1614 | |
1615 "movd 12(%0, %%ebx), %%mm4 \n\t" | |
1616 "movd 15(%0, %%ebx), %%mm1 \n\t" | |
1617 "punpcklbw %%mm7, %%mm4 \n\t" | |
1618 "punpcklbw %%mm7, %%mm1 \n\t" | |
1619 "movd 18(%0, %%ebx), %%mm2 \n\t" | |
1620 "movd 21(%0, %%ebx), %%mm3 \n\t" | |
1621 "punpcklbw %%mm7, %%mm2 \n\t" | |
1622 "punpcklbw %%mm7, %%mm3 \n\t" | |
1623 "pmaddwd %%mm6, %%mm4 \n\t" | |
1624 "pmaddwd %%mm6, %%mm1 \n\t" | |
1625 "pmaddwd %%mm6, %%mm2 \n\t" | |
1626 "pmaddwd %%mm6, %%mm3 \n\t" | |
1627 #ifndef FAST_BGR2YV12 | |
1628 "psrad $8, %%mm4 \n\t" | |
1629 "psrad $8, %%mm1 \n\t" | |
1630 "psrad $8, %%mm2 \n\t" | |
1631 "psrad $8, %%mm3 \n\t" | |
1632 #endif | |
1633 "packssdw %%mm1, %%mm4 \n\t" | |
1634 "packssdw %%mm3, %%mm2 \n\t" | |
1635 "pmaddwd %%mm5, %%mm4 \n\t" | |
1636 "pmaddwd %%mm5, %%mm2 \n\t" | |
1637 "addl $24, %%ebx \n\t" | |
1638 "packssdw %%mm2, %%mm4 \n\t" | |
1639 "psraw $7, %%mm4 \n\t" | |
1640 | |
1641 "packuswb %%mm4, %%mm0 \n\t" | |
4923 | 1642 "paddusb "MANGLE(bgr2YOffset)", %%mm0 \n\t" |
4612 | 1643 |
4619 | 1644 "movq %%mm0, (%1, %%eax) \n\t" |
4612 | 1645 "addl $8, %%eax \n\t" |
1646 " js 1b \n\t" | |
1647 : : "r" (src+width*3), "r" (dst+width), "g" (-width) | |
1648 : "%eax", "%ebx" | |
1649 ); | |
4467 | 1650 #else |
1651 int i; | |
1652 for(i=0; i<width; i++) | |
1653 { | |
1654 int b= src[i*3+0]; | |
1655 int g= src[i*3+1]; | |
1656 int r= src[i*3+2]; | |
1657 | |
1658 dst[i]= ((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16; | |
1659 } | |
1660 #endif | |
1661 } | |
1662 | |
1663 static inline void RENAME(bgr24ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width) | |
1664 { | |
4619 | 1665 #ifdef HAVE_MMX |
1666 asm volatile( | |
1667 "movl %4, %%eax \n\t" | |
4923 | 1668 "movq "MANGLE(w1111)", %%mm5 \n\t" |
1669 "movq "MANGLE(bgr2UCoeff)", %%mm6 \n\t" | |
4619 | 1670 "pxor %%mm7, %%mm7 \n\t" |
1671 "leal (%%eax, %%eax, 2), %%ebx \n\t" | |
1672 "addl %%ebx, %%ebx \n\t" | |
1673 ".balign 16 \n\t" | |
1674 "1: \n\t" | |
1675 PREFETCH" 64(%0, %%ebx) \n\t" | |
1676 PREFETCH" 64(%1, %%ebx) \n\t" | |
1677 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) | |
1678 "movq (%0, %%ebx), %%mm0 \n\t" | |
1679 "movq (%1, %%ebx), %%mm1 \n\t" | |
1680 "movq 6(%0, %%ebx), %%mm2 \n\t" | |
1681 "movq 6(%1, %%ebx), %%mm3 \n\t" | |
1682 PAVGB(%%mm1, %%mm0) | |
1683 PAVGB(%%mm3, %%mm2) | |
1684 "movq %%mm0, %%mm1 \n\t" | |
1685 "movq %%mm2, %%mm3 \n\t" | |
1686 "psrlq $24, %%mm0 \n\t" | |
1687 "psrlq $24, %%mm2 \n\t" | |
1688 PAVGB(%%mm1, %%mm0) | |
1689 PAVGB(%%mm3, %%mm2) | |
1690 "punpcklbw %%mm7, %%mm0 \n\t" | |
1691 "punpcklbw %%mm7, %%mm2 \n\t" | |
1692 #else | |
1693 "movd (%0, %%ebx), %%mm0 \n\t" | |
1694 "movd (%1, %%ebx), %%mm1 \n\t" | |
1695 "movd 3(%0, %%ebx), %%mm2 \n\t" | |
1696 "movd 3(%1, %%ebx), %%mm3 \n\t" | |
1697 "punpcklbw %%mm7, %%mm0 \n\t" | |
1698 "punpcklbw %%mm7, %%mm1 \n\t" | |
1699 "punpcklbw %%mm7, %%mm2 \n\t" | |
1700 "punpcklbw %%mm7, %%mm3 \n\t" | |
1701 "paddw %%mm1, %%mm0 \n\t" | |
1702 "paddw %%mm3, %%mm2 \n\t" | |
1703 "paddw %%mm2, %%mm0 \n\t" | |
1704 "movd 6(%0, %%ebx), %%mm4 \n\t" | |
1705 "movd 6(%1, %%ebx), %%mm1 \n\t" | |
1706 "movd 9(%0, %%ebx), %%mm2 \n\t" | |
1707 "movd 9(%1, %%ebx), %%mm3 \n\t" | |
1708 "punpcklbw %%mm7, %%mm4 \n\t" | |
1709 "punpcklbw %%mm7, %%mm1 \n\t" | |
1710 "punpcklbw %%mm7, %%mm2 \n\t" | |
1711 "punpcklbw %%mm7, %%mm3 \n\t" | |
1712 "paddw %%mm1, %%mm4 \n\t" | |
1713 "paddw %%mm3, %%mm2 \n\t" | |
1714 "paddw %%mm4, %%mm2 \n\t" | |
1715 "psrlw $2, %%mm0 \n\t" | |
1716 "psrlw $2, %%mm2 \n\t" | |
1717 #endif | |
4923 | 1718 "movq "MANGLE(bgr2VCoeff)", %%mm1 \n\t" |
1719 "movq "MANGLE(bgr2VCoeff)", %%mm3 \n\t" | |
4619 | 1720 |
1721 "pmaddwd %%mm0, %%mm1 \n\t" | |
1722 "pmaddwd %%mm2, %%mm3 \n\t" | |
1723 "pmaddwd %%mm6, %%mm0 \n\t" | |
1724 "pmaddwd %%mm6, %%mm2 \n\t" | |
1725 #ifndef FAST_BGR2YV12 | |
1726 "psrad $8, %%mm0 \n\t" | |
1727 "psrad $8, %%mm1 \n\t" | |
1728 "psrad $8, %%mm2 \n\t" | |
1729 "psrad $8, %%mm3 \n\t" | |
1730 #endif | |
1731 "packssdw %%mm2, %%mm0 \n\t" | |
1732 "packssdw %%mm3, %%mm1 \n\t" | |
1733 "pmaddwd %%mm5, %%mm0 \n\t" | |
1734 "pmaddwd %%mm5, %%mm1 \n\t" | |
1735 "packssdw %%mm1, %%mm0 \n\t" // V1 V0 U1 U0 | |
1736 "psraw $7, %%mm0 \n\t" | |
1737 | |
1738 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) | |
1739 "movq 12(%0, %%ebx), %%mm4 \n\t" | |
1740 "movq 12(%1, %%ebx), %%mm1 \n\t" | |
1741 "movq 18(%0, %%ebx), %%mm2 \n\t" | |
1742 "movq 18(%1, %%ebx), %%mm3 \n\t" | |
1743 PAVGB(%%mm1, %%mm4) | |
1744 PAVGB(%%mm3, %%mm2) | |
1745 "movq %%mm4, %%mm1 \n\t" | |
1746 "movq %%mm2, %%mm3 \n\t" | |
1747 "psrlq $24, %%mm4 \n\t" | |
1748 "psrlq $24, %%mm2 \n\t" | |
1749 PAVGB(%%mm1, %%mm4) | |
1750 PAVGB(%%mm3, %%mm2) | |
1751 "punpcklbw %%mm7, %%mm4 \n\t" | |
1752 "punpcklbw %%mm7, %%mm2 \n\t" | |
1753 #else | |
1754 "movd 12(%0, %%ebx), %%mm4 \n\t" | |
1755 "movd 12(%1, %%ebx), %%mm1 \n\t" | |
1756 "movd 15(%0, %%ebx), %%mm2 \n\t" | |
1757 "movd 15(%1, %%ebx), %%mm3 \n\t" | |
1758 "punpcklbw %%mm7, %%mm4 \n\t" | |
1759 "punpcklbw %%mm7, %%mm1 \n\t" | |
1760 "punpcklbw %%mm7, %%mm2 \n\t" | |
1761 "punpcklbw %%mm7, %%mm3 \n\t" | |
1762 "paddw %%mm1, %%mm4 \n\t" | |
1763 "paddw %%mm3, %%mm2 \n\t" | |
1764 "paddw %%mm2, %%mm4 \n\t" | |
1765 "movd 18(%0, %%ebx), %%mm5 \n\t" | |
1766 "movd 18(%1, %%ebx), %%mm1 \n\t" | |
1767 "movd 21(%0, %%ebx), %%mm2 \n\t" | |
1768 "movd 21(%1, %%ebx), %%mm3 \n\t" | |
1769 "punpcklbw %%mm7, %%mm5 \n\t" | |
1770 "punpcklbw %%mm7, %%mm1 \n\t" | |
1771 "punpcklbw %%mm7, %%mm2 \n\t" | |
1772 "punpcklbw %%mm7, %%mm3 \n\t" | |
1773 "paddw %%mm1, %%mm5 \n\t" | |
1774 "paddw %%mm3, %%mm2 \n\t" | |
1775 "paddw %%mm5, %%mm2 \n\t" | |
4923 | 1776 "movq "MANGLE(w1111)", %%mm5 \n\t" |
4619 | 1777 "psrlw $2, %%mm4 \n\t" |
1778 "psrlw $2, %%mm2 \n\t" | |
1779 #endif | |
4923 | 1780 "movq "MANGLE(bgr2VCoeff)", %%mm1 \n\t" |
1781 "movq "MANGLE(bgr2VCoeff)", %%mm3 \n\t" | |
4619 | 1782 |
1783 "pmaddwd %%mm4, %%mm1 \n\t" | |
1784 "pmaddwd %%mm2, %%mm3 \n\t" | |
1785 "pmaddwd %%mm6, %%mm4 \n\t" | |
1786 "pmaddwd %%mm6, %%mm2 \n\t" | |
1787 #ifndef FAST_BGR2YV12 | |
1788 "psrad $8, %%mm4 \n\t" | |
1789 "psrad $8, %%mm1 \n\t" | |
1790 "psrad $8, %%mm2 \n\t" | |
1791 "psrad $8, %%mm3 \n\t" | |
1792 #endif | |
1793 "packssdw %%mm2, %%mm4 \n\t" | |
1794 "packssdw %%mm3, %%mm1 \n\t" | |
1795 "pmaddwd %%mm5, %%mm4 \n\t" | |
1796 "pmaddwd %%mm5, %%mm1 \n\t" | |
1797 "addl $24, %%ebx \n\t" | |
1798 "packssdw %%mm1, %%mm4 \n\t" // V3 V2 U3 U2 | |
1799 "psraw $7, %%mm4 \n\t" | |
1800 | |
1801 "movq %%mm0, %%mm1 \n\t" | |
1802 "punpckldq %%mm4, %%mm0 \n\t" | |
1803 "punpckhdq %%mm4, %%mm1 \n\t" | |
1804 "packsswb %%mm1, %%mm0 \n\t" | |
4923 | 1805 "paddb "MANGLE(bgr2UVOffset)", %%mm0 \n\t" |
4619 | 1806 |
1807 "movd %%mm0, (%2, %%eax) \n\t" | |
1808 "punpckhdq %%mm0, %%mm0 \n\t" | |
1809 "movd %%mm0, (%3, %%eax) \n\t" | |
1810 "addl $4, %%eax \n\t" | |
1811 " js 1b \n\t" | |
1812 : : "r" (src1+width*6), "r" (src2+width*6), "r" (dstU+width), "r" (dstV+width), "g" (-width) | |
1813 : "%eax", "%ebx" | |
1814 ); | |
4467 | 1815 #else |
1816 int i; | |
1817 for(i=0; i<width; i++) | |
1818 { | |
1819 int b= src1[6*i + 0] + src1[6*i + 3] + src2[6*i + 0] + src2[6*i + 3]; | |
1820 int g= src1[6*i + 1] + src1[6*i + 4] + src2[6*i + 1] + src2[6*i + 4]; | |
1821 int r= src1[6*i + 2] + src1[6*i + 5] + src2[6*i + 2] + src2[6*i + 5]; | |
1822 | |
1823 dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+2)) + 128; | |
1824 dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+2)) + 128; | |
1825 } | |
1826 #endif | |
1827 } | |
1828 | |
4578 | 1829 static inline void RENAME(bgr16ToY)(uint8_t *dst, uint8_t *src, int width) |
1830 { | |
1831 int i; | |
1832 for(i=0; i<width; i++) | |
1833 { | |
1834 int d= src[i*2] + (src[i*2+1]<<8); | |
1835 int b= d&0x1F; | |
1836 int g= (d>>5)&0x3F; | |
1837 int r= (d>>11)&0x1F; | |
1838 | |
1839 dst[i]= ((2*RY*r + GY*g + 2*BY*b)>>(RGB2YUV_SHIFT-2)) + 16; | |
1840 } | |
1841 } | |
1842 | |
1843 static inline void RENAME(bgr16ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width) | |
1844 { | |
1845 int i; | |
1846 for(i=0; i<width; i++) | |
1847 { | |
4579 | 1848 #if 1 |
1849 int d0= le2me_32( ((uint32_t*)src1)[i] ); | |
1850 int d1= le2me_32( ((uint32_t*)src2)[i] ); | |
1851 | |
1852 int dl= (d0&0x07E0F81F) + (d1&0x07E0F81F); | |
1853 int dh= ((d0>>5)&0x07C0F83F) + ((d1>>5)&0x07C0F83F); | |
1854 | |
1855 int dh2= (dh>>11) + (dh<<21); | |
1856 int d= dh2 + dl; | |
1857 | |
1858 int b= d&0x7F; | |
1859 int r= (d>>11)&0x7F; | |
1860 int g= d>>21; | |
1861 #else | |
4578 | 1862 int d0= src1[i*4] + (src1[i*4+1]<<8); |
1863 int b0= d0&0x1F; | |
1864 int g0= (d0>>5)&0x3F; | |
1865 int r0= (d0>>11)&0x1F; | |
1866 | |
1867 int d1= src1[i*4+2] + (src1[i*4+3]<<8); | |
1868 int b1= d1&0x1F; | |
1869 int g1= (d1>>5)&0x3F; | |
1870 int r1= (d1>>11)&0x1F; | |
1871 | |
1872 int d2= src2[i*4] + (src2[i*4+1]<<8); | |
1873 int b2= d2&0x1F; | |
1874 int g2= (d2>>5)&0x3F; | |
1875 int r2= (d2>>11)&0x1F; | |
1876 | |
1877 int d3= src2[i*4+2] + (src2[i*4+3]<<8); | |
1878 int b3= d3&0x1F; | |
1879 int g3= (d3>>5)&0x3F; | |
1880 int r3= (d3>>11)&0x1F; | |
1881 | |
1882 int b= b0 + b1 + b2 + b3; | |
1883 int g= g0 + g1 + g2 + g3; | |
1884 int r= r0 + r1 + r2 + r3; | |
4579 | 1885 #endif |
4578 | 1886 dstU[i]= ((2*RU*r + GU*g + 2*BU*b)>>(RGB2YUV_SHIFT+2-2)) + 128; |
1887 dstV[i]= ((2*RV*r + GV*g + 2*BV*b)>>(RGB2YUV_SHIFT+2-2)) + 128; | |
1888 } | |
1889 } | |
1890 | |
4580 | 1891 static inline void RENAME(bgr15ToY)(uint8_t *dst, uint8_t *src, int width) |
1892 { | |
1893 int i; | |
1894 for(i=0; i<width; i++) | |
1895 { | |
1896 int d= src[i*2] + (src[i*2+1]<<8); | |
1897 int b= d&0x1F; | |
1898 int g= (d>>5)&0x1F; | |
1899 int r= (d>>10)&0x1F; | |
1900 | |
1901 dst[i]= ((RY*r + GY*g + BY*b)>>(RGB2YUV_SHIFT-3)) + 16; | |
1902 } | |
1903 } | |
1904 | |
1905 static inline void RENAME(bgr15ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width) | |
1906 { | |
1907 int i; | |
1908 for(i=0; i<width; i++) | |
1909 { | |
1910 #if 1 | |
1911 int d0= le2me_32( ((uint32_t*)src1)[i] ); | |
1912 int d1= le2me_32( ((uint32_t*)src2)[i] ); | |
1913 | |
1914 int dl= (d0&0x03E07C1F) + (d1&0x03E07C1F); | |
1915 int dh= ((d0>>5)&0x03E0F81F) + ((d1>>5)&0x03E0F81F); | |
1916 | |
1917 int dh2= (dh>>11) + (dh<<21); | |
1918 int d= dh2 + dl; | |
1919 | |
1920 int b= d&0x7F; | |
1921 int r= (d>>10)&0x7F; | |
1922 int g= d>>21; | |
1923 #else | |
1924 int d0= src1[i*4] + (src1[i*4+1]<<8); | |
1925 int b0= d0&0x1F; | |
1926 int g0= (d0>>5)&0x1F; | |
1927 int r0= (d0>>10)&0x1F; | |
1928 | |
1929 int d1= src1[i*4+2] + (src1[i*4+3]<<8); | |
1930 int b1= d1&0x1F; | |
1931 int g1= (d1>>5)&0x1F; | |
1932 int r1= (d1>>10)&0x1F; | |
1933 | |
1934 int d2= src2[i*4] + (src2[i*4+1]<<8); | |
1935 int b2= d2&0x1F; | |
1936 int g2= (d2>>5)&0x1F; | |
1937 int r2= (d2>>10)&0x1F; | |
1938 | |
1939 int d3= src2[i*4+2] + (src2[i*4+3]<<8); | |
1940 int b3= d3&0x1F; | |
1941 int g3= (d3>>5)&0x1F; | |
1942 int r3= (d3>>10)&0x1F; | |
1943 | |
1944 int b= b0 + b1 + b2 + b3; | |
1945 int g= g0 + g1 + g2 + g3; | |
1946 int r= r0 + r1 + r2 + r3; | |
1947 #endif | |
1948 dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+2-3)) + 128; | |
1949 dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+2-3)) + 128; | |
1950 } | |
1951 } | |
1952 | |
1953 | |
4558 | 1954 static inline void RENAME(rgb32ToY)(uint8_t *dst, uint8_t *src, int width) |
1955 { | |
1956 int i; | |
1957 for(i=0; i<width; i++) | |
1958 { | |
1959 int r= src[i*4+0]; | |
1960 int g= src[i*4+1]; | |
1961 int b= src[i*4+2]; | |
1962 | |
1963 dst[i]= ((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16; | |
1964 } | |
1965 } | |
1966 | |
1967 static inline void RENAME(rgb32ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width) | |
1968 { | |
1969 int i; | |
1970 for(i=0; i<width; i++) | |
1971 { | |
1972 int r= src1[8*i + 0] + src1[8*i + 4] + src2[8*i + 0] + src2[8*i + 4]; | |
1973 int g= src1[8*i + 1] + src1[8*i + 5] + src2[8*i + 1] + src2[8*i + 5]; | |
1974 int b= src1[8*i + 2] + src1[8*i + 6] + src2[8*i + 2] + src2[8*i + 6]; | |
1975 | |
1976 dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+2)) + 128; | |
1977 dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+2)) + 128; | |
1978 } | |
1979 } | |
1980 | |
1981 static inline void RENAME(rgb24ToY)(uint8_t *dst, uint8_t *src, int width) | |
1982 { | |
1983 int i; | |
1984 for(i=0; i<width; i++) | |
1985 { | |
1986 int r= src[i*3+0]; | |
1987 int g= src[i*3+1]; | |
1988 int b= src[i*3+2]; | |
1989 | |
1990 dst[i]= ((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16; | |
1991 } | |
1992 } | |
1993 | |
1994 static inline void RENAME(rgb24ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width) | |
1995 { | |
1996 int i; | |
1997 for(i=0; i<width; i++) | |
1998 { | |
1999 int r= src1[6*i + 0] + src1[6*i + 3] + src2[6*i + 0] + src2[6*i + 3]; | |
2000 int g= src1[6*i + 1] + src1[6*i + 4] + src2[6*i + 1] + src2[6*i + 4]; | |
2001 int b= src1[6*i + 2] + src1[6*i + 5] + src2[6*i + 2] + src2[6*i + 5]; | |
2002 | |
2003 dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+2)) + 128; | |
2004 dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+2)) + 128; | |
2005 } | |
2006 } | |
2007 | |
4467 | 2008 |
3272 | 2009 // Bilinear / Bicubic scaling |
2010 static inline void RENAME(hScale)(int16_t *dst, int dstW, uint8_t *src, int srcW, int xInc, | |
2011 int16_t *filter, int16_t *filterPos, int filterSize) | |
2012 { | |
2013 #ifdef HAVE_MMX | |
2014 if(filterSize==4) // allways true for upscaling, sometimes for down too | |
2015 { | |
2016 int counter= -2*dstW; | |
2017 filter-= counter*2; | |
2018 filterPos-= counter/2; | |
2019 dst-= counter/2; | |
2020 asm volatile( | |
2021 "pxor %%mm7, %%mm7 \n\t" | |
4248 | 2022 "movq "MANGLE(w02)", %%mm6 \n\t" |
3272 | 2023 "pushl %%ebp \n\t" // we use 7 regs here ... |
2024 "movl %%eax, %%ebp \n\t" | |
2025 ".balign 16 \n\t" | |
2026 "1: \n\t" | |
2027 "movzwl (%2, %%ebp), %%eax \n\t" | |
2028 "movzwl 2(%2, %%ebp), %%ebx \n\t" | |
2029 "movq (%1, %%ebp, 4), %%mm1 \n\t" | |
2030 "movq 8(%1, %%ebp, 4), %%mm3 \n\t" | |
2031 "movd (%3, %%eax), %%mm0 \n\t" | |
2032 "movd (%3, %%ebx), %%mm2 \n\t" | |
2033 "punpcklbw %%mm7, %%mm0 \n\t" | |
2034 "punpcklbw %%mm7, %%mm2 \n\t" | |
2035 "pmaddwd %%mm1, %%mm0 \n\t" | |
2036 "pmaddwd %%mm2, %%mm3 \n\t" | |
2037 "psrad $8, %%mm0 \n\t" | |
2038 "psrad $8, %%mm3 \n\t" | |
2039 "packssdw %%mm3, %%mm0 \n\t" | |
2040 "pmaddwd %%mm6, %%mm0 \n\t" | |
2041 "packssdw %%mm0, %%mm0 \n\t" | |
2042 "movd %%mm0, (%4, %%ebp) \n\t" | |
2043 "addl $4, %%ebp \n\t" | |
2044 " jnc 1b \n\t" | |
3352 | 2045 |
3272 | 2046 "popl %%ebp \n\t" |
2047 : "+a" (counter) | |
2048 : "c" (filter), "d" (filterPos), "S" (src), "D" (dst) | |
2049 : "%ebx" | |
2050 ); | |
2051 } | |
2052 else if(filterSize==8) | |
2053 { | |
2054 int counter= -2*dstW; | |
2055 filter-= counter*4; | |
2056 filterPos-= counter/2; | |
2057 dst-= counter/2; | |
2058 asm volatile( | |
2059 "pxor %%mm7, %%mm7 \n\t" | |
4248 | 2060 "movq "MANGLE(w02)", %%mm6 \n\t" |
3272 | 2061 "pushl %%ebp \n\t" // we use 7 regs here ... |
2062 "movl %%eax, %%ebp \n\t" | |
2063 ".balign 16 \n\t" | |
2064 "1: \n\t" | |
2065 "movzwl (%2, %%ebp), %%eax \n\t" | |
2066 "movzwl 2(%2, %%ebp), %%ebx \n\t" | |
2067 "movq (%1, %%ebp, 8), %%mm1 \n\t" | |
2068 "movq 16(%1, %%ebp, 8), %%mm3 \n\t" | |
2069 "movd (%3, %%eax), %%mm0 \n\t" | |
2070 "movd (%3, %%ebx), %%mm2 \n\t" | |
2071 "punpcklbw %%mm7, %%mm0 \n\t" | |
2072 "punpcklbw %%mm7, %%mm2 \n\t" | |
2073 "pmaddwd %%mm1, %%mm0 \n\t" | |
2074 "pmaddwd %%mm2, %%mm3 \n\t" | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
2075 |
3272 | 2076 "movq 8(%1, %%ebp, 8), %%mm1 \n\t" |
2077 "movq 24(%1, %%ebp, 8), %%mm5 \n\t" | |
2078 "movd 4(%3, %%eax), %%mm4 \n\t" | |
2079 "movd 4(%3, %%ebx), %%mm2 \n\t" | |
2080 "punpcklbw %%mm7, %%mm4 \n\t" | |
2081 "punpcklbw %%mm7, %%mm2 \n\t" | |
2082 "pmaddwd %%mm1, %%mm4 \n\t" | |
2083 "pmaddwd %%mm2, %%mm5 \n\t" | |
2084 "paddd %%mm4, %%mm0 \n\t" | |
2085 "paddd %%mm5, %%mm3 \n\t" | |
2086 | |
2087 "psrad $8, %%mm0 \n\t" | |
2088 "psrad $8, %%mm3 \n\t" | |
2089 "packssdw %%mm3, %%mm0 \n\t" | |
2090 "pmaddwd %%mm6, %%mm0 \n\t" | |
2091 "packssdw %%mm0, %%mm0 \n\t" | |
2092 "movd %%mm0, (%4, %%ebp) \n\t" | |
2093 "addl $4, %%ebp \n\t" | |
2094 " jnc 1b \n\t" | |
3344 | 2095 |
3272 | 2096 "popl %%ebp \n\t" |
2097 : "+a" (counter) | |
2098 : "c" (filter), "d" (filterPos), "S" (src), "D" (dst) | |
2099 : "%ebx" | |
2100 ); | |
2101 } | |
2102 else | |
2103 { | |
2104 int counter= -2*dstW; | |
2105 // filter-= counter*filterSize/2; | |
2106 filterPos-= counter/2; | |
2107 dst-= counter/2; | |
2108 asm volatile( | |
2109 "pxor %%mm7, %%mm7 \n\t" | |
4248 | 2110 "movq "MANGLE(w02)", %%mm6 \n\t" |
3272 | 2111 ".balign 16 \n\t" |
2112 "1: \n\t" | |
2113 "movl %2, %%ecx \n\t" | |
2114 "movzwl (%%ecx, %0), %%eax \n\t" | |
2115 "movzwl 2(%%ecx, %0), %%ebx \n\t" | |
2116 "movl %5, %%ecx \n\t" | |
2117 "pxor %%mm4, %%mm4 \n\t" | |
2118 "pxor %%mm5, %%mm5 \n\t" | |
2119 "2: \n\t" | |
2120 "movq (%1), %%mm1 \n\t" | |
2121 "movq (%1, %6), %%mm3 \n\t" | |
2122 "movd (%%ecx, %%eax), %%mm0 \n\t" | |
2123 "movd (%%ecx, %%ebx), %%mm2 \n\t" | |
2124 "punpcklbw %%mm7, %%mm0 \n\t" | |
2125 "punpcklbw %%mm7, %%mm2 \n\t" | |
2126 "pmaddwd %%mm1, %%mm0 \n\t" | |
2127 "pmaddwd %%mm2, %%mm3 \n\t" | |
2128 "paddd %%mm3, %%mm5 \n\t" | |
2129 "paddd %%mm0, %%mm4 \n\t" | |
2130 "addl $8, %1 \n\t" | |
2131 "addl $4, %%ecx \n\t" | |
2132 "cmpl %4, %%ecx \n\t" | |
2133 " jb 2b \n\t" | |
2134 "addl %6, %1 \n\t" | |
2135 "psrad $8, %%mm4 \n\t" | |
2136 "psrad $8, %%mm5 \n\t" | |
2137 "packssdw %%mm5, %%mm4 \n\t" | |
2138 "pmaddwd %%mm6, %%mm4 \n\t" | |
2139 "packssdw %%mm4, %%mm4 \n\t" | |
2140 "movl %3, %%eax \n\t" | |
2141 "movd %%mm4, (%%eax, %0) \n\t" | |
2142 "addl $4, %0 \n\t" | |
2143 " jnc 1b \n\t" | |
3344 | 2144 |
3641 | 2145 : "+r" (counter), "+r" (filter) |
2146 : "m" (filterPos), "m" (dst), "m"(src+filterSize), | |
3272 | 2147 "m" (src), "r" (filterSize*2) |
3299 | 2148 : "%ebx", "%eax", "%ecx" |
3272 | 2149 ); |
2150 } | |
2151 #else | |
2152 int i; | |
2153 for(i=0; i<dstW; i++) | |
2154 { | |
2155 int j; | |
2156 int srcPos= filterPos[i]; | |
2157 int val=0; | |
3344 | 2158 // printf("filterPos: %d\n", filterPos[i]); |
3272 | 2159 for(j=0; j<filterSize; j++) |
2160 { | |
2161 // printf("filter: %d, src: %d\n", filter[i], src[srcPos + j]); | |
2162 val += ((int)src[srcPos + j])*filter[filterSize*i + j]; | |
2163 } | |
2164 // filter += hFilterSize; | |
2165 dst[i] = MIN(MAX(0, val>>7), (1<<15)-1); // the cubic equation does overflow ... | |
2166 // dst[i] = val>>7; | |
2167 } | |
2168 #endif | |
2169 } | |
2170 // *** horizontal scale Y line to temp buffer | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2171 static inline void RENAME(hyscale)(uint16_t *dst, int dstWidth, uint8_t *src, int srcW, int xInc, |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2172 int flags, int canMMX2BeUsed, int16_t *hLumFilter, |
4467 | 2173 int16_t *hLumFilterPos, int hLumFilterSize, void *funnyYCode, |
5452 | 2174 int srcFormat, uint8_t *formatConvBuffer, int16_t *mmx2Filter, |
2175 int32_t *mmx2FilterPos) | |
2469 | 2176 { |
4467 | 2177 if(srcFormat==IMGFMT_YUY2) |
2178 { | |
2179 RENAME(yuy2ToY)(formatConvBuffer, src, srcW); | |
2180 src= formatConvBuffer; | |
2181 } | |
9071 | 2182 else if(srcFormat==IMGFMT_UYVY) |
2183 { | |
2184 RENAME(uyvyToY)(formatConvBuffer, src, srcW); | |
2185 src= formatConvBuffer; | |
2186 } | |
4467 | 2187 else if(srcFormat==IMGFMT_BGR32) |
2188 { | |
2189 RENAME(bgr32ToY)(formatConvBuffer, src, srcW); | |
2190 src= formatConvBuffer; | |
2191 } | |
2192 else if(srcFormat==IMGFMT_BGR24) | |
2193 { | |
2194 RENAME(bgr24ToY)(formatConvBuffer, src, srcW); | |
2195 src= formatConvBuffer; | |
2196 } | |
4578 | 2197 else if(srcFormat==IMGFMT_BGR16) |
2198 { | |
2199 RENAME(bgr16ToY)(formatConvBuffer, src, srcW); | |
2200 src= formatConvBuffer; | |
2201 } | |
4580 | 2202 else if(srcFormat==IMGFMT_BGR15) |
2203 { | |
2204 RENAME(bgr15ToY)(formatConvBuffer, src, srcW); | |
2205 src= formatConvBuffer; | |
2206 } | |
4558 | 2207 else if(srcFormat==IMGFMT_RGB32) |
2208 { | |
2209 RENAME(rgb32ToY)(formatConvBuffer, src, srcW); | |
2210 src= formatConvBuffer; | |
2211 } | |
2212 else if(srcFormat==IMGFMT_RGB24) | |
2213 { | |
2214 RENAME(rgb24ToY)(formatConvBuffer, src, srcW); | |
2215 src= formatConvBuffer; | |
2216 } | |
4467 | 2217 |
3352 | 2218 #ifdef HAVE_MMX |
2219 // use the new MMX scaler if th mmx2 cant be used (its faster than the x86asm one) | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2220 if(!(flags&SWS_FAST_BILINEAR) || (!canMMX2BeUsed)) |
3352 | 2221 #else |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2222 if(!(flags&SWS_FAST_BILINEAR)) |
3352 | 2223 #endif |
3272 | 2224 { |
2225 RENAME(hScale)(dst, dstWidth, src, srcW, xInc, hLumFilter, hLumFilterPos, hLumFilterSize); | |
2226 } | |
2227 else // Fast Bilinear upscale / crap downscale | |
2228 { | |
2469 | 2229 #ifdef ARCH_X86 |
2230 #ifdef HAVE_MMX2 | |
2671 | 2231 int i; |
2469 | 2232 if(canMMX2BeUsed) |
2233 { | |
2234 asm volatile( | |
2235 "pxor %%mm7, %%mm7 \n\t" | |
5452 | 2236 "movl %0, %%ecx \n\t" |
2237 "movl %1, %%edi \n\t" | |
2238 "movl %2, %%edx \n\t" | |
2239 "movl %3, %%ebx \n\t" | |
2469 | 2240 "xorl %%eax, %%eax \n\t" // i |
5452 | 2241 PREFETCH" (%%ecx) \n\t" |
2242 PREFETCH" 32(%%ecx) \n\t" | |
2243 PREFETCH" 64(%%ecx) \n\t" | |
2520 | 2244 |
2469 | 2245 #define FUNNY_Y_CODE \ |
5452 | 2246 "movl (%%ebx), %%esi \n\t"\ |
2247 "call *%4 \n\t"\ | |
2248 "addl (%%ebx, %%eax), %%ecx \n\t"\ | |
2249 "addl %%eax, %%edi \n\t"\ | |
2250 "xorl %%eax, %%eax \n\t"\ | |
2520 | 2251 |
2469 | 2252 FUNNY_Y_CODE |
2253 FUNNY_Y_CODE | |
2254 FUNNY_Y_CODE | |
2255 FUNNY_Y_CODE | |
2256 FUNNY_Y_CODE | |
2257 FUNNY_Y_CODE | |
2258 FUNNY_Y_CODE | |
2259 FUNNY_Y_CODE | |
2260 | |
5452 | 2261 :: "m" (src), "m" (dst), "m" (mmx2Filter), "m" (mmx2FilterPos), |
2262 "m" (funnyYCode) | |
2469 | 2263 : "%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi" |
2264 ); | |
3215 | 2265 for(i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) dst[i] = src[srcW-1]*128; |
2469 | 2266 } |
2267 else | |
2268 { | |
2269 #endif | |
2270 //NO MMX just normal asm ... | |
2271 asm volatile( | |
2272 "xorl %%eax, %%eax \n\t" // i | |
2273 "xorl %%ebx, %%ebx \n\t" // xx | |
2274 "xorl %%ecx, %%ecx \n\t" // 2*xalpha | |
2800
7847d6b7ad3d
.balign or we¡ll align by 64kb on some architectures
michael
parents:
2799
diff
changeset
|
2275 ".balign 16 \n\t" |
2469 | 2276 "1: \n\t" |
2277 "movzbl (%0, %%ebx), %%edi \n\t" //src[xx] | |
2278 "movzbl 1(%0, %%ebx), %%esi \n\t" //src[xx+1] | |
2279 "subl %%edi, %%esi \n\t" //src[xx+1] - src[xx] | |
2280 "imull %%ecx, %%esi \n\t" //(src[xx+1] - src[xx])*2*xalpha | |
2281 "shll $16, %%edi \n\t" | |
2282 "addl %%edi, %%esi \n\t" //src[xx+1]*2*xalpha + src[xx]*(1-2*xalpha) | |
2283 "movl %1, %%edi \n\t" | |
2284 "shrl $9, %%esi \n\t" | |
2285 "movw %%si, (%%edi, %%eax, 2) \n\t" | |
2286 "addw %4, %%cx \n\t" //2*xalpha += xInc&0xFF | |
2287 "adcl %3, %%ebx \n\t" //xx+= xInc>>8 + carry | |
2288 | |
2289 "movzbl (%0, %%ebx), %%edi \n\t" //src[xx] | |
2290 "movzbl 1(%0, %%ebx), %%esi \n\t" //src[xx+1] | |
2291 "subl %%edi, %%esi \n\t" //src[xx+1] - src[xx] | |
2292 "imull %%ecx, %%esi \n\t" //(src[xx+1] - src[xx])*2*xalpha | |
2293 "shll $16, %%edi \n\t" | |
2294 "addl %%edi, %%esi \n\t" //src[xx+1]*2*xalpha + src[xx]*(1-2*xalpha) | |
2295 "movl %1, %%edi \n\t" | |
2296 "shrl $9, %%esi \n\t" | |
2297 "movw %%si, 2(%%edi, %%eax, 2) \n\t" | |
2298 "addw %4, %%cx \n\t" //2*xalpha += xInc&0xFF | |
2299 "adcl %3, %%ebx \n\t" //xx+= xInc>>8 + carry | |
2300 | |
2301 | |
2302 "addl $2, %%eax \n\t" | |
2303 "cmpl %2, %%eax \n\t" | |
2304 " jb 1b \n\t" | |
2305 | |
2306 | |
2307 :: "r" (src), "m" (dst), "m" (dstWidth), "m" (xInc>>16), "m" (xInc&0xFFFF) | |
2308 : "%eax", "%ebx", "%ecx", "%edi", "%esi" | |
2309 ); | |
2310 #ifdef HAVE_MMX2 | |
2311 } //if MMX2 cant be used | |
2312 #endif | |
2313 #else | |
2671 | 2314 int i; |
2315 unsigned int xpos=0; | |
2316 for(i=0;i<dstWidth;i++) | |
2317 { | |
2318 register unsigned int xx=xpos>>16; | |
2319 register unsigned int xalpha=(xpos&0xFFFF)>>9; | |
2320 dst[i]= (src[xx]<<7) + (src[xx+1] - src[xx])*xalpha; | |
2321 xpos+=xInc; | |
2322 } | |
2469 | 2323 #endif |
3272 | 2324 } |
2469 | 2325 } |
2326 | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2327 inline static void RENAME(hcscale)(uint16_t *dst, int dstWidth, uint8_t *src1, uint8_t *src2, |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2328 int srcW, int xInc, int flags, int canMMX2BeUsed, int16_t *hChrFilter, |
4467 | 2329 int16_t *hChrFilterPos, int hChrFilterSize, void *funnyUVCode, |
5452 | 2330 int srcFormat, uint8_t *formatConvBuffer, int16_t *mmx2Filter, |
2331 int32_t *mmx2FilterPos) | |
2469 | 2332 { |
4467 | 2333 if(srcFormat==IMGFMT_YUY2) |
2334 { | |
2335 RENAME(yuy2ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); | |
2336 src1= formatConvBuffer; | |
2337 src2= formatConvBuffer+2048; | |
2338 } | |
9071 | 2339 else if(srcFormat==IMGFMT_UYVY) |
2340 { | |
2341 RENAME(uyvyToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); | |
2342 src1= formatConvBuffer; | |
2343 src2= formatConvBuffer+2048; | |
2344 } | |
4467 | 2345 else if(srcFormat==IMGFMT_BGR32) |
2346 { | |
2347 RENAME(bgr32ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); | |
2348 src1= formatConvBuffer; | |
2349 src2= formatConvBuffer+2048; | |
2350 } | |
2351 else if(srcFormat==IMGFMT_BGR24) | |
2352 { | |
2353 RENAME(bgr24ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); | |
2354 src1= formatConvBuffer; | |
2355 src2= formatConvBuffer+2048; | |
2356 } | |
4578 | 2357 else if(srcFormat==IMGFMT_BGR16) |
2358 { | |
2359 RENAME(bgr16ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); | |
2360 src1= formatConvBuffer; | |
2361 src2= formatConvBuffer+2048; | |
2362 } | |
4580 | 2363 else if(srcFormat==IMGFMT_BGR15) |
2364 { | |
2365 RENAME(bgr15ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); | |
2366 src1= formatConvBuffer; | |
2367 src2= formatConvBuffer+2048; | |
2368 } | |
4558 | 2369 else if(srcFormat==IMGFMT_RGB32) |
2370 { | |
2371 RENAME(rgb32ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); | |
2372 src1= formatConvBuffer; | |
2373 src2= formatConvBuffer+2048; | |
2374 } | |
2375 else if(srcFormat==IMGFMT_RGB24) | |
2376 { | |
2377 RENAME(rgb24ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); | |
2378 src1= formatConvBuffer; | |
2379 src2= formatConvBuffer+2048; | |
2380 } | |
4481 | 2381 else if(isGray(srcFormat)) |
2382 { | |
2383 return; | |
2384 } | |
4467 | 2385 |
3352 | 2386 #ifdef HAVE_MMX |
2387 // use the new MMX scaler if th mmx2 cant be used (its faster than the x86asm one) | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2388 if(!(flags&SWS_FAST_BILINEAR) || (!canMMX2BeUsed)) |
3352 | 2389 #else |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2390 if(!(flags&SWS_FAST_BILINEAR)) |
3352 | 2391 #endif |
3272 | 2392 { |
2393 RENAME(hScale)(dst , dstWidth, src1, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize); | |
2394 RENAME(hScale)(dst+2048, dstWidth, src2, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize); | |
2395 } | |
2396 else // Fast Bilinear upscale / crap downscale | |
2397 { | |
2469 | 2398 #ifdef ARCH_X86 |
2399 #ifdef HAVE_MMX2 | |
2671 | 2400 int i; |
2469 | 2401 if(canMMX2BeUsed) |
2402 { | |
2403 asm volatile( | |
5452 | 2404 "pxor %%mm7, %%mm7 \n\t" |
2405 "movl %0, %%ecx \n\t" | |
2406 "movl %1, %%edi \n\t" | |
2407 "movl %2, %%edx \n\t" | |
2408 "movl %3, %%ebx \n\t" | |
2409 "xorl %%eax, %%eax \n\t" // i | |
2410 PREFETCH" (%%ecx) \n\t" | |
2411 PREFETCH" 32(%%ecx) \n\t" | |
2412 PREFETCH" 64(%%ecx) \n\t" | |
2413 | |
2414 #define FUNNY_UV_CODE \ | |
2415 "movl (%%ebx), %%esi \n\t"\ | |
2416 "call *%4 \n\t"\ | |
2417 "addl (%%ebx, %%eax), %%ecx \n\t"\ | |
2418 "addl %%eax, %%edi \n\t"\ | |
2419 "xorl %%eax, %%eax \n\t"\ | |
2469 | 2420 |
5452 | 2421 FUNNY_UV_CODE |
2422 FUNNY_UV_CODE | |
2423 FUNNY_UV_CODE | |
2424 FUNNY_UV_CODE | |
2425 "xorl %%eax, %%eax \n\t" // i | |
2426 "movl %5, %%ecx \n\t" // src | |
2427 "movl %1, %%edi \n\t" // buf1 | |
2428 "addl $4096, %%edi \n\t" | |
2429 PREFETCH" (%%ecx) \n\t" | |
2430 PREFETCH" 32(%%ecx) \n\t" | |
2431 PREFETCH" 64(%%ecx) \n\t" | |
2469 | 2432 |
5452 | 2433 FUNNY_UV_CODE |
2434 FUNNY_UV_CODE | |
2435 FUNNY_UV_CODE | |
2436 FUNNY_UV_CODE | |
2469 | 2437 |
5452 | 2438 :: "m" (src1), "m" (dst), "m" (mmx2Filter), "m" (mmx2FilterPos), |
2439 "m" (funnyUVCode), "m" (src2) | |
2440 : "%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi" | |
2441 ); | |
3344 | 2442 for(i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) |
2469 | 2443 { |
3344 | 2444 // printf("%d %d %d\n", dstWidth, i, srcW); |
2445 dst[i] = src1[srcW-1]*128; | |
2446 dst[i+2048] = src2[srcW-1]*128; | |
2469 | 2447 } |
2448 } | |
2449 else | |
2450 { | |
2451 #endif | |
2452 asm volatile( | |
2453 "xorl %%eax, %%eax \n\t" // i | |
2454 "xorl %%ebx, %%ebx \n\t" // xx | |
2455 "xorl %%ecx, %%ecx \n\t" // 2*xalpha | |
2800
7847d6b7ad3d
.balign or we¡ll align by 64kb on some architectures
michael
parents:
2799
diff
changeset
|
2456 ".balign 16 \n\t" |
2469 | 2457 "1: \n\t" |
2458 "movl %0, %%esi \n\t" | |
2459 "movzbl (%%esi, %%ebx), %%edi \n\t" //src[xx] | |
2460 "movzbl 1(%%esi, %%ebx), %%esi \n\t" //src[xx+1] | |
2461 "subl %%edi, %%esi \n\t" //src[xx+1] - src[xx] | |
2462 "imull %%ecx, %%esi \n\t" //(src[xx+1] - src[xx])*2*xalpha | |
2463 "shll $16, %%edi \n\t" | |
2464 "addl %%edi, %%esi \n\t" //src[xx+1]*2*xalpha + src[xx]*(1-2*xalpha) | |
2465 "movl %1, %%edi \n\t" | |
2466 "shrl $9, %%esi \n\t" | |
2467 "movw %%si, (%%edi, %%eax, 2) \n\t" | |
2468 | |
2469 "movzbl (%5, %%ebx), %%edi \n\t" //src[xx] | |
2470 "movzbl 1(%5, %%ebx), %%esi \n\t" //src[xx+1] | |
2471 "subl %%edi, %%esi \n\t" //src[xx+1] - src[xx] | |
2472 "imull %%ecx, %%esi \n\t" //(src[xx+1] - src[xx])*2*xalpha | |
2473 "shll $16, %%edi \n\t" | |
2474 "addl %%edi, %%esi \n\t" //src[xx+1]*2*xalpha + src[xx]*(1-2*xalpha) | |
2475 "movl %1, %%edi \n\t" | |
2476 "shrl $9, %%esi \n\t" | |
2477 "movw %%si, 4096(%%edi, %%eax, 2)\n\t" | |
2478 | |
2479 "addw %4, %%cx \n\t" //2*xalpha += xInc&0xFF | |
2480 "adcl %3, %%ebx \n\t" //xx+= xInc>>8 + carry | |
2481 "addl $1, %%eax \n\t" | |
2482 "cmpl %2, %%eax \n\t" | |
2483 " jb 1b \n\t" | |
2484 | |
2485 :: "m" (src1), "m" (dst), "m" (dstWidth), "m" (xInc>>16), "m" (xInc&0xFFFF), | |
2486 "r" (src2) | |
2487 : "%eax", "%ebx", "%ecx", "%edi", "%esi" | |
2488 ); | |
2489 #ifdef HAVE_MMX2 | |
2490 } //if MMX2 cant be used | |
2491 #endif | |
2492 #else | |
2671 | 2493 int i; |
2494 unsigned int xpos=0; | |
2495 for(i=0;i<dstWidth;i++) | |
2496 { | |
2497 register unsigned int xx=xpos>>16; | |
2498 register unsigned int xalpha=(xpos&0xFFFF)>>9; | |
2499 dst[i]=(src1[xx]*(xalpha^127)+src1[xx+1]*xalpha); | |
2500 dst[i+2048]=(src2[xx]*(xalpha^127)+src2[xx+1]*xalpha); | |
2566 | 2501 /* slower |
2502 dst[i]= (src1[xx]<<7) + (src1[xx+1] - src1[xx])*xalpha; | |
2503 dst[i+2048]=(src2[xx]<<7) + (src2[xx+1] - src2[xx])*xalpha; | |
2504 */ | |
2671 | 2505 xpos+=xInc; |
2506 } | |
2469 | 2507 #endif |
3272 | 2508 } |
2509 } | |
2510 | |
4467 | 2511 static void RENAME(swScale)(SwsContext *c, uint8_t* srcParam[], int srcStrideParam[], int srcSliceY, |
4698 | 2512 int srcSliceH, uint8_t* dstParam[], int dstStrideParam[]){ |
3344 | 2513 |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2514 /* load a few things into local vars to make the code more readable? and faster */ |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2515 const int srcW= c->srcW; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2516 const int dstW= c->dstW; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2517 const int dstH= c->dstH; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2518 const int chrDstW= c->chrDstW; |
6532
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
2519 const int chrSrcW= c->chrSrcW; |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2520 const int lumXInc= c->lumXInc; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2521 const int chrXInc= c->chrXInc; |
4295 | 2522 const int dstFormat= c->dstFormat; |
6503 | 2523 const int srcFormat= c->srcFormat; |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2524 const int flags= c->flags; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2525 const int canMMX2BeUsed= c->canMMX2BeUsed; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2526 int16_t *vLumFilterPos= c->vLumFilterPos; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2527 int16_t *vChrFilterPos= c->vChrFilterPos; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2528 int16_t *hLumFilterPos= c->hLumFilterPos; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2529 int16_t *hChrFilterPos= c->hChrFilterPos; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2530 int16_t *vLumFilter= c->vLumFilter; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2531 int16_t *vChrFilter= c->vChrFilter; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2532 int16_t *hLumFilter= c->hLumFilter; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2533 int16_t *hChrFilter= c->hChrFilter; |
9413 | 2534 int32_t *lumMmxFilter= c->lumMmxFilter; |
2535 int32_t *chrMmxFilter= c->chrMmxFilter; | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2536 const int vLumFilterSize= c->vLumFilterSize; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2537 const int vChrFilterSize= c->vChrFilterSize; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2538 const int hLumFilterSize= c->hLumFilterSize; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2539 const int hChrFilterSize= c->hChrFilterSize; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2540 int16_t **lumPixBuf= c->lumPixBuf; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2541 int16_t **chrPixBuf= c->chrPixBuf; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2542 const int vLumBufSize= c->vLumBufSize; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2543 const int vChrBufSize= c->vChrBufSize; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2544 uint8_t *funnyYCode= c->funnyYCode; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2545 uint8_t *funnyUVCode= c->funnyUVCode; |
4467 | 2546 uint8_t *formatConvBuffer= c->formatConvBuffer; |
6532
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
2547 const int chrSrcSliceY= srcSliceY >> c->chrSrcVSubSample; |
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
2548 const int chrSrcSliceH= -((-srcSliceH) >> c->chrSrcVSubSample); |
3344 | 2549 |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2550 /* vars whch will change and which we need to storw back in the context */ |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2551 int dstY= c->dstY; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2552 int lumBufIndex= c->lumBufIndex; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2553 int chrBufIndex= c->chrBufIndex; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2554 int lastInLumBuf= c->lastInLumBuf; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2555 int lastInChrBuf= c->lastInChrBuf; |
4467 | 2556 int srcStride[3]; |
4698 | 2557 int dstStride[3]; |
4419 | 2558 uint8_t *src[3]; |
2559 uint8_t *dst[3]; | |
6540 | 2560 |
2561 orderYUV(c->srcFormat, src, srcStride, srcParam, srcStrideParam); | |
2562 orderYUV(c->dstFormat, dst, dstStride, dstParam, dstStrideParam); | |
6503 | 2563 |
6540 | 2564 if(isPacked(c->srcFormat)){ |
4467 | 2565 src[0]= |
2566 src[1]= | |
2567 src[2]= srcParam[0]; | |
6540 | 2568 srcStride[0]= |
4467 | 2569 srcStride[1]= |
6540 | 2570 srcStride[2]= srcStrideParam[0]; |
4467 | 2571 } |
6540 | 2572 srcStride[1]<<= c->vChrDrop; |
2573 srcStride[2]<<= c->vChrDrop; | |
4419 | 2574 |
6517 | 2575 // printf("swscale %X %X %X -> %X %X %X\n", (int)src[0], (int)src[1], (int)src[2], |
2576 // (int)dst[0], (int)dst[1], (int)dst[2]); | |
2577 | |
2578 #if 0 //self test FIXME move to a vfilter or something | |
2579 { | |
2580 static volatile int i=0; | |
2581 i++; | |
2582 if(srcFormat==IMGFMT_YV12 && i==1 && srcSliceH>= c->srcH) | |
2583 selfTest(src, srcStride, c->srcW, c->srcH); | |
2584 i--; | |
2585 } | |
2586 #endif | |
4554 | 2587 |
2588 //printf("sws Strides:%d %d %d -> %d %d %d\n", srcStride[0],srcStride[1],srcStride[2], | |
2589 //dstStride[0],dstStride[1],dstStride[2]); | |
4419 | 2590 |
2591 if(dstStride[0]%8 !=0 || dstStride[1]%8 !=0 || dstStride[2]%8 !=0) | |
2592 { | |
2593 static int firstTime=1; //FIXME move this into the context perhaps | |
2594 if(flags & SWS_PRINT_INFO && firstTime) | |
2595 { | |
5937 | 2596 mp_msg(MSGT_SWS,MSGL_WARN,"SwScaler: Warning: dstStride is not aligned!\n" |
4419 | 2597 "SwScaler: ->cannot do aligned memory acesses anymore\n"); |
2598 firstTime=0; | |
2599 } | |
2600 } | |
3344 | 2601 |
4467 | 2602 /* Note the user might start scaling the picture in the middle so this will not get executed |
2603 this is not really intended but works currently, so ppl might do it */ | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2604 if(srcSliceY ==0){ |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2605 lumBufIndex=0; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2606 chrBufIndex=0; |
4467 | 2607 dstY=0; |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2608 lastInLumBuf= -1; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2609 lastInChrBuf= -1; |
3272 | 2610 } |
3344 | 2611 |
2612 for(;dstY < dstH; dstY++){ | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2613 unsigned char *dest =dst[0]+dstStride[0]*dstY; |
6520 | 2614 const int chrDstY= dstY>>c->chrDstVSubSample; |
2615 unsigned char *uDest=dst[1]+dstStride[1]*chrDstY; | |
2616 unsigned char *vDest=dst[2]+dstStride[2]*chrDstY; | |
3344 | 2617 |
2618 const int firstLumSrcY= vLumFilterPos[dstY]; //First line needed as input | |
2619 const int firstChrSrcY= vChrFilterPos[chrDstY]; //First line needed as input | |
2620 const int lastLumSrcY= firstLumSrcY + vLumFilterSize -1; // Last line needed as input | |
2621 const int lastChrSrcY= firstChrSrcY + vChrFilterSize -1; // Last line needed as input | |
2622 | |
4290
1f8ceb12284d
general convolution filtering of the source picture
michael
parents:
4276
diff
changeset
|
2623 //handle holes (FAST_BILINEAR & weird filters) |
1f8ceb12284d
general convolution filtering of the source picture
michael
parents:
4276
diff
changeset
|
2624 if(firstLumSrcY > lastInLumBuf) lastInLumBuf= firstLumSrcY-1; |
1f8ceb12284d
general convolution filtering of the source picture
michael
parents:
4276
diff
changeset
|
2625 if(firstChrSrcY > lastInChrBuf) lastInChrBuf= firstChrSrcY-1; |
1f8ceb12284d
general convolution filtering of the source picture
michael
parents:
4276
diff
changeset
|
2626 //printf("%d %d %d\n", firstChrSrcY, lastInChrBuf, vChrBufSize); |
3344 | 2627 ASSERT(firstLumSrcY >= lastInLumBuf - vLumBufSize + 1) |
2628 ASSERT(firstChrSrcY >= lastInChrBuf - vChrBufSize + 1) | |
2216 | 2629 |
3344 | 2630 // Do we have enough lines in this slice to output the dstY line |
6532
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
2631 if(lastLumSrcY < srcSliceY + srcSliceH && lastChrSrcY < -((-srcSliceY - srcSliceH)>>c->chrSrcVSubSample)) |
2469 | 2632 { |
3344 | 2633 //Do horizontal scaling |
2634 while(lastInLumBuf < lastLumSrcY) | |
2635 { | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2636 uint8_t *s= src[0]+(lastInLumBuf + 1 - srcSliceY)*srcStride[0]; |
3344 | 2637 lumBufIndex++; |
4290
1f8ceb12284d
general convolution filtering of the source picture
michael
parents:
4276
diff
changeset
|
2638 // printf("%d %d %d %d\n", lumBufIndex, vLumBufSize, lastInLumBuf, lastLumSrcY); |
3344 | 2639 ASSERT(lumBufIndex < 2*vLumBufSize) |
2640 ASSERT(lastInLumBuf + 1 - srcSliceY < srcSliceH) | |
2641 ASSERT(lastInLumBuf + 1 - srcSliceY >= 0) | |
2642 // printf("%d %d\n", lumBufIndex, vLumBufSize); | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2643 RENAME(hyscale)(lumPixBuf[ lumBufIndex ], dstW, s, srcW, lumXInc, |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2644 flags, canMMX2BeUsed, hLumFilter, hLumFilterPos, hLumFilterSize, |
5452 | 2645 funnyYCode, c->srcFormat, formatConvBuffer, |
2646 c->lumMmx2Filter, c->lumMmx2FilterPos); | |
3344 | 2647 lastInLumBuf++; |
2648 } | |
2649 while(lastInChrBuf < lastChrSrcY) | |
2650 { | |
6532
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
2651 uint8_t *src1= src[1]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[1]; |
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
2652 uint8_t *src2= src[2]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[2]; |
3344 | 2653 chrBufIndex++; |
2654 ASSERT(chrBufIndex < 2*vChrBufSize) | |
6532
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
2655 ASSERT(lastInChrBuf + 1 - chrSrcSliceY < (chrSrcSliceH)) |
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
2656 ASSERT(lastInChrBuf + 1 - chrSrcSliceY >= 0) |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2657 //FIXME replace parameters through context struct (some at least) |
6503 | 2658 |
2659 if(!(isGray(srcFormat) || isGray(dstFormat))) | |
6532
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
2660 RENAME(hcscale)(chrPixBuf[ chrBufIndex ], chrDstW, src1, src2, chrSrcW, chrXInc, |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2661 flags, canMMX2BeUsed, hChrFilter, hChrFilterPos, hChrFilterSize, |
5452 | 2662 funnyUVCode, c->srcFormat, formatConvBuffer, |
2663 c->chrMmx2Filter, c->chrMmx2FilterPos); | |
3344 | 2664 lastInChrBuf++; |
2665 } | |
2666 //wrap buf index around to stay inside the ring buffer | |
2667 if(lumBufIndex >= vLumBufSize ) lumBufIndex-= vLumBufSize; | |
2668 if(chrBufIndex >= vChrBufSize ) chrBufIndex-= vChrBufSize; | |
2469 | 2669 } |
3344 | 2670 else // not enough lines left in this slice -> load the rest in the buffer |
2469 | 2671 { |
3344 | 2672 /* printf("%d %d Last:%d %d LastInBuf:%d %d Index:%d %d Y:%d FSize: %d %d BSize: %d %d\n", |
2673 firstChrSrcY,firstLumSrcY,lastChrSrcY,lastLumSrcY, | |
2674 lastInChrBuf,lastInLumBuf,chrBufIndex,lumBufIndex,dstY,vChrFilterSize,vLumFilterSize, | |
6532
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
2675 vChrBufSize, vLumBufSize);*/ |
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
2676 |
3344 | 2677 //Do horizontal scaling |
2678 while(lastInLumBuf+1 < srcSliceY + srcSliceH) | |
2469 | 2679 { |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2680 uint8_t *s= src[0]+(lastInLumBuf + 1 - srcSliceY)*srcStride[0]; |
3344 | 2681 lumBufIndex++; |
2682 ASSERT(lumBufIndex < 2*vLumBufSize) | |
2683 ASSERT(lastInLumBuf + 1 - srcSliceY < srcSliceH) | |
2684 ASSERT(lastInLumBuf + 1 - srcSliceY >= 0) | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2685 RENAME(hyscale)(lumPixBuf[ lumBufIndex ], dstW, s, srcW, lumXInc, |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2686 flags, canMMX2BeUsed, hLumFilter, hLumFilterPos, hLumFilterSize, |
5452 | 2687 funnyYCode, c->srcFormat, formatConvBuffer, |
2688 c->lumMmx2Filter, c->lumMmx2FilterPos); | |
3344 | 2689 lastInLumBuf++; |
2469 | 2690 } |
6532
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
2691 while(lastInChrBuf+1 < (chrSrcSliceY + chrSrcSliceH)) |
3344 | 2692 { |
6532
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
2693 uint8_t *src1= src[1]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[1]; |
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
2694 uint8_t *src2= src[2]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[2]; |
3344 | 2695 chrBufIndex++; |
2696 ASSERT(chrBufIndex < 2*vChrBufSize) | |
6532
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
2697 ASSERT(lastInChrBuf + 1 - chrSrcSliceY < chrSrcSliceH) |
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
2698 ASSERT(lastInChrBuf + 1 - chrSrcSliceY >= 0) |
6503 | 2699 |
2700 if(!(isGray(srcFormat) || isGray(dstFormat))) | |
6532
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
2701 RENAME(hcscale)(chrPixBuf[ chrBufIndex ], chrDstW, src1, src2, chrSrcW, chrXInc, |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2702 flags, canMMX2BeUsed, hChrFilter, hChrFilterPos, hChrFilterSize, |
5452 | 2703 funnyUVCode, c->srcFormat, formatConvBuffer, |
2704 c->chrMmx2Filter, c->chrMmx2FilterPos); | |
3344 | 2705 lastInChrBuf++; |
2706 } | |
2707 //wrap buf index around to stay inside the ring buffer | |
2708 if(lumBufIndex >= vLumBufSize ) lumBufIndex-= vLumBufSize; | |
2709 if(chrBufIndex >= vChrBufSize ) chrBufIndex-= vChrBufSize; | |
2710 break; //we cant output a dstY line so lets try with the next slice | |
2469 | 2711 } |
2264
7851375ea156
increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents:
2237
diff
changeset
|
2712 |
2748 | 2713 #ifdef HAVE_MMX |
3344 | 2714 b5Dither= dither8[dstY&1]; |
2715 g6Dither= dither4[dstY&1]; | |
2716 g5Dither= dither8[dstY&1]; | |
2717 r5Dither= dither8[(dstY+1)&1]; | |
2748 | 2718 #endif |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2719 if(dstY < dstH-2) |
3352 | 2720 { |
9414 | 2721 int16_t **lumSrcPtr= lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize; |
2722 int16_t **chrSrcPtr= chrPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize; | |
2723 #ifdef HAVE_MMX | |
2724 int i; | |
2725 for(i=0; i<vLumFilterSize; i++) | |
2726 { | |
2727 lumMmxFilter[4*i+0]= (int32_t)lumSrcPtr[i]; | |
2728 lumMmxFilter[4*i+2]= | |
2729 lumMmxFilter[4*i+3]= | |
2730 ((uint16_t)vLumFilter[dstY*vLumFilterSize + i])*0x10001; | |
2731 } | |
2732 for(i=0; i<vChrFilterSize; i++) | |
2733 { | |
2734 chrMmxFilter[4*i+0]= (int32_t)chrSrcPtr[i]; | |
2735 chrMmxFilter[4*i+2]= | |
2736 chrMmxFilter[4*i+3]= | |
2737 ((uint16_t)vChrFilter[chrDstY*vChrFilterSize + i])*0x10001; | |
2738 } | |
2739 #endif | |
6503 | 2740 if(isPlanarYUV(dstFormat) || isGray(dstFormat)) //YV12 like |
3344 | 2741 { |
7351 | 2742 const int chrSkipMask= (1<<c->chrDstVSubSample)-1; |
2743 if((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; //FIXME split functions in lumi / chromi | |
3344 | 2744 if(vLumFilterSize == 1 && vChrFilterSize == 1) // Unscaled YV12 |
2745 { | |
2746 int16_t *lumBuf = lumPixBuf[0]; | |
2747 int16_t *chrBuf= chrPixBuf[0]; | |
6532
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
2748 RENAME(yuv2yuv1)(lumBuf, chrBuf, dest, uDest, vDest, dstW, chrDstW); |
3344 | 2749 } |
2750 else //General YV12 | |
2751 { | |
9413 | 2752 RENAME(yuv2yuvX)(c, |
6532
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
2753 vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize, |
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
2754 vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, |
9414 | 2755 dest, uDest, vDest, dstW, chrDstW); |
3344 | 2756 } |
2757 } | |
2758 else | |
2759 { | |
2760 ASSERT(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize*2); | |
2761 ASSERT(chrSrcPtr + vChrFilterSize - 1 < chrPixBuf + vChrBufSize*2); | |
2762 if(vLumFilterSize == 1 && vChrFilterSize == 2) //Unscaled RGB | |
2763 { | |
2764 int chrAlpha= vChrFilter[2*dstY+1]; | |
2765 | |
7723 | 2766 RENAME(yuv2packed1)(c, *lumSrcPtr, *chrSrcPtr, *(chrSrcPtr+1), |
6578 | 2767 dest, dstW, chrAlpha, dstFormat, flags, dstY); |
3344 | 2768 } |
2769 else if(vLumFilterSize == 2 && vChrFilterSize == 2) //BiLinear Upscale RGB | |
2770 { | |
2771 int lumAlpha= vLumFilter[2*dstY+1]; | |
2772 int chrAlpha= vChrFilter[2*dstY+1]; | |
7723 | 2773 RENAME(yuv2packed2)(c, *lumSrcPtr, *(lumSrcPtr+1), *chrSrcPtr, *(chrSrcPtr+1), |
6578 | 2774 dest, dstW, lumAlpha, chrAlpha, dstY); |
3344 | 2775 } |
2776 else //General RGB | |
2777 { | |
7723 | 2778 RENAME(yuv2packedX)(c, |
3344 | 2779 vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize, |
2780 vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, | |
9413 | 2781 dest, dstW, dstY); |
3344 | 2782 } |
2783 } | |
3352 | 2784 } |
2785 else // hmm looks like we cant use MMX here without overwriting this arrays tail | |
2786 { | |
2787 int16_t **lumSrcPtr= lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize; | |
2788 int16_t **chrSrcPtr= chrPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize; | |
6615 | 2789 if(isPlanarYUV(dstFormat) || isGray(dstFormat)) //YV12 |
3352 | 2790 { |
7351 | 2791 const int chrSkipMask= (1<<c->chrDstVSubSample)-1; |
2792 if((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; //FIXME split functions in lumi / chromi | |
6540 | 2793 yuv2yuvXinC( |
6532
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
2794 vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize, |
9834d9980c45
yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
michael
parents:
6520
diff
changeset
|
2795 vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, |
6540 | 2796 dest, uDest, vDest, dstW, chrDstW); |
3352 | 2797 } |
2798 else | |
2799 { | |
2800 ASSERT(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize*2); | |
2801 ASSERT(chrSrcPtr + vChrFilterSize - 1 < chrPixBuf + vChrBufSize*2); | |
7723 | 2802 yuv2packedXinC(c, |
3352 | 2803 vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize, |
2804 vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, | |
6578 | 2805 dest, dstW, dstY); |
3352 | 2806 } |
2807 } | |
3344 | 2808 } |
2534
cc9d3fd626f0
patch from Martin Decky <deckm1am@ss1000.ms.mff.cuni.cz> applied and unnecassery "memory" removed
michael
parents:
2521
diff
changeset
|
2809 |
cc9d3fd626f0
patch from Martin Decky <deckm1am@ss1000.ms.mff.cuni.cz> applied and unnecassery "memory" removed
michael
parents:
2521
diff
changeset
|
2810 #ifdef HAVE_MMX |
cc9d3fd626f0
patch from Martin Decky <deckm1am@ss1000.ms.mff.cuni.cz> applied and unnecassery "memory" removed
michael
parents:
2521
diff
changeset
|
2811 __asm __volatile(SFENCE:::"memory"); |
2566 | 2812 __asm __volatile(EMMS:::"memory"); |
2534
cc9d3fd626f0
patch from Martin Decky <deckm1am@ss1000.ms.mff.cuni.cz> applied and unnecassery "memory" removed
michael
parents:
2521
diff
changeset
|
2813 #endif |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2814 /* store changed local vars back in the context */ |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2815 c->dstY= dstY; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2816 c->lumBufIndex= lumBufIndex; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2817 c->chrBufIndex= chrBufIndex; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2818 c->lastInLumBuf= lastInLumBuf; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2819 c->lastInChrBuf= lastInChrBuf; |
3641 | 2820 } |