changeset 22232:d0b60d14d8d7

Move common vo initialization code to video_out.c
author reimar
date Sat, 17 Feb 2007 20:58:55 +0000
parents da19b4ccb83a
children 5bf6c178f09a
files libmpcodecs/vf_vo.c libvo/video_out.c libvo/video_out.h libvo/vo_gl.c libvo/vo_gl2.c libvo/vo_x11.c libvo/vo_xv.c libvo/vo_xvidix.c libvo/vo_xvmc.c mencoder.c
diffstat 10 files changed, 53 insertions(+), 85 deletions(-) [+]
line wrap: on
line diff
--- a/libmpcodecs/vf_vo.c	Sat Feb 17 17:24:07 2007 +0000
+++ b/libmpcodecs/vf_vo.c	Sat Feb 17 20:58:55 2007 +0000
@@ -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
--- a/libvo/video_out.c	Sat Feb 17 17:24:07 2007 +0000
+++ b/libvo/video_out.c	Sat Feb 17 20:58:55 2007 +0000
@@ -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,6 +324,26 @@
     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 
--- a/libvo/video_out.h	Sat Feb 17 17:24:07 2007 +0000
+++ b/libvo/video_out.h	Sat Feb 17 20:58:55 2007 +0000
@@ -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 +181,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
--- a/libvo/vo_gl.c	Sat Feb 17 17:24:07 2007 +0000
+++ b/libvo/vo_gl.c	Sat Feb 17 20:58:55 2007 +0000
@@ -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;
 }
--- a/libvo/vo_gl2.c	Sat Feb 17 17:24:07 2007 +0000
+++ b/libvo/vo_gl2.c	Sat Feb 17 20:58:55 2007 +0000
@@ -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;
 }
--- a/libvo/vo_x11.c	Sat Feb 17 17:24:07 2007 +0000
+++ b/libvo/vo_x11.c	Sat Feb 17 20:58:55 2007 +0000
@@ -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;
 }
--- a/libvo/vo_xv.c	Sat Feb 17 17:24:07 2007 +0000
+++ b/libvo/vo_xv.c	Sat Feb 17 20:58:55 2007 +0000
@@ -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;
 }
--- a/libvo/vo_xvidix.c	Sat Feb 17 17:24:07 2007 +0000
+++ b/libvo/vo_xvidix.c	Sat Feb 17 20:58:55 2007 +0000
@@ -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;
--- a/libvo/vo_xvmc.c	Sat Feb 17 17:24:07 2007 +0000
+++ b/libvo/vo_xvmc.c	Sat Feb 17 20:58:55 2007 +0000
@@ -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;
 }
--- a/mencoder.c	Sat Feb 17 17:24:07 2007 +0000
+++ b/mencoder.c	Sat Feb 17 20:58:55 2007 +0000
@@ -214,6 +214,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);