Mercurial > mplayer.hg
annotate libvo/sub.c @ 754:32a8e9e43d94
debug printfs moved to -v
author | arpi_esp |
---|---|
date | Thu, 10 May 2001 18:44:38 +0000 |
parents | 2cbe922e2f3c |
children | b25a887b6054 |
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"; |
8 | |
218 | 9 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 | 10 int len=strlen(vo_osd_text); |
11 int j; | |
12 int y=10; | |
13 int x=20; | |
202 | 14 |
213 | 15 for(j=0;j<len;j++){ |
16 int c=vo_osd_text[j]; | |
17 int font=vo_font->font[c]; | |
18 if(font>=0) | |
19 draw_alpha(x,y, | |
20 vo_font->width[c], | |
21 vo_font->pic_a[font]->h, | |
22 vo_font->pic_b[font]->bmp+vo_font->start[c], | |
23 vo_font->pic_a[font]->bmp+vo_font->start[c], | |
24 vo_font->pic_a[font]->w); | |
25 x+=vo_font->width[c]+vo_font->charspace; | |
26 } | |
218 | 27 |
28 } | |
29 | |
30 int vo_osd_progbar_type=-1; | |
31 int vo_osd_progbar_value=100; // 0..255 | |
32 | |
33 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)){ | |
34 int len=strlen(vo_osd_text); | |
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]; | |
85 | |
86 | |
87 // vo_osd_progbar_value=(vo_osd_progbar_value+1)&0xFF; | |
88 | |
89 } | |
90 | |
254 | 91 subtitle* vo_sub=NULL; |
726 | 92 int sub_unicode=0; |
218 | 93 |
94 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)){ | |
95 int i; | |
96 int y; | |
97 | |
254 | 98 y=dys-(1+vo_sub->lines)*vo_font->height; |
202 | 99 |
254 | 100 for(i=0;i<vo_sub->lines;i++){ |
101 unsigned char* text=vo_sub->text[i];// "Hello World! HÛDEJÓ!"; | |
213 | 102 int len=strlen(text); |
103 int j; | |
104 int xsize=-vo_font->charspace; | |
105 int x=0; | |
106 | |
107 for(j=0;j<len;j++){ | |
706
8a7666a78f83
better .smi support and display two-byte characters- patch by Sunjin Yang
arpi_esp
parents:
616
diff
changeset
|
108 int c=text[j]; |
726 | 109 int w = vo_font->width[sub_unicode?((c<0x80)?c:(c<<8)+text[++j]):c]; |
706
8a7666a78f83
better .smi support and display two-byte characters- patch by Sunjin Yang
arpi_esp
parents:
616
diff
changeset
|
110 if(w>100) printf("gazvan: %d (%d=%c)\n",w,c,c); |
213 | 111 xsize+=w+vo_font->charspace; |
112 } | |
113 //printf("text width = %d\n",xsize); | |
114 | |
706
8a7666a78f83
better .smi support and display two-byte characters- patch by Sunjin Yang
arpi_esp
parents:
616
diff
changeset
|
115 //if(xsize>dxs) printf("Warning! SUB too wide!!! (%d>%d)\n",xsize,dxs); |
213 | 116 |
117 x=dxs/2-xsize/2; | |
118 | |
119 for(j=0;j<len;j++){ | |
120 int c=text[j]; | |
706
8a7666a78f83
better .smi support and display two-byte characters- patch by Sunjin Yang
arpi_esp
parents:
616
diff
changeset
|
121 int font; |
726 | 122 if (sub_unicode && (c>=0x80)) c=(c<<8)+text[++j]; |
706
8a7666a78f83
better .smi support and display two-byte characters- patch by Sunjin Yang
arpi_esp
parents:
616
diff
changeset
|
123 font = vo_font->font[c]; |
213 | 124 if(x>=0 && x+vo_font->width[c]<dxs) |
125 if(font>=0) | |
126 draw_alpha(x,y, | |
127 vo_font->width[c], | |
128 vo_font->pic_a[font]->h, | |
129 vo_font->pic_b[font]->bmp+vo_font->start[c], | |
130 vo_font->pic_a[font]->bmp+vo_font->start[c], | |
131 vo_font->pic_a[font]->w); | |
132 x+=vo_font->width[c]+vo_font->charspace; | |
133 } | |
134 | |
135 y+=vo_font->height; | |
202 | 136 } |
137 | |
218 | 138 } |
139 | |
140 | |
141 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)){ | |
142 | |
143 if(!vo_font) return; // no font | |
144 | |
145 if(vo_osd_text){ | |
146 vo_draw_text_osd(dxs,dys,draw_alpha); | |
147 } | |
148 | |
254 | 149 if(vo_sub){ |
218 | 150 vo_draw_text_sub(dxs,dys,draw_alpha); |
151 } | |
152 | |
153 if(vo_osd_progbar_type>=0){ | |
154 vo_draw_text_progbar(dxs,dys,draw_alpha); | |
155 } | |
213 | 156 |
202 | 157 } |
158 |