summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-06-14 19:17:31 +0200
committerwm4 <wm4@nowhere>2014-06-14 19:17:31 +0200
commit63266d43720dfce15f89c06f200e9a3350642542 (patch)
treef74d26c2c9a07c8dc9bc65de3e3b11a6ca59eda0
parenta9fd52e493a411f10e9a5fa0e0e428ef353842ab (diff)
downloadmpv-63266d43720dfce15f89c06f200e9a3350642542.tar.bz2
mpv-63266d43720dfce15f89c06f200e9a3350642542.tar.xz
sub: add --sub-scale-with-window option
Implements the feature requested in #839 and #186.
-rw-r--r--DOCS/man/en/options.rst8
-rw-r--r--options/options.c1
-rw-r--r--options/options.h1
-rw-r--r--sub/ass_mp.c11
4 files changed, 17 insertions, 4 deletions
diff --git a/DOCS/man/en/options.rst b/DOCS/man/en/options.rst
index e7044c53d8..051158191b 100644
--- a/DOCS/man/en/options.rst
+++ b/DOCS/man/en/options.rst
@@ -2278,6 +2278,14 @@ OPTIONS
This affects ASS subtitles as well, and may lead to incorrect subtitle
rendering. Use with care, or use ``--sub-text-font-size`` instead.
+``--sub-scale-with-window=yes|no``
+ Make the subtitle font size relative to the window, instead of the video.
+ This is useful if you always want the same font size, even if the video
+ doesn't covert the window fully, e.g. because screen aspect and window
+ aspect mismatch (and the player adds black bars).
+
+ Like ``--sub-scale``, this can break ASS subtitles.
+
``--sub-speed=<0.1-10.0>``
Multiply the subtitle event timestamps with the given value. Can be used
to fix the playback speed for frame-based subtitle formats. Works for
diff --git a/options/options.c b/options/options.c
index 4140c10c5a..b03e8738ca 100644
--- a/options/options.c
+++ b/options/options.c
@@ -320,6 +320,7 @@ const m_option_t mp_opts[] = {
({"simple", 0}, {"complex", 1})),
OPT_CHOICE("ass-style-override", ass_style_override, 0,
({"no", 0}, {"yes", 1}, {"force", 3})),
+ OPT_FLAG("sub-scale-with-window", sub_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),
diff --git a/options/options.h b/options/options.h
index 801ea36ac2..f547675bb6 100644
--- a/options/options.h
+++ b/options/options.h
@@ -227,6 +227,7 @@ typedef struct MPOpts {
int ass_style_override;
int ass_hinting;
int ass_shaper;
+ int sub_scale_with_window;
int hwdec_api;
char *hwdec_codecs;
diff --git a/sub/ass_mp.c b/sub/ass_mp.c
index a4a22b61a6..02172605d5 100644
--- a/sub/ass_mp.c
+++ b/sub/ass_mp.c
@@ -27,8 +27,7 @@
#include <ass/ass.h>
#include <ass/ass_types.h>
-#include <libavutil/common.h>
-
+#include "common/common.h"
#include "common/global.h"
#include "common/msg.h"
#include "options/path.h"
@@ -146,9 +145,13 @@ void mp_ass_configure(ASS_Renderer *priv, struct MPOpts *opts,
set_sub_pos = 100 - opts->sub_pos;
#endif
set_line_spacing = opts->ass_line_spacing;
- set_font_scale = opts->sub_scale;
set_hinting = opts->ass_hinting;
set_force_override = opts->ass_style_override == 3;
+ 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);
+ }
}
ass_set_use_margins(priv, set_use_margins);
@@ -205,7 +208,7 @@ void mp_ass_render_frame(ASS_Renderer *renderer, ASS_Track *track, double time,
if (img->w == 0 || img->h == 0)
continue;
if (res->num_parts >= num_parts_alloc) {
- num_parts_alloc = FFMAX(num_parts_alloc * 2, 32);
+ num_parts_alloc = MPMAX(num_parts_alloc * 2, 32);
res->parts = talloc_realloc(NULL, res->parts, struct sub_bitmap,
num_parts_alloc);
}