[MPlayer-dev-eng] [PATCH] Pan&Scan for Xvideo (again :)

mplayer at svennevid.net mplayer at svennevid.net
Sun Jun 2 14:01:21 CEST 2002


This patch adds Pan&Scan-support to the Xvideo-driver,
by scaling the output-overlay to cover up the black
borders. I made it for my own use, but thought I could
share it with the rest aswell. Enjoy!

And this time I'll also remember to attach the patch
itself, sorry. :D

Control it by the command-line parameter 'panscan',
by passing it a value between 0.0 and 1.0, where 0.0
is full borders, and 1.0 is no borders at all. It's
also possible to change this value at run-time through
the keys 'w' and 'e'.
-------------- next part --------------
? main/main
Index: main/cfg-mplayer.h
===================================================================
RCS file: /cvsroot/mplayer/main/cfg-mplayer.h,v
retrieving revision 1.152
diff -u -r1.152 cfg-mplayer.h
--- main/cfg-mplayer.h	27 May 2002 17:30:46 -0000	1.152
+++ main/cfg-mplayer.h	2 Jun 2002 11:39:17 -0000
@@ -57,6 +57,7 @@
 extern int vo_gamma_blue_intensity;
 extern int vo_directrendering;
 extern int vd_use_slices;
+extern float vo_panscan;
 
 #ifdef USE_OSD
 extern int osd_level;
@@ -237,6 +238,7 @@
 	// wait for v-sync (vesa)
 	{"vsync", &vo_vsync, CONF_TYPE_FLAG, 0, 0, 1, NULL},
 	{"novsync", &vo_vsync, CONF_TYPE_FLAG, 0, 1, 0, NULL},
+	{"panscan", &vo_panscan, CONF_TYPE_FLOAT, CONF_RANGE, 0.0, 1.0, NULL},
 
 #ifdef HAVE_X11
 	// x11,xv,xmga,xvidix
Index: main/mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.511
diff -u -r1.511 mplayer.c
--- main/mplayer.c	28 May 2002 11:55:00 -0000	1.511
+++ main/mplayer.c	2 Jun 2002 11:39:18 -0000
@@ -2542,6 +2542,24 @@
 #endif
 	if(video_out && vo_config_count) video_out->control(VOCTRL_FULLSCREEN, 0);
     } break;
+    case MP_CMD_PANSCAN : {
+      int abs= cmd->args[1].v.i;
+      float v = cmd->args[0].v.f;
+      float res;
+      if(abs)
+	res = v;
+      else
+	res = vo_panscan+v;
+      vo_panscan = res > 1 ? 1 : res < 0 ? 0 : res;
+#ifdef USE_OSD
+      if(osd_level){
+	osd_visible=sh_video->fps; // 1 sec
+	vo_osd_progbar_type=OSD_PANSCAN;
+	vo_osd_progbar_value=vo_panscan*256;
+	vo_osd_changed(OSDTYPE_PROGBAR);
+      }
+#endif
+    } break;
     case MP_CMD_SUB_POS:
     {
         int v;
Index: main/input/input.c
===================================================================
RCS file: /cvsroot/mplayer/main/input/input.c,v
retrieving revision 1.34
diff -u -r1.34 input.c
--- main/input/input.c	25 May 2002 09:46:37 -0000	1.34
+++ main/input/input.c	2 Jun 2002 11:39:19 -0000
@@ -65,6 +65,7 @@
 #endif
   { MP_CMD_VO_FULLSCREEN, "vo_fullscreen", 0, { {-1,{0}} } },
   { MP_CMD_SCREENSHOT, "screenshot", 0, { {-1,{0}} } },
+  { MP_CMD_PANSCAN, "panscan",1,  { {MP_CMD_ARG_FLOAT,{0}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}} } },
 
 #ifdef HAVE_NEW_GUI  
   { MP_CMD_GUI_LOADFILE, "gui_loadfile", 0, { {-1,{0}} } },
@@ -243,6 +244,8 @@
 #endif
   { { 'f', 0 }, "vo_fullscreen" },
   { { 's', 0 }, "screenshot" },
+  { { 'w', 0 }, "panscan -0.1" },
+  { { 'e', 0 }, "panscan +0.1" },
   { { 0 }, NULL }
 };
 
Index: main/input/input.h
===================================================================
RCS file: /cvsroot/mplayer/main/input/input.h,v
retrieving revision 1.12
diff -u -r1.12 input.h
--- main/input/input.h	18 May 2002 00:11:43 -0000	1.12
+++ main/input/input.h	2 Jun 2002 11:39:19 -0000
@@ -26,6 +26,7 @@
 #define MP_CMD_SUB_POS 21
 #define MP_CMD_DVDNAV 22
 #define MP_CMD_SCREENSHOT 23
