2009-02-08 04:27:30 +01:00
|
|
|
/*
|
|
|
|
* libvo common functions, variables used by many/all drivers.
|
|
|
|
*
|
|
|
|
* This file is part of MPlayer.
|
|
|
|
*
|
|
|
|
* MPlayer is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* MPlayer is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with MPlayer; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
2001-02-24 21:28:24 +01:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <unistd.h>
|
2002-03-24 01:44:54 +01:00
|
|
|
//#include <sys/mman.h>
|
2001-02-24 21:28:24 +01:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "video_out.h"
|
2007-02-17 21:58:55 +01:00
|
|
|
#include "aspect.h"
|
|
|
|
#include "geometry.h"
|
2001-02-24 21:28:24 +01:00
|
|
|
|
2002-09-29 23:53:05 +02:00
|
|
|
#include "mp_msg.h"
|
|
|
|
#include "help_mp.h"
|
2010-04-27 17:17:49 +02:00
|
|
|
#include "input/input.h"
|
2004-10-28 03:15:53 +02:00
|
|
|
#include "osdep/shmem.h"
|
2001-02-24 21:28:24 +01:00
|
|
|
|
2002-03-15 00:09:27 +01:00
|
|
|
//int vo_flags=0;
|
2002-02-17 04:06:38 +01:00
|
|
|
|
2006-04-16 15:38:28 +02:00
|
|
|
int xinerama_screen = -1;
|
|
|
|
int xinerama_x;
|
|
|
|
int xinerama_y;
|
|
|
|
|
2001-04-13 15:47:36 +02: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 04:12:15 +02:00
|
|
|
int vo_config_count=0;
|
|
|
|
|
2001-04-13 15:47:36 +02:00
|
|
|
// requested resolution/bpp: (-x -y -bpp options)
|
2002-02-22 19:00:38 +01:00
|
|
|
int vo_dx=0;
|
|
|
|
int vo_dy=0;
|
2001-04-13 15:47:36 +02:00
|
|
|
int vo_dwidth=0;
|
|
|
|
int vo_dheight=0;
|
|
|
|
int vo_dbpp=0;
|
2002-03-07 18:50:25 +01:00
|
|
|
|
2003-09-01 20:24:27 +02:00
|
|
|
int vo_nomouse_input = 0;
|
2002-09-28 22:09:14 +02:00
|
|
|
int vo_grabpointer = 1;
|
2004-11-30 08:42:08 +01:00
|
|
|
int vo_doublebuffering = 1;
|
2002-02-12 16:06:04 +01:00
|
|
|
int vo_vsync = 0;
|
2002-03-07 18:50:25 +01:00
|
|
|
int vo_fs = 0;
|
2001-07-04 01:46:24 +02:00
|
|
|
int vo_fsmode = 0;
|
2002-06-04 22:17:07 +02:00
|
|
|
float vo_panscan = 0.0f;
|
2003-11-30 17:36:10 +01:00
|
|
|
int vo_ontop = 0;
|
2004-03-13 17:48:52 +01:00
|
|
|
int vo_adapter_num=0;
|
|
|
|
int vo_refresh_rate=0;
|
2004-05-01 16:52:15 +02:00
|
|
|
int vo_keepaspect=1;
|
2004-07-29 16:59:48 +02:00
|
|
|
int vo_rootwin=0;
|
2005-11-10 23:25:54 +01:00
|
|
|
int vo_border=1;
|
2009-03-02 12:24:20 +01:00
|
|
|
int64_t WinID = -1;
|
2001-04-13 15:47:36 +02:00
|
|
|
|
2001-11-05 03:58:47 +01:00
|
|
|
int vo_pts=0; // for hw decoding
|
2006-07-12 15:03:40 +02:00
|
|
|
float vo_fps=0;
|
2001-11-05 03:58:47 +01:00
|
|
|
|
2001-06-22 00:34:25 +02:00
|
|
|
char *vo_subdevice = NULL;
|
2002-03-31 22:38:56 +02:00
|
|
|
int vo_directrendering=0;
|
2002-07-24 20:19:39 +02:00
|
|
|
|
2003-10-03 20:13:45 +02:00
|
|
|
int vo_colorkey = 0x0000ff00; // default colorkey is green
|
2008-12-20 12:49:00 +01:00
|
|
|
// (0xff000000 means that colorkey has been disabled)
|
2003-10-03 20:13:45 +02:00
|
|
|
|
2009-11-12 10:21:53 +01:00
|
|
|
// name to be used instead of the vo's default
|
|
|
|
char *vo_winname;
|
|
|
|
// title to be applied to movie window
|
|
|
|
char *vo_wintitle;
|
|
|
|
|
2001-02-24 21:28:24 +01:00
|
|
|
//
|
|
|
|
// Externally visible list of all vo drivers
|
|
|
|
//
|
2010-03-27 16:27:16 +01:00
|
|
|
extern const vo_functions_t video_out_mga;
|
|
|
|
extern const vo_functions_t video_out_xmga;
|
|
|
|
extern const vo_functions_t video_out_x11;
|
2003-03-12 16:04:05 +01:00
|
|
|
extern vo_functions_t video_out_xover;
|
2010-03-27 16:27:16 +01:00
|
|
|
extern const vo_functions_t video_out_xvmc;
|
|
|
|
extern const vo_functions_t video_out_vdpau;
|
|
|
|
extern const vo_functions_t video_out_xv;
|
|
|
|
extern const vo_functions_t video_out_gl_nosw;
|
|
|
|
extern const vo_functions_t video_out_gl;
|
|
|
|
extern const vo_functions_t video_out_gl2;
|
|
|
|
extern const vo_functions_t video_out_matrixview;
|
|
|
|
extern const vo_functions_t video_out_dga;
|
|
|
|
extern const vo_functions_t video_out_sdl;
|
|
|
|
extern const vo_functions_t video_out_3dfx;
|
|
|
|
extern const vo_functions_t video_out_tdfxfb;
|
|
|
|
extern const vo_functions_t video_out_s3fb;
|
|
|
|
extern const vo_functions_t video_out_wii;
|
|
|
|
extern const vo_functions_t video_out_null;
|
|
|
|
extern const vo_functions_t video_out_zr;
|
|
|
|
extern const vo_functions_t video_out_zr2;
|
|
|
|
extern const vo_functions_t video_out_bl;
|
2001-03-28 14:08:44 +02:00
|
|
|
extern vo_functions_t video_out_fbdev;
|
2010-03-27 16:27:16 +01:00
|
|
|
extern const vo_functions_t video_out_fbdev2;
|
2001-04-05 21:01:27 +02:00
|
|
|
extern vo_functions_t video_out_svga;
|
2010-03-27 16:27:16 +01:00
|
|
|
extern const vo_functions_t video_out_png;
|
|
|
|
extern const vo_functions_t video_out_ggi;
|
|
|
|
extern const vo_functions_t video_out_aa;
|
|
|
|
extern const vo_functions_t video_out_caca;
|
|
|
|
extern const vo_functions_t video_out_mpegpes;
|
|
|
|
extern const vo_functions_t video_out_yuv4mpeg;
|
|
|
|
extern const vo_functions_t video_out_direct3d;
|
|
|
|
extern const vo_functions_t video_out_directx;
|
|
|
|
extern const vo_functions_t video_out_kva;
|
|
|
|
extern const vo_functions_t video_out_dxr2;
|
|
|
|
extern const vo_functions_t video_out_dxr3;
|
|
|
|
extern const vo_functions_t video_out_ivtv;
|
|
|
|
extern const vo_functions_t video_out_v4l2;
|
|
|
|
extern const vo_functions_t video_out_jpeg;
|
|
|
|
extern const vo_functions_t video_out_gif89a;
|
2001-10-17 20:24:50 +02:00
|
|
|
extern vo_functions_t video_out_vesa;
|
2010-03-27 16:27:16 +01:00
|
|
|
extern const vo_functions_t video_out_directfb;
|
|
|
|
extern const vo_functions_t video_out_dfbmga;
|
2002-01-13 00:30:20 +01:00
|
|
|
extern vo_functions_t video_out_xvidix;
|
2003-10-02 16:25:52 +02:00
|
|
|
extern vo_functions_t video_out_winvidix;
|
2003-10-05 17:34:40 +02:00
|
|
|
extern vo_functions_t video_out_cvidix;
|
2010-03-27 16:27:16 +01:00
|
|
|
extern const vo_functions_t video_out_tdfx_vid;
|
|
|
|
extern const vo_functions_t video_out_xvr100;
|
|
|
|
extern const vo_functions_t video_out_tga;
|
|
|
|
extern const vo_functions_t video_out_corevideo;
|
|
|
|
extern const vo_functions_t video_out_quartz;
|
|
|
|
extern const vo_functions_t video_out_pnm;
|
|
|
|
extern const vo_functions_t video_out_md5sum;
|
2002-01-13 00:30:20 +01:00
|
|
|
|
2007-12-02 15:24:23 +01:00
|
|
|
const vo_functions_t* const video_out_drivers[] =
|
2001-02-24 21:28:24 +01:00
|
|
|
{
|
2008-08-02 19:38:11 +02:00
|
|
|
#ifdef CONFIG_XVR100
|
2007-08-03 19:14:35 +02:00
|
|
|
&video_out_xvr100,
|
|
|
|
#endif
|
2008-08-02 19:38:11 +02:00
|
|
|
#ifdef CONFIG_TDFX_VID
|
2003-03-07 19:45:02 +01:00
|
|
|
&video_out_tdfx_vid,
|
|
|
|
#endif
|
2008-08-02 19:38:11 +02:00
|
|
|
#ifdef CONFIG_DIRECTX
|
2003-01-03 06:10:44 +01:00
|
|
|
&video_out_directx,
|
|
|
|
#endif
|
2008-11-18 14:18:55 +01:00
|
|
|
#ifdef CONFIG_DIRECT3D
|
|
|
|
&video_out_direct3d,
|
|
|
|
#endif
|
2009-03-14 19:44:58 +01:00
|
|
|
#ifdef CONFIG_KVA
|
|
|
|
&video_out_kva,
|
|
|
|
#endif
|
2008-08-06 09:42:26 +02:00
|
|
|
#ifdef CONFIG_COREVIDEO
|
2009-05-04 18:55:05 +02:00
|
|
|
&video_out_corevideo,
|
2005-05-05 02:17:27 +02:00
|
|
|
#endif
|
2008-08-06 09:42:26 +02:00
|
|
|
#ifdef CONFIG_QUARTZ
|
2008-12-20 12:49:00 +01:00
|
|
|
&video_out_quartz,
|
2004-06-17 03:07:53 +02:00
|
|
|
#endif
|
2008-08-02 19:38:11 +02:00
|
|
|
#ifdef CONFIG_XMGA
|
2001-02-24 21:28:24 +01:00
|
|
|
&video_out_xmga,
|
|
|
|
#endif
|
2008-08-02 19:38:11 +02:00
|
|
|
#ifdef CONFIG_MGA
|
2001-02-24 21:28:24 +01:00
|
|
|
&video_out_mga,
|
|
|
|
#endif
|
2008-08-02 19:38:11 +02:00
|
|
|
#ifdef CONFIG_TDFXFB
|
2001-09-27 14:23:54 +02:00
|
|
|
&video_out_tdfxfb,
|
|
|
|
#endif
|
2008-08-02 19:38:11 +02:00
|
|
|
#ifdef CONFIG_S3FB
|
2006-05-17 22:56:49 +02:00
|
|
|
&video_out_s3fb,
|
|
|
|
#endif
|
2008-08-03 22:04:03 +02:00
|
|
|
#ifdef CONFIG_WII
|
|
|
|
&video_out_wii,
|
|
|
|
#endif
|
2008-08-02 19:38:11 +02:00
|
|
|
#ifdef CONFIG_3DFX
|
2005-12-01 12:58:44 +01:00
|
|
|
&video_out_3dfx,
|
|
|
|
#endif
|
2009-02-21 12:44:10 +01:00
|
|
|
#if CONFIG_VDPAU
|
|
|
|
&video_out_vdpau,
|
|
|
|
#endif
|
2009-04-01 00:06:40 +02:00
|
|
|
#ifdef CONFIG_XV
|
|
|
|
&video_out_xv,
|
|
|
|
#endif
|
2010-02-27 19:16:41 +01:00
|
|
|
#ifdef CONFIG_X11
|
2010-02-25 23:53:04 +01:00
|
|
|
#ifdef CONFIG_GL
|
2010-02-27 19:16:41 +01:00
|
|
|
&video_out_gl_nosw,
|
2010-02-25 23:53:04 +01:00
|
|
|
#endif
|
2001-02-24 21:28:24 +01:00
|
|
|
&video_out_x11,
|
2003-03-12 16:04:05 +01:00
|
|
|
&video_out_xover,
|
2001-02-24 21:28:24 +01:00
|
|
|
#endif
|
2008-08-02 19:38:11 +02:00
|
|
|
#ifdef CONFIG_GL
|
2010-02-27 19:16:41 +01:00
|
|
|
&video_out_gl,
|
2001-10-07 23:35:59 +02:00
|
|
|
&video_out_gl2,
|
2001-02-24 21:28:24 +01:00
|
|
|
#endif
|
2008-08-04 08:16:23 +02:00
|
|
|
#ifdef CONFIG_DGA
|
2001-02-27 02:08:09 +01:00
|
|
|
&video_out_dga,
|
|
|
|
#endif
|
2008-08-02 19:38:11 +02:00
|
|
|
#ifdef CONFIG_SDL
|
2001-02-24 21:28:24 +01:00
|
|
|
&video_out_sdl,
|
2001-03-28 22:14:16 +02:00
|
|
|
#endif
|
2008-08-02 19:38:11 +02:00
|
|
|
#ifdef CONFIG_GGI
|
2008-12-20 12:49:00 +01:00
|
|
|
&video_out_ggi,
|
2001-06-27 01:34:03 +02:00
|
|
|
#endif
|
2008-08-02 19:38:11 +02:00
|
|
|
#ifdef CONFIG_FBDEV
|
2008-12-20 12:49:00 +01:00
|
|
|
&video_out_fbdev,
|
|
|
|
&video_out_fbdev2,
|
2001-04-05 21:01:27 +02:00
|
|
|
#endif
|
2008-08-02 19:38:11 +02:00
|
|
|
#ifdef CONFIG_SVGALIB
|
2008-12-20 12:49:00 +01:00
|
|
|
&video_out_svga,
|
2001-02-24 21:28:24 +01:00
|
|
|
#endif
|
2010-02-25 23:53:04 +01:00
|
|
|
#ifdef CONFIG_MATRIXVIEW
|
|
|
|
&video_out_matrixview,
|
|
|
|
#endif
|
2008-08-02 19:38:11 +02:00
|
|
|
#ifdef CONFIG_AA
|
2008-12-20 12:49:00 +01:00
|
|
|
&video_out_aa,
|
2001-08-14 14:30:56 +02:00
|
|
|
#endif
|
2008-08-02 19:38:11 +02:00
|
|
|
#ifdef CONFIG_CACA
|
2008-12-20 12:49:00 +01:00
|
|
|
&video_out_caca,
|
2004-04-06 02:04:48 +02:00
|
|
|
#endif
|
2008-08-03 17:21:40 +02:00
|
|
|
#ifdef CONFIG_DXR2
|
2008-12-20 12:49:00 +01:00
|
|
|
&video_out_dxr2,
|
2002-05-13 15:15:40 +02:00
|
|
|
#endif
|
2008-08-03 17:21:40 +02:00
|
|
|
#ifdef CONFIG_DXR3
|
2008-12-20 12:49:00 +01:00
|
|
|
&video_out_dxr3,
|
2001-11-03 03:38:10 +01:00
|
|
|
#endif
|
2008-08-03 17:21:40 +02:00
|
|
|
#ifdef CONFIG_IVTV
|
2006-07-20 00:02:09 +02:00
|
|
|
&video_out_ivtv,
|
|
|
|
#endif
|
2008-08-03 17:21:40 +02:00
|
|
|
#ifdef CONFIG_V4L2_DECODER
|
2007-07-29 21:20:55 +02:00
|
|
|
&video_out_v4l2,
|
|
|
|
#endif
|
2008-08-03 17:21:40 +02:00
|
|
|
#ifdef CONFIG_ZR
|
2008-12-20 12:49:00 +01:00
|
|
|
&video_out_zr,
|
|
|
|
&video_out_zr2,
|
2002-01-17 02:32:29 +01:00
|
|
|
#endif
|
2008-08-02 19:38:11 +02:00
|
|
|
#ifdef CONFIG_BL
|
2008-12-20 12:49:00 +01:00
|
|
|
&video_out_bl,
|
2002-09-09 00:41:53 +02:00
|
|
|
#endif
|
2008-08-02 19:38:11 +02:00
|
|
|
#ifdef CONFIG_VESA
|
2008-12-20 12:49:00 +01:00
|
|
|
&video_out_vesa,
|
2001-10-17 20:24:50 +02:00
|
|
|
#endif
|
2008-08-02 19:38:11 +02:00
|
|
|
#ifdef CONFIG_DIRECTFB
|
2008-12-20 12:49:00 +01:00
|
|
|
&video_out_directfb,
|
2008-03-07 18:20:04 +01:00
|
|
|
#endif
|
2008-08-02 19:38:11 +02:00
|
|
|
#ifdef CONFIG_DFBMGA
|
2002-11-01 00:54:26 +01:00
|
|
|
&video_out_dfbmga,
|
|
|
|
#endif
|
2003-10-02 16:25:52 +02:00
|
|
|
#ifdef CONFIG_VIDIX
|
2008-08-04 08:16:23 +02:00
|
|
|
#ifdef CONFIG_X11
|
2008-12-20 12:49:00 +01:00
|
|
|
&video_out_xvidix,
|
2003-10-02 16:25:52 +02:00
|
|
|
#endif
|
2008-10-13 18:23:55 +02:00
|
|
|
#if defined(__MINGW32__) || defined(__CYGWIN__)
|
2008-12-20 12:49:00 +01:00
|
|
|
&video_out_winvidix,
|
2003-10-02 16:25:52 +02:00
|
|
|
#endif
|
2008-12-20 12:49:00 +01:00
|
|
|
&video_out_cvidix,
|
2004-10-04 21:36:12 +02:00
|
|
|
#endif
|
|
|
|
&video_out_null,
|
2008-12-20 12:49:00 +01:00
|
|
|
// should not be auto-selected
|
2009-01-31 00:58:07 +01:00
|
|
|
#if CONFIG_XVMC
|
2006-01-18 19:11:02 +01:00
|
|
|
&video_out_xvmc,
|
|
|
|
#endif
|
2008-12-20 12:49:00 +01:00
|
|
|
&video_out_mpegpes,
|
2008-08-02 19:38:11 +02:00
|
|
|
#ifdef CONFIG_YUV4MPEG
|
2008-12-20 12:49:00 +01:00
|
|
|
&video_out_yuv4mpeg,
|
2008-06-20 21:33:32 +02:00
|
|
|
#endif
|
2010-01-05 11:52:12 +01:00
|
|
|
#ifdef CONFIG_LIBAVCODEC
|
2008-12-20 12:49:00 +01:00
|
|
|
&video_out_png,
|
|
|
|
#endif
|
2008-08-05 10:47:51 +02:00
|
|
|
#ifdef CONFIG_JPEG
|
2008-12-20 12:49:00 +01:00
|
|
|
&video_out_jpeg,
|
2004-10-04 21:36:12 +02:00
|
|
|
#endif
|
2008-08-05 10:47:51 +02:00
|
|
|
#ifdef CONFIG_GIF
|
2008-12-20 12:49:00 +01:00
|
|
|
&video_out_gif89a,
|
2003-08-24 20:26:37 +02:00
|
|
|
#endif
|
2008-08-02 19:38:11 +02:00
|
|
|
#ifdef CONFIG_TGA
|
2003-08-24 20:26:37 +02:00
|
|
|
&video_out_tga,
|
2002-01-13 00:30:20 +01:00
|
|
|
#endif
|
2008-08-05 10:47:51 +02:00
|
|
|
#ifdef CONFIG_PNM
|
2008-12-20 12:49:00 +01:00
|
|
|
&video_out_pnm,
|
2004-10-24 00:43:19 +02:00
|
|
|
#endif
|
2008-08-02 19:38:11 +02:00
|
|
|
#ifdef CONFIG_MD5SUM
|
2008-12-20 12:49:00 +01:00
|
|
|
&video_out_md5sum,
|
2004-10-24 00:43:19 +02:00
|
|
|
#endif
|
2001-02-24 21:28:24 +01:00
|
|
|
NULL
|
|
|
|
};
|
2002-05-13 15:15:40 +02:00
|
|
|
|
2006-02-09 15:08:03 +01:00
|
|
|
void list_video_out(void){
|
2002-09-29 23:53:05 +02:00
|
|
|
int i=0;
|
|
|
|
mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_AvailableVideoOutputDrivers);
|
2006-04-24 09:20:34 +02:00
|
|
|
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_OUTPUTS\n");
|
2002-09-29 23:53:05 +02:00
|
|
|
while (video_out_drivers[i]) {
|
2002-11-11 16:22:10 +01:00
|
|
|
const vo_info_t *info = video_out_drivers[i++]->info;
|
2008-12-20 12:49:00 +01:00
|
|
|
mp_msg(MSGT_GLOBAL, MSGL_INFO,"\t%s\t%s\n", info->short_name, info->name);
|
2002-09-29 23:53:05 +02:00
|
|
|
}
|
2006-04-24 06:23:53 +02:00
|
|
|
mp_msg(MSGT_GLOBAL, MSGL_INFO,"\n");
|
2002-09-29 23:53:05 +02:00
|
|
|
}
|
|
|
|
|
2007-12-02 15:24:23 +01:00
|
|
|
const vo_functions_t* init_best_video_out(char** vo_list){
|
2002-09-29 23:53:05 +02:00
|
|
|
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 03:46:30 +02: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 23:53:05 +02:00
|
|
|
if(vo_subdevice){
|
|
|
|
vo_subdevice[0]=0;
|
|
|
|
++vo_subdevice;
|
|
|
|
}
|
|
|
|
for(i=0;video_out_drivers[i];i++){
|
2007-12-02 15:24:23 +01:00
|
|
|
const vo_functions_t* video_driver=video_out_drivers[i];
|
2002-11-11 16:22:10 +01:00
|
|
|
const vo_info_t *info = video_driver->info;
|
2002-09-29 23:53:05 +02:00
|
|
|
if(!strcmp(info->short_name,vo)){
|
|
|
|
// name matches, try it
|
|
|
|
if(!video_driver->preinit(vo_subdevice))
|
2003-05-31 19:33:33 +02:00
|
|
|
{
|
|
|
|
free(vo);
|
2002-09-29 23:53:05 +02:00
|
|
|
return video_driver; // success!
|
2003-05-31 19:33:33 +02:00
|
|
|
}
|
2002-09-29 23:53:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// continue...
|
2003-05-31 19:33:33 +02:00
|
|
|
free(vo);
|
2002-09-29 23:53:05 +02: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++){
|
2007-12-02 15:24:23 +01:00
|
|
|
const vo_functions_t* video_driver=video_out_drivers[i];
|
2002-09-29 23:53:05 +02:00
|
|
|
if(!video_driver->preinit(vo_subdevice))
|
|
|
|
return video_driver; // success!
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2007-12-02 15:24:23 +01:00
|
|
|
int config_video_out(const vo_functions_t *vo, uint32_t width, uint32_t height,
|
2007-02-17 21:58:55 +01:00
|
|
|
uint32_t d_width, uint32_t d_height, uint32_t flags,
|
|
|
|
char *title, uint32_t format) {
|
|
|
|
panscan_init();
|
|
|
|
aspect_save_orig(width,height);
|
|
|
|
aspect_save_prescale(d_width,d_height);
|
|
|
|
|
2007-02-25 15:35:53 +01:00
|
|
|
if (vo->control(VOCTRL_UPDATE_SCREENINFO, NULL) == VO_TRUE) {
|
2007-02-17 21:58:55 +01:00
|
|
|
aspect(&d_width,&d_height,A_NOZOOM);
|
|
|
|
vo_dx = (int)(vo_screenwidth - d_width) / 2;
|
|
|
|
vo_dy = (int)(vo_screenheight - d_height) / 2;
|
|
|
|
geometry(&vo_dx, &vo_dy, &d_width, &d_height,
|
|
|
|
vo_screenwidth, vo_screenheight);
|
|
|
|
vo_dx += xinerama_x;
|
|
|
|
vo_dy += xinerama_y;
|
|
|
|
vo_dwidth = d_width;
|
|
|
|
vo_dheight = d_height;
|
2007-02-18 22:24:26 +01:00
|
|
|
}
|
2007-02-17 21:58:55 +01:00
|
|
|
|
2007-02-18 21:19:47 +01:00
|
|
|
return vo->config(width, height, d_width, d_height, flags, title, format);
|
2007-02-17 21:58:55 +01:00
|
|
|
}
|
2002-09-29 23:53:05 +02:00
|
|
|
|
2008-12-20 12:52:11 +01:00
|
|
|
/**
|
|
|
|
* \brief lookup an integer in a table, table must have 0 as the last key
|
|
|
|
* \param key key to search for
|
|
|
|
* \result translation corresponding to key or "to" value of last mapping
|
|
|
|
* if not found.
|
|
|
|
*/
|
2010-04-23 12:22:44 +02:00
|
|
|
int lookup_keymap_table(const struct mp_keymap *map, int key) {
|
2008-12-20 12:52:11 +01:00
|
|
|
while (map->from && map->from != key) map++;
|
|
|
|
return map->to;
|
|
|
|
}
|
|
|
|
|
2009-02-12 18:40:53 +01:00
|
|
|
/**
|
|
|
|
* \brief helper function for the kind of panscan-scaling that needs a source
|
|
|
|
* and destination rectangle like Direct3D and VDPAU
|
|
|
|
*/
|
|
|
|
static void src_dst_split_scaling(int src_size, int dst_size, int scaled_src_size,
|
|
|
|
int *src_start, int *src_end, int *dst_start, int *dst_end) {
|
|
|
|
if (scaled_src_size > dst_size) {
|
|
|
|
int border = src_size * (scaled_src_size - dst_size) / scaled_src_size;
|
|
|
|
// round to a multiple of 2, this is at least needed for vo_direct3d and ATI cards
|
|
|
|
border = (border / 2 + 1) & ~1;
|
|
|
|
*src_start = border;
|
|
|
|
*src_end = src_size - border;
|
|
|
|
*dst_start = 0;
|
|
|
|
*dst_end = dst_size;
|
|
|
|
} else {
|
|
|
|
*src_start = 0;
|
|
|
|
*src_end = src_size;
|
|
|
|
*dst_start = (dst_size - scaled_src_size) / 2;
|
|
|
|
*dst_end = *dst_start + scaled_src_size;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Calculate the appropriate source and destination rectangle to
|
|
|
|
* get a correctly scaled picture, including pan-scan.
|
|
|
|
* Can be extended to take future cropping support into account.
|
|
|
|
*
|
|
|
|
* \param crop specifies the cropping border size in the left, right, top and bottom members, may be NULL
|
2009-02-17 12:59:49 +01:00
|
|
|
* \param borders the border values as e.g. EOSD (ASS) and properly placed DVD highlight support requires,
|
|
|
|
* may be NULL and only left and top are currently valid.
|
2009-02-12 18:40:53 +01:00
|
|
|
*/
|
2009-02-17 12:59:49 +01:00
|
|
|
void calc_src_dst_rects(int src_width, int src_height, struct vo_rect *src, struct vo_rect *dst,
|
|
|
|
struct vo_rect *borders, const struct vo_rect *crop) {
|
2009-02-12 18:40:53 +01:00
|
|
|
static const struct vo_rect no_crop = {0, 0, 0, 0, 0, 0};
|
|
|
|
int scaled_width = 0;
|
|
|
|
int scaled_height = 0;
|
|
|
|
if (!crop) crop = &no_crop;
|
|
|
|
src_width -= crop->left + crop->right;
|
|
|
|
src_height -= crop->top + crop->bottom;
|
|
|
|
if (src_width < 2) src_width = 2;
|
|
|
|
if (src_height < 2) src_height = 2;
|
|
|
|
dst->left = 0; dst->right = vo_dwidth;
|
|
|
|
dst->top = 0; dst->bottom = vo_dheight;
|
|
|
|
src->left = 0; src->right = src_width;
|
|
|
|
src->top = 0; src->bottom = src_height;
|
2009-02-17 12:59:49 +01:00
|
|
|
if (borders) {
|
|
|
|
borders->left = 0; borders->top = 0;
|
|
|
|
}
|
2009-08-27 21:13:19 +02:00
|
|
|
if (aspect_scaling()) {
|
|
|
|
aspect(&scaled_width, &scaled_height, A_WINZOOM);
|
|
|
|
panscan_calc_windowed();
|
2009-02-12 18:40:53 +01:00
|
|
|
scaled_width += vo_panscan_x;
|
|
|
|
scaled_height += vo_panscan_y;
|
2009-02-17 12:59:49 +01:00
|
|
|
if (borders) {
|
|
|
|
borders->left = (vo_dwidth - scaled_width ) / 2;
|
|
|
|
borders->top = (vo_dheight - scaled_height) / 2;
|
|
|
|
}
|
2009-02-12 18:40:53 +01:00
|
|
|
src_dst_split_scaling(src_width, vo_dwidth, scaled_width,
|
|
|
|
&src->left, &src->right, &dst->left, &dst->right);
|
|
|
|
src_dst_split_scaling(src_height, vo_dheight, scaled_height,
|
|
|
|
&src->top, &src->bottom, &dst->top, &dst->bottom);
|
|
|
|
}
|
|
|
|
src->left += crop->left; src->right += crop->left;
|
|
|
|
src->top += crop->top; src->bottom += crop->top;
|
|
|
|
src->width = src->right - src->left;
|
|
|
|
src->height = src->bottom - src->top;
|
|
|
|
dst->width = dst->right - dst->left;
|
|
|
|
dst->height = dst->bottom - dst->top;
|
|
|
|
}
|
|
|
|
|
2010-04-25 18:13:57 +02:00
|
|
|
/**
|
|
|
|
* Generates a mouse movement message if those are enable and sends it
|
|
|
|
* to the "main" MPlayer.
|
|
|
|
*
|
|
|
|
* \param posx new x position of mouse
|
|
|
|
* \param posy new y position of mouse
|
|
|
|
*/
|
|
|
|
void vo_mouse_movement(int posx, int posy) {
|
|
|
|
char cmd_str[40];
|
|
|
|
if (!enable_mouse_movements)
|
|
|
|
return;
|
|
|
|
snprintf(cmd_str, sizeof(cmd_str), "set_mouse_pos %i %i", posx, posy);
|
|
|
|
mp_input_queue_cmd(mp_input_parse_cmd(cmd_str));
|
|
|
|
}
|
|
|
|
|
2008-08-02 19:38:11 +02:00
|
|
|
#if defined(CONFIG_FBDEV) || defined(CONFIG_VESA)
|
2008-12-20 12:49:00 +01:00
|
|
|
/* Borrowed from vo_fbdev.c
|
2002-08-23 01:03:51 +02:00
|
|
|
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;
|
2010-02-26 16:01:37 +01:00
|
|
|
if (!(r = realloc(r, sizeof(*r) * (i + 2)))) {
|
2006-04-24 06:23:53 +02:00
|
|
|
mp_msg(MSGT_GLOBAL, MSGL_WARN,"can't realloc 'r'\n");
|
2002-08-23 01:03:51 +02:00
|
|
|
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
|