diff options
author | 2002-05-03 13:12:46 +0000 | |
---|---|---|
committer | 2002-05-03 13:12:46 +0000 | |
commit | 5e1d8aafed1cf7c3d67345a7be1a1c06c53ade77 (patch) | |
tree | 174a26e12102e92046dc376f211fdf80b6cf8ca9 /libvo | |
parent | 5568a8133ad5cdb906bb2baef065fd605fe395ee (diff) |
fix aspect ratio handling
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@5946 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libvo')
-rw-r--r-- | libvo/vo_x11.c | 58 | ||||
-rw-r--r-- | libvo/vo_xmga.c | 19 | ||||
-rw-r--r-- | libvo/vo_xv.c | 54 |
3 files changed, 33 insertions, 98 deletions
diff --git a/libvo/vo_x11.c b/libvo/vo_x11.c index d5b8bc5434..078578258f 100644 --- a/libvo/vo_x11.c +++ b/libvo/vo_x11.c @@ -250,6 +250,7 @@ static uint32_t config( uint32_t width,uint32_t height,uint32_t d_width,uint32_t if(in_format==IMGFMT_I420 || in_format==IMGFMT_IYUV) in_format=IMGFMT_YV12; srcW= width; srcH= height; + vo_dwidth=width; vo_dheight=height; if( flags&0x03 ) fullscreen = 1; if( flags&0x02 ) vm = 1; @@ -622,14 +623,6 @@ static uint32_t preinit(const char *arg) return 0; } -#if 0 -/* for runtime fullscreen switching */ -static int vo_fs_oldx = -1; -static int vo_fs_oldy = -1; -static int vo_fs_oldwidth = -1; -static int vo_fs_oldheight = -1; -#endif - static uint32_t control(uint32_t request, void *data, ...) { switch (request) { @@ -641,55 +634,6 @@ static uint32_t control(uint32_t request, void *data, ...) return get_image(data); case VOCTRL_FULLSCREEN: vo_x11_fullscreen(); -/* - if ((vo_fs_oldwidth == -1) && (vo_fs_oldheight == -1)) - { - int foo; - Window root; - -#ifdef LOCAL_LOOKUP - XGetGeometry(mDisplay, vo_window, &root, &foo, &foo, - &vo_fs_oldwidth, &vo_fs_oldheight, &foo, &foo); - - XTranslateCoordinates(mDisplay, vo_window, root, 0, 0, - &vo_fs_oldx, &vo_fs_oldy,(Window *) &foo); -#else - vo_fs_oldwidth = vo_dwidth; - vo_fs_oldheight = vo_dheight; - vo_fs_oldx = vo_dx; - vo_fs_oldy = vo_dy; -#endif - - mp_msg(MSGT_VO,MSGL_V,"X11 Fullscreen: saved old place: %dx%d-%dx%d\n", - vo_fs_oldx, vo_fs_oldy, vo_fs_oldwidth, vo_fs_oldheight); - - // resize - vo_dwidth = vo_screenwidth; - vo_dheight = vo_screenheight; - vo_x11_decoration( mDisplay,vo_window,0 ); - XMoveResizeWindow(mDisplay, vo_window, 0, 0, - vo_screenwidth, vo_screenheight); - XSync(mDisplay, False); - } - else - { - vo_x11_decoration( mDisplay,vo_window,1 ); - XMoveResizeWindow(mDisplay, vo_window, vo_fs_oldx, vo_fs_oldy, - vo_fs_oldwidth, vo_fs_oldheight); - - -#ifdef LOCAL_LOOKUP - // restore - vo_dwidth = vo_fs_oldwidth; - vo_dheight = vo_fs_oldheight; -#endif - - // clean - vo_fs_oldwidth = -1; - vo_fs_oldheight = -1; - XSync(mDisplay, False); - } -*/ return VO_TRUE; } return VO_NOTIMPL; diff --git a/libvo/vo_xmga.c b/libvo/vo_xmga.c index bac450a198..d22f16a053 100644 --- a/libvo/vo_xmga.c +++ b/libvo/vo_xmga.c @@ -76,8 +76,6 @@ static uint32_t mDepth, bpp, mode; static XWindowAttributes attribs; static uint32_t X_already_started=0; -static uint32_t wndHeight; -static uint32_t wndWidth; static uint32_t wndX; static uint32_t wndY; @@ -109,7 +107,7 @@ static void set_window(){ XGetGeometry( mDisplay,vo_window,&mRoot,&drwX,&drwY,&drwWidth,&drwHeight,&drwBorderWidth,&drwDepth ); fprintf( stderr,"[xmga] x: %d y: %d w: %d h: %d\n",drwX,drwY,drwWidth,drwHeight ); - drwX=0; drwY=0; // drwWidth=wndWidth; drwHeight=wndHeight; + drwX=0; drwY=0; XTranslateCoordinates( mDisplay,vo_window,mRoot,0,0,&drwcX,&drwcY,&mRoot ); fprintf( stderr,"[xmga] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight ); @@ -164,8 +162,8 @@ static void check_events(void) { int e=vo_x11_check_events(mDisplay); if ( !(e&VO_EVENT_RESIZE) && !(e&VO_EVENT_EXPOSE) ) return; - if(e&VO_EVENT_EXPOSE) mDrawColorKey(); set_window(); + if(e&VO_EVENT_EXPOSE) mDrawColorKey(); if ( ioctl( f,MGA_VID_CONFIG,&mga_vid_config ) ) printf( "Error in mga_vid_config ioctl (wrong mga_vid.o version?)" ); } @@ -239,7 +237,6 @@ static uint32_t config( uint32_t width, uint32_t height, uint32_t d_width, uint3 mvWidth=width; mvHeight=height; wndX=0; wndY=0; - wndWidth=d_width; wndHeight=d_height; vo_fs=fullscreen&1; vo_dwidth=d_width; vo_dheight=d_height; if ( vo_fs ) @@ -256,20 +253,20 @@ static uint32_t config( uint32_t width, uint32_t height, uint32_t d_width, uint3 inited=1; - aspect(&d_width,&d_height,A_NOZOOM); + aspect(&vo_dwidth,&vo_dheight,A_NOZOOM); #ifdef HAVE_NEW_GUI if ( vo_window == None ) { #endif if ( vo_fs ) { - wndWidth=vo_screenwidth; - wndHeight=vo_screenheight; + vo_dwidth=vo_screenwidth; + vo_dheight=vo_screenheight; #ifdef X11_FULLSCREEN - aspect(&d_width,&d_height,A_ZOOM); + aspect(&vo_dwidth,&vo_dheight,A_ZOOM); #endif } - dwidth=d_width; dheight=d_height; + dwidth=vo_dwidth; dheight=vo_dheight; XGetWindowAttributes( mDisplay,DefaultRootWindow( mDisplay ),&attribs ); mDepth=attribs.depth; @@ -289,7 +286,7 @@ static uint32_t config( uint32_t width, uint32_t height, uint32_t d_width, uint3 } else vo_window=XCreateWindow( mDisplay,RootWindow( mDisplay,mScreen ), wndX,wndY, - wndWidth,wndHeight, + vo_dwidth,vo_dheight, xWAttribs.border_pixel, mDepth, InputOutput, diff --git a/libvo/vo_xv.c b/libvo/vo_xv.c index cc7729b6cb..de15f6331c 100644 --- a/libvo/vo_xv.c +++ b/libvo/vo_xv.c @@ -91,8 +91,8 @@ static uint32_t image_format; 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 @@ static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, uint32 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 @@ static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, uint32 #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 @@ static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, uint32 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 @@ static void check_events(void) 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 @@ static void check_events(void) 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 @@ static void flip_page(void) { 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; |