annotate libvo/sub.c @ 749:550e3ff06099

big review ! (translators curse me:)
author gabucino
date Thu, 10 May 2001 09:48:03 +0000
parents 2cbe922e2f3c
children b25a887b6054
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
1
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
2 #include "sub.h"
202
6ad0715dfac8 grey+alpha rendering support (for .sub)
arpi_esp
parents:
diff changeset
3
213
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
4 //static int vo_font_loaded=-1;
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
5 font_desc_t* vo_font=NULL;
202
6ad0715dfac8 grey+alpha rendering support (for .sub)
arpi_esp
parents:
diff changeset
6
213
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
7 unsigned char* vo_osd_text="00:00:00";
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
8
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
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
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
10 int len=strlen(vo_osd_text);
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
11 int j;
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
12 int y=10;
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
13 int x=20;
202
6ad0715dfac8 grey+alpha rendering support (for .sub)
arpi_esp
parents:
diff changeset
14
213
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
15 for(j=0;j<len;j++){
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
16 int c=vo_osd_text[j];
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
17 int font=vo_font->font[c];
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
18 if(font>=0)
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
19 draw_alpha(x,y,
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
20 vo_font->width[c],
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
21 vo_font->pic_a[font]->h,
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
22 vo_font->pic_b[font]->bmp+vo_font->start[c],
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
23 vo_font->pic_a[font]->bmp+vo_font->start[c],
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
24 vo_font->pic_a[font]->w);
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
25 x+=vo_font->width[c]+vo_font->charspace;
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
26 }
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
27
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
28 }
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
29
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
30 int vo_osd_progbar_type=-1;
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
31 int vo_osd_progbar_value=100; // 0..255
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
32
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
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)){
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
34 int len=strlen(vo_osd_text);
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
35 int i;
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
36 int y=dys/2;
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
37 int x;
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
38 int c,font;
372
1e57ff895419 progress bar width increased
arpi_esp
parents: 254
diff changeset
39 int width=(dxs*2/3-vo_font->width[0x10]-vo_font->width[0x12]);
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
40 int elems=width/vo_font->width[0x11];
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
41 int mark=(vo_osd_progbar_value*(elems+1))>>8;
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
42 x=(dxs-width)/2;
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
43 // printf("osd.progbar width=%d xpos=%d\n",width,x);
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
44
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
45 c=vo_osd_progbar_type;font=vo_font->font[c];
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
46 if(vo_osd_progbar_type>0 && font>=0)
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
47 draw_alpha(x-vo_font->width[c]-vo_font->spacewidth,y,
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
48 vo_font->width[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
49 vo_font->pic_a[font]->h,
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
50 vo_font->pic_b[font]->bmp+vo_font->start[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
51 vo_font->pic_a[font]->bmp+vo_font->start[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
52 vo_font->pic_a[font]->w);
213
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
53
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
54 c=OSD_PB_START;font=vo_font->font[c];
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
55 if(font>=0)
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
56 draw_alpha(x,y,
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
57 vo_font->width[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
58 vo_font->pic_a[font]->h,
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
59 vo_font->pic_b[font]->bmp+vo_font->start[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
60 vo_font->pic_a[font]->bmp+vo_font->start[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
61 vo_font->pic_a[font]->w);
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
62 x+=vo_font->width[c];
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
63
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
64 for(i=0;i<elems;i++){
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
65 c=(i<mark)?OSD_PB_0:OSD_PB_1;font=vo_font->font[c];
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
66 if(font>=0)
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
67 draw_alpha(x,y,
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
68 vo_font->width[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
69 vo_font->pic_a[font]->h,
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
70 vo_font->pic_b[font]->bmp+vo_font->start[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
71 vo_font->pic_a[font]->bmp+vo_font->start[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
72 vo_font->pic_a[font]->w);
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
73 x+=vo_font->width[c];
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
74 }
202
6ad0715dfac8 grey+alpha rendering support (for .sub)
arpi_esp
parents:
diff changeset
75
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
76 c=OSD_PB_END;font=vo_font->font[c];
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
77 if(font>=0)
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
78 draw_alpha(x,y,
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
79 vo_font->width[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
80 vo_font->pic_a[font]->h,
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
81 vo_font->pic_b[font]->bmp+vo_font->start[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
82 vo_font->pic_a[font]->bmp+vo_font->start[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
83 vo_font->pic_a[font]->w);
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
84 // x+=vo_font->width[c];
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
85
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
86
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
87 // vo_osd_progbar_value=(vo_osd_progbar_value+1)&0xFF;
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
88
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
89 }
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
90
254
57f0156416e3 use subreader's sub struct
arpi_esp
parents: 218
diff changeset
91 subtitle* vo_sub=NULL;
726
2cbe922e2f3c Deal with unicode subs (-unicode -nounicode).
atmosfear
parents: 706
diff changeset
92 int sub_unicode=0;
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
93
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
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)){
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
95 int i;
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
96 int y;
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
97
254
57f0156416e3 use subreader's sub struct
arpi_esp
parents: 218
diff changeset
98 y=dys-(1+vo_sub->lines)*vo_font->height;
202
6ad0715dfac8 grey+alpha rendering support (for .sub)
arpi_esp
parents:
diff changeset
99
254
57f0156416e3 use subreader's sub struct
arpi_esp
parents: 218
diff changeset
100 for(i=0;i<vo_sub->lines;i++){
57f0156416e3 use subreader's sub struct
arpi_esp
parents: 218
diff changeset
101 unsigned char* text=vo_sub->text[i];// "Hello World! HÛDEJÓ!";
213
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
102 int len=strlen(text);
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
103 int j;
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
104 int xsize=-vo_font->charspace;
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
105 int x=0;
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
106
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
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
2cbe922e2f3c Deal with unicode subs (-unicode -nounicode).
atmosfear
parents: 706
diff changeset
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
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
111 xsize+=w+vo_font->charspace;
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
112 }
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
113 //printf("text width = %d\n",xsize);
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
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
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
116
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
117 x=dxs/2-xsize/2;
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
118
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
119 for(j=0;j<len;j++){
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
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
2cbe922e2f3c Deal with unicode subs (-unicode -nounicode).
atmosfear
parents: 706
diff changeset
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
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
124 if(x>=0 && x+vo_font->width[c]<dxs)
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
125 if(font>=0)
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
126 draw_alpha(x,y,
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
127 vo_font->width[c],
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
128 vo_font->pic_a[font]->h,
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
129 vo_font->pic_b[font]->bmp+vo_font->start[c],
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
130 vo_font->pic_a[font]->bmp+vo_font->start[c],
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
131 vo_font->pic_a[font]->w);
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
132 x+=vo_font->width[c]+vo_font->charspace;
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
133 }
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
134
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
135 y+=vo_font->height;
202
6ad0715dfac8 grey+alpha rendering support (for .sub)
arpi_esp
parents:
diff changeset
136 }
6ad0715dfac8 grey+alpha rendering support (for .sub)
arpi_esp
parents:
diff changeset
137
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
138 }
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
139
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
140
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
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)){
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
142
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
143 if(!vo_font) return; // no font
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
144
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
145 if(vo_osd_text){
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
146 vo_draw_text_osd(dxs,dys,draw_alpha);
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
147 }
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
148
254
57f0156416e3 use subreader's sub struct
arpi_esp
parents: 218
diff changeset
149 if(vo_sub){
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
150 vo_draw_text_sub(dxs,dys,draw_alpha);
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
151 }
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
152
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
153 if(vo_osd_progbar_type>=0){
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
154 vo_draw_text_progbar(dxs,dys,draw_alpha);
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
155 }
213
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
156
202
6ad0715dfac8 grey+alpha rendering support (for .sub)
arpi_esp
parents:
diff changeset
157 }
6ad0715dfac8 grey+alpha rendering support (for .sub)
arpi_esp
parents:
diff changeset
158