00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include <stdlib.h>
00028
00029 #include <vlc/vlc.h>
00030 #include <vlc/vout.h>
00031
00032 #include <vga.h>
00033 #include <vgagl.h>
00034 #include <vgakeyboard.h>
00035
00036
00037
00038
00039 static int Create ( vlc_object_t * );
00040 static void Destroy ( vlc_object_t * );
00041
00042 static int Init ( vout_thread_t * );
00043 static void End ( vout_thread_t * );
00044 static int Manage ( vout_thread_t * );
00045 static void Display ( vout_thread_t *, picture_t * );
00046
00047 static void SetPalette( vout_thread_t *, uint16_t *, uint16_t *, uint16_t * );
00048
00049
00050
00051
00052 vlc_module_begin();
00053 set_shortname( "SVGAlib" );
00054 set_category( CAT_VIDEO );
00055 set_subcategory( SUBCAT_VIDEO_VOUT );
00056 set_description( _("SVGAlib video output") );
00057 set_capability( "video output", 0 );
00058 set_callbacks( Create, Destroy );
00059 linked_with_a_crap_library_which_uses_atexit();
00060 vlc_module_end();
00061
00062
00063
00064
00065
00066
00067
00068 struct vout_sys_t
00069 {
00070 int i_vgamode;
00071 };
00072
00073
00074
00075
00076
00077
00078 static int Create( vlc_object_t *p_this )
00079 {
00080 vout_thread_t *p_vout = (vout_thread_t *)p_this;
00081
00082
00083 p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
00084 if( p_vout->p_sys == NULL )
00085 {
00086 return VLC_ENOMEM;
00087 }
00088
00089
00090
00091
00092
00093
00094
00095 p_vout->pf_init = Init;
00096 p_vout->pf_end = End;
00097 p_vout->pf_manage = Manage;
00098 p_vout->pf_render = NULL;
00099 p_vout->pf_display = Display;
00100
00101 return VLC_SUCCESS;
00102 }
00103
00104
00105
00106
00107 static int Init( vout_thread_t *p_vout )
00108 {
00109 int i_index;
00110 picture_t *p_pic;
00111
00112 I_OUTPUTPICTURES = 0;
00113
00114
00115 vga_disabledriverreport();
00116
00117
00118
00119 vga_init();
00120
00121
00122 p_vout->p_sys->i_vgamode = vga_getdefaultmode();
00123 if( p_vout->p_sys->i_vgamode == -1
00124 || vga_getmodeinfo(p_vout->p_sys->i_vgamode)->bytesperpixel != 1 )
00125 {
00126 p_vout->p_sys->i_vgamode = G320x200x256;
00127 }
00128
00129 if( !vga_hasmode( p_vout->p_sys->i_vgamode ) )
00130 {
00131 msg_Err( p_vout, "mode %i not available", p_vout->p_sys->i_vgamode );
00132 return VLC_EGENERIC;
00133 }
00134
00135 vga_setmode( p_vout->p_sys->i_vgamode );
00136 gl_setcontextvga( p_vout->p_sys->i_vgamode );
00137 gl_enableclipping();
00138
00139 if( keyboard_init() )
00140 {
00141 msg_Err( p_vout, "could not initialize keyboard" );
00142 vga_setmode( TEXT );
00143 return VLC_EGENERIC;
00144 }
00145
00146
00147 keyboard_translatekeys( TRANSLATE_CURSORKEYS |
00148 TRANSLATE_KEYPADENTER |
00149 TRANSLATE_DIAGONAL );
00150
00151
00152
00153 p_vout->output.i_chroma = VLC_FOURCC('R','G','B','2');
00154 p_vout->output.pf_setpalette = SetPalette;
00155 p_vout->output.i_width = vga_getxdim();
00156 p_vout->output.i_height = vga_getydim();
00157 p_vout->output.i_aspect = p_vout->output.i_width
00158 * VOUT_ASPECT_FACTOR / p_vout->output.i_height;
00159
00160
00161 p_pic = NULL;
00162
00163
00164 for( i_index = 0 ; i_index < VOUT_MAX_PICTURES ; i_index++ )
00165 {
00166 if( p_vout->p_picture[ i_index ].i_status == FREE_PICTURE )
00167 {
00168 p_pic = p_vout->p_picture + i_index;
00169 break;
00170 }
00171 }
00172
00173
00174 if( p_pic == NULL )
00175 {
00176 return VLC_SUCCESS;
00177 }
00178
00179 vout_AllocatePicture( p_vout, p_pic, p_vout->output.i_chroma,
00180 p_vout->output.i_width, p_vout->output.i_height,
00181 p_vout->output.i_aspect );
00182
00183 if( p_pic->i_planes == 0 )
00184 {
00185 return VLC_SUCCESS;
00186 }
00187
00188 p_pic->i_status = DESTROYED_PICTURE;
00189 p_pic->i_type = DIRECT_PICTURE;
00190
00191 PP_OUTPUTPICTURE[ I_OUTPUTPICTURES ] = p_pic;
00192
00193 I_OUTPUTPICTURES++;
00194
00195 return VLC_SUCCESS;
00196 }
00197
00198
00199
00200
00201 static void End( vout_thread_t *p_vout )
00202 {
00203 keyboard_close();
00204 vga_clear();
00205 vga_setmode( TEXT );
00206 }
00207
00208
00209
00210
00211
00212
00213 static void Destroy( vlc_object_t *p_this )
00214 {
00215 vout_thread_t *p_vout = (vout_thread_t *)p_this;
00216
00217
00218 free( p_vout->p_sys );
00219 }
00220
00221
00222
00223
00224
00225
00226
00227 static int Manage( vout_thread_t *p_vout )
00228 {
00229 keyboard_update();
00230
00231 if( keyboard_keypressed(SCANCODE_ESCAPE)
00232 || keyboard_keypressed(SCANCODE_Q ) )
00233 {
00234 p_vout->p_vlc->b_die = VLC_TRUE;
00235 }
00236
00237 return VLC_SUCCESS;
00238 }
00239
00240
00241
00242
00243
00244
00245 static void Display( vout_thread_t *p_vout, picture_t *p_pic )
00246 {
00247 gl_putbox( 0, 0, p_vout->output.i_width,
00248 p_vout->output.i_height, p_pic->p->p_pixels );
00249 }
00250
00251
00252
00253
00254
00255
00256 static void SetPalette( vout_thread_t *p_vout,
00257 uint16_t *red, uint16_t *green, uint16_t *blue )
00258 {
00259 int i = 256;
00260
00261 while( i-- )
00262 {
00263 vga_setpalette( i, red[i]>>10, green[i]>>10, blue[i]>>10 );
00264 }
00265 }
00266