Mercurial > mplayer.hg
comparison libvo/sub.c @ 5664:ee6c9530729f
bbox calculation fixed (font->height < real height)
author | arpi |
---|---|
date | Wed, 17 Apr 2002 20:46:12 +0000 |
parents | bd5c0d8346f0 |
children | 7bea806b9c5f |
comparison
equal
deleted
inserted
replaced
5663:32869a44fac1 | 5664:ee6c9530729f |
---|---|
30 unsigned char* vo_osd_text=NULL; | 30 unsigned char* vo_osd_text=NULL; |
31 int sub_unicode=0; | 31 int sub_unicode=0; |
32 int sub_utf8=0; | 32 int sub_utf8=0; |
33 int sub_pos=100; | 33 int sub_pos=100; |
34 | 34 |
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 | |
35 inline static void vo_update_text_osd(mp_osd_obj_t* obj,int dxs,int dys){ | 43 inline static void vo_update_text_osd(mp_osd_obj_t* obj,int dxs,int dys){ |
36 unsigned char *cp=vo_osd_text; | 44 unsigned char *cp=vo_osd_text; |
37 int x=20; | 45 int x=20; |
46 int h=0; | |
38 | 47 |
39 obj->bbox.x1=obj->x=x; | 48 obj->bbox.x1=obj->x=x; |
40 obj->bbox.y1=obj->y=10; | 49 obj->bbox.y1=obj->y=10; |
41 | 50 |
42 while (*cp){ | 51 while (*cp){ |
43 int c=*cp++; | 52 int c=*cp++; |
44 x+=vo_font->width[c]+vo_font->charspace; | 53 x+=vo_font->width[c]+vo_font->charspace; |
54 h=get_height(c,h); | |
45 } | 55 } |
46 | 56 |
47 obj->bbox.x2=x; | 57 obj->bbox.x2=x-vo_font->charspace; |
48 obj->bbox.y2=obj->bbox.y1+vo_font->height; | 58 obj->bbox.y2=obj->bbox.y1+h; |
49 obj->flags|=OSDFLAG_BBOX; | 59 obj->flags|=OSDFLAG_BBOX; |
50 | 60 |
51 } | 61 } |
52 | 62 |
53 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)){ | 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)){ |
86 if(vo_osd_progbar_type<0 || !vo_font){ | 96 if(vo_osd_progbar_type<0 || !vo_font){ |
87 obj->flags&=~OSDFLAG_VISIBLE; | 97 obj->flags&=~OSDFLAG_VISIBLE; |
88 return; | 98 return; |
89 } | 99 } |
90 | 100 |
91 { | 101 { int h=0; |
92 int y=(dys-vo_font->height)/2; | 102 int y=(dys-vo_font->height)/2; |
93 int delimw=vo_font->width[OSD_PB_START] | 103 int delimw=vo_font->width[OSD_PB_START] |
94 +vo_font->width[OSD_PB_END] | 104 +vo_font->width[OSD_PB_END] |
95 +vo_font->charspace; | 105 +vo_font->charspace; |
96 int width=(2*dxs-3*delimw)/3; | 106 int width=(2*dxs-3*delimw)/3; |
97 int charw=vo_font->width[OSD_PB_0]+vo_font->charspace; | 107 int charw=vo_font->width[OSD_PB_0]+vo_font->charspace; |
98 int elems=width/charw; | 108 int elems=width/charw; |
99 int x=(dxs-elems*charw-delimw)/2; | 109 int x=(dxs-elems*charw-delimw)/2; |
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); | |
100 obj->bbox.x1=obj->x=x; | 114 obj->bbox.x1=obj->x=x; |
101 obj->bbox.y1=obj->y=y; | 115 obj->bbox.y1=obj->y=y; |
102 obj->bbox.x2=x+width+delimw; | 116 obj->bbox.x2=x+width+delimw; |
103 obj->bbox.y2=y+vo_font->height; | 117 obj->bbox.y2=y+h; //vo_font->height; |
104 obj->flags|=OSDFLAG_BBOX; | 118 obj->flags|=OSDFLAG_BBOX; |
105 obj->params.progbar.elems=elems; | 119 obj->params.progbar.elems=elems; |
106 } | 120 } |
107 | 121 |
108 } | 122 } |
210 if(!vo_sub || !vo_font){ | 224 if(!vo_sub || !vo_font){ |
211 obj->flags&=~OSDFLAG_VISIBLE; | 225 obj->flags&=~OSDFLAG_VISIBLE; |
212 return; | 226 return; |
213 } | 227 } |
214 | 228 |
215 obj->y=dys; | 229 obj->bbox.y2=obj->y=dys; |
216 obj->params.subtitle.lines=0; | 230 obj->params.subtitle.lines=0; |
217 | 231 |
218 // too long lines divide into a smaller ones | 232 // too long lines divide into a smaller ones |
219 i=k=lasth=0; | 233 i=k=lasth=0; |
220 h=vo_font->height; | 234 h=vo_font->height; |
289 // printf("h: %d -> %d \n",vo_font->height,h); | 303 // printf("h: %d -> %d \n",vo_font->height,h); |
290 obj->y -=h; // according to max of vo_font->pic_a[font]->h | 304 obj->y -=h; // according to max of vo_font->pic_a[font]->h |
291 } | 305 } |
292 } | 306 } |
293 | 307 |
294 if (obj->y >= (dys * sub_pos / 100)) obj->y = dys * sub_pos /100; | 308 if (obj->y >= (dys * sub_pos / 100)){ |
295 | 309 int old=obj->y; |
310 obj->y = dys * sub_pos /100; | |
311 obj->bbox.y2-=old-obj->y; | |
312 } | |
313 | |
296 // calculate bbox: | 314 // calculate bbox: |
297 obj->bbox.x1=xmin; | 315 obj->bbox.x1=xmin; |
298 obj->bbox.x2=xmax; | 316 obj->bbox.x2=xmax; |
299 obj->bbox.y1=obj->y; | 317 obj->bbox.y1=obj->y; |
300 obj->bbox.y2=obj->y+obj->params.subtitle.lines*vo_font->height; | 318 // obj->bbox.y2=obj->y+obj->params.subtitle.lines*vo_font->height; |
301 obj->flags|=OSDFLAG_BBOX; | 319 obj->flags|=OSDFLAG_BBOX; |
302 | 320 |
303 } | 321 } |
304 | 322 |
305 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)){ | 323 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)){ |
391 // we don't know, so assume the whole screen changed :( | 409 // we don't know, so assume the whole screen changed :( |
392 obj->bbox.x1=obj->bbox.y1=0; | 410 obj->bbox.x1=obj->bbox.y1=0; |
393 obj->bbox.x2=dxs; | 411 obj->bbox.x2=dxs; |
394 obj->bbox.y2=dys; | 412 obj->bbox.y2=dys; |
395 obj->flags|=OSDFLAG_BBOX; | 413 obj->flags|=OSDFLAG_BBOX; |
396 } else if(obj->flags&OSDFLAG_VISIBLE){ | 414 } else { |
397 mp_msg(MSGT_OSD,MSGL_V,"OSD update: %d;%d %dx%d \n", | 415 // check bbox, reduce it if it's out of bounds (corners): |
416 if(obj->bbox.x1<0) obj->bbox.x1=0; | |
417 if(obj->bbox.y1<0) obj->bbox.y1=0; | |
418 if(obj->bbox.x2>dxs) obj->bbox.x2=dxs; | |
419 if(obj->bbox.y2>dys) obj->bbox.y2=dys; | |
420 if(obj->flags&OSDFLAG_VISIBLE) | |
421 // debug: | |
422 mp_msg(MSGT_OSD,MSGL_DBG2,"OSD update: %d;%d %dx%d \n", | |
398 obj->bbox.x1,obj->bbox.y1,obj->bbox.x2-obj->bbox.x1, | 423 obj->bbox.x1,obj->bbox.y1,obj->bbox.x2-obj->bbox.x1, |
399 obj->bbox.y2-obj->bbox.y1); | 424 obj->bbox.y2-obj->bbox.y1); |
400 } | 425 } |
401 // check if visibility changed: | 426 // check if visibility changed: |
402 if(vis != (obj->flags&OSDFLAG_VISIBLE) ) obj->flags|=OSDFLAG_CHANGED; | 427 if(vis != (obj->flags&OSDFLAG_VISIBLE) ) obj->flags|=OSDFLAG_CHANGED; |