Mercurial > sdl-ios-xcode
comparison src/video/SDL_yuv_mmx.c @ 4046:3a9e60224efe SDL-1.2
Cleaned up tabs.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Wed, 11 Jul 2007 07:21:39 +0000 |
parents | f420bba13676 |
children | 810c6f4ab7aa |
comparison
equal
deleted
inserted
replaced
4045:f420bba13676 | 4046:3a9e60224efe |
---|---|
93 row1 = (Uint32 *)out; // 32 bit target | 93 row1 = (Uint32 *)out; // 32 bit target |
94 row2 = (Uint32 *)out+cols+mod; // start of second row | 94 row2 = (Uint32 *)out+cols+mod; // start of second row |
95 mod = (mod+cols+mod)*4; // increment for row1 in byte | 95 mod = (mod+cols+mod)*4; // increment for row1 in byte |
96 | 96 |
97 __asm__ __volatile__ ( | 97 __asm__ __volatile__ ( |
98 // tap dance to workaround the inability to use %%ebx at will... | 98 // tap dance to workaround the inability to use %%ebx at will... |
99 // move one thing to the stack... | 99 // move one thing to the stack... |
100 "pushl $0\n" // save a slot on the stack. | 100 "pushl $0\n" // save a slot on the stack. |
101 "pushl %%ebx\n" // save %%ebx. | 101 "pushl %%ebx\n" // save %%ebx. |
102 "movl %0, %%ebx\n" // put the thing in ebx. | 102 "movl %0, %%ebx\n" // put the thing in ebx. |
103 "movl %%ebx, 4(%%esp)\n" // put the thing in the stack slot. | 103 "movl %%ebx,4(%%esp)\n" // put the thing in the stack slot. |
104 "popl %%ebx\n" // get back %%ebx (the PIC register). | 104 "popl %%ebx\n" // get back %%ebx (the PIC register). |
105 | 105 |
106 ".align 8\n" | 106 ".align 8\n" |
107 "1:\n" | 107 "1:\n" |
108 | 108 |
109 // create Cr (result in mm1) | 109 // create Cr (result in mm1) |
110 "pushl %%ebx\n" | 110 "pushl %%ebx\n" |
111 "movl 4(%%esp), %%ebx\n" | 111 "movl 4(%%esp),%%ebx\n" |
112 "movd (%%ebx), %%mm1\n" // 0 0 0 0 v3 v2 v1 v0 | 112 "movd (%%ebx),%%mm1\n" // 0 0 0 0 v3 v2 v1 v0 |
113 "popl %%ebx\n" | 113 "popl %%ebx\n" |
114 "pxor %%mm7,%%mm7\n" // 00 00 00 00 00 00 00 00 | 114 "pxor %%mm7,%%mm7\n" // 00 00 00 00 00 00 00 00 |
115 "movd (%2), %%mm2\n" // 0 0 0 0 l3 l2 l1 l0 | 115 "movd (%2), %%mm2\n" // 0 0 0 0 l3 l2 l1 l0 |
116 "punpcklbw %%mm7,%%mm1\n" // 0 v3 0 v2 00 v1 00 v0 | 116 "punpcklbw %%mm7,%%mm1\n" // 0 v3 0 v2 00 v1 00 v0 |
117 "punpckldq %%mm1,%%mm1\n" // 00 v1 00 v0 00 v1 00 v0 | 117 "punpckldq %%mm1,%%mm1\n" // 00 v1 00 v0 00 v1 00 v0 |
118 "psubw %9,%%mm1\n" // mm1-128:r1 r1 r0 r0 r1 r1 r0 r0 | 118 "psubw %9,%%mm1\n" // mm1-128:r1 r1 r0 r0 r1 r1 r0 r0 |
119 | 119 |
120 // create Cr_g (result in mm0) | 120 // create Cr_g (result in mm0) |
121 "movq %%mm1,%%mm0\n" // r1 r1 r0 r0 r1 r1 r0 r0 | 121 "movq %%mm1,%%mm0\n" // r1 r1 r0 r0 r1 r1 r0 r0 |
122 "pmullw %10,%%mm0\n" // red*-46dec=0.7136*64 | 122 "pmullw %10,%%mm0\n" // red*-46dec=0.7136*64 |
123 "pmullw %11,%%mm1\n" // red*89dec=1.4013*64 | 123 "pmullw %11,%%mm1\n" // red*89dec=1.4013*64 |
124 "psraw $6, %%mm0\n" // red=red/64 | 124 "psraw $6, %%mm0\n" // red=red/64 |
125 "psraw $6, %%mm1\n" // red=red/64 | 125 "psraw $6, %%mm1\n" // red=red/64 |
126 | |
127 // create L1 L2 (result in mm2,mm4) | |
128 // L2=lum+cols | |
129 "movq (%2,%4),%%mm3\n" // 0 0 0 0 L3 L2 L1 L0 | |
130 "punpckldq %%mm3,%%mm2\n" // L3 L2 L1 L0 l3 l2 l1 l0 | |
131 "movq %%mm2,%%mm4\n" // L3 L2 L1 L0 l3 l2 l1 l0 | |
132 "pand %12,%%mm2\n" // L3 0 L1 0 l3 0 l1 0 | |
133 "pand %13,%%mm4\n" // 0 L2 0 L0 0 l2 0 l0 | |
134 "psrlw $8,%%mm2\n" // 0 L3 0 L1 0 l3 0 l1 | |
135 | |
136 // create R (result in mm6) | |
137 "movq %%mm2,%%mm5\n" // 0 L3 0 L1 0 l3 0 l1 | |
138 "movq %%mm4,%%mm6\n" // 0 L2 0 L0 0 l2 0 l0 | |
139 "paddsw %%mm1, %%mm5\n" // lum1+red:x R3 x R1 x r3 x r1 | |
140 "paddsw %%mm1, %%mm6\n" // lum1+red:x R2 x R0 x r2 x r0 | |
141 "packuswb %%mm5,%%mm5\n" // R3 R1 r3 r1 R3 R1 r3 r1 | |
142 "packuswb %%mm6,%%mm6\n" // R2 R0 r2 r0 R2 R0 r2 r0 | |
143 "pxor %%mm7,%%mm7\n" // 00 00 00 00 00 00 00 00 | |
144 "punpcklbw %%mm5,%%mm6\n" // R3 R2 R1 R0 r3 r2 r1 r0 | |
145 | |
146 // create Cb (result in mm1) | |
147 "movd (%1), %%mm1\n" // 0 0 0 0 u3 u2 u1 u0 | |
148 "punpcklbw %%mm7,%%mm1\n" // 0 u3 0 u2 00 u1 00 u0 | |
149 "punpckldq %%mm1,%%mm1\n" // 00 u1 00 u0 00 u1 00 u0 | |
150 "psubw %9,%%mm1\n" // mm1-128:u1 u1 u0 u0 u1 u1 u0 u0 | |
151 // create Cb_g (result in mm5) | |
152 "movq %%mm1,%%mm5\n" // u1 u1 u0 u0 u1 u1 u0 u0 | |
153 "pmullw %14,%%mm5\n" // blue*-109dec=1.7129*64 | |
154 "pmullw %15,%%mm1\n" // blue*114dec=1.78125*64 | |
155 "psraw $6, %%mm5\n" // blue=red/64 | |
156 "psraw $6, %%mm1\n" // blue=blue/64 | |
157 | |
158 // create G (result in mm7) | |
159 "movq %%mm2,%%mm3\n" // 0 L3 0 L1 0 l3 0 l1 | |
160 "movq %%mm4,%%mm7\n" // 0 L2 0 L0 0 l2 0 l1 | |
161 "paddsw %%mm5, %%mm3\n" // lum1+Cb_g:x G3t x G1t x g3t x g1t | |
162 "paddsw %%mm5, %%mm7\n" // lum1+Cb_g:x G2t x G0t x g2t x g0t | |
163 "paddsw %%mm0, %%mm3\n" // lum1+Cr_g:x G3 x G1 x g3 x g1 | |
164 "paddsw %%mm0, %%mm7\n" // lum1+blue:x G2 x G0 x g2 x g0 | |
165 "packuswb %%mm3,%%mm3\n" // G3 G1 g3 g1 G3 G1 g3 g1 | |
166 "packuswb %%mm7,%%mm7\n" // G2 G0 g2 g0 G2 G0 g2 g0 | |
167 "punpcklbw %%mm3,%%mm7\n" // G3 G2 G1 G0 g3 g2 g1 g0 | |
168 | |
169 // create B (result in mm5) | |
170 "movq %%mm2,%%mm3\n" // 0 L3 0 L1 0 l3 0 l1 | |
171 "movq %%mm4,%%mm5\n" // 0 L2 0 L0 0 l2 0 l1 | |
172 "paddsw %%mm1, %%mm3\n" // lum1+blue:x B3 x B1 x b3 x b1 | |
173 "paddsw %%mm1, %%mm5\n" // lum1+blue:x B2 x B0 x b2 x b0 | |
174 "packuswb %%mm3,%%mm3\n" // B3 B1 b3 b1 B3 B1 b3 b1 | |
175 "packuswb %%mm5,%%mm5\n" // B2 B0 b2 b0 B2 B0 b2 b0 | |
176 "punpcklbw %%mm3,%%mm5\n" // B3 B2 B1 B0 b3 b2 b1 b0 | |
177 | |
178 // fill destination row1 (needed are mm6=Rr,mm7=Gg,mm5=Bb) | |
179 | |
180 "pxor %%mm2,%%mm2\n" // 0 0 0 0 0 0 0 0 | |
181 "pxor %%mm4,%%mm4\n" // 0 0 0 0 0 0 0 0 | |
182 "movq %%mm6,%%mm1\n" // R3 R2 R1 R0 r3 r2 r1 r0 | |
183 "movq %%mm5,%%mm3\n" // B3 B2 B1 B0 b3 b2 b1 b0 | |
184 // process lower lum | |
185 "punpcklbw %%mm4,%%mm1\n" // 0 r3 0 r2 0 r1 0 r0 | |
186 "punpcklbw %%mm4,%%mm3\n" // 0 b3 0 b2 0 b1 0 b0 | |
187 "movq %%mm1,%%mm2\n" // 0 r3 0 r2 0 r1 0 r0 | |
188 "movq %%mm3,%%mm0\n" // 0 b3 0 b2 0 b1 0 b0 | |
189 "punpcklwd %%mm1,%%mm3\n" // 0 r1 0 b1 0 r0 0 b0 | |
190 "punpckhwd %%mm2,%%mm0\n" // 0 r3 0 b3 0 r2 0 b2 | |
191 | |
192 "pxor %%mm2,%%mm2\n" // 0 0 0 0 0 0 0 0 | |
193 "movq %%mm7,%%mm1\n" // G3 G2 G1 G0 g3 g2 g1 g0 | |
194 "punpcklbw %%mm1,%%mm2\n" // g3 0 g2 0 g1 0 g0 0 | |
195 "punpcklwd %%mm4,%%mm2\n" // 0 0 g1 0 0 0 g0 0 | |
196 "por %%mm3, %%mm2\n" // 0 r1 g1 b1 0 r0 g0 b0 | |
197 "movq %%mm2,(%3)\n" // wrote out ! row1 | |
198 | |
199 "pxor %%mm2,%%mm2\n" // 0 0 0 0 0 0 0 0 | |
200 "punpcklbw %%mm1,%%mm4\n" // g3 0 g2 0 g1 0 g0 0 | |
201 "punpckhwd %%mm2,%%mm4\n" // 0 0 g3 0 0 0 g2 0 | |
202 "por %%mm0, %%mm4\n" // 0 r3 g3 b3 0 r2 g2 b2 | |
203 "movq %%mm4,8(%3)\n" // wrote out ! row1 | |
126 | 204 |
127 // create L1 L2 (result in mm2,mm4) | 205 // fill destination row2 (needed are mm6=Rr,mm7=Gg,mm5=Bb) |
128 // L2=lum+cols | 206 // this can be done "destructive" |
129 "movq (%2,%4),%%mm3\n" // 0 0 0 0 L3 L2 L1 L0 | 207 "pxor %%mm2,%%mm2\n" // 0 0 0 0 0 0 0 0 |
130 "punpckldq %%mm3,%%mm2\n" // L3 L2 L1 L0 l3 l2 l1 l0 | 208 "punpckhbw %%mm2,%%mm6\n" // 0 R3 0 R2 0 R1 0 R0 |
131 "movq %%mm2,%%mm4\n" // L3 L2 L1 L0 l3 l2 l1 l0 | 209 "punpckhbw %%mm1,%%mm5\n" // G3 B3 G2 B2 G1 B1 G0 B0 |
132 "pand %12,%%mm2\n" // L3 0 L1 0 l3 0 l1 0 | 210 "movq %%mm5,%%mm1\n" // G3 B3 G2 B2 G1 B1 G0 B0 |
133 "pand %13,%%mm4\n" // 0 L2 0 L0 0 l2 0 l0 | 211 "punpcklwd %%mm6,%%mm1\n" // 0 R1 G1 B1 0 R0 G0 B0 |
134 "psrlw $8,%%mm2\n" // 0 L3 0 L1 0 l3 0 l1 | 212 "movq %%mm1,(%5)\n" // wrote out ! row2 |
135 | 213 "punpckhwd %%mm6,%%mm5\n" // 0 R3 G3 B3 0 R2 G2 B2 |
136 // create R (result in mm6) | 214 "movq %%mm5,8(%5)\n" // wrote out ! row2 |
137 "movq %%mm2,%%mm5\n" // 0 L3 0 L1 0 l3 0 l1 | |
138 "movq %%mm4,%%mm6\n" // 0 L2 0 L0 0 l2 0 l0 | |
139 "paddsw %%mm1, %%mm5\n" // lum1+red:x R3 x R1 x r3 x r1 | |
140 "paddsw %%mm1, %%mm6\n" // lum1+red:x R2 x R0 x r2 x r0 | |
141 "packuswb %%mm5,%%mm5\n" // R3 R1 r3 r1 R3 R1 r3 r1 | |
142 "packuswb %%mm6,%%mm6\n" // R2 R0 r2 r0 R2 R0 r2 r0 | |
143 "pxor %%mm7,%%mm7\n" // 00 00 00 00 00 00 00 00 | |
144 "punpcklbw %%mm5,%%mm6\n" // R3 R2 R1 R0 r3 r2 r1 r0 | |
145 | |
146 // create Cb (result in mm1) | |
147 "movd (%1), %%mm1\n" // 0 0 0 0 u3 u2 u1 u0 | |
148 "punpcklbw %%mm7,%%mm1\n" // 0 u3 0 u2 00 u1 00 u0 | |
149 "punpckldq %%mm1,%%mm1\n" // 00 u1 00 u0 00 u1 00 u0 | |
150 "psubw %9,%%mm1\n" // mm1-128:u1 u1 u0 u0 u1 u1 u0 u0 | |
151 // create Cb_g (result in mm5) | |
152 "movq %%mm1,%%mm5\n" // u1 u1 u0 u0 u1 u1 u0 u0 | |
153 "pmullw %14,%%mm5\n" // blue*-109dec=1.7129*64 | |
154 "pmullw %15,%%mm1\n" // blue*114dec=1.78125*64 | |
155 "psraw $6, %%mm5\n" // blue=red/64 | |
156 "psraw $6, %%mm1\n" // blue=blue/64 | |
157 | |
158 // create G (result in mm7) | |
159 "movq %%mm2,%%mm3\n" // 0 L3 0 L1 0 l3 0 l1 | |
160 "movq %%mm4,%%mm7\n" // 0 L2 0 L0 0 l2 0 l1 | |
161 "paddsw %%mm5, %%mm3\n" // lum1+Cb_g:x G3t x G1t x g3t x g1t | |
162 "paddsw %%mm5, %%mm7\n" // lum1+Cb_g:x G2t x G0t x g2t x g0t | |
163 "paddsw %%mm0, %%mm3\n" // lum1+Cr_g:x G3 x G1 x g3 x g1 | |
164 "paddsw %%mm0, %%mm7\n" // lum1+blue:x G2 x G0 x g2 x g0 | |
165 "packuswb %%mm3,%%mm3\n" // G3 G1 g3 g1 G3 G1 g3 g1 | |
166 "packuswb %%mm7,%%mm7\n" // G2 G0 g2 g0 G2 G0 g2 g0 | |
167 "punpcklbw %%mm3,%%mm7\n" // G3 G2 G1 G0 g3 g2 g1 g0 | |
168 | 215 |
169 // create B (result in mm5) | 216 "addl $4,%2\n" // lum+4 |
170 "movq %%mm2,%%mm3\n" // 0 L3 0 L1 0 l3 0 l1 | 217 "leal 16(%3),%3\n" // row1+16 |
171 "movq %%mm4,%%mm5\n" // 0 L2 0 L0 0 l2 0 l1 | 218 "leal 16(%5),%5\n" // row2+16 |
172 "paddsw %%mm1, %%mm3\n" // lum1+blue:x B3 x B1 x b3 x b1 | 219 "addl $2,(%%esp)\n" // cr+2 |
173 "paddsw %%mm1, %%mm5\n" // lum1+blue:x B2 x B0 x b2 x b0 | 220 "addl $2,%1\n" // cb+2 |
174 "packuswb %%mm3,%%mm3\n" // B3 B1 b3 b1 B3 B1 b3 b1 | 221 |
175 "packuswb %%mm5,%%mm5\n" // B2 B0 b2 b0 B2 B0 b2 b0 | 222 "addl $4,%6\n" // x+4 |
176 "punpcklbw %%mm3,%%mm5\n" // B3 B2 B1 B0 b3 b2 b1 b0 | 223 "cmpl %4,%6\n" |
177 | 224 |
178 // fill destination row1 (needed are mm6=Rr,mm7=Gg,mm5=Bb) | 225 "jl 1b\n" |
179 | 226 "addl %4,%2\n" // lum += cols |
180 "pxor %%mm2,%%mm2\n" // 0 0 0 0 0 0 0 0 | 227 "addl %8,%3\n" // row1+= mod |
181 "pxor %%mm4,%%mm4\n" // 0 0 0 0 0 0 0 0 | 228 "addl %8,%5\n" // row2+= mod |
182 "movq %%mm6,%%mm1\n" // R3 R2 R1 R0 r3 r2 r1 r0 | 229 "movl $0,%6\n" // x=0 |
183 "movq %%mm5,%%mm3\n" // B3 B2 B1 B0 b3 b2 b1 b0 | 230 "cmpl %7,%2\n" |
184 // process lower lum | 231 "jl 1b\n" |
185 "punpcklbw %%mm4,%%mm1\n" // 0 r3 0 r2 0 r1 0 r0 | 232 |
186 "punpcklbw %%mm4,%%mm3\n" // 0 b3 0 b2 0 b1 0 b0 | 233 "addl $4,%%esp\n" // get rid of the stack slot we reserved. |
187 "movq %%mm1,%%mm2\n" // 0 r3 0 r2 0 r1 0 r0 | 234 "emms\n" // reset MMX registers. |
188 "movq %%mm3,%%mm0\n" // 0 b3 0 b2 0 b1 0 b0 | 235 : |
189 "punpcklwd %%mm1,%%mm3\n" // 0 r1 0 b1 0 r0 0 b0 | 236 : "m" (cr), "r"(cb),"r"(lum), |
190 "punpckhwd %%mm2,%%mm0\n" // 0 r3 0 b3 0 r2 0 b2 | 237 "r"(row1),"r"(cols),"r"(row2),"m"(x),"m"(y),"m"(mod), |
191 | 238 "m"(MMX_0080w),"m"(MMX_VgrnRGB),"m"(MMX_VredRGB), |
192 "pxor %%mm2,%%mm2\n" // 0 0 0 0 0 0 0 0 | 239 "m"(MMX_FF00w),"m"(MMX_00FFw),"m"(MMX_UgrnRGB), |
193 "movq %%mm7,%%mm1\n" // G3 G2 G1 G0 g3 g2 g1 g0 | 240 "m"(MMX_UbluRGB) |
194 "punpcklbw %%mm1,%%mm2\n" // g3 0 g2 0 g1 0 g0 0 | |
195 "punpcklwd %%mm4,%%mm2\n" // 0 0 g1 0 0 0 g0 0 | |
196 "por %%mm3, %%mm2\n" // 0 r1 g1 b1 0 r0 g0 b0 | |
197 "movq %%mm2,(%3)\n" // wrote out ! row1 | |
198 | |
199 "pxor %%mm2,%%mm2\n" // 0 0 0 0 0 0 0 0 | |
200 "punpcklbw %%mm1,%%mm4\n" // g3 0 g2 0 g1 0 g0 0 | |
201 "punpckhwd %%mm2,%%mm4\n" // 0 0 g3 0 0 0 g2 0 | |
202 "por %%mm0, %%mm4\n" // 0 r3 g3 b3 0 r2 g2 b2 | |
203 "movq %%mm4,8(%3)\n" // wrote out ! row1 | |
204 | |
205 // fill destination row2 (needed are mm6=Rr,mm7=Gg,mm5=Bb) | |
206 // this can be done "destructive" | |
207 "pxor %%mm2,%%mm2\n" // 0 0 0 0 0 0 0 0 | |
208 "punpckhbw %%mm2,%%mm6\n" // 0 R3 0 R2 0 R1 0 R0 | |
209 "punpckhbw %%mm1,%%mm5\n" // G3 B3 G2 B2 G1 B1 G0 B0 | |
210 "movq %%mm5,%%mm1\n" // G3 B3 G2 B2 G1 B1 G0 B0 | |
211 "punpcklwd %%mm6,%%mm1\n" // 0 R1 G1 B1 0 R0 G0 B0 | |
212 "movq %%mm1,(%5)\n" // wrote out ! row2 | |
213 "punpckhwd %%mm6,%%mm5\n" // 0 R3 G3 B3 0 R2 G2 B2 | |
214 "movq %%mm5,8(%5)\n" // wrote out ! row2 | |
215 | |
216 "addl $4,%2\n" // lum+4 | |
217 "leal 16(%3),%3\n" // row1+16 | |
218 "leal 16(%5),%5\n" // row2+16 | |
219 "addl $2, (%%esp)\n" // cr+2 | |
220 "addl $2, %1\n" // cb+2 | |
221 | |
222 "addl $4,%6\n" // x+4 | |
223 "cmpl %4,%6\n" | |
224 | |
225 "jl 1b\n" | |
226 "addl %4, %2\n" // lum += cols | |
227 "addl %8, %3\n" // row1+= mod | |
228 "addl %8, %5\n" // row2+= mod | |
229 "movl $0, %6\n" // x=0 | |
230 "cmpl %7, %2\n" | |
231 "jl 1b\n" | |
232 | |
233 "addl $4, %%esp\n" // get rid of the stack slot we reserved. | |
234 "emms\n" // reset MMX registers. | |
235 : | |
236 : "m" (cr), "r"(cb),"r"(lum), | |
237 "r"(row1),"r"(cols),"r"(row2),"m"(x),"m"(y),"m"(mod), | |
238 "m"(MMX_0080w),"m"(MMX_VgrnRGB),"m"(MMX_VredRGB), | |
239 "m"(MMX_FF00w),"m"(MMX_00FFw),"m"(MMX_UgrnRGB), | |
240 "m"(MMX_UbluRGB) | |
241 ); | 241 ); |
242 } | 242 } |
243 | 243 |
244 void Color565DitherYV12MMX1X( int *colortab, Uint32 *rgb_2_pix, | 244 void Color565DitherYV12MMX1X( int *colortab, Uint32 *rgb_2_pix, |
245 unsigned char *lum, unsigned char *cr, | 245 unsigned char *lum, unsigned char *cr, |
246 unsigned char *cb, unsigned char *out, | 246 unsigned char *cb, unsigned char *out, |
247 int rows, int cols, int mod ) | 247 int rows, int cols, int mod ) |
248 { | 248 { |
249 Uint16 *row1; | 249 Uint16 *row1; |
250 Uint16 *row2; | 250 Uint16 *row2; |
251 | 251 |
252 unsigned char* y = lum +cols*rows; /* Pointer to the end */ | 252 unsigned char* y = lum +cols*rows; /* Pointer to the end */ |
253 int x=0; | 253 int x = 0; |
254 row1 = (Uint16 *)out; /* 16 bit target */ | 254 row1 = (Uint16 *)out; /* 16 bit target */ |
255 row2 = (Uint16 *)out+cols+mod; /* start of second row */ | 255 row2 = (Uint16 *)out+cols+mod; /* start of second row */ |
256 mod = (mod+cols+mod)*2; /* increment for row1 in byte */ | 256 mod = (mod+cols+mod)*2; /* increment for row1 in byte */ |
257 | 257 |
258 | 258 __asm__ __volatile__( |
259 __asm__ __volatile__( | 259 // tap dance to workaround the inability to use %%ebx at will... |
260 // tap dance to workaround the inability to use %%ebx at will... | 260 // move one thing to the stack... |
261 // move one thing to the stack... | 261 "pushl $0\n" // save a slot on the stack. |
262 "pushl $0\n" // save a slot on the stack. | 262 "pushl %%ebx\n" // save %%ebx. |
263 "pushl %%ebx\n" // save %%ebx. | 263 "movl %0, %%ebx\n" // put the thing in ebx. |
264 "movl %0, %%ebx\n" // put the thing in ebx. | 264 "movl %%ebx, 4(%%esp)\n" // put the thing in the stack slot. |
265 "movl %%ebx, 4(%%esp)\n" // put the thing in the stack slot. | 265 "popl %%ebx\n" // get back %%ebx (the PIC register). |
266 "popl %%ebx\n" // get back %%ebx (the PIC register). | 266 |
267 | 267 ".align 8\n" |
268 ".align 8\n" | 268 "1:\n" |
269 "1:\n" | 269 "movd (%1), %%mm0\n" // 4 Cb 0 0 0 0 u3 u2 u1 u0 |
270 "movd (%1), %%mm0\n" // 4 Cb 0 0 0 0 u3 u2 u1 u0 | 270 "pxor %%mm7, %%mm7\n" |
271 "pxor %%mm7, %%mm7\n" | 271 "pushl %%ebx\n" |
272 "pushl %%ebx\n" | 272 "movl 4(%%esp), %%ebx\n" |
273 "movl 4(%%esp), %%ebx\n" | 273 "movd (%%ebx), %%mm1\n" // 4 Cr 0 0 0 0 v3 v2 v1 v0 |
274 "movd (%%ebx), %%mm1\n" // 4 Cr 0 0 0 0 v3 v2 v1 v0 | 274 "popl %%ebx\n" |
275 "popl %%ebx\n" | 275 |
276 | 276 "punpcklbw %%mm7, %%mm0\n" // 4 W cb 0 u3 0 u2 0 u1 0 u0 |
277 "punpcklbw %%mm7, %%mm0\n" // 4 W cb 0 u3 0 u2 0 u1 0 u0 | 277 "punpcklbw %%mm7, %%mm1\n" // 4 W cr 0 v3 0 v2 0 v1 0 v0 |
278 "punpcklbw %%mm7, %%mm1\n" // 4 W cr 0 v3 0 v2 0 v1 0 v0 | 278 "psubw %9, %%mm0\n" |
279 "psubw %9, %%mm0\n" | 279 "psubw %9, %%mm1\n" |
280 "psubw %9, %%mm1\n" | 280 "movq %%mm0, %%mm2\n" // Cb 0 u3 0 u2 0 u1 0 u0 |
281 "movq %%mm0, %%mm2\n" // Cb 0 u3 0 u2 0 u1 0 u0 | 281 "movq %%mm1, %%mm3\n" // Cr |
282 "movq %%mm1, %%mm3\n" // Cr | 282 "pmullw %10, %%mm2\n" // Cb2green 0 R3 0 R2 0 R1 0 R0 |
283 "pmullw %10, %%mm2\n" // Cb2green 0 R3 0 R2 0 R1 0 R0 | 283 "movq (%2), %%mm6\n" // L1 l7 L6 L5 L4 L3 L2 L1 L0 |
284 "movq (%2), %%mm6\n" // L1 l7 L6 L5 L4 L3 L2 L1 L0 | 284 "pmullw %11, %%mm0\n" // Cb2blue |
285 "pmullw %11, %%mm0\n" // Cb2blue | 285 "pand %12, %%mm6\n" // L1 00 L6 00 L4 00 L2 00 L0 |
286 "pand %12, %%mm6\n" // L1 00 L6 00 L4 00 L2 00 L0 | 286 "pmullw %13, %%mm3\n" // Cr2green |
287 "pmullw %13, %%mm3\n" // Cr2green | 287 "movq (%2), %%mm7\n" // L2 |
288 "movq (%2), %%mm7\n" // L2 | 288 "pmullw %14, %%mm1\n" // Cr2red |
289 "pmullw %14, %%mm1\n" // Cr2red | 289 "psrlw $8, %%mm7\n" // L2 00 L7 00 L5 00 L3 00 L1 |
290 "psrlw $8, %%mm7\n" // L2 00 L7 00 L5 00 L3 00 L1 | 290 "pmullw %15, %%mm6\n" // lum1 |
291 "pmullw %15, %%mm6\n" // lum1 | 291 "paddw %%mm3, %%mm2\n" // Cb2green + Cr2green == green |
292 "paddw %%mm3, %%mm2\n" // Cb2green + Cr2green == green | 292 "pmullw %15, %%mm7\n" // lum2 |
293 "pmullw %15, %%mm7\n" // lum2 | 293 |
294 | 294 "movq %%mm6, %%mm4\n" // lum1 |
295 "movq %%mm6, %%mm4\n" // lum1 | 295 "paddw %%mm0, %%mm6\n" // lum1 +blue 00 B6 00 B4 00 B2 00 B0 |
296 "paddw %%mm0, %%mm6\n" // lum1 +blue 00 B6 00 B4 00 B2 00 B0 | 296 "movq %%mm4, %%mm5\n" // lum1 |
297 "movq %%mm4, %%mm5\n" // lum1 | 297 "paddw %%mm1, %%mm4\n" // lum1 +red 00 R6 00 R4 00 R2 00 R0 |
298 "paddw %%mm1, %%mm4\n" // lum1 +red 00 R6 00 R4 00 R2 00 R0 | 298 "paddw %%mm2, %%mm5\n" // lum1 +green 00 G6 00 G4 00 G2 00 G0 |
299 "paddw %%mm2, %%mm5\n" // lum1 +green 00 G6 00 G4 00 G2 00 G0 | 299 "psraw $6, %%mm4\n" // R1 0 .. 64 |
300 "psraw $6, %%mm4\n" // R1 0 .. 64 | 300 "movq %%mm7, %%mm3\n" // lum2 00 L7 00 L5 00 L3 00 L1 |
301 "movq %%mm7, %%mm3\n" // lum2 00 L7 00 L5 00 L3 00 L1 | 301 "psraw $6, %%mm5\n" // G1 - .. + |
302 "psraw $6, %%mm5\n" // G1 - .. + | 302 "paddw %%mm0, %%mm7\n" // Lum2 +blue 00 B7 00 B5 00 B3 00 B1 |
303 "paddw %%mm0, %%mm7\n" // Lum2 +blue 00 B7 00 B5 00 B3 00 B1 | 303 "psraw $6, %%mm6\n" // B1 0 .. 64 |
304 "psraw $6, %%mm6\n" // B1 0 .. 64 | 304 "packuswb %%mm4, %%mm4\n" // R1 R1 |
305 "packuswb %%mm4, %%mm4\n" // R1 R1 | 305 "packuswb %%mm5, %%mm5\n" // G1 G1 |
306 "packuswb %%mm5, %%mm5\n" // G1 G1 | 306 "packuswb %%mm6, %%mm6\n" // B1 B1 |
307 "packuswb %%mm6, %%mm6\n" // B1 B1 | 307 "punpcklbw %%mm4, %%mm4\n" |
308 "punpcklbw %%mm4, %%mm4\n" | 308 "punpcklbw %%mm5, %%mm5\n" |
309 "punpcklbw %%mm5, %%mm5\n" | 309 |
310 | 310 "pand %16, %%mm4\n" |
311 "pand %16, %%mm4\n" | 311 "psllw $3, %%mm5\n" // GREEN 1 |
312 "psllw $3, %%mm5\n" // GREEN 1 | 312 "punpcklbw %%mm6, %%mm6\n" |
313 "punpcklbw %%mm6, %%mm6\n" | 313 "pand %17, %%mm5\n" |
314 "pand %17, %%mm5\n" | 314 "pand %16, %%mm6\n" |
315 "pand %16, %%mm6\n" | 315 "por %%mm5, %%mm4\n" // |
316 "por %%mm5, %%mm4\n" // | 316 "psrlw $11, %%mm6\n" // BLUE 1 |
317 "psrlw $11, %%mm6\n" // BLUE 1 | 317 "movq %%mm3, %%mm5\n" // lum2 |
318 "movq %%mm3, %%mm5\n" // lum2 | 318 "paddw %%mm1, %%mm3\n" // lum2 +red 00 R7 00 R5 00 R3 00 R1 |
319 "paddw %%mm1, %%mm3\n" // lum2 +red 00 R7 00 R5 00 R3 00 R1 | 319 "paddw %%mm2, %%mm5\n" // lum2 +green 00 G7 00 G5 00 G3 00 G1 |
320 "paddw %%mm2, %%mm5\n" // lum2 +green 00 G7 00 G5 00 G3 00 G1 | 320 "psraw $6, %%mm3\n" // R2 |
321 "psraw $6, %%mm3\n" // R2 | 321 "por %%mm6, %%mm4\n" // MM4 |
322 "por %%mm6, %%mm4\n" // MM4 | 322 "psraw $6, %%mm5\n" // G2 |
323 "psraw $6, %%mm5\n" // G2 | 323 "movq (%2, %4), %%mm6\n" // L3 load lum2 |
324 "movq (%2, %4), %%mm6\n" // L3 load lum2 | 324 "psraw $6, %%mm7\n" |
325 "psraw $6, %%mm7\n" | 325 "packuswb %%mm3, %%mm3\n" |
326 "packuswb %%mm3, %%mm3\n" | 326 "packuswb %%mm5, %%mm5\n" |
327 "packuswb %%mm5, %%mm5\n" | 327 "packuswb %%mm7, %%mm7\n" |
328 "packuswb %%mm7, %%mm7\n" | 328 "pand %12, %%mm6\n" // L3 |
329 "pand %12, %%mm6\n" // L3 | 329 "punpcklbw %%mm3, %%mm3\n" |
330 "punpcklbw %%mm3, %%mm3\n" | 330 "punpcklbw %%mm5, %%mm5\n" |
331 "punpcklbw %%mm5, %%mm5\n" | 331 "pmullw %15, %%mm6\n" // lum3 |
332 "pmullw %15, %%mm6\n" // lum3 | 332 "punpcklbw %%mm7, %%mm7\n" |
333 "punpcklbw %%mm7, %%mm7\n" | 333 "psllw $3, %%mm5\n" // GREEN 2 |
334 "psllw $3, %%mm5\n" // GREEN 2 | 334 "pand %16, %%mm7\n" |
335 "pand %16, %%mm7\n" | 335 "pand %16, %%mm3\n" |
336 "pand %16, %%mm3\n" | 336 "psrlw $11, %%mm7\n" // BLUE 2 |
337 "psrlw $11, %%mm7\n" // BLUE 2 | 337 "pand %17, %%mm5\n" |
338 "pand %17, %%mm5\n" | 338 "por %%mm7, %%mm3\n" |
339 "por %%mm7, %%mm3\n" | 339 "movq (%2,%4), %%mm7\n" // L4 load lum2 |
340 "movq (%2,%4), %%mm7\n" // L4 load lum2 | 340 "por %%mm5, %%mm3\n" // |
341 "por %%mm5, %%mm3\n" // | 341 "psrlw $8, %%mm7\n" // L4 |
342 "psrlw $8, %%mm7\n" // L4 | 342 "movq %%mm4, %%mm5\n" |
343 "movq %%mm4, %%mm5\n" | 343 "punpcklwd %%mm3, %%mm4\n" |
344 "punpcklwd %%mm3, %%mm4\n" | 344 "pmullw %15, %%mm7\n" // lum4 |
345 "pmullw %15, %%mm7\n" // lum4 | 345 "punpckhwd %%mm3, %%mm5\n" |
346 "punpckhwd %%mm3, %%mm5\n" | 346 |
347 | 347 "movq %%mm4, (%3)\n" // write row1 |
348 "movq %%mm4, (%3)\n" // write row1 | 348 "movq %%mm5, 8(%3)\n" // write row1 |
349 "movq %%mm5, 8(%3)\n" // write row1 | 349 |
350 | 350 "movq %%mm6, %%mm4\n" // Lum3 |
351 "movq %%mm6, %%mm4\n" // Lum3 | 351 "paddw %%mm0, %%mm6\n" // Lum3 +blue |
352 "paddw %%mm0, %%mm6\n" // Lum3 +blue | 352 |
353 | 353 "movq %%mm4, %%mm5\n" // Lum3 |
354 "movq %%mm4, %%mm5\n" // Lum3 | 354 "paddw %%mm1, %%mm4\n" // Lum3 +red |
355 "paddw %%mm1, %%mm4\n" // Lum3 +red | 355 "paddw %%mm2, %%mm5\n" // Lum3 +green |
356 "paddw %%mm2, %%mm5\n" // Lum3 +green | 356 "psraw $6, %%mm4\n" |
357 "psraw $6, %%mm4\n" | 357 "movq %%mm7, %%mm3\n" // Lum4 |
358 "movq %%mm7, %%mm3\n" // Lum4 | 358 "psraw $6, %%mm5\n" |
359 "psraw $6, %%mm5\n" | 359 "paddw %%mm0, %%mm7\n" // Lum4 +blue |
360 "paddw %%mm0, %%mm7\n" // Lum4 +blue | 360 "psraw $6, %%mm6\n" // Lum3 +blue |
361 "psraw $6, %%mm6\n" // Lum3 +blue | 361 "movq %%mm3, %%mm0\n" // Lum4 |
362 "movq %%mm3, %%mm0\n" // Lum4 | 362 "packuswb %%mm4, %%mm4\n" |
363 "packuswb %%mm4, %%mm4\n" | 363 "paddw %%mm1, %%mm3\n" // Lum4 +red |
364 "paddw %%mm1, %%mm3\n" // Lum4 +red | 364 "packuswb %%mm5, %%mm5\n" |
365 "packuswb %%mm5, %%mm5\n" | 365 "paddw %%mm2, %%mm0\n" // Lum4 +green |
366 "paddw %%mm2, %%mm0\n" // Lum4 +green | 366 "packuswb %%mm6, %%mm6\n" |
367 "packuswb %%mm6, %%mm6\n" | 367 "punpcklbw %%mm4, %%mm4\n" |
368 "punpcklbw %%mm4, %%mm4\n" | 368 "punpcklbw %%mm5, %%mm5\n" |
369 "punpcklbw %%mm5, %%mm5\n" | 369 "punpcklbw %%mm6, %%mm6\n" |
370 "punpcklbw %%mm6, %%mm6\n" | 370 "psllw $3, %%mm5\n" // GREEN 3 |
371 "psllw $3, %%mm5\n" // GREEN 3 | 371 "pand %16, %%mm4\n" |
372 "pand %16, %%mm4\n" | 372 "psraw $6, %%mm3\n" // psr 6 |
373 "psraw $6, %%mm3\n" // psr 6 | 373 "psraw $6, %%mm0\n" |
374 "psraw $6, %%mm0\n" | 374 "pand %16, %%mm6\n" // BLUE |
375 "pand %16, %%mm6\n" // BLUE | 375 "pand %17, %%mm5\n" |
376 "pand %17, %%mm5\n" | 376 "psrlw $11, %%mm6\n" // BLUE 3 |
377 "psrlw $11, %%mm6\n" // BLUE 3 | 377 "por %%mm5, %%mm4\n" |
378 "por %%mm5, %%mm4\n" | 378 "psraw $6, %%mm7\n" |
379 "psraw $6, %%mm7\n" | 379 "por %%mm6, %%mm4\n" |
380 "por %%mm6, %%mm4\n" | 380 "packuswb %%mm3, %%mm3\n" |
381 "packuswb %%mm3, %%mm3\n" | 381 "packuswb %%mm0, %%mm0\n" |
382 "packuswb %%mm0, %%mm0\n" | 382 "packuswb %%mm7, %%mm7\n" |
383 "packuswb %%mm7, %%mm7\n" | 383 "punpcklbw %%mm3, %%mm3\n" |
384 "punpcklbw %%mm3, %%mm3\n" | 384 "punpcklbw %%mm0, %%mm0\n" |
385 "punpcklbw %%mm0, %%mm0\n" | 385 "punpcklbw %%mm7, %%mm7\n" |
386 "punpcklbw %%mm7, %%mm7\n" | 386 "pand %16, %%mm3\n" |
387 "pand %16, %%mm3\n" | 387 "pand %16, %%mm7\n" // BLUE |
388 "pand %16, %%mm7\n" // BLUE | 388 "psllw $3, %%mm0\n" // GREEN 4 |
389 "psllw $3, %%mm0\n" // GREEN 4 | 389 "psrlw $11, %%mm7\n" |
390 "psrlw $11, %%mm7\n" | 390 "pand %17, %%mm0\n" |
391 "pand %17, %%mm0\n" | 391 "por %%mm7, %%mm3\n" |
392 "por %%mm7, %%mm3\n" | 392 "por %%mm0, %%mm3\n" |
393 "por %%mm0, %%mm3\n" | 393 |
394 | 394 "movq %%mm4, %%mm5\n" |
395 "movq %%mm4, %%mm5\n" | 395 |
396 | 396 "punpcklwd %%mm3, %%mm4\n" |
397 "punpcklwd %%mm3, %%mm4\n" | 397 "punpckhwd %%mm3, %%mm5\n" |
398 "punpckhwd %%mm3, %%mm5\n" | 398 |
399 | 399 "movq %%mm4, (%5)\n" |
400 "movq %%mm4, (%5)\n" | 400 "movq %%mm5, 8(%5)\n" |
401 "movq %%mm5, 8(%5)\n" | 401 |
402 | 402 "addl $8, %6\n" |
403 "addl $8, %6\n" | 403 "addl $8, %2\n" |
404 "addl $8, %2\n" | 404 "addl $4, (%%esp)\n" |
405 "addl $4, (%%esp)\n" | 405 "addl $4, %1\n" |
406 "addl $4, %1\n" | 406 "cmpl %4, %6\n" |
407 "cmpl %4, %6\n" | 407 "leal 16(%3), %3\n" |
408 "leal 16(%3), %3\n" | 408 "leal 16(%5),%5\n" // row2+16 |
409 "leal 16(%5),%5\n" // row2+16 | 409 |
410 | 410 "jl 1b\n" |
411 | 411 "addl %4, %2\n" // lum += cols |
412 "jl 1b\n" | 412 "addl %8, %3\n" // row1+= mod |
413 "addl %4, %2\n" // lum += cols | 413 "addl %8, %5\n" // row2+= mod |
414 "addl %8, %3\n" // row1+= mod | 414 "movl $0, %6\n" // x=0 |
415 "addl %8, %5\n" // row2+= mod | 415 "cmpl %7, %2\n" |
416 "movl $0, %6\n" // x=0 | 416 "jl 1b\n" |
417 "cmpl %7, %2\n" | 417 "addl $4, %%esp\n" // get rid of the stack slot we reserved. |
418 "jl 1b\n" | 418 "emms\n" |
419 "addl $4, %%esp\n" // get rid of the stack slot we reserved. | 419 : |
420 "emms\n" | 420 : "m" (cr), "r"(cb),"r"(lum), |
421 : | 421 "r"(row1),"r"(cols),"r"(row2),"m"(x),"m"(y),"m"(mod), |
422 : "m" (cr), "r"(cb),"r"(lum), | 422 "m"(MMX_0080w),"m"(MMX_Ugrn565),"m"(MMX_Ublu5x5), |
423 "r"(row1),"r"(cols),"r"(row2),"m"(x),"m"(y),"m"(mod), | 423 "m"(MMX_00FFw),"m"(MMX_Vgrn565),"m"(MMX_Vred5x5), |
424 "m"(MMX_0080w),"m"(MMX_Ugrn565),"m"(MMX_Ublu5x5), | 424 "m"(MMX_Ycoeff),"m"(MMX_red565),"m"(MMX_grn565) |
425 "m"(MMX_00FFw),"m"(MMX_Vgrn565),"m"(MMX_Vred5x5), | 425 ); |
426 "m"(MMX_Ycoeff),"m"(MMX_red565),"m"(MMX_grn565)); | |
427 } | 426 } |
428 | 427 |
429 #endif /* GCC3 i386 inline assembly */ | 428 #endif /* GCC3 i386 inline assembly */ |
430 | 429 |