2 /* this file contains libvo's common functions, variables used by
10 //#include <sys/mman.h>
13 #include "video_out.h"
20 #include "osdep/shmem.h"
24 int xinerama_screen
= -1;
28 // currect resolution/bpp on screen: (should be autodetected by vo_init())
29 int vo_depthonscreen
=0;
31 int vo_screenheight
=0;
33 int vo_config_count
=0;
35 // requested resolution/bpp: (-x -y -bpp options)
42 int vo_nomouse_input
= 0;
43 int vo_grabpointer
= 1;
44 int vo_doublebuffering
= 1;
48 float vo_panscan
= 0.0f
;
51 int vo_refresh_rate
=0;
57 int vo_pts
=0; // for hw decoding
60 char *vo_subdevice
= NULL
;
61 int vo_directrendering
=0;
63 int vo_colorkey
= 0x0000ff00; // default colorkey is green
64 // (0xff000000 means that colorkey has been disabled)
67 // Externally visible list of all vo drivers
69 extern vo_functions_t video_out_mga
;
70 extern vo_functions_t video_out_xmga
;
71 extern vo_functions_t video_out_x11
;
72 extern vo_functions_t video_out_xover
;
73 extern vo_functions_t video_out_xvmc
;
74 extern vo_functions_t video_out_xv
;
75 extern vo_functions_t video_out_gl
;
76 extern vo_functions_t video_out_gl2
;
77 extern vo_functions_t video_out_dga
;
78 extern vo_functions_t video_out_sdl
;
79 extern vo_functions_t video_out_3dfx
;
80 extern vo_functions_t video_out_tdfxfb
;
81 extern vo_functions_t video_out_s3fb
;
82 extern vo_functions_t video_out_null
;
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_fbdev
;
87 extern vo_functions_t video_out_fbdev2
;
88 extern vo_functions_t video_out_svga
;
89 extern vo_functions_t video_out_png
;
90 extern vo_functions_t video_out_ggi
;
91 extern vo_functions_t video_out_aa
;
92 extern vo_functions_t video_out_caca
;
93 extern vo_functions_t video_out_mpegpes
;
94 extern vo_functions_t video_out_yuv4mpeg
;
96 extern vo_functions_t video_out_directx
;
99 extern vo_functions_t video_out_dxr2
;
101 extern vo_functions_t video_out_dxr3
;
103 extern vo_functions_t video_out_ivtv
;
105 #ifdef HAVE_V4L2_DECODER
106 extern vo_functions_t video_out_v4l2
;
109 extern vo_functions_t video_out_jpeg
;
112 extern vo_functions_t video_out_gif89a
;
115 extern vo_functions_t video_out_vesa
;
118 extern vo_functions_t video_out_directfb
;
120 extern vo_functions_t video_out_dfbmga
;
124 extern vo_functions_t video_out_xvidix
;
125 extern vo_functions_t video_out_winvidix
;
126 extern vo_functions_t video_out_cvidix
;
129 extern vo_functions_t video_out_tdfx_vid
;
132 extern vo_functions_t video_out_xvr100
;
135 extern vo_functions_t video_out_tga
;
138 #ifdef MACOSX_COREVIDEO
139 extern vo_functions_t video_out_macosx
;
141 extern vo_functions_t video_out_quartz
;
144 extern vo_functions_t video_out_pnm
;
147 extern vo_functions_t video_out_md5sum
;
150 const vo_functions_t
* const video_out_drivers
[] =
162 #ifdef MACOSX_COREVIDEO
224 #ifdef HAVE_V4L2_DECODER
253 // should not be auto-selected
280 void list_video_out(void){
282 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_AvailableVideoOutputDrivers
);
283 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_VIDEO_OUTPUTS\n");
284 while (video_out_drivers
[i
]) {
285 const vo_info_t
*info
= video_out_drivers
[i
++]->info
;
286 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,"\t%s\t%s\n", info
->short_name
, info
->name
);
288 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,"\n");
291 const vo_functions_t
* init_best_video_out(char** vo_list
){
293 // first try the preferred drivers, with their optional subdevice param:
294 if(vo_list
&& vo_list
[0])
295 while(vo_list
[0][0]){
296 char* vo
=strdup(vo_list
[0]);
297 vo_subdevice
=strchr(vo
,':');
298 if (!strcmp(vo
, "pgm"))
299 mp_msg(MSGT_CPLAYER
, MSGL_ERR
, MSGTR_VO_PGM_HasBeenReplaced
);
300 if (!strcmp(vo
, "md5"))
301 mp_msg(MSGT_CPLAYER
, MSGL_ERR
, MSGTR_VO_MD5_HasBeenReplaced
);
306 for(i
=0;video_out_drivers
[i
];i
++){
307 const vo_functions_t
* video_driver
=video_out_drivers
[i
];
308 const vo_info_t
*info
= video_driver
->info
;
309 if(!strcmp(info
->short_name
,vo
)){
310 // name matches, try it
311 if(!video_driver
->preinit(vo_subdevice
))
314 return video_driver
; // success!
321 if(!(vo_list
[0])) return NULL
; // do NOT fallback to others
323 // now try the rest...
325 for(i
=0;video_out_drivers
[i
];i
++){
326 const vo_functions_t
* video_driver
=video_out_drivers
[i
];
327 if(!video_driver
->preinit(vo_subdevice
))
328 return video_driver
; // success!
333 int config_video_out(const vo_functions_t
*vo
, uint32_t width
, uint32_t height
,
334 uint32_t d_width
, uint32_t d_height
, uint32_t flags
,
335 char *title
, uint32_t format
) {
337 aspect_save_orig(width
,height
);
338 aspect_save_prescale(d_width
,d_height
);
340 if (vo
->control(VOCTRL_UPDATE_SCREENINFO
, NULL
) == VO_TRUE
) {
341 aspect(&d_width
,&d_height
,A_NOZOOM
);
342 vo_dx
= (int)(vo_screenwidth
- d_width
) / 2;
343 vo_dy
= (int)(vo_screenheight
- d_height
) / 2;
344 geometry(&vo_dx
, &vo_dy
, &d_width
, &d_height
,
345 vo_screenwidth
, vo_screenheight
);
349 vo_dheight
= d_height
;
352 return vo
->config(width
, height
, d_width
, d_height
, flags
, title
, format
);
355 #if defined(HAVE_FBDEV)||defined(HAVE_VESA)
356 /* Borrowed from vo_fbdev.c
357 Monitor ranges related functions*/
359 char *monitor_hfreq_str
= NULL
;
360 char *monitor_vfreq_str
= NULL
;
361 char *monitor_dotclock_str
= NULL
;
363 float range_max(range_t
*r
)
367 for (/* NOTHING */; (r
->min
!= -1 && r
->max
!= -1); r
++)
368 if (max
< r
->max
) max
= r
->max
;
373 int in_range(range_t
*r
, float f
)
375 for (/* NOTHING */; (r
->min
!= -1 && r
->max
!= -1); r
++)
376 if (f
>= r
->min
&& f
<= r
->max
)
381 range_t
*str2range(char *s
)
383 float tmp_min
, tmp_max
;
384 char *endptr
= s
; // to start the loop
390 for (i
= 0; *endptr
; i
++) {
393 if (!(r
= (range_t
*) realloc(r
, sizeof(*r
) * (i
+ 2)))) {
394 mp_msg(MSGT_GLOBAL
, MSGL_WARN
,"can't realloc 'r'\n");
397 tmp_min
= strtod(s
, &endptr
);
398 if (*endptr
== 'k' || *endptr
== 'K') {
401 } else if (*endptr
== 'm' || *endptr
== 'M') {
402 tmp_min
*= 1000000.0;
405 if (*endptr
== '-') {
406 tmp_max
= strtod(endptr
+ 1, &endptr
);
407 if (*endptr
== 'k' || *endptr
== 'K') {
410 } else if (*endptr
== 'm' || *endptr
== 'M') {
411 tmp_max
*= 1000000.0;
414 if (*endptr
!= ',' && *endptr
)
416 } else if (*endptr
== ',' || !*endptr
) {
422 if (r
[i
].min
< 0 || r
[i
].max
< 0)
426 r
[i
].min
= r
[i
].max
= -1;
434 /* Borrowed from vo_fbdev.c END */