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