typo fixes
[mplayer/greg.git] / libvo / video_out.c
blobf4ff125d51010796d51b71e0cb60728e0c6c5874
2 /* this file contains libvo's common functions, variables used by
3 many/all drivers. */
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <string.h>
9 #include <unistd.h>
10 //#include <sys/mman.h>
12 #include "config.h"
13 #include "video_out.h"
15 #include "mp_msg.h"
16 #include "help_mp.h"
18 #include "osdep/shmem.h"
20 //int vo_flags=0;
22 int xinerama_screen = -1;
23 int xinerama_x;
24 int xinerama_y;
26 // currect resolution/bpp on screen: (should be autodetected by vo_init())
27 int vo_depthonscreen=0;
28 int vo_screenwidth=0;
29 int vo_screenheight=0;
31 int vo_config_count=0;
33 // requested resolution/bpp: (-x -y -bpp options)
34 int vo_dx=0;
35 int vo_dy=0;
36 int vo_dwidth=0;
37 int vo_dheight=0;
38 int vo_dbpp=0;
40 int vo_nomouse_input = 0;
41 int vo_grabpointer = 1;
42 int vo_doublebuffering = 1;
43 int vo_vsync = 0;
44 int vo_fs = 0;
45 int vo_fsmode = 0;
46 float vo_panscan = 0.0f;
47 int vo_ontop = 0;
48 int vo_adapter_num=0;
49 int vo_refresh_rate=0;
50 int vo_keepaspect=1;
51 int vo_rootwin=0;
52 int vo_border=1;
53 int WinID = -1;
55 int vo_pts=0; // for hw decoding
56 float vo_fps=0; // for mp1e rte
58 char *vo_subdevice = NULL;
59 int vo_directrendering=0;
61 int vo_colorkey = 0x0000ff00; // default colorkey is green
62 // (0xff000000 means that colorkey has been disabled)
65 // Externally visible list of all vo drivers
67 extern vo_functions_t video_out_mga;
68 extern vo_functions_t video_out_xmga;
69 extern vo_functions_t video_out_x11;
70 extern vo_functions_t video_out_xover;
71 extern vo_functions_t video_out_xvmc;
72 extern vo_functions_t video_out_xv;
73 extern vo_functions_t video_out_gl;
74 extern vo_functions_t video_out_gl2;
75 extern vo_functions_t video_out_dga;
76 extern vo_functions_t video_out_fsdga;
77 extern vo_functions_t video_out_sdl;
78 extern vo_functions_t video_out_3dfx;
79 extern vo_functions_t video_out_tdfxfb;
80 extern vo_functions_t video_out_s3fb;
81 extern vo_functions_t video_out_null;
82 //extern vo_functions_t video_out_odivx;
83 extern vo_functions_t video_out_zr;
84 extern vo_functions_t video_out_zr2;
85 extern vo_functions_t video_out_bl;
86 extern vo_functions_t video_out_syncfb;
87 extern vo_functions_t video_out_fbdev;
88 extern vo_functions_t video_out_fbdev2;
89 extern vo_functions_t video_out_svga;
90 extern vo_functions_t video_out_png;
91 extern vo_functions_t video_out_ggi;
92 extern vo_functions_t video_out_aa;
93 extern vo_functions_t video_out_caca;
94 extern vo_functions_t video_out_mpegpes;
95 extern vo_functions_t video_out_yuv4mpeg;
96 #ifdef HAVE_DIRECTX
97 extern vo_functions_t video_out_directx;
98 #endif
99 #ifdef HAVE_DXR2
100 extern vo_functions_t video_out_dxr2;
101 #endif
102 extern vo_functions_t video_out_dxr3;
103 #ifdef HAVE_JPEG
104 extern vo_functions_t video_out_jpeg;
105 #endif
106 #ifdef HAVE_GIF
107 extern vo_functions_t video_out_gif89a;
108 #endif
109 #ifdef HAVE_VESA
110 extern vo_functions_t video_out_vesa;
111 #endif
112 #ifdef HAVE_DIRECTFB
113 extern vo_functions_t video_out_directfb;
114 #if DIRECTFBVERSION >= 915
115 extern vo_functions_t video_out_dfbmga;
116 #endif
117 #endif
118 #ifdef CONFIG_VIDIX
119 extern vo_functions_t video_out_xvidix;
120 extern vo_functions_t video_out_winvidix;
121 extern vo_functions_t video_out_cvidix;
122 #endif
123 #ifdef HAVE_TDFX_VID
124 extern vo_functions_t video_out_tdfx_vid;
125 #endif
126 #ifdef HAVE_TGA
127 extern vo_functions_t video_out_tga;
128 #endif
129 #ifdef MACOSX
130 #ifdef MACOSX_COREVIDEO
131 extern vo_functions_t video_out_macosx;
132 #endif
133 extern vo_functions_t video_out_quartz;
134 #endif
135 #ifdef HAVE_PNM
136 extern vo_functions_t video_out_pnm;
137 #endif
138 #ifdef HAVE_MD5SUM
139 extern vo_functions_t video_out_md5sum;
140 #endif
142 vo_functions_t* video_out_drivers[] =
144 #ifdef HAVE_TDFX_VID
145 &video_out_tdfx_vid,
146 #endif
147 #ifdef HAVE_DIRECTX
148 &video_out_directx,
149 #endif
150 #ifdef MACOSX
151 #ifdef MACOSX_COREVIDEO
152 &video_out_macosx,
153 #endif
154 &video_out_quartz,
155 #endif
156 #ifdef HAVE_XMGA
157 &video_out_xmga,
158 #endif
159 #ifdef HAVE_MGA
160 &video_out_mga,
161 #endif
162 #ifdef HAVE_SYNCFB
163 &video_out_syncfb,
164 #endif
165 #ifdef HAVE_TDFXFB
166 &video_out_tdfxfb,
167 #endif
168 #ifdef HAVE_S3FB
169 &video_out_s3fb,
170 #endif
171 #ifdef HAVE_3DFX
172 &video_out_3dfx,
173 #endif
174 #ifdef HAVE_XV
175 &video_out_xv,
176 #endif
177 #ifdef HAVE_X11
178 &video_out_x11,
179 &video_out_xover,
180 #endif
181 #ifdef HAVE_GL
182 &video_out_gl,
183 &video_out_gl2,
184 #endif
185 #ifdef HAVE_DGA
186 &video_out_dga,
187 // &video_out_fsdga,
188 #endif
189 #ifdef HAVE_SDL
190 &video_out_sdl,
191 #endif
192 #ifdef HAVE_GGI
193 &video_out_ggi,
194 #endif
195 #ifdef HAVE_FBDEV
196 &video_out_fbdev,
197 &video_out_fbdev2,
198 #endif
199 #ifdef HAVE_SVGALIB
200 &video_out_svga,
201 #endif
202 #ifdef HAVE_AA
203 &video_out_aa,
204 #endif
205 #ifdef HAVE_CACA
206 &video_out_caca,
207 #endif
208 #ifdef HAVE_DXR2
209 &video_out_dxr2,
210 #endif
211 #ifdef HAVE_DXR3
212 &video_out_dxr3,
213 #endif
214 #ifdef HAVE_ZR
215 &video_out_zr,
216 &video_out_zr2,
217 #endif
218 #ifdef HAVE_BL
219 &video_out_bl,
220 #endif
221 #ifdef HAVE_VESA
222 &video_out_vesa,
223 #endif
224 #ifdef HAVE_DIRECTFB
225 &video_out_directfb,
226 #if DIRECTFBVERSION >= 915
227 &video_out_dfbmga,
228 #endif
229 #endif
230 #ifdef CONFIG_VIDIX
231 #ifdef HAVE_X11
232 &video_out_xvidix,
233 #endif
234 #ifdef WIN32
235 &video_out_winvidix,
236 #endif
237 &video_out_cvidix,
238 #endif
239 &video_out_null,
240 // should not be auto-selected
241 #ifdef HAVE_XVMC
242 &video_out_xvmc,
243 #endif
244 &video_out_mpegpes,
245 &video_out_yuv4mpeg,
246 #ifdef HAVE_PNG
247 &video_out_png,
248 #endif
249 #ifdef HAVE_JPEG
250 &video_out_jpeg,
251 #endif
252 #ifdef HAVE_GIF
253 &video_out_gif89a,
254 #endif
255 #ifdef HAVE_TGA
256 &video_out_tga,
257 #endif
258 #ifdef HAVE_PNM
259 &video_out_pnm,
260 #endif
261 #ifdef HAVE_MD5SUM
262 &video_out_md5sum,
263 #endif
264 NULL
267 void list_video_out(void){
268 int i=0;
269 mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_AvailableVideoOutputDrivers);
270 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_OUTPUTS\n");
271 while (video_out_drivers[i]) {
272 const vo_info_t *info = video_out_drivers[i++]->info;
273 mp_msg(MSGT_GLOBAL, MSGL_INFO,"\t%s\t%s\n", info->short_name, info->name);
275 mp_msg(MSGT_GLOBAL, MSGL_INFO,"\n");
278 vo_functions_t* init_best_video_out(char** vo_list){
279 int i;
280 // first try the preferred drivers, with their optional subdevice param:
281 if(vo_list && vo_list[0])
282 while(vo_list[0][0]){
283 char* vo=strdup(vo_list[0]);
284 vo_subdevice=strchr(vo,':');
285 if (!strcmp(vo, "pgm"))
286 mp_msg(MSGT_CPLAYER, MSGL_ERR, MSGTR_VO_PGM_HasBeenReplaced);
287 if (!strcmp(vo, "md5"))
288 mp_msg(MSGT_CPLAYER, MSGL_ERR, MSGTR_VO_MD5_HasBeenReplaced);
289 if(vo_subdevice){
290 vo_subdevice[0]=0;
291 ++vo_subdevice;
293 for(i=0;video_out_drivers[i];i++){
294 vo_functions_t* video_driver=video_out_drivers[i];
295 const vo_info_t *info = video_driver->info;
296 if(!strcmp(info->short_name,vo)){
297 // name matches, try it
298 if(!video_driver->preinit(vo_subdevice))
300 free(vo);
301 return video_driver; // success!
305 // continue...
306 free(vo);
307 ++vo_list;
308 if(!(vo_list[0])) return NULL; // do NOT fallback to others
310 // now try the rest...
311 vo_subdevice=NULL;
312 for(i=0;video_out_drivers[i];i++){
313 vo_functions_t* video_driver=video_out_drivers[i];
314 if(!video_driver->preinit(vo_subdevice))
315 return video_driver; // success!
317 return NULL;
321 #if defined(HAVE_FBDEV)||defined(HAVE_VESA)
322 /* Borrowed from vo_fbdev.c
323 Monitor ranges related functions*/
325 char *monitor_hfreq_str = NULL;
326 char *monitor_vfreq_str = NULL;
327 char *monitor_dotclock_str = NULL;
329 float range_max(range_t *r)
331 float max = 0;
333 for (/* NOTHING */; (r->min != -1 && r->max != -1); r++)
334 if (max < r->max) max = r->max;
335 return max;
339 int in_range(range_t *r, float f)
341 for (/* NOTHING */; (r->min != -1 && r->max != -1); r++)
342 if (f >= r->min && f <= r->max)
343 return 1;
344 return 0;
347 range_t *str2range(char *s)
349 float tmp_min, tmp_max;
350 char *endptr = s; // to start the loop
351 range_t *r = NULL;
352 int i;
354 if (!s)
355 return NULL;
356 for (i = 0; *endptr; i++) {
357 if (*s == ',')
358 goto out_err;
359 if (!(r = (range_t *) realloc(r, sizeof(*r) * (i + 2)))) {
360 mp_msg(MSGT_GLOBAL, MSGL_WARN,"can't realloc 'r'\n");
361 return NULL;
363 tmp_min = strtod(s, &endptr);
364 if (*endptr == 'k' || *endptr == 'K') {
365 tmp_min *= 1000.0;
366 endptr++;
367 } else if (*endptr == 'm' || *endptr == 'M') {
368 tmp_min *= 1000000.0;
369 endptr++;
371 if (*endptr == '-') {
372 tmp_max = strtod(endptr + 1, &endptr);
373 if (*endptr == 'k' || *endptr == 'K') {
374 tmp_max *= 1000.0;
375 endptr++;
376 } else if (*endptr == 'm' || *endptr == 'M') {
377 tmp_max *= 1000000.0;
378 endptr++;
380 if (*endptr != ',' && *endptr)
381 goto out_err;
382 } else if (*endptr == ',' || !*endptr) {
383 tmp_max = tmp_min;
384 } else
385 goto out_err;
386 r[i].min = tmp_min;
387 r[i].max = tmp_max;
388 if (r[i].min < 0 || r[i].max < 0)
389 goto out_err;
390 s = endptr + 1;
392 r[i].min = r[i].max = -1;
393 return r;
394 out_err:
395 if (r)
396 free(r);
397 return NULL;
400 /* Borrowed from vo_fbdev.c END */
401 #endif