Mercurial > mplayer.hg
changeset 6307:72c87b2ec779
added panscan support for xmga/xvidix
author | pontscho |
---|---|
date | Wed, 05 Jun 2002 19:35:54 +0000 |
parents | 786ab42c10be |
children | 4764574062a0 |
files | libvo/aspect.c libvo/aspect.h libvo/mga_common.c libvo/video_out.h libvo/vo_xmga.c libvo/vo_xv.c libvo/vo_xvidix.c mplayer.c |
diffstat | 8 files changed, 127 insertions(+), 45 deletions(-) [+] |
line wrap: on
line diff
--- a/libvo/aspect.c Wed Jun 05 02:24:35 2002 +0000 +++ b/libvo/aspect.c Wed Jun 05 19:35:54 2002 +0000 @@ -10,6 +10,12 @@ #include <stdio.h> #endif +int vo_panscan_x = 0; +int vo_panscan_y = 0; +float vo_panscan_amount = 0; + +#include "video_out.h" + float monitor_aspect=4.0/3.0; static struct { @@ -19,6 +25,7 @@ int preh; // prescaled height int scrw; // horizontal resolution int scrh; // vertical resolution + float asp; } aspdat; void aspect_save_orig(int orgw, int orgh){ @@ -79,8 +86,24 @@ #endif } } + aspdat.asp=*srcw / (float)*srch; #ifdef ASPECT_DEBUG printf("aspect(3) wh: %dx%d (org: %dx%d)\n",*srcw,*srch,aspdat.prew,aspdat.preh); #endif } +void panscan_init( void ) +{ + vo_panscan_x=0; + vo_panscan_y=0; + vo_panscan_amount=0.0f; +} + +void panscan_calc( void ) +{ + int vo_panscan_area = (vo_screenheight-vo_dheight); + vo_panscan_amount = vo_fs ? vo_panscan : 0; + vo_panscan_x = vo_panscan_area * vo_panscan_amount * aspdat.asp; + vo_panscan_y = vo_panscan_area * vo_panscan_amount; +} +
--- a/libvo/aspect.h Wed Jun 05 02:24:35 2002 +0000 +++ b/libvo/aspect.h Wed Jun 05 19:35:54 2002 +0000 @@ -2,6 +2,13 @@ #define __ASPECT_H /* Stuff for correct aspect scaling. */ +extern int vo_panscan_x; +extern int vo_panscan_y; +extern float vo_panscan_amount; + +extern void panscan_init( void ); +extern void panscan_calc( void ); + void aspect_save_orig(int orgw, int orgh); void aspect_save_prescale(int prew, int preh);
--- a/libvo/mga_common.c Wed Jun 05 02:24:35 2002 +0000 +++ b/libvo/mga_common.c Wed Jun 05 19:35:54 2002 +0000 @@ -280,6 +280,17 @@ case VOCTRL_GUISUPPORT: return VO_TRUE; #endif +#ifdef VO_XMGA + case VOCTRL_GET_PANSCAN: + return VO_TRUE; + case VOCTRL_SET_PANSCAN: + if ( vo_fs && ( vo_panscan != vo_panscan_amount ) ) + { + panscan_calc(); + set_window( 1 ); + } + return VO_TRUE; +#endif } return VO_NOTIMPL; }
--- a/libvo/video_out.h Wed Jun 05 02:24:35 2002 +0000 +++ b/libvo/video_out.h Wed Jun 05 19:35:54 2002 +0000 @@ -45,6 +45,9 @@ #define VOCTRL_GET_FRAME_NUM 11 #define VOCTRL_SET_FRAME_NUM 12 +#define VOCTRL_GET_PANSCAN 13 +#define VOCTRL_SET_PANSCAN 14 + #define VO_TRUE 1 #define VO_FALSE 0 #define VO_ERROR -1
--- a/libvo/vo_xmga.c Wed Jun 05 02:24:35 2002 +0000 +++ b/libvo/vo_xmga.c Wed Jun 05 19:35:54 2002 +0000 @@ -103,7 +103,7 @@ XFlush( mDisplay ); } -static void set_window(){ +static void set_window( int ps ){ if ( WinID ) { @@ -127,8 +127,7 @@ drwHeight=(dheight > vo_screenheight?vo_screenheight:dheight); mp_msg(MSGT_VO,MSGL_V,"[xmga-fs] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight ); } - - mDrawColorKey(); + vo_dwidth=drwWidth; vo_dheight=drwHeight; #ifdef HAVE_XINERAMA if(XineramaIsActive(mDisplay)) @@ -155,18 +154,34 @@ } #endif + + mDrawColorKey(); + mga_vid_config.x_org=drwcX; mga_vid_config.y_org=drwcY; mga_vid_config.dest_width=drwWidth; mga_vid_config.dest_height=drwHeight; - + if ( ps ) + { + drwX-=vo_panscan_x>>1; + drwY-=vo_panscan_y>>1; + drwWidth+=vo_panscan_x; + drwHeight+=vo_panscan_y; + + mga_vid_config.x_org-=vo_panscan_x>>1; + mga_vid_config.y_org-=vo_panscan_y>>1; + mga_vid_config.dest_width=drwWidth; + mga_vid_config.dest_height=drwHeight; + mDrawColorKey(); + if ( ioctl( f,MGA_VID_CONFIG,&mga_vid_config ) ) mp_msg(MSGT_VO,MSGL_WARN,"Error in mga_vid_config ioctl (wrong mga_vid.o version?)" ); + } } static void check_events(void) { int e=vo_x11_check_events(mDisplay); if ( !(e&VO_EVENT_RESIZE) && !(e&VO_EVENT_EXPOSE) ) return; - set_window(); + set_window( 0 ); mDrawColorKey(); if ( ioctl( f,MGA_VID_CONFIG,&mga_vid_config ) ) mp_msg(MSGT_VO,MSGL_WARN,"Error in mga_vid_config ioctl (wrong mga_vid.o version?)" ); } @@ -231,6 +246,8 @@ mvWidth=width; mvHeight=height; + vo_panscan_x=vo_panscan_y=vo_panscan_amount=0; + vo_dx=( vo_screenwidth - d_width ) / 2; vo_dy=( vo_screenheight - d_height ) / 2; vo_dwidth=d_width; vo_dheight=d_height; vo_mouse_autohide=1; @@ -307,7 +324,7 @@ if ( ( flags&1 )&&( !WinID ) ) { vo_dx=0; vo_dy=0; vo_dwidth=vo_screenwidth; vo_dheight=vo_screenheight; vo_fs=1; } - set_window(); + set_window( 0 ); mga_vid_config.src_width=width; mga_vid_config.src_height=height;
--- a/libvo/vo_xv.c Wed Jun 05 02:24:35 2002 +0000 +++ b/libvo/vo_xv.c Wed Jun 05 19:35:54 2002 +0000 @@ -94,10 +94,6 @@ 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; @@ -338,9 +334,7 @@ static uint32_t vm_height; #endif - panscan_x = 0; - panscan_y = 0; - panscan_amount = 0.0f; + panscan_init(); aspect_save_orig(width,height); aspect_save_prescale(d_width,d_height); @@ -604,31 +598,19 @@ 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-(panscan_x>>1),drwY-(panscan_y>>1),vo_dwidth+panscan_x,(vo_fs?vo_dheight - 1:vo_dheight)+panscan_y, + drwX-(vo_panscan_x>>1),drwY-(vo_panscan_y>>1),vo_dwidth+vo_panscan_x,(vo_fs?vo_dheight - 1:vo_dheight)+vo_panscan_y, False); } else { XvPutImage(mDisplay, xv_port, vo_window, vo_gc, xvimage[current_buf], 0, 0, image_width, image_height, - drwX-(panscan_x>>1),drwY-(panscan_y>>1),vo_dwidth+panscan_x,(vo_fs?vo_dheight - 1:vo_dheight)+panscan_y); + drwX-(vo_panscan_x>>1),drwY-(vo_panscan_y>>1),vo_dwidth+vo_panscan_x,(vo_fs?vo_dheight - 1:vo_dheight)+vo_panscan_y); } if (num_buffers>1){ current_buf=(current_buf+1)%num_buffers; @@ -874,6 +856,20 @@ case VOCTRL_FULLSCREEN: vo_x11_fullscreen(); return VO_TRUE; + case VOCTRL_GUISUPPORT: + return VO_TRUE; + case VOCTRL_GET_PANSCAN: + return VO_TRUE; + case VOCTRL_SET_PANSCAN: + +// if((vo_fs && (vo_panscan != vo_panscan_amount)) || (!vo_fs && vo_panscan_amount)) + if ( vo_fs && ( vo_panscan != vo_panscan_amount ) ) + { + panscan_calc(); + XClearWindow(mDisplay, vo_window); + XFlush(mDisplay); + } + return VO_TRUE; } return VO_NOTIMPL; }
--- a/libvo/vo_xvidix.c Wed Jun 05 02:24:35 2002 +0000 +++ b/libvo/vo_xvidix.c Wed Jun 05 19:35:54 2002 +0000 @@ -74,7 +74,7 @@ static uint32_t drwX, drwY, drwWidth, drwHeight, drwBorderWidth, drwDepth, drwcX, drwcY, dwidth, dheight; -static void set_window(int force_update,const vo_tune_info_t *info) +static void set_window(int force_update,const vo_tune_info_t *info, int ps) { Window mRoot; if ( WinID ) @@ -82,9 +82,9 @@ XGetGeometry(mDisplay, vo_window, &mRoot, &drwX, &drwY, &drwWidth, &drwHeight, &drwBorderWidth, &drwDepth); drwX = drwY = 0; + XTranslateCoordinates(mDisplay, vo_window, mRoot, 0, 0, &drwcX, &drwcY, &mRoot); - aspect(&dwidth,&dheight,A_NOZOOM); if (!vo_fs) mp_msg(MSGT_VO, MSGL_V, "[xvidix] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n", @@ -113,6 +113,8 @@ } #endif + vo_dwidth=drwWidth; vo_dheight=drwHeight; + #ifdef HAVE_XINERAMA if (XineramaIsActive(mDisplay)) { @@ -135,6 +137,16 @@ } #endif + if ( ps ) + { + drwcX-=vo_panscan_x >> 1; + drwcY-=vo_panscan_y >> 1; + drwX-=vo_panscan_x >> 1; + drwY-=vo_panscan_y >> 1; + drwWidth+=vo_panscan_x; + drwHeight+=vo_panscan_y; + } + /* set new values in VIDIX */ if (force_update || (window_x != drwcX) || (window_y != drwcY) || (window_width != drwWidth) || (window_height != drwHeight)) @@ -196,6 +208,8 @@ // free(title); title = "MPlayer VIDIX X11 Overlay"; + panscan_init(); + image_height = height; image_width = width; image_format = format; @@ -349,7 +363,7 @@ vidix_grkey_set(&gr_key); } - set_window(1,info); + set_window(1,info,0); if(info) memcpy(&vtune,info,sizeof(vo_tune_info_t)); else memset(&vtune,0,sizeof(vo_tune_info_t)); XFlush(mDisplay); @@ -370,7 +384,7 @@ const int event = vo_x11_check_events(mDisplay); if ((event & VO_EVENT_RESIZE) || (event & VO_EVENT_EXPOSE)) - set_window(0,&vtune); + set_window(0,&vtune,0); return; } @@ -449,6 +463,15 @@ case VOCTRL_FULLSCREEN: vo_x11_fullscreen(); return VO_TRUE; + case VOCTRL_GET_PANSCAN: + return VO_TRUE; + case VOCTRL_SET_PANSCAN: + if ( vo_fs && ( vo_panscan != vo_panscan_amount ) ) + { + panscan_calc(); + set_window( 0,&vtune,1 ); + } + return VO_TRUE; } return VO_NOTIMPL; }
--- a/mplayer.c Wed Jun 05 02:24:35 2002 +0000 +++ b/mplayer.c Wed Jun 05 19:35:54 2002 +0000 @@ -2545,22 +2545,24 @@ 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; + if ( video_out->control( VOCTRL_GET_PANSCAN,NULL ) == VO_TRUE ) + { + 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; + video_out->control( VOCTRL_SET_PANSCAN,NULL ); #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); - } + 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: {