Mercurial > sdl-ios-xcode
annotate src/video/SDL_yuv_mmx.c @ 1018:012af0b7e8e6
Date: Fri, 24 Dec 2004 23:32:06 -0500
From: Mike Frysinger
Subject: [SDL] minor fix for gcc-2.x building
in src/video/directfb/SDL_DirectFB_video.c, some variables are not declared at
the beginning of scope ... newer gcc's will accept this, but gcc-2.x does not
find attached a simple patch by Matt Taylor to resolve this
http://bugs.gentoo.org/show_bug.cgi?id=75392
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 27 Dec 2004 20:03:53 +0000 |
parents | e0d96eb0af19 |
children | 29d7db09776e |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
769
b8d311d90021
Updated copyright information for 2004 (Happy New Year!)
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
3 Copyright (C) 1997-2004 Sam Lantinga |
0 | 4 |
5 This library is free software; you can redistribute it and/or | |
6 modify it under the terms of the GNU Library General Public | |
7 License as published by the Free Software Foundation; either | |
8 version 2 of the License, or (at your option) any later version. | |
9 | |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 Library General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU Library General Public | |
16 License along with this library; if not, write to the Free | |
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | |
19 Sam Lantinga | |
252
e8157fcb3114
Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
20 slouken@libsdl.org |
0 | 21 */ |
22 | |
23 #ifdef SAVE_RCSID | |
24 static char rcsid = | |
25 "@(#) $Id$"; | |
26 #endif | |
27 | |
28 | |
29 #if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT) | |
30 | |
31 #include "SDL_types.h" | |
32 | |
946
8520712f8ef0
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
887
diff
changeset
|
33 static unsigned int MMX_0080w[] = {0x00800080, 0x00800080}; |
8520712f8ef0
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
887
diff
changeset
|
34 static unsigned int MMX_00FFw[] = {0x00ff00ff, 0x00ff00ff}; |
8520712f8ef0
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
887
diff
changeset
|
35 static unsigned int MMX_FF00w[] = {0xff00ff00, 0xff00ff00}; |
0 | 36 |
946
8520712f8ef0
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
887
diff
changeset
|
37 static unsigned short MMX_Ycoeff[] = {0x004a, 0x004a, 0x004a, 0x004a}; |
0 | 38 |
946
8520712f8ef0
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
887
diff
changeset
|
39 static unsigned short MMX_UbluRGB[] = {0x0072, 0x0072, 0x0072, 0x0072}; |
8520712f8ef0
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
887
diff
changeset
|
40 static unsigned short MMX_VredRGB[] = {0x0059, 0x0059, 0x0059, 0x0059}; |
8520712f8ef0
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
887
diff
changeset
|
41 static unsigned short MMX_UgrnRGB[] = {0xffea, 0xffea, 0xffea, 0xffea}; |
8520712f8ef0
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
887
diff
changeset
|
42 static unsigned short MMX_VgrnRGB[] = {0xffd2, 0xffd2, 0xffd2, 0xffd2}; |
0 | 43 |
946
8520712f8ef0
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
887
diff
changeset
|
44 static unsigned short MMX_Ublu5x5[] = {0x0081, 0x0081, 0x0081, 0x0081}; |
8520712f8ef0
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
887
diff
changeset
|
45 static unsigned short MMX_Vred5x5[] = {0x0066, 0x0066, 0x0066, 0x0066}; |
8520712f8ef0
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
887
diff
changeset
|
46 static unsigned short MMX_Ugrn555[] = {0xffe7, 0xffe7, 0xffe7, 0xffe7}; |
8520712f8ef0
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
887
diff
changeset
|
47 static unsigned short MMX_Vgrn555[] = {0xffcc, 0xffcc, 0xffcc, 0xffcc}; |
8520712f8ef0
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
887
diff
changeset
|
48 static unsigned short MMX_Ugrn565[] = {0xffe8, 0xffe8, 0xffe8, 0xffe8}; |
8520712f8ef0
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
887
diff
changeset
|
49 static unsigned short MMX_Vgrn565[] = {0xffcd, 0xffcd, 0xffcd, 0xffcd}; |
0 | 50 |
946
8520712f8ef0
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
887
diff
changeset
|
51 static unsigned short MMX_red555[] = {0x7c00, 0x7c00, 0x7c00, 0x7c00}; |
8520712f8ef0
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
887
diff
changeset
|
52 static unsigned short MMX_red565[] = {0xf800, 0xf800, 0xf800, 0xf800}; |
8520712f8ef0
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
887
diff
changeset
|
53 static unsigned short MMX_grn555[] = {0x03e0, 0x03e0, 0x03e0, 0x03e0}; |
8520712f8ef0
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
887
diff
changeset
|
54 static unsigned short MMX_grn565[] = {0x07e0, 0x07e0, 0x07e0, 0x07e0}; |
8520712f8ef0
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
887
diff
changeset
|
55 static unsigned short MMX_blu5x5[] = {0x001f, 0x001f, 0x001f, 0x001f}; |
0 | 56 |
57 /** | |
58 This MMX assembler is my first assembler/MMX program ever. | |
59 Thus it maybe buggy. | |
60 Send patches to: | |
61 mvogt@rhrk.uni-kl.de | |
62 | |
63 After it worked fine I have "obfuscated" the code a bit to have | |
64 more parallism in the MMX units. This means I moved | |
65 initilisation around and delayed other instruction. | |
66 Performance measurement did not show that this brought any advantage | |
67 but in theory it _should_ be faster this way. | |
68 | |
69 The overall performanve gain to the C based dither was 30%-40%. | |
70 The MMX routine calculates 256bit=8RGB values in each cycle | |
71 (4 for row1 & 4 for row2) | |
72 | |
73 The red/green/blue.. coefficents are taken from the mpeg_play | |
74 player. They look nice, but I dont know if you can have | |
75 better values, to avoid integer rounding errors. | |
76 | |
77 | |
78 IMPORTANT: | |
79 ========== | |
80 | |
81 It is a requirement that the cr/cb/lum are 8 byte aligned and | |
82 the out are 16byte aligned or you will/may get segfaults | |
83 | |
84 */ | |
85 | |
86 void ColorRGBDitherYV12MMX1X( int *colortab, Uint32 *rgb_2_pix, | |
87 unsigned char *lum, unsigned char *cr, | |
88 unsigned char *cb, unsigned char *out, | |
89 int rows, int cols, int mod ) | |
90 { | |
91 Uint32 *row1; | |
92 Uint32 *row2; | |
93 | |
94 unsigned char* y = lum +cols*rows; // Pointer to the end | |
95 int x=0; | |
96 row1 = (Uint32 *)out; // 32 bit target | |
97 row2 = (Uint32 *)out+cols+mod; // start of second row | |
98 mod = (mod+cols+mod)*4; // increment for row1 in byte | |
99 | |
100 __asm__ __volatile__ ( | |
101 /* We don't really care about PIC - the code should be rewritten to use | |
102 relative addressing for the static tables, so right now we take the | |
103 COW hit on the pages this code resides. Big deal. | |
104 This spill is just to reduce register pressure in the PIC case. */ | |
105 "pushl %%ebx\n" | |
106 "movl %0, %%ebx\n" | |
107 | |
108 ".align 8\n" | |
109 "1:\n" | |
110 | |
111 // create Cr (result in mm1) | |
112 "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 | |
114 "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 | |
116 "punpckldq %%mm1,%%mm1\n" // 00 v1 00 v0 00 v1 00 v0 | |
887
b4b64bb88f2f
Date: Mon, 10 May 2004 10:17:46 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
117 "psubw %[_MMX_0080w],%%mm1\n" // mm1-128:r1 r1 r0 r0 r1 r1 r0 r0 |
0 | 118 |
119 // create Cr_g (result in mm0) | |
120 "movq %%mm1,%%mm0\n" // r1 r1 r0 r0 r1 r1 r0 r0 | |
887
b4b64bb88f2f
Date: Mon, 10 May 2004 10:17:46 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
121 "pmullw %[_MMX_VgrnRGB],%%mm0\n"// red*-46dec=0.7136*64 |
b4b64bb88f2f
Date: Mon, 10 May 2004 10:17:46 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
122 "pmullw %[_MMX_VredRGB],%%mm1\n"// red*89dec=1.4013*64 |
0 | 123 "psraw $6, %%mm0\n" // red=red/64 |
124 "psraw $6, %%mm1\n" // red=red/64 | |
125 | |
126 // create L1 L2 (result in mm2,mm4) | |
127 // L2=lum+cols | |
128 "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 | |
130 "movq %%mm2,%%mm4\n" // L3 L2 L1 L0 l3 l2 l1 l0 | |
887
b4b64bb88f2f
Date: Mon, 10 May 2004 10:17:46 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
131 "pand %[_MMX_FF00w],%%mm2\n" // L3 0 L1 0 l3 0 l1 0 |
b4b64bb88f2f
Date: Mon, 10 May 2004 10:17:46 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
132 "pand %[_MMX_00FFw],%%mm4\n" // 0 L2 0 L0 0 l2 0 l0 |
0 | 133 "psrlw $8,%%mm2\n" // 0 L3 0 L1 0 l3 0 l1 |
134 | |
135 // create R (result in mm6) | |
136 "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 | |
138 "paddsw %%mm1, %%mm5\n" // lum1+red:x R3 x R1 x r3 x r1 | |
139 "paddsw %%mm1, %%mm6\n" // lum1+red:x R2 x R0 x r2 x r0 | |
140 "packuswb %%mm5,%%mm5\n" // R3 R1 r3 r1 R3 R1 r3 r1 | |
141 "packuswb %%mm6,%%mm6\n" // R2 R0 r2 r0 R2 R0 r2 r0 | |
142 "pxor %%mm7,%%mm7\n" // 00 00 00 00 00 00 00 00 | |
143 "punpcklbw %%mm5,%%mm6\n" // R3 R2 R1 R0 r3 r2 r1 r0 | |
144 | |
145 // create Cb (result in mm1) | |
146 "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 | |
148 "punpckldq %%mm1,%%mm1\n" // 00 u1 00 u0 00 u1 00 u0 | |
887
b4b64bb88f2f
Date: Mon, 10 May 2004 10:17:46 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
149 "psubw %[_MMX_0080w],%%mm1\n" // mm1-128:u1 u1 u0 u0 u1 u1 u0 u0 |
0 | 150 // create Cb_g (result in mm5) |
151 "movq %%mm1,%%mm5\n" // u1 u1 u0 u0 u1 u1 u0 u0 | |
887
b4b64bb88f2f
Date: Mon, 10 May 2004 10:17:46 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
152 "pmullw %[_MMX_UgrnRGB],%%mm5\n" // blue*-109dec=1.7129*64 |
b4b64bb88f2f
Date: Mon, 10 May 2004 10:17:46 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
153 "pmullw %[_MMX_UbluRGB],%%mm1\n" // blue*114dec=1.78125*64 |
0 | 154 "psraw $6, %%mm5\n" // blue=red/64 |
155 "psraw $6, %%mm1\n" // blue=blue/64 | |
156 | |
157 // create G (result in mm7) | |
158 "movq %%mm2,%%mm3\n" // 0 L3 0 L1 0 l3 0 l1 | |
159 "movq %%mm4,%%mm7\n" // 0 L2 0 L0 0 l2 0 l1 | |
160 "paddsw %%mm5, %%mm3\n" // lum1+Cb_g:x G3t x G1t x g3t x g1t | |
161 "paddsw %%mm5, %%mm7\n" // lum1+Cb_g:x G2t x G0t x g2t x g0t | |
162 "paddsw %%mm0, %%mm3\n" // lum1+Cr_g:x G3 x G1 x g3 x g1 | |
163 "paddsw %%mm0, %%mm7\n" // lum1+blue:x G2 x G0 x g2 x g0 | |
164 "packuswb %%mm3,%%mm3\n" // G3 G1 g3 g1 G3 G1 g3 g1 | |
165 "packuswb %%mm7,%%mm7\n" // G2 G0 g2 g0 G2 G0 g2 g0 | |
166 "punpcklbw %%mm3,%%mm7\n" // G3 G2 G1 G0 g3 g2 g1 g0 | |
167 | |
168 // create B (result in mm5) | |
169 "movq %%mm2,%%mm3\n" // 0 L3 0 L1 0 l3 0 l1 | |
170 "movq %%mm4,%%mm5\n" // 0 L2 0 L0 0 l2 0 l1 | |
171 "paddsw %%mm1, %%mm3\n" // lum1+blue:x B3 x B1 x b3 x b1 | |
172 "paddsw %%mm1, %%mm5\n" // lum1+blue:x B2 x B0 x b2 x b0 | |
173 "packuswb %%mm3,%%mm3\n" // B3 B1 b3 b1 B3 B1 b3 b1 | |
174 "packuswb %%mm5,%%mm5\n" // B2 B0 b2 b0 B2 B0 b2 b0 | |
175 "punpcklbw %%mm3,%%mm5\n" // B3 B2 B1 B0 b3 b2 b1 b0 | |
176 | |
177 // fill destination row1 (needed are mm6=Rr,mm7=Gg,mm5=Bb) | |
178 | |
179 "pxor %%mm2,%%mm2\n" // 0 0 0 0 0 0 0 0 | |
180 "pxor %%mm4,%%mm4\n" // 0 0 0 0 0 0 0 0 | |
181 "movq %%mm6,%%mm1\n" // R3 R2 R1 R0 r3 r2 r1 r0 | |
182 "movq %%mm5,%%mm3\n" // B3 B2 B1 B0 b3 b2 b1 b0 | |
183 // process lower lum | |
184 "punpcklbw %%mm4,%%mm1\n" // 0 r3 0 r2 0 r1 0 r0 | |
185 "punpcklbw %%mm4,%%mm3\n" // 0 b3 0 b2 0 b1 0 b0 | |
186 "movq %%mm1,%%mm2\n" // 0 r3 0 r2 0 r1 0 r0 | |
187 "movq %%mm3,%%mm0\n" // 0 b3 0 b2 0 b1 0 b0 | |
188 "punpcklwd %%mm1,%%mm3\n" // 0 r1 0 b1 0 r0 0 b0 | |
189 "punpckhwd %%mm2,%%mm0\n" // 0 r3 0 b3 0 r2 0 b2 | |
190 | |
191 "pxor %%mm2,%%mm2\n" // 0 0 0 0 0 0 0 0 | |
192 "movq %%mm7,%%mm1\n" // G3 G2 G1 G0 g3 g2 g1 g0 | |
193 "punpcklbw %%mm1,%%mm2\n" // g3 0 g2 0 g1 0 g0 0 | |
194 "punpcklwd %%mm4,%%mm2\n" // 0 0 g1 0 0 0 g0 0 | |
195 "por %%mm3, %%mm2\n" // 0 r1 g1 b1 0 r0 g0 b0 | |
196 "movq %%mm2,(%3)\n" // wrote out ! row1 | |
197 | |
198 "pxor %%mm2,%%mm2\n" // 0 0 0 0 0 0 0 0 | |
199 "punpcklbw %%mm1,%%mm4\n" // g3 0 g2 0 g1 0 g0 0 | |
200 "punpckhwd %%mm2,%%mm4\n" // 0 0 g3 0 0 0 g2 0 | |
201 "por %%mm0, %%mm4\n" // 0 r3 g3 b3 0 r2 g2 b2 | |
202 "movq %%mm4,8(%3)\n" // wrote out ! row1 | |
203 | |
204 // fill destination row2 (needed are mm6=Rr,mm7=Gg,mm5=Bb) | |
205 // this can be done "destructive" | |
206 "pxor %%mm2,%%mm2\n" // 0 0 0 0 0 0 0 0 | |
207 "punpckhbw %%mm2,%%mm6\n" // 0 R3 0 R2 0 R1 0 R0 | |
208 "punpckhbw %%mm1,%%mm5\n" // G3 B3 G2 B2 G1 B1 G0 B0 | |
209 "movq %%mm5,%%mm1\n" // G3 B3 G2 B2 G1 B1 G0 B0 | |
210 "punpcklwd %%mm6,%%mm1\n" // 0 R1 G1 B1 0 R0 G0 B0 | |
211 "movq %%mm1,(%5)\n" // wrote out ! row2 | |
212 "punpckhwd %%mm6,%%mm5\n" // 0 R3 G3 B3 0 R2 G2 B2 | |
213 "movq %%mm5,8(%5)\n" // wrote out ! row2 | |
214 | |
215 "addl $4,%2\n" // lum+4 | |
216 "leal 16(%3),%3\n" // row1+16 | |
217 "leal 16(%5),%5\n" // row2+16 | |
218 "addl $2, %%ebx\n" // cr+2 | |
219 "addl $2, %1\n" // cb+2 | |
220 | |
221 "addl $4,%6\n" // x+4 | |
222 "cmpl %4,%6\n" | |
223 | |
224 "jl 1b\n" | |
225 "addl %4, %2\n" // lum += cols | |
226 "addl %8, %3\n" // row1+= mod | |
227 "addl %8, %5\n" // row2+= mod | |
228 "movl $0, %6\n" // x=0 | |
229 "cmpl %7, %2\n" | |
230 "jl 1b\n" | |
231 "emms\n" | |
232 "popl %%ebx\n" | |
233 : | |
234 : "m" (cr), "r"(cb),"r"(lum), | |
949
e0d96eb0af19
I don't know how this got missed, but...
Sam Lantinga <slouken@libsdl.org>
parents:
946
diff
changeset
|
235 "r"(row1),"r"(cols),"r"(row2),"m"(x),"m"(y),"m"(mod), |
e0d96eb0af19
I don't know how this got missed, but...
Sam Lantinga <slouken@libsdl.org>
parents:
946
diff
changeset
|
236 [_MMX_0080w] "m" (*MMX_0080w), |
e0d96eb0af19
I don't know how this got missed, but...
Sam Lantinga <slouken@libsdl.org>
parents:
946
diff
changeset
|
237 [_MMX_00FFw] "m" (*MMX_00FFw), |
e0d96eb0af19
I don't know how this got missed, but...
Sam Lantinga <slouken@libsdl.org>
parents:
946
diff
changeset
|
238 [_MMX_FF00w] "m" (*MMX_FF00w), |
e0d96eb0af19
I don't know how this got missed, but...
Sam Lantinga <slouken@libsdl.org>
parents:
946
diff
changeset
|
239 [_MMX_VgrnRGB] "m" (*MMX_VgrnRGB), |
e0d96eb0af19
I don't know how this got missed, but...
Sam Lantinga <slouken@libsdl.org>
parents:
946
diff
changeset
|
240 [_MMX_VredRGB] "m" (*MMX_VredRGB), |
e0d96eb0af19
I don't know how this got missed, but...
Sam Lantinga <slouken@libsdl.org>
parents:
946
diff
changeset
|
241 [_MMX_UgrnRGB] "m" (*MMX_UgrnRGB), |
e0d96eb0af19
I don't know how this got missed, but...
Sam Lantinga <slouken@libsdl.org>
parents:
946
diff
changeset
|
242 [_MMX_UbluRGB] "m" (*MMX_UbluRGB) |
0 | 243 ); |
244 } | |
245 | |
246 void Color565DitherYV12MMX1X( int *colortab, Uint32 *rgb_2_pix, | |
247 unsigned char *lum, unsigned char *cr, | |
248 unsigned char *cb, unsigned char *out, | |
249 int rows, int cols, int mod ) | |
250 { | |
251 Uint16 *row1; | |
252 Uint16 *row2; | |
253 | |
254 unsigned char* y = lum +cols*rows; /* Pointer to the end */ | |
255 int x=0; | |
256 row1 = (Uint16 *)out; /* 16 bit target */ | |
257 row2 = (Uint16 *)out+cols+mod; /* start of second row */ | |
258 mod = (mod+cols+mod)*2; /* increment for row1 in byte */ | |
259 | |
260 | |
261 __asm__ __volatile__( | |
262 "pushl %%ebx\n" | |
263 "movl %0, %%ebx\n" | |
264 | |
265 ".align 8\n" | |
266 "1:\n" | |
267 "movd (%1), %%mm0\n" // 4 Cb 0 0 0 0 u3 u2 u1 u0 | |
268 "pxor %%mm7, %%mm7\n" | |
269 "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 | |
271 "punpcklbw %%mm7, %%mm1\n" // 4 W cr 0 v3 0 v2 0 v1 0 v0 | |
949
e0d96eb0af19
I don't know how this got missed, but...
Sam Lantinga <slouken@libsdl.org>
parents:
946
diff
changeset
|
272 "psubw %[_MMX_0080w], %%mm0\n" |
e0d96eb0af19
I don't know how this got missed, but...
Sam Lantinga <slouken@libsdl.org>
parents:
946
diff
changeset
|
273 "psubw %[_MMX_0080w], %%mm1\n" |
0 | 274 "movq %%mm0, %%mm2\n" // Cb 0 u3 0 u2 0 u1 0 u0 |
275 "movq %%mm1, %%mm3\n" // Cr | |
949
e0d96eb0af19
I don't know how this got missed, but...
Sam Lantinga <slouken@libsdl.org>
parents:
946
diff
changeset
|
276 "pmullw %[_MMX_Ugrn565], %%mm2\n" // Cb2green 0 R3 0 R2 0 R1 0 R0 |
0 | 277 "movq (%2), %%mm6\n" // L1 l7 L6 L5 L4 L3 L2 L1 L0 |
949
e0d96eb0af19
I don't know how this got missed, but...
Sam Lantinga <slouken@libsdl.org>
parents:
946
diff
changeset
|
278 "pmullw %[_MMX_Ublu5x5], %%mm0\n" // Cb2blue |
e0d96eb0af19
I don't know how this got missed, but...
Sam Lantinga <slouken@libsdl.org>
parents:
946
diff
changeset
|
279 "pand %[_MMX_00FFw], %%mm6\n" // L1 00 L6 00 L4 00 L2 00 L0 |
e0d96eb0af19
I don't know how this got missed, but...
Sam Lantinga <slouken@libsdl.org>
parents:
946
diff
changeset
|
280 "pmullw %[_MMX_Vgrn565], %%mm3\n" // Cr2green |
0 | 281 "movq (%2), %%mm7\n" // L2 |
949
e0d96eb0af19
I don't know how this got missed, but...
Sam Lantinga <slouken@libsdl.org>
parents:
946
diff
changeset
|
282 "pmullw %[_MMX_Vred5x5], %%mm1\n" // Cr2red |
0 | 283 "psrlw $8, %%mm7\n" // L2 00 L7 00 L5 00 L3 00 L1 |
949
e0d96eb0af19
I don't know how this got missed, but...
Sam Lantinga <slouken@libsdl.org>
parents:
946
diff
changeset
|
284 "pmullw %[_MMX_Ycoeff], %%mm6\n" // lum1 |
0 | 285 "paddw %%mm3, %%mm2\n" // Cb2green + Cr2green == green |
949
e0d96eb0af19
I don't know how this got missed, but...
Sam Lantinga <slouken@libsdl.org>
parents:
946
diff
changeset
|
286 "pmullw %[_MMX_Ycoeff], %%mm7\n" // lum2 |
0 | 287 |
288 "movq %%mm6, %%mm4\n" // lum1 | |
289 "paddw %%mm0, %%mm6\n" // lum1 +blue 00 B6 00 B4 00 B2 00 B0 | |
290 "movq %%mm4, %%mm5\n" // lum1 | |
291 "paddw %%mm1, %%mm4\n" // lum1 +red 00 R6 00 R4 00 R2 00 R0 | |
292 "paddw %%mm2, %%mm5\n" // lum1 +green 00 G6 00 G4 00 G2 00 G0 | |
293 "psraw $6, %%mm4\n" // R1 0 .. 64 | |
294 "movq %%mm7, %%mm3\n" // lum2 00 L7 00 L5 00 L3 00 L1 | |
295 "psraw $6, %%mm5\n" // G1 - .. + | |
296 "paddw %%mm0, %%mm7\n" // Lum2 +blue 00 B7 00 B5 00 B3 00 B1 | |
297 "psraw $6, %%mm6\n" // B1 0 .. 64 | |
298 "packuswb %%mm4, %%mm4\n" // R1 R1 | |
299 "packuswb %%mm5, %%mm5\n" // G1 G1 | |
300 "packuswb %%mm6, %%mm6\n" // B1 B1 | |
301 "punpcklbw %%mm4, %%mm4\n" | |
302 "punpcklbw %%mm5, %%mm5\n" | |
303 | |
949
e0d96eb0af19
I don't know how this got missed, but...
Sam Lantinga <slouken@libsdl.org>
parents:
946
diff
changeset
|
304 "pand %[_MMX_red565], %%mm4\n" |
0 | 305 "psllw $3, %%mm5\n" // GREEN 1 |
306 "punpcklbw %%mm6, %%mm6\n" | |
949
e0d96eb0af19
I don't know how this got missed, but...
Sam Lantinga <slouken@libsdl.org>
parents:
946
diff
changeset
|
307 "pand %[_MMX_grn565], %%mm5\n" |
e0d96eb0af19
I don't know how this got missed, but...
Sam Lantinga <slouken@libsdl.org>
parents:
946
diff
changeset
|
308 "pand %[_MMX_red565], %%mm6\n" |
0 | 309 "por %%mm5, %%mm4\n" // |
310 "psrlw $11, %%mm6\n" // BLUE 1 | |
311 "movq %%mm3, %%mm5\n" // lum2 | |
312 "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 | |
314 "psraw $6, %%mm3\n" // R2 | |
315 "por %%mm6, %%mm4\n" // MM4 | |
316 "psraw $6, %%mm5\n" // G2 | |
317 "movq (%2, %4), %%mm6\n" // L3 load lum2 | |
318 "psraw $6, %%mm7\n" | |
319 "packuswb %%mm3, %%mm3\n" | |
320 "packuswb %%mm5, %%mm5\n" | |
321 "packuswb %%mm7, %%mm7\n" | |
949
e0d96eb0af19
I don't know how this got missed, but...
Sam Lantinga <slouken@libsdl.org>
parents:
946
diff
changeset
|
322 "pand %[_MMX_00FFw], %%mm6\n" // L3 |
0 | 323 "punpcklbw %%mm3, %%mm3\n" |
324 "punpcklbw %%mm5, %%mm5\n" | |
949
e0d96eb0af19
I don't know how this got missed, but...
Sam Lantinga <slouken@libsdl.org>
parents:
946
diff
changeset
|
325 "pmullw %[_MMX_Ycoeff], %%mm6\n" // lum3 |
0 | 326 "punpcklbw %%mm7, %%mm7\n" |
327 "psllw $3, %%mm5\n" // GREEN 2 | |
949
e0d96eb0af19
I don't know how this got missed, but...
Sam Lantinga <slouken@libsdl.org>
parents:
946
diff
changeset
|
328 "pand %[_MMX_red565], %%mm7\n" |
e0d96eb0af19
I don't know how this got missed, but...
Sam Lantinga <slouken@libsdl.org>
parents:
946
diff
changeset
|
329 "pand %[_MMX_red565], %%mm3\n" |
0 | 330 "psrlw $11, %%mm7\n" // BLUE 2 |
949
e0d96eb0af19
I don't know how this got missed, but...
Sam Lantinga <slouken@libsdl.org>
parents:
946
diff
changeset
|
331 "pand %[_MMX_grn565], %%mm5\n" |
0 | 332 "por %%mm7, %%mm3\n" |
333 "movq (%2,%4), %%mm7\n" // L4 load lum2 | |
334 "por %%mm5, %%mm3\n" // | |
335 "psrlw $8, %%mm7\n" // L4 | |
336 "movq %%mm4, %%mm5\n" | |
337 "punpcklwd %%mm3, %%mm4\n" | |
949
e0d96eb0af19
I don't know how this got missed, but...
Sam Lantinga <slouken@libsdl.org>
parents:
946
diff
changeset
|
338 "pmullw %[_MMX_Ycoeff], %%mm7\n" // lum4 |
0 | 339 "punpckhwd %%mm3, %%mm5\n" |
340 | |
341 "movq %%mm4, (%3)\n" // write row1 | |
342 "movq %%mm5, 8(%3)\n" // write row1 | |
343 | |
344 "movq %%mm6, %%mm4\n" // Lum3 | |
345 "paddw %%mm0, %%mm6\n" // Lum3 +blue | |
346 | |
347 "movq %%mm4, %%mm5\n" // Lum3 | |
348 "paddw %%mm1, %%mm4\n" // Lum3 +red | |
349 "paddw %%mm2, %%mm5\n" // Lum3 +green | |
350 "psraw $6, %%mm4\n" | |
351 "movq %%mm7, %%mm3\n" // Lum4 | |
352 "psraw $6, %%mm5\n" | |
353 "paddw %%mm0, %%mm7\n" // Lum4 +blue | |
354 "psraw $6, %%mm6\n" // Lum3 +blue | |
355 "movq %%mm3, %%mm0\n" // Lum4 | |
356 "packuswb %%mm4, %%mm4\n" | |
357 "paddw %%mm1, %%mm3\n" // Lum4 +red | |
358 "packuswb %%mm5, %%mm5\n" | |
359 "paddw %%mm2, %%mm0\n" // Lum4 +green | |
360 "packuswb %%mm6, %%mm6\n" | |
361 "punpcklbw %%mm4, %%mm4\n" | |
362 "punpcklbw %%mm5, %%mm5\n" | |
363 "punpcklbw %%mm6, %%mm6\n" | |
364 "psllw $3, %%mm5\n" // GREEN 3 | |
949
e0d96eb0af19
I don't know how this got missed, but...
Sam Lantinga <slouken@libsdl.org>
parents:
946
diff
changeset
|
365 "pand %[_MMX_red565], %%mm4\n" |
0 | 366 "psraw $6, %%mm3\n" // psr 6 |
367 "psraw $6, %%mm0\n" | |
949
e0d96eb0af19
I don't know how this got missed, but...
Sam Lantinga <slouken@libsdl.org>
parents:
946
diff
changeset
|
368 "pand %[_MMX_red565], %%mm6\n" // BLUE |
e0d96eb0af19
I don't know how this got missed, but...
Sam Lantinga <slouken@libsdl.org>
parents:
946
diff
changeset
|
369 "pand %[_MMX_grn565], %%mm5\n" |
0 | 370 "psrlw $11, %%mm6\n" // BLUE 3 |
371 "por %%mm5, %%mm4\n" | |
372 "psraw $6, %%mm7\n" | |
373 "por %%mm6, %%mm4\n" | |
374 "packuswb %%mm3, %%mm3\n" | |
375 "packuswb %%mm0, %%mm0\n" | |
376 "packuswb %%mm7, %%mm7\n" | |
377 "punpcklbw %%mm3, %%mm3\n" | |
378 "punpcklbw %%mm0, %%mm0\n" | |
379 "punpcklbw %%mm7, %%mm7\n" | |
949
e0d96eb0af19
I don't know how this got missed, but...
Sam Lantinga <slouken@libsdl.org>
parents:
946
diff
changeset
|
380 "pand %[_MMX_red565], %%mm3\n" |
e0d96eb0af19
I don't know how this got missed, but...
Sam Lantinga <slouken@libsdl.org>
parents:
946
diff
changeset
|
381 "pand %[_MMX_red565], %%mm7\n" // BLUE |
0 | 382 "psllw $3, %%mm0\n" // GREEN 4 |
383 "psrlw $11, %%mm7\n" | |
949
e0d96eb0af19
I don't know how this got missed, but...
Sam Lantinga <slouken@libsdl.org>
parents:
946
diff
changeset
|
384 "pand %[_MMX_grn565], %%mm0\n" |
0 | 385 "por %%mm7, %%mm3\n" |
386 "por %%mm0, %%mm3\n" | |
387 | |
388 "movq %%mm4, %%mm5\n" | |
389 | |
390 "punpcklwd %%mm3, %%mm4\n" | |
391 "punpckhwd %%mm3, %%mm5\n" | |
392 | |
393 "movq %%mm4, (%5)\n" | |
394 "movq %%mm5, 8(%5)\n" | |
395 | |
396 "addl $8, %6\n" | |
397 "addl $8, %2\n" | |
398 "addl $4, %%ebx\n" | |
399 "addl $4, %1\n" | |
400 "cmpl %4, %6\n" | |
401 "leal 16(%3), %3\n" | |
402 "leal 16(%5),%5\n" // row2+16 | |
403 | |
404 | |
405 "jl 1b\n" | |
406 "addl %4, %2\n" // lum += cols | |
407 "addl %8, %3\n" // row1+= mod | |
408 "addl %8, %5\n" // row2+= mod | |
409 "movl $0, %6\n" // x=0 | |
410 "cmpl %7, %2\n" | |
411 "jl 1b\n" | |
412 "emms\n" | |
413 "popl %%ebx\n" | |
946
8520712f8ef0
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
887
diff
changeset
|
414 : |
8520712f8ef0
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
887
diff
changeset
|
415 :"m" (cr), "r"(cb),"r"(lum), |
887
b4b64bb88f2f
Date: Mon, 10 May 2004 10:17:46 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
416 "r"(row1),"r"(cols),"r"(row2),"m"(x),"m"(y),"m"(mod), |
949
e0d96eb0af19
I don't know how this got missed, but...
Sam Lantinga <slouken@libsdl.org>
parents:
946
diff
changeset
|
417 [_MMX_0080w] "m" (*MMX_0080w), |
e0d96eb0af19
I don't know how this got missed, but...
Sam Lantinga <slouken@libsdl.org>
parents:
946
diff
changeset
|
418 [_MMX_Ugrn565] "m" (*MMX_Ugrn565), |
e0d96eb0af19
I don't know how this got missed, but...
Sam Lantinga <slouken@libsdl.org>
parents:
946
diff
changeset
|
419 [_MMX_Ublu5x5] "m" (*MMX_Ublu5x5), |
e0d96eb0af19
I don't know how this got missed, but...
Sam Lantinga <slouken@libsdl.org>
parents:
946
diff
changeset
|
420 [_MMX_00FFw] "m" (*MMX_00FFw), |
e0d96eb0af19
I don't know how this got missed, but...
Sam Lantinga <slouken@libsdl.org>
parents:
946
diff
changeset
|
421 [_MMX_Vgrn565] "m" (*MMX_Vgrn565), |
e0d96eb0af19
I don't know how this got missed, but...
Sam Lantinga <slouken@libsdl.org>
parents:
946
diff
changeset
|
422 [_MMX_Vred5x5] "m" (*MMX_Vred5x5), |
e0d96eb0af19
I don't know how this got missed, but...
Sam Lantinga <slouken@libsdl.org>
parents:
946
diff
changeset
|
423 [_MMX_Ycoeff] "m" (*MMX_Ycoeff), |
e0d96eb0af19
I don't know how this got missed, but...
Sam Lantinga <slouken@libsdl.org>
parents:
946
diff
changeset
|
424 [_MMX_red565] "m" (*MMX_red565), |
e0d96eb0af19
I don't know how this got missed, but...
Sam Lantinga <slouken@libsdl.org>
parents:
946
diff
changeset
|
425 [_MMX_grn565] "m" (*MMX_grn565) |
0 | 426 ); |
427 } | |
428 | |
429 #endif /* GCC i386 inline assembly */ |