From 4587f030ccded80f3ddb21dab2bca36af42fe497 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Cl=C3=A9ment=20B=C5=93sch?= Date: Tue, 8 Feb 2011 00:35:51 +0100 Subject: [PATCH] options: move sub_name, sub_auto and vobsub_name to struct --- cfg-common.h | 5 ++--- cfg-mplayer.h | 2 +- defaultopts.c | 1 + mplayer.c | 19 ++++++++----------- mplayer.h | 2 -- options.h | 3 +++ 6 files changed, 15 insertions(+), 17 deletions(-) diff --git a/cfg-common.h b/cfg-common.h index 6e74eb66cc..b2df2ade0d 100644 --- a/cfg-common.h +++ b/cfg-common.h @@ -628,7 +628,7 @@ const m_option_t common_opts[] = { {"codecs-file", &codecs_file, CONF_TYPE_STRING, 0, 0, 0, NULL}, // ------------------------- subtitles options -------------------- - {"sub", &sub_name, CONF_TYPE_STRING_LIST, 0, 0, 0, NULL}, + OPT_STRINGLIST("sub", sub_name, 0), #ifdef CONFIG_FRIBIDI {"fribidi-charset", &fribidi_charset, CONF_TYPE_STRING, 0, 0, 0, NULL}, {"flip-hebrew", &flip_hebrew, CONF_TYPE_FLAG, 0, 0, 1, NULL}, @@ -647,8 +647,7 @@ const m_option_t common_opts[] = { #endif {"subdelay", &sub_delay, CONF_TYPE_FLOAT, 0, 0.0, 10.0, NULL}, {"subfps", &sub_fps, CONF_TYPE_FLOAT, 0, 0.0, 10.0, NULL}, - {"autosub", &sub_auto, CONF_TYPE_FLAG, 0, 0, 1, NULL}, - {"noautosub", &sub_auto, CONF_TYPE_FLAG, 0, 1, 0, NULL}, + OPT_MAKE_FLAGS("autosub", sub_auto, 0), {"unicode", &sub_unicode, CONF_TYPE_FLAG, 0, 0, 1, NULL}, {"nounicode", &sub_unicode, CONF_TYPE_FLAG, 0, 1, 0, NULL}, {"utf8", &sub_utf8, CONF_TYPE_FLAG, 0, 0, 1, NULL}, diff --git a/cfg-mplayer.h b/cfg-mplayer.h index e2a52ee637..885f4a4609 100644 --- a/cfg-mplayer.h +++ b/cfg-mplayer.h @@ -235,7 +235,7 @@ const m_option_t mplayer_opts[]={ {"menu", "OSD menu support was not compiled in.\n", CONF_TYPE_PRINT,0, 0, 0, NULL}, #endif /* CONFIG_MENU */ - {"vobsub", &vobsub_name, CONF_TYPE_STRING, 0, 0, 0, NULL}, + OPT_STRING("vobsub", vobsub_name, 0), {"vobsubid", &vobsub_id, CONF_TYPE_INT, CONF_RANGE, 0, 31, NULL}, #ifdef CONFIG_UNRAR_EXEC {"unrarexec", &unrar_executable, CONF_TYPE_STRING, 0, 0, 0, NULL}, diff --git a/defaultopts.c b/defaultopts.c index d49841a731..8bb927bb54 100644 --- a/defaultopts.c +++ b/defaultopts.c @@ -46,6 +46,7 @@ void set_default_mplayer_options(struct MPOpts *opts) .movie_aspect = -1., .flip = -1, .vd_use_slices = 1, + .sub_auto = 1, #ifdef CONFIG_ASS .ass_enabled = 1, #endif diff --git a/mplayer.c b/mplayer.c index f0a343140c..645ce35e98 100644 --- a/mplayer.c +++ b/mplayer.c @@ -323,11 +323,8 @@ char *font_name=NULL; char *sub_font_name=NULL; extern int font_fontconfig; float font_factor=0.75; -char **sub_name=NULL; float sub_delay=0; float sub_fps=0; -int sub_auto = 1; -char *vobsub_name=NULL; int subcc_enabled=0; int suboverlap_enabled = 1; @@ -4170,12 +4167,12 @@ if (edl_output_filename) { //==================== Open VOB-Sub ============================ current_module="vobsub"; - if (vobsub_name){ - vo_vobsub=vobsub_open(vobsub_name,spudec_ifo,1,&vo_spudec); + if (opts->vobsub_name){ + vo_vobsub=vobsub_open(opts->vobsub_name,spudec_ifo,1,&vo_spudec); if(vo_vobsub==NULL) mp_tmsg(MSGT_CPLAYER,MSGL_ERR,"Cannot load subtitles: %s\n", - filename_recode(vobsub_name)); - } else if (sub_auto && mpctx->filename){ + filename_recode(opts->vobsub_name)); + } else if (opts->sub_auto && mpctx->filename){ /* try to autodetect vobsub from movie filename ::atmos */ char *buf = strdup(mpctx->filename), *psub; char *pdot = strrchr(buf, '.'); @@ -4566,11 +4563,11 @@ if(vo_spudec==NULL && // check .sub current_module="read_subtitles_file"; double sub_fps = mpctx->sh_video ? mpctx->sh_video->fps : 25; - if(sub_name){ - for (i = 0; sub_name[i] != NULL; ++i) - add_subtitles(mpctx, sub_name[i], sub_fps, 0); + if(opts->sub_name){ + for (i = 0; opts->sub_name[i] != NULL; ++i) + add_subtitles(mpctx, opts->sub_name[i], sub_fps, 0); } - if(sub_auto) { // auto load sub file ... + if(opts->sub_auto) { // auto load sub file ... char *psub = get_path( "sub/" ); char **tmp = sub_filenames((psub ? psub : ""), mpctx->filename); int i = 0; diff --git a/mplayer.h b/mplayer.h index 4f0c927763..267b6501b3 100644 --- a/mplayer.h +++ b/mplayer.h @@ -38,10 +38,8 @@ extern char * sub_font_name; extern float font_factor; extern double force_fps; -//extern char **sub_name; extern float sub_delay; extern float sub_fps; -extern int sub_auto; extern int stream_cache_size; diff --git a/options.h b/options.h index ed3dbdc926..459f64fb49 100644 --- a/options.h +++ b/options.h @@ -31,6 +31,7 @@ typedef struct MPOpts { int osd_level; int osd_duration; + char *vobsub_name; int auto_quality; int benchmark; char *stream_dump_name; @@ -86,6 +87,8 @@ typedef struct MPOpts { float screen_size_xy; int flip; int vd_use_slices; + char **sub_name; + int sub_auto; int ass_enabled; struct lavc_param { int workaround_bugs; -- 2.11.4.GIT