mga_common.c
字号:
mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_MGA_CouldNotGetLumaValuesFromTheKernelModule); return VO_FALSE; } if ( !strcmp( data,"contrast" ) ) val=(luma & 0xFFFF); else val=(luma >> 16); va_start(ap, data); value = va_arg(ap, int*); va_end(ap); *value = (val*200)/255; return VO_TRUE; } #ifndef VO_XMGA case VOCTRL_FULLSCREEN: if (vo_screenwidth && vo_screenheight) mga_fullscreen(); else mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_MGA_ScreenWidthHeightUnknown); return VO_TRUE; case VOCTRL_GET_PANSCAN: if ( !vo_fs ) return VO_FALSE; return VO_TRUE;#endif#if defined( VO_XMGA ) && defined( HAVE_NEW_GUI ) case VOCTRL_GUISUPPORT: return VO_TRUE;#endif#ifdef VO_XMGA case VOCTRL_ONTOP: vo_x11_ontop(); return VO_TRUE; case VOCTRL_GET_PANSCAN: if ( !inited || !vo_fs ) return VO_FALSE; return VO_TRUE; case VOCTRL_FULLSCREEN: vo_x11_fullscreen(); vo_panscan_amount=0; /* indended, fallthrough to update panscan on fullscreen/windowed switch */#endif case VOCTRL_SET_PANSCAN: if ( vo_fs && ( vo_panscan != vo_panscan_amount ) ) // || ( !vo_fs && vo_panscan_amount ) ) {// int old_y = vo_panscan_y; panscan_calc();// if ( old_y != vo_panscan_y ) set_window(); } return VO_TRUE; } return VO_NOTIMPL;}static int mga_init(int width,int height,unsigned int format){ switch(format){ case IMGFMT_YV12: width+=width&1;height+=height&1; mga_vid_config.frame_size = ((width + 31) & ~31) * height + (((width + 31) & ~31) * height) / 2; mga_vid_config.format=MGA_VID_FORMAT_I420; break; case IMGFMT_I420: case IMGFMT_IYUV: width+=width&1;height+=height&1; mga_vid_config.frame_size = ((width + 31) & ~31) * height + (((width + 31) & ~31) * height) / 2; mga_vid_config.format=MGA_VID_FORMAT_YV12; break; case IMGFMT_YUY2: mga_vid_config.frame_size = ((width + 31) & ~31) * height * 2; mga_vid_config.format=MGA_VID_FORMAT_YUY2; break; case IMGFMT_UYVY: mga_vid_config.frame_size = ((width + 31) & ~31) * height * 2; mga_vid_config.format=MGA_VID_FORMAT_UYVY; break; default: mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_MGA_InvalidOutputFormat,format); return (-1); } mga_vid_config.src_width = width; mga_vid_config.src_height= height; if(!mga_vid_config.dest_width) mga_vid_config.dest_width = width; if(!mga_vid_config.dest_height) mga_vid_config.dest_height= height; mga_vid_config.colkey_on=0; mga_vid_config.num_frames=(vo_directrendering && !vo_doublebuffering)?1:3; mga_vid_config.version=MGA_VID_VERSION; if(width > 1024 && height > 1024) { mp_msg(MSGT_VO,MSGL_ERR, MGSTR_LIBVO_MGA_ResolutionTooHigh); return (-1); } else if(height <= 1024) { // try whether we have a G550 int ret; if ((ret = ioctl(f,MGA_VID_CONFIG,&mga_vid_config))) { if(mga_vid_config.card_type != MGA_G550) { // we don't have a G550, so our resolution is too high mp_msg(MSGT_VO,MSGL_ERR, MGSTR_LIBVO_MGA_ResolutionTooHigh); return (-1); } else { // there is a deeper problem // we have a G550, but still couldn't configure mga_vid perror("Error in mga_vid_config ioctl()"); mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_MGA_IncompatibleDriverVersion); return -1; } // if we arrived here, then we could successfully configure mga_vid // at this high resolution } } else { // configure mga_vid in case resolution is < 1024x1024 too if (ioctl(f,MGA_VID_CONFIG,&mga_vid_config)) { perror("Error in mga_vid_config ioctl()"); mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_MGA_IncompatibleDriverVersion); return -1; } } mp_msg(MSGT_VO,MSGL_V,"[MGA] Using %d buffers.\n",mga_vid_config.num_frames); frames[0] = (char*)mmap(0,mga_vid_config.frame_size*mga_vid_config.num_frames,PROT_WRITE,MAP_SHARED,f,0); frames[1] = frames[0] + 1*mga_vid_config.frame_size; frames[2] = frames[0] + 2*mga_vid_config.frame_size; frames[3] = frames[0] + 3*mga_vid_config.frame_size; mga_next_frame = 0; vid_data = frames[mga_next_frame]; //clear the buffer memset(frames[0],0x80,mga_vid_config.frame_size*mga_vid_config.num_frames);#ifndef VO_XMGA ioctl(f,MGA_VID_ON,0);#endif return 0;}static int mga_uninit(){ if(f>=0){ ioctl( f,MGA_VID_OFF,0 ); munmap(frames[0],mga_vid_config.frame_size*mga_vid_config.num_frames); close(f); f = -1; } return 0;}static int preinit(const char *vo_subdevice){ const char *devname=vo_subdevice?vo_subdevice:"/dev/mga_vid"; sws_rgb2rgb_init(get_sws_cpuflags()); f = open(devname,O_RDWR); if(f == -1) { perror("open"); mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_MGA_CouldntOpen,devname); return(-1); }#ifdef VO_XMGA if (!vo_init()) { close(f); return -1; }#endif return 0;}static void set_window( void ){#ifdef VO_XMGA if ( WinID ) { XGetGeometry( mDisplay,vo_window,&mRoot,&drwX,&drwY,&drwWidth,&drwHeight,&drwBorderWidth,&drwDepth ); mp_msg(MSGT_VO,MSGL_V,"[xmga] x: %d y: %d w: %d h: %d\n",drwX,drwY,drwWidth,drwHeight ); drwX=0; drwY=0; XTranslateCoordinates( mDisplay,vo_window,mRoot,0,0,&drwcX,&drwcY,&mRoot ); mp_msg(MSGT_VO,MSGL_V,"[xmga] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight ); } else#endif { drwX=drwcX=vo_dx; drwY=drwcY=vo_dy; drwWidth=vo_dwidth; drwHeight=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,"[xmga-fs] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight ); } vo_dwidth=drwWidth; vo_dheight=drwHeight;#ifdef VO_XMGA#ifdef HAVE_XINERAMA if(XineramaIsActive(mDisplay)) { XineramaScreenInfo *screens; int num_screens; int i; screens = XineramaQueryScreens(mDisplay,&num_screens); /* find the screen we are on */ i = 0; while(i<num_screens && ((screens[i].x_org < drwcX) || (screens[i].y_org < drwcY) || (screens[i].x_org + screens[i].width >= drwcX) || (screens[i].y_org + screens[i].height >= drwcY))) { i++; } if(i<num_screens) { /* save the screen we are on */ xinerama_screen = i; } else { /* oops.. couldnt find the screen we are on * because the upper left corner left the * visual range. assume we are still on the * same screen */ i = xinerama_screen; } if(xinerama_screen == -1) { // The default value of the xinerama_screen is // still there. Which means we could never // figure out on which screen we are. // Choose the first screen as default xinerama_screen = i = 0; } /* set drwcX and drwcY to the right values */ drwcX = drwcX - screens[i].x_org; drwcY = drwcY - screens[i].y_org; XFree(screens); }#endif mDrawColorKey();#endif 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 ( vo_panscan > 0.0f && vo_fs ) { 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;#ifdef VO_XMGA mDrawColorKey();#endif } 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?)" );}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -