2002-09-09 22:03:21 +02:00
|
|
|
|
|
|
|
/* this file contains libvo's common functions, variables used by
|
|
|
|
many/all drivers. */
|
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"
|
|
|
|
|
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;
|
2004-12-21 21:33:51 +01:00
|
|
|
int 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
|
2003-10-17 11:08:37 +02:00
|
|
|
// (0xff000000 means that colorkey has been disabled)
|
2003-10-03 20:13:45 +02:00
|
|
|
|
2001-02-24 21:28:24 +01: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 16:04:05 +01:00
|
|
|
extern vo_functions_t video_out_xover;
|
2003-06-21 03:47:26 +02:00
|
|
|
extern vo_functions_t video_out_xvmc;
|
2001-02-24 21:28:24 +01:00
|
|
|
extern vo_functions_t video_out_xv;
|
|
|
|
extern vo_functions_t video_out_gl;
|
2001-10-07 23:35:59 +02:00
|
|
|
extern vo_functions_t video_out_gl2;
|
2001-02-27 02:08:09 +01:00
|
|
|
extern vo_functions_t video_out_dga;
|
2001-02-24 21:28:24 +01:00
|
|
|
extern vo_functions_t video_out_sdl;
|
|
|
|
extern vo_functions_t video_out_3dfx;
|
2001-09-27 14:23:54 +02:00
|
|
|
extern vo_functions_t video_out_tdfxfb;
|
2006-05-17 22:56:49 +02:00
|
|
|
extern vo_functions_t video_out_s3fb;
|
2001-02-24 21:28:24 +01:00
|
|
|
extern vo_functions_t video_out_null;
|
2002-01-17 02:32:29 +01:00
|
|
|
extern vo_functions_t video_out_zr;
|
2003-11-04 21:05:47 +01:00
|
|
|
extern vo_functions_t video_out_zr2;
|
2002-09-09 00:41:53 +02:00
|
|
|
extern vo_functions_t video_out_bl;
|
2001-03-28 14:08:44 +02:00
|
|
|
extern vo_functions_t video_out_fbdev;
|
2003-09-01 01:00:39 +02:00
|
|
|
extern vo_functions_t video_out_fbdev2;
|
2001-04-05 21:01:27 +02:00
|
|
|
extern vo_functions_t video_out_svga;
|
2001-04-19 22:14:30 +02:00
|
|
|
extern vo_functions_t video_out_png;
|
2001-06-15 14:37:05 +02:00
|
|
|
extern vo_functions_t video_out_ggi;
|
2001-08-14 14:30:56 +02:00
|
|
|
extern vo_functions_t video_out_aa;
|
2004-04-06 02:04:48 +02:00
|
|
|
extern vo_functions_t video_out_caca;
|
2001-09-08 22:48:02 +02:00
|
|
|
extern vo_functions_t video_out_mpegpes;
|
2002-02-09 02:30:35 +01:00
|
|
|
extern vo_functions_t video_out_yuv4mpeg;
|
2002-09-28 21:03:50 +02:00
|
|
|
extern vo_functions_t video_out_directx;
|
2002-05-13 15:15:40 +02:00
|
|
|
extern vo_functions_t video_out_dxr2;
|
2001-11-03 03:38:10 +01:00
|
|
|
extern vo_functions_t video_out_dxr3;
|
2006-07-20 00:02:09 +02:00
|
|
|
extern vo_functions_t video_out_ivtv;
|
2007-07-29 21:20:55 +02:00
|
|
|
extern vo_functions_t video_out_v4l2;
|
2002-04-16 13:21:59 +02:00
|
|
|
extern vo_functions_t video_out_jpeg;
|
2002-05-12 03:07:25 +02:00
|
|
|
extern vo_functions_t video_out_gif89a;
|
2001-10-17 20:24:50 +02:00
|
|
|
extern vo_functions_t video_out_vesa;
|
2001-12-03 02:09:36 +01:00
|
|
|
extern vo_functions_t video_out_directfb;
|
2002-11-01 00:54:26 +01:00
|
|
|
extern 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;
|
2003-03-07 19:45:02 +01:00
|
|
|
extern vo_functions_t video_out_tdfx_vid;
|
2007-08-03 19:14:35 +02:00
|
|
|
extern vo_functions_t video_out_xvr100;
|
2003-08-24 20:26:37 +02:00
|
|
|
extern vo_functions_t video_out_tga;
|
2005-04-29 13:41:07 +02:00
|
|
|
extern vo_functions_t video_out_macosx;
|
2004-04-05 23:20:19 +02:00
|
|
|
extern vo_functions_t video_out_quartz;
|
2004-09-20 03:31:26 +02:00
|
|
|
extern vo_functions_t video_out_pnm;
|
2004-09-20 03:35:43 +02:00
|
|
|
extern 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
|
|
|
{
|
2007-08-03 19:14:35 +02:00
|
|
|
#ifdef HAVE_XVR100
|
|
|
|
&video_out_xvr100,
|
|
|
|
#endif
|
2003-03-07 19:45:02 +01:00
|
|
|
#ifdef HAVE_TDFX_VID
|
|
|
|
&video_out_tdfx_vid,
|
|
|
|
#endif
|
2003-01-03 06:10:44 +01:00
|
|
|
#ifdef HAVE_DIRECTX
|
|
|
|
&video_out_directx,
|
|
|
|
#endif
|
2005-05-05 02:17:27 +02:00
|
|
|
#ifdef MACOSX_COREVIDEO
|
2005-04-29 13:41:07 +02:00
|
|
|
&video_out_macosx,
|
2005-05-05 02:17:27 +02:00
|
|
|
#endif
|
2008-03-07 18:20:04 +01:00
|
|
|
#ifdef MACOSX
|
2004-06-17 03:07:53 +02:00
|
|
|
&video_out_quartz,
|
|
|
|
#endif
|
2001-06-21 17:19:38 +02:00
|
|
|
#ifdef HAVE_XMGA
|
2001-02-24 21:28:24 +01:00
|
|
|
&video_out_xmga,
|
|
|
|
#endif
|
2001-06-21 17:19:38 +02:00
|
|
|
#ifdef HAVE_MGA
|
2001-02-24 21:28:24 +01:00
|
|
|
&video_out_mga,
|
|
|
|
#endif
|
2001-09-27 14:23:54 +02:00
|
|
|
#ifdef HAVE_TDFXFB
|
|
|
|
&video_out_tdfxfb,
|
|
|
|
#endif
|
2006-05-17 22:56:49 +02:00
|
|
|
#ifdef HAVE_S3FB
|
|
|
|
&video_out_s3fb,
|
|
|
|
#endif
|
2005-12-01 12:58:44 +01:00
|
|
|
#ifdef HAVE_3DFX
|
|
|
|
&video_out_3dfx,
|
|
|
|
#endif
|
2001-02-24 21:28:24 +01:00
|
|
|
#ifdef HAVE_XV
|
|
|
|
&video_out_xv,
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_X11
|
|
|
|
&video_out_x11,
|
2003-03-12 16:04:05 +01:00
|
|
|
&video_out_xover,
|
2001-02-24 21:28:24 +01:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_GL
|
2003-09-19 16:33:51 +02:00
|
|
|
&video_out_gl,
|
2001-10-07 23:35:59 +02:00
|
|
|
&video_out_gl2,
|
2001-02-24 21:28:24 +01:00
|
|
|
#endif
|
2001-02-27 02:08:09 +01:00
|
|
|
#ifdef HAVE_DGA
|
|
|
|
&video_out_dga,
|
|
|
|
#endif
|
2001-02-24 21:28:24 +01:00
|
|
|
#ifdef HAVE_SDL
|
|
|
|
&video_out_sdl,
|
2001-03-28 22:14:16 +02:00
|
|
|
#endif
|
2001-06-27 01:34:03 +02:00
|
|
|
#ifdef HAVE_GGI
|
|
|
|
&video_out_ggi,
|
|
|
|
#endif
|
2001-03-28 22:14:16 +02:00
|
|
|
#ifdef HAVE_FBDEV
|
|
|
|
&video_out_fbdev,
|
2003-09-01 01:00:39 +02:00
|
|
|
&video_out_fbdev2,
|
2001-04-05 21:01:27 +02:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SVGALIB
|
|
|
|
&video_out_svga,
|
2001-02-24 21:28:24 +01:00
|
|
|
#endif
|
2001-08-14 14:30:56 +02:00
|
|
|
#ifdef HAVE_AA
|
|
|
|
&video_out_aa,
|
|
|
|
#endif
|
2004-04-06 02:04:48 +02:00
|
|
|
#ifdef HAVE_CACA
|
|
|
|
&video_out_caca,
|
|
|
|
#endif
|
2002-05-13 15:15:40 +02:00
|
|
|
#ifdef HAVE_DXR2
|
|
|
|
&video_out_dxr2,
|
|
|
|
#endif
|
2001-11-03 03:38:10 +01:00
|
|
|
#ifdef HAVE_DXR3
|
|
|
|
&video_out_dxr3,
|
|
|
|
#endif
|
2006-07-20 00:02:09 +02:00
|
|
|
#ifdef HAVE_IVTV
|
|
|
|
&video_out_ivtv,
|
|
|
|
#endif
|
2007-07-29 21:20:55 +02:00
|
|
|
#ifdef HAVE_V4L2_DECODER
|
|
|
|
&video_out_v4l2,
|
|
|
|
#endif
|
2002-01-17 02:32:29 +01:00
|
|
|
#ifdef HAVE_ZR
|
|
|
|
&video_out_zr,
|
2003-11-04 21:05:47 +01:00
|
|
|
&video_out_zr2,
|
2002-01-17 02:32:29 +01:00
|
|
|
#endif
|
2002-09-09 00:41:53 +02:00
|
|
|
#ifdef HAVE_BL
|
|
|
|
&video_out_bl,
|
|
|
|
#endif
|
2002-02-07 03:29:55 +01:00
|
|
|
#ifdef HAVE_VESA
|
2001-10-17 20:24:50 +02:00
|
|
|
&video_out_vesa,
|
|
|
|
#endif
|
2001-12-03 02:09:36 +01:00
|
|
|
#ifdef HAVE_DIRECTFB
|
|
|
|
&video_out_directfb,
|
2008-03-07 18:20:04 +01:00
|
|
|
#endif
|
2006-10-14 20:00:26 +02:00
|
|
|
#ifdef HAVE_DFBMGA
|
2002-11-01 00:54:26 +01:00
|
|
|
&video_out_dfbmga,
|
|
|
|
#endif
|
2003-10-02 16:25:52 +02:00
|
|
|
#ifdef CONFIG_VIDIX
|
|
|
|
#ifdef HAVE_X11
|
2002-01-13 00:30:20 +01:00
|
|
|
&video_out_xvidix,
|
2003-10-02 16:25:52 +02:00
|
|
|
#endif
|
|
|
|
#ifdef WIN32
|
|
|
|
&video_out_winvidix,
|
|
|
|
#endif
|
2003-10-05 17:34:40 +02:00
|
|
|
&video_out_cvidix,
|
2004-10-04 21:36:12 +02:00
|
|
|
#endif
|
|
|
|
&video_out_null,
|
|
|
|
// should not be auto-selected
|
2006-01-18 19:11:02 +01:00
|
|
|
#ifdef HAVE_XVMC
|
|
|
|
&video_out_xvmc,
|
|
|
|
#endif
|
2004-10-04 21:36:12 +02: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 20:26:37 +02:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_TGA
|
|
|
|
&video_out_tga,
|
2002-01-13 00:30:20 +01:00
|
|
|
#endif
|
2004-10-24 00:43:19 +02:00
|
|
|
#ifdef HAVE_PNM
|
2004-09-20 03:31:26 +02:00
|
|
|
&video_out_pnm,
|
2004-10-24 00:43:19 +02:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_MD5SUM
|
2004-09-20 03:35:43 +02: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;
|
2006-04-24 06:23:53 +02: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
|
|
|
|
2002-08-23 01:03:51 +02: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 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
|
|
|
|
|