[Mplayer-users] Keystrokes and vanishing OSD

Adam Tla/lka atlka at pg.gda.pl
Fri Aug 10 16:37:45 CEST 2001


Hi,

I included modifications which should remove OSD disappearing while playing
on fast machines and also some modifications according to event handling.
My prevoius patch which adds sub_utf8 handling is also here.
I corrected small bug in vo_svga.c so it does not quit whith sig11.
I added function draw_osd to vo interface so OSD text is drawn before
we sleep waiting for proper time to display frame. I I think all frame
contents should be ready (with OSD part too) before we start waiting for
moment to display this frame. But of course this function could be empty and
sub text could be generated just before flipping page.

chunks:

cfg-mplayer.h	"utf8" option

demux_avi.c	updating d_video->pts value

libvo/sub.c	some improvements and utf8 handling

libvo/video_out.h	void (*draw_osd)(void) added

libvo/video_out_internal.h draw_osd added before flip_page

libvo/vo_*.c	added draw_osd function (in most of them it's just empty )

libvo/vo_sxga	corrected uninit

libvo/vo_x11	using XSync(mDisplay, False) against XFlush(mDisplay) makes
		OSD rock stable (image should be better too)

libvo/vo_xv	XSync normal and XFlush while doublebuffering

libvo/x11_common added '0'..'9' keypresses handling

subreader.c	added ".utf" file searching and switching sub_utf8 to 1
		if this kind of file is found

mplayer.c	added d_videp->draw_osd() just after frame decoding
		added d_video->check_events() before flipping page
		corrected values of mixer, brightness etc. to be always 0..100

With XSync its not that bad. I could play MissCongeniality.avi with utf8 subs
640x352 high quality DivX (using -vo odivx and DivX4Linux lib)
with P200MMX and frame dropping of course but it is still playable.

Regards
-- 
 . .  Adam Tla/lka      mailto:atlka at pg.gda.pl    ^v^ ^v^ ^v^
  -  Computer Center,  Technical University of Gdansk, Poland
     PGP public key:   finger atlka at sunrise.pg.gda.pl
-------------- next part --------------
diff -ruN MPlayer-20010810/cfg-mplayer.h MPlayer-20010810n/cfg-mplayer.h
--- MPlayer-20010810/cfg-mplayer.h	Mon Aug  6 02:30:29 2001
+++ MPlayer-20010810n/cfg-mplayer.h	Fri Aug 10 07:45:25 2001
@@ -35,6 +35,7 @@
 
 #ifdef USE_SUB
 extern int sub_unicode;
+extern int sub_utf8;
 #endif
 
 #ifdef USE_OSD
@@ -92,6 +93,8 @@
         {"noautosub", &sub_auto, CONF_TYPE_FLAG, 0, 1, 0},
 	{"unicode", &sub_unicode, CONF_TYPE_FLAG, 0, 0, 1},
 	{"nounicode", &sub_unicode, CONF_TYPE_FLAG, 0, 1, 0},
+	{"utf8", &sub_utf8, CONF_TYPE_FLAG, 0, 0, 1},
+	{"noutf8", &sub_utf8, CONF_TYPE_FLAG, 0, 1, 0},
 #endif
 #ifdef USE_OSD
 	{"font", &font_name, CONF_TYPE_STRING, 0, 0, 0},
diff -ruN MPlayer-20010810/demux_avi.c MPlayer-20010810n/demux_avi.c
--- MPlayer-20010810/demux_avi.c	Fri Aug 10 03:00:34 2001
+++ MPlayer-20010810n/demux_avi.c	Fri Aug 10 07:46:12 2001
@@ -492,7 +492,7 @@
           sh_audio->timer=-skip_audio_secs;
 
       }
-
+   d_video->pts=avi_video_pts; // update video pts AST
 
 }
 
diff -ruN MPlayer-20010810/libvo/sub.c MPlayer-20010810n/libvo/sub.c
--- MPlayer-20010810/libvo/sub.c	Tue Jun 12 16:03:18 2001
+++ MPlayer-20010810n/libvo/sub.c	Fri Aug 10 08:01:52 2001
@@ -6,17 +6,17 @@
 
 unsigned char* vo_osd_text="00:00:00";
 int sub_unicode=0;
+int sub_utf8;
 
