diff libvo/vo_xv.c @ 5945:f9fe22a52e80

fix aspect ratio handling
author pontscho
date Fri, 03 May 2002 13:12:46 +0000
parents 5074aa8fae5a
children caac20b1ca79
line wrap: on
line diff
--- a/libvo/vo_xv.c	Fri May 03 12:56:29 2002 +0000
+++ b/libvo/vo_xv.c	Fri May 03 13:12:46 2002 +0000
@@ -91,8 +91,8 @@
 static int flip_flag;
 
 static Window                 mRoot;
-static uint32_t               drwX,drwY,drwWidth,drwHeight,drwBorderWidth,drwDepth;
-static uint32_t               drwcX,drwcY,dwidth,dheight;
+static uint32_t               drwX,drwY,drwBorderWidth,drwDepth;
+static uint32_t               dwidth,dheight;
 
 static void (*draw_alpha_fnc)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride);
 
@@ -331,6 +331,7 @@
  image_width = width;
  image_format=format;
 
+ vo_dwidth=d_width; vo_dheight=d_height;
  vo_fs=flags&1;
  if ( vo_fs )
   { vo_old_width=d_width; vo_old_height=d_height; }
@@ -393,7 +394,8 @@
 #endif
 
     }
-   dwidth=d_width; dheight=d_height; //XXX: what are the copy vars used for?
+//   dwidth=d_width; dheight=d_height; //XXX: what are the copy vars used for?
+   vo_dwidth=d_width; vo_dheight=d_height;
    hint.flags = PPosition | PSize;
    XGetWindowAttributes(mDisplay, DefaultRootWindow(mDisplay), &attribs);
    depth=attribs.depth;
@@ -466,23 +468,19 @@
 
      set_gamma_correction();
 
-     XGetGeometry( mDisplay,vo_window,&mRoot,&drwX,&drwY,&drwWidth,&drwHeight,&drwBorderWidth,&drwDepth );
-     drwX=0; drwY=0;
-     XTranslateCoordinates( mDisplay,vo_window,mRoot,0,0,&drwcX,&drwcY,&mRoot );
-     mp_msg(MSGT_VO,MSGL_V, "[xv] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight );
-
-     aspect(&dwidth,&dheight,A_NOZOOM);
+     aspect(&vo_dwidth,&vo_dheight,A_NOZOOM);
      if ( vo_fs )
       {
-       aspect(&dwidth,&dheight,A_ZOOM);
-       drwX=( vo_screenwidth - (dwidth > vo_screenwidth?vo_screenwidth:dwidth) ) / 2;
-       drwcX+=drwX;
-       drwY=( vo_screenheight - (dheight > vo_screenheight?vo_screenheight:dheight) ) / 2;
-       drwcY+=drwY;
-       drwWidth=(dwidth > vo_screenwidth?vo_screenwidth:dwidth);
-       drwHeight=(dheight > vo_screenheight?vo_screenheight:dheight);
-       mp_msg(MSGT_VO,MSGL_V, "[xv-fs] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight );
+       aspect(&vo_dwidth,&vo_dheight,A_ZOOM);
+       drwX=( vo_screenwidth - (vo_dwidth > vo_screenwidth?vo_screenwidth:vo_dwidth) ) / 2;
+       drwY=( vo_screenheight - (vo_dheight > vo_screenheight?vo_screenheight:vo_dheight) ) / 2;
+       vo_dwidth=(vo_dwidth > vo_screenwidth?vo_screenwidth:vo_dwidth);
+       vo_dheight=(vo_dheight > vo_screenheight?vo_screenheight:vo_dheight);
+       mp_msg(MSGT_VO,MSGL_V, "[xv-fs] dx: %d dy: %d dw: %d dh: %d\n",drwX,drwY,vo_dwidth,vo_dheight );
       }
+
+     mp_msg(MSGT_VO,MSGL_V, "[xv] dx: %d dy: %d dw: %d dh: %d\n",drwX,drwY,vo_dwidth,vo_dheight );
+
      saver_off(mDisplay);  // turning off screen saver
      return 0;
 }
@@ -548,22 +546,18 @@
  int e=vo_x11_check_events(mDisplay);
  if(e&VO_EVENT_RESIZE)
   {
-   XGetGeometry( mDisplay,vo_window,&mRoot,&drwX,&drwY,&drwWidth,&drwHeight,&drwBorderWidth,&drwDepth );
-   drwX=0; drwY=0;
-   XTranslateCoordinates( mDisplay,vo_window,mRoot,0,0,&drwcX,&drwcY,&mRoot );
-   mp_msg(MSGT_VO,MSGL_V, "[xv] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight );
+   XGetGeometry( mDisplay,vo_window,&mRoot,&drwX,&drwY,&vo_dwidth,&vo_dheight,&drwBorderWidth,&drwDepth );
+   mp_msg(MSGT_VO,MSGL_V, "[xv] dx: %d dy: %d dw: %d dh: %d\n",drwX,drwY,vo_dwidth,vo_dheight );
 
    aspect(&dwidth,&dheight,A_NOZOOM);
    if ( vo_fs )
     {
      aspect(&dwidth,&dheight,A_ZOOM);
      drwX=( vo_screenwidth - (dwidth > vo_screenwidth?vo_screenwidth:dwidth) ) / 2;
-     drwcX+=drwX;
      drwY=( vo_screenheight - (dheight > vo_screenheight?vo_screenheight:dheight) ) / 2;
-     drwcY+=drwY;
-     drwWidth=(dwidth > vo_screenwidth?vo_screenwidth:dwidth);
-     drwHeight=(dheight > vo_screenheight?vo_screenheight:dheight);
-     mp_msg(MSGT_VO,MSGL_V, "[xv-fs] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight );
+     vo_dwidth=(dwidth > vo_screenwidth?vo_screenwidth:dwidth);
+     vo_dheight=(dheight > vo_screenheight?vo_screenheight:dheight);
+     mp_msg(MSGT_VO,MSGL_V, "[xv-fs] dx: %d dy: %d dw: %d dh: %d\n",drwX,drwY,vo_dwidth,vo_dheight );
     }
   }
  if ( e & VO_EVENT_EXPOSE )
@@ -571,12 +565,12 @@
    if ( Shmem_Flag )
     {
      XvShmPutImage(mDisplay, xv_port, vo_window, vo_gc, xvimage[current_buf], 0, 0,  image_width, image_height, drwX, drwY, 1, 1, False);
-     XvShmPutImage(mDisplay, xv_port, vo_window, vo_gc, xvimage[current_buf], 0, 0,  image_width, image_height, drwX,drwY,drwWidth,(vo_fs?drwHeight - 1:drwHeight), False);
+     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), False);
     }
    else
     {
      XvPutImage(mDisplay, xv_port, vo_window, vo_gc, xvimage[current_buf], 0, 0,  image_width, image_height, drwX, drwY, 1, 1);
-     XvPutImage(mDisplay, xv_port, vo_window, vo_gc, xvimage[current_buf], 0, 0,  image_width, image_height, drwX,drwY,drwWidth,(vo_fs?drwHeight - 1:drwHeight));
+     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));
     }
   }
 }
@@ -590,14 +584,14 @@
   {
    XvShmPutImage(mDisplay, xv_port, vo_window, vo_gc, xvimage[current_buf],
          0, 0,  image_width, image_height,
-         drwX,drwY,drwWidth,(vo_fs?drwHeight - 1:drwHeight),
+         drwX,drwY,vo_dwidth,(vo_fs?vo_dheight - 1:vo_dheight),
          False);
   }
  else
   {
    XvPutImage(mDisplay, xv_port, vo_window, vo_gc, xvimage[current_buf],
          0, 0,  image_width, image_height,
-         drwX,drwY,drwWidth,(vo_fs?drwHeight - 1:drwHeight));
+         drwX,drwY,vo_dwidth,(vo_fs?vo_dheight - 1:vo_dheight));
   }
  if (num_buffers>1){
     current_buf=(current_buf+1)%num_buffers;