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_wii
;
83 extern vo_functions_t video_out_null
;
84 extern vo_functions_t video_out_zr
;
85 extern vo_functions_t video_out_zr2
;
86 extern vo_functions_t video_out_bl
;
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 extern vo_functions_t video_out_direct3d
;
97 extern vo_functions_t video_out_directx
;
98 extern vo_functions_t video_out_dxr2
;
99 extern vo_functions_t video_out_dxr3
;
100 extern vo_functions_t video_out_ivtv
;
101 extern vo_functions_t video_out_v4l2
;
102 extern vo_functions_t video_out_jpeg
;
103 extern vo_functions_t video_out_gif89a
;
104 extern vo_functions_t video_out_vesa
;
105 extern vo_functions_t video_out_directfb
;
106 extern vo_functions_t video_out_dfbmga
;
107 extern vo_functions_t video_out_xvidix
;
108 extern vo_functions_t video_out_winvidix
;
109 extern vo_functions_t video_out_cvidix
;
110 extern vo_functions_t video_out_tdfx_vid
;
111 extern vo_functions_t video_out_xvr100
;
112 extern vo_functions_t video_out_tga
;
113 extern vo_functions_t video_out_macosx
;
114 extern vo_functions_t video_out_quartz
;
115 extern vo_functions_t video_out_pnm
;
116 extern vo_functions_t video_out_md5sum
;
118 const vo_functions_t
* const video_out_drivers
[] =
123 #ifdef CONFIG_TDFX_VID
126 #ifdef CONFIG_DIRECTX
129 #ifdef CONFIG_DIRECT3D
132 #ifdef CONFIG_COREVIDEO
180 #ifdef CONFIG_SVGALIB
198 #ifdef CONFIG_V4L2_DECODER
211 #ifdef CONFIG_DIRECTFB
221 #if defined(__MINGW32__) || defined(__CYGWIN__)
227 // should not be auto-selected
232 #ifdef CONFIG_YUV4MPEG
256 void list_video_out(void){
258 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_AvailableVideoOutputDrivers
);
259 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_VIDEO_OUTPUTS\n");
260 while (video_out_drivers
[i
]) {
261 const vo_info_t
*info
= video_out_drivers
[i
++]->info
;
262 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,"\t%s\t%s\n", info
->short_name
, info
->name
);
264 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,"\n");
267 const vo_functions_t
* init_best_video_out(char** vo_list
){
269 // first try the preferred drivers, with their optional subdevice param:
270 if(vo_list
&& vo_list
[0])
271 while(vo_list
[0][0]){
272 char* vo
=strdup(vo_list
[0]);
273 vo_subdevice
=strchr(vo
,':');
274 if (!strcmp(vo
, "pgm"))
275 mp_msg(MSGT_CPLAYER
, MSGL_ERR
, MSGTR_VO_PGM_HasBeenReplaced
);
276 if (!strcmp(vo
, "md5"))
277 mp_msg(MSGT_CPLAYER
, MSGL_ERR
, MSGTR_VO_MD5_HasBeenReplaced
);
282 for(i
=0;video_out_drivers
[i
];i
++){
283 const vo_functions_t
* video_driver
=video_out_drivers
[i
];
284 const vo_info_t
*info
= video_driver
->info
;
285 if(!strcmp(info
->short_name
,vo
)){
286 // name matches, try it
287 if(!video_driver
->preinit(vo_subdevice
))
290 return video_driver
; // success!
297 if(!(vo_list
[0])) return NULL
; // do NOT fallback to others
299 // now try the rest...
301 for(i
=0;video_out_drivers
[i
];i
++){
302 const vo_functions_t
* video_driver
=video_out_drivers
[i
];
303 if(!video_driver
->preinit(vo_subdevice
))
304 return video_driver
; // success!
309 int config_video_out(const vo_functions_t
*vo
, uint32_t width
, uint32_t height
,
310 uint32_t d_width
, uint32_t d_height
, uint32_t flags
,
311 char *title
, uint32_t format
) {
313 aspect_save_orig(width
,height
);
314 aspect_save_prescale(d_width
,d_height
);
316 if (vo
->control(VOCTRL_UPDATE_SCREENINFO
, NULL
) == VO_TRUE
) {
317 aspect(&d_width
,&d_height
,A_NOZOOM
);
318 vo_dx
= (int)(vo_screenwidth
- d_width
) / 2;
319 vo_dy
= (int)(vo_screenheight
- d_height
) / 2;
320 geometry(&vo_dx
, &vo_dy
, &d_width
, &d_height
,
321 vo_screenwidth
, vo_screenheight
);
325 vo_dheight
= d_height
;
328 return vo
->config(width
, height
, d_width
, d_height
, flags
, title
, format
);
331 #if defined(CONFIG_FBDEV) || defined(CONFIG_VESA)
332 /* Borrowed from vo_fbdev.c
333 Monitor ranges related functions*/
335 char *monitor_hfreq_str
= NULL
;
336 char *monitor_vfreq_str
= NULL
;
337 char *monitor_dotclock_str
= NULL
;
339 float range_max(range_t
*r
)
343 for (/* NOTHING */; (r
->min
!= -1 && r
->max
!= -1); r
++)
344 if (max
< r
->max
) max
= r
->max
;
349 int in_range(range_t
*r
, float f
)
351 for (/* NOTHING */; (r
->min
!= -1 && r
->max
!= -1); r
++)
352 if (f
>= r
->min
&& f
<= r
->max
)
357 range_t
*str2range(char *s
)
359 float tmp_min
, tmp_max
;
360 char *endptr
= s
; // to start the loop
366 for (i
= 0; *endptr
; i
++) {
369 if (!(r
= (range_t
*) realloc(r
, sizeof(*r
) * (i
+ 2)))) {
370 mp_msg(MSGT_GLOBAL
, MSGL_WARN
,"can't realloc 'r'\n");
373 tmp_min
= strtod(s
, &endptr
);
374 if (*endptr
== 'k' || *endptr
== 'K') {
377 } else if (*endptr
== 'm' || *endptr
== 'M') {
378 tmp_min
*= 1000000.0;
381 if (*endptr
== '-') {
382 tmp_max
= strtod(endptr
+ 1, &endptr
);
383 if (*endptr
== 'k' || *endptr
== 'K') {
386 } else if (*endptr
== 'm' || *endptr
== 'M') {
387 tmp_max
*= 1000000.0;
390 if (*endptr
!= ',' && *endptr
)
392 } else if (*endptr
== ',' || !*endptr
) {
398 if (r
[i
].min
< 0 || r
[i
].max
< 0)
402 r
[i
].min
= r
[i
].max
= -1;
410 /* Borrowed from vo_fbdev.c END */