-static void vo_draw_text_osd(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)){
-        int len=strlen(vo_osd_text);
-        int j;
+inline static void vo_draw_text_osd(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)){
+	unsigned char *cp=vo_osd_text;
+	int c;
+	int font;
         int y=10;
         int x=20;
 
-        for(j=0;j<len;j++){
-          int c=vo_osd_text[j];
-          int font=vo_font->font[c];
-          if(font>=0)
+        while ((c=*cp++)){
+           if ((font=vo_font->font[c])>=0)
             draw_alpha(x,y,
               vo_font->width[c],
               vo_font->pic_a[font]->h,
@@ -31,9 +31,9 @@
 int vo_osd_progbar_type=-1;
 int vo_osd_progbar_value=100;   // 0..255
 
-static void vo_draw_text_progbar(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)){
+inline static void vo_draw_text_progbar(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)){
         int i;
-        int y=dys/2;
+        int y=(dys-vo_font->height)/2;
         int x;
         int c,font;
         int width=(dxs*2/3-vo_font->width[0x10]-vo_font->width[0x12]);
@@ -42,8 +42,8 @@
         x=(dxs-width)/2;
 //        printf("osd.progbar  width=%d  xpos=%d\n",width,x);
 
-        c=vo_osd_progbar_type;font=vo_font->font[c];
-        if(vo_osd_progbar_type>0 && font>=0)
+        c=vo_osd_progbar_type;
+        if (vo_osd_progbar_type>0 && (font=vo_font->font[c])>=0)
             draw_alpha(x-vo_font->width[c]-vo_font->spacewidth,y,
               vo_font->width[c],
               vo_font->pic_a[font]->h,
@@ -51,8 +51,8 @@
               vo_font->pic_a[font]->bmp+vo_font->start[c],
               vo_font->pic_a[font]->w);
 
-        c=OSD_PB_START;font=vo_font->font[c];
-        if(font>=0)
+        c=OSD_PB_START;
+        if ((font=vo_font->font[c])>=0)
             draw_alpha(x,y,
               vo_font->width[c],
               vo_font->pic_a[font]->h,
@@ -61,20 +61,32 @@
               vo_font->pic_a[font]->w);
         x+=vo_font->width[c];
 
-        for(i=0;i<elems;i++){
-          c=(i<mark)?OSD_PB_0:OSD_PB_1;font=vo_font->font[c];
-          if(font>=0)
-            draw_alpha(x,y,
-              vo_font->width[c],
-              vo_font->pic_a[font]->h,
-              vo_font->pic_b[font]->bmp+vo_font->start[c],
-              vo_font->pic_a[font]->bmp+vo_font->start[c],
-              vo_font->pic_a[font]->w);
-          x+=vo_font->width[c];
-        }
+   	c=OSD_PB_0;
+   	if ((font=vo_font->font[c])>=0)
+     	   for (i=mark;i--;){
+	       draw_alpha(x,y,
+			  vo_font->width[c],
+			  vo_font->pic_a[font]->h,
+			  vo_font->pic_b[font]->bmp+vo_font->start[c],
+			  vo_font->pic_a[font]->bmp+vo_font->start[c],
+			  vo_font->pic_a[font]->w);
+	       x+=vo_font->width[c];
+	   }
+
+   	c=OSD_PB_1;
+	if ((font=vo_font->font[c])>=0)
+     	   for (i=elems-mark;i--;){
+	       draw_alpha(x,y,
+			  vo_font->width[c],
+			  vo_font->pic_a[font]->h,
+			  vo_font->pic_b[font]->bmp+vo_font->start[c],
+			  vo_font->pic_a[font]->bmp+vo_font->start[c],
+			  vo_font->pic_a[font]->w);
+	       x+=vo_font->width[c];
+	   }
 
-        c=OSD_PB_END;font=vo_font->font[c];
-        if(font>=0)
+        c=OSD_PB_END;
+        if ((font=vo_font->font[c])>=0)
             draw_alpha(x,y,
               vo_font->width[c],
               vo_font->pic_a[font]->h,
@@ -90,97 +102,110 @@
 
 subtitle* vo_sub=NULL;
 
-static void vo_draw_text_sub(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)){
-    int i;
-    int y;
-    y=dys-(1+vo_sub->lines-1)*vo_font->height-10;
-
-    // too long lines divide into smaller ones
-    for(i=0;i<vo_sub->lines;i++){
-        unsigned char* text=vo_sub->text[i];
-        int len=strlen(text);
-	int j;
-        int xsize=-vo_font->charspace;
-	int lastStripPosition=-1;
-	int previousStrip=0;
-	int lastxsize=0;
-
-	for(j=0;j<len;j++){
-          int c=text[j];
-          int w;
-          if (sub_unicode && (c>=0x80)) c=(c<<8)+text[++j];
-          w = vo_font->width[c];
-	  if (text[j]==' ' && dxs>xsize)
-	  {
-	    lastStripPosition=j;
-	    lastxsize=xsize;
-	  }
-          xsize+=w+vo_font->charspace;
-	  if (dxs<xsize && lastStripPosition>0)
-	  {
-	    xsize=lastxsize;
-	    j=lastStripPosition;
-            y-=vo_font->height;
-	    previousStrip=lastStripPosition;
-            xsize=-vo_font->charspace;
-	  }
-        }
-    }
-
+#define MAX_UCS 1600
+#define MAX_UCSLINES 16
 
-    for(i=0;i<vo_sub->lines;i++){
-        unsigned char* text=vo_sub->text[i];//  "Hello World! H?DEJ?!";
-        int len=strlen(text);
-        int j,k;
-        int xsize=-vo_font->charspace;
-        int x=0;
-
-	int lastStripPosition=-1;
-	int previousStrip=0;
-	int lastxsize=xsize;
-
-	for(j=0;j<len;j++){
-          int c=text[j];
-          int w;
-          if (sub_unicode && (c>=0x80)) c=(c<<8)+text[++j];
-          w = vo_font->width[c];
-          if (c==' ' && dxs>xsize)
-	  {
-	    lastStripPosition=j;
-	    lastxsize=xsize;
+inline static void vo_draw_text_sub(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)){
+   static int utbl[MAX_UCS+1];
+   static int xtbl[MAX_UCSLINES];
+   static int lines;
+   static subtitle *memsub=NULL;
+   static int memy;
+   static int memdxs;
+   static int memdys;
+   unsigned char *t;
+   int i;
+   int j;
+   int k;
+   int l;
+   int x;
+   int y;
+
+   int c;
+   int len;
+   int line;
+   int font;
+   int lastStripPosition;
+   int xsize;
+   int lastxsize;
+   int lastk;
+   
+   if ((memsub!=vo_sub)||(memdxs!=dxs)||(memdys!=dys)){
+      memsub=vo_sub;
+      memdxs=dxs;
+      memdys=dys;
+      
+      memy=dys-vo_font->height/4;
+      
+      // too long lines divide into smaller ones
+      i=k=lines=0; l=vo_sub->lines;
+      while (l--){
+	  t=vo_sub->text[i++];	  
+	  len=strlen(t)-1;
+	  xsize=lastxsize=-vo_font->charspace;
+	  lastStripPosition=-1;
+
+	  for (j=0;j<=len;j++){
+	      if ((c=t[j])>=0x80){
+		 if (sub_unicode) 
+		    c = (c<<8) + t[++j]; 
+		 else
+		    if (sub_utf8){
+		       if ((c & 0xe0) == 0xc0)    /* 2 bytes U+00080..U+0007FF*/
+			  c = (c & 0x1f)<<6 | (t[++j] & 0x3f);
+		       else if((c & 0xf0) == 0xe0)/* 3 bytes U+00800..U+00FFFF*/
+			  c = ((c & 0x0f)<<6 |
+			       (t[++j] & 0x3f))<<6 | (t[++j] & 0x3f);
+		    }
+	      }
+	      if (k==MAX_UCS){
+		 utbl[k]=l=0;
+		 break;
+	      } else
+	         utbl[k++]=c;
+	      if (c==' '){
+		 lastk=k;
+		 lastStripPosition=j;
+		 lastxsize=xsize;
+	      }
+	      xsize+=vo_font->width[c]+vo_font->charspace;
+	      if (dxs<xsize && lastStripPosition>0){
+		 j=lastStripPosition;
+		 k=lastk;
+	      } else if (j==len){
+		 lastxsize=xsize;
+	      } else
+	         continue;	       	       	       
+	      utbl[k++]=0;
+	      xtbl[lines++]=(dxs-lastxsize)/2;
+	      if (lines==MAX_UCSLINES||k>MAX_UCS){
+		 l=0;
+		 break;
+	      }
+	      memy-=vo_font->height;
+	      xsize=lastxsize=-vo_font->charspace;
 	  }
-          xsize+=w+vo_font->charspace;
-	  if ((dxs<xsize && lastStripPosition>0) || j==len-1)
-	  {
-	    if (j==len-1) lastStripPosition=len;
-	      else xsize=lastxsize;
-	    j=lastStripPosition;
-
-            x=dxs/2-xsize/2;
-
-            for(k=previousStrip;k<lastStripPosition;k++){
-              int c=text[k];
-	      int font;
-              if (sub_unicode && (c>=0x80)) c=(c<<8)+text[++k];
-              font=vo_font->font[c];
-              if(x>=0 && x+vo_font->width[c]<dxs)
-                if(font>=0)
-                  draw_alpha(x,y,
-                    vo_font->width[c],
-                    vo_font->pic_a[font]->h,
-                    vo_font->pic_b[font]->bmp+vo_font->start[c],
-                    vo_font->pic_a[font]->bmp+vo_font->start[c],
-                    vo_font->pic_a[font]->w);
-              x+=vo_font->width[c]+vo_font->charspace;
-            }
-            x=0;
-            y+=vo_font->height;
-	    previousStrip=lastStripPosition;
-            xsize=lastxsize=-vo_font->charspace;
-	  }
-        }
-    }
-
+      }
+   }
+   
+   y = memy;
+
+   k=i=0; l=lines;
+   while (l--){
+       x = xtbl[i++];
+       while ((c=utbl[k++])){
+	     if (x>=0 && x+vo_font->width[c]<=dxs)
+		if ((font=vo_font->font[c])>=0)
+	           draw_alpha(x,y,
+			      vo_font->width[c],
+			      vo_font->pic_a[font]->h,
+			      vo_font->pic_b[font]->bmp+vo_font->start[c],
+			      vo_font->pic_a[font]->bmp+vo_font->start[c],
+			      vo_font->pic_a[font]->w);
+	  x+=vo_font->width[c]+vo_font->charspace;
+       }
+       y+=vo_font->height;
+   }   
 }
 
 static int draw_alpha_init_flag=0;
diff -ruN MPlayer-20010810/libvo/video_out.h MPlayer-20010810n/libvo/video_out.h
--- MPlayer-20010810/libvo/video_out.h	Mon Jul 16 14:11:49 2001
+++ MPlayer-20010810n/libvo/video_out.h	Fri Aug 10 08:42:06 2001
@@ -72,6 +72,11 @@
          */
         uint32_t (*draw_slice)(uint8_t *src[], int stride[], int w,int h, int x,int y);
 
+   	/*
+         * Draws OSD to the screen buffer
+         */
+        void (*draw_osd)(void);
+
         /*
          * Blit/Flip buffer to the screen. Must be called after each frame!
          */
diff -ruN MPlayer-20010810/libvo/video_out_internal.h MPlayer-20010810n/libvo/video_out_internal.h
--- MPlayer-20010810/libvo/video_out_internal.h	Tue Apr 24 13:42:04 2001
+++ MPlayer-20010810n/libvo/video_out_internal.h	Fri Aug 10 09:31:08 2001
@@ -25,6 +25,7 @@
 static const vo_info_t* get_info(void);
 static uint32_t draw_frame(uint8_t *src[]);
 static uint32_t draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y);
+static void draw_osd(void);
 static void flip_page(void);
 static void check_events(void);
 static void uninit(void);
@@ -37,6 +38,7 @@
 	get_info,\
 	draw_frame,\
 	draw_slice,\
+        draw_osd,\
 	flip_page,\
 	check_events,\
 	uninit,\
diff -ruN MPlayer-20010810/libvo/vo_3dfx.c MPlayer-20010810n/libvo/vo_3dfx.c
--- MPlayer-20010810/libvo/vo_3dfx.c	Sun Jun 17 03:22:09 2001
+++ MPlayer-20010810n/libvo/vo_3dfx.c	Fri Aug 10 09:03:04 2001
@@ -450,6 +450,10 @@
 	return 0;
 }
 
+static void draw_osd(void)
+{
+}
+
 static void 
 flip_page(void) 
 {
diff -ruN MPlayer-20010810/libvo/vo_dga.c MPlayer-20010810n/libvo/vo_dga.c
--- MPlayer-20010810/libvo/vo_dga.c	Mon Jul 16 20:41:52 2001
+++ MPlayer-20010810n/libvo/vo_dga.c	Fri Aug 10 14:46:53 2001
@@ -524,11 +524,11 @@
 
 #include "sub.h"
 
-static void flip_page( void ){
-
-  if(vo_dga_dbf_mem_offset != 0){
-    vo_draw_text(vo_dga_src_width,vo_dga_src_height,draw_alpha);
+static void draw_osd(void)
+{ vo_draw_text(vo_dga_src_width,vo_dga_src_height,draw_alpha); }
 
+static void flip_page( void ){
+  if (vo_dga_dbf_mem_offset!=0){
 #ifdef HAVE_DGA2
     XDGASetViewport (vo_dga_dpy, XDefaultScreen(vo_dga_dpy), 
 		    0, vo_dga_dbf_current * vo_dga_dbf_y_offset, 
@@ -539,7 +539,6 @@
 #endif
     vo_dga_dbf_current = 1 - vo_dga_dbf_current;
   }
-  check_events();
 }
 
 //---------------------------------------------------------
diff -ruN MPlayer-20010810/libvo/vo_fbdev.c MPlayer-20010810n/libvo/vo_fbdev.c
--- MPlayer-20010810/libvo/vo_fbdev.c	Mon Jun 11 00:04:54 2001
+++ MPlayer-20010810n/libvo/vo_fbdev.c	Fri Aug 10 09:01:05 2001
@@ -1130,10 +1130,13 @@
 	}
 }
 
+static void draw_osd(void)
+{
+}
+
 static void flip_page(void)
 {
 	vo_draw_text(in_width, in_height, draw_alpha);
-	check_events();
 	put_frame();
 }
 
diff -ruN MPlayer-20010810/libvo/vo_fsdga.c MPlayer-20010810n/libvo/vo_fsdga.c
--- MPlayer-20010810/libvo/vo_fsdga.c	Tue Apr 24 12:21:12 2001
+++ MPlayer-20010810n/libvo/vo_fsdga.c	Fri Aug 10 09:00:25 2001
@@ -173,8 +173,11 @@
     int e=vo_x11_check_events(vo_dga_dpy);
 }
 
+static void draw_osd(void)
+{
+}
+
 static void flip_page( void ){
-    check_events(); 
   //  printf("vo_dga: In flippage\n");
 
 }
diff -ruN MPlayer-20010810/libvo/vo_ggi.c MPlayer-20010810n/libvo/vo_ggi.c
--- MPlayer-20010810/libvo/vo_ggi.c	Sat Jun 23 15:28:28 2001
+++ MPlayer-20010810n/libvo/vo_ggi.c	Fri Aug 10 10:22:03 2001
@@ -524,9 +524,12 @@
 }
 #endif
 
+static void draw_osd(void)
+{
+}
+
 static void flip_page(void)
 {
-    check_events();
 #ifdef GGI_OSD
     vo_draw_text(ggi_conf.width, ggi_conf.height, draw_alpha);
 #endif
diff -ruN MPlayer-20010810/libvo/vo_gl.c MPlayer-20010810n/libvo/vo_gl.c
--- MPlayer-20010810/libvo/vo_gl.c	Tue Jul 10 15:24:59 2001
+++ MPlayer-20010810n/libvo/vo_gl.c	Fri Aug 10 08:58:39 2001
@@ -332,13 +332,13 @@
     if(e&VO_EVENT_RESIZE) resize(vo_dwidth,vo_dheight);
 }
 
-
+static void draw_osd(void)
+{
+}
+   
 static void
 flip_page(void)
 {
-
-    check_events();
-
 //  glEnable(GL_TEXTURE_2D);
 //  glBindTexture(GL_TEXTURE_2D, texture_id);
 
diff -ruN MPlayer-20010810/libvo/vo_md5.c MPlayer-20010810n/libvo/vo_md5.c
--- MPlayer-20010810/libvo/vo_md5.c	Mon Jun 11 14:41:53 2001
+++ MPlayer-20010810n/libvo/vo_md5.c	Fri Aug 10 08:57:05 2001
@@ -49,6 +49,10 @@
     return &vo_info;
 }
 
+static void draw_osd(void)
+{
+}
+
 static void flip_page (void)
 {
     char buf2[100];
diff -ruN MPlayer-20010810/libvo/vo_mga.c MPlayer-20010810n/libvo/vo_mga.c
--- MPlayer-20010810/libvo/vo_mga.c	Sat Jun 23 21:44:22 2001
+++ MPlayer-20010810n/libvo/vo_mga.c	Fri Aug 10 08:56:36 2001
@@ -113,6 +113,10 @@
 printf("vo: uninit!\n");
 }
 
+static void draw_osd(void)
+{
+}
+
 static void flip_page(void)
 {
     vo_draw_text(mga_vid_config.src_width,mga_vid_config.src_height,draw_alpha);
diff -ruN MPlayer-20010810/libvo/vo_null.c MPlayer-20010810n/libvo/vo_null.c
--- MPlayer-20010810/libvo/vo_null.c	Sat Mar  3 22:46:39 2001
+++ MPlayer-20010810n/libvo/vo_null.c	Fri Aug 10 08:55:33 2001
@@ -45,6 +45,10 @@
 	return 0;
 }
 
+static void draw_osd(void)
+{
+}
+
 static void
 flip_page(void)
 {
diff -ruN MPlayer-20010810/libvo/vo_odivx.c MPlayer-20010810n/libvo/vo_odivx.c
--- MPlayer-20010810/libvo/vo_odivx.c	Tue Apr 24 12:21:12 2001
+++ MPlayer-20010810n/libvo/vo_odivx.c	Fri Aug 10 09:11:55 2001
@@ -137,6 +137,10 @@
     DWORD               dwChunkLength;          // Length of chunk
 } AVIINDEXENTRY;
 
+static void draw_osd(void)
+{
+}
+
 static void
 flip_page(void)
 {
diff -ruN MPlayer-20010810/libvo/vo_pgm.c MPlayer-20010810n/libvo/vo_pgm.c
--- MPlayer-20010810/libvo/vo_pgm.c	Tue Jun 12 16:03:18 2001
+++ MPlayer-20010810n/libvo/vo_pgm.c	Fri Aug 10 09:18:51 2001
@@ -58,6 +58,10 @@
     return &vo_info;
 }
 
+static void draw_osd(void)
+{
+}
+
 static void flip_page (void)
 {
     FILE * f;
diff -ruN MPlayer-20010810/libvo/vo_png.c MPlayer-20010810n/libvo/vo_png.c
--- MPlayer-20010810/libvo/vo_png.c	Sat Jun  9 19:53:54 2001
+++ MPlayer-20010810n/libvo/vo_png.c	Fri Aug 10 09:18:42 2001
@@ -221,6 +221,10 @@
 
 }
 
+static void draw_osd(void)
+{
+}
+
 static void flip_page (void)
 {
     char buf[100];
diff -ruN MPlayer-20010810/libvo/vo_sdl.c MPlayer-20010810n/libvo/vo_sdl.c
--- MPlayer-20010810/libvo/vo_sdl.c	Sat Jul 28 07:54:02 2001
+++ MPlayer-20010810n/libvo/vo_sdl.c	Fri Aug 10 10:27:22 2001
@@ -1153,6 +1153,13 @@
 }
 
 
+static void draw_osd(void)
+{	struct sdl_priv_s *priv = &sdl_priv;
+
+	/* update osd/subtitles */
+	vo_draw_text(priv->width,priv->height,draw_alpha);
+}
+
 /**
  * Display the surface we have written our data to and check for events.
  *
@@ -1161,15 +1168,7 @@
  **/
 
 static void flip_page (void)
-{
-	struct sdl_priv_s *priv = &sdl_priv;
-
-	/* update osd/subtitles */
-	vo_draw_text(priv->width,priv->height,draw_alpha);	
-		
-	/* check and react on keypresses and window resizes */
-	check_events();
-
+{	struct sdl_priv_s *priv = &sdl_priv;
 	switch(priv->format) {
 	    case IMGFMT_RGB15:
 	    case IMGFMT_BGR15:	
diff -ruN MPlayer-20010810/libvo/vo_svga.c MPlayer-20010810n/libvo/vo_svga.c
--- MPlayer-20010810/libvo/vo_svga.c	Tue Jul 17 15:57:32 2001
+++ MPlayer-20010810n/libvo/vo_svga.c	Fri Aug 10 13:57:23 2001
@@ -509,6 +509,10 @@
   return (0);
 }
 
+static void draw_osd(void)
+{
+}
+
 static void flip_page(void) {
   if (y_pos) {
     gl_fillbox(0, 0, WIDTH, y_pos, 0);
@@ -518,7 +522,6 @@
     gl_fillbox(0, 0, x_pos, HEIGHT, 0);
     gl_fillbox(WIDTH - x_pos, 0, x_pos, HEIGHT, 0);
   }
-
   vo_draw_text(WIDTH, HEIGHT, draw_alpha);
   gl_copyscreen(screen);
 }
@@ -538,13 +541,10 @@
     free(scalebuf);
   if (yuvbuf != NULL)
     free(yuvbuf);
-  if (modelist != NULL) {
-    while (modelist->next != NULL) {
-      list = modelist;
-      while (list->next != NULL)
-        list = list->next;
-      free(list);
-    }
-    free(modelist);
+  while (modelist != NULL) {
+       list=modelist;
+       modelist=modelist->next;
+       free(list);
   }
+   
 }
diff -ruN MPlayer-20010810/libvo/vo_syncfb.c MPlayer-20010810n/libvo/vo_syncfb.c
--- MPlayer-20010810/libvo/vo_syncfb.c	Tue Apr 24 13:30:57 2001
+++ MPlayer-20010810n/libvo/vo_syncfb.c	Fri Aug 10 09:18:15 2001
@@ -273,7 +273,9 @@
 }
 
 
-
+static void draw_osd(void)
+{
+}
 
 static void
 flip_page(void)
diff -ruN MPlayer-20010810/libvo/vo_x11.c MPlayer-20010810n/libvo/vo_x11.c
--- MPlayer-20010810/libvo/vo_x11.c	Sun Jun 17 03:22:09 2001
+++ MPlayer-20010810n/libvo/vo_x11.c	Fri Aug 10 11:06:58 2001
@@ -373,7 +373,6 @@
                  0,0,
                  ( vo_dwidth - myximage->width ) / 2,( vo_dheight - myximage->height ) / 2,
                  myximage->width,myximage->height,True );
-   XFlush( mDisplay );
   }
   else
 #endif
@@ -382,7 +381,6 @@
                0,0,
                ( vo_dwidth - myximage->width ) / 2,( vo_dheight - myximage->height ) / 2,
                myximage->width,myximage->height );
-    XFlush( mDisplay );
   }
 #endif
 }
