Mercurial > mplayer.hg
annotate libvo/osd.c @ 5862:e03dc14d3f2f
Runtime cpu detection is disabled by default.
author | ksorim |
---|---|
date | Sat, 27 Apr 2002 12:25:48 +0000 |
parents | 27cb0e43de32 |
children | 5074aa8fae5a |
rev | line source |
---|---|
326 | 1 // Generic alpha renderers for all YUV modes and RGB depths. |
2 // These are "reference implementations", should be optimized later (MMX, etc) | |
3142 | 3 // Templating Code from Michael Niedermayer (michaelni@gmx.at) is under GPL |
326 | 4 |
947
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
5 //#define FAST_OSD |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
6 //#define FAST_OSD_TABLE |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
7 |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
8 #include "config.h" |
622 | 9 #include "osd.h" |
2833 | 10 //#define ENABLE_PROFILE |
11 #include "../my_profile.h" | |
2846 | 12 #include <inttypes.h> |
3142 | 13 #include "../cpudetect.h" |
4245 | 14 #include "../mangle.h" |
2846 | 15 |
3142 | 16 extern int verbose; // defined in mplayer.c |
17 | |
18 #ifdef ARCH_X86 | |
19 #define CAN_COMPILE_X86_ASM | |
2846 | 20 #endif |
622 | 21 |
3142 | 22 #ifdef CAN_COMPILE_X86_ASM |
23 static const uint64_t bFF __attribute__((aligned(8))) = 0xFFFFFFFFFFFFFFFFULL; | |
2839 | 24 static const unsigned long long mask24lh __attribute__((aligned(8))) = 0xFFFF000000000000ULL; |
25 static const unsigned long long mask24hl __attribute__((aligned(8))) = 0x0000FFFFFFFFFFFFULL; | |
26 #endif | |
3142 | 27 |
28 //Note: we have C, X86-nommx, MMX, MMX2, 3DNOW version therse no 3DNOW+MMX2 one | |
29 //Plain C versions | |
3153 | 30 #if !defined (HAVE_MMX) || defined (RUNTIME_CPUDETECT) |
31 #define COMPILE_C | |
32 #endif | |
33 | |
34 #ifdef CAN_COMPILE_X86_ASM | |
35 | |
36 #if (defined (HAVE_MMX) && !defined (HAVE_3DNOW) && !defined (HAVE_MMX2)) || defined (RUNTIME_CPUDETECT) | |
37 #define COMPILE_MMX | |
38 #endif | |
39 | |
40 #if defined (HAVE_MMX2) || defined (RUNTIME_CPUDETECT) | |
41 #define COMPILE_MMX2 | |
42 #endif | |
43 | |
44 #if (defined (HAVE_3DNOW) && !defined (HAVE_MMX2)) || defined (RUNTIME_CPUDETECT) | |
45 #define COMPILE_3DNOW | |
46 #endif | |
47 #endif //CAN_COMPILE_X86_ASM | |
48 | |
49 #undef HAVE_MMX | |
50 #undef HAVE_MMX2 | |
51 #undef HAVE_3DNOW | |
52 #undef ARCH_X86 | |
53 | |
54 #ifdef COMPILE_C | |
3142 | 55 #undef HAVE_MMX |
56 #undef HAVE_MMX2 | |
57 #undef HAVE_3DNOW | |
58 #undef ARCH_X86 | |
59 #define RENAME(a) a ## _C | |
60 #include "osd_template.c" | |
3153 | 61 #endif |
3142 | 62 |
63 #ifdef CAN_COMPILE_X86_ASM | |
64 | |
65 //X86 noMMX versions | |
3153 | 66 #ifdef COMPILE_C |
3142 | 67 #undef RENAME |
68 #undef HAVE_MMX | |
69 #undef HAVE_MMX2 | |
70 #undef HAVE_3DNOW | |
71 #define ARCH_X86 | |
72 #define RENAME(a) a ## _X86 | |
73 #include "osd_template.c" | |
3153 | 74 #endif |
3142 | 75 |
76 //MMX versions | |
3153 | 77 #ifdef COMPILE_MMX |
3142 | 78 #undef RENAME |
79 #define HAVE_MMX | |
80 #undef HAVE_MMX2 | |
81 #undef HAVE_3DNOW | |
82 #define ARCH_X86 | |
83 #define RENAME(a) a ## _MMX | |
84 #include "osd_template.c" | |
3153 | 85 #endif |
3142 | 86 |
87 //MMX2 versions | |
3153 | 88 #ifdef COMPILE_MMX2 |
3142 | 89 #undef RENAME |
90 #define HAVE_MMX | |
91 #define HAVE_MMX2 | |
92 #undef HAVE_3DNOW | |
93 #define ARCH_X86 | |
94 #define RENAME(a) a ## _MMX2 | |
95 #include "osd_template.c" | |
3153 | 96 #endif |
3142 | 97 |
98 //3DNOW versions | |
3153 | 99 #ifdef COMPILE_3DNOW |
3142 | 100 #undef RENAME |
101 #define HAVE_MMX | |
102 #undef HAVE_MMX2 | |
103 #define HAVE_3DNOW | |
104 #define ARCH_X86 | |
105 #define RENAME(a) a ## _3DNow | |
106 #include "osd_template.c" | |
3153 | 107 #endif |
3142 | 108 |
109 #endif //CAN_COMPILE_X86_ASM | |
110 | |
111 void vo_draw_alpha_yv12(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride){ | |
3153 | 112 #ifdef RUNTIME_CPUDETECT |
3142 | 113 #ifdef CAN_COMPILE_X86_ASM |
114 // ordered per speed fasterst first | |
115 if(gCpuCaps.hasMMX2) | |
116 vo_draw_alpha_yv12_MMX2(w, h, src, srca, srcstride, dstbase, dststride); | |
117 else if(gCpuCaps.has3DNow) | |
118 vo_draw_alpha_yv12_3DNow(w, h, src, srca, srcstride, dstbase, dststride); | |
119 else if(gCpuCaps.hasMMX) | |
120 vo_draw_alpha_yv12_MMX(w, h, src, srca, srcstride, dstbase, dststride); | |
121 else | |
122 vo_draw_alpha_yv12_X86(w, h, src, srca, srcstride, dstbase, dststride); | |
123 #else | |
124 vo_draw_alpha_yv12_C(w, h, src, srca, srcstride, dstbase, dststride); | |
125 #endif | |
3153 | 126 #else //RUNTIME_CPUDETECT |
127 #ifdef HAVE_MMX2 | |
128 vo_draw_alpha_yv12_MMX2(w, h, src, srca, srcstride, dstbase, dststride); | |
129 #elif defined (HAVE_3DNOW) | |
130 vo_draw_alpha_yv12_3DNow(w, h, src, srca, srcstride, dstbase, dststride); | |
131 #elif defined (HAVE_MMX) | |
132 vo_draw_alpha_yv12_MMX(w, h, src, srca, srcstride, dstbase, dststride); | |
133 #elif defined (ARCH_X86) | |
134 vo_draw_alpha_yv12_X86(w, h, src, srca, srcstride, dstbase, dststride); | |
135 #else | |
136 vo_draw_alpha_yv12_C(w, h, src, srca, srcstride, dstbase, dststride); | |
137 #endif | |
138 #endif //!RUNTIME_CPUDETECT | |
3142 | 139 } |
140 | |
141 void vo_draw_alpha_yuy2(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride){ | |
3153 | 142 #ifdef RUNTIME_CPUDETECT |
3142 | 143 #ifdef CAN_COMPILE_X86_ASM |
144 // ordered per speed fasterst first | |
145 if(gCpuCaps.hasMMX2) | |
146 vo_draw_alpha_yuy2_MMX2(w, h, src, srca, srcstride, dstbase, dststride); | |
147 else if(gCpuCaps.has3DNow) | |
148 vo_draw_alpha_yuy2_3DNow(w, h, src, srca, srcstride, dstbase, dststride); | |
149 else if(gCpuCaps.hasMMX) | |
150 vo_draw_alpha_yuy2_MMX(w, h, src, srca, srcstride, dstbase, dststride); | |
151 else | |
152 vo_draw_alpha_yuy2_X86(w, h, src, srca, srcstride, dstbase, dststride); | |
153 #else | |
154 vo_draw_alpha_yuy2_C(w, h, src, srca, srcstride, dstbase, dststride); | |
155 #endif | |
3153 | 156 #else //RUNTIME_CPUDETECT |
157 #ifdef HAVE_MMX2 | |
158 vo_draw_alpha_yuy2_MMX2(w, h, src, srca, srcstride, dstbase, dststride); | |
159 #elif defined (HAVE_3DNOW) | |
160 vo_draw_alpha_yuy2_3DNow(w, h, src, srca, srcstride, dstbase, dststride); | |
161 #elif defined (HAVE_MMX) | |
162 vo_draw_alpha_yuy2_MMX(w, h, src, srca, srcstride, dstbase, dststride); | |
163 #elif defined (ARCH_X86) | |
164 vo_draw_alpha_yuy2_X86(w, h, src, srca, srcstride, dstbase, dststride); | |
165 #else | |
166 vo_draw_alpha_yuy2_C(w, h, src, srca, srcstride, dstbase, dststride); | |
167 #endif | |
168 #endif //!RUNTIME_CPUDETECT | |
3142 | 169 } |
170 | |
326 | 171 void vo_draw_alpha_rgb24(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride){ |
3153 | 172 #ifdef RUNTIME_CPUDETECT |
3142 | 173 #ifdef CAN_COMPILE_X86_ASM |
174 // ordered per speed fasterst first | |
175 if(gCpuCaps.hasMMX2) | |
176 vo_draw_alpha_rgb24_MMX2(w, h, src, srca, srcstride, dstbase, dststride); | |
177 else if(gCpuCaps.has3DNow) | |
178 vo_draw_alpha_rgb24_3DNow(w, h, src, srca, srcstride, dstbase, dststride); | |
179 else if(gCpuCaps.hasMMX) | |
180 vo_draw_alpha_rgb24_MMX(w, h, src, srca, srcstride, dstbase, dststride); | |
181 else | |
182 vo_draw_alpha_rgb24_X86(w, h, src, srca, srcstride, dstbase, dststride); | |
947
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
183 #else |
3142 | 184 vo_draw_alpha_rgb24_C(w, h, src, srca, srcstride, dstbase, dststride); |
947
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
185 #endif |
3153 | 186 #else //RUNTIME_CPUDETECT |
187 #ifdef HAVE_MMX2 | |
188 vo_draw_alpha_rgb24_MMX2(w, h, src, srca, srcstride, dstbase, dststride); | |
189 #elif defined (HAVE_3DNOW) | |
190 vo_draw_alpha_rgb24_3DNow(w, h, src, srca, srcstride, dstbase, dststride); | |
191 #elif defined (HAVE_MMX) | |
192 vo_draw_alpha_rgb24_MMX(w, h, src, srca, srcstride, dstbase, dststride); | |
193 #elif defined (ARCH_X86) | |
194 vo_draw_alpha_rgb24_X86(w, h, src, srca, srcstride, dstbase, dststride); | |
195 #else | |
196 vo_draw_alpha_rgb24_C(w, h, src, srca, srcstride, dstbase, dststride); | |
197 #endif | |
198 #endif //!RUNTIME_CPUDETECT | |
326 | 199 } |
200 | |
201 void vo_draw_alpha_rgb32(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride){ | |
3153 | 202 #ifdef RUNTIME_CPUDETECT |
3142 | 203 #ifdef CAN_COMPILE_X86_ASM |
204 // ordered per speed fasterst first | |
205 if(gCpuCaps.hasMMX2) | |
206 vo_draw_alpha_rgb32_MMX2(w, h, src, srca, srcstride, dstbase, dststride); | |
207 else if(gCpuCaps.has3DNow) | |
208 vo_draw_alpha_rgb32_3DNow(w, h, src, srca, srcstride, dstbase, dststride); | |
209 else if(gCpuCaps.hasMMX) | |
210 vo_draw_alpha_rgb32_MMX(w, h, src, srca, srcstride, dstbase, dststride); | |
211 else | |
212 vo_draw_alpha_rgb32_X86(w, h, src, srca, srcstride, dstbase, dststride); | |
213 #else | |
214 vo_draw_alpha_rgb32_C(w, h, src, srca, srcstride, dstbase, dststride); | |
2846 | 215 #endif |
3153 | 216 #else //RUNTIME_CPUDETECT |
217 #ifdef HAVE_MMX2 | |
218 vo_draw_alpha_rgb32_MMX2(w, h, src, srca, srcstride, dstbase, dststride); | |
219 #elif defined (HAVE_3DNOW) | |
220 vo_draw_alpha_rgb32_3DNow(w, h, src, srca, srcstride, dstbase, dststride); | |
221 #elif defined (HAVE_MMX) | |
222 vo_draw_alpha_rgb32_MMX(w, h, src, srca, srcstride, dstbase, dststride); | |
223 #elif defined (ARCH_X86) | |
224 vo_draw_alpha_rgb32_X86(w, h, src, srca, srcstride, dstbase, dststride); | |
225 #else | |
226 vo_draw_alpha_rgb32_C(w, h, src, srca, srcstride, dstbase, dststride); | |
227 #endif | |
228 #endif //!RUNTIME_CPUDETECT | |
326 | 229 } |
230 | |
947
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
231 #ifdef FAST_OSD_TABLE |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
232 static unsigned short fast_osd_15bpp_table[256]; |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
233 static unsigned short fast_osd_16bpp_table[256]; |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
234 #endif |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
235 |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
236 void vo_draw_alpha_init(){ |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
237 #ifdef FAST_OSD_TABLE |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
238 int i; |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
239 for(i=0;i<256;i++){ |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
240 fast_osd_15bpp_table[i]=((i>>3)<<10)|((i>>3)<<5)|(i>>3); |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
241 fast_osd_16bpp_table[i]=((i>>3)<<11)|((i>>2)<<5)|(i>>3); |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
242 } |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
243 #endif |
3142 | 244 //FIXME the optimized stuff is a lie for 15/16bpp as they arent optimized yet |
245 if(verbose) | |
246 { | |
3153 | 247 #ifdef RUNTIME_CPUDETECT |
3142 | 248 #ifdef CAN_COMPILE_X86_ASM |
249 // ordered per speed fasterst first | |
250 if(gCpuCaps.hasMMX2) | |
251 printf("Using MMX (with tiny bit MMX2) Optimized OnScreenDisplay\n"); | |
252 else if(gCpuCaps.has3DNow) | |
253 printf("Using MMX (with tiny bit 3DNow) Optimized OnScreenDisplay\n"); | |
254 else if(gCpuCaps.hasMMX) | |
255 printf("Using MMX Optimized OnScreenDisplay\n"); | |
256 else | |
257 printf("Using X86 Optimized OnScreenDisplay\n"); | |
258 #else | |
259 printf("Using Unoptimized OnScreenDisplay\n"); | |
260 #endif | |
3153 | 261 #else //RUNTIME_CPUDETECT |
262 #ifdef HAVE_MMX2 | |
263 printf("Using MMX (with tiny bit MMX2) Optimized OnScreenDisplay\n"); | |
264 #elif defined (HAVE_3DNOW) | |
265 printf("Using MMX (with tiny bit 3DNow) Optimized OnScreenDisplay\n"); | |
266 #elif defined (HAVE_MMX) | |
267 printf("Using MMX Optimized OnScreenDisplay\n"); | |
268 #elif defined (ARCH_X86) | |
269 printf("Using X86 Optimized OnScreenDisplay\n"); | |
270 #else | |
271 printf("Using Unoptimized OnScreenDisplay\n"); | |
272 #endif | |
273 #endif //!RUNTIME_CPUDETECT | |
3142 | 274 } |
947
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
275 } |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
276 |
326 | 277 void vo_draw_alpha_rgb15(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride){ |
278 int y; | |
279 for(y=0;y<h;y++){ | |
280 register unsigned short *dst = (unsigned short*) dstbase; | |
281 register int x; | |
282 for(x=0;x<w;x++){ | |
283 if(srca[x]){ | |
947
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
284 #ifdef FAST_OSD |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
285 #ifdef FAST_OSD_TABLE |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
286 dst[x]=fast_osd_15bpp_table[src[x]]; |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
287 #else |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
288 register unsigned int a=src[x]>>3; |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
289 dst[x]=(a<<10)|(a<<5)|a; |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
290 #endif |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
291 #else |
326 | 292 unsigned char r=dst[x]&0x1F; |
293 unsigned char g=(dst[x]>>5)&0x1F; | |
294 unsigned char b=(dst[x]>>10)&0x1F; | |
295 r=(((r*srca[x])>>5)+src[x])>>3; | |
296 g=(((g*srca[x])>>5)+src[x])>>3; | |
297 b=(((b*srca[x])>>5)+src[x])>>3; | |
298 dst[x]=(b<<10)|(g<<5)|r; | |
947
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
299 #endif |
326 | 300 } |
301 } | |
302 src+=srcstride; | |
303 srca+=srcstride; | |
304 dstbase+=dststride; | |
305 } | |
306 return; | |
307 } | |
308 | |
309 void vo_draw_alpha_rgb16(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride){ | |
310 int y; | |
311 for(y=0;y<h;y++){ | |
312 register unsigned short *dst = (unsigned short*) dstbase; | |
313 register int x; | |
314 for(x=0;x<w;x++){ | |
315 if(srca[x]){ | |
947
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
316 #ifdef FAST_OSD |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
317 #ifdef FAST_OSD_TABLE |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
318 dst[x]=fast_osd_16bpp_table[src[x]]; |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
319 #else |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
320 dst[x]=((src[x]>>3)<<11)|((src[x]>>2)<<5)|(src[x]>>3); |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
321 #endif |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
322 #else |
326 | 323 unsigned char r=dst[x]&0x1F; |
324 unsigned char g=(dst[x]>>5)&0x3F; | |
325 unsigned char b=(dst[x]>>11)&0x1F; | |
326 r=(((r*srca[x])>>5)+src[x])>>3; | |
327 g=(((g*srca[x])>>6)+src[x])>>2; | |
328 b=(((b*srca[x])>>5)+src[x])>>3; | |
329 dst[x]=(b<<11)|(g<<5)|r; | |
947
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
330 #endif |
326 | 331 } |
332 } | |
333 src+=srcstride; | |
334 srca+=srcstride; | |
335 dstbase+=dststride; | |
336 } | |
337 return; | |
338 } | |
339 |