Mercurial > mplayer.hg
annotate libvo/osd_template.c @ 2674:aadcae54d45c
started mencoder documentation
author | gabucino |
---|---|
date | Sun, 04 Nov 2001 11:20:11 +0000 |
parents | d363fde389b5 |
children | ee2cd36a81a2 |
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) | |
3 | |
947
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
4 //#define FAST_OSD |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
5 //#define FAST_OSD_TABLE |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
6 |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
7 #include "config.h" |
622 | 8 #include "osd.h" |
9 | |
326 | 10 void vo_draw_alpha_yv12(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride){ |
11 int y; | |
947
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
12 #ifdef FAST_OSD |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
13 w=w>>1; |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
14 #endif |
326 | 15 for(y=0;y<h;y++){ |
16 register int x; | |
17 for(x=0;x<w;x++){ | |
947
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
18 #ifdef FAST_OSD |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
19 if(srca[2*x+0]) dstbase[2*x+0]=src[2*x+0]; |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
20 if(srca[2*x+1]) dstbase[2*x+1]=src[2*x+1]; |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
21 #else |
326 | 22 if(srca[x]) dstbase[x]=((dstbase[x]*srca[x])>>8)+src[x]; |
947
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
23 #endif |
326 | 24 } |
25 src+=srcstride; | |
26 srca+=srcstride; | |
27 dstbase+=dststride; | |
28 } | |
29 return; | |
30 } | |
31 | |
32 void vo_draw_alpha_yuy2(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride){ | |
33 int y; | |
947
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
34 #ifdef FAST_OSD |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
35 w=w>>1; |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
36 #endif |
326 | 37 for(y=0;y<h;y++){ |
38 register int x; | |
39 for(x=0;x<w;x++){ | |
947
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
40 #ifdef FAST_OSD |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
41 if(srca[2*x+0]) dstbase[4*x+0]=src[2*x+0]; |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
42 if(srca[2*x+1]) dstbase[4*x+2]=src[2*x+1]; |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
43 #else |
326 | 44 if(srca[x]) dstbase[2*x]=((dstbase[2*x]*srca[x])>>8)+src[x]; |
947
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
45 #endif |
326 | 46 } |
47 src+=srcstride; | |
48 srca+=srcstride; | |
49 dstbase+=dststride; | |
50 } | |
51 return; | |
52 } | |
53 | |
54 void vo_draw_alpha_rgb24(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride){ | |
55 int y; | |
56 for(y=0;y<h;y++){ | |
57 register unsigned char *dst = dstbase; | |
58 register int x; | |
59 for(x=0;x<w;x++){ | |
60 if(srca[x]){ | |
947
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
61 #ifdef FAST_OSD |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
62 dst[0]=dst[1]=dst[2]=src[x]; |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
63 #else |
326 | 64 dst[0]=((dst[0]*srca[x])>>8)+src[x]; |
65 dst[1]=((dst[1]*srca[x])>>8)+src[x]; | |
66 dst[2]=((dst[2]*srca[x])>>8)+src[x]; | |
947
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
67 #endif |
326 | 68 } |
69 dst+=3; // 24bpp | |
70 } | |
71 src+=srcstride; | |
72 srca+=srcstride; | |
73 dstbase+=dststride; | |
74 } | |
75 return; | |
76 } | |
77 | |
78 void vo_draw_alpha_rgb32(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride){ | |
79 int y; | |
80 for(y=0;y<h;y++){ | |
81 register int x; | |
2578 | 82 // printf("%d, %d, %d\n", (int)src&31, (int)srca%31, (int)dstbase&31); |
83 #ifdef HAVE_MMXFIXME | |
84 /* asm( | |
85 "pxor %%mm7, %%mm7 \n\t" | |
86 "xorl %%eax, %%eax \n\t" | |
87 "pcmpeqb %%mm6, %%mm6 \n\t" // F..F | |
88 "1: \n\t" | |
89 "movq (%0, %%eax, 4), %%mm0 \n\t" // dstbase | |
90 "movq %%mm0, %%mm1 \n\t" | |
91 "punpcklbw %%mm7, %%mm0 \n\t" | |
92 "punpckhbw %%mm7, %%mm1 \n\t" | |
93 "movd (%1, %%eax), %%mm2 \n\t" // srca ABCD0000 | |
94 "paddb %%mm6, %%mm2 \n\t" | |
95 "punpcklbw %%mm2, %%mm2 \n\t" // srca AABBCCDD | |
96 "punpcklbw %%mm2, %%mm2 \n\t" // srca AAAABBBB | |
97 "movq %%mm2, %%mm3 \n\t" | |
98 "punpcklbw %%mm7, %%mm2 \n\t" // srca 0A0A0A0A | |
99 "punpckhbw %%mm7, %%mm3 \n\t" // srca 0B0B0B0B | |
100 "pmullw %%mm2, %%mm0 \n\t" | |
101 "pmullw %%mm3, %%mm1 \n\t" | |
102 "psrlw $8, %%mm0 \n\t" | |
103 "psrlw $8, %%mm1 \n\t" | |
104 "packuswb %%mm1, %%mm0 \n\t" | |
105 "movd (%2, %%eax), %%mm2 \n\t" // src ABCD0000 | |
106 "punpcklbw %%mm2, %%mm2 \n\t" // src AABBCCDD | |
107 "punpcklbw %%mm2, %%mm2 \n\t" // src AAAABBBB | |
108 "paddb %%mm2, %%mm0 \n\t" | |
109 "movq %%mm0, (%0, %%eax, 4) \n\t" | |
110 "addl $2, %%eax \n\t" | |
111 "cmpl %3, %%eax \n\t" | |
112 " jb 1b \n\t" | |
113 | |
114 :: "r" (dstbase), "r" (srca), "r" (src), "r" (w) | |
115 : "%eax" | |
116 );*/ | |
117 asm( | |
118 "xorl %%eax, %%eax \n\t" | |
119 "xorl %%ebx, %%ebx \n\t" | |
120 "xorl %%edx, %%edx \n\t" | |
121 "1: \n\t" | |
122 "movb (%1, %%eax), %%bl \n\t" | |
123 "cmpb $0, %%bl \n\t" | |
124 " jz 2f \n\t" | |
125 "movzxb (%2, %%eax), %%edx \n\t" | |
126 "shll $8, %%edx \n\t" | |
127 "decb %%bl \n\t" | |
128 "movzxb (%0, %%eax, 4), %%ecx \n\t" | |
129 "imull %%ebx, %%ecx \n\t" | |
130 "addl %%edx, %%ecx \n\t" | |
131 "movb %%ch, (%0, %%eax, 4) \n\t" | |
132 | |
133 "movzxb 1(%0, %%eax, 4), %%ecx \n\t" | |
134 "imull %%ebx, %%ecx \n\t" | |
135 "addl %%edx, %%ecx \n\t" | |
136 "movb %%ch, 1(%0, %%eax, 4) \n\t" | |
137 | |
138 "movzxb 2(%0, %%eax, 4), %%ecx \n\t" | |
139 "imull %%ebx, %%ecx \n\t" | |
140 "addl %%edx, %%ecx \n\t" | |
141 "movb %%ch, 2(%0, %%eax, 4) \n\t" | |
142 | |
143 "2: \n\t" | |
144 "addl $1, %%eax \n\t" | |
145 "cmpl %3, %%eax \n\t" | |
146 " jb 1b \n\t" | |
147 | |
148 :: "r" (dstbase), "r" (srca), "r" (src), "m" (w) | |
149 : "%eax", "%ebx", "%ecx", "%edx" | |
150 ); | |
151 #else //HAVE_MMX | |
326 | 152 for(x=0;x<w;x++){ |
153 if(srca[x]){ | |
947
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
154 #ifdef FAST_OSD |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
155 dstbase[4*x+0]=dstbase[4*x+1]=dstbase[4*x+2]=src[x]; |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
156 #else |
326 | 157 dstbase[4*x+0]=((dstbase[4*x+0]*srca[x])>>8)+src[x]; |
158 dstbase[4*x+1]=((dstbase[4*x+1]*srca[x])>>8)+src[x]; | |
159 dstbase[4*x+2]=((dstbase[4*x+2]*srca[x])>>8)+src[x]; | |
947
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
160 #endif |
326 | 161 } |
162 } | |
2578 | 163 #endif // !HAVE_MMX |
326 | 164 src+=srcstride; |
165 srca+=srcstride; | |
166 dstbase+=dststride; | |
167 } | |
2578 | 168 #ifdef HAVE_3DNOW |
169 asm("femms\n\t"); | |
170 #elif defined (HAVE_MMX) | |
171 asm("emms\n\t"); | |
172 #endif | |
173 | |
326 | 174 return; |
175 } | |
176 | |
947
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
177 #ifdef FAST_OSD_TABLE |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
178 static unsigned short fast_osd_15bpp_table[256]; |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
179 static unsigned short fast_osd_16bpp_table[256]; |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
180 #endif |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
181 |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
182 void vo_draw_alpha_init(){ |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
183 #ifdef FAST_OSD_TABLE |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
184 int i; |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
185 for(i=0;i<256;i++){ |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
186 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
|
187 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
|
188 } |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
189 #endif |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
190 } |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
191 |
326 | 192 void vo_draw_alpha_rgb15(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride){ |
193 int y; | |
194 for(y=0;y<h;y++){ | |
195 register unsigned short *dst = (unsigned short*) dstbase; | |
196 register int x; | |
197 for(x=0;x<w;x++){ | |
198 if(srca[x]){ | |
947
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
199 #ifdef FAST_OSD |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
200 #ifdef FAST_OSD_TABLE |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
201 dst[x]=fast_osd_15bpp_table[src[x]]; |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
202 #else |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
203 register unsigned int a=src[x]>>3; |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
204 dst[x]=(a<<10)|(a<<5)|a; |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
205 #endif |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
206 #else |
326 | 207 unsigned char r=dst[x]&0x1F; |
208 unsigned char g=(dst[x]>>5)&0x1F; | |
209 unsigned char b=(dst[x]>>10)&0x1F; | |
210 r=(((r*srca[x])>>5)+src[x])>>3; | |
211 g=(((g*srca[x])>>5)+src[x])>>3; | |
212 b=(((b*srca[x])>>5)+src[x])>>3; | |
213 dst[x]=(b<<10)|(g<<5)|r; | |
947
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
214 #endif |
326 | 215 } |
216 } | |
217 src+=srcstride; | |
218 srca+=srcstride; | |
219 dstbase+=dststride; | |
220 } | |
221 return; | |
222 } | |
223 | |
224 void vo_draw_alpha_rgb16(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride){ | |
225 int y; | |
226 for(y=0;y<h;y++){ | |
227 register unsigned short *dst = (unsigned short*) dstbase; | |
228 register int x; | |
229 for(x=0;x<w;x++){ | |
230 if(srca[x]){ | |
947
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
231 #ifdef FAST_OSD |
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 dst[x]=fast_osd_16bpp_table[src[x]]; |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
234 #else |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
235 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
|
236 #endif |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
237 #else |
326 | 238 unsigned char r=dst[x]&0x1F; |
239 unsigned char g=(dst[x]>>5)&0x3F; | |
240 unsigned char b=(dst[x]>>11)&0x1F; | |
241 r=(((r*srca[x])>>5)+src[x])>>3; | |
242 g=(((g*srca[x])>>6)+src[x])>>2; | |
243 b=(((b*srca[x])>>5)+src[x])>>3; | |
244 dst[x]=(b<<11)|(g<<5)|r; | |
947
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
622
diff
changeset
|
245 #endif |
326 | 246 } |
247 } | |
248 src+=srcstride; | |
249 srca+=srcstride; | |
250 dstbase+=dststride; | |
251 } | |
252 return; | |
253 } | |
254 |