Mercurial > mplayer.hg
annotate libvo/sub.c @ 947:76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
author | arpi_esp |
---|---|
date | Sat, 02 Jun 2001 16:02:38 +0000 |
parents | 83919c1b9924 |
children | a013b2124f05 |
rev | line source |
---|---|
218 | 1 |
2 #include "sub.h" | |
202 | 3 |
213 | 4 //static int vo_font_loaded=-1; |
5 font_desc_t* vo_font=NULL; | |
202 | 6 |
213 | 7 unsigned char* vo_osd_text="00:00:00"; |
803
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
8 int sub_unicode=0; |
213 | 9 |
865 | 10 static void vo_draw_text_osd(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)){ |
213 | 11 int len=strlen(vo_osd_text); |
12 int j; | |
13 int y=10; | |
14 int x=20; | |
202 | 15 |
213 | 16 for(j=0;j<len;j++){ |
17 int c=vo_osd_text[j]; | |
18 int font=vo_font->font[c]; | |
19 if(font>=0) | |
20 draw_alpha(x,y, | |
21 vo_font->width[c], | |
22 vo_font->pic_a[font]->h, | |
23 vo_font->pic_b[font]->bmp+vo_font->start[c], | |
24 vo_font->pic_a[font]->bmp+vo_font->start[c], | |
25 vo_font->pic_a[font]->w); | |
26 x+=vo_font->width[c]+vo_font->charspace; | |
27 } | |
218 | 28 |
29 } | |
30 | |
31 int vo_osd_progbar_type=-1; | |
32 int vo_osd_progbar_value=100; // 0..255 | |
33 | |
865 | 34 static void vo_draw_text_progbar(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)){ |
218 | 35 int len=strlen(vo_osd_text); |
36 int i; | |
37 int y=dys/2; | |
38 int x; | |
39 int c,font; | |
372 | 40 int width=(dxs*2/3-vo_font->width[0x10]-vo_font->width[0x12]); |
218 | 41 int elems=width/vo_font->width[0x11]; |
42 int mark=(vo_osd_progbar_value*(elems+1))>>8; | |
43 x=(dxs-width)/2; | |
44 // printf("osd.progbar width=%d xpos=%d\n",width,x); | |
45 | |
46 c=vo_osd_progbar_type;font=vo_font->font[c]; | |
47 if(vo_osd_progbar_type>0 && font>=0) | |
48 draw_alpha(x-vo_font->width[c]-vo_font->spacewidth,y, | |
49 vo_font->width[c], | |
50 vo_font->pic_a[font]->h, | |
51 vo_font->pic_b[font]->bmp+vo_font->start[c], | |
52 vo_font->pic_a[font]->bmp+vo_font->start[c], | |
53 vo_font->pic_a[font]->w); | |
213 | 54 |
218 | 55 c=OSD_PB_START;font=vo_font->font[c]; |
56 if(font>=0) | |
57 draw_alpha(x,y, | |
58 vo_font->width[c], | |
59 vo_font->pic_a[font]->h, | |
60 vo_font->pic_b[font]->bmp+vo_font->start[c], | |
61 vo_font->pic_a[font]->bmp+vo_font->start[c], | |
62 vo_font->pic_a[font]->w); | |
63 x+=vo_font->width[c]; | |
64 | |
65 for(i=0;i<elems;i++){ | |
66 c=(i<mark)?OSD_PB_0:OSD_PB_1;font=vo_font->font[c]; | |
67 if(font>=0) | |
68 draw_alpha(x,y, | |
69 vo_font->width[c], | |
70 vo_font->pic_a[font]->h, | |
71 vo_font->pic_b[font]->bmp+vo_font->start[c], | |
72 vo_font->pic_a[font]->bmp+vo_font->start[c], | |
73 vo_font->pic_a[font]->w); | |
74 x+=vo_font->width[c]; | |
75 } | |
202 | 76 |
218 | 77 c=OSD_PB_END;font=vo_font->font[c]; |
78 if(font>=0) | |
79 draw_alpha(x,y, | |
80 vo_font->width[c], | |
81 vo_font->pic_a[font]->h, | |
82 vo_font->pic_b[font]->bmp+vo_font->start[c], | |
83 vo_font->pic_a[font]->bmp+vo_font->start[c], | |
84 vo_font->pic_a[font]->w); | |
85 // x+=vo_font->width[c]; | |
803
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
86 |
218 | 87 |
88 // vo_osd_progbar_value=(vo_osd_progbar_value+1)&0xFF; | |
89 | |
90 } | |
91 | |
254 | 92 subtitle* vo_sub=NULL; |
218 | 93 |
865 | 94 static void vo_draw_text_sub(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)){ |
218 | 95 int i; |
96 int y; | |
803
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
97 y=dys-(1+vo_sub->lines-1)*vo_font->height-10; |
218 | 98 |
803
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
99 // too long lines divide into smaller ones |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
100 for(i=0;i<vo_sub->lines;i++){ |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
101 unsigned char* text=vo_sub->text[i]; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
102 int len=strlen(text); |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
103 int j,k; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
104 int xsize=-vo_font->charspace; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
105 int x=0; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
106 |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
107 int lastStripPosition=-1; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
108 int previousStrip=0; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
109 int lastxsize=0; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
110 |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
111 for(j=0;j<len;j++){ |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
112 int c=text[j]; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
113 int w; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
114 if (sub_unicode && (c>=0x80)) c=(c<<8)+text[++j]; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
115 w = vo_font->width[c]; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
116 if (text[j]==' ' && dxs>xsize) |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
117 { |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
118 lastStripPosition=j; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
119 lastxsize=xsize; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
120 } |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
121 xsize+=w+vo_font->charspace; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
122 if (dxs<xsize & lastStripPosition>0) |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
123 { |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
124 xsize=lastxsize; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
125 j=lastStripPosition; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
126 y-=vo_font->height; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
127 previousStrip=lastStripPosition; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
128 xsize=-vo_font->charspace; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
129 } |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
130 } |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
131 } |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
132 |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
133 |
254 | 134 for(i=0;i<vo_sub->lines;i++){ |
135 unsigned char* text=vo_sub->text[i];// "Hello World! HÛDEJÓ!"; | |
213 | 136 int len=strlen(text); |
803
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
137 int j,k; |
213 | 138 int xsize=-vo_font->charspace; |
139 int x=0; | |
140 | |
803
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
141 int lastStripPosition=-1; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
142 int previousStrip=0; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
143 int lastxsize=xsize; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
144 |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
145 for(j=0;j<len;j++){ |
213 | 146 int c=text[j]; |
803
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
147 int w; |
726 | 148 if (sub_unicode && (c>=0x80)) c=(c<<8)+text[++j]; |
803
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
149 w = vo_font->width[c]; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
150 if (c==' ' && dxs>xsize) |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
151 { |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
152 lastStripPosition=j; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
153 lastxsize=xsize; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
154 } |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
155 xsize+=w+vo_font->charspace; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
156 if ((dxs<xsize & lastStripPosition>0)| j==len-1) |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
157 { |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
158 if (j==len-1) lastStripPosition=len; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
159 else xsize=lastxsize; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
160 j=lastStripPosition; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
161 |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
162 x=dxs/2-xsize/2; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
163 |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
164 for(k=previousStrip;k<lastStripPosition;k++){ |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
165 int c=text[k]; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
166 int font; |
805 | 167 if (sub_unicode && (c>=0x80)) c=(c<<8)+text[++k]; |
803
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
168 font=vo_font->font[c]; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
169 if(x>=0 && x+vo_font->width[c]<dxs) |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
170 if(font>=0) |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
171 draw_alpha(x,y, |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
172 vo_font->width[c], |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
173 vo_font->pic_a[font]->h, |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
174 vo_font->pic_b[font]->bmp+vo_font->start[c], |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
175 vo_font->pic_a[font]->bmp+vo_font->start[c], |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
176 vo_font->pic_a[font]->w); |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
177 x+=vo_font->width[c]+vo_font->charspace; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
178 } |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
179 x=0; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
180 y+=vo_font->height; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
181 previousStrip=lastStripPosition; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
182 xsize=lastxsize=-vo_font->charspace; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
183 } |
213 | 184 } |
202 | 185 } |
186 | |
218 | 187 } |
188 | |
947
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
865
diff
changeset
|
189 static int draw_alpha_init_flag=0; |
218 | 190 |
191 void vo_draw_text(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)){ | |
192 | |
193 if(!vo_font) return; // no font | |
194 | |
947
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
865
diff
changeset
|
195 if(!draw_alpha_init_flag){ |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
865
diff
changeset
|
196 draw_alpha_init_flag=1; |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
865
diff
changeset
|
197 vo_draw_alpha_init(); |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
865
diff
changeset
|
198 } |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
865
diff
changeset
|
199 |
218 | 200 if(vo_osd_text){ |
201 vo_draw_text_osd(dxs,dys,draw_alpha); | |
202 } | |
203 | |
254 | 204 if(vo_sub){ |
218 | 205 vo_draw_text_sub(dxs,dys,draw_alpha); |
206 } | |
207 | |
208 if(vo_osd_progbar_type>=0){ | |
209 vo_draw_text_progbar(dxs,dys,draw_alpha); | |
210 } | |
213 | 211 |
202 | 212 } |
213 | |
803
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
214 |