@@ -405,10 +403,12 @@
     }
 }
 
+static void draw_osd(void)
+{ vo_draw_text(image_width,image_height,draw_alpha); }
+
 static void flip_page( void ){
-    vo_draw_text(image_width,image_height,draw_alpha);
-    check_events();
     Display_Image( myximage,ImageData );
+    XSync(mDisplay, False);   
 }
 
 static uint32_t draw_slice( uint8_t *src[],int stride[],int w,int h,int x,int y )
diff -ruN MPlayer-20010810/libvo/vo_xmga.c MPlayer-20010810n/libvo/vo_xmga.c
--- MPlayer-20010810/libvo/vo_xmga.c	Sat Jun 23 21:44:22 2001
+++ MPlayer-20010810n/libvo/vo_xmga.c	Fri Aug 10 10:07:47 2001
@@ -161,7 +161,12 @@
 
 }
 
+static void draw_osd(void)
+{ 
+}
+
 static void flip_page(void){
+   vo_draw_text(mga_vid_config.src_width,mga_vid_config.src_height,draw_alpha);
 #ifdef SHOW_TIME
     unsigned int t;
     t=GetTimer();
@@ -169,10 +174,6 @@
     timerd=t-timer;
     timer=t;
 #endif
-
-    vo_draw_text(mga_vid_config.src_width,mga_vid_config.src_height,draw_alpha);
-
-    check_events();
     vo_mga_flip_page();
 }
 
diff -ruN MPlayer-20010810/libvo/vo_xv.c MPlayer-20010810n/libvo/vo_xv.c
--- MPlayer-20010810/libvo/vo_xv.c	Wed Jul  4 01:22:29 2001
+++ MPlayer-20010810n/libvo/vo_xv.c	Fri Aug 10 11:00:32 2001
@@ -328,20 +328,23 @@
 
 }
 
-static void flip_page(void)
+static void draw_osd(void)
 {
- vo_draw_text(image_width,image_height,draw_alpha);
- check_events();
+   vo_draw_text(image_width,image_height,draw_alpha);
+}
+
+static void flip_page(void){
  XvShmPutImage(mDisplay, xv_port, mywindow, mygc, xvimage[current_buf],
          0, 0,  image_width, image_height,
          drwX,drwY,drwWidth,(mFullscreen?drwHeight - 1:drwHeight),
          False);
- XFlush(mDisplay);
- current_buf=(current_buf+1)%num_buffers;
+ if (num_buffers>1){
+    current_buf=(current_buf+1)%num_buffers;
+    XFlush(mDisplay);
+ } else
+    XSync(mDisplay, False);
  return;
 }
-
-
 
 static uint32_t draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y)
 {
diff -ruN MPlayer-20010810/libvo/x11_common.c MPlayer-20010810n/libvo/x11_common.c
--- MPlayer-20010810/libvo/x11_common.c	Tue Aug  7 01:59:50 2001
+++ MPlayer-20010810n/libvo/x11_common.c	Fri Aug 10 08:19:49 2001
@@ -137,7 +137,8 @@
    case wsM:	     mplayer_put_key('m'); break;
    case wso:
    case wsO:         mplayer_put_key('o'); break;
-   default: if((key>='a' && key<='z')||(key>='A' && key<='Z')) mplayer_put_key(key);
+   default: if((key>='a' && key<='z')||(key>='A' && key<='Z')||
+	       (key>='0' && key<='9')) mplayer_put_key(key);
   }
 
 }
