Magellan Linux

Contents of /trunk/libsdl/patches/libsdl-1.2.9-PIC-yuv-mmx.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 144 - (show annotations) (download)
Tue May 8 20:06:05 2007 UTC (17 years ago) by niro
File size: 13260 byte(s)
-import

1 --- src/video/SDL_yuv_mmx.c
2 +++ src/video/SDL_yuv_mmx.c
3 @@ -29,32 +29,31 @@ static char rcsid =
4 #if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT)
5
6 #include "SDL_types.h"
7 +#include "mmx.h"
8
9 -#define ASM_ARRAY(x) x[] __asm__("_" #x) __attribute__((used))
10 -
11 -static unsigned int ASM_ARRAY(MMX_0080w) = {0x00800080, 0x00800080};
12 -static unsigned int ASM_ARRAY(MMX_00FFw) = {0x00ff00ff, 0x00ff00ff};
13 -static unsigned int ASM_ARRAY(MMX_FF00w) = {0xff00ff00, 0xff00ff00};
14 -
15 -static unsigned short ASM_ARRAY(MMX_Ycoeff) = {0x004a, 0x004a, 0x004a, 0x004a};
16 -
17 -static unsigned short ASM_ARRAY(MMX_UbluRGB) = {0x0072, 0x0072, 0x0072, 0x0072};
18 -static unsigned short ASM_ARRAY(MMX_VredRGB) = {0x0059, 0x0059, 0x0059, 0x0059};
19 -static unsigned short ASM_ARRAY(MMX_UgrnRGB) = {0xffea, 0xffea, 0xffea, 0xffea};
20 -static unsigned short ASM_ARRAY(MMX_VgrnRGB) = {0xffd2, 0xffd2, 0xffd2, 0xffd2};
21 -
22 -static unsigned short ASM_ARRAY(MMX_Ublu5x5) = {0x0081, 0x0081, 0x0081, 0x0081};
23 -static unsigned short ASM_ARRAY(MMX_Vred5x5) = {0x0066, 0x0066, 0x0066, 0x0066};
24 -static unsigned short ASM_ARRAY(MMX_Ugrn555) = {0xffe7, 0xffe7, 0xffe7, 0xffe7};
25 -static unsigned short ASM_ARRAY(MMX_Vgrn555) = {0xffcc, 0xffcc, 0xffcc, 0xffcc};
26 -static unsigned short ASM_ARRAY(MMX_Ugrn565) = {0xffe8, 0xffe8, 0xffe8, 0xffe8};
27 -static unsigned short ASM_ARRAY(MMX_Vgrn565) = {0xffcd, 0xffcd, 0xffcd, 0xffcd};
28 -
29 -static unsigned short ASM_ARRAY(MMX_red555) = {0x7c00, 0x7c00, 0x7c00, 0x7c00};
30 -static unsigned short ASM_ARRAY(MMX_red565) = {0xf800, 0xf800, 0xf800, 0xf800};
31 -static unsigned short ASM_ARRAY(MMX_grn555) = {0x03e0, 0x03e0, 0x03e0, 0x03e0};
32 -static unsigned short ASM_ARRAY(MMX_grn565) = {0x07e0, 0x07e0, 0x07e0, 0x07e0};
33 -static unsigned short ASM_ARRAY(MMX_blu5x5) = {0x001f, 0x001f, 0x001f, 0x001f};
34 +static mmx_t MMX_0080w = { .ud = {0x00800080, 0x00800080} };
35 +static mmx_t MMX_00FFw = { .ud = {0x00ff00ff, 0x00ff00ff} };
36 +static mmx_t MMX_FF00w = { .ud = {0xff00ff00, 0xff00ff00} };
37 +
38 +static mmx_t MMX_Ycoeff = { .uw = {0x004a, 0x004a, 0x004a, 0x004a} };
39 +
40 +static mmx_t MMX_UbluRGB = { .uw = {0x0072, 0x0072, 0x0072, 0x0072} };
41 +static mmx_t MMX_VredRGB = { .uw = {0x0059, 0x0059, 0x0059, 0x0059} };
42 +static mmx_t MMX_UgrnRGB = { .uw = {0xffea, 0xffea, 0xffea, 0xffea} };
43 +static mmx_t MMX_VgrnRGB = { .uw = {0xffd2, 0xffd2, 0xffd2, 0xffd2} };
44 +
45 +static mmx_t MMX_Ublu5x5 = { .uw = {0x0081, 0x0081, 0x0081, 0x0081} };
46 +static mmx_t MMX_Vred5x5 = { .uw = {0x0066, 0x0066, 0x0066, 0x0066} };
47 +static mmx_t MMX_Ugrn555 = { .uw = {0xffe7, 0xffe7, 0xffe7, 0xffe7} };
48 +static mmx_t MMX_Vgrn555 = { .uw = {0xffcc, 0xffcc, 0xffcc, 0xffcc} };
49 +static mmx_t MMX_Ugrn565 = { .uw = {0xffe8, 0xffe8, 0xffe8, 0xffe8} };
50 +static mmx_t MMX_Vgrn565 = { .uw = {0xffcd, 0xffcd, 0xffcd, 0xffcd} };
51 +
52 +static mmx_t MMX_red555 = { .uw = {0x7c00, 0x7c00, 0x7c00, 0x7c00} };
53 +static mmx_t MMX_red565 = { .uw = {0xf800, 0xf800, 0xf800, 0xf800} };
54 +static mmx_t MMX_grn555 = { .uw = {0x03e0, 0x03e0, 0x03e0, 0x03e0} };
55 +static mmx_t MMX_grn565 = { .uw = {0x07e0, 0x07e0, 0x07e0, 0x07e0} };
56 +static mmx_t MMX_blu5x5 = { .uw = {0x001f, 0x001f, 0x001f, 0x001f} };
57
58 /**
59 This MMX assembler is my first assembler/MMX program ever.
60 @@ -116,12 +115,12 @@ void ColorRGBDitherYV12MMX1X( int *color
61 "movd (%2), %%mm2\n" // 0 0 0 0 l3 l2 l1 l0
62 "punpcklbw %%mm7,%%mm1\n" // 0 v3 0 v2 00 v1 00 v0
63 "punpckldq %%mm1,%%mm1\n" // 00 v1 00 v0 00 v1 00 v0
64 - "psubw _MMX_0080w,%%mm1\n" // mm1-128:r1 r1 r0 r0 r1 r1 r0 r0
65 + "psubw %9,%%mm1\n" // mm1-128:r1 r1 r0 r0 r1 r1 r0 r0
66
67 // create Cr_g (result in mm0)
68 "movq %%mm1,%%mm0\n" // r1 r1 r0 r0 r1 r1 r0 r0
69 - "pmullw _MMX_VgrnRGB,%%mm0\n"// red*-46dec=0.7136*64
70 - "pmullw _MMX_VredRGB,%%mm1\n"// red*89dec=1.4013*64
71 + "pmullw %10,%%mm0\n" // red*-46dec=0.7136*64
72 + "pmullw %11,%%mm1\n" // red*89dec=1.4013*64
73 "psraw $6, %%mm0\n" // red=red/64
74 "psraw $6, %%mm1\n" // red=red/64
75
76 @@ -130,8 +129,8 @@ void ColorRGBDitherYV12MMX1X( int *color
77 "movq (%2,%4),%%mm3\n" // 0 0 0 0 L3 L2 L1 L0
78 "punpckldq %%mm3,%%mm2\n" // L3 L2 L1 L0 l3 l2 l1 l0
79 "movq %%mm2,%%mm4\n" // L3 L2 L1 L0 l3 l2 l1 l0
80 - "pand _MMX_FF00w,%%mm2\n" // L3 0 L1 0 l3 0 l1 0
81 - "pand _MMX_00FFw,%%mm4\n" // 0 L2 0 L0 0 l2 0 l0
82 + "pand %12,%%mm2\n" // L3 0 L1 0 l3 0 l1 0
83 + "pand %13,%%mm4\n" // 0 L2 0 L0 0 l2 0 l0
84 "psrlw $8,%%mm2\n" // 0 L3 0 L1 0 l3 0 l1
85
86 // create R (result in mm6)
87 @@ -148,11 +147,11 @@ void ColorRGBDitherYV12MMX1X( int *color
88 "movd (%1), %%mm1\n" // 0 0 0 0 u3 u2 u1 u0
89 "punpcklbw %%mm7,%%mm1\n" // 0 u3 0 u2 00 u1 00 u0
90 "punpckldq %%mm1,%%mm1\n" // 00 u1 00 u0 00 u1 00 u0
91 - "psubw _MMX_0080w,%%mm1\n" // mm1-128:u1 u1 u0 u0 u1 u1 u0 u0
92 + "psubw %9,%%mm1\n" // mm1-128:u1 u1 u0 u0 u1 u1 u0 u0
93 // create Cb_g (result in mm5)
94 "movq %%mm1,%%mm5\n" // u1 u1 u0 u0 u1 u1 u0 u0
95 - "pmullw _MMX_UgrnRGB,%%mm5\n" // blue*-109dec=1.7129*64
96 - "pmullw _MMX_UbluRGB,%%mm1\n" // blue*114dec=1.78125*64
97 + "pmullw %14,%%mm5\n" // blue*-109dec=1.7129*64
98 + "pmullw %15,%%mm1\n" // blue*114dec=1.78125*64
99 "psraw $6, %%mm5\n" // blue=red/64
100 "psraw $6, %%mm1\n" // blue=blue/64
101
102 @@ -234,7 +233,10 @@ void ColorRGBDitherYV12MMX1X( int *color
103 "popl %%ebx\n"
104 :
105 : "m" (cr), "r"(cb),"r"(lum),
106 - "r"(row1),"r"(cols),"r"(row2),"m"(x),"m"(y),"m"(mod));
107 + "r"(row1),"r"(cols),"r"(row2),"m"(x),"m"(y),"m"(mod),
108 + "m"(MMX_0080w),"m"(MMX_VgrnRGB),"m"(MMX_VredRGB),
109 + "m"(MMX_FF00w),"m"(MMX_00FFw),"m"(MMX_UgrnRGB),
110 + "m"(MMX_UbluRGB));
111 }
112
113 void Color565DitherYV12MMX1X( int *colortab, Uint32 *rgb_2_pix,
114 @@ -263,21 +265,21 @@ void Color565DitherYV12MMX1X( int *color
115 "movd (%%ebx), %%mm1\n" // 4 Cr 0 0 0 0 v3 v2 v1 v0
116 "punpcklbw %%mm7, %%mm0\n" // 4 W cb 0 u3 0 u2 0 u1 0 u0
117 "punpcklbw %%mm7, %%mm1\n" // 4 W cr 0 v3 0 v2 0 v1 0 v0
118 - "psubw _MMX_0080w, %%mm0\n"
119 - "psubw _MMX_0080w, %%mm1\n"
120 + "psubw %9, %%mm0\n"
121 + "psubw %9, %%mm1\n"
122 "movq %%mm0, %%mm2\n" // Cb 0 u3 0 u2 0 u1 0 u0
123 "movq %%mm1, %%mm3\n" // Cr
124 - "pmullw _MMX_Ugrn565, %%mm2\n" // Cb2green 0 R3 0 R2 0 R1 0 R0
125 + "pmullw %10, %%mm2\n" // Cb2green 0 R3 0 R2 0 R1 0 R0
126 "movq (%2), %%mm6\n" // L1 l7 L6 L5 L4 L3 L2 L1 L0
127 - "pmullw _MMX_Ublu5x5, %%mm0\n" // Cb2blue
128 - "pand _MMX_00FFw, %%mm6\n" // L1 00 L6 00 L4 00 L2 00 L0
129 - "pmullw _MMX_Vgrn565, %%mm3\n" // Cr2green
130 + "pmullw %11, %%mm0\n" // Cb2blue
131 + "pand %12, %%mm6\n" // L1 00 L6 00 L4 00 L2 00 L0
132 + "pmullw %13, %%mm3\n" // Cr2green
133 "movq (%2), %%mm7\n" // L2
134 - "pmullw _MMX_Vred5x5, %%mm1\n" // Cr2red
135 + "pmullw %14, %%mm1\n" // Cr2red
136 "psrlw $8, %%mm7\n" // L2 00 L7 00 L5 00 L3 00 L1
137 - "pmullw _MMX_Ycoeff, %%mm6\n" // lum1
138 + "pmullw %15, %%mm6\n" // lum1
139 "paddw %%mm3, %%mm2\n" // Cb2green + Cr2green == green
140 - "pmullw _MMX_Ycoeff, %%mm7\n" // lum2
141 + "pmullw %15, %%mm7\n" // lum2
142
143 "movq %%mm6, %%mm4\n" // lum1
144 "paddw %%mm0, %%mm6\n" // lum1 +blue 00 B6 00 B4 00 B2 00 B0
145 @@ -295,11 +297,11 @@ void Color565DitherYV12MMX1X( int *color
146 "punpcklbw %%mm4, %%mm4\n"
147 "punpcklbw %%mm5, %%mm5\n"
148
149 - "pand _MMX_red565, %%mm4\n"
150 + "pand %16, %%mm4\n"
151 "psllw $3, %%mm5\n" // GREEN 1
152 "punpcklbw %%mm6, %%mm6\n"
153 - "pand _MMX_grn565, %%mm5\n"
154 - "pand _MMX_red565, %%mm6\n"
155 + "pand %17, %%mm5\n"
156 + "pand %16, %%mm6\n"
157 "por %%mm5, %%mm4\n" //
158 "psrlw $11, %%mm6\n" // BLUE 1
159 "movq %%mm3, %%mm5\n" // lum2
160 @@ -313,23 +315,23 @@ void Color565DitherYV12MMX1X( int *color
161 "packuswb %%mm3, %%mm3\n"
162 "packuswb %%mm5, %%mm5\n"
163 "packuswb %%mm7, %%mm7\n"
164 - "pand _MMX_00FFw, %%mm6\n" // L3
165 + "pand %12, %%mm6\n" // L3
166 "punpcklbw %%mm3, %%mm3\n"
167 "punpcklbw %%mm5, %%mm5\n"
168 - "pmullw _MMX_Ycoeff, %%mm6\n" // lum3
169 + "pmullw %15, %%mm6\n" // lum3
170 "punpcklbw %%mm7, %%mm7\n"
171 "psllw $3, %%mm5\n" // GREEN 2
172 - "pand _MMX_red565, %%mm7\n"
173 - "pand _MMX_red565, %%mm3\n"
174 + "pand %16, %%mm7\n"
175 + "pand %16, %%mm3\n"
176 "psrlw $11, %%mm7\n" // BLUE 2
177 - "pand _MMX_grn565, %%mm5\n"
178 + "pand %17, %%mm5\n"
179 "por %%mm7, %%mm3\n"
180 "movq (%2,%4), %%mm7\n" // L4 load lum2
181 "por %%mm5, %%mm3\n" //
182 "psrlw $8, %%mm7\n" // L4
183 "movq %%mm4, %%mm5\n"
184 "punpcklwd %%mm3, %%mm4\n"
185 - "pmullw _MMX_Ycoeff, %%mm7\n" // lum4
186 + "pmullw %15, %%mm7\n" // lum4
187 "punpckhwd %%mm3, %%mm5\n"
188
189 "movq %%mm4, (%3)\n" // write row1
190 @@ -356,11 +358,11 @@ void Color565DitherYV12MMX1X( int *color
191 "punpcklbw %%mm5, %%mm5\n"
192 "punpcklbw %%mm6, %%mm6\n"
193 "psllw $3, %%mm5\n" // GREEN 3
194 - "pand _MMX_red565, %%mm4\n"
195 + "pand %16, %%mm4\n"
196 "psraw $6, %%mm3\n" // psr 6
197 "psraw $6, %%mm0\n"
198 - "pand _MMX_red565, %%mm6\n" // BLUE
199 - "pand _MMX_grn565, %%mm5\n"
200 + "pand %16, %%mm6\n" // BLUE
201 + "pand %17, %%mm5\n"
202 "psrlw $11, %%mm6\n" // BLUE 3
203 "por %%mm5, %%mm4\n"
204 "psraw $6, %%mm7\n"
205 @@ -371,11 +373,11 @@ void Color565DitherYV12MMX1X( int *color
206 "punpcklbw %%mm3, %%mm3\n"
207 "punpcklbw %%mm0, %%mm0\n"
208 "punpcklbw %%mm7, %%mm7\n"
209 - "pand _MMX_red565, %%mm3\n"
210 - "pand _MMX_red565, %%mm7\n" // BLUE
211 + "pand %16, %%mm3\n"
212 + "pand %16, %%mm7\n" // BLUE
213 "psllw $3, %%mm0\n" // GREEN 4
214 "psrlw $11, %%mm7\n"
215 - "pand _MMX_grn565, %%mm0\n"
216 + "pand %17, %%mm0\n"
217 "por %%mm7, %%mm3\n"
218 "por %%mm0, %%mm3\n"
219
220 @@ -407,7 +409,10 @@ void Color565DitherYV12MMX1X( int *color
221 "popl %%ebx\n"
222 :
223 :"m" (cr), "r"(cb),"r"(lum),
224 - "r"(row1),"r"(cols),"r"(row2),"m"(x),"m"(y),"m"(mod));
225 + "r"(row1),"r"(cols),"r"(row2),"m"(x),"m"(y),"m"(mod),
226 + "m"(MMX_0080w),"m"(MMX_Ugrn565),"m"(MMX_Ublu5x5),
227 + "m"(MMX_00FFw),"m"(MMX_Vgrn565),"m"(MMX_Vred5x5),
228 + "m"(MMX_Ycoeff),"m"(MMX_red565),"m"(MMX_grn565));
229 }
230
231 #endif /* GCC i386 inline assembly */