comparison src/video/SDL_yuv_mmx.c @ 1148:63fb2da89a4b

Patched inline assembly to compile on gcc 4.0.1. Details are here: http://bugs.gentoo.org/show_bug.cgi?id=104437 I believe the patch is from Harald van Dijk (comment #16 at the above url).
author Ryan C. Gordon <icculus@icculus.org>
date Wed, 28 Sep 2005 02:26:29 +0000
parents 29d7db09776e
children c9b51268668f
comparison
equal deleted inserted replaced
1147:b580f7201543 1148:63fb2da89a4b
28 28
29 #if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT) 29 #if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT)
30 30
31 #include "SDL_types.h" 31 #include "SDL_types.h"
32 32
33 #if __GNUC__ > 2 33 #define ASM_ARRAY(x) x[] __asm__("_" #x) __attribute__((used))
34 # undef GCC2_HACK
35 #else
36 # define GCC2_HACK
37 #endif
38
39 34
40 #if defined(GCC2_HACK) && defined (__ELF__) 35 static unsigned int ASM_ARRAY(MMX_0080w) = {0x00800080, 0x00800080};
41 #define ASM_VAR(X) _##X 36 static unsigned int ASM_ARRAY(MMX_00FFw) = {0x00ff00ff, 0x00ff00ff};
42 #else 37 static unsigned int ASM_ARRAY(MMX_FF00w) = {0xff00ff00, 0xff00ff00};
43 #define ASM_VAR(X) X 38
44 #endif 39 static unsigned short ASM_ARRAY(MMX_Ycoeff) = {0x004a, 0x004a, 0x004a, 0x004a};
45 40
46 static volatile unsigned int ASM_VAR(MMX_0080w)[] = {0x00800080, 0x00800080}; 41 static unsigned short ASM_ARRAY(MMX_UbluRGB) = {0x0072, 0x0072, 0x0072, 0x0072};
47 static volatile unsigned int ASM_VAR(MMX_00FFw)[] = {0x00ff00ff, 0x00ff00ff}; 42 static unsigned short ASM_ARRAY(MMX_VredRGB) = {0x0059, 0x0059, 0x0059, 0x0059};
48 static volatile unsigned int ASM_VAR(MMX_FF00w)[] = {0xff00ff00, 0xff00ff00}; 43 static unsigned short ASM_ARRAY(MMX_UgrnRGB) = {0xffea, 0xffea, 0xffea, 0xffea};
49 44 static unsigned short ASM_ARRAY(MMX_VgrnRGB) = {0xffd2, 0xffd2, 0xffd2, 0xffd2};
50 static volatile unsigned short ASM_VAR(MMX_Ycoeff)[] = {0x004a, 0x004a, 0x004a, 0x004a}; 45
51 46 static unsigned short ASM_ARRAY(MMX_Ublu5x5) = {0x0081, 0x0081, 0x0081, 0x0081};
52 static volatile unsigned short ASM_VAR(MMX_UbluRGB)[] = {0x0072, 0x0072, 0x0072, 0x0072}; 47 static unsigned short ASM_ARRAY(MMX_Vred5x5) = {0x0066, 0x0066, 0x0066, 0x0066};
53 static volatile unsigned short ASM_VAR(MMX_VredRGB)[] = {0x0059, 0x0059, 0x0059, 0x0059}; 48 static unsigned short ASM_ARRAY(MMX_Ugrn555) = {0xffe7, 0xffe7, 0xffe7, 0xffe7};
54 static volatile unsigned short ASM_VAR(MMX_UgrnRGB)[] = {0xffea, 0xffea, 0xffea, 0xffea}; 49 static unsigned short ASM_ARRAY(MMX_Vgrn555) = {0xffcc, 0xffcc, 0xffcc, 0xffcc};
55 static volatile unsigned short ASM_VAR(MMX_VgrnRGB)[] = {0xffd2, 0xffd2, 0xffd2, 0xffd2}; 50 static unsigned short ASM_ARRAY(MMX_Ugrn565) = {0xffe8, 0xffe8, 0xffe8, 0xffe8};
56 51 static unsigned short ASM_ARRAY(MMX_Vgrn565) = {0xffcd, 0xffcd, 0xffcd, 0xffcd};
57 static volatile unsigned short ASM_VAR(MMX_Ublu5x5)[] = {0x0081, 0x0081, 0x0081, 0x0081}; 52
58 static volatile unsigned short ASM_VAR(MMX_Vred5x5)[] = {0x0066, 0x0066, 0x0066, 0x0066}; 53 static unsigned short ASM_ARRAY(MMX_red555) = {0x7c00, 0x7c00, 0x7c00, 0x7c00};
59 static volatile unsigned short ASM_VAR(MMX_Ugrn555)[] = {0xffe7, 0xffe7, 0xffe7, 0xffe7}; 54 static unsigned short ASM_ARRAY(MMX_red565) = {0xf800, 0xf800, 0xf800, 0xf800};
60 static volatile unsigned short ASM_VAR(MMX_Vgrn555)[] = {0xffcc, 0xffcc, 0xffcc, 0xffcc}; 55 static unsigned short ASM_ARRAY(MMX_grn555) = {0x03e0, 0x03e0, 0x03e0, 0x03e0};
61 static volatile unsigned short ASM_VAR(MMX_Ugrn565)[] = {0xffe8, 0xffe8, 0xffe8, 0xffe8}; 56 static unsigned short ASM_ARRAY(MMX_grn565) = {0x07e0, 0x07e0, 0x07e0, 0x07e0};
62 static volatile unsigned short ASM_VAR(MMX_Vgrn565)[] = {0xffcd, 0xffcd, 0xffcd, 0xffcd}; 57 static unsigned short ASM_ARRAY(MMX_blu5x5) = {0x001f, 0x001f, 0x001f, 0x001f};
63
64 static volatile unsigned short ASM_VAR(MMX_red555)[] = {0x7c00, 0x7c00, 0x7c00, 0x7c00};
65 static volatile unsigned short ASM_VAR(MMX_red565)[] = {0xf800, 0xf800, 0xf800, 0xf800};
66 static volatile unsigned short ASM_VAR(MMX_grn555)[] = {0x03e0, 0x03e0, 0x03e0, 0x03e0};
67 static volatile unsigned short ASM_VAR(MMX_grn565)[] = {0x07e0, 0x07e0, 0x07e0, 0x07e0};
68 static volatile unsigned short ASM_VAR(MMX_blu5x5)[] = {0x001f, 0x001f, 0x001f, 0x001f};
69 58
70 /** 59 /**
71 This MMX assembler is my first assembler/MMX program ever. 60 This MMX assembler is my first assembler/MMX program ever.
72 Thus it maybe buggy. 61 Thus it maybe buggy.
73 Send patches to: 62 Send patches to:
125 "movd (%%ebx), %%mm1\n" // 0 0 0 0 v3 v2 v1 v0 114 "movd (%%ebx), %%mm1\n" // 0 0 0 0 v3 v2 v1 v0
126 "pxor %%mm7,%%mm7\n" // 00 00 00 00 00 00 00 00 115 "pxor %%mm7,%%mm7\n" // 00 00 00 00 00 00 00 00
127 "movd (%2), %%mm2\n" // 0 0 0 0 l3 l2 l1 l0 116 "movd (%2), %%mm2\n" // 0 0 0 0 l3 l2 l1 l0
128 "punpcklbw %%mm7,%%mm1\n" // 0 v3 0 v2 00 v1 00 v0 117 "punpcklbw %%mm7,%%mm1\n" // 0 v3 0 v2 00 v1 00 v0
129 "punpckldq %%mm1,%%mm1\n" // 00 v1 00 v0 00 v1 00 v0 118 "punpckldq %%mm1,%%mm1\n" // 00 v1 00 v0 00 v1 00 v0
130 #ifdef GCC2_HACK
131 "psubw _MMX_0080w,%%mm1\n" // mm1-128:r1 r1 r0 r0 r1 r1 r0 r0 119 "psubw _MMX_0080w,%%mm1\n" // mm1-128:r1 r1 r0 r0 r1 r1 r0 r0
132 #else
133 "psubw %[_MMX_0080w],%%mm1\n" // mm1-128:r1 r1 r0 r0 r1 r1 r0 r0
134 #endif
135 120
136 // create Cr_g (result in mm0) 121 // create Cr_g (result in mm0)
137 "movq %%mm1,%%mm0\n" // r1 r1 r0 r0 r1 r1 r0 r0 122 "movq %%mm1,%%mm0\n" // r1 r1 r0 r0 r1 r1 r0 r0
138 #ifdef GCC2_HACK
139 "pmullw _MMX_VgrnRGB,%%mm0\n"// red*-46dec=0.7136*64 123 "pmullw _MMX_VgrnRGB,%%mm0\n"// red*-46dec=0.7136*64
140 "pmullw _MMX_VredRGB,%%mm1\n"// red*89dec=1.4013*64 124 "pmullw _MMX_VredRGB,%%mm1\n"// red*89dec=1.4013*64
141 #else
142 "pmullw %[_MMX_VgrnRGB],%%mm0\n"// red*-46dec=0.7136*64
143 "pmullw %[_MMX_VredRGB],%%mm1\n"// red*89dec=1.4013*64
144 #endif
145 "psraw $6, %%mm0\n" // red=red/64 125 "psraw $6, %%mm0\n" // red=red/64
146 "psraw $6, %%mm1\n" // red=red/64 126 "psraw $6, %%mm1\n" // red=red/64
147 127
148 // create L1 L2 (result in mm2,mm4) 128 // create L1 L2 (result in mm2,mm4)
149 // L2=lum+cols 129 // L2=lum+cols
150 "movq (%2,%4),%%mm3\n" // 0 0 0 0 L3 L2 L1 L0 130 "movq (%2,%4),%%mm3\n" // 0 0 0 0 L3 L2 L1 L0
151 "punpckldq %%mm3,%%mm2\n" // L3 L2 L1 L0 l3 l2 l1 l0 131 "punpckldq %%mm3,%%mm2\n" // L3 L2 L1 L0 l3 l2 l1 l0
152 "movq %%mm2,%%mm4\n" // L3 L2 L1 L0 l3 l2 l1 l0 132 "movq %%mm2,%%mm4\n" // L3 L2 L1 L0 l3 l2 l1 l0
153 #ifdef GCC2_HACK
154 "pand _MMX_FF00w,%%mm2\n" // L3 0 L1 0 l3 0 l1 0 133 "pand _MMX_FF00w,%%mm2\n" // L3 0 L1 0 l3 0 l1 0
155 "pand _MMX_00FFw,%%mm4\n" // 0 L2 0 L0 0 l2 0 l0 134 "pand _MMX_00FFw,%%mm4\n" // 0 L2 0 L0 0 l2 0 l0
156 #else
157 "pand %[_MMX_FF00w],%%mm2\n" // L3 0 L1 0 l3 0 l1 0
158 "pand %[_MMX_00FFw],%%mm4\n" // 0 L2 0 L0 0 l2 0 l0
159 #endif
160 "psrlw $8,%%mm2\n" // 0 L3 0 L1 0 l3 0 l1 135 "psrlw $8,%%mm2\n" // 0 L3 0 L1 0 l3 0 l1
161 136
162 // create R (result in mm6) 137 // create R (result in mm6)
163 "movq %%mm2,%%mm5\n" // 0 L3 0 L1 0 l3 0 l1 138 "movq %%mm2,%%mm5\n" // 0 L3 0 L1 0 l3 0 l1
164 "movq %%mm4,%%mm6\n" // 0 L2 0 L0 0 l2 0 l0 139 "movq %%mm4,%%mm6\n" // 0 L2 0 L0 0 l2 0 l0
171 146
172 // create Cb (result in mm1) 147 // create Cb (result in mm1)
173 "movd (%1), %%mm1\n" // 0 0 0 0 u3 u2 u1 u0 148 "movd (%1), %%mm1\n" // 0 0 0 0 u3 u2 u1 u0
174 "punpcklbw %%mm7,%%mm1\n" // 0 u3 0 u2 00 u1 00 u0 149 "punpcklbw %%mm7,%%mm1\n" // 0 u3 0 u2 00 u1 00 u0
175 "punpckldq %%mm1,%%mm1\n" // 00 u1 00 u0 00 u1 00 u0 150 "punpckldq %%mm1,%%mm1\n" // 00 u1 00 u0 00 u1 00 u0
176 #ifdef GCC2_HACK
177 "psubw _MMX_0080w,%%mm1\n" // mm1-128:u1 u1 u0 u0 u1 u1 u0 u0 151 "psubw _MMX_0080w,%%mm1\n" // mm1-128:u1 u1 u0 u0 u1 u1 u0 u0
178 #else
179 "psubw %[_MMX_0080w],%%mm1\n" // mm1-128:u1 u1 u0 u0 u1 u1 u0 u0
180 #endif
181 // create Cb_g (result in mm5) 152 // create Cb_g (result in mm5)
182 "movq %%mm1,%%mm5\n" // u1 u1 u0 u0 u1 u1 u0 u0 153 "movq %%mm1,%%mm5\n" // u1 u1 u0 u0 u1 u1 u0 u0
183 #ifdef GCC2_HACK
184 "pmullw _MMX_UgrnRGB,%%mm5\n" // blue*-109dec=1.7129*64 154 "pmullw _MMX_UgrnRGB,%%mm5\n" // blue*-109dec=1.7129*64
185 "pmullw _MMX_UbluRGB,%%mm1\n" // blue*114dec=1.78125*64 155 "pmullw _MMX_UbluRGB,%%mm1\n" // blue*114dec=1.78125*64
186 #else
187 "pmullw %[_MMX_UgrnRGB],%%mm5\n" // blue*-109dec=1.7129*64
188 "pmullw %[_MMX_UbluRGB],%%mm1\n" // blue*114dec=1.78125*64
189 #endif
190 "psraw $6, %%mm5\n" // blue=red/64 156 "psraw $6, %%mm5\n" // blue=red/64
191 "psraw $6, %%mm1\n" // blue=blue/64 157 "psraw $6, %%mm1\n" // blue=blue/64
192 158
193 // create G (result in mm7) 159 // create G (result in mm7)
194 "movq %%mm2,%%mm3\n" // 0 L3 0 L1 0 l3 0 l1 160 "movq %%mm2,%%mm3\n" // 0 L3 0 L1 0 l3 0 l1
266 "jl 1b\n" 232 "jl 1b\n"
267 "emms\n" 233 "emms\n"
268 "popl %%ebx\n" 234 "popl %%ebx\n"
269 : 235 :
270 : "m" (cr), "r"(cb),"r"(lum), 236 : "m" (cr), "r"(cb),"r"(lum),
271 "r"(row1),"r"(cols),"r"(row2),"m"(x),"m"(y),"m"(mod) 237 "r"(row1),"r"(cols),"r"(row2),"m"(x),"m"(y),"m"(mod));
272 #ifndef GCC2_HACK
273 ,[_MMX_0080w] "m" (*MMX_0080w),
274 [_MMX_00FFw] "m" (*MMX_00FFw),
275 [_MMX_FF00w] "m" (*MMX_FF00w),
276 [_MMX_VgrnRGB] "m" (*MMX_VgrnRGB),
277 [_MMX_VredRGB] "m" (*MMX_VredRGB),
278 [_MMX_UgrnRGB] "m" (*MMX_UgrnRGB),
279 [_MMX_UbluRGB] "m" (*MMX_UbluRGB)
280 #endif
281 );
282 } 238 }
283 239
284 void Color565DitherYV12MMX1X( int *colortab, Uint32 *rgb_2_pix, 240 void Color565DitherYV12MMX1X( int *colortab, Uint32 *rgb_2_pix,
285 unsigned char *lum, unsigned char *cr, 241 unsigned char *lum, unsigned char *cr,
286 unsigned char *cb, unsigned char *out, 242 unsigned char *cb, unsigned char *out,
305 "movd (%1), %%mm0\n" // 4 Cb 0 0 0 0 u3 u2 u1 u0 261 "movd (%1), %%mm0\n" // 4 Cb 0 0 0 0 u3 u2 u1 u0
306 "pxor %%mm7, %%mm7\n" 262 "pxor %%mm7, %%mm7\n"
307 "movd (%%ebx), %%mm1\n" // 4 Cr 0 0 0 0 v3 v2 v1 v0 263 "movd (%%ebx), %%mm1\n" // 4 Cr 0 0 0 0 v3 v2 v1 v0
308 "punpcklbw %%mm7, %%mm0\n" // 4 W cb 0 u3 0 u2 0 u1 0 u0 264 "punpcklbw %%mm7, %%mm0\n" // 4 W cb 0 u3 0 u2 0 u1 0 u0
309 "punpcklbw %%mm7, %%mm1\n" // 4 W cr 0 v3 0 v2 0 v1 0 v0 265 "punpcklbw %%mm7, %%mm1\n" // 4 W cr 0 v3 0 v2 0 v1 0 v0
310 #ifdef GCC2_HACK
311 "psubw _MMX_0080w, %%mm0\n" 266 "psubw _MMX_0080w, %%mm0\n"
312 "psubw _MMX_0080w, %%mm1\n" 267 "psubw _MMX_0080w, %%mm1\n"
313 #else
314 "psubw %[_MMX_0080w], %%mm0\n"
315 "psubw %[_MMX_0080w], %%mm1\n"
316 #endif
317 "movq %%mm0, %%mm2\n" // Cb 0 u3 0 u2 0 u1 0 u0 268 "movq %%mm0, %%mm2\n" // Cb 0 u3 0 u2 0 u1 0 u0
318 "movq %%mm1, %%mm3\n" // Cr 269 "movq %%mm1, %%mm3\n" // Cr
319 #ifdef GCC2_HACK
320 "pmullw _MMX_Ugrn565, %%mm2\n" // Cb2green 0 R3 0 R2 0 R1 0 R0 270 "pmullw _MMX_Ugrn565, %%mm2\n" // Cb2green 0 R3 0 R2 0 R1 0 R0
321 #else
322 "pmullw %[_MMX_Ugrn565], %%mm2\n" // Cb2green 0 R3 0 R2 0 R1 0 R0
323 #endif
324 "movq (%2), %%mm6\n" // L1 l7 L6 L5 L4 L3 L2 L1 L0 271 "movq (%2), %%mm6\n" // L1 l7 L6 L5 L4 L3 L2 L1 L0
325 #ifdef GCC2_HACK
326 "pmullw _MMX_Ublu5x5, %%mm0\n" // Cb2blue 272 "pmullw _MMX_Ublu5x5, %%mm0\n" // Cb2blue
327 "pand _MMX_00FFw, %%mm6\n" // L1 00 L6 00 L4 00 L2 00 L0 273 "pand _MMX_00FFw, %%mm6\n" // L1 00 L6 00 L4 00 L2 00 L0
328 "pmullw _MMX_Vgrn565, %%mm3\n" // Cr2green 274 "pmullw _MMX_Vgrn565, %%mm3\n" // Cr2green
329 #else
330 "pmullw %[_MMX_Ublu5x5], %%mm0\n" // Cb2blue
331 "pand %[_MMX_00FFw], %%mm6\n" // L1 00 L6 00 L4 00 L2 00 L0
332 "pmullw %[_MMX_Vgrn565], %%mm3\n" // Cr2green
333 #endif
334 "movq (%2), %%mm7\n" // L2 275 "movq (%2), %%mm7\n" // L2
335 #ifdef GCC2_HACK
336 "pmullw _MMX_Vred5x5, %%mm1\n" // Cr2red 276 "pmullw _MMX_Vred5x5, %%mm1\n" // Cr2red
337 #else
338 "pmullw %[_MMX_Vred5x5], %%mm1\n" // Cr2red
339 #endif
340 "psrlw $8, %%mm7\n" // L2 00 L7 00 L5 00 L3 00 L1 277 "psrlw $8, %%mm7\n" // L2 00 L7 00 L5 00 L3 00 L1
341 #ifdef GCC2_HACK
342 "pmullw _MMX_Ycoeff, %%mm6\n" // lum1 278 "pmullw _MMX_Ycoeff, %%mm6\n" // lum1
343 #else
344 "pmullw %[_MMX_Ycoeff], %%mm6\n" // lum1
345 #endif
346 "paddw %%mm3, %%mm2\n" // Cb2green + Cr2green == green 279 "paddw %%mm3, %%mm2\n" // Cb2green + Cr2green == green
347 #ifdef GCC2_HACK
348 "pmullw _MMX_Ycoeff, %%mm7\n" // lum2 280 "pmullw _MMX_Ycoeff, %%mm7\n" // lum2
349 #else
350 "pmullw %[_MMX_Ycoeff], %%mm7\n" // lum2
351 #endif
352 281
353 "movq %%mm6, %%mm4\n" // lum1 282 "movq %%mm6, %%mm4\n" // lum1
354 "paddw %%mm0, %%mm6\n" // lum1 +blue 00 B6 00 B4 00 B2 00 B0 283 "paddw %%mm0, %%mm6\n" // lum1 +blue 00 B6 00 B4 00 B2 00 B0
355 "movq %%mm4, %%mm5\n" // lum1 284 "movq %%mm4, %%mm5\n" // lum1
356 "paddw %%mm1, %%mm4\n" // lum1 +red 00 R6 00 R4 00 R2 00 R0 285 "paddw %%mm1, %%mm4\n" // lum1 +red 00 R6 00 R4 00 R2 00 R0
364 "packuswb %%mm5, %%mm5\n" // G1 G1 293 "packuswb %%mm5, %%mm5\n" // G1 G1
365 "packuswb %%mm6, %%mm6\n" // B1 B1 294 "packuswb %%mm6, %%mm6\n" // B1 B1
366 "punpcklbw %%mm4, %%mm4\n" 295 "punpcklbw %%mm4, %%mm4\n"
367 "punpcklbw %%mm5, %%mm5\n" 296 "punpcklbw %%mm5, %%mm5\n"
368 297
369 #ifdef GCC2_HACK
370 "pand _MMX_red565, %%mm4\n" 298 "pand _MMX_red565, %%mm4\n"
371 #else
372 "pand %[_MMX_red565], %%mm4\n"
373 #endif
374 "psllw $3, %%mm5\n" // GREEN 1 299 "psllw $3, %%mm5\n" // GREEN 1
375 "punpcklbw %%mm6, %%mm6\n" 300 "punpcklbw %%mm6, %%mm6\n"
376 #ifdef GCC2_HACK
377 "pand _MMX_grn565, %%mm5\n" 301 "pand _MMX_grn565, %%mm5\n"
378 "pand _MMX_red565, %%mm6\n" 302 "pand _MMX_red565, %%mm6\n"
379 #else
380 "pand %[_MMX_grn565], %%mm5\n"
381 "pand %[_MMX_red565], %%mm6\n"
382 #endif
383 "por %%mm5, %%mm4\n" // 303 "por %%mm5, %%mm4\n" //
384 "psrlw $11, %%mm6\n" // BLUE 1 304 "psrlw $11, %%mm6\n" // BLUE 1
385 "movq %%mm3, %%mm5\n" // lum2 305 "movq %%mm3, %%mm5\n" // lum2
386 "paddw %%mm1, %%mm3\n" // lum2 +red 00 R7 00 R5 00 R3 00 R1 306 "paddw %%mm1, %%mm3\n" // lum2 +red 00 R7 00 R5 00 R3 00 R1
387 "paddw %%mm2, %%mm5\n" // lum2 +green 00 G7 00 G5 00 G3 00 G1 307 "paddw %%mm2, %%mm5\n" // lum2 +green 00 G7 00 G5 00 G3 00 G1
391 "movq (%2, %4), %%mm6\n" // L3 load lum2 311 "movq (%2, %4), %%mm6\n" // L3 load lum2
392 "psraw $6, %%mm7\n" 312 "psraw $6, %%mm7\n"
393 "packuswb %%mm3, %%mm3\n" 313 "packuswb %%mm3, %%mm3\n"
394 "packuswb %%mm5, %%mm5\n" 314 "packuswb %%mm5, %%mm5\n"
395 "packuswb %%mm7, %%mm7\n" 315 "packuswb %%mm7, %%mm7\n"
396 #ifdef GCC2_HACK
397 "pand _MMX_00FFw, %%mm6\n" // L3 316 "pand _MMX_00FFw, %%mm6\n" // L3
398 #else
399 "pand %[_MMX_00FFw], %%mm6\n" // L3
400 #endif
401 "punpcklbw %%mm3, %%mm3\n" 317 "punpcklbw %%mm3, %%mm3\n"
402 "punpcklbw %%mm5, %%mm5\n" 318 "punpcklbw %%mm5, %%mm5\n"
403 #ifdef GCC2_HACK
404 "pmullw _MMX_Ycoeff, %%mm6\n" // lum3 319 "pmullw _MMX_Ycoeff, %%mm6\n" // lum3
405 #else
406 "pmullw %[_MMX_Ycoeff], %%mm6\n" // lum3
407 #endif
408 "punpcklbw %%mm7, %%mm7\n" 320 "punpcklbw %%mm7, %%mm7\n"
409 "psllw $3, %%mm5\n" // GREEN 2 321 "psllw $3, %%mm5\n" // GREEN 2
410 #ifdef GCC2_HACK
411 "pand _MMX_red565, %%mm7\n" 322 "pand _MMX_red565, %%mm7\n"
412 "pand _MMX_red565, %%mm3\n" 323 "pand _MMX_red565, %%mm3\n"
413 #else
414 "pand %[_MMX_red565], %%mm7\n"
415 "pand %[_MMX_red565], %%mm3\n"
416 #endif
417 "psrlw $11, %%mm7\n" // BLUE 2 324 "psrlw $11, %%mm7\n" // BLUE 2
418 #ifdef GCC2_HACK
419 "pand _MMX_grn565, %%mm5\n" 325 "pand _MMX_grn565, %%mm5\n"
420 #else
421 "pand %[_MMX_grn565], %%mm5\n"
422 #endif
423 "por %%mm7, %%mm3\n" 326 "por %%mm7, %%mm3\n"
424 "movq (%2,%4), %%mm7\n" // L4 load lum2 327 "movq (%2,%4), %%mm7\n" // L4 load lum2
425 "por %%mm5, %%mm3\n" // 328 "por %%mm5, %%mm3\n" //
426 "psrlw $8, %%mm7\n" // L4 329 "psrlw $8, %%mm7\n" // L4
427 "movq %%mm4, %%mm5\n" 330 "movq %%mm4, %%mm5\n"
428 "punpcklwd %%mm3, %%mm4\n" 331 "punpcklwd %%mm3, %%mm4\n"
429 #ifdef GCC2_HACK
430 "pmullw _MMX_Ycoeff, %%mm7\n" // lum4 332 "pmullw _MMX_Ycoeff, %%mm7\n" // lum4
431 #else
432 "pmullw %[_MMX_Ycoeff], %%mm7\n" // lum4
433 #endif
434 "punpckhwd %%mm3, %%mm5\n" 333 "punpckhwd %%mm3, %%mm5\n"
435 334
436 "movq %%mm4, (%3)\n" // write row1 335 "movq %%mm4, (%3)\n" // write row1
437 "movq %%mm5, 8(%3)\n" // write row1 336 "movq %%mm5, 8(%3)\n" // write row1
438 337
455 "packuswb %%mm6, %%mm6\n" 354 "packuswb %%mm6, %%mm6\n"
456 "punpcklbw %%mm4, %%mm4\n" 355 "punpcklbw %%mm4, %%mm4\n"
457 "punpcklbw %%mm5, %%mm5\n" 356 "punpcklbw %%mm5, %%mm5\n"
458 "punpcklbw %%mm6, %%mm6\n" 357 "punpcklbw %%mm6, %%mm6\n"
459 "psllw $3, %%mm5\n" // GREEN 3 358 "psllw $3, %%mm5\n" // GREEN 3
460 #ifdef GCC2_HACK
461 "pand _MMX_red565, %%mm4\n" 359 "pand _MMX_red565, %%mm4\n"
462 #else
463 "pand %[_MMX_red565], %%mm4\n"
464 #endif
465 "psraw $6, %%mm3\n" // psr 6 360 "psraw $6, %%mm3\n" // psr 6
466 "psraw $6, %%mm0\n" 361 "psraw $6, %%mm0\n"
467 #ifdef GCC2_HACK
468 "pand _MMX_red565, %%mm6\n" // BLUE 362 "pand _MMX_red565, %%mm6\n" // BLUE
469 "pand _MMX_grn565, %%mm5\n" 363 "pand _MMX_grn565, %%mm5\n"
470 #else
471 "pand %[_MMX_red565], %%mm6\n" // BLUE
472 "pand %[_MMX_grn565], %%mm5\n"
473 #endif
474 "psrlw $11, %%mm6\n" // BLUE 3 364 "psrlw $11, %%mm6\n" // BLUE 3
475 "por %%mm5, %%mm4\n" 365 "por %%mm5, %%mm4\n"
476 "psraw $6, %%mm7\n" 366 "psraw $6, %%mm7\n"
477 "por %%mm6, %%mm4\n" 367 "por %%mm6, %%mm4\n"
478 "packuswb %%mm3, %%mm3\n" 368 "packuswb %%mm3, %%mm3\n"
479 "packuswb %%mm0, %%mm0\n" 369 "packuswb %%mm0, %%mm0\n"
480 "packuswb %%mm7, %%mm7\n" 370 "packuswb %%mm7, %%mm7\n"
481 "punpcklbw %%mm3, %%mm3\n" 371 "punpcklbw %%mm3, %%mm3\n"
482 "punpcklbw %%mm0, %%mm0\n" 372 "punpcklbw %%mm0, %%mm0\n"
483 "punpcklbw %%mm7, %%mm7\n" 373 "punpcklbw %%mm7, %%mm7\n"
484 #ifdef GCC2_HACK
485 "pand _MMX_red565, %%mm3\n" 374 "pand _MMX_red565, %%mm3\n"
486 "pand _MMX_red565, %%mm7\n" // BLUE 375 "pand _MMX_red565, %%mm7\n" // BLUE
487 #else
488 "pand %[_MMX_red565], %%mm3\n"
489 "pand %[_MMX_red565], %%mm7\n" // BLUE
490 #endif
491 "psllw $3, %%mm0\n" // GREEN 4 376 "psllw $3, %%mm0\n" // GREEN 4
492 "psrlw $11, %%mm7\n" 377 "psrlw $11, %%mm7\n"
493 #ifdef GCC2_HACK
494 "pand _MMX_grn565, %%mm0\n" 378 "pand _MMX_grn565, %%mm0\n"
495 #else
496 "pand %[_MMX_grn565], %%mm0\n"
497 #endif
498 "por %%mm7, %%mm3\n" 379 "por %%mm7, %%mm3\n"
499 "por %%mm0, %%mm3\n" 380 "por %%mm0, %%mm3\n"
500 381
501 "movq %%mm4, %%mm5\n" 382 "movq %%mm4, %%mm5\n"
502 383
524 "jl 1b\n" 405 "jl 1b\n"
525 "emms\n" 406 "emms\n"
526 "popl %%ebx\n" 407 "popl %%ebx\n"
527 : 408 :
528 :"m" (cr), "r"(cb),"r"(lum), 409 :"m" (cr), "r"(cb),"r"(lum),
529 "r"(row1),"r"(cols),"r"(row2),"m"(x),"m"(y),"m"(mod) 410 "r"(row1),"r"(cols),"r"(row2),"m"(x),"m"(y),"m"(mod));
530 #ifndef GCC2_HACK
531 ,[_MMX_0080w] "m" (*MMX_0080w),
532 [_MMX_Ugrn565] "m" (*MMX_Ugrn565),
533 [_MMX_Ublu5x5] "m" (*MMX_Ublu5x5),
534 [_MMX_00FFw] "m" (*MMX_00FFw),
535 [_MMX_Vgrn565] "m" (*MMX_Vgrn565),
536 [_MMX_Vred5x5] "m" (*MMX_Vred5x5),
537 [_MMX_Ycoeff] "m" (*MMX_Ycoeff),
538 [_MMX_red565] "m" (*MMX_red565),
539 [_MMX_grn565] "m" (*MMX_grn565)
540 #endif
541 );
542 } 411 }
543 412
544 #undef GCC2_HACK
545
546 #endif /* GCC i386 inline assembly */ 413 #endif /* GCC i386 inline assembly */