2 /* this file contains libvo's common functions, variables used by
10 //#include <sys/mman.h>
15 #include "video_out.h"
22 #include "osdep/shmem.h"
24 #include "x11_common.h"
27 int xinerama_screen
= -1;
31 int vo_nomouse_input
= 0;
32 int vo_grabpointer
= 1;
33 int vo_doublebuffering
= 1;
37 float vo_panscan
= 0.0f
;
39 int vo_refresh_rate
=0;
45 int vo_pts
=0; // for hw decoding
48 char *vo_subdevice
= NULL
;
49 int vo_directrendering
=0;
51 int vo_colorkey
= 0x0000ff00; // default colorkey is green
52 // (0xff000000 means that colorkey has been disabled)
55 // Externally visible list of all vo drivers
57 extern struct vo_driver video_out_mga
;
58 extern struct vo_driver video_out_xmga
;
59 extern struct vo_driver video_out_x11
;
60 extern struct vo_driver video_out_xover
;
61 extern struct vo_driver video_out_xvmc
;
62 extern struct vo_driver video_out_xv
;
63 extern struct vo_driver video_out_gl
;
64 extern struct vo_driver video_out_gl2
;
65 extern struct vo_driver video_out_dga
;
66 extern struct vo_driver video_out_sdl
;
67 extern struct vo_driver video_out_3dfx
;
68 extern struct vo_driver video_out_tdfxfb
;
69 extern struct vo_driver video_out_s3fb
;
70 extern struct vo_driver video_out_wii
;
71 extern struct vo_driver video_out_null
;
72 extern struct vo_driver video_out_zr
;
73 extern struct vo_driver video_out_zr2
;
74 extern struct vo_driver video_out_bl
;
75 extern struct vo_driver video_out_fbdev
;
76 extern struct vo_driver video_out_fbdev2
;
77 extern struct vo_driver video_out_svga
;
78 extern struct vo_driver video_out_png
;
79 extern struct vo_driver video_out_ggi
;
80 extern struct vo_driver video_out_aa
;
81 extern struct vo_driver video_out_caca
;
82 extern struct vo_driver video_out_mpegpes
;
83 extern struct vo_driver video_out_yuv4mpeg
;
84 extern struct vo_driver video_out_direct3d
;
85 extern struct vo_driver video_out_directx
;
86 extern struct vo_driver video_out_dxr2
;
87 extern struct vo_driver video_out_dxr3
;
88 extern struct vo_driver video_out_ivtv
;
89 extern struct vo_driver video_out_v4l2
;
90 extern struct vo_driver video_out_jpeg
;
91 extern struct vo_driver video_out_gif89a
;
92 extern struct vo_driver video_out_vesa
;
93 extern struct vo_driver video_out_directfb
;
94 extern struct vo_driver video_out_dfbmga
;
95 extern struct vo_driver video_out_xvidix
;
96 extern struct vo_driver video_out_winvidix
;
97 extern struct vo_driver video_out_cvidix
;
98 extern struct vo_driver video_out_tdfx_vid
;
99 extern struct vo_driver video_out_xvr100
;
100 extern struct vo_driver video_out_tga
;
101 extern struct vo_driver video_out_macosx
;
102 extern struct vo_driver video_out_quartz
;
103 extern struct vo_driver video_out_pnm
;
104 extern struct vo_driver video_out_md5sum
;
106 const struct vo_driver
*video_out_drivers
[] =
111 #ifdef CONFIG_TDFX_VID
114 #ifdef CONFIG_DIRECTX
117 #ifdef CONFIG_DIRECT3D
120 #ifdef CONFIG_COREVIDEO
168 #ifdef CONFIG_SVGALIB
186 #ifdef CONFIG_V4L2_DECODER
199 #ifdef CONFIG_DIRECTFB
209 #if defined(__MINGW32__) || defined(__CYGWIN__)
215 // should not be auto-selected
220 #ifdef CONFIG_YUV4MPEG
245 static int vo_preinit(struct vo
*vo
, const char *arg
)
247 return vo
->driver
->preinit(vo
, arg
);
250 int vo_control(struct vo
*vo
, uint32_t request
, void *data
)
252 return vo
->driver
->control(vo
, request
, data
);
255 int vo_draw_frame(struct vo
*vo
, uint8_t *src
[])
259 return vo
->driver
->draw_frame(vo
, src
);
262 int vo_draw_slice(struct vo
*vo
, uint8_t *src
[], int stride
[], int w
, int h
, int x
, int y
)
264 return vo
->driver
->draw_slice(vo
, src
, stride
, w
, h
, x
, y
);
267 void vo_draw_osd(struct vo
*vo
, struct osd_state
*osd
)
271 vo
->driver
->draw_osd(vo
, osd
);
274 void vo_flip_page(struct vo
*vo
)
278 vo
->driver
->flip_page(vo
);
281 void vo_check_events(struct vo
*vo
)
285 vo
->driver
->check_events(vo
);
288 void vo_destroy(struct vo
*vo
)
290 vo
->driver
->uninit(vo
);
294 void list_video_out(void)
297 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_AvailableVideoOutputDrivers
);
298 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_VIDEO_OUTPUTS\n");
299 while (video_out_drivers
[i
]) {
300 const vo_info_t
*info
= video_out_drivers
[i
++]->info
;
301 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,"\t%s\t%s\n", info
->short_name
, info
->name
);
303 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,"\n");
306 struct vo
*init_best_video_out(struct MPOpts
*opts
, struct vo_x11_state
*x11
,
307 struct mp_fifo
*key_fifo
,
308 struct input_ctx
*input_ctx
)
310 char **vo_list
= opts
->video_driver_list
;
312 struct vo
*vo
= talloc_ptrtype(NULL
, vo
);
313 struct vo initial_values
= {
316 .key_fifo
= key_fifo
,
317 .input_ctx
= input_ctx
,
319 // first try the preferred drivers, with their optional subdevice param:
320 if (vo_list
&& vo_list
[0])
321 while (vo_list
[0][0]) {
322 char *name
= strdup(vo_list
[0]);
323 vo_subdevice
= strchr(name
,':');
324 if (!strcmp(name
, "pgm"))
325 mp_msg(MSGT_CPLAYER
, MSGL_ERR
, MSGTR_VO_PGM_HasBeenReplaced
);
326 if (!strcmp(name
, "md5"))
327 mp_msg(MSGT_CPLAYER
, MSGL_ERR
, MSGTR_VO_MD5_HasBeenReplaced
);
332 for (i
= 0; video_out_drivers
[i
]; i
++) {
333 const struct vo_driver
*video_driver
= video_out_drivers
[i
];
334 const vo_info_t
*info
= video_driver
->info
;
335 if (!strcmp(info
->short_name
, name
)) {
336 // name matches, try it
337 *vo
= initial_values
;
338 vo
->driver
= video_driver
;
339 if (!vo_preinit(vo
, vo_subdevice
)) {
341 return vo
; // success!
349 return NULL
; // do NOT fallback to others
351 // now try the rest...
353 for (i
= 0; video_out_drivers
[i
]; i
++) {
354 const struct vo_driver
*video_driver
= video_out_drivers
[i
];
355 *vo
= initial_values
;
356 vo
->driver
= video_driver
;
357 if (!vo_preinit(vo
, vo_subdevice
))
358 return vo
; // success!
364 int vo_config(struct vo
*vo
, uint32_t width
, uint32_t height
,
365 uint32_t d_width
, uint32_t d_height
, uint32_t flags
,
366 char *title
, uint32_t format
)
368 struct MPOpts
*opts
= vo
->opts
;
370 aspect_save_orig(vo
, width
, height
);
371 aspect_save_prescale(vo
, d_width
, d_height
);
373 if (vo_control(vo
, VOCTRL_UPDATE_SCREENINFO
, NULL
) == VO_TRUE
) {
374 aspect(vo
, &d_width
, &d_height
, A_NOZOOM
);
375 vo
->dx
= (int)(opts
->vo_screenwidth
- d_width
) / 2;
376 vo
->dy
= (int)(opts
->vo_screenheight
- d_height
) / 2;
377 geometry(&vo
->dx
, &vo
->dy
, &d_width
, &d_height
,
378 opts
->vo_screenwidth
, opts
->vo_screenheight
);
379 vo
->dx
+= xinerama_x
;
380 vo
->dy
+= xinerama_y
;
381 vo
->dwidth
= d_width
;
382 vo
->dheight
= d_height
;
385 int ret
= vo
->driver
->config(vo
, width
, height
, d_width
, d_height
, flags
,
387 vo
->config_ok
= (ret
== 0);
388 vo
->config_count
+= vo
->config_ok
;
392 #if defined(CONFIG_FBDEV)||defined(CONFIG_VESA)
393 /* Borrowed from vo_fbdev.c
394 Monitor ranges related functions*/
396 char *monitor_hfreq_str
= NULL
;
397 char *monitor_vfreq_str
= NULL
;
398 char *monitor_dotclock_str
= NULL
;
400 float range_max(range_t
*r
)
404 for (/* NOTHING */; (r
->min
!= -1 && r
->max
!= -1); r
++)
405 if (max
< r
->max
) max
= r
->max
;
410 int in_range(range_t
*r
, float f
)
412 for (/* NOTHING */; (r
->min
!= -1 && r
->max
!= -1); r
++)
413 if (f
>= r
->min
&& f
<= r
->max
)
418 range_t
*str2range(char *s
)
420 float tmp_min
, tmp_max
;
421 char *endptr
= s
; // to start the loop
427 for (i
= 0; *endptr
; i
++) {
430 if (!(r
= (range_t
*) realloc(r
, sizeof(*r
) * (i
+ 2)))) {
431 mp_msg(MSGT_GLOBAL
, MSGL_WARN
,"can't realloc 'r'\n");
434 tmp_min
= strtod(s
, &endptr
);
435 if (*endptr
== 'k' || *endptr
== 'K') {
438 } else if (*endptr
== 'm' || *endptr
== 'M') {
439 tmp_min
*= 1000000.0;
442 if (*endptr
== '-') {
443 tmp_max
= strtod(endptr
+ 1, &endptr
);
444 if (*endptr
== 'k' || *endptr
== 'K') {
447 } else if (*endptr
== 'm' || *endptr
== 'M') {
448 tmp_max
*= 1000000.0;
451 if (*endptr
!= ',' && *endptr
)
453 } else if (*endptr
== ',' || !*endptr
) {
459 if (r
[i
].min
< 0 || r
[i
].max
< 0)
463 r
[i
].min
= r
[i
].max
= -1;
471 /* Borrowed from vo_fbdev.c END */