From 9afcdab6944587aaee7db0307f3087b5a275771d Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Wed, 2 Dec 2009 17:36:59 +0200 Subject: options: Move ass_enabled to options struct --- ass_mp.c | 1 - ass_mp.h | 1 - cfg-common-opts.h | 4 ++-- command.c | 11 ++++++----- libmpdemux/demuxer.c | 2 +- mpcommon.c | 2 +- mplayer.c | 11 ++++++----- options.h | 1 + 8 files changed, 17 insertions(+), 16 deletions(-) diff --git a/ass_mp.c b/ass_mp.c index 89a0c6eaa1..ef2337e043 100644 --- a/ass_mp.c +++ b/ass_mp.c @@ -37,7 +37,6 @@ // libass-related command line options ASS_Library *ass_library; -int ass_enabled = 0; float ass_font_scale = 1.; float ass_line_spacing = 0.; int ass_top_margin = 0; diff --git a/ass_mp.h b/ass_mp.h index 9e4da23ff0..41b120c4da 100644 --- a/ass_mp.h +++ b/ass_mp.h @@ -32,7 +32,6 @@ #include extern ASS_Library *ass_library; -extern int ass_enabled; extern float ass_font_scale; extern float ass_line_spacing; extern int ass_top_margin; diff --git a/cfg-common-opts.h b/cfg-common-opts.h index 285942411e..7927bedf14 100644 --- a/cfg-common-opts.h +++ b/cfg-common-opts.h @@ -320,8 +320,8 @@ {"subfont-autoscale", &subtitle_autoscale, CONF_TYPE_INT, CONF_RANGE, 0, 3, NULL}, #endif #ifdef CONFIG_ASS - {"ass", &ass_enabled, CONF_TYPE_FLAG, 0, 0, 1, NULL}, - {"noass", &ass_enabled, CONF_TYPE_FLAG, 0, 1, 0, NULL}, + OPT_FLAG_ON("ass", ass_enabled, 0), + OPT_FLAG_OFF("noass", ass_enabled, 0), {"ass-font-scale", &ass_font_scale, CONF_TYPE_FLOAT, CONF_RANGE, 0, 100, NULL}, {"ass-line-spacing", &ass_line_spacing, CONF_TYPE_FLOAT, CONF_RANGE, -1000, 1000, NULL}, {"ass-top-margin", &ass_top_margin, CONF_TYPE_INT, CONF_RANGE, 0, 2000, NULL}, diff --git a/command.c b/command.c index 342a49a5b3..3eca97982a 100644 --- a/command.c +++ b/command.c @@ -1524,7 +1524,7 @@ static int mp_property_sub(m_option_t *prop, int action, void *arg, mpctx->set_of_sub_pos = mpctx->global_sub_pos - mpctx->global_sub_indices[SUB_SOURCE_SUBS]; #ifdef CONFIG_ASS - if (ass_enabled && mpctx->set_of_ass_tracks[mpctx->set_of_sub_pos]) + if (opts->ass_enabled && mpctx->set_of_ass_tracks[mpctx->set_of_sub_pos]) ass_track = mpctx->set_of_ass_tracks[mpctx->set_of_sub_pos]; else #endif @@ -1554,7 +1554,7 @@ static int mp_property_sub(m_option_t *prop, int action, void *arg, if (sh->type == 'v') init_vo_spudec(mpctx); #ifdef CONFIG_ASS - else if (ass_enabled) + else if (opts->ass_enabled) ass_track = sh->ass_track; #endif } else { @@ -1862,6 +1862,7 @@ static int mp_property_sub_forced_only(m_option_t *prop, int action, static int mp_property_sub_scale(m_option_t *prop, int action, void *arg, MPContext *mpctx) { + struct MPOpts *opts = &mpctx->opts; switch (action) { case M_PROPERTY_SET: @@ -1869,7 +1870,7 @@ static int mp_property_sub_scale(m_option_t *prop, int action, void *arg, return M_PROPERTY_ERROR; M_PROPERTY_CLAMP(prop, *(float *) arg); #ifdef CONFIG_ASS - if (ass_enabled) { + if (opts->ass_enabled) { ass_font_scale = *(float *) arg; ass_force_reload = 1; } @@ -1880,7 +1881,7 @@ static int mp_property_sub_scale(m_option_t *prop, int action, void *arg, case M_PROPERTY_STEP_UP: case M_PROPERTY_STEP_DOWN: #ifdef CONFIG_ASS - if (ass_enabled) { + if (opts->ass_enabled) { ass_font_scale += (arg ? *(float *) arg : 0.1)* (action == M_PROPERTY_STEP_UP ? 1.0 : -1.0); M_PROPERTY_CLAMP(prop, ass_font_scale); @@ -1894,7 +1895,7 @@ static int mp_property_sub_scale(m_option_t *prop, int action, void *arg, return M_PROPERTY_OK; default: #ifdef CONFIG_ASS - if (ass_enabled) + if (opts->ass_enabled) return m_property_float_ro(prop, action, arg, ass_font_scale); else #endif diff --git a/libmpdemux/demuxer.c b/libmpdemux/demuxer.c index be1cfde73c..564655609f 100644 --- a/libmpdemux/demuxer.c +++ b/libmpdemux/demuxer.c @@ -923,7 +923,7 @@ static demuxer_t *demux_open_stream(struct MPOpts *opts, stream_t *stream, sh_video->i_bps / 1024.0f); } #ifdef CONFIG_ASS - if (ass_enabled && ass_library) { + if (opts->ass_enabled && ass_library) { for (i = 0; i < MAX_S_STREAMS; ++i) { sh_sub_t *sh = demuxer->s_streams[i]; if (sh && sh->type == 'a') { diff --git a/mpcommon.c b/mpcommon.c index c2f3c6cd18..3fb38ece17 100644 --- a/mpcommon.c +++ b/mpcommon.c @@ -183,7 +183,7 @@ void update_subtitles(struct MPContext *mpctx, struct MPOpts *opts, continue; } #ifdef CONFIG_ASS - if (ass_enabled) { + if (opts->ass_enabled) { sh_sub_t* sh = d_dvdsub->sh; ass_track = sh ? sh->ass_track : NULL; if (!ass_track) continue; diff --git a/mplayer.c b/mplayer.c index 68269544ac..671e8c5039 100644 --- a/mplayer.c +++ b/mplayer.c @@ -1041,6 +1041,7 @@ static int playtree_add_playlist(struct MPContext *mpctx, play_tree_t* entry) void add_subtitles(struct MPContext *mpctx, char *filename, float fps, int noerr) { + struct MPOpts *opts = &mpctx->opts; sub_data *subd; #ifdef CONFIG_ASS ASS_Track *asst = 0; @@ -1052,13 +1053,13 @@ void add_subtitles(struct MPContext *mpctx, char *filename, float fps, int noerr subd = sub_read_file(filename, fps); #ifdef CONFIG_ASS - if (ass_enabled) + if (opts->ass_enabled) #ifdef CONFIG_ICONV asst = ass_read_file(ass_library, filename, sub_cp); #else asst = ass_read_file(ass_library, filename, 0); #endif - if (ass_enabled && subd && !asst) + if (opts->ass_enabled && subd && !asst) asst = ass_read_subdata(ass_library, subd, fps); if (!asst && !subd) @@ -2193,7 +2194,7 @@ int reinit_video_chain(struct MPContext *mpctx) #endif #ifdef CONFIG_ASS - if(ass_enabled) { + if(opts->ass_enabled) { int i; int insert = 1; if (opts->vf_settings) @@ -2218,7 +2219,7 @@ int reinit_video_chain(struct MPContext *mpctx) sh_video->vfilter = append_filters(sh_video->vfilter, opts->vf_settings); #ifdef CONFIG_ASS - if (ass_enabled) + if (opts->ass_enabled) sh_video->vfilter->control(sh_video->vfilter, VFCTRL_INIT_EOSD, ass_library); #endif @@ -3634,7 +3635,7 @@ if (mpctx->global_sub_size <= mpctx->global_sub_indices[SUB_SOURCE_DEMUX] + opts mpctx->global_sub_size = mpctx->global_sub_indices[SUB_SOURCE_DEMUX] + opts->sub_id + 1; #ifdef CONFIG_ASS -if (ass_enabled && ass_library) { +if (opts->ass_enabled && ass_library) { for (int j = 0; j < mpctx->num_sources; j++) { struct demuxer *d = mpctx->sources[j].demuxer; for (int i = 0; i < d->num_attachments; i++) { diff --git a/options.h b/options.h index 6ce7818e63..56cd6b6b39 100644 --- a/options.h +++ b/options.h @@ -44,6 +44,7 @@ typedef struct MPOpts { float screen_size_xy; int flip; int vd_use_slices; + int ass_enabled; struct lavc_param { int workaround_bugs; int error_resilience; -- cgit v1.2.3