diff -ruN MPlayer-20010810/mplayer.c MPlayer-20010810n/mplayer.c
--- MPlayer-20010810/mplayer.c	Fri Aug 10 03:27:02 2001
+++ MPlayer-20010810n/mplayer.c	Fri Aug 10 13:59:42 2001
@@ -1234,11 +1234,16 @@
     if(in_size>max_framesize) max_framesize=in_size;
     blit_frame=decode_video(video_out,sh_video,start,in_size,drop_frame);
   }
-
+     
   vdecode_time=video_time_usage-vdecode_time;
 
 //------------------------ frame decoded. --------------------
 
+//------------------------ add OSD to frame contents ---------
+#ifndef USE_LIBVO2
+    video_out->draw_osd();
+#endif
+     
     // Increase video timers:
     sh_video->num_frames+=frame_time;
     frame_time*=sh_video->frametime;
@@ -1277,7 +1282,7 @@
 	      printf("\nstill dropping, %.2f\n", time_frame);
 	  }
       }
-
+      video_out->check_events(); // check events AST
     } else {
       // It's time to sleep...
       current_module="sleep";
@@ -1324,12 +1329,15 @@
 
         current_module="flip_page";
 #ifdef USE_LIBVO2
+
         if(blit_frame) vo2_flip(video_out,0);
 #else
+	video_out->check_events();
         if(blit_frame) video_out->flip_page();
+       
 #endif
 //        usec_sleep(50000); // test only!
-
+     
     }
 
     current_module=NULL;