+#define MP_CMD_PANSCAN 24
 
 #define MP_CMD_GUI_EVENTS       5000
 #define MP_CMD_GUI_LOADFILE     5001
Index: main/libvo/sub.h
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/sub.h,v
retrieving revision 1.18
diff -u -r1.18 sub.h
--- main/libvo/sub.h	17 May 2002 23:47:27 -0000	1.18
+++ main/libvo/sub.h	2 Jun 2002 11:39:19 -0000
@@ -74,6 +74,7 @@
 #define OSD_VOLUME 0x09
 #define OSD_BRIGHTNESS 0x0A
 #define OSD_HUE 0x0B
+#define OSD_PANSCAN 0x50
 
 #define OSD_PB_START 0x10
 #define OSD_PB_0 0x11
Index: main/libvo/video_out.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/video_out.c,v
retrieving revision 1.51
diff -u -r1.51 video_out.c
--- main/libvo/video_out.c	13 May 2002 13:15:40 -0000	1.51
+++ main/libvo/video_out.c	2 Jun 2002 11:39:19 -0000
@@ -56,6 +56,7 @@
 int vo_vsync = 0;
 int vo_fs = 0;
 int vo_fsmode = 0;
+float vo_panscan = 0.0f;
 
 int vo_pts=0; // for hw decoding
 float vo_fps=0; // for mp1e rte
Index: main/libvo/video_out.h
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/video_out.h,v
retrieving revision 1.33
diff -u -r1.33 video_out.h
--- main/libvo/video_out.h	17 May 2002 23:47:27 -0000	1.33
+++ main/libvo/video_out.h	2 Jun 2002 11:39:19 -0000
@@ -216,6 +216,7 @@
 extern int vo_vsync;
 extern int vo_fs;
 extern int vo_fsmode;
+extern float vo_panscan;
 
 extern int vo_mouse_timer_const;
 
Index: main/libvo/vo_xv.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_xv.c,v
retrieving revision 1.91
diff -u -r1.91 vo_xv.c
--- main/libvo/vo_xv.c	31 May 2002 21:51:20 -0000	1.91
+++ main/libvo/vo_xv.c	2 Jun 2002 11:39:20 -0000
@@ -94,6 +94,10 @@
 static uint32_t image_format;
 static int flip_flag;
 
+static int panscan_x;
+static int panscan_y;
+static float panscan_amount;
+
 static Window                 mRoot;
 static uint32_t               drwX,drwY,drwBorderWidth,drwDepth;
 static uint32_t               dwidth,dheight;
@@ -327,6 +331,10 @@
  static uint32_t vm_height;
 #endif
 
+ panscan_x = 0;
+ panscan_y = 0;
+ panscan_amount = 0.0f;
+
  aspect_save_orig(width,height);
  aspect_save_prescale(d_width,d_height);
 
@@ -589,18 +597,31 @@
 
 static void flip_page(void)
 {
+ if((vo_fs && (vo_panscan != panscan_amount)) || (!vo_fs && panscan_amount))
+  {
+   int panscan_area = (vo_screenheight-vo_dheight);
+
+   panscan_amount = vo_fs ? vo_panscan : 0;
+
+   panscan_x = panscan_area * panscan_amount * (image_width / (float)image_height);
+   panscan_y = panscan_area * panscan_amount;
+
+   XClearWindow(mDisplay, vo_window);
+   XFlush(mDisplay);
+  }
+
  if ( Shmem_Flag )
   {
    XvShmPutImage(mDisplay, xv_port, vo_window, vo_gc, xvimage[current_buf],
          0, 0,  image_width, image_height,
-         drwX,drwY,vo_dwidth,(vo_fs?vo_dheight - 1:vo_dheight),
+         drwX-(panscan_x>>1),drwY-(panscan_y>>1),vo_dwidth+panscan_x,(vo_fs?vo_dheight - 1:vo_dheight)+panscan_y,
          False);
   }
  else
   {
    XvPutImage(mDisplay, xv_port, vo_window, vo_gc, xvimage[current_buf],
          0, 0,  image_width, image_height,
-         drwX,drwY,vo_dwidth,(vo_fs?vo_dheight - 1:vo_dheight));
+         drwX-(panscan_x>>1),drwY-(panscan_y>>1),vo_dwidth+panscan_x,(vo_fs?vo_dheight - 1:vo_dheight)+panscan_y);
   }
  if (num_buffers>1){
     current_buf=(current_buf+1)%num_buffers;


More information about the MPlayer-dev-eng mailing list