📄 vout_fb.c
字号:
/***************************************************************************** * vout_fb.c: Linux framebuffer video output display method ***************************************************************************** * Copyright (C) 1999, 2000 VideoLAN * * Authors: * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. *****************************************************************************//***************************************************************************** * Preamble *****************************************************************************/#include "defs.h"#include <errno.h> /* ENOMEM */#include <stdlib.h> /* free() */#include <string.h> /* strerror() */#include <fcntl.h> /* open() */#include <unistd.h> /* close() */#include <linux/fb.h>#include <sys/ioctl.h>#include <sys/mman.h> /* mmap() */#include "config.h"#include "common.h"#include "threads.h"#include "mtime.h"#include "plugins.h"#include "video.h"#include "video_output.h"#include "intf_msg.h"#include "main.h"/***************************************************************************** * vout_sys_t: video output framebuffer method descriptor ***************************************************************************** * This structure is part of the video output thread descriptor. * It describes the FB specific properties of an output thread. *****************************************************************************/typedef struct vout_sys_s{ /* System informations */ int i_fb_dev; /* framebuffer device handle */ struct fb_var_screeninfo var_info; /* framebuffer mode informations */ /* Video memory */ byte_t * p_video; /* base adress */ size_t i_page_size; /* page size */ struct fb_cmap fb_cmap; /* original colormap */ unsigned short *fb_palette; /* original palette */} vout_sys_t;/***************************************************************************** * Local prototypes *****************************************************************************/static int FBOpenDisplay ( vout_thread_t *p_vout );static void FBCloseDisplay ( vout_thread_t *p_vout );static void FBSetPalette ( p_vout_thread_t p_vout, u16 *red, u16 *green, u16 *blue, u16 *transp );/***************************************************************************** * vout_SysCreate: allocates FB video thread output method ***************************************************************************** * This function allocates and initializes a FB vout method. *****************************************************************************/int vout_SysCreate( vout_thread_t *p_vout, char *psz_display, int i_root_window, void *p_data ){ /* Allocate structure */ p_vout->p_sys = malloc( sizeof( vout_sys_t ) ); if( p_vout->p_sys == NULL ) { intf_ErrMsg("error: %s\n", strerror(ENOMEM) ); return( 1 ); } /* Open and initialize device */ if( FBOpenDisplay( p_vout ) ) { intf_ErrMsg("vout error: can't open display\n"); free( p_vout->p_sys ); return( 1 ); } return( 0 );}/***************************************************************************** * vout_SysInit: initialize framebuffer video thread output method *****************************************************************************/int vout_SysInit( vout_thread_t *p_vout ){ p_vout->p_set_palette = FBSetPalette; return( 0 );}/***************************************************************************** * vout_SysEnd: terminate FB video thread output method *****************************************************************************/void vout_SysEnd( vout_thread_t *p_vout ){ ;}/***************************************************************************** * vout_SysDestroy: destroy FB video thread output method ***************************************************************************** * Terminate an output method created by vout_CreateOutputMethod *****************************************************************************/void vout_SysDestroy( vout_thread_t *p_vout ){ FBCloseDisplay( p_vout ); free( p_vout->p_sys );}/***************************************************************************** * vout_SysManage: handle FB events ***************************************************************************** * This function should be called regularly by video output thread. It manages * console events. It returns a non null value on error. *****************************************************************************/int vout_SysManage( vout_thread_t *p_vout ){ /* * Size change */ if( p_vout->i_changes & VOUT_SIZE_CHANGE ) { intf_DbgMsg("resizing window\n"); p_vout->i_changes &= ~VOUT_SIZE_CHANGE; /* Destroy XImages to change their size */ vout_SysEnd( p_vout ); /* Recreate XImages. If SysInit failed, the thread can't go on. */ if( vout_SysInit( p_vout ) ) { intf_ErrMsg("error: can't resize display\n"); return( 1 ); }#if 1 /* Tell the video output thread that it will need to rebuild YUV * tables. This is needed since conversion buffer size may have changed */ p_vout->i_changes |= VOUT_YUV_CHANGE; intf_Msg("Video display resized (%dx%d)\n", p_vout->i_width, p_vout->i_height);#endif } return 0;}/***************************************************************************** * vout_SysDisplay: displays previously rendered output ***************************************************************************** * This function send the currently rendered image to FB image, waits until * it is displayed and switch the two rendering buffers, preparing next frame. *****************************************************************************/void vout_SysDisplay( vout_thread_t *p_vout ){ /* swap the two Y offsets */ p_vout->p_sys->var_info.yoffset = p_vout->i_buffer_index ? p_vout->p_sys->var_info.yres : 0; /* the X offset should be 0, but who knows ... * some other app might have played with the framebuffer */ p_vout->p_sys->var_info.xoffset = 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -