[MPlayer-dev-eng] [PATCH] move common vo config() code to video_out.c

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Thu Feb 15 15:10:48 CET 2007


Hello,
a lot of vo code, esp. for aspect and -geometry handling is duplicated
in many vos.
Attached patch factors that code out.
It should also help to contain the changes for my VOFLAG_SAME_INPUT
patch to libvo.
I'd like to apply soon.

Greetings,
Reimar Döffinger
-------------- next part --------------
Index: libmpcodecs/vf_vo.c
===================================================================
--- libmpcodecs/vf_vo.c	(revision 22221)
+++ libmpcodecs/vf_vo.c	(working copy)
@@ -62,7 +62,7 @@
     // save vo's stride capability for the wanted colorspace:
     vf->default_caps=query_format(vf,outfmt) & VFCAP_ACCEPT_STRIDE;
 
-    if(video_out->config(width,height,d_width,d_height,flags,"MPlayer",outfmt))
+    if(config_video_out(video_out,width,height,d_width,d_height,flags,"MPlayer",outfmt))
 	return 0;
 
 #ifdef USE_ASS
Index: libvo/vo_xvidix.c
===================================================================
--- libvo/vo_xvidix.c	(revision 22221)
+++ libvo/vo_xvidix.c	(working copy)
@@ -240,23 +240,11 @@
 
     title = "MPlayer VIDIX X11 Overlay";
 
-    panscan_init();
-
     image_height = height;
     image_width = width;
     image_format = format;
     vo_mouse_autohide = 1;
 
-    aspect_save_orig(width, height);
-    aspect_save_prescale(d_width, d_height);
-    aspect_save_screenres(vo_screenwidth, vo_screenheight);
-
-    vo_dx = 0;
-    vo_dy = 0;
-    vo_dx = (vo_screenwidth - d_width) / 2;
-    vo_dy = (vo_screenheight - d_height) / 2;
-    geometry(&vo_dx, &vo_dy, &d_width, &d_height, vo_screenwidth,
-             vo_screenheight);
     window_width = d_width;
     window_height = d_height;
 
@@ -288,11 +276,6 @@
     }
     mp_msg(MSGT_VO, MSGL_V, "Using colorkey: %x\n", colorkey);
 
-    aspect(&d_width, &d_height, A_NOZOOM);
-
-    vo_dwidth = d_width;
-    vo_dheight = d_height;
-
 #ifdef HAVE_NEW_GUI
     if (use_gui)
         guiGetEvent(guiSetShVideo, 0);  // the GUI will set up / resize the window
@@ -556,6 +539,10 @@
 
                 return vidix_control(request, data, value);
             }
+        case VOCTRL_UPDATE_SCREENINFO:
+            aspect_save_screenres(vo_screenwidth, vo_screenheight);
+            return VO_TRUE;
+
     }
     return vidix_control(request, data);
 //  return VO_NOTIMPL;
Index: libvo/video_out.c
===================================================================
--- libvo/video_out.c	(revision 22221)
+++ libvo/video_out.c	(working copy)
@@ -11,6 +11,8 @@
 
 #include "config.h"
 #include "video_out.h"
+#include "aspect.h"
+#include "geometry.h"
 
 #include "mp_msg.h"
 #include "help_mp.h"
@@ -322,7 +330,27 @@
     return NULL;
 }
 
+int config_video_out(vo_functions_t *vo, uint32_t width, uint32_t height,
+                     uint32_t d_width, uint32_t d_height, uint32_t flags,
+                     char *title, uint32_t format) {
+  panscan_init();
+  aspect_save_orig(width,height);
+  aspect_save_prescale(d_width,d_height);
+  vo->control(VOCTRL_UPDATE_SCREENINFO, NULL);
 
+  aspect(&d_width,&d_height,A_NOZOOM);
+  vo_dx = (int)(vo_screenwidth - d_width) / 2;
+  vo_dy = (int)(vo_screenheight - d_height) / 2;
+  geometry(&vo_dx, &vo_dy, &d_width, &d_height,
+           vo_screenwidth, vo_screenheight);
+  vo_dx += xinerama_x;
+  vo_dy += xinerama_y;
+  vo_dwidth = d_width;
+  vo_dheight = d_height;
+
+  return vo->config(width, height, d_width, d_height, flags, title, format);
+}
+
 #if defined(HAVE_FBDEV)||defined(HAVE_VESA)  
 /* Borrowed from vo_fbdev.c 
 Monitor ranges related functions*/
