Mercurial > mplayer.hg
annotate postproc/swscale_template.c @ 9434:d2da6447daac
1000l
author | michael |
---|---|
date | Sat, 15 Feb 2003 17:29:01 +0000 |
parents | 53f03173e48f |
children | eff727517e6b |
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 |
9417 | 348 #define YSCALEYUV2PACKED1(index, c) \ |
349 "xorl "#index", "#index" \n\t"\ | |
7723 | 350 ".balign 16 \n\t"\ |
351 "1: \n\t"\ | |
9417 | 352 "movq (%2, "#index"), %%mm3 \n\t" /* uvbuf0[eax]*/\ |
353 "movq 4096(%2, "#index"), %%mm4 \n\t" /* uvbuf0[eax+2048]*/\ | |
7723 | 354 "psraw $7, %%mm3 \n\t" \ |
355 "psraw $7, %%mm4 \n\t" \ | |
9417 | 356 "movq (%0, "#index", 2), %%mm1 \n\t" /*buf0[eax]*/\ |
357 "movq 8(%0, "#index", 2), %%mm7 \n\t" /*buf0[eax]*/\ | |
7723 | 358 "psraw $7, %%mm1 \n\t" \ |
359 "psraw $7, %%mm7 \n\t" \ | |
360 | |
9417 | 361 #define YSCALEYUV2RGB1(index, c) \ |
362 "xorl "#index", "#index" \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"\ |
9417 | 365 "movq (%2, "#index"), %%mm3 \n\t" /* uvbuf0[eax]*/\ |
366 "movq 4096(%2, "#index"), %%mm4 \n\t" /* uvbuf0[eax+2048]*/\ | |
2316
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*/\ |
9417 | 369 "psubw "U_OFFSET"("#c"), %%mm3 \n\t" /* (U-128)8*/\ |
370 "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
|
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*/\ |
9417 | 373 "pmulhw "UG_COEFF"("#c"), %%mm3\n\t"\ |
374 "pmulhw "VG_COEFF"("#c"), %%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 */\ |
9417 | 376 "movq (%0, "#index", 2), %%mm1 \n\t" /*buf0[eax]*/\ |
377 "movq 8(%0, "#index", 2), %%mm7 \n\t" /*buf0[eax]*/\ | |
2569
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*/\ |
9417 | 380 "pmulhw "UB_COEFF"("#c"), %%mm2\n\t"\ |
381 "pmulhw "VR_COEFF"("#c"), %%mm5\n\t"\ | |
382 "psubw "Y_OFFSET"("#c"), %%mm1 \n\t" /* 8(Y-16)*/\ | |
383 "psubw "Y_OFFSET"("#c"), %%mm7 \n\t" /* 8(Y-16)*/\ | |
384 "pmulhw "Y_COEFF"("#c"), %%mm1 \n\t"\ | |
385 "pmulhw "Y_COEFF"("#c"), %%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 |
9417 | 409 #define YSCALEYUV2PACKED1b(index, c) \ |
410 "xorl "#index", "#index" \n\t"\ | |
7723 | 411 ".balign 16 \n\t"\ |
412 "1: \n\t"\ | |
9417 | 413 "movq (%2, "#index"), %%mm2 \n\t" /* uvbuf0[eax]*/\ |
414 "movq (%3, "#index"), %%mm3 \n\t" /* uvbuf1[eax]*/\ | |
415 "movq 4096(%2, "#index"), %%mm5 \n\t" /* uvbuf0[eax+2048]*/\ | |
416 "movq 4096(%3, "#index"), %%mm4 \n\t" /* uvbuf1[eax+2048]*/\ | |
7723 | 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" \ | |
9417 | 421 "movq (%0, "#index", 2), %%mm1 \n\t" /*buf0[eax]*/\ |
422 "movq 8(%0, "#index", 2), %%mm7 \n\t" /*buf0[eax]*/\ | |
7723 | 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 |
9417 | 427 #define YSCALEYUV2RGB1b(index, c) \ |
428 "xorl "#index", "#index" \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"\ |
9417 | 431 "movq (%2, "#index"), %%mm2 \n\t" /* uvbuf0[eax]*/\ |
432 "movq (%3, "#index"), %%mm3 \n\t" /* uvbuf1[eax]*/\ | |
433 "movq 4096(%2, "#index"), %%mm5 \n\t" /* uvbuf0[eax+2048]*/\ | |
434 "movq 4096(%3, "#index"), %%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*/\ | |
9417 | 439 "psubw "U_OFFSET"("#c"), %%mm3 \n\t" /* (U-128)8*/\ |
440 "psubw "V_OFFSET"("#c"), %%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*/\ |
9417 | 443 "pmulhw "UG_COEFF"("#c"), %%mm3\n\t"\ |
444 "pmulhw "VG_COEFF"("#c"), %%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 */\ |
9417 | 446 "movq (%0, "#index", 2), %%mm1 \n\t" /*buf0[eax]*/\ |
447 "movq 8(%0, "#index", 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*/\ |
9417 | 450 "pmulhw "UB_COEFF"("#c"), %%mm2\n\t"\ |
451 "pmulhw "VR_COEFF"("#c"), %%mm5\n\t"\ | |
452 "psubw "Y_OFFSET"("#c"), %%mm1 \n\t" /* 8(Y-16)*/\ | |
453 "psubw "Y_OFFSET"("#c"), %%mm7 \n\t" /* 8(Y-16)*/\ | |
454 "pmulhw "Y_COEFF"("#c"), %%mm1 \n\t"\ | |
455 "pmulhw "Y_COEFF"("#c"), %%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 { |
3344 | 1262 const int yalpha1=0; |
6578 | 1263 int i; |
1264 | |
1265 uint16_t *buf1= buf0; //FIXME needed for the rgb1/bgr1 | |
1266 const int yalpha= 4096; //FIXME ... | |
2671 | 1267 |
4467 | 1268 if(flags&SWS_FULL_CHR_H_INT) |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1269 { |
7723 | 1270 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
|
1271 return; |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1272 } |
2576 | 1273 |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1274 #ifdef HAVE_MMX |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1275 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
|
1276 { |
6578 | 1277 switch(dstFormat) |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1278 { |
6578 | 1279 case IMGFMT_BGR32: |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1280 asm volatile( |
9417 | 1281 "movl %%esp, "ESP_OFFSET"(%5) \n\t" |
1282 "movl %4, %%esp \n\t" | |
1283 YSCALEYUV2RGB1(%%eax, %5) | |
1284 WRITEBGR32(%%esp, 8280(%5), %%eax) | |
1285 "movl "ESP_OFFSET"(%5), %%esp \n\t" | |
1286 | |
1287 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "m" (dest), | |
1288 "r" (&c->redDither) | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1289 : "%eax" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1290 ); |
6578 | 1291 return; |
1292 case IMGFMT_BGR24: | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1293 asm volatile( |
9417 | 1294 "movl %%esp, "ESP_OFFSET"(%5) \n\t" |
1295 "movl %4, %%esp \n\t" | |
1296 YSCALEYUV2RGB1(%%eax, %5) | |
1297 WRITEBGR24(%%esp, 8280(%5), %%eax) | |
1298 "movl "ESP_OFFSET"(%5), %%esp \n\t" | |
1299 | |
1300 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "m" (dest), | |
1301 "r" (&c->redDither) | |
1302 : "%eax" | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1303 ); |
6578 | 1304 return; |
1305 case IMGFMT_BGR15: | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1306 asm volatile( |
9417 | 1307 "movl %%esp, "ESP_OFFSET"(%5) \n\t" |
1308 "movl %4, %%esp \n\t" | |
1309 YSCALEYUV2RGB1(%%eax, %5) | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1310 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1311 #ifdef DITHER1XBPP |
4248 | 1312 "paddusb "MANGLE(b5Dither)", %%mm2\n\t" |
1313 "paddusb "MANGLE(g5Dither)", %%mm4\n\t" | |
1314 "paddusb "MANGLE(r5Dither)", %%mm5\n\t" | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1315 #endif |
9417 | 1316 WRITEBGR15(%%esp, 8280(%5), %%eax) |
1317 "movl "ESP_OFFSET"(%5), %%esp \n\t" | |
1318 | |
1319 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "m" (dest), | |
1320 "r" (&c->redDither) | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1321 : "%eax" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1322 ); |
6578 | 1323 return; |
1324 case IMGFMT_BGR16: | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1325 asm volatile( |
9417 | 1326 "movl %%esp, "ESP_OFFSET"(%5) \n\t" |
1327 "movl %4, %%esp \n\t" | |
1328 YSCALEYUV2RGB1(%%eax, %5) | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1329 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */ |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1330 #ifdef DITHER1XBPP |
4248 | 1331 "paddusb "MANGLE(b5Dither)", %%mm2\n\t" |
1332 "paddusb "MANGLE(g6Dither)", %%mm4\n\t" | |
1333 "paddusb "MANGLE(r5Dither)", %%mm5\n\t" | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1334 #endif |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1335 |
9417 | 1336 WRITEBGR16(%%esp, 8280(%5), %%eax) |
1337 "movl "ESP_OFFSET"(%5), %%esp \n\t" | |
1338 | |
1339 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "m" (dest), | |
1340 "r" (&c->redDither) | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1341 : "%eax" |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1342 ); |
6578 | 1343 return; |
7723 | 1344 case IMGFMT_YUY2: |
1345 asm volatile( | |
9417 | 1346 "movl %%esp, "ESP_OFFSET"(%5) \n\t" |
1347 "movl %4, %%esp \n\t" | |
1348 YSCALEYUV2PACKED1(%%eax, %5) | |
1349 WRITEYUY2(%%esp, 8280(%5), %%eax) | |
1350 "movl "ESP_OFFSET"(%5), %%esp \n\t" | |
1351 | |
1352 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "m" (dest), | |
1353 "r" (&c->redDither) | |
7723 | 1354 : "%eax" |
1355 ); | |
1356 return; | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1357 } |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1358 } |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1359 else |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1360 { |
6578 | 1361 switch(dstFormat) |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1362 { |
6578 | 1363 case IMGFMT_BGR32: |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1364 asm volatile( |
9417 | 1365 "movl %%esp, "ESP_OFFSET"(%5) \n\t" |
1366 "movl %4, %%esp \n\t" | |
1367 YSCALEYUV2RGB1b(%%eax, %5) | |
1368 WRITEBGR32(%%esp, 8280(%5), %%eax) | |
1369 "movl "ESP_OFFSET"(%5), %%esp \n\t" | |
1370 | |
1371 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "m" (dest), | |
1372 "r" (&c->redDither) | |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1373 : "%eax" |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1374 ); |
6578 | 1375 return; |
1376 case IMGFMT_BGR24: | |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1377 asm volatile( |
9417 | 1378 "movl %%esp, "ESP_OFFSET"(%5) \n\t" |
1379 "movl %4, %%esp \n\t" | |
1380 YSCALEYUV2RGB1b(%%eax, %5) | |
1381 WRITEBGR24(%%esp, 8280(%5), %%eax) | |
1382 "movl "ESP_OFFSET"(%5), %%esp \n\t" | |
1383 | |
1384 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "m" (dest), | |
1385 "r" (&c->redDither) | |
1386 : "%eax" | |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1387 ); |
6578 | 1388 return; |
1389 case IMGFMT_BGR15: | |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1390 asm volatile( |
9417 | 1391 "movl %%esp, "ESP_OFFSET"(%5) \n\t" |
1392 "movl %4, %%esp \n\t" | |
1393 YSCALEYUV2RGB1b(%%eax, %5) | |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1394 /* 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
|
1395 #ifdef DITHER1XBPP |
4248 | 1396 "paddusb "MANGLE(b5Dither)", %%mm2\n\t" |
1397 "paddusb "MANGLE(g5Dither)", %%mm4\n\t" | |
1398 "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
|
1399 #endif |
9417 | 1400 WRITEBGR15(%%esp, 8280(%5), %%eax) |
1401 "movl "ESP_OFFSET"(%5), %%esp \n\t" | |
1402 | |
1403 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "m" (dest), | |
1404 "r" (&c->redDither) | |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1405 : "%eax" |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1406 ); |
6578 | 1407 return; |
1408 case IMGFMT_BGR16: | |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1409 asm volatile( |
9417 | 1410 "movl %%esp, "ESP_OFFSET"(%5) \n\t" |
1411 "movl %4, %%esp \n\t" | |
1412 YSCALEYUV2RGB1b(%%eax, %5) | |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1413 /* 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
|
1414 #ifdef DITHER1XBPP |
4248 | 1415 "paddusb "MANGLE(b5Dither)", %%mm2\n\t" |
1416 "paddusb "MANGLE(g6Dither)", %%mm4\n\t" | |
1417 "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
|
1418 #endif |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1419 |
9417 | 1420 WRITEBGR16(%%esp, 8280(%5), %%eax) |
1421 "movl "ESP_OFFSET"(%5), %%esp \n\t" | |
1422 | |
1423 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "m" (dest), | |
1424 "r" (&c->redDither) | |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1425 : "%eax" |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1426 ); |
6578 | 1427 return; |
7723 | 1428 case IMGFMT_YUY2: |
1429 asm volatile( | |
9417 | 1430 "movl %%esp, "ESP_OFFSET"(%5) \n\t" |
1431 "movl %4, %%esp \n\t" | |
1432 YSCALEYUV2PACKED1b(%%eax, %5) | |
1433 WRITEYUY2(%%esp, 8280(%5), %%eax) | |
1434 "movl "ESP_OFFSET"(%5), %%esp \n\t" | |
1435 | |
1436 :: "r" (buf0), "r" (buf1), "r" (uvbuf0), "r" (uvbuf1), "m" (dest), | |
1437 "r" (&c->redDither) | |
7723 | 1438 : "%eax" |
1439 ); | |
1440 return; | |
2569
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1441 } |
30b736e7feef
interpolate chrominance for every second line in the 1:1 vertical scale function
michael
parents:
2566
diff
changeset
|
1442 } |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1443 #endif |
6578 | 1444 if( uvalpha < 2048 ) |
1445 { | |
7723 | 1446 YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB1_C, YSCALE_YUV_2_PACKED1_C) |
6578 | 1447 }else{ |
7723 | 1448 YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB1B_C, YSCALE_YUV_2_PACKED1B_C) |
6578 | 1449 } |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1450 } |
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
1451 |
4481 | 1452 //FIXME yuy2* can read upto 7 samples to much |
1453 | |
4467 | 1454 static inline void RENAME(yuy2ToY)(uint8_t *dst, uint8_t *src, int width) |
1455 { | |
4481 | 1456 #ifdef HAVE_MMX |
1457 asm volatile( | |
1458 "movq "MANGLE(bm01010101)", %%mm2\n\t" | |
1459 "movl %0, %%eax \n\t" | |
1460 "1: \n\t" | |
1461 "movq (%1, %%eax,2), %%mm0 \n\t" | |
1462 "movq 8(%1, %%eax,2), %%mm1 \n\t" | |
1463 "pand %%mm2, %%mm0 \n\t" | |
1464 "pand %%mm2, %%mm1 \n\t" | |
1465 "packuswb %%mm1, %%mm0 \n\t" | |
1466 "movq %%mm0, (%2, %%eax) \n\t" | |
1467 "addl $8, %%eax \n\t" | |
1468 " js 1b \n\t" | |
1469 : : "g" (-width), "r" (src+width*2), "r" (dst+width) | |
1470 : "%eax" | |
1471 ); | |
4467 | 1472 #else |
1473 int i; | |
1474 for(i=0; i<width; i++) | |
1475 dst[i]= src[2*i]; | |
1476 #endif | |
1477 } | |
1478 | |
1479 static inline void RENAME(yuy2ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width) | |
1480 { | |
4481 | 1481 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) |
1482 asm volatile( | |
1483 "movq "MANGLE(bm01010101)", %%mm4\n\t" | |
1484 "movl %0, %%eax \n\t" | |
1485 "1: \n\t" | |
1486 "movq (%1, %%eax,4), %%mm0 \n\t" | |
1487 "movq 8(%1, %%eax,4), %%mm1 \n\t" | |
1488 "movq (%2, %%eax,4), %%mm2 \n\t" | |
1489 "movq 8(%2, %%eax,4), %%mm3 \n\t" | |
1490 PAVGB(%%mm2, %%mm0) | |
1491 PAVGB(%%mm3, %%mm1) | |
1492 "psrlw $8, %%mm0 \n\t" | |
1493 "psrlw $8, %%mm1 \n\t" | |
1494 "packuswb %%mm1, %%mm0 \n\t" | |
1495 "movq %%mm0, %%mm1 \n\t" | |
1496 "psrlw $8, %%mm0 \n\t" | |
1497 "pand %%mm4, %%mm1 \n\t" | |
1498 "packuswb %%mm0, %%mm0 \n\t" | |
1499 "packuswb %%mm1, %%mm1 \n\t" | |
1500 "movd %%mm0, (%4, %%eax) \n\t" | |
1501 "movd %%mm1, (%3, %%eax) \n\t" | |
1502 "addl $4, %%eax \n\t" | |
1503 " js 1b \n\t" | |
1504 : : "g" (-width), "r" (src1+width*4), "r" (src2+width*4), "r" (dstU+width), "r" (dstV+width) | |
1505 : "%eax" | |
1506 ); | |
4467 | 1507 #else |
1508 int i; | |
1509 for(i=0; i<width; i++) | |
1510 { | |
1511 dstU[i]= (src1[4*i + 1] + src2[4*i + 1])>>1; | |
1512 dstV[i]= (src1[4*i + 3] + src2[4*i + 3])>>1; | |
1513 } | |
1514 #endif | |
1515 } | |
1516 | |
9071 | 1517 //this is allmost identical to the previous, end exists only cuz yuy2ToY/UV)(dst, src+1, ...) would have 100% unaligned accesses |
1518 static inline void RENAME(uyvyToY)(uint8_t *dst, uint8_t *src, int width) | |
1519 { | |
1520 #ifdef HAVE_MMX | |
1521 asm volatile( | |
1522 "movl %0, %%eax \n\t" | |
1523 "1: \n\t" | |
1524 "movq (%1, %%eax,2), %%mm0 \n\t" | |
1525 "movq 8(%1, %%eax,2), %%mm1 \n\t" | |
1526 "psrlw $8, %%mm0 \n\t" | |
1527 "psrlw $8, %%mm1 \n\t" | |
1528 "packuswb %%mm1, %%mm0 \n\t" | |
1529 "movq %%mm0, (%2, %%eax) \n\t" | |
1530 "addl $8, %%eax \n\t" | |
1531 " js 1b \n\t" | |
1532 : : "g" (-width), "r" (src+width*2), "r" (dst+width) | |
1533 : "%eax" | |
1534 ); | |
1535 #else | |
1536 int i; | |
1537 for(i=0; i<width; i++) | |
1538 dst[i]= src[2*i+1]; | |
1539 #endif | |
1540 } | |
1541 | |
1542 static inline void RENAME(uyvyToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width) | |
1543 { | |
1544 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) | |
1545 asm volatile( | |
1546 "movq "MANGLE(bm01010101)", %%mm4\n\t" | |
1547 "movl %0, %%eax \n\t" | |
1548 "1: \n\t" | |
1549 "movq (%1, %%eax,4), %%mm0 \n\t" | |
1550 "movq 8(%1, %%eax,4), %%mm1 \n\t" | |
1551 "movq (%2, %%eax,4), %%mm2 \n\t" | |
1552 "movq 8(%2, %%eax,4), %%mm3 \n\t" | |
1553 PAVGB(%%mm2, %%mm0) | |
1554 PAVGB(%%mm3, %%mm1) | |
1555 "pand %%mm4, %%mm0 \n\t" | |
1556 "pand %%mm4, %%mm1 \n\t" | |
1557 "packuswb %%mm1, %%mm0 \n\t" | |
1558 "movq %%mm0, %%mm1 \n\t" | |
1559 "psrlw $8, %%mm0 \n\t" | |
1560 "pand %%mm4, %%mm1 \n\t" | |
1561 "packuswb %%mm0, %%mm0 \n\t" | |
1562 "packuswb %%mm1, %%mm1 \n\t" | |
1563 "movd %%mm0, (%4, %%eax) \n\t" | |
1564 "movd %%mm1, (%3, %%eax) \n\t" | |
1565 "addl $4, %%eax \n\t" | |
1566 " js 1b \n\t" | |
1567 : : "g" (-width), "r" (src1+width*4), "r" (src2+width*4), "r" (dstU+width), "r" (dstV+width) | |
1568 : "%eax" | |
1569 ); | |
1570 #else | |
1571 int i; | |
1572 for(i=0; i<width; i++) | |
1573 { | |
1574 dstU[i]= (src1[4*i + 0] + src2[4*i + 0])>>1; | |
1575 dstV[i]= (src1[4*i + 2] + src2[4*i + 2])>>1; | |
1576 } | |
1577 #endif | |
1578 } | |
1579 | |
4467 | 1580 static inline void RENAME(bgr32ToY)(uint8_t *dst, uint8_t *src, int width) |
1581 { | |
1582 #ifdef HAVE_MMXFIXME | |
1583 #else | |
1584 int i; | |
1585 for(i=0; i<width; i++) | |
1586 { | |
9433 | 1587 int b= ((uint32_t*)src)[i]&0xFF; |
1588 int g= (((uint32_t*)src)[i]>>8)&0xFF; | |
1589 int r= ((uint32_t*)src)[i]>>16; | |
4467 | 1590 |
9433 | 1591 dst[i]= ((RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1)) )>>RGB2YUV_SHIFT); |
4467 | 1592 } |
1593 #endif | |
1594 } | |
1595 | |
1596 static inline void RENAME(bgr32ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width) | |
1597 { | |
1598 #ifdef HAVE_MMXFIXME | |
1599 #else | |
1600 int i; | |
1601 for(i=0; i<width; i++) | |
1602 { | |
9433 | 1603 const int a= ((uint32_t*)src1)[2*i+0]; |
1604 const int e= ((uint32_t*)src1)[2*i+1]; | |
1605 const int c= ((uint32_t*)src2)[2*i+0]; | |
1606 const int d= ((uint32_t*)src2)[2*i+1]; | |
1607 const int l= (a&0xFF00FF) + (e&0xFF00FF) + (c&0xFF00FF) + (d&0xFF00FF); | |
1608 const int h= (a&0x00FF00) + (e&0x00FF00) + (c&0x00FF00) + (d&0x00FF00); | |
1609 const int b= l&0x3FF; | |
1610 const int g= h>>8; | |
1611 const int r= l>>16; | |
4467 | 1612 |
1613 dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+2)) + 128; | |
1614 dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+2)) + 128; | |
1615 } | |
1616 #endif | |
1617 } | |
1618 | |
1619 static inline void RENAME(bgr24ToY)(uint8_t *dst, uint8_t *src, int width) | |
1620 { | |
4612 | 1621 #ifdef HAVE_MMX |
1622 asm volatile( | |
1623 "movl %2, %%eax \n\t" | |
4923 | 1624 "movq "MANGLE(bgr2YCoeff)", %%mm6 \n\t" |
1625 "movq "MANGLE(w1111)", %%mm5 \n\t" | |
4612 | 1626 "pxor %%mm7, %%mm7 \n\t" |
1627 "leal (%%eax, %%eax, 2), %%ebx \n\t" | |
1628 ".balign 16 \n\t" | |
1629 "1: \n\t" | |
1630 PREFETCH" 64(%0, %%ebx) \n\t" | |
1631 "movd (%0, %%ebx), %%mm0 \n\t" | |
1632 "movd 3(%0, %%ebx), %%mm1 \n\t" | |
1633 "punpcklbw %%mm7, %%mm0 \n\t" | |
1634 "punpcklbw %%mm7, %%mm1 \n\t" | |
1635 "movd 6(%0, %%ebx), %%mm2 \n\t" | |
1636 "movd 9(%0, %%ebx), %%mm3 \n\t" | |
1637 "punpcklbw %%mm7, %%mm2 \n\t" | |
1638 "punpcklbw %%mm7, %%mm3 \n\t" | |
1639 "pmaddwd %%mm6, %%mm0 \n\t" | |
1640 "pmaddwd %%mm6, %%mm1 \n\t" | |
1641 "pmaddwd %%mm6, %%mm2 \n\t" | |
1642 "pmaddwd %%mm6, %%mm3 \n\t" | |
1643 #ifndef FAST_BGR2YV12 | |
1644 "psrad $8, %%mm0 \n\t" | |
1645 "psrad $8, %%mm1 \n\t" | |
1646 "psrad $8, %%mm2 \n\t" | |
1647 "psrad $8, %%mm3 \n\t" | |
1648 #endif | |
1649 "packssdw %%mm1, %%mm0 \n\t" | |
1650 "packssdw %%mm3, %%mm2 \n\t" | |
1651 "pmaddwd %%mm5, %%mm0 \n\t" | |
1652 "pmaddwd %%mm5, %%mm2 \n\t" | |
1653 "packssdw %%mm2, %%mm0 \n\t" | |
1654 "psraw $7, %%mm0 \n\t" | |
1655 | |
1656 "movd 12(%0, %%ebx), %%mm4 \n\t" | |
1657 "movd 15(%0, %%ebx), %%mm1 \n\t" | |
1658 "punpcklbw %%mm7, %%mm4 \n\t" | |
1659 "punpcklbw %%mm7, %%mm1 \n\t" | |
1660 "movd 18(%0, %%ebx), %%mm2 \n\t" | |
1661 "movd 21(%0, %%ebx), %%mm3 \n\t" | |
1662 "punpcklbw %%mm7, %%mm2 \n\t" | |
1663 "punpcklbw %%mm7, %%mm3 \n\t" | |
1664 "pmaddwd %%mm6, %%mm4 \n\t" | |
1665 "pmaddwd %%mm6, %%mm1 \n\t" | |
1666 "pmaddwd %%mm6, %%mm2 \n\t" | |
1667 "pmaddwd %%mm6, %%mm3 \n\t" | |
1668 #ifndef FAST_BGR2YV12 | |
1669 "psrad $8, %%mm4 \n\t" | |
1670 "psrad $8, %%mm1 \n\t" | |
1671 "psrad $8, %%mm2 \n\t" | |
1672 "psrad $8, %%mm3 \n\t" | |
1673 #endif | |
1674 "packssdw %%mm1, %%mm4 \n\t" | |
1675 "packssdw %%mm3, %%mm2 \n\t" | |
1676 "pmaddwd %%mm5, %%mm4 \n\t" | |
1677 "pmaddwd %%mm5, %%mm2 \n\t" | |
1678 "addl $24, %%ebx \n\t" | |
1679 "packssdw %%mm2, %%mm4 \n\t" | |
1680 "psraw $7, %%mm4 \n\t" | |
1681 | |
1682 "packuswb %%mm4, %%mm0 \n\t" | |
4923 | 1683 "paddusb "MANGLE(bgr2YOffset)", %%mm0 \n\t" |
4612 | 1684 |
4619 | 1685 "movq %%mm0, (%1, %%eax) \n\t" |
4612 | 1686 "addl $8, %%eax \n\t" |
1687 " js 1b \n\t" | |
1688 : : "r" (src+width*3), "r" (dst+width), "g" (-width) | |
1689 : "%eax", "%ebx" | |
1690 ); | |
4467 | 1691 #else |
1692 int i; | |
1693 for(i=0; i<width; i++) | |
1694 { | |
1695 int b= src[i*3+0]; | |
1696 int g= src[i*3+1]; | |
1697 int r= src[i*3+2]; | |
1698 | |
9434 | 1699 dst[i]= ((RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1)) )>>RGB2YUV_SHIFT); |
4467 | 1700 } |
1701 #endif | |
1702 } | |
1703 | |
1704 static inline void RENAME(bgr24ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width) | |
1705 { | |
4619 | 1706 #ifdef HAVE_MMX |
1707 asm volatile( | |
1708 "movl %4, %%eax \n\t" | |
4923 | 1709 "movq "MANGLE(w1111)", %%mm5 \n\t" |
1710 "movq "MANGLE(bgr2UCoeff)", %%mm6 \n\t" | |
4619 | 1711 "pxor %%mm7, %%mm7 \n\t" |
1712 "leal (%%eax, %%eax, 2), %%ebx \n\t" | |
1713 "addl %%ebx, %%ebx \n\t" | |
1714 ".balign 16 \n\t" | |
1715 "1: \n\t" | |
1716 PREFETCH" 64(%0, %%ebx) \n\t" | |
1717 PREFETCH" 64(%1, %%ebx) \n\t" | |
1718 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) | |
1719 "movq (%0, %%ebx), %%mm0 \n\t" | |
1720 "movq (%1, %%ebx), %%mm1 \n\t" | |
1721 "movq 6(%0, %%ebx), %%mm2 \n\t" | |
1722 "movq 6(%1, %%ebx), %%mm3 \n\t" | |
1723 PAVGB(%%mm1, %%mm0) | |
1724 PAVGB(%%mm3, %%mm2) | |
1725 "movq %%mm0, %%mm1 \n\t" | |
1726 "movq %%mm2, %%mm3 \n\t" | |
1727 "psrlq $24, %%mm0 \n\t" | |
1728 "psrlq $24, %%mm2 \n\t" | |
1729 PAVGB(%%mm1, %%mm0) | |
1730 PAVGB(%%mm3, %%mm2) | |
1731 "punpcklbw %%mm7, %%mm0 \n\t" | |
1732 "punpcklbw %%mm7, %%mm2 \n\t" | |
1733 #else | |
1734 "movd (%0, %%ebx), %%mm0 \n\t" | |
1735 "movd (%1, %%ebx), %%mm1 \n\t" | |
1736 "movd 3(%0, %%ebx), %%mm2 \n\t" | |
1737 "movd 3(%1, %%ebx), %%mm3 \n\t" | |
1738 "punpcklbw %%mm7, %%mm0 \n\t" | |
1739 "punpcklbw %%mm7, %%mm1 \n\t" | |
1740 "punpcklbw %%mm7, %%mm2 \n\t" | |
1741 "punpcklbw %%mm7, %%mm3 \n\t" | |
1742 "paddw %%mm1, %%mm0 \n\t" | |
1743 "paddw %%mm3, %%mm2 \n\t" | |
1744 "paddw %%mm2, %%mm0 \n\t" | |
1745 "movd 6(%0, %%ebx), %%mm4 \n\t" | |
1746 "movd 6(%1, %%ebx), %%mm1 \n\t" | |
1747 "movd 9(%0, %%ebx), %%mm2 \n\t" | |
1748 "movd 9(%1, %%ebx), %%mm3 \n\t" | |
1749 "punpcklbw %%mm7, %%mm4 \n\t" | |
1750 "punpcklbw %%mm7, %%mm1 \n\t" | |
1751 "punpcklbw %%mm7, %%mm2 \n\t" | |
1752 "punpcklbw %%mm7, %%mm3 \n\t" | |
1753 "paddw %%mm1, %%mm4 \n\t" | |
1754 "paddw %%mm3, %%mm2 \n\t" | |
1755 "paddw %%mm4, %%mm2 \n\t" | |
1756 "psrlw $2, %%mm0 \n\t" | |
1757 "psrlw $2, %%mm2 \n\t" | |
1758 #endif | |
4923 | 1759 "movq "MANGLE(bgr2VCoeff)", %%mm1 \n\t" |
1760 "movq "MANGLE(bgr2VCoeff)", %%mm3 \n\t" | |
4619 | 1761 |
1762 "pmaddwd %%mm0, %%mm1 \n\t" | |
1763 "pmaddwd %%mm2, %%mm3 \n\t" | |
1764 "pmaddwd %%mm6, %%mm0 \n\t" | |
1765 "pmaddwd %%mm6, %%mm2 \n\t" | |
1766 #ifndef FAST_BGR2YV12 | |
1767 "psrad $8, %%mm0 \n\t" | |
1768 "psrad $8, %%mm1 \n\t" | |
1769 "psrad $8, %%mm2 \n\t" | |
1770 "psrad $8, %%mm3 \n\t" | |
1771 #endif | |
1772 "packssdw %%mm2, %%mm0 \n\t" | |
1773 "packssdw %%mm3, %%mm1 \n\t" | |
1774 "pmaddwd %%mm5, %%mm0 \n\t" | |
1775 "pmaddwd %%mm5, %%mm1 \n\t" | |
1776 "packssdw %%mm1, %%mm0 \n\t" // V1 V0 U1 U0 | |
1777 "psraw $7, %%mm0 \n\t" | |
1778 | |
1779 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) | |
1780 "movq 12(%0, %%ebx), %%mm4 \n\t" | |
1781 "movq 12(%1, %%ebx), %%mm1 \n\t" | |
1782 "movq 18(%0, %%ebx), %%mm2 \n\t" | |
1783 "movq 18(%1, %%ebx), %%mm3 \n\t" | |
1784 PAVGB(%%mm1, %%mm4) | |
1785 PAVGB(%%mm3, %%mm2) | |
1786 "movq %%mm4, %%mm1 \n\t" | |
1787 "movq %%mm2, %%mm3 \n\t" | |
1788 "psrlq $24, %%mm4 \n\t" | |
1789 "psrlq $24, %%mm2 \n\t" | |
1790 PAVGB(%%mm1, %%mm4) | |
1791 PAVGB(%%mm3, %%mm2) | |
1792 "punpcklbw %%mm7, %%mm4 \n\t" | |
1793 "punpcklbw %%mm7, %%mm2 \n\t" | |
1794 #else | |
1795 "movd 12(%0, %%ebx), %%mm4 \n\t" | |
1796 "movd 12(%1, %%ebx), %%mm1 \n\t" | |
1797 "movd 15(%0, %%ebx), %%mm2 \n\t" | |
1798 "movd 15(%1, %%ebx), %%mm3 \n\t" | |
1799 "punpcklbw %%mm7, %%mm4 \n\t" | |
1800 "punpcklbw %%mm7, %%mm1 \n\t" | |
1801 "punpcklbw %%mm7, %%mm2 \n\t" | |
1802 "punpcklbw %%mm7, %%mm3 \n\t" | |
1803 "paddw %%mm1, %%mm4 \n\t" | |
1804 "paddw %%mm3, %%mm2 \n\t" | |
1805 "paddw %%mm2, %%mm4 \n\t" | |
1806 "movd 18(%0, %%ebx), %%mm5 \n\t" | |
1807 "movd 18(%1, %%ebx), %%mm1 \n\t" | |
1808 "movd 21(%0, %%ebx), %%mm2 \n\t" | |
1809 "movd 21(%1, %%ebx), %%mm3 \n\t" | |
1810 "punpcklbw %%mm7, %%mm5 \n\t" | |
1811 "punpcklbw %%mm7, %%mm1 \n\t" | |
1812 "punpcklbw %%mm7, %%mm2 \n\t" | |
1813 "punpcklbw %%mm7, %%mm3 \n\t" | |
1814 "paddw %%mm1, %%mm5 \n\t" | |
1815 "paddw %%mm3, %%mm2 \n\t" | |
1816 "paddw %%mm5, %%mm2 \n\t" | |
4923 | 1817 "movq "MANGLE(w1111)", %%mm5 \n\t" |
4619 | 1818 "psrlw $2, %%mm4 \n\t" |
1819 "psrlw $2, %%mm2 \n\t" | |
1820 #endif | |
4923 | 1821 "movq "MANGLE(bgr2VCoeff)", %%mm1 \n\t" |
1822 "movq "MANGLE(bgr2VCoeff)", %%mm3 \n\t" | |
4619 | 1823 |
1824 "pmaddwd %%mm4, %%mm1 \n\t" | |
1825 "pmaddwd %%mm2, %%mm3 \n\t" | |
1826 "pmaddwd %%mm6, %%mm4 \n\t" | |
1827 "pmaddwd %%mm6, %%mm2 \n\t" | |
1828 #ifndef FAST_BGR2YV12 | |
1829 "psrad $8, %%mm4 \n\t" | |
1830 "psrad $8, %%mm1 \n\t" | |
1831 "psrad $8, %%mm2 \n\t" | |
1832 "psrad $8, %%mm3 \n\t" | |
1833 #endif | |
1834 "packssdw %%mm2, %%mm4 \n\t" | |
1835 "packssdw %%mm3, %%mm1 \n\t" | |
1836 "pmaddwd %%mm5, %%mm4 \n\t" | |
1837 "pmaddwd %%mm5, %%mm1 \n\t" | |
1838 "addl $24, %%ebx \n\t" | |
1839 "packssdw %%mm1, %%mm4 \n\t" // V3 V2 U3 U2 | |
1840 "psraw $7, %%mm4 \n\t" | |
1841 | |
1842 "movq %%mm0, %%mm1 \n\t" | |
1843 "punpckldq %%mm4, %%mm0 \n\t" | |
1844 "punpckhdq %%mm4, %%mm1 \n\t" | |
1845 "packsswb %%mm1, %%mm0 \n\t" | |
4923 | 1846 "paddb "MANGLE(bgr2UVOffset)", %%mm0 \n\t" |
4619 | 1847 |
1848 "movd %%mm0, (%2, %%eax) \n\t" | |
1849 "punpckhdq %%mm0, %%mm0 \n\t" | |
1850 "movd %%mm0, (%3, %%eax) \n\t" | |
1851 "addl $4, %%eax \n\t" | |
1852 " js 1b \n\t" | |
1853 : : "r" (src1+width*6), "r" (src2+width*6), "r" (dstU+width), "r" (dstV+width), "g" (-width) | |
1854 : "%eax", "%ebx" | |
1855 ); | |
4467 | 1856 #else |
1857 int i; | |
1858 for(i=0; i<width; i++) | |
1859 { | |
1860 int b= src1[6*i + 0] + src1[6*i + 3] + src2[6*i + 0] + src2[6*i + 3]; | |
1861 int g= src1[6*i + 1] + src1[6*i + 4] + src2[6*i + 1] + src2[6*i + 4]; | |
1862 int r= src1[6*i + 2] + src1[6*i + 5] + src2[6*i + 2] + src2[6*i + 5]; | |
1863 | |
1864 dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+2)) + 128; | |
1865 dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+2)) + 128; | |
1866 } | |
1867 #endif | |
1868 } | |
1869 | |
4578 | 1870 static inline void RENAME(bgr16ToY)(uint8_t *dst, uint8_t *src, int width) |
1871 { | |
1872 int i; | |
1873 for(i=0; i<width; i++) | |
1874 { | |
9433 | 1875 int d= ((uint16_t*)src)[i]; |
4578 | 1876 int b= d&0x1F; |
1877 int g= (d>>5)&0x3F; | |
1878 int r= (d>>11)&0x1F; | |
1879 | |
1880 dst[i]= ((2*RY*r + GY*g + 2*BY*b)>>(RGB2YUV_SHIFT-2)) + 16; | |
1881 } | |
1882 } | |
1883 | |
1884 static inline void RENAME(bgr16ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width) | |
1885 { | |
1886 int i; | |
1887 for(i=0; i<width; i++) | |
1888 { | |
9433 | 1889 int d0= ((uint32_t*)src1)[i]; |
1890 int d1= ((uint32_t*)src2)[i]; | |
4579 | 1891 |
1892 int dl= (d0&0x07E0F81F) + (d1&0x07E0F81F); | |
1893 int dh= ((d0>>5)&0x07C0F83F) + ((d1>>5)&0x07C0F83F); | |
1894 | |
1895 int dh2= (dh>>11) + (dh<<21); | |
1896 int d= dh2 + dl; | |
1897 | |
1898 int b= d&0x7F; | |
1899 int r= (d>>11)&0x7F; | |
1900 int g= d>>21; | |
4578 | 1901 dstU[i]= ((2*RU*r + GU*g + 2*BU*b)>>(RGB2YUV_SHIFT+2-2)) + 128; |
1902 dstV[i]= ((2*RV*r + GV*g + 2*BV*b)>>(RGB2YUV_SHIFT+2-2)) + 128; | |
1903 } | |
1904 } | |
1905 | |
4580 | 1906 static inline void RENAME(bgr15ToY)(uint8_t *dst, uint8_t *src, int width) |
1907 { | |
1908 int i; | |
1909 for(i=0; i<width; i++) | |
1910 { | |
9433 | 1911 int d= ((uint16_t*)src)[i]; |
4580 | 1912 int b= d&0x1F; |
1913 int g= (d>>5)&0x1F; | |
1914 int r= (d>>10)&0x1F; | |
1915 | |
1916 dst[i]= ((RY*r + GY*g + BY*b)>>(RGB2YUV_SHIFT-3)) + 16; | |
1917 } | |
1918 } | |
1919 | |
1920 static inline void RENAME(bgr15ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width) | |
1921 { | |
1922 int i; | |
1923 for(i=0; i<width; i++) | |
1924 { | |
9433 | 1925 int d0= ((uint32_t*)src1)[i]; |
1926 int d1= ((uint32_t*)src2)[i]; | |
4580 | 1927 |
1928 int dl= (d0&0x03E07C1F) + (d1&0x03E07C1F); | |
1929 int dh= ((d0>>5)&0x03E0F81F) + ((d1>>5)&0x03E0F81F); | |
1930 | |
1931 int dh2= (dh>>11) + (dh<<21); | |
1932 int d= dh2 + dl; | |
1933 | |
1934 int b= d&0x7F; | |
1935 int r= (d>>10)&0x7F; | |
1936 int g= d>>21; | |
1937 dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+2-3)) + 128; | |
1938 dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+2-3)) + 128; | |
1939 } | |
1940 } | |
1941 | |
1942 | |
4558 | 1943 static inline void RENAME(rgb32ToY)(uint8_t *dst, uint8_t *src, int width) |
1944 { | |
1945 int i; | |
1946 for(i=0; i<width; i++) | |
1947 { | |
9433 | 1948 int r= ((uint32_t*)src)[i]&0xFF; |
1949 int g= (((uint32_t*)src)[i]>>8)&0xFF; | |
1950 int b= ((uint32_t*)src)[i]>>16; | |
4558 | 1951 |
9433 | 1952 dst[i]= ((RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1)) )>>RGB2YUV_SHIFT); |
4558 | 1953 } |
1954 } | |
1955 | |
1956 static inline void RENAME(rgb32ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width) | |
1957 { | |
1958 int i; | |
1959 for(i=0; i<width; i++) | |
1960 { | |
9433 | 1961 const int a= ((uint32_t*)src1)[2*i+0]; |
1962 const int e= ((uint32_t*)src1)[2*i+1]; | |
1963 const int c= ((uint32_t*)src2)[2*i+0]; | |
1964 const int d= ((uint32_t*)src2)[2*i+1]; | |
1965 const int l= (a&0xFF00FF) + (e&0xFF00FF) + (c&0xFF00FF) + (d&0xFF00FF); | |
1966 const int h= (a&0x00FF00) + (e&0x00FF00) + (c&0x00FF00) + (d&0x00FF00); | |
1967 const int r= l&0x3FF; | |
1968 const int g= h>>8; | |
1969 const int b= l>>16; | |
4558 | 1970 |
1971 dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+2)) + 128; | |
1972 dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+2)) + 128; | |
1973 } | |
1974 } | |
1975 | |
1976 static inline void RENAME(rgb24ToY)(uint8_t *dst, uint8_t *src, int width) | |
1977 { | |
1978 int i; | |
1979 for(i=0; i<width; i++) | |
1980 { | |
1981 int r= src[i*3+0]; | |
1982 int g= src[i*3+1]; | |
1983 int b= src[i*3+2]; | |
1984 | |
9433 | 1985 dst[i]= ((RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1)) )>>RGB2YUV_SHIFT); |
4558 | 1986 } |
1987 } | |
1988 | |
1989 static inline void RENAME(rgb24ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width) | |
1990 { | |
1991 int i; | |
1992 for(i=0; i<width; i++) | |
1993 { | |
1994 int r= src1[6*i + 0] + src1[6*i + 3] + src2[6*i + 0] + src2[6*i + 3]; | |
1995 int g= src1[6*i + 1] + src1[6*i + 4] + src2[6*i + 1] + src2[6*i + 4]; | |
1996 int b= src1[6*i + 2] + src1[6*i + 5] + src2[6*i + 2] + src2[6*i + 5]; | |
1997 | |
1998 dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+2)) + 128; | |
1999 dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+2)) + 128; | |
2000 } | |
2001 } | |
2002 | |
4467 | 2003 |
3272 | 2004 // Bilinear / Bicubic scaling |
2005 static inline void RENAME(hScale)(int16_t *dst, int dstW, uint8_t *src, int srcW, int xInc, | |
2006 int16_t *filter, int16_t *filterPos, int filterSize) | |
2007 { | |
2008 #ifdef HAVE_MMX | |
2009 if(filterSize==4) // allways true for upscaling, sometimes for down too | |
2010 { | |
2011 int counter= -2*dstW; | |
2012 filter-= counter*2; | |
2013 filterPos-= counter/2; | |
2014 dst-= counter/2; | |
2015 asm volatile( | |
2016 "pxor %%mm7, %%mm7 \n\t" | |
4248 | 2017 "movq "MANGLE(w02)", %%mm6 \n\t" |
3272 | 2018 "pushl %%ebp \n\t" // we use 7 regs here ... |
2019 "movl %%eax, %%ebp \n\t" | |
2020 ".balign 16 \n\t" | |
2021 "1: \n\t" | |
2022 "movzwl (%2, %%ebp), %%eax \n\t" | |
2023 "movzwl 2(%2, %%ebp), %%ebx \n\t" | |
2024 "movq (%1, %%ebp, 4), %%mm1 \n\t" | |
2025 "movq 8(%1, %%ebp, 4), %%mm3 \n\t" | |
2026 "movd (%3, %%eax), %%mm0 \n\t" | |
2027 "movd (%3, %%ebx), %%mm2 \n\t" | |
2028 "punpcklbw %%mm7, %%mm0 \n\t" | |
2029 "punpcklbw %%mm7, %%mm2 \n\t" | |
2030 "pmaddwd %%mm1, %%mm0 \n\t" | |
2031 "pmaddwd %%mm2, %%mm3 \n\t" | |
2032 "psrad $8, %%mm0 \n\t" | |
2033 "psrad $8, %%mm3 \n\t" | |
2034 "packssdw %%mm3, %%mm0 \n\t" | |
2035 "pmaddwd %%mm6, %%mm0 \n\t" | |
2036 "packssdw %%mm0, %%mm0 \n\t" | |
2037 "movd %%mm0, (%4, %%ebp) \n\t" | |
2038 "addl $4, %%ebp \n\t" | |
2039 " jnc 1b \n\t" | |
3352 | 2040 |
3272 | 2041 "popl %%ebp \n\t" |
2042 : "+a" (counter) | |
2043 : "c" (filter), "d" (filterPos), "S" (src), "D" (dst) | |
2044 : "%ebx" | |
2045 ); | |
2046 } | |
2047 else if(filterSize==8) | |
2048 { | |
2049 int counter= -2*dstW; | |
2050 filter-= counter*4; | |
2051 filterPos-= counter/2; | |
2052 dst-= counter/2; | |
2053 asm volatile( | |
2054 "pxor %%mm7, %%mm7 \n\t" | |
4248 | 2055 "movq "MANGLE(w02)", %%mm6 \n\t" |
3272 | 2056 "pushl %%ebp \n\t" // we use 7 regs here ... |
2057 "movl %%eax, %%ebp \n\t" | |
2058 ".balign 16 \n\t" | |
2059 "1: \n\t" | |
2060 "movzwl (%2, %%ebp), %%eax \n\t" | |
2061 "movzwl 2(%2, %%ebp), %%ebx \n\t" | |
2062 "movq (%1, %%ebp, 8), %%mm1 \n\t" | |
2063 "movq 16(%1, %%ebp, 8), %%mm3 \n\t" | |
2064 "movd (%3, %%eax), %%mm0 \n\t" | |
2065 "movd (%3, %%ebx), %%mm2 \n\t" | |
2066 "punpcklbw %%mm7, %%mm0 \n\t" | |
2067 "punpcklbw %%mm7, %%mm2 \n\t" | |
2068 "pmaddwd %%mm1, %%mm0 \n\t" | |
2069 "pmaddwd %%mm2, %%mm3 \n\t" | |
2316
bcb229557e9b
fixed alignment (static variables where sometimes not 8-byte aligned)
michael
parents:
2297
diff
changeset
|
2070 |
3272 | 2071 "movq 8(%1, %%ebp, 8), %%mm1 \n\t" |
2072 "movq 24(%1, %%ebp, 8), %%mm5 \n\t" | |
2073 "movd 4(%3, %%eax), %%mm4 \n\t" | |
2074 "movd 4(%3, %%ebx), %%mm2 \n\t" | |
2075 "punpcklbw %%mm7, %%mm4 \n\t" | |
2076 "punpcklbw %%mm7, %%mm2 \n\t" | |
2077 "pmaddwd %%mm1, %%mm4 \n\t" | |
2078 "pmaddwd %%mm2, %%mm5 \n\t" | |
2079 "paddd %%mm4, %%mm0 \n\t" | |
2080 "paddd %%mm5, %%mm3 \n\t" | |
2081 | |
2082 "psrad $8, %%mm0 \n\t" | |
2083 "psrad $8, %%mm3 \n\t" | |
2084 "packssdw %%mm3, %%mm0 \n\t" | |
2085 "pmaddwd %%mm6, %%mm0 \n\t" | |
2086 "packssdw %%mm0, %%mm0 \n\t" | |
2087 "movd %%mm0, (%4, %%ebp) \n\t" | |
2088 "addl $4, %%ebp \n\t" | |
2089 " jnc 1b \n\t" | |
3344 | 2090 |
3272 | 2091 "popl %%ebp \n\t" |
2092 : "+a" (counter) | |
2093 : "c" (filter), "d" (filterPos), "S" (src), "D" (dst) | |
2094 : "%ebx" | |
2095 ); | |
2096 } | |
2097 else | |
2098 { | |
2099 int counter= -2*dstW; | |
2100 // filter-= counter*filterSize/2; | |
2101 filterPos-= counter/2; | |
2102 dst-= counter/2; | |
2103 asm volatile( | |
2104 "pxor %%mm7, %%mm7 \n\t" | |
4248 | 2105 "movq "MANGLE(w02)", %%mm6 \n\t" |
3272 | 2106 ".balign 16 \n\t" |
2107 "1: \n\t" | |
2108 "movl %2, %%ecx \n\t" | |
2109 "movzwl (%%ecx, %0), %%eax \n\t" | |
2110 "movzwl 2(%%ecx, %0), %%ebx \n\t" | |
2111 "movl %5, %%ecx \n\t" | |
2112 "pxor %%mm4, %%mm4 \n\t" | |
2113 "pxor %%mm5, %%mm5 \n\t" | |
2114 "2: \n\t" | |
2115 "movq (%1), %%mm1 \n\t" | |
2116 "movq (%1, %6), %%mm3 \n\t" | |
2117 "movd (%%ecx, %%eax), %%mm0 \n\t" | |
2118 "movd (%%ecx, %%ebx), %%mm2 \n\t" | |
2119 "punpcklbw %%mm7, %%mm0 \n\t" | |
2120 "punpcklbw %%mm7, %%mm2 \n\t" | |
2121 "pmaddwd %%mm1, %%mm0 \n\t" | |
2122 "pmaddwd %%mm2, %%mm3 \n\t" | |
2123 "paddd %%mm3, %%mm5 \n\t" | |
2124 "paddd %%mm0, %%mm4 \n\t" | |
2125 "addl $8, %1 \n\t" | |
2126 "addl $4, %%ecx \n\t" | |
2127 "cmpl %4, %%ecx \n\t" | |
2128 " jb 2b \n\t" | |
2129 "addl %6, %1 \n\t" | |
2130 "psrad $8, %%mm4 \n\t" | |
2131 "psrad $8, %%mm5 \n\t" | |
2132 "packssdw %%mm5, %%mm4 \n\t" | |
2133 "pmaddwd %%mm6, %%mm4 \n\t" | |
2134 "packssdw %%mm4, %%mm4 \n\t" | |
2135 "movl %3, %%eax \n\t" | |
2136 "movd %%mm4, (%%eax, %0) \n\t" | |
2137 "addl $4, %0 \n\t" | |
2138 " jnc 1b \n\t" | |
3344 | 2139 |
3641 | 2140 : "+r" (counter), "+r" (filter) |
2141 : "m" (filterPos), "m" (dst), "m"(src+filterSize), | |
3272 | 2142 "m" (src), "r" (filterSize*2) |
3299 | 2143 : "%ebx", "%eax", "%ecx" |
3272 | 2144 ); |
2145 } | |
2146 #else | |
2147 int i; | |
2148 for(i=0; i<dstW; i++) | |
2149 { | |
2150 int j; | |
2151 int srcPos= filterPos[i]; | |
2152 int val=0; | |
3344 | 2153 // printf("filterPos: %d\n", filterPos[i]); |
3272 | 2154 for(j=0; j<filterSize; j++) |
2155 { | |
2156 // printf("filter: %d, src: %d\n", filter[i], src[srcPos + j]); | |
2157 val += ((int)src[srcPos + j])*filter[filterSize*i + j]; | |
2158 } | |
2159 // filter += hFilterSize; | |
2160 dst[i] = MIN(MAX(0, val>>7), (1<<15)-1); // the cubic equation does overflow ... | |
2161 // dst[i] = val>>7; | |
2162 } | |
2163 #endif | |
2164 } | |
2165 // *** horizontal scale Y line to temp buffer | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2166 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
|
2167 int flags, int canMMX2BeUsed, int16_t *hLumFilter, |
4467 | 2168 int16_t *hLumFilterPos, int hLumFilterSize, void *funnyYCode, |
5452 | 2169 int srcFormat, uint8_t *formatConvBuffer, int16_t *mmx2Filter, |
2170 int32_t *mmx2FilterPos) | |
2469 | 2171 { |
4467 | 2172 if(srcFormat==IMGFMT_YUY2) |
2173 { | |
2174 RENAME(yuy2ToY)(formatConvBuffer, src, srcW); | |
2175 src= formatConvBuffer; | |
2176 } | |
9071 | 2177 else if(srcFormat==IMGFMT_UYVY) |
2178 { | |
2179 RENAME(uyvyToY)(formatConvBuffer, src, srcW); | |
2180 src= formatConvBuffer; | |
2181 } | |
4467 | 2182 else if(srcFormat==IMGFMT_BGR32) |
2183 { | |
2184 RENAME(bgr32ToY)(formatConvBuffer, src, srcW); | |
2185 src= formatConvBuffer; | |
2186 } | |
2187 else if(srcFormat==IMGFMT_BGR24) | |
2188 { | |
2189 RENAME(bgr24ToY)(formatConvBuffer, src, srcW); | |
2190 src= formatConvBuffer; | |
2191 } | |
4578 | 2192 else if(srcFormat==IMGFMT_BGR16) |
2193 { | |
2194 RENAME(bgr16ToY)(formatConvBuffer, src, srcW); | |
2195 src= formatConvBuffer; | |
2196 } | |
4580 | 2197 else if(srcFormat==IMGFMT_BGR15) |
2198 { | |
2199 RENAME(bgr15ToY)(formatConvBuffer, src, srcW); | |
2200 src= formatConvBuffer; | |
2201 } | |
4558 | 2202 else if(srcFormat==IMGFMT_RGB32) |
2203 { | |
2204 RENAME(rgb32ToY)(formatConvBuffer, src, srcW); | |
2205 src= formatConvBuffer; | |
2206 } | |
2207 else if(srcFormat==IMGFMT_RGB24) | |
2208 { | |
2209 RENAME(rgb24ToY)(formatConvBuffer, src, srcW); | |
2210 src= formatConvBuffer; | |
2211 } | |
4467 | 2212 |
3352 | 2213 #ifdef HAVE_MMX |
2214 // 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
|
2215 if(!(flags&SWS_FAST_BILINEAR) || (!canMMX2BeUsed)) |
3352 | 2216 #else |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2217 if(!(flags&SWS_FAST_BILINEAR)) |
3352 | 2218 #endif |
3272 | 2219 { |
2220 RENAME(hScale)(dst, dstWidth, src, srcW, xInc, hLumFilter, hLumFilterPos, hLumFilterSize); | |
2221 } | |
2222 else // Fast Bilinear upscale / crap downscale | |
2223 { | |
2469 | 2224 #ifdef ARCH_X86 |
2225 #ifdef HAVE_MMX2 | |
2671 | 2226 int i; |
2469 | 2227 if(canMMX2BeUsed) |
2228 { | |
2229 asm volatile( | |
2230 "pxor %%mm7, %%mm7 \n\t" | |
5452 | 2231 "movl %0, %%ecx \n\t" |
2232 "movl %1, %%edi \n\t" | |
2233 "movl %2, %%edx \n\t" | |
2234 "movl %3, %%ebx \n\t" | |
2469 | 2235 "xorl %%eax, %%eax \n\t" // i |
5452 | 2236 PREFETCH" (%%ecx) \n\t" |
2237 PREFETCH" 32(%%ecx) \n\t" | |
2238 PREFETCH" 64(%%ecx) \n\t" | |
2520 | 2239 |
2469 | 2240 #define FUNNY_Y_CODE \ |
5452 | 2241 "movl (%%ebx), %%esi \n\t"\ |
2242 "call *%4 \n\t"\ | |
2243 "addl (%%ebx, %%eax), %%ecx \n\t"\ | |
2244 "addl %%eax, %%edi \n\t"\ | |
2245 "xorl %%eax, %%eax \n\t"\ | |
2520 | 2246 |
2469 | 2247 FUNNY_Y_CODE |
2248 FUNNY_Y_CODE | |
2249 FUNNY_Y_CODE | |
2250 FUNNY_Y_CODE | |
2251 FUNNY_Y_CODE | |
2252 FUNNY_Y_CODE | |
2253 FUNNY_Y_CODE | |
2254 FUNNY_Y_CODE | |
2255 | |
5452 | 2256 :: "m" (src), "m" (dst), "m" (mmx2Filter), "m" (mmx2FilterPos), |
2257 "m" (funnyYCode) | |
2469 | 2258 : "%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi" |
2259 ); | |
3215 | 2260 for(i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) dst[i] = src[srcW-1]*128; |
2469 | 2261 } |
2262 else | |
2263 { | |
2264 #endif | |
2265 //NO MMX just normal asm ... | |
2266 asm volatile( | |
2267 "xorl %%eax, %%eax \n\t" // i | |
2268 "xorl %%ebx, %%ebx \n\t" // xx | |
2269 "xorl %%ecx, %%ecx \n\t" // 2*xalpha | |
2800
7847d6b7ad3d
.balign or we¡ll align by 64kb on some architectures
michael
parents:
2799
diff
changeset
|
2270 ".balign 16 \n\t" |
2469 | 2271 "1: \n\t" |
2272 "movzbl (%0, %%ebx), %%edi \n\t" //src[xx] | |
2273 "movzbl 1(%0, %%ebx), %%esi \n\t" //src[xx+1] | |
2274 "subl %%edi, %%esi \n\t" //src[xx+1] - src[xx] | |
2275 "imull %%ecx, %%esi \n\t" //(src[xx+1] - src[xx])*2*xalpha | |
2276 "shll $16, %%edi \n\t" | |
2277 "addl %%edi, %%esi \n\t" //src[xx+1]*2*xalpha + src[xx]*(1-2*xalpha) | |
2278 "movl %1, %%edi \n\t" | |
2279 "shrl $9, %%esi \n\t" | |
2280 "movw %%si, (%%edi, %%eax, 2) \n\t" | |
2281 "addw %4, %%cx \n\t" //2*xalpha += xInc&0xFF | |
2282 "adcl %3, %%ebx \n\t" //xx+= xInc>>8 + carry | |
2283 | |
2284 "movzbl (%0, %%ebx), %%edi \n\t" //src[xx] | |
2285 "movzbl 1(%0, %%ebx), %%esi \n\t" //src[xx+1] | |
2286 "subl %%edi, %%esi \n\t" //src[xx+1] - src[xx] | |
2287 "imull %%ecx, %%esi \n\t" //(src[xx+1] - src[xx])*2*xalpha | |
2288 "shll $16, %%edi \n\t" | |
2289 "addl %%edi, %%esi \n\t" //src[xx+1]*2*xalpha + src[xx]*(1-2*xalpha) | |
2290 "movl %1, %%edi \n\t" | |
2291 "shrl $9, %%esi \n\t" | |
2292 "movw %%si, 2(%%edi, %%eax, 2) \n\t" | |
2293 "addw %4, %%cx \n\t" //2*xalpha += xInc&0xFF | |
2294 "adcl %3, %%ebx \n\t" //xx+= xInc>>8 + carry | |
2295 | |
2296 | |
2297 "addl $2, %%eax \n\t" | |
2298 "cmpl %2, %%eax \n\t" | |
2299 " jb 1b \n\t" | |
2300 | |
2301 | |
2302 :: "r" (src), "m" (dst), "m" (dstWidth), "m" (xInc>>16), "m" (xInc&0xFFFF) | |
2303 : "%eax", "%ebx", "%ecx", "%edi", "%esi" | |
2304 ); | |
2305 #ifdef HAVE_MMX2 | |
2306 } //if MMX2 cant be used | |
2307 #endif | |
2308 #else | |
2671 | 2309 int i; |
2310 unsigned int xpos=0; | |
2311 for(i=0;i<dstWidth;i++) | |
2312 { | |
2313 register unsigned int xx=xpos>>16; | |
2314 register unsigned int xalpha=(xpos&0xFFFF)>>9; | |
2315 dst[i]= (src[xx]<<7) + (src[xx+1] - src[xx])*xalpha; | |
2316 xpos+=xInc; | |
2317 } | |
2469 | 2318 #endif |
3272 | 2319 } |
2469 | 2320 } |
2321 | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2322 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
|
2323 int srcW, int xInc, int flags, int canMMX2BeUsed, int16_t *hChrFilter, |
4467 | 2324 int16_t *hChrFilterPos, int hChrFilterSize, void *funnyUVCode, |
5452 | 2325 int srcFormat, uint8_t *formatConvBuffer, int16_t *mmx2Filter, |
2326 int32_t *mmx2FilterPos) | |
2469 | 2327 { |
4467 | 2328 if(srcFormat==IMGFMT_YUY2) |
2329 { | |
2330 RENAME(yuy2ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); | |
2331 src1= formatConvBuffer; | |
2332 src2= formatConvBuffer+2048; | |
2333 } | |
9071 | 2334 else if(srcFormat==IMGFMT_UYVY) |
2335 { | |
2336 RENAME(uyvyToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); | |
2337 src1= formatConvBuffer; | |
2338 src2= formatConvBuffer+2048; | |
2339 } | |
4467 | 2340 else if(srcFormat==IMGFMT_BGR32) |
2341 { | |
2342 RENAME(bgr32ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); | |
2343 src1= formatConvBuffer; | |
2344 src2= formatConvBuffer+2048; | |
2345 } | |
2346 else if(srcFormat==IMGFMT_BGR24) | |
2347 { | |
2348 RENAME(bgr24ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); | |
2349 src1= formatConvBuffer; | |
2350 src2= formatConvBuffer+2048; | |
2351 } | |
4578 | 2352 else if(srcFormat==IMGFMT_BGR16) |
2353 { | |
2354 RENAME(bgr16ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); | |
2355 src1= formatConvBuffer; | |
2356 src2= formatConvBuffer+2048; | |
2357 } | |
4580 | 2358 else if(srcFormat==IMGFMT_BGR15) |
2359 { | |
2360 RENAME(bgr15ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); | |
2361 src1= formatConvBuffer; | |
2362 src2= formatConvBuffer+2048; | |
2363 } | |
4558 | 2364 else if(srcFormat==IMGFMT_RGB32) |
2365 { | |
2366 RENAME(rgb32ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); | |
2367 src1= formatConvBuffer; | |
2368 src2= formatConvBuffer+2048; | |
2369 } | |
2370 else if(srcFormat==IMGFMT_RGB24) | |
2371 { | |
2372 RENAME(rgb24ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); | |
2373 src1= formatConvBuffer; | |
2374 src2= formatConvBuffer+2048; | |
2375 } | |
4481 | 2376 else if(isGray(srcFormat)) |
2377 { | |
2378 return; | |
2379 } | |
4467 | 2380 |
3352 | 2381 #ifdef HAVE_MMX |
2382 // 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
|
2383 if(!(flags&SWS_FAST_BILINEAR) || (!canMMX2BeUsed)) |
3352 | 2384 #else |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2385 if(!(flags&SWS_FAST_BILINEAR)) |
3352 | 2386 #endif |
3272 | 2387 { |
2388 RENAME(hScale)(dst , dstWidth, src1, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize); | |
2389 RENAME(hScale)(dst+2048, dstWidth, src2, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize); | |
2390 } | |
2391 else // Fast Bilinear upscale / crap downscale | |
2392 { | |
2469 | 2393 #ifdef ARCH_X86 |
2394 #ifdef HAVE_MMX2 | |
2671 | 2395 int i; |
2469 | 2396 if(canMMX2BeUsed) |
2397 { | |
2398 asm volatile( | |
5452 | 2399 "pxor %%mm7, %%mm7 \n\t" |
2400 "movl %0, %%ecx \n\t" | |
2401 "movl %1, %%edi \n\t" | |
2402 "movl %2, %%edx \n\t" | |
2403 "movl %3, %%ebx \n\t" | |
2404 "xorl %%eax, %%eax \n\t" // i | |
2405 PREFETCH" (%%ecx) \n\t" | |
2406 PREFETCH" 32(%%ecx) \n\t" | |
2407 PREFETCH" 64(%%ecx) \n\t" | |
2408 | |
2409 #define FUNNY_UV_CODE \ | |
2410 "movl (%%ebx), %%esi \n\t"\ | |
2411 "call *%4 \n\t"\ | |
2412 "addl (%%ebx, %%eax), %%ecx \n\t"\ | |
2413 "addl %%eax, %%edi \n\t"\ | |
2414 "xorl %%eax, %%eax \n\t"\ | |
2469 | 2415 |
5452 | 2416 FUNNY_UV_CODE |
2417 FUNNY_UV_CODE | |
2418 FUNNY_UV_CODE | |
2419 FUNNY_UV_CODE | |
2420 "xorl %%eax, %%eax \n\t" // i | |
2421 "movl %5, %%ecx \n\t" // src | |
2422 "movl %1, %%edi \n\t" // buf1 | |
2423 "addl $4096, %%edi \n\t" | |
2424 PREFETCH" (%%ecx) \n\t" | |
2425 PREFETCH" 32(%%ecx) \n\t" | |
2426 PREFETCH" 64(%%ecx) \n\t" | |
2469 | 2427 |
5452 | 2428 FUNNY_UV_CODE |
2429 FUNNY_UV_CODE | |
2430 FUNNY_UV_CODE | |
2431 FUNNY_UV_CODE | |
2469 | 2432 |
5452 | 2433 :: "m" (src1), "m" (dst), "m" (mmx2Filter), "m" (mmx2FilterPos), |
2434 "m" (funnyUVCode), "m" (src2) | |
2435 : "%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi" | |
2436 ); | |
3344 | 2437 for(i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) |
2469 | 2438 { |
3344 | 2439 // printf("%d %d %d\n", dstWidth, i, srcW); |
2440 dst[i] = src1[srcW-1]*128; | |
2441 dst[i+2048] = src2[srcW-1]*128; | |
2469 | 2442 } |
2443 } | |
2444 else | |
2445 { | |
2446 #endif | |
2447 asm volatile( | |
2448 "xorl %%eax, %%eax \n\t" // i | |
2449 "xorl %%ebx, %%ebx \n\t" // xx | |
2450 "xorl %%ecx, %%ecx \n\t" // 2*xalpha | |
2800
7847d6b7ad3d
.balign or we¡ll align by 64kb on some architectures
michael
parents:
2799
diff
changeset
|
2451 ".balign 16 \n\t" |
2469 | 2452 "1: \n\t" |
2453 "movl %0, %%esi \n\t" | |
2454 "movzbl (%%esi, %%ebx), %%edi \n\t" //src[xx] | |
2455 "movzbl 1(%%esi, %%ebx), %%esi \n\t" //src[xx+1] | |
2456 "subl %%edi, %%esi \n\t" //src[xx+1] - src[xx] | |
2457 "imull %%ecx, %%esi \n\t" //(src[xx+1] - src[xx])*2*xalpha | |
2458 "shll $16, %%edi \n\t" | |
2459 "addl %%edi, %%esi \n\t" //src[xx+1]*2*xalpha + src[xx]*(1-2*xalpha) | |
2460 "movl %1, %%edi \n\t" | |
2461 "shrl $9, %%esi \n\t" | |
2462 "movw %%si, (%%edi, %%eax, 2) \n\t" | |
2463 | |
2464 "movzbl (%5, %%ebx), %%edi \n\t" //src[xx] | |
2465 "movzbl 1(%5, %%ebx), %%esi \n\t" //src[xx+1] | |
2466 "subl %%edi, %%esi \n\t" //src[xx+1] - src[xx] | |
2467 "imull %%ecx, %%esi \n\t" //(src[xx+1] - src[xx])*2*xalpha | |
2468 "shll $16, %%edi \n\t" | |
2469 "addl %%edi, %%esi \n\t" //src[xx+1]*2*xalpha + src[xx]*(1-2*xalpha) | |
2470 "movl %1, %%edi \n\t" | |
2471 "shrl $9, %%esi \n\t" | |
2472 "movw %%si, 4096(%%edi, %%eax, 2)\n\t" | |
2473 | |
2474 "addw %4, %%cx \n\t" //2*xalpha += xInc&0xFF | |
2475 "adcl %3, %%ebx \n\t" //xx+= xInc>>8 + carry | |
2476 "addl $1, %%eax \n\t" | |
2477 "cmpl %2, %%eax \n\t" | |
2478 " jb 1b \n\t" | |
2479 | |
2480 :: "m" (src1), "m" (dst), "m" (dstWidth), "m" (xInc>>16), "m" (xInc&0xFFFF), | |
2481 "r" (src2) | |
2482 : "%eax", "%ebx", "%ecx", "%edi", "%esi" | |
2483 ); | |
2484 #ifdef HAVE_MMX2 | |
2485 } //if MMX2 cant be used | |
2486 #endif | |
2487 #else | |
2671 | 2488 int i; |
2489 unsigned int xpos=0; | |
2490 for(i=0;i<dstWidth;i++) | |
2491 { | |
2492 register unsigned int xx=xpos>>16; | |
2493 register unsigned int xalpha=(xpos&0xFFFF)>>9; | |
2494 dst[i]=(src1[xx]*(xalpha^127)+src1[xx+1]*xalpha); | |
2495 dst[i+2048]=(src2[xx]*(xalpha^127)+src2[xx+1]*xalpha); | |
2566 | 2496 /* slower |
2497 dst[i]= (src1[xx]<<7) + (src1[xx+1] - src1[xx])*xalpha; | |
2498 dst[i+2048]=(src2[xx]<<7) + (src2[xx+1] - src2[xx])*xalpha; | |
2499 */ | |
2671 | 2500 xpos+=xInc; |
2501 } | |
2469 | 2502 #endif |
3272 | 2503 } |
2504 } | |
2505 | |
4467 | 2506 static void RENAME(swScale)(SwsContext *c, uint8_t* srcParam[], int srcStrideParam[], int srcSliceY, |
4698 | 2507 int srcSliceH, uint8_t* dstParam[], int dstStrideParam[]){ |
3344 | 2508 |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2509 /* 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
|
2510 const int srcW= c->srcW; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2511 const int dstW= c->dstW; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2512 const int dstH= c->dstH; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2513 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
|
2514 const int chrSrcW= c->chrSrcW; |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2515 const int lumXInc= c->lumXInc; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2516 const int chrXInc= c->chrXInc; |
4295 | 2517 const int dstFormat= c->dstFormat; |
6503 | 2518 const int srcFormat= c->srcFormat; |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2519 const int flags= c->flags; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2520 const int canMMX2BeUsed= c->canMMX2BeUsed; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2521 int16_t *vLumFilterPos= c->vLumFilterPos; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2522 int16_t *vChrFilterPos= c->vChrFilterPos; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2523 int16_t *hLumFilterPos= c->hLumFilterPos; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2524 int16_t *hChrFilterPos= c->hChrFilterPos; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2525 int16_t *vLumFilter= c->vLumFilter; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2526 int16_t *vChrFilter= c->vChrFilter; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2527 int16_t *hLumFilter= c->hLumFilter; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2528 int16_t *hChrFilter= c->hChrFilter; |
9413 | 2529 int32_t *lumMmxFilter= c->lumMmxFilter; |
2530 int32_t *chrMmxFilter= c->chrMmxFilter; | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2531 const int vLumFilterSize= c->vLumFilterSize; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2532 const int vChrFilterSize= c->vChrFilterSize; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2533 const int hLumFilterSize= c->hLumFilterSize; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2534 const int hChrFilterSize= c->hChrFilterSize; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2535 int16_t **lumPixBuf= c->lumPixBuf; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2536 int16_t **chrPixBuf= c->chrPixBuf; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2537 const int vLumBufSize= c->vLumBufSize; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2538 const int vChrBufSize= c->vChrBufSize; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2539 uint8_t *funnyYCode= c->funnyYCode; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2540 uint8_t *funnyUVCode= c->funnyUVCode; |
4467 | 2541 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
|
2542 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
|
2543 const int chrSrcSliceH= -((-srcSliceH) >> c->chrSrcVSubSample); |
3344 | 2544 |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2545 /* 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
|
2546 int dstY= c->dstY; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2547 int lumBufIndex= c->lumBufIndex; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2548 int chrBufIndex= c->chrBufIndex; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2549 int lastInLumBuf= c->lastInLumBuf; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2550 int lastInChrBuf= c->lastInChrBuf; |
4467 | 2551 int srcStride[3]; |
4698 | 2552 int dstStride[3]; |
4419 | 2553 uint8_t *src[3]; |
2554 uint8_t *dst[3]; | |
6540 | 2555 |
2556 orderYUV(c->srcFormat, src, srcStride, srcParam, srcStrideParam); | |
2557 orderYUV(c->dstFormat, dst, dstStride, dstParam, dstStrideParam); | |
6503 | 2558 |
6540 | 2559 if(isPacked(c->srcFormat)){ |
4467 | 2560 src[0]= |
2561 src[1]= | |
2562 src[2]= srcParam[0]; | |
6540 | 2563 srcStride[0]= |
4467 | 2564 srcStride[1]= |
6540 | 2565 srcStride[2]= srcStrideParam[0]; |
4467 | 2566 } |
6540 | 2567 srcStride[1]<<= c->vChrDrop; |
2568 srcStride[2]<<= c->vChrDrop; | |
4419 | 2569 |
6517 | 2570 // printf("swscale %X %X %X -> %X %X %X\n", (int)src[0], (int)src[1], (int)src[2], |
2571 // (int)dst[0], (int)dst[1], (int)dst[2]); | |
2572 | |
2573 #if 0 //self test FIXME move to a vfilter or something | |
2574 { | |
2575 static volatile int i=0; | |
2576 i++; | |
2577 if(srcFormat==IMGFMT_YV12 && i==1 && srcSliceH>= c->srcH) | |
2578 selfTest(src, srcStride, c->srcW, c->srcH); | |
2579 i--; | |
2580 } | |
2581 #endif | |
4554 | 2582 |
2583 //printf("sws Strides:%d %d %d -> %d %d %d\n", srcStride[0],srcStride[1],srcStride[2], | |
2584 //dstStride[0],dstStride[1],dstStride[2]); | |
4419 | 2585 |
2586 if(dstStride[0]%8 !=0 || dstStride[1]%8 !=0 || dstStride[2]%8 !=0) | |
2587 { | |
2588 static int firstTime=1; //FIXME move this into the context perhaps | |
2589 if(flags & SWS_PRINT_INFO && firstTime) | |
2590 { | |
5937 | 2591 mp_msg(MSGT_SWS,MSGL_WARN,"SwScaler: Warning: dstStride is not aligned!\n" |
4419 | 2592 "SwScaler: ->cannot do aligned memory acesses anymore\n"); |
2593 firstTime=0; | |
2594 } | |
2595 } | |
3344 | 2596 |
4467 | 2597 /* Note the user might start scaling the picture in the middle so this will not get executed |
2598 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
|
2599 if(srcSliceY ==0){ |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2600 lumBufIndex=0; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2601 chrBufIndex=0; |
4467 | 2602 dstY=0; |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2603 lastInLumBuf= -1; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2604 lastInChrBuf= -1; |
3272 | 2605 } |
3344 | 2606 |
2607 for(;dstY < dstH; dstY++){ | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2608 unsigned char *dest =dst[0]+dstStride[0]*dstY; |
6520 | 2609 const int chrDstY= dstY>>c->chrDstVSubSample; |
2610 unsigned char *uDest=dst[1]+dstStride[1]*chrDstY; | |
2611 unsigned char *vDest=dst[2]+dstStride[2]*chrDstY; | |
3344 | 2612 |
2613 const int firstLumSrcY= vLumFilterPos[dstY]; //First line needed as input | |
2614 const int firstChrSrcY= vChrFilterPos[chrDstY]; //First line needed as input | |
2615 const int lastLumSrcY= firstLumSrcY + vLumFilterSize -1; // Last line needed as input | |
2616 const int lastChrSrcY= firstChrSrcY + vChrFilterSize -1; // Last line needed as input | |
2617 | |
4290
1f8ceb12284d
general convolution filtering of the source picture
michael
parents:
4276
diff
changeset
|
2618 //handle holes (FAST_BILINEAR & weird filters) |
1f8ceb12284d
general convolution filtering of the source picture
michael
parents:
4276
diff
changeset
|
2619 if(firstLumSrcY > lastInLumBuf) lastInLumBuf= firstLumSrcY-1; |
1f8ceb12284d
general convolution filtering of the source picture
michael
parents:
4276
diff
changeset
|
2620 if(firstChrSrcY > lastInChrBuf) lastInChrBuf= firstChrSrcY-1; |
1f8ceb12284d
general convolution filtering of the source picture
michael
parents:
4276
diff
changeset
|
2621 //printf("%d %d %d\n", firstChrSrcY, lastInChrBuf, vChrBufSize); |
3344 | 2622 ASSERT(firstLumSrcY >= lastInLumBuf - vLumBufSize + 1) |
2623 ASSERT(firstChrSrcY >= lastInChrBuf - vChrBufSize + 1) | |
2216 | 2624 |
3344 | 2625 // 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
|
2626 if(lastLumSrcY < srcSliceY + srcSliceH && lastChrSrcY < -((-srcSliceY - srcSliceH)>>c->chrSrcVSubSample)) |
2469 | 2627 { |
3344 | 2628 //Do horizontal scaling |
2629 while(lastInLumBuf < lastLumSrcY) | |
2630 { | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2631 uint8_t *s= src[0]+(lastInLumBuf + 1 - srcSliceY)*srcStride[0]; |
3344 | 2632 lumBufIndex++; |
4290
1f8ceb12284d
general convolution filtering of the source picture
michael
parents:
4276
diff
changeset
|
2633 // printf("%d %d %d %d\n", lumBufIndex, vLumBufSize, lastInLumBuf, lastLumSrcY); |
3344 | 2634 ASSERT(lumBufIndex < 2*vLumBufSize) |
2635 ASSERT(lastInLumBuf + 1 - srcSliceY < srcSliceH) | |
2636 ASSERT(lastInLumBuf + 1 - srcSliceY >= 0) | |
2637 // printf("%d %d\n", lumBufIndex, vLumBufSize); | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2638 RENAME(hyscale)(lumPixBuf[ lumBufIndex ], dstW, s, srcW, lumXInc, |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2639 flags, canMMX2BeUsed, hLumFilter, hLumFilterPos, hLumFilterSize, |
5452 | 2640 funnyYCode, c->srcFormat, formatConvBuffer, |
2641 c->lumMmx2Filter, c->lumMmx2FilterPos); | |
3344 | 2642 lastInLumBuf++; |
2643 } | |
2644 while(lastInChrBuf < lastChrSrcY) | |
2645 { | |
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
|
2646 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
|
2647 uint8_t *src2= src[2]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[2]; |
3344 | 2648 chrBufIndex++; |
2649 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
|
2650 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
|
2651 ASSERT(lastInChrBuf + 1 - chrSrcSliceY >= 0) |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2652 //FIXME replace parameters through context struct (some at least) |
6503 | 2653 |
2654 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
|
2655 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
|
2656 flags, canMMX2BeUsed, hChrFilter, hChrFilterPos, hChrFilterSize, |
5452 | 2657 funnyUVCode, c->srcFormat, formatConvBuffer, |
2658 c->chrMmx2Filter, c->chrMmx2FilterPos); | |
3344 | 2659 lastInChrBuf++; |
2660 } | |
2661 //wrap buf index around to stay inside the ring buffer | |
2662 if(lumBufIndex >= vLumBufSize ) lumBufIndex-= vLumBufSize; | |
2663 if(chrBufIndex >= vChrBufSize ) chrBufIndex-= vChrBufSize; | |
2469 | 2664 } |
3344 | 2665 else // not enough lines left in this slice -> load the rest in the buffer |
2469 | 2666 { |
3344 | 2667 /* printf("%d %d Last:%d %d LastInBuf:%d %d Index:%d %d Y:%d FSize: %d %d BSize: %d %d\n", |
2668 firstChrSrcY,firstLumSrcY,lastChrSrcY,lastLumSrcY, | |
2669 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
|
2670 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
|
2671 |
3344 | 2672 //Do horizontal scaling |
2673 while(lastInLumBuf+1 < srcSliceY + srcSliceH) | |
2469 | 2674 { |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2675 uint8_t *s= src[0]+(lastInLumBuf + 1 - srcSliceY)*srcStride[0]; |
3344 | 2676 lumBufIndex++; |
2677 ASSERT(lumBufIndex < 2*vLumBufSize) | |
2678 ASSERT(lastInLumBuf + 1 - srcSliceY < srcSliceH) | |
2679 ASSERT(lastInLumBuf + 1 - srcSliceY >= 0) | |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2680 RENAME(hyscale)(lumPixBuf[ lumBufIndex ], dstW, s, srcW, lumXInc, |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2681 flags, canMMX2BeUsed, hLumFilter, hLumFilterPos, hLumFilterSize, |
5452 | 2682 funnyYCode, c->srcFormat, formatConvBuffer, |
2683 c->lumMmx2Filter, c->lumMmx2FilterPos); | |
3344 | 2684 lastInLumBuf++; |
2469 | 2685 } |
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
|
2686 while(lastInChrBuf+1 < (chrSrcSliceY + chrSrcSliceH)) |
3344 | 2687 { |
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
|
2688 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
|
2689 uint8_t *src2= src[2]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[2]; |
3344 | 2690 chrBufIndex++; |
2691 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
|
2692 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
|
2693 ASSERT(lastInChrBuf + 1 - chrSrcSliceY >= 0) |
6503 | 2694 |
2695 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
|
2696 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
|
2697 flags, canMMX2BeUsed, hChrFilter, hChrFilterPos, hChrFilterSize, |
5452 | 2698 funnyUVCode, c->srcFormat, formatConvBuffer, |
2699 c->chrMmx2Filter, c->chrMmx2FilterPos); | |
3344 | 2700 lastInChrBuf++; |
2701 } | |
2702 //wrap buf index around to stay inside the ring buffer | |
2703 if(lumBufIndex >= vLumBufSize ) lumBufIndex-= vLumBufSize; | |
2704 if(chrBufIndex >= vChrBufSize ) chrBufIndex-= vChrBufSize; | |
2705 break; //we cant output a dstY line so lets try with the next slice | |
2469 | 2706 } |
2264
7851375ea156
increased precission of s_xinc s_xinc2 (needed for the mmx2 bugfix)
michael
parents:
2237
diff
changeset
|
2707 |
2748 | 2708 #ifdef HAVE_MMX |
3344 | 2709 b5Dither= dither8[dstY&1]; |
2710 g6Dither= dither4[dstY&1]; | |
2711 g5Dither= dither8[dstY&1]; | |
2712 r5Dither= dither8[(dstY+1)&1]; | |
2748 | 2713 #endif |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2714 if(dstY < dstH-2) |
3352 | 2715 { |
9414 | 2716 int16_t **lumSrcPtr= lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize; |
2717 int16_t **chrSrcPtr= chrPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize; | |
2718 #ifdef HAVE_MMX | |
2719 int i; | |
2720 for(i=0; i<vLumFilterSize; i++) | |
2721 { | |
2722 lumMmxFilter[4*i+0]= (int32_t)lumSrcPtr[i]; | |
2723 lumMmxFilter[4*i+2]= | |
2724 lumMmxFilter[4*i+3]= | |
2725 ((uint16_t)vLumFilter[dstY*vLumFilterSize + i])*0x10001; | |
2726 } | |
2727 for(i=0; i<vChrFilterSize; i++) | |
2728 { | |
2729 chrMmxFilter[4*i+0]= (int32_t)chrSrcPtr[i]; | |
2730 chrMmxFilter[4*i+2]= | |
2731 chrMmxFilter[4*i+3]= | |
2732 ((uint16_t)vChrFilter[chrDstY*vChrFilterSize + i])*0x10001; | |
2733 } | |
2734 #endif | |
6503 | 2735 if(isPlanarYUV(dstFormat) || isGray(dstFormat)) //YV12 like |
3344 | 2736 { |
7351 | 2737 const int chrSkipMask= (1<<c->chrDstVSubSample)-1; |
2738 if((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; //FIXME split functions in lumi / chromi | |
3344 | 2739 if(vLumFilterSize == 1 && vChrFilterSize == 1) // Unscaled YV12 |
2740 { | |
2741 int16_t *lumBuf = lumPixBuf[0]; | |
2742 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
|
2743 RENAME(yuv2yuv1)(lumBuf, chrBuf, dest, uDest, vDest, dstW, chrDstW); |
3344 | 2744 } |
2745 else //General YV12 | |
2746 { | |
9413 | 2747 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
|
2748 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
|
2749 vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, |
9414 | 2750 dest, uDest, vDest, dstW, chrDstW); |
3344 | 2751 } |
2752 } | |
2753 else | |
2754 { | |
2755 ASSERT(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize*2); | |
2756 ASSERT(chrSrcPtr + vChrFilterSize - 1 < chrPixBuf + vChrBufSize*2); | |
2757 if(vLumFilterSize == 1 && vChrFilterSize == 2) //Unscaled RGB | |
2758 { | |
2759 int chrAlpha= vChrFilter[2*dstY+1]; | |
7723 | 2760 RENAME(yuv2packed1)(c, *lumSrcPtr, *chrSrcPtr, *(chrSrcPtr+1), |
6578 | 2761 dest, dstW, chrAlpha, dstFormat, flags, dstY); |
3344 | 2762 } |
2763 else if(vLumFilterSize == 2 && vChrFilterSize == 2) //BiLinear Upscale RGB | |
2764 { | |
2765 int lumAlpha= vLumFilter[2*dstY+1]; | |
2766 int chrAlpha= vChrFilter[2*dstY+1]; | |
7723 | 2767 RENAME(yuv2packed2)(c, *lumSrcPtr, *(lumSrcPtr+1), *chrSrcPtr, *(chrSrcPtr+1), |
6578 | 2768 dest, dstW, lumAlpha, chrAlpha, dstY); |
3344 | 2769 } |
2770 else //General RGB | |
2771 { | |
7723 | 2772 RENAME(yuv2packedX)(c, |
3344 | 2773 vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize, |
2774 vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, | |
9413 | 2775 dest, dstW, dstY); |
3344 | 2776 } |
2777 } | |
3352 | 2778 } |
2779 else // hmm looks like we cant use MMX here without overwriting this arrays tail | |
2780 { | |
2781 int16_t **lumSrcPtr= lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize; | |
2782 int16_t **chrSrcPtr= chrPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize; | |
6615 | 2783 if(isPlanarYUV(dstFormat) || isGray(dstFormat)) //YV12 |
3352 | 2784 { |
7351 | 2785 const int chrSkipMask= (1<<c->chrDstVSubSample)-1; |
2786 if((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; //FIXME split functions in lumi / chromi | |
6540 | 2787 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
|
2788 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
|
2789 vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, |
6540 | 2790 dest, uDest, vDest, dstW, chrDstW); |
3352 | 2791 } |
2792 else | |
2793 { | |
2794 ASSERT(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize*2); | |
2795 ASSERT(chrSrcPtr + vChrFilterSize - 1 < chrPixBuf + vChrBufSize*2); | |
7723 | 2796 yuv2packedXinC(c, |
3352 | 2797 vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize, |
2798 vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, | |
6578 | 2799 dest, dstW, dstY); |
3352 | 2800 } |
2801 } | |
3344 | 2802 } |
2534
cc9d3fd626f0
patch from Martin Decky <deckm1am@ss1000.ms.mff.cuni.cz> applied and unnecassery "memory" removed
michael
parents:
2521
diff
changeset
|
2803 |
cc9d3fd626f0
patch from Martin Decky <deckm1am@ss1000.ms.mff.cuni.cz> applied and unnecassery "memory" removed
michael
parents:
2521
diff
changeset
|
2804 #ifdef HAVE_MMX |
cc9d3fd626f0
patch from Martin Decky <deckm1am@ss1000.ms.mff.cuni.cz> applied and unnecassery "memory" removed
michael
parents:
2521
diff
changeset
|
2805 __asm __volatile(SFENCE:::"memory"); |
2566 | 2806 __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
|
2807 #endif |
4276
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2808 /* store changed local vars back in the context */ |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2809 c->dstY= dstY; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2810 c->lumBufIndex= lumBufIndex; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2811 c->chrBufIndex= chrBufIndex; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2812 c->lastInLumBuf= lastInLumBuf; |
9199d15cb4e0
removed global vars so that multiple swscalers can be used
michael
parents:
4248
diff
changeset
|
2813 c->lastInChrBuf= lastInChrBuf; |
3641 | 2814 } |