sub: mess with styling defaults, change --ass-use-margins behavior

Now --ass-use-margins doesn't apply to normal subtitles anymore. This is
probably the inverse from the mpv behavior users expected so far, and
thus a breaking change, so rename the option, that the user at least has
a chance to lookup the option and decide whether the new behavior is
wanted or not.

The basic idea here is:
- plain text subtitles should have a certain useful defalt behavior,
  like actually using margins
- ASS subtitles should never be broken by default
- ASS subtitles should look and behave like plaintext subtitles if
  the --ass-style-override=force option is used

This also subtly changes --sub-scale-with-window and adds the --ass-
scale-with-window option. Since this one isn't so important, don't
bother with compatibility.
This commit is contained in:
wm4 2015-02-16 20:04:15 +01:00
parent b63503db04
commit 2308b3a2a6
10 changed files with 70 additions and 27 deletions

View File

@ -1381,8 +1381,11 @@ Property list
``sub-scale`` (RW)
Subtitle font size multiplier.
``ass-use-margins`` (RW)
See ``--ass-use-margins``.
``ass-force-margins`` (RW)
See ``--ass-force-margins``.
``sub-use-margins`` (RW)
See ``--sub-use-margins``.
``ass-vsfilter-aspect-compat`` (RW)
See ``--ass-vsfilter-aspect-compat``.

View File

@ -438,7 +438,8 @@ Program Behavior
Enable the youtube-dl hook-script. It will look at the input URL, and will
play the video located on the website. This works with many streaming sites,
not just the one that the script is named after. This requires a recent
version of youtube-dl to be installed on the system. (Enabled by default.)
version of youtube-dl to be installed on the system. (Enabled by default,
except when the client API / libmpv is used.)
If the script can't do anything with an URL, it will do nothing.
@ -1155,13 +1156,22 @@ Subtitles
doesn't covert the window fully, e.g. because screen aspect and window
aspect mismatch (and the player adds black bars).
Default: yes.
This option is misnamed. The difference to the confusingly similar sounding
option ``--sub-scale-by-window`` is that ``--sub-scale-with-window`` still
scales with the approximate window size, while the other option disables
this scaling.
Affects plain text subtitles only (or ASS if ``--ass-style-override`` is
set high enough).
``--ass-scale-with-window=<yes|no>``
Like ``--sub-scale-with-window``, but affects subtitles in ASS format only.
Like ``--sub-scale``, this can break ASS subtitles.
Default: no.
``--embeddedfonts``, ``--no-embeddedfonts``
Use fonts embedded in Matroska container files and ASS scripts (default:
enabled). These fonts can be used for SSA/ASS subtitle rendering.
@ -1245,9 +1255,21 @@ Subtitles
options. Requires a modified libass, can break rendering easily.
Probably more reliable than ``force``.
``--ass-use-margins``
``--ass-force-margins``
Enables placing toptitles and subtitles in black borders when they are
available.
available, if the subtitles are in the ASS format.
Default: no.
``--sub-use-margins``
Enables placing toptitles and subtitles in black borders when they are
available, if the subtitles are in a plain text format (or ASS if
``--ass-style-override`` is set high enough).
Default: yes.
Renamed from ``--ass-use-margins``. To place ASS subtitles in the borders
too (like the old option did), also add ``--ass-force-margins``.
``--ass-vsfilter-aspect-compat=<yes|no>``
Stretch SSA/ASS subtitles when playing anamorphic videos for compatibility

View File

@ -445,9 +445,9 @@ Available filters are:
``<bottom-margin>``
Adds a black band at the bottom of the frame. The SSA/ASS renderer can
place subtitles there (with ``--ass-use-margins``).
place subtitles there (with ``--sub-use-margins``).
``<top-margin>``
Black band on the top for toptitles (with ``--ass-use-margins``).
Black band on the top for toptitles (with ``--sub-use-margins``).
.. admonition:: Examples

