vo_dfbmga.c

来自「君正早期ucos系统(只有早期的才不没有打包成库),MPLAYER,文件系统,图」· C语言 代码 · 共 1,527 行 · 第 1/4 页

C
1,527
字号
               return -1;          }     }     if (!use_bes && !use_crtc2) {	  mp_msg( MSGT_VO, MSGL_ERR, "vo_dfbmga: No output selected\n" );          return -1;     }          if ((res = DirectFBInit( NULL, NULL )) != DFB_OK) {               mp_msg( MSGT_VO, MSGL_ERR,                       "vo_dfbmga: DirectFBInit() failed - %s\n",                       DirectFBErrorString( res ) );               return -1;          }          switch (tvnorm) {          case 0:               DirectFBSetOption( "matrox-tv-standard", "pal" );               mp_msg( MSGT_VO, MSGL_INFO, "vo_dfbmga: Forced TV standard to PAL\n" );               break;          case 1:               DirectFBSetOption( "matrox-tv-standard", "ntsc" );               mp_msg( MSGT_VO, MSGL_INFO, "vo_dfbmga: Forced TV standard to NTSC\n" );               break;          case 2:               if (vo_fps > 27) {                    DirectFBSetOption( "matrox-tv-standard", "ntsc" );                    mp_msg( MSGT_VO, MSGL_INFO,                            "vo_dfbmga: Selected TV standard based upon FPS: NTSC\n" );               } else {                    DirectFBSetOption( "matrox-tv-standard", "pal" );                    mp_msg( MSGT_VO, MSGL_INFO,                            "vo_dfbmga: Selected TV standard based upon FPS: PAL\n" );               }               break;          }          if ((res = DirectFBCreate( &dfb )) != DFB_OK) {               mp_msg( MSGT_VO, MSGL_ERR,                       "vo_dfbmga: DirectFBCreate() failed - %s\n",                       DirectFBErrorString( res ) );               return -1;          }     if (use_bes) {          struct layer_enum l = {               "FBDev Primary Layer",               &primary,               DFB_UNSUPPORTED          };          dfb->EnumDisplayLayers( dfb, get_layer_by_name, &l );          if (l.res != DFB_OK) {               mp_msg( MSGT_VO, MSGL_ERR, "vo_dfbmga: Can't get primary layer - %s\n",                       DirectFBErrorString( l.res ) );               uninit();               return -1;          }          if ((res = primary->SetCooperativeLevel( primary, DLSCL_EXCLUSIVE )) != DFB_OK) {               mp_msg( MSGT_VO, MSGL_ERR, "Can't get exclusive access to primary layer - %s\n",                       DirectFBErrorString( res ) );               uninit();               return -1;          }          use_input = 1;     }     if (force_input != -1)          use_input = force_input;     if (use_bes) {          DFBDisplayLayerConfig      dlc;          DFBDisplayLayerConfigFlags failed;          struct layer_enum l = {               "Matrox Backend Scaler",               &bes,               DFB_UNSUPPORTED          };          dfb->EnumDisplayLayers( dfb, get_layer_by_name, &l );          if (l.res != DFB_OK) {               mp_msg( MSGT_VO, MSGL_ERR, "Can't get BES layer - %s\n",                       DirectFBErrorString( l.res ) );               uninit();               return -1;          }          if ((res = bes->SetCooperativeLevel( bes, DLSCL_EXCLUSIVE )) != DFB_OK) {               mp_msg( MSGT_VO, MSGL_ERR, "Can't get exclusive access to BES - %s\n",                       DirectFBErrorString( res ) );               uninit();               return -1;          }          dlc.flags = DLCONF_PIXELFORMAT;          dlc.pixelformat = DSPF_RGB16;          if (bes->TestConfiguration( bes, &dlc, &failed ) != DFB_OK) {               is_g200 = 1;               use_crtc2 = 0;          }     }     if (use_crtc2) {          struct layer_enum l = {#if DIRECTFBVERSION > DFB_VERSION(0,9,20)               "Matrox CRTC2 Layer",#else               "Matrox CRTC2",#endif               &crtc2,               DFB_UNSUPPORTED          };          dfb->EnumDisplayLayers( dfb, get_layer_by_name, &l );          if (l.res != DFB_OK) {               mp_msg( MSGT_VO, MSGL_ERR, "Can't get CRTC2 layer - %s\n",                       DirectFBErrorString( l.res ) );               uninit();               return -1;          }          if ((res = crtc2->SetCooperativeLevel( crtc2, DLSCL_EXCLUSIVE )) != DFB_OK) {               mp_msg( MSGT_VO, MSGL_ERR, "Can't get exclusive access to CRTC2 - %s\n",                       DirectFBErrorString( res ) );               uninit();               return -1;          }     }     if (use_input || use_remote) {          if ((res = dfb->CreateEventBuffer( dfb, &buffer )) != DFB_OK) {               mp_msg( MSGT_VO, MSGL_ERR,                       "vo_dfbmga: Can't create event buffer - %s\n",                       DirectFBErrorString( res ) );               uninit();               return -1;          }     }     if (use_input) {          if ((res = dfb->GetInputDevice( dfb, DIDID_KEYBOARD, &keyboard )) != DFB_OK) {               mp_msg( MSGT_VO, MSGL_ERR,                       "vo_dfbmga: Can't get keyboard - %s\n",                       DirectFBErrorString( res ) );               uninit();               return -1;          }          if ((res = keyboard->AttachEventBuffer( keyboard, buffer )) != DFB_OK) {               mp_msg( MSGT_VO, MSGL_ERR,                       "vo_dfbmga: Can't attach event buffer to keyboard - %s\n",                       DirectFBErrorString( res ) );               uninit();               return -1;          }     }     if (use_remote) {          if ((res = dfb->GetInputDevice( dfb, DIDID_REMOTE, &remote )) != DFB_OK) {               mp_msg( MSGT_VO, MSGL_ERR,                       "vo_dfbmga: Can't get remote control - %s\n",                       DirectFBErrorString( res ) );               uninit();               return -1;          }          if ((res = remote->AttachEventBuffer( remote, buffer )) != DFB_OK) {               mp_msg( MSGT_VO, MSGL_ERR,                       "vo_dfbmga: Can't attach event buffer to remote control - %s\n",                       DirectFBErrorString( res ) );               uninit();               return -1;          }     }          return 0;}static void release_config( void ){     if (spicframe)          spicframe->Release( spicframe );     if (spic)          spic->Release( spic );     if (c2frame)          c2frame->Release( c2frame );     if (besframe)          besframe->Release( besframe );     if (bufs[0])          bufs[0]->Release( bufs[0] );     if (bufs[1])          bufs[1]->Release( bufs[1] );     if (bufs[2])          bufs[2]->Release( bufs[2] );          spicframe = NULL;     spic = NULL;     c2frame = NULL;     besframe = NULL;     bufs[0] = NULL;     bufs[1] = NULL;     bufs[2] = NULL;}static intconfig( uint32_t width, uint32_t height,        uint32_t d_width, uint32_t d_height,        uint32_t flags,        char *title,	uint32_t format ){     DFBResult res;     DFBDisplayLayerConfig      dlc;     DFBDisplayLayerConfigFlags failed;     uint32_t out_width;     uint32_t out_height;     release_config();     in_width  = width;     in_height = height;     aspect_save_orig(width, height);     aspect_save_prescale(d_width, d_height);     dlc.pixelformat   = imgfmt_to_pixelformat( format );     {          /* Draw to a temporary surface */          DFBSurfaceDescription dsc;          dsc.flags       = DSDESC_WIDTH | DSDESC_HEIGHT |                            DSDESC_PIXELFORMAT;          dsc.width       = (in_width + 15) & ~15;          dsc.height      = (in_height + 15) & ~15;          dsc.pixelformat = dlc.pixelformat;          /* Don't waste video memory since we don't need direct stretchblit */          if (use_bes) {               dsc.flags |= DSDESC_CAPS;               dsc.caps   = DSCAPS_SYSTEMONLY;          }          for (num_bufs = 0; num_bufs < 3; num_bufs++) {               if ((res = dfb->CreateSurface( dfb, &dsc, &bufs[num_bufs] )) != DFB_OK) {                    if (num_bufs == 0) {                         mp_msg( MSGT_VO, MSGL_ERR,                                 "vo_dfbmga: Can't create surfaces - %s!\n",                                 DirectFBErrorString( res ) );                         return -1;                    }                    break;               }          }          frame = bufs[0];          current_buf = 0;          current_ip_buf = 0;          buf_height = dsc.height;     }     frame->GetPixelFormat( frame, &frame_format );     mp_msg( MSGT_VO, MSGL_INFO, "vo_dfbmga: Video surface %dx%d %s\n",             in_width, in_height,             pixelformat_name( frame_format ) );     /*      * BES      */     if (use_bes) {          aspect_save_screenres( 0x10000, 0x10000 );          aspect( &out_width, &out_height, A_ZOOM );          besrect.x = (0x10000 - out_width) * in_width / out_width / 2;          besrect.y = (0x10000 - out_height) * in_height / out_height / 2;          besrect.w = in_width;          besrect.h = in_height;          dlc.flags       = DLCONF_WIDTH | DLCONF_HEIGHT | DLCONF_PIXELFORMAT | DLCONF_BUFFERMODE;          dlc.width       = besrect.w + besrect.x * 2;          dlc.height      = besrect.h + besrect.y * 2;          if (use_crtc2)               dlc.buffermode = DLBM_FRONTONLY;          else               dlc.buffermode = buffermode;          if ((res = bes->TestConfiguration( bes, &dlc, &failed )) != DFB_OK) {               mp_msg( MSGT_VO, MSGL_ERR,                       "vo_dfbmga: Invalid BES configuration - %s!\n",                       DirectFBErrorString( res ) );               return -1;          }          if ((res = bes->SetConfiguration( bes, &dlc )) != DFB_OK) {               mp_msg( MSGT_VO, MSGL_ERR,                       "vo_dfbmga: BES configuration failed - %s!\n",                       DirectFBErrorString( res ) );               return -1;          }          bes->GetSurface( bes, &besframe );          besframe->SetBlittingFlags( besframe, DSBLIT_NOFX );          bes->SetScreenLocation( bes, 0.0, 0.0, 1.0, 1.0 );          besframe->Clear( besframe, 0, 0, 0, 0xff );          besframe->Flip( besframe, NULL, 0 );          besframe->Clear( besframe, 0, 0, 0, 0xff );          besframe->Flip( besframe, NULL, 0 );          besframe->Clear( besframe, 0, 0, 0, 0xff );          mp_msg( MSGT_VO, MSGL_INFO, "vo_dfbmga: BES using %s buffering\n",                  dlc.buffermode == DLBM_TRIPLE ? "triple" :                  dlc.buffermode == DLBM_BACKVIDEO ? "double" : "single" );          mp_msg( MSGT_VO, MSGL_INFO, "vo_dfbmga: BES surface %dx%d %s\n", dlc.width, dlc.height, pixelformat_name( dlc.pixelformat ) );     }     /*      * CRTC2      */     if (use_crtc2) {          dlc.flags      = DLCONF_PIXELFORMAT | DLCONF_BUFFERMODE | DLCONF_OPTIONS;          dlc.buffermode = buffermode;          dlc.options    = DLOP_NONE;#if DIRECTFBVERSION > DFB_VERSION(0,9,16)          if (field_parity != -1) {               dlc.options |= DLOP_FIELD_PARITY;          }#endif          mp_msg( MSGT_VO, MSGL_INFO, "vo_dfbmga: Field parity set to: ");          switch (field_parity) {          case -1:               mp_msg( MSGT_VO, MSGL_INFO, "Don't care\n");               break;          case 0:               mp_msg( MSGT_VO, MSGL_INFO, "Top field first\n");               break;          case 1:               mp_msg( MSGT_VO, MSGL_INFO, "Bottom field first\n");               break;          }          switch (dlc.pixelformat) {          case DSPF_I420:          case DSPF_YV12:               /* sub-picture supported */               break;          case DSPF_YUY2:          case DSPF_UYVY:               /* Blit to YUY2/UYVY not supported */               dlc.pixelformat = DSPF_ARGB;               /* fall through */          default:               /* sub-picture not supported */               use_spic = 0;          }          if ((res = crtc2->TestConfiguration( crtc2, &dlc, &failed )) != DFB_OK) {               mp_msg( MSGT_VO, MSGL_ERR,                       "vo_dfbmga: Invalid CRTC2 configuration - %s!\n",                       DirectFBErrorString( res ) );               return -1;          }          if ((res = crtc2->SetConfiguration( crtc2, &dlc )) != DFB_OK) {               mp_msg( MSGT_VO, MSGL_ERR,                       "vo_dfbmga: CRTC2 configuration failed - %s!\n",                       DirectFBErrorString( res ) );               return -1;          }#if DIRECTFBVERSION > DFB_VERSION(0,9,16)          if (field_parity != -1)               crtc2->SetFieldParity( crtc2, field_parity );#endif          crtc2->GetSurface( crtc2, &c2frame );          c2frame->SetBlittingFlags( c2frame, DSBLIT_NOFX );          c2frame->SetColor( c2frame, 0, 0, 0, 0xff );          c2frame->GetSize( c2frame, &screen_width, &screen_height );          /* Don't stretch only slightly smaller videos */          if ((in_width > (0.95 * screen_width)) &&              (in_width < screen_width))               out_width = in_width;          else               out_width = screen_width;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?