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