2009-02-08 03:27:30 +00: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 20:28:24 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2009-09-17 14:47:43 +00:00
|
|
|
#include <assert.h>
|
2009-09-18 13:27:55 +00:00
|
|
|
#include <stdbool.h>
|
2001-02-24 20:28:24 +00:00
|
|
|
|
|
|
|
#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"
|
2008-04-19 04:04:55 +00:00
|
|
|
#include "options.h"
|
2008-04-20 03:04:10 +00:00
|
|
|
#include "talloc.h"
|
2001-02-24 20:28:24 +00:00
|
|
|
#include "video_out.h"
|
2007-02-17 20:58:55 +00:00
|
|
|
#include "aspect.h"
|
|
|
|
#include "geometry.h"
|
2009-09-17 14:47:43 +00:00
|
|
|
#include "old_vo_wrapper.h"
|
2010-04-26 16:22:56 +00:00
|
|
|
#include "input/input.h"
|
2010-12-14 19:58:47 +00:00
|
|
|
#include "mp_fifo.h"
|
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
|
2002-09-29 21:53:05 +00:00
|
|
|
#include "mp_msg.h"
|
|
|
|
|
2004-10-28 01:15:53 +00:00
|
|
|
#include "osdep/shmem.h"
|
2008-08-07 23:04:43 +00:00
|
|
|
#ifdef CONFIG_X11
|
2008-04-20 04:36:34 +00:00
|
|
|
#include "x11_common.h"
|
|
|
|
#endif
|
2001-02-24 20:28:24 +00:00
|
|
|
|
2006-04-16 13:38:28 +00:00
|
|
|
int xinerama_screen = -1;
|
|
|
|
int xinerama_x;
|
|
|
|
int xinerama_y;
|
|
|
|
|
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;
|
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;
|
2005-11-10 22:25:54 +00:00
|
|
|
int vo_border=1;
|
2009-03-02 11:24:20 +00:00
|
|
|
int64_t 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
|
2006-07-12 13:03:40 +00:00
|
|
|
float vo_fps=0;
|
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
|
2008-12-20 11:49:00 +00:00
|
|
|
// (0xff000000 means that colorkey has been disabled)
|
2003-10-03 18:13:45 +00:00
|
|
|
|
2009-11-12 09:21:53 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
//
|
|
|
|
// Externally visible list of all vo drivers
|
|
|
|
//
|
2008-04-03 03:25:41 +00:00
|
|
|
extern struct vo_driver video_out_mga;
|
|
|
|
extern struct vo_driver video_out_xmga;
|
|
|
|
extern struct vo_driver video_out_x11;
|
|
|
|
extern struct vo_driver video_out_xover;
|
2009-02-17 23:07:37 +00:00
|
|
|
extern struct vo_driver video_out_vdpau;
|
2008-04-03 03:25:41 +00:00
|
|
|
extern struct vo_driver video_out_xv;
|
2010-03-10 00:14:30 +00:00
|
|
|
extern struct vo_driver video_out_gl_nosw;
|
2008-04-03 03:25:41 +00:00
|
|
|
extern struct vo_driver video_out_gl;
|
2011-09-29 20:20:46 +00:00
|
|
|
extern struct vo_driver video_out_gl_sdl;
|
2008-04-03 03:25:41 +00:00
|
|
|
extern struct vo_driver video_out_dga;
|
|
|
|
extern struct vo_driver video_out_sdl;
|
|
|
|
extern struct vo_driver video_out_3dfx;
|
|
|
|
extern struct vo_driver video_out_tdfxfb;
|
|
|
|
extern struct vo_driver video_out_s3fb;
|
2008-08-07 23:04:43 +00:00
|
|
|
extern struct vo_driver video_out_wii;
|
2008-04-03 03:25:41 +00:00
|
|
|
extern struct vo_driver video_out_null;
|
|
|
|
extern struct vo_driver video_out_bl;
|
|
|
|
extern struct vo_driver video_out_fbdev;
|
|
|
|
extern struct vo_driver video_out_fbdev2;
|
|
|
|
extern struct vo_driver video_out_svga;
|
|
|
|
extern struct vo_driver video_out_png;
|
|
|
|
extern struct vo_driver video_out_ggi;
|
|
|
|
extern struct vo_driver video_out_aa;
|
|
|
|
extern struct vo_driver video_out_caca;
|
|
|
|
extern struct vo_driver video_out_mpegpes;
|
|
|
|
extern struct vo_driver video_out_yuv4mpeg;
|
2008-11-22 17:16:43 +00:00
|
|
|
extern struct vo_driver video_out_direct3d;
|
2008-04-03 03:25:41 +00:00
|
|
|
extern struct vo_driver video_out_directx;
|
2009-03-14 21:52:45 +00:00
|
|
|
extern struct vo_driver video_out_kva;
|
2008-04-03 03:25:41 +00:00
|
|
|
extern struct vo_driver video_out_dxr3;
|
|
|
|
extern struct vo_driver video_out_ivtv;
|
|
|
|
extern struct vo_driver video_out_v4l2;
|
|
|
|
extern struct vo_driver video_out_jpeg;
|
|
|
|
extern struct vo_driver video_out_gif89a;
|
|
|
|
extern struct vo_driver video_out_vesa;
|
|
|
|
extern struct vo_driver video_out_directfb;
|
|
|
|
extern struct vo_driver video_out_dfbmga;
|
|
|
|
extern struct vo_driver video_out_tdfx_vid;
|
|
|
|
extern struct vo_driver video_out_xvr100;
|
|
|
|
extern struct vo_driver video_out_tga;
|
2009-05-08 20:50:26 +00:00
|
|
|
extern struct vo_driver video_out_corevideo;
|
2008-04-03 03:25:41 +00:00
|
|
|
extern struct vo_driver video_out_quartz;
|
|
|
|
extern struct vo_driver video_out_pnm;
|
|
|
|
extern struct vo_driver video_out_md5sum;
|
|
|
|
|
|
|
|
const struct vo_driver *video_out_drivers[] =
|
2001-02-24 20:28:24 +00:00
|
|
|
{
|
2008-08-02 17:38:11 +00:00
|
|
|
#ifdef CONFIG_XVR100
|
2007-08-03 17:14:35 +00:00
|
|
|
&video_out_xvr100,
|
|
|
|
#endif
|
2008-08-02 17:38:11 +00:00
|
|
|
#ifdef CONFIG_TDFX_VID
|
2003-03-07 18:45:02 +00:00
|
|
|
&video_out_tdfx_vid,
|
|
|
|
#endif
|
2008-08-02 17:38:11 +00:00
|
|
|
#ifdef CONFIG_DIRECTX
|
2003-01-03 05:10:44 +00:00
|
|
|
&video_out_directx,
|
|
|
|
#endif
|
2008-11-18 13:18:55 +00:00
|
|
|
#ifdef CONFIG_DIRECT3D
|
|
|
|
&video_out_direct3d,
|
|
|
|
#endif
|
2009-03-14 18:44:58 +00:00
|
|
|
#ifdef CONFIG_KVA
|
|
|
|
&video_out_kva,
|
|
|
|
#endif
|
2008-08-06 07:42:26 +00:00
|
|
|
#ifdef CONFIG_COREVIDEO
|
2009-05-04 16:55:05 +00:00
|
|
|
&video_out_corevideo,
|
2005-05-05 00:17:27 +00:00
|
|
|
#endif
|
2008-08-06 07:42:26 +00:00
|
|
|
#ifdef CONFIG_QUARTZ
|
2008-12-20 11:49:00 +00:00
|
|
|
&video_out_quartz,
|
2004-06-17 01:07:53 +00:00
|
|
|
#endif
|
2008-08-02 17:38:11 +00:00
|
|
|
#ifdef CONFIG_XMGA
|
2001-02-24 20:28:24 +00:00
|
|
|
&video_out_xmga,
|
|
|
|
#endif
|
2008-08-02 17:38:11 +00:00
|
|
|
#ifdef CONFIG_MGA
|
2001-02-24 20:28:24 +00:00
|
|
|
&video_out_mga,
|
|
|
|
#endif
|
2008-08-02 17:38:11 +00:00
|
|
|
#ifdef CONFIG_TDFXFB
|
2001-09-27 12:23:54 +00:00
|
|
|
&video_out_tdfxfb,
|
|
|
|
#endif
|
2008-08-02 17:38:11 +00:00
|
|
|
#ifdef CONFIG_S3FB
|
2006-05-17 20:56:49 +00:00
|
|
|
&video_out_s3fb,
|
|
|
|
#endif
|
2008-08-03 20:04:03 +00:00
|
|
|
#ifdef CONFIG_WII
|
|
|
|
&video_out_wii,
|
|
|
|
#endif
|
2008-08-02 17:38:11 +00:00
|
|
|
#ifdef CONFIG_3DFX
|
2005-12-01 11:58:44 +00:00
|
|
|
&video_out_3dfx,
|
|
|
|
#endif
|
2009-04-02 20:48:10 +00:00
|
|
|
#if CONFIG_VDPAU
|
|
|
|
&video_out_vdpau,
|
|
|
|
#endif
|
2009-09-18 21:25:36 +00:00
|
|
|
#ifdef CONFIG_XV
|
|
|
|
&video_out_xv,
|
|
|
|
#endif
|
2010-02-27 18:16:41 +00:00
|
|
|
#ifdef CONFIG_X11
|
2010-02-25 22:53:04 +00:00
|
|
|
#ifdef CONFIG_GL
|
2010-02-27 18:16:41 +00:00
|
|
|
&video_out_gl_nosw,
|
2010-02-25 22:53:04 +00:00
|
|
|
#endif
|
2001-02-24 20:28:24 +00:00
|
|
|
&video_out_x11,
|
2003-03-12 15:04:05 +00:00
|
|
|
&video_out_xover,
|
2001-02-24 20:28:24 +00:00
|
|
|
#endif
|
2010-05-30 13:50:14 +00:00
|
|
|
#ifdef CONFIG_SDL
|
|
|
|
&video_out_sdl,
|
|
|
|
#endif
|
2008-08-02 17:38:11 +00:00
|
|
|
#ifdef CONFIG_GL
|
2010-02-27 18:16:41 +00:00
|
|
|
&video_out_gl,
|
2001-02-24 20:28:24 +00:00
|
|
|
#endif
|
2011-09-29 20:20:46 +00:00
|
|
|
#ifdef CONFIG_GL_SDL
|
|
|
|
&video_out_gl_sdl,
|
|
|
|
#endif
|
2008-08-04 06:16:23 +00:00
|
|
|
#ifdef CONFIG_DGA
|
2001-02-27 01:08:09 +00:00
|
|
|
&video_out_dga,
|
|
|
|
#endif
|
2008-08-02 17:38:11 +00:00
|
|
|
#ifdef CONFIG_GGI
|
2008-12-20 11:49:00 +00:00
|
|
|
&video_out_ggi,
|
2001-06-26 23:34:03 +00:00
|
|
|
#endif
|
2008-08-02 17:38:11 +00:00
|
|
|
#ifdef CONFIG_FBDEV
|
2008-12-20 11:49:00 +00:00
|
|
|
&video_out_fbdev,
|
|
|
|
&video_out_fbdev2,
|
2001-04-05 19:01:27 +00:00
|
|
|
#endif
|
2008-08-02 17:38:11 +00:00
|
|
|
#ifdef CONFIG_SVGALIB
|
2008-12-20 11:49:00 +00:00
|
|
|
&video_out_svga,
|
2001-02-24 20:28:24 +00:00
|
|
|
#endif
|
2008-08-02 17:38:11 +00:00
|
|
|
#ifdef CONFIG_AA
|
2008-12-20 11:49:00 +00:00
|
|
|
&video_out_aa,
|
2001-08-14 12:30:56 +00:00
|
|
|
#endif
|
2008-08-02 17:38:11 +00:00
|
|
|
#ifdef CONFIG_CACA
|
2008-12-20 11:49:00 +00:00
|
|
|
&video_out_caca,
|
2004-04-06 00:04:48 +00:00
|
|
|
#endif
|
2008-08-03 15:21:40 +00:00
|
|
|
#ifdef CONFIG_DXR3
|
2008-12-20 11:49:00 +00:00
|
|
|
&video_out_dxr3,
|
2001-11-03 02:38:10 +00:00
|
|
|
#endif
|
2008-08-03 15:21:40 +00:00
|
|
|
#ifdef CONFIG_IVTV
|
2006-07-19 22:02:09 +00:00
|
|
|
&video_out_ivtv,
|
|
|
|
#endif
|
2008-08-03 15:21:40 +00:00
|
|
|
#ifdef CONFIG_V4L2_DECODER
|
2007-07-29 19:20:55 +00:00
|
|
|
&video_out_v4l2,
|
|
|
|
#endif
|
2008-08-02 17:38:11 +00:00
|
|
|
#ifdef CONFIG_BL
|
2008-12-20 11:49:00 +00:00
|
|
|
&video_out_bl,
|
2002-09-08 22:41:53 +00:00
|
|
|
#endif
|
2008-08-02 17:38:11 +00:00
|
|
|
#ifdef CONFIG_VESA
|
2008-12-20 11:49:00 +00:00
|
|
|
&video_out_vesa,
|
2001-10-17 18:24:50 +00:00
|
|
|
#endif
|
2010-09-15 15:58:48 +00:00
|
|
|
#ifdef CONFIG_DIRECTFB
|
2002-10-31 23:54:26 +00:00
|
|
|
&video_out_dfbmga,
|
2004-10-04 19:36:12 +00:00
|
|
|
#endif
|
|
|
|
&video_out_null,
|
2008-12-20 11:49:00 +00:00
|
|
|
// should not be auto-selected
|
2010-01-31 00:01:12 +00:00
|
|
|
#ifdef CONFIG_DIRECTFB
|
|
|
|
// vo directfb can call exit() if initialization fails
|
|
|
|
&video_out_directfb,
|
2006-01-18 18:11:02 +00:00
|
|
|
#endif
|
2008-12-20 11:49:00 +00:00
|
|
|
&video_out_mpegpes,
|
2008-08-02 17:38:11 +00:00
|
|
|
#ifdef CONFIG_YUV4MPEG
|
2008-12-20 11:49:00 +00:00
|
|
|
&video_out_yuv4mpeg,
|
2008-06-20 19:33:32 +00:00
|
|
|
#endif
|
2008-12-20 11:49:00 +00:00
|
|
|
&video_out_png,
|
2008-08-05 08:47:51 +00:00
|
|
|
#ifdef CONFIG_JPEG
|
2008-12-20 11:49:00 +00:00
|
|
|
&video_out_jpeg,
|
2004-10-04 19:36:12 +00:00
|
|
|
#endif
|
2008-08-05 08:47:51 +00:00
|
|
|
#ifdef CONFIG_GIF
|
2008-12-20 11:49:00 +00:00
|
|
|
&video_out_gif89a,
|
2003-08-24 18:26:37 +00:00
|
|
|
#endif
|
2008-08-02 17:38:11 +00:00
|
|
|
#ifdef CONFIG_TGA
|
2003-08-24 18:26:37 +00:00
|
|
|
&video_out_tga,
|
2002-01-12 23:30:20 +00:00
|
|
|
#endif
|
2008-08-05 08:47:51 +00:00
|
|
|
#ifdef CONFIG_PNM
|
2008-12-20 11:49:00 +00:00
|
|
|
&video_out_pnm,
|
2004-10-23 22:43:19 +00:00
|
|
|
#endif
|
2008-08-02 17:38:11 +00:00
|
|
|
#ifdef CONFIG_MD5SUM
|
2008-12-20 11:49:00 +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
|
|
|
|
2008-04-03 03:25:41 +00:00
|
|
|
|
|
|
|
static int vo_preinit(struct vo *vo, const char *arg)
|
|
|
|
{
|
|
|
|
return vo->driver->preinit(vo, arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
int vo_control(struct vo *vo, uint32_t request, void *data)
|
|
|
|
{
|
|
|
|
return vo->driver->control(vo, request, data);
|
|
|
|
}
|
|
|
|
|
2009-09-18 13:27:55 +00:00
|
|
|
// Return -1 if driver appears not to support a draw_image interface,
|
|
|
|
// 0 otherwise (whether the driver actually drew something or not).
|
|
|
|
int vo_draw_image(struct vo *vo, struct mp_image *mpi, double pts)
|
|
|
|
{
|
|
|
|
if (!vo->config_ok)
|
|
|
|
return 0;
|
|
|
|
if (vo->driver->buffer_frames) {
|
|
|
|
vo->driver->draw_image(vo, mpi, pts);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
vo->frame_loaded = true;
|
|
|
|
vo->next_pts = pts;
|
2011-12-04 16:10:17 +00:00
|
|
|
// Guaranteed to support at least DRAW_IMAGE later
|
|
|
|
if (vo->driver->is_new) {
|
|
|
|
vo->waiting_mpi = mpi;
|
|
|
|
return 0;
|
|
|
|
}
|
2009-09-18 13:27:55 +00:00
|
|
|
if (vo_control(vo, VOCTRL_DRAW_IMAGE, mpi) == VO_NOTIMPL)
|
|
|
|
return -1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-12-05 03:24:18 +00:00
|
|
|
int vo_redraw_frame(struct vo *vo)
|
|
|
|
{
|
|
|
|
if (!vo->config_ok)
|
|
|
|
return -1;
|
|
|
|
if (vo_control(vo, VOCTRL_REDRAW_FRAME, NULL) == true) {
|
|
|
|
vo->redrawing = true;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-09-18 13:27:55 +00:00
|
|
|
int vo_get_buffered_frame(struct vo *vo, bool eof)
|
|
|
|
{
|
|
|
|
if (!vo->config_ok)
|
|
|
|
return -1;
|
|
|
|
if (vo->frame_loaded)
|
|
|
|
return 0;
|
|
|
|
if (!vo->driver->buffer_frames)
|
|
|
|
return -1;
|
|
|
|
vo->driver->get_buffered_frame(vo, eof);
|
|
|
|
return vo->frame_loaded ? 0 : -1;
|
|
|
|
}
|
|
|
|
|
2011-03-03 10:54:36 +00:00
|
|
|
void vo_skip_frame(struct vo *vo)
|
|
|
|
{
|
2011-12-04 16:10:17 +00:00
|
|
|
vo_control(vo, VOCTRL_SKIPFRAME, NULL);
|
2011-03-03 10:54:36 +00:00
|
|
|
vo->frame_loaded = false;
|
|
|
|
}
|
|
|
|
|
2008-04-03 03:25:41 +00:00
|
|
|
int vo_draw_frame(struct vo *vo, uint8_t *src[])
|
|
|
|
{
|
2009-09-17 14:47:43 +00:00
|
|
|
assert(!vo->driver->is_new);
|
2008-04-18 03:28:47 +00:00
|
|
|
if (!vo->config_ok)
|
|
|
|
return 0;
|
2009-09-17 14:47:43 +00:00
|
|
|
return old_vo_draw_frame(vo, src);
|
2008-04-03 03:25:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int vo_draw_slice(struct vo *vo, uint8_t *src[], int stride[], int w, int h, int x, int y)
|
|
|
|
{
|
|
|
|
return vo->driver->draw_slice(vo, src, stride, w, h, x, y);
|
|
|
|
}
|
|
|
|
|
2011-12-04 16:10:17 +00:00
|
|
|
void vo_new_frame_imminent(struct vo *vo)
|
|
|
|
{
|
|
|
|
if (!vo->driver->is_new)
|
|
|
|
return;
|
|
|
|
if (vo->driver->buffer_frames)
|
|
|
|
vo_control(vo, VOCTRL_NEWFRAME, NULL);
|
|
|
|
else {
|
|
|
|
vo_control(vo, VOCTRL_DRAW_IMAGE, vo->waiting_mpi);
|
|
|
|
vo->waiting_mpi = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-06-23 22:53:58 +00:00
|
|
|
void vo_draw_osd(struct vo *vo, struct osd_state *osd)
|
2008-04-03 03:25:41 +00:00
|
|
|
{
|
2008-04-18 03:28:47 +00:00
|
|
|
if (!vo->config_ok)
|
|
|
|
return;
|
2008-06-23 22:53:58 +00:00
|
|
|
vo->driver->draw_osd(vo, osd);
|
2008-04-03 03:25:41 +00:00
|
|
|
}
|
|
|
|
|
2009-11-15 02:39:22 +00:00
|
|
|
void vo_flip_page(struct vo *vo, unsigned int pts_us, int duration)
|
2008-04-03 03:25:41 +00:00
|
|
|
{
|
2008-04-18 03:28:47 +00:00
|
|
|
if (!vo->config_ok)
|
|
|
|
return;
|
2011-12-05 03:24:18 +00:00
|
|
|
if (!vo->redrawing) {
|
|
|
|
vo->frame_loaded = false;
|
|
|
|
vo->next_pts = MP_NOPTS_VALUE;
|
|
|
|
}
|
2011-12-05 04:36:20 +00:00
|
|
|
vo->want_redraw = false;
|
2011-12-05 03:24:18 +00:00
|
|
|
vo->redrawing = false;
|
2009-11-15 02:39:22 +00:00
|
|
|
if (vo->driver->flip_page_timed)
|
|
|
|
vo->driver->flip_page_timed(vo, pts_us, duration);
|
|
|
|
else
|
|
|
|
vo->driver->flip_page(vo);
|
2008-04-03 03:25:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void vo_check_events(struct vo *vo)
|
|
|
|
{
|
2010-12-14 19:58:47 +00:00
|
|
|
if (!vo->config_ok) {
|
|
|
|
if (vo->registered_fd != -1)
|
|
|
|
mp_input_rm_key_fd(vo->input_ctx, vo->registered_fd);
|
|
|
|
vo->registered_fd = -1;
|
2008-04-18 03:28:47 +00:00
|
|
|
return;
|
2010-12-14 19:58:47 +00:00
|
|
|
}
|
2008-04-03 03:25:41 +00:00
|
|
|
vo->driver->check_events(vo);
|
|
|
|
}
|
|
|
|
|
2009-09-18 13:27:55 +00:00
|
|
|
void vo_seek_reset(struct vo *vo)
|
|
|
|
{
|
|
|
|
vo_control(vo, VOCTRL_RESET, NULL);
|
|
|
|
vo->frame_loaded = false;
|
|
|
|
}
|
|
|
|
|
2008-04-03 03:25:41 +00:00
|
|
|
void vo_destroy(struct vo *vo)
|
|
|
|
{
|
2010-12-14 19:58:47 +00:00
|
|
|
if (vo->registered_fd != -1)
|
|
|
|
mp_input_rm_key_fd(vo->input_ctx, vo->registered_fd);
|
2008-04-03 03:25:41 +00:00
|
|
|
vo->driver->uninit(vo);
|
2008-04-20 03:04:10 +00:00
|
|
|
talloc_free(vo);
|
2008-04-03 03:25:41 +00:00
|
|
|
}
|
|
|
|
|
2008-04-03 01:58:32 +00:00
|
|
|
void list_video_out(void)
|
|
|
|
{
|
|
|
|
int i = 0;
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "Available video output drivers:\n");
|
2008-04-03 01:58:32 +00:00
|
|
|
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_OUTPUTS\n");
|
|
|
|
while (video_out_drivers[i]) {
|
2002-11-11 15:22:10 +00:00
|
|
|
const vo_info_t *info = video_out_drivers[i++]->info;
|
2008-04-03 01:58:32 +00:00
|
|
|
mp_msg(MSGT_GLOBAL, MSGL_INFO,"\t%s\t%s\n", info->short_name, info->name);
|
|
|
|
}
|
|
|
|
mp_msg(MSGT_GLOBAL, MSGL_INFO,"\n");
|
2002-09-29 21:53:05 +00:00
|
|
|
}
|
|
|
|
|
2008-04-29 12:12:19 +00:00
|
|
|
struct vo *init_best_video_out(struct MPOpts *opts, struct vo_x11_state *x11,
|
2008-04-30 08:06:55 +00:00
|
|
|
struct mp_fifo *key_fifo,
|
|
|
|
struct input_ctx *input_ctx)
|
2008-04-03 01:58:32 +00:00
|
|
|
{
|
2008-04-19 04:04:55 +00:00
|
|
|
char **vo_list = opts->video_driver_list;
|
2002-09-29 21:53:05 +00:00
|
|
|
int i;
|
2008-04-20 03:04:10 +00:00
|
|
|
struct vo *vo = talloc_ptrtype(NULL, vo);
|
2008-04-30 08:06:55 +00:00
|
|
|
struct vo initial_values = {
|
|
|
|
.opts = opts,
|
|
|
|
.x11 = x11,
|
|
|
|
.key_fifo = key_fifo,
|
|
|
|
.input_ctx = input_ctx,
|
2010-12-14 19:58:47 +00:00
|
|
|
.event_fd = -1,
|
|
|
|
.registered_fd = -1,
|
2008-04-30 08:06:55 +00:00
|
|
|
};
|
2002-09-29 21:53:05 +00:00
|
|
|
// first try the preferred drivers, with their optional subdevice param:
|
2008-04-03 01:58:32 +00:00
|
|
|
if (vo_list && vo_list[0])
|
|
|
|
while (vo_list[0][0]) {
|
|
|
|
char *name = strdup(vo_list[0]);
|
|
|
|
vo_subdevice = strchr(name,':');
|
|
|
|
if (!strcmp(name, "pgm"))
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_CPLAYER, MSGL_ERR, "The pgm video output driver has been replaced by -vo pnm:pgmyuv.\n");
|
2008-04-03 01:58:32 +00:00
|
|
|
if (!strcmp(name, "md5"))
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_CPLAYER, MSGL_ERR, "The md5 video output driver has been replaced by -vo md5sum.\n");
|
2008-04-03 01:58:32 +00:00
|
|
|
if (vo_subdevice) {
|
|
|
|
vo_subdevice[0] = 0;
|
|
|
|
++vo_subdevice;
|
|
|
|
}
|
|
|
|
for (i = 0; video_out_drivers[i]; i++) {
|
2008-04-03 03:25:41 +00:00
|
|
|
const struct vo_driver *video_driver = video_out_drivers[i];
|
2008-04-03 01:58:32 +00:00
|
|
|
const vo_info_t *info = video_driver->info;
|
|
|
|
if (!strcmp(info->short_name, name)) {
|
|
|
|
// name matches, try it
|
2008-04-30 08:06:55 +00:00
|
|
|
*vo = initial_values;
|
2008-04-03 03:25:41 +00:00
|
|
|
vo->driver = video_driver;
|
|
|
|
if (!vo_preinit(vo, vo_subdevice)) {
|
2008-04-03 01:58:32 +00:00
|
|
|
free(name);
|
2008-04-03 03:25:41 +00:00
|
|
|
return vo; // success!
|
2008-04-03 01:58:32 +00:00
|
|
|
}
|
2009-05-08 23:37:35 +00:00
|
|
|
talloc_free_children(vo);
|
2003-05-31 17:33:33 +00:00
|
|
|
}
|
2002-09-29 21:53:05 +00:00
|
|
|
}
|
2008-04-03 01:58:32 +00:00
|
|
|
// continue...
|
|
|
|
free(name);
|
|
|
|
++vo_list;
|
|
|
|
if (!(vo_list[0]))
|
|
|
|
return NULL; // do NOT fallback to others
|
2002-09-29 21:53:05 +00:00
|
|
|
}
|
|
|
|
// now try the rest...
|
2008-04-03 01:58:32 +00:00
|
|
|
vo_subdevice = NULL;
|
|
|
|
for (i = 0; video_out_drivers[i]; i++) {
|
2008-04-03 03:25:41 +00:00
|
|
|
const struct vo_driver *video_driver = video_out_drivers[i];
|
2008-04-30 08:06:55 +00:00
|
|
|
*vo = initial_values;
|
2008-04-03 03:25:41 +00:00
|
|
|
vo->driver = video_driver;
|
|
|
|
if (!vo_preinit(vo, vo_subdevice))
|
|
|
|
return vo; // success!
|
2009-05-08 23:37:35 +00:00
|
|
|
talloc_free_children(vo);
|
2002-09-29 21:53:05 +00:00
|
|
|
}
|
2008-04-03 03:25:41 +00:00
|
|
|
free(vo);
|
2002-09-29 21:53:05 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-12-14 19:58:47 +00:00
|
|
|
static int event_fd_callback(void *ctx, int fd)
|
|
|
|
{
|
|
|
|
struct vo *vo = ctx;
|
|
|
|
vo_check_events(vo);
|
2011-07-17 01:47:50 +00:00
|
|
|
return MP_INPUT_NOTHING;
|
2010-12-14 19:58:47 +00:00
|
|
|
}
|
|
|
|
|
2008-04-03 03:25:41 +00:00
|
|
|
int vo_config(struct vo *vo, uint32_t width, uint32_t height,
|
2007-02-17 20:58:55 +00:00
|
|
|
uint32_t d_width, uint32_t d_height, uint32_t flags,
|
2011-12-06 19:23:54 +00:00
|
|
|
uint32_t format)
|
2008-04-03 01:58:32 +00:00
|
|
|
{
|
2008-04-20 23:18:28 +00:00
|
|
|
struct MPOpts *opts = vo->opts;
|
2008-05-01 08:02:26 +00:00
|
|
|
panscan_init(vo);
|
|
|
|
aspect_save_orig(vo, width, height);
|
|
|
|
aspect_save_prescale(vo, d_width, d_height);
|
2007-02-17 20:58:55 +00:00
|
|
|
|
2008-04-03 03:25:41 +00:00
|
|
|
if (vo_control(vo, VOCTRL_UPDATE_SCREENINFO, NULL) == VO_TRUE) {
|
2008-05-01 08:02:26 +00:00
|
|
|
aspect(vo, &d_width, &d_height, A_NOZOOM);
|
2008-04-20 23:18:28 +00:00
|
|
|
vo->dx = (int)(opts->vo_screenwidth - d_width) / 2;
|
|
|
|
vo->dy = (int)(opts->vo_screenheight - d_height) / 2;
|
2008-04-20 20:29:28 +00:00
|
|
|
geometry(&vo->dx, &vo->dy, &d_width, &d_height,
|
2008-04-20 23:18:28 +00:00
|
|
|
opts->vo_screenwidth, opts->vo_screenheight);
|
2010-06-05 20:23:18 +00:00
|
|
|
geometry_xy_changed |= xinerama_screen >= 0;
|
2008-04-20 20:29:28 +00:00
|
|
|
vo->dx += xinerama_x;
|
|
|
|
vo->dy += xinerama_y;
|
|
|
|
vo->dwidth = d_width;
|
|
|
|
vo->dheight = d_height;
|
2008-04-03 01:58:32 +00:00
|
|
|
}
|
2007-02-17 20:58:55 +00:00
|
|
|
|
2008-04-18 03:28:47 +00:00
|
|
|
int ret = vo->driver->config(vo, width, height, d_width, d_height, flags,
|
2011-12-06 19:23:54 +00:00
|
|
|
format);
|
2008-04-18 03:28:47 +00:00
|
|
|
vo->config_ok = (ret == 0);
|
|
|
|
vo->config_count += vo->config_ok;
|
2010-12-14 19:58:47 +00:00
|
|
|
if (vo->registered_fd == -1 && vo->event_fd != -1 && vo->config_ok) {
|
|
|
|
mp_input_add_key_fd(vo->input_ctx, vo->event_fd, 1, event_fd_callback,
|
|
|
|
NULL, vo);
|
|
|
|
vo->registered_fd = vo->event_fd;
|
|
|
|
}
|
2011-12-04 16:10:17 +00:00
|
|
|
vo->frame_loaded = false;
|
|
|
|
vo->waiting_mpi = NULL;
|
2011-12-05 03:24:18 +00:00
|
|
|
vo->redrawing = false;
|
2008-04-18 03:28:47 +00:00
|
|
|
return ret;
|
2007-02-17 20:58:55 +00:00
|
|
|
}
|
2002-09-29 21:53:05 +00:00
|
|
|
|
2008-12-20 11:52:11 +00: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 10:22:44 +00:00
|
|
|
int lookup_keymap_table(const struct mp_keymap *map, int key) {
|
2008-12-20 11:52:11 +00:00
|
|
|
while (map->from && map->from != key) map++;
|
|
|
|
return map->to;
|
|
|
|
}
|
|
|
|
|
2009-02-12 17:40:53 +00: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 11:59:49 +00: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 17:40:53 +00:00
|
|
|
*/
|
2009-02-17 23:07:37 +00:00
|
|
|
void calc_src_dst_rects(struct vo *vo, 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 17:40:53 +00: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;
|
2009-02-13 01:52:51 +00:00
|
|
|
dst->left = 0; dst->right = vo->dwidth;
|
|
|
|
dst->top = 0; dst->bottom = vo->dheight;
|
2009-02-12 17:40:53 +00:00
|
|
|
src->left = 0; src->right = src_width;
|
|
|
|
src->top = 0; src->bottom = src_height;
|
2009-02-17 11:59:49 +00:00
|
|
|
if (borders) {
|
|
|
|
borders->left = 0; borders->top = 0;
|
|
|
|
}
|
2009-08-27 19:13:19 +00:00
|
|
|
if (aspect_scaling()) {
|
2009-09-04 16:49:35 +00:00
|
|
|
aspect(vo, &scaled_width, &scaled_height, A_WINZOOM);
|
|
|
|
panscan_calc_windowed(vo);
|
2009-02-13 01:52:51 +00:00
|
|
|
scaled_width += vo->panscan_x;
|
|
|
|
scaled_height += vo->panscan_y;
|
2009-02-17 11:59:49 +00:00
|
|
|
if (borders) {
|
2009-02-17 23:07:37 +00:00
|
|
|
borders->left = (vo->dwidth - scaled_width ) / 2;
|
|
|
|
borders->top = (vo->dheight - scaled_height) / 2;
|
2009-02-17 11:59:49 +00:00
|
|
|
}
|
2009-02-13 01:52:51 +00:00
|
|
|
src_dst_split_scaling(src_width, vo->dwidth, scaled_width,
|
2009-02-12 17:40:53 +00:00
|
|
|
&src->left, &src->right, &dst->left, &dst->right);
|
2009-02-13 01:52:51 +00:00
|
|
|
src_dst_split_scaling(src_height, vo->dheight, scaled_height,
|
2009-02-12 17:40:53 +00:00
|
|
|
&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;
|
|
|
|
}
|
|
|
|
|
2011-12-06 19:23:54 +00:00
|
|
|
// Return the window title the VO should set. Always returns a null terminated
|
|
|
|
// string. The string is valid until frontend code is invoked again. Copy it if
|
|
|
|
// you need to keep the string for an extended period of time.
|
|
|
|
const char *vo_get_window_title(struct vo *vo)
|
|
|
|
{
|
|
|
|
if (vo->opts->vo_wintitle) {
|
|
|
|
return vo->opts->vo_wintitle;
|
|
|
|
} else {
|
2011-12-05 22:17:34 +00:00
|
|
|
return "mplayer2";
|
2011-12-06 19:23:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-25 16:13:57 +00: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
|
|
|
|
*/
|
2010-04-26 16:22:56 +00:00
|
|
|
void vo_mouse_movement(struct vo *vo, int posx, int posy)
|
|
|
|
{
|
2010-04-25 16:13:57 +00:00
|
|
|
char cmd_str[40];
|
|
|
|
if (!enable_mouse_movements)
|
|
|
|
return;
|
|
|
|
snprintf(cmd_str, sizeof(cmd_str), "set_mouse_pos %i %i", posx, posy);
|
2010-04-26 16:22:56 +00:00
|
|
|
mp_input_queue_cmd(vo->input_ctx, mp_input_parse_cmd(cmd_str));
|
2010-04-25 16:13:57 +00:00
|
|
|
}
|
|
|
|
|
2008-08-02 17:38:11 +00:00
|
|
|
#if defined(CONFIG_FBDEV) || defined(CONFIG_VESA)
|
2008-04-03 01:58:32 +00:00
|
|
|
/* Borrowed from vo_fbdev.c
|
2002-08-22 23:03:51 +00: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 15:01:37 +00:00
|
|
|
if (!(r = realloc(r, sizeof(*r) * (i + 2)))) {
|
2006-04-24 04:23:53 +00:00
|
|
|
mp_msg(MSGT_GLOBAL, MSGL_WARN,"can't realloc 'r'\n");
|
2002-08-22 23:03:51 +00: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:
|
2010-11-14 09:12:34 +00:00
|
|
|
free(r);
|
2002-08-22 23:03:51 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Borrowed from vo_fbdev.c END */
|
|
|
|
#endif
|