2002-09-09 20:03:21 +00:00
|
|
|
|
|
|
|
/* this file contains libvo's common functions, variables used by
|
|
|
|
many/all drivers. */
|
2001-02-24 20:28:24 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <unistd.h>
|
2002-03-24 00:44:54 +00:00
|
|
|
//#include <sys/mman.h>
|
2001-02-24 20:28:24 +00:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "video_out.h"
|
|
|
|
|
2002-09-29 21:53:05 +00:00
|
|
|
#include "mp_msg.h"
|
|
|
|
#include "help_mp.h"
|
|
|
|
|
2004-10-28 01:15:53 +00:00
|
|
|
#include "osdep/shmem.h"
|
2001-02-24 20:28:24 +00:00
|
|
|
|
2002-03-14 23:09:27 +00:00
|
|
|
//int vo_flags=0;
|
2002-02-17 03:06:38 +00:00
|
|
|
|
2001-04-13 13:47:36 +00:00
|
|
|
// currect resolution/bpp on screen: (should be autodetected by vo_init())
|
|
|
|
int vo_depthonscreen=0;
|
|
|
|
int vo_screenwidth=0;
|
|
|
|
int vo_screenheight=0;
|
|
|
|
|
2002-04-07 02:12:15 +00:00
|
|
|
int vo_config_count=0;
|
|
|
|
|
2001-04-13 13:47:36 +00:00
|
|
|
// requested resolution/bpp: (-x -y -bpp options)
|
2002-02-22 18:00:38 +00:00
|
|
|
int vo_dx=0;
|
|
|
|
int vo_dy=0;
|
2001-04-13 13:47:36 +00:00
|
|
|
int vo_dwidth=0;
|
|
|
|
int vo_dheight=0;
|
|
|
|
int vo_dbpp=0;
|
2002-03-07 17:50:25 +00:00
|
|
|
|
2003-09-01 18:24:27 +00:00
|
|
|
int vo_nomouse_input = 0;
|
2002-09-28 20:09:14 +00:00
|
|
|
int vo_grabpointer = 1;
|
2004-11-30 07:42:08 +00:00
|
|
|
int vo_doublebuffering = 1;
|
2002-02-12 15:06:04 +00:00
|
|
|
int vo_vsync = 0;
|
2002-03-07 17:50:25 +00:00
|
|
|
int vo_fs = 0;
|
2001-07-03 23:46:24 +00:00
|
|
|
int vo_fsmode = 0;
|
2002-06-04 20:17:07 +00:00
|
|
|
float vo_panscan = 0.0f;
|
2003-11-30 16:36:10 +00:00
|
|
|
int vo_ontop = 0;
|
2004-03-13 16:48:52 +00:00
|
|
|
int vo_adapter_num=0;
|
|
|
|
int vo_refresh_rate=0;
|
2004-05-01 14:52:15 +00:00
|
|
|
int vo_keepaspect=1;
|
2004-07-29 14:59:48 +00:00
|
|
|
int vo_rootwin=0;
|
2004-12-21 20:33:51 +00:00
|
|
|
int WinID = -1;
|
2001-04-13 13:47:36 +00:00
|
|
|
|
2001-11-05 02:58:47 +00:00
|
|
|
int vo_pts=0; // for hw decoding
|
2001-11-29 17:31:58 +00:00
|
|
|
float vo_fps=0; // for mp1e rte
|
2001-11-05 02:58:47 +00:00
|
|
|
|
2001-06-21 22:34:25 +00:00
|
|
|
char *vo_subdevice = NULL;
|
2002-03-31 20:38:56 +00:00
|
|
|
int vo_directrendering=0;
|
2002-07-24 18:19:39 +00:00
|
|
|
|
2003-10-03 18:13:45 +00:00
|
|
|
int vo_colorkey = 0x0000ff00; // default colorkey is green
|
2003-10-17 09:08:37 +00:00
|
|
|
// (0xff000000 means that colorkey has been disabled)
|
2003-10-03 18:13:45 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
//
|
|
|
|
// Externally visible list of all vo drivers
|
|
|
|
//
|
|
|
|
extern vo_functions_t video_out_mga;
|
|
|
|
extern vo_functions_t video_out_xmga;
|
|
|
|
extern vo_functions_t video_out_x11;
|
2003-03-12 15:04:05 +00:00
|
|
|
extern vo_functions_t video_out_xover;
|
2003-06-21 01:47:26 +00:00
|
|
|
extern vo_functions_t video_out_xvmc;
|
2001-02-24 20:28:24 +00:00
|
|
|
extern vo_functions_t video_out_xv;
|
|
|
|
extern vo_functions_t video_out_gl;
|
2001-10-07 21:35:59 +00:00
|
|
|
extern vo_functions_t video_out_gl2;
|
2001-02-27 01:08:09 +00:00
|
|
|
extern vo_functions_t video_out_dga;
|
2001-03-05 02:25:07 +00:00
|
|
|
extern vo_functions_t video_out_fsdga;
|
2001-02-24 20:28:24 +00:00
|
|
|
extern vo_functions_t video_out_sdl;
|
|
|
|
extern vo_functions_t video_out_3dfx;
|
2001-09-27 12:23:54 +00:00
|
|
|
extern vo_functions_t video_out_tdfxfb;
|
2001-02-24 20:28:24 +00:00
|
|
|
extern vo_functions_t video_out_null;
|
2001-10-29 00:48:20 +00:00
|
|
|
//extern vo_functions_t video_out_odivx;
|
2002-01-17 01:32:29 +00:00
|
|
|
extern vo_functions_t video_out_zr;
|
2003-11-04 20:05:47 +00:00
|
|
|
extern vo_functions_t video_out_zr2;
|
2002-09-08 22:41:53 +00:00
|
|
|
extern vo_functions_t video_out_bl;
|
2001-02-24 20:28:24 +00:00
|
|
|
extern vo_functions_t video_out_syncfb;
|
2001-03-28 12:08:44 +00:00
|
|
|
extern vo_functions_t video_out_fbdev;
|
2003-08-31 23:00:39 +00:00
|
|
|
extern vo_functions_t video_out_fbdev2;
|
2001-04-05 19:01:27 +00:00
|
|
|
extern vo_functions_t video_out_svga;
|
2001-04-19 20:14:30 +00:00
|
|
|
extern vo_functions_t video_out_png;
|
2001-06-15 12:37:05 +00:00
|
|
|
extern vo_functions_t video_out_ggi;
|
2001-08-14 12:30:56 +00:00
|
|
|
extern vo_functions_t video_out_aa;
|
2004-04-06 00:04:48 +00:00
|
|
|
extern vo_functions_t video_out_caca;
|
2001-09-08 20:48:02 +00:00
|
|
|
extern vo_functions_t video_out_mpegpes;
|
2002-02-09 01:30:35 +00:00
|
|
|
extern vo_functions_t video_out_yuv4mpeg;
|
2002-09-28 19:03:50 +00:00
|
|
|
#ifdef HAVE_DIRECTX
|
|
|
|
extern vo_functions_t video_out_directx;
|
|
|
|
#endif
|
2002-05-13 13:15:40 +00:00
|
|
|
#ifdef HAVE_DXR2
|
|
|
|
extern vo_functions_t video_out_dxr2;
|
|
|
|
#endif
|
2001-11-03 02:38:10 +00:00
|
|
|
extern vo_functions_t video_out_dxr3;
|
2002-04-16 11:21:59 +00:00
|
|
|
#ifdef HAVE_JPEG
|
|
|
|
extern vo_functions_t video_out_jpeg;
|
|
|
|
#endif
|
2002-05-12 01:07:25 +00:00
|
|
|
#ifdef HAVE_GIF
|
|
|
|
extern vo_functions_t video_out_gif89a;
|
|
|
|
#endif
|
2002-02-07 02:29:55 +00:00
|
|
|
#ifdef HAVE_VESA
|
2001-10-17 18:24:50 +00:00
|
|
|
extern vo_functions_t video_out_vesa;
|
|
|
|
#endif
|
2002-10-31 23:54:26 +00:00
|
|
|
#ifdef HAVE_DIRECTFB
|
2001-12-03 01:09:36 +00:00
|
|
|
extern vo_functions_t video_out_directfb;
|
2003-05-01 20:35:56 +00:00
|
|
|
#if DIRECTFBVERSION >= 915
|
2002-10-31 23:54:26 +00:00
|
|
|
extern vo_functions_t video_out_dfbmga;
|
|
|
|
#endif
|
|
|
|
#endif
|
2002-01-12 23:30:20 +00:00
|
|
|
#ifdef CONFIG_VIDIX
|
|
|
|
extern vo_functions_t video_out_xvidix;
|
2003-10-02 14:25:52 +00:00
|
|
|
extern vo_functions_t video_out_winvidix;
|
2003-10-05 15:34:40 +00:00
|
|
|
extern vo_functions_t video_out_cvidix;
|
2002-01-12 23:30:20 +00:00
|
|
|
#endif
|
2003-03-07 18:45:02 +00:00
|
|
|
#ifdef HAVE_TDFX_VID
|
|
|
|
extern vo_functions_t video_out_tdfx_vid;
|
|
|
|
#endif
|
2003-08-24 18:26:37 +00:00
|
|
|
#ifdef HAVE_TGA
|
|
|
|
extern vo_functions_t video_out_tga;
|
|
|
|
#endif
|
2004-04-05 21:20:19 +00:00
|
|
|
#ifdef MACOSX
|
|
|
|
extern vo_functions_t video_out_quartz;
|
|
|
|
#endif
|
2004-10-23 22:43:19 +00:00
|
|
|
#ifdef HAVE_PNM
|
2004-09-20 01:31:26 +00:00
|
|
|
extern vo_functions_t video_out_pnm;
|
2004-10-23 22:43:19 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_MD5SUM
|
2004-09-20 01:35:43 +00:00
|
|
|
extern vo_functions_t video_out_md5sum;
|
2004-10-23 22:43:19 +00:00
|
|
|
#endif
|
2002-01-12 23:30:20 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
vo_functions_t* video_out_drivers[] =
|
|
|
|
{
|
2003-03-07 18:45:02 +00:00
|
|
|
#ifdef HAVE_TDFX_VID
|
|
|
|
&video_out_tdfx_vid,
|
|
|
|
#endif
|
2003-01-03 05:10:44 +00:00
|
|
|
#ifdef HAVE_DIRECTX
|
|
|
|
&video_out_directx,
|
|
|
|
#endif
|
2004-06-17 01:07:53 +00:00
|
|
|
#ifdef MACOSX
|
|
|
|
&video_out_quartz,
|
|
|
|
#endif
|
2001-06-21 15:19:38 +00:00
|
|
|
#ifdef HAVE_XMGA
|
2001-02-24 20:28:24 +00:00
|
|
|
&video_out_xmga,
|
|
|
|
#endif
|
2001-06-21 15:19:38 +00:00
|
|
|
#ifdef HAVE_MGA
|
2001-02-24 20:28:24 +00:00
|
|
|
&video_out_mga,
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SYNCFB
|
|
|
|
&video_out_syncfb,
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_3DFX
|
|
|
|
&video_out_3dfx,
|
|
|
|
#endif
|
2001-09-27 12:23:54 +00:00
|
|
|
#ifdef HAVE_TDFXFB
|
|
|
|
&video_out_tdfxfb,
|
|
|
|
#endif
|
2003-06-21 01:47:26 +00:00
|
|
|
#ifdef HAVE_XVMC
|
|
|
|
&video_out_xvmc,
|
|
|
|
#endif
|
2001-02-24 20:28:24 +00:00
|
|
|
#ifdef HAVE_XV
|
|
|
|
&video_out_xv,
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_X11
|
|
|
|
&video_out_x11,
|
2003-03-12 15:04:05 +00:00
|
|
|
&video_out_xover,
|
2001-02-24 20:28:24 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_GL
|
2003-09-19 14:33:51 +00:00
|
|
|
#ifndef GL_WIN32
|
|
|
|
&video_out_gl,
|
|
|
|
#endif
|
2001-10-07 21:35:59 +00:00
|
|
|
&video_out_gl2,
|
2001-02-24 20:28:24 +00:00
|
|
|
#endif
|
2001-02-27 01:08:09 +00:00
|
|
|
#ifdef HAVE_DGA
|
|
|
|
&video_out_dga,
|
2001-06-26 23:34:03 +00:00
|
|
|
// &video_out_fsdga,
|
2001-02-27 01:08:09 +00:00
|
|
|
#endif
|
2001-02-24 20:28:24 +00:00
|
|
|
#ifdef HAVE_SDL
|
|
|
|
&video_out_sdl,
|
2001-03-28 20:14:16 +00:00
|
|
|
#endif
|
2001-06-26 23:34:03 +00:00
|
|
|
#ifdef HAVE_GGI
|
|
|
|
&video_out_ggi,
|
|
|
|
#endif
|
2001-03-28 20:14:16 +00:00
|
|
|
#ifdef HAVE_FBDEV
|
|
|
|
&video_out_fbdev,
|
2003-08-31 23:00:39 +00:00
|
|
|
&video_out_fbdev2,
|
2001-04-05 19:01:27 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SVGALIB
|
|
|
|
&video_out_svga,
|
2001-02-24 20:28:24 +00:00
|
|
|
#endif
|
2001-08-14 12:30:56 +00:00
|
|
|
#ifdef HAVE_AA
|
|
|
|
&video_out_aa,
|
|
|
|
#endif
|
2004-04-06 00:04:48 +00:00
|
|
|
#ifdef HAVE_CACA
|
|
|
|
&video_out_caca,
|
|
|
|
#endif
|
2002-05-13 13:15:40 +00:00
|
|
|
#ifdef HAVE_DXR2
|
|
|
|
&video_out_dxr2,
|
|
|
|
#endif
|
2001-11-03 02:38:10 +00:00
|
|
|
#ifdef HAVE_DXR3
|
|
|
|
&video_out_dxr3,
|
|
|
|
#endif
|
2002-01-17 01:32:29 +00:00
|
|
|
#ifdef HAVE_ZR
|
|
|
|
&video_out_zr,
|
2003-11-04 20:05:47 +00:00
|
|
|
&video_out_zr2,
|
2002-01-17 01:32:29 +00:00
|
|
|
#endif
|
2002-09-08 22:41:53 +00:00
|
|
|
#ifdef HAVE_BL
|
|
|
|
&video_out_bl,
|
|
|
|
#endif
|
2002-02-07 02:29:55 +00:00
|
|
|
#ifdef HAVE_VESA
|
2001-10-17 18:24:50 +00:00
|
|
|
&video_out_vesa,
|
|
|
|
#endif
|
2001-12-03 01:09:36 +00:00
|
|
|
#ifdef HAVE_DIRECTFB
|
|
|
|
&video_out_directfb,
|
2003-05-01 20:35:56 +00:00
|
|
|
#if DIRECTFBVERSION >= 915
|
2002-10-31 23:54:26 +00:00
|
|
|
&video_out_dfbmga,
|
|
|
|
#endif
|
|
|
|
#endif
|
2003-10-02 14:25:52 +00:00
|
|
|
#ifdef CONFIG_VIDIX
|
|
|
|
#ifdef HAVE_X11
|
2002-01-12 23:30:20 +00:00
|
|
|
&video_out_xvidix,
|
2003-10-02 14:25:52 +00:00
|
|
|
#endif
|
|
|
|
#ifdef WIN32
|
|
|
|
&video_out_winvidix,
|
|
|
|
#endif
|
2003-10-05 15:34:40 +00:00
|
|
|
&video_out_cvidix,
|
2004-10-04 19:36:12 +00:00
|
|
|
#endif
|
|
|
|
&video_out_null,
|
|
|
|
// should not be auto-selected
|
|
|
|
&video_out_mpegpes,
|
|
|
|
&video_out_yuv4mpeg,
|
|
|
|
#ifdef HAVE_PNG
|
|
|
|
&video_out_png,
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_JPEG
|
|
|
|
&video_out_jpeg,
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_GIF
|
|
|
|
&video_out_gif89a,
|
2003-08-24 18:26:37 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_TGA
|
|
|
|
&video_out_tga,
|
2002-01-12 23:30:20 +00:00
|
|
|
#endif
|
2004-10-23 22:43:19 +00:00
|
|
|
#ifdef HAVE_PNM
|
2004-09-20 01:31:26 +00:00
|
|
|
&video_out_pnm,
|
2004-10-23 22:43:19 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_MD5SUM
|
2004-09-20 01:35:43 +00:00
|
|
|
&video_out_md5sum,
|
2004-10-23 22:43:19 +00:00
|
|
|
#endif
|
2001-02-24 20:28:24 +00:00
|
|
|
NULL
|
|
|
|
};
|
2002-05-13 13:15:40 +00:00
|
|
|
|
2002-09-29 21:53:05 +00:00
|
|
|
void list_video_out(){
|
|
|
|
int i=0;
|
|
|
|
mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_AvailableVideoOutputDrivers);
|
|
|
|
while (video_out_drivers[i]) {
|
2002-11-11 15:22:10 +00:00
|
|
|
const vo_info_t *info = video_out_drivers[i++]->info;
|
2002-09-29 21:53:05 +00:00
|
|
|
printf("\t%s\t%s\n", info->short_name, info->name);
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
vo_functions_t* init_best_video_out(char** vo_list){
|
|
|
|
int i;
|
|
|
|
// first try the preferred drivers, with their optional subdevice param:
|
|
|
|
if(vo_list && vo_list[0])
|
|
|
|
while(vo_list[0][0]){
|
|
|
|
char* vo=strdup(vo_list[0]);
|
|
|
|
vo_subdevice=strchr(vo,':');
|
2004-09-29 01:46:30 +00:00
|
|
|
if (!strcmp(vo, "pgm"))
|
|
|
|
mp_msg(MSGT_CPLAYER, MSGL_ERR, MSGTR_VO_PGM_HasBeenReplaced);
|
|
|
|
if (!strcmp(vo, "md5"))
|
|
|
|
mp_msg(MSGT_CPLAYER, MSGL_ERR, MSGTR_VO_MD5_HasBeenReplaced);
|
2002-09-29 21:53:05 +00:00
|
|
|
if(vo_subdevice){
|
|
|
|
vo_subdevice[0]=0;
|
|
|
|
++vo_subdevice;
|
|
|
|
}
|
|
|
|
for(i=0;video_out_drivers[i];i++){
|
|
|
|
vo_functions_t* video_driver=video_out_drivers[i];
|
2002-11-11 15:22:10 +00:00
|
|
|
const vo_info_t *info = video_driver->info;
|
2002-09-29 21:53:05 +00:00
|
|
|
if(!strcmp(info->short_name,vo)){
|
|
|
|
// name matches, try it
|
|
|
|
if(!video_driver->preinit(vo_subdevice))
|
2003-05-31 17:33:33 +00:00
|
|
|
{
|
|
|
|
free(vo);
|
2002-09-29 21:53:05 +00:00
|
|
|
return video_driver; // success!
|
2003-05-31 17:33:33 +00:00
|
|
|
}
|
2002-09-29 21:53:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// continue...
|
2003-05-31 17:33:33 +00:00
|
|
|
free(vo);
|
2002-09-29 21:53:05 +00:00
|
|
|
++vo_list;
|
|
|
|
if(!(vo_list[0])) return NULL; // do NOT fallback to others
|
|
|
|
}
|
|
|
|
// now try the rest...
|
|
|
|
vo_subdevice=NULL;
|
|
|
|
for(i=0;video_out_drivers[i];i++){
|
|
|
|
vo_functions_t* video_driver=video_out_drivers[i];
|
|
|
|
if(!video_driver->preinit(vo_subdevice))
|
|
|
|
return video_driver; // success!
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-22 23:03:51 +00:00
|
|
|
#if defined(HAVE_FBDEV)||defined(HAVE_VESA)
|
|
|
|
/* Borrowed from vo_fbdev.c
|
|
|
|
Monitor ranges related functions*/
|
|
|
|
|
|
|
|
char *monitor_hfreq_str = NULL;
|
|
|
|
char *monitor_vfreq_str = NULL;
|
|
|
|
char *monitor_dotclock_str = NULL;
|
|
|
|
|
|
|
|
float range_max(range_t *r)
|
|
|
|
{
|
|
|
|
float max = 0;
|
|
|
|
|
|
|
|
for (/* NOTHING */; (r->min != -1 && r->max != -1); r++)
|
|
|
|
if (max < r->max) max = r->max;
|
|
|
|
return max;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int in_range(range_t *r, float f)
|
|
|
|
{
|
|
|
|
for (/* NOTHING */; (r->min != -1 && r->max != -1); r++)
|
|
|
|
if (f >= r->min && f <= r->max)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
range_t *str2range(char *s)
|
|
|
|
{
|
|
|
|
float tmp_min, tmp_max;
|
|
|
|
char *endptr = s; // to start the loop
|
|
|
|
range_t *r = NULL;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!s)
|
|
|
|
return NULL;
|
|
|
|
for (i = 0; *endptr; i++) {
|
|
|
|
if (*s == ',')
|
|
|
|
goto out_err;
|
|
|
|
if (!(r = (range_t *) realloc(r, sizeof(*r) * (i + 2)))) {
|
|
|
|
printf("can't realloc 'r'\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
tmp_min = strtod(s, &endptr);
|
|
|
|
if (*endptr == 'k' || *endptr == 'K') {
|
|
|
|
tmp_min *= 1000.0;
|
|
|
|
endptr++;
|
|
|
|
} else if (*endptr == 'm' || *endptr == 'M') {
|
|
|
|
tmp_min *= 1000000.0;
|
|
|
|
endptr++;
|
|
|
|
}
|
|
|
|
if (*endptr == '-') {
|
|
|
|
tmp_max = strtod(endptr + 1, &endptr);
|
|
|
|
if (*endptr == 'k' || *endptr == 'K') {
|
|
|
|
tmp_max *= 1000.0;
|
|
|
|
endptr++;
|
|
|
|
} else if (*endptr == 'm' || *endptr == 'M') {
|
|
|
|
tmp_max *= 1000000.0;
|
|
|
|
endptr++;
|
|
|
|
}
|
|
|
|
if (*endptr != ',' && *endptr)
|
|
|
|
goto out_err;
|
|
|
|
} else if (*endptr == ',' || !*endptr) {
|
|
|
|
tmp_max = tmp_min;
|
|
|
|
} else
|
|
|
|
goto out_err;
|
|
|
|
r[i].min = tmp_min;
|
|
|
|
r[i].max = tmp_max;
|
|
|
|
if (r[i].min < 0 || r[i].max < 0)
|
|
|
|
goto out_err;
|
|
|
|
s = endptr + 1;
|
|
|
|
}
|
|
|
|
r[i].min = r[i].max = -1;
|
|
|
|
return r;
|
|
|
|
out_err:
|
|
|
|
if (r)
|
|
|
|
free(r);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Borrowed from vo_fbdev.c END */
|
|
|
|
#endif
|
|
|
|
|