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"
|
2007-02-17 20:58:55 +00:00
|
|
|
#include "aspect.h"
|
|
|
|
#include "geometry.h"
|
2001-02-24 20:28:24 +00:00
|
|
|
|
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
|
|
|
|
2006-04-16 13:38:28 +00:00
|
|
|
int xinerama_screen = -1;
|
|
|
|
int xinerama_x;
|
|
|
|
int xinerama_y;
|
|
|
|
|
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;
|
2005-11-10 22:25:54 +00:00
|
|
|
int vo_border=1;
|
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
|
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
|
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-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;
|
2006-05-17 20:56:49 +00:00
|
|
|
extern vo_functions_t video_out_s3fb;
|
2001-02-24 20:28:24 +00:00
|
|
|
extern vo_functions_t video_out_null;
|
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-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
|
|
|
extern vo_functions_t video_out_directx;
|
2002-05-13 13:15:40 +00:00
|
|
|
extern vo_functions_t video_out_dxr2;
|
2001-11-03 02:38:10 +00:00
|
|
|
extern vo_functions_t video_out_dxr3;
|
2006-07-19 22:02:09 +00:00
|
|
|
extern vo_functions_t video_out_ivtv;
|
2007-07-29 19:20:55 +00:00
|
|
|
extern vo_functions_t video_out_v4l2;
|
2002-04-16 11:21:59 +00:00
|
|
|
extern vo_functions_t video_out_jpeg;
|
2002-05-12 01:07:25 +00:00
|
|
|
extern vo_functions_t video_out_gif89a;
|
2001-10-17 18:24:50 +00:00
|
|
|
extern vo_functions_t video_out_vesa;
|
2001-12-03 01:09:36 +00:00
|
|
|
extern vo_functions_t video_out_directfb;
|
2002-10-31 23:54:26 +00:00
|
|
|
extern vo_functions_t video_out_dfbmga;
|
2002-01-12 23:30:20 +00:00
|
|
|
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;
|
2003-03-07 18:45:02 +00:00
|
|
|
extern vo_functions_t video_out_tdfx_vid;
|
2007-08-03 17:14:35 +00:00
|
|
|
extern vo_functions_t video_out_xvr100;
|
2003-08-24 18:26:37 +00:00
|
|
|
extern vo_functions_t video_out_tga;
|
2005-04-29 11:41:07 +00:00
|
|
|
extern vo_functions_t video_out_macosx;
|
2004-04-05 21:20:19 +00:00
|
|
|
extern vo_functions_t video_out_quartz;
|
2004-09-20 01:31:26 +00:00
|
|
|
extern vo_functions_t video_out_pnm;
|
2004-09-20 01:35:43 +00:00
|
|
|
extern vo_functions_t video_out_md5sum;
|
2002-01-12 23:30:20 +00:00
|
|
|
|
2007-12-02 14:24:23 +00:00
|
|
|
const vo_functions_t* const video_out_drivers[] =
|
2001-02-24 20:28:24 +00:00
|
|
|
{
|
2007-08-03 17:14:35 +00:00
|
|
|
#ifdef HAVE_XVR100
|
|
|
|
&video_out_xvr100,
|
|
|
|
#endif
|
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
|
2008-03-15 09:19:38 +00:00
|
|
|
#ifdef HAVE_COREVIDEO
|
2005-04-29 11:41:07 +00:00
|
|
|
&video_out_macosx,
|
2005-05-05 00:17:27 +00:00
|
|
|
#endif
|
2008-03-15 09:49:14 +00:00
|
|
|
#ifdef HAVE_QUARTZ
|
2004-06-17 01:07:53 +00:00
|
|
|
&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
|
2001-09-27 12:23:54 +00:00
|
|
|
#ifdef HAVE_TDFXFB
|
|
|
|
&video_out_tdfxfb,
|
|
|
|
#endif
|
2006-05-17 20:56:49 +00:00
|
|
|
#ifdef HAVE_S3FB
|
|
|
|
&video_out_s3fb,
|
|
|
|
#endif
|
2005-12-01 11:58:44 +00:00
|
|
|
#ifdef HAVE_3DFX
|
|
|
|
&video_out_3dfx,
|
|
|
|
#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
|
|
|
&video_out_gl,
|
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,
|
|
|
|
#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
|
2006-07-19 22:02:09 +00:00
|
|
|
#ifdef HAVE_IVTV
|
|
|
|
&video_out_ivtv,
|
|
|
|
#endif
|
2007-07-29 19:20:55 +00:00
|
|
|
#ifdef HAVE_V4L2_DECODER
|
|
|
|
&video_out_v4l2,
|
|
|
|
#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,
|
2008-03-07 17:20:04 +00:00
|
|
|
#endif
|
2006-10-14 18:00:26 +00:00
|
|
|
#ifdef HAVE_DFBMGA
|
2002-10-31 23:54:26 +00:00
|
|
|
&video_out_dfbmga,
|
|
|
|
#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
|
2006-01-18 18:11:02 +00:00
|
|
|
#ifdef HAVE_XVMC
|
|
|
|
&video_out_xvmc,
|
|
|
|
#endif
|
2004-10-04 19:36:12 +00:00
|
|
|
&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
|
|
|
|
2006-02-09 14:08:03 +00:00
|
|
|
void list_video_out(void){
|
2002-09-29 21:53:05 +00:00
|
|
|
int i=0;
|
|
|
|
mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_AvailableVideoOutputDrivers);
|
2006-04-24 07:20:34 +00:00
|
|
|
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_OUTPUTS\n");
|
2002-09-29 21:53:05 +00:00
|
|
|
while (video_out_drivers[i]) {
|
2002-11-11 15:22:10 +00:00
|
|
|
const vo_info_t *info = video_out_drivers[i++]->info;
|
2006-04-24 04:23:53 +00:00
|
|
|
mp_msg(MSGT_GLOBAL, MSGL_INFO,"\t%s\t%s\n", info->short_name, info->name);
|
2002-09-29 21:53:05 +00:00
|
|
|
}
|
2006-04-24 04:23:53 +00:00
|
|
|
mp_msg(MSGT_GLOBAL, MSGL_INFO,"\n");
|
2002-09-29 21:53:05 +00:00
|
|
|
}
|
|
|
|
|
2007-12-02 14:24:23 +00:00
|
|
|
const vo_functions_t* init_best_video_out(char** vo_list){
|
2002-09-29 21:53:05 +00: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 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++){
|
2007-12-02 14:24:23 +00:00
|
|
|
const 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++){
|
2007-12-02 14:24:23 +00:00
|
|
|
const vo_functions_t* video_driver=video_out_drivers[i];
|
2002-09-29 21:53:05 +00:00
|
|
|
if(!video_driver->preinit(vo_subdevice))
|
|
|
|
return video_driver; // success!
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2007-12-02 14:24:23 +00:00
|
|
|
int config_video_out(const vo_functions_t *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,
|
|
|
|
char *title, uint32_t format) {
|
|
|
|
panscan_init();
|
|
|
|
aspect_save_orig(width,height);
|
|
|
|
aspect_save_prescale(d_width,d_height);
|
|
|
|
|
2007-02-25 14:35:53 +00:00
|
|
|
if (vo->control(VOCTRL_UPDATE_SCREENINFO, NULL) == VO_TRUE) {
|
2007-02-17 20:58:55 +00: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 21:24:26 +00:00
|
|
|
}
|
2007-02-17 20:58:55 +00:00
|
|
|
|
2007-02-18 20:19:47 +00:00
|
|
|
return vo->config(width, height, d_width, d_height, flags, title, format);
|
2007-02-17 20:58:55 +00:00
|
|
|
}
|
2002-09-29 21:53:05 +00:00
|
|
|
|
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)))) {
|
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:
|
|
|
|
if (r)
|
|
|
|
free(r);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Borrowed from vo_fbdev.c END */
|
|
|
|
#endif
|
|
|
|
|