From b0e5f570bb6b17f6160a2382356e4ec9a127d55d Mon Sep 17 00:00:00 2001 From: ivo Date: Fri, 11 Mar 2005 02:09:24 +0000 Subject: [PATCH] Convert vo_aa suboption parser to using the subopt-helper. This obsoletes all -aa* commandline options. Use -vo aa:* instead. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@14936 b3059339-0415-0410-9bf9-f77b7e298cf2 --- DOCS/man/en/mplayer.1 | 9 +-- cfg-mplayer.h | 7 +- help/help_mp-en.h | 10 +++ libvo/vo_aa.c | 183 +++++++++++++++++++++--------------------- 4 files changed, 106 insertions(+), 103 deletions(-) diff --git a/DOCS/man/en/mplayer.1 b/DOCS/man/en/mplayer.1 index 25b72b124a..2a7cbfff26 100644 --- a/DOCS/man/en/mplayer.1 +++ b/DOCS/man/en/mplayer.1 @@ -1912,11 +1912,6 @@ plugin audio output driver .SH "VIDEO OUTPUT OPTIONS (MPLAYER ONLY)" . .TP -.B \-aa* (\-vo aa only) -You can get a list and an explanation of available options executing -.I mplayer \-aahelp -. -.TP .B \-adapter Set the graphics card that will receive the image. Needs the \-vm option to work. @@ -2637,8 +2632,10 @@ Produces no video output. Useful for benchmarking. . .TP -.B aa (also see \-aa*) +.B aa\ \ \ \ \ ASCII art video output driver that works on a text console. +You can get a list and an explanation of available suboptions executing +.I mplayer \-vo aa:help . .TP .B caca\ \ \ diff --git a/cfg-mplayer.h b/cfg-mplayer.h index fb5c518a86..ee1c85f134 100644 --- a/cfg-mplayer.h +++ b/cfg-mplayer.h @@ -73,11 +73,6 @@ extern int WinID; extern int menu_startup; #endif -#ifdef HAVE_AA -extern int vo_aa_parseoption(m_option_t* conf, char *opt, char * param); -extern void vo_aa_revertoption(m_option_t* opt,char* param); -#endif - #ifdef HAVE_ZR extern int vo_zr_parseoption(m_option_t* conf, char *opt, char * param); extern void vo_zr_revertoption(m_option_t* opt,char* pram); @@ -284,7 +279,7 @@ m_option_t mplayer_opts[]={ #ifdef HAVE_AA // -vo aa - {"aa*", vo_aa_parseoption, CONF_TYPE_FUNC_FULL, 0, 0, 0 , &vo_aa_revertoption}, + {"aa*", "-aa* is deprecated. Use -vo aa:suboption instead.\n", CONF_TYPE_PRINT, 0, 0, 0, NULL}, #endif #ifdef HAVE_ZR diff --git a/help/help_mp-en.h b/help/help_mp-en.h index 061d1a4f3c..245f03e1ae 100644 --- a/help/help_mp-en.h +++ b/help/help_mp-en.h @@ -897,6 +897,16 @@ static char help_text[]= #define MSGTR_VO_NoValueSpecified "No value specified." #define MSGTR_VO_UnknownSuboptions "Unknown suboption(s)" +// vo_aa.c + +#define MSGTR_VO_AA_HelpHeader "\n\nHere are the aalib vo_aa suboptions:\n" +#define MSGTR_VO_AA_AdditionalOptions "Additional options vo_aa provides:\n" \ +" help print this help message\n" \ +" osdcolor set osd color\n subcolor set subtitle color\n" \ +" the color parameters are:\n 0 : normal\n" \ +" 1 : dim\n 2 : bold\n 3 : boldfont\n" \ +" 4 : reverse\n 5 : special\n\n\n" + // vo_jpeg.c #define MSGTR_VO_JPEG_ProgressiveJPEG "Progressive JPEG enabled." #define MSGTR_VO_JPEG_NoProgressiveJPEG "Progressive JPEG disabled." diff --git a/libvo/vo_aa.c b/libvo/vo_aa.c index dea6d86bb2..1332bbe63e 100644 --- a/libvo/vo_aa.c +++ b/libvo/vo_aa.c @@ -34,7 +34,8 @@ #include "osdep/keycodes.h" #include -#include "m_option.h" +#include "subopt-helper.h" +#include "help_mp.h" #include "mp_msg.h" @@ -288,11 +289,11 @@ config(uint32_t width, uint32_t height, uint32_t d_width, mp_msg(MSGT_VO,MSGL_INFO, "\n" - "Important Options\n" - "\t-aaextended use use all 256 characters\n" - "\t-aaeight use eight bit ascii\n" - "\t-aadriver set recommended aalib driver (X11,curses,linux)\n" - "\t-aahelp to see all options provided by aalib\n" + "Important suboptions\n" + "\textended use use all 256 characters\n" + "\teight use eight bit ascii\n" + "\tdriver set recommended aalib driver (X11,curses,linux)\n" + "\thelp to see all options provided by aalib\n" "\n" "AA-MPlayer Keys\n" "\t1 : contrast -\n" @@ -588,94 +589,94 @@ getcolor(char * s){ else return -1; } -int -vo_aa_parseoption(m_option_t * conf, char *opt, char *param){ - /* got an option starting with aa */ - char *pseudoargv[4]; - int pseudoargc; - char * x, *help; - int i; - /* do WE need it ? */ - if (!strcasecmp(opt, "aaosdcolor")){ - if (param==NULL) return M_OPT_MISSING_PARAM; - if ((i=getcolor(param))==-1) return M_OPT_OUT_OF_RANGE; - aaopt_osdcolor=i; - return 1; - }else if (!strcasecmp(opt, "aasubcolor")){ - if ((i=getcolor(param))==-1) return M_OPT_OUT_OF_RANGE; - aaopt_subcolor=i; - return 1; - }else if (!strcasecmp(opt, "aahelp")){ - printf("Here are the aalib options:\n"); - help=strdup(aa_help); /* aa_help is const :( */ - x=strtok(help,"-"); - printf(x); - while ((x=strtok(NULL, "-"))){ - if (*(x-2)==' ') printf("-aa"); - else printf("-"); - printf("%s", x); - } - printf( - "\n" - "\n" - "Additional options vo_aa provides:\n" - " -aaosdcolor set osd color\n" - " -aasubcolor set subtitle color\n" - " the color parameters are:\n" - " 0 : normal\n" - " 1 : dim\n" - " 2 : bold\n" - " 3 : boldfont\n" - " 4 : reverse\n" - " 5 : special\n" - "\n\n" - " dT8 8Tb\n" - " dT 8 8 Tb\n" - " dT 8 8 Tb\n" - " \n" - " dT 8 8 Tb\n" - " dT 8 8 Tb\n" - "\n" +static int parse_suboptions(const char *arg) { + char *pseudoargv[4], *osdcolor = NULL, *subcolor = NULL, **strings, + *helpmsg = NULL; + int pseudoargc, displayhelp = 0, *booleans; + opt_t extra_opts[] = { + {"osdcolor", OPT_ARG_MSTRZ, &osdcolor, NULL, 0}, + {"subcolor", OPT_ARG_MSTRZ, &subcolor, NULL, 0}, + {"help", OPT_ARG_BOOL, &displayhelp, NULL, 0} }; + opt_t *subopts = NULL, *p; + char *strings_list[] = {"-driver", "-kbddriver", "-mousedriver", "-font", + "-width", "-height", "-minwidth", "-minheight", "-maxwidth", + "-maxheight", "-recwidth", "-recheight", "-bright", "-contrast", + "-gamma", "-dimmul", "-boldmul", "-random" }; + char *booleans_list[] = {"-dim", "-bold", "-reverse", "-normal", + "-boldfont", "-inverse", "-extended", "-eight", "-dither", + "-floyd_steinberg", "-error_distribution"}; + char *nobooleans_list[] = {"-nodim", "-nobold", "-noreverse", "-nonormal", + "-noboldfont", "-noinverse", "-noextended", "-noeight", "-nodither", + "-nofloyd_steinberg", "-noerror_distribution"}; + const int nstrings = sizeof(strings_list) / sizeof(char*); + const int nbooleans = sizeof(booleans_list) / sizeof(int); + const int nextra_opts = sizeof(extra_opts) / sizeof(opt_t); + const int nsubopts = nstrings + nbooleans + nextra_opts; + int i, retval = 0; - ); - exit(0); - - }else{ - /* parse param to aalib */ - pseudoargv[1]=malloc(strlen(opt)); - pseudoargv[3]=NULL; - sprintf(pseudoargv[1], "-%s", opt+2); - if (param!=NULL){ - pseudoargv[2]=param; - pseudoargc=3; - }else{ - pseudoargv[2]=NULL; - pseudoargc=2; - } - fprintf(stderr,"VO: [aa] "); - i=aa_parseoptions(&aa_defparams, &aa_defrenderparams, &pseudoargc, pseudoargv); - if (i!=1){ - return M_OPT_MISSING_PARAM; - } - if (pseudoargv[1]!=NULL){ - /* aalib has given param back */ - fprintf(stderr," Parameter -%s accepted\n", opt); - return 0; /* param could be the filename */ - } - fprintf(stderr," Parameter -%s %s accepted\n", opt, ((param==NULL) ? "" : param) ); - return 1; /* all opt & params accepted */ + subopts = calloc(nsubopts + 1, sizeof(opt_t)); + strings = calloc(nstrings, sizeof(char*)); + booleans = calloc(nbooleans, sizeof(int)); + p = subopts; + for (i=0; iname = strings_list[i] + 1; // skip '-' + p->type = OPT_ARG_MSTRZ; + p->valp = &strings[i]; } - return M_OPT_UNKNOWN; - -} + for (i=0; iname = booleans_list[i] + 1; + p->type = OPT_ARG_BOOL; + p->valp = &booleans[i]; + } + memcpy(p, extra_opts, sizeof(extra_opts)); -void -vo_aa_revertoption(m_option_t* opt,char* param) { - if (!strcasecmp(param, "aaosdcolor")) - aaopt_osdcolor= AA_SPECIAL; - else if (!strcasecmp(param, "aasubcolor")) - aaopt_subcolor= AA_SPECIAL; + retval = subopt_parse(arg, subopts); + + if (retval == 0 && displayhelp) { + helpmsg = strdup(aa_help); + for (i=0; i<(signed)strlen(helpmsg); i++) + if (helpmsg[i] == '-') helpmsg[i] = ' '; + mp_msg(MSGT_VO, MSGL_INFO, MSGTR_VO_AA_HelpHeader); + mp_msg(MSGT_VO, MSGL_INFO, "%s\n\n", helpmsg); + mp_msg(MSGT_VO, MSGL_INFO, MSGTR_VO_AA_AdditionalOptions); + retval = -1; + } + if (retval == 0) { + pseudoargv[3] = NULL; + for (i=0; i