⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vout_fb.c

📁 vlc stand 0.1.99 ist sehr einfach
💻 C
📖 第 1 页 / 共 2 页
字号:
    //ioctl( p_vout->p_sys->i_fb_dev, FBIOPUT_VSCREENINFO, &p_vout->p_sys->var_info );    ioctl( p_vout->p_sys->i_fb_dev, FBIOPAN_DISPLAY, &p_vout->p_sys->var_info );}/* following functions are local *//***************************************************************************** * FBOpenDisplay: open and initialize framebuffer device ***************************************************************************** * XXX?? The framebuffer mode is only provided as a fast and efficient way to * display video, providing the card is configured and the mode ok. It is * not portable, and is not supposed to work with many cards. Use at your * own risk ! *****************************************************************************/static int FBOpenDisplay( vout_thread_t *p_vout ){    char *psz_device;                             /* framebuffer device path */    struct fb_fix_screeninfo    fix_info;     /* framebuffer fix information */    /* Open framebuffer device */    psz_device = main_GetPszVariable( VOUT_FB_DEV_VAR, VOUT_FB_DEV_DEFAULT );    p_vout->p_sys->i_fb_dev = open( psz_device, O_RDWR);    if( p_vout->p_sys->i_fb_dev == -1 )    {        intf_ErrMsg("vout error: can't open %s (%s)\n", psz_device, strerror(errno) );        return( 1 );    }    /* Get framebuffer device informations */    if( ioctl( p_vout->p_sys->i_fb_dev, FBIOGET_VSCREENINFO, &p_vout->p_sys->var_info ) )    {        intf_ErrMsg( "vout error: can't get framebuffer informations (%s)\n", strerror(errno) );        close( p_vout->p_sys->i_fb_dev );        return( 1 );    }    /* Framebuffer must have some basic properties to be usable */    /* XXX?? */    /* Set some attributes */    p_vout->p_sys->var_info.activate = FB_ACTIVATE_NXTOPEN;    p_vout->p_sys->var_info.xoffset =  0;    p_vout->p_sys->var_info.yoffset =  0;    intf_ErrMsg( "vout: ypanstep is %i\n", fix_info.ypanstep );    /* XXX?? ask sam p_vout->p_sys->mode_info.sync = FB_SYNC_VERT_HIGH_ACT; */    if( ioctl( p_vout->p_sys->i_fb_dev, FBIOPUT_VSCREENINFO, &p_vout->p_sys->var_info ) )    {        intf_ErrMsg("vout error: can't set framebuffer informations (%s)\n", strerror(errno) );        close( p_vout->p_sys->i_fb_dev );        return( 1 );    }    /* Get some informations again, in the definitive configuration */    if( ioctl( p_vout->p_sys->i_fb_dev, FBIOGET_FSCREENINFO, &fix_info ) ||        ioctl( p_vout->p_sys->i_fb_dev, FBIOGET_VSCREENINFO, &p_vout->p_sys->var_info ) )    {        intf_ErrMsg("vout error: can't get framebuffer informations (%s)\n", strerror(errno) );        /* FIXME: restore fb config ?? */        close( p_vout->p_sys->i_fb_dev );        return( 1 );    }    /* FIXME: if the image is full-size, it gets cropped on the left     * because of the xres / xres_virtual slight difference */    intf_Msg( "%ix%i (virtual %ix%i)\n", p_vout->p_sys->var_info.xres, p_vout->p_sys->var_info.yres, p_vout->p_sys->var_info.xres_virtual, p_vout->p_sys->var_info.yres_virtual );    p_vout->i_width =                   p_vout->p_sys->var_info.xres_virtual ? p_vout->p_sys->var_info.xres_virtual : p_vout->p_sys->var_info.xres;    p_vout->i_height =                  p_vout->p_sys->var_info.yres;    p_vout->i_screen_depth =            p_vout->p_sys->var_info.bits_per_pixel;    switch( p_vout->i_screen_depth )    {    case 8:                                                         /* 8 bpp */        p_vout->p_sys->fb_palette = malloc( 8 * 256 * sizeof(unsigned short) );        p_vout->p_sys->fb_cmap.start = 0;        p_vout->p_sys->fb_cmap.len = 256;        p_vout->p_sys->fb_cmap.red = p_vout->p_sys->fb_palette;        p_vout->p_sys->fb_cmap.green = p_vout->p_sys->fb_palette + 256 * sizeof(unsigned short);        p_vout->p_sys->fb_cmap.blue = p_vout->p_sys->fb_palette + 2 * 256 * sizeof(unsigned short);        p_vout->p_sys->fb_cmap.transp = p_vout->p_sys->fb_palette + 3 * 256 * sizeof(unsigned short);        /* saves the colormap */        ioctl( p_vout->p_sys->i_fb_dev, FBIOGETCMAP, &p_vout->p_sys->fb_cmap );        p_vout->i_bytes_per_pixel = 1;        p_vout->i_bytes_per_line = p_vout->i_width;        break;    case 15:                      /* 15 bpp (16bpp with a missing green bit) */    case 16:                                        /* 16 bpp (65536 colors) */        p_vout->i_bytes_per_pixel = 2;        p_vout->i_bytes_per_line = p_vout->i_width * 2;        break;    case 24:                                  /* 24 bpp (millions of colors) */        p_vout->i_bytes_per_pixel = 3;        p_vout->i_bytes_per_line = p_vout->i_width * 3;        break;    case 32:                                  /* 32 bpp (millions of colors) */        p_vout->i_bytes_per_pixel = 4;        p_vout->i_bytes_per_line = p_vout->i_width * 4;        break;    default:                                     /* unsupported screen depth */        intf_ErrMsg( "vout error: screen depth %d is not supported\n",                     p_vout->i_screen_depth);        return( 1 );        break;    }    switch( p_vout->i_screen_depth )    {    case 15:    case 16:    case 24:    case 32:        p_vout->i_red_mask =    ( (1 << p_vout->p_sys->var_info.red.length) - 1 )                                    << p_vout->p_sys->var_info.red.offset;        p_vout->i_green_mask =    ( (1 << p_vout->p_sys->var_info.green.length) - 1 )                                    << p_vout->p_sys->var_info.green.offset;        p_vout->i_blue_mask =    ( (1 << p_vout->p_sys->var_info.blue.length) - 1 )                                    << p_vout->p_sys->var_info.blue.offset;    }    p_vout->p_sys->i_page_size = p_vout->i_width *                p_vout->i_height * p_vout->i_bytes_per_pixel;    /* Map two framebuffers a the very beginning of the fb */    p_vout->p_sys->p_video = mmap(0, p_vout->p_sys->i_page_size * 2,                          PROT_READ | PROT_WRITE, MAP_SHARED,                          p_vout->p_sys->i_fb_dev, 0 );    if( (int)p_vout->p_sys->p_video == -1 ) /* XXX?? according to man, it is -1. What about NULL ? */    {        intf_ErrMsg("vout error: can't map video memory (%s)\n", strerror(errno) );        /* FIXME: restore fb config ?? */        close( p_vout->p_sys->i_fb_dev );        return( 1 );    }    /* Set and initialize buffers */    vout_SetBuffers( p_vout, p_vout->p_sys->p_video,                     p_vout->p_sys->p_video + p_vout->p_sys->i_page_size );    intf_DbgMsg("framebuffer type=%d, visual=%d, ypanstep=%d, ywrap=%d, accel=%d\n",                fix_info.type, fix_info.visual, fix_info.ypanstep, fix_info.ywrapstep, fix_info.accel );    return( 0 );}/***************************************************************************** * FBCloseDisplay: close and reset framebuffer device ***************************************************************************** * Returns all resources allocated by FBOpenDisplay and restore the original * state of the device. *****************************************************************************/static void FBCloseDisplay( vout_thread_t *p_vout ){    /* Restore palette */    if( p_vout->i_screen_depth == 8 );    {        ioctl( p_vout->p_sys->i_fb_dev, FBIOPUTCMAP, &p_vout->p_sys->fb_cmap );        free( p_vout->p_sys->fb_palette );    }    /* Destroy window and close display */    close( p_vout->p_sys->i_fb_dev );}/***************************************************************************** * FBSetPalette: sets an 8 bpp palette ***************************************************************************** * This function sets the palette given as an argument. It does not return * anything, but could later send information on which colors it was unable * to set. *****************************************************************************/static void    FBSetPalette   ( p_vout_thread_t p_vout,                                u16 *red, u16 *green, u16 *blue, u16 *transp ){    struct fb_cmap cmap = { 0, 256, red, green, blue, transp };    ioctl( p_vout->p_sys->i_fb_dev, FBIOPUTCMAP, &cmap );}

⌨️ 快捷键说明

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