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

📄 ggi.c

📁 video linux conference
💻 C
📖 第 1 页 / 共 2 页
字号:
/***************************************************************************** * ggi.c : GGI plugin for vlc ***************************************************************************** * Copyright (C) 2000, 2001 VideoLAN * $Id: ggi.c 10101 2005-03-02 16:47:31Z robux4 $ * * Authors: Vincent Seguin <seguin@via.ecp.fr> *          Samuel Hocevar <sam@zoy.org> * * 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 <stdlib.h>                                      /* malloc(), free() */#include <string.h>#include <errno.h>                                                 /* ENOMEM */#include <ggi/ggi.h>#include <vlc/vlc.h>#include <vlc/intf.h>#include <vlc/vout.h>/***************************************************************************** * Local prototypes *****************************************************************************/static int  Create    ( vlc_object_t * );static void Destroy   ( vlc_object_t * );static int  Init      ( vout_thread_t * );static void End       ( vout_thread_t * );static int  Manage    ( vout_thread_t * );static void Display   ( vout_thread_t *, picture_t * );static int  OpenDisplay    ( vout_thread_t * );static void CloseDisplay   ( vout_thread_t * );static void SetPalette     ( vout_thread_t *, uint16_t *, uint16_t *, uint16_t * );/***************************************************************************** * Module descriptor *****************************************************************************/#define DISPLAY_TEXT N_("X11 display name")#define DISPLAY_LONGTEXT N_( \            "Specify the X11 hardware display you want to use.\n" \            "By default, VLC will use the value of the DISPLAY " \            "environment variable.")vlc_module_begin();    add_string( "ggi-display", NULL, NULL, DISPLAY_TEXT, DISPLAY_LONGTEXT, VLC_TRUE );    set_description( "General Graphics Interface video output" );    set_capability( "video output", 30 );    set_callbacks( Create, Destroy );vlc_module_end();/***************************************************************************** * vout_sys_t: video output GGI method descriptor ***************************************************************************** * This structure is part of the video output thread descriptor. * It describes the GGI specific properties of an output thread. *****************************************************************************/struct vout_sys_t{    /* GGI system information */    ggi_visual_t        p_display;                         /* display device */    ggi_mode            mode;                             /* mode descriptor */    int                 i_bits_per_pixel;    /* Buffer information */    ggi_directbuffer *  pp_buffer[2];                             /* buffers */    int                 i_index;    vlc_bool_t          b_must_acquire;   /* must be acquired before writing */};/***************************************************************************** * Create: allocate GGI video thread output method ***************************************************************************** * This function allocate and initialize a GGI vout method. It uses some of the * vout properties to choose the correct mode, and change them according to the * mode actually used. *****************************************************************************/static int Create( vlc_object_t *p_this ){    vout_thread_t *p_vout = (vout_thread_t *)p_this;    /* Allocate structure */    p_vout->p_sys = malloc( sizeof( vout_sys_t ) );    if( p_vout->p_sys == NULL )    {        msg_Err( p_vout, "out of memory" );        return( 1 );    }    /* Open and initialize device */    if( OpenDisplay( p_vout ) )    {        msg_Err( p_vout, "cannot initialize GGI display" );        free( p_vout->p_sys );        return( 1 );    }    p_vout->pf_init = Init;    p_vout->pf_end = End;    p_vout->pf_manage = Manage;    p_vout->pf_render = NULL;    p_vout->pf_display = Display;    return( 0 );}/***************************************************************************** * Init: initialize GGI video thread output method ***************************************************************************** * This function initialize the GGI display device. *****************************************************************************/static int Init( vout_thread_t *p_vout ){#define p_b p_vout->p_sys->pp_buffer    int i_index;    picture_t *p_pic;    I_OUTPUTPICTURES = 0;    p_vout->output.i_width  = p_vout->p_sys->mode.visible.x;    p_vout->output.i_height = p_vout->p_sys->mode.visible.y;    p_vout->output.i_aspect = p_vout->p_sys->mode.visible.x                               * VOUT_ASPECT_FACTOR                               / p_vout->p_sys->mode.visible.y;    switch( p_vout->p_sys->i_bits_per_pixel )    {        case 8:            p_vout->output.i_chroma = VLC_FOURCC('R','G','B','2');            p_vout->output.pf_setpalette = SetPalette;            break;        case 15:            p_vout->output.i_chroma = VLC_FOURCC('R','V','1','5'); break;        case 16:            p_vout->output.i_chroma = VLC_FOURCC('R','V','1','6'); break;        case 24:            p_vout->output.i_chroma = VLC_FOURCC('R','V','2','4'); break;        case 32:            p_vout->output.i_chroma = VLC_FOURCC('R','V','3','2'); break;        default:            msg_Err( p_vout, "unknown screen depth %i",                     p_vout->p_sys->i_bits_per_pixel );            return 0;    }    /* Only useful for bits_per_pixel != 8 */    p_vout->output.i_rmask = p_b[ 0 ]->buffer.plb.pixelformat->red_mask;    p_vout->output.i_gmask = p_b[ 0 ]->buffer.plb.pixelformat->green_mask;    p_vout->output.i_bmask = p_b[ 0 ]->buffer.plb.pixelformat->blue_mask;    p_pic = NULL;    /* Find an empty picture slot */    for( i_index = 0 ; i_index < VOUT_MAX_PICTURES ; i_index++ )    {        if( p_vout->p_picture[ i_index ].i_status == FREE_PICTURE )        {            p_pic = p_vout->p_picture + i_index;            break;        }    }    if( p_pic == NULL )    {        return 0;    }    /* We know the chroma, allocate a buffer which will be used     * directly by the decoder */    p_vout->p_sys->i_index = 0;    p_pic->p->p_pixels = p_b[ 0 ]->write;    p_pic->p->i_pixel_pitch = p_b[ 0 ]->buffer.plb.pixelformat->size / 8;    p_pic->p->i_lines = p_vout->p_sys->mode.visible.y;    p_pic->p->i_visible_lines = p_vout->p_sys->mode.visible.y;    p_pic->p->i_pitch = p_b[ 0 ]->buffer.plb.stride;    if( p_b[ 0 ]->buffer.plb.pixelformat->size / 8         * p_vout->p_sys->mode.visible.x        != p_b[ 0 ]->buffer.plb.stride )    {        p_pic->p->i_visible_pitch = p_b[ 0 ]->buffer.plb.pixelformat->size                                     / 8 * p_vout->p_sys->mode.visible.x;    }    else    {        p_pic->p->i_visible_pitch = p_b[ 0 ]->buffer.plb.stride;    }    p_pic->i_planes = 1;    p_pic->i_status = DESTROYED_PICTURE;    p_pic->i_type   = DIRECT_PICTURE;    PP_OUTPUTPICTURE[ I_OUTPUTPICTURES ] = p_pic;    I_OUTPUTPICTURES++;    /* Acquire first buffer */    if( p_vout->p_sys->b_must_acquire )    {        ggiResourceAcquire( p_b[ 0 ]->resource,                            GGI_ACTYPE_WRITE );    }    /* Listen to the keyboard and the mouse buttons */    ggiSetEventMask( p_vout->p_sys->p_display,                     emKeyboard | emPtrButtonPress | emPtrButtonRelease );    /* Set asynchronous display mode -- usually quite faster */    ggiAddFlags( p_vout->p_sys->p_display, GGIFLAG_ASYNC );    return( 0 );#undef p_b}/***************************************************************************** * End: terminate GGI video thread output method ***************************************************************************** * Terminate an output method created by Create *****************************************************************************/static void End( vout_thread_t *p_vout ){#define p_b p_vout->p_sys->pp_buffer    /* Release buffer */    if( p_vout->p_sys->b_must_acquire )    {        ggiResourceRelease( p_b[ p_vout->p_sys->i_index ]->resource );    }#undef p_b}/***************************************************************************** * Destroy: destroy GGI video thread output method ***************************************************************************** * Terminate an output method created by Create *****************************************************************************/static void Destroy( vlc_object_t *p_this ){    vout_thread_t *p_vout = (vout_thread_t *)p_this;    CloseDisplay( p_vout );    free( p_vout->p_sys );}/***************************************************************************** * Manage: handle GGI events ***************************************************************************** * This function should be called regularly by video output thread. It returns

⌨️ 快捷键说明

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