[Mplayer-cvslog] CVS: main/libvo sub.c,1.49,1.50

Arpi of Ize arpi at mplayerhq.hu
Wed Apr 17 22:46:20 CEST 2002


Update of /cvsroot/mplayer/main/libvo
In directory mail:/var/tmp.root/cvs-serv18352

Modified Files:
	sub.c 
Log Message:
bbox calculation fixed (font->height < real height)

Index: sub.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/sub.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -r1.49 -r1.50
--- sub.c	16 Apr 2002 00:35:01 -0000	1.49
+++ sub.c	17 Apr 2002 20:46:12 -0000	1.50
@@ -32,9 +32,18 @@
 int sub_utf8=0;
 int sub_pos=100;
 
+// return the real height of a char:
+static inline int get_height(int c,int h){
+    int font;
+    if ((font=vo_font->font[c])>=0)
+	if(h<vo_font->pic_a[font]->h) h=vo_font->pic_a[font]->h;
+    return h;
+}
+
 inline static void vo_update_text_osd(mp_osd_obj_t* obj,int dxs,int dys){
 	unsigned char *cp=vo_osd_text;
 	int x=20;
+	int h=0;
 
         obj->bbox.x1=obj->x=x;
         obj->bbox.y1=obj->y=10;
@@ -42,10 +51,11 @@
         while (*cp){
           int c=*cp++;
           x+=vo_font->width[c]+vo_font->charspace;
+	  h=get_height(c,h);
         }
 	
-	obj->bbox.x2=x;
-	obj->bbox.y2=obj->bbox.y1+vo_font->height;
+	obj->bbox.x2=x-vo_font->charspace;
+	obj->bbox.y2=obj->bbox.y1+h;
 	obj->flags|=OSDFLAG_BBOX;
 
 }
@@ -88,7 +98,7 @@
        return;
     }
     
-    {
+    {	int h=0;
         int y=(dys-vo_font->height)/2;
         int delimw=vo_font->width[OSD_PB_START]
      		  +vo_font->width[OSD_PB_END]
@@ -97,10 +107,14 @@
    	int charw=vo_font->width[OSD_PB_0]+vo_font->charspace;
         int elems=width/charw;
    	int x=(dxs-elems*charw-delimw)/2;
+	h=get_height(OSD_PB_START,h);
+	h=get_height(OSD_PB_END,h);
+	h=get_height(OSD_PB_0,h);
+	h=get_height(OSD_PB_1,h);
 	obj->bbox.x1=obj->x=x;
 	obj->bbox.y1=obj->y=y;
 	obj->bbox.x2=x+width+delimw;
-	obj->bbox.y2=y+vo_font->height;
+	obj->bbox.y2=y+h; //vo_font->height;
 	obj->flags|=OSDFLAG_BBOX;
 	obj->params.progbar.elems=elems;
     }
@@ -212,7 +226,7 @@
        return;
    }
    
-   obj->y=dys;
+   obj->bbox.y2=obj->y=dys;
    obj->params.subtitle.lines=0;
 
       // too long lines divide into a smaller ones
@@ -291,13 +305,17 @@
 	  }
       }
 
-    if (obj->y >= (dys * sub_pos / 100)) obj->y = dys * sub_pos /100;
-      
+    if (obj->y >= (dys * sub_pos / 100)){
+	int old=obj->y;
+	obj->y = dys * sub_pos /100;
+	obj->bbox.y2-=old-obj->y;
+    }
+    
     // calculate bbox:
     obj->bbox.x1=xmin;
     obj->bbox.x2=xmax;
     obj->bbox.y1=obj->y;
-    obj->bbox.y2=obj->y+obj->params.subtitle.lines*vo_font->height;
+//    obj->bbox.y2=obj->y+obj->params.subtitle.lines*vo_font->height;
     obj->flags|=OSDFLAG_BBOX;
     
 }
@@ -393,8 +411,15 @@
 	    obj->bbox.x2=dxs;
 	    obj->bbox.y2=dys;
 	    obj->flags|=OSDFLAG_BBOX;
-	} else if(obj->flags&OSDFLAG_VISIBLE){
-	    mp_msg(MSGT_OSD,MSGL_V,"OSD update: %d;%d %dx%d  \n",
+	} else {
+	    // check bbox, reduce it if it's out of bounds (corners):
+	    if(obj->bbox.x1<0) obj->bbox.x1=0;
+	    if(obj->bbox.y1<0) obj->bbox.y1=0;
+	    if(obj->bbox.x2>dxs) obj->bbox.x2=dxs;
+	    if(obj->bbox.y2>dys) obj->bbox.y2=dys;
+	    if(obj->flags&OSDFLAG_VISIBLE)
+	    // debug:
+	    mp_msg(MSGT_OSD,MSGL_DBG2,"OSD update: %d;%d %dx%d  \n",
 		obj->bbox.x1,obj->bbox.y1,obj->bbox.x2-obj->bbox.x1,
 		obj->bbox.y2-obj->bbox.y1);
 	}




More information about the MPlayer-cvslog mailing list