2 /* this file contains libvo's common functions, variables used by
10 //#include <sys/mman.h>
14 #include "video_out.h"
21 #include "osdep/shmem.h"
25 int xinerama_screen
= -1;
29 // currect resolution/bpp on screen: (should be autodetected by vo_init())
30 int vo_depthonscreen
=0;
32 int vo_screenheight
=0;
34 int vo_config_count
=0;
36 // requested resolution/bpp: (-x -y -bpp options)
43 int vo_nomouse_input
= 0;
44 int vo_grabpointer
= 1;
45 int vo_doublebuffering
= 1;
49 float vo_panscan
= 0.0f
;
52 int vo_refresh_rate
=0;
58 int vo_pts
=0; // for hw decoding
61 char *vo_subdevice
= NULL
;
62 int vo_directrendering
=0;
64 int vo_colorkey
= 0x0000ff00; // default colorkey is green
65 // (0xff000000 means that colorkey has been disabled)
68 // Externally visible list of all vo drivers
70 extern struct vo_driver video_out_mga
;
71 extern struct vo_driver video_out_xmga
;
72 extern struct vo_driver video_out_x11
;
73 extern struct vo_driver video_out_xover
;
74 extern struct vo_driver video_out_xvmc
;
75 extern struct vo_driver video_out_xv
;
76 extern struct vo_driver video_out_gl
;
77 extern struct vo_driver video_out_gl2
;
78 extern struct vo_driver video_out_dga
;
79 extern struct vo_driver video_out_sdl
;
80 extern struct vo_driver video_out_3dfx
;
81 extern struct vo_driver video_out_tdfxfb
;
82 extern struct vo_driver video_out_s3fb
;
83 extern struct vo_driver video_out_null
;
84 extern struct vo_driver video_out_zr
;
85 extern struct vo_driver video_out_zr2
;
86 extern struct vo_driver video_out_bl
;
87 extern struct vo_driver video_out_fbdev
;
88 extern struct vo_driver video_out_fbdev2
;
89 extern struct vo_driver video_out_svga
;
90 extern struct vo_driver video_out_png
;
91 extern struct vo_driver video_out_ggi
;
92 extern struct vo_driver video_out_aa
;
93 extern struct vo_driver video_out_caca
;
94 extern struct vo_driver video_out_mpegpes
;
95 extern struct vo_driver video_out_yuv4mpeg
;
96 extern struct vo_driver video_out_directx
;
97 extern struct vo_driver video_out_dxr2
;
98 extern struct vo_driver video_out_dxr3
;
99 extern struct vo_driver video_out_ivtv
;
100 extern struct vo_driver video_out_v4l2
;
101 extern struct vo_driver video_out_jpeg
;
102 extern struct vo_driver video_out_gif89a
;
103 extern struct vo_driver video_out_vesa
;
104 extern struct vo_driver video_out_directfb
;
105 extern struct vo_driver video_out_dfbmga
;
106 extern struct vo_driver video_out_xvidix
;
107 extern struct vo_driver video_out_winvidix
;
108 extern struct vo_driver video_out_cvidix
;
109 extern struct vo_driver video_out_tdfx_vid
;
110 extern struct vo_driver video_out_xvr100
;
111 extern struct vo_driver video_out_tga
;
112 extern struct vo_driver video_out_macosx
;
113 extern struct vo_driver video_out_quartz
;
114 extern struct vo_driver video_out_pnm
;
115 extern struct vo_driver video_out_md5sum
;
117 const struct vo_driver
*video_out_drivers
[] =
128 #ifdef HAVE_COREVIDEO
191 #ifdef HAVE_V4L2_DECODER
220 // should not be auto-selected
248 static int vo_preinit(struct vo
*vo
, const char *arg
)
250 return vo
->driver
->preinit(vo
, arg
);
253 int vo_control(struct vo
*vo
, uint32_t request
, void *data
)
255 return vo
->driver
->control(vo
, request
, data
);
258 int vo_draw_frame(struct vo
*vo
, uint8_t *src
[])
260 return vo
->driver
->draw_frame(vo
, src
);
263 int vo_draw_slice(struct vo
*vo
, uint8_t *src
[], int stride
[], int w
, int h
, int x
, int y
)
265 return vo
->driver
->draw_slice(vo
, src
, stride
, w
, h
, x
, y
);
268 void vo_draw_osd(struct vo
*vo
)
270 vo
->driver
->draw_osd(vo
);
273 void vo_flip_page(struct vo
*vo
)
275 vo
->driver
->flip_page(vo
);
278 void vo_check_events(struct vo
*vo
)
280 vo
->driver
->check_events(vo
);
283 void vo_destroy(struct vo
*vo
)
285 vo
->driver
->uninit(vo
);
289 void list_video_out(void)
292 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_AvailableVideoOutputDrivers
);
293 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_VIDEO_OUTPUTS\n");
294 while (video_out_drivers
[i
]) {
295 const vo_info_t
*info
= video_out_drivers
[i
++]->info
;
296 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,"\t%s\t%s\n", info
->short_name
, info
->name
);
298 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,"\n");
301 struct vo
*init_best_video_out(struct MPOpts
*opts
)
303 char **vo_list
= opts
->video_driver_list
;
305 struct vo
*vo
= malloc(sizeof *vo
);
306 // first try the preferred drivers, with their optional subdevice param:
307 if (vo_list
&& vo_list
[0])
308 while (vo_list
[0][0]) {
309 char *name
= strdup(vo_list
[0]);
310 vo_subdevice
= strchr(name
,':');
311 if (!strcmp(name
, "pgm"))
312 mp_msg(MSGT_CPLAYER
, MSGL_ERR
, MSGTR_VO_PGM_HasBeenReplaced
);
313 if (!strcmp(name
, "md5"))
314 mp_msg(MSGT_CPLAYER
, MSGL_ERR
, MSGTR_VO_MD5_HasBeenReplaced
);
319 for (i
= 0; video_out_drivers
[i
]; i
++) {
320 const struct vo_driver
*video_driver
= video_out_drivers
[i
];
321 const vo_info_t
*info
= video_driver
->info
;
322 if (!strcmp(info
->short_name
, name
)) {
323 // name matches, try it
324 *vo
= (struct vo
){.opts
= opts
};
325 vo
->driver
= video_driver
;
326 if (!vo_preinit(vo
, vo_subdevice
)) {
328 return vo
; // success!
336 return NULL
; // do NOT fallback to others
338 // now try the rest...
340 for (i
= 0; video_out_drivers
[i
]; i
++) {
341 const struct vo_driver
*video_driver
= video_out_drivers
[i
];
342 *vo
= (struct vo
){.opts
= opts
};
343 vo
->driver
= video_driver
;
344 if (!vo_preinit(vo
, vo_subdevice
))
345 return vo
; // success!
351 int vo_config(struct vo
*vo
, uint32_t width
, uint32_t height
,
352 uint32_t d_width
, uint32_t d_height
, uint32_t flags
,
353 char *title
, uint32_t format
)
356 aspect_save_orig(width
, height
);
357 aspect_save_prescale(d_width
, d_height
);
359 if (vo_control(vo
, VOCTRL_UPDATE_SCREENINFO
, NULL
) == VO_TRUE
) {
360 aspect(&d_width
, &d_height
, A_NOZOOM
);
361 vo_dx
= (int)(vo_screenwidth
- d_width
) / 2;
362 vo_dy
= (int)(vo_screenheight
- d_height
) / 2;
363 geometry(&vo_dx
, &vo_dy
, &d_width
, &d_height
,
364 vo_screenwidth
, vo_screenheight
);
368 vo_dheight
= d_height
;
371 return vo
->driver
->config(vo
, width
, height
, d_width
, d_height
, flags
,
375 #if defined(HAVE_FBDEV)||defined(HAVE_VESA)
376 /* Borrowed from vo_fbdev.c
377 Monitor ranges related functions*/
379 char *monitor_hfreq_str
= NULL
;
380 char *monitor_vfreq_str
= NULL
;
381 char *monitor_dotclock_str
= NULL
;
383 float range_max(range_t
*r
)
387 for (/* NOTHING */; (r
->min
!= -1 && r
->max
!= -1); r
++)
388 if (max
< r
->max
) max
= r
->max
;
393 int in_range(range_t
*r
, float f
)
395 for (/* NOTHING */; (r
->min
!= -1 && r
->max
!= -1); r
++)
396 if (f
>= r
->min
&& f
<= r
->max
)
401 range_t
*str2range(char *s
)
403 float tmp_min
, tmp_max
;
404 char *endptr
= s
; // to start the loop
410 for (i
= 0; *endptr
; i
++) {
413 if (!(r
= (range_t
*) realloc(r
, sizeof(*r
) * (i
+ 2)))) {
414 mp_msg(MSGT_GLOBAL
, MSGL_WARN
,"can't realloc 'r'\n");
417 tmp_min
= strtod(s
, &endptr
);
418 if (*endptr
== 'k' || *endptr
== 'K') {
421 } else if (*endptr
== 'm' || *endptr
== 'M') {
422 tmp_min
*= 1000000.0;
425 if (*endptr
== '-') {
426 tmp_max
= strtod(endptr
+ 1, &endptr
);
427 if (*endptr
== 'k' || *endptr
== 'K') {
430 } else if (*endptr
== 'm' || *endptr
== 'M') {
431 tmp_max
*= 1000000.0;
434 if (*endptr
!= ',' && *endptr
)
436 } else if (*endptr
== ',' || !*endptr
) {
442 if (r
[i
].min
< 0 || r
[i
].max
< 0)
446 r
[i
].min
= r
[i
].max
= -1;
454 /* Borrowed from vo_fbdev.c END */