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;
|
218
|
92
|
|
93 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)){
|
|
94 int i;
|
|
95 int y;
|
|
96
|
254
|
97 y=dys-(1+vo_sub->lines)*vo_font->height;
|
202
|
98
|
254
|
99 for(i=0;i<vo_sub->lines;i++){
|
|
100 unsigned char* text=vo_sub->text[i];// "Hello World! HÛDEJÓ!";
|
213
|
101 int len=strlen(text);
|
|
102 int j;
|
|
103 int xsize=-vo_font->charspace;
|
|
104 int x=0;
|
|
105
|
|
106 for(j=0;j<len;j++){
|
|
107 int w=vo_font->width[text[j]];
|
|
108 if(w>100) printf("gazvan: %d (%d=%c)\n",w,text[j],text[j]);
|
|
109 xsize+=w+vo_font->charspace;
|
|
110 }
|
|
111 //printf("text width = %d\n",xsize);
|
|
112
|
|
113 if(xsize>dxs) printf("Warning! SUB too wide!!! (%d>%d)\n",xsize,dxs);
|
|
114
|
|
115 x=dxs/2-xsize/2;
|
|
116
|
|
117 for(j=0;j<len;j++){
|
|
118 int c=text[j];
|
|
119 int font=vo_font->font[c];
|
|
120 if(x>=0 && x+vo_font->width[c]<dxs)
|
|
121 if(font>=0)
|
|
122 draw_alpha(x,y,
|
|
123 vo_font->width[c],
|
|
124 vo_font->pic_a[font]->h,
|
|
125 vo_font->pic_b[font]->bmp+vo_font->start[c],
|
|
126 vo_font->pic_a[font]->bmp+vo_font->start[c],
|
|
127 vo_font->pic_a[font]->w);
|
|
128 x+=vo_font->width[c]+vo_font->charspace;
|
|
129 }
|
|
130
|
|
131 y+=vo_font->height;
|
202
|
132 }
|
|
133
|
218
|
134 }
|
|
135
|
|
136
|
|
137 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)){
|
|
138
|
|
139 if(!vo_font) return; // no font
|
|
140
|
|
141 if(vo_osd_text){
|
|
142 vo_draw_text_osd(dxs,dys,draw_alpha);
|
|
143 }
|
|
144
|
254
|
145 if(vo_sub){
|
218
|
146 vo_draw_text_sub(dxs,dys,draw_alpha);
|
|
147 }
|
|
148
|
|
149 if(vo_osd_progbar_type>=0){
|
|
150 vo_draw_text_progbar(dxs,dys,draw_alpha);
|
|
151 }
|
213
|
152
|
202
|
153 }
|
|
154
|