2 * libvo common functions, variables used by many/all drivers.
4 * This file is part of MPlayer.
6 * MPlayer is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * MPlayer is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 //#include <sys/mman.h>
29 #include "video_out.h"
36 #include "osdep/shmem.h"
40 int xinerama_screen
= -1;
44 // currect resolution/bpp on screen: (should be autodetected by vo_init())
45 int vo_depthonscreen
=0;
47 int vo_screenheight
=0;
49 int vo_config_count
=0;
51 // requested resolution/bpp: (-x -y -bpp options)
58 int vo_nomouse_input
= 0;
59 int vo_grabpointer
= 1;
60 int vo_doublebuffering
= 1;
64 float vo_panscan
= 0.0f
;
67 int vo_refresh_rate
=0;
73 int vo_pts
=0; // for hw decoding
76 char *vo_subdevice
= NULL
;
77 int vo_directrendering
=0;
79 int vo_colorkey
= 0x0000ff00; // default colorkey is green
80 // (0xff000000 means that colorkey has been disabled)
83 // Externally visible list of all vo drivers
85 extern vo_functions_t video_out_mga
;
86 extern vo_functions_t video_out_xmga
;
87 extern vo_functions_t video_out_x11
;
88 extern vo_functions_t video_out_xover
;
89 extern vo_functions_t video_out_xvmc
;
90 extern vo_functions_t video_out_xv
;
91 extern vo_functions_t video_out_gl
;
92 extern vo_functions_t video_out_gl2
;
93 extern vo_functions_t video_out_dga
;
94 extern vo_functions_t video_out_sdl
;
95 extern vo_functions_t video_out_3dfx
;
96 extern vo_functions_t video_out_tdfxfb
;
97 extern vo_functions_t video_out_s3fb
;
98 extern vo_functions_t video_out_wii
;
99 extern vo_functions_t video_out_null
;
100 extern vo_functions_t video_out_zr
;
101 extern vo_functions_t video_out_zr2
;
102 extern vo_functions_t video_out_bl
;
103 extern vo_functions_t video_out_fbdev
;
104 extern vo_functions_t video_out_fbdev2
;
105 extern vo_functions_t video_out_svga
;
106 extern vo_functions_t video_out_png
;
107 extern vo_functions_t video_out_ggi
;
108 extern vo_functions_t video_out_aa
;
109 extern vo_functions_t video_out_caca
;
110 extern vo_functions_t video_out_mpegpes
;
111 extern vo_functions_t video_out_yuv4mpeg
;
112 extern vo_functions_t video_out_direct3d
;
113 extern vo_functions_t video_out_directx
;
114 extern vo_functions_t video_out_dxr2
;
115 extern vo_functions_t video_out_dxr3
;
116 extern vo_functions_t video_out_ivtv
;
117 extern vo_functions_t video_out_v4l2
;
118 extern vo_functions_t video_out_jpeg
;
119 extern vo_functions_t video_out_gif89a
;
120 extern vo_functions_t video_out_vesa
;
121 extern vo_functions_t video_out_directfb
;
122 extern vo_functions_t video_out_dfbmga
;
123 extern vo_functions_t video_out_xvidix
;
124 extern vo_functions_t video_out_winvidix
;
125 extern vo_functions_t video_out_cvidix
;
126 extern vo_functions_t video_out_tdfx_vid
;
127 extern vo_functions_t video_out_xvr100
;
128 extern vo_functions_t video_out_tga
;
129 extern vo_functions_t video_out_macosx
;
130 extern vo_functions_t video_out_quartz
;
131 extern vo_functions_t video_out_pnm
;
132 extern vo_functions_t video_out_md5sum
;
134 const vo_functions_t
* const video_out_drivers
[] =
139 #ifdef CONFIG_TDFX_VID
142 #ifdef CONFIG_DIRECTX
145 #ifdef CONFIG_DIRECT3D
148 #ifdef CONFIG_COREVIDEO
196 #ifdef CONFIG_SVGALIB
214 #ifdef CONFIG_V4L2_DECODER
227 #ifdef CONFIG_DIRECTFB
237 #if defined(__MINGW32__) || defined(__CYGWIN__)
243 // should not be auto-selected
248 #ifdef CONFIG_YUV4MPEG
272 void list_video_out(void){
274 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_AvailableVideoOutputDrivers
);
275 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_VIDEO_OUTPUTS\n");
276 while (video_out_drivers
[i
]) {
277 const vo_info_t
*info
= video_out_drivers
[i
++]->info
;
278 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,"\t%s\t%s\n", info
->short_name
, info
->name
);
280 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,"\n");
283 const vo_functions_t
* init_best_video_out(char** vo_list
){
285 // first try the preferred drivers, with their optional subdevice param:
286 if(vo_list
&& vo_list
[0])
287 while(vo_list
[0][0]){
288 char* vo
=strdup(vo_list
[0]);
289 vo_subdevice
=strchr(vo
,':');
290 if (!strcmp(vo
, "pgm"))
291 mp_msg(MSGT_CPLAYER
, MSGL_ERR
, MSGTR_VO_PGM_HasBeenReplaced
);
292 if (!strcmp(vo
, "md5"))
293 mp_msg(MSGT_CPLAYER
, MSGL_ERR
, MSGTR_VO_MD5_HasBeenReplaced
);
298 for(i
=0;video_out_drivers
[i
];i
++){
299 const vo_functions_t
* video_driver
=video_out_drivers
[i
];
300 const vo_info_t
*info
= video_driver
->info
;
301 if(!strcmp(info
->short_name
,vo
)){
302 // name matches, try it
303 if(!video_driver
->preinit(vo_subdevice
))
306 return video_driver
; // success!
313 if(!(vo_list
[0])) return NULL
; // do NOT fallback to others
315 // now try the rest...
317 for(i
=0;video_out_drivers
[i
];i
++){
318 const vo_functions_t
* video_driver
=video_out_drivers
[i
];
319 if(!video_driver
->preinit(vo_subdevice
))
320 return video_driver
; // success!
325 int config_video_out(const vo_functions_t
*vo
, uint32_t width
, uint32_t height
,
326 uint32_t d_width
, uint32_t d_height
, uint32_t flags
,
327 char *title
, uint32_t format
) {
329 aspect_save_orig(width
,height
);
330 aspect_save_prescale(d_width
,d_height
);
332 if (vo
->control(VOCTRL_UPDATE_SCREENINFO
, NULL
) == VO_TRUE
) {
333 aspect(&d_width
,&d_height
,A_NOZOOM
);
334 vo_dx
= (int)(vo_screenwidth
- d_width
) / 2;
335 vo_dy
= (int)(vo_screenheight
- d_height
) / 2;
336 geometry(&vo_dx
, &vo_dy
, &d_width
, &d_height
,
337 vo_screenwidth
, vo_screenheight
);
341 vo_dheight
= d_height
;
344 return vo
->config(width
, height
, d_width
, d_height
, flags
, title
, format
);
348 * \brief lookup an integer in a table, table must have 0 as the last key
349 * \param key key to search for
350 * \result translation corresponding to key or "to" value of last mapping
353 int lookup_keymap_table(const struct keymap
*map
, int key
) {
354 while (map
->from
&& map
->from
!= key
) map
++;
358 #if defined(CONFIG_FBDEV) || defined(CONFIG_VESA)
359 /* Borrowed from vo_fbdev.c
360 Monitor ranges related functions*/
362 char *monitor_hfreq_str
= NULL
;
363 char *monitor_vfreq_str
= NULL
;
364 char *monitor_dotclock_str
= NULL
;
366 float range_max(range_t
*r
)
370 for (/* NOTHING */; (r
->min
!= -1 && r
->max
!= -1); r
++)
371 if (max
< r
->max
) max
= r
->max
;
376 int in_range(range_t
*r
, float f
)
378 for (/* NOTHING */; (r
->min
!= -1 && r
->max
!= -1); r
++)
379 if (f
>= r
->min
&& f
<= r
->max
)
384 range_t
*str2range(char *s
)
386 float tmp_min
, tmp_max
;
387 char *endptr
= s
; // to start the loop
393 for (i
= 0; *endptr
; i
++) {
396 if (!(r
= (range_t
*) realloc(r
, sizeof(*r
) * (i
+ 2)))) {
397 mp_msg(MSGT_GLOBAL
, MSGL_WARN
,"can't realloc 'r'\n");
400 tmp_min
= strtod(s
, &endptr
);
401 if (*endptr
== 'k' || *endptr
== 'K') {
404 } else if (*endptr
== 'm' || *endptr
== 'M') {
405 tmp_min
*= 1000000.0;
408 if (*endptr
== '-') {
409 tmp_max
= strtod(endptr
+ 1, &endptr
);
410 if (*endptr
== 'k' || *endptr
== 'K') {
413 } else if (*endptr
== 'm' || *endptr
== 'M') {
414 tmp_max
*= 1000000.0;
417 if (*endptr
!= ',' && *endptr
)
419 } else if (*endptr
== ',' || !*endptr
) {
425 if (r
[i
].min
< 0 || r
[i
].max
< 0)
429 r
[i
].min
= r
[i
].max
= -1;
437 /* Borrowed from vo_fbdev.c END */