summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-10-11 02:23:29 +0200
committerwm4 <wm4@nowhere>2012-10-12 10:13:42 +0200
commitc9df2c8bd83b31375a79ab2bc4f854a53ff019c1 (patch)
tree033bb4a08d8aa13ab8ccec05ccae4588531637f0
parent2f6713bedeb77a7c058ce4954eb95ee7a2ca7119 (diff)
downloadmpv-c9df2c8bd83b31375a79ab2bc4f854a53ff019c1.tar.bz2
mpv-c9df2c8bd83b31375a79ab2bc4f854a53ff019c1.tar.xz
sub: add --ass-style-override option to disable style overrides
There are a number of options which modify ASS subtitle rendering. Most of these do things that can interfere with the styling done by subtitle scripts, resulting in incorrect rendering. Add the --ass-style-override option to make it easy to disable all overrides. This helps trouble- shooting, and makes it more practical to use the override features. (You can simply toggle the ass-style-override property at runtime, should one of the style override options break subtitle rendering at a certain point.) This mainly affects whether most --ass-* options are applied, as well as --sub-pos. Some things, like explicit style overrides loaded with --ass-force-style, can't be changed at runtime using the ass-style-override property.
-rw-r--r--DOCS/man/en/input.rst1
-rw-r--r--DOCS/man/en/options.rst8
-rw-r--r--cfg-mplayer.h2
-rw-r--r--command.c2
-rw-r--r--defaultopts.c1
-rw-r--r--mplayer.c3
-rw-r--r--options.h1
-rw-r--r--sub/ass_mp.c38
-rw-r--r--sub/sd_ass.c4
9 files changed, 46 insertions, 14 deletions
diff --git a/DOCS/man/en/input.rst b/DOCS/man/en/input.rst
index ab392a5696..9a4e4dcc93 100644
--- a/DOCS/man/en/input.rst
+++ b/DOCS/man/en/input.rst
@@ -296,6 +296,7 @@ sub-forced-only x see ``--sub-forced-only``
sub-scale x subtitle font size multiplicator
ass-use-margins x see ``--ass-use-margins``
ass-vsfilter-aspect-compat x see ``--ass-vsfilter-aspect-compat``
+ass-style-override x see ``--ass-style-override``
tv-brightness
tv-contrast
tv-saturation
diff --git a/DOCS/man/en/options.rst b/DOCS/man/en/options.rst
index 875b9c4b4a..6151e0d21a 100644
--- a/DOCS/man/en/options.rst
+++ b/DOCS/man/en/options.rst
@@ -176,6 +176,14 @@
rendering text subtitles. The syntax of the file is exactly like the ``[V4
Styles]`` / ``[V4+ Styles]`` section of SSA/ASS.
+--ass-style-override=<yes|no>
+ Control whether user style overrides should be applied.
+
+ :yes: Apply all the ``--ass-*`` style override options. Changing the default
+ for any of these options can lead to incorrect subtitle rendering.
+ (Default.)
+ :no: Render subtitles as forced by subtitle scripts.
+
--ass-top-margin=<value>
Adds a black band at the top of the frame. The SSA/ASS renderer can place
toptitles there (with ``--ass-use-margins``).
diff --git a/cfg-mplayer.h b/cfg-mplayer.h
index daf3c5d42e..4bd7daba1c 100644
--- a/cfg-mplayer.h
+++ b/cfg-mplayer.h
@@ -553,6 +553,8 @@ const m_option_t common_opts[] = {
OPT_STRING("ass-border-color", ass_border_color, 0),
OPT_STRING("ass-styles", ass_styles_file, 0),
OPT_INTRANGE("ass-hinting", ass_hinting, 0, 0, 7),
+ OPT_CHOICE("ass-style-override", ass_style_override, 0,
+ ({"no", 0}, {"yes", 1})),
{NULL, NULL, 0, 0, 0, 0, NULL}
};
diff --git a/command.c b/command.c
index eaaa2d241b..94625352af 100644
--- a/command.c
+++ b/command.c
@@ -1477,6 +1477,7 @@ static const m_option_t mp_properties[] = {
#ifdef CONFIG_ASS
M_OPTION_PROPERTY_CUSTOM("ass-use-margins", property_sub_helper),
M_OPTION_PROPERTY_CUSTOM("ass-vsfilter-aspect-compat", property_sub_helper),
+ M_OPTION_PROPERTY_CUSTOM("ass-style-override", property_sub_helper),
#endif
#ifdef CONFIG_TV
@@ -1576,6 +1577,7 @@ static struct property_osd_display {
{ "sub-forced-only", _("Forced sub only") },
{ "sub-scale", _("Sub Scale")},
{ "ass-vsfilter-aspect-compat", _("Subtitle VSFilter aspect compat")},
+ { "ass-style-override", _("ASS subtitle style override")},
#ifdef CONFIG_TV
{ "tv-brightness", _("Brightness"), .osd_progbar = OSD_BRIGHTNESS },
{ "tv-hue", _("Hue"), .osd_progbar = OSD_HUE},
diff --git a/defaultopts.c b/defaultopts.c
index 672dbd5f5c..af470492f1 100644
--- a/defaultopts.c
+++ b/defaultopts.c
@@ -54,6 +54,7 @@ void set_default_mplayer_options(struct MPOpts *opts)
#endif
.ass_font_scale = 1,
.ass_vsfilter_aspect_compat = 1,
+ .ass_style_override = 1,
.use_embedded_fonts = 1,
.lavc_param = {
diff --git a/mplayer.c b/mplayer.c
index 52316a8aa8..90e73bd7c8 100644
--- a/mplayer.c
+++ b/mplayer.c
@@ -3739,7 +3739,8 @@ static void play_current_file(struct MPContext *mpctx)
}
#ifdef CONFIG_ASS
- ass_set_style_overrides(mpctx->ass_library, opts->ass_force_style_list);
+ if (opts->ass_style_override)
+ ass_set_style_overrides(mpctx->ass_library, opts->ass_force_style_list);
#endif
if (mpctx->video_out && mpctx->video_out->config_ok)
vo_control(mpctx->video_out, VOCTRL_RESUME, NULL);
diff --git a/options.h b/options.h
index 5c8f8c0aab..61d18993fb 100644
--- a/options.h
+++ b/options.h
@@ -116,6 +116,7 @@ typedef struct MPOpts {
char *ass_color;
char *ass_border_color;
char *ass_styles_file;
+ int ass_style_override;
int ass_hinting;
struct lavc_param {
int workaround_bugs;
diff --git a/sub/ass_mp.c b/sub/ass_mp.c
index e2729df8ca..908a552acf 100644
--- a/sub/ass_mp.c
+++ b/sub/ass_mp.c
@@ -47,7 +47,7 @@ ASS_Track *mp_ass_default_track(ASS_Library *library, struct MPOpts *opts)
track->PlayResY = 288;
track->WrapStyle = 0;
- if (opts->ass_styles_file)
+ if (opts->ass_styles_file && opts->ass_style_override)
ass_read_styles(track, opts->ass_styles_file, sub_cp);
if (track->n_styles == 0) {
@@ -95,7 +95,9 @@ ASS_Track *mp_ass_default_track(ASS_Library *library, struct MPOpts *opts)
style->ScaleY = 1.;
}
- ass_process_force_style(track);
+ if (opts->ass_style_override)
+ ass_process_force_style(track);
+
return track;
}
@@ -228,20 +230,32 @@ ASS_Track *mp_ass_read_stream(ASS_Library *library, const char *fname,
void mp_ass_configure(ASS_Renderer *priv, struct MPOpts *opts,
struct mp_eosd_res *dim, bool unscaled)
{
- int hinting;
ass_set_frame_size(priv, dim->w, dim->h);
ass_set_margins(priv, dim->mt, dim->mb, dim->ml, dim->mr);
- ass_set_use_margins(priv, opts->ass_use_margins);
+
+ int set_use_margins = 0;
+ int set_sub_pos = 0;
+ float set_line_spacing = 0;
+ float set_font_scale = 1;
+ int set_hinting = 0;
+ if (opts->ass_style_override) {
+ set_use_margins = opts->ass_use_margins;
+ set_sub_pos = 100 - sub_pos;
+ set_line_spacing = opts->ass_line_spacing;
+ set_font_scale = opts->ass_font_scale;
+ if (!unscaled && (opts->ass_hinting & 4))
+ set_hinting = 0;
+ else
+ set_hinting = opts->ass_hinting & 3;
+ }
+
+ ass_set_use_margins(priv, set_use_margins);
#if LIBASS_VERSION >= 0x01010000
- ass_set_line_position(priv, 100 - sub_pos);
+ ass_set_line_position(priv, set_sub_pos);
#endif
- ass_set_font_scale(priv, opts->ass_font_scale);
- if (!unscaled && (opts->ass_hinting & 4))
- hinting = 0;
- else
- hinting = opts->ass_hinting & 3;
- ass_set_hinting(priv, hinting);
- ass_set_line_spacing(priv, opts->ass_line_spacing);
+ ass_set_font_scale(priv, set_font_scale);
+ ass_set_hinting(priv, set_hinting);
+ ass_set_line_spacing(priv, set_line_spacing);
}
void mp_ass_configure_fonts(ASS_Renderer *priv)
diff --git a/sub/sd_ass.c b/sub/sd_ass.c
index 9295cab07d..fcedc9fec5 100644
--- a/sub/sd_ass.c
+++ b/sub/sd_ass.c
@@ -135,7 +135,9 @@ static void get_bitmaps(struct sh_sub *sh, struct osd_state *osd,
return;
double scale = osd->normal_scale;
- if (ctx->vsfilter_aspect && opts->ass_vsfilter_aspect_compat)
+ bool use_vs_aspect = opts->ass_style_override
+ ? opts->ass_vsfilter_aspect_compat : 1;
+ if (ctx->vsfilter_aspect && use_vs_aspect)
scale = osd->vsfilter_scale;
ASS_Renderer *renderer = osd->ass_renderer;
mp_ass_configure(renderer, opts, &osd->dim, osd->unscaled);