Mercurial > mplayer.hg
annotate libvo/sub.c @ 1155:be5942e385e5
original and CE version of mpfc
author | arpi_esp |
---|---|
date | Sun, 17 Jun 2001 23:58:38 +0000 |
parents | a013b2124f05 |
children | d40f2b686846 |
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 i; |
36 int y=dys/2; | |
37 int x; | |
38 int c,font; | |
372 | 39 int width=(dxs*2/3-vo_font->width[0x10]-vo_font->width[0x12]); |
218 | 40 int elems=width/vo_font->width[0x11]; |
41 int mark=(vo_osd_progbar_value*(elems+1))>>8; | |
42 x=(dxs-width)/2; | |
43 // printf("osd.progbar width=%d xpos=%d\n",width,x); | |
44 | |
45 c=vo_osd_progbar_type;font=vo_font->font[c]; | |
46 if(vo_osd_progbar_type>0 && font>=0) | |
47 draw_alpha(x-vo_font->width[c]-vo_font->spacewidth,y, | |
48 vo_font->width[c], | |
49 vo_font->pic_a[font]->h, | |
50 vo_font->pic_b[font]->bmp+vo_font->start[c], | |
51 vo_font->pic_a[font]->bmp+vo_font->start[c], | |
52 vo_font->pic_a[font]->w); | |
213 | 53 |
218 | 54 c=OSD_PB_START;font=vo_font->font[c]; |
55 if(font>=0) | |
56 draw_alpha(x,y, | |
57 vo_font->width[c], | |
58 vo_font->pic_a[font]->h, | |
59 vo_font->pic_b[font]->bmp+vo_font->start[c], | |
60 vo_font->pic_a[font]->bmp+vo_font->start[c], | |
61 vo_font->pic_a[font]->w); | |
62 x+=vo_font->width[c]; | |
63 | |
64 for(i=0;i<elems;i++){ | |
65 c=(i<mark)?OSD_PB_0:OSD_PB_1;font=vo_font->font[c]; | |
66 if(font>=0) | |
67 draw_alpha(x,y, | |
68 vo_font->width[c], | |
69 vo_font->pic_a[font]->h, | |
70 vo_font->pic_b[font]->bmp+vo_font->start[c], | |
71 vo_font->pic_a[font]->bmp+vo_font->start[c], | |
72 vo_font->pic_a[font]->w); | |
73 x+=vo_font->width[c]; | |
74 } | |
202 | 75 |
218 | 76 c=OSD_PB_END;font=vo_font->font[c]; |
77 if(font>=0) | |
78 draw_alpha(x,y, | |
79 vo_font->width[c], | |
80 vo_font->pic_a[font]->h, | |
81 vo_font->pic_b[font]->bmp+vo_font->start[c], | |
82 vo_font->pic_a[font]->bmp+vo_font->start[c], | |
83 vo_font->pic_a[font]->w); | |
84 // x+=vo_font->width[c]; | |
803
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
85 |
218 | 86 |
87 // vo_osd_progbar_value=(vo_osd_progbar_value+1)&0xFF; | |
88 | |
89 } | |
90 | |
254 | 91 subtitle* vo_sub=NULL; |
218 | 92 |
865 | 93 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 | 94 int i; |
95 int y; | |
803
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
96 y=dys-(1+vo_sub->lines-1)*vo_font->height-10; |
218 | 97 |
803
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
98 // 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
|
99 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
|
100 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
|
101 int len=strlen(text); |
1109 | 102 int j; |
803
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
103 int xsize=-vo_font->charspace; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
104 int lastStripPosition=-1; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
105 int previousStrip=0; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
106 int lastxsize=0; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
107 |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
108 for(j=0;j<len;j++){ |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
109 int c=text[j]; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
110 int w; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
111 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
|
112 w = vo_font->width[c]; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
113 if (text[j]==' ' && dxs>xsize) |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
114 { |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
115 lastStripPosition=j; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
116 lastxsize=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 xsize+=w+vo_font->charspace; |
1109 | 119 if (dxs<xsize && lastStripPosition>0) |
803
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=lastxsize; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
122 j=lastStripPosition; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
123 y-=vo_font->height; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
124 previousStrip=lastStripPosition; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
125 xsize=-vo_font->charspace; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
126 } |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
127 } |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
128 } |
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 |
254 | 131 for(i=0;i<vo_sub->lines;i++){ |
132 unsigned char* text=vo_sub->text[i];// "Hello World! HÛDEJÓ!"; | |
213 | 133 int len=strlen(text); |
803
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
134 int j,k; |
213 | 135 int xsize=-vo_font->charspace; |
136 int x=0; | |
137 | |
803
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
138 int lastStripPosition=-1; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
139 int previousStrip=0; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
140 int lastxsize=xsize; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
141 |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
142 for(j=0;j<len;j++){ |
213 | 143 int c=text[j]; |
803
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
144 int w; |
726 | 145 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
|
146 w = vo_font->width[c]; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
147 if (c==' ' && dxs>xsize) |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
148 { |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
149 lastStripPosition=j; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
150 lastxsize=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 xsize+=w+vo_font->charspace; |
1109 | 153 if ((dxs<xsize && lastStripPosition>0) || j==len-1) |
803
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 if (j==len-1) lastStripPosition=len; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
156 else xsize=lastxsize; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
157 j=lastStripPosition; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
158 |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
159 x=dxs/2-xsize/2; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
160 |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
161 for(k=previousStrip;k<lastStripPosition;k++){ |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
162 int c=text[k]; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
163 int font; |
805 | 164 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
|
165 font=vo_font->font[c]; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
166 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
|
167 if(font>=0) |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
168 draw_alpha(x,y, |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
169 vo_font->width[c], |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
170 vo_font->pic_a[font]->h, |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
171 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
|
172 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
|
173 vo_font->pic_a[font]->w); |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
174 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
|
175 } |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
176 x=0; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
177 y+=vo_font->height; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
178 previousStrip=lastStripPosition; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
179 xsize=lastxsize=-vo_font->charspace; |
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
180 } |
213 | 181 } |
202 | 182 } |
183 | |
218 | 184 } |
185 | |
947
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
865
diff
changeset
|
186 static int draw_alpha_init_flag=0; |
218 | 187 |
1109 | 188 extern void vo_draw_alpha_init(); |
189 | |
218 | 190 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)){ |
191 | |
192 if(!vo_font) return; // no font | |
193 | |
947
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
865
diff
changeset
|
194 if(!draw_alpha_init_flag){ |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
865
diff
changeset
|
195 draw_alpha_init_flag=1; |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
865
diff
changeset
|
196 vo_draw_alpha_init(); |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
865
diff
changeset
|
197 } |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
865
diff
changeset
|
198 |
218 | 199 if(vo_osd_text){ |
200 vo_draw_text_osd(dxs,dys,draw_alpha); | |
201 } | |
202 | |
254 | 203 if(vo_sub){ |
218 | 204 vo_draw_text_sub(dxs,dys,draw_alpha); |
205 } | |
206 | |
207 if(vo_osd_progbar_type>=0){ | |
208 vo_draw_text_progbar(dxs,dys,draw_alpha); | |
209 } | |
213 | 210 |
202 | 211 } |