Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

vout.c

00001 /*****************************************************************************
00002  * vout_dummy.c: Dummy video output display method for testing purposes
00003  *****************************************************************************
00004  * Copyright (C) 2000, 2001 the VideoLAN team
00005  * $Id: vout.c 11664 2005-07-09 06:17:09Z courmisch $
00006  *
00007  * Authors: Samuel Hocevar <[email protected]>
00008  *
00009  * This program is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
00022  *****************************************************************************/
00023 
00024 /*****************************************************************************
00025  * Preamble
00026  *****************************************************************************/
00027 #include <stdlib.h>                                                /* free() */
00028 #include <string.h>                                            /* strerror() */
00029 
00030 #include <vlc/vlc.h>
00031 #include <vlc/vout.h>
00032 
00033 #define DUMMY_WIDTH 16
00034 #define DUMMY_HEIGHT 16
00035 #define DUMMY_MAX_DIRECTBUFFERS 10
00036 
00037 /*****************************************************************************
00038  * Local prototypes
00039  *****************************************************************************/
00040 static int  Init       ( vout_thread_t * );
00041 static void End        ( vout_thread_t * );
00042 static int  Manage     ( vout_thread_t * );
00043 static void Render     ( vout_thread_t *, picture_t * );
00044 static void Display    ( vout_thread_t *, picture_t * );
00045 static void SetPalette ( vout_thread_t *, uint16_t *, uint16_t *, uint16_t * );
00046 
00047 /*****************************************************************************
00048  * OpenVideo: activates dummy video thread output method
00049  *****************************************************************************
00050  * This function initializes a dummy vout method.
00051  *****************************************************************************/
00052 int E_(OpenVideo) ( vlc_object_t *p_this )
00053 {
00054     vout_thread_t * p_vout = (vout_thread_t *)p_this;
00055 
00056     p_vout->pf_init = Init;
00057     p_vout->pf_end = End;
00058     p_vout->pf_manage = Manage;
00059     p_vout->pf_render = Render;
00060     p_vout->pf_display = Display;
00061 
00062     return VLC_SUCCESS;
00063 }
00064 
00065 /*****************************************************************************
00066  * Init: initialize dummy video thread output method
00067  *****************************************************************************/
00068 static int Init( vout_thread_t *p_vout )
00069 {
00070     int i_index, i_chroma;
00071     char *psz_chroma;
00072     picture_t *p_pic;
00073     vlc_bool_t b_chroma = 0;
00074 
00075     psz_chroma = config_GetPsz( p_vout, "dummy-chroma" );
00076     if( psz_chroma )
00077     {
00078         if( strlen( psz_chroma ) >= 4 )
00079         {
00080             i_chroma = VLC_FOURCC( psz_chroma[0], psz_chroma[1],
00081                                    psz_chroma[2], psz_chroma[3] );
00082             b_chroma = 1;
00083         }
00084 
00085         free( psz_chroma );
00086     }
00087 
00088     I_OUTPUTPICTURES = 0;
00089 
00090     /* Initialize the output structure */
00091     if( b_chroma )
00092     {
00093         msg_Dbg( p_vout, "forcing chroma 0x%.8x (%4.4s)",
00094                          i_chroma, (char*)&i_chroma );
00095         p_vout->output.i_chroma = i_chroma;
00096         if ( i_chroma == VLC_FOURCC( 'R', 'G', 'B', '2' ) )
00097         {
00098             p_vout->output.pf_setpalette = SetPalette;
00099         }
00100         p_vout->output.i_width  = p_vout->render.i_width;
00101         p_vout->output.i_height = p_vout->render.i_height;
00102         p_vout->output.i_aspect = p_vout->render.i_aspect;
00103     }
00104     else
00105     {
00106         /* Use same chroma as input */
00107         p_vout->output.i_chroma = p_vout->render.i_chroma;
00108         p_vout->output.i_rmask  = p_vout->render.i_rmask;
00109         p_vout->output.i_gmask  = p_vout->render.i_gmask;
00110         p_vout->output.i_bmask  = p_vout->render.i_bmask;
00111         p_vout->output.i_width  = p_vout->render.i_width;
00112         p_vout->output.i_height = p_vout->render.i_height;
00113         p_vout->output.i_aspect = p_vout->render.i_aspect;
00114     }
00115 
00116     /* Try to initialize DUMMY_MAX_DIRECTBUFFERS direct buffers */
00117     while( I_OUTPUTPICTURES < DUMMY_MAX_DIRECTBUFFERS )
00118     {
00119         p_pic = NULL;
00120 
00121         /* Find an empty picture slot */
00122         for( i_index = 0 ; i_index < VOUT_MAX_PICTURES ; i_index++ )
00123         {
00124             if( p_vout->p_picture[ i_index ].i_status == FREE_PICTURE )
00125             {
00126                 p_pic = p_vout->p_picture + i_index;
00127                 break;
00128             }
00129         }
00130 
00131         /* Allocate the picture */
00132         if( p_pic == NULL )
00133         {
00134             break;
00135         }
00136 
00137         vout_AllocatePicture( VLC_OBJECT(p_vout), p_pic, p_vout->output.i_chroma,
00138                               p_vout->output.i_width, p_vout->output.i_height,
00139                               p_vout->output.i_aspect );
00140 
00141         if( p_pic->i_planes == 0 )
00142         {
00143             break;
00144         }
00145 
00146         p_pic->i_status = DESTROYED_PICTURE;
00147         p_pic->i_type   = DIRECT_PICTURE;
00148 
00149         PP_OUTPUTPICTURE[ I_OUTPUTPICTURES ] = p_pic;
00150 
00151         I_OUTPUTPICTURES++;
00152     }
00153 
00154     return( 0 );
00155 }
00156 
00157 /*****************************************************************************
00158  * End: terminate dummy video thread output method
00159  *****************************************************************************/
00160 static void End( vout_thread_t *p_vout )
00161 {
00162     int i_index;
00163 
00164     /* Free the fake output buffers we allocated */
00165     for( i_index = I_OUTPUTPICTURES ; i_index ; )
00166     {
00167         i_index--;
00168         free( PP_OUTPUTPICTURE[ i_index ]->p_data_orig );
00169     }
00170 }
00171 
00172 /*****************************************************************************
00173  * Manage: handle dummy events
00174  *****************************************************************************
00175  * This function should be called regularly by video output thread. It manages
00176  * console events. It returns a non null value on error.
00177  *****************************************************************************/
00178 static int Manage( vout_thread_t *p_vout )
00179 {
00180     return( 0 );
00181 }
00182 
00183 /*****************************************************************************
00184  * Render: render previously calculated output
00185  *****************************************************************************/
00186 static void Render( vout_thread_t *p_vout, picture_t *p_pic )
00187 {
00188     /* No need to do anything, the fake direct buffers stay as they are */
00189 }
00190 
00191 /*****************************************************************************
00192  * Display: displays previously rendered output
00193  *****************************************************************************/
00194 static void Display( vout_thread_t *p_vout, picture_t *p_pic )
00195 {
00196     /* No need to do anything, the fake direct buffers stay as they are */
00197 }
00198 
00199 /*****************************************************************************
00200  * SetPalette: set the palette for the picture
00201  *****************************************************************************/
00202 static void SetPalette ( vout_thread_t *p_vout,
00203                          uint16_t *red, uint16_t *green, uint16_t *blue )
00204 {
00205     /* No need to do anything, the fake direct buffers stay as they are */
00206 }

Generated on Tue Dec 20 10:14:41 2005 for vlc-0.8.4a by  doxygen 1.4.2