@@ -1559,16 +1567,19 @@
     case 'x':
       sub_delay += 0.1;
       break;
+    case '9': c='/'; goto _jump1;
+    case '0': c='*';
+_jump1:	 
     case '*':
     case '/': {
         float mixer_l, mixer_r;
         mixer_getvolume( &mixer_l,&mixer_r );
         if(c=='*'){
-            mixer_l++; if ( mixer_l > 100 ) mixer_l = 100;
-            mixer_r++; if ( mixer_r > 100 ) mixer_r = 100;
+            if ( ++mixer_l > 100 ) mixer_l = 100;
+            if ( ++mixer_r > 100 ) mixer_r = 100;
         } else {
-            mixer_l--; if ( mixer_l < 0 ) mixer_l = 0;
-            mixer_r--; if ( mixer_r < 0 ) mixer_r = 0;
+            if ( --mixer_l < 0 ) mixer_l = 0;
+            if ( --mixer_r < 0 ) mixer_r = 0;
         }
         mixer_setvolume( mixer_l,mixer_r );
 
@@ -1590,9 +1601,9 @@
     case '1':
     case '2':
         if(c=='2'){
-	    if ( v_cont++ > 100 ) v_cont = 100;
+	    if ( ++v_cont > 100 ) v_cont = 100;
         } else {
-    	    if ( v_cont-- < 0 ) v_cont = 0;	    
+    	    if ( --v_cont < 0 ) v_cont = 0;	    
         }
 	if(set_video_colors(sh_video,"Contrast",v_cont)){
 #ifdef USE_OSD
@@ -1609,9 +1620,9 @@
     case '3':
     case '4':
         if(c=='4'){
-	    if ( v_bright++ > 100 ) v_bright = 100;
+	    if ( ++v_bright > 100 ) v_bright = 100;
         } else {
-    	    if ( v_bright-- < 0 ) v_bright = 0;	    
+    	    if ( --v_bright < 0 ) v_bright = 0;	    
         }
 	if(set_video_colors(sh_video,"Brightness",v_bright)){
 #ifdef USE_OSD
@@ -1628,9 +1639,9 @@
     case '5':
     case '6':
         if(c=='6'){
-	    if ( v_hue++ > 100 ) v_hue = 100;
+	    if ( ++v_hue > 100 ) v_hue = 100;
         } else {
-    	    if ( v_hue-- < 0 ) v_hue = 0;	    
+    	    if ( --v_hue < 0 ) v_hue = 0;	    
         }
 	if(set_video_colors(sh_video,"Hue",v_hue)){
 #ifdef USE_OSD
@@ -1647,9 +1658,9 @@
     case '7':
     case '8':
         if(c=='8'){
-	    if ( v_saturation++ > 100 ) v_saturation = 100;
+	    if ( ++v_saturation > 100 ) v_saturation = 100;
         } else {
-    	    if ( v_saturation-- < 0 ) v_saturation = 0;	    
+    	    if ( --v_saturation < 0 ) v_saturation = 0;	    
         }
 	if(set_video_colors(sh_video,"Saturation",v_saturation)){
 #ifdef USE_OSD
@@ -1666,7 +1677,8 @@
       frame_dropping=(frame_dropping+1)%3;
       printf("== drop: %d ==  \n",frame_dropping);
       break;
-  }
+      }
+   
 } // keyboard event handler
 
   if (seek_to_sec) {
diff -ruN MPlayer-20010810/subreader.c MPlayer-20010810n/subreader.c
--- MPlayer-20010810/subreader.c	Sat Jun  9 22:09:18 2001
+++ MPlayer-20010810n/subreader.c	Fri Aug 10 08:28:02 2001
@@ -437,6 +437,7 @@
 
 char * sub_filename(char* path,  char * fname )
 {
+ extern int sub_utf8;
  char * sub_name1;
  char * sub_name2;
  char * aviptr1, * aviptr2, * tmp;
@@ -444,7 +445,9 @@
  FILE * f;
  int pos=0;
  char * sub_exts[] = 
-  { ".sub",
+  { ".utf",
+    ".UTF",
+    ".sub",
     ".SUB",
     ".srt",
     ".SRT",
@@ -484,6 +487,7 @@
    if((f=fopen( sub_name,"rt" ))) {
      fclose( f );
      printf( "SUB: Detected sub file: %s\n",sub_name );
+     if (i<2) sub_utf8=1;
      return sub_name;
    }
   }


More information about the MPlayer-users mailing list