comparison src/video/SDL_yuv_mmx.c @ 1038:29d7db09776e

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