View File

@ -337,7 +337,8 @@ const m_option_t mp_opts[] = {
OPT_FLAG("sub-ass", ass_enabled, 0),
OPT_FLOATRANGE("sub-scale", sub_scale, 0, 0, 100),
OPT_FLOATRANGE("ass-line-spacing", ass_line_spacing, 0, -1000, 1000),
OPT_FLAG("ass-use-margins", ass_use_margins, 0),
OPT_FLAG("sub-use-margins", sub_use_margins, 0),
OPT_FLAG("ass-force-margins", ass_use_margins, 0),
OPT_FLAG("ass-vsfilter-aspect-compat", ass_vsfilter_aspect_compat, 0),
OPT_CHOICE("ass-vsfilter-color-compat", ass_vsfilter_color_compat, 0,
({"no", 0}, {"basic", 1}, {"full", 2}, {"force-601", 3})),
@ -353,6 +354,7 @@ const m_option_t mp_opts[] = {
({"no", 0}, {"yes", 1}, {"force", 3}, {"signfs", 4})),
OPT_FLAG("sub-scale-by-window", sub_scale_by_window, 0),
OPT_FLAG("sub-scale-with-window", sub_scale_with_window, 0),
OPT_FLAG("ass-scale-with-window", ass_scale_with_window, 0),
OPT_FLAG("osd-bar", osd_bar_visible, 0),
OPT_FLOATRANGE("osd-bar-align-x", osd_bar_align_x, 0, -1.0, +1.0),
OPT_FLOATRANGE("osd-bar-align-y", osd_bar_align_y, 0, -1.0, +1.0),
@ -473,8 +475,6 @@ const m_option_t mp_opts[] = {
OPT_FLAG("keepaspect", vo.keepaspect, 0),
OPT_FLAG("keepaspect-window", vo.keepaspect_window, 0),
//---------------------- mplayer-only options ------------------------
OPT_FLAG("use-filedir-conf", use_filedir_conf, 0),
OPT_CHOICE("osd-level", osd_level, 0,
({"0", 0}, {"1", 1}, {"2", 2}, {"3", 3})),
@ -658,6 +658,7 @@ const m_option_t mp_opts[] = {
OPT_REMOVED("fixed-vo", "--fixed-vo=yes is now the default"),
OPT_REPLACED("mkv-subtitle-preroll", "demuxer-mkv-subtitle-preroll"),
OPT_REPLACED("dtshd", "ad-spdif-dtshd"),
OPT_REPLACED("ass-use-margins", "sub-use-margins"),
{0}
};
@ -706,6 +707,10 @@ const struct MPOpts mp_default_opts = {
.osd_scale = 1,
.osd_scale_by_window = 1,
.sub_scale_by_window = 1,
.ass_use_margins = 0,
.sub_use_margins = 1,
.ass_scale_with_window = 0,
.sub_scale_with_window = 1,
.use_text_osd = 1,
#if HAVE_LUA
.lua_load_osc = 1,

View File

@ -241,6 +241,7 @@ typedef struct MPOpts {
int osd_scale_by_window;
int sub_scale_by_window;
int sub_scale_with_window;
int ass_scale_with_window;
struct osd_style_opts *osd_style;
struct osd_style_opts *sub_text_style;
float sub_scale;
@ -249,6 +250,7 @@ typedef struct MPOpts {
int ass_enabled;
float ass_line_spacing;
int ass_use_margins;
int sub_use_margins;
int ass_vsfilter_aspect_compat;
int ass_vsfilter_color_compat;
int ass_vsfilter_blur_compat;

View File

@ -3448,7 +3448,8 @@ static const struct m_property mp_properties[] = {
{"sub-visibility", property_osd_helper},
{"sub-forced-only", property_osd_helper},
{"sub-scale", property_osd_helper},
{"ass-use-margins", property_osd_helper},
{"sub-use-margins", property_osd_helper},
{"ass-force-margins", property_osd_helper},
{"ass-vsfilter-aspect-compat", property_osd_helper},
{"ass-style-override", property_osd_helper},

View File

@ -243,7 +243,8 @@ static const char *const backup_properties[] = {
"options/sub-pos",
"options/sub-visibility",
"options/sub-scale",
"options/ass-use-margins",
"options/sub-use-margins",
"options/ass-force-margins",
"options/ass-vsfilter-aspect-compat",
"options/ass-style-override",
"options/ab-loop-a",

View File

@ -126,34 +126,43 @@ ASS_Track *mp_ass_default_track(ASS_Library *library, struct MPOpts *opts)
return track;
}
void mp_ass_configure(ASS_Renderer *priv, struct MPOpts *opts,
void mp_ass_configure(ASS_Renderer *priv, struct MPOpts *opts, bool is_ass,
struct mp_osd_res *dim)
{
ass_set_frame_size(priv, dim->w, dim->h);
ass_set_margins(priv, dim->mt, dim->mb, dim->ml, dim->mr);
int set_use_margins = 0;
bool set_use_margins = false;
int set_sub_pos = 0;
float set_line_spacing = 0;
float set_font_scale = 1;
int set_hinting = 0;
if (opts->ass_style_override) {
bool set_scale_with_window = false;
bool set_scale_by_window = true;
// With forced overrides, apply the --sub-* specific options
if (!is_ass || opts->ass_style_override == 3) {
set_scale_with_window = opts->sub_scale_with_window;
set_use_margins = opts->sub_use_margins;
set_scale_by_window = opts->sub_scale_by_window;
} else {
set_scale_with_window = opts->ass_scale_with_window;
set_use_margins = opts->ass_use_margins;
}
if (!is_ass || opts->ass_style_override) {
set_sub_pos = 100 - opts->sub_pos;
set_line_spacing = opts->ass_line_spacing;
set_hinting = opts->ass_hinting;
set_font_scale = opts->sub_scale;
if (opts->sub_scale_with_window) {
int vidh = dim->h - (dim->mt + dim->mb);
set_font_scale *= dim->h / (float)MPMAX(vidh, 1);
}
if (!opts->sub_scale_by_window) {
double factor = dim->h / 720.0;
if (factor != 0.0)
set_font_scale /= factor;
}
}
if (set_scale_with_window) {
int vidh = dim->h - (dim->mt + dim->mb);
set_font_scale *= dim->h / (float)MPMAX(vidh, 1);
}
if (!set_scale_by_window) {
double factor = dim->h / 720.0;
if (factor != 0.0)
set_font_scale /= factor;
}
ass_set_use_margins(priv, set_use_margins);
#if LIBASS_VERSION >= 0x01010000
ass_set_line_position(priv, set_sub_pos);

View File

@ -53,7 +53,7 @@ void mp_ass_add_default_styles(ASS_Track *track, struct MPOpts *opts);
ASS_Track *mp_ass_default_track(ASS_Library *library, struct MPOpts *opts);
struct MPOpts;
void mp_ass_configure(ASS_Renderer *priv, struct MPOpts *opts,
void mp_ass_configure(ASS_Renderer *priv, struct MPOpts *opts, bool is_ass,
struct mp_osd_res *dim);
void mp_ass_configure_fonts(ASS_Renderer *priv, struct osd_style_opts *opts,
struct mpv_global *global, struct mp_log *log);

View File

@ -145,7 +145,7 @@ static void get_bitmaps(struct sd *sd, struct mp_osd_res dim, double pts,
if (isnormal(par))
scale = par;
}
mp_ass_configure(renderer, opts, &dim);
mp_ass_configure(renderer, opts, !ctx->is_converted, &dim);
ass_set_aspect_ratio(renderer, scale, 1);
#if LIBASS_VERSION >= 0x01020000
if (!ctx->is_converted && (!opts->ass_style_override ||