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