Index: libvo/video_out.h
===================================================================
--- libvo/video_out.h	(revision 22221)
+++ libvo/video_out.h	(working copy)
@@ -68,6 +68,8 @@
 #define VOCTRL_SET_DEINTERLACE 30
 #define VOCTRL_GET_DEINTERLACE 31
 
+#define VOCTRL_UPDATE_SCREENINFO 32
+
 // Vo can be used by xover
 #define VOCTRL_XOVERLAY_SUPPORT 22
 
@@ -179,6 +182,9 @@
 int vo_init(void);
 
 vo_functions_t* init_best_video_out(char** vo_list);
+int config_video_out(vo_functions_t *vo, uint32_t width, uint32_t height,
+                     uint32_t d_width, uint32_t d_height, uint32_t flags,
+                     char *title, uint32_t format);
 void list_video_out(void);
 
 // NULL terminated array of all drivers
Index: libvo/vo_xvmc.c
===================================================================
--- libvo/vo_xvmc.c	(revision 22221)
+++ libvo/vo_xvmc.c	(working copy)
@@ -601,24 +601,11 @@
    vo_xv_enable_vsync();//it won't break anything
 
 //taken from vo_xv
-   panscan_init();
-
-   aspect_save_orig(width,height);
-   aspect_save_prescale(d_width,d_height);
-
    image_height = height;
    image_width = width;
 
    vo_mouse_autohide = 1;
 
-   update_xinerama_info();
-   aspect(&d_width,&d_height,A_NOZOOM);
-   vo_dx=( vo_screenwidth - d_width ) / 2; vo_dy=( vo_screenheight - d_height ) / 2;
-   geometry(&vo_dx, &vo_dy, &d_width, &d_height, vo_screenwidth, vo_screenheight);
-   vo_dx += xinerama_x;
-   vo_dy += xinerama_y;
-   vo_dwidth=d_width; vo_dheight=d_height;
-
 #ifdef HAVE_XF86VM
    if( flags&VOFLAG_MODESWITCHING ) vm = 1;
 #endif
@@ -1442,6 +1429,9 @@
 
          return(vo_xv_get_eq(xv_port, data, value));
       }
+      case VOCTRL_UPDATE_SCREENINFO:
+         update_xinerama_info();
+         return VO_TRUE;
    }
 return VO_NOTIMPL;
 }
Index: libvo/vo_xv.c
===================================================================
--- libvo/vo_xv.c	(revision 22221)
+++ libvo/vo_xv.c	(working copy)
@@ -168,11 +168,6 @@
     static uint32_t vm_height;
 #endif
 
-    panscan_init();
-
-    aspect_save_orig(width, height);
-    aspect_save_prescale(d_width, d_height);
-
     image_height = height;
     image_width = width;
     image_format = format;
@@ -190,17 +185,6 @@
     int_pause = 0;
     visible_buf = -1;
 
-    update_xinerama_info();
-    aspect(&d_width, &d_height, A_NOZOOM);
-    vo_dx = (vo_screenwidth - d_width) / 2;
-    vo_dy = (vo_screenheight - d_height) / 2;
-    geometry(&vo_dx, &vo_dy, &d_width, &d_height, vo_screenwidth,
-             vo_screenheight);
-    vo_dx += xinerama_x;
-    vo_dy += xinerama_y;
-    vo_dwidth = d_width;
-    vo_dheight = d_height;
-
 #ifdef HAVE_XF86VM
     if (flags & VOFLAG_MODESWITCHING)
         vm = 1;
@@ -1004,6 +988,9 @@
         case VOCTRL_ONTOP:
             vo_x11_ontop();
             return VO_TRUE;
+        case VOCTRL_UPDATE_SCREENINFO:
+            update_xinerama_info();
+            return VO_TRUE;
     }
     return VO_NOTIMPL;
 }
Index: libvo/vo_gl.c
===================================================================
--- libvo/vo_gl.c	(revision 22221)
+++ libvo/vo_gl.c	(working copy)
@@ -451,23 +451,9 @@
   int_pause = 0;
   vo_flipped = !!(flags & VOFLAG_FLIPPING);
 
-  panscan_init();
-  aspect_save_orig(width,height);
-  aspect_save_prescale(d_width,d_height);
-  update_xinerama_info();
-
-  aspect(&d_width,&d_height,A_NOZOOM);
-  vo_dx = (int)(vo_screenwidth - d_width) / 2;
-  vo_dy = (int)(vo_screenheight - d_height) / 2;
-  geometry(&vo_dx, &vo_dy, &d_width, &d_height,
-           vo_screenwidth, vo_screenheight);
-  vo_dx += xinerama_x;
-  vo_dy += xinerama_y;
 #ifdef HAVE_NEW_GUI
   if (use_gui) {
     // GUI creates and manages window for us
-    vo_dwidth = d_width;
-    vo_dheight= d_height;
     guiGetEvent(guiSetShVideo, 0);
 #ifndef GL_WIN32
     goto glconfig;
@@ -1066,6 +1052,9 @@
       return VO_TRUE;
     }
     break;
+  case VOCTRL_UPDATE_SCREENINFO:
+    update_xinerama_info();
+    return VO_TRUE;
   }
   return VO_NOTIMPL;
 }
Index: libvo/vo_x11.c
===================================================================
--- libvo/vo_x11.c	(revision 22221)
+++ libvo/vo_x11.c	(working copy)
@@ -336,15 +336,6 @@
     in_format = format;
     srcW = width;
     srcH = height;
-    update_xinerama_info();
-    vo_dx = (vo_screenwidth - d_width) / 2;
-    vo_dy = (vo_screenheight - d_height) / 2;
-    geometry(&vo_dx, &vo_dy, &d_width, &d_height, vo_screenwidth,
-             vo_screenheight);
-    vo_dx += xinerama_x;
-    vo_dy += xinerama_y;
-    vo_dwidth = d_width;
-    vo_dheight = d_height;
 
     if (flags & (VOFLAG_FULLSCREEN|VOFLAG_MODESWITCHING))
         fullscreen = 1;
@@ -834,6 +825,9 @@
                 vo_x11_clearwindow(mDisplay, vo_window);
             }
             return VO_TRUE;
+        case VOCTRL_UPDATE_SCREENINFO:
+            update_xinerama_info();
+            return VO_TRUE;
     }
     return VO_NOTIMPL;
 }
Index: libvo/vo_gl2.c
===================================================================
--- libvo/vo_gl2.c	(revision 22221)
+++ libvo/vo_gl2.c	(working copy)
@@ -738,8 +738,6 @@
 
 #ifdef HAVE_NEW_GUI
 static int config_glx_gui(uint32_t d_width, uint32_t d_height) {
-  vo_dwidth = d_width;
-  vo_dheight = d_height;
   guiGetEvent( guiSetShVideo,0 ); // the GUI will set up / resize the window
   return 0;
 }
@@ -810,19 +808,6 @@
 
 	int_pause = 0;
   
-	panscan_init();
-	aspect_save_orig(width,height);
-	aspect_save_prescale(d_width,d_height);
-	update_xinerama_info();
-
-	aspect(&d_width,&d_height,A_NOZOOM);
-	vo_dx = (int)(vo_screenwidth - d_width) / 2;
-	vo_dy = (int)(vo_screenheight - d_height) / 2;
-	geometry(&vo_dx, &vo_dy, &d_width, &d_height,
-	          vo_screenwidth, vo_screenheight);
-	vo_dx += xinerama_x;
-	vo_dy += xinerama_y;
-
 #ifdef HAVE_NEW_GUI
 	if (use_gui) {
 	  if (config_glx_gui(d_width, d_height) == -1)
@@ -1142,6 +1127,9 @@
       return vo_x11_get_equalizer(data, value);
     }
 #endif
+  case VOCTRL_UPDATE_SCREENINFO:
+    update_xinerama_info();
+    return VO_TRUE;
   }
   return VO_NOTIMPL;
 }
Index: mencoder.c
===================================================================
--- mencoder.c	(revision 22221)
+++ mencoder.c	(working copy)
@@ -214,6 +216,12 @@
 char *info_sourceform=NULL;
 char *info_comment=NULL;
 
+// Needed by libmpcodecs vf_vo.c
+int config_video_out(vo_functions_t *vo, uint32_t width, uint32_t height,
+                     uint32_t d_width, uint32_t d_height, uint32_t flags,
+                     char *title, uint32_t format) {
+  return 1;
+}
 // Needed by libmpdemux.
 int mp_input_check_interrupt(int time) {
   usec_sleep(time);


More information about the MPlayer-dev-eng mailing list