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