mirror of https://github.com/mpv-player/mpv
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
This commit is contained in:
parent
0c7b6fc212
commit
b0e5f570bb
|
@ -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 <value>
|
||||
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\ \ \
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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."
|
||||
|
|
183
libvo/vo_aa.c
183
libvo/vo_aa.c
|
@ -34,7 +34,8 @@
|
|||
|
||||
#include "osdep/keycodes.h"
|
||||
#include <aalib.h>
|
||||
#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"
|
||||
" <PROJECT><PROJECT>\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; i<nstrings; i++, p++) {
|
||||
p->name = strings_list[i] + 1; // skip '-'
|
||||
p->type = OPT_ARG_MSTRZ;
|
||||
p->valp = &strings[i];
|
||||
}
|
||||
return M_OPT_UNKNOWN;
|
||||
|
||||
}
|
||||
for (i=0; i<nbooleans; i++, p++) {
|
||||
p->name = 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<nstrings; i++) {
|
||||
pseudoargc = 3; // inside loop because aalib changes it
|
||||
if (strings[i] != NULL) {
|
||||
pseudoargv[1] = strings_list[i];
|
||||
pseudoargv[2] = strings[i];
|
||||
aa_parseoptions(&aa_defparams, &aa_defrenderparams,
|
||||
&pseudoargc, pseudoargv) != 1;
|
||||
}
|
||||
}
|
||||
pseudoargv[2] = NULL;
|
||||
for (i=0; i<nbooleans; i++) {
|
||||
pseudoargc = 2;
|
||||
if (booleans[i]) pseudoargv[1] = booleans_list[i];
|
||||
else pseudoargv[1] = nobooleans_list[i];
|
||||
aa_parseoptions(&aa_defparams, &aa_defrenderparams,
|
||||
&pseudoargc, pseudoargv) != 1;
|
||||
}
|
||||
if (osdcolor) aaopt_osdcolor = getcolor(osdcolor);
|
||||
if (subcolor) aaopt_subcolor = getcolor(subcolor);
|
||||
}
|
||||
|
||||
if (subopts) free(subopts);
|
||||
if (booleans) free(booleans);
|
||||
if (strings) {
|
||||
for (i=0; i<nstrings; i++)
|
||||
if (strings[i])
|
||||
free(strings[i]);
|
||||
free(strings);
|
||||
}
|
||||
if (osdcolor) free(osdcolor);
|
||||
if (subcolor) free(subcolor);
|
||||
if (helpmsg) free(helpmsg);
|
||||
return retval;
|
||||
}
|
||||
|
||||
static uint32_t preinit(const char *arg)
|
||||
|
@ -689,7 +690,7 @@ static uint32_t preinit(const char *arg)
|
|||
|
||||
if(arg)
|
||||
{
|
||||
mp_msg(MSGT_VO,MSGL_ERR,"vo_aa: Unknown subdevice: %s\n",arg);
|
||||
if (parse_suboptions(arg) != 0)
|
||||
return ENOSYS;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue