1 /*****************************************************************************
2 * vout_dummy.c: Dummy video output display method for testing purposes
3 *****************************************************************************
4 * Copyright (C) 2000, 2001 VideoLAN
5 * $Id: vout_dummy.c,v 1.25 2002/07/20 18:01:42 sam Exp $
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 <errno.h> /* ENOMEM */
28 #include <stdlib.h> /* free() */
29 #include <string.h> /* strerror() */
34 #define DUMMY_WIDTH 16
35 #define DUMMY_HEIGHT 16
36 #define DUMMY_MAX_DIRECTBUFFERS 10
38 /*****************************************************************************
39 * vout_sys_t: dummy video output method descriptor
40 *****************************************************************************
41 * This structure is part of the video output thread descriptor.
42 * It describes the dummy specific properties of an output thread.
43 *****************************************************************************/
46 /* Nothing needed here. Maybe stats ? */
48 /* Prevent malloc(0) */
52 /*****************************************************************************
54 *****************************************************************************/
55 static int vout_Create ( vout_thread_t * );
56 static int vout_Init ( vout_thread_t * );
57 static void vout_End ( vout_thread_t * );
58 static void vout_Destroy ( vout_thread_t * );
59 static int vout_Manage ( vout_thread_t * );
60 static void vout_Render ( vout_thread_t *, picture_t * );
61 static void vout_Display ( vout_thread_t *, picture_t * );
63 /*****************************************************************************
64 * Functions exported as capabilities. They are declared as static so that
65 * we don't pollute the namespace too much.
66 *****************************************************************************/
67 void _M( vout_getfunctions )( function_list_t * p_function_list )
69 p_function_list->functions.vout.pf_create = vout_Create;
70 p_function_list->functions.vout.pf_init = vout_Init;
71 p_function_list->functions.vout.pf_end = vout_End;
72 p_function_list->functions.vout.pf_destroy = vout_Destroy;
73 p_function_list->functions.vout.pf_manage = vout_Manage;
74 p_function_list->functions.vout.pf_render = vout_Render;
75 p_function_list->functions.vout.pf_display = vout_Display;
78 /*****************************************************************************
79 * vout_Create: allocates dummy video thread output method
80 *****************************************************************************
81 * This function allocates and initializes a dummy vout method.
82 *****************************************************************************/
83 static int vout_Create( vout_thread_t *p_vout )
85 /* Allocate structure */
86 p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
87 if( p_vout->p_sys == NULL )
89 msg_Err( p_vout, "out of memory" );
96 /*****************************************************************************
97 * vout_Init: initialize dummy video thread output method
98 *****************************************************************************/
99 static int vout_Init( vout_thread_t *p_vout )
101 int i_index, i_chroma;
104 vlc_bool_t b_chroma = 0;
106 psz_chroma = config_GetPsz( p_vout, "dummy-chroma" );
109 if( strlen( psz_chroma ) >= 4 )
111 i_chroma = (unsigned char)psz_chroma[0] << 0;
112 i_chroma |= (unsigned char)psz_chroma[1] << 8;
113 i_chroma |= (unsigned char)psz_chroma[2] << 16;
114 i_chroma |= (unsigned char)psz_chroma[3] << 24;
122 I_OUTPUTPICTURES = 0;
124 /* Initialize the output structure */
127 msg_Dbg( p_vout, "forcing chroma 0x%.8x (%4.4s)",
128 i_chroma, (char*)&i_chroma );
129 p_vout->output.i_chroma = i_chroma;
130 p_vout->output.i_width = p_vout->render.i_width;
131 p_vout->output.i_height = p_vout->render.i_height;
132 p_vout->output.i_aspect = p_vout->render.i_aspect;
136 p_vout->output.i_chroma = FOURCC_RV16;
137 p_vout->output.i_rmask = 0xf800;
138 p_vout->output.i_gmask = 0x07e0;
139 p_vout->output.i_bmask = 0x001f;
140 p_vout->output.i_width = p_vout->render.i_width;
141 p_vout->output.i_height = p_vout->render.i_height;
142 p_vout->output.i_aspect = p_vout->render.i_aspect;
145 /* Try to initialize DUMMY_MAX_DIRECTBUFFERS direct buffers */
146 while( I_OUTPUTPICTURES < DUMMY_MAX_DIRECTBUFFERS )
150 /* Find an empty picture slot */
151 for( i_index = 0 ; i_index < VOUT_MAX_PICTURES ; i_index++ )
153 if( p_vout->p_picture[ i_index ].i_status == FREE_PICTURE )
155 p_pic = p_vout->p_picture + i_index;
160 /* Allocate the picture */
166 vout_AllocatePicture( p_vout, p_pic, p_vout->output.i_width,
167 p_vout->output.i_height,
168 p_vout->output.i_chroma );
170 if( p_pic->i_planes == 0 )
175 p_pic->i_status = DESTROYED_PICTURE;
176 p_pic->i_type = DIRECT_PICTURE;
178 PP_OUTPUTPICTURE[ I_OUTPUTPICTURES ] = p_pic;
186 /*****************************************************************************
187 * vout_End: terminate dummy video thread output method
188 *****************************************************************************/
189 static void vout_End( vout_thread_t *p_vout )
193 /* Free the fake output buffers we allocated */
194 for( i_index = I_OUTPUTPICTURES ; i_index ; )
197 free( PP_OUTPUTPICTURE[ i_index ]->p_data_orig );
201 /*****************************************************************************
202 * vout_Destroy: destroy dummy video thread output method
203 *****************************************************************************
204 * Terminate an output method created by DummyCreateOutputMethod
205 *****************************************************************************/
206 static void vout_Destroy( vout_thread_t *p_vout )
208 free( p_vout->p_sys );
211 /*****************************************************************************
212 * vout_Manage: handle dummy events
213 *****************************************************************************
214 * This function should be called regularly by video output thread. It manages
215 * console events. It returns a non null value on error.
216 *****************************************************************************/
217 static int vout_Manage( vout_thread_t *p_vout )
222 /*****************************************************************************
223 * vout_Render: render previously calculated output
224 *****************************************************************************/
225 static void vout_Render( vout_thread_t *p_vout, picture_t *p_pic )
227 /* No need to do anything, the fake direct buffers stay as they are */
230 /*****************************************************************************
231 * vout_Display: displays previously rendered output
232 *****************************************************************************/
233 static void vout_Display( vout_thread_t *p_vout, picture_t *p_pic )
235 /* No need to do anything, the fake direct buffers stay as they are */