1 /*****************************************************************************
2 * vout_dummy.c: Dummy video output display method for testing purposes
3 *****************************************************************************
4 * Copyright (C) 2000, 2001 VideoLAN (Centrale Réseaux) and its contributors
7 * Authors: Samuel Hocevar <sam@zoy.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
27 #include <stdlib.h> /* free() */
28 #include <string.h> /* strerror() */
33 #define DUMMY_WIDTH 16
34 #define DUMMY_HEIGHT 16
35 #define DUMMY_MAX_DIRECTBUFFERS 10
37 /*****************************************************************************
39 *****************************************************************************/
40 static int Init ( vout_thread_t * );
41 static void End ( vout_thread_t * );
42 static int Manage ( vout_thread_t * );
43 static void Render ( vout_thread_t *, picture_t * );
44 static void Display ( vout_thread_t *, picture_t * );
45 static void SetPalette ( vout_thread_t *, uint16_t *, uint16_t *, uint16_t * );
47 /*****************************************************************************
48 * OpenVideo: activates dummy video thread output method
49 *****************************************************************************
50 * This function initializes a dummy vout method.
51 *****************************************************************************/
52 int E_(OpenVideo) ( vlc_object_t *p_this )
54 vout_thread_t * p_vout = (vout_thread_t *)p_this;
56 p_vout->pf_init = Init;
58 p_vout->pf_manage = Manage;
59 p_vout->pf_render = Render;
60 p_vout->pf_display = Display;
65 /*****************************************************************************
66 * Init: initialize dummy video thread output method
67 *****************************************************************************/
68 static int Init( vout_thread_t *p_vout )
70 int i_index, i_chroma;
73 vlc_bool_t b_chroma = 0;
75 psz_chroma = config_GetPsz( p_vout, "dummy-chroma" );
78 if( strlen( psz_chroma ) >= 4 )
80 i_chroma = VLC_FOURCC( psz_chroma[0], psz_chroma[1],
81 psz_chroma[2], psz_chroma[3] );
90 /* Initialize the output structure */
93 msg_Dbg( p_vout, "forcing chroma 0x%.8x (%4.4s)",
94 i_chroma, (char*)&i_chroma );
95 p_vout->output.i_chroma = i_chroma;
96 if ( i_chroma == VLC_FOURCC( 'R', 'G', 'B', '2' ) )
98 p_vout->output.pf_setpalette = SetPalette;
100 p_vout->output.i_width = p_vout->render.i_width;
101 p_vout->output.i_height = p_vout->render.i_height;
102 p_vout->output.i_aspect = p_vout->render.i_aspect;
106 /* Use same chroma as input */
107 p_vout->output.i_chroma = p_vout->render.i_chroma;
108 p_vout->output.i_rmask = p_vout->render.i_rmask;
109 p_vout->output.i_gmask = p_vout->render.i_gmask;
110 p_vout->output.i_bmask = p_vout->render.i_bmask;
111 p_vout->output.i_width = p_vout->render.i_width;
112 p_vout->output.i_height = p_vout->render.i_height;
113 p_vout->output.i_aspect = p_vout->render.i_aspect;
116 /* Try to initialize DUMMY_MAX_DIRECTBUFFERS direct buffers */
117 while( I_OUTPUTPICTURES < DUMMY_MAX_DIRECTBUFFERS )
121 /* Find an empty picture slot */
122 for( i_index = 0 ; i_index < VOUT_MAX_PICTURES ; i_index++ )
124 if( p_vout->p_picture[ i_index ].i_status == FREE_PICTURE )
126 p_pic = p_vout->p_picture + i_index;
131 /* Allocate the picture */
137 vout_AllocatePicture( VLC_OBJECT(p_vout), p_pic, p_vout->output.i_chroma,
138 p_vout->output.i_width, p_vout->output.i_height,
139 p_vout->output.i_aspect );
141 if( p_pic->i_planes == 0 )
146 p_pic->i_status = DESTROYED_PICTURE;
147 p_pic->i_type = DIRECT_PICTURE;
149 PP_OUTPUTPICTURE[ I_OUTPUTPICTURES ] = p_pic;
157 /*****************************************************************************
158 * End: terminate dummy video thread output method
159 *****************************************************************************/
160 static void End( vout_thread_t *p_vout )
164 /* Free the fake output buffers we allocated */
165 for( i_index = I_OUTPUTPICTURES ; i_index ; )
168 free( PP_OUTPUTPICTURE[ i_index ]->p_data_orig );
172 /*****************************************************************************
173 * Manage: handle dummy events
174 *****************************************************************************
175 * This function should be called regularly by video output thread. It manages
176 * console events. It returns a non null value on error.
177 *****************************************************************************/
178 static int Manage( vout_thread_t *p_vout )
183 /*****************************************************************************
184 * Render: render previously calculated output
185 *****************************************************************************/
186 static void Render( vout_thread_t *p_vout, picture_t *p_pic )
188 /* No need to do anything, the fake direct buffers stay as they are */
191 /*****************************************************************************
192 * Display: displays previously rendered output
193 *****************************************************************************/
194 static void Display( vout_thread_t *p_vout, picture_t *p_pic )
196 /* No need to do anything, the fake direct buffers stay as they are */
199 /*****************************************************************************
200 * SetPalette: set the palette for the picture
201 *****************************************************************************/
202 static void SetPalette ( vout_thread_t *p_vout,
203 uint16_t *red, uint16_t *green, uint16_t *blue )
205 /* No need to do anything, the fake direct buffers stay as they are */