Mercurial > mplayer.hg
annotate libvo/sub.c @ 7067:b395b1240954
fix dxr3 subtitle handling and add some optimizations
author | pontscho |
---|---|
date | Thu, 22 Aug 2002 13:58:38 +0000 |
parents | 60a473935d7d |
children | 6abc330b5b32 |
rev | line source |
---|---|
5503 | 1 |
2 #include <stdio.h> | |
3 #include <stdlib.h> | |
7003
60a473935d7d
warning fixes by Sylvain Petreolle <spetreolle@yahoo.fr>
arpi
parents:
6190
diff
changeset
|
4 #include <string.h> |
218 | 5 |
4088 | 6 #include "config.h" |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
7 #include "mp_msg.h" |
4088 | 8 #include "video_out.h" |
5294 | 9 #include "font_load.h" |
218 | 10 #include "sub.h" |
7003
60a473935d7d
warning fixes by Sylvain Petreolle <spetreolle@yahoo.fr>
arpi
parents:
6190
diff
changeset
|
11 #include "../spudec.h" |
202 | 12 |
2498 | 13 char * __sub_osd_names[]={ |
14 "Seekbar", | |
15 "Play", | |
16 "Pause", | |
17 "Stop", | |
18 "Rewind", | |
19 "Forward", | |
20 "Clock", | |
21 "Contrast", | |
22 "Saturation", | |
23 "Volume", | |
24 "Brightness", | |
25 "Hue" | |
26 }; | |
27 char * __sub_osd_names_short[] ={ "", "|>", "||", "[]", "<<" , ">>", "", "", "", "", "", ""}; | |
28 | |
213 | 29 //static int vo_font_loaded=-1; |
30 font_desc_t* vo_font=NULL; | |
202 | 31 |
1991
dee4b2ea5e5b
add gui support to config scripts, and fixed some warning.
pontscho
parents:
1878
diff
changeset
|
32 unsigned char* vo_osd_text=NULL; |
803
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
33 int sub_unicode=0; |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
34 int sub_utf8=0; |
4773 | 35 int sub_pos=100; |
213 | 36 |
5664 | 37 // return the real height of a char: |
38 static inline int get_height(int c,int h){ | |
39 int font; | |
40 if ((font=vo_font->font[c])>=0) | |
41 if(h<vo_font->pic_a[font]->h) h=vo_font->pic_a[font]->h; | |
42 return h; | |
43 } | |
44 | |
5640 | 45 inline static void vo_update_text_osd(mp_osd_obj_t* obj,int dxs,int dys){ |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
46 unsigned char *cp=vo_osd_text; |
5640 | 47 int x=20; |
5664 | 48 int h=0; |
5640 | 49 |
50 obj->bbox.x1=obj->x=x; | |
51 obj->bbox.y1=obj->y=10; | |
202 | 52 |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
53 while (*cp){ |
5640 | 54 int c=*cp++; |
55 x+=vo_font->width[c]+vo_font->charspace; | |
5664 | 56 h=get_height(c,h); |
5640 | 57 } |
58 | |
5664 | 59 obj->bbox.x2=x-vo_font->charspace; |
60 obj->bbox.y2=obj->bbox.y1+h; | |
5640 | 61 obj->flags|=OSDFLAG_BBOX; |
62 | |
63 } | |
64 | |
65 inline static void vo_draw_text_osd(mp_osd_obj_t* obj,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)){ | |
66 unsigned char *cp=vo_osd_text; | |
67 int font; | |
68 int x=obj->x; | |
69 | |
70 while (*cp){ | |
71 int c=*cp++; | |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
72 if ((font=vo_font->font[c])>=0) |
5640 | 73 draw_alpha(x,obj->y, |
213 | 74 vo_font->width[c], |
75 vo_font->pic_a[font]->h, | |
76 vo_font->pic_b[font]->bmp+vo_font->start[c], | |
77 vo_font->pic_a[font]->bmp+vo_font->start[c], | |
78 vo_font->pic_a[font]->w); | |
79 x+=vo_font->width[c]+vo_font->charspace; | |
80 } | |
218 | 81 } |
82 | |
83 int vo_osd_progbar_type=-1; | |
1726 | 84 int vo_osd_progbar_value=100; // 0..256 |
85 | |
86 // if we have n=256 bars then OSD progbar looks like below | |
87 // | |
1878 | 88 // 0 1 2 3 ... 256 <= vo_osd_progbar_value |
89 // | | | | | | |
1726 | 90 // [ === === === ... === ] |
91 // | |
92 // the above schema is rescalled to n=elems bars | |
218 | 93 |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
94 inline static void vo_update_text_progbar(mp_osd_obj_t* obj,int dxs,int dys){ |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
95 |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
96 obj->flags|=OSDFLAG_CHANGED|OSDFLAG_VISIBLE; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
97 |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
98 if(vo_osd_progbar_type<0 || !vo_font){ |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
99 obj->flags&=~OSDFLAG_VISIBLE; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
100 return; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
101 } |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
102 |
5664 | 103 { int h=0; |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
104 int y=(dys-vo_font->height)/2; |
1548
eee7951a23af
changes according to proper subfont bar positioning and char spaceing - sub.c
atlka
parents:
1524
diff
changeset
|
105 int delimw=vo_font->width[OSD_PB_START] |
1549 | 106 +vo_font->width[OSD_PB_END] |
107 +vo_font->charspace; | |
1548
eee7951a23af
changes according to proper subfont bar positioning and char spaceing - sub.c
atlka
parents:
1524
diff
changeset
|
108 int width=(2*dxs-3*delimw)/3; |
1549 | 109 int charw=vo_font->width[OSD_PB_0]+vo_font->charspace; |
1548
eee7951a23af
changes according to proper subfont bar positioning and char spaceing - sub.c
atlka
parents:
1524
diff
changeset
|
110 int elems=width/charw; |
1549 | 111 int x=(dxs-elems*charw-delimw)/2; |
5664 | 112 h=get_height(OSD_PB_START,h); |
113 h=get_height(OSD_PB_END,h); | |
114 h=get_height(OSD_PB_0,h); | |
115 h=get_height(OSD_PB_1,h); | |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
116 obj->bbox.x1=obj->x=x; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
117 obj->bbox.y1=obj->y=y; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
118 obj->bbox.x2=x+width+delimw; |
5664 | 119 obj->bbox.y2=y+h; //vo_font->height; |
5640 | 120 obj->flags|=OSDFLAG_BBOX; |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
121 obj->params.progbar.elems=elems; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
122 } |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
123 |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
124 } |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
125 |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
126 inline static void vo_draw_text_progbar(mp_osd_obj_t* obj,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)){ |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
127 unsigned char *s; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
128 unsigned char *sa; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
129 int i,w,h,st,mark; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
130 int x=obj->x; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
131 int y=obj->y; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
132 int c,font; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
133 int charw=vo_font->width[OSD_PB_0]+vo_font->charspace; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
134 int elems=obj->params.progbar.elems; |
1548
eee7951a23af
changes according to proper subfont bar positioning and char spaceing - sub.c
atlka
parents:
1524
diff
changeset
|
135 |
1726 | 136 if (vo_osd_progbar_value<=0) |
137 mark=0; | |
1878 | 138 else { |
139 int ev=vo_osd_progbar_value*elems; | |
140 mark=ev>>8; | |
141 if (ev & 0xFF) mark++; | |
142 if (mark>elems) mark=elems; | |
143 } | |
144 | |
1727 | 145 |
218 | 146 // printf("osd.progbar width=%d xpos=%d\n",width,x); |
147 | |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
148 c=vo_osd_progbar_type; |
1569
fcbfc99cf8e6
skip lines with negative y position if there is too many lines to display
atlka
parents:
1549
diff
changeset
|
149 if(vo_osd_progbar_type>0 && (font=vo_font->font[c])>=0) { |
fcbfc99cf8e6
skip lines with negative y position if there is too many lines to display
atlka
parents:
1549
diff
changeset
|
150 int xp=x-vo_font->width[c]-vo_font->spacewidth; |
fcbfc99cf8e6
skip lines with negative y position if there is too many lines to display
atlka
parents:
1549
diff
changeset
|
151 draw_alpha((xp<0?0:xp),y, |
218 | 152 vo_font->width[c], |
153 vo_font->pic_a[font]->h, | |
154 vo_font->pic_b[font]->bmp+vo_font->start[c], | |
155 vo_font->pic_a[font]->bmp+vo_font->start[c], | |
156 vo_font->pic_a[font]->w); | |
1569
fcbfc99cf8e6
skip lines with negative y position if there is too many lines to display
atlka
parents:
1549
diff
changeset
|
157 } |
fcbfc99cf8e6
skip lines with negative y position if there is too many lines to display
atlka
parents:
1549
diff
changeset
|
158 |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
159 c=OSD_PB_START; |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
160 if ((font=vo_font->font[c])>=0) |
218 | 161 draw_alpha(x,y, |
162 vo_font->width[c], | |
163 vo_font->pic_a[font]->h, | |
164 vo_font->pic_b[font]->bmp+vo_font->start[c], | |
165 vo_font->pic_a[font]->bmp+vo_font->start[c], | |
166 vo_font->pic_a[font]->w); | |
1548
eee7951a23af
changes according to proper subfont bar positioning and char spaceing - sub.c
atlka
parents:
1524
diff
changeset
|
167 x+=vo_font->width[c]+vo_font->charspace; |
218 | 168 |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
169 c=OSD_PB_0; |
1602 | 170 if ((font=vo_font->font[c])>=0){ |
171 w=vo_font->width[c]; | |
172 h=vo_font->pic_a[font]->h; | |
173 s=vo_font->pic_b[font]->bmp+vo_font->start[c]; | |
174 sa=vo_font->pic_a[font]->bmp+vo_font->start[c]; | |
175 st=vo_font->pic_a[font]->w; | |
2204 | 176 if ((i=mark)) do { |
1602 | 177 draw_alpha(x,y,w,h,s,sa,st); |
1548
eee7951a23af
changes according to proper subfont bar positioning and char spaceing - sub.c
atlka
parents:
1524
diff
changeset
|
178 x+=charw; |
2204 | 179 } while(--i); |
1602 | 180 } |
202 | 181 |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
182 c=OSD_PB_1; |
1602 | 183 if ((font=vo_font->font[c])>=0){ |
184 w=vo_font->width[c]; | |
185 h=vo_font->pic_a[font]->h; | |
186 s =vo_font->pic_b[font]->bmp+vo_font->start[c]; | |
187 sa=vo_font->pic_a[font]->bmp+vo_font->start[c]; | |
188 st=vo_font->pic_a[font]->w; | |
2204 | 189 if ((i=elems-mark)) do { |
1602 | 190 draw_alpha(x,y,w,h,s,sa,st); |
1548
eee7951a23af
changes according to proper subfont bar positioning and char spaceing - sub.c
atlka
parents:
1524
diff
changeset
|
191 x+=charw; |
2204 | 192 } while(--i); |
1602 | 193 } |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
194 |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
195 c=OSD_PB_END; |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
196 if ((font=vo_font->font[c])>=0) |
218 | 197 draw_alpha(x,y, |
198 vo_font->width[c], | |
199 vo_font->pic_a[font]->h, | |
200 vo_font->pic_b[font]->bmp+vo_font->start[c], | |
201 vo_font->pic_a[font]->bmp+vo_font->start[c], | |
202 vo_font->pic_a[font]->w); | |
1548
eee7951a23af
changes according to proper subfont bar positioning and char spaceing - sub.c
atlka
parents:
1524
diff
changeset
|
203 // x+=vo_font->width[c]+vo_font->charspace; |
803
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
204 |
218 | 205 |
206 // vo_osd_progbar_value=(vo_osd_progbar_value+1)&0xFF; | |
207 | |
208 } | |
209 | |
254 | 210 subtitle* vo_sub=NULL; |
218 | 211 |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
212 // 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)) |
1591 | 213 |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
214 inline static void vo_update_text_sub(mp_osd_obj_t* obj,int dxs,int dys){ |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
215 unsigned char *t; |
1591 | 216 int c,i,j,l,x,y,font; |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
217 int len; |
1591 | 218 int k,lastk; |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
219 int lastStripPosition; |
1591 | 220 int xsize,lastxsize; |
5640 | 221 int xmin=dxs,xmax=0; |
1591 | 222 int h,lasth; |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
223 |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
224 obj->flags|=OSDFLAG_CHANGED|OSDFLAG_VISIBLE; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
225 |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
226 if(!vo_sub || !vo_font){ |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
227 obj->flags&=~OSDFLAG_VISIBLE; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
228 return; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
229 } |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
230 |
5664 | 231 obj->bbox.y2=obj->y=dys; |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
232 obj->params.subtitle.lines=0; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
233 |
1602 | 234 // too long lines divide into a smaller ones |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
235 i=k=lasth=0; |
1591 | 236 h=vo_font->height; |
237 xsize=-vo_font->charspace; | |
238 lastStripPosition=-1; | |
239 l=vo_sub->lines; | |
240 | |
2204 | 241 while (l) { |
242 l--; | |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
243 t=vo_sub->text[i++]; |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
244 len=strlen(t)-1; |
1824 | 245 |
1852 | 246 // printf("sub(%d) '%s'\n",len,t); |
1824 | 247 // if(len<0) memy -=h; // according to max of vo_font->pic_a[font]->h |
248 // else | |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
249 for (j=0;j<=len;j++){ |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
250 if ((c=t[j])>=0x80){ |
2176 | 251 if (sub_utf8){ |
252 if ((c & 0xe0) == 0xc0) /* 2 bytes U+00080..U+0007FF*/ | |
253 c = (c & 0x1f)<<6 | (t[++j] & 0x3f); | |
254 else if((c & 0xf0) == 0xe0)/* 3 bytes U+00800..U+00FFFF*/ | |
255 c = ((c & 0x0f)<<6 | | |
256 (t[++j] & 0x3f))<<6 | (t[++j] & 0x3f); | |
257 } else if (sub_unicode) | |
258 c = (c<<8) + t[++j]; | |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
259 } |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
260 if (k==MAX_UCS){ |
2204 | 261 len=j; // end here |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
262 mp_msg(MSGT_OSD,MSGL_WARN,"\nMAX_UCS exceeded!\n"); |
1591 | 263 } |
2204 | 264 if (!c) c++; // avoid UCS 0 |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
265 if (c==' '){ |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
266 lastk=k; |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
267 lastStripPosition=j; |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
268 lastxsize=xsize; |
2204 | 269 } else if ((font=vo_font->font[c])>=0){ |
1591 | 270 if (vo_font->pic_a[font]->h > h){ |
271 h=vo_font->pic_a[font]->h; | |
272 } | |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
273 } |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
274 obj->params.subtitle.utbl[k++]=c; |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
275 xsize+=vo_font->width[c]+vo_font->charspace; |
1591 | 276 if (dxs<xsize){ |
277 if (lastStripPosition>0){ | |
278 j=lastStripPosition; | |
279 xsize=lastxsize; | |
280 k=lastk; | |
281 } else { | |
282 xsize -=vo_font->width[c]+vo_font->charspace; // go back | |
283 k--; // cut line here | |
284 while (t[j] && t[j]!=' ') j++; // jump to the nearest space | |
285 } | |
286 } else if (j<len) | |
287 continue; | |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
288 if (h>obj->y){ // out of the screen so end parsing |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
289 obj->y -= lasth - vo_font->height; // correct the y position |
2204 | 290 l=0; |
291 break; | |
1591 | 292 } |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
293 obj->params.subtitle.utbl[k++]=0; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
294 obj->params.subtitle.xtbl[obj->params.subtitle.lines++]=(dxs-xsize)/2; |
5640 | 295 if(xmin>(dxs-xsize)/2) xmin=(dxs-xsize)/2; |
296 if(xmax<(dxs+xsize)/2) xmax=(dxs+xsize)/2; | |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
297 if (obj->params.subtitle.lines==MAX_UCSLINES||k>MAX_UCS){ |
2204 | 298 l=0; len=j; // end parsing |
1602 | 299 } else if(l || j<len){ // not the last line or not the last char |
1591 | 300 lastStripPosition=-1; |
301 xsize=-vo_font->charspace; | |
302 lasth=h; | |
303 h=vo_font->height; | |
304 } | |
2176 | 305 // printf("h: %d -> %d \n",vo_font->height,h); |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
306 obj->y -=h; // according to max of vo_font->pic_a[font]->h |
1591 | 307 } |
1573
c394d04d6b30
changes according to max of vo_font->pic_a[font]->h for the last line of subs
atlka
parents:
1569
diff
changeset
|
308 } |
5640 | 309 |
5664 | 310 if (obj->y >= (dys * sub_pos / 100)){ |
311 int old=obj->y; | |
312 obj->y = dys * sub_pos /100; | |
313 obj->bbox.y2-=old-obj->y; | |
314 } | |
315 | |
5640 | 316 // calculate bbox: |
317 obj->bbox.x1=xmin; | |
318 obj->bbox.x2=xmax; | |
319 obj->bbox.y1=obj->y; | |
5664 | 320 // obj->bbox.y2=obj->y+obj->params.subtitle.lines*vo_font->height; |
5640 | 321 obj->flags|=OSDFLAG_BBOX; |
322 | |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
323 } |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
324 |
6190
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
325 inline static void vo_update_spudec_sub(mp_osd_obj_t* obj, int dxs, int dys) |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
326 { |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
327 unsigned int bbox[4]; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
328 int i; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
329 spudec_calc_bbox(vo_spudec, dxs, dys, bbox); |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
330 obj->bbox.x1 = bbox[0]; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
331 obj->bbox.x2 = bbox[1]; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
332 obj->bbox.y1 = bbox[2]; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
333 obj->bbox.y2 = bbox[3]; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
334 obj->flags |= OSDFLAG_BBOX; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
335 } |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
336 |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
337 inline static void vo_draw_spudec_sub(mp_osd_obj_t* obj, void (*draw_alpha)(int x0, int y0, int w, int h, unsigned char* src, unsigned char* srca, int stride)) |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
338 { |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
339 spudec_draw_scaled(vo_spudec, obj->dxs, obj->dys, draw_alpha); |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
340 } |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
341 inline static void vo_draw_text_sub(mp_osd_obj_t* obj,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)){ |
5640 | 342 int i,j,c,x,l,font; |
343 int y=obj->y; | |
202 | 344 |
2204 | 345 i=j=0; |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
346 if ((l=obj->params.subtitle.lines)) for (;;) { |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
347 x=obj->params.subtitle.xtbl[i++]; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
348 while ((c=obj->params.subtitle.utbl[j++])){ |
2176 | 349 if ((font=vo_font->font[c])>=0) |
1569
fcbfc99cf8e6
skip lines with negative y position if there is too many lines to display
atlka
parents:
1549
diff
changeset
|
350 draw_alpha(x,y, |
fcbfc99cf8e6
skip lines with negative y position if there is too many lines to display
atlka
parents:
1549
diff
changeset
|
351 vo_font->width[c], |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
352 vo_font->pic_a[font]->h+y<obj->dys ? vo_font->pic_a[font]->h : obj->dys-y, |
1569
fcbfc99cf8e6
skip lines with negative y position if there is too many lines to display
atlka
parents:
1549
diff
changeset
|
353 vo_font->pic_b[font]->bmp+vo_font->start[c], |
fcbfc99cf8e6
skip lines with negative y position if there is too many lines to display
atlka
parents:
1549
diff
changeset
|
354 vo_font->pic_a[font]->bmp+vo_font->start[c], |
fcbfc99cf8e6
skip lines with negative y position if there is too many lines to display
atlka
parents:
1549
diff
changeset
|
355 vo_font->pic_a[font]->w); |
2204 | 356 x+=vo_font->width[c]+vo_font->charspace; |
1569
fcbfc99cf8e6
skip lines with negative y position if there is too many lines to display
atlka
parents:
1549
diff
changeset
|
357 } |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
358 if (!--l) break; |
1591 | 359 y+=vo_font->height; |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
360 } |
218 | 361 } |
362 | |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
2498
diff
changeset
|
363 void *vo_spudec=NULL; |
4081
9e581ab5e54b
Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents:
3180
diff
changeset
|
364 void *vo_vobsub=NULL; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
2498
diff
changeset
|
365 |
947
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
865
diff
changeset
|
366 static int draw_alpha_init_flag=0; |
218 | 367 |
1109 | 368 extern void vo_draw_alpha_init(); |
369 | |
7067
b395b1240954
fix dxr3 subtitle handling and add some optimizations
pontscho
parents:
7003
diff
changeset
|
370 mp_osd_obj_t* vo_osd_list=NULL; |
218 | 371 |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
372 mp_osd_obj_t* new_osd_obj(int type){ |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
373 mp_osd_obj_t* osd=malloc(sizeof(mp_osd_obj_t)); |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
374 memset(osd,0,sizeof(mp_osd_obj_t)); |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
375 osd->next=vo_osd_list; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
376 vo_osd_list=osd; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
377 osd->type=type; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
378 return osd; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
379 } |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
380 |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
381 void free_osd_list(){ |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
382 mp_osd_obj_t* obj=vo_osd_list; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
383 while(obj){ |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
384 mp_osd_obj_t* next=obj->next; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
385 free(obj); |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
386 obj=next; |
4081
9e581ab5e54b
Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents:
3180
diff
changeset
|
387 } |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
388 vo_osd_list=NULL; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
389 } |
4081
9e581ab5e54b
Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents:
3180
diff
changeset
|
390 |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
391 int vo_update_osd(int dxs,int dys){ |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
392 mp_osd_obj_t* obj=vo_osd_list; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
393 int chg=0; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
394 while(obj){ |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
395 if(dxs!=obj->dxs || dys!=obj->dys || obj->flags&OSDFLAG_FORCE_UPDATE){ |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
396 int vis=obj->flags&OSDFLAG_VISIBLE; |
5640 | 397 obj->flags&=~OSDFLAG_BBOX; |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
398 switch(obj->type){ |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
399 case OSDTYPE_SUBTITLE: |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
400 vo_update_text_sub(obj,dxs,dys); |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
401 break; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
402 case OSDTYPE_PROGBAR: |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
403 vo_update_text_progbar(obj,dxs,dys); |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
404 break; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
405 case OSDTYPE_SPU: |
6190
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
406 if(vo_spudec && spudec_visible(vo_spudec)){ |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
407 vo_update_spudec_sub(obj, dxs, dys); |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
408 obj->flags|=OSDFLAG_VISIBLE|OSDFLAG_CHANGED; |
6190
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
409 } |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
410 else |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
411 obj->flags&=~OSDFLAG_VISIBLE; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
412 break; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
413 case OSDTYPE_OSD: |
5640 | 414 if(vo_font && vo_osd_text && vo_osd_text[0]){ |
415 vo_update_text_osd(obj,dxs,dys); // update bbox | |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
416 obj->flags|=OSDFLAG_VISIBLE|OSDFLAG_CHANGED; |
5640 | 417 } else |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
418 obj->flags&=~OSDFLAG_VISIBLE; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
419 break; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
420 } |
5640 | 421 // check bbox: |
422 if(!(obj->flags&OSDFLAG_BBOX)){ | |
423 // we don't know, so assume the whole screen changed :( | |
424 obj->bbox.x1=obj->bbox.y1=0; | |
425 obj->bbox.x2=dxs; | |
426 obj->bbox.y2=dys; | |
427 obj->flags|=OSDFLAG_BBOX; | |
5664 | 428 } else { |
429 // check bbox, reduce it if it's out of bounds (corners): | |
430 if(obj->bbox.x1<0) obj->bbox.x1=0; | |
431 if(obj->bbox.y1<0) obj->bbox.y1=0; | |
432 if(obj->bbox.x2>dxs) obj->bbox.x2=dxs; | |
433 if(obj->bbox.y2>dys) obj->bbox.y2=dys; | |
434 if(obj->flags&OSDFLAG_VISIBLE) | |
435 // debug: | |
436 mp_msg(MSGT_OSD,MSGL_DBG2,"OSD update: %d;%d %dx%d \n", | |
5640 | 437 obj->bbox.x1,obj->bbox.y1,obj->bbox.x2-obj->bbox.x1, |
438 obj->bbox.y2-obj->bbox.y1); | |
439 } | |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
440 // check if visibility changed: |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
441 if(vis != (obj->flags&OSDFLAG_VISIBLE) ) obj->flags|=OSDFLAG_CHANGED; |
5640 | 442 // remove the cause of automatic update: |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
443 obj->dxs=dxs; obj->dys=dys; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
444 obj->flags&=~OSDFLAG_FORCE_UPDATE; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
445 } |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
446 if(obj->flags&OSDFLAG_CHANGED){ |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
447 chg|=1<<obj->type; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
448 mp_msg(MSGT_OSD,MSGL_DBG2,"OSD chg: %d V: %s pb:%d \n",obj->type,(obj->flags&OSDFLAG_VISIBLE)?"yes":"no",vo_osd_progbar_type); |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
449 } |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
450 obj=obj->next; |
4081
9e581ab5e54b
Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents:
3180
diff
changeset
|
451 } |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
452 return chg; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
453 } |
4081
9e581ab5e54b
Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents:
3180
diff
changeset
|
454 |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
455 void vo_init_osd(){ |
947
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
865
diff
changeset
|
456 if(!draw_alpha_init_flag){ |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
865
diff
changeset
|
457 draw_alpha_init_flag=1; |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
865
diff
changeset
|
458 vo_draw_alpha_init(); |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
865
diff
changeset
|
459 } |
6110 | 460 if(vo_osd_list) free_osd_list(); |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
461 // temp hack, should be moved to mplayer/mencoder later |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
462 new_osd_obj(OSDTYPE_OSD); |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
463 new_osd_obj(OSDTYPE_SUBTITLE); |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
464 new_osd_obj(OSDTYPE_PROGBAR); |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
465 new_osd_obj(OSDTYPE_SPU); |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
466 } |
947
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
865
diff
changeset
|
467 |
5642
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
468 int vo_osd_changed_flag=0; |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
469 |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
470 void vo_remove_text(int dxs,int dys,void (*remove)(int x0,int y0, int w,int h)){ |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
471 mp_osd_obj_t* obj=vo_osd_list; |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
472 vo_update_osd(dxs,dys); |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
473 while(obj){ |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
474 if(((obj->flags&OSDFLAG_CHANGED) || (obj->flags&OSDFLAG_VISIBLE)) && |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
475 (obj->flags&OSDFLAG_OLD_BBOX)){ |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
476 int w=obj->old_bbox.x2-obj->old_bbox.x1; |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
477 int h=obj->old_bbox.y2-obj->old_bbox.y1; |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
478 if(w>0 && h>0){ |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
479 vo_osd_changed_flag=obj->flags&OSDFLAG_CHANGED; // temp hack |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
480 remove(obj->old_bbox.x1,obj->old_bbox.y1,w,h); |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
481 } |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
482 // obj->flags&=~OSDFLAG_OLD_BBOX; |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
483 } |
5645 | 484 obj=obj->next; |
5642
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
485 } |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
486 } |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
487 |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
488 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)){ |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
489 mp_osd_obj_t* obj=vo_osd_list; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
490 vo_update_osd(dxs,dys); |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
491 while(obj){ |
5642
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
492 if(obj->flags&OSDFLAG_VISIBLE){ |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
493 vo_osd_changed_flag=obj->flags&OSDFLAG_CHANGED; // temp hack |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
494 switch(obj->type){ |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
495 case OSDTYPE_SPU: |
6190
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
496 vo_draw_spudec_sub(obj, draw_alpha); // FIXME |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
497 break; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
498 case OSDTYPE_OSD: |
5640 | 499 vo_draw_text_osd(obj,draw_alpha); |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
500 break; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
501 case OSDTYPE_SUBTITLE: |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
502 vo_draw_text_sub(obj,draw_alpha); |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
503 break; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
504 case OSDTYPE_PROGBAR: |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
505 vo_draw_text_progbar(obj,draw_alpha); |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
506 break; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
507 } |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
508 obj->old_bbox=obj->bbox; |
5642
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
509 obj->flags|=OSDFLAG_OLD_BBOX; |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
510 } |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
511 obj->flags&=~OSDFLAG_CHANGED; |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
512 obj=obj->next; |
218 | 513 } |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
514 } |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
2498
diff
changeset
|
515 |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4773
diff
changeset
|
516 static int vo_osd_changed_status = 0; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4773
diff
changeset
|
517 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4773
diff
changeset
|
518 int vo_osd_changed(int new_value) |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4773
diff
changeset
|
519 { |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
520 mp_osd_obj_t* obj=vo_osd_list; |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4773
diff
changeset
|
521 int ret = vo_osd_changed_status; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4773
diff
changeset
|
522 vo_osd_changed_status = new_value; |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
523 |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
524 while(obj){ |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
525 if(obj->type==new_value) obj->flags|=OSDFLAG_FORCE_UPDATE; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
526 obj=obj->next; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
527 } |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
528 |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4773
diff
changeset
|
529 return ret; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4773
diff
changeset
|
530 } |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
531 |
5645 | 532 // BBBBBBBBBBBB AAAAAAAAAAAAA BBBBBBBBBBB |
533 // BBBBBBBBBBBB BBBBBBBBBBBBB | |
534 // BBBBBBB | |
535 | |
536 // return TRUE if we have osd in the specified rectangular area: | |
537 int vo_osd_check_range_update(int x1,int y1,int x2,int y2){ | |
538 mp_osd_obj_t* obj=vo_osd_list; | |
539 while(obj){ | |
540 if(obj->flags&OSDFLAG_VISIBLE){ | |
541 if( (obj->bbox.x1<=x2 && obj->bbox.x2>=x1) && | |
542 (obj->bbox.y1<=y2 && obj->bbox.y2>=y1) ) return 1; | |
543 } | |
544 obj=obj->next; | |
545 } | |
546 return 0; | |
547 } |